summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Cord-Landwehr <cordlandwehr@kde.org>2016-04-07 19:45:30 (GMT)
committerAndreas Cord-Landwehr <cordlandwehr@kde.org>2016-04-07 19:45:30 (GMT)
commit3c95c89f6585903e21905c3c136697edcc915970 (patch)
tree475cea9638b2a0d572afac26e793b70aeb4f5b3e
parent0b82a51ec33fbcf236439d14a86214ab5deb8bde (diff)
Port loading of Avogadro tools.
-rw-r--r--compoundviewer/kalziumglwidget.cpp42
-rw-r--r--compoundviewer/kalziumglwidget.h1
2 files changed, 29 insertions, 14 deletions
diff --git a/compoundviewer/kalziumglwidget.cpp b/compoundviewer/kalziumglwidget.cpp
index 98d75d9..7a58b65 100644
--- a/compoundviewer/kalziumglwidget.cpp
+++ b/compoundviewer/kalziumglwidget.cpp
@@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2006 by Carsten Niehaus <cniehaus@kde.org>
* Copyright (C) 2007-2008 by Marcus D. Hanwell <marcus@cryos.org>
+ * Copyright (C) 2016 by Andreas Cord-Landwehr <cordlandwehr@kde.org>
***************************************************************************/
/***************************************************************************
@@ -13,23 +14,23 @@
***************************************************************************/
#include "kalziumglwidget.h"
+#include "iowrapper.h"
-#include <QSettings>
-
-#include <avogadro/rendering/primitive.h>
-#include <avogadro/qtplugins/pluginmanager.h>
#include <avogadro/qtgui/molecule.h>
#include <avogadro/qtgui/sceneplugin.h>
-// #include <avogadro/toolgroup.h>//FIXME:Avogadro2 port away from toolgroup
-#include <QWidget>
-#include "iowrapper.h"
+#include <avogadro/qtgui/sceneplugin.h>
+#include <avogadro/qtgui/toolplugin.h>
#include <avogadro/qtopengl/glwidget.h>
+#include <avogadro/qtplugins/pluginmanager.h>
+#include <avogadro/rendering/primitive.h>
+
+#include <QWidget>
+#include <QSettings>
+
#include <config-kalzium.h>
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.
@@ -50,6 +51,8 @@ KalziumGLWidget::KalziumGLWidget(QWidget *parent)
}
Avogadro::QtPlugins::PluginManager *manager = Avogadro::QtPlugins::PluginManager::instance();
manager->load();
+
+ // load render engines
QList<Avogadro::QtGui::ScenePluginFactory*> scenePluginFactories =
manager->pluginFactories<Avogadro::QtGui::ScenePluginFactory>();
foreach (auto *factory, scenePluginFactories) {
@@ -61,10 +64,23 @@ KalziumGLWidget::KalziumGLWidget(QWidget *parent)
sceneModel().addItem(scenePlugin);
}
-// Avogadro::ToolGroup* tools = new Avogadro::ToolGroup(this);//FIXME:Avogadro2 port away from ToolGroup
-// tools->append(manager->tools(this));
-// tools->setActiveTool("Navigate");
-// setToolGroup(tools);
+ // load tools
+ if (!tools().isEmpty()) {
+ qCritical() << "Updating non-empty toolset, erasing first.";
+ qDeleteAll(tools());
+ }
+ auto toolPluginFactories =
+ manager->pluginFactories<Avogadro::QtGui::ToolPluginFactory>();
+ foreach (auto *factory, toolPluginFactories) {
+ auto *tool = factory->createInstance();
+ if (tool) {
+ addTool(tool);
+ if (factory->identifier() == QStringLiteral("Navigator")) {
+ setDefaultTool(tool);
+ setActiveTool(tool);
+ }
+ }
+ }
setMolecule(new Avogadro::QtGui::Molecule(this));
update();
diff --git a/compoundviewer/kalziumglwidget.h b/compoundviewer/kalziumglwidget.h
index 5060723..6fbb446 100644
--- a/compoundviewer/kalziumglwidget.h
+++ b/compoundviewer/kalziumglwidget.h
@@ -30,7 +30,6 @@ public slots:
protected:
QByteArray m_lc_numeric;
- int m_lastEngine1, m_lastEngine2;
};
#endif // KALZIUMGLWIDGET_H