#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-13 17:19:14 +01:00
parent b755ddc11d
commit 9cad0bff1e
6 changed files with 75 additions and 97 deletions

View File

@ -74,16 +74,6 @@ void RivReservoirSimWellsPartMgr::clearGeometryCache()
//--------------------------------------------------------------------------------------------------
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();
}
@ -93,16 +83,6 @@ void RivReservoirSimWellsPartMgr::scheduleGeometryRegen()
void RivReservoirSimWellsPartMgr::setScaleTransform(cvf::Transform * 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);
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);
wellHeadMgr->setScaleTransform(m_scaleTransform.p());
}
}
for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx)
{
m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex);
m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex);
m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model,
frameIndex,
m_reservoirView->displayCoordTransform().p());
m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model,
frameIndex,
m_reservoirView->displayCoordTransform().p());
}
// Well spheres

View File

@ -60,7 +60,6 @@
//--------------------------------------------------------------------------------------------------
RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimSimWellInView* well, Rim2dIntersectionView * intersectionView)
: m_rimWell(well)
, m_needsToRebuildGeometry(true)
, 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;
@ -151,7 +132,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts()
for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx)
{
(*cvfCoords)[cIdx] = ((*cvfCoords)[cIdx]).getTransformedPoint(flatningCSs[cIdx]);
(*cvfCoords)[cIdx] = m_displayCoordTransform->scaleToDisplaySize((*cvfCoords)[cIdx]);
(*cvfCoords)[cIdx] = displayXf->scaleToDisplaySize((*cvfCoords)[cIdx]);
}
}
else
@ -160,7 +141,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts()
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};
}
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 (!m_rimWell->isWellPipeVisible(frameIndex)) return;
if (m_needsToRebuildGeometry) buildWellPipeParts();
buildWellPipeParts(displayXf);
std::list<RivPipeBranchData>::iterator it;
for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it)

View File

@ -54,22 +54,17 @@ public:
~RivSimWellPipesPartMgr();
void setDisplayCoordTransform(caf::DisplayCoordTransform* displayXf);
void scheduleGeometryRegen();
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex);
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
size_t frameIndex,
const caf::DisplayCoordTransform* displayXf);
void updatePipeResultColor(size_t frameIndex);
private:
Rim3dView* viewWithSettings();
void buildWellPipeParts();
void buildWellPipeParts(const caf::DisplayCoordTransform* displayXf);
caf::PdmPointer<RimSimWellInView> m_rimWell;
caf::PdmPointer<Rim2dIntersectionView> m_intersectionView;
bool m_isFlattened;
cvf::ref<caf::DisplayCoordTransform> m_displayCoordTransform;
bool m_needsToRebuildGeometry;
struct RivPipeBranchData
{

View File

@ -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();
if (m_rimReservoirView.isNull()) return;
if (!viewWithSettings()) return;
RigEclipseCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->eclipseCaseData();
RimSimWellInView* well = m_rimWell;
double characteristicCellSize = rigReservoir->mainGrid()->characteristicIJCellSize();
double characteristicCellSize = viewWithSettings()->ownerCase()->characteristicCellSize();
cvf::Vec3d whEndPos;
cvf::Vec3d whStartPos;
{
well->wellHeadTopBottomPosition(static_cast<int>(frameIndex), &whEndPos, &whStartPos);
cvf::ref<caf::DisplayCoordTransform> transForm = m_rimReservoirView->displayCoordTransform();
whEndPos = transForm->transformToDisplayCoord(whEndPos);
whStartPos = transForm->transformToDisplayCoord(whStartPos);
whEndPos = displayXf->transformToDisplayCoord(whEndPos);
whStartPos = displayXf->transformToDisplayCoord(whStartPos);
whEndPos.z() += characteristicCellSize;
}
if (!well->simWellData()->hasWellResult(frameIndex)) return;
const RigWellResultFrame& wellResultFrame = well->simWellData()->wellResultFrame(frameIndex);
@ -141,7 +136,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
part->setDrawable(pipeSurface.p());
caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(well->wellPipeColor()), caf::PO_1);
if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled())
if (viewWithSettings() && viewWithSettings()->isLightingDisabled())
{
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)
{
@ -269,7 +264,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
}
caf::SurfaceEffectGenerator surfaceGen(headColor, caf::PO_1);
if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled())
if (viewWithSettings() && viewWithSettings()->isLightingDisabled())
{
surfaceGen.enableLighting(false);
}
@ -291,7 +286,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
drawableText->setDrawBorder(false);
drawableText->setDrawBackground(false);
drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER);
drawableText->setTextColor(m_rimReservoirView->wellCollection()->wellLabelColor());
drawableText->setTextColor(simWellInViewCollection()->wellLabelColor());
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;
RimSimWellInViewCollection* wellCollection = nullptr;
m_rimWell->firstAncestorOrThisOfType(wellCollection);
if (!wellCollection) return;
if (!viewWithSettings()) return;
if (!m_rimWell->isWellPipeVisible(frameIndex)) return;
buildWellHeadParts(frameIndex);
buildWellHeadParts(frameIndex, displayXf);
// Always add pipe part of well head
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;
}

View File

@ -30,32 +30,35 @@ namespace cvf
class Transform;
class Font;
}
namespace caf
{
class DisplayCoordTransform;
}
class RimEclipseView;
class Rim3dView;
class RimSimWellInView;
class RimSimWellInViewCollection;
class RivWellHeadPartMgr : public cvf::Object
{
public:
RivWellHeadPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well);
RivWellHeadPartMgr( RimSimWellInView* well);
~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:
void buildWellHeadParts(size_t frameIndex);
void clearAllGeometry();
void buildWellHeadParts(size_t frameIndex,
const caf::DisplayCoordTransform * displayXf);
void clearAllGeometry();
Rim3dView* viewWithSettings();
RimSimWellInViewCollection* simWellInViewCollection();
private:
caf::PdmPointer<RimEclipseView> m_rimReservoirView;
caf::PdmPointer<RimSimWellInView> m_rimWell;
cvf::ref<cvf::Transform> m_scaleTransform;
cvf::ref< cvf::Part > m_wellHeadArrowPart;
cvf::ref< cvf::Part > m_wellHeadLabelPart;
cvf::ref< cvf::Part > m_wellHeadPipeSurfacePart;

View File

@ -472,8 +472,9 @@ void Rim2dIntersectionView::updateCurrentTimeStep()
cvf::ref<cvf::ModelBasicList> simWellModelBasicList = new cvf::ModelBasicList;
simWellModelBasicList->setName(name);
m_flatSimWellPipePartMgr->setDisplayCoordTransform(this->displayCoordTransform().p());
m_flatSimWellPipePartMgr->appendDynamicGeometryPartsToModel(simWellModelBasicList.p(), m_currentTimeStep);
m_flatSimWellPipePartMgr->appendDynamicGeometryPartsToModel(simWellModelBasicList.p(),
m_currentTimeStep,
this->displayCoordTransform().p());
simWellModelBasicList->updateBoundingBoxesRecursive();
frameScene->addModel(simWellModelBasicList.p());