#2331 Add 2d Intersection View collection with automatic views. The create command is adjusted into a "Show" command.

This commit is contained in:
Jacob Støren 2018-01-23 14:23:28 +01:00
parent 9cfd2ff3cf
commit d34b3a7c74
19 changed files with 321 additions and 36 deletions

View File

@ -36,6 +36,7 @@
#include "RigEclipseCaseData.h"
#include "Rim2dIntersectionViewCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimCaseCollection.h"
#include "RimCellEdgeColors.h"
@ -584,6 +585,14 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi
{
m_project->viewLinkerCollection()->viewLinker()->updateOverrides();
}
// Intersection Views: Sync from intersections in the case.
for (RimCase* cas: casesToLoad)
{
cas->intersectionViewCollection()->syncFromExistingIntersections(false);
}
loadAndUpdatePlotData();

View File

@ -42,6 +42,20 @@ bool RicNewIntersectionViewFeature::isCommandEnabled()
return !objects.empty();
}
Rim2dIntersectionView* correspondingIntersectionView(RimIntersection* intersection)
{
std::vector<caf::PdmObjectHandle*> objects;
intersection->objectsWithReferringPtrFields(objects);
Rim2dIntersectionView* isectView = nullptr;
for (auto obj : objects)
{
isectView = dynamic_cast<Rim2dIntersectionView*>(obj);
if (isectView) break;
}
return isectView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -67,10 +81,11 @@ void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked)
QMessageBox::warning(RiuMainWindow::instance(), "New Intersection View", text);
}
Rim2dIntersectionView* intersectionView = rimCase->createAndAddIntersectionView(intersection);
Rim2dIntersectionView* intersectionView = correspondingIntersectionView(intersection);
intersectionView->setVisible(true);
intersectionView->loadDataAndUpdate();
rimCase->updateConnectedEditors();
intersectionView->updateConnectedEditors();
objectToSelect = intersectionView;
}
@ -87,7 +102,7 @@ void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked)
//--------------------------------------------------------------------------------------------------
void RicNewIntersectionViewFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("New Intersection View");
actionToSetup->setText("Show 2D Intersection View");
// actionToSetup->setIcon(QIcon(":/chain.png"));
}

View File

@ -129,6 +129,7 @@ void RicDeleteItemExec::redo()
parentObj->firstAncestorOrThisOfType(crossSectionColl);
if (view && crossSectionColl)
{
crossSectionColl->syncronize2dIntersectionViews();
view->scheduleCreateDisplayModelAndRedraw();
}

View File

@ -62,6 +62,7 @@ ${CEE_CURRENT_LIST_DIR}RimViewWindow.h
${CEE_CURRENT_LIST_DIR}Rim3dView.h
${CEE_CURRENT_LIST_DIR}RimGridView.h
${CEE_CURRENT_LIST_DIR}Rim2dIntersectionView.h
${CEE_CURRENT_LIST_DIR}Rim2dIntersectionViewCollection.h
${CEE_CURRENT_LIST_DIR}RimViewManipulator.h
${CEE_CURRENT_LIST_DIR}RimCase.h
${CEE_CURRENT_LIST_DIR}RimViewController.h
@ -165,6 +166,7 @@ ${CEE_CURRENT_LIST_DIR}RimViewWindow.cpp
${CEE_CURRENT_LIST_DIR}Rim3dView.cpp
${CEE_CURRENT_LIST_DIR}RimGridView.cpp
${CEE_CURRENT_LIST_DIR}Rim2dIntersectionView.cpp
${CEE_CURRENT_LIST_DIR}Rim2dIntersectionViewCollection.cpp
${CEE_CURRENT_LIST_DIR}RimViewManipulator.cpp
${CEE_CURRENT_LIST_DIR}RimCase.cpp
${CEE_CURRENT_LIST_DIR}RimViewController.cpp

View File

