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