Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
OVMPropertyVisualizerBooleanT.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 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT
51 
52 #define OVM_PROPERTY_VISUALIZER_BOOLEAN_CC
53 
54 #include <ACG/Utils/ColorConversion.hh>
55 #include "OVMPropertyVisualizerBoolean.hh"
56 
57 template <typename MeshT>
58 OVMPropertyVisualizerBoolean<MeshT>::OVMPropertyVisualizerBoolean(MeshT* _mesh, int objectID, PropertyInfo _propertyInfo)
59  : OVMPropertyVisualizer<MeshT>(_mesh, objectID, _propertyInfo)
60 {
61  if (PropertyVisualizer::widget) delete PropertyVisualizer::widget;
62  BooleanWidget* w = new BooleanWidget();
63  w->paramBool->setTitle(QString("Boolean Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
64  PropertyVisualizer::widget = w;
65 
66 }
67 
68 template <typename MeshT>
69 template <typename PropType, typename EntityIterator>
70 void OVMPropertyVisualizerBoolean<MeshT>::visualizeProp(PropType prop, EntityIterator e_begin, EntityIterator e_end)
71 {
72  if (!prop)
73  return;
74 
75  BooleanWidget* booleanWidget = static_cast<BooleanWidget*>(PropertyVisualizer::widget);
76  ACG::Vec4f colorTrue, colorFalse;
77 
78  colorTrue = ACG::to_Vec4f(booleanWidget->colorTrue->color());
79  colorFalse = ACG::to_Vec4f(booleanWidget->colorFalse->color());
80 
82  PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
83 
84  for (EntityIterator e_it = e_begin ; e_it != e_end; ++e_it)
85  if ( prop[*e_it] )
86  object->colors()[*e_it] = colorTrue;
87  else
88  object->colors()[*e_it] = colorFalse;
89 }
90 CALLS_TO_VISUALIZE_PROP(OVMPropertyVisualizerBoolean<MeshT>, typename MeshT, bool)
91 
92 template <typename MeshT>
93 void OVMPropertyVisualizerBoolean<MeshT>::duplicateProperty()
94 {
95  OVMPropertyVisualizer<MeshT>::template duplicateProperty_stage1<bool>();
96 }
97 
98 template <typename MeshT>
99 void OVMPropertyVisualizerBoolean<MeshT>::setCellPropertyFromText(unsigned int index, QString text)
100 {
101  MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
102 
103  OpenVolumeMesh::CellPropertyT<bool> prop = mesh->template request_cell_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
104  if ( !prop )
105  {
106  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
107  return;
108  }
109 
110  OpenVolumeMesh::CellHandle ch(index);
111 
112  prop[ch] = this->strToBool(text);
113 }
114 
115 template <typename MeshT>
116 void OVMPropertyVisualizerBoolean<MeshT>::setFacePropertyFromText(unsigned int index, QString text)
117 {
118  MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
119 
120  OpenVolumeMesh::FacePropertyT<bool> prop = mesh->template request_face_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
121  if ( !prop )
122  {
123  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
124  return;
125  }
126 
127  OpenVolumeMesh::FaceHandle fh(index);
128 
129  prop[fh] = this->strToBool(text);
130 }
131 
132 template <typename MeshT>
133 void OVMPropertyVisualizerBoolean<MeshT>::setHalffacePropertyFromText(unsigned int index, QString text)
134 {
135  MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
136 
137  OpenVolumeMesh::HalfFacePropertyT<bool> prop = mesh->template request_halfface_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
138  if ( !prop )
139  {
140  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
141  return;
142  }
143 
145 
146  prop[hfh] = this->strToBool(text);
147 }
148 
149 template <typename MeshT>
150 void OVMPropertyVisualizerBoolean<MeshT>::setEdgePropertyFromText(unsigned int index, QString text)
151 {
152  MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
153 
154  OpenVolumeMesh::EdgePropertyT<bool> prop = mesh->template request_edge_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
155  if ( !prop )
156  {
157  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
158  return;
159  }
160 
161  OpenVolumeMesh::EdgeHandle eh(index);
162 
163  prop[eh] = this->strToBool(text);
164 }
165 
166 template <typename MeshT>
167 void OVMPropertyVisualizerBoolean<MeshT>::setHalfedgePropertyFromText(unsigned int index, QString text)
168 {
169  MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
170 
171  OpenVolumeMesh::HalfEdgePropertyT<bool> prop = mesh->template request_halfedge_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
172  if ( !prop )
173  {
174  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
175  return;
176  }
177 
179 
180  prop[heh] = this->strToBool(text);
181 }
182 
183 template <typename MeshT>
184 void OVMPropertyVisualizerBoolean<MeshT>::setVertexPropertyFromText(unsigned int index, QString text)
185 {
186  MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
187 
188  OpenVolumeMesh::VertexPropertyT<bool> prop = mesh->template request_vertex_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
189  if ( !prop )
190  {
191  emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
192  return;
193  }
194 
196 
197  prop[vh] = this->strToBool(text);
198 }
199 
200 
201 template <typename MeshT>
202 QString OVMPropertyVisualizerBoolean<MeshT>::getPropertyText(unsigned int index)
203 {
204  return OVMPropertyVisualizer<MeshT>::template getPropertyText_<bool>(index);
205 }
206 
207 #endif /* ENABLE_OPENVOLUMEMESH_SUPPORT */
bool getObject(int _identifier, BSplineCurveObject *&_object)
Property classes for the different entity types.
Cellection of information about a property.
Definition: Utils.hh:115