44 #define OM_PROPERTY_VISUALIZER_INTEGER_CC 46 #include <ACG/Utils/IColorCoder.hh> 47 #include <ACG/Utils/ColorConversion.hh> 48 #include "OMPropertyVisualizerInteger.hh" 50 template <
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 template <
typename MeshT,
typename T>
72 template <
typename MeshT,
typename T>
77 typename MeshT::Color colorMin = ACG::to_Vec4f(integerWidget->intMin->color());
80 std::map< int, typename MeshT::Color> randomColor;
82 if ( integerWidget->intRandom->isChecked() && integerWidget->intMapBlack->isChecked() )
83 randomColor[ integerWidget->intMapBlackValue->value() ] =
typename MeshT::Color(0.0, 0.0, 0.0, 1.0);
91 T max = std::numeric_limits<T>::min();
92 T min = std::numeric_limits<T>::max();
95 min = std::min( min, getValue(prop, f_it));
96 max = std::max( max, getValue(prop, f_it));
100 if( integerWidget->intFixedRange->isChecked())
102 min = integerWidget->intFixedRangeMin->value();
103 max = integerWidget->intFixedRangeMax->value();
107 integerWidget->intFixedRangeMin->setValue(min);
108 integerWidget->intFixedRangeMax->setValue(max);
111 unsigned int range = max - min;
122 double pos = (getValue(prop, f_it) - min) / (
double) range;
126 if (integerWidget->intRandom->isChecked() ){
127 if ( randomColor.find( getValue(prop, f_it) ) == randomColor.end() ){
132 randomColor[ getValue(prop, f_it) ] = color;
135 color = randomColor[ getValue(prop, f_it) ];
137 color = cc->color_float4(pos);
148 template <
typename MeshT,
typename T>
153 typename MeshT::Color colorMin = ACG::to_Vec4f(integerWidget->intMin->color());
156 std::map< int, typename MeshT::Color> randomColor;
158 if ( integerWidget->intRandom->isChecked() && integerWidget->intMapBlack->isChecked() )
159 randomColor[ integerWidget->intMapBlackValue->value() ] =
typename MeshT::Color(0.0, 0.0, 0.0, 1.0);
167 T max = std::numeric_limits<T>::min();
168 T min = std::numeric_limits<T>::max();
171 min = std::min( min, getValue(prop, e_it));
172 max = std::max( max, getValue(prop, e_it));
176 if( integerWidget->intFixedRange->isChecked())
178 min = integerWidget->intFixedRangeMin->value();
179 max = integerWidget->intFixedRangeMax->value();
183 integerWidget->intFixedRangeMin->setValue(min);
184 integerWidget->intFixedRangeMax->setValue(max);
187 unsigned int range = max - min;
198 double pos = (getValue(prop, e_it) - min) / (
double) range;
202 if (integerWidget->intRandom->isChecked() ){
203 if ( randomColor.find( getValue(prop, e_it) ) == randomColor.end() ){
208 randomColor[ getValue(prop, e_it) ] = color;
211 color = randomColor[ getValue(prop, e_it) ];
213 color = cc->color_float4(pos);
225 template <
typename MeshT,
typename T>
230 typename MeshT::Color colorMin = ACG::to_Vec4f(integerWidget->intMin->color());
233 std::map< int, typename MeshT::Color> randomColor;
235 if ( integerWidget->intRandom->isChecked() && integerWidget->intMapBlack->isChecked() )
236 randomColor[ integerWidget->intMapBlackValue->value() ] =
typename MeshT::Color(0.0, 0.0, 0.0, 1.0);
244 T max = std::numeric_limits<T>::min();
245 T min = std::numeric_limits<T>::max();
248 min = std::min( min, getValue(prop, he_it));
249 max = std::max( max, getValue(prop, he_it));
253 if( integerWidget->intFixedRange->isChecked())
255 min = integerWidget->intFixedRangeMin->value();
256 max = integerWidget->intFixedRangeMax->value();
260 integerWidget->intFixedRangeMin->setValue(min);
261 integerWidget->intFixedRangeMax->setValue(max);
264 unsigned int range = max - min;
275 double pos = (getValue(prop, he_it) - min) / (
double) range;
279 if (integerWidget->intRandom->isChecked() ){
280 if ( randomColor.find( getValue(prop, he_it) ) == randomColor.end() ){
285 randomColor[ getValue(prop, he_it) ] = color;
288 color = randomColor[ getValue(prop, he_it) ];
290 color = cc->color_float4(pos);
301 template <
typename MeshT,
typename T>
306 typename MeshT::Color colorMin = ACG::to_Vec4f(integerWidget->intMin->color());
309 std::map< int, typename MeshT::Color> randomColor;
311 if ( integerWidget->intRandom->isChecked() && integerWidget->intMapBlack->isChecked() )
312 randomColor[ integerWidget->intMapBlackValue->value() ] =
typename MeshT::Color(0.0, 0.0, 0.0, 1.0);
320 T max = std::numeric_limits<T>::min();
321 T min = std::numeric_limits<T>::max();
324 min = std::min( min, getValue(prop, v_it));
325 max = std::max( max, getValue(prop, v_it));
329 if( integerWidget->intFixedRange->isChecked())
331 min = integerWidget->intFixedRangeMin->value();
332 max = integerWidget->intFixedRangeMax->value();
336 integerWidget->intFixedRangeMin->setValue(min);
337 integerWidget->intFixedRangeMax->setValue(max);
340 unsigned int range = max - min;
351 double pos = (getValue(prop, v_it) - min) / (
double) range;
355 if (integerWidget->intRandom->isChecked() ){
356 if ( randomColor.find( getValue(prop, v_it) ) == randomColor.end() ){
361 randomColor[ getValue(prop, v_it) ] = color;
364 color = randomColor[ getValue(prop, v_it) ];
366 color = cc->color_float4(pos);
378 template <
typename MeshT,
typename T>
384 if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
385 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
388 typename MeshT::FaceHandle fh = mesh->face_handle(index);
391 mesh->property(prop, fh) = this->strToT(text, dummy);
394 template <
typename MeshT,
typename T>
400 if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
401 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
403 typename MeshT::EdgeHandle eh = mesh->edge_handle(index);
406 mesh->property(prop, eh) = this->strToT(text, dummy);
409 template <
typename MeshT,
typename T>
415 if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
416 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
419 typename MeshT::HalfedgeHandle heh = mesh->halfedge_handle(index);
422 mesh->property(prop, heh) = this->strToT(text, dummy);
425 template <
typename MeshT,
typename T>
431 if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
432 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
435 typename MeshT::VertexHandle vh = mesh->vertex_handle(index);
438 mesh->property(prop, vh) = this->strToT(text, dummy);
441 template<
typename MeshT,
typename T>
447 template<
typename MeshT,
typename T>
void duplicateProperty() override
Duplicates the property.
DrawMode EDGES_COLORED
draw edges with colors (without shading)
Add colors to mesh item (vertices/faces/edges)
std::unique_ptr< ACG::IColorCoder > buildColorCoder()
Builds a color coder according to UI settings.
void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, int _viewer)
Set the draw Mode of a Viewer. .
void removeProperty() override
Removes the property.
DrawMode SOLID_POINTS_COLORED
draw colored, but not lighted faces using interpolated vertex colors
DrawMode SOLID_FACES_COLORED
draw colored, but not lighted faces using face colors
DrawMode HALFEDGES_COLORED
draw halfedges with colors (without shading)
Cellection of information about a property.
virtual Vec4f generateNextColor()
QString getPropertyText(unsigned int index) override
Returns the value of a property in text form.