| 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_QTPLUGINS_LABELEDITOR_H |
| 7 |
#define AVOGADRO_QTPLUGINS_LABELEDITOR_H |
| 8 |
|
| 9 |
#include <avogadro/qtgui/molecule.h> |
| 10 |
#include <avogadro/qtgui/rwmolecule.h> |
| 11 |
#include <avogadro/qtgui/toolplugin.h> |
| 12 |
|
| 13 |
namespace Avogadro { |
| 14 |
namespace QtPlugins { |
| 15 |
|
| 16 |
class LabelEditor : public QtGui::ToolPlugin |
| 17 |
{ |
| 18 |
Q_OBJECT |
| 19 |
public: |
| 20 |
explicit LabelEditor(QObject* parent_ = nullptr); |
| 21 |
~LabelEditor() override; |
| 22 |
|
| 23 |
QString name() const override { return tr("Label editor tool"); } |
| 24 |
QString description() const override { return tr("Label editor tool"); } |
| 25 |
unsigned char priority() const override { return 95; } |
| 26 |
QAction* activateAction() const override { return m_activateAction; } |
| 27 |
void setIcon(bool darkTheme = false) override; |
| 28 |
|
| 29 |
void setMolecule(QtGui::Molecule* mol) override |
| 30 |
{ |
| 31 |
if (mol) |
| 32 |
m_molecule = mol->undoMolecule(); |
| 33 |
} |
| 34 |
|
| 35 |
void setEditMolecule(QtGui::RWMolecule* mol) override { m_molecule = mol; } |
| 36 |
|
| 37 |
void setGLWidget(QtOpenGL::GLWidget* widget) override { m_glWidget = widget; } |
| 38 |
|
| 39 |
void setGLRenderer(Rendering::GLRenderer* renderer) override |
| 40 |
{ |
| 41 |
m_renderer = renderer; |
| 42 |
} |
| 43 |
|
| 44 |
QWidget* toolWidget() const override { return nullptr; } |
| 45 |
|
| 46 |
QUndoCommand* mousePressEvent(QMouseEvent* e) override; |
| 47 |
QUndoCommand* mouseReleaseEvent(QMouseEvent* e) override; |
| 48 |
QUndoCommand* mouseMoveEvent(QMouseEvent* e) override; |
| 49 |
QUndoCommand* keyPressEvent(QKeyEvent* e) override; |
| 50 |
|
| 51 |
void draw(Rendering::GroupNode& node) override; |
| 52 |
|
| 53 |
private: |
| 54 |
void save(); |
| 55 |
|
| 56 |
QAction* m_activateAction; |
| 57 |
QtGui::RWMolecule* m_molecule; |
| 58 |
QtOpenGL::GLWidget* m_glWidget; |
| 59 |
Rendering::GLRenderer* m_renderer; |
| 60 |
bool m_selected; |
| 61 |
QtGui::RWAtom m_selectedAtom; |
| 62 |
QString m_text; |
| 63 |
}; |
| 64 |
|
| 65 |
} // namespace QtPlugins |
| 66 |
} // namespace Avogadro |
| 67 |
#endif |