Deep fix of #316 and also implements #317

#316 Do not show wrong results ...
#317 Avoid stopping animation when switching results
This commit cleans up some of the inconsistencies etc in the top of the
display model generation logic.
This commit is contained in:
Jacob Støren
2015-06-09 16:18:11 +02:00
parent 05315bc7a9
commit 30fcbebc8e
12 changed files with 100 additions and 83 deletions

View File

@@ -180,7 +180,7 @@ void Rim3dOverlayInfoConfig::updateReservoir3DInfo(RimEclipseView * reservoirVie
infoText += QString("<b>Cell Property:</b> %1 ").arg(propName);
}
if (reservoirView->animationMode() && reservoirView->cellResult()->hasResult())
if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult())
{
infoText += QString("<b>Cell Property:</b> %1 ").arg(propName);
@@ -232,7 +232,7 @@ void Rim3dOverlayInfoConfig::updateReservoir3DInfo(RimEclipseView * reservoirVie
}
if (reservoirView->animationMode() && reservoirView->cellEdgeResult()->hasResult())
if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellEdgeResult()->hasResult())
{
double min, max;
reservoirView->cellEdgeResult()->minMaxCellEdgeValues(min, max);
@@ -255,7 +255,7 @@ void Rim3dOverlayInfoConfig::updateReservoir3DInfo(RimEclipseView * reservoirVie
if (showHistogram())
{
if (reservoirView->animationMode() && reservoirView->cellResult()->hasResult())
if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult())
{
double min, max;
double p10, p90;
@@ -296,7 +296,7 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView)
"<p><b><center>-- %1 --</center></b><p>"
"<b>Cell count:</b> %2 <b>Z-Scale:</b> %3<br>").arg(caseName, cellCount, zScale);
if (geoMechView->cellResult().notNull())
if (geoMechView->hasUserRequestedAnimation() && geoMechView->cellResult()->hasResult())
{
QString resultPos;
QString fieldName = geoMechView->cellResult()->resultFieldName();
@@ -357,8 +357,8 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView)
if (showHistogram())
{
if (geoMechView->cellResult().notNull())
{
if (geoMechView->hasUserRequestedAnimation() && geoMechView->cellResult()->hasResult())
{
QString fieldName = geoMechView->cellResult()->resultFieldName();
QString compName = geoMechView->cellResult()->resultComponentName();
QString resultName = compName.isEmpty() ? fieldName : compName;

View File

@@ -450,11 +450,13 @@ void RimEclipseView::createDisplayModel()
if (isAnimationActive || cellResult->hasResult())
{
m_viewer->slotSetCurrentFrame(m_currentTimeStep);
m_viewer->animationControl()->setCurrentFrame(m_currentTimeStep);
}
else
{
overlayInfoConfig()->update3DInfo();
updateLegends();
}
overlayInfoConfig()->update3DInfo();
updateLegends();
}
@@ -463,6 +465,8 @@ void RimEclipseView::createDisplayModel()
//--------------------------------------------------------------------------------------------------
void RimEclipseView::updateCurrentTimeStep()
{
updateLegends(); // To make sure the scalar mappers are set up correctly
std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType> geometriesToRecolor;
if (this->propertyFilterCollection()->hasActiveFilters())
@@ -566,11 +570,11 @@ void RimEclipseView::updateCurrentTimeStep()
for (size_t i = 0; i < geometriesToRecolor.size(); ++i)
{
if (this->animationMode() && this->cellEdgeResult()->hasResult())
if (this->hasUserRequestedAnimation() && this->cellEdgeResult()->hasResult())
{
m_reservoirGridPartManager->updateCellEdgeResultColor(geometriesToRecolor[i], m_currentTimeStep, this->cellResult(), this->cellEdgeResult());
}
else if ((this->animationMode() && this->cellResult()->hasResult()) || this->cellResult()->isTernarySaturationSelected())
else if ((this->hasUserRequestedAnimation() && this->cellResult()->hasResult()) || this->cellResult()->isTernarySaturationSelected())
{
m_reservoirGridPartManager->updateCellResultColor(geometriesToRecolor[i], m_currentTimeStep, this->cellResult());
}
@@ -655,7 +659,6 @@ void RimEclipseView::updateCurrentTimeStep()
}
overlayInfoConfig()->update3DInfo();
updateLegends();
}
//--------------------------------------------------------------------------------------------------
@@ -1250,9 +1253,9 @@ void RimEclipseView::updateDisplayModelForWellResults()
createDisplayModel();
updateDisplayModelVisibility();
if (animationMode && m_viewer)
if (hasUserRequestedAnimation() && m_viewer)
{
m_viewer->slotSetCurrentFrame(m_currentTimeStep);
m_viewer->animationControl()->setCurrentFrame(m_currentTimeStep);
}
RiuMainWindow::instance()->refreshAnimationActions();
@@ -1386,7 +1389,7 @@ void RimEclipseView::updateFaultColors()
for (size_t i = 0; i < faultGeometriesToRecolor.size(); ++i)
{
if (this->animationMode() && this->cellEdgeResult()->hasResult())
if (this->hasUserRequestedAnimation() && this->cellEdgeResult()->hasResult())
{
m_reservoirGridPartManager->updateFaultCellEdgeResultColor(faultGeometriesToRecolor[i], m_currentTimeStep, faultResultSlot, this->cellEdgeResult());
}

View File

@@ -174,13 +174,12 @@ void RimGeoMechResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedFi
m_resultComponentName = "";
}
m_reservoirView->geoMechCase()->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress());
if (m_reservoirView)
if (m_reservoirView->geoMechCase()->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress()))
{
m_reservoirView->animationMode = true;
m_reservoirView->createDisplayModelAndRedraw();
m_reservoirView->hasUserRequestedAnimation = true;
}
m_reservoirView->createDisplayModelAndRedraw();
}
}
}
@@ -252,3 +251,11 @@ RigGeoMechCaseData* RimGeoMechResultSlot::ownerCaseData()
{
return m_reservoirView->geoMechCase()->geoMechData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGeoMechResultSlot::hasResult()
{
return ownerCaseData()->femPartResults()->assertResultsLoaded(this->resultAddress());
}

View File

@@ -44,6 +44,7 @@ public:
void setReservoirView(RimGeoMechView* ownerReservoirView);
RigGeoMechCaseData* ownerCaseData();
bool hasResult();
RigFemResultAddress resultAddress() { return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString());}

