Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SplatCloudObjectSelectionPlugin.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 //================================================================
51 //
52 // CLASS SplatCloudObjectSelectionPlugin
53 //
54 //================================================================
55 
56 
57 #ifndef SPLATCLOUDOBJECTSELECTIONPLUGIN_HH
58 #define SPLATCLOUDOBJECTSELECTIONPLUGIN_HH
59 
60 
61 //== INCLUDES ====================================================
62 
63 
64 #include <QObject>
65 
71 #include <OpenFlipper/BasePlugin/INIInterface.hh>
74 
77 #include <OpenFlipper/INIFile/INIFile.hh>
78 
80 
81 
82 //== CLASS DEFINITION ============================================
83 
84 
86 {
87  Q_OBJECT
88  Q_INTERFACES( BaseInterface )
89  Q_INTERFACES( BackupInterface )
90  Q_INTERFACES( LoggingInterface )
91  Q_INTERFACES( SelectionInterface )
92  Q_INTERFACES( LoadSaveInterface )
93  Q_INTERFACES( INIInterface )
94  Q_INTERFACES( KeyInterface )
95  Q_INTERFACES( ScriptInterface )
96 
97 #if QT_VERSION >= 0x050000
98  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-SelectionSplatCloudObject")
99 #endif
100 
101 public:
104 
105  friend class SelectVolumeAction;
106 
107 signals:
108 
109  //-- Base Interface --
110  void updateView();
111  void updatedObject( int _objectId, const UpdateType& _type );
112  void nodeVisibilityChanged( int _objectId );
113  void setSlotDescription( QString _slotName, QString _slotDescription, QStringList _parameters, QStringList _descriptions );
114 
115  //-- Backup Interface --
116  void createBackup( int _objectId, QString _name, UpdateType _type = UPDATE_ALL );
117 
118  //-- Logging Interface --
119  void log( QString _message );
120  void log( Logtype _type, QString _message );
121 
122  //-- Selection Interface --
123  void addSelectionEnvironment( QString _modeName, QString _description, QString _icon, QString &_handleName );
124  void registerType( QString _handleName, DataType _type );
125  void addPrimitiveType( QString _handleName, QString _name, QString _icon, SelectionInterface::PrimitiveType &_typeHandle );
126  void addSelectionOperations( QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u );
127 
128  void showToggleSelectionMode ( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
129  void showSphereSelectionMode ( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
130  void showLassoSelectionMode ( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
131  void showVolumeLassoSelectionMode( QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes );
132 
133  void getActiveDataTypes( SelectionInterface::TypeList &_types );
134  void getActivePrimitiveType( SelectionInterface::PrimitiveType &_type );
135  void targetObjectsOnly( bool &_targetsOnly );
136 
137  void registerKeyShortcut( int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier );
138 
139  //-- LoadSave Interface --
140  void deleteObject( int _objectId );
141 
142  //-- Script Interface --
143  void scriptInfo( QString _functionName );
144 
145 public slots:
146 
147  //-- Selection Interface --
148  void loadSelection( int _objectId, const QString &_filename );
149 
150 private slots:
151 
152  //-- INI Interface --
153  void loadIniFile( INIFile &_ini, int _objectId );
154  void saveIniFile( INIFile &_ini, int _objectId );
155 
156  //-- Base Interface --
157  void initializePlugin();
158  void pluginsInitialized();
159  void noguiSupported() { };
160 
161  //-- Selection Interface --
162  void slotSelectionOperation( QString _operation );
163 
164  void slotToggleSelection ( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect );
165  void slotSphereSelection ( QMouseEvent *_event, double _radius, SelectionInterface::PrimitiveType _currentType, bool _deselect );
166  void slotLassoSelection ( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect );
167  void slotVolumeLassoSelection( QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect );
168 
169  void slotLoadSelection( const INIFile &_file );
170  void slotSaveSelection( INIFile &_file );
171 
172  void slotKeyShortcutEvent( int _key, Qt::KeyboardModifiers _modifiers );
173 
174 public:
175 
176  //-- Base Interface --
177  QString name() { return QString( tr("SplatCloud Object Selection" ) ); }
178  QString description() { return QString( tr("Allows to select parts of SplatCloud Objects") ); }
179 
180  //===========================================================================
183  //===========================================================================
184 private:
185 
187  void updateSlotDescriptions();
188 
190  void setColorForSelection( const int _objectId, const PrimitiveType _primitiveType );
191 
194  //===========================================================================
197  //===========================================================================
198 private slots:
199 
202 public slots:
203 
204  QString version() { return QString( "1.0" ); }
205 
206  // Is vertex type active? (for use in plugins that need SplatCloud selection)
207  bool vertexTypeActive()
208  {
209  SelectionInterface::PrimitiveType t;
210  emit getActivePrimitiveType( t );
211  return (t & vertexType_) > 0;
212  }
213 
214  //===========================================================================
217  //===========================================================================
218 public slots:
219 
220  //==========================================
221  // VERTEX OPERATIONS
222  //==========================================
223 
224  void selectVertices ( int _objectId, IdList _vertexList );
225  void unselectVertices ( int _objectId, IdList _vertexList );
226  void selectAllVertices ( int _objectId );
227  void clearVertexSelection ( int _objectId );
228  void invertVertexSelection ( int _objectId );
229  IdList getVertexSelection ( int _objectId );
230  void deleteVertexSelection ( int _objectId );
231  void colorizeVertexSelection( int _objectId, int _r, int _g, int _b, int _a );
232 
233  //===========================================================================
234 
235  void lassoSelect( QRegion &_region, PrimitiveType _primitiveType, bool _deselection );
236 
239  //===========================================================================
242  //===========================================================================
243 
244 private:
245 
246  bool splatCloudDeleteSelection ( SplatCloud *_splatCloud, PrimitiveType _primitiveType );
247  void splatCloudToggleSelection ( SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, PrimitiveType _primitiveType );
248  void splatCloudSphereSelection ( SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, double _radius, PrimitiveType _primitiveTypes, bool _deselection );
249  bool splatCloudVolumeSelection ( SplatCloud *_splatCloud, ACG::GLState &_state, QRegion *_region, PrimitiveType _primitiveTypes, bool _deselection );
250  void splatCloudColorizeSelection ( SplatCloud *_splatCloud, PrimitiveType _primitiveTypes, int _r, int _g, int _b, int _a );
251 
254  //===========================================================================
257  //===========================================================================
258 
259 private:
260 
262  SelectionInterface::PrimitiveType vertexType_;
263  SelectionInterface::PrimitiveType allSupportedTypes_;
264  QPolygon lasso_2Dpoints_;
265  QVector<QPoint> volumeLassoPoints_;
266 
268 };
269 
270 
272 class SelectVolumeAction
273 {
274 public:
275 
276  SelectVolumeAction( QRegion &_region, SplatCloudObjectSelectionPlugin *_plugin, unsigned int _type, bool _deselection, ACG::GLState &_state ) :
277  state_ ( _state ),
278  region_ ( _region ),
279  plugin_ ( _plugin ),
280  type_ ( _type ),
281  deselection_( _deselection )
282  { }
283 
284  void enter( BaseNode * /*_node*/ ) { }
285  void leave( BaseNode * /*_node*/ ) { }
286 
287  bool operator()( BaseNode *_node );
288 
289 private:
290  ACG::GLState &state_;
291  QRegion &region_;
293  unsigned int type_;
294  bool deselection_;
295 };
296 
297 
298 //================================================================
299 
300 
301 #endif // SPLATCLOUDOBJECTSELECTIONPLUGIN_HH
void slotSphereSelection(QMouseEvent *_event, double _radius, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a sphere selection.
Interface class from which all plugins have to be created.
QString description()
Return a description of what the plugin is doing.
SelectionInterface::PrimitiveType vertexType_
Primitive type handle.
Keyboard Event Interface.
Definition: KeyInterface.hh:76
SelectionInterface::PrimitiveType allSupportedTypes_
Primitive type handle.
Interface class for Plugins which have to store information in ini files.
Definition: INIInterface.hh:81
Logtype
Log types for Message Window.
void lassoSelect(QRegion &_region, PrimitiveType _primitiveType, bool _deselection)
Lasso selection tool.
bool splatCloudVolumeSelection(SplatCloud *_splatCloud, ACG::GLState &_state, QRegion *_region, PrimitiveType _primitiveTypes, bool _deselection)
Surface volume selection tool.
void clearVertexSelection(int _objectId)
Unselect all vertices.
Update type class.
Definition: UpdateType.hh:70
QPolygon lasso_2Dpoints_
Used for lasso selection tool.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void slotSaveSelection(INIFile &_file)
Save selection for all objects in the scene.
Interface for all plugins which want to use selection functions.
void colorizeVertexSelection(int _objectId, int _r, int _g, int _b, int _a)
Colorize the vertex selection.
Interface for all Plugins which do logging to the logging window of the framework.
void splatCloudColorizeSelection(SplatCloud *_splatCloud, PrimitiveType _primitiveTypes, int _r, int _g, int _b, int _a)
Colorize the selection.
bool splatCloudDeleteSelection(SplatCloud *_splatCloud, PrimitiveType _primitiveType)
Delete all selected elements of a SplatCloud.
Traverse the scenegraph and call the selection function for all mesh nodes.
void setColorForSelection(const int _objectId, const PrimitiveType _primitiveType)
Set color for selection.
void selectVertices(int _objectId, IdList _vertexList)
Select given vertices.
QString environmentHandle_
Handle to selection environment.
void slotSelectionOperation(QString _operation)
A specific operation is requested.
IdList getVertexSelection(int _objectId)
Return a list of all selected vertices.
Class for the handling of simple configuration files.
Definition: INIFile.hh:105
void slotToggleSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a toggle selection.
bool operator()(BaseNode *_node)
Traverse the scenegraph and call the selection function for all mesh nodes.
QString name()
Return a name for the plugin.
void splatCloudToggleSelection(SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, PrimitiveType _primitiveType)
Toggle SplatCloud selection.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:192
void updateSlotDescriptions()
Set descriptions for local public slots.
Interface for all Plugins which provide scriptable Functions.
void slotVolumeLassoSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a volume lasso selection.
void invertVertexSelection(int _objectId)
Invert the current vertex selection.
Interface for all plugins which want to Load or Save files and create Objects.
void deleteVertexSelection(int _objectId)
Delete vertices that are currently selected.
void splatCloudSphereSelection(SplatCloud *_splatCloud, uint _index, ACG::Vec3d &_hit_point, double _radius, PrimitiveType _primitiveTypes, bool _deselection)
Use the event to paint selection with a sphere.
void slotLoadSelection(const INIFile &_file)
Load selection for specific objects in the scene.
QVector< QPoint > volumeLassoPoints_
Used for volume lasso tool.
Interface class for backup handling.
void unselectVertices(int _objectId, IdList _vertexList)
Unselect given vertices.
void selectAllVertices(int _objectId)
Select all vertices.
Predefined datatypes.
Definition: DataTypes.hh:96
void slotLassoSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a lasso selection.
void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers)
One of the previously registered keys has been pressed.