Developer Documentation

ObjectSelectionPlugin.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 OBJECTSELECTIONPLUGIN_HH
51 #define OBJECTSELECTIONPLUGIN_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 class ObjectSelectionPlugin : public QObject, BaseInterface, KeyInterface, LoadSaveInterface,
70 INIInterface, BackupInterface, LoggingInterface, ScriptInterface, SelectionInterface
71 {
72 Q_OBJECT
73 Q_INTERFACES(BaseInterface)
74 Q_INTERFACES(KeyInterface)
75 Q_INTERFACES(LoadSaveInterface)
76 Q_INTERFACES(INIInterface)
77 Q_INTERFACES(BackupInterface)
78 Q_INTERFACES(LoggingInterface)
79 Q_INTERFACES(ScriptInterface)
80 Q_INTERFACES(SelectionInterface)
81
82 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-SelectionObject")
83
84 public:
85
87 ObjectSelectionPlugin();
88
90 ~ObjectSelectionPlugin();
91
92 signals:
93
94 // BaseInterface
95 void updateView();
96 void updatedObject(int, const UpdateType&);
97 void nodeVisibilityChanged(int _identifier);
98 void setSlotDescription(QString _slotName, QString _slotDescription,
99 QStringList _parameters, QStringList _descriptions);
100
101 // LoggingInterface
102 void log(Logtype _type, QString _message);
103 void log(QString _message);
104
105 // ScriptInterface
106 void scriptInfo(QString _functionName);
107
108 // SelectionInterface
109 void addSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName);
110 void registerType(QString _handleName, DataType _type);
111 void addPrimitiveType(QString _handleName, QString _name, QString _icon, SelectionInterface::PrimitiveType& _typeHandle);
112 void addSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u);
113 void showToggleSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
114 void showVolumeLassoSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes);
115
116 void getActiveDataTypes(SelectionInterface::TypeList& _types);
117 void getActivePrimitiveType(SelectionInterface::PrimitiveType& _type);
118 void targetObjectsOnly(bool& _targetsOnly);
119
120 void registerKeyShortcut(int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier);
121
122 // LoadSaveInterface
123 void deleteObject(int _id);
124
125 private slots:
126
127 // INIInterface
128 void loadIniFile(INIFile& _ini, int _id);
129 void saveIniFile(INIFile& _ini, int _id);
130
131 // BaseInterface
132 void initializePlugin();
133 void pluginsInitialized();
134 void noguiSupported() {};
135
136 // SelectionInterface
137 void slotSelectionOperation(QString _operation);
138 void slotToggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
139 void slotVolumeLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect);
140
141 void slotLoadSelection(const INIFile& _file);
142 void slotSaveSelection(INIFile& _file);
143
144 void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers);
145
146 public slots:
147
148 // SelectionInterface
149 void loadSelection(int _objId, const QString& _filename);
150
151 public:
152
153 // BaseInterface
154 QString name() {
155 return (QString(tr("Object Selection")));
156 };
157
158 QString description() {
159 return (QString(tr("Allows to select objects")));
160 };
161
162 //===========================================================================
165 //===========================================================================
166 private:
167
169 void updateSlotDescriptions();
170
173 public slots:
174
175 QString version() {
176 return QString("1.0");
177 };
178
179 //===========================================================================
182 //===========================================================================
183
185 void selectAllObjects();
186
188 void selectObjects(IdList _list);
189
191 void deselectAllObjects();
192
194 void invertObjectSelection();
195
197 void deleteSelectedObjects();
198
200 IdList getObjectSelection();
201
204 //===========================================================================
207 //===========================================================================
208
209 private:
210
212 QString environmentHandle_;
213
215 PrimitiveType objectType_;
216
218 QVector<QPoint> volumeLassoPoints_;
219
222 };
223
224 //=============================================================================
225 #endif // OBJECTSELECTIONPLUGIN_HH defined
226 //=============================================================================
INIInterface
Interface class for Plugins which have to store information in ini files.
Definition: INIInterface.hh:60
ObjectSelectionPlugin::slotLoadSelection
void slotLoadSelection(const INIFile &_file)
Load selection for specific objects in the scene.
Definition: ObjectSelectionPlugin.cc:283
UpdateType
Update type class.
Definition: UpdateType.hh:60
ObjectSelectionPlugin::objectType_
PrimitiveType objectType_
Primitive type handles:
Definition: ObjectSelectionPlugin.hh:215
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:92
LoadSaveInterface
Interface for all plugins which want to Load or Save files and create Objects.
Definition: LoadSaveInterface.hh:59
ObjectSelectionPlugin::slotToggleSelection
void slotToggleSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a toggle selection.
Definition: ObjectSelectionPlugin.cc:170
ObjectSelectionPlugin::deselectAllObjects
void deselectAllObjects()
Deselect all objects.
Definition: ObjectSelectionFunctions.cc:76
ScriptInterface
Interface for all Plugins which provide scriptable Functions.
Definition: ScriptInterface.hh:58
ObjectSelectionPlugin::~ObjectSelectionPlugin
~ObjectSelectionPlugin()
Default destructor.
Definition: ObjectSelectionPlugin.cc:72
LoggingInterface.hh
ObjectSelectionPlugin::ObjectSelectionPlugin
ObjectSelectionPlugin()
Default constructor.
Definition: ObjectSelectionPlugin.cc:66
PluginFunctions.hh
ObjectSelectionPlugin::environmentHandle_
QString environmentHandle_
Handle to selection environment.
Definition: ObjectSelectionPlugin.hh:212
ObjectSelectionPlugin::slotVolumeLassoSelection
void slotVolumeLassoSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a volume lasso selection.
Definition: ObjectSelectionPlugin.cc:200
ObjectSelectionPlugin::deleteSelectedObjects
void deleteSelectedObjects()
Delete selected objects.
Definition: ObjectSelectionFunctions.cc:100
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:112
ObjectSelectionPlugin::name
QString name()
Return a name for the plugin.
Definition: ObjectSelectionPlugin.hh:154
ObjectSelectionPlugin::description
QString description()
Return a description of what the plugin is doing.
Definition: ObjectSelectionPlugin.hh:158
ObjectSelectionPlugin::slotSaveSelection
void slotSaveSelection(INIFile &_file)
Save selection for all objects in the scene.
Definition: ObjectSelectionPlugin.cc:309
BaseInterface.hh
ObjectSelectionPlugin::updateSlotDescriptions
void updateSlotDescriptions()
Set slot descriptions for scripting functions.
Definition: ObjectSelectionPlugin.cc:126
KeyInterface.hh
ObjectSelectionPlugin::slotKeyShortcutEvent
void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers)
One of the previously registered keys has been pressed.
Definition: ObjectSelectionPlugin.cc:327
IdList
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:179
ToolbarInterface.hh
LoadSaveInterface.hh
ObjectSelectionPlugin::selectObjects
void selectObjects(IdList _list)
Select specified objects.
Definition: ObjectSelectionFunctions.cc:62
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:65
ToolboxInterface.hh
ObjectSelectionPlugin::selectAllObjects
void selectAllObjects()
Select all objects.
Definition: ObjectSelectionFunctions.cc:50
SelectionInterface.hh
ObjectSelectionPlugin::slotSelectionOperation
void slotSelectionOperation(QString _operation)
A specific operation is requested.
Definition: ObjectSelectionPlugin.cc:145
BackupInterface.hh
ObjectSelectionPlugin
Definition: ObjectSelectionPlugin.hh:69
Types.hh
KeyInterface
Keyboard Event Interface.
Definition: KeyInterface.hh:59
SelectionInterface
Interface for all plugins which want to use selection functions.
Definition: SelectionInterface.hh:67
DataType
Predefined datatypes.
Definition: DataTypes.hh:83
ObjectSelectionPlugin::invertObjectSelection
void invertObjectSelection()
Invert object selection.
Definition: ObjectSelectionFunctions.cc:88
ObjectSelectionPlugin::getObjectSelection
IdList getObjectSelection()
Get selected objects.
Definition: ObjectSelectionFunctions.cc:127
BackupInterface
Interface class for backup handling.
Definition: BackupInterface.hh:59
ObjectSelectionPlugin::volumeLassoPoints_
QVector< QPoint > volumeLassoPoints_
Keep volume lasso points.
Definition: ObjectSelectionPlugin.hh:218
INIFile
Class for the handling of simple configuration files.
Definition: INIFile.hh:99
ScriptInterface.hh