Developer Documentation
OVMPropertyModelT.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#ifndef OVM_PROPERTY_MODEL_H
45#define OVM_PROPERTY_MODEL_H
46
47#include "OVMPropertyVisualizer.hh"
48#include "OVMPropertyVisualizerBoolean.hh"
49#include "OVMPropertyVisualizerDouble.hh"
50#include "OVMPropertyVisualizerInteger.hh"
51#include "OVMPropertyVisualizerMatrix3x3.hh"
52#include "OVMPropertyVisualizerVector.hh"
53#include "OVMPropertyVisualizerVectorFieldDifference.hh"
54
55#include <OpenVolumeMesh/Core/Properties/PropertyStorageBase.hh>
56
57#include "../Utils.hh"
58
59#include "Widgets/LoadSaveWidget.hh"
60#include "Widgets/PickWidget.hh"
61
62#include <vector>
63
64#include "../Utils.hh"
65
66#define PROP_VIS "PropertyVisualization"
67
68#include "OVMPropertyModelSubclass.hh"
69
71
72template<typename MeshT>
74
75public:
76 OVMPropertyModel(MeshT* mesh, int objectID, QObject *parent = 0);
77 virtual ~OVMPropertyModel(){}
78
79 virtual void updateWidget(const QModelIndexList& selectedIndices);
80
82 void resetPicking();
83
85 virtual void pickProperty();
86
88 virtual void pickModeChanged(const std::string& _mode);
89
91 virtual void mouseEvent(QMouseEvent* _event);
92
93 virtual bool parseHeader(QString header, PropertyVisualizer*& propVis, unsigned int& n);
94
95 static bool isBoolType(const PropertyInfo& propInfo);
96 static bool isBoolType(const TypeInfoWrapper& typeInfo);
97 static bool isIntType(const PropertyInfo& propInfo);
98 static bool isIntType(const TypeInfoWrapper& typeInfo);
99 static bool isDoubleType(const PropertyInfo& propInfo);
100 static bool isDoubleType(const TypeInfoWrapper& typeInfo);
101 static bool isUnsignedIntType(const PropertyInfo& propInfo);
102 static bool isUnsignedIntType(const TypeInfoWrapper& typeInfo);
103 static bool isVec3dType(const PropertyInfo& propInfo);
104 static bool isVec3dType(const TypeInfoWrapper& typeInfo);
105 static bool isVec3dOVMType(const PropertyInfo& propInfo);
106 static bool isVec3dOVMType(const TypeInfoWrapper& typeInfo);
107 static bool isVec3fType(const PropertyInfo& propInfo);
108 static bool isVec3fType(const TypeInfoWrapper& typeInfo);
109 static bool isVectorType(const PropertyInfo& propInfo);
110 static bool isVectorType(const TypeInfoWrapper& typeInfo);
111 static bool isVectorOVMType(const PropertyInfo& propInfo);
112 static bool isVectorOVMType(const TypeInfoWrapper& typeInfo);
113 static bool isMatrix3x3Type(const PropertyInfo& propInfo);
114 static bool isMatrix3x3Type(const TypeInfoWrapper& typeInfo);
115
116#define DECLARE_PROPTYPES(primitive) \
117 static const TypeInfoWrapper proptype_##primitive##_bool; \
118 static const TypeInfoWrapper proptype_##primitive##_int; \
119 static const TypeInfoWrapper proptype_##primitive##_uint; \
120 static const TypeInfoWrapper proptype_##primitive##_double; \
121 static const TypeInfoWrapper proptype_##primitive##_Vec3d; \
122 static const TypeInfoWrapper proptype_##primitive##_Vec3dOVM; \
123 static const TypeInfoWrapper proptype_##primitive##_Vec3f; \
124 static const TypeInfoWrapper proptype_##primitive##_Matrix3x3d;
125
126 DECLARE_PROPTYPES(Cell)
127 DECLARE_PROPTYPES(Face)
128 DECLARE_PROPTYPES(HalfFace)
129 DECLARE_PROPTYPES(Edge)
130 DECLARE_PROPTYPES(HalfEdge)
131 DECLARE_PROPTYPES(Vertex)
132#undef DECLARE_PROPTYPES
133
134protected:
135
136 virtual QString getLoadFilenameFilter();
137 virtual QString getSaveFilenameFilter(unsigned int propId);
138
139private:
140
142 virtual void combine();
143
145 bool combinable(PropertyVisualizer* propertyVisualizer1, PropertyVisualizer* propertyVisualizer2) const;
146
148 virtual void saveProperty();
149
151 template<typename PropIter>
152 void gatherProperties( MeshT* mesh,
153 PropIter props_first, PropIter props_last,
154 PropertyInfo::ENTITY_FILTER filter);
156 void gatherProperties();
157
159 bool isSupported(OpenVolumeMesh::BasePropertyPtr* const baseProp) const;
160
162 bool isSupported(QString friendlyName) const;
163
165 bool isNew(OpenVolumeMesh::BasePropertyPtr* const baseProp, PropertyInfo::ENTITY_FILTER filter) const;
166
168 bool isPropertyFree(QString propName, PropertyInfo::ENTITY_FILTER filter, TypeInfoWrapper typeInfo);
169
172
174 TypeInfoWrapper getSupportedTypeInfoWrapper(QString friendlyName, PropertyInfo::ENTITY_FILTER filter) const;
175
176 bool isEntityType(const TypeInfoWrapper& typeInfo, PropertyInfo::ENTITY_FILTER entity_type) const;
177
179 void addPropertyVisualizer(OpenVolumeMesh::BasePropertyPtr* const baseProp, MeshT* mesh, PropertyInfo::ENTITY_FILTER filter);
180
182 void addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter);
183
184 void initializeSupportedPropertyTypes();
185
186 MeshT* mesh_;
187
188 int objectID_;
189
190 QPushButton bCombine;
191 const PropertyInfo* mCombineProperty1;
192 const PropertyInfo* mCombineProperty2;
193
194 LoadSaveWidget mLoadSaveWidget;
195
196 PickWidget mPickWidget;
197
198 bool pickModeActive;
199 std::string lastPickMode;
200 Viewer::ActionMode lastActionMode;
201
202 typedef std::set<TypeInfoWrapper> TypeInfoWrapperSet;
203 TypeInfoWrapperSet supportedPropertyTypes;
204
205};
206
207#define INITIALIZE_PROPTYPES(primitive) \
208template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##primitive##_bool \
209 = TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT<bool>), "bool"); \
210template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##primitive##_int \
211 = TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT<int>), "int"); \
212template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##primitive##_uint \
213 = TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT<unsigned int>), "unsigned int"); \
214template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##primitive##_double \
215 = TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT<double>), "double"); \
216template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##primitive##_Vec3d \
217 = TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT<ACG::Vec3d>), "Vec3d"); \
218template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##primitive##_Vec3dOVM \
219 = TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT<OpenVolumeMesh::Vec3d>), "Vec3dOVM"); \
220template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##primitive##_Vec3f \
221 = TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT<ACG::Vec3f>), "Vec3f"); \
222template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##primitive##_Matrix3x3d \
223 = TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT<ACG::Matrix3x3d>), "Matrix3x3d");
224
225INITIALIZE_PROPTYPES(Cell)
226INITIALIZE_PROPTYPES(Face)
227INITIALIZE_PROPTYPES(HalfFace)
228INITIALIZE_PROPTYPES(Edge)
229INITIALIZE_PROPTYPES(HalfEdge)
230INITIALIZE_PROPTYPES(Vertex)
231
232#undef INITIALIZE_PROPTYPES
233
234
235#if defined(INCLUDE_TEMPLATES) && !defined(OVM_PROPERTY_MODEL_CC)
236#include "OVMPropertyModelT_impl.hh"
237#endif
238
239#endif /* OVM_PROPERTY_MODEL_H */
240
ActionMode
Enum listing action modes of the viewers.
virtual void saveProperty()
Saves the currently slected properties.
void gatherProperties()
Searches for all properties and creates the visualizers.
virtual QString getSaveFilenameFilter(unsigned int propId)
Returns the filename filter for saving.
void resetPicking()
Disables picking.
TypeInfoWrapper getSupportedTypeInfoWrapper(OpenVolumeMesh::BasePropertyPtr *const baseProp) const
Returns the TypeInfoWrapper for the property if it is supported.
void addPropertyVisualizer(OpenVolumeMesh::BasePropertyPtr *const baseProp, MeshT *mesh, PropertyInfo::ENTITY_FILTER filter)
Adds a new PropertyVisualizer.
virtual void pickProperty()
Toggle picking on and off.
void addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter)
Adds a new property to the mesh.
bool isPropertyFree(QString propName, PropertyInfo::ENTITY_FILTER filter, TypeInfoWrapper typeInfo)
Checks if a property name is still available for an entity type and a property type.
bool combinable(PropertyVisualizer *propertyVisualizer1, PropertyVisualizer *propertyVisualizer2) const
Checks if two properties are combinable.
virtual void pickModeChanged(const std::string &_mode)
Handles changing of pick mode.
bool isSupported(OpenVolumeMesh::BasePropertyPtr *const baseProp) const
Checks if visualizing this property is supported.
virtual bool parseHeader(QString header, PropertyVisualizer *&propVis, unsigned int &n)
Parses the property file header.
virtual void mouseEvent(QMouseEvent *_event)
Handles mouse events for picking.
virtual void updateWidget(const QModelIndexList &selectedIndices)
Updates the widget.
virtual void combine()
Combines two properties.
virtual QString getLoadFilenameFilter()
Returns the filename filter for loading.
bool isNew(OpenVolumeMesh::BasePropertyPtr *const baseProp, PropertyInfo::ENTITY_FILTER filter) const
Checks if we already created a PropertyVisualizer for this property.
Cellection of information about a property.
Definition: Utils.hh:109
This class vizualizes a property.
Wraps the information of a type.
Definition: Utils.hh:73