Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef OM_PROPERTY_MODEL_H
51 #define OM_PROPERTY_MODEL_H
52 
53 #include "SingleObjectPropertyModel.hh"
54 #include "OMPropertyVisualizer.hh"
55 
56 #include "Widgets/LoadSaveWidget.hh"
57 #include "Widgets/PickWidget.hh"
58 
60 
61 class PropertyVisPlugin;
62 
73 {
74 Q_OBJECT
75 public:
76  OMPropertyModelSubclass(QObject *parent = 0)
78  {
79  }
80 
81 public slots:
82  virtual void slotCombine(){ combine(); }
83  virtual void slotSaveProperty(){ saveProperty(); }
84  virtual void slotLoadProperty(){ loadProperty(); }
85  virtual void slotPickProperty(){ pickProperty(); }
86 
87 private:
88  virtual void combine(){}
89  virtual void saveProperty(){}
90  virtual void pickProperty(){}
91 
92 };
93 
94 template<typename MeshT>
96 
97 public:
98  OMPropertyModel(MeshT* mesh, int objectID, QObject *parent = 0);
99  virtual ~OMPropertyModel(){}
100 
101  virtual void updateWidget(const QModelIndexList& selectedIndices);
102 
103 protected:
104 
105  virtual QString getLoadFilenameFilter();
106  virtual QString getSaveFilenameFilter(unsigned int propId);
107 
108 private:
109 
111  virtual void combine();
112 
114  bool combinable(PropertyVisualizer* propertyVisualizer1, PropertyVisualizer* propertyVisualizer2);
115 
117  virtual void saveProperty();
118 
119  virtual bool parseHeader(QString header, PropertyVisualizer*& propVis, unsigned int& n);
120  virtual void setPropertyFromFile(QTextStream*& file_stream_, unsigned int n, PropertyVisualizer *propVis);
121 
123  void resetPicking();
124 
126  virtual void pickProperty();
127 
129  virtual void pickModeChanged(const std::string& _mode);
130 
132  virtual void mouseEvent(QMouseEvent* _event);
133 
134  bool isVectorType(const TypeInfoWrapper& typeInfo) const;
135 
137  void gatherProperties( MeshT* mesh,
138  typename MeshT::prop_iterator props_first,
139  typename MeshT::prop_iterator props_last,
140  PropertyInfo::ENTITY_FILTER filter);
142  void gatherProperties();
143 
145  bool isSupported(OpenMesh::BaseProperty* const baseProp) const;
146 
148  bool isSupported(QString friendlyName) const;
149 
151  bool isNew(OpenMesh::BaseProperty* const baseProp, PropertyInfo::ENTITY_FILTER filter);
152 
155 
157  TypeInfoWrapper getSupportedTypeInfoWrapper(QString friendlyName);
158 
160  void addPropertyVisualizer(OpenMesh::BaseProperty* const baseProp, MeshT* mesh, PropertyInfo::ENTITY_FILTER filter);
161 
163  void addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter);
164 
165  void initializeSupportedPropertyTypes();
166 
167 public:
168  static const TypeInfoWrapper proptype_bool;
169  static const TypeInfoWrapper proptype_int;
170  static const TypeInfoWrapper proptype_uint;
171  static const TypeInfoWrapper proptype_uint8_t;
172  static const TypeInfoWrapper proptype_double;
173  static const TypeInfoWrapper proptype_Vec3d;
174  static const TypeInfoWrapper proptype_Vec3f;
175  static const TypeInfoWrapper proptype_Vec2d;
176  static const TypeInfoWrapper proptype_Vec2f;
177 #ifdef ENABLE_SKELETON_SUPPORT
178  static const TypeInfoWrapper proptype_SkinWeights;
179 #endif
180 
181 private:
182  MeshT* mesh_;
183 
184  int objectID_;
185 
186  QPushButton bCombine;
187  const PropertyInfo* mCombineProperty1;
188  const PropertyInfo* mCombineProperty2;
189 
190  LoadSaveWidget mLoadSaveWidget;
191  PickWidget mPickWidget;
192 
193  bool pickModeActive;
194  std::string lastPickMode;
195  Viewer::ActionMode lastActionMode;
196 
197  typedef std::set<TypeInfoWrapper> TypeInfoWrapperSet;
198  TypeInfoWrapperSet supportedPropertyTypes;
199 
200 };
201 
202 
203 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_bool
204  = TypeInfoWrapper(typeid(OpenMesh::PropertyT<bool>), "bool");
205 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_int
206  = TypeInfoWrapper(typeid(OpenMesh::PropertyT<int>), "int");
207 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_uint
208  = TypeInfoWrapper(typeid(OpenMesh::PropertyT<unsigned int>), "unsigned int");
209 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_uint8_t
210  = TypeInfoWrapper(typeid(OpenMesh::PropertyT<uint8_t>), "uint8_t");
211 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_double
212  = TypeInfoWrapper(typeid(OpenMesh::PropertyT<double>), "double");
213 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_Vec3d
215 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_Vec3f
217 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_Vec2d
219 template <typename T> const TypeInfoWrapper OMPropertyModel<T>::proptype_Vec2f
221 
222 #ifdef ENABLE_SKELETON_SUPPORT
225 #endif
226 
227 
228 #if defined(INCLUDE_TEMPLATES) && !defined(OM_PROPERTY_MODEL_CC)
229 #include "OMPropertyModelT.cc"
230 #endif
231 
232 
233 #endif /* OM_PROPERTY_MODEL_H */
This class manages the visualizers for a single object.
Added for signal/slot support.
This class vizualizes a property.
virtual void saveProperty()
Saves the currently slected properties.
Default property class for any type T.
Definition: Property.hh:94
Wraps the information of a type.
Definition: Utils.hh:79
void gatherProperties()
Searches for all properties and creates the visualizers.
bool isNew(OpenMesh::BaseProperty *const baseProp, PropertyInfo::ENTITY_FILTER filter)
Checks if we already created a PropertyVisualizer for this property.
void addPropertyVisualizer(OpenMesh::BaseProperty *const baseProp, MeshT *mesh, PropertyInfo::ENTITY_FILTER filter)
Adds a new PropertyVisualizer.
bool isSupported(OpenMesh::BaseProperty *const baseProp) const
Checks if visualizing this property is supported.
virtual void setPropertyFromFile(QTextStream *&file_stream_, unsigned int n, PropertyVisualizer *propVis)
Sets the property values from a given file.
virtual QString getLoadFilenameFilter()
Returns the filename filter for loading.
virtual void mouseEvent(QMouseEvent *_event)
Handles mouse events for picking.
void resetPicking()
Disables picking.
TypeInfoWrapper getSupportedTypeInfoWrapper(OpenMesh::BaseProperty *const baseProp)
Returns the TypeInfoWrapper for the property if it is supported.
virtual void updateWidget(const QModelIndexList &selectedIndices)
Updates the widget.
virtual bool parseHeader(QString header, PropertyVisualizer *&propVis, unsigned int &n)
Parses the property file header.
virtual QString getSaveFilenameFilter(unsigned int propId)
Returns the filename filter for saving.
virtual void combine()
Combines two properties.
virtual void pickProperty()
Toggle picking on and off.
virtual void pickModeChanged(const std::string &_mode)
Handles changing of pick mode.
Cellection of information about a property.
Definition: Utils.hh:115
void addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter)
Adds a new property to the mesh.
bool combinable(PropertyVisualizer *propertyVisualizer1, PropertyVisualizer *propertyVisualizer2)
Checks if two properties are combinable.