Skip to content

Commit

Permalink
(#540) Override range filter update system improved
Browse files Browse the repository at this point in the history
Rename of forgotten viewLink ->viewController
Remember to update group of linked views before adding a new dependent view.
  • Loading branch information
JacobStoren committed Oct 20, 2015
1 parent 4fc0553 commit 8b894d8
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ void RicSetMasterViewFeature::onActionTriggered(bool isChecked)
RimView* previousMasterView = viewLinker->masterView();

viewLinker->setMasterView(activeView);
viewLinker->updateDependentViews();

viewLinker->addDependentView(previousMasterView);

viewLinker->updateDependentViews();

proj->viewLinkerCollection.uiCapability()->updateConnectedEditors();
proj->updateConnectedEditors();
Expand Down
7 changes: 5 additions & 2 deletions ApplicationCode/ProjectDataModel/RimView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ RimView::RimView(void)
windowGeometry.uiCapability()->setUiHidden(true);

CAF_PDM_InitFieldNoDefault(&m_rangeFilterCollection, "RangeFilters", "Range Filters", "", "", "");
m_rangeFilterCollection = new RimCellRangeFilterCollection();
m_rangeFilterCollection.uiCapability()->setUiHidden(true);

CAF_PDM_InitFieldNoDefault(&m_overrideRangeFilterCollection, "RangeFiltersControlled", "Range Filters (controlled)", "", "", "");
Expand Down Expand Up @@ -566,6 +565,7 @@ RimCellRangeFilterCollection* RimView::rangeFilterCollection()
{
if (this->viewController() && this->viewController()->isRangeFiltersControlled())
{
CVF_ASSERT(m_overrideRangeFilterCollection());
return m_overrideRangeFilterCollection;
}
else
Expand All @@ -581,6 +581,7 @@ const RimCellRangeFilterCollection* RimView::rangeFilterCollection() const
{
if (this->viewController() && this->viewController()->isRangeFiltersControlled())
{
CVF_ASSERT(m_overrideRangeFilterCollection());
return m_overrideRangeFilterCollection;
}
else
Expand All @@ -594,6 +595,8 @@ const RimCellRangeFilterCollection* RimView::rangeFilterCollection() const
//--------------------------------------------------------------------------------------------------
void RimView::setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc)
{
if (m_overrideRangeFilterCollection()) delete m_overrideRangeFilterCollection();

m_overrideRangeFilterCollection = rfc;
this->scheduleGeometryRegen(RANGE_FILTERED);
this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE);
Expand Down Expand Up @@ -697,7 +700,7 @@ bool RimView::isMasterView() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCellRangeFilterCollection* RimView::rangeFilterCollectionCopy()
RimCellRangeFilterCollection* RimView::overrideRangeFilterCollection()
{
return m_overrideRangeFilterCollection();
}
Expand Down
4 changes: 2 additions & 2 deletions ApplicationCode/ProjectDataModel/RimView.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class RimView : public caf::PdmObject
RimCellRangeFilterCollection* rangeFilterCollection();
const RimCellRangeFilterCollection* rangeFilterCollection() const;

RimCellRangeFilterCollection* rangeFilterCollectionCopy();
RimCellRangeFilterCollection* overrideRangeFilterCollection();
void setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc);

caf::PdmField< std::vector<int> > windowGeometry;

Expand Down Expand Up @@ -182,7 +183,6 @@ class RimView : public caf::PdmObject

private:
RimViewLinker* viewLinkerIfMasterView() const;
void setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc);

