Developer Documentation
PropertyVisualizer.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 PROPERTY_VISUALIZER_HH
51 #define PROPERTY_VISUALIZER_HH
52 
53 #include "Utils.hh"
54 
57 
58 #include "OpenMesh/Core/Geometry/VectorT.hh"
59 
60 #ifdef ENABLE_SKELETON_SUPPORT
61  #include <ObjectTypes/Skeleton/BaseSkin.hh>
62 #endif
63 
64 #include <stdexcept>
65 
66 class VizException : public std::logic_error {
67  public:
68  VizException(const std::string &msg) : std::logic_error(msg) {}
69 };
70 
71 
80 class PropertyVisualizer: public QObject
81 {
82  Q_OBJECT
83 
84 signals:
85  void log(Logtype _type, QString _message);
86  void log(QString _message);
87 
88 public:
95  :
96  propertyInfo(_propertyInfo),
97  widget(0)
98  {
99  }
100 
102  virtual ~PropertyVisualizer(){delete widget; }
103 
105  virtual void visualize(bool _setDrawMode, QWidget* _widget);
106 
108  virtual void removeProperty();
109 
111  virtual void duplicateProperty();
112 
114  virtual void clear();
115 
122  virtual QString getName() { return propertyInfo.toString(); }
123 
129  virtual QWidget* getWidget() { return widget; }
130 
132  const PropertyInfo& getPropertyInfo() const { return propertyInfo; }
133 
139  virtual QString getPropertyText(unsigned int i) = 0;
140 
141 
151  virtual void setPropertyFromText(unsigned int index, QString text) = 0;
152 
154  virtual int getEntityCount() = 0;
155 
157  virtual QString getHeader() = 0;
158 
159 
160  static inline QString toStr(bool b) { return b ? QObject::tr("True") : QObject::tr("False"); }
161  static inline QString toStr(double d) { return QObject::tr("%1").arg(d); }
162  static inline QString toStr(int i) { return QObject::tr("%1").arg(i); }
163  static inline QString toStr(uint8_t i) { return QObject::tr("%1").arg(i); }
164  static inline QString toStr(unsigned int i) { return QObject::tr("%1").arg(i); }
165  static QString toStr(OpenMesh::Vec3d v);
166  static QString toStr(OpenMesh::Vec2d v);
167  static QString toStr(OpenMesh::Vec2f v);
168 #ifdef ENABLE_SKELETON_SUPPORT
169  static QString toStr(BaseSkin::SkinWeights sw);
170 #endif
171 
172  static inline bool strToBool (QString str) { return (str.compare(QObject::tr("True"))==0); }
173  static inline double strToDouble(QString str) { return str.toDouble() ; }
174  static inline int strToInt (QString str) { return str.toInt(); }
175  static inline unsigned int strToUInt (QString str) { return str.toUInt(); }
176  static OpenMesh::Vec3d strToVec3d (QString str);
177  static OpenMesh::Vec2d strToVec2d (QString str);
178  static OpenMesh::Vec2f strToVec2f (QString str);
179 
180 
181 protected:
182 
183  PropertyInfo propertyInfo;
184 
185 public:
186  QWidget* widget;
187 
188 };
189 
190 #endif /* PROPERTY_VISUALIZER_HH */
std::map< unsigned int, double > SkinWeights
Stores the joint weights per vertex.
Definition: BaseSkin.hh:99
Cellection of information about a property.
Definition: Utils.hh:115
Logtype
Log types for Message Window.
const PropertyInfo & getPropertyInfo() const
Returns the PropertyInfo.
This class vizualizes a property.
PropertyVisualizer(PropertyInfo _propertyInfo)
Constructor.
virtual QString getName()
Returns a beautiful name.
virtual ~PropertyVisualizer()
Destructor.
virtual QWidget * getWidget()
Returns the visualizer&#39;s widget.