#1648 Remove dependency on active view from color generation.

Separate the fracture geometry generation methods from the wellpath methods. Use eclipse View as argument.
Fixed some constness stuff in View
This commit is contained in:
Jacob Støren
2017-06-25 10:36:15 +02:00
parent 50a0dcd499
commit cbb0a58673
12 changed files with 72 additions and 47 deletions

View File

@@ -104,13 +104,12 @@ void RivWellFracturePartMgr::generateSurfacePart(const caf::DisplayCoordTransfor
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::applyFractureUniformColor() void RivWellFracturePartMgr::applyFractureUniformColor(const RimEclipseView* activeView)
{ {
if ( m_surfacePart.notNull() ) if ( m_surfacePart.notNull() )
{ {
cvf::Color4f fractureColor = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN)); cvf::Color4f fractureColor = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN));
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
if ( activeView ) if ( activeView )
{ {
fractureColor = cvf::Color4f(activeView->stimPlanColors->defaultColor()); fractureColor = cvf::Color4f(activeView->stimPlanColors->defaultColor());
@@ -125,14 +124,13 @@ void RivWellFracturePartMgr::applyFractureUniformColor()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::applyResultTextureColor() void RivWellFracturePartMgr::applyResultTextureColor(const RimEclipseView* activeView)
{ {
if (m_surfacePart.isNull()) return; if (m_surfacePart.isNull()) return;
if (m_rimFracture) if (m_rimFracture)
{ {
RimLegendConfig* legendConfig = nullptr; RimLegendConfig* legendConfig = nullptr;
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
if (activeView && activeView->stimPlanColors()) if (activeView && activeView->stimPlanColors())
{ {
if (activeView->stimPlanColors()->isChecked()) if (activeView->stimPlanColors()->isChecked())
@@ -199,7 +197,7 @@ void RivWellFracturePartMgr::applyResultTextureColor()
} }
else else
{ {
applyFractureUniformColor(); applyFractureUniformColor(activeView);
} }
} }
} }
@@ -261,7 +259,8 @@ void RivWellFracturePartMgr::generateStimPlanMeshPart(const caf::DisplayCoordTra
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const caf::DisplayCoordTransform* displayCoordTransform) cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate,
const caf::DisplayCoordTransform* displayCoordTransform)
{ {
//TODO: This is needed to avoid errors when loading project with stimPlan fractures with multipled timesteps. //TODO: This is needed to avoid errors when loading project with stimPlan fractures with multipled timesteps.
//Should probably be moved, since it now is called twice in some cases... //Should probably be moved, since it now is called twice in some cases...
@@ -287,8 +286,10 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri
return nullptr; return nullptr;
} }
cvf::Mat4d m = m_rimFracture->transformMatrix(); cvf::Mat4d fractureXf = m_rimFracture->transformMatrix();
std::vector<cvf::Vec3f> stimPlanMeshVerticesDisplayCoords = transfromToFractureDisplayCoords(stimPlanMeshVertices, m, displayCoordTransform); std::vector<cvf::Vec3f> stimPlanMeshVerticesDisplayCoords = transfromToFractureDisplayCoords(stimPlanMeshVertices,
fractureXf,
displayCoordTransform);
cvf::Vec3fArray* stimPlanMeshVertexList; cvf::Vec3fArray* stimPlanMeshVertexList;
stimPlanMeshVertexList = new cvf::Vec3fArray; stimPlanMeshVertexList = new cvf::Vec3fArray;
@@ -412,34 +413,35 @@ std::vector<double> RivWellFracturePartMgr::mirrorDataAtSingleDepth(std::vector<
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform) void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model,
const RimEclipseView* eclView)
{ {
clearGeometryCache(); clearGeometryCache();
if (!m_rimFracture->isChecked()) return; if (!m_rimFracture->isChecked()) return;
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate()); RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
auto displayCoordTransform = eclView->displayCoordTransform();
if (m_surfacePart.isNull()) if (m_surfacePart.isNull())
{ {
if (m_rimFracture->fractureTemplate()) if (m_rimFracture->fractureTemplate())
{ {
if (stimPlanFracTemplate) if (stimPlanFracTemplate)
{ {
generateSurfacePart(displayCoordTransform); generateSurfacePart(displayCoordTransform.p());
generateFractureOutlinePolygonPart(displayCoordTransform); generateFractureOutlinePolygonPart(displayCoordTransform.p());
applyResultTextureColor(); applyResultTextureColor(eclView);
if (stimPlanFracTemplate->showStimPlanMesh()) if (stimPlanFracTemplate->showStimPlanMesh())
{ {
generateStimPlanMeshPart(displayCoordTransform); generateStimPlanMeshPart(displayCoordTransform.p());
} }
} }
else // Ellipse else // Ellipse
{ {
generateSurfacePart(displayCoordTransform); generateSurfacePart(displayCoordTransform.p());
applyFractureUniformColor(); applyFractureUniformColor(eclView);
} }
} }
} }
@@ -476,7 +478,8 @@ void RivWellFracturePartMgr::clearGeometryCache()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::buildDrawableGeoFromTriangles(const std::vector<cvf::uint>& triangleIndices, const std::vector<cvf::Vec3f>& nodeCoords) cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::buildDrawableGeoFromTriangles(const std::vector<cvf::uint>& triangleIndices,
const std::vector<cvf::Vec3f>& nodeCoords)
{ {
CVF_ASSERT(triangleIndices.size() > 0); CVF_ASSERT(triangleIndices.size() > 0);
CVF_ASSERT(nodeCoords.size() > 0); CVF_ASSERT(nodeCoords.size() > 0);
@@ -496,7 +499,9 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::buildDrawableGeoFromTriangles
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RivWellFracturePartMgr::stimPlanCellTouchesPolygon(const std::vector<cvf::Vec3f>& polygon, double xMin, double xMax, double yMin, double yMax, float polygonXmin, float polygonXmax, float polygonYmin, float polygonYmax) bool RivWellFracturePartMgr::stimPlanCellTouchesPolygon(const std::vector<cvf::Vec3f>& polygon,
double xMin, double xMax, double yMin, double yMax,
float polygonXmin, float polygonXmax, float polygonYmin, float polygonYmax)
{ {
if (static_cast<float>(xMin) > polygonXmin && static_cast<float>(xMax) < polygonXmax) if (static_cast<float>(xMin) > polygonXmin && static_cast<float>(xMax) < polygonXmax)
@@ -507,8 +512,6 @@ bool RivWellFracturePartMgr::stimPlanCellTouchesPolygon(const std::vector<cvf::V
} }
} }
//std::vector<cvf::Vec3f> polygon = m_rimFracture->attachedFractureDefinition()->fracturePolygon(m_rimFracture->fractureUnit);
for (cvf::Vec3f v : polygon) for (cvf::Vec3f v : polygon)
{ {
if (v.x() > xMin && v.x() < xMax) if (v.x() > xMin && v.x() < xMax)

View File

@@ -41,6 +41,7 @@ namespace caf
class RimFracture; class RimFracture;
class RimStimPlanFractureTemplate; class RimStimPlanFractureTemplate;
class RimEclipseView;
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@@ -52,7 +53,7 @@ public:
~RivWellFracturePartMgr(); ~RivWellFracturePartMgr();
void appendGeometryPartsToModel(cvf::ModelBasicList* model, void appendGeometryPartsToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform); const RimEclipseView* eclView);
void clearGeometryCache(); void clearGeometryCache();
static std::vector<double> mirrorDataAtSingleDepth(std::vector<double> depthData); static std::vector<double> mirrorDataAtSingleDepth(std::vector<double> depthData);
@@ -60,9 +61,9 @@ public:
private: private:
void generateSurfacePart(const caf::DisplayCoordTransform* displayCoordTransform); void generateSurfacePart(const caf::DisplayCoordTransform* displayCoordTransform);
void applyFractureUniformColor(); void applyFractureUniformColor(const RimEclipseView* activeView);
void applyResultTextureColor(); void applyResultTextureColor(const RimEclipseView* activeView);
void generateFractureOutlinePolygonPart(const caf::DisplayCoordTransform* displayCoordTransform); void generateFractureOutlinePolygonPart(const caf::DisplayCoordTransform* displayCoordTransform);
void generateStimPlanMeshPart(const caf::DisplayCoordTransform* displayCoordTransform); void generateStimPlanMeshPart(const caf::DisplayCoordTransform* displayCoordTransform);
@@ -71,7 +72,10 @@ private:
cvf::ref<cvf::DrawableGeo> createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, cvf::ref<cvf::DrawableGeo> createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate,
const caf::DisplayCoordTransform* displayCoordTransform); const caf::DisplayCoordTransform* displayCoordTransform);
void getPolygonBB(float &polygonXmin, float &polygonXmax, float &polygonYmin, float &polygonYmax); void getPolygonBB(float &polygonXmin,
float &polygonXmax,
float &polygonYmin,
float &polygonYmax);
std::vector<cvf::Vec3f> transfromToFractureDisplayCoords(const std::vector<cvf::Vec3f>& polygon, std::vector<cvf::Vec3f> transfromToFractureDisplayCoords(const std::vector<cvf::Vec3f>& polygon,
cvf::Mat4d m, cvf::Mat4d m,

View File

@@ -101,7 +101,7 @@ RivWellPathPartMgr::~RivWellPathPartMgr()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivWellPathPartMgr::appendFracturePartsToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform) void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const RimEclipseView* eclView)
{ {
if (!m_rimWellPath || !m_rimWellPath->fractureCollection()->isChecked()) return; if (!m_rimWellPath || !m_rimWellPath->fractureCollection()->isChecked()) return;
@@ -109,7 +109,7 @@ void RivWellPathPartMgr::appendFracturePartsToModel(cvf::ModelBasicList* model,
{ {
CVF_ASSERT(f); CVF_ASSERT(f);
f->fracturePartManager()->appendGeometryPartsToModel(model, displayCoordTransform); f->fracturePartManager()->appendGeometryPartsToModel(model, eclView);
} }
} }
@@ -384,12 +384,6 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* m
// The pipe geometry needs to be rebuilt on scale change to keep the pipes round // The pipe geometry needs to be rebuilt on scale change to keep the pipes round
buildWellPathParts(displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox); buildWellPathParts(displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox);
for (RimWellPathFracture* f : m_rimWellPath->fractureCollection()->fractures())
{
// Always recompute geometry, as the well part can be displayed in more than one view
f->fracturePartManager()->clearGeometryCache();
}
if (m_pipeBranchData.m_surfacePart.notNull()) if (m_pipeBranchData.m_surfacePart.notNull())
{ {
model->addPart(m_pipeBranchData.m_surfacePart.p()); model->addPart(m_pipeBranchData.m_surfacePart.p());
@@ -405,8 +399,6 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* m
model->addPart(m_wellLabelPart.p()); model->addPart(m_wellLabelPart.p());
} }
appendFracturePartsToModel(model, displayCoordTransform);
appendFishboneSubsPartsToModel(model, displayCoordTransform, characteristicCellSize); appendFishboneSubsPartsToModel(model, displayCoordTransform, characteristicCellSize);
appendImportedFishbonesToModel(model, displayCoordTransform, characteristicCellSize); appendImportedFishbonesToModel(model, displayCoordTransform, characteristicCellSize);
} }

View File

@@ -44,6 +44,7 @@ class RimProject;
class RimWellPath; class RimWellPath;
class RivFishbonesSubsPartMgr; class RivFishbonesSubsPartMgr;
class RimWellPathCollection; class RimWellPathCollection;
class RimEclipseView;
class QDateTime; class QDateTime;
@@ -58,6 +59,9 @@ public:
const cvf::BoundingBox& wellPathClipBoundingBox, const cvf::BoundingBox& wellPathClipBoundingBox,
const caf::DisplayCoordTransform* displayCoordTransform); const caf::DisplayCoordTransform* displayCoordTransform);
void appendStaticFracturePartsToModel(cvf::ModelBasicList* model,
const RimEclipseView* eclView);
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
const QDateTime& timeStamp, const QDateTime& timeStamp,
double characteristicCellSize, double characteristicCellSize,
@@ -80,8 +84,6 @@ private:
const caf::DisplayCoordTransform* displayCoordTransform, const caf::DisplayCoordTransform* displayCoordTransform,
double characteristicCellSize); double characteristicCellSize);
void appendFracturePartsToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform);
void buildWellPathParts(const caf::DisplayCoordTransform* displayCoordTransform, void buildWellPathParts(const caf::DisplayCoordTransform* displayCoordTransform,
double characteristicCellSize, double characteristicCellSize,

View File

@@ -447,6 +447,8 @@ void RimEclipseView::createDisplayModel()
addWellPathsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox()); addWellPathsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox());
wellPathsPartManager()->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p(), this);
m_viewer->addStaticModelOnce(m_wellPathPipeVizModel.p()); m_viewer->addStaticModelOnce(m_wellPathPipeVizModel.p());
// Create Scenes from the frameModels // Create Scenes from the frameModels
@@ -688,10 +690,11 @@ void RimEclipseView::updateCurrentTimeStep()
} }
} }
f->fracturePartManager()->appendGeometryPartsToModel(simWellFracturesModelBasicList.p(), transForm.p()); f->fracturePartManager()->appendGeometryPartsToModel(simWellFracturesModelBasicList.p(), this);
} }
simWellFracturesModelBasicList->updateBoundingBoxesRecursive(); simWellFracturesModelBasicList->updateBoundingBoxesRecursive();
frameScene->addModel(simWellFracturesModelBasicList.p());
} }
} }
} }
@@ -1506,7 +1509,7 @@ cvf::Transform* RimEclipseView::scaleTransform()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimCase* RimEclipseView::ownerCase() RimCase* RimEclipseView::ownerCase() const
{ {
return eclipseCase(); return eclipseCase();
} }

