diff --git a/avogadro/qtplugins/forcefield/forcefield.cpp b/avogadro/qtplugins/forcefield/forcefield.cpp index b85de0f5a1..285a9e2920 100644 --- a/avogadro/qtplugins/forcefield/forcefield.cpp +++ b/avogadro/qtplugins/forcefield/forcefield.cpp @@ -31,9 +31,6 @@ #include #include -#include -#include -#include #include namespace Avogadro { @@ -132,7 +129,11 @@ QList Forcefield::actions() const QStringList Forcefield::menuPath(QAction* action) const { QStringList path; - path << tr("&Extensions") << tr("&Calculate"); + if (action->data().toInt() == optimizeAction) + path << tr("&Extensions"); + else + path << tr("&Extensions") << tr("&Calculate"); + return path; } @@ -229,7 +230,6 @@ void Forcefield::optimize() m_molecule->undoMolecule()->setInteractive(true); cppoptlib::LbfgsSolver solver; - // cppoptlib::ConjugatedGradientDescentSolver solver; int n = m_molecule->atomCount(); diff --git a/avogadro/qtplugins/forcefield/obmmenergy.cpp b/avogadro/qtplugins/forcefield/obmmenergy.cpp index a5f9ee57e8..594dba9f80 100644 --- a/avogadro/qtplugins/forcefield/obmmenergy.cpp +++ b/avogadro/qtplugins/forcefield/obmmenergy.cpp @@ -17,52 +17,6 @@ namespace Avogadro::QtPlugins { -class OBMMEnergy::ProcessListener : public QObject -{ - Q_OBJECT -public: - ProcessListener(QProcess* proc) - : QObject(), m_finished(false), m_process(proc) - { - } - - bool waitForOutput(QByteArray output, int msTimeout = 2000) - { - connect(m_process, SIGNAL(readyRead()), SLOT(readyRead())); - if (!wait(msTimeout)) - return false; - - // success! - output = m_output; - disconnect(m_process, nullptr, nullptr, nullptr); - m_finished = false; - return true; - } - -public slots: - void readyRead() - { - m_finished = true; - m_output = m_process->readAllStandardOutput(); - } - -private: - bool wait(int msTimeout) - { - QTimer timer; - timer.start(msTimeout); - - while (timer.isActive() && !m_finished) - qApp->processEvents(QEventLoop::AllEvents, 500); - - return m_finished; - } - - QProcess* m_process; - bool m_finished; - QByteArray m_output; -}; - OBMMEnergy::OBMMEnergy(const std::string& method) : m_identifier(method), m_name(method), m_process(nullptr), m_molecule(nullptr), @@ -127,8 +81,7 @@ QByteArray OBMMEnergy::writeAndRead(const QByteArray& input) QByteArray result, line; m_process->write(input + "\n"); QThread::msleep(1); - m_process->waitForReadyRead(50); - bool gotInvalid = false; + m_process->waitForReadyRead(5); while (m_process->canReadLine() && !line.startsWith("command >")) { line = m_process->readLine(); result += line; @@ -137,7 +90,7 @@ QByteArray OBMMEnergy::writeAndRead(const QByteArray& input) if (!result.contains("invalid command\n command >")) { m_process->write(" \n"); QThread::msleep(1); - m_process->waitForReadyRead(50); + m_process->waitForReadyRead(5); while (m_process->canReadLine()) { line = m_process->readLine(); result += line; @@ -241,7 +194,7 @@ void OBMMEnergy::setMolecule(Core::Molecule* mol) } QByteArray input, line, result; - bool ready = m_process->waitForReadyRead(); + m_process->waitForReadyRead(); result.clear(); while (!result.contains("command >")) { result += m_process->readLine(); diff --git a/avogadro/qtplugins/forcefield/obmmenergy.h b/avogadro/qtplugins/forcefield/obmmenergy.h index 49a2694684..63d0d9d2b3 100644 --- a/avogadro/qtplugins/forcefield/obmmenergy.h +++ b/avogadro/qtplugins/forcefield/obmmenergy.h @@ -23,10 +23,6 @@ namespace Io { class FileFormat; } -namespace QtGui { -class PythonScript; -} - namespace QtPlugins { class OBMMEnergy : public Avogadro::Calc::EnergyCalculator @@ -73,7 +69,6 @@ class OBMMEnergy : public Avogadro::Calc::EnergyCalculator /** * @brief Synchronous use of the QProcess. */ - class ProcessListener; QByteArray writeAndRead(const QByteArray& input); private: