Developer Documentation

OVMPropertyVisualizerBooleanT_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
45 #define OVM_PROPERTY_VISUALIZER_BOOLEAN_CC
46
47 #include <ACG/Utils/ColorConversion.hh>
48 #include "OVMPropertyVisualizerBoolean.hh"
49
50 template <typename MeshT>
51 OVMPropertyVisualizerBoolean<MeshT>::OVMPropertyVisualizerBoolean(MeshT* _mesh, int objectID, PropertyInfo _propertyInfo)
52 : OVMPropertyVisualizer<MeshT>(_mesh, objectID, _propertyInfo)
53 {
54 if (PropertyVisualizer::widget) delete PropertyVisualizer::widget;
55 BooleanWidget* w = new BooleanWidget();
56 w->paramBool->setTitle(QString("Boolean Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
57 PropertyVisualizer::widget = w;
58
59 }
60
61 template <typename MeshT>
62 template <typename PropType, typename EntityIterator>
63 void OVMPropertyVisualizerBoolean<MeshT>::visualizeProp(PropType prop, EntityIterator e_begin, EntityIterator e_end)
64 {
65 if (!prop)
66 return;
67
68 BooleanWidget* booleanWidget = static_cast<BooleanWidget*>(PropertyVisualizer::widget);
69 ACG::Vec4f colorTrue, colorFalse;
70
71 colorTrue = ACG::to_Vec4f(booleanWidget->colorTrue->color());
72 colorFalse = ACG::to_Vec4f(booleanWidget->colorFalse->color());
73
74 VolumeMeshObject<MeshT>* object;
75 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
76
77 for (EntityIterator e_it = e_begin ; e_it != e_end; ++e_it)
78 if ( prop[*e_it] )
79 object->colors()[*e_it] = colorTrue;
80 else
81 object->colors()[*e_it] = colorFalse;
82 }
83 CALLS_TO_VISUALIZE_PROP(OVMPropertyVisualizerBoolean<MeshT>, typename MeshT, bool)
84
85 template <typename MeshT>
86 void OVMPropertyVisualizerBoolean<MeshT>::duplicateProperty()
87 {
88 OVMPropertyVisualizer<MeshT>::template duplicateProperty_stage1<bool>();
89 }
90
91 template <typename MeshT>
92 void OVMPropertyVisualizerBoolean<MeshT>::setCellPropertyFromText(unsigned int index, QString text)
93 {
94 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
95
96 OpenVolumeMesh::CellPropertyT<bool> prop = mesh->template request_cell_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
97 if ( !prop )
98 {
99 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
100 return;
101 }
102
103 OpenVolumeMesh::CellHandle ch(index);
104
105 prop[ch] = this->strToBool(text);
106 }
107
108 template <typename MeshT>
109 void OVMPropertyVisualizerBoolean<MeshT>::setFacePropertyFromText(unsigned int index, QString text)
110 {
111 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
112
113 OpenVolumeMesh::FacePropertyT<bool> prop = mesh->template request_face_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
114 if ( !prop )
115 {
116 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
117 return;
118 }
119
120 OpenVolumeMesh::FaceHandle fh(index);
121
122 prop[fh] = this->strToBool(text);
123 }
124
125 template <typename MeshT>
126 void OVMPropertyVisualizerBoolean<MeshT>::setHalffacePropertyFromText(unsigned int index, QString text)
127 {
128 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
129
130 OpenVolumeMesh::HalfFacePropertyT<bool> prop = mesh->template request_halfface_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
131 if ( !prop )
132 {
133 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
134 return;
135 }
136
137 OpenVolumeMesh::HalfFaceHandle hfh(index);
138
139 prop[hfh] = this->strToBool(text);
140 }
141
142 template <typename MeshT>
143 void OVMPropertyVisualizerBoolean<MeshT>::setEdgePropertyFromText(unsigned int index, QString text)
144 {
145 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
146
147 OpenVolumeMesh::EdgePropertyT<bool> prop = mesh->template request_edge_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
148 if ( !prop )
149 {
150 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
151 return;
152 }
153
154 OpenVolumeMesh::EdgeHandle eh(index);
155
156 prop[eh] = this->strToBool(text);
157 }
158
159 template <typename MeshT>
160 void OVMPropertyVisualizerBoolean<MeshT>::setHalfedgePropertyFromText(unsigned int index, QString text)
161 {
162 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
163
164 OpenVolumeMesh::HalfEdgePropertyT<bool> prop = mesh->template request_halfedge_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
165 if ( !prop )
166 {
167 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
168 return;
169 }
170
171 OpenVolumeMesh::HalfEdgeHandle heh(index);
172
173 prop[heh] = this->strToBool(text);
174 }
175
176 template <typename MeshT>
177 void OVMPropertyVisualizerBoolean<MeshT>::setVertexPropertyFromText(unsigned int index, QString text)
178 {
179 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
180
181 OpenVolumeMesh::VertexPropertyT<bool> prop = mesh->template request_vertex_property<bool>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
182 if ( !prop )
183 {
184 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
185 return;
186 }
187
188 OpenVolumeMesh::VertexHandle vh(index);
189
190 prop[vh] = this->strToBool(text);
191 }
192
193
194 template <typename MeshT>
195 QString OVMPropertyVisualizerBoolean<MeshT>::getPropertyText(unsigned int index)
196 {
197 return OVMPropertyVisualizer<MeshT>::template getPropertyText_<bool>(index);
198 }
199
LOGERR
Definition: LoggingInterface.hh:96
OpenVolumeMesh::HandleT< Entity::Cell >
BooleanWidget
Definition: BooleanWidget.hh:46
PluginFunctions::getObject
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
Definition: PluginFunctions.cc:296
OVMPropertyVisualizer
Definition: OVMPropertyVisualizer.hh:61
OpenMesh::VectorT
Definition: Vector11T.hh:83
OVMPropertyVisualizerBoolean::duplicateProperty
void duplicateProperty() override
Duplicates a property.
Definition: OVMPropertyVisualizerBooleanT_impl.hh:86
OpenVolumeMesh::PropertyTT
Definition: ForwardDeclarations.hh:15
OVMPropertyVisualizerBoolean
Definition: OVMPropertyVisualizerBoolean.hh:54
PropertyInfo
Cellection of information about a property.
Definition: Utils.hh:109
VolumeMeshObject
Definition: VolumeMeshObject.hh:63
OVMPropertyVisualizerBoolean::getPropertyText
QString getPropertyText(unsigned int index) override
Returns the value of a property in text form.
Definition: OVMPropertyVisualizerBooleanT_impl.hh:195