Guard against missing well results

When project file has settings for wells but there are no well results
p4#: 20416
This commit is contained in:
Jacob Støren 2013-02-07 13:44:18 +01:00
parent 9f8f39b80b
commit 09544f082b
5 changed files with 35 additions and 10 deletions

View File

@ -266,7 +266,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{
if (m_rimReservoirView.isNull()) return;
if (m_rimWell.isNull()) return;
if (m_rimWell.isNull() || m_rimWell->wellResults() == NULL) return;
if ( m_rimReservoirView->wellCollection()->wellPipeVisibility() != RimWellCollection::FORCE_ALL_ON
&& m_rimWell->showWellPipes() == false) return;

View File

@ -325,7 +325,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
void RivWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{
if (m_rimReservoirView.isNull()) return;
if (m_rimWell.isNull()) return;
if (m_rimWell.isNull() || m_rimWell->wellResults() == NULL) return;
if ( m_rimReservoirView->wellCollection()->wellPipeVisibility() != RimWellCollection::FORCE_ALL_ON
&& m_rimWell->showWellPipes() == false) return;

View File

@ -261,6 +261,27 @@ void RimReservoirView::updateViewerWidgetWindowTitle()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::clampCurrentTimestep()
{
// Clamp the current timestep to actual possibilities
if (this->gridCellResults())
{
if (m_currentTimeStep() > this->gridCellResults()->maxTimeStepCount())
{
m_currentTimeStep = this->gridCellResults()->maxTimeStepCount() -1;
}
}
if (m_currentTimeStep < 0 ) m_currentTimeStep = 0;
if (!this->cellResult()->hasResult() || cellResult->hasStaticResult())
{
m_currentTimeStep = 0;
}
}
//--------------------------------------------------------------------------------------------------
///
@ -271,11 +292,11 @@ void RimReservoirView::createDisplayModelAndRedraw()
{
m_viewer->animationControl()->slotStop();
this->clampCurrentTimestep();
createDisplayModel();
updateDisplayModelVisibility();
if (m_currentTimeStep < 0 ) m_currentTimeStep = 0;
if (m_viewer->frameCount() > 0)
{
m_viewer->animationControl()->setCurrentFrame(m_currentTimeStep);
@ -708,6 +729,7 @@ void RimReservoirView::loadDataAndUpdate()
m_geometry->clearGeometryCache();
syncronizeWellsWithResults();
this->clampCurrentTimestep();
createDisplayModel();
updateDisplayModelVisibility();

View File

@ -155,7 +155,8 @@ protected:
private:
void syncronizeWellsWithResults();
void syncronizeWellsWithResults();
void clampCurrentTimestep();
private:
caf::PdmField<int> m_currentTimeStep;
@ -174,7 +175,6 @@ private:
void updateStaticCellColors(unsigned short geometryType);
void updateLegends();
cvf::ref<RivReservoirViewPartMgr> m_geometry;
cvf::ref<RivReservoirPipesPartMgr> m_pipesPartManager;
};

View File

@ -314,11 +314,14 @@ void ProgressInfoStatic::setProgress(size_t progressValue)
progressStack().back() = progressValue;
progressSpanStack().back() = 1;
assert(static_cast<int>(currentTotalProgress()) <= progressDialog()->maximum());
size_t totProg = currentTotalProgress();
int totalProgress = static_cast<int>(currentTotalProgress());
int totalMaxProgress = static_cast<int>(currentTotalMaxProgressValue());
assert(static_cast<int>(totalProgress) <= totalMaxProgress);
progressDialog()->setMaximum(totalMaxProgress);
progressDialog()->setValue(totalProgress);
progressDialog()->setMaximum(static_cast<int>(currentTotalMaxProgressValue()));
progressDialog()->setValue(static_cast<int>(currentTotalProgress()));
QCoreApplication::processEvents();
}