summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Cord-Landwehr <cordlandwehr@kde.org>2015-09-30 20:39:58 (GMT)
committerAndreas Cord-Landwehr <cordlandwehr@kde.org>2015-10-01 17:48:19 (GMT)
commit98edb9981f67a3f289e03bf903953c9f56cfea31 (patch)
treea8459ee3f003d07a6dfc4a6402224271b5f0abac
parent465a40e4f2824163324fa2f0ce43f59a01767668 (diff)
Compile porting to Avogadro2.
After fixing the wrong build switches, the Avogadro-dependend parts break the build -- this patch makes them built with the cost of heavy commenting out. Trivial changes are directly ported, all other code is commented out and marked with "//FIXME:Avogadro2".
-rw-r--r--compoundviewer/CMakeLists.txt6
-rw-r--r--compoundviewer/kalziumglwidget.cpp154
-rw-r--r--compoundviewer/kalziumglwidget.h9
-rw-r--r--compoundviewer/libkdeedu_compoundviewer_export.h2
-rw-r--r--compoundviewer/openbabel2wrapper.cpp23
-rw-r--r--compoundviewer/openbabel2wrapper.h13
-rw-r--r--libscience/CMakeLists.txt1
-rw-r--r--src/CMakeLists.txt8
-rw-r--r--src/tools/moleculeview.cpp183
-rw-r--r--src/tools/moleculeview.h5
10 files changed, 213 insertions, 191 deletions
diff --git a/compoundviewer/CMakeLists.txt b/compoundviewer/CMakeLists.txt
index ee7109f..b1db8ff 100644
--- a/compoundviewer/CMakeLists.txt
+++ b/compoundviewer/CMakeLists.txt
@@ -18,11 +18,13 @@ target_link_libraries(compoundviewer
KF5::I18n
KF5::WidgetsAddons
KF5::CoreAddons
+ KF5::KDELibs4Support
Qt5::OpenGL
Qt5::Gui
${OPENBABEL2_LIBRARIES}
- ${OPENGL_LIBRARIES}
- ${AvogadroLibs_LIBRARY_DIR}/libavogadro.so
+ AvogadroQtGui
+ AvogadroQtOpenGL
+ AvogadroQtPlugins
)
set_target_properties(compoundviewer PROPERTIES
diff --git a/compoundviewer/kalziumglwidget.cpp b/compoundviewer/kalziumglwidget.cpp
index ae2126b..25214f8 100644
--- a/compoundviewer/kalziumglwidget.cpp
+++ b/compoundviewer/kalziumglwidget.cpp
@@ -16,17 +16,20 @@
#include <QSettings>
-#include <avogadro/primitive.h>
-#include <avogadro/pluginmanager.h>
-#include <avogadro/toolgroup.h>
-#include <avogadro/engine.h>
+#include <avogadro/rendering/primitive.h>
+#include <avogadro/qtplugins/pluginmanager.h>
+#include <avogadro/qtgui/molecule.h>
+// #include <avogadro/toolgroup.h>//FIXME:Avogadro2 port away from toolgroup
+// #include <avogadro/engine.h>//FIXME:Avogadro2 port away from engine.h
#include <QWidget>
#include "openbabel2wrapper.h"
-#include<avogadro/glwidget.h>
+#include <avogadro/qtopengl/glwidget.h>
#include <config-kalzium.h>
-KalziumGLWidget::KalziumGLWidget(QWidget *parent) : Avogadro::GLWidget(parent),
- m_lastEngine1(0), m_lastEngine2(0)
+KalziumGLWidget::KalziumGLWidget(QWidget *parent)
+ : Avogadro::QtOpenGL::GLWidget(parent)
+ , m_lastEngine1(0)
+ , m_lastEngine2(0)
{
// work around a bug in OpenBabel: the chemical data files parsing
// is dependent on the LC_NUMERIC locale.
@@ -45,19 +48,19 @@ KalziumGLWidget::KalziumGLWidget(QWidget *parent) : Avogadro::GLWidget(parent),
}
s_pluginDirSet = true;
}
- Avogadro::PluginManager *manager = Avogadro::PluginManager::instance();
- manager->loadFactories();
- Avogadro::ToolGroup* tools = new Avogadro::ToolGroup(this);
- tools->append(manager->tools(this));
- tools->setActiveTool("Navigate");
- setToolGroup(tools);
+ Avogadro::QtPlugins::PluginManager *manager = Avogadro::QtPlugins::PluginManager::instance();
+// manager->loadFactories();//FIXME:Avogadro2
+// Avogadro::ToolGroup* tools = new Avogadro::ToolGroup(this);//FIXME:Avogadro2 port away from ToolGroup
+// tools->append(manager->tools(this));
+// tools->setActiveTool("Navigate");
+// setToolGroup(tools);
// Set the default engine to be active
- loadDefaultEngines();
+// loadDefaultEngines();//FIXME:Avogadro2 port away from engine.h
// Set the default quality level to high
setQuality(2);
- setMolecule(new Avogadro::Molecule(this));
+ setMolecule(new Avogadro::QtGui::Molecule(this));
update();
}
@@ -69,11 +72,11 @@ KalziumGLWidget::~KalziumGLWidget()
bool KalziumGLWidget::openFile(const QString &file)
{
- Avogadro::Molecule* mol = OpenBabel2Wrapper::readMolecule(file);
+ Avogadro::QtGui::Molecule* mol;// = OpenBabel2Wrapper::readMolecule(file);//FIXME:Avogadro2
if (!mol) {
return false;
}
- Avogadro::Molecule* oldmol = molecule();
+ Avogadro::QtGui::Molecule* oldmol = molecule();
if (oldmol) {
oldmol->deleteLater();
}
@@ -84,73 +87,76 @@ bool KalziumGLWidget::openFile(const QString &file)
void KalziumGLWidget::setStyle(int style)
{
- foreach (Avogadro::Engine *engine, engines()) {
- if ((m_lastEngine1 == 0 && engine->identifier() == "Ball and Stick")
- || (m_lastEngine1 == 1 && engine->identifier() == "Stick")
- || (m_lastEngine1 == 2 && engine->identifier() == "Van der Waals Spheres")
- || (m_lastEngine1 == 3 && engine->identifier() == "Wireframe")) {
- engine->setEnabled(false);
- }
- if ((style == 0 && engine->identifier() == "Ball and Stick")
- || (style == 1 && engine->identifier() == "Stick")
- || (style == 2 && engine->identifier() == "Van der Waals Spheres")
- || (style == 3 && engine->identifier() == "Wireframe")) {
- engine->setEnabled(true);
- }
- }
+ //FIXME:Avogadro2
+// foreach (Avogadro::Engine *engine, engines()) {
+// if ((m_lastEngine1 == 0 && engine->identifier() == "Ball and Stick")
+// || (m_lastEngine1 == 1 && engine->identifier() == "Stick")
+// || (m_lastEngine1 == 2 && engine->identifier() == "Van der Waals Spheres")
+// || (m_lastEngine1 == 3 && engine->identifier() == "Wireframe")) {
+// engine->setEnabled(false);
+// }
+// if ((style == 0 && engine->identifier() == "Ball and Stick")
+// || (style == 1 && engine->identifier() == "Stick")
+// || (style == 2 && engine->identifier() == "Van der Waals Spheres")
+// || (style == 3 && engine->identifier() == "Wireframe")) {
+// engine->setEnabled(true);
+// }
+// }
m_lastEngine1 = style;
update();
}
void KalziumGLWidget::setStyle2(int style)
{
- foreach (Avogadro::Engine *engine, engines()) {
- if ((m_lastEngine2 == 1 && engine->identifier() == "Ribbon")
- || (m_lastEngine2 == 2 && engine->identifier() == "Ring")
- || (m_lastEngine2 == 3 && engine->identifier() == "Orbitals")) {
- engine->setEnabled(false);
- }
- if ((style == 1 && engine->identifier() == "Ribbon")
- || (style == 2 && engine->identifier() == "Ring")
- || (style == 3 && engine->identifier() == "Orbitals")) {
- engine->setEnabled(true);
- }
- }
+ //FIXME:Avogadro2
+// foreach (Avogadro::Engine *engine, engines()) {
+// if ((m_lastEngine2 == 1 && engine->identifier() == "Ribbon")
+// || (m_lastEngine2 == 2 && engine->identifier() == "Ring")
+// || (m_lastEngine2 == 3 && engine->identifier() == "Orbitals")) {
+// engine->setEnabled(false);
+// }
+// if ((style == 1 && engine->identifier() == "Ribbon")
+// || (style == 2 && engine->identifier() == "Ring")
+// || (style == 3 && engine->identifier() == "Orbitals")) {
+// engine->setEnabled(true);
+// }
+// }
m_lastEngine2 = style;
update();
}
void KalziumGLWidget::setLabels(int style)
{
- // Use the QSettings framework to configure the label engine
- foreach (Avogadro::Engine *engine, engines()) {
- if (engine->name() == "Label") {
- QSettings settings;
- int atomType = 0;
- int bondType = 0;
- bool enabled = false;
- // We need to use
- switch(style) {
- case 0: // Display no labels
- enabled = false;
- break;
- case 1: // Display the atom symbol
- enabled = true;
- atomType = 3;
- break;
- case 2: // Display the atom name
- enabled = true;
- atomType = 2;
- break;
- default:
- engine->setEnabled(false);
- }
- settings.setValue("atomLabel", atomType);
- settings.setValue("bondLabel", bondType);
- settings.setValue("enabled", enabled);
- engine->readSettings(settings);
- }
- }
+ //FIXME:Avogadro2
+// // Use the QSettings framework to configure the label engine
+// foreach (Avogadro::Engine *engine, engines()) {
+// if (engine->name() == "Label") {
+// QSettings settings;
+// int atomType = 0;
+// int bondType = 0;
+// bool enabled = false;
+// // We need to use
+// switch(style) {
+// case 0: // Display no labels
+// enabled = false;
+// break;
+// case 1: // Display the atom symbol
+// enabled = true;
+// atomType = 3;
+// break;
+// case 2: // Display the atom name
+// enabled = true;
+// atomType = 2;
+// break;
+// default:
+// engine->setEnabled(false);
+// }
+// settings.setValue("atomLabel", atomType);
+// settings.setValue("bondLabel", bondType);
+// settings.setValue("enabled", enabled);
+// engine->readSettings(settings);
+// }
+// }
}
void KalziumGLWidget::setQuality(int quality)
@@ -162,7 +168,7 @@ void KalziumGLWidget::setQuality(int quality)
} else if (quality == 2) {
q = 4;
}
- GLWidget::setQuality(q);
- invalidateDLs();
+// GLWidget::setQuality(q);//FIXME:Avogadro2
+// invalidateDLs();//FIXME:Avogadro2
GLWidget::update();
}
diff --git a/compoundviewer/kalziumglwidget.h b/compoundviewer/kalziumglwidget.h
index 548dcc8..71a708c 100644
--- a/compoundviewer/kalziumglwidget.h
+++ b/compoundviewer/kalziumglwidget.h
@@ -14,11 +14,12 @@
#ifndef KALZIUMGLWIDGET_H
#define KALZIUMGLWIDGET_H
-#include<QtWidgets>
-#include<QtOpenGL>
-#include <avogadro/glwidget.h>
+#include <QtWidgets>
+#include <QtOpenGL>
+#include <QOpenGLWidget>
+#include <avogadro/qtopengl/glwidget.h>
-class Q_DECL_EXPORT KalziumGLWidget : public Avogadro::GLWidget
+class Q_DECL_EXPORT KalziumGLWidget : public Avogadro::QtOpenGL::GLWidget
{
Q_OBJECT
public:
diff --git a/compoundviewer/libkdeedu_compoundviewer_export.h b/compoundviewer/libkdeedu_compoundviewer_export.h
index da2a210..cfd26f8 100644
--- a/compoundviewer/libkdeedu_compoundviewer_export.h
+++ b/compoundviewer/libkdeedu_compoundviewer_export.h
@@ -21,7 +21,7 @@
#define LIBKDEEDU_COMPOUNDVIEWER_EXPORT_H
/* needed for KDE_EXPORT and KDE_IMPORT macros */
-#include <QtGlobal>
+#include <kglobal.h>
#ifndef COMPOUNDVIEWER_EXPORT
diff --git a/compoundviewer/openbabel2wrapper.cpp b/compoundviewer/openbabel2wrapper.cpp
index e0051a2..1e9def6 100644
--- a/compoundviewer/openbabel2wrapper.cpp
+++ b/compoundviewer/openbabel2wrapper.cpp
@@ -26,17 +26,20 @@
#include <string.h>
#include <stdlib.h>
+#include <openbabel/obconversion.h>
+#include <openbabel/mol.h>
+
#include <QMouseEvent>
#include <QRegExp>
#include <QFile>
-Avogadro::Molecule* OpenBabel2Wrapper::readMolecule(const QString& filename)
+Avogadro::QtGui::Molecule* OpenBabel2Wrapper::readMolecule(const QString& filename)
{
OpenBabel::OBConversion Conv;
OpenBabel::OBFormat *inFormat = NULL;
// the Avogadro Molecule
- Avogadro::Molecule *mol = new Avogadro::Molecule;
+ Avogadro::QtGui::Molecule *mol = new Avogadro::QtGui::Molecule;
OpenBabel::OBMol *obmol = new OpenBabel::OBMol;
std::ifstream inFileStream(QFile::encodeName(filename));
if (!inFileStream) {
@@ -58,11 +61,11 @@ Avogadro::Molecule* OpenBabel2Wrapper::readMolecule(const QString& filename)
Conv.Read(obmol, &inFileStream);
qDebug() << QString::fromLatin1(obmol->GetFormula().c_str()) << " (Weight: " << obmol->GetMolWt() << ", Title: "<< obmol->GetTitle() << ")";
- mol->setOBMol(obmol);
+// mol->setOBMol(obmol);///*FIXME:Avogadro2*/ method gone
return mol;
}
-bool OpenBabel2Wrapper::writeMolecule(const QString& filename, Avogadro::Molecule* mol)
+bool OpenBabel2Wrapper::writeMolecule(const QString& filename, Avogadro::QtGui::Molecule* mol)
{
OpenBabel::OBConversion Conv;
OpenBabel::OBFormat *outFormat = NULL;
@@ -80,20 +83,20 @@ bool OpenBabel2Wrapper::writeMolecule(const QString& filename, Avogadro::Molecul
return false;
}
Conv.SetInAndOutFormats(outFormat,outFormat);
- OpenBabel::OBMol obmol = mol->OBMol();
- Conv.Write(&obmol, &outFileStream);
+// OpenBabel::OBMol obmol = mol->OBMol();//FIXME:Avogadro2 method gone
+// Conv.Write(&obmol, &outFileStream);//FIXME:Avogadro2
return true;
}
-QString OpenBabel2Wrapper::getFormula(Avogadro::Molecule* molecule)
+QString OpenBabel2Wrapper::getFormula(Avogadro::QtGui::Molecule* molecule)
{
- QString formula(molecule->OBMol().GetFormula().c_str());
+ QString formula;//(molecule->OBMol().GetFormula().c_str());//FIXME:Avogadro2 method gone
return formula;
}
-QString OpenBabel2Wrapper::getPrettyFormula(Avogadro::Molecule* molecule)
+QString OpenBabel2Wrapper::getPrettyFormula(Avogadro::QtGui::Molecule* molecule)
{
- QString formula(molecule->OBMol().GetSpacedFormula(1, "").c_str());
+ QString formula;//(molecule->OBMol().GetSpacedFormula(1, "").c_str());//FIXME:Avogadro2 method gone
formula.replace(QRegExp("(\\d+)"), "<sub>\\1</sub>");
return formula;
}
diff --git a/compoundviewer/openbabel2wrapper.h b/compoundviewer/openbabel2wrapper.h
index f16818f..58e5890 100644
--- a/compoundviewer/openbabel2wrapper.h
+++ b/compoundviewer/openbabel2wrapper.h
@@ -15,10 +15,7 @@
#ifndef OPENBABEL2WRAPPER_H
#define OPENBABEL2WRAPPER_H
-//includes for OpenBabel2
-#include <openbabel/obconversion.h>
-#include <openbabel/mol.h>
-#include <avogadro/molecule.h>
+#include <avogadro/qtgui/molecule.h>
#include <libkdeedu_compoundviewer_export.h>
@@ -32,13 +29,13 @@ public:
* This class reads the molecule in the file @p filename. It returns 0 if
* the file couldn't be read.
*/
- static Avogadro::Molecule *readMolecule(const QString& filename);
+ static Avogadro::QtGui::Molecule *readMolecule(const QString& filename);
- static bool writeMolecule(const QString& filename, Avogadro::Molecule *);
+ static bool writeMolecule(const QString& filename, Avogadro::QtGui::Molecule *);
- static QString getFormula(Avogadro::Molecule *molecule);
+ static QString getFormula(Avogadro::QtGui::Molecule *molecule);
- static QString getPrettyFormula(Avogadro::Molecule *molecule);
+ static QString getPrettyFormula(Avogadro::QtGui::Molecule *molecule);
};
#endif // OPENBABEL2WRAPPER_H
diff --git a/libscience/CMakeLists.txt b/libscience/CMakeLists.txt
index ca629df..d7c23a4 100644
--- a/libscience/CMakeLists.txt
+++ b/libscience/CMakeLists.txt
@@ -14,7 +14,6 @@ set(science_LIB_SRCS
psetables.cpp
)
-
add_library(science SHARED ${science_LIB_SRCS})
target_link_libraries(science Qt5::OpenGL Qt5::Xml KF5::UnitConversion KF5::WidgetsAddons KF5::KDELibs4Support)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 895c5e8..3576365 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -140,7 +140,13 @@ target_link_libraries(kalzium KF5::Plotting KF5::KHtml KF5::KDELibs4Support KF5:
if (OPENBABEL2_FOUND)
target_link_libraries(kalzium ${OPENBABEL2_LIBRARIES})
if (EIGEN3_FOUND AND AvogadroLibs_FOUND)
- target_link_libraries(kalzium ${QT_QTOPENGL_LIBRARY} compoundviewer avogadro)
+ target_link_libraries(kalzium
+ Qt5::OpenGL
+ compoundviewer
+ AvogadroQtGui
+ AvogadroQtOpenGL
+ AvogadroQtPlugins
+ )
endif (EIGEN3_FOUND AND AvogadroLibs_FOUND)
endif (OPENBABEL2_FOUND)
diff --git a/src/tools/moleculeview.cpp b/src/tools/moleculeview.cpp
index e716e73..922ff0d 100644
--- a/src/tools/moleculeview.cpp
+++ b/src/tools/moleculeview.cpp
@@ -14,9 +14,10 @@
#include "moleculeview.h"
-#include <avogadro/toolgroup.h>
-#include <avogadro/elementtranslator.h>
-#include <avogadro/periodictableview.h>
+// #include <avogadro/toolgroup.h>//FIXME:Avogadro2
+#include <avogadro/qtgui/elementtranslator.h>
+#include <avogadro/qtgui/periodictableview.h>
+#include <avogadro/qtgui/molecule.h>
#include <QFileInfo>
#include <QGLFormat>
@@ -43,7 +44,7 @@
#include <QStandardPaths>
using namespace OpenBabel;
-using namespace Avogadro;
+using namespace Avogadro::QtGui;
OpenBabel2Wrapper openBabel;
MoleculeDialog::MoleculeDialog(QWidget * parent)
@@ -89,7 +90,7 @@ MoleculeDialog::MoleculeDialog(QWidget * parent)
// Need the undo stack even though we aren't using it just yet - atom deletion
// doesn't work without it...
QUndoStack* tmp = new QUndoStack(this);
- ui.glWidget->setUndoStack(tmp);
+// ui.glWidget->setUndoStack(tmp);//FIXME:Avogadro2
// Set up the elements combo and bond order combo
elementCombo();
@@ -140,37 +141,37 @@ MoleculeDialog::MoleculeDialog(QWidget * parent)
this, SLOT(slotSaveMolecule()));
// Check that we have managed to load up some tools and engines
- int nEngines = ui.glWidget->engines().size() - 1;
- int nTools = ui.glWidget->toolGroup()->tools().size();
+// int nEngines = ui.glWidget->engines().size() - 1;//FIXME:Avogadro2
+// int nTools = ui.glWidget->toolGroup()->tools().size();//FIXME:Avogadro2
QString error;
- if (!nEngines && !nTools) {
- error = i18n("No tools or engines loaded - it is likely that the Avogadro plugins could not be located.");
- } else if (!nEngines) {
- error = i18n("No engines loaded - it is likely that the Avogadro plugins could not be located.");
- } else if (!nTools) {
- error = i18n("No tools loaded - it is likely that the Avogadro plugins could not be located.");
- }
- if (!nEngines || !nTools) {
- KMessageBox::error(this, error, i18n("Kalzium"));
- }
+// if (!nEngines && !nTools) {//FIXME:Avogadro2
+// error = i18n("No tools or engines loaded - it is likely that the Avogadro plugins could not be located.");
+// } else if (!nEngines) {
+// error = i18n("No engines loaded - it is likely that the Avogadro plugins could not be located.");
+// } else if (!nTools) {
+// error = i18n("No tools loaded - it is likely that the Avogadro plugins could not be located.");
+// }
+// if (!nEngines || !nTools) {
+// KMessageBox::error(this, error, i18n("Kalzium"));
+// }
}
void MoleculeDialog::slotLoadMolecule()
{
// Check that we have managed to load up some tools and engines
- int nEngines = ui.glWidget->engines().size() - 1;
- int nTools = ui.glWidget->toolGroup()->tools().size();
- QString error;
- if (!nEngines && !nTools) {
- error = i18n("No tools or engines loaded - it is likely that the Avogadro plugins could not be located. No molecules can be viewed until this issue is resolved.");
- } else if (!nEngines) {
- error = i18n("No engines loaded - it is likely that the Avogadro plugins could not be located. No molecules can be viewed until this issue is resolved.");
- } else if (!nTools) {
- error = i18n("No tools loaded - it is likely that the Avogadro plugins could not be located. No molecules can be viewed until this issue is resolved.");
- }
- if (!nEngines || !nTools) {
- KMessageBox::information(this, error);
- }
+// int nEngines = ui.glWidget->engines().size() - 1;//FIXME:Avogadro2
+// int nTools = ui.glWidget->toolGroup()->tools().size();//FIXME:Avogadro2
+// QString error;
+// if (!nEngines && !nTools) {//FIXME:Avogadro2
+// error = i18n("No tools or engines loaded - it is likely that the Avogadro plugins could not be located. No molecules can be viewed until this issue is resolved.");
+// } else if (!nEngines) {
+// error = i18n("No engines loaded - it is likely that the Avogadro plugins could not be located. No molecules can be viewed until this issue is resolved.");
+// } else if (!nTools) {
+// error = i18n("No tools loaded - it is likely that the Avogadro plugins could not be located. No molecules can be viewed until this issue is resolved.");
+// }
+// if (!nEngines || !nTools) {
+// KMessageBox::information(this, error);
+// }
m_path = QStandardPaths::locate(QStandardPaths::DataLocation, "data/molecules/") + "data/molecules/";
m_path = QFileInfo(m_path).absolutePath();
@@ -178,17 +179,18 @@ void MoleculeDialog::slotLoadMolecule()
QString commonMoleculeFormats = i18n("Common molecule formats");
QString allFiles = i18n("All files");
- QString filename = KFileDialog::getOpenFileName(
- m_path,
- "*.cml *.xyz *.ent *.pdb *.alc *.chm *.cdx *.cdxml *.c3d1 *.c3d2"
- " *.gpr *.mdl *.mol *.sdf *.sd *.crk3d *.cht *.dmol *.bgf"
- " *.gam *.inp *.gamin *.gamout *.tmol *.fract"
- " *.mpd *.mol2|" + commonMoleculeFormats + "\n"
- "* *.*|" + allFiles,
- this,
- i18n("Choose a file to open"));
-
- loadMolecule(filename);
+ //FIXME:KF5
+// QString filename = KFileDialog::getOpenFileName(
+// m_path,
+// "*.cml *.xyz *.ent *.pdb *.alc *.chm *.cdx *.cdxml *.c3d1 *.c3d2"
+// " *.gpr *.mdl *.mol *.sdf *.sd *.crk3d *.cht *.dmol *.bgf"
+// " *.gam *.inp *.gamin *.gamout *.tmol *.fract"
+// " *.mpd *.mol2|" + commonMoleculeFormats + "\n"
+// "* *.*|" + allFiles,
+// this,
+// i18n("Choose a file to open"));
+//
+// loadMolecule(filename);
}
void MoleculeDialog::loadMolecule(const QString &filename)
@@ -199,28 +201,30 @@ void MoleculeDialog::loadMolecule(const QString &filename)
qDebug() << "Filename to load: " << filename;
- Molecule* molecule = OpenBabel2Wrapper::readMolecule(filename);
+ Avogadro::QtGui::Molecule* molecule = OpenBabel2Wrapper::readMolecule(filename);
// Check that a valid molecule object was returned
if (!molecule) {
return;
}
- if (molecule->numAtoms() != 0) {
- disconnect(ui.glWidget->molecule(), 0, this, 0);
- molecule->center();
- ui.glWidget->setMolecule(molecule);
- ui.glWidget->update();
- slotUpdateStatistics();
- connect(molecule, SIGNAL(updated()), this, SLOT(slotUpdateStatistics()));
- }
- ui.glWidget->invalidateDLs();
+//FIXME:Avogadro2
+// if (molecule->numAtoms() != 0) {
+// disconnect(ui.glWidget->molecule(), 0, this, 0);
+// molecule->center();
+// ui.glWidget->setMolecule(molecule);
+// ui.glWidget->update();
+// slotUpdateStatistics();
+// connect(molecule, SIGNAL(updated()), this, SLOT(slotUpdateStatistics()));
+// }
+// ui.glWidget->invalidateDLs();
}
void MoleculeDialog::clearAllElementsInEditor()
{
- ui.glWidget->molecule()->clear();
- ui.glWidget->update();
+//FIXME:Avogadro2
+// ui.glWidget->molecule()->clear();
+// ui.glWidget->update();
}
void MoleculeDialog::slotSaveMolecule()
@@ -241,21 +245,22 @@ void MoleculeDialog::slotSaveMolecule()
}
OpenBabel2Wrapper openBabel;
- openBabel.writeMolecule(filename, ui.glWidget->molecule());
+// openBabel.writeMolecule(filename, ui.glWidget->molecule());//FIXME:Avogadro2
}
void MoleculeDialog::setViewEdit(int mode)
{
- if (mode == 0) {
- ui.glWidget->toolGroup()->setActiveTool("Navigate");
- } else if (mode == 1) {
- ui.glWidget->toolGroup()->setActiveTool("Draw");
- if (ui.glWidget->toolGroup()->activeTool()) {
- ui.glWidget->toolGroup()->activeTool()->readSettings(*m_drawSettings);
- }
- } else if (mode == 2) {
- ui.glWidget->toolGroup()->setActiveTool("Measure");
- }
+//FIXME:Avogadro2
+// if (mode == 0) {
+// ui.glWidget->toolGroup()->setActiveTool("Navigate");
+// } else if (mode == 1) {
+// ui.glWidget->toolGroup()->setActiveTool("Draw");
+// if (ui.glWidget->toolGroup()->activeTool()) {
+// ui.glWidget->toolGroup()->activeTool()->readSettings(*m_drawSettings);
+// }
+// } else if (mode == 2) {
+// ui.glWidget->toolGroup()->setActiveTool("Measure");
+// }
}
MoleculeDialog::~MoleculeDialog()
@@ -265,14 +270,14 @@ MoleculeDialog::~MoleculeDialog()
void MoleculeDialog::slotUpdateStatistics()
{
- Avogadro::Molecule* mol = ui.glWidget->molecule();
+ Molecule* mol = ui.glWidget->molecule();
if (!mol) {
return;
}
-
- ui.nameLabel->setText(mol->OBMol().GetTitle());
- ui.weightLabel->setText(i18nc("This 'u' stands for the chemical unit (u for 'units'). Most likely this does not need to be translated at all!", "%1 u", mol->OBMol().GetMolWt()));
- ui.formulaLabel->setText(openBabel.getPrettyFormula(mol));
+//FIXME:Avogadro2
+// ui.nameLabel->setText(mol->OBMol().GetTitle());
+// ui.weightLabel->setText(i18nc("This 'u' stands for the chemical unit (u for 'units'). Most likely this does not need to be translated at all!", "%1 u", mol->OBMol().GetMolWt()));
+// ui.formulaLabel->setText(openBabel.getPrettyFormula(mol));
// ui.glWidget->update();
}
@@ -298,7 +303,7 @@ void MoleculeDialog::slotDownloadNewStuff()
qDebug() << "Changed Entry: " << entry.installedFiles();
foreach (const QString &origFile, entry.installedFiles()) {
const QString destFile = destinationDir + '/' + QFileInfo(origFile).fileName();
- KJob *job = KIO::file_move(QUrl::fromLocalFile(origFile), QUrl::fromPath(destFile));
+ KJob *job;// = KIO::file_move(QUrl::fromLocalFile(origFile), QUrl::fromPath(destFile));//TODO:KF5
const bool success = job->exec();
if (success) {
if (exactlyOneFile.isEmpty()) {
@@ -367,16 +372,16 @@ void MoleculeDialog::slotElementChanged(int element)
}
m_drawSettings->setValue("currentElement", m_elementsIndex[element]);
- ui.glWidget->toolGroup()->activeTool()->readSettings(*m_drawSettings);
+// ui.glWidget->toolGroup()->activeTool()->readSettings(*m_drawSettings);//FIXME:Avogadro2
}
void MoleculeDialog::slotCustomElementChanged(int element)
{
// Set the element so we can draw with it
m_drawSettings->setValue("currentElement", element);
- if (ui.glWidget->toolGroup()->activeTool()) {
- ui.glWidget->toolGroup()->activeTool()->readSettings(*m_drawSettings);
- }
+// if (ui.glWidget->toolGroup()->activeTool()) {//FIXME:Avogadro2
+// ui.glWidget->toolGroup()->activeTool()->readSettings(*m_drawSettings);
+// }
// Check to see if we already have this in the comboBox list
// If not, we get back -1 and need to create a new item
@@ -411,17 +416,17 @@ void MoleculeDialog::slotCustomElementChanged(int element)
void MoleculeDialog::slotBondOrderChanged(int bond)
{
m_drawSettings->setValue("bondOrder", bond+1);
- if (ui.glWidget->toolGroup()->activeTool()) {
- ui.glWidget->toolGroup()->activeTool()->readSettings(*m_drawSettings);
- }
+// if (ui.glWidget->toolGroup()->activeTool()) {//FIXME:Avogadro2
+// ui.glWidget->toolGroup()->activeTool()->readSettings(*m_drawSettings);
+// }
}
void MoleculeDialog::slotAddHydrogensChanged(int hydrogens)
{
m_drawSettings->setValue("addHydrogens", hydrogens);
- if (ui.glWidget->toolGroup()->activeTool()) {
- ui.glWidget->toolGroup()->activeTool()->readSettings(*m_drawSettings);
- }
+// if (ui.glWidget->toolGroup()->activeTool()) {//FIXME:Avogadro2
+// ui.glWidget->toolGroup()->activeTool()->readSettings(*m_drawSettings);
+// }
}
void MoleculeDialog::slotAdjustHydrogens()
@@ -429,14 +434,14 @@ void MoleculeDialog::slotAdjustHydrogens()
// Add/remove hydrogens from the molecule
if (!m_addHydrogens) {
ui.hydrogensButton->setText(i18n("Remove hydrogens"));
- ui.glWidget->molecule()->addHydrogens();
+// ui.glWidget->molecule()->addHydrogens();//FIXME:Avogadro2
m_addHydrogens = true;
} else {
ui.hydrogensButton->setText(i18n("Add hydrogens"));
- ui.glWidget->molecule()->removeHydrogens();
+// ui.glWidget->molecule()->removeHydrogens();//FIXME:Avogadro2
m_addHydrogens = false;
}
- ui.glWidget->molecule()->update();
+// ui.glWidget->molecule()->update();//FIXME:Avogadro2
}
void MoleculeDialog::slotGeometryOptimize()
@@ -447,7 +452,7 @@ void MoleculeDialog::slotGeometryOptimize()
}
Molecule* molecule = ui.glWidget->molecule();
- OpenBabel::OBMol obmol(molecule->OBMol());
+ OpenBabel::OBMol obmol;//(molecule->OBMol());//FIXME:Avogadro2
// Warn the user if the force field cannot be set up for the molecule
if (!m_forceField->Setup(obmol)) {
@@ -460,9 +465,9 @@ void MoleculeDialog::slotGeometryOptimize()
// Reasonable default values for most users
m_forceField->SteepestDescentInitialize(500, 1.0e-5);
// Provide some feedback as the optimization runs
- while (m_forceField->SteepestDescentTakeNSteps(5)) {
- m_forceField->UpdateCoordinates(obmol);
- molecule->setOBMol(&obmol);
- molecule->update();
- }
+// while (m_forceField->SteepestDescentTakeNSteps(5)) {//FIXME:Avogadro2
+// m_forceField->UpdateCoordinates(obmol);
+// molecule->setOBMol(&obmol);
+// molecule->update();
+// }
}
diff --git a/src/tools/moleculeview.h b/src/tools/moleculeview.h
index 73bf9b8..a13aac1 100644
--- a/src/tools/moleculeview.h
+++ b/src/tools/moleculeview.h
@@ -25,8 +25,11 @@ class OBForceField;
}
namespace Avogadro
{
+namespace QtGui
+{
class PeriodicTableView;
}
+}
class QSettings;
/**
@@ -45,7 +48,7 @@ public:
private:
QString m_path;///to store the path were the molecules are located
QList<int> m_elementsIndex; // Index storing the element combo index
- Avogadro::PeriodicTableView *m_periodicTable;
+ Avogadro::QtGui::PeriodicTableView *m_periodicTable;
OpenBabel::OBForceField* m_forceField;
QSettings *m_drawSettings;
bool m_addHydrogens;