Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
OMPropertyVisualizer.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_VISUALIZER_HH
51 #define OM_PROPERTY_VISUALIZER_HH
52 
53 #include "../PropertyVisualizer.hh"
54 
57 
58 #include <iostream>
59 
60 template <typename MeshT>
62 
63 public:
64  OMPropertyVisualizer(MeshT* _mesh, PropertyInfo _propertyInfo)
65  : PropertyVisualizer(_propertyInfo),
66  mesh(_mesh)
67  { }
68 
69  virtual ~OMPropertyVisualizer(){clear();}
70 
71 
73  virtual void visualize(bool _setDrawMode, QWidget* _widget);
74 
81  virtual void removeProperty(){ /*implemented by subclass*/}
82 
88  virtual void duplicateProperty(){ /*implemented by subclass*/}
89 
91  virtual void clear();
92 
94  unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint);
95 
96  virtual QString getPropertyText(unsigned int index);
97 
98 protected:
99  MeshT* mesh;
100 
101  virtual void visualizeFaceProp(bool _setDrawMode = true);
102  virtual void visualizeEdgeProp(bool _setDrawMode = true);
103  virtual void visualizeHalfedgeProp(bool _setDrawMode = true);
104  virtual void visualizeVertexProp(bool _setDrawMode = true);
105 
106  template <typename PropType>
107  void removeProperty_stage1();
108  template <typename PropType>
109  void removeProperty_stage2();
110 
111  template<typename PropType>
112  void duplicateProperty_stage1();
113  template<typename PropHandle, typename Iterator>
114  void duplicateProperty_stage2(Iterator first, Iterator last);
115 
116 
117 
118  virtual void clearFaceProp();
119  virtual void clearEdgeProp();
120  virtual void clearHalfedgeProp();
121  virtual void clearVertexProp();
122 
123  virtual void setFacePropertyFromText(unsigned int index, QString text);
124  virtual void setEdgePropertyFromText(unsigned int index, QString text);
125  virtual void setHalfedgePropertyFromText(unsigned int index, QString text);
126  virtual void setVertexPropertyFromText(unsigned int index, QString text);
127 
128  OpenMesh::Vec4f convertColor(QColor color);
129  virtual void setPropertyFromText(unsigned int index, QString text);
130 
131  virtual int getEntityCount();
132 
133  virtual QString getHeader();
134 
135  unsigned int getClosestFaceId(unsigned int _face, ACG::Vec3d& _hitPoint);
136  unsigned int getClosestEdgeId(unsigned int _face, ACG::Vec3d& _hitPoint);
137  unsigned int getClosestHalfedgeId(unsigned int _face, ACG::Vec3d& _hitPoint);
138  unsigned int getClosestVertexId(unsigned int _face, ACG::Vec3d& _hitPoint);
139 
140 
141  template <typename InnerType >
142  QString getPropertyText_(unsigned int index);
143 
144 private:
145  template<typename PropHandleT>
147  {
148  public:
149  CopyProperty(const PropHandleT& _p1, const PropHandleT& _p2, MeshT*& mesh) :
150  p1(_p1), p2(_p2), mesh(mesh) {}
151 
152  template<typename PrimitiveHandleT>
153  inline void operator() (const PrimitiveHandleT &pr) {
154  mesh->property(p1, pr) = mesh->property(p2, pr);
155  }
156 
157  private:
158  const PropHandleT &p1, &p2;
159  MeshT*& mesh;
160  };
161 
162 };
163 
164 
165 
166 #if defined(INCLUDE_TEMPLATES) && !defined(OM_PROPERTY_VISUALIZER_CC)
167 #include "OMPropertyVisualizerT.cc"
168 #endif
169 
170 
171 #endif /* OM_PROPERTY_VISUALIZER_HH */
virtual void visualize(bool _setDrawMode, QWidget *_widget)
Visualizes the property.
This class vizualizes a property.
virtual QString getPropertyText(unsigned int index)
Returns the value of a property in text form.
unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint)
Returns the ID of the closest primitive.
virtual void setPropertyFromText(unsigned int index, QString text)
Returns the value of a property in text form.
virtual void clear()
Clears the property.
virtual QString getHeader()
Returns the header for saving.
virtual void duplicateProperty()
Duplicates the property.
PropertyVisualizer(PropertyInfo _propertyInfo)
Constructor.
virtual int getEntityCount()
Returns the number of entities.
virtual void removeProperty()
Removes the property.
Cellection of information about a property.
Definition: Utils.hh:115