Commit ceb6e7fe authored by Martin Heistermann's avatar Martin Heistermann

ovm-double propvis: simplify logic

parent 0a494df6
......@@ -73,31 +73,24 @@ void OVMPropertyVisualizerDouble<MeshT>::visualizeProp(PropType prop, HandleIter
if (!prop) return;
DoubleWidget* doubleWidget = static_cast<DoubleWidget*>(PropertyVisualizer::widget);
ACG::Vec4f colorMin = ACG::to_Vec4f(doubleWidget->doubleMin->color());
auto cc = doubleWidget->buildColorCoder();
double min, max;
if ( doubleWidget->doubleAbsolute->isChecked() ){
min = FLT_MAX;
max = 0.0;
} else {
min = FLT_MAX;
max = FLT_MIN;
}
for (const Handle& h: handles) {
double value = prop[h];
if ( doubleWidget->doubleAbsolute->isChecked() ){
min = std::min( min, fabs(value));
max = std::max( max, fabs(value));
bool abs = doubleWidget->doubleAbsolute->isChecked();
auto transform_value = [abs](double v) {
if (abs) {
return std::fabs(v);
} else {
min = std::min( min, value);
max = std::max( max, value);
}
}
return v;
};
};
auto get_value = [&](Handle handle)
{
return transform_value(prop[handle]);
};
// fixed range?
double min, max;
if( doubleWidget->doubleFixedRange->isChecked())
{
min = doubleWidget->doubleFixedRangeMin->value();
......@@ -105,6 +98,13 @@ void OVMPropertyVisualizerDouble<MeshT>::visualizeProp(PropType prop, HandleIter
}
else
{
min = std::numeric_limits<double>::infinity();
max = -std::numeric_limits<double>::infinity();
for (const Handle &h: handles) {
auto value = get_value(h);
min = std::min(min, value);
max = std::max(max, value);
}
doubleWidget->doubleFixedRangeMin->setValue(min);
doubleWidget->doubleFixedRangeMax->setValue(max);
}
......@@ -113,21 +113,11 @@ void OVMPropertyVisualizerDouble<MeshT>::visualizeProp(PropType prop, HandleIter
VolumeMeshObject<MeshT>* object;
PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
for (const Handle& h: handles) {
if (range == 0.0)
object->colors()[h] = colorMin;
else {
double value = prop[h];
// absolut value?
if ( doubleWidget->doubleAbsolute->isChecked())
value = fabs(value);
double t = (value-min)/range;
object->colors()[h] = cc->color_float4(t);
}
for (const Handle &h: handles)
{
double value = get_value(h);
double t = (value - min) / range;
object->colors()[h] = cc->color_float4(t);
}
}
CALLS_TO_VISUALIZE_PROP(OVMPropertyVisualizerDouble<MeshT>, typename MeshT, double)
......
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