54#include <OpenFlipper/BasePlugin/INIInterface.hh>
62#include <OpenFlipper/INIFile/INIFile.hh>
67#include <ACG/QtWidgets/QtColorChooserButton.hh>
69#include "widgets/ConversionDialog.hh"
90 Q_PLUGIN_METADATA(IID
"org.OpenFlipper.Plugins.Plugin-SelectionMeshObject")
106 void nodeVisibilityChanged(
int _identifier);
107 void setSlotDescription(QString _slotName, QString _slotDescription,
108 QStringList _parameters, QStringList _descriptions);
114 void log(
Logtype _type, QString _message);
115 void log(QString _message);
118 void addSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName);
119 void registerType(QString _handleName,
DataType _type);
120 void addPrimitiveType(QString _handleName, QString _name, QString _icon, SelectionInterface::PrimitiveType& _typeHandle);
121 void addSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, SelectionInterface::PrimitiveType _type = 0u);
122 void addSelectionParameters(QString _handleName, QWidget* _widget, QString _category, SelectionInterface::PrimitiveType _type = 0u);
124 void showToggleSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
126 void showLassoSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
127 void showVolumeLassoSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
128 void showSphereSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
129 void showClosestBoundarySelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
130 void showFloodFillSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
131 void showComponentsSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes);
133 void getActiveDataTypes(SelectionInterface::TypeList& _types);
134 void getActivePrimitiveType(SelectionInterface::PrimitiveType& _type);
135 void targetObjectsOnly(
bool& _targetsOnly);
137 void registerKeyShortcut(
int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier);
140 void deleteObject(
int _objectId);
141 void addEmptyObject(
DataType _type,
int& _id);
144 void scriptInfo(QString _functionName);
149 void loadSelection(
int _objId,
const QString& _filename);
154 void loadIniFile(
INIFile& _ini,
int _id);
155 void saveIniFile(
INIFile& _ini,
int _id);
158 void initializePlugin();
159 void pluginsInitialized();
160 void noguiSupported() {};
164 void slotToggleSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
166 void slotLassoSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
168 void slotSphereSelection(QMouseEvent* _event,
double _radius, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
170 void slotFloodFillSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
171 void slotComponentsSelection(QMouseEvent* _event, SelectionInterface::PrimitiveType _currentType,
bool _deselect);
172 void slotIndexSelection(
int _key);
195 return (QString(tr(
"MeshObjectSelection")));
199 return (QString(tr(
"Allows to select parts of Mesh Objects")));
236 return QString(
"1.0");
240 bool vertexTypeActive() {
241 SelectionInterface::PrimitiveType t = 0u;
242 emit getActivePrimitiveType(t);
247 bool edgeTypeActive() {
248 SelectionInterface::PrimitiveType t = 0u;
249 emit getActivePrimitiveType(t);
254 bool faceTypeActive() {
255 SelectionInterface::PrimitiveType t = 0u;
256 emit getActivePrimitiveType(t);
274 bool selectVertex(
int _objectId,
int _idx,
bool _fly_to_vertex);
359 void selectEdges(
int objectId,
IdList _edgeList,
const double _dihedral_angle_threshold = 0.0);
362 bool selectEdge(
int _objectId,
int _idx,
bool _fly_to_edge);
408 bool selectHalfedge(
int _objectId,
int _idx,
bool _fly_to_halfedge);
445 bool selectFace(
int _objectId,
int _idx,
bool _fly_to_face);
483 void lassoSelect(QRegion& _region, PrimitiveType _primitiveType,
bool _deselection);
486 void convertSelection(
const int& _objectId ,
const QString& _from,
const QString& _to,
bool _deselect);
489 void conversion(
const QString& _from,
const QString& _to,
bool _deselect);
492 template <
typename HandleT>
493 bool selectElement(
int _objectId, HandleT _handle,
bool _fly_to_element);
496 template <
typename MeshObjectT,
typename HandleT>
497 void getFlightData(MeshObjectT& _mesh_object, HandleT _handle,
525 template<
typename MeshT>
529 template<
typename MeshT>
533 template<
typename MeshT>
537 template<
typename MeshT>
539 typename MeshT::Point _hitpoint,
double _radius,
540 PrimitiveType _primitiveTypes,
bool _deselection);
543 template<
class MeshT>
545 QRegion *_region, PrimitiveType _primitiveTypes,
bool _deselection);
548 template<
class MeshT>
550 PrimitiveType _primitiveTypes,
bool _deselection);
553 template<
class MeshT>
555 double _maxAngle, PrimitiveType _primitiveTypes,
bool _deselection);
558 template<
typename MeshT>
560 ACG::Vec3d& _hit_point, PrimitiveType _primitiveType);
563 template<
class MeshT>
564 void colorizeSelection(
MeshT* _mesh, PrimitiveType _primitiveTypes,
int _red,
int _green,
int _blue,
int _alpha);
567 template<
class MeshT >
571 template<
class MeshT >
639 unsigned int _type,
bool _deselection,
ACG::GLState& _state) :
640 state_(_state), region_(_region), plugin_(_plugin), type_(_type), deselection_(_deselection) {};
656#if defined(INCLUDE_TEMPLATES) && !defined(MESHOBJECTSELECTIONPLUGINT_CC)
657#define MESHOBJECTSELECTIONPLUGINT_TEMPLATES
658#include "MeshObjectSelectionPluginT_impl.hh"
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Logtype
Log types for Message Window.
Interface class for backup handling.
Interface class from which all plugins have to be created.
Class for the handling of simple configuration files.
Interface class for Plugins which have to store information in ini files.
Keyboard Event Interface.
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.
void colorizeSelection(MeshT *_mesh, PrimitiveType _primitiveTypes, int _red, int _green, int _blue, int _alpha)
Colorize the selection.
void selectAllVertices(int _objectId)
Select all Vertices.
void deleteFaceSelection(int _objectId)
Delete face that are currently selected.
IdList getModelingVertices(int objectId)
Get a list of all modeling vertices.
double get_max_angle()
get max angle for flood fill selection
QString environmentHandle_
Handle to selection environment.
IdList convertVertexPairsToEdges(int _id, const IdList &_vertices)
Inverse of function above.
bool initializeOptionsWidget(QWidget *&_widget)
Initialize the Options Widget.
QPolygon lasso_2Dpoints_
Used for lasso selection tool.
void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers)
One of the previously registered keys has been pressed.
void selectVertices(int objectId, IdList _vertexList)
select given vertices
IdList getHandleVertices(int objectId)
Get a list of all handle vertices.
void invertFaceSelection(int objectId)
Invert the current face selection.
void clearHandleVertices(int objectId)
Clear handle Area.
void selectBoundaryHalfedges(int objectId)
Select boundary edges.
void clearModelingVertices(int objectId)
Clear Modeling Area.
void createMeshFromSelection(MeshT &_mesh, MeshT &_newMesh, PrimitiveType _primitiveType)
Create a new mesh from the selection.
void unselectEdges(int objectId, IdList _edgeList)
Unselect given Edges.
void selectBoundaryVertices(int _objectId)
Select all boundary vertices of the given object.
ParameterWidget * parameterWidget_
Handle to selection environment.
bool selectHalfedge(int _objectId, int _idx, bool _fly_to_halfedge)
Select halfedge with id _idx and maybe fly to it.
void slotLoadSelection(const INIFile &_file)
Load selection for specific objects in the scene.
void clearFaceSelection(int objectId)
Unselect all faces.
void selectAllFaces(int objectId)
Select all faces.
IdList getEdgeSelection(int objectId)
Return a list of all selected edges.
double get_dihedral_angle_threshold()
get dihedral angle threshold for edge selection
bool selectElement(int _objectId, HandleT _handle, bool _fly_to_element)
set dihedral angle threshold for edge selection
SelectionInterface::PrimitiveType vertexType_
Primitive type handles:
void selectAllHalfedges(int objectId)
Select all Halfedges.
void colorizeFaceSelection(int objectId, int r, int g, int b, int a)
Colorize the face selection.
void unselectFaces(int objectId, IdList _facesList)
Unselect given faces.
IdList getHalfedgeSelection(int objectId)
Return a list of all selected edges.
void invertHalfedgeSelection(int objectId)
Unselect all Halfedges.
void updateSlotDescriptions()
Set descriptions for local public slots.
void slotToggleSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a toggle selection.
ACG::Vec4f featureColor_
Handle to selection environment.
void invertVertexSelection(int _objectId)
Invert the current vertex selection.
double max_angle_
Handle to selection environment.
MeshObjectSelectionPlugin()
Default constructor.
IdList convertVertexPairsToHalfedges(int _id, const IdList &_vertices)
Inverse of function above.
double dihedral_angle_threshold_
Handle to selection environment.
ACG::Vec4f handleColor_
Handle to selection environment.
void floodFillSelection(MeshT *_mesh, int _objectId, uint _fh, double _maxAngle, PrimitiveType _primitiveTypes, bool _deselection)
Select all entities that are connected (and do not exceed the maximum dihedral angle)
void slotFloodFillSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a flood fill selection.
void toggleMeshSelection(int _objectId, MeshT *_mesh, uint _fh, ACG::Vec3d &_hit_point, PrimitiveType _primitiveType)
Toggle mesh selection.
void invertEdgeSelection(int objectId)
Unselect all Edges.
QtColorChooserButton * colorButtonFeature_
Handle to selection environment.
void slotComponentsSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a connected components selection.
void closestBoundarySelection(MeshT *_mesh, int _vh, PrimitiveType _primitiveTypes, bool _deselection)
Select all entities that are incident to closest boundary.
int createMeshFromFaceSelection(int _objectId)
Create a mesh containing the face selection of the given mesh.
void lassoSelect(QRegion &_region, PrimitiveType _primitiveType, bool _deselection)
Lasso selection tool.
ACG::Vec4f areaColor_
Handle to selection environment.
void setAllHandleVertices(int objectId)
Set all vertices to be part of the handle area.
int createMeshFromEdgeSelection(int _objectId)
Create a mesh containing the face selection of the given mesh.
bool selectVertex(int _objectId, int _idx, bool _fly_to_vertex)
select vertex with id _idx and maybe fly to it
void selectHalfedges(int objectId, IdList _vertexList)
Select given Halfedges.
void selectEdges(int objectId, IdList _edgeList, const double _dihedral_angle_threshold=0.0)
Select given Edges.
void clearHalfedgeSelection(int objectId)
Invert the current edge selection.
void shrinkVertexSelection(int _objectId)
Shrink the current vertex selection.
bool selectFace(int _objectId, int _idx, bool _fly_to_face)
Select face with id _idx and maybe fly to it.
QString description()
Return a description of what the plugin is doing.
void selectClosestBoundaryVertices(int _objectId, int _vertexId)
Select all vertices of the boundary close to the given vertex.
void conversion(const QString &_from, const QString &_to, bool _deselect)
Convert the selection on all target objects.
int createMeshFromVertexSelection(int _objectId)
set dihedral angle threshold for edge selection
void growVertexSelection(int _objectId)
Grow the current vertex selection.
void slotSphereSelection(QMouseEvent *_event, double _radius, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a sphere selection.
void set_dihedral_angle_threshold(const double _a)
set dihedral angle threshold for edge selection
void saveFlipperModelingSelection(int _objectId, QString _filename)
Save a selection in Flipper Selection Format.
void setDefaultColorValues()
sets the default color values for selection/handle/region/feature nodes for all objects of this type
void unselectHandleVertices(int objectId, IdList _vertexList)
Remove vertices from handle area.
void clearVertexSelection(int _objectId)
Unselect all vertices.
bool selectEdge(int _objectId, int _idx, bool _fly_to_edge)
Select edge with id _idx and maybe fly to it.
void slotClosestBoundarySelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a closest boundary selection.
void selectAllEdges(int objectId)
Select all Edges.
void selectModelingVertices(int objectId, IdList _vertexList)
Set vertices to be part of the modeling area.
void growFaceSelection(int objectId)
Grow the current face selection.
void clearEdgeSelection(int objectId)
Invert the current edge selection.
void traceEdgePath(int objectId, double threshold)
Trace Edge Path.
IdList getVertexSelection(int _objectId)
Return a list of all selected vertices.
void set_max_angle(const double _a)
set max angle for flood fill selection
IdList convertHalfedgesToVertexPairs(int _id, const IdList &_halfedges)
Convert halfedge ids to vertex pairs.
void update_regions(MeshT *_mesh)
Update face selection to correspond to the vertex selection.
void slotSaveSelection(INIFile &_file)
Save selection for all objects in the scene.
void loadFlipperModelingSelection(int _objectId, QString _filename)
Load a selection from an Flipper selection file for the given object.
bool volumeSelection(MeshT *_mesh, int _objectId, ACG::GLState &_state, QRegion *_region, PrimitiveType _primitiveTypes, bool _deselection)
Surface volume selection tool.
QtColorChooserButton * colorButtonSelection_
Options.
void updateColorValues()
Set descriptions for local public slots.
void selectFaces(int objectId, IdList _facesList)
Select given faces.
SelectionInterface::PrimitiveType edgeType_
Handle to selection environment.
void selectVerticesByValue(int _objectId, QString _component, bool _greater, double _value)
Select vertices by their value.
SelectionInterface::PrimitiveType halfedgeType_
Handle to selection environment.
QtColorChooserButton * colorButtonHandle_
Handle to selection environment.
void unselectModelingVertices(int objectId, IdList _vertexList)
Remove vertices from modeling area.
void colorizeHalfedgeSelection(int objectId, int r, int g, int b, int a)
Colorize the edge selection.
void selectBoundaryEdges(int objectId)
select boundary edges
void update_dihedral_angle_threshold_from_ui()
set dihedral angle threshold for edge selection
void addedEmptyObject(int _id)
An empty object has been added.
void getFlightData(MeshObjectT &_mesh_object, HandleT _handle, OpenMesh::Vec3d ¢er, OpenMesh::Vec3d &normal, bool &handle_valid)
set dihedral angle threshold for edge selection
IdList getFaceSelection(int objectId)
Return a list of all selected faces.
void componentsMeshSelection(MeshT *_mesh, int _objectId, uint _fh, ACG::Vec3d &_hit_point, PrimitiveType _primitiveType)
Connected component mesh selection.
bool deleteSelection(MeshT *_mesh, PrimitiveType _primitiveType)
Delete all selected elements of a mesh.
void setColorForSelection(const int _objectId, const PrimitiveType _primitiveType)
Set color for selection.
void selectHandleVertices(int objectId, IdList _vertexList)
Set vertices to be part of the handle area.
void colorizeEdgeSelection(int objectId, int r, int g, int b, int a)
Colorize the edge selection.
IdList convertEdgesToVertexPairs(int _id, const IdList &_edges)
Convert edge ids to vertex pairs.
void unselectVertices(int objectId, IdList _vertexList)
unselect given vertices
void slotLassoSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a lasso selection.
SelectionInterface::PrimitiveType allSupportedTypes_
Handle to selection environment.
void convertSelection(const int &_objectId, const QString &_from, const QString &_to, bool _deselect)
Convert the selection on one object.
void selectBoundaryFaces(int objectId)
Select all boundary faces of the given object.
ConversionDialog * conversionDialog_
Handle to selection environment.
void slotVolumeLassoSelection(QMouseEvent *_event, SelectionInterface::PrimitiveType _currentType, bool _deselect)
Called whenever the user performs a volume lasso selection.
void paintSphereSelection(MeshT *_mesh, int _objectId, int _target_idx, typename MeshT::Point _hitpoint, double _radius, PrimitiveType _primitiveTypes, bool _deselection)
Use the event to paint selection with a sphere.
ACG::Vec4f statusColor_
Handle to selection environment.
void slotSelectionOperation(QString _operation)
A specific operation is requested.
QtColorChooserButton * colorButtonArea_
Handle to selection environment.
void shrinkFaceSelection(int objectId)
Shrink the current face selection.
void slotMouseWheelEvent(QWheelEvent *event, std::string const &mode)
Wheel Event from main application.
void deleteVertexSelection(int _objectId)
Delete vertices and faces that are currently selected.
void colorizeVertexSelection(int _objectId, int _r, int _g, int _b, int a)
Colorize the vertex selection.
void deleteEdgeSelection(int _objectId)
Delete edges that are currently selected.
void conversionRequested()
Show selection conversion dialog.
~MeshObjectSelectionPlugin()
Default destructor.
QVector< QPoint > volumeLassoPoints_
Used for volume lasso tool.
void unselectHalfedges(int objectId, IdList _vertexList)
Unselect given Halfedges.
SelectionInterface::PrimitiveType faceType_
Handle to selection environment.
void setAllModelingVertices(int objectId)
Set all vertices to be part of the modeling area.
Interface class for receiving mouse events.
Options Dialog interface.
Interface class for exporting functions to python.
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.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.