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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 //=============================================================================
51 //
52 // CLASS InfoMeshObjectPlugin
53 //
54 // Author: David Bommes <bommes@cs.rwth-aachen.de>
55 //=============================================================================
56 
57 #ifndef INFOPLUGIN_HH
58 #define INFOPLUGIN_HH
59 
60 //== INCLUDES =================================================================
61 
62 #include <QObject>
63 
72 
73 #include "infoDialog.hh"
74 #include "infoBar.hh"
75 
76 //== CLASS DEFINITION =========================================================
77 
78 
84 {
85  Q_OBJECT
86  Q_INTERFACES(BaseInterface)
87  Q_INTERFACES(InformationInterface)
88  Q_INTERFACES(LoggingInterface)
89  Q_INTERFACES(StatusbarInterface)
90  Q_INTERFACES(LoadSaveInterface)
91 
92 #if QT_VERSION >= 0x050000
93  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-MeshObjectInfo")
94 #endif
95 
96  signals:
97  // BaseInterface
98  void setSlotDescription(QString _slotName, QString _slotDescription,
99  QStringList _parameters, QStringList _descriptions);
100 
101  // LoggingInterface
102  void log(Logtype _type, QString _message);
103  void log(QString _message);
104 
105  // StatusbarInterface
106  void addWidgetToStatusbar(QWidget* _widget);
107 
108  private slots :
109 
110  // BaseInterface
111  void initializePlugin();
112  void pluginsInitialized();
113  void slotObjectUpdated( int _identifier, const UpdateType& _type );
114  void slotObjectSelectionChanged( int _identifier );
115  void slotAllCleared();
116 
117  // LoadSaveInterface
118  void objectDeleted( int _identifier );
119 
120  void noguiSupported( ) {} ;
121 
122  // InformationInterface
123  void slotInformationRequested(const QPoint _clickedPoint, DataType _type);
125 
126  void slotShowHistogram();
127 
128  public :
129 
130  // default constructor
132 
133  // default destructor
135 
137  QString name(){ return (QString("InfoMeshObject")); };
138 
140  QString description() { return (QString(tr("Provides Information on Mesh Objects"))); };
141 
142  private :
143  InfoDialog* info_;
144 
145  InfoBar* infoBar_;
146 
147  template< class MeshT >
148  void printMeshInfo( MeshT* _mesh, int _id, unsigned int _face, ACG::Vec3d& _hitPoint );
149 
151  void updateData( int _identifier , const UpdateType& _type, const bool deleted);
152 
153 //===========================================================================
156 //===========================================================================
157 
158  public slots:
159 
161  int vertexCount(int _id);
163  int edgeCount(int _id);
165  int faceCount(int _id);
167  int boundaryCount(int _id);
169  int componentCount(int _id);
170 
172  int genus(int _id);
174  Vector cog(int _id);
176  Vector boundingBoxMin(int _id);
178  Vector boundingBoxMax(int _id);
180  Vector boundingBoxSize(int _id);
181 
183  double edgeLength(int _id, int _edgeHandle);
185  double faceArea (int _id, int _faceHandle);
187  double aspectRatio(int _id, int _faceHandle);
189  int vertexValence (int _id, int _vertexHandle);
190 
192  double minEdgeLength(int _id);
194  double maxEdgeLength(int _id);
196  double meanEdgeLength(int _id);
197 
198  public slots:
199  QString version() { return QString("1.0"); };
200 
201  private:
203  void setDescriptions();
204 
206  template< class MeshT >
207  int getClosestVertexInFace(MeshT* _mesh, int _face_idx, ACG::Vec3d& _hitPoint);
208 
210  template< class MeshT >
211  int getClosestEdgeInFace(MeshT* _mesh, int _face_idx, const ACG::Vec3d& _hitPoint);
212 
214  template< class MeshT >
215  int getClosestVertexFromEdge(MeshT* _mesh, int _edge_idx, ACG::Vec3d& _hitPoint);
216 
218  template< class MeshT >
219  void getEdgeLengths(MeshT* _mesh, double &min, double &max, double &mean);
220 
222  bool getEdgeLengths(int _id, double &min, double &max, double &mean);
223 
226  private:
227  BaseObjectData *lastPickedObject_;
228  int lastPickedObjectId_;
229 };
230 
231 #endif //MOVEPLUGIN_HH
232 
int getClosestVertexFromEdge(MeshT *_mesh, int _edge_idx, ACG::Vec3d &_hitPoint)
Get closest vertex index from an edge.
double edgeLength(int _id, int _edgeHandle)
get the length of an edge
void slotInformationRequested(const QPoint _clickedPoint, DataType _type)
Show information dialog on clicked object.
Predefined datatypes.
Definition: DataTypes.hh:96
double minEdgeLength(int _id)
get the minimal edge length
Logtype
Log types for Message Window.
int faceCount(int _id)
get total number of faces for a given object
QString name()
Name of the Plugin.
Plugin to visualize information about objects in the scene.
Control OpenFlippers status bar.
double maxEdgeLength(int _id)
get the maximal edge length
int boundaryCount(int _id)
get the number of boundaries for a given object
QString description()
Description of the Plugin.
Vector boundingBoxMax(int _id)
get maximum bounding box point
int componentCount(int _id)
get the number of components for a given object
Interface class from which all plugins have to be created.
Update type class.
Definition: UpdateType.hh:70
Interface for all Plugins which do logging to the logging window of the framework.
void setDescriptions()
set scripting slot descriptions
Vector boundingBoxMin(int _id)
get minumum bounding box point
int vertexValence(int _id, int _vertexHandle)
get vertex valence
double faceArea(int _id, int _faceHandle)
get the area of a face
double meanEdgeLength(int _id)
get the mean edge length
int vertexCount(int _id)
get total number of vertices for a given object
int getClosestVertexInFace(MeshT *_mesh, int _face_idx, ACG::Vec3d &_hitPoint)
Get closest vertex index from a face.
double aspectRatio(int _id, int _faceHandle)
get the aspect ratio of a face
int edgeCount(int _id)
get total number of edges for a given object
void getEdgeLengths(MeshT *_mesh, double &min, double &max, double &mean)
Get edge lengths.
DataType supportedDataTypes()
Get data type for information requests.
int getClosestEdgeInFace(MeshT *_mesh, int _face_idx, const ACG::Vec3d &_hitPoint)
Get closest edge index from a face.
Interface for all plugins which want to Load or Save files and create Objects.
void pluginsInitialized()
initialize the plugin
QString version()
set scripting slot descriptions
void updateData(int _identifier, const UpdateType &_type, const bool deleted)
Slot that updates the visualization.
Vector cog(int _id)
get the center of gravity
int genus(int _id)
get the genus of the given object
Interface class for providing information on objects.
Vector boundingBoxSize(int _id)
get the size of the bounding box