50 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT
52 #define OVM_PROPERTY_VISUALIZER_ITEGER_CC
54 #include "OVMPropertyVisualizerInteger.hh"
55 #include <ACG/Utils/ColorConversion.hh>
56 #include <ACG/Utils/LinearTwoColorCoder.hh>
58 template <
typename MeshT,
typename T>
59 OVMPropertyVisualizerInteger<MeshT,T>::OVMPropertyVisualizerInteger(MeshT* _mesh,
int objectID,
PropertyInfo _propertyInfo,
bool isUnsigned)
60 : OVMPropertyVisualizer<MeshT>(_mesh, objectID, _propertyInfo)
62 if (PropertyVisualizer::widget)
delete PropertyVisualizer::widget;
64 w->paramInt->setTitle(QString(
"Integer Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
65 PropertyVisualizer::widget = w;
69 w->intAbsolute->setChecked(
false);
70 w->intAbsolute->setCheckable(
false);
74 mNumericLimitMax = std::numeric_limits<T>::max();
75 mNumericLimitMin = std::numeric_limits<T>::min();
79 template <
typename MeshT,
typename T>
80 template <
typename PropType,
typename EntityIterator>
81 void OVMPropertyVisualizerInteger<MeshT, T>::visualizeProp(PropType prop, EntityIterator e_begin, EntityIterator e_end)
87 ACG::Vec4f colorMin = ACG::to_Vec4f(integerWidget->intMin->color());
89 std::map< int, ACG::Vec4f> randomColor;
91 if ( integerWidget->intRandom->isChecked() && integerWidget->intMapBlack->isChecked() )
92 randomColor[ integerWidget->intMapBlackValue->value() ] =
ACG::Vec4f(0.0, 0.0, 0.0, 0.0);
94 T min = mNumericLimitMax;
95 T max = mNumericLimitMin;
97 for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it)
99 T value = prop[*e_it];
100 min = std::min( min, value);
101 max = std::max( max, value);
104 if( integerWidget->intFixedRange->isChecked())
106 min = integerWidget->intFixedRangeMin->value();
107 max = integerWidget->intFixedRangeMax->value();
111 integerWidget->intFixedRangeMin->setValue(min);
112 integerWidget->intFixedRangeMax->setValue(max);
117 unsigned int range = max - min;
121 for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it)
124 object->colors()[*e_it] = colorMin;
126 T value = prop[*e_it];
127 double pos = (value - min) / (
double) range;
129 if ( integerWidget->intRandom->isChecked() )
132 if ( randomColor.find( value ) == randomColor.end() )
134 color = mColorGenerator.generateNextColor();
136 randomColor[ value ] = color;
138 color = randomColor[ value ];
142 color = cc->color_float4(pos);
145 object->colors()[*e_it] = color;
150 CALLS_TO_VISUALIZE_PROP(OVMPropertyVisualizerInteger<MeshT KOMMA T>,
typename MeshT KOMMA
typename T, T)
153 template <
typename MeshT,
typename T>
154 void OVMPropertyVisualizerInteger<MeshT, T>::duplicateProperty()
156 OVMPropertyVisualizer<MeshT>::template duplicateProperty_stage1<T>();
159 template <
typename MeshT,
typename T>
160 QString OVMPropertyVisualizerInteger<MeshT, T>::getPropertyText(
unsigned int index)
162 return OVMPropertyVisualizer<MeshT>::template getPropertyText_<T>(index);
165 template <
typename MeshT,
typename T>
166 void OVMPropertyVisualizerInteger<MeshT, T>::setCellPropertyFromText(
unsigned int index, QString text)
168 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
173 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
179 prop[ch] = this->strToInt(text);
182 template <
typename MeshT,
typename T>
183 void OVMPropertyVisualizerInteger<MeshT, T>::setFacePropertyFromText(
unsigned int index, QString text)
185 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
190 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
196 prop[fh] = this->strToInt(text);
199 template <
typename MeshT,
typename T>
200 void OVMPropertyVisualizerInteger<MeshT, T>::setHalffacePropertyFromText(
unsigned int index, QString text)
202 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
207 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
213 prop[hfh] = this->strToInt(text);
216 template <
typename MeshT,
typename T>
217 void OVMPropertyVisualizerInteger<MeshT, T>::setEdgePropertyFromText(
unsigned int index, QString text)
219 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
224 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
230 prop[eh] = this->strToInt(text);
233 template <
typename MeshT,
typename T>
234 void OVMPropertyVisualizerInteger<MeshT, T>::setHalfedgePropertyFromText(
unsigned int index, QString text)
236 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
241 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
247 prop[heh] = this->strToInt(text);
250 template <
typename MeshT,
typename T>
251 void OVMPropertyVisualizerInteger<MeshT, T>::setVertexPropertyFromText(
unsigned int index, QString text)
253 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
258 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
264 prop[vh] = this->strToInt(text);
267 template <
typename MeshT,
typename T>
268 std::unique_ptr<ACG::IColorCoder> OVMPropertyVisualizerInteger<MeshT, T>::buildColorCoder()
std::unique_ptr< ACG::IColorCoder > buildColorCoder()
Builds a color coder according to UI settings.
bool getObject(int _identifier, BSplineCurveObject *&_object)
Property classes for the different entity types.
VectorT< float, 4 > Vec4f
Cellection of information about a property.