diff --git a/.gitmodules b/.gitmodules index f2cfc927..2c007844 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "SimVis"] path = SimVis url = https://github.com/ComputationalPhysics/SimVis.git -[submodule "atomify-lammps/QMLPlot"] - path = atomify-lammps/QMLPlot - url = https://github.com/andeplane/QMLPlot.git diff --git a/SimVis b/SimVis index 08c714c1..84fe80d5 160000 --- a/SimVis +++ b/SimVis @@ -1 +1 @@ -Subproject commit 08c714c1f5607ce70b606b3e40128378157697e2 +Subproject commit 84fe80d52f64b1f8da5d054edc696e5129ec3549 diff --git a/atomify-lammps/LammpsWrappers/atoms.cpp b/atomify-lammps/LammpsWrappers/atoms.cpp index 3d87d786..4ef5cfd2 100644 --- a/atomify-lammps/LammpsWrappers/atoms.cpp +++ b/atomify-lammps/LammpsWrappers/atoms.cpp @@ -135,8 +135,9 @@ void Atoms::synchronize(LAMMPSController *lammpsController) void Atoms::updateData(System *system, LAMMPS *lammps) { - AtomData atomData = m_atomData; - if(!atomData.isValid()) { + m_atomDataProcessed = m_atomData; + // AtomData atomData = m_atomData; + if(!m_atomDataProcessed.isValid()) { qDebug() << "Atom data is not valid before modifiers."; exit(1); } @@ -144,23 +145,27 @@ void Atoms::updateData(System *system, LAMMPS *lammps) for(QVariant &modifier_ : m_modifiers) { Modifier *modifier = modifier_.value(); modifier->setSystem(system); - modifier->apply(atomData); - if(!atomData.isValid()) { + modifier->apply(m_atomDataProcessed); + if(!m_atomDataProcessed.isValid()) { // TODO: insert modifier name to debug message qDebug() << "Atom data is not valid after modifier."; exit(1); } } - if(m_sort) { - QElapsedTimer t; - t.start(); - m_atomData.sort(system->cameraPosition()); - qDebug() << "Sorted using " << t.elapsed() << " ms."; - } +// if(m_sort) { +// QElapsedTimer t; +// t.start(); +// m_atomData.sort(system->cameraPosition()); +// qDebug() << "Sorted using " << t.elapsed() << " ms."; +// } +// generateBondData(m_atomDataProcessed, *system); +// generateSphereData(m_atomDataProcessed); +} - generateBondData(atomData, *system); - generateSphereData(atomData); +void Atoms::synchronizeRenderer() { + generateBondData(m_atomDataProcessed); + generateSphereData(m_atomDataProcessed); } //void Atoms::findOcclusion(AtomData &atomData) { @@ -191,7 +196,7 @@ void Atoms::generateSphereData(AtomData &atomData) { m_sphereData->setData(atomData.positions, atomData.colors, atomData.radii); } -void Atoms::generateBondData(AtomData &atomData, System &system) { +void Atoms::generateBondData(AtomData &atomData) { bondsDataRaw.resize(0); if(!m_bonds->enabled()) { m_bondData->setData(bondsDataRaw); diff --git a/atomify-lammps/LammpsWrappers/atoms.h b/atomify-lammps/LammpsWrappers/atoms.h index 0f473958..d5005245 100644 --- a/atomify-lammps/LammpsWrappers/atoms.h +++ b/atomify-lammps/LammpsWrappers/atoms.h @@ -45,6 +45,7 @@ class Atoms : public QObject float bondRadius() const; void reset(); bool sort() const; + void synchronizeRenderer(); public slots: void setBondRadius(float bondRadius); @@ -61,6 +62,7 @@ public slots: private: AtomData m_atomData; + AtomData m_atomDataProcessed; QVector bondsDataRaw; QMap m_atomStyleTypes; QVector m_atomStyles; @@ -69,7 +71,7 @@ public slots: class Bonds* m_bonds = nullptr; QVariantList m_modifiers; float m_bondRadius = 0.1; - void generateBondData(AtomData &atomData, System &system); + void generateBondData(AtomData &atomData); void generateBondDataFromLammpsNeighborlist(AtomData &atomData, LAMMPS_NS::LAMMPS &lammps); void generateSphereData(AtomData &atomData); bool m_sort = false; diff --git a/atomify-lammps/LammpsWrappers/bonds.cpp b/atomify-lammps/LammpsWrappers/bonds.cpp index 798e5f03..40826d51 100644 --- a/atomify-lammps/LammpsWrappers/bonds.cpp +++ b/atomify-lammps/LammpsWrappers/bonds.cpp @@ -46,7 +46,7 @@ void Bonds::reset() } } - m_enabled = true; + m_enabled = false; } void Bonds::setEnabled(bool enabled) diff --git a/atomify-lammps/LammpsWrappers/computes.cpp b/atomify-lammps/LammpsWrappers/computes.cpp index d1958857..855d0ae0 100644 --- a/atomify-lammps/LammpsWrappers/computes.cpp +++ b/atomify-lammps/LammpsWrappers/computes.cpp @@ -78,14 +78,30 @@ void Computes::synchronize(LAMMPSController *lammpsController) removeCompute(compute->identifier()); } - setCount(m_data.size()); - setModel(QVariant::fromValue(m_data)); + for(QObject *obj : m_data) { + CPCompute *compute = qobject_cast(obj); + for(QVariant &variant : compute->data1D()) { + CP1DData *data = variant.value(); + emit data->updated(); + } + } if(!lammpsController->state.canProcessSimulatorControls) return; for(QObject *object : m_data) { CPCompute *compute = qobject_cast(object); compute->copyData(lammpsController); } + + setCount(m_data.size()); + setModel(QVariant::fromValue(m_data)); +} + +void Computes::computeAll(LAMMPSController *lammpsController) +{ + for(QObject *object : m_data) { + CPCompute *compute = qobject_cast(object); + compute->computeInLAMMPS(lammpsController); + } } int Computes::count() const diff --git a/atomify-lammps/LammpsWrappers/computes.h b/atomify-lammps/LammpsWrappers/computes.h index 732a43de..dc71298c 100644 --- a/atomify-lammps/LammpsWrappers/computes.h +++ b/atomify-lammps/LammpsWrappers/computes.h @@ -17,6 +17,7 @@ class Computes : public QObject public: explicit Computes(QObject *parent = 0); void synchronize(class LAMMPSController *lammpsController); + void computeAll(class LAMMPSController *lammpsController); void reset(); int count() const; QVariant model() const; diff --git a/atomify-lammps/LammpsWrappers/simulatorcontrols/cpcompute.cpp b/atomify-lammps/LammpsWrappers/simulatorcontrols/cpcompute.cpp index 43c19225..d05cc09a 100644 --- a/atomify-lammps/LammpsWrappers/simulatorcontrols/cpcompute.cpp +++ b/atomify-lammps/LammpsWrappers/simulatorcontrols/cpcompute.cpp @@ -25,7 +25,7 @@ CP1DData *CPCompute::ensureExists(QString key, bool enabledByDefault) { bool CPCompute::copyData(ComputeTemp *compute, LAMMPSController *lammpsController) { if(!compute) return false; - double value = compute->compute_scalar(); + double value = compute->scalar; setHasScalarData(true); setScalarValue(value); CP1DData *data = ensureExists(QString("Temperature"), true); @@ -38,7 +38,7 @@ bool CPCompute::copyData(ComputeTemp *compute, LAMMPSController *lammpsControlle bool CPCompute::copyData(ComputePE *compute, LAMMPSController *lammpsController) { if(!compute) return false; if(lammpsController->lammps()->update->ntimestep != lammpsController->lammps()->update->eflag_global) return true; - double value = compute->compute_scalar(); + double value = compute->scalar; setHasScalarData(true); setScalarValue(value); CP1DData *data = ensureExists(QString("Potential energy"), true); @@ -50,7 +50,7 @@ bool CPCompute::copyData(ComputePE *compute, LAMMPSController *lammpsController) bool CPCompute::copyData(ComputeKE *compute, LAMMPSController *lammpsController) { if(!compute) return false; - double value = compute->compute_scalar(); + double value = compute->scalar; setHasScalarData(true); setScalarValue(value); CP1DData *data = ensureExists(QString("Kinetic energy"), true); @@ -66,7 +66,7 @@ bool CPCompute::copyData(ComputePressure *compute, LAMMPSController *lammpsContr if(!virialComputed) return true; // First compute scalar pressure - double value = compute->compute_scalar(); + double value = compute->scalar; setHasScalarData(true); setScalarValue(value); CP1DData *data = ensureExists(QString("Pressure"), true); @@ -75,7 +75,7 @@ bool CPCompute::copyData(ComputePressure *compute, LAMMPSController *lammpsContr data->add(lammpsController->system()->simulationTime(), value); // Then compute stress tensor - compute->compute_vector(); + // compute->compute_vector(); // xx, yy, zz, xy, xz, yz QStringList components = {"xx", "yy", "zz", "xy", "xz", "yz"}; @@ -92,7 +92,7 @@ bool CPCompute::copyData(ComputePressure *compute, LAMMPSController *lammpsContr bool CPCompute::copyData(ComputeRDF *compute, LAMMPSController *lammpsController) { Q_UNUSED(lammpsController); if(!compute) return false; - compute->compute_array(); + // compute->compute_array(); int numBins = compute->size_array_rows; // rows in global array int numColumns = compute->size_array_cols; // columns in global array int numPairs = (numColumns - 1)/2; @@ -107,15 +107,18 @@ bool CPCompute::copyData(ComputeRDF *compute, LAMMPSController *lammpsController double rdf = compute->array[bin][1+2*pairId]; data->add(r,rdf,true); } + emit data->updated(); } + + return true; } bool CPCompute::copyData(ComputeMSD *compute, LAMMPSController *lammpsController) { if(!compute) return false; - compute->compute_vector(); + // compute->compute_vector(); // http://www.ascii.cl/htmlcodes.htm QStringList components = {"∆x2", "∆y2", "∆z2", "∆r2"}; @@ -133,7 +136,7 @@ bool CPCompute::copyData(ComputeMSD *compute, LAMMPSController *lammpsController bool CPCompute::copyData(ComputeVACF *compute, LAMMPSController *lammpsController) { if(!compute) return false; - compute->compute_vector(); + // compute->compute_vector(); // < because < is used as a html tag. Using HTML names instead: http://www.ascii.cl/htmlcodes.htm QStringList components = {"<vx, vx0\>", "<vy, vy0>", "<vz, vz0>", "<v, v0>"}; @@ -151,7 +154,7 @@ bool CPCompute::copyData(ComputeVACF *compute, LAMMPSController *lammpsControlle bool CPCompute::copyData(ComputeCOM *compute, LAMMPSController *lammpsController) { if(!compute) return false; - compute->compute_vector(); + // compute->compute_vector(); // < because < is used as a html tag. Using HTML names instead: http://www.ascii.cl/htmlcodes.htm QStringList components = {"x_cm", "y_cm", "z_cm"}; @@ -171,7 +174,7 @@ bool CPCompute::copyData(ComputeGyration *compute, LAMMPSController *lammpsContr if(!compute) return false; // First compute scalar Rg - double value = compute->compute_scalar(); + double value = compute->scalar; setHasScalarData(true); setScalarValue(value); CP1DData *data = ensureExists(QString("Radius of gyration"), true); @@ -179,7 +182,7 @@ bool CPCompute::copyData(ComputeGyration *compute, LAMMPSController *lammpsContr setYLabel("Pressure"); data->add(lammpsController->system()->simulationTime(), value); - compute->compute_vector(); + // compute->compute_vector(); // < because < is used as a html tag. Using HTML names instead: http://www.ascii.cl/htmlcodes.htm QStringList components = {"xx", "yy", "zz", "xy", "xz", "yz"}; @@ -195,22 +198,41 @@ bool CPCompute::copyData(ComputeGyration *compute, LAMMPSController *lammpsContr return true; } -bool CPCompute::copyData(ComputeChunkAtom *compute, LAMMPSController *lammpsController) { - if(!compute) return false; - - enum{BIN1D,BIN2D,BIN3D,BINSPHERE,BINCYLINDER, - TYPE,MOLECULE,COMPUTE,FIX,VARIABLE}; - enum{LOWER,CENTER,UPPER,COORD}; - enum{BOX,LATTICE,REDUCED}; - enum{NODISCARD,MIXED,YESDISCARD}; - enum{ONCE,NFREQ,EVERY}; // used in several files - enum{LIMITMAX,LIMITEXACT}; +void CPCompute::computeInLAMMPS(LAMMPSController *lammpsController) { + Compute *compute = lammpsController->findComputeByIdentifier(identifier()); + if(compute->scalar_flag == 1) { + try { + compute->compute_scalar(); + } catch (LammpsException &exception) { + // TODO: handle this better than just ignoring exception. - if(compute->which == BIN2D) { +// qDebug() << "ERROR: LAMMPS threw an exception!"; +// qDebug() << "ERROR: File:" << QString::fromStdString(exception.file()); +// qDebug() << "ERROR: Message:" << QString::fromStdString(exception.error()); + } + } + if(compute->vector_flag == 1) { + try { + compute->compute_scalar(); + } catch (LammpsException &exception) { + // TODO: handle this better than just ignoring exception. +// qDebug() << "ERROR: LAMMPS threw an exception!"; +// qDebug() << "ERROR: File:" << QString::fromStdString(exception.file()); +// qDebug() << "ERROR: Message:" << QString::fromStdString(exception.error()); + } } - return true; + if(compute->array_flag == 1) { + try { + compute->compute_array(); + } catch (LammpsException &exception) { + // TODO: handle this better than just ignoring exception. +// qDebug() << "ERROR: LAMMPS threw an exception!"; +// qDebug() << "ERROR: File:" << QString::fromStdString(exception.file()); +// qDebug() << "ERROR: Message:" << QString::fromStdString(exception.error()); + } + } } void CPCompute::copyData(LAMMPSController *lammpsController) @@ -220,25 +242,29 @@ void CPCompute::copyData(LAMMPSController *lammpsController) // if(lammpsController->system()->timesteps() % m_frequency != 0) return; Compute *lmp_compute = lammpsController->findComputeByIdentifier(identifier()); if(lmp_compute == nullptr) return; - - if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; - if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; - if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; - if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; - if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; - if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; - if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; - if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; - if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; - if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; - + try { + if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; + if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; + if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; + if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; + if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; + if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; + if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; + if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; + if(copyData(dynamic_cast(lmp_compute), lammpsController)) return; + } catch (LammpsException &exception) { + qDebug() << "ERROR: LAMMPS threw an exception!"; + qDebug() << "ERROR: File:" << QString::fromStdString(exception.file()); + qDebug() << "ERROR: Message:" << QString::fromStdString(exception.error()); + return; + } if(lmp_compute->scalar_flag == 1) { try { double value = lmp_compute->compute_scalar(); setHasScalarData(true); setScalarValue(value); CP1DData *data = ensureExists("scalar", true); - data->add(lammpsController->system()->simulationTime(), value); + data->add(lammpsController->system()->simulationTime(), value, true); } catch (LammpsException &exception) { qDebug() << "ERROR: LAMMPS threw an exception!"; qDebug() << "ERROR: File:" << QString::fromStdString(exception.file()); @@ -253,7 +279,7 @@ void CPCompute::copyData(LAMMPSController *lammpsController) QString key = QString("%1").arg(i); CP1DData *data = ensureExists(key, true); double value = lmp_compute->vector[i-1]; - data->add(lammpsController->system()->simulationTime(), value); + data->add(lammpsController->system()->simulationTime(), value, true); } } catch (LammpsException &exception) { qDebug() << "ERROR: LAMMPS threw an exception!"; @@ -261,9 +287,6 @@ void CPCompute::copyData(LAMMPSController *lammpsController) qDebug() << "ERROR: Message:" << QString::fromStdString(exception.error()); } } - if(lmp_compute->array_flag == 1) { - - } } void CPCompute::updateCommand() diff --git a/atomify-lammps/LammpsWrappers/simulatorcontrols/cpcompute.h b/atomify-lammps/LammpsWrappers/simulatorcontrols/cpcompute.h index f1a5b44e..be735a5e 100644 --- a/atomify-lammps/LammpsWrappers/simulatorcontrols/cpcompute.h +++ b/atomify-lammps/LammpsWrappers/simulatorcontrols/cpcompute.h @@ -35,6 +35,7 @@ class CPCompute : public SimulatorControl ~CPCompute(); void copyData(LAMMPSController *lammpsController); bool existsInLammps(LAMMPSController *lammpsController) override; + void computeInLAMMPS(LAMMPSController *lammpsController); bool isVector() const; QString group() const; int frequency() const; @@ -80,13 +81,12 @@ public slots: bool copyData(ComputeVACF *compute, LAMMPSController *lammpsController); bool copyData(ComputeCOM *compute, LAMMPSController *lammpsController); bool copyData(ComputeGyration *compute, LAMMPSController *lammpsController); - bool copyData(ComputeChunkAtom *compute, LAMMPSController *lammpsController); CP1DData *ensureExists(QString key, bool enabledByDefault); bool m_isVector = false; double m_time = 0; QString m_group = "all"; - int m_frequency = 2; + int m_frequency = 10; bool m_hasScalarData = false; float m_scalarValue = 0.0; int m_num1DData = 0; diff --git a/atomify-lammps/LammpsWrappers/simulatorcontrols/cpfix.cpp b/atomify-lammps/LammpsWrappers/simulatorcontrols/cpfix.cpp index 7841c1e9..cc51d1a6 100644 --- a/atomify-lammps/LammpsWrappers/simulatorcontrols/cpfix.cpp +++ b/atomify-lammps/LammpsWrappers/simulatorcontrols/cpfix.cpp @@ -49,7 +49,6 @@ bool CPFix::copyData(FixAveChunk *fix, LAMMPSController *lammpsController) { float maxValues[fix->nvalues]; for(int i=0; invalues; i++) { - m_dataRaw[i]->setSize(size); m_dataRaw[i]->setXMin(xMin); m_dataRaw[i]->setXMax(xMax); m_dataRaw[i]->setZMin(zMin); @@ -57,6 +56,7 @@ bool CPFix::copyData(FixAveChunk *fix, LAMMPSController *lammpsController) { m_dataRaw[i]->setXLabel(xLabel); m_dataRaw[i]->setYLabel(yLabel); m_dataRaw[i]->setZLabel(zLabel); + m_dataRaw[i]->setSize(size); minValues[i] = 1e9; maxValues[i] = -1e9; } diff --git a/atomify-lammps/LammpsWrappers/simulatorcontrols/cpfix.h b/atomify-lammps/LammpsWrappers/simulatorcontrols/cpfix.h index 44ecd9b1..5b3de46a 100644 --- a/atomify-lammps/LammpsWrappers/simulatorcontrols/cpfix.h +++ b/atomify-lammps/LammpsWrappers/simulatorcontrols/cpfix.h @@ -10,6 +10,7 @@ class CPFix : public SimulatorControl Q_PROPERTY(int frequency READ frequency WRITE setFrequency NOTIFY frequencyChanged) Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged) Q_PROPERTY(QVariantList data READ data WRITE setData NOTIFY dataChanged) + Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) protected: QList enabledCommands() override; QList disableCommands() override; @@ -29,6 +30,11 @@ class CPFix : public SimulatorControl bool interactive() const; QVariantList data() const; + QVariant model() const + { + return m_model; + } + signals: void groupChanged(QString group); void frequencyChanged(int frequency); @@ -36,12 +42,23 @@ class CPFix : public SimulatorControl void dataChanged(QVariantList data); void updatedContent(); + void modelChanged(QVariant model); + public slots: void setGroup(QString group); void setFrequency(int frequency); void setInteractive(bool interactive); void setData(QVariantList data); + void setModel(QVariant model) + { + if (m_model == model) + return; + + m_model = model; + emit modelChanged(model); + } + private: QString m_group = "all"; int m_frequency = 10; @@ -49,6 +66,7 @@ public slots: bool copyData(FixAveChunk *fix, class LAMMPSController *lammpsController); QVariantList m_data; QList m_dataRaw; + QVariant m_model; }; #endif // CPFIX_H diff --git a/atomify-lammps/dataproviders/data2d.cpp b/atomify-lammps/dataproviders/data2d.cpp index abf15388..7d7827d1 100644 --- a/atomify-lammps/dataproviders/data2d.cpp +++ b/atomify-lammps/dataproviders/data2d.cpp @@ -10,6 +10,7 @@ Data2D::Data2D(QObject *parent) : QSurfaceDataProxy(parent) void Data2D::update() { resetArray(m_dataArray); + emit updated(); } float Data2D::xMin() const @@ -69,8 +70,8 @@ void Data2D::setValue(float x, float y, float z) int i = (x - m_xMin) / deltaX; int j = (z - m_zMin) / deltaZ; -// if( i == m_size.width()) i--; -// if( j == m_size.height()) j--; + if( i == m_size.width()) i--; + if( j == m_size.height()) j--; // qDebug() << "Setting value (" << x << ", " << y << ", " << z << ")"; if(i < 0 || i >= m_size.width() || j < 0 || j >= m_size.height()) { @@ -96,10 +97,20 @@ void Data2D::setSize(QSize size) } // Do not recreate array if dimensions have not changed m_dataArray = new QSurfaceDataArray; - m_dataArray->reserve(size.height()); - for (int i = 0; i < size.height(); i++) { - QSurfaceDataRow *newProxyRow = new QSurfaceDataRow(size.width()); + m_dataArray->reserve(size.width()); + + float deltaX = (m_xMax - m_xMin) / m_size.width(); + float deltaZ = (m_zMax - m_zMin) / m_size.height(); + + for (int i = 0; i < size.width(); i++) { + float x = m_xMin + i*deltaX; + QSurfaceDataRow *newProxyRow = new QSurfaceDataRow(size.height()); m_dataArray->append(newProxyRow); + for(int j=0; jsystem()->synchronize(&m_lammpsController); - atomifySimulator->system()->atoms()->updateData(atomifySimulator->system(), m_lammpsController.lammps()); + atomifySimulator->system()->atoms()->synchronizeRenderer(); + // atomifySimulator->system()->atoms()->updateData(atomifySimulator->system(), m_lammpsController.lammps()); if(m_lammpsController.crashed()) return; @@ -154,6 +157,10 @@ void MyWorker::synchronizeSimulator(Simulator *simulator) void MyWorker::work() { m_lammpsController.tick(); + if(m_lammpsController.state.canProcessSimulatorControls) { + m_lammpsController.system()->computes()->computeAll(&m_lammpsController); + m_lammpsController.system()->atoms()->updateData(m_lammpsController.system(), m_lammpsController.lammps()); + } auto dt = m_elapsed.elapsed(); double delta = 16 - dt; if(delta > 0) { diff --git a/atomify-lammps/qml/desktop/DesktopController.qml b/atomify-lammps/qml/desktop/DesktopController.qml index eae4b0b7..b11e43d8 100644 --- a/atomify-lammps/qml/desktop/DesktopController.qml +++ b/atomify-lammps/qml/desktop/DesktopController.qml @@ -17,7 +17,7 @@ Entity { QtObject { id: d - readonly property vector3d firstPersonUp: Qt.vector3d(0, 1, 0) + property vector3d firstPersonUp: Qt.vector3d(0, 1, 0) } function zoomDistance(firstPoint, secondPoint) { @@ -160,6 +160,7 @@ Entity { root.camera.translate(Qt.vector3d(keyboardXAxis.value*speed, 0.0, keyboardYAxis.value*speed)) root.camera.viewCenter = Qt.vector3d(0,0,0) root.camera.roll(rollAxis.value*speed); + d.firstPersonUp = root.camera.upVector if(!leftMouseButtonAction.active && !middleMouseButtonAction.active) { timeSinceLastAction += dt diff --git a/atomify-lammps/qml/desktop/MainDesktop.qml b/atomify-lammps/qml/desktop/MainDesktop.qml index 90c614d8..3fb31143 100644 --- a/atomify-lammps/qml/desktop/MainDesktop.qml +++ b/atomify-lammps/qml/desktop/MainDesktop.qml @@ -72,9 +72,8 @@ Item { periodicImages.numberOfCopiesX: periodicXSlider.value periodicImages.numberOfCopiesY: periodicYSlider.value periodicImages.numberOfCopiesZ: periodicZSlider.value - renderMode: deferredModeSwitch.checked ? "deferred" : "forward" + // renderMode: deferredModeSwitch.checked ? "deferred" : "forward" } - } RightBar { @@ -232,7 +231,7 @@ Item { } Switch { id: deferredModeSwitch - checked: true + checked: false } } } diff --git a/atomify-lammps/qml/desktop/SimulationSummary.qml b/atomify-lammps/qml/desktop/SimulationSummary.qml index 5df8e858..86f6916c 100644 --- a/atomify-lammps/qml/desktop/SimulationSummary.qml +++ b/atomify-lammps/qml/desktop/SimulationSummary.qml @@ -7,14 +7,6 @@ Pane { id: rectangleRoot property System system - onSystemChanged: { - if(system) { - system.groups.onActiveChanged.connect(updateGroups) - system.regions.onActiveChanged.connect(updateRegions) - system.computes.onActiveChanged.connect(updateComputes) - } - } - function getGlobalPosition(p, item) { var globalX = p.x var globalY = p.y @@ -123,6 +115,8 @@ Pane { } Column { + id: groupsColumn + property bool expanded height: groupsRow.height + groupsList.height Row { @@ -133,10 +127,10 @@ Pane { Image { id: collapseGroups y: 3 - source: "qrc:/images/expand.gif" + source: groupsColumn.expanded ? "qrc:/images/collapse.gif" : "qrc:/images/expand.gif" MouseArea { anchors.fill: parent - onClicked: system.groups.active = !system.groups.active + onClicked: groupsColumn.expanded = !groupsColumn.expanded } } Label { @@ -144,7 +138,7 @@ Pane { text: "Groups: "+system.groups.count MouseArea { anchors.fill: parent - onClicked: system.groups.active = !system.groups.active + onClicked: groupsColumn.expanded = !groupsColumn.expanded } } } @@ -155,7 +149,7 @@ Pane { x: groupsLabel.x model: system ? system.groups.model : null height: visible ? count*26 : 0 - visible: false + visible: groupsColumn.expanded delegate: Row { spacing: 5 Image { @@ -192,6 +186,8 @@ Pane { } Column { + id: regionsColumn + property bool expanded height: regionsRow.height + regionsList.height Row { @@ -202,10 +198,10 @@ Pane { Image { id: collapseRegions y: 3 - source: "qrc:/images/expand.gif" + source: regionsColumn.expanded ? "qrc:/images/collapse.gif" : "qrc:/images/expand.gif" MouseArea { anchors.fill: parent - onClicked: system.regions.active = !system.regions.active + onClicked: regionsColumn.expanded = !regionsColumn.expanded } } Label { @@ -213,7 +209,7 @@ Pane { text: "Regions: "+system.regions.count MouseArea { anchors.fill: parent - onClicked: system.regions.active = !system.regions.active + onClicked: regionsColumn.expanded = !regionsColumn.expanded } } } @@ -224,7 +220,7 @@ Pane { x: regionsLabel.x model: system ? system.regions.model : null height: visible ? count*26 : 0 - visible: false + visible: regionsColumn.expanded delegate: Row { spacing: 5 Image { @@ -263,7 +259,9 @@ Pane { } Column { + id: computesColumn height: computesRow.height + computesList.height + property bool expanded: false Row { id: computesRow @@ -273,10 +271,10 @@ Pane { Image { id: collapseComputes y: 3 - source: "qrc:/images/expand.gif" + source: computesColumn.expanded ? "qrc:/images/collapse.gif" : "qrc:/images/expand.gif" MouseArea { anchors.fill: parent - onClicked: system.computes.active = !system.computes.active + onClicked: computesColumn.expanded = !computesColumn.expanded } } Label { @@ -284,7 +282,7 @@ Pane { text: "Computes: "+system.computes.count MouseArea { anchors.fill: parent - onClicked: system.computes.active = !system.computes.active + onClicked: computesColumn.expanded = !computesColumn.expanded } } } @@ -295,7 +293,7 @@ Pane { x: computesLabel.x model: system ? system.computes.model : null height: visible ? count*20 : 0 - visible: false + visible: computesColumn.expanded delegate: Row { visible: computesList.visible Label { diff --git a/atomify-lammps/qml/desktop/editor/CodeEditorWindow.qml b/atomify-lammps/qml/desktop/editor/CodeEditorWindow.qml index 0b12142f..7304fb3f 100644 --- a/atomify-lammps/qml/desktop/editor/CodeEditorWindow.qml +++ b/atomify-lammps/qml/desktop/editor/CodeEditorWindow.qml @@ -184,7 +184,7 @@ Item { } } - StackLayout { + SwipeView { id: stackLayout Layout.fillWidth: true Layout.fillHeight: true diff --git a/atomify-lammps/qml/plotting/ColorMaps.qml b/atomify-lammps/qml/plotting/ColorMaps.qml new file mode 100644 index 00000000..3006d65a --- /dev/null +++ b/atomify-lammps/qml/plotting/ColorMaps.qml @@ -0,0 +1,109 @@ +import QtQuick 2.7 +import QtDataVisualization 1.2 + +Item { + property ColorGradient magma: ColorGradient { + ColorGradientStop { position: 0.0; color: Qt.rgba(0.001462, 0.000466, 0.013866, 1.0) } + ColorGradientStop { position: 0.1015625; color: Qt.rgba(0.083446, 0.056225, 0.220755, 1.0) } + ColorGradientStop { position: 0.203125; color: Qt.rgba(0.238826, 0.059517, 0.443256, 1.0) } + ColorGradientStop { position: 0.30078125; color: Qt.rgba(0.396467, 0.102902, 0.502658, 1.0) } + ColorGradientStop { position: 0.40234375; color: Qt.rgba(0.556571, 0.163269, 0.50523, 1.0) } + ColorGradientStop { position: 0.5; color: Qt.rgba(0.716387, 0.214982, 0.47529, 1.0) } + ColorGradientStop { position: 0.6015625; color: Qt.rgba(0.874176, 0.291859, 0.406205, 1.0) } + ColorGradientStop { position: 0.703125; color: Qt.rgba(0.96968, 0.446936, 0.360311, 1.0) } + ColorGradientStop { position: 0.80078125; color: Qt.rgba(0.995122, 0.631696, 0.431951, 1.0) } + ColorGradientStop { position: 0.90234375; color: Qt.rgba(0.995424, 0.819875, 0.57914, 1.0) } + ColorGradientStop { position: 1.0; color: Qt.rgba(0.987053, 0.991438, 0.749504, 1.0) } + } + property Gradient magma_: Gradient { + GradientStop { position: 0.0; color: Qt.rgba(0.001462, 0.000466, 0.013866, 1.0) } + GradientStop { position: 0.1015625; color: Qt.rgba(0.083446, 0.056225, 0.220755, 1.0) } + GradientStop { position: 0.203125; color: Qt.rgba(0.238826, 0.059517, 0.443256, 1.0) } + GradientStop { position: 0.30078125; color: Qt.rgba(0.396467, 0.102902, 0.502658, 1.0) } + GradientStop { position: 0.40234375; color: Qt.rgba(0.556571, 0.163269, 0.50523, 1.0) } + GradientStop { position: 0.5; color: Qt.rgba(0.716387, 0.214982, 0.47529, 1.0) } + GradientStop { position: 0.6015625; color: Qt.rgba(0.874176, 0.291859, 0.406205, 1.0) } + GradientStop { position: 0.703125; color: Qt.rgba(0.96968, 0.446936, 0.360311, 1.0) } + GradientStop { position: 0.80078125; color: Qt.rgba(0.995122, 0.631696, 0.431951, 1.0) } + GradientStop { position: 0.90234375; color: Qt.rgba(0.995424, 0.819875, 0.57914, 1.0) } + GradientStop { position: 1.0; color: Qt.rgba(0.987053, 0.991438, 0.749504, 1.0) } + } + property ColorGradient inferno: ColorGradient { + ColorGradientStop { position: 0.0; color: Qt.rgba(0.001462, 0.000466, 0.013866, 1.0) } + ColorGradientStop { position: 0.1015625; color: Qt.rgba(0.09299, 0.045583, 0.234358, 1.0) } + ColorGradientStop { position: 0.203125; color: Qt.rgba(0.26481, 0.039647, 0.409345, 1.0) } + ColorGradientStop { position: 0.30078125; color: Qt.rgba(0.422549, 0.092501, 0.432714, 1.0) } + ColorGradientStop { position: 0.40234375; color: Qt.rgba(0.584521, 0.150294, 0.402385, 1.0) } + ColorGradientStop { position: 0.5; color: Qt.rgba(0.735683, 0.215906, 0.330245, 1.0) } + ColorGradientStop { position: 0.6015625; color: Qt.rgba(0.869409, 0.321827, 0.221482, 1.0) } + ColorGradientStop { position: 0.703125; color: Qt.rgba(0.956852, 0.475356, 0.094695, 1.0) } + ColorGradientStop { position: 0.80078125; color: Qt.rgba(0.987819, 0.652773, 0.045581, 1.0) } + ColorGradientStop { position: 0.90234375; color: Qt.rgba(0.962517, 0.851476, 0.285546, 1.0) } + ColorGradientStop { position: 1.0; color: Qt.rgba(0.988362, 0.998364, 0.644924, 1.0) } + } + property Gradient inferno_: Gradient { + GradientStop { position: 0.0; color: Qt.rgba(0.001462, 0.000466, 0.013866, 1.0) } + GradientStop { position: 0.1015625; color: Qt.rgba(0.09299, 0.045583, 0.234358, 1.0) } + GradientStop { position: 0.203125; color: Qt.rgba(0.26481, 0.039647, 0.409345, 1.0) } + GradientStop { position: 0.30078125; color: Qt.rgba(0.422549, 0.092501, 0.432714, 1.0) } + GradientStop { position: 0.40234375; color: Qt.rgba(0.584521, 0.150294, 0.402385, 1.0) } + GradientStop { position: 0.5; color: Qt.rgba(0.735683, 0.215906, 0.330245, 1.0) } + GradientStop { position: 0.6015625; color: Qt.rgba(0.869409, 0.321827, 0.221482, 1.0) } + GradientStop { position: 0.703125; color: Qt.rgba(0.956852, 0.475356, 0.094695, 1.0) } + GradientStop { position: 0.80078125; color: Qt.rgba(0.987819, 0.652773, 0.045581, 1.0) } + GradientStop { position: 0.90234375; color: Qt.rgba(0.962517, 0.851476, 0.285546, 1.0) } + GradientStop { position: 1.0; color: Qt.rgba(0.988362, 0.998364, 0.644924, 1.0) } + } + property ColorGradient viridis: ColorGradient { + ColorGradientStop { position: 0.0; color: Qt.rgba(0.267004, 0.004874, 0.329415, 1.0) } + ColorGradientStop { position: 0.1015625; color: Qt.rgba(0.28229, 0.145912, 0.46151, 1.0) } + ColorGradientStop { position: 0.203125; color: Qt.rgba(0.252194, 0.269783, 0.531579, 1.0) } + ColorGradientStop { position: 0.30078125; color: Qt.rgba(0.204903, 0.375746, 0.553533, 1.0) } + ColorGradientStop { position: 0.40234375; color: Qt.rgba(0.162142, 0.474838, 0.55814, 1.0) } + ColorGradientStop { position: 0.5; color: Qt.rgba(0.127568, 0.566949, 0.550556, 1.0) } + ColorGradientStop { position: 0.6015625; color: Qt.rgba(0.137339, 0.662252, 0.515571, 1.0) } + ColorGradientStop { position: 0.703125; color: Qt.rgba(0.274149, 0.751988, 0.436601, 1.0) } + ColorGradientStop { position: 0.80078125; color: Qt.rgba(0.487026, 0.823929, 0.312321, 1.0) } + ColorGradientStop { position: 0.90234375; color: Qt.rgba(0.751884, 0.874951, 0.143228, 1.0) } + ColorGradientStop { position: 1.0; color: Qt.rgba(0.993248, 0.906157, 0.143936, 1.0) } + } + property Gradient viridis_: Gradient { + GradientStop { position: 0.0; color: Qt.rgba(0.267004, 0.004874, 0.329415, 1.0) } + GradientStop { position: 0.1015625; color: Qt.rgba(0.28229, 0.145912, 0.46151, 1.0) } + GradientStop { position: 0.203125; color: Qt.rgba(0.252194, 0.269783, 0.531579, 1.0) } + GradientStop { position: 0.30078125; color: Qt.rgba(0.204903, 0.375746, 0.553533, 1.0) } + GradientStop { position: 0.40234375; color: Qt.rgba(0.162142, 0.474838, 0.55814, 1.0) } + GradientStop { position: 0.5; color: Qt.rgba(0.127568, 0.566949, 0.550556, 1.0) } + GradientStop { position: 0.6015625; color: Qt.rgba(0.137339, 0.662252, 0.515571, 1.0) } + GradientStop { position: 0.703125; color: Qt.rgba(0.274149, 0.751988, 0.436601, 1.0) } + GradientStop { position: 0.80078125; color: Qt.rgba(0.487026, 0.823929, 0.312321, 1.0) } + GradientStop { position: 0.90234375; color: Qt.rgba(0.751884, 0.874951, 0.143228, 1.0) } + GradientStop { position: 1.0; color: Qt.rgba(0.993248, 0.906157, 0.143936, 1.0) } + } + property ColorGradient plasma: ColorGradient { + ColorGradientStop { position: 0.0; color: Qt.rgba(0.050383, 0.029803, 0.527975, 1.0) } + ColorGradientStop { position: 0.1015625; color: Qt.rgba(0.261183, 0.013308, 0.617911, 1.0) } + ColorGradientStop { position: 0.203125; color: Qt.rgba(0.423689, 0.000646, 0.658956, 1.0) } + ColorGradientStop { position: 0.30078125; color: Qt.rgba(0.568201, 0.055778, 0.639477, 1.0) } + ColorGradientStop { position: 0.40234375; color: Qt.rgba(0.697324, 0.169573, 0.560919, 1.0) } + ColorGradientStop { position: 0.5; color: Qt.rgba(0.798216, 0.280197, 0.469538, 1.0) } + ColorGradientStop { position: 0.6015625; color: Qt.rgba(0.884436, 0.397139, 0.37986, 1.0) } + ColorGradientStop { position: 0.703125; color: Qt.rgba(0.951344, 0.52285, 0.292275, 1.0) } + ColorGradientStop { position: 0.80078125; color: Qt.rgba(0.989128, 0.658043, 0.2081, 1.0) } + ColorGradientStop { position: 0.90234375; color: Qt.rgba(0.987621, 0.815978, 0.144363, 1.0) } + ColorGradientStop { position: 1.0; color: Qt.rgba(0.940015, 0.975158, 0.131326, 1.0) } + } + property Gradient plasma_: Gradient { + GradientStop { position: 0.0; color: Qt.rgba(0.050383, 0.029803, 0.527975, 1.0) } + GradientStop { position: 0.1015625; color: Qt.rgba(0.261183, 0.013308, 0.617911, 1.0) } + GradientStop { position: 0.203125; color: Qt.rgba(0.423689, 0.000646, 0.658956, 1.0) } + GradientStop { position: 0.30078125; color: Qt.rgba(0.568201, 0.055778, 0.639477, 1.0) } + GradientStop { position: 0.40234375; color: Qt.rgba(0.697324, 0.169573, 0.560919, 1.0) } + GradientStop { position: 0.5; color: Qt.rgba(0.798216, 0.280197, 0.469538, 1.0) } + GradientStop { position: 0.6015625; color: Qt.rgba(0.884436, 0.397139, 0.37986, 1.0) } + GradientStop { position: 0.703125; color: Qt.rgba(0.951344, 0.52285, 0.292275, 1.0) } + GradientStop { position: 0.80078125; color: Qt.rgba(0.989128, 0.658043, 0.2081, 1.0) } + GradientStop { position: 0.90234375; color: Qt.rgba(0.987621, 0.815978, 0.144363, 1.0) } + GradientStop { position: 1.0; color: Qt.rgba(0.940015, 0.975158, 0.131326, 1.0) } + } +} diff --git a/atomify-lammps/qml/plotting/Plot2D.qml b/atomify-lammps/qml/plotting/Plot2D.qml index 50c28dfa..98b2b78c 100644 --- a/atomify-lammps/qml/plotting/Plot2D.qml +++ b/atomify-lammps/qml/plotting/Plot2D.qml @@ -1,5 +1,5 @@ import QtQuick 2.7 -import QtQuick.Controls 2.0 +import QtQuick.Controls 1.5 import QtQuick.Layouts 1.0 import QtQuick.Window 2.2 import Atomify 1.0 @@ -9,28 +9,24 @@ import QtDataVisualization 1.2 WindowGL2 { id: root - width: 500 - height: 500 + width: 850 + height: 750 -// property var dataSeries: [] property Fix fix + function updateLimits() { + xAxis.min = fix.data[0].xMin + xAxis.max = fix.data[0].xMax + yAxis.min = fix.data[0].yMin + yAxis.max = fix.data[0].yMax + zAxis.min = fix.data[0].zMin + zAxis.max = fix.data[0].zMax + } + onFixChanged: { surfaceSeries.dataProxy = fix.data[0] -// xAxis.min = fix.data[0].xMin -// xAxis.max = fix.data[0].xMax - -// yAxis.min = fix.data[0].yMin -// yAxis.max = fix.data[0].yMax - -// zAxis.min = fix.data[0].zMin -// zAxis.max = fix.data[0].zMax -// for(var key in fix.data) { -// console.log("Stuff: ", fix.data[key]) - -// // compute.data1D[key].updated.connect(updateGraphs(key)) -// } - //title = "Compute '"+compute.identifier+"'" + fix.data[0].updated.connect(updateLimits) + updateLimits() } Shortcut { @@ -40,106 +36,173 @@ WindowGL2 { } } - Rectangle { - id: surfaceView - anchors.fill: parent - - ColorGradient { - id: surfaceGradient - ColorGradientStop { position: 0.0; color: "black" } - ColorGradientStop { position: 0.2; color: "red" } - ColorGradientStop { position: 0.5; color: "blue" } - ColorGradientStop { position: 0.8; color: "yellow" } - ColorGradientStop { position: 1.0; color: "white" } - } + ColorMaps { + id: colorMaps + } - ValueAxis3D { - id: xAxis - segmentCount: 8 - labelFormat: "%f" - title: "x" - min: 0 - max: 17 - titleVisible: true - titleFixed: false - } + ValueAxis3D { + id: xAxis + segmentCount: 8 + labelFormat: "%f" + title: "x" + min: 0 + max: 17 + titleVisible: true + titleFixed: false + } + + ValueAxis3D { + id: yAxis + segmentCount: 8 + labelFormat: "%f" + title: "y" + min: 0 + max: 10 + titleVisible: true + labelAutoRotation: 0 + titleFixed: false + } + + ValueAxis3D { + id: zAxis + segmentCount: 5 + labelFormat: "%f" + title: "z" + min: 0 + max: 17 + titleVisible: true + titleFixed: false + } + + Theme3D { + id: customTheme + type: Theme3D.ThemeQt + // Don't show specular spotlight as we don't want it to distort the colors + lightStrength: 0.0 + ambientLightStrength: 1.0 + backgroundEnabled: false + colorStyle: Theme3D.ColorStyleRangeGradient + font.pointSize: 30 + gridEnabled: false // TODO: checkbox + gridLineColor: "#AAAAAA" + windowColor: root.color + } - ValueAxis3D { - id: yAxis - segmentCount: 8 - labelFormat: "%f" - title: "Value" - min: 0 - max: 10 - titleVisible: true - labelAutoRotation: 0 - titleFixed: false + Surface3D { + id: surfaceGraph + anchors { + left: parent.left + top: parent.top + bottom: parent.bottom + right: legendMax.left + topMargin: -100 + rightMargin: 50 } - ValueAxis3D { - id: zAxis - segmentCount: 5 - labelFormat: "%f" - title: "z" - min: 0 - max: 17 - titleVisible: true - titleFixed: false + shadowQuality: AbstractGraph3D.ShadowQualityNone + axisX: xAxis + axisY: yAxis + axisZ: zAxis + + theme: customTheme + // theme: Theme3D.ThemeDigia + inputHandler: TouchInputHandler3D { + id: customInputHandler + rotationEnabled: true + zoomEnabled: false + } + orthoProjection: true + scene.activeCamera.cameraPreset: Camera3D.CameraPresetDirectlyAbove + flipHorizontalGrid: true + radialLabelOffset: 0.01 + // selectionMode: AbstractGraph3D.SelectionSlice | AbstractGraph3D.SelectionItemAndRow + selectionMode: AbstractGraph3D.SelectionItem + horizontalAspectRatio: 1 + scene.activeCamera.zoomLevel: 100 + + Surface3DSeries { + id: surfaceSeries + flatShadingEnabled: true + drawMode: Surface3DSeries.DrawSurface + baseGradient: colorMaps.inferno + colorStyle: Theme3D.ColorStyleRangeGradient + itemLabelFormat: "(@xLabel, @zLabel): @yLabel" } + } - Theme3D { - id: customTheme - type: Theme3D.ThemeQt - // Don't show specular spotlight as we don't want it to distort the colors - lightStrength: 0.0 - ambientLightStrength: 1.0 - backgroundEnabled: false - gridLineColor: "#AAAAAA" - windowColor: "#EEEEEE" + Rectangle { + id: legend + anchors.margins: 20 + anchors.bottom: parent.bottom + anchors.top: parent.top + anchors.right: parent.right + border.color: "black" + border.width: 1 + width: 50 + rotation: 180 + gradient: colorMaps.inferno_ + } + + Label { + id: legendMax + anchors.verticalCenter: legend.top + anchors.right: legend.left + anchors.margins: 10 + width: 30 + horizontalAlignment: Qt.AlignRight + color: "black" + text: surfaceGraph.axisY.max.toFixed(2) + } + + Label { + anchors.verticalCenter: legend.verticalCenter + anchors.right: legend.left + anchors.margins: 10 + width: legendMax.width + horizontalAlignment: Qt.AlignRight + color: "black" + text: ((surfaceGraph.axisY.max + surfaceGraph.axisY.min) / 2).toFixed(2) + } + + Label { + anchors.verticalCenter: legend.bottom + anchors.right: legend.left + anchors.margins: 10 + width: legendMax.width + horizontalAlignment: Qt.AlignRight + color: "black" + text: surfaceGraph.axisY.min.toFixed(2) + } + + Row { + spacing: 3 + Label { + y: 5 + text: "Colormap: " } - Surface3D { - //! [7] - id: surfaceGraph - width: Math.min(parent.width, parent.height) - height: Math.min(parent.width, parent.height) - onWidthChanged: { - console.log("Width: ", width) - } - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - - // shadowQuality: AbstractGraph3D.ShadowQualityHigh - // selectionMode: AbstractGraph3D.SelectionSlice | AbstractGraph3D.SelectionItemAndColumn - axisX: xAxis - axisY: yAxis - axisZ: zAxis - - theme: customTheme - inputHandler: TouchInputHandler3D { - id: customInputHandler -// rotationEnabled: false -// zoomEnabled: false - } - orthoProjection: true - scene.activeCamera.cameraPreset: Camera3D.CameraPresetDirectlyAbove - Component.onCompleted: { - scene.activeCamera.zoomLevel = 110 - } - flipHorizontalGrid: true - radialLabelOffset: 0.01 - - horizontalAspectRatio: 1 - scene.activeCamera.zoomLevel: 85 - - Surface3DSeries { - id: surfaceSeries - flatShadingEnabled: false - drawMode: Surface3DSeries.DrawSurface - baseGradient: surfaceGradient - colorStyle: Theme3D.ColorStyleRangeGradient - // itemLabelFormat: "(@xLabel, @zLabel): @yLabel" + ComboBox { + model: ["Viridis", "Magma", "Inferno", "Plasma" ] + currentIndex: 0 + onCurrentTextChanged: { + if(currentText==="Magma") { + legend.gradient = colorMaps.magma_ + surfaceSeries.baseGradient = colorMaps.magma + } else if(currentText==="Inferni") { + legend.gradient = colorMaps.inferno_ + surfaceSeries.baseGradient = colorMaps.inferno + } else if(currentText==="Viridis") { + legend.gradient = colorMaps.viridis_ + surfaceSeries.baseGradient = colorMaps.viridis + } else if(currentText==="Plasma") { + legend.gradient = colorMaps.plasma_ + surfaceSeries.baseGradient = colorMaps.plasma + } } } } } + + + + diff --git a/atomify-lammps/qml/qml.qrc b/atomify-lammps/qml/qml.qrc index 5166db1b..4dfccf12 100644 --- a/atomify-lammps/qml/qml.qrc +++ b/atomify-lammps/qml/qml.qrc @@ -59,5 +59,6 @@ desktop/RightBar.qml desktop/Examples.qml plotting/Plot2D.qml + plotting/ColorMaps.qml diff --git a/atomify-lammps/qml/visualization/AtomifyVisualizer.qml b/atomify-lammps/qml/visualization/AtomifyVisualizer.qml index 5877d8f2..a90eb84a 100644 --- a/atomify-lammps/qml/visualization/AtomifyVisualizer.qml +++ b/atomify-lammps/qml/visualization/AtomifyVisualizer.qml @@ -30,24 +30,24 @@ Scene3D { property alias sphereScale: colorModifier.scale property real bondRadius: 0.1 property alias periodicImages: periodicImages - property string renderMode: "forward" - property string renderQuality: "low" + property string renderMode: "deferred" + property string renderQuality: "high" multisample: true onRenderQualityChanged: { if(renderQuality === "low") { - // forwardFrameGraph.window.width = forwardFrameGraph.window.width - 1 root.renderMode = "forward" - // forwardFrameGraph.window.width = forwardFrameGraph.window.width + 1 + spheres.fragmentColor = spheres.fragmentBuilder.normalDotCamera + bonds.fragmentColor = bonds.fragmentBuilder.normalDotCamera + forwardFrameGraph.window.width = forwardFrameGraph.window.width-1 } else if(renderQuality === "medium") { - // deferredFrameGraph.window.width = deferredFrameGraph.window.width - 1 - root.renderMode = "deferred" - ambientOcclusion.samples = 12 - // deferredFrameGraph.window.width = deferredFrameGraph.window.width + 1 + root.renderMode = "forward" + spheres.fragmentColor = spheresMediumQuality + bonds.fragmentColor = bondsMediumQuality + forwardFrameGraph.window.width = forwardFrameGraph.window.width-1 } else if(renderQuality === "high") { - // deferredFrameGraph.window.width = deferredFrameGraph.window.width - 1 root.renderMode = "deferred" - ambientOcclusion.samples = 40 - // deferredFrameGraph.window.width = deferredFrameGraph.window.width + 1 + ambientOcclusion.samples = 32 + deferredFrameGraph.window.width = deferredFrameGraph.window.width-1 } } @@ -67,8 +67,8 @@ Scene3D { // projectionType: CameraLens.OrthographicProjection fieldOfView: 50 aspectRatio: root.width / root.height - nearPlane : 3.0 - farPlane : 300.0 + nearPlane : root.renderMode === "forward" ? 1.0 : 3.0 + farPlane : root.renderMode === "forward" ? 10000.0 : 300.0 position: Qt.vector3d(7.0, 7.0, 50.0) upVector: Qt.vector3d(0.0, 1.0, 0.0) viewCenter: Qt.vector3d(7.0, 7.0, 7.0) @@ -378,52 +378,52 @@ void main() } " } - } - } + } + } ] - } - } - - components: [ - blurMaterial, - quadMesh, - quadTransform - ] - } + } + } - Entity { - id : finalQuadEntity + components: [ + blurMaterial, + quadMesh, + quadTransform + ] + } - Material { - id: finalMaterial - parameters : [ - Parameter { name: "blurTexture"; value : deferredFrameGraph.blurTexture }, - Parameter { name: "ssaoTexture"; value : deferredFrameGraph.ssaoTexture }, - Parameter { name: "normalTexture"; value : deferredFrameGraph.normalTexture }, - Parameter { name: "positionTexture"; value : deferredFrameGraph.positionTexture }, - Parameter { name: "colorTexture"; value : deferredFrameGraph.colorTexture }, - Parameter { name: "depthTexture"; value : deferredFrameGraph.depthTexture }, - Parameter { name: "winSize"; value : Qt.size(root.width, root.height) }, - Parameter { name: "posMin"; value: spheres.posMin }, - Parameter { name: "posMax"; value: spheres.posMax } - ] - effect: Effect { - techniques : [ - Technique { - filterKeys: FilterKey { - name: "renderingStyle" - value: "deferred" - } - graphicsApiFilter { - api: GraphicsApiFilter.OpenGL - profile: GraphicsApiFilter.CoreProfile - majorVersion: 3 - minorVersion: 2 - } - renderPasses : RenderPass { - filterKeys : FilterKey { name : "pass"; value : "final" } - shaderProgram : ShaderProgram { - vertexShaderCode: " + Entity { + id : finalQuadEntity + + Material { + id: finalMaterial + parameters : [ + Parameter { name: "blurTexture"; value : deferredFrameGraph.blurTexture }, + Parameter { name: "ssaoTexture"; value : deferredFrameGraph.ssaoTexture }, + Parameter { name: "normalTexture"; value : deferredFrameGraph.normalTexture }, + Parameter { name: "positionTexture"; value : deferredFrameGraph.positionTexture }, + Parameter { name: "colorTexture"; value : deferredFrameGraph.colorTexture }, + Parameter { name: "depthTexture"; value : deferredFrameGraph.depthTexture }, + Parameter { name: "winSize"; value : Qt.size(root.width, root.height) }, + Parameter { name: "posMin"; value: spheres.posMin }, + Parameter { name: "posMax"; value: spheres.posMax } + ] + effect: Effect { + techniques : [ + Technique { + filterKeys: FilterKey { + name: "renderingStyle" + value: "deferred" + } + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.CoreProfile + majorVersion: 3 + minorVersion: 2 + } + renderPasses : RenderPass { + filterKeys : FilterKey { name : "pass"; value : "final" } + shaderProgram : ShaderProgram { + vertexShaderCode: " #version 410 uniform highp mat4 modelMatrix; @@ -441,124 +441,124 @@ void main() } " - fragmentShaderCode: finalShaderBuilder.finalShader - // onFragmentShaderCodeChanged: console.log(fragmentShaderCode) - } - } - } - ] - } - - ShaderBuilder { - id: finalShaderBuilder - function selectOutput(outputName) { - if(outputName === "blurMultiply" || outputName === "Normal") { - output.value = blurMultiply - } - if(outputName === "ssaoMultiply") { - output.value = ssaoMultiply - } - if(outputName === "blur" || outputName === "Blurred SEM") { - output.value = blurNode - } - - if(outputName === "ssao" || outputName === "SEM") { - output.value = ssaoNode - } - if(outputName === "position") { - output.value = position - } - if(outputName === "color") { - output.value = color - } - if(outputName === "normal") { - output.value = normal - } - } - - property ShaderNode position: ShaderNode { - type: "vec3" - name: "position" - result: "position" - } - property ShaderNode normal: ShaderNode { - type: "vec3" - name: "normal" - result: "normal" - } - property ShaderNode ssao: ShaderNode { - type: "vec3" - name: "ssao" - result: "ssao" - } - property ShaderNode blur: ShaderNode { - type: "vec3" - name: "blur" - result: "blur" - } - property ShaderNode color: ShaderNode { - type: "vec4" - name: "color" - result: "color" - } - - material: finalMaterial - - outputs: [ - ShaderOutput { - id: output - name: "fragColor" - type: "vec4" - value: blurMultiply - // value: finalShaderBuilder - } - ] - - Multiply { - id: ssaoMultiply - value1: ssaoNode - value2: standardMaterial - } - Multiply { - id: blurMultiply - value1: blurNode - value2: standardMaterial - } - ShaderNode { - id: blurNode - property var blur: finalShaderBuilder.blur - name: "ambientOcclusion" - type: "vec3" - result: "$(blur, vec3)" - } - ShaderNode { - id: ssaoNode - property var ssao: finalShaderBuilder.ssao - name: "ambientOcclusion" - type: "vec3" - result: "$(ssao, vec3)" - } - StandardMaterial { - id: standardMaterial - color: finalShaderBuilder.color - lights: [ - Light { - position: light1.position - strength: light1.strength - attenuation: light1.attenuation - }, - Light { - position: light2.position - strength: light2.strength - attenuation: light2.attenuation - } - ] - } - - source: " + fragmentShaderCode: finalShaderBuilder.finalShader + // onFragmentShaderCodeChanged: console.log(fragmentShaderCode) + } + } + } + ] + } + + ShaderBuilder { + id: finalShaderBuilder + function selectOutput(outputName) { + if(outputName === "blurMultiply" || outputName === "Normal") { + output.value = blurMultiply + } + if(outputName === "ssaoMultiply") { + output.value = ssaoMultiply + } + if(outputName === "blur" || outputName === "Blurred SEM") { + output.value = blurNode + } + + if(outputName === "ssao" || outputName === "SEM") { + output.value = ssaoNode + } + if(outputName === "position") { + output.value = position + } + if(outputName === "color") { + output.value = color + } + if(outputName === "normal") { + output.value = normal + } + } + + property ShaderNode position: ShaderNode { + type: "vec3" + name: "position" + result: "position" + } + property ShaderNode normal: ShaderNode { + type: "vec3" + name: "normal" + result: "normal" + } + property ShaderNode ssao: ShaderNode { + type: "vec3" + name: "ssao" + result: "ssao" + } + property ShaderNode blur: ShaderNode { + type: "vec3" + name: "blur" + result: "blur" + } + property ShaderNode color: ShaderNode { + type: "vec4" + name: "color" + result: "color" + } + + material: finalMaterial + + outputs: [ + ShaderOutput { + id: output + name: "fragColor" + type: "vec4" + value: blurMultiply + // value: finalShaderBuilder + } + ] + + Multiply { + id: ssaoMultiply + value1: ssaoNode + value2: standardMaterial + } + Multiply { + id: blurMultiply + value1: blurNode + value2: standardMaterial + } + ShaderNode { + id: blurNode + property var blur: finalShaderBuilder.blur + name: "ambientOcclusion" + type: "vec3" + result: "$(blur, vec3)" + } + ShaderNode { + id: ssaoNode + property var ssao: finalShaderBuilder.ssao + name: "ambientOcclusion" + type: "vec3" + result: "$(ssao, vec3)" + } + StandardMaterial { + id: standardMaterial + color: finalShaderBuilder.color + lights: [ + Light { + position: light1.position + strength: light1.strength + attenuation: light1.attenuation + }, + Light { + position: light2.position + strength: light2.strength + attenuation: light2.attenuation + } + ] + } + + source: " #version 410 " - +(Qt.platform.os=="osx" ? "#define MACOSX" : "")+" + +(Qt.platform.os=="osx" ? "#define MACOSX" : "")+" uniform highp sampler2D blurTexture; uniform highp sampler2D ssaoTexture; @@ -617,108 +617,115 @@ void main() } " - } - } + } + } + + components: [ + // finalLayer, + quadMesh, + quadTransform, + finalMaterial + ] + } - components: [ - // finalLayer, - quadMesh, - quadTransform, - finalMaterial - ] - } + AtomifySimulator { + id: simulator + simulationSpeed: 1 + system.atoms.modifiers: [ + colorModifier, + groupModifier, + regionModifier, + periodicImages + ] + } - AtomifySimulator { - id: simulator - simulationSpeed: 1 - system.atoms.modifiers: [ - colorModifier, - groupModifier, - regionModifier, - periodicImages - ] - } + DesktopController { + id: navigationController + camera: visualizer.camera + onPressed: { + root.focus = true + } + } - DesktopController { - id: navigationController - camera: visualizer.camera - onPressed: { - root.focus = true - } - } + ColorModifier { + id: colorModifier + scale: 0.2 + } - ColorModifier { - id: colorModifier - scale: 0.2 - } + GroupModifier { + id: groupModifier + } - GroupModifier { - id: groupModifier - } + RegionModifier { + id: regionModifier + } - RegionModifier { - id: regionModifier - } + PeriodicImages { + id: periodicImages + numberOfCopiesX: 1 + numberOfCopiesY: 1 + numberOfCopiesZ: 1 + } - PeriodicImages { - id: periodicImages - numberOfCopiesX: 1 - numberOfCopiesY: 1 - numberOfCopiesZ: 1 - } + StandardMaterial { + id: spheresMediumQuality + color: spheres.fragmentBuilder.color + lights: [ + Light { + id: light1 + position: visualizer.camera.position.plus( + (visualizer.camera.viewVector.normalized().plus( + visualizer.camera.upVector.normalized()).plus( + visualizer.camera.viewVector.crossProduct(visualizer.camera.upVector)).normalized()).times(20)) + strength: 0.5 + attenuation: 0.0 + }, + Light { + id: light2 + position: visualizer.camera.position.minus( + (visualizer.camera.viewVector.normalized().plus( + visualizer.camera.upVector.normalized()).plus( + visualizer.camera.viewVector.crossProduct(visualizer.camera.upVector)).normalized()).times(10)) + strength: 0.5 + attenuation: 0.0 + } + ] + } - Spheres { - id: spheres - camera: visualizer.camera - sphereData: simulator.system.atoms.sphereData - // TODO: Is posMin/posMax +-100 ok? We don't need system size anymore since all positions are relative to camera - posMin: -100 - posMax: 100 - fragmentColor: StandardMaterial { - color: spheres.fragmentBuilder.color - lights: [ - Light { - id: light1 - position: visualizer.camera.position.plus( - (visualizer.camera.viewVector.normalized().plus( - visualizer.camera.upVector.normalized()).plus( - visualizer.camera.viewVector.crossProduct(visualizer.camera.upVector)).normalized()).times(20)) - strength: 0.4 - attenuation: 0.0 - }, - Light { - id: light2 - position: visualizer.camera.position.minus( - (visualizer.camera.viewVector.normalized().plus( - visualizer.camera.upVector.normalized()).plus( - visualizer.camera.viewVector.crossProduct(visualizer.camera.upVector)).normalized()).times(10)) - strength: 0.4 - attenuation: 0.0 - } - ] - } - } + StandardMaterial { + id: bondsMediumQuality + color: "white" + lights: [ + Light { + position: light1.position + strength: light1.strength + attenuation: light1.attenuation + }, + Light { + position: light2.position + strength: light2.strength + attenuation: light2.attenuation + } + ] + } - Bonds { - id: bonds - bondData: simulator.system.atoms.bondData - posMin: spheres.posMin - posMax: spheres.posMax - fragmentColor: StandardMaterial { - color: spheres.fragmentBuilder.color - lights: [ - Light { - position: light1.position - strength: light1.strength - attenuation: light1.attenuation - }, - Light { - position: light2.position - strength: light2.strength - attenuation: light2.attenuation - } - ] - } - } - } -} + Spheres { + id: spheres + camera: visualizer.camera + sphereData: simulator.system.atoms.sphereData + // TODO: Is posMin/posMax +-100 ok? We don't need system size anymore since all positions are relative to camera + posMin: -100 + posMax: 100 + fragmentColor: spheresMediumQuality + } + + Bonds { + id: bonds + color: "white" + bondData: simulator.system.atoms.bondData + posMin: spheres.posMin + posMax: spheres.posMax + fragmentColor: bondsMediumQuality + } + } + }