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  void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode& _mode);
94 
95 protected:
96  MeshT* mesh;
97  int mObjectID;
98 
99  virtual void visualizeFaceProp(bool _setDrawMode = true);
100  virtual void visualizeEdgeProp(bool _setDrawMode = true);
101  virtual void visualizeHalfedgeProp(bool _setDrawMode = true);
102  virtual void visualizeVertexProp(bool _setDrawMode = true);
103 
104  template <typename PropType>
105  void removeProperty_stage1();
106  template <typename PropType>
107  void removeProperty_stage2();
108 
109  template<typename PropType>
110  void duplicateProperty_stage1();
111  template<typename PropHandle, typename Iterator>
112  void duplicateProperty_stage2(Iterator first, Iterator last);
113 
114 
115 
116  virtual void clearFaceProp();
117  virtual void clearEdgeProp();
118  virtual void clearHalfedgeProp();
119  virtual void clearVertexProp();
120 
121  virtual void setFacePropertyFromText(unsigned int index, QString text);
122  virtual void setEdgePropertyFromText(unsigned int index, QString text);
123  virtual void setHalfedgePropertyFromText(unsigned int index, QString text);
124  virtual void setVertexPropertyFromText(unsigned int index, QString text);
125 
126  virtual void setPropertyFromText(unsigned int index, QString text);
127 
128  virtual int getEntityCount();
129 
130  virtual QString getHeader();
131 
132  unsigned int getClosestFaceId(unsigned int _face, ACG::Vec3d& _hitPoint);
133  unsigned int getClosestEdgeId(unsigned int _face, ACG::Vec3d& _hitPoint);
134  unsigned int getClosestHalfedgeId(unsigned int _face, ACG::Vec3d& _hitPoint);
135  unsigned int getClosestVertexId(unsigned int _face, ACG::Vec3d& _hitPoint);
136 
137 
138  template <typename InnerType >
139  QString getPropertyText_(unsigned int index);
140 
141  template<typename Type>
142  void showHistogram(ACG::QtWidgets::QtHistogramWidget *histogramWidget);
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 #if defined(INCLUDE_TEMPLATES) && !defined(OM_PROPERTY_VISUALIZER_CC)
166 #include "OMPropertyVisualizerT_impl.hh"
167 #endif
168 
169 
170 #endif /* OM_PROPERTY_VISUALIZER_HH */
PropertyVisualizer(const PropertyInfo &_propertyInfo)
Constructor.
virtual void removeProperty()
Removes the property.
unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint)
Returns the ID of the closest primitive.
virtual void visualize(bool _setDrawMode, QWidget *_widget)
Visualizes the property.
virtual void setPropertyFromText(unsigned int index, QString text)
Returns the value of a property in text form.
virtual int getEntityCount()
Returns the number of entities.
Cellection of information about a property.
Definition: Utils.hh:109
virtual void clear()
Clears the property.
This class vizualizes a property.
virtual void duplicateProperty()
Duplicates the property.
virtual QString getHeader()
Returns the header for saving.
virtual QString getPropertyText(unsigned int index)
Returns the value of a property in text form.