Commit 9173dc74 authored by Jan Möbius's avatar Jan Möbius
Browse files

Merge branch 'vector-color-normalization' into 'master'

add "normalized" checkbox for visualizing vectors as colors

See merge request !4
parents 7a5f003d 689fcf54
......@@ -91,12 +91,17 @@ namespace {
template<typename PROPTYPE, typename MeshT, typename ENTITY_IT, typename PROPINFO_TYPE>
void visualizeVectorAsColorForEntity(MeshT *mesh, const ENTITY_IT e_begin, const ENTITY_IT e_end,
const PROPINFO_TYPE &propinfo) {
const PROPINFO_TYPE &propinfo, bool normalized) {
PROPTYPE prop;
if (!mesh->get_property_handle(prop, propinfo.propName()))
throw VizException("Getting PropHandle from mesh for selected property failed.");
for (ENTITY_IT e_it = e_begin; e_it != e_end; ++e_it) {
typename MeshT::Point v = mesh->property(prop, *e_it).normalized() * .5 + typename MeshT::Point(.5, .5, .5);
using point_t = typename MeshT::Point;
point_t v = mesh->property(prop, *e_it);
if (normalized)
v = v.normalized() * .5 + point_t(.5);
else
v = v.min(point_t(1)).max(point_t(0));
mesh->set_color(*e_it, typename MeshT::Color(v[0], v[1], v[2], 1.0));
}
}
......@@ -144,7 +149,8 @@ void OMPropertyVisualizerVector<MeshT>::visualizeFaceProp(bool _setDrawMode)
OMPropertyVisualizer<MeshT>::mesh,
OMPropertyVisualizer<MeshT>::mesh->faces_begin(),
OMPropertyVisualizer<MeshT>::mesh->faces_end(),
PropertyVisualizer::propertyInfo);
PropertyVisualizer::propertyInfo,
w->normalize_colors->isChecked());
} else {
visualizeVectorLengthAsColorForEntity<OpenMesh::FPropHandleT<typename MeshT::Point> >(
OMPropertyVisualizer<MeshT>::mesh,
......@@ -175,7 +181,8 @@ void OMPropertyVisualizerVector<MeshT>::visualizeEdgeProp(bool _setDrawMode)
mesh,
mesh->edges_begin(),
mesh->edges_end(),
PropertyVisualizer::propertyInfo);
PropertyVisualizer::propertyInfo,
w->normalize_colors->isChecked());
} else {
visualizeVectorLengthAsColorForEntity<
OpenMesh::EPropHandleT<typename MeshT::Point> >(
......@@ -208,7 +215,8 @@ void OMPropertyVisualizerVector<MeshT>::visualizeHalfedgeProp(bool _setDrawMode)
mesh,
mesh->halfedges_begin(),
mesh->halfedges_end(),
PropertyVisualizer::propertyInfo);
PropertyVisualizer::propertyInfo,
w->normalize_colors->isChecked());
} else {
visualizeVectorLengthAsColorForEntity<
OpenMesh::HPropHandleT<typename MeshT::Point> >(
......@@ -240,7 +248,8 @@ void OMPropertyVisualizerVector<MeshT>::visualizeVertexProp(bool _setDrawMode)
OMPropertyVisualizer<MeshT>::mesh,
OMPropertyVisualizer<MeshT>::mesh->vertices_begin(),
OMPropertyVisualizer<MeshT>::mesh->vertices_end(),
PropertyVisualizer::propertyInfo);
PropertyVisualizer::propertyInfo,
w->normalize_colors->isChecked());
} else {
visualizeVectorLengthAsColorForEntity<
OpenMesh::VPropHandleT<typename MeshT::Point> >(
......
......@@ -74,7 +74,7 @@ public:
protected:
template<typename PropType, typename EntityIterator>
void visualizeVectorAsColorForEntity(PropType prop, EntityIterator e_begin, EntityIterator e_end);
void visualizeVectorAsColorForEntity(PropType prop, EntityIterator e_begin, EntityIterator e_end, bool normalized);
virtual void duplicateProperty();
virtual void visualizeFacePropAsStrokes();
......
......@@ -85,13 +85,17 @@ void OVMPropertyVisualizerVector<MeshT>::duplicateProperty()
template<typename MeshT>
template<typename PropType, typename EntityIterator>
void OVMPropertyVisualizerVector<MeshT>::visualizeVectorAsColorForEntity(PropType prop, EntityIterator e_begin, EntityIterator e_end) {
void OVMPropertyVisualizerVector<MeshT>::visualizeVectorAsColorForEntity(PropType prop, EntityIterator e_begin, EntityIterator e_end, bool normalized) {
if (!prop)
throw VizException("Getting PropHandle from mesh for selected property failed.");
VolumeMeshObject<MeshT>* object;
PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it) {
ACG::Vec3d v = prop[*e_it].normalized() * .5 + ACG::Vec3d(.5, .5, .5);
ACG::Vec3d v = prop[*e_it];
if (normalized)
v = v.normalized() * .5 + ACG::Vec3d(.5);
else
v = v.min(ACG::Vec3d(1)).max(ACG::Vec3d(0));
object->colors()[*e_it] = ACG::Vec4f(v[0], v[1], v[2], 1.0);
}
}
......@@ -105,7 +109,8 @@ void OVMPropertyVisualizerVector<MeshT>::visualizeCellProp(bool _setDrawMode)
OpenVolumeMesh::CellPropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_cell_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
visualizeVectorAsColorForEntity(prop,
OVMPropertyVisualizer<MeshT>::mesh->cells_begin(),
OVMPropertyVisualizer<MeshT>::mesh->cells_end());
OVMPropertyVisualizer<MeshT>::mesh->cells_end(),
w->normalize_colors->isChecked());
if (_setDrawMode)
{
VolumeMeshObject<MeshT>* object;
......@@ -125,7 +130,8 @@ void OVMPropertyVisualizerVector<MeshT>::visualizeFaceProp(bool _setDrawMode)
OpenVolumeMesh::FacePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_face_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
visualizeVectorAsColorForEntity(prop,
OVMPropertyVisualizer<MeshT>::mesh->faces_begin(),
OVMPropertyVisualizer<MeshT>::mesh->faces_end());
OVMPropertyVisualizer<MeshT>::mesh->faces_end(),
w->normalize_colors->isChecked());
if (_setDrawMode)
{
VolumeMeshObject<MeshT>* object;
......@@ -146,7 +152,8 @@ void OVMPropertyVisualizerVector<MeshT>::visualizeHalffaceProp(bool _setDrawMode
OpenVolumeMesh::HalfFacePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_halfface_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
visualizeVectorAsColorForEntity(prop,
OVMPropertyVisualizer<MeshT>::mesh->halffaces_begin(),
OVMPropertyVisualizer<MeshT>::mesh->halffaces_end());
OVMPropertyVisualizer<MeshT>::mesh->halffaces_end(),
w->normalize_colors->isChecked());
if (_setDrawMode)
{
VolumeMeshObject<MeshT>* object;
......@@ -166,7 +173,8 @@ void OVMPropertyVisualizerVector<MeshT>::visualizeEdgeProp(bool _setDrawMode)
OpenVolumeMesh::EdgePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_edge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
visualizeVectorAsColorForEntity(prop,
OVMPropertyVisualizer<MeshT>::mesh->edges_begin(),
OVMPropertyVisualizer<MeshT>::mesh->edges_end());
OVMPropertyVisualizer<MeshT>::mesh->edges_end(),
w->normalize_colors->isChecked());
if (_setDrawMode)
{
VolumeMeshObject<MeshT>* object;
......@@ -186,7 +194,8 @@ void OVMPropertyVisualizerVector<MeshT>::visualizeHalfedgeProp(bool _setDrawMode
OpenVolumeMesh::HalfEdgePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_halfedge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
visualizeVectorAsColorForEntity(prop,
OVMPropertyVisualizer<MeshT>::mesh->halfedges_begin(),
OVMPropertyVisualizer<MeshT>::mesh->halfedges_end());
OVMPropertyVisualizer<MeshT>::mesh->halfedges_end(),
w->normalize_colors->isChecked());
if (_setDrawMode)
{
VolumeMeshObject<MeshT>* object;
......@@ -206,7 +215,8 @@ void OVMPropertyVisualizerVector<MeshT>::visualizeVertexProp(bool _setDrawMode)
OpenVolumeMesh::VertexPropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_vertex_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
visualizeVectorAsColorForEntity(prop,
OVMPropertyVisualizer<MeshT>::mesh->vertices_begin(),
OVMPropertyVisualizer<MeshT>::mesh->vertices_end());
OVMPropertyVisualizer<MeshT>::mesh->vertices_end(),
w->normalize_colors->isChecked());
if (_setDrawMode)
{
VolumeMeshObject<MeshT>* object;
......
......@@ -2,11 +2,31 @@
<ui version="4.0">
<class>VectorWidget</class>
<widget class="QWidget" name="VectorWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>325</width>
<height>201</height>
</rect>
</property>
<property name="windowTitle">
<string>Property Visualization</string>
</property>
<property name="toolTip">
<string>Vectors are normalized and then transformed to the [0,1] range</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
......@@ -15,46 +35,124 @@
<string>3D Vector Parameters</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="vector_edgeColors_widget" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<property name="visible">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</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>
<property name="decimals">
<number>4</number>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.400000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string></string>
</property>
</widget>
</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>
<property name="decimals">
<number>4</number>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.600000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QRadioButton" name="vectors_edges_rb">
<item row="0" column="1">
<widget class="QRadioButton" name="vectors_colors_rb">
<property name="text">
<string>Color Edges According
to Angle btw. Vectors</string>
<string>Encode as RGB</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">
<item row="1" column="1">
<widget class="QRadioButton" name="vectors_length_color_rb">
<property name="text">
<string>Strokes</string>
</property>
<property name="checked">
<bool>true</bool>
<string>Length as Color</string>
</property>
<attribute name="buttonGroup">
<string notr="true">vector_buttonGroup</string>
</attribute>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="vectors_colors_rb">
<item row="0" column="0">
<widget class="QRadioButton" name="vectors_strokes_rb">
<property name="text">
<string>Encode as RGB</string>
<string>Strokes</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">vector_buttonGroup</string>
</attribute>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="vectors_length_color_rb">
<item row="1" column="0">
<widget class="QRadioButton" name="vectors_edges_rb">
<property name="text">
<string>Length as Color</string>
<string>Color Edges According
to Angle btw. Vectors</string>
</property>
<attribute name="buttonGroup">
<string notr="true">vector_buttonGroup</string>
......@@ -133,78 +231,19 @@
</widget>
</item>
<item>
<widget class="QWidget" name="vector_edgeColors_widget" native="true">
<widget class="QCheckBox" name="normalize_colors">
<property name="enabled">
<bool>true</bool>
</property>
<property name="visible">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</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>
<property name="decimals">
<number>4</number>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.400000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string></string>
</property>
</widget>
</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>
<property name="decimals">
<number>4</number>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.600000000000000</double>
</property>
</widget>
</item>
</layout>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Vectors are first normalized and then scaled to the [0,1] range&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Normalize</string>
</property>
</widget>
</item>
</layout>
......@@ -262,6 +301,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>vectors_edges_rb</sender>
<signal>toggled(bool)</signal>
<receiver>vector_edgeColors_widget</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>88</x>
<y>86</y>
</hint>
<hint type="destinationlabel">
<x>65</x>
<y>209</y>
</hint>
</hints>
</connection>
<connection>
<sender>vectors_strokes_rb</sender>
<signal>toggled(bool)</signal>
......@@ -279,18 +334,18 @@
</hints>
</connection>
<connection>
<sender>vectors_edges_rb</sender>
<sender>vectors_colors_rb</sender>
<signal>toggled(bool)</signal>
<receiver>vector_edgeColors_widget</receiver>
<receiver>normalize_colors</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>88</x>
<y>86</y>
<x>249</x>
<y>71</y>
</hint>
<hint type="destinationlabel">
<x>65</x>
<y>209</y>
<x>162</x>
<y>229</y>
</hint>
</hints>
</connection>
......
Supports Markdown
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