Commit ceb6e7fe authored by Martin Heistermann's avatar Martin Heistermann
Browse files

ovm-double propvis: simplify logic

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