Developer Documentation
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 #ifndef OM_PROPERTY_VISUALIZER_HH
45 #define OM_PROPERTY_VISUALIZER_HH
46 
47 #include "PropertyVisualizer/PropertyVisualizer.hh"
48 
51 
52 #include <iostream>
53 
54 template <typename MeshT>
56 
57 public:
58  OMPropertyVisualizer(MeshT* _mesh, int objectID, const PropertyInfo& _propertyInfo)
59  : PropertyVisualizer(_propertyInfo),
60  mesh(_mesh),
61  mObjectID(objectID)
62  { }
63 
64  virtual ~OMPropertyVisualizer(){clear();}
65 
66 
68  virtual void visualize(bool _setDrawMode, QWidget* _widget);
69 
76  virtual void removeProperty(){ /*implemented by subclass*/}
77 
83  virtual void duplicateProperty(){ /*implemented by subclass*/}
84 
86  virtual void clear();
87 
89  unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint);
90 
91  virtual QString getPropertyText(unsigned int index);
92 
93 protected:
94  MeshT* mesh;
95  int mObjectID;
96 
97  virtual void visualizeFaceProp(bool _setDrawMode = true);
98  virtual void visualizeEdgeProp(bool _setDrawMode = true);
99  virtual void visualizeHalfedgeProp(bool _setDrawMode = true);
100  virtual void visualizeVertexProp(bool _setDrawMode = true);
101 
102  template <typename PropType>
103  void removeProperty_stage1();
104  template <typename PropType>
105  void removeProperty_stage2();
106 
107  template<typename PropType>
108  void duplicateProperty_stage1();
109  template<typename PropHandle, typename Iterator>
110  void duplicateProperty_stage2(Iterator first, Iterator last);
111 
112 
113 
114  virtual void clearFaceProp();
115  virtual void clearEdgeProp();
116  virtual void clearHalfedgeProp();
117  virtual void clearVertexProp();
118 
119  virtual void setFacePropertyFromText(unsigned int index, QString text);
120  virtual void setEdgePropertyFromText(unsigned int index, QString text);
121  virtual void setHalfedgePropertyFromText(unsigned int index, QString text);
122  virtual void setVertexPropertyFromText(unsigned int index, QString text);
123 
124  virtual void setPropertyFromText(unsigned int index, QString text);
125 
126  virtual int getEntityCount();
127 
128  virtual QString getHeader();
129 
130  unsigned int getClosestFaceId(unsigned int _face, ACG::Vec3d& _hitPoint);
131  unsigned int getClosestEdgeId(unsigned int _face, ACG::Vec3d& _hitPoint);
132  unsigned int getClosestHalfedgeId(unsigned int _face, ACG::Vec3d& _hitPoint);
133  unsigned int getClosestVertexId(unsigned int _face, ACG::Vec3d& _hitPoint);
134 
135 
136  template <typename InnerType >
137  QString getPropertyText_(unsigned int index);
138 
139  template<typename Type>
140  void showHistogram(ACG::QtWidgets::QtHistogramWidget *histogramWidget);
141 
142 private:
143  template<typename PropHandleT>
145  {
146  public:
147  CopyProperty(const PropHandleT& _p1, const PropHandleT& _p2, MeshT*& mesh) :
148  p1(_p1), p2(_p2), mesh(mesh) {}
149 
150  template<typename PrimitiveHandleT>
151  inline void operator() (const PrimitiveHandleT &pr) {
152  mesh->property(p1, pr) = mesh->property(p2, pr);
153  }
154 
155  private:
156  const PropHandleT &p1, &p2;
157  MeshT*& mesh;
158  };
159 };
160 
161 
162 
163 #if defined(INCLUDE_TEMPLATES) && !defined(OM_PROPERTY_VISUALIZER_CC)
164 #include "OMPropertyVisualizerT_impl.hh"
165 #endif
166 
167 
168 #endif /* OM_PROPERTY_VISUALIZER_HH */
virtual void removeProperty()
Removes the property.
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 QString getHeader()
Returns the header for saving.
This class vizualizes a property.
virtual void clear()
Clears the property.
virtual void duplicateProperty()
Duplicates the property.
virtual void visualize(bool _setDrawMode, QWidget *_widget)
Visualizes the property.
PropertyVisualizer(const PropertyInfo &_propertyInfo)
Constructor.
virtual int getEntityCount()
Returns the number of entities.
Cellection of information about a property.
Definition: Utils.hh:109
virtual QString getPropertyText(unsigned int index)
Returns the value of a property in text form.