#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() )
{
cvf::Color4f fractureColor = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN));
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
if ( activeView )
{
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_rimFracture)
{
RimLegendConfig* legendConfig = nullptr;
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
if (activeView && activeView->stimPlanColors())
{
if (activeView->stimPlanColors()->isChecked())
@ -199,7 +197,7 @@ void RivWellFracturePartMgr::applyResultTextureColor()
}
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.
//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;
}
cvf::Mat4d m = m_rimFracture->transformMatrix();
std::vector<cvf::Vec3f> stimPlanMeshVerticesDisplayCoords = transfromToFractureDisplayCoords(stimPlanMeshVertices, m, displayCoordTransform);
cvf::Mat4d fractureXf = m_rimFracture->transformMatrix();
std::vector<cvf::Vec3f> stimPlanMeshVerticesDisplayCoords = transfromToFractureDisplayCoords(stimPlanMeshVertices,
fractureXf,
displayCoordTransform);
cvf::Vec3fArray* stimPlanMeshVertexList;
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();
if (!m_rimFracture->isChecked()) return;
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
auto displayCoordTransform = eclView->displayCoordTransform();
if (m_surfacePart.isNull())
{
if (m_rimFracture->fractureTemplate())
{
if (stimPlanFracTemplate)
{
generateSurfacePart(displayCoordTransform);
generateFractureOutlinePolygonPart(displayCoordTransform);
generateSurfacePart(displayCoordTransform.p());
generateFractureOutlinePolygonPart(displayCoordTransform.p());
applyResultTextureColor();
applyResultTextureColor(eclView);
if (stimPlanFracTemplate->showStimPlanMesh())
{
generateStimPlanMeshPart(displayCoordTransform);
generateStimPlanMeshPart(displayCoordTransform.p());
}
}
else // Ellipse
{
generateSurfacePart(displayCoordTransform);
applyFractureUniformColor();
generateSurfacePart(displayCoordTransform.p());
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(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)
@ -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)
{
if (v.x() > xMin && v.x() < xMax)

View File

@ -41,6 +41,7 @@ namespace caf
class RimFracture;
class RimStimPlanFractureTemplate;
class RimEclipseView;
//--------------------------------------------------------------------------------------------------
///
@ -52,7 +53,7 @@ public:
~RivWellFracturePartMgr();
void appendGeometryPartsToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform);
const RimEclipseView* eclView);
void clearGeometryCache();
static std::vector<double> mirrorDataAtSingleDepth(std::vector<double> depthData);
@ -60,9 +61,9 @@ public:
private:
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 generateStimPlanMeshPart(const caf::DisplayCoordTransform* displayCoordTransform);
@ -71,7 +72,10 @@ private:
cvf::ref<cvf::DrawableGeo> createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate,
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,
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;
@ -109,7 +109,7 @@ void RivWellPathPartMgr::appendFracturePartsToModel(cvf::ModelBasicList* model,
{
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
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())
{
model->addPart(m_pipeBranchData.m_surfacePart.p());
@ -405,8 +399,6 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* m
model->addPart(m_wellLabelPart.p());
}
appendFracturePartsToModel(model, displayCoordTransform);
appendFishboneSubsPartsToModel(model, displayCoordTransform, characteristicCellSize);
appendImportedFishbonesToModel(model, displayCoordTransform, characteristicCellSize);
}

View File

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

View File

@ -447,6 +447,8 @@ void RimEclipseView::createDisplayModel()
addWellPathsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox());
wellPathsPartManager()->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p(), this);
m_viewer->addStaticModelOnce(m_wellPathPipeVizModel.p());
// 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();
frameScene->addModel(simWellFracturesModelBasicList.p());
}
}
}
@ -1506,7 +1509,7 @@ cvf::Transform* RimEclipseView::scaleTransform()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCase* RimEclipseView::ownerCase()
RimCase* RimEclipseView::ownerCase() const
{
return eclipseCase();
}

View File

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

View File

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

View File

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

View File

@ -720,9 +720,9 @@ void RimView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList,
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
wellPathsPartManager()->appendStaticGeometryPartsToModel(wellPathModelBasicList,
this->ownerCase()->characteristicCellSize(),
wellPathClipBoundingBox,
transForm.p());
this->ownerCase()->characteristicCellSize(),
wellPathClipBoundingBox,
transForm.p());
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;

View File

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

View File

@ -49,6 +49,7 @@
#include <fstream>
#include <cmath>
#include "RivWellPathPartMgr.h"
#include "RimEclipseView.h"
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 RimProject;
class RigWellPath;
class RimEclipseView;
namespace cvf {
class ModelBasicList;
@ -101,6 +102,9 @@ public:
const cvf::BoundingBox& wellPathClipBoundingBox,
const caf::DisplayCoordTransform* displayCoordTransform);
void appendStaticFracturePartsToModel(cvf::ModelBasicList* model,
const RimEclipseView* eclView);
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
const QDateTime& timeStamp,
double characteristicCellSize,