#1025 Replaced check-box with enum for showing cell center spheres

This commit is contained in:
astridkbjorke 2016-12-12 10:08:11 +01:00
parent 829c775f63
commit 21a8acdb76
7 changed files with 91 additions and 52 deletions

View File

@ -48,9 +48,9 @@ RivReservoirWellSpheresPartMgr::~RivReservoirWellSpheresPartMgr()
} }
//-------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
/// // /
//-------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
void RivReservoirWellSpheresPartMgr::setScaleTransform(cvf::Transform * scaleTransform) void RivReservoirWellSpheresPartMgr::setScaleTransform(cvf::Transform * scaleTransform)
{ {
m_scaleTransform = scaleTransform; m_scaleTransform = scaleTransform;
@ -62,8 +62,8 @@ void RivReservoirWellSpheresPartMgr::setScaleTransform(cvf::Transform * scaleTra
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivReservoirWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) void RivReservoirWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
{ {
if (!m_reservoirView->wellCollection()->showCellCenterSpheres) return; if (m_reservoirView->wellCollection()->wellSphereVisibility == RimEclipseWellCollection::PIPES_FORCE_ALL_OFF) return;
if (!m_reservoirView->wellCollection()->isActive()) return; if (!m_reservoirView->wellCollection()->isActive()) return;
if (m_reservoirView->wellCollection()->wells.size() != m_wellSpheresPartMgrs.size()) if (m_reservoirView->wellCollection()->wells.size() != m_wellSpheresPartMgrs.size())
@ -78,8 +78,33 @@ void RivReservoirWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode
for (size_t i = 0; i < m_wellSpheresPartMgrs.size(); i++) for (size_t i = 0; i < m_wellSpheresPartMgrs.size(); i++)
{ {
bool showGeo = false;
if (m_reservoirView->wellCollection()->wells[i]->showWell()) if (m_reservoirView->wellCollection()->wells[i]->showWell())
{ {
if (m_reservoirView->wellCollection->wellSphereVisibility == RimEclipseWellCollection::PIPES_FORCE_ALL_ON)
{
showGeo = true;
}
else if (m_reservoirView->wellCollection->wellSphereVisibility == RimEclipseWellCollection::PIPES_INDIVIDUALLY && m_reservoirView->wellCollection()->wells[i]->showWellSpheres() )
{
showGeo = true;
}
else if (m_reservoirView->wellCollection->wellSphereVisibility == RimEclipseWellCollection::PIPES_OPEN_IN_VISIBLE_CELLS && m_reservoirView->wellCollection->wells[i]->visibleCellsInstersectsWell(frameIndex))
{
showGeo = true;
}
}
if (showGeo)
{
m_wellSpheresPartMgrs.at(i)->appendDynamicGeometryPartsToModel(model, frameIndex); m_wellSpheresPartMgrs.at(i)->appendDynamicGeometryPartsToModel(model, frameIndex);
} }
} }

View File

@ -63,6 +63,7 @@ RivWellSpheresPartMgr::~RivWellSpheresPartMgr()
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -71,7 +72,10 @@ void RivWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLis
if (m_rimReservoirView.isNull()) return; if (m_rimReservoirView.isNull()) return;
if (!m_rimReservoirView->eclipseCase()) return; if (!m_rimReservoirView->eclipseCase()) return;
if (!m_rimReservoirView->eclipseCase()->reservoirData()) return; if (!m_rimReservoirView->eclipseCase()->reservoirData()) return;
if (!m_rimWell->showWellSpheres()) return;
// if (!m_rimWell->showWellSpheres() ) return; //TODO: Check that all on is not on...
const RigMainGrid* mainGrid = m_rimReservoirView->eclipseCase()->reservoirData()->mainGrid(); const RigMainGrid* mainGrid = m_rimReservoirView->eclipseCase()->reservoirData()->mainGrid();
CVF_ASSERT(mainGrid); CVF_ASSERT(mainGrid);
@ -115,7 +119,6 @@ void RivWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLis
model->addPart(part.p()); model->addPart(part.p());
} }
//TODO: Transparency må være linka til show cell center spheres og All On/Of for well pipes
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
// / // /

View File

@ -59,8 +59,8 @@ public:
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex);
private: private:
static cvf::ref<cvf::DrawableGeo> createSphere(double radius, const cvf::Vec3d& pos); // static cvf::ref<cvf::DrawableGeo> createSphere(double radius, const cvf::Vec3d& pos);
cvf::ref<cvf::Part> createPart(cvf::DrawableGeo* geo, const cvf::Color3f& color); // cvf::ref<cvf::Part> createPart(cvf::DrawableGeo* geo, const cvf::Color3f& color);
cvf::Color3f wellCellColor(const RigWellResultFrame& wellResultFrame, const RigWellResultPoint& wellResultPoint); cvf::Color3f wellCellColor(const RigWellResultFrame& wellResultFrame, const RigWellResultPoint& wellResultPoint);
cvf::ref<cvf::Part> createPart(std::vector<std::pair<cvf::Vec3f, cvf::Color3f> >& centerColorPairs); cvf::ref<cvf::Part> createPart(std::vector<std::pair<cvf::Vec3f, cvf::Color3f> >& centerColorPairs);

View File

@ -190,55 +190,65 @@ bool RimEclipseWell::calculateWellPipeVisibility(size_t frameIndex)
if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimEclipseWellCollection::PIPES_OPEN_IN_VISIBLE_CELLS) if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimEclipseWellCollection::PIPES_OPEN_IN_VISIBLE_CELLS)
{ {
const std::vector<RivCellSetEnum>& visGridParts = m_reservoirView->visibleGridParts();
cvf::cref<RivReservoirViewPartMgr> rvMan = m_reservoirView->reservoirGridPartManager();
for (size_t gpIdx = 0; gpIdx < visGridParts.size(); ++gpIdx) return visibleCellsInstersectsWell(frameIndex);
}
CVF_ASSERT(false); // Never end here. have you added new pipe visibility modes ?
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseWell::visibleCellsInstersectsWell(size_t frameIndex)
{
//TODO: lag egen funksjon her:
const std::vector<RivCellSetEnum>& visGridParts = m_reservoirView->visibleGridParts();
cvf::cref<RivReservoirViewPartMgr> rvMan = m_reservoirView->reservoirGridPartManager();
for (size_t gpIdx = 0; gpIdx < visGridParts.size(); ++gpIdx)
{
const RigWellResultFrame& wrsf = this->wellResults()->wellResultFrame(frameIndex);
// First check the wellhead:
size_t gridIndex = wrsf.m_wellHead.m_gridIndex;
size_t gridCellIndex = wrsf.m_wellHead.m_gridCellIndex;
if (gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T)
{ {
const RigWellResultFrame& wrsf = this->wellResults()->wellResultFrame(frameIndex); cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex);
if ((*cellVisibility)[gridCellIndex])
// First check the wellhead:
size_t gridIndex = wrsf.m_wellHead.m_gridIndex;
size_t gridCellIndex = wrsf.m_wellHead.m_gridCellIndex;
if (gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T)
{ {
cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex); return true;
if ((*cellVisibility)[gridCellIndex])
{
return true;
}
} }
}
// Then check the rest of the well, with all the branches // Then check the rest of the well, with all the branches
const std::vector<RigWellResultBranch>& wellResSegments = wrsf.m_wellResultBranches; const std::vector<RigWellResultBranch>& wellResSegments = wrsf.m_wellResultBranches;
for (size_t wsIdx = 0; wsIdx < wellResSegments.size(); ++wsIdx) for (size_t wsIdx = 0; wsIdx < wellResSegments.size(); ++wsIdx)
{
const std::vector<RigWellResultPoint>& wsResCells = wellResSegments[wsIdx].m_branchResultPoints;
for (size_t cIdx = 0; cIdx < wsResCells.size(); ++cIdx)
{ {
const std::vector<RigWellResultPoint>& wsResCells = wellResSegments[wsIdx].m_branchResultPoints; if (wsResCells[cIdx].isCell())
for (size_t cIdx = 0; cIdx < wsResCells.size(); ++ cIdx)
{ {
if (wsResCells[cIdx].isCell()) gridIndex = wsResCells[cIdx].m_gridIndex;
{ gridCellIndex = wsResCells[cIdx].m_gridCellIndex;
gridIndex = wsResCells[cIdx].m_gridIndex;
gridCellIndex = wsResCells[cIdx].m_gridCellIndex;
cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex); cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex);
if ((*cellVisibility)[gridCellIndex]) if ((*cellVisibility)[gridCellIndex])
{ {
return true; return true;
}
} }
} }
} }
} }
return false;
} }
CVF_ASSERT(false); // Never end here. have you added new pipe visibility modes ?
return false; return false;
} }

