Commit 78492bde authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

Plugin-PropertyViz: Added new vector viz mode.


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@18259 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 6ae09b78
...@@ -90,22 +90,57 @@ void visualizeVectorAsColorForEntity(MeshT *mesh, const ENTITY_IT e_begin, const ...@@ -90,22 +90,57 @@ void visualizeVectorAsColorForEntity(MeshT *mesh, const ENTITY_IT e_begin, const
} }
} }
template<typename PROPTYPE, typename MeshT, typename ENTITY_IT, typename PROPINFO_TYPE>
void visualizeVectorLengthAsColorForEntity(
MeshT *mesh, const ENTITY_IT e_begin, const ENTITY_IT e_end,
const PROPINFO_TYPE &propinfo) {
PROPTYPE prop;
if (!mesh->get_property_handle(prop, propinfo.propName()))
throw VizException("Getting PropHandle from mesh for selected "
"property failed.");
double min = std::numeric_limits<double>::infinity();
double max = -std::numeric_limits<double>::infinity();
for (ENTITY_IT e_it = e_begin; e_it != e_end; ++e_it) {
const double val = mesh->property(prop, *e_it).norm();
min = std::min(min, val);
max = std::max(max, val);
}
ACG::ColorCoder color_coder(min, max);
for (ENTITY_IT e_it = e_begin; e_it != e_end; ++e_it) {
mesh->set_color(*e_it, color_coder(mesh->property(prop, *e_it).norm()));
}
}
} }
template <typename MeshT> template <typename MeshT>
void OMPropertyVisualizerVector<MeshT>::visualizeFaceProp(bool _setDrawMode) void OMPropertyVisualizerVector<MeshT>::visualizeFaceProp(bool _setDrawMode)
{ {
VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget; VectorWidget* const w = (VectorWidget*)PropertyVisualizer::widget;
if (w->vectors_edges_rb->isChecked()) visualizeFacePropOnEdges(); if (w->vectors_edges_rb->isChecked()) {
else if (w->vectors_colors_rb->isChecked()) visualizeFacePropOnEdges();
{ } else if (w->vectors_colors_rb->isChecked() ||
w->vectors_length_color_rb->isChecked()) {
if ( !OMPropertyVisualizer<MeshT>::mesh->has_face_colors() ) if ( !OMPropertyVisualizer<MeshT>::mesh->has_face_colors() )
OMPropertyVisualizer<MeshT>::mesh->request_face_colors(); OMPropertyVisualizer<MeshT>::mesh->request_face_colors();
visualizeVectorAsColorForEntity<OpenMesh::FPropHandleT<typename MeshT::Point> >(
if (w->vectors_colors_rb->isChecked()) {
visualizeVectorAsColorForEntity<OpenMesh::FPropHandleT<typename MeshT::Point> >(
OMPropertyVisualizer<MeshT>::mesh,
OMPropertyVisualizer<MeshT>::mesh->faces_begin(),
OMPropertyVisualizer<MeshT>::mesh->faces_end(),
PropertyVisualizer::propertyInfo);
} else {
visualizeVectorLengthAsColorForEntity<OpenMesh::FPropHandleT<typename MeshT::Point> >(
OMPropertyVisualizer<MeshT>::mesh, OMPropertyVisualizer<MeshT>::mesh,
OMPropertyVisualizer<MeshT>::mesh->faces_begin(), OMPropertyVisualizer<MeshT>::mesh->faces_begin(),
OMPropertyVisualizer<MeshT>::mesh->faces_end(), OMPropertyVisualizer<MeshT>::mesh->faces_end(),
PropertyVisualizer::propertyInfo); PropertyVisualizer::propertyInfo);
}
if (_setDrawMode) if (_setDrawMode)
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED);
} }
...@@ -115,15 +150,29 @@ void OMPropertyVisualizerVector<MeshT>::visualizeFaceProp(bool _setDrawMode) ...@@ -115,15 +150,29 @@ void OMPropertyVisualizerVector<MeshT>::visualizeFaceProp(bool _setDrawMode)
template <typename MeshT> template <typename MeshT>
void OMPropertyVisualizerVector<MeshT>::visualizeEdgeProp(bool _setDrawMode) void OMPropertyVisualizerVector<MeshT>::visualizeEdgeProp(bool _setDrawMode)
{ {
VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget; VectorWidget* const w = (VectorWidget*)PropertyVisualizer::widget;
if (w->vectors_colors_rb->isChecked()) if (w->vectors_colors_rb->isChecked() ||
{ w->vectors_length_color_rb->isChecked()) {
if ( !OMPropertyVisualizer<MeshT>::mesh->has_edge_colors() ) if ( !OMPropertyVisualizer<MeshT>::mesh->has_edge_colors() )
OMPropertyVisualizer<MeshT>::mesh->request_edge_colors(); OMPropertyVisualizer<MeshT>::mesh->request_edge_colors();
MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh; MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
if ( !mesh->has_edge_colors() ) if ( !mesh->has_edge_colors() )
mesh->request_edge_colors(); mesh->request_edge_colors();
visualizeVectorAsColorForEntity<OpenMesh::EPropHandleT<typename MeshT::Point> >(mesh,mesh->edges_begin(),mesh->edges_end(), PropertyVisualizer::propertyInfo); if (w->vectors_colors_rb->isChecked()) {
visualizeVectorAsColorForEntity<
OpenMesh::EPropHandleT<typename MeshT::Point> >(
mesh,
mesh->edges_begin(),
mesh->edges_end(),
PropertyVisualizer::propertyInfo);
} else {
visualizeVectorLengthAsColorForEntity<
OpenMesh::EPropHandleT<typename MeshT::Point> >(
mesh,
mesh->edges_begin(),
mesh->edges_end(),
PropertyVisualizer::propertyInfo);
}
if (_setDrawMode) if (_setDrawMode)
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED);
} }
...@@ -133,18 +182,34 @@ void OMPropertyVisualizerVector<MeshT>::visualizeEdgeProp(bool _setDrawMode) ...@@ -133,18 +182,34 @@ void OMPropertyVisualizerVector<MeshT>::visualizeEdgeProp(bool _setDrawMode)
template <typename MeshT> template <typename MeshT>
void OMPropertyVisualizerVector<MeshT>::visualizeHalfedgeProp(bool _setDrawMode) void OMPropertyVisualizerVector<MeshT>::visualizeHalfedgeProp(bool _setDrawMode)
{ {
VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget; VectorWidget* const w = (VectorWidget*)PropertyVisualizer::widget;
if (w->vectors_colors_rb->isChecked()) if (w->vectors_colors_rb->isChecked() ||
{ w->vectors_length_color_rb->isChecked()) {
if ( !OMPropertyVisualizer<MeshT>::mesh->has_halfedge_colors() ) if ( !OMPropertyVisualizer<MeshT>::mesh->has_halfedge_colors() )
OMPropertyVisualizer<MeshT>::mesh->request_halfedge_colors(); OMPropertyVisualizer<MeshT>::mesh->request_halfedge_colors();
MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh; MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
if ( ! mesh->has_halfedge_colors() ) if ( ! mesh->has_halfedge_colors() )
mesh->request_halfedge_colors(); mesh->request_halfedge_colors();
visualizeVectorAsColorForEntity<OpenMesh::HPropHandleT<typename MeshT::Point> >(mesh,mesh->halfedges_begin(),mesh->halfedges_end(),PropertyVisualizer::propertyInfo);
if (w->vectors_colors_rb->isChecked()) {
visualizeVectorAsColorForEntity<
OpenMesh::HPropHandleT<typename MeshT::Point> >(
mesh,
mesh->halfedges_begin(),
mesh->halfedges_end(),
PropertyVisualizer::propertyInfo);
} else {
visualizeVectorLengthAsColorForEntity<
OpenMesh::HPropHandleT<typename MeshT::Point> >(
mesh,
mesh->halfedges_begin(),
mesh->halfedges_end(),
PropertyVisualizer::propertyInfo);
}
if (_setDrawMode) if (_setDrawMode)
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::HALFEDGES_COLORED); PluginFunctions::setDrawMode(
ACG::SceneGraph::DrawModes::HALFEDGES_COLORED);
} }
else visualizeHalfedgePropAsStrokes(); else visualizeHalfedgePropAsStrokes();
} }
...@@ -152,18 +217,30 @@ void OMPropertyVisualizerVector<MeshT>::visualizeHalfedgeProp(bool _setDrawMode) ...@@ -152,18 +217,30 @@ void OMPropertyVisualizerVector<MeshT>::visualizeHalfedgeProp(bool _setDrawMode)
template <typename MeshT> template <typename MeshT>
void OMPropertyVisualizerVector<MeshT>::visualizeVertexProp(bool _setDrawMode) void OMPropertyVisualizerVector<MeshT>::visualizeVertexProp(bool _setDrawMode)
{ {
VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget; VectorWidget* const w = (VectorWidget*)PropertyVisualizer::widget;
if (w->vectors_colors_rb->isChecked()) if (w->vectors_colors_rb->isChecked() ||
{ w->vectors_length_color_rb->isChecked()) {
if ( !OMPropertyVisualizer<MeshT>::mesh->has_vertex_colors() ) if ( !OMPropertyVisualizer<MeshT>::mesh->has_vertex_colors() )
OMPropertyVisualizer<MeshT>::mesh->request_vertex_colors(); OMPropertyVisualizer<MeshT>::mesh->request_vertex_colors();
visualizeVectorAsColorForEntity<OpenMesh::VPropHandleT<typename MeshT::Point> >(
if (w->vectors_colors_rb->isChecked()) {
visualizeVectorAsColorForEntity<
OpenMesh::VPropHandleT<typename MeshT::Point> >(
OMPropertyVisualizer<MeshT>::mesh,
OMPropertyVisualizer<MeshT>::mesh->vertices_begin(),
OMPropertyVisualizer<MeshT>::mesh->vertices_end(),
PropertyVisualizer::propertyInfo);
} else {
visualizeVectorLengthAsColorForEntity<
OpenMesh::VPropHandleT<typename MeshT::Point> >(
OMPropertyVisualizer<MeshT>::mesh, OMPropertyVisualizer<MeshT>::mesh,
OMPropertyVisualizer<MeshT>::mesh->vertices_begin(), OMPropertyVisualizer<MeshT>::mesh->vertices_begin(),
OMPropertyVisualizer<MeshT>::mesh->vertices_end(), OMPropertyVisualizer<MeshT>::mesh->vertices_end(),
PropertyVisualizer::propertyInfo); PropertyVisualizer::propertyInfo);
}
if (_setDrawMode) if (_setDrawMode)
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); PluginFunctions::setDrawMode(
ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED);
} }
else visualizeVertexPropAsStrokes(); else visualizeVertexPropAsStrokes();
} }
......
...@@ -2,14 +2,6 @@ ...@@ -2,14 +2,6 @@
<ui version="4.0"> <ui version="4.0">
<class>VectorWidget</class> <class>VectorWidget</class>
<widget class="QWidget" name="VectorWidget"> <widget class="QWidget" name="VectorWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>437</width>
<height>198</height>
</rect>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Property Visualization</string> <string>Property Visualization</string>
</property> </property>
...@@ -24,11 +16,19 @@ ...@@ -24,11 +16,19 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QGridLayout" name="gridLayout">
<property name="topMargin"> <item row="1" column="0">
<number>0</number> <widget class="QRadioButton" name="vectors_edges_rb">
</property> <property name="text">
<item> <string>Color Edges According
to Angle btw. Vectors</string>
</property>
<attribute name="buttonGroup">
<string notr="true">vector_buttonGroup</string>
</attribute>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="vectors_strokes_rb"> <widget class="QRadioButton" name="vectors_strokes_rb">
<property name="text"> <property name="text">
<string>Strokes</string> <string>Strokes</string>
...@@ -41,21 +41,20 @@ ...@@ -41,21 +41,20 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QRadioButton" name="vectors_colors_rb"> <widget class="QRadioButton" name="vectors_colors_rb">
<property name="text"> <property name="text">
<string>Colors</string> <string>Encode as RGB</string>
</property> </property>
<attribute name="buttonGroup"> <attribute name="buttonGroup">
<string notr="true">vector_buttonGroup</string> <string notr="true">vector_buttonGroup</string>
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item> <item row="1" column="1">
<widget class="QRadioButton" name="vectors_edges_rb"> <widget class="QRadioButton" name="vectors_length_color_rb">
<property name="text"> <property name="text">
<string>Color Edges According <string>Length as Color</string>
to Angle btw. Vectors</string>
</property> </property>
<attribute name="buttonGroup"> <attribute name="buttonGroup">
<string notr="true">vector_buttonGroup</string> <string notr="true">vector_buttonGroup</string>
...@@ -150,6 +149,12 @@ ...@@ -150,6 +149,12 @@
</property> </property>
<item> <item>
<widget class="QDoubleSpinBox" name="vectors_edges_alpha"> <widget class="QDoubleSpinBox" name="vectors_edges_alpha">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="prefix"> <property name="prefix">
<string>α = </string> <string>α = </string>
</property> </property>
...@@ -169,12 +174,6 @@ ...@@ -169,12 +174,6 @@
</item> </item>
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string></string> <string></string>
</property> </property>
...@@ -182,6 +181,12 @@ ...@@ -182,6 +181,12 @@
</item> </item>
<item> <item>
<widget class="QDoubleSpinBox" name="vectors_edges_beta"> <widget class="QDoubleSpinBox" name="vectors_edges_beta">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="prefix"> <property name="prefix">
<string>β = </string> <string>β = </string>
</property> </property>
...@@ -228,8 +233,16 @@ ...@@ -228,8 +233,16 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>vectors_strokes_rb</tabstop>
<tabstop>vectors_colors_rb</tabstop>
<tabstop>vectors_edges_rb</tabstop>
<tabstop>vectors_length_color_rb</tabstop>
<tabstop>normalize</tabstop>
<tabstop>scale</tabstop> <tabstop>scale</tabstop>
<tabstop>scaleBox</tabstop> <tabstop>scaleBox</tabstop>
<tabstop>lineColor</tabstop>
<tabstop>vectors_edges_alpha</tabstop>
<tabstop>vectors_edges_beta</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections> <connections>
...@@ -240,12 +253,12 @@ ...@@ -240,12 +253,12 @@
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>224</x> <x>172</x>
<y>1313</y> <y>142</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>418</x> <x>324</x>
<y>1316</y> <y>145</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
...@@ -256,12 +269,12 @@ ...@@ -256,12 +269,12 @@
<slot>setVisible(bool)</slot> <slot>setVisible(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>86</x> <x>122</x>
<y>1250</y> <y>45</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>29</x> <x>63</x>
<y>1328</y> <y>178</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
...@@ -272,12 +285,12 @@ ...@@ -272,12 +285,12 @@
<slot>setVisible(bool)</slot> <slot>setVisible(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>52</x> <x>88</x>
<y>1403</y> <y>86</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>31</x> <x>65</x>
<y>1425</y> <y>209</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment