Commit b85857e6 authored by Martin Heistermann's avatar Martin Heistermann

Refactor IColorColor and fix 'map outside range to alpha 0'.

The map-outside-range-to-alpha-0 option was broken for OM double props,
Instead of adding to the awful amount of duplicated code, I moved
clamping/alpha logic to the colorcode.
parent 08b20d96
......@@ -129,10 +129,6 @@ void OMPropertyVisualizerDouble<MeshT>::visualizeFaceProp(bool _setDrawMode)
if ( doubleWidget->doubleAbsolute->isChecked())
v = fabs(v);
// clamping
v = std::max(min,v);
v = std::min(max,v);
double t = (v-min)/range;
typename MeshT::Color color = cc->color_float4(t);
......@@ -212,10 +208,6 @@ void OMPropertyVisualizerDouble<MeshT>::visualizeEdgeProp(bool _setDrawMode)
if ( doubleWidget->doubleAbsolute->isChecked())
v = fabs(v);
// clamping
v = std::max(min,v);
v = std::min(max,v);
double t = (v-min)/range;
typename MeshT::Color color = cc->color_float4(t);
......@@ -294,10 +286,6 @@ void OMPropertyVisualizerDouble<MeshT>::visualizeHalfedgeProp(bool _setDrawMode)
if ( doubleWidget->doubleAbsolute->isChecked())
v = fabs(v);
// clamping
v = std::max(min,v);
v = std::min(max,v);
double t = (v-min)/range;
typename MeshT::Color color = cc->color_float4(t);
......@@ -374,10 +362,6 @@ void OMPropertyVisualizerDouble<MeshT>::visualizeVertexProp(bool _setDrawMode)
if ( doubleWidget->doubleAbsolute->isChecked())
v = fabs(v);
// clamping
v = std::max(min,v);
v = std::min(max,v);
double t = (v-min)/range;
typename MeshT::Color color = cc->color_float4(t);
......
......@@ -130,21 +130,8 @@ void OVMPropertyVisualizerDouble<MeshT>::visualizeProp(PropType prop, EntityIter
if ( doubleWidget->doubleAbsolute->isChecked())
value = fabs(value);
// clamping
value = std::max(min,value);
value = std::min(max,value);
double t = (value-min)/range;
ACG::Vec4f color = cc->color_float4(t);
if (doubleWidget->doubleMapOutsideRange->isChecked()) {
if (prop[*e_it] < min || prop[*e_it] > max)
color[3] = 0.f;
}
// set color
object->colors()[*e_it] = color;
object->colors()[*e_it] = cc->color_float4(t);
}
}
}
......
......@@ -81,13 +81,16 @@ public:
*/
std::unique_ptr<ACG::IColorCoder> buildColorCoder()
{
std::unique_ptr<ACG::IColorCoder> cc;
if (doubleColorCoder->isChecked()) {
return ptr::make_unique<ACG::ColorCoder>();
cc = ptr::make_unique<ACG::ColorCoder>();
} else {
return ptr::make_unique<ACG::LinearTwoColorCoder>(
cc = ptr::make_unique<ACG::LinearTwoColorCoder>(
ACG::to_Vec4f(doubleMin->color()),
ACG::to_Vec4f(doubleMax->color()));
}
cc->setMapOutsideRangeToAlpha0(doubleMapOutsideRange->isChecked());
return cc;
}
signals:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment