Commit 4f240755 authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

Plugin-PropertyVis: Added color viz for vector properties.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14826 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 657c9ebd
......@@ -433,8 +433,7 @@ namespace {
};
}
void PropertyVisPlugin::slotVisualize()
{
void PropertyVisPlugin::slotVisualize() {
int id = tool_->meshNames->itemData( tool_->meshNames->currentIndex() ).toInt();
BaseObjectData* object = 0;
......@@ -454,6 +453,9 @@ void PropertyVisPlugin::slotVisualize()
return;
}
// Actual Viz takes place in try-catch block to catch VizExceptions.
try {
/*
* Visualize single properties.
*/
......@@ -463,8 +465,10 @@ void PropertyVisPlugin::slotVisualize()
const PropertyNameListModel::PROP_INFO &currentProp = propertyNameListModel_[it->row()];
if (triMesh) visualizeProperty(triMesh, currentProp);
else if (polyMesh) visualizeProperty(polyMesh, currentProp);
if (triMesh)
visualizeProperty(triMesh, currentProp);
else if (polyMesh)
visualizeProperty(polyMesh, currentProp);
}
/*
......@@ -476,11 +480,14 @@ void PropertyVisPlugin::slotVisualize()
std::vector<const PropertyNameListModel::PROP_INFO*> propList;
QModelIndexList selectedIndices = tool_->propertyName_lv->selectionModel()->selectedIndexes();
for (QModelIndexList::const_iterator it = selectedIndices.begin(), it_end = selectedIndices.end();
it != it_end; ++it) {
const PropertyNameListModel::PROP_INFO &currentProp = propertyNameListModel_[it->row()];
if (currentProp.typeinfo() == PropertyNameListModel::proptype_Vec3d || currentProp.typeinfo() == PropertyNameListModel::proptype_Vec3f)
QModelIndexList selectedIndices =
tool_->propertyName_lv->selectionModel()->selectedIndexes();
for (QModelIndexList::const_iterator it = selectedIndices.begin(), it_end =
selectedIndices.end(); it != it_end; ++it) {
const PropertyNameListModel::PROP_INFO &currentProp =
propertyNameListModel_[it->row()];
if (currentProp.typeinfo() == PropertyNameListModel::proptype_Vec3d
|| currentProp.typeinfo() == PropertyNameListModel::proptype_Vec3f)
propList.push_back(&currentProp);
}
......@@ -493,19 +500,34 @@ void PropertyVisPlugin::slotVisualize()
*/
if (it != propList.end()) {
if (tool_->vecFieldDiff_norm_diff_rb->isChecked()) {
if (triMesh) visualizeVectorFieldDifference<TriMesh, scalarFn_norm_of_diff<TriMesh> >(triMesh, **it, **(it+1));
else if (polyMesh) visualizeVectorFieldDifference<PolyMesh, scalarFn_norm_of_diff<PolyMesh> >(polyMesh, **it, **(it+1));
if (triMesh)
visualizeVectorFieldDifference<TriMesh, scalarFn_norm_of_diff<TriMesh> >(
triMesh, **it, **(it + 1));
else if (polyMesh)
visualizeVectorFieldDifference<PolyMesh, scalarFn_norm_of_diff<PolyMesh> >(
polyMesh, **it, **(it + 1));
} else if (tool_->vecFieldDiff_diff_norm_rb->isChecked()) {
if (triMesh) visualizeVectorFieldDifference<TriMesh, scalarFn_diff_of_norms<TriMesh> >(triMesh, **it, **(it+1));
else if (polyMesh) visualizeVectorFieldDifference<PolyMesh, scalarFn_diff_of_norms<PolyMesh> >(polyMesh, **it, **(it+1));
if (triMesh)
visualizeVectorFieldDifference<TriMesh, scalarFn_diff_of_norms<TriMesh> >(
triMesh, **it, **(it + 1));
else if (polyMesh)
visualizeVectorFieldDifference<PolyMesh, scalarFn_diff_of_norms<PolyMesh> >(
polyMesh, **it, **(it + 1));
} else if (tool_->vecFieldDiff_4symm_rb->isChecked()) {
if (triMesh) visualizeVectorFieldDifference<TriMesh, scalarFn_4_symm_diff<TriMesh> >(triMesh, **it, **(it+1));
else if (polyMesh) visualizeVectorFieldDifference<PolyMesh, scalarFn_4_symm_diff<PolyMesh> >(polyMesh, **it, **(it+1));
if (triMesh)
visualizeVectorFieldDifference<TriMesh, scalarFn_4_symm_diff<TriMesh> >(
triMesh, **it, **(it + 1));
else if (polyMesh)
visualizeVectorFieldDifference<PolyMesh, scalarFn_4_symm_diff<PolyMesh> >(
polyMesh, **it, **(it + 1));
} else {
emit log("This vector field difference mode is not implemented.");
}
}
}
} catch (const VizException &e) {
QMessageBox::warning(this->tool_, trUtf8("Error in Visualization"), trUtf8(e.what()), QMessageBox::Cancel, QMessageBox::Cancel);
}
emit updatedObject( object->id(), UPDATE_COLOR );
}
......
......@@ -83,8 +83,14 @@
#include <ACG/Scenegraph/LineNode.hh>
#include <ACG/Utils/ColorGenerator.hh>
#include <stdexcept>
//== CLASS DEFINITION =========================================================
class VizException : public std::logic_error {
public:
VizException(const std::string &msg) : std::logic_error(msg) {}
};
class PropertyVisPlugin : public QObject, BaseInterface, ToolboxInterface, KeyInterface, ScriptInterface, MouseInterface, PickingInterface, LoggingInterface, INIInterface
{
......@@ -252,6 +258,12 @@ private:
template< class MeshT >
typename MeshT::Point halfedge_point(const typename MeshT::HalfedgeHandle _heh, const MeshT *_mesh);
template< class MeshT >
void visualizeVector_asStroke( MeshT* _mesh, const PropertyNameListModel::PROP_INFO &currentProp);
template< class MeshT >
void visualizeVector_asColor( MeshT* _mesh, const PropertyNameListModel::PROP_INFO &currentProp);
template< class MeshT >
void visualizeDouble( MeshT* _mesh, const PropertyNameListModel::PROP_INFO &currentProp);
......
......@@ -55,9 +55,60 @@
//------------------------------------------------------------------------------
template< class MeshT >
void PropertyVisPlugin::visualizeVector( MeshT* _mesh, const PropertyNameListModel::PROP_INFO &currentProp)
{
template<class MeshT>
void PropertyVisPlugin::visualizeVector(
MeshT* _mesh, const PropertyNameListModel::PROP_INFO &currentProp) {
if (tool_->vectors_strokes_rb->isChecked()) {
visualizeVector_asStroke(_mesh, currentProp);
} else if (tool_->vectors_colors_rb->isChecked()) {
visualizeVector_asColor(_mesh, currentProp);
} else {
throw VizException("Unknown vector viz mode selected.");
}
}
namespace {
template<typename PROPTYPE, typename MeshT, typename ENTITY_IT, typename PROPINFO_TYPE>
void visualizeVector_asColorForEntity(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.");
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);
mesh->set_color(*e_it, typename MeshT::Color(v[0], v[1], v[2], 1.0));
}
}
} /* anonymous namespace */
template<class MeshT>
void PropertyVisPlugin::visualizeVector_asColor(
MeshT* _mesh, const PropertyNameListModel::PROP_INFO &currentProp) {
if (currentProp.isFaceProp()) {
visualizeVector_asColorForEntity<OpenMesh::FPropHandleT<typename MeshT::Point> >(
_mesh, _mesh->faces_begin(), _mesh->faces_end(), currentProp);
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED);
} else if (currentProp.isVertexProp()) {
visualizeVector_asColorForEntity<OpenMesh::VPropHandleT<typename MeshT::Point> >(
_mesh, _mesh->vertices_begin(), _mesh->vertices_end(), currentProp);
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED);
} else if (currentProp.isEdgeProp()) {
visualizeVector_asColorForEntity<OpenMesh::EPropHandleT<typename MeshT::Point> >(
_mesh, _mesh->edges_begin(), _mesh->edges_end(), currentProp);
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED);
} else {
throw VizException("PropertyVisPlugin::visualizeVector_asColor: Unknown property type.");
}
}
template<class MeshT>
void PropertyVisPlugin::visualizeVector_asStroke(
MeshT* _mesh, const PropertyNameListModel::PROP_INFO &currentProp) {
//perhaps add the node
......
......@@ -658,6 +658,31 @@
<string>3D Vector Parameters</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="vectors_strokes_rb">
<property name="text">
<string>Strokes</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string>vector_buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QWidget" name="vector_strokes_widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_11">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="normalize">
<property name="text">
......@@ -712,6 +737,19 @@
</layout>
</widget>
</item>
<item>
<widget class="QRadioButton" name="vectors_colors_rb">
<property name="text">
<string>Colors</string>
</property>
<attribute name="buttonGroup">
<string>vector_buttonGroup</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="paramSkinWeights">
<property name="title">
......@@ -1007,10 +1045,8 @@
<tabstop>vecFieldDiff_4symm_rb</tabstop>
<tabstop>vecFieldDiff_diff_norm_rb</tabstop>
<tabstop>vecFieldDiff_norm_diff_rb</tabstop>
<tabstop>normalize</tabstop>
<tabstop>scale</tabstop>
<tabstop>scaleBox</tabstop>
<tabstop>lineColor</tabstop>
<tabstop>boneId</tabstop>
<tabstop>pickButton</tabstop>
<tabstop>propertyDataType</tabstop>
......@@ -1254,14 +1290,33 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>192</x>
<y>1308</y>
<x>224</x>
<y>1348</y>
</hint>
<hint type="destinationlabel">
<x>418</x>
<y>1351</y>
</hint>
</hints>
</connection>
<connection>
<sender>vectors_strokes_rb</sender>
<signal>toggled(bool)</signal>
<receiver>vector_strokes_widget</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>60</x>
<y>1273</y>
</hint>
<hint type="destinationlabel">
<x>266</x>
<y>1307</y>
<x>29</x>
<y>1328</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="vector_buttonGroup"/>
</buttongroups>
</ui>
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