Developer Documentation
OVMPropertyVisualizerBooleanT_impl.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 
45 #define OVM_PROPERTY_VISUALIZER_BOOLEAN_CC
46 
47 #include <ACG/Utils/ColorConversion.hh>
48 #include "OVMPropertyVisualizerBoolean.hh"
49 
50 template <typename MeshT>
52  : OVMPropertyVisualizer<MeshT>(_mesh, objectID, _propertyInfo)
53 {
54  if (PropertyVisualizer::widget) delete PropertyVisualizer::widget;
55  BooleanWidget* w = new BooleanWidget();
56  w->paramBool->setTitle(QString("Boolean Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
57  PropertyVisualizer::widget = w;
58 
59 }
60 
61 template <typename MeshT>
62 template <typename PropType, typename HandleIterable>
63 void OVMPropertyVisualizerBoolean<MeshT>::visualizeProp(PropType prop, HandleIterable handles)
64 {
65  if (!prop)
66  return;
67 
68  BooleanWidget* booleanWidget = static_cast<BooleanWidget*>(PropertyVisualizer::widget);
69  ACG::Vec4f colorTrue, colorFalse;
70 
71  colorTrue = ACG::to_Vec4f(booleanWidget->colorTrue->color());
72  colorFalse = ACG::to_Vec4f(booleanWidget->colorFalse->color());
73 
76 
77  for (const auto &h: handles)
78  if ( prop[h] )
79  object->colors()[h] = colorTrue;
80  else
81  object->colors()[h] = colorFalse;
82 }
83 CALLS_TO_VISUALIZE_PROP(OVMPropertyVisualizerBoolean<MeshT>, typename MeshT, bool)
84 
85 template <typename MeshT>
87 {
88  OVMPropertyVisualizer<MeshT>::template duplicateProperty_stage1<bool>();
89 }
90 
91 template <typename MeshT>
92 void OVMPropertyVisualizerBoolean<MeshT>::setCellPropertyFromText(unsigned int index, QString text)
93 {
95 
96  OpenVolumeMesh::CellPropertyT<bool> prop = mesh->template request_cell_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
97  if ( !prop )
98  {
99  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
100  return;
101  }
102 
103  OpenVolumeMesh::CellHandle ch(index);
104 
105  prop[ch] = this->strToBool(text);
106 }
107 
108 template <typename MeshT>
109 void OVMPropertyVisualizerBoolean<MeshT>::setFacePropertyFromText(unsigned int index, QString text)
110 {
112 
113  OpenVolumeMesh::FacePropertyT<bool> prop = mesh->template request_face_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
114  if ( !prop )
115  {
116  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
117  return;
118  }
119 
120  OpenVolumeMesh::FaceHandle fh(index);
121 
122  prop[fh] = this->strToBool(text);
123 }
124 
125 template <typename MeshT>
126 void OVMPropertyVisualizerBoolean<MeshT>::setHalffacePropertyFromText(unsigned int index, QString text)
127 {
129 
130  OpenVolumeMesh::HalfFacePropertyT<bool> prop = mesh->template request_halfface_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
131  if ( !prop )
132  {
133  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
134  return;
135  }
136 
138 
139  prop[hfh] = this->strToBool(text);
140 }
141 
142 template <typename MeshT>
143 void OVMPropertyVisualizerBoolean<MeshT>::setEdgePropertyFromText(unsigned int index, QString text)
144 {
146 
147  OpenVolumeMesh::EdgePropertyT<bool> prop = mesh->template request_edge_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
148  if ( !prop )
149  {
150  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
151  return;
152  }
153 
154  OpenVolumeMesh::EdgeHandle eh(index);
155 
156  prop[eh] = this->strToBool(text);
157 }
158 
159 template <typename MeshT>
160 void OVMPropertyVisualizerBoolean<MeshT>::setHalfedgePropertyFromText(unsigned int index, QString text)
161 {
163 
164  OpenVolumeMesh::HalfEdgePropertyT<bool> prop = mesh->template request_halfedge_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
165  if ( !prop )
166  {
167  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
168  return;
169  }
170 
172 
173  prop[heh] = this->strToBool(text);
174 }
175 
176 template <typename MeshT>
177 void OVMPropertyVisualizerBoolean<MeshT>::setVertexPropertyFromText(unsigned int index, QString text)
178 {
180 
181  OpenVolumeMesh::VertexPropertyT<bool> prop = mesh->template request_vertex_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
182  if ( !prop )
183  {
184  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
185  return;
186  }
187 
189 
190  prop[vh] = this->strToBool(text);
191 }
192 
193 
194 template <typename MeshT>
196 {
197  return OVMPropertyVisualizer<MeshT>::template getPropertyText_<bool>(index);
198 }
199 
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
void duplicateProperty() override
Duplicates a property.
Cellection of information about a property.
Definition: Utils.hh:109
QString getPropertyText(unsigned int index) override
Returns the value of a property in text form.