View File

@ -56,6 +56,10 @@ public:
bool calculateWellPipeVisibility(size_t frameIndex); bool calculateWellPipeVisibility(size_t frameIndex);
bool visibleCellsInstersectsWell(size_t frameIndex);
//Trengs det en calculateWellGeometryVisibility??
virtual caf::PdmFieldHandle* userDescriptionField(); virtual caf::PdmFieldHandle* userDescriptionField();
virtual caf::PdmFieldHandle* objectToggleField(); virtual caf::PdmFieldHandle* objectToggleField();

View File

@ -108,8 +108,7 @@ RimEclipseWellCollection::RimEclipseWellCollection()
CAF_PDM_InitField(&isAutoDetectingBranches, "IsAutoDetectingBranches", true, "Geometry based branch detection", "", "Toggle wether the well pipe visualization will try to detect when a part of the well \nis really a branch, and thus is starting from wellhead", ""); CAF_PDM_InitField(&isAutoDetectingBranches, "IsAutoDetectingBranches", true, "Geometry based branch detection", "", "Toggle wether the well pipe visualization will try to detect when a part of the well \nis really a branch, and thus is starting from wellhead", "");
CAF_PDM_InitField(&showCellCenterSpheres, "showCellCenterSpheres", false, "Show sphere in cell center", "", "", ""); CAF_PDM_InitField(&wellSphereVisibility, "wellSphereVisibility", WellVisibilityEnum(PIPES_OPEN_IN_VISIBLE_CELLS), "Global well sphere visibility", "", "", "");
// CAF_PDM_InitField(&wellSphereVisibility, "wellSphereVisibility", WellVisibilityEnum(PIPES_OPEN_IN_VISIBLE_CELLS), "Global well sphere visibility", "", "", "");
CAF_PDM_InitField(&cellCenterSpheresScaleFactor, "CellCenterSphereScale", 0.2, "Cell Center sphere radius", "", "", ""); CAF_PDM_InitField(&cellCenterSpheresScaleFactor, "CellCenterSphereScale", 0.2, "Cell Center sphere radius", "", "", "");
CAF_PDM_InitFieldNoDefault(&wells, "Wells", "Wells", "", "", ""); CAF_PDM_InitFieldNoDefault(&wells, "Wells", "Wells", "", "", "");
@ -179,7 +178,7 @@ bool RimEclipseWellCollection::hasVisibleWellCells()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Used to know if we need animation of timesteps due to the wells /// Used to know if we need animation of timesteps due to the wells
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimEclipseWellCollection::hasVisibleWellPipes() bool RimEclipseWellCollection::hasVisibleWellPipes()
{ {
if (!this->isActive()) return false; if (!this->isActive()) return false;
if (this->wellPipeVisibility() == PIPES_FORCE_ALL_OFF) return false; if (this->wellPipeVisibility() == PIPES_FORCE_ALL_OFF) return false;
@ -189,7 +188,6 @@ bool RimEclipseWellCollection::hasVisibleWellPipes()
return true; return true;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -228,7 +226,7 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang
m_reservoirView->scheduleCreateDisplayModelAndRedraw(); m_reservoirView->scheduleCreateDisplayModelAndRedraw();
} }
} }
else if ( &showCellCenterSpheres == changedField else if ( &wellSphereVisibility == changedField
|| &cellCenterSpheresScaleFactor == changedField) || &cellCenterSpheresScaleFactor == changedField)
{ {
if (m_reservoirView) if (m_reservoirView)
@ -298,7 +296,7 @@ void RimEclipseWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi
wellPipe->add(&pipeRadiusScaleFactor); wellPipe->add(&pipeRadiusScaleFactor);
caf::PdmUiGroup* cellCenterSpheres = uiOrdering.addNewGroup("Well cell center spheres"); caf::PdmUiGroup* cellCenterSpheres = uiOrdering.addNewGroup("Well cell center spheres");
cellCenterSpheres->add(&showCellCenterSpheres); cellCenterSpheres->add(&wellSphereVisibility);
cellCenterSpheres->add(&cellCenterSpheresScaleFactor); cellCenterSpheres->add(&cellCenterSpheresScaleFactor);
caf::PdmUiGroup* advancedGroup = uiOrdering.addNewGroup("Advanced"); caf::PdmUiGroup* advancedGroup = uiOrdering.addNewGroup("Advanced");

View File

@ -45,7 +45,7 @@ public:
RimEclipseWellCollection(); RimEclipseWellCollection();
virtual ~RimEclipseWellCollection(); virtual ~RimEclipseWellCollection();
void setReservoirView(RimEclipseView* ownerReservoirView); void setReservoirView(RimEclipseView* ownerReservoirView);
enum WellVisibilityType enum WellVisibilityType
@ -102,8 +102,7 @@ public:
caf::PdmField<bool> isAutoDetectingBranches; caf::PdmField<bool> isAutoDetectingBranches;
caf::PdmField<bool> showCellCenterSpheres; caf::PdmField<WellVisibilityEnum> wellSphereVisibility;
//caf::PdmField<WellVisibilityEnum> wellSphereVisibility;
caf::PdmField<double> cellCenterSpheresScaleFactor; caf::PdmField<double> cellCenterSpheresScaleFactor;