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
60template <typename MeshT>
62
63public:
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
95protected slots:
96 template <typename Type>
97 void showHistogram(ACG::QtWidgets::QtHistogramWidget *histogramWidget);
98
99protected:
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
138
139private:
140
141 template<typename Property>
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) \
161template <Template> \
162void 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());\
166 if (_setDrawMode)\
167 {\
168 VolumeMeshObject<MeshT>* object;\
169 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);\
170 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.cellsColoredPerCell);\
171 }\
172}\
173template <Template>\
174void 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());\
178 if (_setDrawMode)\
179 {\
180 VolumeMeshObject<MeshT>* object;\
181 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);\
182 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.facesColoredPerFace);\
183 }\
184}\
185template <Template>\
186void 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());\
190 if (_setDrawMode)\
191 {\
192 VolumeMeshObject<MeshT>* object;\
193 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);\
194 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halffacesColoredPerHalfface);\
195 }\
196}\
197template <Template>\
198void 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());\
202 if (_setDrawMode)\
203 {\
204 VolumeMeshObject<MeshT>* object;\
205 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);\
206 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.edgesColoredPerEdge);\
207 }\
208}\
209template <Template>\
210void 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());\
214 if (_setDrawMode)\
215 {\
216 VolumeMeshObject<MeshT>* object;\
217 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);\
218 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halfedgesColoredPerHalfedge);\
219 }\
220}\
221template <Template>\
222void 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());\
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
virtual QString getPropertyText(unsigned int index)=0
Returns the value of a property in text form.
virtual void removeProperty()
Should remove the property.
virtual void clear()
Clears a property.
virtual int getEntityCount()
Returns the number of entities.
virtual void setPropertyFromText(unsigned int index, QString text)
Returns the value of a property in text form.
virtual void duplicateProperty()
Duplicates a property.
virtual void visualize(bool _setDrawMode, QWidget *_widget)
Visualizes a property.
virtual QString getHeader()
Returns the header for saving.
unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint)
Returns the ID of the closest primitive.
Cellection of information about a property.
Definition: Utils.hh:109
This class vizualizes a property.
PropertyVisualizer(const PropertyInfo &_propertyInfo)
Constructor.
This class provides easy access to DrawModes supported by OpenVolumeMesh.