@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#include "Rim2dIntersectionView.h"
#include "Rim2dIntersectionViewCollection.h"
#include "RimIntersection.h"
#include "RimCase.h"
#include "RiuViewer.h"
@ -38,7 +39,9 @@ Rim2dIntersectionView::Rim2dIntersectionView(void)
CAF_PDM_InitObject("Intersection View", ":/CrossSection16x16.png", "", "");
CAF_PDM_InitFieldNoDefault(&m_intersection, "Intersection", "Intersection", ":/CrossSection16x16.png", "", "");
m_intersection.uiCapability()->setUiHidden(true);
m_showWindow = false;
m_scaleTransform = new cvf::Transform();
m_intersectionVizModel = new cvf::ModelBasicList;
}
@ -51,12 +54,31 @@ Rim2dIntersectionView::~Rim2dIntersectionView(void)
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::setVisible(bool isVisible)
{
m_showWindow = isVisible;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionView::setIntersection(RimIntersection* intersection)
{
m_intersection = intersection;
Rim3dView * parentView = nullptr;
intersection->firstAncestorOrThisOfTypeAsserted(parentView);
name = parentView->name() + ": " + intersection->name();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIntersection* Rim2dIntersectionView::intersection()
{
return m_intersection();
}
//--------------------------------------------------------------------------------------------------
@ -109,6 +131,23 @@ QList<caf::PdmOptionItemInfo> Rim2dIntersectionView::calculateValueOptions(const
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Rim2dIntersectionView::isWindowVisible()
{
if (m_showWindow())
{
Rim2dIntersectionViewCollection* viewColl = nullptr;
this->firstAncestorOrThisOfTypeAsserted(viewColl);
return viewColl->isActive();
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -39,8 +39,9 @@ public:
Rim2dIntersectionView(void);
virtual ~Rim2dIntersectionView(void);
void setIntersection(RimIntersection* intersection);
void setVisible(bool isVisible);
void setIntersection(RimIntersection* intersection);
RimIntersection* intersection();
virtual bool isUsingFormationNames() const override;
virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) override;
@ -50,11 +51,8 @@ public:
virtual RimViewLinker* assosiatedViewLinker() const override { return nullptr; }
virtual RimViewController* viewController() const override { return nullptr; }
protected:
caf::PdmPtrField<RimIntersection*> m_intersection;
virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) override;
virtual void createDisplayModel() override;
@ -68,16 +66,16 @@ protected:
virtual cvf::Transform* scaleTransform() override;
virtual void resetLegendsInViewer() override;
virtual void onLoadDataAndUpdate() override;
virtual bool isWindowVisible() override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
cvf::ref<cvf::ModelBasicList> m_intersectionVizModel;
cvf::ref<cvf::Transform> m_scaleTransform;
caf::PdmPtrField<RimIntersection*> m_intersection;
cvf::ref<cvf::ModelBasicList> m_intersectionVizModel;
cvf::ref<cvf::Transform> m_scaleTransform;
};

View File

@ -0,0 +1,130 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "Rim2dIntersectionViewCollection.h"
#include "Rim2dIntersectionView.h"
#include "RimCase.h"
#include "RimIntersection.h"
CAF_PDM_SOURCE_INIT(Rim2dIntersectionViewCollection, "Intersection2dViewCollection");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim2dIntersectionViewCollection::Rim2dIntersectionViewCollection()
{
CAF_PDM_InitObject("2D Intersection Views", ":/CrossSection16x16.png", "", "");
CAF_PDM_InitField(&m_isActive, "IsActive", true, "Show", "","","");
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.
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim2dIntersectionViewCollection::~Rim2dIntersectionViewCollection()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<Rim2dIntersectionView*> Rim2dIntersectionViewCollection::views()
{
return m_intersectionViews.childObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpdate )
{
RimCase* parentCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted(parentCase);
std::vector<RimIntersection*> allOrderedIntersectionsInCase;
parentCase->descendantsIncludingThisOfType(allOrderedIntersectionsInCase);
std::set<RimIntersection*> currentIntersections(allOrderedIntersectionsInCase.begin(), allOrderedIntersectionsInCase.end());
std::set<RimIntersection*> intersectionsNeedingViews = currentIntersections;
// Delete views without a valid intersection
for ( Rim2dIntersectionView* iv: m_intersectionViews )
{
if ( iv && !iv->intersection() )
{
delete iv;
}
}
// Clean up the container by removing nullptr's
m_intersectionViews.removeChildObject(nullptr);
// Build map from intersection to view
std::map<RimIntersection*, Rim2dIntersectionView*> intersectionToViewMap;
for (Rim2dIntersectionView* iv: m_intersectionViews)
{
CVF_ASSERT (iv && iv->intersection());
intersectionToViewMap[iv->intersection()] = iv;
}
m_intersectionViews.clear(); // Not deleting the views. The are managed by the map
// Insert the old views in correct order, and create new views as we go
for (RimIntersection* intersection : allOrderedIntersectionsInCase)
{
auto it = intersectionToViewMap.find(intersection);
if (it == intersectionToViewMap.end())
{
Rim2dIntersectionView* newView = new Rim2dIntersectionView();
newView->setIntersection(intersection);
m_intersectionViews.push_back(newView);
}
else
{
m_intersectionViews.push_back(it->second);
}
}
if (doUpdate) this->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue)
{
if (changedField == &m_isActive)
{
for (auto view : m_intersectionViews)
{
view->updateMdiWindowVisibility();
}
}
}

View File

@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmChildArrayField.h"
class Rim2dIntersectionView;
class Rim2dIntersectionViewCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
Rim2dIntersectionViewCollection();
virtual ~Rim2dIntersectionViewCollection();
bool isActive() { return m_isActive();}
void syncFromExistingIntersections( bool doUpdate );
std::vector<Rim2dIntersectionView*> views();
private:
virtual caf::PdmFieldHandle* objectToggleField() override { return &m_isActive; }
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
caf::PdmField<bool> m_isActive;
caf::PdmChildArrayField<Rim2dIntersectionView*> m_intersectionViews;
};

View File

@ -29,6 +29,7 @@
#include "cafPdmObjectFactory.h"
#include "Rim2dIntersectionView.h"
#include "Rim2dIntersectionViewCollection.h"
#include "RimIntersection.h"
@ -52,10 +53,10 @@ RimCase::RimCase() : m_isInActiveDestruction(false)
m_timeStepFilter.uiCapability()->setUiTreeChildrenHidden(true);
m_timeStepFilter = new RimTimeStepFilter;
CAF_PDM_InitFieldNoDefault(&m_intersectionViews, "IntersectionViews", "Intersection Views", ":/CrossSections16x16.png", "", "");
m_intersectionViews.uiCapability()->setUiTreeHidden(true);
//m_intersectionViews.push_back(new Rim2dIntersectionView());
CAF_PDM_InitFieldNoDefault(&m_2dIntersectionViewCollection, "IntersectionViewCollection", "2D Intersection Views", ":/CrossSections16x16.png", "", "");
m_2dIntersectionViewCollection.uiCapability()->setUiTreeHidden(true);
m_2dIntersectionViewCollection.xmlCapability()->setIOWritable(false); // Temporarily until something of value are present.
m_2dIntersectionViewCollection = new Rim2dIntersectionViewCollection();
}
//--------------------------------------------------------------------------------------------------
@ -74,7 +75,9 @@ std::vector<Rim3dView*> RimCase::views() const
if (m_isInActiveDestruction) return std::vector<Rim3dView*>();
std::vector<Rim3dView*> allViews = this->allSpecialViews();
for (auto view: m_intersectionViews)
std::vector<Rim2dIntersectionView*> isectViews = m_2dIntersectionViewCollection->views();
for (auto view: isectViews)
{
allViews.push_back(view);
}
@ -116,17 +119,9 @@ size_t RimCase::uiToNativeTimeStepIndex(size_t uiTimeStepIndex)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim2dIntersectionView* RimCase::createAndAddIntersectionView(RimIntersection* intersection)
Rim2dIntersectionViewCollection* RimCase::intersectionViewCollection()
{
Rim2dIntersectionView* intersectionView = new Rim2dIntersectionView;
intersectionView->setIntersection(intersection);
QString name = QString("View of Intersection %1").arg(intersection->name());
intersectionView->name = name;
m_intersectionViews.push_back(intersectionView);
return intersectionView;
return m_2dIntersectionViewCollection;
}
//--------------------------------------------------------------------------------------------------

View File

@ -35,6 +35,7 @@ class RimFormationNames;
class RimTimeStepFilter;
class Rim2dIntersectionView;
class RimIntersection;
class Rim2dIntersectionViewCollection;
namespace cvf {
class BoundingBox;
@ -72,8 +73,7 @@ public:
size_t uiToNativeTimeStepIndex(size_t uiTimeStepIndex);
Rim2dIntersectionView* createAndAddIntersectionView(RimIntersection* intersection);
Rim2dIntersectionViewCollection* intersectionViewCollection();
protected:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
virtual std::vector<Rim3dView*> allSpecialViews() const = 0;
@ -83,7 +83,7 @@ private:
protected:
caf::PdmChildField<RimTimeStepFilter*> m_timeStepFilter;
caf::PdmChildArrayField<Rim2dIntersectionView*> m_intersectionViews;
caf::PdmChildField<Rim2dIntersectionViewCollection*> m_2dIntersectionViewCollection;
private:
bool m_isInActiveDestruction;

View File

@ -59,6 +59,7 @@
#include "cafPdmDocument.h"
#include "cafProgressInfo.h"
#include "cafPdmUiTreeOrdering.h"
#include <QFile>
#include <QFileInfo>
@ -389,6 +390,19 @@ void RimEclipseCase::updateFormationNamesData()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCase::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
{
std::vector<PdmObjectHandle*> children;
reservoirViews.childObjects(&children);
for (auto child : children) uiTreeOrdering.add(child);
uiTreeOrdering.add(&m_2dIntersectionViewCollection);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -111,6 +111,7 @@ public:
protected:
virtual void initAfterRead();
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
virtual void updateFormationNamesData() override;

View File

@ -41,6 +41,7 @@
#include "RimGeoMechPropertyFilter.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafUtils.h"
#include <QFile>
@ -216,6 +217,19 @@ std::vector<Rim3dView*> RimGeoMechCase::allSpecialViews() const
return views;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechCase::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
{
std::vector<PdmObjectHandle*> children;
geoMechViews.childObjects(&children);
for ( auto child : children ) uiTreeOrdering.add(child);
uiTreeOrdering.add(&m_2dIntersectionViewCollection);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -80,6 +80,7 @@ private:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;

View File

@ -19,10 +19,12 @@
#include "RimIntersectionCollection.h"
#include "Rim2dIntersectionViewCollection.h"
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimIntersection.h"
#include "RimIntersectionBox.h"
#include "RimSimWellInView.h"
#include "Rim3dView.h"
#include "RiuMainWindow.h"
@ -153,6 +155,8 @@ void RimIntersectionCollection::appendIntersection(RimIntersection* intersection
{
m_intersections.push_back(intersection);
syncronize2dIntersectionViews();
updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem(intersection);
@ -164,6 +168,16 @@ void RimIntersectionCollection::appendIntersection(RimIntersection* intersection
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionCollection::syncronize2dIntersectionViews()
{
RimCase* ownerCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted(ownerCase);
ownerCase->intersectionViewCollection()->syncFromExistingIntersections(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -49,12 +49,15 @@ public:
caf::PdmField<bool> isActive;
void appendIntersection(RimIntersection* intersection);
void appendIntersectionBox(RimIntersectionBox* intersectionBox);
bool hasActiveIntersectionForSimulationWell(const RimSimWellInView* simWell) const;
void updateIntersectionBoxGeometry();
void syncronize2dIntersectionViews();
// Visualization interface
void applySingleColorEffect();

View File

@ -140,7 +140,7 @@ void RimMdiWindowController::updateViewerWidget()
RiuMainWindowBase* mainWindow = getMainWindow();
if ( !mainWindow ) return;
if ( viewPdmObject()->m_showWindow() )
if ( viewPdmObject()->isWindowVisible() )
{
if ( !viewWidget() )
{

View File

@ -86,7 +86,7 @@ void RimViewWindow::updateMdiWindowVisibility()
{
if (viewWidget())
{
if (m_showWindow)
if (isWindowVisible())
{
viewWidget()->show();
}
@ -149,7 +149,7 @@ void RimViewWindow::fieldChangedByUi(const caf::PdmFieldHandle* changedField, co
{
if ( changedField == &m_showWindow )
{
if (m_showWindow)
if (isWindowVisible())
{
onLoadDataAndUpdate();
}

View File

@ -49,6 +49,7 @@ public:
void loadDataAndUpdate();
void handleMdiWindowClosed();
void updateMdiWindowVisibility();
void setAs3DViewMdiWindow() { setAsMdiWindow(0); }
void setAsPlotMdiWindow() { setAsMdiWindow(1); }
@ -64,7 +65,6 @@ public:
protected:
void removeMdiWindowFromMdiArea();
void updateMdiWindowVisibility();
///////// Interface for the Window controller
friend class RimMdiWindowController;
@ -74,6 +74,7 @@ protected:
virtual void updateMdiWindowTitle(); // Has real default implementation
virtual void deleteViewWidget() = 0;
virtual void onLoadDataAndUpdate() = 0;
virtual bool isWindowVisible() { return m_showWindow();} // Virtual To allow special visibility control
//////////
// Derived classes are not supposed to override this function. The intention is to always use m_showWindow