private:
bool m_previousGridModeMeshLinesWasFaults;
Expand Down
85 changes: 23 additions & 62 deletions ApplicationCode/ProjectDataModel/RimViewController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ void RimViewController::fieldChangedByUi(const caf::PdmFieldHandle* changedField
{
if (changedField == &m_isActive)
{
updateCameraLink();
updateTimeStepLink();
updateResultColorsControl();
updateOverrides();
updateResultColorsControl();
updateCameraLink();
updateDisplayNameAndIcon();
updateTimeStepLink();
}
else if (changedField == &m_syncCamera)
{
Expand All @@ -175,7 +175,7 @@ void RimViewController::fieldChangedByUi(const caf::PdmFieldHandle* changedField
}
else if (changedField == &m_syncRangeFilters)
{
updateRangeFiltersControl();
updateOverrides();
}
else if (changedField == &m_syncPropertyFilters)
{
Expand Down Expand Up @@ -203,9 +203,9 @@ void RimViewController::fieldChangedByUi(const caf::PdmFieldHandle* changedField
//--------------------------------------------------------------------------------------------------
void RimViewController::initAfterRead()
{
updateOptionSensitivity();
updateOverrides();
updateDisplayNameAndIcon();
updateOptionSensitivity();
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -286,6 +286,8 @@ void RimViewController::updateOverrides()
}
}
}

this->updateRangeFilterOverrides(NULL);

if (manGeoView)
{
Expand Down Expand Up @@ -318,6 +320,8 @@ void RimViewController::removeOverrides(RimView* view)

if (manEclView) manEclView->setOverridePropertyFilterCollection(NULL);
if (manGeoView) manGeoView->setOverridePropertyFilterCollection(NULL);

view->setOverrideRangeFilterCollection(NULL);
}
}

Expand Down Expand Up @@ -386,12 +390,13 @@ RimView* RimViewController::managedView()
void RimViewController::setManagedView(RimView* view)
{
m_managedView = view;
updateCameraLink();
updateTimeStepLink();
updateResultColorsControl();
updateOverrides();

updateOptionSensitivity();
updateOverrides();
updateResultColorsControl();
updateCameraLink();
updateDisplayNameAndIcon();
updateTimeStepLink();
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -465,17 +470,6 @@ void RimViewController::updateResultColorsControl()
viewLinker->updateCellResult();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewController::updateRangeFiltersControl()
{
if (!this->isRangeFiltersControlled()) return;

RimViewLinker* viewLinker = ownerViewLinker();
viewLinker->updateRangeFilters(NULL);
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -758,57 +752,24 @@ bool RimViewController::isPropertyFilterOveridden()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewController::updateRangeFilterCollectionOverride(RimView* sourceView, RimCellRangeFilter* changedRangeFilter)
void RimViewController::updateRangeFilterOverrides(RimCellRangeFilter* changedRangeFilter)
{
RimCellRangeFilterCollection* filterCollectionCopy = managedView()->rangeFilterCollectionCopy();

if (!sourceView)
if (!isRangeFiltersControlled())
{
filterCollectionCopy->rangeFilters.deleteAllChildObjects();

managedView()->rangeFilterCollection()->uiCapability()->updateConnectedEditors();
managedView()->setOverrideRangeFilterCollection(NULL);

return;
}

RimCellRangeFilterCollection* sourceFilterCollection = sourceView->rangeFilterCollection();
RimCellRangeFilterCollection* sourceFilterCollection = masterView()->rangeFilterCollection();
QString xmlRangeFilterCollCopy = sourceFilterCollection->writeObjectToXmlString();

// TODO: Convert ijk values in source to correct ijk values in our range filter collection
PdmObjectHandle* objectCopy = PdmXmlObjectHandle::readUnknownObjectFromXmlString(xmlRangeFilterCollCopy, caf::PdmDefaultObjectFactory::instance());

filterCollectionCopy->rangeFilters.deleteAllChildObjects();

// Filter copy if ijk-ranges are identical
for (size_t i = 0; i < sourceFilterCollection->rangeFilters.size(); i++)
{
RimCellRangeFilter* sourceFilter = sourceFilterCollection->rangeFilters[i];

RimCellRangeFilter* filter = new RimCellRangeFilter;
filter->startIndexI = sourceFilter->startIndexI;
filter->startIndexJ = sourceFilter->startIndexJ;
filter->startIndexK = sourceFilter->startIndexK;

filter->cellCountI = sourceFilter->cellCountI;
filter->cellCountJ = sourceFilter->cellCountJ;
filter->cellCountK = sourceFilter->cellCountK;

filterCollectionCopy->rangeFilters.push_back(filter);
}
RimCellRangeFilterCollection* overrideRangeFilter = dynamic_cast<RimCellRangeFilterCollection*>(objectCopy);
managedView()->setOverrideRangeFilterCollection(overrideRangeFilter);

managedView()->rangeFilterCollection()->uiCapability()->updateConnectedEditors();
}
// TODO: Convert ijk values in source to correct ijk values in our range filter collection

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewController::updateRangeFilterOverrides(RimCellRangeFilter* changedRangeFilter)
{
if (isRangeFiltersControlled())
{
updateRangeFilterCollectionOverride(masterView(), changedRangeFilter);
}
else
{
updateRangeFilterCollectionOverride(NULL, NULL);
}
}

4 changes: 0 additions & 4 deletions ApplicationCode/ProjectDataModel/RimViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,10 @@ class RimViewController : public caf::PdmObject
void updateCameraLink();
void updateTimeStepLink();
void updateResultColorsControl();
void updateRangeFiltersControl();

bool isMasterAndDepViewDifferentType();
bool isRangeFilterControlPossible();

void updateRangeFilterCollectionOverride(RimView* sourceView, RimCellRangeFilter* changedRangeFilter);


RimEclipseView* managedEclipseView();
RimGeoMechView* managedGeoView();
static void removeOverrides(RimView* view);
Expand Down
Loading

0 comments on commit 8b894d8

Please sign in to comment.