#2333 Add flattened intersectino geometry. Some view modifications to move towards a final 2D view experience

This commit is contained in:
Jacob Støren
2018-01-25 17:37:22 +01:00
parent 47d8508196
commit 02f6b95959
17 changed files with 336 additions and 180 deletions

View File

@@ -28,6 +28,12 @@
#include "cvfModelBasicList.h"
#include "cvfTransform.h"
#include "cvfScene.h"
#include "RimEclipseView.h"
#include "RimEclipseCellColors.h"
#include "RimGeoMechView.h"
#include "RimGeoMechCellColors.h"
#include <QDateTime>
CAF_PDM_XML_ABSTRACT_SOURCE_INIT(Rim2dIntersectionView, "Intersection2dView");
@@ -44,6 +50,16 @@ Rim2dIntersectionView::Rim2dIntersectionView(void)
m_showWindow = false;
m_scaleTransform = new cvf::Transform();
m_intersectionVizModel = new cvf::ModelBasicList;
hasUserRequestedAnimation = true;
isPerspectiveView = false;
cvf::Mat4d mx( 1, 0, 0, 0,
0, 0, 1, 0,
0, -1, 0, 100,
0, 0, 0, 1);
((RiuViewerToViewInterface*)this)->setCameraPosition(mx );
disableGridBox();
}
//--------------------------------------------------------------------------------------------------
@@ -67,10 +83,14 @@ void Rim2dIntersectionView::setVisible(bool isVisible)
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::setIntersection(RimIntersection* intersection)
{
CAF_ASSERT(intersection);
m_intersection = intersection;
Rim3dView * parentView = nullptr;
intersection->firstAncestorOrThisOfTypeAsserted(parentView);
name = parentView->name() + ": " + intersection->name();
}
//--------------------------------------------------------------------------------------------------
@@ -96,6 +116,7 @@ bool Rim2dIntersectionView::isUsingFormationNames() const
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::scheduleGeometryRegen(RivCellSetEnum geometryType)
{
m_flatIntersectionPartMgr = nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -109,6 +130,21 @@ RimCase* Rim2dIntersectionView::ownerCase() const
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Rim2dIntersectionView::isTimeStepDependentDataVisible() const
{
if ( m_intersection() )
{
RimGridView * gridView = nullptr;
m_intersection->firstAncestorOrThisOfTypeAsserted(gridView);
return gridView->isTimeStepDependentDataVisible();
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -116,21 +152,47 @@ QList<caf::PdmOptionItemInfo> Rim2dIntersectionView::calculateValueOptions(const
bool* useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
if (fieldNeedingOptions == &m_intersection)
{
std::vector<RimIntersection*> intersections;
this->ownerCase()->descendantsIncludingThisOfType(intersections);
for (auto intersection : intersections)
{
options.push_back(caf::PdmOptionItemInfo(intersection->name(), intersection));
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Rim2dIntersectionView::hasResults()
{
if (!m_intersection()) return false;
RimEclipseView * eclView = nullptr;
m_intersection->firstAncestorOrThisOfType(eclView);
if (eclView)
{
return (eclView->cellResult()->hasResult() || eclView->cellResult()->isTernarySaturationSelected());
}
RimGeoMechView * geoView = nullptr;
m_intersection->firstAncestorOrThisOfType(geoView);
if (geoView)
{
return geoView->cellResult()->hasResult();
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int Rim2dIntersectionView::timeStepCount()
{
if ( isTimeStepDependentDataVisible() )
{
return static_cast<int>( this->ownerCase()->timeStepDates().size());
}
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -163,14 +225,37 @@ void Rim2dIntersectionView::createDisplayModel()
{
if (m_viewer.isNull()) return;
if (!m_intersection()) return;
updateScaleTransform();
m_viewer->removeAllFrames();
int tsCount = this->timeStepCount();
for (int i = 0; i < tsCount; ++i)
{
m_viewer->addFrame(new cvf::Scene());
}
if ( m_flatIntersectionPartMgr.isNull() || m_intersection() != m_flatIntersectionPartMgr->intersection())
{
m_flatIntersectionPartMgr = new RivIntersectionPartMgr(m_intersection(), true);
}
m_intersectionVizModel->removeAllParts();
m_intersection()->intersectionPartMgr()->appendNativeCrossSectionFacesToModel(m_intersectionVizModel.p(), scaleTransform());
m_intersection()->intersectionPartMgr()->appendMeshLinePartsToModel(m_intersectionVizModel.p(), scaleTransform());
m_flatIntersectionPartMgr->appendNativeCrossSectionFacesToModel(m_intersectionVizModel.p(), scaleTransform());
m_flatIntersectionPartMgr->appendMeshLinePartsToModel(m_intersectionVizModel.p(), scaleTransform());
m_flatIntersectionPartMgr->applySingleColorEffect();
m_viewer->addStaticModelOnce(m_intersectionVizModel.p());
if ( this->hasUserRequestedAnimation() )
{
m_viewer->setCurrentFrame(m_currentTimeStep);
}
}
//--------------------------------------------------------------------------------------------------
@@ -180,13 +265,6 @@ void Rim2dIntersectionView::createPartCollectionFromSelection(cvf::Collection<cv
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::updateDisplayModelVisibility()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -199,6 +277,14 @@ void Rim2dIntersectionView::clampCurrentTimestep()
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::updateCurrentTimeStep()
{
if ((this->hasUserRequestedAnimation() && this->hasResults()))
{
m_flatIntersectionPartMgr->updateCellResultColor(m_currentTimeStep);
}
else
{
m_flatIntersectionPartMgr->applySingleColorEffect();
}
}
//--------------------------------------------------------------------------------------------------
@@ -242,7 +328,10 @@ cvf::Transform* Rim2dIntersectionView::scaleTransform()
void Rim2dIntersectionView::resetLegendsInViewer()
{
m_viewer->showAxisCross(false);
m_viewer->showAnimationProgress(false);
m_viewer->showAnimationProgress(true);
m_viewer->showHistogram(false);
m_viewer->showInfoText(false);
m_viewer->setMainScene(new cvf::Scene());
}

View File

@@ -22,6 +22,7 @@
#include "cafPdmPtrField.h"
class RimIntersection;
class RivIntersectionPartMgr;
namespace cvf
{
@@ -51,13 +52,13 @@ public:
virtual RimViewLinker* assosiatedViewLinker() const override { return nullptr; }
virtual RimViewController* viewController() const override { return nullptr; }
protected:
virtual bool isTimeStepDependentDataVisible() const override;
protected:
virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) override;
virtual void createDisplayModel() override;
virtual void createPartCollectionFromSelection(cvf::Collection<cvf::Part>* parts) override;
virtual void updateDisplayModelVisibility() override;
virtual void clampCurrentTimestep() override;
virtual void updateCurrentTimeStep() override;
virtual void onTimeStepChanged() override;
@@ -72,8 +73,12 @@ protected:
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
bool hasResults();
int timeStepCount();
caf::PdmPtrField<RimIntersection*> m_intersection;
cvf::ref<RivIntersectionPartMgr> m_flatIntersectionPartMgr;
cvf::ref<cvf::ModelBasicList> m_intersectionVizModel;
cvf::ref<cvf::Transform> m_scaleTransform;

View File

@@ -35,7 +35,6 @@ Rim2dIntersectionViewCollection::Rim2dIntersectionViewCollection()
CAF_PDM_InitFieldNoDefault(&m_intersectionViews, "IntersectionViews", "Intersection Views", ":/CrossSection16x16.png", "", "");
m_intersectionViews.uiCapability()->setUiTreeHidden(true);
//m_intersectionViews.xmlCapability()->setIOWritable(false); // Temporarily until something of value are present.
}
//--------------------------------------------------------------------------------------------------

View File

@@ -113,7 +113,7 @@ Rim3dView::Rim3dView(void)
CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid Lines", "", "", "");
CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid Surface", "", "", "");
CAF_PDM_InitField(&showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", "");
CAF_PDM_InitField(&m_showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", "");
CAF_PDM_InitField(&m_disableLighting, "DisableLighting", false, "Disable Results Lighting", "", "Disable light model for scalar result colors", "");
@@ -234,7 +234,7 @@ void Rim3dView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrd
caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup("Viewer");
viewGroup->add(&name);
viewGroup->add(&m_backgroundColor);
viewGroup->add(&showGridBox);
viewGroup->add(&m_showGridBox);
viewGroup->add(&isPerspectiveView);
viewGroup->add(&m_disableLighting);
@@ -572,7 +572,7 @@ void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const
RiuMainWindow::instance()->refreshDrawStyleActions();
RiuMainWindow::instance()->refreshAnimationActions();
}
else if (changedField == &showGridBox)
else if (changedField == &m_showGridBox)
{
createHighlightAndGridBoxDisplayModelWithRedraw();
}
@@ -761,7 +761,48 @@ void Rim3dView::createHighlightAndGridBoxDisplayModel()
m_viewer->addStaticModelOnce(m_highlightVizModel.p());
}
m_viewer->showGridBox(showGridBox());
m_viewer->showGridBox(m_showGridBox());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::updateDisplayModelVisibility()
{
if (m_viewer.isNull()) return;
const cvf::uint uintSurfaceBit = surfaceBit;
const cvf::uint uintMeshSurfaceBit = meshSurfaceBit;
const cvf::uint uintFaultBit = faultBit;
const cvf::uint uintMeshFaultBit = meshFaultBit;
// Initialize the mask to show everything except the the bits controlled here
unsigned int mask = 0xffffffff & ~uintSurfaceBit & ~uintFaultBit & ~uintMeshSurfaceBit & ~uintMeshFaultBit ;
// Then turn the appropriate bits on according to the user settings
if (surfaceMode == SURFACE)
{
mask |= uintSurfaceBit;
mask |= uintFaultBit;
}
else if (surfaceMode == FAULTS)
{
mask |= uintFaultBit;
}
if (meshMode == FULL_MESH)
{
mask |= uintMeshSurfaceBit;
mask |= uintMeshFaultBit;
}
else if (meshMode == FAULTS_MESH)
{
mask |= uintMeshFaultBit;
}
m_viewer->setEnableMask(mask);
m_viewer->update();
}
//--------------------------------------------------------------------------------------------------
@@ -819,6 +860,14 @@ void Rim3dView::forceShowWindowOn()
m_showWindow.setValueWithFieldChanged(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::disableGridBox()
{
m_showGridBox = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -66,6 +66,17 @@ namespace caf
{
class DisplayCoordTransform;
}
enum PartRenderMaskEnum
{
surfaceBit = 0x00000001,
meshSurfaceBit = 0x00000002,
faultBit = 0x00000004,
meshFaultBit = 0x00000008,
};
//==================================================================================================
///
///
@@ -118,6 +129,7 @@ public:
int currentTimeStep() const { return m_currentTimeStep;}
void setCurrentTimeStep(int frameIdx);
void setCurrentTimeStepAndUpdate(int frameIdx) override;
virtual bool isTimeStepDependentDataVisible() const = 0;
// Updating
void updateCurrentTimeStepAndRedraw() override;
@@ -135,7 +147,8 @@ public:
virtual RimCase* ownerCase() const = 0;
protected:
void setDefaultView();
virtual void setDefaultView();
void disableGridBox();
RimWellPathCollection* wellPathCollection();
void addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList,
@@ -153,7 +166,7 @@ protected:
virtual void createDisplayModel() = 0;
virtual void createPartCollectionFromSelection(cvf::Collection<cvf::Part>* parts) = 0;
virtual void updateDisplayModelVisibility() = 0;
virtual void updateDisplayModelVisibility();
virtual void clampCurrentTimestep() = 0;
virtual void updateCurrentTimeStep() = 0;
@@ -209,6 +222,6 @@ private:
caf::PdmField<cvf::Mat4d> m_cameraPosition;
caf::PdmField<cvf::Vec3d> m_cameraPointOfInterest;
caf::PdmField< cvf::Color3f > m_backgroundColor;
caf::PdmField<bool> showGridBox;
caf::PdmField<bool> m_showGridBox;
};

View File

@@ -875,40 +875,7 @@ void RimEclipseView::updateStaticCellColors(RivCellSetEnum geometryType)
//--------------------------------------------------------------------------------------------------
void RimEclipseView::updateDisplayModelVisibility()
{
if (m_viewer.isNull()) return;
const cvf::uint uintSurfaceBit = surfaceBit;
const cvf::uint uintMeshSurfaceBit = meshSurfaceBit;
const cvf::uint uintFaultBit = faultBit;
const cvf::uint uintMeshFaultBit = meshFaultBit;
// Initialize the mask to show everything except the the bits controlled here
unsigned int mask = 0xffffffff & ~uintSurfaceBit & ~uintFaultBit & ~uintMeshSurfaceBit & ~uintMeshFaultBit ;
// Then turn the appropriate bits on according to the user settings
if (surfaceMode == SURFACE)
{
mask |= uintSurfaceBit;
mask |= uintFaultBit;
}
else if (surfaceMode == FAULTS)
{
mask |= uintFaultBit;
}
if (meshMode == FULL_MESH)
{
mask |= uintMeshSurfaceBit;
mask |= uintMeshFaultBit;
}
else if (meshMode == FAULTS_MESH)
{
mask |= uintMeshFaultBit;
}
m_viewer->setEnableMask(mask);
m_viewer->update();
Rim3dView::updateDisplayModelVisibility();
faultCollection->updateConnectedEditors();

View File

@@ -69,14 +69,6 @@ namespace cvf
class OverlayItem;
}
enum PartRenderMaskEnum
{
surfaceBit = 0x00000001,
meshSurfaceBit = 0x00000002,
faultBit = 0x00000004,
meshFaultBit = 0x00000008,
};
//==================================================================================================
///
///

View File

@@ -317,46 +317,6 @@ void RimGeoMechView::updateStaticCellColors()
m_vizLogic->updateStaticCellColors(-1);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::updateDisplayModelVisibility()
{
if (m_viewer.isNull()) return;
const cvf::uint uintSurfaceBit = surfaceBit;
const cvf::uint uintMeshSurfaceBit = meshSurfaceBit;
const cvf::uint uintFaultBit = faultBit;
const cvf::uint uintMeshFaultBit = meshFaultBit;
// Initialize the mask to show everything except the the bits controlled here
unsigned int mask = 0xffffffff & ~uintSurfaceBit & ~uintFaultBit & ~uintMeshSurfaceBit & ~uintMeshFaultBit ;
// Then turn the appropriate bits on according to the user settings
if (surfaceMode == SURFACE)
{
mask |= uintSurfaceBit;
mask |= uintFaultBit;
}
else if (surfaceMode == FAULTS)
{
mask |= uintFaultBit;
}
if (meshMode == FULL_MESH)
{
mask |= uintMeshSurfaceBit;
mask |= uintMeshFaultBit;
}
else if (meshMode == FAULTS_MESH)
{
mask |= uintMeshFaultBit;
}
m_viewer->setEnableMask(mask);
m_viewer->update();
}
//--------------------------------------------------------------------------------------------------
///
@@ -477,7 +437,7 @@ void RimGeoMechView::clampCurrentTimestep()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGeoMechView::isTimeStepDependentDataVisible()
bool RimGeoMechView::isTimeStepDependentDataVisible() const
{
return this->hasUserRequestedAnimation() && (this->cellResult()->hasResult() || this->geoMechPropertyFilterCollection()->hasActiveFilters());
}

View File

@@ -72,7 +72,7 @@ public:
const RimGeoMechPropertyFilterCollection* geoMechPropertyFilterCollection() const;
void setOverridePropertyFilterCollection(RimGeoMechPropertyFilterCollection* pfc);
bool isTimeStepDependentDataVisible();
bool isTimeStepDependentDataVisible() const override ;
virtual cvf::Transform* scaleTransform() override;
virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) override;
@@ -92,7 +92,6 @@ protected:
private:
virtual void createDisplayModel() override;
virtual void updateDisplayModelVisibility() override;
virtual void updateScaleTransform() override;
virtual void clampCurrentTimestep() override;

View File

@@ -47,6 +47,7 @@
#include "cvfBoundingBox.h"
#include "cvfGeometryTools.h"
#include "cvfPlane.h"
#include "Rim2dIntersectionView.h"
namespace caf {
@@ -723,6 +724,24 @@ void RimIntersection::appendPointToPolyLine(const cvf::Vec3d& point)
rebuildGeometryAndScheduleCreateDisplayModel();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim2dIntersectionView* RimIntersection::correspondingIntersectionView()
{
std::vector<caf::PdmObjectHandle*> objects;
this->objectsWithReferringPtrFields(objects);
Rim2dIntersectionView* isectView = nullptr;
for (auto obj : objects)
{
isectView = dynamic_cast<Rim2dIntersectionView*>(obj);
if (isectView) break;
}
return isectView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -851,6 +870,13 @@ void RimIntersection::rebuildGeometryAndScheduleCreateDisplayModel()
{
rimView->scheduleCreateDisplayModelAndRedraw();
}
Rim2dIntersectionView * iview = correspondingIntersectionView();
if (iview)
{
iview->scheduleGeometryRegen(RivCellSetEnum::ALL_CELLS);
iview->scheduleCreateDisplayModelAndRedraw();
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -33,6 +33,7 @@ class RimWellPath;
class RivIntersectionPartMgr;
class RimSimWellInView;
class RimSimWellInViewCollection;
class Rim2dIntersectionView;
namespace caf
{
@@ -86,6 +87,7 @@ public:
std::vector< std::vector <cvf::Vec3d> > polyLines() const;
void appendPointToPolyLine(const cvf::Vec3d& point);
Rim2dIntersectionView* correspondingIntersectionView();
RivIntersectionPartMgr* intersectionPartMgr();
std::vector< std::vector <cvf::Vec3d> > polyLinesForExtrusionDirection() const;