| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#ifndef AVOGADRO_QTGUI_SCENEPLUGIN_H |
| 7 |
#define AVOGADRO_QTGUI_SCENEPLUGIN_H |
| 8 |
|
| 9 |
#include "avogadroqtguiexport.h" |
| 10 |
|
| 11 |
#include "pluginlayermanager.h" |
| 12 |
#include <avogadro/core/avogadrocore.h> |
| 13 |
#include <avogadro/qtplugins/pluginfactory.h> |
| 14 |
|
| 15 |
#include <QtCore/QObject> |
| 16 |
|
| 17 |
namespace Avogadro { |
| 18 |
|
| 19 |
namespace Core { |
| 20 |
class Molecule; |
| 21 |
} |
| 22 |
|
| 23 |
namespace Rendering { |
| 24 |
class GroupNode; |
| 25 |
} |
| 26 |
|
| 27 |
namespace QtGui { |
| 28 |
|
| 29 |
class RWMolecule; |
| 30 |
class Molecule; |
| 31 |
|
| 32 |
/** |
| 33 |
* @class ScenePluginFactory sceneplugin.h <avogadro/qtgui/sceneplugin.h> |
| 34 |
* @brief The base class for scene plugin factories in Avogadro. |
| 35 |
* @author Marcus D. Hanwell |
| 36 |
*/ |
| 37 |
class AVOGADROQTGUI_EXPORT ScenePlugin : public QObject |
| 38 |
{ |
| 39 |
Q_OBJECT |
| 40 |
|
| 41 |
public: |
| 42 |
explicit ScenePlugin(QObject* parent = nullptr); |
| 43 |
~ScenePlugin() override; |
| 44 |
|
| 45 |
/** |
| 46 |
* Process the supplied atom, and add the necessary primitives to the scene. |
| 47 |
*/ |
| 48 |
virtual void process(const QtGui::Molecule& molecule, |
| 49 |
Rendering::GroupNode& node); |
| 50 |
|
| 51 |
virtual void processEditable(const RWMolecule& molecule, |
| 52 |
Rendering::GroupNode& node); |
| 53 |
|
| 54 |
/** |
| 55 |
* The name of the scene plugin, will be displayed in the user interface. |
| 56 |
*/ |
| 57 |
virtual QString name() const = 0; |
| 58 |
|
| 59 |
/** |
| 60 |
* A description of the scene plugin, may be displayed in the user interface. |
| 61 |
*/ |
| 62 |
virtual QString description() const = 0; |
| 63 |
|
| 64 |
/** |
| 65 |
* Returns true if the scene plugin has been enabled and is active. |
| 66 |
*/ |
| 67 |
virtual bool isEnabled() const; |
| 68 |
|
| 69 |
/** |
| 70 |
* Returns true if the scene plugin has been enabled and is active in the |
| 71 |
* active scene. |
| 72 |
*/ |
| 73 |
virtual bool isActiveLayerEnabled() const; |
| 74 |
|
| 75 |
/** |
| 76 |
* Set the enabled state of the plugin (default should be false). |
| 77 |
*/ |
| 78 |
virtual void setEnabled(bool enable); |
| 79 |
|
| 80 |
/** |
| 81 |
* @return whether this plugin works with the current molecule. |
| 82 |
* This is used to determine if the plugin should be enabled in the UI. |
| 83 |
* For example, a plugin that only works with unit cells would return |
| 84 |
* false if the current molecule does not include a unit cell. |
| 85 |
*/ |
| 86 |
virtual bool isApplicable() const { return true; } |
| 87 |
|
| 88 |
/** |
| 89 |
* @return the widget for plugin settings (e.g., colors, widths, etc.) |
| 90 |
*/ |
| 91 |
virtual QWidget* setupWidget(); |
| 92 |
/** |
| 93 |
* This method exists to query without creating the widget. |
| 94 |
* @return true if the plugin has a setup widget |
| 95 |
*/ |
| 96 |
virtual bool hasSetupWidget() const { return false; } |
| 97 |
|
| 98 |
/** |
| 99 |
* Returns if this plugin should be considered in the default behavior, |
| 100 |
* or it should reset to true or false. |
| 101 |
*/ |
| 102 |
enum DefaultBehavior |
| 103 |
{ |
| 104 |
Ignore, |
| 105 |
False, |
| 106 |
True |
| 107 |
}; |
| 108 |
virtual DefaultBehavior defaultBehavior() const { return Ignore; } |
| 109 |
|
| 110 |
signals: |
| 111 |
void drawablesChanged(); |
| 112 |
|
| 113 |
protected: |
| 114 |
PluginLayerManager m_layerManager; |
| 115 |
}; |
| 116 |
|
| 117 |
/** |
| 118 |
* @class ScenePluginFactory sceneplugin.h <avogadro/qtgui/sceneplugin.h> |
| 119 |
* @brief The base class for scene plugin factories in Avogadro. |
| 120 |
* @author Marcus D. Hanwell |
| 121 |
*/ |
| 122 |
class AVOGADROQTGUI_EXPORT ScenePluginFactory |
| 123 |
: public Avogadro::QtPlugins::PluginFactory<ScenePlugin> |
| 124 |
{ |
| 125 |
public: |
| 126 |
~ScenePluginFactory() override {} |
| 127 |
}; |
| 128 |
|
| 129 |
} // namespace QtGui |
| 130 |
} // namespace Avogadro |
| 131 |
|
| 132 |
Q_DECLARE_INTERFACE(Avogadro::QtGui::ScenePluginFactory, |
| 133 |
"org.openchemistry.avogadro.ScenePluginFactory") |
| 134 |
|
| 135 |
#endif // AVOGADRO_QTGUI_SCENEPLUGIN_H |