View File

@@ -116,7 +116,7 @@ public:
void setEclipseCase(RimEclipseCase* reservoir); void setEclipseCase(RimEclipseCase* reservoir);
RimEclipseCase* eclipseCase() const; RimEclipseCase* eclipseCase() const;
virtual RimCase* ownerCase(); virtual RimCase* ownerCase() const override;
RigMainGrid* mainGrid() const; RigMainGrid* mainGrid() const;

View File

@@ -507,7 +507,7 @@ void RimGeoMechView::initAfterRead()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimCase* RimGeoMechView::ownerCase() RimCase* RimGeoMechView::ownerCase() const
{ {
return m_geomechCase; return m_geomechCase;
} }

View File

@@ -61,7 +61,7 @@ public:
void setGeoMechCase(RimGeoMechCase* gmCase); void setGeoMechCase(RimGeoMechCase* gmCase);
RimGeoMechCase* geoMechCase(); RimGeoMechCase* geoMechCase();
virtual RimCase* ownerCase(); virtual RimCase* ownerCase() const override;
virtual void loadDataAndUpdate(); virtual void loadDataAndUpdate();

View File

@@ -720,9 +720,9 @@ void RimView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList,
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform(); cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
wellPathsPartManager()->appendStaticGeometryPartsToModel(wellPathModelBasicList, wellPathsPartManager()->appendStaticGeometryPartsToModel(wellPathModelBasicList,
this->ownerCase()->characteristicCellSize(), this->ownerCase()->characteristicCellSize(),
wellPathClipBoundingBox, wellPathClipBoundingBox,
transForm.p()); transForm.p());
wellPathModelBasicList->updateBoundingBoxesRecursive(); wellPathModelBasicList->updateBoundingBoxesRecursive();
} }
@@ -1026,7 +1026,7 @@ void RimView::zoomAll()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<caf::DisplayCoordTransform> RimView::displayCoordTransform() cvf::ref<caf::DisplayCoordTransform> RimView::displayCoordTransform() const
{ {
cvf::ref<caf::DisplayCoordTransform> coordTrans = new caf::DisplayCoordTransform; cvf::ref<caf::DisplayCoordTransform> coordTrans = new caf::DisplayCoordTransform;

View File

@@ -163,7 +163,7 @@ public:
virtual void zoomAll() override; virtual void zoomAll() override;
cvf::ref<caf::DisplayCoordTransform> displayCoordTransform(); cvf::ref<caf::DisplayCoordTransform> displayCoordTransform() const;
virtual QWidget* viewWidget() override; virtual QWidget* viewWidget() override;
void forceShowWindowOn(); void forceShowWindowOn();
@@ -171,7 +171,7 @@ public:
public: public:
virtual void loadDataAndUpdate() = 0; virtual void loadDataAndUpdate() = 0;
void updateGridBoxData(); void updateGridBoxData();
virtual RimCase* ownerCase() = 0; virtual RimCase* ownerCase() const = 0;
virtual caf::PdmFieldHandle* userDescriptionField() { return &name; } virtual caf::PdmFieldHandle* userDescriptionField() { return &name; }
protected: protected:

View File

@@ -49,6 +49,7 @@
#include <fstream> #include <fstream>
#include <cmath> #include <cmath>
#include "RivWellPathPartMgr.h" #include "RivWellPathPartMgr.h"
#include "RimEclipseView.h"
namespace caf namespace caf
{ {
@@ -349,6 +350,22 @@ void RimWellPathCollection::appendStaticGeometryPartsToModel(cvf::ModelBasicList
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::appendStaticFracturePartsToModel(cvf::ModelBasicList* model,
const RimEclipseView* eclView)
{
if (!this->isActive()) return;
if (this->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return;
for (size_t wIdx = 0; wIdx < this->wellPaths.size(); wIdx++)
{
RivWellPathPartMgr* partMgr = this->wellPaths[wIdx]->partMgr();
partMgr->appendStaticFracturePartsToModel(model, eclView);
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -40,6 +40,7 @@ class RifWellPathImporter;
class RimWellPath; class RimWellPath;
class RimProject; class RimProject;
class RigWellPath; class RigWellPath;
class RimEclipseView;
namespace cvf { namespace cvf {
class ModelBasicList; class ModelBasicList;
@@ -101,6 +102,9 @@ public:
const cvf::BoundingBox& wellPathClipBoundingBox, const cvf::BoundingBox& wellPathClipBoundingBox,
const caf::DisplayCoordTransform* displayCoordTransform); const caf::DisplayCoordTransform* displayCoordTransform);
void appendStaticFracturePartsToModel(cvf::ModelBasicList* model,
const RimEclipseView* eclView);
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
const QDateTime& timeStamp, const QDateTime& timeStamp,
double characteristicCellSize, double characteristicCellSize,