Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PropertyVisualizer.cc
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 #include "PropertyVisualizer.hh"
51 
59 void PropertyVisualizer::visualize(bool _setDrawMode, QWidget* _widget)
60 {
61  log(LOGERR, "Visualizing for this type of object not yet supported.");
62 }
63 
72 {
73  log(LOGERR, "Removing for this type of object not yet supported.");
74 }
75 
84 {
85  log(LOGERR, "Duplicating for this type of object not yet supported.");
86 }
87 
96 {
97  log(LOGERR, "Clearing for this type of object not yet supported.");
98 }
99 
100 QString PropertyVisualizer::toStr(OpenMesh::Vec3d v)
101 {
102  return QObject::trUtf8("∥(%1, %2, %3)∥ = %4").arg(v[0]).arg(v[1]).arg(v[2])
103  .arg(v.norm());
104 }
105 
106 QString PropertyVisualizer::toStr(OpenMesh::Vec2d v)
107 {
108  return QObject::tr("∥(%1, %2)∥ = %3").arg(v[0]).arg(v[1]).arg(v.norm());
109 }
110 
111 QString PropertyVisualizer::toStr(OpenMesh::Vec2f v)
112 {
113  return QObject::tr("∥(%1, %2)∥ = %3").arg(v[0]).arg(v[1]).arg(v.norm());
114 }
115 
116 #ifdef ENABLE_SKELETON_SUPPORT
117 QString PropertyVisualizer::toStr(BaseSkin::SkinWeights sw)
118 {
119  QString text = "";
120  for (std::map<unsigned int, double>::iterator it = sw.begin(); it != sw.end(); ++it) {
121  text += "(";
122  text += QString::number((*it).first);
123  text += ",";
124  text += QString::number((*it).second);
125  text += ")\n";
126  }
127  return text;
128 }
129 #endif
130 
131 
132 OpenMesh::Vec3d PropertyVisualizer::strToVec3d (QString str)
133 {
134  QString s = str;
135  s.remove(0,2);
136  s.truncate(s.lastIndexOf(")"));
137  QStringList strList = s.split(QObject::tr(", "));
138  return OpenMesh::Vec3d(strList[0].toDouble(),strList[1].toDouble(),strList[2].toDouble());
139 }
140 
141 OpenMesh::Vec2d PropertyVisualizer::strToVec2d (QString str)
142 {
143  QString s = str;
144  s.remove(0,2);
145  s.truncate(s.lastIndexOf(")"));
146  QStringList strList = s.split(QObject::tr(", "));
147  return OpenMesh::Vec2d(strList[0].toDouble(),strList[1].toDouble());
148 }
149 
150 OpenMesh::Vec2f PropertyVisualizer::strToVec2f (QString str)
151 {
152  QString s = str;
153  s.remove(0,2);
154  s.truncate(s.lastIndexOf(")"));
155  QStringList strList = s.split(QObject::tr(", "));
156  return OpenMesh::Vec2f(strList[0].toFloat(),strList[1].toFloat());
157 }
VectorT< double, 3 > Vec3d
Definition: Vector11T.hh:771
virtual void clear()
Clears the property visualization.
VectorT< float, 2 > Vec2f
Definition: Vector11T.hh:752
std::map< unsigned int, double > SkinWeights
Stores the joint weights per vertex.
Definition: BaseSkin.hh:99
virtual void removeProperty()
Removes the property.
virtual void visualize(bool _setDrawMode, QWidget *_widget)
Visualizes the property.
virtual void duplicateProperty()
Duplicates the property.
VectorT< double, 2 > Vec2d
Definition: Vector11T.hh:754