mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1231 Moved category handling to new class RimPropertyFilter
This commit is contained in:
@@ -84,6 +84,7 @@ ${CEE_CURRENT_LIST_DIR}RimEclipseInputCaseOpm.h
|
|||||||
${CEE_CURRENT_LIST_DIR}RimIntersectionBox.h
|
${CEE_CURRENT_LIST_DIR}RimIntersectionBox.h
|
||||||
${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.h
|
${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.h
|
||||||
${CEE_CURRENT_LIST_DIR}RimMdiWindowController.h
|
${CEE_CURRENT_LIST_DIR}RimMdiWindowController.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RimPropertyFilter.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
@@ -166,6 +167,7 @@ ${CEE_CURRENT_LIST_DIR}RimEclipseInputCaseOpm.cpp
|
|||||||
${CEE_CURRENT_LIST_DIR}RimIntersectionBox.cpp
|
${CEE_CURRENT_LIST_DIR}RimIntersectionBox.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.cpp
|
${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RimMdiWindowController.cpp
|
${CEE_CURRENT_LIST_DIR}RimMdiWindowController.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RimPropertyFilter.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
|
@@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
#include "RimCellFilter.h"
|
#include "RimCellFilter.h"
|
||||||
|
|
||||||
#include "cafAppEnum.h"
|
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
@@ -47,8 +45,6 @@ RimCellFilter::RimCellFilter()
|
|||||||
CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", "");
|
CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", "");
|
||||||
isActive.uiCapability()->setUiHidden(true);
|
isActive.uiCapability()->setUiHidden(true);
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&m_selectedCategoryValues, "SelectedValues", "Values", "", "", "");
|
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&filterMode, "FilterType", "Filter Type", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&filterMode, "FilterType", "Filter Type", "", "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,14 +63,6 @@ caf::PdmFieldHandle* RimCellFilter::userDescriptionField()
|
|||||||
return &name;
|
return &name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
std::vector<int> RimCellFilter::selectedCategoryValues() const
|
|
||||||
{
|
|
||||||
return m_selectedCategoryValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -123,67 +111,3 @@ caf::PdmFieldHandle* RimCellFilter::objectToggleField()
|
|||||||
return &isActive;
|
return &isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
QList<caf::PdmOptionItemInfo> RimCellFilter::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
|
||||||
{
|
|
||||||
QList<caf::PdmOptionItemInfo> options;
|
|
||||||
|
|
||||||
if (&m_selectedCategoryValues == fieldNeedingOptions)
|
|
||||||
{
|
|
||||||
if (useOptionsOnly) *useOptionsOnly = true;
|
|
||||||
|
|
||||||
if (m_categoryValues.size() == m_categoryNames.size())
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < m_categoryValues.size(); i++)
|
|
||||||
{
|
|
||||||
int categoryValue = m_categoryValues[i];
|
|
||||||
QString categoryName = m_categoryNames[i];
|
|
||||||
|
|
||||||
options.push_back(caf::PdmOptionItemInfo(categoryName, categoryValue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (auto it : m_categoryValues)
|
|
||||||
{
|
|
||||||
QString str = QString::number(it);
|
|
||||||
options.push_back(caf::PdmOptionItemInfo(str, it));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimCellFilter::setCategoryValues(const std::vector<int>& categoryValues)
|
|
||||||
{
|
|
||||||
m_categoryValues = categoryValues;
|
|
||||||
m_categoryNames.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimCellFilter::setCategoryNames(const std::vector<QString>& categoryNames)
|
|
||||||
{
|
|
||||||
m_categoryNames = categoryNames;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < m_categoryNames.size(); i++)
|
|
||||||
{
|
|
||||||
m_categoryValues.push_back(static_cast<int>(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimCellFilter::clearCategories()
|
|
||||||
{
|
|
||||||
m_categoryValues.clear();
|
|
||||||
m_categoryNames.clear();
|
|
||||||
}
|
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "cafPdmField.h"
|
#include "cafPdmField.h"
|
||||||
#include "cafPdmObject.h"
|
#include "cafPdmObject.h"
|
||||||
#include "cafPdmPointer.h"
|
|
||||||
#include "cafAppEnum.h"
|
#include "cafAppEnum.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -45,22 +44,9 @@ public:
|
|||||||
caf::PdmField<bool> isActive;
|
caf::PdmField<bool> isActive;
|
||||||
caf::PdmField< caf::AppEnum< FilterModeType > > filterMode;
|
caf::PdmField< caf::AppEnum< FilterModeType > > filterMode;
|
||||||
|
|
||||||
std::vector<int> selectedCategoryValues() const;
|
|
||||||
|
|
||||||
void updateIconState();
|
void updateIconState();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual caf::PdmFieldHandle* userDescriptionField();
|
virtual caf::PdmFieldHandle* userDescriptionField();
|
||||||
virtual caf::PdmFieldHandle* objectToggleField();
|
virtual caf::PdmFieldHandle* objectToggleField();
|
||||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly);
|
|
||||||
|
|
||||||
void setCategoryValues(const std::vector<int>& categoryValues);
|
|
||||||
void setCategoryNames(const std::vector<QString>& categoryNames);
|
|
||||||
void clearCategories();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::vector<int> m_categoryValues;
|
|
||||||
std::vector<QString> m_categoryNames;
|
|
||||||
|
|
||||||
caf::PdmField< std::vector<int> > m_selectedCategoryValues;
|
|
||||||
};
|
};
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "RimCellFilter.h"
|
#include "RimPropertyFilter.h"
|
||||||
|
|
||||||
#include "cafPdmChildField.h"
|
#include "cafPdmChildField.h"
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ class RigCaseCellResultsData;
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
class RimEclipsePropertyFilter : public RimCellFilter
|
class RimEclipsePropertyFilter : public RimPropertyFilter
|
||||||
{
|
{
|
||||||
CAF_PDM_HEADER_INIT;
|
CAF_PDM_HEADER_INIT;
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "RimCellFilter.h"
|
#include "RimPropertyFilter.h"
|
||||||
|
|
||||||
#include "cafPdmChildField.h"
|
#include "cafPdmChildField.h"
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ class RimGeoMechPropertyFilterCollection;
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
class RimGeoMechPropertyFilter : public RimCellFilter
|
class RimGeoMechPropertyFilter : public RimPropertyFilter
|
||||||
{
|
{
|
||||||
CAF_PDM_HEADER_INIT;
|
CAF_PDM_HEADER_INIT;
|
||||||
|
|
||||||
|
112
ApplicationCode/ProjectDataModel/RimPropertyFilter.cpp
Normal file
112
ApplicationCode/ProjectDataModel/RimPropertyFilter.cpp
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017- Statoil ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "RimPropertyFilter.h"
|
||||||
|
|
||||||
|
|
||||||
|
CAF_PDM_SOURCE_INIT(RimPropertyFilter, "PropertyFilter");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RimPropertyFilter::RimPropertyFilter()
|
||||||
|
{
|
||||||
|
CAF_PDM_InitObject("Property Filter", "", "", "");
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault(&m_selectedCategoryValues, "SelectedValues", "Values", "", "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RimPropertyFilter::~RimPropertyFilter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<int> RimPropertyFilter::selectedCategoryValues() const
|
||||||
|
{
|
||||||
|
return m_selectedCategoryValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QList<caf::PdmOptionItemInfo> RimPropertyFilter::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
||||||
|
{
|
||||||
|
QList<caf::PdmOptionItemInfo> options;
|
||||||
|
|
||||||
|
if (&m_selectedCategoryValues == fieldNeedingOptions)
|
||||||
|
{
|
||||||
|
if (useOptionsOnly) *useOptionsOnly = true;
|
||||||
|
|
||||||
|
if (m_categoryValues.size() == m_categoryNames.size())
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < m_categoryValues.size(); i++)
|
||||||
|
{
|
||||||
|
int categoryValue = m_categoryValues[i];
|
||||||
|
QString categoryName = m_categoryNames[i];
|
||||||
|
|
||||||
|
options.push_back(caf::PdmOptionItemInfo(categoryName, categoryValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto it : m_categoryValues)
|
||||||
|
{
|
||||||
|
QString str = QString::number(it);
|
||||||
|
options.push_back(caf::PdmOptionItemInfo(str, it));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimPropertyFilter::setCategoryValues(const std::vector<int>& categoryValues)
|
||||||
|
{
|
||||||
|
m_categoryValues = categoryValues;
|
||||||
|
m_categoryNames.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimPropertyFilter::setCategoryNames(const std::vector<QString>& categoryNames)
|
||||||
|
{
|
||||||
|
m_categoryNames = categoryNames;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < m_categoryNames.size(); i++)
|
||||||
|
{
|
||||||
|
m_categoryValues.push_back(static_cast<int>(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimPropertyFilter::clearCategories()
|
||||||
|
{
|
||||||
|
m_categoryValues.clear();
|
||||||
|
m_categoryNames.clear();
|
||||||
|
}
|
49
ApplicationCode/ProjectDataModel/RimPropertyFilter.h
Normal file
49
ApplicationCode/ProjectDataModel/RimPropertyFilter.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017- Statoil ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "RimCellFilter.h"
|
||||||
|
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RimPropertyFilter : public RimCellFilter
|
||||||
|
{
|
||||||
|
CAF_PDM_HEADER_INIT;
|
||||||
|
public:
|
||||||
|
RimPropertyFilter();
|
||||||
|
virtual ~RimPropertyFilter();
|
||||||
|
|
||||||
|
std::vector<int> selectedCategoryValues() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setCategoryValues(const std::vector<int>& categoryValues);
|
||||||
|
void setCategoryNames(const std::vector<QString>& categoryNames);
|
||||||
|
void clearCategories();
|
||||||
|
|
||||||
|
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
caf::PdmField< std::vector<int> > m_selectedCategoryValues;
|
||||||
|
|
||||||
|
std::vector<int> m_categoryValues;
|
||||||
|
std::vector<QString> m_categoryNames;
|
||||||
|
};
|
Reference in New Issue
Block a user