View File

@@ -141,8 +141,10 @@ void RimGeoMechView::loadDataAndUpdate()
progress.setProgressDescription("Reading Current Result");
CVF_ASSERT(this->cellResult() != NULL);
m_geomechCase->geoMechData()->femPartResults()->assertResultsLoaded(this->cellResult()->resultAddress());
if (this->hasUserRequestedAnimation())
{
m_geomechCase->geoMechData()->femPartResults()->assertResultsLoaded(this->cellResult()->resultAddress());
}
progress.incrementProgress();
progress.setProgressDescription("Create Display model");
@@ -220,7 +222,6 @@ void RimGeoMechView::createDisplayModel()
// Remove all existing animation frames from the viewer.
// The parts are still cached in the RivReservoir geometry and friends
bool isAnimationActive = m_viewer->isAnimationActive();
m_viewer->removeAllFrames();
m_vizLogic->appendNoAnimPartsToModel(frameModels[0].p());
@@ -246,13 +247,15 @@ void RimGeoMechView::createDisplayModel()
// If the animation was active before recreating everything, make viewer view current frame
if (isAnimationActive && cellResult->resultFieldName() != "")
if (isTimeStepDependentDataVisible())
{
m_viewer->slotSetCurrentFrame(m_currentTimeStep);
m_viewer->animationControl()->setCurrentFrame(m_currentTimeStep);
}
else
{
updateLegends();
overlayInfoConfig()->update3DInfo();
}
updateLegends();
overlayInfoConfig()->update3DInfo();
}
//--------------------------------------------------------------------------------------------------
@@ -261,7 +264,8 @@ void RimGeoMechView::createDisplayModel()
void RimGeoMechView::updateCurrentTimeStep()
{
updateLegends();
if ((this->animationMode() && cellResult()->resultFieldName() != ""))
if (this->isTimeStepDependentDataVisible())
{
if (m_viewer)
{
@@ -282,6 +286,7 @@ void RimGeoMechView::updateCurrentTimeStep()
else
{
this->updateStaticCellColors();
m_viewer->animationControl()->slotPause(); // To avoid animation timer spinning in the background
}
overlayInfoConfig()->update3DInfo();
@@ -367,46 +372,37 @@ void RimGeoMechView::updateLegends()
m_viewer->removeAllColorLegends();
}
if (!m_geomechCase || !m_viewer || !m_geomechCase->geoMechData() )
if (!m_geomechCase || !m_viewer || !m_geomechCase->geoMechData()
|| !this->isTimeStepDependentDataVisible() )
{
return;
}
RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData();
CVF_ASSERT(gmCase);
double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero;
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
RigFemResultAddress resVarAddress = cellResult->resultAddress();
if (resVarAddress.fieldName != "")
{
gmCase->femPartResults()->minMaxScalarValues(resVarAddress, m_currentTimeStep, &localMin, &localMax);
gmCase->femPartResults()->posNegClosestToZero(resVarAddress, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero);
RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData();
CVF_ASSERT(gmCase);
gmCase->femPartResults()->minMaxScalarValues(resVarAddress, &globalMin, &globalMax);
gmCase->femPartResults()->posNegClosestToZero(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero);
RigFemResultAddress resVarAddress = cellResult()->resultAddress();
gmCase->femPartResults()->minMaxScalarValues(resVarAddress, m_currentTimeStep, &localMin, &localMax);
gmCase->femPartResults()->posNegClosestToZero(resVarAddress, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero);
gmCase->femPartResults()->minMaxScalarValues(resVarAddress, &globalMin, &globalMax);
gmCase->femPartResults()->posNegClosestToZero(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero);
cellResult->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
cellResult->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
m_viewer->addColorLegendToBottomLeftCorner(cellResult->legendConfig->legend());
cellResult->legendConfig->legend()->setTitle(cvfqt::Utils::toString(
caf::AppEnum<RigFemResultPosEnum>(cellResult->resultPositionType()).uiText() + "\n"
+ cellResult->resultFieldName() + " " + cellResult->resultComponentName() ));
}
else
{
cellResult->legendConfig->setClosestToZeroValues(0, 0, 0, 0);
cellResult->legendConfig->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
}
cellResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
cellResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend());
cellResult()->legendConfig->legend()->setTitle(cvfqt::Utils::toString(
caf::AppEnum<RigFemResultPosEnum>(cellResult->resultPositionType()).uiText() + "\n"
+ cellResult->resultFieldName() + " " + cellResult->resultComponentName()));
}
//--------------------------------------------------------------------------------------------------
@@ -437,7 +433,7 @@ void RimGeoMechView::clampCurrentTimestep()
//--------------------------------------------------------------------------------------------------
bool RimGeoMechView::isTimeStepDependentDataVisible()
{
return (cellResult->resultFieldName() != "");
return this->hasUserRequestedAnimation() && this->cellResult()->hasResult();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -75,7 +75,7 @@ void RimResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, co
if (newValue != RimDefines::undefinedResultName())
{
if (m_reservoirView) m_reservoirView->animationMode = true;
if (m_reservoirView) m_reservoirView->hasUserRequestedAnimation = true;
}
RiuMainWindow::instance()->uiPdmModel()->updateUiSubTree(this);

View File

@@ -71,8 +71,8 @@ RimView::RimView(void)
CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum frame rate", "", "", "");
maximumFrameRate.setUiHidden(true);
CAF_PDM_InitField(&animationMode, "AnimationMode", false, "Animation Mode", "", "", "");
animationMode.setUiHidden(true);
CAF_PDM_InitField(&hasUserRequestedAnimation, "AnimationMode", false, "Animation Mode", "", "", "");
hasUserRequestedAnimation.setUiHidden(true);
CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", "");
m_currentTimeStep.setUiHidden(true);
@@ -187,7 +187,7 @@ void RimView::scheduleCreateDisplayModelAndRedraw()
void RimView::setCurrentTimeStep(int frameIndex)
{
m_currentTimeStep = frameIndex;
this->animationMode = true;
this->hasUserRequestedAnimation = true;
this->updateCurrentTimeStep();
}
//--------------------------------------------------------------------------------------------------
@@ -207,17 +207,10 @@ void RimView::createDisplayModelAndRedraw()
{
if (m_viewer)
{
m_viewer->animationControl()->slotStop();
this->clampCurrentTimestep();
createDisplayModel();
updateDisplayModelVisibility();
if (m_viewer->frameCount() > 0)
{
m_viewer->animationControl()->setCurrentFrame(m_currentTimeStep);
}
}
RiuMainWindow::instance()->refreshAnimationActions();
@@ -241,7 +234,7 @@ void RimView::setDefaultView()
//--------------------------------------------------------------------------------------------------
void RimView::endAnimation()
{
this->animationMode = false;
this->hasUserRequestedAnimation = false;
this->updateStaticCellColors();
}
@@ -253,7 +246,7 @@ void RimView::setupBeforeSave()
{
if (m_viewer)
{
animationMode = m_viewer->isAnimationActive();
hasUserRequestedAnimation = m_viewer->isAnimationActive(); // JJS: This is not conceptually correct. The variable is updated as we go, and store the user intentions. But I guess that in practice...
cameraPosition = m_viewer->mainCamera()->viewMatrix();
}
}

View File

@@ -57,7 +57,7 @@ public:
caf::PdmField< cvf::Color3f > backgroundColor;
caf::PdmField<int> maximumFrameRate;
caf::PdmField<bool> animationMode;
caf::PdmField<bool> hasUserRequestedAnimation;
caf::PdmField<RimCellRangeFilterCollection*> rangeFilterCollection;