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