diff --git a/avogadro/qtplugins/surfaces/surfacedialog.cpp b/avogadro/qtplugins/surfaces/surfacedialog.cpp index bb9db140e4..bdb455e482 100644 --- a/avogadro/qtplugins/surfaces/surfacedialog.cpp +++ b/avogadro/qtplugins/surfaces/surfacedialog.cpp @@ -120,10 +120,6 @@ void SurfaceDialog::smoothingComboChanged(int n) m_ui->smoothingPassesSpinBox->setValue(0); m_ui->smoothingPassesSpinBox->setEnabled(false); break; - case 1: // Light smoothing - m_ui->smoothingPassesSpinBox->setValue(1); - m_ui->smoothingPassesSpinBox->setEnabled(false); - break; case 2: // Medium smoothing m_ui->smoothingPassesSpinBox->setValue(5); m_ui->smoothingPassesSpinBox->setEnabled(false); @@ -136,8 +132,9 @@ void SurfaceDialog::smoothingComboChanged(int n) m_ui->smoothingPassesSpinBox->setValue(5); m_ui->smoothingPassesSpinBox->setEnabled(true); break; + case 1: // Light smoothing default: - m_ui->smoothingPassesSpinBox->setValue(5); + m_ui->smoothingPassesSpinBox->setValue(1); m_ui->smoothingPassesSpinBox->setEnabled(false); break; } diff --git a/avogadro/qtplugins/surfaces/surfacedialog.ui b/avogadro/qtplugins/surfaces/surfacedialog.ui index 47a3a10c7d..9dd2275271 100644 --- a/avogadro/qtplugins/surfaces/surfacedialog.ui +++ b/avogadro/qtplugins/surfaces/surfacedialog.ui @@ -360,10 +360,10 @@ true - Medium + Light - 2 + 1 @@ -407,7 +407,7 @@ 1 - 5 + 1 diff --git a/avogadro/qtplugins/surfaces/surfaces.cpp b/avogadro/qtplugins/surfaces/surfaces.cpp index 375af870b8..fc27fc25d3 100644 --- a/avogadro/qtplugins/surfaces/surfaces.cpp +++ b/avogadro/qtplugins/surfaces/surfaces.cpp @@ -65,6 +65,7 @@ using namespace tinycolormap; namespace Avogadro::QtPlugins { using Core::Array; +using Core::Cube; using Core::GaussianSet; using Core::NeighborPerceiver; using QtGui::Molecule; @@ -707,29 +708,36 @@ void Surfaces::displayMesh() } m_meshGenerator1->initialize(m_cube, m_mesh1, -m_isoValue, m_smoothingPasses); - // TODO - only do this if we're generating an orbital - // and we need two meshes - // How do we know? - likely ask the cube if it's an MO? - qDebug() << "Cube " << m_cube->name().c_str() << " type " - << m_cube->cubeType(); + bool isMO = false; + // if it's from a file we should "play it safe" + if (m_cube->cubeType() == Cube::Type::MO || + m_cube->cubeType() == Cube::Type::FromFile) { + isMO = true; + } - if (!m_mesh2) - m_mesh2 = m_molecule->addMesh(); - if (!m_meshGenerator2) { - m_meshGenerator2 = new QtGui::MeshGenerator; - connect(m_meshGenerator2, SIGNAL(finished()), SLOT(meshFinished())); + if (isMO) { + if (!m_mesh2) + m_mesh2 = m_molecule->addMesh(); + if (!m_meshGenerator2) { + 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 // to function as expected. Write locks are exclusive, read locks can have // many read locks but no write lock. m_meshGenerator1->start(); - m_meshGenerator2->start(); + if (isMO) + m_meshGenerator2->start(); // Track how many meshes are left to show. - m_meshesLeft = 2; + if (isMO) + m_meshesLeft = 2; + else + m_meshesLeft = 1; } Core::Color3f Surfaces::chargeGradient(double value, double clamp, @@ -825,6 +833,12 @@ void Surfaces::meshFinished() --m_meshesLeft; if (m_meshesLeft == 0) { colorMesh(); + + // finished, so request to enable the mesh display type + QStringList displayTypes; + displayTypes << tr("Meshes"); + requestActiveDisplayTypes(displayTypes); + if (m_recordingMovie) { // Move to the next frame. qDebug() << "Let's get to the next frameā€¦"; @@ -834,12 +848,9 @@ void Surfaces::meshFinished() if (m_dialog != nullptr) m_dialog->reenableCalculateButton(); - qDebug() << " mesh finished"; - m_molecule->emitChanged(QtGui::Molecule::Added); } } - // TODO: enable the mesh display type } void Surfaces::recordMovie()