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