Developer Documentation
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 #include "PropertyVisualizer.hh"
45 
53 void PropertyVisualizer::visualize(bool _setDrawMode, QWidget* _widget)
54 {
55  log(LOGERR, "Visualizing for this type of object not yet supported.");
56 }
57 
66 {
67  log(LOGERR, "Removing for this type of object not yet supported.");
68 }
69 
78 {
79  log(LOGERR, "Duplicating for this type of object not yet supported.");
80 }
81 
90 {
91  log(LOGERR, "Clearing for this type of object not yet supported.");
92 }
93 
94 QString PropertyVisualizer::toStr(OpenMesh::Vec3d v)
95 {
96  return QObject::trUtf8("∥(%1, %2, %3)∥ = %4").arg(v[0]).arg(v[1]).arg(v[2])
97  .arg(v.norm());
98 }
99 
100 QString PropertyVisualizer::toStr(OpenMesh::Vec2d v)
101 {
102  return QObject::tr("∥(%1, %2)∥ = %3").arg(v[0]).arg(v[1]).arg(v.norm());
103 }
104 
105 QString PropertyVisualizer::toStr(OpenMesh::Vec2f v)
106 {
107  return QObject::tr("∥(%1, %2)∥ = %3").arg(v[0]).arg(v[1]).arg(v.norm());
108 }
109 
110 #ifdef ENABLE_SKELETON_SUPPORT
111 QString PropertyVisualizer::toStr(BaseSkin::SkinWeights sw)
112 {
113  QString text = "";
114  for (std::map<unsigned int, double>::iterator it = sw.begin(); it != sw.end(); ++it) {
115  text += "(";
116  text += QString::number((*it).first);
117  text += ",";
118  text += QString::number((*it).second);
119  text += ")\n";
120  }
121  return text;
122 }
123 #endif
124 
125 
126 OpenMesh::Vec3d PropertyVisualizer::strToVec3d (QString str)
127 {
128  QString s = str;
129  s.remove(0,2);
130  s.truncate(s.lastIndexOf(")"));
131  QStringList strList = s.split(QObject::tr(", "));
132  return OpenMesh::Vec3d(strList[0].toDouble(),strList[1].toDouble(),strList[2].toDouble());
133 }
134 
135 OpenMesh::Vec2d PropertyVisualizer::strToVec2d (QString str)
136 {
137  QString s = str;
138  s.remove(0,2);
139  s.truncate(s.lastIndexOf(")"));
140  QStringList strList = s.split(QObject::tr(", "));
141  return OpenMesh::Vec2d(strList[0].toDouble(),strList[1].toDouble());
142 }
143 
144 OpenMesh::Vec2f PropertyVisualizer::strToVec2f (QString str)
145 {
146  QString s = str;
147  s.remove(0,2);
148  s.truncate(s.lastIndexOf(")"));
149  QStringList strList = s.split(QObject::tr(", "));
150  return OpenMesh::Vec2f(strList[0].toFloat(),strList[1].toFloat());
151 }
152 
153 std::unique_ptr<ACG::IColorCoder> PropertyVisualizer::buildColorCoder()
154 {
155  throw std::runtime_error("Requested color coder on a Propvis that does not implement it");
156 }
auto norm() const -> decltype(std::sqrt(std::declval< VectorT< S, DIM >>().sqrnorm()))
compute euclidean norm
Definition: Vector11T.hh:409
virtual void removeProperty()
Removes the property.
virtual void clear()
Clears the property visualization.
virtual void visualize(bool _setDrawMode, QWidget *_widget)
Visualizes the property.
VectorT< float, 2 > Vec2f
Definition: Vector11T.hh:794
virtual void duplicateProperty()
Duplicates the property.
std::map< unsigned int, double > SkinWeights
Stores the joint weights per vertex.
Definition: BaseSkin.hh:94
VectorT< double, 3 > Vec3d
Definition: Vector11T.hh:813
VectorT< double, 2 > Vec2d
Definition: Vector11T.hh:796