Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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