Refactored GeoMechView createDisplayModel

Made adding well paths less obfuscated
Preparing for #314 Property Filter
This commit is contained in:
Jacob Støren
2015-06-22 09:09:33 +02:00
parent 088bc12459
commit 8f2090eccf
6 changed files with 110 additions and 88 deletions

View File

@@ -732,7 +732,7 @@ void RimEclipseView::updateStaticCellColors()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseView::updateStaticCellColors(unsigned short geometryType)
void RimEclipseView::updateStaticCellColors(RivCellSetEnum geometryType)
{
float opacity = static_cast< float> (1 - cvf::Math::clamp(this->wellCollection()->wellCellTransparencyLevel(), 0.0, 1.0));
cvf::Color4f color(cvf::Color3::ORANGE);
@@ -753,7 +753,7 @@ void RimEclipseView::updateStaticCellColors(unsigned short geometryType)
case RANGE_FILTERED_INACTIVE: color = cvf::Color4f(cvf::Color3::LIGHT_GRAY); break;
}
m_reservoirGridPartManager->updateCellColor(static_cast<RivCellSetEnum>(geometryType), color);
m_reservoirGridPartManager->updateCellColor(geometryType, color);
}
//--------------------------------------------------------------------------------------------------
@@ -1456,3 +1456,43 @@ RimCase* RimEclipseView::ownerCase()
return eclipseCase();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseView::addWellPathsToScene(cvf::Scene* scene,
const cvf::Vec3d& displayModelOffset,
double characteristicCellSize,
const cvf::BoundingBox& wellPathClipBoundingBox,
cvf::Transform* scaleTransform)
{
CVF_ASSERT(scene);
CVF_ASSERT(scaleTransform);
cvf::String wellPathModelName = "WellPathModel";
std::vector<cvf::Model*> wellPathModels;
for (cvf::uint i = 0; i < scene->modelCount(); i++)
{
if (scene->model(i)->name() == wellPathModelName)
{
wellPathModels.push_back(scene->model(i));
}
}
for (size_t i = 0; i < wellPathModels.size(); i++)
{
scene->removeModel(wellPathModels[i]);
}
// Append static Well Paths to model
cvf::ref<cvf::ModelBasicList> wellPathModelBasicList = new cvf::ModelBasicList;
wellPathModelBasicList->setName(wellPathModelName);
addWellPathsToModel(wellPathModelBasicList.p(),
displayModelOffset,
characteristicCellSize,
wellPathClipBoundingBox,
scaleTransform);
scene->addModel(wellPathModelBasicList.p());
}

View File

@@ -140,7 +140,7 @@ private:
virtual cvf::Transform* scaleTransform();
virtual void updateStaticCellColors();
void updateStaticCellColors(unsigned short geometryType);
void updateStaticCellColors(RivCellSetEnum geometryType);
void updateLegends();
void updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimResultSlot* resultSlot, RigCaseCellResultsData* cellResultsData);
virtual void resetLegendsInViewer();
@@ -151,6 +151,12 @@ private:
void updateFaultColors();
void syncronizeWellsWithResults();
void addWellPathsToScene(cvf::Scene* scene,
const cvf::Vec3d& displayModelOffset,
double characteristicCellSize,
const cvf::BoundingBox& wellPathClipBoundingBox,
cvf::Transform* scaleTransform);
void clampCurrentTimestep();
virtual RimCase* ownerCase();

View File

