#2552 Refactor and align the partmanagers of sim well and sim well head. Prepare to get wellhead into 2d intersection views

This commit is contained in:
Jacob Støren
2018-03-14 15:13:24 +01:00
parent b755ddc11d
commit 9cad0bff1e
6 changed files with 75 additions and 97 deletions
@@ -74,16 +74,6 @@ void RivReservoirSimWellsPartMgr::clearGeometryCache()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivReservoirSimWellsPartMgr::scheduleGeometryRegen() void RivReservoirSimWellsPartMgr::scheduleGeometryRegen()
{ {
for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx)
{
m_wellPipesPartMgrs[wIdx]->scheduleGeometryRegen();
}
for (size_t wIdx = 0; wIdx != m_wellHeadPartMgrs.size(); ++ wIdx)
{
//m_wellHeadPartMgrs[wIdx]->scheduleGeometryRegen(scaleTransform);
}
m_wellSpheresPartMgrs.clear(); m_wellSpheresPartMgrs.clear();
} }
@@ -93,16 +83,6 @@ void RivReservoirSimWellsPartMgr::scheduleGeometryRegen()
void RivReservoirSimWellsPartMgr::setScaleTransform(cvf::Transform * scaleTransform) void RivReservoirSimWellsPartMgr::setScaleTransform(cvf::Transform * scaleTransform)
{ {
m_scaleTransform = scaleTransform; m_scaleTransform = scaleTransform;
for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx)
{
m_wellPipesPartMgrs[wIdx]->setDisplayCoordTransform(m_reservoirView->displayCoordTransform().p());
}
for (size_t wIdx = 0; wIdx != m_wellHeadPartMgrs.size(); ++ wIdx)
{
m_wellHeadPartMgrs[wIdx]->setScaleTransform(scaleTransform);
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -120,18 +100,21 @@ void RivReservoirSimWellsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa
{ {
RivSimWellPipesPartMgr * wppmgr = new RivSimWellPipesPartMgr( m_reservoirView->wellCollection()->wells[i], false); RivSimWellPipesPartMgr * wppmgr = new RivSimWellPipesPartMgr( m_reservoirView->wellCollection()->wells[i], false);
m_wellPipesPartMgrs.push_back(wppmgr); m_wellPipesPartMgrs.push_back(wppmgr);
wppmgr->setDisplayCoordTransform(m_reservoirView->displayCoordTransform().p());
RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]); RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView->wellCollection()->wells[i]);
m_wellHeadPartMgrs.push_back(wellHeadMgr); m_wellHeadPartMgrs.push_back(wellHeadMgr);
wellHeadMgr->setScaleTransform(m_scaleTransform.p());
} }
} }
for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx)
{ {
m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model,
m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); frameIndex,
m_reservoirView->displayCoordTransform().p());
m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model,
frameIndex,
m_reservoirView->displayCoordTransform().p());
} }
// Well spheres // Well spheres
@@ -60,7 +60,6 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimSimWellInView* well, Rim2dIntersectionView * intersectionView) RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimSimWellInView* well, Rim2dIntersectionView * intersectionView)
: m_rimWell(well) : m_rimWell(well)
, m_needsToRebuildGeometry(true)
, m_intersectionView(intersectionView) , m_intersectionView(intersectionView)
{ {
} }
@@ -73,24 +72,6 @@ RivSimWellPipesPartMgr::~RivSimWellPipesPartMgr()
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivSimWellPipesPartMgr::setDisplayCoordTransform(caf::DisplayCoordTransform* displayXf)
{
m_displayCoordTransform = displayXf;
scheduleGeometryRegen();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivSimWellPipesPartMgr::scheduleGeometryRegen()
{
m_needsToRebuildGeometry = true;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -105,7 +86,7 @@ Rim3dView* RivSimWellPipesPartMgr::viewWithSettings()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivSimWellPipesPartMgr::buildWellPipeParts() void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform* displayXf)
{ {
if (!this->viewWithSettings()) return; if (!this->viewWithSettings()) return;
@@ -151,7 +132,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts()
for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx) for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx)
{ {
(*cvfCoords)[cIdx] = ((*cvfCoords)[cIdx]).getTransformedPoint(flatningCSs[cIdx]); (*cvfCoords)[cIdx] = ((*cvfCoords)[cIdx]).getTransformedPoint(flatningCSs[cIdx]);
(*cvfCoords)[cIdx] = m_displayCoordTransform->scaleToDisplaySize((*cvfCoords)[cIdx]); (*cvfCoords)[cIdx] = displayXf->scaleToDisplaySize((*cvfCoords)[cIdx]);
} }
} }
else else
@@ -160,7 +141,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts()
for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx ) for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx )
{ {
(*cvfCoords)[cIdx] = m_displayCoordTransform->transformToDisplayCoord((*cvfCoords)[cIdx]); (*cvfCoords)[cIdx] = displayXf->transformToDisplayCoord((*cvfCoords)[cIdx]);
} }
} }
@@ -202,19 +183,20 @@ void RivSimWellPipesPartMgr::buildWellPipeParts()
if (m_intersectionView) flattenedStartOffset += { 2*m_intersectionView->intersection()->extentLength(), 0.0, 0.0}; if (m_intersectionView) flattenedStartOffset += { 2*m_intersectionView->intersection()->extentLength(), 0.0, 0.0};
} }
m_needsToRebuildGeometry = false;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
size_t frameIndex,
const caf::DisplayCoordTransform* displayXf)
{ {
if (!viewWithSettings()) return; if (!viewWithSettings()) return;
if (!m_rimWell->isWellPipeVisible(frameIndex)) return; if (!m_rimWell->isWellPipeVisible(frameIndex)) return;
if (m_needsToRebuildGeometry) buildWellPipeParts(); buildWellPipeParts(displayXf);
std::list<RivPipeBranchData>::iterator it; std::list<RivPipeBranchData>::iterator it;
for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it) for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it)
@@ -54,22 +54,17 @@ public:
~RivSimWellPipesPartMgr(); ~RivSimWellPipesPartMgr();
void setDisplayCoordTransform(caf::DisplayCoordTransform* displayXf); void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
void scheduleGeometryRegen(); size_t frameIndex,
const caf::DisplayCoordTransform* displayXf);
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex);
void updatePipeResultColor(size_t frameIndex); void updatePipeResultColor(size_t frameIndex);
private: private:
Rim3dView* viewWithSettings(); Rim3dView* viewWithSettings();
void buildWellPipeParts(); void buildWellPipeParts(const caf::DisplayCoordTransform* displayXf);
caf::PdmPointer<RimSimWellInView> m_rimWell; caf::PdmPointer<RimSimWellInView> m_rimWell;
caf::PdmPointer<Rim2dIntersectionView> m_intersectionView; caf::PdmPointer<Rim2dIntersectionView> m_intersectionView;
bool m_isFlattened;
cvf::ref<caf::DisplayCoordTransform> m_displayCoordTransform;
bool m_needsToRebuildGeometry;
struct RivPipeBranchData struct RivPipeBranchData
{ {
@@ -56,10 +56,9 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivWellHeadPartMgr::RivWellHeadPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well) RivWellHeadPartMgr::RivWellHeadPartMgr(RimSimWellInView* well)
: m_rimWell(well)
{ {
m_rimReservoirView = reservoirView;
m_rimWell = well;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -73,31 +72,27 @@ RivWellHeadPartMgr::~RivWellHeadPartMgr()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex,
const caf::DisplayCoordTransform * displayXf)
{ {
clearAllGeometry(); clearAllGeometry();
if (m_rimReservoirView.isNull()) return; if (!viewWithSettings()) return;
RigEclipseCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->eclipseCaseData();
RimSimWellInView* well = m_rimWell; RimSimWellInView* well = m_rimWell;
double characteristicCellSize = rigReservoir->mainGrid()->characteristicIJCellSize(); double characteristicCellSize = viewWithSettings()->ownerCase()->characteristicCellSize();
cvf::Vec3d whEndPos; cvf::Vec3d whEndPos;
cvf::Vec3d whStartPos; cvf::Vec3d whStartPos;
{ {
well->wellHeadTopBottomPosition(static_cast<int>(frameIndex), &whEndPos, &whStartPos); well->wellHeadTopBottomPosition(static_cast<int>(frameIndex), &whEndPos, &whStartPos);
cvf::ref<caf::DisplayCoordTransform> transForm = m_rimReservoirView->displayCoordTransform(); whEndPos = displayXf->transformToDisplayCoord(whEndPos);
whEndPos = transForm->transformToDisplayCoord(whEndPos); whStartPos = displayXf->transformToDisplayCoord(whStartPos);
whStartPos = transForm->transformToDisplayCoord(whStartPos);
whEndPos.z() += characteristicCellSize; whEndPos.z() += characteristicCellSize;
} }
if (!well->simWellData()->hasWellResult(frameIndex)) return; if (!well->simWellData()->hasWellResult(frameIndex)) return;
const RigWellResultFrame& wellResultFrame = well->simWellData()->wellResultFrame(frameIndex); const RigWellResultFrame& wellResultFrame = well->simWellData()->wellResultFrame(frameIndex);
@@ -141,7 +136,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
part->setDrawable(pipeSurface.p()); part->setDrawable(pipeSurface.p());
caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(well->wellPipeColor()), caf::PO_1); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(well->wellPipeColor()), caf::PO_1);
if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled()) if (viewWithSettings() && viewWithSettings()->isLightingDisabled())
{ {
surfaceGen.enableLighting(false); surfaceGen.enableLighting(false);
} }
@@ -170,7 +165,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
} }
} }
double arrowLength = characteristicCellSize * m_rimReservoirView->wellCollection()->wellHeadScaleFactor() * m_rimWell->wellHeadScaleFactor(); double arrowLength = characteristicCellSize * simWellInViewCollection()->wellHeadScaleFactor() * m_rimWell->wellHeadScaleFactor();
if (wellResultFrame.m_isOpen) if (wellResultFrame.m_isOpen)
{ {
@@ -269,7 +264,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
} }
caf::SurfaceEffectGenerator surfaceGen(headColor, caf::PO_1); caf::SurfaceEffectGenerator surfaceGen(headColor, caf::PO_1);
if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled()) if (viewWithSettings() && viewWithSettings()->isLightingDisabled())
{ {
surfaceGen.enableLighting(false); surfaceGen.enableLighting(false);
} }
@@ -291,7 +286,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
drawableText->setDrawBorder(false); drawableText->setDrawBorder(false);
drawableText->setDrawBackground(false); drawableText->setDrawBackground(false);
drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER); drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER);
drawableText->setTextColor(m_rimReservoirView->wellCollection()->wellLabelColor()); drawableText->setTextColor(simWellInViewCollection()->wellLabelColor());
cvf::String cvfString = cvfqt::Utils::toString(m_rimWell->name()); cvf::String cvfString = cvfqt::Utils::toString(m_rimWell->name());
@@ -326,18 +321,16 @@ void RivWellHeadPartMgr::clearAllGeometry()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
size_t frameIndex,
const caf::DisplayCoordTransform * displayXf)
{ {
if (m_rimReservoirView.isNull()) return;
if (m_rimWell.isNull()) return; if (m_rimWell.isNull()) return;
if (!viewWithSettings()) return;
RimSimWellInViewCollection* wellCollection = nullptr;
m_rimWell->firstAncestorOrThisOfType(wellCollection);
if (!wellCollection) return;
if (!m_rimWell->isWellPipeVisible(frameIndex)) return; if (!m_rimWell->isWellPipeVisible(frameIndex)) return;
buildWellHeadParts(frameIndex); buildWellHeadParts(frameIndex, displayXf);
// Always add pipe part of well head // Always add pipe part of well head
if (m_wellHeadPipeCenterPart.notNull()) model->addPart(m_wellHeadPipeCenterPart.p()); if (m_wellHeadPipeCenterPart.notNull()) model->addPart(m_wellHeadPipeCenterPart.p());
@@ -356,4 +349,25 @@ void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList*
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim3dView* RivWellHeadPartMgr::viewWithSettings()
{
Rim3dView* view = nullptr;
if (m_rimWell) m_rimWell->firstAncestorOrThisOfType(view);
return view;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSimWellInViewCollection* RivWellHeadPartMgr::simWellInViewCollection()
{
RimSimWellInViewCollection* wellCollection = nullptr;
if (m_rimWell) m_rimWell->firstAncestorOrThisOfType(wellCollection);
return wellCollection;
}
@@ -30,32 +30,35 @@ namespace cvf
class Transform; class Transform;
class Font; class Font;
} }
namespace caf
{
class DisplayCoordTransform;
}
class RimEclipseView; class Rim3dView;
class RimSimWellInView; class RimSimWellInView;
class RimSimWellInViewCollection;
class RivWellHeadPartMgr : public cvf::Object class RivWellHeadPartMgr : public cvf::Object
{ {
public: public:
RivWellHeadPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well); RivWellHeadPartMgr( RimSimWellInView* well);
~RivWellHeadPartMgr(); ~RivWellHeadPartMgr();
void setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform;} void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
size_t frameIndex,
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); const caf::DisplayCoordTransform * displayXf);
private: private:
void buildWellHeadParts(size_t frameIndex); void buildWellHeadParts(size_t frameIndex,
void clearAllGeometry(); const caf::DisplayCoordTransform * displayXf);
void clearAllGeometry();
Rim3dView* viewWithSettings();
RimSimWellInViewCollection* simWellInViewCollection();
private: private:
caf::PdmPointer<RimEclipseView> m_rimReservoirView;
caf::PdmPointer<RimSimWellInView> m_rimWell; caf::PdmPointer<RimSimWellInView> m_rimWell;
cvf::ref<cvf::Transform> m_scaleTransform;
cvf::ref< cvf::Part > m_wellHeadArrowPart; cvf::ref< cvf::Part > m_wellHeadArrowPart;
cvf::ref< cvf::Part > m_wellHeadLabelPart; cvf::ref< cvf::Part > m_wellHeadLabelPart;
cvf::ref< cvf::Part > m_wellHeadPipeSurfacePart; cvf::ref< cvf::Part > m_wellHeadPipeSurfacePart;
@@ -472,8 +472,9 @@ void Rim2dIntersectionView::updateCurrentTimeStep()
cvf::ref<cvf::ModelBasicList> simWellModelBasicList = new cvf::ModelBasicList; cvf::ref<cvf::ModelBasicList> simWellModelBasicList = new cvf::ModelBasicList;
simWellModelBasicList->setName(name); simWellModelBasicList->setName(name);
m_flatSimWellPipePartMgr->setDisplayCoordTransform(this->displayCoordTransform().p()); m_flatSimWellPipePartMgr->appendDynamicGeometryPartsToModel(simWellModelBasicList.p(),
m_flatSimWellPipePartMgr->appendDynamicGeometryPartsToModel(simWellModelBasicList.p(), m_currentTimeStep); m_currentTimeStep,
this->displayCoordTransform().p());
simWellModelBasicList->updateBoundingBoxesRecursive(); simWellModelBasicList->updateBoundingBoxesRecursive();
frameScene->addModel(simWellModelBasicList.p()); frameScene->addModel(simWellModelBasicList.p());