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
@ -34,7 +34,9 @@ RimCellRangeFilterCollection::RimCellRangeFilterCollection()
|
||||
{
|
||||
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)
|
||||
{
|
||||
// cvf::Trace::show("RimCellRangeFilterCollection::fieldChangedByUi");
|
||||
updateIconState();
|
||||
|
||||
CVF_ASSERT(m_reservoirView);
|
||||
|
||||
m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
|
||||
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
|
||||
{
|
||||
if (!active) return false;
|
||||
|
||||
std::list< caf::PdmPointer< RimCellRangeFilter > >::const_iterator it;
|
||||
for (it = rangeFilters.v().begin(); it != rangeFilters.v().end(); ++it)
|
||||
{
|
||||
@ -205,3 +211,35 @@ bool RimCellRangeFilterCollection::hasActiveFilters() const
|
||||
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,27 +35,32 @@ public:
|
||||
virtual ~RimCellRangeFilterCollection();
|
||||
|
||||
// Fields
|
||||
caf::PdmField<bool> active;
|
||||
caf::PdmField< std::list< caf::PdmPointer< RimCellRangeFilter > > > rangeFilters;
|
||||
|
||||
// Methods
|
||||
RimCellRangeFilter* createAndAppendRangeFilter();
|
||||
void remove(RimCellRangeFilter* rangeFilter);
|
||||
void remove(RimCellRangeFilter* rangeFilter);
|
||||
|
||||
void compoundCellRangeFilter(cvf::CellRangeFilter* cellRangeFilter, const RigGridBase* grid) const;
|
||||
bool hasActiveFilters() const;
|
||||
void compoundCellRangeFilter(cvf::CellRangeFilter* cellRangeFilter, const RigGridBase* grid) const;
|
||||
bool hasActiveFilters() const;
|
||||
|
||||
void setReservoirView(RimReservoirView* reservoirView);
|
||||
RimReservoirView* reservoirView();
|
||||
RigMainGrid* mainGrid() const;
|
||||
RigActiveCellInfo* activeCellInfo() const;
|
||||
|
||||
void updateIconState();
|
||||
|
||||
// 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:
|
||||
// Overridden methods
|
||||
virtual void initAfterRead();
|
||||
|
||||
|
||||
private:
|
||||
RimReservoirView* m_reservoirView;
|
||||
};
|
||||
|
@ -116,7 +116,7 @@ RimReservoirView::RimReservoirView()
|
||||
CAF_PDM_InitFieldNoDefault(&wellCollection, "WellCollection","Wells", "", "", "");
|
||||
wellCollection = new RimWellCollection;
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&rangeFilterCollection, "RangeFilters", "Range Filters", ":/CellFilter_Range.png", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&rangeFilterCollection, "RangeFilters", "Range Filters", "", "", "");
|
||||
rangeFilterCollection = new RimCellRangeFilterCollection();
|
||||
rangeFilterCollection->setReservoirView(this);
|
||||
|
||||
|
@ -1178,13 +1178,13 @@ bool RimUiTreeView::checkAndHandleToggleOfMultipleSelection()
|
||||
}
|
||||
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
myModel->setObjectToggleStateForSelection(selectedIndexes, state);
|
||||
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(curr);
|
||||
|
||||
RimWell* well = dynamic_cast<RimWell*>(uiItem->dataObject().p());
|
||||
if (well)
|
||||
{
|
||||
myModel->setObjectToggleStateForSelection(selectedIndexes, state);
|
||||
|
||||
RimReservoirView* reservoirView = NULL;
|
||||
well->firstAncestorOfType(reservoirView);
|
||||
if (reservoirView)
|
||||
@ -1192,6 +1192,18 @@ bool RimUiTreeView::checkAndHandleToggleOfMultipleSelection()
|
||||
reservoirView->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (QModelIndex index, selectedIndexes)
|
||||
{
|
||||
if (!index.isValid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
myModel->setData(index, state, Qt::CheckStateRole);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user