From a8a1b616463d1881154d86f09c9041c259831299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 14 Aug 2015 15:20:50 +0200 Subject: [PATCH] (#373) Fixed update after delete. Removed the editors used to update after delete, and did all the updating from the command directly. Less code easier to follow, not as generic. --- .../Commands/RicDeleteItemExec.cpp | 43 ++++++++++++++++++- .../RimCellRangeFilterCollection.cpp | 32 -------------- .../RimEclipsePropertyFilterCollection.cpp | 30 ------------- .../RimWellPathCollection.cpp | 25 ----------- 4 files changed, 42 insertions(+), 88 deletions(-) diff --git a/ApplicationCode/Commands/RicDeleteItemExec.cpp b/ApplicationCode/Commands/RicDeleteItemExec.cpp index 601d5ec513..98c4bc8176 100644 --- a/ApplicationCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationCode/Commands/RicDeleteItemExec.cpp @@ -28,6 +28,11 @@ #include "cafNotificationCenter.h" #include "cafSelectionManager.h" #include "cafPdmDocument.h" +#include "RimCellRangeFilterCollection.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimGeoMechPropertyFilterCollection.h" +#include "RimWellPathCollection.h" +#include "RimView.h" namespace caf @@ -63,10 +68,45 @@ void RicDeleteItemExec::redo() } listField->erase(m_commandData->m_indexToObject); + delete obj; - listField->uiCapability()->updateConnectedEditors(); + caf::PdmObjectHandle* parentObj = listField->ownerObject(); + parentObj->capability()->updateConnectedEditors(); + + RimView* view = NULL; + parentObj->firstAnchestorOrThisOfType(view); + RimCellRangeFilterCollection* rangeFilterColl; + parentObj->firstAnchestorOrThisOfType(rangeFilterColl); + + if (view && rangeFilterColl) + { + view->scheduleGeometryRegen(RANGE_FILTERED); + view->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); + + view->scheduleCreateDisplayModelAndRedraw(); + } + + RimEclipsePropertyFilterCollection* eclipsePropColl; + parentObj->firstAnchestorOrThisOfType(eclipsePropColl); + + RimGeoMechPropertyFilterCollection* geoMechPropColl; + parentObj->firstAnchestorOrThisOfType(geoMechPropColl); + + if (view && (eclipsePropColl || geoMechPropColl)) + { + view->scheduleGeometryRegen(PROPERTY_FILTERED); + view->scheduleCreateDisplayModelAndRedraw(); + } + + RimWellPathCollection* wellPathColl; + parentObj->firstAnchestorOrThisOfType(wellPathColl); + + if (wellPathColl) + { + wellPathColl->scheduleGeometryRegenAndRedrawViews(); + } } } @@ -87,6 +127,7 @@ void RicDeleteItemExec::undo() PdmDocument::initAfterReadTraversal(obj); listField->uiCapability()->updateConnectedEditors(); + listField->ownerObject()->capability()->updateConnectedEditors(); if (m_notificationCenter) m_notificationCenter->notifyObservers(); } diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index c3d7c2b900..107b1aa2be 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -33,37 +33,6 @@ #include "cafPdmUiEditorHandle.h" -class ResViewRangeFiltersEditorHandle : public caf::PdmUiEditorHandle -{ -public: - ResViewRangeFiltersEditorHandle(caf::PdmFieldHandle* a) - { - this->bindToPdmItem(a->uiCapability()); - } - - //-------------------------------------------------------------------------------------------------- - /// - //-------------------------------------------------------------------------------------------------- - virtual void configureAndUpdateUi(const QString& uiConfigName) - { - caf::PdmUiFieldHandle* uiFieldHandle = dynamic_cast(this->pdmItem()); - caf::PdmObjectHandle* objHandle = uiFieldHandle->fieldHandle()->ownerObject(); - - RimView* view = NULL; - objHandle->firstAnchestorOrThisOfType(view); - CVF_ASSERT(view); - - view->scheduleGeometryRegen(RANGE_FILTERED); - view->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); - - view->scheduleCreateDisplayModelAndRedraw(); - - // This will update UI editors related to tree view (and others), as there is no tree view entity for editor for - // the property filters childarrayfield (this field is hidden) - uiObj(objHandle)->updateConnectedEditors(); - } -}; - CAF_PDM_SOURCE_INIT(RimCellRangeFilterCollection, "CellRangeFilterCollection"); @@ -80,7 +49,6 @@ RimCellRangeFilterCollection::RimCellRangeFilterCollection() CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", ""); isActive.uiCapability()->setUiHidden(true); - rangeFilters.uiCapability()->addFieldEditor(new ResViewRangeFiltersEditorHandle(&rangeFilters)); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp index ad0296f719..797fa6493b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp @@ -27,35 +27,6 @@ #include "cafPdmUiEditorHandle.h" -class ResViewPropertyFilterEditorHandle : public caf::PdmUiEditorHandle -{ -public: - ResViewPropertyFilterEditorHandle(caf::PdmFieldHandle* a) - { - this->bindToPdmItem(a->uiCapability()); - } - - //-------------------------------------------------------------------------------------------------- - /// - //-------------------------------------------------------------------------------------------------- - virtual void configureAndUpdateUi(const QString& uiConfigName) - { - caf::PdmUiFieldHandle* uiFieldHandle = dynamic_cast(this->pdmItem()); - caf::PdmObjectHandle* objHandle = uiFieldHandle->fieldHandle()->ownerObject(); - - RimEclipseView* view = NULL; - objHandle->firstAnchestorOrThisOfType(view); - CVF_ASSERT(view); - - view->scheduleGeometryRegen(PROPERTY_FILTERED); - view->scheduleCreateDisplayModelAndRedraw(); - - // This will update UI editors related to tree view (and others), as there is no tree view entity for editor for - // the property filters childarrayfield (this field is hidden) - uiObj(objHandle)->updateConnectedEditors(); - } -}; - CAF_PDM_SOURCE_INIT(RimEclipsePropertyFilterCollection, "CellPropertyFilters"); //-------------------------------------------------------------------------------------------------- @@ -71,7 +42,6 @@ RimEclipsePropertyFilterCollection::RimEclipsePropertyFilterCollection() CAF_PDM_InitField(&active, "Active", true, "Active", "", "", ""); active.uiCapability()->setUiHidden(true); - propertyFilters.uiCapability()->addFieldEditor(new ResViewPropertyFilterEditorHandle(&propertyFilters)); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index 5d030a10f6..93920297ed 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -46,30 +46,6 @@ namespace caf } } -class RimWellPathCollectionEditorHandle : public caf::PdmUiEditorHandle -{ -public: - RimWellPathCollectionEditorHandle(caf::PdmFieldHandle* a) - { - this->bindToPdmItem(a->uiCapability()); - } - - //-------------------------------------------------------------------------------------------------- - /// - //-------------------------------------------------------------------------------------------------- - virtual void configureAndUpdateUi(const QString& uiConfigName) - { - caf::PdmUiFieldHandle* uiFieldHandle = dynamic_cast(this->pdmItem()); - RimWellPathCollection* wellPathColl = dynamic_cast(uiFieldHandle->fieldHandle()->ownerObject()); - - wellPathColl->scheduleGeometryRegenAndRedrawViews(); - - // This will update UI editors related to tree view (and others), as there is no tree view entity for editor for - // the property filters childarrayfield (this field is hidden) - uiObj(wellPathColl)->updateConnectedEditors(); - } -}; - CAF_PDM_SOURCE_INIT(RimWellPathCollection, "WellPaths"); @@ -106,7 +82,6 @@ RimWellPathCollection::RimWellPathCollection() m_asciiFileReader = new RimWellPathAsciiFileReader; - wellPaths.uiCapability()->addFieldEditor(new RimWellPathCollectionEditorHandle(&wellPaths)); }