50 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT
52 #define OVM_PROPERTY_VISUALIZER_VECTOR_CC
54 #include "OVMPropertyVisualizerVector.hh"
57 template <
typename MeshT>
58 OVMPropertyVisualizerVector<MeshT>::OVMPropertyVisualizerVector(MeshT* _mesh,
int objectID,
PropertyInfo _propertyInfo)
59 : OVMPropertyVisualizer<MeshT>(_mesh, objectID, _propertyInfo)
61 if (PropertyVisualizer::widget)
delete PropertyVisualizer::widget;
63 w->paramVector->setTitle(QString(
"3D Vector Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
64 PropertyVisualizer::widget = w;
68 w->vectors_edges_rb->hide();
71 template <
typename MeshT>
72 void OVMPropertyVisualizerVector<MeshT>::clear()
75 OVMPropertyVisualizer<MeshT>::clear();
78 template <
typename MeshT>
79 void OVMPropertyVisualizerVector<MeshT>::duplicateProperty()
81 OVMPropertyVisualizer<MeshT>::template duplicateProperty_stage1<ACG::Vec3d>();
84 template<
typename MeshT>
85 template<
typename PropType,
typename EntityIterator>
86 void OVMPropertyVisualizerVector<MeshT>::visualizeVectorAsColorForEntity(PropType prop, EntityIterator e_begin, EntityIterator e_end) {
88 throw VizException(
"Getting PropHandle from mesh for selected property failed.");
91 for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it) {
93 object->colors()[*e_it] =
ACG::Vec4f(v[0], v[1], v[2], 1.0);
97 template <
typename MeshT>
98 void OVMPropertyVisualizerVector<MeshT>::visualizeCellProp(
bool _setDrawMode)
101 if (w->vectors_colors_rb->isChecked())
104 visualizeVectorAsColorForEntity(prop,
105 OVMPropertyVisualizer<MeshT>::mesh->cells_begin(),
106 OVMPropertyVisualizer<MeshT>::mesh->cells_end());
111 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.cellsColoredPerCell);
114 else visualizeCellPropAsStrokes();
117 template <
typename MeshT>
118 void OVMPropertyVisualizerVector<MeshT>::visualizeFaceProp(
bool _setDrawMode)
121 if (w->vectors_colors_rb->isChecked())
124 visualizeVectorAsColorForEntity(prop,
125 OVMPropertyVisualizer<MeshT>::mesh->faces_begin(),
126 OVMPropertyVisualizer<MeshT>::mesh->faces_end());
131 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.facesColoredPerFace);
134 else visualizeFacePropAsStrokes();
138 template <
typename MeshT>
139 void OVMPropertyVisualizerVector<MeshT>::visualizeHalffaceProp(
bool _setDrawMode)
142 if (w->vectors_colors_rb->isChecked())
145 visualizeVectorAsColorForEntity(prop,
146 OVMPropertyVisualizer<MeshT>::mesh->halffaces_begin(),
147 OVMPropertyVisualizer<MeshT>::mesh->halffaces_end());
152 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halffacesColoredPerHalfface);
155 else visualizeHalffacePropAsStrokes();
158 template <
typename MeshT>
159 void OVMPropertyVisualizerVector<MeshT>::visualizeEdgeProp(
bool _setDrawMode)
162 if (w->vectors_colors_rb->isChecked())
165 visualizeVectorAsColorForEntity(prop,
166 OVMPropertyVisualizer<MeshT>::mesh->edges_begin(),
167 OVMPropertyVisualizer<MeshT>::mesh->edges_end());
172 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.edgesColoredPerEdge);
175 else visualizeEdgePropAsStrokes();
178 template <
typename MeshT>
179 void OVMPropertyVisualizerVector<MeshT>::visualizeHalfedgeProp(
bool _setDrawMode)
182 if (w->vectors_colors_rb->isChecked())
185 visualizeVectorAsColorForEntity(prop,
186 OVMPropertyVisualizer<MeshT>::mesh->halfedges_begin(),
187 OVMPropertyVisualizer<MeshT>::mesh->halfedges_end());
192 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halfedgesColoredPerHalfedge);
195 else visualizeHalfedgePropAsStrokes();
198 template <
typename MeshT>
199 void OVMPropertyVisualizerVector<MeshT>::visualizeVertexProp(
bool _setDrawMode)
202 if (w->vectors_colors_rb->isChecked())
205 visualizeVectorAsColorForEntity(prop,
206 OVMPropertyVisualizer<MeshT>::mesh->vertices_begin(),
207 OVMPropertyVisualizer<MeshT>::mesh->vertices_end());
212 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.verticesColored);
215 else visualizeVertexPropAsStrokes();
218 template <
typename MeshT>
219 void OVMPropertyVisualizerVector<MeshT>::visualizeFacePropAsStrokes()
225 ACG::Vec4f color = OVMPropertyVisualizer<MeshT>::convertColor(vectorWidget->lineColor->color());
232 OpenVolumeMesh::FaceIter f_begin(OVMPropertyVisualizer<MeshT>::mesh->faces_begin()), f_end(OVMPropertyVisualizer<MeshT>::mesh->faces_end());
241 center += OVMPropertyVisualizer<MeshT>::mesh->vertex(*hfv_it);
248 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
251 if(vectorWidget->scale->isChecked())
252 v *= vectorWidget->scaleBox->value();
254 lineNode->add_line( center, (center+v) );
255 lineNode->add_color(color);
259 template <
typename MeshT>
260 void OVMPropertyVisualizerVector<MeshT>::visualizeEdgePropAsStrokes()
266 ACG::Vec4f color = OVMPropertyVisualizer<MeshT>::convertColor(vectorWidget->lineColor->color());
272 OpenVolumeMesh::EdgeIter e_begin(OVMPropertyVisualizer<MeshT>::mesh->edges_begin()), e_end(OVMPropertyVisualizer<MeshT>::mesh->edges_end());
276 ACG::Vec3d v1 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.from_vertex());
277 ACG::Vec3d v2 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.to_vertex());
282 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
287 if(vectorWidget->scale->isChecked())
288 v *= vectorWidget->scaleBox->value();
290 lineNode->add_line( start, (start+v) );
291 lineNode->add_color(color);
295 template <
typename MeshT>
296 void OVMPropertyVisualizerVector<MeshT>::visualizeHalfedgePropAsStrokes()
302 ACG::Vec4f color = OVMPropertyVisualizer<MeshT>::convertColor(vectorWidget->lineColor->color());
308 OpenVolumeMesh::HalfEdgeIter he_begin(OVMPropertyVisualizer<MeshT>::mesh->halfedges_begin()), he_end(OVMPropertyVisualizer<MeshT>::mesh->halfedges_end());
313 ACG::Vec3d v1 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.from_vertex());
314 ACG::Vec3d v2 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.to_vertex());
319 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
322 if(vectorWidget->scale->isChecked())
323 v *= vectorWidget->scaleBox->value();
325 lineNode->add_line( start, (start+v) );
326 lineNode->add_color(color);
330 template <
typename MeshT>
331 void OVMPropertyVisualizerVector<MeshT>::visualizeVertexPropAsStrokes()
337 ACG::Vec4f color = OVMPropertyVisualizer<MeshT>::convertColor(vectorWidget->lineColor->color());
343 OpenVolumeMesh::VertexIter v_begin(OVMPropertyVisualizer<MeshT>::mesh->vertices_begin()), v_end(OVMPropertyVisualizer<MeshT>::mesh->vertices_end());
346 ACG::Vec3d start = OVMPropertyVisualizer<MeshT>::mesh->vertex(*v_it);
350 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
353 if(vectorWidget->scale->isChecked())
354 v *= vectorWidget->scaleBox->value();
356 lineNode->add_line( start, (start+v) );
357 lineNode->add_color(color);
361 template <
typename MeshT>
362 void OVMPropertyVisualizerVector<MeshT>::visualizeCellPropAsStrokes()
368 ACG::Vec4f color = OVMPropertyVisualizer<MeshT>::convertColor(vectorWidget->lineColor->color());
375 OpenVolumeMesh::CellIter c_begin(OVMPropertyVisualizer<MeshT>::mesh->cells_begin()), c_end(OVMPropertyVisualizer<MeshT>::mesh->cells_end());
380 unsigned int vCount = OVMPropertyVisualizer<MeshT>::mesh->n_vertices_in_cell(*c_it);
382 center += OVMPropertyVisualizer<MeshT>::mesh->vertex(*cv_it) / (double)vCount;
387 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
390 if(vectorWidget->scale->isChecked())
391 v *= vectorWidget->scaleBox->value();
393 lineNode->add_line( center, (center+v) );
394 lineNode->add_color(color);
398 template <
typename MeshT>
399 void OVMPropertyVisualizerVector<MeshT>::visualizeHalffacePropAsStrokes()
405 ACG::Vec4f color = OVMPropertyVisualizer<MeshT>::convertColor(vectorWidget->lineColor->color());
412 OpenVolumeMesh::HalfFaceIter hf_begin(OVMPropertyVisualizer<MeshT>::mesh->halffaces_begin()), hf_end(OVMPropertyVisualizer<MeshT>::mesh->halffaces_end());
420 center += OVMPropertyVisualizer<MeshT>::mesh->vertex(*hfv_it);
427 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
430 if(vectorWidget->scale->isChecked())
431 v *= vectorWidget->scaleBox->value();
433 lineNode->add_line( center, (center+v) );
434 lineNode->add_color(color);
438 template <
typename MeshT>
439 QString OVMPropertyVisualizerVector<MeshT>::getPropertyText(
unsigned int index)
441 return OVMPropertyVisualizer<MeshT>::template getPropertyText_<ACG::Vec3d>(index);
445 template <
typename MeshT>
446 void OVMPropertyVisualizerVector<MeshT>::setCellPropertyFromText(
unsigned int index, QString text)
448 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
453 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
459 prop[ch] = this->strToVec3d(text);
462 template <
typename MeshT>
463 void OVMPropertyVisualizerVector<MeshT>::setFacePropertyFromText(
unsigned int index, QString text)
465 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
470 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
476 prop[fh] = this->strToVec3d(text);
479 template <
typename MeshT>
480 void OVMPropertyVisualizerVector<MeshT>::setHalffacePropertyFromText(
unsigned int index, QString text)
482 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
487 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
493 prop[hfh] = this->strToVec3d(text);
496 template <
typename MeshT>
497 void OVMPropertyVisualizerVector<MeshT>::setEdgePropertyFromText(
unsigned int index, QString text)
499 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
504 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
510 prop[eh] = this->strToVec3d(text);
513 template <
typename MeshT>
514 void OVMPropertyVisualizerVector<MeshT>::setHalfedgePropertyFromText(
unsigned int index, QString text)
516 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
521 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
527 prop[heh] = this->strToVec3d(text);
530 template <
typename MeshT>
531 void OVMPropertyVisualizerVector<MeshT>::setVertexPropertyFromText(
unsigned int index, QString text)
533 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
538 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
544 prop[vh] = this->strToVec3d(text);
bool getObject(int _identifier, BSplineCurveObject *&_object)
VectorT< float, 4 > Vec4f
VectorT< double, 3 > Vec3d
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
Property classes for the different entity types.
Cellection of information about a property.