mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Find parent container instead of having a member pointer
This commit is contained in:
@@ -38,7 +38,6 @@ CAF_PDM_SOURCE_INIT(RimCellRangeFilter, "CellRangeFilter");
|
|||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RimCellRangeFilter::RimCellRangeFilter()
|
RimCellRangeFilter::RimCellRangeFilter()
|
||||||
: m_parentContainer(NULL)
|
|
||||||
{
|
{
|
||||||
CAF_PDM_InitObject("Cell Range Filter", ":/CellFilter_Range.png", "", "");
|
CAF_PDM_InitObject("Cell Range Filter", ":/CellFilter_Range.png", "", "");
|
||||||
|
|
||||||
@@ -82,25 +81,17 @@ void RimCellRangeFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedFiel
|
|||||||
{
|
{
|
||||||
computeAndSetValidValues();
|
computeAndSetValidValues();
|
||||||
|
|
||||||
CVF_ASSERT(m_parentContainer);
|
CVF_ASSERT(parentContainer());
|
||||||
m_parentContainer->fieldChangedByUi(changedField, oldValue, newValue);
|
parentContainer()->fieldChangedByUi(changedField, oldValue, newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimCellRangeFilter::setParentContainer(RimCellRangeFilterCollection* parentContainer)
|
|
||||||
{
|
|
||||||
m_parentContainer = parentContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimCellRangeFilter::computeAndSetValidValues()
|
void RimCellRangeFilter::computeAndSetValidValues()
|
||||||
{
|
{
|
||||||
CVF_ASSERT(m_parentContainer);
|
CVF_ASSERT(parentContainer());
|
||||||
|
|
||||||
const cvf::StructGridInterface* grid = selectedGrid();
|
const cvf::StructGridInterface* grid = selectedGrid();
|
||||||
if (grid && grid->cellCountI() > 0 && grid->cellCountJ() > 0 && grid->cellCountK() > 0)
|
if (grid && grid->cellCountI() > 0 && grid->cellCountJ() > 0 && grid->cellCountK() > 0)
|
||||||
@@ -122,12 +113,12 @@ void RimCellRangeFilter::computeAndSetValidValues()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimCellRangeFilter::setDefaultValues()
|
void RimCellRangeFilter::setDefaultValues()
|
||||||
{
|
{
|
||||||
CVF_ASSERT(m_parentContainer);
|
CVF_ASSERT(parentContainer());
|
||||||
|
|
||||||
const cvf::StructGridInterface* grid = selectedGrid();
|
const cvf::StructGridInterface* grid = selectedGrid();
|
||||||
|
|
||||||
RigActiveCellInfo* actCellInfo = m_parentContainer->activeCellInfo();
|
RigActiveCellInfo* actCellInfo = parentContainer()->activeCellInfo();
|
||||||
if (grid == m_parentContainer->gridByIndex(0) && actCellInfo)
|
if (grid == parentContainer()->gridByIndex(0) && actCellInfo)
|
||||||
{
|
{
|
||||||
cvf::Vec3st min, max;
|
cvf::Vec3st min, max;
|
||||||
actCellInfo->IJKBoundingBox(min, max);
|
actCellInfo->IJKBoundingBox(min, max);
|
||||||
@@ -164,7 +155,7 @@ void RimCellRangeFilter::setDefaultValues()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RimCellRangeFilterCollection* RimCellRangeFilter::parentContainer()
|
RimCellRangeFilterCollection* RimCellRangeFilter::parentContainer()
|
||||||
{
|
{
|
||||||
return m_parentContainer;
|
return dynamic_cast<RimCellRangeFilterCollection*>(this->parentField()->ownerObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -173,7 +164,7 @@ RimCellRangeFilterCollection* RimCellRangeFilter::parentContainer()
|
|||||||
void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
|
void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
|
||||||
{
|
{
|
||||||
caf::PdmUiSliderEditorAttribute* myAttr = static_cast<caf::PdmUiSliderEditorAttribute*>(attribute);
|
caf::PdmUiSliderEditorAttribute* myAttr = static_cast<caf::PdmUiSliderEditorAttribute*>(attribute);
|
||||||
if (!myAttr || !m_parentContainer)
|
if (!myAttr || !parentContainer())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -196,8 +187,8 @@ void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field,
|
|||||||
myAttr->m_maximum = static_cast<int>(grid->cellCountK());
|
myAttr->m_maximum = static_cast<int>(grid->cellCountK());
|
||||||
}
|
}
|
||||||
|
|
||||||
RigActiveCellInfo* actCellInfo = m_parentContainer->activeCellInfo();
|
RigActiveCellInfo* actCellInfo = parentContainer()->activeCellInfo();
|
||||||
if (grid == m_parentContainer->gridByIndex(0) && actCellInfo)
|
if (grid == parentContainer()->gridByIndex(0) && actCellInfo)
|
||||||
{
|
{
|
||||||
cvf::Vec3st min, max;
|
cvf::Vec3st min, max;
|
||||||
actCellInfo->IJKBoundingBox(min, max);
|
actCellInfo->IJKBoundingBox(min, max);
|
||||||
@@ -265,12 +256,12 @@ QList<caf::PdmOptionItemInfo> RimCellRangeFilter::calculateValueOptions(const ca
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
const cvf::StructGridInterface* RimCellRangeFilter::selectedGrid()
|
const cvf::StructGridInterface* RimCellRangeFilter::selectedGrid()
|
||||||
{
|
{
|
||||||
if (gridIndex() >= m_parentContainer->gridCount())
|
if (gridIndex() >= parentContainer()->gridCount())
|
||||||
{
|
{
|
||||||
gridIndex = 0;
|
gridIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cvf::StructGridInterface* grid = m_parentContainer->gridByIndex(gridIndex());
|
const cvf::StructGridInterface* grid = parentContainer()->gridByIndex(gridIndex());
|
||||||
|
|
||||||
CVF_ASSERT(grid);
|
CVF_ASSERT(grid);
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ public:
|
|||||||
RimCellRangeFilter();
|
RimCellRangeFilter();
|
||||||
virtual ~RimCellRangeFilter();
|
virtual ~RimCellRangeFilter();
|
||||||
|
|
||||||
void setParentContainer(RimCellRangeFilterCollection* parentContainer);
|
|
||||||
RimCellRangeFilterCollection* parentContainer();
|
RimCellRangeFilterCollection* parentContainer();
|
||||||
void setDefaultValues();
|
void setDefaultValues();
|
||||||
|
|
||||||
@@ -69,8 +68,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const cvf::StructGridInterface* selectedGrid();
|
const cvf::StructGridInterface* selectedGrid();
|
||||||
|
|
||||||
RimCellRangeFilterCollection* m_parentContainer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -162,10 +162,8 @@ void RimCellRangeFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* c
|
|||||||
RimCellRangeFilter* RimCellRangeFilterCollection::createAndAppendRangeFilter()
|
RimCellRangeFilter* RimCellRangeFilterCollection::createAndAppendRangeFilter()
|
||||||
{
|
{
|
||||||
RimCellRangeFilter* rangeFilter = new RimCellRangeFilter();
|
RimCellRangeFilter* rangeFilter = new RimCellRangeFilter();
|
||||||
rangeFilter->setParentContainer(this);
|
|
||||||
rangeFilter->setDefaultValues();
|
|
||||||
|
|
||||||
rangeFilters.push_back(rangeFilter);
|
rangeFilters.push_back(rangeFilter);
|
||||||
|
rangeFilter->setDefaultValues();
|
||||||
|
|
||||||
rangeFilter->name = QString("New Filter (%1)").arg(rangeFilters().size());
|
rangeFilter->name = QString("New Filter (%1)").arg(rangeFilters().size());
|
||||||
|
|
||||||
@@ -195,7 +193,6 @@ void RimCellRangeFilterCollection::initAfterRead()
|
|||||||
for (size_t i = 0; i < rangeFilters.size(); i++)
|
for (size_t i = 0; i < rangeFilters.size(); i++)
|
||||||
{
|
{
|
||||||
RimCellRangeFilter* rangeFilter = rangeFilters[i];
|
RimCellRangeFilter* rangeFilter = rangeFilters[i];
|
||||||
rangeFilter->setParentContainer(this);
|
|
||||||
rangeFilter->updateIconState();
|
rangeFilter->updateIconState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user