Commit 5d154ef2 authored by Martin Heistermann's avatar Martin Heistermann
Browse files

Implement propvis histograms for OM/OVM double properties.

parent 9dbcb099
...@@ -27,5 +27,9 @@ if(OPENVOLUMEMESH_FOUND) ...@@ -27,5 +27,9 @@ if(OPENVOLUMEMESH_FOUND)
endif() endif()
endif() endif()
find_package(CXX11)
if(CXX11_FLAG_DETECTED)
add_definitions (-DENABLE_PROPVIS_HISTOGRAMS)
endif()
openflipper_plugin (INSTALLDATA Icons DIRS OpenMesh OpenVolumeMesh Widgets DEPS OpenMesh OpenVolumeMesh) openflipper_plugin (INSTALLDATA Icons DIRS OpenMesh OpenVolumeMesh Widgets DEPS OpenMesh OpenVolumeMesh)
...@@ -140,6 +140,11 @@ protected: ...@@ -140,6 +140,11 @@ protected:
template <typename InnerType > template <typename InnerType >
QString getPropertyText_(unsigned int index); QString getPropertyText_(unsigned int index);
#ifdef ENABLE_PROPVIS_HISTOGRAMS
template<typename Type>
void showHistogram(ACG::QtWidgets::QtHistogramWidget *histogramWidget);
#endif
private: private:
template<typename PropHandleT> template<typename PropHandleT>
class CopyProperty class CopyProperty
...@@ -157,7 +162,6 @@ private: ...@@ -157,7 +162,6 @@ private:
const PropHandleT &p1, &p2; const PropHandleT &p1, &p2;
MeshT*& mesh; MeshT*& mesh;
}; };
}; };
......
...@@ -84,6 +84,8 @@ protected: ...@@ -84,6 +84,8 @@ protected:
virtual void setEdgePropertyFromText(unsigned int index, QString text); virtual void setEdgePropertyFromText(unsigned int index, QString text);
virtual void setHalfedgePropertyFromText(unsigned int index, QString text); virtual void setHalfedgePropertyFromText(unsigned int index, QString text);
virtual void setVertexPropertyFromText(unsigned int index, QString text); virtual void setVertexPropertyFromText(unsigned int index, QString text);
ACG::IColorCoder *buildColorCoder() override;
}; };
......
...@@ -60,6 +60,10 @@ OMPropertyVisualizerDouble<MeshT>::OMPropertyVisualizerDouble(MeshT* _mesh, Prop ...@@ -60,6 +60,10 @@ OMPropertyVisualizerDouble<MeshT>::OMPropertyVisualizerDouble(MeshT* _mesh, Prop
DoubleWidget* w = new DoubleWidget(); DoubleWidget* w = new DoubleWidget();
w->paramDouble->setTitle(QString("Double Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str())); w->paramDouble->setTitle(QString("Double Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
PropertyVisualizer::widget = w; PropertyVisualizer::widget = w;
#ifdef ENABLE_PROPVIS_HISTOGRAMS
this->connect(w->computeHistogramButton, &QPushButton::clicked,
[this, w](){this->template showHistogram<double>(w->histogram);});
#endif
} }
template <typename MeshT> template <typename MeshT>
...@@ -449,6 +453,13 @@ void OMPropertyVisualizerDouble<MeshT>::setVertexPropertyFromText(unsigned int i ...@@ -449,6 +453,13 @@ void OMPropertyVisualizerDouble<MeshT>::setVertexPropertyFromText(unsigned int i
mesh->property(prop, vh) = this->strToDouble(text); mesh->property(prop, vh) = this->strToDouble(text);
} }
template<typename MeshT>
ACG::IColorCoder *OMPropertyVisualizerDouble<MeshT>::buildColorCoder()
{
DoubleWidget* doubleWidget = static_cast<DoubleWidget*>(PropertyVisualizer::widget);
return doubleWidget->buildColorCoder();
}
template<typename MeshT> template<typename MeshT>
void OMPropertyVisualizerDouble<MeshT>::removeProperty() void OMPropertyVisualizerDouble<MeshT>::removeProperty()
......
...@@ -423,3 +423,59 @@ void OMPropertyVisualizer<MeshT>::setVertexPropertyFromText(unsigned int index, ...@@ -423,3 +423,59 @@ void OMPropertyVisualizer<MeshT>::setVertexPropertyFromText(unsigned int index,
{ {
emit log(LOGERR, "Setting vertex property not implemented"); emit log(LOGERR, "Setting vertex property not implemented");
} }
#ifdef ENABLE_PROPVIS_HISTOGRAMS
template<typename MeshT>
template<typename Type>
void OMPropertyVisualizer<MeshT>::showHistogram(ACG::QtWidgets::QtHistogramWidget *histogramWidget) {
using PV = OMPropertyVisualizer<MeshT>;
const std::string &prop_name = PV::propertyInfo.propName();
// ugly repetition ahead. In C++14, we could use a generic lambda,
// in C++11 the cleanest solution would be to add another templated member function - not worth it.
switch (PropertyVisualizer::propertyInfo.entityType()) {
case PropertyInfo::EF_FACE:
{
OpenMesh::FPropHandleT<Type> prop_handle;
if (!PV::mesh->get_property_handle(prop_handle, prop_name)) break;
PropertyVisualizer::template showHistogramT<Type>(
histogramWidget,
PV::mesh->property(prop_handle).data_vector());
break;
}
case PropertyInfo::EF_EDGE:
{
OpenMesh::EPropHandleT<Type> prop_handle;
if (!PV::mesh->get_property_handle(prop_handle, prop_name)) break;
PropertyVisualizer::template showHistogramT<Type>(
histogramWidget,
PV::mesh->property(prop_handle).data_vector());
break;
}
case PropertyInfo::EF_HALFEDGE:
{
OpenMesh::HPropHandleT<Type> prop_handle;
if (!PV::mesh->get_property_handle(prop_handle, prop_name)) break;
PropertyVisualizer::template showHistogramT<Type>(
histogramWidget,
PV::mesh->property(prop_handle).data_vector());
break;
}
case PropertyInfo::EF_VERTEX:
{
OpenMesh::VPropHandleT<Type> prop_handle;
if (!PV::mesh->get_property_handle(prop_handle, prop_name)) break;
PropertyVisualizer::template showHistogramT<Type>(
histogramWidget,
PV::mesh->property(prop_handle).data_vector());
break;
}
default:
assert(false);
}
}
#endif
...@@ -60,6 +60,8 @@ ...@@ -60,6 +60,8 @@
#include <ObjectTypes/VolumeMeshObject/VolumeMeshDrawModesContainer.hh> #include <ObjectTypes/VolumeMeshObject/VolumeMeshDrawModesContainer.hh>
#include <ACG/QtWidgets/QtHistogramWidget.hh>
#include <iostream> #include <iostream>
template <typename MeshT> template <typename MeshT>
...@@ -97,6 +99,12 @@ public: ...@@ -97,6 +99,12 @@ public:
/// Returns the ID of the closest primitive. /// Returns the ID of the closest primitive.
unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint); unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint);
#ifdef ENABLE_PROPVIS_HISTOGRAMS
protected slots:
template <typename Type>
void showHistogram(ACG::QtWidgets::QtHistogramWidget *histogramWidget);
#endif
protected: protected:
MeshT* mesh; MeshT* mesh;
...@@ -240,3 +248,4 @@ void Classname::visualizeVertexProp(bool _setDrawMode)\ ...@@ -240,3 +248,4 @@ void Classname::visualizeVertexProp(bool _setDrawMode)\
#endif /* OVM_PROPERTY_VISUALIZER_HH */ #endif /* OVM_PROPERTY_VISUALIZER_HH */
#endif /* ENABLE_OPENVOLUMEMESH_SUPPORT */ #endif /* ENABLE_OPENVOLUMEMESH_SUPPORT */
...@@ -89,6 +89,8 @@ protected: ...@@ -89,6 +89,8 @@ protected:
virtual void setEdgePropertyFromText(unsigned int index, QString text); virtual void setEdgePropertyFromText(unsigned int index, QString text);
virtual void setHalfedgePropertyFromText(unsigned int index, QString text); virtual void setHalfedgePropertyFromText(unsigned int index, QString text);
virtual void setVertexPropertyFromText(unsigned int index, QString text); virtual void setVertexPropertyFromText(unsigned int index, QString text);
ACG::IColorCoder *buildColorCoder() override;
}; };
#if defined(INCLUDE_TEMPLATES) && !defined(OVM_PROPERTY_VISUALIZER_DOUBLE_CC) #if defined(INCLUDE_TEMPLATES) && !defined(OVM_PROPERTY_VISUALIZER_DOUBLE_CC)
......
...@@ -57,6 +57,8 @@ ...@@ -57,6 +57,8 @@
#include <ACG/Utils/LinearTwoColorCoder.hh> #include <ACG/Utils/LinearTwoColorCoder.hh>
#include <ACG/Utils/ColorConversion.hh> #include <ACG/Utils/ColorConversion.hh>
#include <QObject>
template <typename MeshT> template <typename MeshT>
OVMPropertyVisualizerDouble<MeshT>::OVMPropertyVisualizerDouble(MeshT* _mesh, int objectID, PropertyInfo _propertyInfo) OVMPropertyVisualizerDouble<MeshT>::OVMPropertyVisualizerDouble(MeshT* _mesh, int objectID, PropertyInfo _propertyInfo)
: OVMPropertyVisualizer<MeshT>(_mesh, objectID, _propertyInfo) : OVMPropertyVisualizer<MeshT>(_mesh, objectID, _propertyInfo)
...@@ -65,6 +67,11 @@ OVMPropertyVisualizerDouble<MeshT>::OVMPropertyVisualizerDouble(MeshT* _mesh, in ...@@ -65,6 +67,11 @@ OVMPropertyVisualizerDouble<MeshT>::OVMPropertyVisualizerDouble(MeshT* _mesh, in
DoubleWidget* w = new DoubleWidget(); DoubleWidget* w = new DoubleWidget();
w->paramDouble->setTitle(QString("Double Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str())); w->paramDouble->setTitle(QString("Double Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
PropertyVisualizer::widget = w; PropertyVisualizer::widget = w;
#ifdef ENABLE_PROPVIS_HISTOGRAMS
this->connect(w->computeHistogramButton, &QPushButton::clicked,
[this, w](){this->template showHistogram<double>(w->histogram);});
#endif
} }
template <typename MeshT> template <typename MeshT>
...@@ -261,4 +268,11 @@ void OVMPropertyVisualizerDouble<MeshT>::setVertexPropertyFromText(unsigned int ...@@ -261,4 +268,11 @@ void OVMPropertyVisualizerDouble<MeshT>::setVertexPropertyFromText(unsigned int
prop[vh] = this->strToDouble(text); prop[vh] = this->strToDouble(text);
} }
template <typename MeshT>
ACG::IColorCoder *OVMPropertyVisualizerDouble<MeshT>::buildColorCoder()
{
DoubleWidget* doubleWidget = static_cast<DoubleWidget*>(PropertyVisualizer::widget);
return doubleWidget->buildColorCoder();
}
#endif /* ENABLE_OPENVOLUMEMESH_SUPPORT */ #endif /* ENABLE_OPENVOLUMEMESH_SUPPORT */
...@@ -88,6 +88,8 @@ protected: ...@@ -88,6 +88,8 @@ protected:
virtual void setHalfedgePropertyFromText(unsigned int index, QString text); virtual void setHalfedgePropertyFromText(unsigned int index, QString text);
virtual void setVertexPropertyFromText(unsigned int index, QString text); virtual void setVertexPropertyFromText(unsigned int index, QString text);
ACG::IColorCoder *buildColorCoder() override;
T mNumericLimitMax; T mNumericLimitMax;
T mNumericLimitMin; T mNumericLimitMin;
......
...@@ -265,4 +265,11 @@ void OVMPropertyVisualizerInteger<MeshT, T>::setVertexPropertyFromText(unsigned ...@@ -265,4 +265,11 @@ void OVMPropertyVisualizerInteger<MeshT, T>::setVertexPropertyFromText(unsigned
prop[vh] = this->strToInt(text); prop[vh] = this->strToInt(text);
} }
template <typename MeshT, typename T>
ACG::IColorCoder *OVMPropertyVisualizerInteger<MeshT, T>::buildColorCoder()
{
IntegerWidget* integerWidget = static_cast<IntegerWidget*>(PropertyVisualizer::widget);
return integerWidget->buildColorCoder();
}
#endif /* ENABLE_OPENVOLUMEMESH_SUPPORT */ #endif /* ENABLE_OPENVOLUMEMESH_SUPPORT */
...@@ -63,6 +63,8 @@ ...@@ -63,6 +63,8 @@
#include "OVMPropertyVisualizer.hh" #include "OVMPropertyVisualizer.hh"
#include <ACG/Utils/Histogram.hh>
template <typename MeshT> template <typename MeshT>
template <typename InnerType> template <typename InnerType>
QString OVMPropertyVisualizer<MeshT>::getPropertyText_(unsigned int index) QString OVMPropertyVisualizer<MeshT>::getPropertyText_(unsigned int index)
...@@ -407,4 +409,49 @@ void OVMPropertyVisualizer<MeshT>::setVertexPropertyFromText(unsigned int /*inde ...@@ -407,4 +409,49 @@ void OVMPropertyVisualizer<MeshT>::setVertexPropertyFromText(unsigned int /*inde
emit log(LOGERR, "Setting VertexProp not implemented for this property type"); emit log(LOGERR, "Setting VertexProp not implemented for this property type");
} }
#ifdef ENABLE_PROPVIS_HISTOGRAMS
template<typename MeshT>
template<typename Type>
void OVMPropertyVisualizer<MeshT>::showHistogram(ACG::QtWidgets::QtHistogramWidget *histogramWidget) {
using PV = OVMPropertyVisualizer<MeshT>;
const std::string &prop_name = PV::propertyInfo.propName();
switch (PropertyVisualizer::propertyInfo.entityType()) {
case PropertyInfo::EF_CELL:
this->showHistogramT<Type>(
histogramWidget,
PV::mesh->template request_cell_property<Type>(prop_name));
break;
case PropertyInfo::EF_FACE:
this->showHistogramT<Type>(
histogramWidget,
PV::mesh->template request_face_property<Type>(prop_name));
break;
case PropertyInfo::EF_HALFFACE:
this->showHistogramT<Type>(
histogramWidget,
PV::mesh->template request_halfface_property<Type>(prop_name));
break;
case PropertyInfo::EF_EDGE:
this->showHistogramT<Type>(
histogramWidget,
PV::mesh->template request_edge_property<Type>(prop_name));
break;
case PropertyInfo::EF_HALFEDGE:
this->showHistogramT<Type>(
histogramWidget,
PV::mesh->template request_halfedge_property<Type>(prop_name));
break;
case PropertyInfo::EF_VERTEX:
this->showHistogramT<Type>(
histogramWidget,
PV::mesh->template request_vertex_property<Type>(prop_name));
break;
case PropertyInfo::EF_ANY:
assert(false);
}
}
#endif
#endif /* ENABLE_OPENVOLUMEMESH_SUPPORT */ #endif /* ENABLE_OPENVOLUMEMESH_SUPPORT */
...@@ -155,3 +155,8 @@ OpenMesh::Vec2f PropertyVisualizer::strToVec2f (QString str) ...@@ -155,3 +155,8 @@ OpenMesh::Vec2f PropertyVisualizer::strToVec2f (QString str)
QStringList strList = s.split(QObject::tr(", ")); QStringList strList = s.split(QObject::tr(", "));
return OpenMesh::Vec2f(strList[0].toFloat(),strList[1].toFloat()); return OpenMesh::Vec2f(strList[0].toFloat(),strList[1].toFloat());
} }
ACG::IColorCoder *PropertyVisualizer::buildColorCoder()
{
throw std::runtime_error("Requested color coder on a Propvis that does not implement it");
}
...@@ -54,6 +54,8 @@ ...@@ -54,6 +54,8 @@
#include <OpenFlipper/BasePlugin/BaseInterface.hh> #include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh> #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <ACG/QtWidgets/QtHistogramWidget.hh>
#include <ACG/Utils/IColorCoder.hh>
#include "OpenMesh/Core/Geometry/VectorT.hh" #include "OpenMesh/Core/Geometry/VectorT.hh"
...@@ -178,12 +180,31 @@ public: ...@@ -178,12 +180,31 @@ public:
protected: protected:
virtual ACG::IColorCoder *buildColorCoder();
#ifdef ENABLE_PROPVIS_HISTOGRAMS
template<typename PropType, typename Iterable>
void showHistogramT(ACG::QtWidgets::QtHistogramWidget *widget,
Iterable data);
#endif
PropertyInfo propertyInfo; PropertyInfo propertyInfo;
public: public:
QWidget* widget; QWidget* widget;
}; };
#ifdef ENABLE_PROPVIS_HISTOGRAMS
template<typename PropType, typename Iterable>
void PropertyVisualizer::showHistogramT(
ACG::QtWidgets::QtHistogramWidget *widget,
Iterable data)
{
const size_t max_bins = 50; // TODO: expose in GUI?
widget->setMinimumHeight(300);
widget->setColorCoder(buildColorCoder());
ACG::Histogram *hist = new ACG::HistogramT<PropType>(data.begin(), data.end(), max_bins);
widget->setHistogram(hist);
}
#endif
#endif /* PROPERTY_VISUALIZER_HH */ #endif /* PROPERTY_VISUALIZER_HH */
...@@ -6,29 +6,14 @@ ...@@ -6,29 +6,14 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>404</width> <width>453</width>
<height>172</height> <height>291</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Property Visualization</string> <string>Property Visualization</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<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> <item>
<widget class="QGroupBox" name="paramDouble"> <widget class="QGroupBox" name="paramDouble">
<property name="title"> <property name="title">
...@@ -152,6 +137,35 @@ ...@@ -152,6 +137,35 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="histogramGroupbox">
<property name="title">
<string>Histogram</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="computeHistogramButton">
<property name="text">
<string>Compute Histogram</string>
</property>
</widget>
</item>
<item>
<widget class="ACG::QtWidgets::QtHistogramWidget" name="histogram" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
...@@ -160,6 +174,12 @@ ...@@ -160,6 +174,12 @@
<extends>QPushButton</extends> <extends>QPushButton</extends>
<header>ACG/QtWidgets/QtColorChooserButton.hh</header> <header>ACG/QtWidgets/QtColorChooserButton.hh</header>
</customwidget> </customwidget>
<customwidget>
<class>ACG::QtWidgets::QtHistogramWidget</class>
<extends>QWidget</extends>
<header>ACG/QtWidgets/QtHistogramWidget.hh</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>doubleFixedRange</tabstop> <tabstop>doubleFixedRange</tabstop>
......
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