mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added toggle option for range filter collection
p4#: 21428
This commit is contained in:
parent
f730707448
commit
7b2ec05383
@ -35,6 +35,8 @@ RimCellRangeFilterCollection::RimCellRangeFilterCollection()
|
|||||||
CAF_PDM_InitObject("Cell Range Filters", ":/CellFilter_Range.png", "", "");
|
CAF_PDM_InitObject("Cell Range Filters", ":/CellFilter_Range.png", "", "");
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&rangeFilters, "RangeFilters", "Range Filters", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&rangeFilters, "RangeFilters", "Range Filters", "", "", "");
|
||||||
|
CAF_PDM_InitField(&active, "Active", true, "Active", "", "", "");
|
||||||
|
active.setUiHidden(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -135,12 +137,14 @@ RigActiveCellInfo* RimCellRangeFilterCollection::activeCellInfo() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimCellRangeFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
void RimCellRangeFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||||
{
|
{
|
||||||
// cvf::Trace::show("RimCellRangeFilterCollection::fieldChangedByUi");
|
updateIconState();
|
||||||
|
|
||||||
|
CVF_ASSERT(m_reservoirView);
|
||||||
|
|
||||||
m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
|
m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
|
||||||
m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
|
m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
|
||||||
|
|
||||||
if (m_reservoirView) m_reservoirView->createDisplayModelAndRedraw();
|
m_reservoirView->createDisplayModelAndRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -196,6 +200,8 @@ void RimCellRangeFilterCollection::remove(RimCellRangeFilter* rangeFilter)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RimCellRangeFilterCollection::hasActiveFilters() const
|
bool RimCellRangeFilterCollection::hasActiveFilters() const
|
||||||
{
|
{
|
||||||
|
if (!active) return false;
|
||||||
|
|
||||||
std::list< caf::PdmPointer< RimCellRangeFilter > >::const_iterator it;
|
std::list< caf::PdmPointer< RimCellRangeFilter > >::const_iterator it;
|
||||||
for (it = rangeFilters.v().begin(); it != rangeFilters.v().end(); ++it)
|
for (it = rangeFilters.v().begin(); it != rangeFilters.v().end(); ++it)
|
||||||
{
|
{
|
||||||
@ -205,3 +211,35 @@ bool RimCellRangeFilterCollection::hasActiveFilters() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
caf::PdmFieldHandle* RimCellRangeFilterCollection::objectToggleField()
|
||||||
|
{
|
||||||
|
return &active;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimCellRangeFilterCollection::updateIconState()
|
||||||
|
{
|
||||||
|
// Reset dynamic icon
|
||||||
|
this->setUiIcon(QIcon());
|
||||||
|
// Get static one
|
||||||
|
QIcon icon = this->uiIcon();
|
||||||
|
|
||||||
|
// Get a pixmap, and modify it
|
||||||
|
|
||||||
|
QPixmap icPixmap;
|
||||||
|
icPixmap = icon.pixmap(16, 16, QIcon::Normal);
|
||||||
|
|
||||||
|
if (!active)
|
||||||
|
{
|
||||||
|
QIcon temp(icPixmap);
|
||||||
|
icPixmap = temp.pixmap(16, 16, QIcon::Disabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon newIcon(icPixmap);
|
||||||
|
this->setUiIcon(newIcon);
|
||||||
|
}
|
||||||
|
@ -35,6 +35,7 @@ public:
|
|||||||
virtual ~RimCellRangeFilterCollection();
|
virtual ~RimCellRangeFilterCollection();
|
||||||
|
|
||||||
// Fields
|
// Fields
|
||||||
|
caf::PdmField<bool> active;
|
||||||
caf::PdmField< std::list< caf::PdmPointer< RimCellRangeFilter > > > rangeFilters;
|
caf::PdmField< std::list< caf::PdmPointer< RimCellRangeFilter > > > rangeFilters;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
@ -49,13 +50,17 @@ public:
|
|||||||
RigMainGrid* mainGrid() const;
|
RigMainGrid* mainGrid() const;
|
||||||
RigActiveCellInfo* activeCellInfo() const;
|
RigActiveCellInfo* activeCellInfo() const;
|
||||||
|
|
||||||
|
void updateIconState();
|
||||||
|
|
||||||
// Overridden methods
|
// Overridden methods
|
||||||
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
|
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
|
||||||
|
virtual caf::PdmFieldHandle* objectToggleField();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overridden methods
|
// Overridden methods
|
||||||
virtual void initAfterRead();
|
virtual void initAfterRead();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RimReservoirView* m_reservoirView;
|
RimReservoirView* m_reservoirView;
|
||||||
};
|
};
|
||||||
|
@ -116,7 +116,7 @@ RimReservoirView::RimReservoirView()
|
|||||||
CAF_PDM_InitFieldNoDefault(&wellCollection, "WellCollection","Wells", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&wellCollection, "WellCollection","Wells", "", "", "");
|
||||||
wellCollection = new RimWellCollection;
|
wellCollection = new RimWellCollection;
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&rangeFilterCollection, "RangeFilters", "Range Filters", ":/CellFilter_Range.png", "", "");
|
CAF_PDM_InitFieldNoDefault(&rangeFilterCollection, "RangeFilters", "Range Filters", "", "", "");
|
||||||
rangeFilterCollection = new RimCellRangeFilterCollection();
|
rangeFilterCollection = new RimCellRangeFilterCollection();
|
||||||
rangeFilterCollection->setReservoirView(this);
|
rangeFilterCollection->setReservoirView(this);
|
||||||
|
|
||||||
|
@ -1178,13 +1178,13 @@ bool RimUiTreeView::checkAndHandleToggleOfMultipleSelection()
|
|||||||
}
|
}
|
||||||
|
|
||||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||||
myModel->setObjectToggleStateForSelection(selectedIndexes, state);
|
|
||||||
|
|
||||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(curr);
|
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(curr);
|
||||||
|
|
||||||
RimWell* well = dynamic_cast<RimWell*>(uiItem->dataObject().p());
|
RimWell* well = dynamic_cast<RimWell*>(uiItem->dataObject().p());
|
||||||
if (well)
|
if (well)
|
||||||
{
|
{
|
||||||
|
myModel->setObjectToggleStateForSelection(selectedIndexes, state);
|
||||||
|
|
||||||
RimReservoirView* reservoirView = NULL;
|
RimReservoirView* reservoirView = NULL;
|
||||||
well->firstAncestorOfType(reservoirView);
|
well->firstAncestorOfType(reservoirView);
|
||||||
if (reservoirView)
|
if (reservoirView)
|
||||||
@ -1192,6 +1192,18 @@ bool RimUiTreeView::checkAndHandleToggleOfMultipleSelection()
|
|||||||
reservoirView->createDisplayModelAndRedraw();
|
reservoirView->createDisplayModelAndRedraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (QModelIndex index, selectedIndexes)
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
myModel->setData(index, state, Qt::CheckStateRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user