Developer Documentation
OMPropertyVisualizerBooleanT_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 #define OM_PROPERTY_VISUALIZER_BOOLEAN_CC
45 
46 #include "OMPropertyVisualizerBoolean.hh"
47 #include <ACG/Utils/ColorConversion.hh>
48 
49 template <typename MeshT>
50 OMPropertyVisualizerBoolean<MeshT>::OMPropertyVisualizerBoolean(MeshT* _mesh, int _objectID, const PropertyInfo& _propertyInfo)
51  : OMPropertyVisualizer<MeshT>(_mesh, _objectID, _propertyInfo)
52 {
53  if (PropertyVisualizer::widget) delete PropertyVisualizer::widget;
54  BooleanWidget* w = new BooleanWidget();
55  w->paramBool->setTitle(QString("Boolean Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
56  PropertyVisualizer::widget = w;
57 }
58 
59 template <typename MeshT>
61 {
62  return OMPropertyVisualizer<MeshT>::template getPropertyText_<bool>(index);
63 }
64 
65 template <typename MeshT>
67 {
68  BooleanWidget* booleanWidget = static_cast<BooleanWidget*>(PropertyVisualizer::widget);
70  typename MeshT::Color colorTrue, colorFalse;
71 
72  colorTrue = ACG::to_Vec4f(booleanWidget->colorTrue->color());
73  colorFalse = ACG::to_Vec4f(booleanWidget->colorFalse->color());
74 
76 
77  if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
78  return;
79 
80  if ( !mesh->has_face_colors() )
81  OMPropertyVisualizer<MeshT>::mesh->request_face_colors();
82 
83  for (typename MeshT::FaceIter f_it = mesh->faces_begin() ; f_it != mesh->faces_end() ; ++f_it)
84  if ( mesh->property(prop, *f_it) )
85  mesh->set_color(*f_it, colorTrue);
86  else
87  mesh->set_color(*f_it, colorFalse);
88 
89  if (_setDrawMode)
91 
92 }
93 
94 template <typename MeshT>
96 {
97  BooleanWidget* booleanWidget = static_cast<BooleanWidget*>(PropertyVisualizer::widget);
99  typename MeshT::Color colorTrue, colorFalse;
100 
101  colorTrue = ACG::to_Vec4f(booleanWidget->colorTrue->color());
102  colorFalse = ACG::to_Vec4f(booleanWidget->colorFalse->color());
103 
105 
106  if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
107  return;
108 
109  if ( !mesh->has_edge_colors() )
110  mesh->request_edge_colors();
111 
112  for (typename MeshT::EdgeIter e_it = mesh->edges_begin() ; e_it != mesh->edges_end() ; ++e_it)
113  if ( mesh->property(prop, *e_it) )
114  mesh->set_color(*e_it, colorTrue);
115  else
116  mesh->set_color(*e_it, colorFalse);
117 
118  if (_setDrawMode)
120 }
121 
122 template <typename MeshT>
124 {
125  BooleanWidget* booleanWidget = static_cast<BooleanWidget*>(PropertyVisualizer::widget);
126  MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
127  typename MeshT::Color colorTrue, colorFalse;
128 
129  colorTrue = ACG::to_Vec4f(booleanWidget->colorTrue->color());
130  colorFalse = ACG::to_Vec4f(booleanWidget->colorFalse->color());
131 
133 
134  if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
135  return;
136 
137  if ( ! mesh->has_halfedge_colors() )
138  mesh->request_halfedge_colors();
139 
140  for (typename MeshT::HalfedgeIter he_it = mesh->halfedges_begin() ; he_it != mesh->halfedges_end() ; ++he_it)
141  if ( mesh->property(prop, *he_it) )
142  mesh->set_color(*he_it, colorTrue);
143  else
144  mesh->set_color(*he_it, colorFalse);
145 
146  if (_setDrawMode)
148 
149 }
150 
151 template <typename MeshT>
153 {
154  BooleanWidget* booleanWidget = static_cast<BooleanWidget*>(PropertyVisualizer::widget);
155  MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
156  typename MeshT::Color colorTrue, colorFalse;
157 
158  colorTrue = ACG::to_Vec4f(booleanWidget->colorTrue->color());
159  colorFalse = ACG::to_Vec4f(booleanWidget->colorFalse->color());
160 
162 
163  if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
164  return;
165 
166  if ( ! mesh->has_vertex_colors() )
167  mesh->request_vertex_colors();
168 
169  for (typename MeshT::VertexIter v_it = mesh->vertices_begin() ; v_it != mesh->vertices_end() ; ++v_it)
170  if ( mesh->property(prop, *v_it) )
171  mesh->set_color(*v_it, colorTrue);
172  else
173  mesh->set_color(*v_it, colorFalse);
174 
175  if (_setDrawMode)
177 
178 }
179 
180 template <typename MeshT>
181 void OMPropertyVisualizerBoolean<MeshT>::setFacePropertyFromText(unsigned int index, QString text)
182 {
184  MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
185 
186  if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
187  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
188 
189 
190  typename MeshT::FaceHandle fh = mesh->face_handle(index);
191 
192  mesh->property(prop, fh) = this->strToBool(text);
193 }
194 
195 template <typename MeshT>
196 void OMPropertyVisualizerBoolean<MeshT>::setEdgePropertyFromText(unsigned int index, QString text)
197 {
199  MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
200 
201  if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
202  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
203 
204 
205  typename MeshT::EdgeHandle eh = mesh->edge_handle(index);
206 
207  mesh->property(prop, eh) = this->strToBool(text);
208 }
209 
210 template <typename MeshT>
211 void OMPropertyVisualizerBoolean<MeshT>::setHalfedgePropertyFromText(unsigned int index, QString text)
212 {
214  MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
215 
216  if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
217  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
218 
219 
220  typename MeshT::HalfedgeHandle heh = mesh->halfedge_handle(index);
221 
222  mesh->property(prop, heh) = this->strToBool(text);
223 }
224 
225 template <typename MeshT>
226 void OMPropertyVisualizerBoolean<MeshT>::setVertexPropertyFromText(unsigned int index, QString text)
227 {
229  MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
230 
231  if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
232  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
233 
234 
235  typename MeshT::VertexHandle vh = mesh->vertex_handle(index);
236 
237  mesh->property(prop, vh) = this->strToBool(text);
238 }
239 
240 template<typename MeshT>
242 {
243  OMPropertyVisualizer<MeshT>::template removeProperty_stage1<bool>();
244 }
245 
246 template<typename MeshT>
248 {
249  OMPropertyVisualizer<MeshT>::template duplicateProperty_stage1<bool>();
250 }
void duplicateProperty() override
Duplicates the property.
QString getPropertyText(unsigned int index) override
Returns the value of a property in text form.
void removeProperty() override
Removes the property.
Add colors to mesh item (vertices/faces/edges)
Definition: Attributes.hh:83
DrawMode HALFEDGES_COLORED
draw halfedges with colors (without shading)
Definition: DrawModes.cc:103
DrawMode SOLID_POINTS_COLORED
draw colored, but not lighted faces using interpolated vertex colors
Definition: DrawModes.cc:85
Cellection of information about a property.
Definition: Utils.hh:109
DrawMode SOLID_FACES_COLORED
draw colored, but not lighted faces using face colors
Definition: DrawModes.cc:84
DrawMode EDGES_COLORED
draw edges with colors (without shading)
Definition: DrawModes.cc:77