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
50 #include <OpenFlipper/common/ViewerProperties.hh>
51
52 class PropertyVisPlugin;
53
54
55 template<typename MeshT>
56 class OMPropertyModel: public OMPropertyModelSubclass {
57
58 public:
59 OMPropertyModel(MeshT* mesh, int objectID, QObject *parent = 0);
60 virtual ~OMPropertyModel(){}
61
62 virtual void updateWidget(const QModelIndexList& selectedIndices);
63
64 protected:
65
66 virtual QString getLoadFilenameFilter();
67 virtual QString getSaveFilenameFilter(unsigned int propId);
68
69 private:
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
115 TypeInfoWrapper getSupportedTypeInfoWrapper(OpenMesh::BaseProperty* const baseProp);
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
128 public:
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
142 private:
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
164 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_bool
165 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<bool>), "bool");
166 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_int
167 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<int>), "int");
168 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_uint
169 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<unsigned int>), "unsigned int");
170 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_uint8_t
171 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<uint8_t>), "uint8_t");
172 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_double
173 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<double>), "double");
174 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_Vec3d
175 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<ACG::Vec3d>), "Vec3d");
176 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_Vec3f
177 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<ACG::Vec3f>), "Vec3f");
178 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_Vec2d
179 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<ACG::Vec2d>), "Vec2d");
180 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_Vec2f
181 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<ACG::Vec2f>), "Vec2f");
182
183 #ifdef ENABLE_SKELETON_SUPPORT
184 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_SkinWeights
185 = TypeInfoWrapper(typeid(OpenMesh::PropertyT<BaseSkin::SkinWeights>), "SkinWeights");
186 #endif
187
188
189 #if defined(INCLUDE_TEMPLATES) && !defined(OM_PROPERTY_MODEL_CC)
190 #include "OMPropertyModelT_impl.hh"
191 #endif
192
193
OpenMesh::PropertyT< bool >
Definition: Property.hh:222
OMPropertyModel::addProperty
void addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter)
Adds a new property to the mesh.
Definition: OMPropertyModelT_impl.hh:575
OMPropertyModel::isNew
bool isNew(OpenMesh::BaseProperty *const baseProp, PropertyInfo::ENTITY_FILTER filter)
Checks if we already created a PropertyVisualizer for this property.
Definition: OMPropertyModelT_impl.hh:480
PickWidget
Definition: PickWidget.hh:46
OMPropertyModel::pickProperty
virtual void pickProperty()
Toggle picking on and off.
Definition: OMPropertyModelT_impl.hh:340
ViewerProperties.hh
OMPropertyModel::getSaveFilenameFilter
virtual QString getSaveFilenameFilter(unsigned int propId)
Returns the filename filter for saving.
Definition: OMPropertyModelT_impl.hh:150
PropertyVisPlugin
Definition: PropertyVisPlugin.hh:81
OMPropertyModel::isSupported
bool isSupported(OpenMesh::BaseProperty *const baseProp) const
Checks if visualizing this property is supported.
Definition: OMPropertyModelT_impl.hh:441
Viewer::ActionMode
ActionMode
Enum listing action modes of the viewers.
Definition: ViewerProperties.hh:75
TypeInfoWrapper
Wraps the information of a type.
Definition: Utils.hh:73
OMPropertyModelSubclass
Added for signal/slot support.
Definition: OMPropertyModelSubclass.hh:56
LoadSaveWidget
Definition: LoadSaveWidget.hh:45
OMPropertyModel::combinable
bool combinable(PropertyVisualizer *propertyVisualizer1, PropertyVisualizer *propertyVisualizer2)
Checks if two properties are combinable.
Definition: OMPropertyModelT_impl.hh:201
OMPropertyModel::updateWidget
virtual void updateWidget(const QModelIndexList &selectedIndices)
Updates the widget.
Definition: OMPropertyModelT_impl.hh:107
OMPropertyModel::pickModeChanged
virtual void pickModeChanged(const std::string &_mode)
Handles changing of pick mode.
Definition: OMPropertyModelT_impl.hh:357
OMPropertyModel::getLoadFilenameFilter
virtual QString getLoadFilenameFilter()
Returns the filename filter for loading.
Definition: OMPropertyModelT_impl.hh:138
OMPropertyModel::gatherProperties
void gatherProperties()
Searches for all properties and creates the visualizers.
Definition: OMPropertyModelT_impl.hh:420
OpenMesh::PropertyT
Default property class for any type T.
Definition: Property.hh:89
OMPropertyModel::addPropertyVisualizer
void addPropertyVisualizer(OpenMesh::BaseProperty *const baseProp, MeshT *mesh, PropertyInfo::ENTITY_FILTER filter)
Adds a new PropertyVisualizer.
Definition: OMPropertyModelT_impl.hh:538
OMPropertyModel::resetPicking
void resetPicking()
Disables picking.
Definition: OMPropertyModelT_impl.hh:327
PropertyVisualizer
This class vizualizes a property.
Definition: PropertyVisualizer.hh:77
OMPropertyModel::mouseEvent
virtual void mouseEvent(QMouseEvent *_event)
Handles mouse events for picking.
Definition: OMPropertyModelT_impl.hh:376
OMPropertyModel::getSupportedTypeInfoWrapper
TypeInfoWrapper getSupportedTypeInfoWrapper(OpenMesh::BaseProperty *const baseProp)
Returns the TypeInfoWrapper for the property if it is supported.
Definition: OMPropertyModelT_impl.hh:499
OMPropertyModel
Definition: OMPropertyModel.hh:56
OMPropertyModel::saveProperty
virtual void saveProperty()
Saves the currently slected properties.
Definition: OMPropertyModelT_impl.hh:212
OMPropertyModel::combine
virtual void combine()
Combines two properties.
Definition: OMPropertyModelT_impl.hh:179
OpenMesh::BaseProperty
Definition: BaseProperty.hh:60
OMPropertyModel::parseHeader
virtual bool parseHeader(QString header, PropertyVisualizer *&propVis, unsigned int &n)
Parses the property file header.
Definition: OMPropertyModelT_impl.hh:221
PropertyInfo
Cellection of information about a property.
Definition: Utils.hh:109
OMPropertyModel::setPropertyFromFile
virtual void setPropertyFromFile(QTextStream &file_stream, unsigned int n, PropertyVisualizer *propVis)
Sets the property values from a given file.
Definition: OMPropertyModelT_impl.hh:305