Developer Documentation
Loading...
Searching...
No Matches
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
49template <typename MeshT>
51 : OMPropertyVisualizer<MeshT>(_mesh, _objectID, _propertyInfo)
52{
53 if (PropertyVisualizer::widget) delete PropertyVisualizer::widget;
55 w->paramBool->setTitle(QString("Boolean Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
56 PropertyVisualizer::widget = w;
57}
58
59template <typename MeshT>
61{
62 return OMPropertyVisualizer<MeshT>::template getPropertyText_<bool>(index);
63}
64
65template <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
94template <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
122template <typename MeshT>
124{
125 BooleanWidget* booleanWidget = static_cast<BooleanWidget*>(PropertyVisualizer::widget);
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
151template <typename MeshT>
153{
154 BooleanWidget* booleanWidget = static_cast<BooleanWidget*>(PropertyVisualizer::widget);
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
180template <typename MeshT>
181void OMPropertyVisualizerBoolean<MeshT>::setFacePropertyFromText(unsigned int index, QString text)
182{
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
195template <typename MeshT>
196void OMPropertyVisualizerBoolean<MeshT>::setEdgePropertyFromText(unsigned int index, QString text)
197{
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
210template <typename MeshT>
211void OMPropertyVisualizerBoolean<MeshT>::setHalfedgePropertyFromText(unsigned int index, QString text)
212{
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
225template <typename MeshT>
226void OMPropertyVisualizerBoolean<MeshT>::setVertexPropertyFromText(unsigned int index, QString text)
227{
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
240template<typename MeshT>
245
246template<typename MeshT>
@ LOGERR
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.
Cellection of information about a property.
Definition Utils.hh:109
DrawMode HALFEDGES_COLORED
draw halfedges with colors (without shading)
Definition DrawModes.cc:103
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
DrawMode SOLID_POINTS_COLORED
draw colored, but not lighted faces using interpolated vertex colors
Definition DrawModes.cc:85
void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, int _viewer)
Set the draw Mode of a Viewer. .