@@ -134,7 +134,6 @@ void RimGeoMechView::loadDataAndUpdate()
m_geomechCase = NULL;
return;
}
// m_geoMechFullModel->clearAndSetReservoir(m_geomechCase->geoMechData(), this);
}
progress.incrementProgress();
@@ -194,62 +193,47 @@ void RimGeoMechView::createDisplayModel()
if (partCount <= 0) return;
// Define a vector containing time step indices to produce geometry for.
// First entry in this vector is used to define the geometry only result mode with no results.
std::vector<int> timeStepIndices;
// Remove all existing animation frames from the viewer.
// The parts are still cached in the RivReservoir geometry and friends
// The one and only geometry entry
timeStepIndices.push_back(0);
// Find the number of time frames the animation needs to show the requested data.
m_viewer->removeAllFrames();
if (isTimeStepDependentDataVisible())
{
int i;
for (i = 0; i < geoMechCase()->geoMechData()->femPartResults()->frameCount(); ++i)
// Create empty frames in the viewer
int frameCount = geoMechCase()->geoMechData()->femPartResults()->frameCount();
for (int frameIndex = 0; frameIndex < frameCount; frameIndex++)
{
timeStepIndices.push_back(i);
cvf::ref<cvf::Scene> scene = new cvf::Scene;
scene->addModel(new cvf::ModelBasicList);
m_viewer->addFrame(scene.p());
}
}
cvf::Collection<cvf::ModelBasicList> frameModels;
size_t timeIdx;
for (timeIdx = 0; timeIdx < timeStepIndices.size(); timeIdx++)
{
frameModels.push_back(new cvf::ModelBasicList);
}
// Set the Main scene in the viewer. Used when the animation is in "Stopped" state
// Remove all existing animation frames from the viewer.
// The parts are still cached in the RivReservoir geometry and friends
cvf::ref<cvf::Scene> mainScene = new cvf::Scene;
m_viewer->setMainScene(mainScene.p());
m_viewer->removeAllFrames();
// Grid model
cvf::ref<cvf::ModelBasicList> mainSceneModel = new cvf::ModelBasicList;
m_vizLogic->appendNoAnimPartsToModel(mainSceneModel.p());
mainSceneModel->updateBoundingBoxesRecursive();
mainScene->addModel(mainSceneModel.p());
m_vizLogic->appendNoAnimPartsToModel(frameModels[0].p());
m_vizLogic->updateStaticCellColors(-1);
// Well path model
// Create Scenes from the frameModels
// Animation frames for results display, starts from frame 1
double characteristicCellSize = geoMechCase()->geoMechData()->femParts()->characteristicElementSize();
cvf::BoundingBox femBBox = geoMechCase()->geoMechData()->femParts()->boundingBox();
cvf::ref<cvf::ModelBasicList> wellPathModel = new cvf::ModelBasicList;
addWellPathsToModel(wellPathModel.p(),
cvf::Vec3d(0, 0, 0),
characteristicCellSize,
femBBox,
scaleTransform());
mainScene->addModel(wellPathModel.p());
size_t frameIndex;
for (frameIndex = 0; frameIndex < frameModels.size(); frameIndex++)
{
cvf::ModelBasicList* model = frameModels.at(frameIndex);
model->updateBoundingBoxesRecursive();
cvf::ref<cvf::Scene> scene = new cvf::Scene;
scene->addModel(model);
if (frameIndex == 0)
m_viewer->setMainScene(scene.p());
else
m_viewer->addFrame(scene.p());
double characteristicCellSize = geoMechCase()->geoMechData()->femParts()->characteristicElementSize();
cvf::BoundingBox femBBox = geoMechCase()->geoMechData()->femParts()->boundingBox();
addWellPathsToScene(scene.p(), cvf::Vec3d(0, 0, 0),
characteristicCellSize, femBBox, scaleTransform());
}
// If the animation was active before recreating everything, make viewer view current frame
@@ -260,6 +244,7 @@ void RimGeoMechView::createDisplayModel()
else
{
updateLegends();
m_vizLogic->updateStaticCellColors(-1);
overlayInfoConfig()->update3DInfo();
}
}
@@ -278,25 +263,36 @@ void RimGeoMechView::updateCurrentTimeStep()
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
if (frameScene)
{
frameScene->removeAllModels();
// Grid model
cvf::ref<cvf::ModelBasicList> frameParts = new cvf::ModelBasicList;
m_vizLogic->appendPartsToModel(m_currentTimeStep, frameParts.p());
frameParts->updateBoundingBoxesRecursive();
frameScene->removeAllModels();
frameScene->addModel(frameParts.p());
// Well Path model
double characteristicCellSize = geoMechCase()->geoMechData()->femParts()->characteristicElementSize();
cvf::BoundingBox femBBox = geoMechCase()->geoMechData()->femParts()->boundingBox();
addWellPathsToScene(frameScene, cvf::Vec3d(0, 0, 0),
characteristicCellSize, femBBox, scaleTransform());
cvf::ref<cvf::ModelBasicList> wellPathModel = new cvf::ModelBasicList;
addWellPathsToModel(wellPathModel.p(),
cvf::Vec3d(0, 0, 0),
characteristicCellSize,
femBBox,
scaleTransform());
frameScene->addModel(wellPathModel.p());
}
}
m_vizLogic->updateCellResultColor(m_currentTimeStep(), this->cellResult());
if (this->cellResult()->hasResult())
m_vizLogic->updateCellResultColor(m_currentTimeStep(), this->cellResult());
else
m_vizLogic->updateStaticCellColors(m_currentTimeStep());
}
else
{
m_vizLogic->updateStaticCellColors(m_currentTimeStep);
m_vizLogic->updateStaticCellColors(-1);
m_viewer->animationControl()->slotPause(); // To avoid animation timer spinning in the background
}

