From df46e626c9011615db9472328a51a9a7edc18f67 Mon Sep 17 00:00:00 2001 From: astridkbjorke Date: Wed, 7 Dec 2016 15:08:46 +0100 Subject: [PATCH] #1025 Setting colour of cell center spheres based on well type --- .../RivWellSpheresPartMgr.cpp | 61 ++++++++++++++----- .../RivWellSpheresPartMgr.h | 18 +++--- 2 files changed, 54 insertions(+), 25 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp index c32ab52019..4ed33d81e5 100644 --- a/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp @@ -74,8 +74,6 @@ void RivWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLis const RigWellResultFrame& wellResultFrame = rigWellResult->wellResultFrame(frameIndex); - std::vector cellCenters; - for (const RigWellResultBranch& wellResultBranch : wellResultFrame.m_wellResultBranches) { for (const RigWellResultPoint& wellResultPoint : wellResultBranch.m_branchResultPoints) @@ -88,20 +86,19 @@ void RivWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLis cvf::Vec3d center = rigCell.center(); - cellCenters.push_back(center); + cvf::Color3f color = wellCellColor(wellResultFrame, wellResultPoint); + + cvf::ref transForm = m_rimReservoirView->displayCoordTransform(); + cvf::Vec3d displayCoord = transForm->transformToDisplayCoord(center); + + cvf::ref geo = createSphere(10, displayCoord); + cvf::ref part = createPart(geo.p(), color); + + model->addPart(part.p()); + } } } - cvf::ref transForm = m_rimReservoirView->displayCoordTransform(); - for (cvf::Vec3d c : cellCenters) - { - cvf::Vec3d displayCoord = transForm->transformToDisplayCoord(c); - - cvf::ref geo = createSphere(10, displayCoord); - cvf::ref part = createPart(geo.p()); - - model->addPart(part.p()); - } } //-------------------------------------------------------------------------------------------------- @@ -136,12 +133,12 @@ cvf::ref RivWellSpheresPartMgr::createSphere(double radius, co //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivWellSpheresPartMgr::createPart(cvf::DrawableGeo* geo) +cvf::ref RivWellSpheresPartMgr::createPart(cvf::DrawableGeo* geo, const cvf::Color3f& color) { cvf::ref part = new cvf::Part; part->setDrawable(geo); - caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(cvf::Color3f::GREEN), caf::PO_1); + caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(color), caf::PO_1); cvf::ref eff = surfaceGen.generateCachedEffect(); part->setEffect(eff.p()); @@ -149,3 +146,37 @@ cvf::ref RivWellSpheresPartMgr::createPart(cvf::DrawableGeo* geo) return part; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RivWellSpheresPartMgr::wellCellColor(const RigWellResultFrame& wellResultFrame, const RigWellResultPoint& wellResultPoint) +{ + // Colours should be synchronized with RivWellPipesPartMgr::updatePipeResultColor + + cvf::Color3f cellColor(cvf::Color3f::GRAY); + + if (wellResultPoint.m_isOpen) + { + switch (wellResultFrame.m_productionType) + { + case RigWellResultFrame::PRODUCER: + cellColor = cvf::Color3f::GREEN; + break; + case RigWellResultFrame::OIL_INJECTOR: + cellColor = cvf::Color3f::RED; + break; + case RigWellResultFrame::GAS_INJECTOR: + cellColor = cvf::Color3f::RED; + break; + case RigWellResultFrame::WATER_INJECTOR: + cellColor = cvf::Color3f::BLUE; + break; + case RigWellResultFrame::UNDEFINED_PRODUCTION_TYPE: + cellColor = cvf::Color3f::GRAY; + break; + } + } + + return cellColor; +} + diff --git a/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.h b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.h index f67a132a55..e5ba7199ad 100644 --- a/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.h @@ -23,8 +23,8 @@ #include "cvfVector3.h" #include "cafPdmPointer.h" + #include -#include "RigSingleWellResultsData.h" namespace cvf { @@ -34,11 +34,15 @@ namespace cvf class Effect; class DrawableGeo; class ScalarMapper; + class Color3f; } class RivPipeGeometryGenerator; class RimEclipseView; class RimEclipseWell; +class RigWellResultFrame; + +struct RigWellResultPoint; class RivWellSpheresPartMgr : public cvf::Object { @@ -55,20 +59,14 @@ public: private: static cvf::ref createSphere(double radius, const cvf::Vec3d& pos); - cvf::ref createPart(cvf::DrawableGeo* geo); + cvf::ref createPart(cvf::DrawableGeo* geo, const cvf::Color3f& color); + + cvf::Color3f wellCellColor(const RigWellResultFrame& wellResultFrame, const RigWellResultPoint& wellResultPoint); private: caf::PdmPointer m_rimReservoirView; caf::PdmPointer m_rimWell; - - struct RivPipeBranchData - { - cvf::ref m_surfacePart; - cvf::ref m_surfaceDrawable; - }; - - cvf::ref m_scaleTransform; bool m_needsTransformUpdate; };