Developer Documentation

PolyLineSelectionPlugin.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $Author$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50 #ifndef POLYLINESELECTIONPLUGIN_HH
51 #define POLYLINESELECTIONPLUGIN_HH
52
53 #include <QObject>
54
55 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
56 #include <OpenFlipper/BasePlugin/KeyInterface.hh>
57 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
58 #include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
59 #include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
60 #include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
61 #include <OpenFlipper/BasePlugin/BackupInterface.hh>
62 #include <OpenFlipper/BasePlugin/INIInterface.hh>
63 #include <OpenFlipper/BasePlugin/ScriptInterface.hh>
64 #include <OpenFlipper/BasePlugin/SelectionInterface.hh>
65 #include <OpenFlipper/common/Types.hh>
66 #include <OpenFlipper/BasePlugin/PluginFunctions.hh>
67 #include <OpenFlipper/INIFile/INIFile.hh>
68
69 #include <ObjectTypes/PolyLine/PolyLine.hh>
70
71 class PolyLineSelectionPlugin : public QObject, BaseInterface, KeyInterface,
72 INIInterface, BackupInterface, LoggingInterface, ScriptInterface, SelectionInterface
73 {
74 Q_OBJECT
75 Q_INTERFACES(BaseInterface)
76 Q_INTERFACES(KeyInterface)
77 Q_INTERFACES(INIInterface)
78 Q_INTERFACES(BackupInterface)
79 Q_INTERFACES(LoggingInterface)
80 Q_INTERFACES(ScriptInterface)
81 Q_INTERFACES(SelectionInterface)
82
83 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-SelectionPolyLine")
84
85 public:
86
88 PolyLineSelectionPlugin();
89
91 ~PolyLineSelectionPlugin();
92
93 signals:
94
95 // BaseInterface
96 void updateView();
97 void updatedObject(int, const UpdateType&);
98 void nodeVisibilityChanged(int _identifier);
99 void setSlotDescription(QString _slotName, QString _slotDescription,
100 QStringList _parameters, QStringList _descriptions);
101
102 // LoggingInterface
103 void log(Logtype _type, QString _message);
104 void log(QString _message);
105
106 // ScriptInterface
107 void scriptInfo(QString _functionName);
108
109 // SelectionInterface
110 void addSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName);
111 void registerType(QString _handleName, DataType _type);
112 void addPrimitiveType(QString _handleName, QString _name, QString _icon, SelectionInterface::PrimitiveType& _typeHandle);
113 void addSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u);
114 void showToggleSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
115 void showVolumeLassoSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
116
117 void getActiveDataTypes(SelectionInterface::TypeList& _types);
118 void getActivePrimitiveType(SelectionInterface::PrimitiveType& _type);
119 void targetObjectsOnly(bool& _targetsOnly);
120
121 void registerKeyShortcut(int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier);
122
123 private slots:
124
125 // INIInterface
126 void loadIniFile(INIFile& _ini, int _id);
127 void saveIniFile(INIFile& _ini, int _id);
128
129 // BaseInterface
130 void initializePlugin();
131 void pluginsInitialized();
132 void noguiSupported() {};
133
134 // SelectionInterface
135 void slotSelectionOperation(QString _operation);
136 void slotToggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
137 void slotVolumeLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
138
139 void slotLoadSelection(const INIFile& _file);
140 void slotSaveSelection(INIFile& _file);
141
142 void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers);
143
144 public slots:
145
146 // SelectionInterface
147 void loadSelection(int _objId, const QString& _filename);
148
149 public:
150
151 // BaseInterface
152 QString name() {
153 return (QString(tr("PolyLine Selection")));
154 };
155
156 QString description() {
157 return (QString(tr("Allows to select PolyLines")));
158 };
159
160 //===========================================================================
163 //===========================================================================
164 private:
165
167 void updateSlotDescriptions();
168
171 public slots:
172
173 QString version() {
174 return QString("1.0");
175 };
176
177 //===========================================================================
180 //===========================================================================
181
183 void selectAllVertices(int _objectId);
184
186 void deselectAllVertices(int _objectId);
187
189 void invertVertexSelection(int _objectId);
190
192 void deleteSelectedVertices(int _objectId);
193
195 void selectVertices(int _objectId, const IdList& _ids, bool _deselect = false);
196
198 IdList getVertexSelection(int _objectId);
199
200 //===========================================================================
201
203 void selectAllEdges(int _objectId);
204
206 void deselectAllEdges(int _objectId);
207
209 void invertEdgeSelection(int _objectId);
210
212 void deleteSelectedEdges(int _objectId);
213
215 void selectEdges(int _objectId, const IdList& _ids, bool _deselect = false);
216
218 IdList getEdgeSelection(int _objectId);
219
222 //===========================================================================
225 //===========================================================================
226
227 private:
228
230 QString environmentHandle_;
231
233 PrimitiveType vertexType_;
234 PrimitiveType edgeType_;
235
236 PrimitiveType allSupportedTypes_;
237
239 QVector<QPoint> volumeLassoPoints_;
240
243 };
244
245 //=============================================================================
246 #endif // POLYLINESELECTIONPLUGIN_HH defined
247 //=============================================================================
SelectionInterface.hh
PolyLineSelectionPlugin::getEdgeSelection
IdList getEdgeSelection(int _objectId)
Get current edge selection.
Definition: PolyLineSelectionFunctions.cc:360
PolyLineSelectionPlugin::slotSelectionOperation
void slotSelectionOperation(QString _operation)
A specific operation is requested.
Definition: PolyLineSelectionPlugin.cc:174
ScriptInterface.hh
PolyLineSelectionPlugin::name
QString name()
Return a name for the plugin.
Definition: PolyLineSelectionPlugin.hh:152
ToolboxInterface.hh
PolyLineSelectionPlugin::invertEdgeSelection
void invertEdgeSelection(int _objectId)
Invert edge selection.
Definition: PolyLineSelectionFunctions.cc:246
PolyLineSelectionPlugin::deselectAllVertices
void deselectAllVertices(int _objectId)
Deselect all vertices of a skeleton.
Definition: PolyLineSelectionFunctions.cc:67
LoadSaveInterface.hh
PolyLineSelectionPlugin::selectAllEdges
void selectAllEdges(int _objectId)
Select all edges of a skeleton.
Definition: PolyLineSelectionFunctions.cc:206
PolyLineSelectionPlugin::deselectAllEdges
void deselectAllEdges(int _objectId)
Deselect all edges of a skeleton.
Definition: PolyLineSelectionFunctions.cc:226
PolyLineSelectionPlugin::slotToggleSelection
void slotToggleSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a toggle selection.
Definition: PolyLineSelectionPlugin.cc:273
PolyLineSelectionPlugin::selectEdges
void selectEdges(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific edges of a skeleton.
Definition: PolyLineSelectionFunctions.cc:327
PolyLineSelectionPlugin::deleteSelectedVertices
void deleteSelectedVertices(int _objectId)
Delete selected vertices.
Definition: PolyLineSelectionFunctions.cc:111
PolyLineSelectionPlugin::description
QString description()
Return a description of what the plugin is doing.
Definition: PolyLineSelectionPlugin.hh:156
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:92
PolyLineSelectionPlugin::slotVolumeLassoSelection
void slotVolumeLassoSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a volume lasso selection.
Definition: PolyLineSelectionPlugin.cc:329
DataType
Predefined datatypes.
Definition: DataTypes.hh:83
PluginFunctions.hh
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:112
LoggingInterface.hh
PolyLineSelectionPlugin::slotSaveSelection
void slotSaveSelection(INIFile &_file)
Save selection for all objects in the scene.
Definition: PolyLineSelectionPlugin.cc:477
PolyLineSelectionPlugin::allSupportedTypes_
PrimitiveType allSupportedTypes_
Handle to selection environment.
Definition: PolyLineSelectionPlugin.hh:236
IdList
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:179
PolyLine.hh
ToolbarInterface.hh
PolyLineSelectionPlugin::updateSlotDescriptions
void updateSlotDescriptions()
Set slot descriptions for scripting functions.
Definition: PolyLineSelectionPlugin.cc:144
PolyLineSelectionPlugin::selectAllVertices
void selectAllVertices(int _objectId)
Select all vertices of a skeleton.
Definition: PolyLineSelectionFunctions.cc:47
PolyLineSelectionPlugin
Definition: PolyLineSelectionPlugin.hh:71
SelectionInterface
Interface for all plugins which want to use selection functions.
Definition: SelectionInterface.hh:67
UpdateType
Update type class.
Definition: UpdateType.hh:60
PolyLineSelectionPlugin::volumeLassoPoints_
QVector< QPoint > volumeLassoPoints_
Keep volume lasso points.
Definition: PolyLineSelectionPlugin.hh:239
PolyLineSelectionPlugin::selectVertices
void selectVertices(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific vertices of a skeleton.
Definition: PolyLineSelectionFunctions.cc:149
PolyLineSelectionPlugin::slotLoadSelection
void slotLoadSelection(const INIFile &_file)
Load selection for specific objects in the scene.
Definition: PolyLineSelectionPlugin.cc:447
PolyLineSelectionPlugin::deleteSelectedEdges
void deleteSelectedEdges(int _objectId)
Delete selected edges.
Definition: PolyLineSelectionFunctions.cc:269
PolyLineSelectionPlugin::invertVertexSelection
void invertVertexSelection(int _objectId)
Invert vertex selection.
Definition: PolyLineSelectionFunctions.cc:87
PolyLineSelectionPlugin::environmentHandle_
QString environmentHandle_
Handle to selection environment.
Definition: PolyLineSelectionPlugin.hh:230
PolyLineSelectionPlugin::slotKeyShortcutEvent
void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers)
One of the previously registered keys has been pressed.
Definition: PolyLineSelectionPlugin.cc:496
KeyInterface
Keyboard Event Interface.
Definition: KeyInterface.hh:59
INIInterface
Interface class for Plugins which have to store information in ini files.
Definition: INIInterface.hh:60
INIFile
Class for the handling of simple configuration files.
Definition: INIFile.hh:99
PolyLineSelectionPlugin::getVertexSelection
IdList getVertexSelection(int _objectId)
Get current vertex selection.
Definition: PolyLineSelectionFunctions.cc:181
ScriptInterface
Interface for all Plugins which provide scriptable Functions.
Definition: ScriptInterface.hh:58
PolyLineSelectionPlugin::~PolyLineSelectionPlugin
~PolyLineSelectionPlugin()
Default destructor.
Definition: PolyLineSelectionPlugin.cc:80
Types.hh
PolyLineSelectionPlugin::PolyLineSelectionPlugin
PolyLineSelectionPlugin()
Default constructor.
Definition: PolyLineSelectionPlugin.cc:72
PolyLineSelectionPlugin::edgeType_
PrimitiveType edgeType_
Handle to selection environment.
Definition: PolyLineSelectionPlugin.hh:234
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:65
BaseInterface.hh
BackupInterface
Interface class for backup handling.
Definition: BackupInterface.hh:59
BackupInterface.hh
PolyLineSelectionPlugin::vertexType_
PrimitiveType vertexType_
Primitive type handles:
Definition: PolyLineSelectionPlugin.hh:233
KeyInterface.hh