diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 2c2037ed31..bb2ab2fd58 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -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(); diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp index 07d5e9563f..b97518ca4b 100644 --- a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp @@ -42,6 +42,20 @@ bool RicNewIntersectionViewFeature::isCommandEnabled() return !objects.empty(); } +Rim2dIntersectionView* correspondingIntersectionView(RimIntersection* intersection) +{ + std::vector objects; + + intersection->objectsWithReferringPtrFields(objects); + Rim2dIntersectionView* isectView = nullptr; + for (auto obj : objects) + { + isectView = dynamic_cast(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")); } diff --git a/ApplicationCode/Commands/RicDeleteItemExec.cpp b/ApplicationCode/Commands/RicDeleteItemExec.cpp index e3fdf1a4a6..74e304a82f 100644 --- a/ApplicationCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationCode/Commands/RicDeleteItemExec.cpp @@ -129,6 +129,7 @@ void RicDeleteItemExec::redo() parentObj->firstAncestorOrThisOfType(crossSectionColl); if (view && crossSectionColl) { + crossSectionColl->syncronize2dIntersectionViews(); view->scheduleCreateDisplayModelAndRedraw(); } diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index bb8c37206c..845ed151fb 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -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 diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp index 5eb600de7c..a2123ea6a3 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -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 Rim2dIntersectionView::calculateValueOptions(const return options; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::isWindowVisible() +{ + if (m_showWindow()) + { + Rim2dIntersectionViewCollection* viewColl = nullptr; + this->firstAncestorOrThisOfTypeAsserted(viewColl); + return viewColl->isActive(); + } + else + { + return false; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h index 6948d4e91d..4516ebaec4 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -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 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 calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; - cvf::ref m_intersectionVizModel; - cvf::ref m_scaleTransform; + caf::PdmPtrField m_intersection; + + cvf::ref m_intersectionVizModel; + cvf::ref m_scaleTransform; }; - - - diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp new file mode 100644 index 0000000000..fa91a0780e --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp @@ -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 +// 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 Rim2dIntersectionViewCollection::views() +{ + return m_intersectionViews.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpdate ) +{ + RimCase* parentCase = nullptr; + this->firstAncestorOrThisOfTypeAsserted(parentCase); + + std::vector allOrderedIntersectionsInCase; + parentCase->descendantsIncludingThisOfType(allOrderedIntersectionsInCase); + + std::set currentIntersections(allOrderedIntersectionsInCase.begin(), allOrderedIntersectionsInCase.end()); + std::set 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 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(); + } + } +} diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h new file mode 100644 index 0000000000..2bf1ca68f7 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h @@ -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 +// 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 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 m_isActive; + caf::PdmChildArrayField m_intersectionViews; +}; + + + diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index e1fb8f6a37..1d26e788c5 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -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 RimCase::views() const if (m_isInActiveDestruction) return std::vector(); std::vector allViews = this->allSpecialViews(); - for (auto view: m_intersectionViews) + std::vector 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; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index fb33a38f74..029079cd9d 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -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 calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual std::vector allSpecialViews() const = 0; @@ -83,7 +83,7 @@ private: protected: caf::PdmChildField m_timeStepFilter; - caf::PdmChildArrayField m_intersectionViews; + caf::PdmChildField m_2dIntersectionViewCollection; private: bool m_isInActiveDestruction; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 70c7da6a2a..de60daac41 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -59,6 +59,7 @@ #include "cafPdmDocument.h" #include "cafProgressInfo.h" +#include "cafPdmUiTreeOrdering.h" #include #include @@ -389,6 +390,19 @@ void RimEclipseCase::updateFormationNamesData() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +{ + std::vector children; + reservoirViews.childObjects(&children); + + for (auto child : children) uiTreeOrdering.add(child); + + uiTreeOrdering.add(&m_2dIntersectionViewCollection); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h index 423b5f91cb..a4673b1927 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -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; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index b0c7b6157f..2760eac9d4 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -41,6 +41,7 @@ #include "RimGeoMechPropertyFilter.h" #include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTreeOrdering.h" #include "cafUtils.h" #include @@ -216,6 +217,19 @@ std::vector RimGeoMechCase::allSpecialViews() const return views; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +{ + std::vector children; + geoMechViews.childObjects(&children); + + for ( auto child : children ) uiTreeOrdering.add(child); + + uiTreeOrdering.add(&m_2dIntersectionViewCollection); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index 2fc819d06b..7d55de5861 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -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 calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp index bdbc82d0e5..3a70143d66 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp @@ -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); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h index 2575250b64..afd4d58cce 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h @@ -49,12 +49,15 @@ public: caf::PdmField isActive; void appendIntersection(RimIntersection* intersection); + void appendIntersectionBox(RimIntersectionBox* intersectionBox); bool hasActiveIntersectionForSimulationWell(const RimSimWellInView* simWell) const; void updateIntersectionBoxGeometry(); + void syncronize2dIntersectionViews(); + // Visualization interface void applySingleColorEffect(); diff --git a/ApplicationCode/ProjectDataModel/RimMdiWindowController.cpp b/ApplicationCode/ProjectDataModel/RimMdiWindowController.cpp index 5064c83b1e..689dcb5ca5 100644 --- a/ApplicationCode/ProjectDataModel/RimMdiWindowController.cpp +++ b/ApplicationCode/ProjectDataModel/RimMdiWindowController.cpp @@ -140,7 +140,7 @@ void RimMdiWindowController::updateViewerWidget() RiuMainWindowBase* mainWindow = getMainWindow(); if ( !mainWindow ) return; - if ( viewPdmObject()->m_showWindow() ) + if ( viewPdmObject()->isWindowVisible() ) { if ( !viewWidget() ) { diff --git a/ApplicationCode/ProjectDataModel/RimViewWindow.cpp b/ApplicationCode/ProjectDataModel/RimViewWindow.cpp index 68e4ed20ef..b0e995cee3 100644 --- a/ApplicationCode/ProjectDataModel/RimViewWindow.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewWindow.cpp @@ -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(); } diff --git a/ApplicationCode/ProjectDataModel/RimViewWindow.h b/ApplicationCode/ProjectDataModel/RimViewWindow.h index f869994792..3583aea248 100644 --- a/ApplicationCode/ProjectDataModel/RimViewWindow.h +++ b/ApplicationCode/ProjectDataModel/RimViewWindow.h @@ -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