Commit 347a79e6 authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

Plugin-PropertyVis: Implemented another vector property viz mode.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14900 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 4f240755
......@@ -186,12 +186,13 @@ void PropertyVisPlugin::updateGUI() {
void PropertyVisPlugin::propertySelectionChanged() {
enum TYPE {
T_VECTOR = 0x01,
T_DOUBLE = 0x02,
T_INT = 0x04,
T_UINT = 0x08,
T_BOOL = 0x10,
T_SKIN_WEIGHTS = 0x20,
T_VECTOR = 1 << 0,
T_DOUBLE = 1 << 1,
T_INT = 1 << 2,
T_UINT = 1 << 3,
T_BOOL = 1 << 4,
T_SKIN_WEIGHTS = 1 << 5,
T_VECTOR_EDGES = 1 << 6,
};
int visibleMask = 0;
......@@ -208,6 +209,8 @@ void PropertyVisPlugin::propertySelectionChanged() {
currentProp.typeinfo() == PropertyNameListModel::proptype_Vec3f) {
visibleMask |= T_VECTOR;
++selectedVectors;
if (currentProp.entityType() == PropertyNameListModel::EF_FACE)
visibleMask |= T_VECTOR_EDGES;
} else if (currentProp.typeinfo() == PropertyNameListModel::proptype_double) {
visibleMask |= T_DOUBLE;
} else if (currentProp.typeinfo() == PropertyNameListModel::proptype_int) {
......@@ -234,6 +237,9 @@ void PropertyVisPlugin::propertySelectionChanged() {
tool_->paramInt->setVisible(visibleMask & T_INT);
tool_->paramBool->setVisible(visibleMask & T_BOOL);
tool_->paramSkinWeights->setVisible(visibleMask & T_SKIN_WEIGHTS);
tool_->vectors_edges_rb->setVisible(visibleMask & T_VECTOR_EDGES);
if (tool_->vectors_edges_rb->isChecked() && (visibleMask & T_VECTOR_EDGES) == 0)
tool_->vectors_strokes_rb->setChecked(true);
}
......
......@@ -264,6 +264,9 @@ private:
template< class MeshT >
void visualizeVector_asColor( MeshT* _mesh, const PropertyNameListModel::PROP_INFO &currentProp);
template< class MeshT >
void visualizeVector_onEdges( MeshT* _mesh, const PropertyNameListModel::PROP_INFO &currentProp);
template< class MeshT >
void visualizeDouble( MeshT* _mesh, const PropertyNameListModel::PROP_INFO &currentProp);
......
......@@ -51,6 +51,7 @@
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <ACG/Utils/ColorCoder.hh>
#include <cmath>
//------------------------------------------------------------------------------
......@@ -63,11 +64,59 @@ void PropertyVisPlugin::visualizeVector(
visualizeVector_asStroke(_mesh, currentProp);
} else if (tool_->vectors_colors_rb->isChecked()) {
visualizeVector_asColor(_mesh, currentProp);
} else if (tool_->vectors_edges_rb->isChecked()) {
visualizeVector_onEdges(_mesh, currentProp);
} else {
throw VizException("Unknown vector viz mode selected.");
}
}
template<class MeshT>
void PropertyVisPlugin::visualizeVector_onEdges(
MeshT* _mesh, const PropertyNameListModel::PROP_INFO &currentProp) {
const double thresh_1 = tool_->vectors_edges_alpha->value();
const double thresh_2 = std::min(thresh_1, tool_->vectors_edges_alpha->value());
if (!currentProp.isFaceProp())
throw VizException("Sorry, this viz mode is only available for face properties.");
OpenMesh::FPropHandleT<typename MeshT::Point> prop;
if (!_mesh->get_property_handle(prop, currentProp.propName()))
throw VizException("Getting PropHandle from mesh for selected property failed.");
if (!_mesh->has_edge_colors())
_mesh->request_edge_colors();
const ACG::Vec4f cold(0, 0, 0, 1.0), hot(0, 1, 0, 1.0), degen(1, 1, 0, 1.0);
for (typename MeshT::EdgeIter e_it = _mesh->edges_begin(), e_end = _mesh->edges_end();
e_it != e_end; ++e_it) {
typename MeshT::Point p1 = _mesh->property(prop, _mesh->face_handle(_mesh->halfedge_handle(*e_it, 0)));
typename MeshT::Point p2 = _mesh->property(prop, _mesh->face_handle(_mesh->halfedge_handle(*e_it, 1)));
ACG::Vec4f color;
const char degenerate = ((p1.sqrnorm() < 1e-6) ? 1 : 0) | ((p2.sqrnorm() < 1e-6) ? 2 : 0);
if (degenerate == 3) {
color = cold;
} else if (degenerate == 0) {
p1.normalize(); p2.normalize();
const double alpha = std::min(1.0, std::abs(p1 | p2));
if (alpha < thresh_1)
color = hot;
else if (alpha > thresh_2)
color = cold;
else {
const double beta = (alpha - thresh_1) / (thresh_2 - thresh_1);
color = cold * beta + hot * (1.0 - beta);
}
} else {
color = degen;
}
_mesh->set_color(e_it, color);
}
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED | ACG::SceneGraph::DrawModes::EDGES_COLORED);
}
namespace {
template<typename PROPTYPE, typename MeshT, typename ENTITY_IT, typename PROPINFO_TYPE>
......
......@@ -747,6 +747,85 @@
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="vectors_edges_rb">
<property name="text">
<string>Color Edges According to Angle btw. Vectors</string>
</property>
<attribute name="buttonGroup">
<string>vector_buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QWidget" name="vector_edgeColors_widget" native="true">
<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="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="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string></string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="vectors_edges_beta">
<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>
</layout>
</widget>
</item>
......@@ -1066,12 +1145,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>216</x>
<y>856</y>
<x>242</x>
<y>821</y>
</hint>
<hint type="destinationlabel">
<x>219</x>
<y>758</y>
<y>723</y>
</hint>
</hints>
</connection>
......@@ -1082,12 +1161,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>236</x>
<y>856</y>
<x>262</x>
<y>821</y>
</hint>
<hint type="destinationlabel">
<x>418</x>
<y>758</y>
<y>723</y>
</hint>
</hints>
</connection>
......@@ -1098,12 +1177,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>159</x>
<y>856</y>
<x>185</x>
<y>821</y>
</hint>
<hint type="destinationlabel">
<x>150</x>
<y>889</y>
<x>177</x>
<y>854</y>
</hint>
</hints>
</connection>
......@@ -1114,12 +1193,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>217</x>
<y>856</y>
<x>243</x>
<y>821</y>
</hint>
<hint type="destinationlabel">
<x>418</x>
<y>892</y>
<y>857</y>
</hint>
</hints>
</connection>
......@@ -1130,8 +1209,8 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>166</x>
<y>1129</y>
<x>192</x>
<y>1094</y>
</hint>
<hint type="destinationlabel">
<x>135</x>
......@@ -1146,12 +1225,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>88</x>
<y>1129</y>
<x>114</x>
<y>1094</y>
</hint>
<hint type="destinationlabel">
<x>86</x>
<y>1159</y>
<x>112</x>
<y>1124</y>
</hint>
</hints>
</connection>
......@@ -1162,12 +1241,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>109</x>
<y>1129</y>
<x>135</x>
<y>1094</y>
</hint>
<hint type="destinationlabel">
<x>111</x>
<y>1189</y>
<x>137</x>
<y>1154</y>
</hint>
</hints>
</connection>
......@@ -1178,12 +1257,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>134</x>
<y>1129</y>
<x>160</x>
<y>1094</y>
</hint>
<hint type="destinationlabel">
<x>137</x>
<y>1219</y>
<x>163</x>
<y>1184</y>
</hint>
</hints>
</connection>
......@@ -1194,12 +1273,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>122</x>
<y>513</y>
<x>148</x>
<y>480</y>
</hint>
<hint type="destinationlabel">
<x>121</x>
<y>537</y>
<x>148</x>
<y>516</y>
</hint>
</hints>
</connection>
......@@ -1210,12 +1289,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>162</x>
<y>505</y>
<x>188</x>
<y>480</y>
</hint>
<hint type="destinationlabel">
<x>365</x>
<y>538</y>
<x>418</x>
<y>516</y>
</hint>
</hints>
</connection>
......@@ -1226,12 +1305,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>107</x>
<y>718</y>
<x>133</x>
<y>687</y>
</hint>
<hint type="destinationlabel">
<x>106</x>
<y>742</y>
<x>133</x>
<y>723</y>
</hint>
</hints>
</connection>
......@@ -1242,12 +1321,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>176</x>
<y>706</y>
<x>202</x>
<y>687</y>
</hint>
<hint type="destinationlabel">
<x>366</x>
<y>737</y>
<x>418</x>
<y>723</y>
</hint>
</hints>
</connection>
......@@ -1258,12 +1337,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>101</x>
<y>947</y>
<x>127</x>
<y>924</y>
</hint>
<hint type="destinationlabel">
<x>101</x>
<y>976</y>
<x>128</x>
<y>960</y>
</hint>
</hints>
</connection>
......@@ -1274,12 +1353,12 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>296</x>
<y>954</y>
<x>322</x>
<y>924</y>
</hint>
<hint type="destinationlabel">
<x>294</x>
<y>973</y>
<x>418</x>
<y>960</y>
</hint>
</hints>
</connection>
......@@ -1291,11 +1370,11 @@
<hints>
<hint type="sourcelabel">
<x>224</x>
<y>1348</y>
<y>1313</y>
</hint>
<hint type="destinationlabel">
<x>418</x>
<y>1351</y>
<y>1316</y>
</hint>
</hints>
</connection>
......@@ -1306,8 +1385,8 @@
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>60</x>
<y>1273</y>
<x>86</x>
<y>1250</y>
</hint>
<hint type="destinationlabel">
<x>29</x>
......@@ -1315,6 +1394,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>52</x>
<y>1403</y>
</hint>
<hint type="destinationlabel">
<x>31</x>
<y>1425</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="vector_buttonGroup"/>
......
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