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
}
}
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>
void OMPropertyVisualizerVector<MeshT>::visualizeFaceProp(bool _setDrawMode)
{
VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
if (w->vectors_edges_rb->isChecked()) visualizeFacePropOnEdges();
else if (w->vectors_colors_rb->isChecked())
{
VectorWidget* const w = (VectorWidget*)PropertyVisualizer::widget;
if (w->vectors_edges_rb->isChecked()) {
visualizeFacePropOnEdges();
} else if (w->vectors_colors_rb->isChecked() ||
w->vectors_length_color_rb->isChecked()) {
if ( !OMPropertyVisualizer<MeshT>::mesh->has_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->faces_begin(),
OMPropertyVisualizer<MeshT>::mesh->faces_end(),
PropertyVisualizer::propertyInfo);
}
if (_setDrawMode)
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED);
}
......@@ -115,15 +150,29 @@ void OMPropertyVisualizerVector<MeshT>::visualizeFaceProp(bool _setDrawMode)
template <typename MeshT>
void OMPropertyVisualizerVector<MeshT>::visualizeEdgeProp(bool _setDrawMode)
{
VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
if (w->vectors_colors_rb->isChecked())
{
VectorWidget* const w = (VectorWidget*)PropertyVisualizer::widget;
if (w->vectors_colors_rb->isChecked() ||
w->vectors_length_color_rb->isChecked()) {
if ( !OMPropertyVisualizer<MeshT>::mesh->has_edge_colors() )
OMPropertyVisualizer<MeshT>::mesh->request_edge_colors();
MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
if ( !mesh->has_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)
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED);
}
......@@ -133,18 +182,34 @@ void OMPropertyVisualizerVector<MeshT>::visualizeEdgeProp(bool _setDrawMode)
template <typename MeshT>
void OMPropertyVisualizerVector<MeshT>::visualizeHalfedgeProp(bool _setDrawMode)
{
VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
if (w->vectors_colors_rb->isChecked())
{
VectorWidget* const w = (VectorWidget*)PropertyVisualizer::widget;
if (w->vectors_colors_rb->isChecked() ||
w->vectors_length_color_rb->isChecked()) {
if ( !OMPropertyVisualizer<MeshT>::mesh->has_halfedge_colors() )
OMPropertyVisualizer<MeshT>::mesh->request_halfedge_colors();
MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
if ( ! mesh->has_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)
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::HALFEDGES_COLORED);
PluginFunctions::setDrawMode(
ACG::SceneGraph::DrawModes::HALFEDGES_COLORED);
}
else visualizeHalfedgePropAsStrokes();
}
......@@ -152,18 +217,30 @@ void OMPropertyVisualizerVector<MeshT>::visualizeHalfedgeProp(bool _setDrawMode)
template <typename MeshT>
void OMPropertyVisualizerVector<MeshT>::visualizeVertexProp(bool _setDrawMode)
{
VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
if (w->vectors_colors_rb->isChecked())
{
VectorWidget* const w = (VectorWidget*)PropertyVisualizer::widget;
if (w->vectors_colors_rb->isChecked() ||
w->vectors_length_color_rb->isChecked()) {
if ( !OMPropertyVisualizer<MeshT>::mesh->has_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->vertices_begin(),
OMPropertyVisualizer<MeshT>::mesh->vertices_end(),
PropertyVisualizer::propertyInfo);
}
if (_setDrawMode)
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED);
PluginFunctions::setDrawMode(
ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED);
}
else visualizeVertexPropAsStrokes();
}
......
......@@ -2,14 +2,6 @@
<ui version="4.0">
<class>VectorWidget</class>
<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">
<string>Property Visualization</string>
</property>
......@@ -24,11 +16,19 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QRadioButton" name="vectors_edges_rb">
<property name="text">
<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">
<property name="text">
<string>Strokes</string>
......@@ -41,21 +41,20 @@
</attribute>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QRadioButton" name="vectors_colors_rb">
<property name="text">
<string>Colors</string>
<string>Encode as RGB</string>
</property>
<attribute name="buttonGroup">
<string notr="true">vector_buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="vectors_edges_rb">
<item row="1" column="1">
<widget class="QRadioButton" name="vectors_length_color_rb">
<property name="text">
<string>Color Edges According
to Angle btw. Vectors</string>
<string>Length as Color</string>
</property>
<attribute name="buttonGroup">
<string notr="true">vector_buttonGroup</string>
......@@ -150,6 +149,12 @@
</property>
<item>
<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">
<string>α = </string>
</property>
......@@ -169,12 +174,6 @@
</item>
<item>
<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">
<string></string>
</property>
......@@ -182,6 +181,12 @@
</item>
<item>
<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">
<string>β = </string>
</property>
......@@ -228,8 +233,16 @@
</customwidget>
</customwidgets>
<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>scaleBox</tabstop>
<tabstop>lineColor</tabstop>
<tabstop>vectors_edges_alpha</tabstop>
<tabstop>vectors_edges_beta</tabstop>
</tabstops>
<resources/>
<connections>
......@@ -240,12 +253,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>224</x>
<y>1313</y>
<x>172</x>
<y>142</y>
</hint>
<hint type="destinationlabel">
<x>418</x>
<y>1316</y>
<x>324</x>
<y>145</y>
</hint>
</hints>
</connection>
......@@ -256,12 +269,12 @@
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>86</x>
<y>1250</y>
<x>122</x>
<y>45</y>
</hint>
<hint type="destinationlabel">
<x>29</x>
<y>1328</y>
<x>63</x>
<y>178</y>
</hint>
</hints>
</connection>
......@@ -272,12 +285,12 @@
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>52</x>
<y>1403</y>
<x>88</x>
<y>86</y>
</hint>
<hint type="destinationlabel">
<x>31</x>
<y>1425</y>
<x>65</x>
<y>209</y>
</hint>
</hints>
</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