diff --git a/avogadro/qtplugins/meshes/meshes.cpp b/avogadro/qtplugins/meshes/meshes.cpp index 6348df675b..5353a34ff9 100644 --- a/avogadro/qtplugins/meshes/meshes.cpp +++ b/avogadro/qtplugins/meshes/meshes.cpp @@ -15,8 +15,8 @@ #include #include -#include #include +#include #include #include @@ -36,17 +36,15 @@ Meshes::Meshes(QObject* p) : ScenePlugin(p), m_setupWidget(nullptr) // out of 255 m_opacity = settings.value("meshes/opacity", 150).toUInt(); - auto color = - settings.value("meshes/color1", QColor(Qt::red)).value(); + auto color = settings.value("meshes/color1", QColor(Qt::red)).value(); m_color1[0] = static_cast(color.red()); m_color1[1] = static_cast(color.green()); m_color1[2] = static_cast(color.blue()); - color = - settings.value("meshes/color2", QColor(Qt::blue)).value(); + color = settings.value("meshes/color2", QColor(Qt::blue)).value(); m_color2[0] = static_cast(color.red()); m_color2[1] = static_cast(color.green()); - m_color2[2] = static_cast(color.blue()); + m_color2[2] = static_cast(color.blue()); } Meshes::~Meshes() {} @@ -67,7 +65,7 @@ void Meshes::process(const QtGui::Molecule& mol, GroupNode& node) if (mol.meshCount()) { auto* geometry = new GeometryNode; node.addChild(geometry); - + const Mesh* mesh = mol.mesh(0); /// @todo Allow use of MeshGeometry without an index array when all vertices @@ -84,20 +82,19 @@ void Meshes::process(const QtGui::Molecule& mol, GroupNode& node) mesh1->setOpacity(m_opacity); if (hasColors) { - auto colors = mesh->colors(); - Core::Array colorsRGB(colors.size()); - for (size_t i = 0; i < colors.size(); i++) - colorsRGB[i] = Vector3ub( - colors[i].red() * 255, colors[i].green() * 255, colors[i].blue() * 255 - ); - mesh1->addVertices(mesh->vertices(), mesh->normals(), colorsRGB); + auto colors = mesh->colors(); + Core::Array colorsRGB(colors.size()); + for (size_t i = 0; i < colors.size(); i++) + colorsRGB[i] = Vector3ub(colors[i].red() * 255, colors[i].green() * 255, + colors[i].blue() * 255); + mesh1->addVertices(mesh->vertices(), mesh->normals(), colorsRGB); } else { // probably a molecular orbital mesh1->setColor(m_color1); mesh1->addVertices(mesh->vertices(), mesh->normals()); } mesh1->addTriangles(indices); mesh1->setRenderPass(m_opacity == 255 ? Rendering::SolidPass - : Rendering::TranslucentPass); + : Rendering::TranslucentPass); if (mol.meshCount() >= 2) { // it's a molecular orbital, two parts auto* mesh2 = new MeshGeometry; @@ -115,7 +112,7 @@ void Meshes::process(const QtGui::Molecule& mol, GroupNode& node) mesh2->addVertices(mesh->vertices(), mesh->normals()); mesh2->addTriangles(indices); mesh2->setRenderPass(m_opacity == 255 ? Rendering::SolidPass - : Rendering::TranslucentPass); + : Rendering::TranslucentPass); } } } @@ -189,4 +186,4 @@ QWidget* Meshes::setupWidget() return m_setupWidget; } -} // namespace Avogadro +} // namespace Avogadro::QtPlugins diff --git a/avogadro/qtplugins/propertytables/propertyview.h b/avogadro/qtplugins/propertytables/propertyview.h index 41ef815884..280fd85b66 100644 --- a/avogadro/qtplugins/propertytables/propertyview.h +++ b/avogadro/qtplugins/propertytables/propertyview.h @@ -24,15 +24,15 @@ class PropertyView : public QTableView explicit PropertyView(PropertyType type, QWidget* parent = 0); void selectionChanged(const QItemSelection& selected, - const QItemSelection& previous); + const QItemSelection& previous) override; void setMolecule(QtGui::Molecule* molecule); void setSourceModel(PropertyModel* model) { m_model = model; } - void hideEvent(QHideEvent* event); + void hideEvent(QHideEvent* event) override; void contextMenuEvent(QContextMenuEvent* event) override; protected: // copy the selected properties to the clipboard - void keyPressEvent(QKeyEvent* event); + void keyPressEvent(QKeyEvent* event) override; private: PropertyType m_type; diff --git a/avogadro/qtplugins/spacegroup/spacegroup.h b/avogadro/qtplugins/spacegroup/spacegroup.h index 4c3d6a776c..2e089291e7 100644 --- a/avogadro/qtplugins/spacegroup/spacegroup.h +++ b/avogadro/qtplugins/spacegroup/spacegroup.h @@ -21,10 +21,10 @@ class SpaceGroup : public Avogadro::QtGui::ExtensionPlugin explicit SpaceGroup(QObject* parent_ = nullptr); ~SpaceGroup(); - QString name() const { return tr("SpaceGroup"); } - QString description() const; - QList actions() const; - QStringList menuPath(QAction*) const; + QString name() const override { return tr("SpaceGroup"); } + QString description() const override; + QList actions() const override; + QStringList menuPath(QAction*) const override; bool handleCommand(const QString& command, const QVariantMap& options) override; @@ -32,7 +32,7 @@ class SpaceGroup : public Avogadro::QtGui::ExtensionPlugin void registerCommands() override; public slots: - void setMolecule(QtGui::Molecule* mol); + void setMolecule(QtGui::Molecule* mol) override; void moleculeChanged(unsigned int changes); diff --git a/avogadro/qtplugins/surfaces/surfacedialog.cpp b/avogadro/qtplugins/surfaces/surfacedialog.cpp index bdb455e482..14228849de 100644 --- a/avogadro/qtplugins/surfaces/surfacedialog.cpp +++ b/avogadro/qtplugins/surfaces/surfacedialog.cpp @@ -52,8 +52,12 @@ void SurfaceDialog::surfaceComboChanged(int n) if (type == Surfaces::Type::MolecularOrbital || type == Surfaces::Type::FromFile) { m_ui->orbitalCombo->setEnabled(true); + m_ui->propertyCombo->setEnabled(false); + m_ui->propertyCombo->setCurrentIndex(0); // None + m_ui->colormapCombo->setEnabled(false); } else { m_ui->orbitalCombo->setEnabled(false); + m_ui->propertyCombo->setEnabled(true); } } diff --git a/avogadro/qtplugins/surfaces/surfaces.cpp b/avogadro/qtplugins/surfaces/surfaces.cpp index fc27fc25d3..ccdf629a17 100644 --- a/avogadro/qtplugins/surfaces/surfaces.cpp +++ b/avogadro/qtplugins/surfaces/surfaces.cpp @@ -129,8 +129,6 @@ bool Surfaces::handleCommand(const QString& command, const QVariantMap& options) if (m_molecule == nullptr) return false; // No molecule to handle the command. - qDebug() << "handle surface cmd:" << command << options; - // Set up some defaults for the options. int index = -1; int homo = -1; @@ -593,7 +591,7 @@ void Surfaces::calculateQM(Type type, int index, bool beta, float isoValue, } else { m_slaterConcurrent->calculateElectronDensity(m_cube); } - } else if (type == ElectronDensity) { + } else if (type == SpinDensity) { progressText = tr("Calculating spin density"); m_cube->setName("Spin Density"); m_cube->setCubeType(Core::Cube::Type::SpinDensity); @@ -693,8 +691,6 @@ void Surfaces::displayMesh() if (!m_cube) return; - // qDebug() << " running displayMesh"; - if (m_dialog != nullptr) m_smoothingPasses = m_dialog->smoothingPassesValue(); else @@ -706,7 +702,7 @@ void Surfaces::displayMesh() m_meshGenerator1 = new QtGui::MeshGenerator; connect(m_meshGenerator1, SIGNAL(finished()), SLOT(meshFinished())); } - m_meshGenerator1->initialize(m_cube, m_mesh1, -m_isoValue, m_smoothingPasses); + m_meshGenerator1->initialize(m_cube, m_mesh1, m_isoValue, m_smoothingPasses); bool isMO = false; // if it's from a file we should "play it safe" @@ -722,8 +718,8 @@ void Surfaces::displayMesh() m_meshGenerator2 = new QtGui::MeshGenerator; connect(m_meshGenerator2, SIGNAL(finished()), SLOT(meshFinished())); } - m_meshGenerator2->initialize(m_cube, m_mesh2, m_isoValue, m_smoothingPasses, - true); + m_meshGenerator2->initialize(m_cube, m_mesh2, -m_isoValue, + m_smoothingPasses, true); } // Start the mesh generation - this needs an improved mutex with a read lock @@ -797,6 +793,9 @@ void Surfaces::colorMeshByPotential() const auto colormap = getColormapFromString(m_dialog->colormapName()); const auto positionsf = m_mesh1->vertices(); + if (positionsf.empty()) + return; + Core::Array positions(positionsf.size()); std::transform(positionsf.begin(), positionsf.end(), positions.begin(), [](const Vector3f& pos) { return pos.cast(); });