View File

@@ -61,21 +61,17 @@ public:
virtual void loadDataAndUpdate();
virtual void endAnimation() {}
caf::PdmField<RimGeoMechResultSlot*> cellResult;
bool isTimeStepDependentDataVisible();
virtual cvf::Transform* scaleTransform();
virtual cvf::Transform* scaleTransform();
private:
virtual void scheduleGeometryRegen(RivCellSetEnum geometryType);
virtual void createDisplayModel();
virtual void updateDisplayModelVisibility();
virtual void updateScaleTransform();
virtual void clampCurrentTimestep();
virtual void updateCurrentTimeStep();

View File

@@ -473,42 +473,24 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::addWellPathsToScene(cvf::Scene* scene, const cvf::Vec3d& displayModelOffset,
double characteristicCellSize, const cvf::BoundingBox& wellPathClipBoundingBox,
void RimView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList,
const cvf::Vec3d& displayModelOffset,
double characteristicCellSize,
const cvf::BoundingBox& wellPathClipBoundingBox,
cvf::Transform* scaleTransform)
{
CVF_ASSERT(scene);
CVF_ASSERT(scaleTransform);
cvf::String wellPathModelName = "WellPathModel";
std::vector<cvf::Model*> wellPathModels;
for (cvf::uint i = 0; i < scene->modelCount(); i++)
{
if (scene->model(i)->name() == wellPathModelName)
{
wellPathModels.push_back(scene->model(i));
}
}
for (size_t i = 0; i < wellPathModels.size(); i++)
{
scene->removeModel(wellPathModels[i]);
}
// Append static Well Paths to model
cvf::ref<cvf::ModelBasicList> wellPathModelBasicList = new cvf::ModelBasicList;
wellPathModelBasicList->setName(wellPathModelName);
RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL;
RimWellPathCollection* wellPathCollection = oilFields ? oilFields->wellPathCollection() : NULL;
RivWellPathCollectionPartMgr* wellPathCollectionPartMgr = wellPathCollection ? wellPathCollection->wellPathCollectionPartMgr() : NULL;
if (wellPathCollectionPartMgr)
{
wellPathCollectionPartMgr->appendStaticGeometryPartsToModel(wellPathModelBasicList.p(), displayModelOffset,
scaleTransform, characteristicCellSize, wellPathClipBoundingBox);
wellPathCollectionPartMgr->appendStaticGeometryPartsToModel(wellPathModelBasicList,
displayModelOffset,
scaleTransform,
characteristicCellSize,
wellPathClipBoundingBox);
}
wellPathModelBasicList->updateBoundingBoxesRecursive();
scene->addModel(wellPathModelBasicList.p());
}

View File

@@ -35,6 +35,7 @@ namespace cvf
{
class BoundingBox;
class Scene;
class ModelBasicList;
class Transform;
}
@@ -114,8 +115,9 @@ public:
protected:
void setDefaultView();
void addWellPathsToScene(cvf::Scene* scene,
const cvf::Vec3d& displayModelOffset,
void addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList,
const cvf::Vec3d& displayModelOffset,
double characteristicCellSize,
const cvf::BoundingBox& wellPathClipBoundingBox,
cvf::Transform* scaleTransform);