Developer Documentation
OMPropertyModel.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#pragma once
43
44#include "Models/SingleObjectPropertyModel.hh"
45#include "OMPropertyModelSubclass.hh"
46#include "OMPropertyVisualizer.hh"
47#include "Widgets/LoadSaveWidget.hh"
48#include "Widgets/PickWidget.hh"
49
51
53
54
55template<typename MeshT>
57
58public:
59 OMPropertyModel(MeshT* mesh, int objectID, QObject *parent = 0);
60 virtual ~OMPropertyModel(){}
61
62 virtual void updateWidget(const QModelIndexList& selectedIndices);
63
64protected:
65
66 virtual QString getLoadFilenameFilter();
67 virtual QString getSaveFilenameFilter(unsigned int propId);
68
69private:
70
72 virtual void combine();
73
75 bool combinable(PropertyVisualizer* propertyVisualizer1, PropertyVisualizer* propertyVisualizer2);
76
78 virtual void saveProperty();
79
80 virtual bool parseHeader(QString header, PropertyVisualizer*& propVis, unsigned int& n);
81 virtual void setPropertyFromFile(QTextStream &file_stream, unsigned int n, PropertyVisualizer *propVis);
82
84 void resetPicking();
85
87 virtual void pickProperty();
88
90 virtual void pickModeChanged(const std::string& _mode);
91
93 virtual void mouseEvent(QMouseEvent* _event);
94
95 bool isVectorType(const TypeInfoWrapper& typeInfo) const;
96
98 void gatherProperties( MeshT* mesh,
99 typename MeshT::prop_iterator props_first,
100 typename MeshT::prop_iterator props_last,
101 PropertyInfo::ENTITY_FILTER filter);
103 void gatherProperties();
104
106 bool isSupported(OpenMesh::BaseProperty* const baseProp) const;
107
109 bool isSupported(QString friendlyName) const;
110
112 bool isNew(OpenMesh::BaseProperty* const baseProp, PropertyInfo::ENTITY_FILTER filter);
113
116
118 TypeInfoWrapper getSupportedTypeInfoWrapper(QString friendlyName);
119
121 void addPropertyVisualizer(OpenMesh::BaseProperty* const baseProp, MeshT* mesh, PropertyInfo::ENTITY_FILTER filter);
122
124 void addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter);
125
126 void initializeSupportedPropertyTypes();
127
128public:
129 static const TypeInfoWrapper proptype_bool;
130 static const TypeInfoWrapper proptype_int;
131 static const TypeInfoWrapper proptype_uint;
132 static const TypeInfoWrapper proptype_uint8_t;
133 static const TypeInfoWrapper proptype_double;
134 static const TypeInfoWrapper proptype_Vec3d;
135 static const TypeInfoWrapper proptype_Vec3f;
136 static const TypeInfoWrapper proptype_Vec2d;
137 static const TypeInfoWrapper proptype_Vec2f;
138#ifdef ENABLE_SKELETON_SUPPORT
139 static const TypeInfoWrapper proptype_SkinWeights;
140#endif
141
142private:
143 MeshT* mesh_;
144
145 int objectID_;
146
147 QPushButton bCombine;
148 const PropertyInfo* mCombineProperty1;
149 const PropertyInfo* mCombineProperty2;
150
151 LoadSaveWidget mLoadSaveWidget;
152 PickWidget mPickWidget;
153
154 bool pickModeActive;
155 std::string lastPickMode;
156 Viewer::ActionMode lastActionMode;
157
158 typedef std::set<TypeInfoWrapper> TypeInfoWrapperSet;
159 TypeInfoWrapperSet supportedPropertyTypes;
160
161};
162
163
164template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_bool
166template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_int
168template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_uint
169 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<unsigned int>), "unsigned int");
171 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<uint8_t>), "uint8_t");
173 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<double>), "double");
174template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_Vec3d
176template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_Vec3f
178template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_Vec2d
180template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_Vec2f
182
183#ifdef ENABLE_SKELETON_SUPPORT
186#endif
187
188
189#if defined(INCLUDE_TEMPLATES) && !defined(OM_PROPERTY_MODEL_CC)
190#include "OMPropertyModelT_impl.hh"
191#endif
192
193
ActionMode
Enum listing action modes of the viewers.
Added for signal/slot support.
virtual void saveProperty()
Saves the currently slected properties.
virtual QString getLoadFilenameFilter()
Returns the filename filter for loading.
virtual void pickModeChanged(const std::string &_mode)
Handles changing of pick mode.
virtual void mouseEvent(QMouseEvent *_event)
Handles mouse events for picking.
bool isNew(OpenMesh::BaseProperty *const baseProp, PropertyInfo::ENTITY_FILTER filter)
Checks if we already created a PropertyVisualizer for this property.
void gatherProperties()
Searches for all properties and creates the visualizers.
virtual bool parseHeader(QString header, PropertyVisualizer *&propVis, unsigned int &n)
Parses the property file header.
virtual void updateWidget(const QModelIndexList &selectedIndices)
Updates the widget.
void resetPicking()
Disables picking.
void addPropertyVisualizer(OpenMesh::BaseProperty *const baseProp, MeshT *mesh, PropertyInfo::ENTITY_FILTER filter)
Adds a new PropertyVisualizer.
virtual QString getSaveFilenameFilter(unsigned int propId)
Returns the filename filter for saving.
virtual void combine()
Combines two properties.
TypeInfoWrapper getSupportedTypeInfoWrapper(OpenMesh::BaseProperty *const baseProp)
Returns the TypeInfoWrapper for the property if it is supported.
bool isSupported(OpenMesh::BaseProperty *const baseProp) const
Checks if visualizing this property is supported.
void addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter)
Adds a new property to the mesh.
virtual void pickProperty()
Toggle picking on and off.
virtual void setPropertyFromFile(QTextStream &file_stream, unsigned int n, PropertyVisualizer *propVis)
Sets the property values from a given file.
bool combinable(PropertyVisualizer *propertyVisualizer1, PropertyVisualizer *propertyVisualizer2)
Checks if two properties are combinable.
Default property class for any type T.
Definition: Property.hh:93
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