Developer Documentation

MeshObjectInfoPlugin.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 //=============================================================================
45 //
46 // CLASS InfoMeshObjectPlugin
47 //
48 // Author: David Bommes <bommes@cs.rwth-aachen.de>
49 //=============================================================================
50
51 #ifndef INFOPLUGIN_HH
52 #define INFOPLUGIN_HH
53
54 //== INCLUDES =================================================================
55
56 #include <QObject>
57
58 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
59 #include <OpenFlipper/BasePlugin/InformationInterface.hh>
60 #include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
61 #include <OpenFlipper/BasePlugin/StatusbarInterface.hh>
62 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
63 #include <OpenFlipper/BasePlugin/PythonInterface.hh>
64 #include <OpenFlipper/common/Types.hh>
65 #include <ObjectTypes/PolyMesh/PolyMesh.hh>
66 #include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
67
68 #include "infoDialog.hh"
69 #include "infoBar.hh"
70
71 //== CLASS DEFINITION =========================================================
72
73
78 class InfoMeshObjectPlugin : public QObject, BaseInterface, InformationInterface, LoggingInterface, StatusbarInterface, LoadSaveInterface, PythonInterface
79 {
80 Q_OBJECT
81 Q_INTERFACES(BaseInterface)
82 Q_INTERFACES(InformationInterface)
83 Q_INTERFACES(LoggingInterface)
84 Q_INTERFACES(StatusbarInterface)
85 Q_INTERFACES(LoadSaveInterface)
86 Q_INTERFACES(PythonInterface)
87
88 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-MeshObjectInfo")
89
90 signals:
91 // BaseInterface
92 void setSlotDescription(QString _slotName, QString _slotDescription,
93 QStringList _parameters, QStringList _descriptions);
94
95 // LoggingInterface
96 void log(Logtype _type, QString _message);
97 void log(QString _message);
98
99 // StatusbarInterface
100 void addWidgetToStatusbar(QWidget* _widget);
101
102 private slots :
103
104 // BaseInterface
105 void initializePlugin();
106 void pluginsInitialized();
107 void slotObjectUpdated( int _identifier, const UpdateType& _type );
108 void slotObjectSelectionChanged( int _identifier );
109 void slotAllCleared();
110
111 // LoadSaveInterface
112 void objectDeleted( int _identifier );
113
114 void noguiSupported( ) {} ;
115
116 // InformationInterface
117 void slotInformationRequested(const QPoint _clickedPoint, DataType _type);
118 DataType supportedDataTypes();
119
120 void slotShowHistogram();
121
122 public :
123
124 // default constructor
125 InfoMeshObjectPlugin();
126
127 // default destructor
128 ~InfoMeshObjectPlugin();
129
131 QString name(){ return (QString("InfoMeshObject")); };
132
134 QString description() { return (QString(tr("Provides Information on Mesh Objects"))); };
135
136 private :
137 InfoDialog* info_;
138
139 InfoBar* infoBar_;
140
141 template< class MeshT >
142 void printMeshInfo( MeshT* _mesh, int _id, unsigned int _face, ACG::Vec3d& _hitPoint );
143
145 void updateData( int _identifier , const UpdateType& _type, const bool deleted);
146
147 //===========================================================================
150 //===========================================================================
151
152 public slots:
153
155 int vertexCount(int _id);
157 int edgeCount(int _id);
159 int faceCount(int _id);
161 int boundaryCount(int _id);
163 int componentCount(int _id);
164
166 int genus(int _id);
168 Vector cog(int _id);
170 Vector boundingBoxMin(int _id);
172 Vector boundingBoxMax(int _id);
174 Vector boundingBoxSize(int _id);
175
177 double edgeLength(int _id, int _edgeHandle);
179 double faceArea (int _id, int _faceHandle);
181 double aspectRatio(int _id, int _faceHandle);
183 int vertexValence (int _id, int _vertexHandle);
184
186 double minEdgeLength(int _id);
188 double maxEdgeLength(int _id);
190 double meanEdgeLength(int _id);
191
192 public slots:
193 QString version() { return QString("1.0"); };
194
195 private:
197 void setDescriptions();
198
200 template< class MeshT >
201 int getClosestVertexInFace(MeshT* _mesh, int _face_idx, ACG::Vec3d& _hitPoint);
202
204 template< class MeshT >
205 int getClosestEdgeInFace(MeshT* _mesh, int _face_idx, const ACG::Vec3d& _hitPoint);
206
208 template< class MeshT >
209 int getClosestVertexFromEdge(MeshT* _mesh, int _edge_idx, ACG::Vec3d& _hitPoint);
210
212 template< class MeshT >
213 void getEdgeLengths(MeshT* _mesh, double &min, double &max, double &mean);
214
216 bool getEdgeLengths(int _id, double &min, double &max, double &mean);
217
220 private:
221 BaseObjectData *lastPickedObject_;
222 int lastPickedObjectId_;
223 };
224
225 #endif //MOVEPLUGIN_HH
226
InfoMeshObjectPlugin::getClosestVertexFromEdge
int getClosestVertexFromEdge(MeshT *_mesh, int _edge_idx, ACG::Vec3d &_hitPoint)
Get closest vertex index from an edge.
Definition: MeshObjectInfoPlugin.cc:696
InfoMeshObjectPlugin::getClosestEdgeInFace
int getClosestEdgeInFace(MeshT *_mesh, int _face_idx, const ACG::Vec3d &_hitPoint)
Get closest edge index from a face.
Definition: MeshObjectInfoPlugin.cc:649
InfoMeshObjectPlugin::boundingBoxSize
Vector boundingBoxSize(int _id)
get the size of the bounding box
Definition: MeshObjectInfoScripting.cc:516
UpdateType
Update type class.
Definition: UpdateType.hh:60
TriangleMesh.hh
InfoMeshObjectPlugin::vertexCount
int vertexCount(int _id)
get total number of vertices for a given object
Definition: MeshObjectInfoScripting.cc:122
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:92
InfoMeshObjectPlugin::vertexValence
int vertexValence(int _id, int _vertexHandle)
get vertex valence
Definition: MeshObjectInfoScripting.cc:760
LoadSaveInterface
Interface for all plugins which want to Load or Save files and create Objects.
Definition: LoadSaveInterface.hh:59
StatusbarInterface
Control OpenFlippers status bar.
Definition: StatusbarInterface.hh:81
InformationInterface
Interface class for providing information on objects.
Definition: InformationInterface.hh:62
InfoMeshObjectPlugin::version
QString version()
set scripting slot descriptions
Definition: MeshObjectInfoPlugin.hh:193
InfoMeshObjectPlugin::boundingBoxMax
Vector boundingBoxMax(int _id)
get maximum bounding box point
Definition: MeshObjectInfoScripting.cc:466
LoggingInterface.hh
InformationInterface.hh
InfoMeshObjectPlugin::supportedDataTypes
DataType supportedDataTypes()
Get data type for information requests.
Definition: MeshObjectInfoPlugin.cc:112
InfoMeshObjectPlugin::genus
int genus(int _id)
get the genus of the given object
Definition: MeshObjectInfoScripting.cc:332
InfoMeshObjectPlugin::boundingBoxMin
Vector boundingBoxMin(int _id)
get minumum bounding box point
Definition: MeshObjectInfoScripting.cc:416
InfoMeshObjectPlugin::getClosestVertexInFace
int getClosestVertexInFace(MeshT *_mesh, int _face_idx, ACG::Vec3d &_hitPoint)
Get closest vertex index from a face.
Definition: MeshObjectInfoPlugin.cc:610
InfoMeshObjectPlugin::edgeCount
int edgeCount(int _id)
get total number of edges for a given object
Definition: MeshObjectInfoScripting.cc:164
InfoMeshObjectPlugin::getEdgeLengths
void getEdgeLengths(MeshT *_mesh, double &min, double &max, double &mean)
Get edge lengths.
Definition: MeshObjectInfoPlugin.cc:796
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:112
InfoBar
Definition: infoBar.hh:47
InfoMeshObjectPlugin::componentCount
int componentCount(int _id)
get the number of components for a given object
Definition: MeshObjectInfoScripting.cc:290
BaseInterface.hh
InfoMeshObjectPlugin::description
QString description()
Description of the Plugin.
Definition: MeshObjectInfoPlugin.hh:134
InfoMeshObjectPlugin::edgeLength
double edgeLength(int _id, int _edgeHandle)
get the length of an edge
Definition: MeshObjectInfoScripting.cc:567
InfoMeshObjectPlugin::faceArea
double faceArea(int _id, int _faceHandle)
get the area of a face
Definition: MeshObjectInfoScripting.cc:632
InfoMeshObjectPlugin::cog
Vector cog(int _id)
get the center of gravity
Definition: MeshObjectInfoScripting.cc:374
LoadSaveInterface.hh
InfoMeshObjectPlugin::slotInformationRequested
void slotInformationRequested(const QPoint _clickedPoint, DataType _type)
Show information dialog on clicked object.
Definition: MeshObjectInfoPlugin.cc:715
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:65
InfoMeshObjectPlugin::aspectRatio
double aspectRatio(int _id, int _faceHandle)
get the aspect ratio of a face
Definition: MeshObjectInfoScripting.cc:707
InfoMeshObjectPlugin::name
QString name()
Name of the Plugin.
Definition: MeshObjectInfoPlugin.hh:131
InfoMeshObjectPlugin
Plugin to visualize information about objects in the scene.
Definition: MeshObjectInfoPlugin.hh:78
InfoMeshObjectPlugin::boundaryCount
int boundaryCount(int _id)
get the number of boundaries for a given object
Definition: MeshObjectInfoScripting.cc:248
PythonInterface.hh
InfoMeshObjectPlugin::meanEdgeLength
double meanEdgeLength(int _id)
get the mean edge length
Definition: MeshObjectInfoScripting.cc:863
Types.hh
InfoMeshObjectPlugin::maxEdgeLength
double maxEdgeLength(int _id)
get the maximal edge length
Definition: MeshObjectInfoScripting.cc:846
DataType
Predefined datatypes.
Definition: DataTypes.hh:83
InfoMeshObjectPlugin::updateData
void updateData(int _identifier, const UpdateType &_type, const bool deleted)
Slot that updates the visualization.
Definition: MeshObjectInfoPlugin.cc:857
OpenMesh::VectorT
Definition: Vector11T.hh:83
InfoDialog
Definition: infoDialog.hh:46
InfoMeshObjectPlugin::minEdgeLength
double minEdgeLength(int _id)
get the minimal edge length
Definition: MeshObjectInfoScripting.cc:829
BaseObjectData
Definition: BaseObjectData.hh:102
StatusbarInterface.hh
InfoMeshObjectPlugin::setDescriptions
void setDescriptions()
set scripting slot descriptions
Definition: MeshObjectInfoScripting.cc:54
InfoMeshObjectPlugin::pluginsInitialized
void pluginsInitialized()
initialize the plugin
Definition: MeshObjectInfoPlugin.cc:85
InfoMeshObjectPlugin::faceCount
int faceCount(int _id)
get total number of faces for a given object
Definition: MeshObjectInfoScripting.cc:206
PythonInterface
Interface class for exporting functions to python.
Definition: PythonInterface.hh:58
PolyMesh.hh