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