50 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT 52 #define OVM_PROPERTY_VISUALIZER_ITEGER_CC 54 #include "OVMPropertyVisualizerInteger.hh" 56 template <
typename MeshT,
typename T>
57 OVMPropertyVisualizerInteger<MeshT,T>::OVMPropertyVisualizerInteger(MeshT* _mesh,
int objectID,
PropertyInfo _propertyInfo,
bool isUnsigned)
58 : OVMPropertyVisualizer<MeshT>(_mesh, objectID, _propertyInfo)
60 if (PropertyVisualizer::widget)
delete PropertyVisualizer::widget;
62 w->paramInt->setTitle(QString(
"Integer Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
63 PropertyVisualizer::widget = w;
67 w->intAbsolute->setChecked(
false);
68 w->intAbsolute->setCheckable(
false);
72 mNumericLimitMax = std::numeric_limits<T>::max();
73 mNumericLimitMin = std::numeric_limits<T>::min();
77 template <
typename MeshT,
typename T>
78 template <
typename PropType,
typename EntityIterator>
79 void OVMPropertyVisualizerInteger<MeshT, T>::visualizeProp(PropType prop, EntityIterator e_begin, EntityIterator e_end)
86 colorMin = OVMPropertyVisualizer<MeshT>::convertColor(integerWidget->intMin->color());
87 colorMax = OVMPropertyVisualizer<MeshT>::convertColor(integerWidget->intMax->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->intColorCoder->isChecked())
134 if ( !integerWidget->intRandom->isChecked() )
136 color[0] = colorMin[0] * (1-pos) + pos * colorMax[0];
137 color[1] = colorMin[1] * (1-pos) + pos * colorMax[1];
138 color[2] = colorMin[2] * (1-pos) + pos * colorMax[2];
143 if ( randomColor.find( value ) == randomColor.end() )
145 color = mColorGenerator.generateNextColor();
147 randomColor[ value ] = color;
149 color = randomColor[ value ];
152 object->colors()[*e_it] = color;
158 CALLS_TO_VISUALIZE_PROP(OVMPropertyVisualizerInteger<MeshT KOMMA T>,
typename MeshT KOMMA
typename T, T)
161 template <
typename MeshT,
typename T>
162 void OVMPropertyVisualizerInteger<MeshT, T>::duplicateProperty()
164 OVMPropertyVisualizer<MeshT>::template duplicateProperty_stage1<T>();
167 template <
typename MeshT,
typename T>
168 QString OVMPropertyVisualizerInteger<MeshT, T>::getPropertyText(
unsigned int index)
170 return OVMPropertyVisualizer<MeshT>::template getPropertyText_<T>(index);
173 template <
typename MeshT,
typename T>
174 void OVMPropertyVisualizerInteger<MeshT, T>::setCellPropertyFromText(
unsigned int index, QString text)
176 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
181 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
187 prop[ch] = this->strToInt(text);
190 template <
typename MeshT,
typename T>
191 void OVMPropertyVisualizerInteger<MeshT, T>::setFacePropertyFromText(
unsigned int index, QString text)
193 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
198 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
204 prop[fh] = this->strToInt(text);
207 template <
typename MeshT,
typename T>
208 void OVMPropertyVisualizerInteger<MeshT, T>::setHalffacePropertyFromText(
unsigned int index, QString text)
210 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
215 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
221 prop[hfh] = this->strToInt(text);
224 template <
typename MeshT,
typename T>
225 void OVMPropertyVisualizerInteger<MeshT, T>::setEdgePropertyFromText(
unsigned int index, QString text)
227 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
232 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
238 prop[eh] = this->strToInt(text);
241 template <
typename MeshT,
typename T>
242 void OVMPropertyVisualizerInteger<MeshT, T>::setHalfedgePropertyFromText(
unsigned int index, QString text)
244 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
249 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
255 prop[heh] = this->strToInt(text);
258 template <
typename MeshT,
typename T>
259 void OVMPropertyVisualizerInteger<MeshT, T>::setVertexPropertyFromText(
unsigned int index, QString text)
261 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
266 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
272 prop[vh] = this->strToInt(text);
VectorT< float, 4 > Vec4f
Cellection of information about a property.
bool getObject(int _identifier, BSplineCurveObject *&_object)
ACG::Vec4f color_float4(float _v) const
color coding
Property classes for the different entity types.
Class for generating nice colors for doubles.