Developer Documentation

OVMPropertyVisualizer.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 #ifndef OVM_PROPERTY_VISUALIZER_HH
46 #define OVM_PROPERTY_VISUALIZER_HH
47
48 #include "PropertyVisualizer/PropertyVisualizer.hh"
49
50 #include <ObjectTypes/VolumeMeshObject/VolumeMeshObject.hh>
51
52 #include <OpenFlipper/BasePlugin/PluginFunctionsViewControls.hh>
53
54 #include <ObjectTypes/VolumeMeshObject/VolumeMeshDrawModesContainer.hh>
55
56 #include <ACG/QtWidgets/QtHistogramWidget.hh>
57
58 #include <iostream>
59
60 template <typename MeshT>
61 class OVMPropertyVisualizer: public PropertyVisualizer{
62
63 public:
64 OVMPropertyVisualizer(MeshT* _mesh, int objectID, PropertyInfo _propertyInfo)
65 : PropertyVisualizer(_propertyInfo),
66 mesh(_mesh),
67 mObjectID(objectID),
68 drawModes()
69 {}
70
71 virtual ~OVMPropertyVisualizer(){ clear(); }
72
74 virtual void visualize(bool _setDrawMode, QWidget* _widget);
75
82 virtual void removeProperty(){ emit log("Removing properties not yet implemented for OpenVolumeMeshs."); }
83
85 virtual void duplicateProperty(){ /*implemented by subclass*/}
86
88 virtual void clear();
89
90 virtual QString getPropertyText(unsigned int index)=0;
91
93 unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint);
94
95 protected slots:
96 template <typename Type>
97 void showHistogram(ACG::QtWidgets::QtHistogramWidget *histogramWidget);
98
99 protected:
100 MeshT* mesh;
101
102 virtual void visualizeFaceProp(bool _setDrawMode = true);
103 virtual void visualizeEdgeProp(bool _setDrawMode = true);
104 virtual void visualizeHalfedgeProp(bool _setDrawMode = true);
105 virtual void visualizeVertexProp(bool _setDrawMode = true);
106 virtual void visualizeCellProp(bool _setDrawMode = true);
107 virtual void visualizeHalffaceProp(bool _setDrawMode = true);
108
109 template<typename PropType>
110 void duplicateProperty_stage1();
111
112 template <typename InnerType>
113 QString getPropertyText_(unsigned int index);
114
115 virtual void setCellPropertyFromText(unsigned int index, QString text);
116 virtual void setFacePropertyFromText(unsigned int index, QString text);
117 virtual void setHalffacePropertyFromText(unsigned int index, QString text);
118 virtual void setEdgePropertyFromText(unsigned int index, QString text);
119 virtual void setHalfedgePropertyFromText(unsigned int index, QString text);
120 virtual void setVertexPropertyFromText(unsigned int index, QString text);
121
122 virtual void setPropertyFromText(unsigned int index, QString text);
123
124 virtual int getEntityCount();
125
126 virtual QString getHeader();
127
128 unsigned int getClosestCellId(unsigned int _face, ACG::Vec3d& _hitPoint);
129 unsigned int getClosestFaceId(unsigned int _face, ACG::Vec3d& _hitPoint);
130 unsigned int getClosestHalffaceId(unsigned int _face, ACG::Vec3d& _hitPoint);
131 unsigned int getClosestEdgeId(unsigned int _face, ACG::Vec3d& _hitPoint);
132 unsigned int getClosestHalfedgeId(unsigned int _face, ACG::Vec3d& _hitPoint);
133 unsigned int getClosestVertexId(unsigned int _face, ACG::Vec3d& _hitPoint);
134
135 int mObjectID;
136
137 VolumeMeshDrawModesContainer drawModes;
138
139 private:
140
141 template<typename Property>
142 class CopyProperty
143 {
144 public:
145 CopyProperty(Property& p1, const Property& p2, MeshT*& mesh) :
146 p1(p1), p2(p2), mesh(mesh) {}
147
148 template<typename PrimitiveHandleT>
149 inline void operator() (const PrimitiveHandleT &pr) {
150 p1[pr] = p2[pr];
151 }
152
153 private:
154 Property &p1;
155 const Property &p2;
156 MeshT*& mesh;
157 };
158 };
159
160 #define CALLS_TO_VISUALIZE_PROP(Classname, Template, PropType) \
161 template <Template> \
162 void Classname::visualizeCellProp(bool _setDrawMode) \
163 {\
164 OpenVolumeMesh::CellPropertyT<PropType> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_cell_property<PropType>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());\
165 visualizeProp(prop, OVMPropertyVisualizer<MeshT>::mesh->cells_begin(), OVMPropertyVisualizer<MeshT>::mesh->cells_end());\
166 if (_setDrawMode)\
167 {\
168 VolumeMeshObject<MeshT>* object;\
169 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);\
170 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.cellsColoredPerCell);\
171 }\
172 }\
173 template <Template>\
174 void Classname::visualizeFaceProp(bool _setDrawMode)\
175 {\
176 OpenVolumeMesh::FacePropertyT<PropType> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_face_property<PropType>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());\
177 visualizeProp(prop, OVMPropertyVisualizer<MeshT>::mesh->faces_begin(), OVMPropertyVisualizer<MeshT>::mesh->faces_end());\
178 if (_setDrawMode)\
179 {\
180 VolumeMeshObject<MeshT>* object;\
181 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);\
182 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.facesColoredPerFace);\
183 }\
184 }\
185 template <Template>\
186 void Classname::visualizeHalffaceProp(bool _setDrawMode)\
187 {\
188 OpenVolumeMesh::HalfFacePropertyT<PropType> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_halfface_property<PropType>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());\
189 visualizeProp(prop, OVMPropertyVisualizer<MeshT>::mesh->halffaces_begin(), OVMPropertyVisualizer<MeshT>::mesh->halffaces_end());\
190 if (_setDrawMode)\
191 {\
192 VolumeMeshObject<MeshT>* object;\
193 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);\
194 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halffacesColoredPerHalfface);\
195 }\
196 }\
197 template <Template>\
198 void Classname::visualizeEdgeProp(bool _setDrawMode)\
199 {\
200 OpenVolumeMesh::EdgePropertyT<PropType> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_edge_property<PropType>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());\
201 visualizeProp(prop, OVMPropertyVisualizer<MeshT>::mesh->edges_begin(), OVMPropertyVisualizer<MeshT>::mesh->edges_end());\
202 if (_setDrawMode)\
203 {\
204 VolumeMeshObject<MeshT>* object;\
205 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);\
206 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.edgesColoredPerEdge);\
207 }\
208 }\
209 template <Template>\
210 void Classname::visualizeHalfedgeProp(bool _setDrawMode)\
211 {\
212 OpenVolumeMesh::HalfEdgePropertyT<PropType> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_halfedge_property<PropType>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());\
213 visualizeProp(prop, OVMPropertyVisualizer<MeshT>::mesh->halfedges_begin(), OVMPropertyVisualizer<MeshT>::mesh->halfedges_end());\
214 if (_setDrawMode)\
215 {\
216 VolumeMeshObject<MeshT>* object;\
217 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);\
218 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halfedgesColoredPerHalfedge);\
219 }\
220 }\
221 template <Template>\
222 void Classname::visualizeVertexProp(bool _setDrawMode)\
223 {\
224 OpenVolumeMesh::VertexPropertyT<PropType> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_vertex_property<PropType>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());\
225 visualizeProp(prop, OVMPropertyVisualizer<MeshT>::mesh->vertices_begin(), OVMPropertyVisualizer<MeshT>::mesh->vertices_end());\
226 if (_setDrawMode)\
227 {\
228 VolumeMeshObject<MeshT>* object;\
229 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);\
230 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.verticesColored);\
231 }\
232 }\
233
234
235 #if defined(INCLUDE_TEMPLATES) && !defined(OVM_PROPERTY_VISUALIZER_CC)
236 #include "OVMPropertyVisualizerT_impl.hh"
237 #endif
238
239 #endif /* OVM_PROPERTY_VISUALIZER_HH */
240
241
ACG::QtWidgets::QtHistogramWidget
Definition: QtHistogramWidget.hh:57
OVMPropertyVisualizer::getPropertyText
virtual QString getPropertyText(unsigned int index)=0
Returns the value of a property in text form.
OVMPropertyVisualizer::CopyProperty
Definition: OVMPropertyVisualizer.hh:142
OVMPropertyVisualizer::getClosestPrimitiveId
unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint)
Returns the ID of the closest primitive.
Definition: OVMPropertyVisualizerT_impl.hh:144
OVMPropertyVisualizer::clear
virtual void clear()
Clears a property.
Definition: OVMPropertyVisualizerT_impl.hh:347
OVMPropertyVisualizer::visualize
virtual void visualize(bool _setDrawMode, QWidget *_widget)
Visualizes a property.
Definition: OVMPropertyVisualizerT_impl.hh:203
OVMPropertyVisualizer
Definition: OVMPropertyVisualizer.hh:61
OVMPropertyVisualizer::getHeader
virtual QString getHeader()
Returns the header for saving.
Definition: OVMPropertyVisualizerT_impl.hh:131
OVMPropertyVisualizer::removeProperty
virtual void removeProperty()
Should remove the property.
Definition: OVMPropertyVisualizer.hh:82
PropertyVisualizer
This class vizualizes a property.
Definition: PropertyVisualizer.hh:77
OpenMesh::VectorT
Definition: Vector11T.hh:83
OVMPropertyVisualizer::setPropertyFromText
virtual void setPropertyFromText(unsigned int index, QString text)
Returns the value of a property in text form.
Definition: OVMPropertyVisualizerT_impl.hh:97
OVMPropertyVisualizer::getEntityCount
virtual int getEntityCount()
Returns the number of entities.
Definition: OVMPropertyVisualizerT_impl.hh:114
PropertyVisualizer::PropertyVisualizer
PropertyVisualizer(const PropertyInfo &_propertyInfo)
Constructor.
Definition: PropertyVisualizer.hh:91
VolumeMeshDrawModesContainer
This class provides easy access to DrawModes supported by OpenVolumeMesh.
Definition: VolumeMeshDrawModesContainer.hh:50
OVMPropertyVisualizer::duplicateProperty
virtual void duplicateProperty()
Duplicates a property.
Definition: OVMPropertyVisualizer.hh:85
PropertyInfo
Cellection of information about a property.
Definition: Utils.hh:109