Developer Documentation
VolumeMeshSelectionPlugin.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#ifndef VOLUMEMESHSELECTIONPLUGIN_HH
43#define VOLUMEMESHSELECTIONPLUGIN_HH
44
45#include <QObject>
46
54#include <OpenFlipper/BasePlugin/INIInterface.hh>
59#include <OpenFlipper/INIFile/INIFile.hh>
60
63#ifdef ENABLE_TETRAHEDRALMESH_SUPPORT
65#endif
66
68
71{
72 Q_OBJECT
73 Q_INTERFACES(BaseInterface)
74 Q_INTERFACES(KeyInterface)
75 Q_INTERFACES(INIInterface)
76 Q_INTERFACES(BackupInterface)
77 Q_INTERFACES(LoggingInterface)
78 Q_INTERFACES(ScriptInterface)
79 Q_INTERFACES(SelectionInterface)
80
81 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-SelectionVolumeMesh")
82
83public:
84
87
90
91 friend class SelectVolumeAction;
92
94 void set_max_angle(const double _a);
96 double get_max_angle();
97
98signals:
99
100 // BaseInterface
101 void updateView() override;
102 void updatedObject(int, const UpdateType&) override;
103 void nodeVisibilityChanged(int _identifier) override;
104 void setSlotDescription(QString _slotName, QString _slotDescription,
105 QStringList _parameters, QStringList _descriptions) override;
106
107 // LoggingInterface
108 void log(Logtype _type, QString _message) override;
109 void log(QString _message) override;
110
111 // ScriptInterface
112 void scriptInfo(QString _functionName);
113
114 // SelectionInterface
115 void addSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName) override;
116 void registerType(QString _handleName, DataType _type) override;
117 void addPrimitiveType(QString _handleName, QString _name, QString _icon, SelectionInterface::PrimitiveType& _typeHandle) override;
118 void addSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u) override;
119 void addSelectionParameters(QString _handleName, QWidget* _widget, QString _category, SelectionInterface::PrimitiveType _type = 0u) override;
120
121 void showToggleSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes) override;
122
123 void showVolumeLassoSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes) override;
124 void showFloodFillSelectionMode(QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes) override;
125 void addCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
126 SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier) override;
127
128 void getActiveDataTypes(SelectionInterface::TypeList& _types) override;
129 void getActivePrimitiveType(SelectionInterface::PrimitiveType& _type) override;
130 void targetObjectsOnly(bool& _targetsOnly) override;
131
132 void registerKeyShortcut(int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier) override;
133
134private slots:
135
136 // INIInterface
137 void loadIniFile(INIFile& _ini, int _id) override;
138 void saveIniFile(INIFile& _ini, int _id) override;
139
140 // BaseInterface
141 void initializePlugin() override;
142 void pluginsInitialized() override;
143 void noguiSupported() override {};
144
145 // SelectionInterface
146 void slotSelectionOperation(QString _operation) override;
147 void slotToggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect) override;
148
149 void slotVolumeLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect) override;
150 void slotFloodFillSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType, bool _deselect) override;
151 void slotCustomSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, QString _customIdentifier, bool _deselect) override;
152
153 void slotLoadSelection(const INIFile& _file) override;
154 void slotSaveSelection(INIFile& _file) override;
155
156 void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers) override;
157
158public slots:
159
160 // SelectionInterface
161 void loadSelection(int _objId, const QString& _filename) override;
162
163public:
164
165 // BaseInterface
166 QString name() override {
167 return (QString(tr("VolumeMesh Selection")));
168 };
169
170 QString description() override {
171 return (QString(tr("Allows to select VolumeMeshes")));
172 };
173
174 //===========================================================================
177 //===========================================================================
178private:
179
182
185public slots:
186
187 QString version() override {
188 return QString("1.0");
189 };
190
191 //===========================================================================
194 //===========================================================================
195
197 bool vertexTypeActive();
198
200 bool edgeTypeActive();
201
203 bool faceTypeActive();
204
206 bool cellTypeActive();
207
208 //===========================================================================
209
211 void selectAllVertices(int _objectId);
212
214 void deselectAllVertices(int _objectId);
215
217 void invertVertexSelection(int _objectId);
218
220 void selectVertices(int _objectId, const IdList& _ids, bool _deselect = false);
221
223 IdList getVertexSelection(int _objectId);
224
226 void deleteSelectedVertices(int _objectId, bool _preserveManifoldness = true);
227
228 //===========================================================================
229
231 void selectAllEdges(int _objectId);
232
234 void deselectAllEdges(int _objectId);
235
237 void invertEdgeSelection(int _objectId);
238
240 void selectEdges(int _objectId, const IdList& _ids, bool _deselect = false);
241
243 IdList getEdgeSelection(int _objectId);
244
246 void deleteSelectedEdges(int _objectId, bool _preserveManifoldness = true);
247
248 //===========================================================================
249
251 void selectAllHalfEdges(int _objectId);
252
254 void deselectAllHalfEdges(int _objectId);
255
257 void invertHalfEdgeSelection(int _objectId);
258
260 void selectHalfEdges(int _objectId, const IdList& _ids, bool _deselect = false);
261
263 IdList getHalfEdgeSelection(int _objectId);
264
265 //===========================================================================
266
268 void selectAllFaces(int _objectId);
269
271 void deselectAllFaces(int _objectId);
272
274 void invertFaceSelection(int _objectId);
275
277 void selectFaces(int _objectId, const IdList& _ids, bool _deselect = false);
278
280 IdList getFaceSelection(int _objectId);
281
283 void deleteSelectedFaces(int _objectId, bool _preserveManifoldness = true);
284
285 //===========================================================================
286
288 void selectAllHalfFaces(int _objectId);
289
291 void deselectAllHalfFaces(int _objectId);
292
294 void invertHalfFaceSelection(int _objectId);
295
297 void selectHalfFaces(int _objectId, const IdList& _ids, bool _deselect = false);
298
300 IdList getHalfFaceSelection(int _objectId);
301
302 //===========================================================================
303
305 void selectAllCells(int _objectId);
306
308 void deselectAllCells(int _objectId);
309
311 void invertCellSelection(int _objectId);
312
314 void selectCells(int _objectId, const IdList& _ids, bool _deselect = false);
315
317 IdList getCellSelection(int _objectId);
318
320 void deleteSelectedCells(int _objectId, bool _preserveManifoldness = true);
321
324 //===========================================================================
327 //===========================================================================
328
329private:
331 template<class MeshT>
332 bool volumeSelection(MeshT* _mesh, ACG::GLState& _state, QRegion *_region,
333 PrimitiveType _primitiveTypes, bool _deselection);
334
336 template<class MeshT>
337 void floodFillSelection(MeshT* _mesh, uint _fh, double _maxAngle,
338 PrimitiveType _primitiveTypes, bool _deselection);
339
340 // Get orthogonal orientation of neighboring cell
342 const OpenVolumeMesh::CellHandle& _ch2, unsigned char _firstOrthDirection, const HexahedralMesh* _mesh) const;
343
344 // Get face shared by two adjacent cells
345 typedef std::pair<OpenVolumeMesh::HalfFaceHandle,OpenVolumeMesh::HalfFaceHandle> HFPair;
347 const OpenVolumeMesh::CellHandle& _ch2, const HexahedralMesh* _mesh) const;
348
349
352
355
358
360 PrimitiveType vertexType_;
361 PrimitiveType edgeType_;
362 PrimitiveType faceType_;
363 PrimitiveType cellType_;
364
365 PrimitiveType allSupportedTypes_;
367
369
371
373 QVector<QPoint> volumeLassoPoints_;
374
375 // Store last picked cell for sheet selection
378 std::map<OpenVolumeMesh::CellHandle, unsigned char> orientationMap_;
379
382};
383
386{
387public:
388 SelectVolumeAction(QRegion&_region, VolumeMeshSelectionPlugin* _plugin,
389 unsigned int _type, bool _deselection, ACG::GLState& _state)
390 : state_(_state)
391 , region_(_region)
392 , plugin_(_plugin)
393 , type_(_type)
394 , deselection_(_deselection)
395 {
396 }
397
398 void enter(BaseNode* /*_node*/) {}
399 void leave(BaseNode* /*_node*/) {}
400
401 bool operator()(BaseNode* _node);
402
403private:
404 ACG::GLState& state_;
405 QRegion& region_;
407 unsigned int type_;
408 bool deselection_;
409};
410//=============================================================================
411#if defined(INCLUDE_TEMPLATES) && !defined(VOLUMEMESHSELECTIONPLUGINT_CC)
412#define VOLUMEMESHSELECTIONPLUGINT_TEMPLATES
413#include "VolumeMeshSelectionPluginT_impl.hh"
414#endif
415
416//=============================================================================
417#endif // VOLUMEMESHSELECTIONPLUGIN_HH defined
418//=============================================================================
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 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.
Update type class.
Definition: UpdateType.hh:59
void slotCustomSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, QString _customIdentifier, bool _deselect) override
Called whenever the user performs a custom selection.
bool vertexTypeActive()
Is vertex type active? (for use in plugins that need mesh selection)
PrimitiveType vertexType_
Primitive type handles:
void invertFaceSelection(int _objectId)
Invert face selection.
void invertCellSelection(int _objectId)
Invert cell selection.
void selectHalfFaces(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific half-faces of a volume mesh.
void deleteSelectedVertices(int _objectId, bool _preserveManifoldness=true)
Delete selected vertices from mesh.
bool edgeTypeActive()
Is vertex type active? (for use in plugins that need mesh selection)
void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers) override
One of the previously registered keys has been pressed.
void floodFillSelection(MeshT *_mesh, uint _fh, double _maxAngle, PrimitiveType _primitiveTypes, bool _deselection)
Select all entities that are connected (and do not exceed the maximum dihedral angle)
void selectAllEdges(int _objectId)
Select all edges of a volume mesh.
QString name() override
Return a name for the plugin.
void selectFaces(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific faces of a volume mesh.
unsigned char lastPickedOrientation_
Handle to selection environment.
bool faceTypeActive()
Is face type active? (for use in plugins that need mesh selection)
void slotVolumeLassoSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect) override
Called whenever the user performs a volume lasso selection.
IdList getCellSelection(int _objectId)
Get current cell selection.
PrimitiveType floodFillSupportedTypes_
Handle to selection environment.
void selectAllHalfEdges(int _objectId)
Select all half-edges of a volume mesh.
PrimitiveType cellType_
Handle to selection environment.
QString description() override
Return a description of what the plugin is doing.
IdList getHalfFaceSelection(int _objectId)
Get current half-face selection.
void selectAllCells(int _objectId)
Select all cells of a volume mesh.
void deleteSelectedCells(int _objectId, bool _preserveManifoldness=true)
Delete selected cells from mesh.
IdList getFaceSelection(int _objectId)
Get current face selection.
VolMeshParamWidget * parameterWidget_
Handle to selection environment.
void deleteSelectedEdges(int _objectId, bool _preserveManifoldness=true)
Delete selected edges from mesh.
std::map< OpenVolumeMesh::CellHandle, unsigned char > orientationMap_
Handle to selection environment.
bool volumeSelection(MeshT *_mesh, ACG::GLState &_state, QRegion *_region, PrimitiveType _primitiveTypes, bool _deselection)
Surface volume selection tool.
void set_max_angle(const double _a)
set max angle for flood fill selection
void invertEdgeSelection(int _objectId)
Invert edge selection.
bool cellTypeActive()
Is cell type active? (for use in plugins that need mesh selection)
QString columnSelectionHandle_
Handle to selection environment.
void deleteSelectedFaces(int _objectId, bool _preserveManifoldness=true)
Delete selected faces from mesh.
void selectVertices(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific vertices of a volume mesh.
VolumeMeshSelectionPlugin()
Default constructor.
void selectAllHalfFaces(int _objectId)
Select all half-faces of a volume mesh.
~VolumeMeshSelectionPlugin()
Default destructor.
void slotToggleSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect) override
Called whenever the user performs a toggle selection.
HFPair getCommonFace(const OpenVolumeMesh::CellHandle &_ch1, const OpenVolumeMesh::CellHandle &_ch2, const HexahedralMesh *_mesh) const
Handle to selection environment.
IdList getHalfEdgeSelection(int _objectId)
Get current half-edge selection.
void selectHalfEdges(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific half-edges of a volume mesh.
void selectAllVertices(int _objectId)
Select all vertices of a volume mesh.
void slotSaveSelection(INIFile &_file) override
Save selection for all objects in the scene.
void invertHalfFaceSelection(int _objectId)
Invert half-face selection.
void deselectAllCells(int _objectId)
Deselect all cells of a volume mesh.
void selectEdges(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific edges of a volume mesh.
PrimitiveType edgeType_
Handle to selection environment.
double max_angle_
Handle to selection environment.
std::pair< OpenVolumeMesh::HalfFaceHandle, OpenVolumeMesh::HalfFaceHandle > HFPair
Handle to selection environment.
QString sheetSelectionHandle_
Handle to selection environment.
void invertVertexSelection(int _objectId)
Invert vertex selection.
void deselectAllVertices(int _objectId)
Deselect all vertices of a volume mesh.
double get_max_angle()
get max angle for flood fill selection
void deselectAllHalfEdges(int _objectId)
Deselect all half-edges of a volume mesh.
void invertHalfEdgeSelection(int _objectId)
Invert half-edge selection.
unsigned char getOrthogonalOrientationOfNeighborCell(const OpenVolumeMesh::CellHandle &_ch1, const OpenVolumeMesh::CellHandle &_ch2, unsigned char _firstOrthDirection, const HexahedralMesh *_mesh) const
Handle to selection environment.
PrimitiveType faceType_
Handle to selection environment.
IdList getEdgeSelection(int _objectId)
Get current edge selection.
void slotSelectionOperation(QString _operation) override
A specific operation is requested.
OpenVolumeMesh::CellHandle lastPickedCell_
Handle to selection environment.
void deselectAllFaces(int _objectId)
Deselect all faces of a volume mesh.
void deselectAllEdges(int _objectId)
Deselect all edges of a volume mesh.
void slotFloodFillSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect) override
Called whenever the user performs a flood fill selection.
void slotLoadSelection(const INIFile &_file) override
Load selection for specific objects in the scene.
IdList getVertexSelection(int _objectId)
Get current vertex selection.
void selectCells(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific cells of a volume mesh.
void selectAllFaces(int _objectId)
Select all faces of a volume mesh.
OpenVolumeMesh::StatusAttrib * getStatus(int _objectId)
Handle to selection environment.
QVector< QPoint > volumeLassoPoints_
Keep volume lasso points.
PrimitiveType allSupportedTypes_
Handle to selection environment.
void updateSlotDescriptions()
Set slot descriptions for scripting functions.
void deselectAllHalfFaces(int _objectId)
Deselect all half-faces of a volume mesh.
QString environmentHandle_
Handle to selection environment.