44#define OVM_PROPERTY_VISUALIZER_ITEGER_CC
46#include "OVMPropertyVisualizerInteger.hh"
47#include <ACG/Utils/ColorConversion.hh>
48#include <ACG/Utils/LinearTwoColorCoder.hh>
50template <
typename MeshT,
typename T>
54 if (PropertyVisualizer::widget)
delete PropertyVisualizer::widget;
56 w->paramInt->setTitle(QString(
"Integer Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
57 PropertyVisualizer::widget = w;
61 w->intAbsolute->setChecked(
false);
62 w->intAbsolute->setCheckable(
false);
66 mNumericLimitMax = std::numeric_limits<T>::max();
67 mNumericLimitMin = std::numeric_limits<T>::min();
69 this->connect(w->computeHistogramButton, &QPushButton::clicked,
70 [
this, w](){this->template showHistogram<T>(w->histogram);});
74template <
typename MeshT,
typename T>
75template <
typename PropType,
typename HandleIterable>
82 ACG::Vec4f colorMin = ACG::to_Vec4f(integerWidget->intMin->color());
84 std::map< int, ACG::Vec4f> randomColor;
86 if ( integerWidget->intRandom->isChecked() && integerWidget->intMapBlack->isChecked() )
87 randomColor[ integerWidget->intMapBlackValue->value() ] =
ACG::Vec4f(0.0, 0.0, 0.0, 0.0);
89 T
min = mNumericLimitMax;
90 T
max = mNumericLimitMin;
92 for (
const auto &h: handles)
95 min = std::min(
min, value);
96 max = std::max(
max, value);
99 if( integerWidget->intFixedRange->isChecked())
101 min = integerWidget->intFixedRangeMin->value();
102 max = integerWidget->intFixedRangeMax->value();
106 integerWidget->intFixedRangeMin->setValue(
min);
107 integerWidget->intFixedRangeMax->setValue(
max);
112 unsigned int range =
max -
min;
116 for (
const auto &h: handles)
119 object->colors()[h] = colorMin;
122 double pos = (value -
min) / (
double) range;
124 if ( integerWidget->intRandom->isChecked() )
127 if ( randomColor.find( value ) == randomColor.end() )
129 color = mColorGenerator.generateNextColor();
131 randomColor[ value ] = color;
133 color = randomColor[ value ];
137 color = cc->color_float4(pos);
140 object->colors()[h] = color;
148template <
typename MeshT,
typename T>
154template <
typename MeshT,
typename T>
160template <
typename MeshT,
typename T>
168 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
174 prop[ch] = this->strToInt(text);
177template <
typename MeshT,
typename T>
185 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
191 prop[fh] = this->strToInt(text);
194template <
typename MeshT,
typename T>
202 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
208 prop[hfh] = this->strToInt(text);
211template <
typename MeshT,
typename T>
219 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
225 prop[eh] = this->strToInt(text);
228template <
typename MeshT,
typename T>
236 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
242 prop[heh] = this->strToInt(text);
245template <
typename MeshT,
typename T>
253 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
259 prop[vh] = this->strToInt(text);
262template <
typename MeshT,
typename T>
QString getPropertyText(unsigned int index) override
Returns the value of a property in text form.
void duplicateProperty() override
Duplicates a property.
VectorT< Scalar, DIM > min(const VectorT< Scalar, DIM > &_v1, const VectorT< Scalar, DIM > &_v2)
VectorT< Scalar, DIM > max(const VectorT< Scalar, DIM > &_v1, const VectorT< Scalar, DIM > &_v2)
Cellection of information about a property.
VectorT< float, 4 > Vec4f
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.