50 #define OM_PROPERTY_VISUALIZER_INTEGER_CC
52 #include <ACG/Utils/IColorCoder.hh>
53 #include <ACG/Utils/ColorConversion.hh>
54 #include "OMPropertyVisualizerInteger.hh"
56 template <
typename MeshT,
typename T>
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 template <
typename MeshT,
typename T>
78 template <
typename MeshT,
typename T>
83 typename MeshT::Color colorMin = ACG::to_Vec4f(integerWidget->intMin->color());
86 std::map< int, typename MeshT::Color> randomColor;
88 if ( integerWidget->intRandom->isChecked() && integerWidget->intMapBlack->isChecked() )
89 randomColor[ integerWidget->intMapBlackValue->value() ] =
typename MeshT::Color(0.0, 0.0, 0.0, 1.0);
97 T max = std::numeric_limits<T>::min();
98 T min = std::numeric_limits<T>::max();
101 min = std::min( min, getValue(prop, f_it));
102 max = std::max( max, getValue(prop, f_it));
106 if( integerWidget->intFixedRange->isChecked())
108 min = integerWidget->intFixedRangeMin->value();
109 max = integerWidget->intFixedRangeMax->value();
113 integerWidget->intFixedRangeMin->setValue(min);
114 integerWidget->intFixedRangeMax->setValue(max);
117 unsigned int range = max - min;
128 double pos = (getValue(prop, f_it) - min) / (
double) range;
132 if (integerWidget->intRandom->isChecked() ){
133 if ( randomColor.find( getValue(prop, f_it) ) == randomColor.end() ){
135 color = mColorGenerator.generateNextColor();
138 randomColor[ getValue(prop, f_it) ] = color;
141 color = randomColor[ getValue(prop, f_it) ];
143 color = cc->color_float4(pos);
154 template <
typename MeshT,
typename T>
159 typename MeshT::Color colorMin = ACG::to_Vec4f(integerWidget->intMin->color());
162 std::map< int, typename MeshT::Color> randomColor;
164 if ( integerWidget->intRandom->isChecked() && integerWidget->intMapBlack->isChecked() )
165 randomColor[ integerWidget->intMapBlackValue->value() ] =
typename MeshT::Color(0.0, 0.0, 0.0, 1.0);
173 T max = std::numeric_limits<T>::min();
174 T min = std::numeric_limits<T>::max();
177 min = std::min( min, getValue(prop, e_it));
178 max = std::max( max, getValue(prop, e_it));
182 if( integerWidget->intFixedRange->isChecked())
184 min = integerWidget->intFixedRangeMin->value();
185 max = integerWidget->intFixedRangeMax->value();
189 integerWidget->intFixedRangeMin->setValue(min);
190 integerWidget->intFixedRangeMax->setValue(max);
193 unsigned int range = max - min;
204 double pos = (getValue(prop, e_it) - min) / (
double) range;
208 if (integerWidget->intRandom->isChecked() ){
209 if ( randomColor.find( getValue(prop, e_it) ) == randomColor.end() ){
211 color = mColorGenerator.generateNextColor();
214 randomColor[ getValue(prop, e_it) ] = color;
217 color = randomColor[ getValue(prop, e_it) ];
219 color = cc->color_float4(pos);
231 template <
typename MeshT,
typename T>
236 typename MeshT::Color colorMin = ACG::to_Vec4f(integerWidget->intMin->color());
239 std::map< int, typename MeshT::Color> randomColor;
241 if ( integerWidget->intRandom->isChecked() && integerWidget->intMapBlack->isChecked() )
242 randomColor[ integerWidget->intMapBlackValue->value() ] =
typename MeshT::Color(0.0, 0.0, 0.0, 1.0);
250 T max = std::numeric_limits<T>::min();
251 T min = std::numeric_limits<T>::max();
254 min = std::min( min, getValue(prop, he_it));
255 max = std::max( max, getValue(prop, he_it));
259 if( integerWidget->intFixedRange->isChecked())
261 min = integerWidget->intFixedRangeMin->value();
262 max = integerWidget->intFixedRangeMax->value();
266 integerWidget->intFixedRangeMin->setValue(min);
267 integerWidget->intFixedRangeMax->setValue(max);
270 unsigned int range = max - min;
281 double pos = (getValue(prop, he_it) - min) / (
double) range;
285 if (integerWidget->intRandom->isChecked() ){
286 if ( randomColor.find( getValue(prop, he_it) ) == randomColor.end() ){
288 color = mColorGenerator.generateNextColor();
291 randomColor[ getValue(prop, he_it) ] = color;
294 color = randomColor[ getValue(prop, he_it) ];
296 color = cc->color_float4(pos);
307 template <
typename MeshT,
typename T>
312 typename MeshT::Color colorMin = ACG::to_Vec4f(integerWidget->intMin->color());
315 std::map< int, typename MeshT::Color> randomColor;
317 if ( integerWidget->intRandom->isChecked() && integerWidget->intMapBlack->isChecked() )
318 randomColor[ integerWidget->intMapBlackValue->value() ] =
typename MeshT::Color(0.0, 0.0, 0.0, 1.0);
326 T max = std::numeric_limits<T>::min();
327 T min = std::numeric_limits<T>::max();
330 min = std::min( min, getValue(prop, v_it));
331 max = std::max( max, getValue(prop, v_it));
335 if( integerWidget->intFixedRange->isChecked())
337 min = integerWidget->intFixedRangeMin->value();
338 max = integerWidget->intFixedRangeMax->value();
342 integerWidget->intFixedRangeMin->setValue(min);
343 integerWidget->intFixedRangeMax->setValue(max);
346 unsigned int range = max - min;
357 double pos = (getValue(prop, v_it) - min) / (
double) range;
361 if (integerWidget->intRandom->isChecked() ){
362 if ( randomColor.find( getValue(prop, v_it) ) == randomColor.end() ){
364 color = mColorGenerator.generateNextColor();
367 randomColor[ getValue(prop, v_it) ] = color;
370 color = randomColor[ getValue(prop, v_it) ];
372 color = cc->color_float4(pos);
384 template <
typename MeshT,
typename T>
390 if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
391 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
394 typename MeshT::FaceHandle fh = mesh->face_handle(index);
397 mesh->property(prop, fh) = this->strToT(text, dummy);
400 template <
typename MeshT,
typename T>
406 if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
407 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
409 typename MeshT::EdgeHandle eh = mesh->edge_handle(index);
412 mesh->property(prop, eh) = this->strToT(text, dummy);
415 template <
typename MeshT,
typename T>
421 if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
422 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
425 typename MeshT::HalfedgeHandle heh = mesh->halfedge_handle(index);
428 mesh->property(prop, heh) = this->strToT(text, dummy);
431 template <
typename MeshT,
typename T>
437 if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
438 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
441 typename MeshT::VertexHandle vh = mesh->vertex_handle(index);
444 mesh->property(prop, vh) = this->strToT(text, dummy);
447 template<
typename MeshT,
typename T>
453 template<
typename MeshT,
typename T>
std::unique_ptr< ACG::IColorCoder > buildColorCoder()
Builds a color coder according to UI settings.
virtual void removeProperty()
Removes the property.
void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, int _viewer)
Set the draw Mode of a Viewer. .
DrawMode SOLID_POINTS_COLORED
draw colored, but not lighted faces using interpolated vertex colors
DrawMode EDGES_COLORED
draw edges with colors (without shading)
virtual QString getPropertyText(unsigned int index)
Returns the value of a property in text form.
DrawMode HALFEDGES_COLORED
draw halfedges with colors (without shading)
virtual void duplicateProperty()
Duplicates the property.
Add colors to mesh item (vertices/faces/edges)
Cellection of information about a property.
DrawMode SOLID_FACES_COLORED
draw colored, but not lighted faces using face colors