From 619142210395098ada4afc39ec35f65a6e84c34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Hagen?= Date: Fri, 19 Jun 2015 14:09:45 +0200 Subject: [PATCH] Property filters for geo mech (#314) Added GUI objects for property filters for geo mech models. --- .../ProjectDataModel/CMakeLists_files.cmake | 6 + .../RimGeoMechPropertyFilter.cpp | 189 ++++++++++ .../RimGeoMechPropertyFilter.h | 75 ++++ .../RimGeoMechPropertyFilterCollection.cpp | 178 ++++++++++ .../RimGeoMechPropertyFilterCollection.h | 69 ++++ .../RimGeoMechResultDefinition.cpp | 335 ++++++++++++++++++ .../RimGeoMechResultDefinition.h | 91 +++++ .../ProjectDataModel/RimGeoMechResultSlot.cpp | 255 +------------ .../ProjectDataModel/RimGeoMechResultSlot.h | 54 +-- .../ProjectDataModel/RimGeoMechView.cpp | 5 + .../ProjectDataModel/RimGeoMechView.h | 3 +- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 49 +++ .../ProjectDataModel/RimUiTreeModelPdm.h | 2 + .../ProjectDataModel/RimUiTreeView.cpp | 44 +++ .../ProjectDataModel/RimUiTreeView.h | 2 + 15 files changed, 1052 insertions(+), 305 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.h create mode 100644 ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h create mode 100644 ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index c73e5b11c4..753d7c3e9e 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -54,6 +54,9 @@ ${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNncCollection.h ${CEE_CURRENT_LIST_DIR}RimGeoMechModels.h ${CEE_CURRENT_LIST_DIR}RimGeoMechCase.h ${CEE_CURRENT_LIST_DIR}RimGeoMechView.h +${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilter.h +${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilterCollection.h +${CEE_CURRENT_LIST_DIR}RimGeoMechResultDefinition.h ${CEE_CURRENT_LIST_DIR}RimGeoMechResultSlot.h ${CEE_CURRENT_LIST_DIR}RimView.h ${CEE_CURRENT_LIST_DIR}RimCase.h @@ -109,6 +112,9 @@ ${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNncCollection.cpp ${CEE_CURRENT_LIST_DIR}RimGeoMechModels.cpp ${CEE_CURRENT_LIST_DIR}RimGeoMechCase.cpp ${CEE_CURRENT_LIST_DIR}RimGeoMechView.cpp +${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilter.cpp +${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilterCollection.cpp +${CEE_CURRENT_LIST_DIR}RimGeoMechResultDefinition.cpp ${CEE_CURRENT_LIST_DIR}RimGeoMechResultSlot.cpp ${CEE_CURRENT_LIST_DIR}RimView.cpp ${CEE_CURRENT_LIST_DIR}RimCase.cpp diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp new file mode 100644 index 0000000000..1139007e14 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp @@ -0,0 +1,189 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimGeoMechPropertyFilter.h" +#include "RimGeoMechPropertyFilterCollection.h" +#include "RimGeoMechResultDefinition.h" + +#include "cvfMath.h" + +#include "cafPdmUiDoubleSliderEditor.h" +#include "cvfAssert.h" +#include "RigFemPartResultsCollection.h" +#include "RigGeoMechCaseData.h" +#include "RimGeoMechView.h" + +/* +#include "RigCaseCellResultsData.h" +#include "RimCellPropertyFilterCollection.h" +#include "RimReservoirCellResultsStorage.h" +#include "RimResultDefinition.h" + +#include "cafPdmUiDoubleSliderEditor.h" +#include "cvfAssert.h" +*/ + + +CAF_PDM_SOURCE_INIT(RimGeoMechPropertyFilter, "GeoMechPropertyFilter"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilter::RimGeoMechPropertyFilter() + : m_parentContainer(NULL) +{ + CAF_PDM_InitObject("GeoMech Property Filter", ":/CellFilter_Values.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&resultDefinition, "ResultDefinition", "Result definition", "", "", ""); + resultDefinition = new RimGeoMechResultDefinition(); + resultDefinition->setOwnerPropertyFilter(this); + + // Set to hidden to avoid this item to been displayed as a child item + // Fields in this object are displayed using defineUiOrdering() + resultDefinition.setUiHidden(true); + + CAF_PDM_InitField(&lowerBound, "LowerBound", 0.0, "Min", "", "", ""); + lowerBound.setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + + CAF_PDM_InitField(&upperBound, "UpperBound", 0.0, "Max", "", "", ""); + upperBound.setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + + updateIconState(); + + m_minimumResultValue = cvf::UNDEFINED_DOUBLE; + m_maximumResultValue = cvf::UNDEFINED_DOUBLE; + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilter::~RimGeoMechPropertyFilter() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if ( &lowerBound == changedField + || &upperBound == changedField + || &isActive == changedField + || &filterMode == changedField) + { + this->updateIconState(); + ((RimView*)resultDefinition->reservoirView())->scheduleGeometryRegen(PROPERTY_FILTERED); + resultDefinition->reservoirView()->scheduleCreateDisplayModelAndRedraw(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::setParentContainer(RimGeoMechPropertyFilterCollection* parentContainer) +{ + m_parentContainer = parentContainer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilterCollection* RimGeoMechPropertyFilter::parentContainer() +{ + return m_parentContainer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::updateDefaultValues() +{ + CVF_ASSERT(m_parentContainer); + + computeResultValueRange(); + + lowerBound = m_minimumResultValue; + upperBound = m_maximumResultValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + uiOrdering.add(&name); + + caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Result"); + group1->add(&(resultDefinition->m_resultPositionTypeUiField)); + group1->add(&(resultDefinition->m_resultVariableUiField)); + + uiOrdering.add(&isActive); + uiOrdering.add(&filterMode); + + uiOrdering.add(&lowerBound); + uiOrdering.add(&upperBound); + uiOrdering.add(&filterMode); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + if (m_minimumResultValue == cvf::UNDEFINED_DOUBLE || m_maximumResultValue == cvf::UNDEFINED_DOUBLE) + { + return; + } + + if (field == &lowerBound || field == &upperBound) + { + caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast(attribute); + if (!myAttr) + { + return; + } + + myAttr->m_minimum = m_minimumResultValue; + myAttr->m_maximum = m_maximumResultValue; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilter::computeResultValueRange() +{ + CVF_ASSERT(m_parentContainer); + + double min = 0.0; + double max = 0.0; + + RigFemResultAddress resultAddress = resultDefinition->resultAddress(); + if (resultAddress.isValid() && resultDefinition->ownerCaseData()) + { + resultDefinition->ownerCaseData()->femPartResults()->minMaxScalarValues(resultAddress, &min, &max); + } + + m_maximumResultValue = max; + m_minimumResultValue = min; + + lowerBound.setUiName(QString("Min (%1)").arg(min)); + upperBound.setUiName(QString("Max (%1)").arg(max)); +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.h b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.h new file mode 100644 index 0000000000..ba0bc2df42 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.h @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RimCellFilter.h" + +/*class RimEclipseView; +class RimCellPropertyFilterCollection; +class RimResultDefinition; + +class RigGridBase; +class RigCaseCellResultsData; +*/ + +class RimGeoMechResultDefinition; +class RimGeoMechPropertyFilterCollection; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGeoMechPropertyFilter : public RimCellFilter +{ + CAF_PDM_HEADER_INIT; + + enum EvaluationRegionType + { + RANGE_FILTER_REGION, + GLOBAL_REGION + }; + +public: + RimGeoMechPropertyFilter(); + virtual ~RimGeoMechPropertyFilter(); + + void setParentContainer(RimGeoMechPropertyFilterCollection* parentContainer); + RimGeoMechPropertyFilterCollection* parentContainer(); + void updateDefaultValues(); + void computeResultValueRange(); + + caf::PdmField resultDefinition; + + caf::PdmField lowerBound; + caf::PdmField upperBound; + + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + + +protected: + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) ; + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); + +private: + RimGeoMechPropertyFilterCollection* m_parentContainer; + double m_minimumResultValue, m_maximumResultValue; +}; + diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp new file mode 100644 index 0000000000..6ac229c41f --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp @@ -0,0 +1,178 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimGeoMechPropertyFilterCollection.h" +#include "RimGeoMechPropertyFilter.h" +#include "RimGeoMechView.h" +#include "RimGeoMechResultSlot.h" + +#include "cvfAssert.h" + + +CAF_PDM_SOURCE_INIT(RimGeoMechPropertyFilterCollection, "GeoMechPropertyFilters"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilterCollection::RimGeoMechPropertyFilterCollection() +{ + CAF_PDM_InitObject("GeoMech Property Filters", ":/CellFilter_Values.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&propertyFilters, "PropertyFilters", "Property Filters", "", "", ""); + CAF_PDM_InitField(&active, "Active", true, "Active", "", "", ""); + active.setUiHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilterCollection::~RimGeoMechPropertyFilterCollection() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilterCollection::setReservoirView(RimGeoMechView* reservoirView) +{ + m_reservoirView = reservoirView; + + for (size_t i = 0; i < propertyFilters.size(); i++) + { + RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i]; + propertyFilter->resultDefinition->setReservoirView(m_reservoirView.p()); + + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechView* RimGeoMechPropertyFilterCollection::reservoirView() +{ + CVF_ASSERT(!m_reservoirView.isNull()); + return m_reservoirView; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + this->updateUiIconFromToggleField(); + + ((RimView*)m_reservoirView)->scheduleGeometryRegen(PROPERTY_FILTERED); + m_reservoirView->scheduleCreateDisplayModelAndRedraw(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilter* RimGeoMechPropertyFilterCollection::createAndAppendPropertyFilter() +{ + RimGeoMechPropertyFilter* propertyFilter = new RimGeoMechPropertyFilter(); + + propertyFilter->resultDefinition->setReservoirView(m_reservoirView.p()); + + propertyFilter->setParentContainer(this); + propertyFilters.push_back(propertyFilter); + + propertyFilter->resultDefinition->setResultAddress(m_reservoirView->cellResult()->resultAddress()); + propertyFilter->resultDefinition->loadResult(); + propertyFilter->updateDefaultValues(); + + propertyFilter->name = QString("New Filter (%1)").arg(propertyFilters().size()); + + return propertyFilter; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilterCollection::loadAndInitializePropertyFilters() +{ + for (size_t i = 0; i < propertyFilters.size(); i++) + { + RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i]; + + propertyFilter->resultDefinition->loadResult(); + propertyFilter->computeResultValueRange(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilterCollection::initAfterRead() +{ + for (size_t i = 0; i < propertyFilters.size(); i++) + { + RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i]; + + propertyFilter->setParentContainer(this); + propertyFilter->resultDefinition->setReservoirView(m_reservoirView.p()); + propertyFilter->updateIconState(); + } + + this->updateUiIconFromToggleField(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechPropertyFilterCollection::remove(RimGeoMechPropertyFilter* propertyFilter) +{ + propertyFilters.removeChildObject(propertyFilter); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGeoMechPropertyFilterCollection::hasActiveFilters() const +{ + if (!active) return false; + + for (size_t i = 0; i < propertyFilters.size(); i++) + { + RimGeoMechPropertyFilter* propertyFilter = propertyFilters[i]; + if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult()) return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// Returns whether any of the active property filters are based on a dynamic result +//-------------------------------------------------------------------------------------------------- +bool RimGeoMechPropertyFilterCollection::hasActiveDynamicFilters() const +{ + return hasActiveFilters(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimGeoMechPropertyFilterCollection::objectToggleField() +{ + return &active; +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h new file mode 100644 index 0000000000..521dee9570 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmObject.h" +#include "cafPdmField.h" +#include "cafPdmPointer.h" + +class RimGeoMechPropertyFilter; +class RimGeoMechView; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGeoMechPropertyFilterCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimGeoMechPropertyFilterCollection(); + virtual ~RimGeoMechPropertyFilterCollection(); + + void setReservoirView(RimGeoMechView* reservoirView); + RimGeoMechView* reservoirView(); + + + // Fields: + caf::PdmField active; + caf::PdmPointersField propertyFilters; + + // Methods + RimGeoMechPropertyFilter* createAndAppendPropertyFilter(); + void remove(RimGeoMechPropertyFilter* propertyFilter); + + bool hasActiveFilters() const; + bool hasActiveDynamicFilters() const; + + + void loadAndInitializePropertyFilters(); + + + // Overridden methods + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + virtual caf::PdmFieldHandle* objectToggleField(); + +protected: + // Overridden methods + virtual void initAfterRead(); + +private: + caf::PdmPointer m_reservoirView; +}; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp new file mode 100644 index 0000000000..c4c982295f --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -0,0 +1,335 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimGeoMechResultDefinition.h" +#include "RimGeoMechView.h" +#include "RimDefines.h" +#include "RimGeoMechCase.h" +#include "RifGeoMechReaderInterface.h" +#include "cafPdmUiListEditor.h" +#include "RigGeoMechCaseData.h" +#include "RigFemPartResultsCollection.h" +#include "RiuMainWindow.h" +#include "RimGeoMechPropertyFilter.h" +#include "RigFemResultAddress.h" + +namespace caf { + +template<> +void caf::AppEnum< RigFemResultPosEnum >::setUp() +{ + addItem(RIG_NODAL, "NODAL", "Nodal"); + addItem(RIG_ELEMENT_NODAL, "ELEMENT_NODAL", "Element Nodal"); + addItem(RIG_INTEGRATION_POINT,"INTEGRATION_POINT","Integration Point"); + setDefault(RIG_NODAL); +} +} + + +CAF_PDM_SOURCE_INIT(RimGeoMechResultDefinition, "GeoMechResultDefinition"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) +{ + CAF_PDM_InitObject("Color Result", ":/CellResult.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType" , "Result Position", "", "", ""); + m_resultPositionType.setUiHidden(true); + CAF_PDM_InitField(&m_resultFieldName, "ResultFieldName", QString(""), "Field Name", "", "", ""); + m_resultFieldName.setUiHidden(true); + CAF_PDM_InitField(&m_resultComponentName, "ResultComponentName", QString(""), "Component", "", "", ""); + m_resultComponentName.setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position", "", "", ""); + m_resultPositionTypeUiField.setIOWritable(false); + m_resultPositionTypeUiField.setIOReadable(false); + + CAF_PDM_InitField(&m_resultVariableUiField, "ResultVariableUI", QString(""), "Value", "", "", ""); + m_resultVariableUiField.setIOWritable(false); + m_resultVariableUiField.setIOReadable(false); + + m_resultVariableUiField.setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); + m_resultVariableUiField.setUiLabelPosition(caf::PdmUiItemInfo::TOP); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechResultDefinition::~RimGeoMechResultDefinition(void) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimGeoMechResultDefinition::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +{ + QList options; + *useOptionsOnly = true; + + if (m_reservoirView) + { + + + + if (&m_resultVariableUiField == fieldNeedingOptions) + { + std::map > fieldCompNames = getResultMetaDataForUIFieldSetting(); + QStringList uiVarNames; + QStringList varNames; + getUiAndResultVariableStringList(&uiVarNames, &varNames, fieldCompNames); + + for (int oIdx = 0; oIdx < uiVarNames.size(); ++oIdx) + { + options.push_back(caf::PdmOptionItemInfo(uiVarNames[oIdx], varNames[oIdx])); + } + +#if 0 + + for (auto fieldIt = fieldCompNames.begin(); fieldIt != fieldCompNames.end(); ++fieldIt) + { + options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(fieldIt->first), QString::fromStdString(fieldIt->first))); + + for (auto compIt = fieldIt->second.begin(); compIt != fieldIt->second.end(); ++compIt) + { + options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(" " + *compIt), QString::fromStdString(fieldIt->first + " " + *compIt))); + } + } +#endif + } + } + + return options; +} + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechResultDefinition::setReservoirView(RimGeoMechView* ownerReservoirView) +{ + m_reservoirView = ownerReservoirView; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechView* RimGeoMechResultDefinition::reservoirView() +{ + return m_reservoirView; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if(&m_resultPositionTypeUiField == changedField) + { + std::map > fieldCompNames = getResultMetaDataForUIFieldSetting(); + QStringList uiVarNames; + QStringList varNames; + getUiAndResultVariableStringList(&uiVarNames, &varNames, fieldCompNames); + + if (m_resultPositionTypeUiField() == m_resultPositionType() + && varNames.contains(composeUiVarString(m_resultFieldName(), m_resultComponentName()))) + { + m_resultVariableUiField = composeUiVarString(m_resultFieldName(), m_resultComponentName()); + } + else + { + m_resultVariableUiField = ""; + } + + } + + if (&m_resultVariableUiField == changedField) + { + QStringList fieldComponentNames = m_resultVariableUiField().split(QRegExp("\\s+")); + if (fieldComponentNames.size() > 0) + { + m_resultPositionType = m_resultPositionTypeUiField; + m_resultFieldName = fieldComponentNames[0]; + if (fieldComponentNames.size() > 1) + { + m_resultComponentName = fieldComponentNames[1]; + } + else + { + m_resultComponentName = ""; + } + + if (m_reservoirView->geoMechCase()->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress())) + { + m_reservoirView->hasUserRequestedAnimation = true; + } + + if (m_propertyFilter) + { + m_propertyFilter->updateDefaultValues(); + } + + m_reservoirView->createDisplayModelAndRedraw(); + } + } + + if (m_propertyFilter) + { + m_propertyFilter->updateConnectedEditors(); + } + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map > RimGeoMechResultDefinition::getResultMetaDataForUIFieldSetting() +{ + RimGeoMechCase* gmCase = m_reservoirView->geoMechCase(); + if (gmCase && gmCase->geoMechData()) + { + return gmCase->geoMechData()->femPartResults()->scalarFieldAndComponentNames(m_resultPositionTypeUiField()); + } + else + { + return std::map >() ; + } +} + +void RimGeoMechResultDefinition::getUiAndResultVariableStringList(QStringList* uiNames, QStringList* variableNames, + const std::map >& fieldCompNames) +{ + CVF_ASSERT(uiNames && variableNames); + + std::map >::const_iterator fieldIt; + for (fieldIt = fieldCompNames.begin(); fieldIt != fieldCompNames.end(); ++fieldIt) + { + QString resultFieldName = QString::fromStdString(fieldIt->first); + + if (resultFieldName == "E" || resultFieldName == "S") continue; // We will not show the native Stress and Strain + + QString resultFieldUiName = convertToUiResultFieldName(resultFieldName); + + uiNames->push_back(resultFieldUiName); + variableNames->push_back(resultFieldName); + + std::vector::const_iterator compIt; + for (compIt = fieldIt->second.begin(); compIt != fieldIt->second.end(); ++compIt) + { + QString resultCompName = QString::fromStdString(*compIt); + uiNames->push_back(" " + resultCompName); + variableNames->push_back(composeUiVarString(resultFieldName, resultCompName)); + } + } +} + + +QString RimGeoMechResultDefinition::composeUiVarString(const QString& resultFieldName, const QString& resultComponentName) +{ + return resultFieldName + " " + resultComponentName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechResultDefinition::initAfterRead() +{ + m_resultPositionTypeUiField = m_resultPositionType; + m_resultVariableUiField = composeUiVarString(m_resultFieldName(), m_resultComponentName()); + +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechResultDefinition::loadResult() +{ + if (m_reservoirView->geoMechCase()) + { + m_reservoirView->geoMechCase()->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigGeoMechCaseData* RimGeoMechResultDefinition::ownerCaseData() +{ + return m_reservoirView->geoMechCase()->geoMechData(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGeoMechResultDefinition::hasResult() +{ + return ownerCaseData()->femPartResults()->assertResultsLoaded(this->resultAddress()); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGeoMechResultDefinition::resultFieldUiName() +{ + return convertToUiResultFieldName(m_resultFieldName()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGeoMechResultDefinition::resultComponentUiName() +{ + return m_resultComponentName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGeoMechResultDefinition::convertToUiResultFieldName(QString resultFieldName) +{ + if (resultFieldName == "E") return "NativeAbaqus Strain"; + if (resultFieldName == "S") return "NativeAbaqus Stess"; + if (resultFieldName == "NE") return "E"; // Make NE and NS appear as E and S + if (resultFieldName == "NS") return "S"; + + return resultFieldName; +} + +void RimGeoMechResultDefinition::setOwnerPropertyFilter( RimGeoMechPropertyFilter* propertyFilter ) +{ + m_propertyFilter = propertyFilter; +} + +void RimGeoMechResultDefinition::setResultAddress( const RigFemResultAddress& resultAddress ) +{ + m_resultPositionType = resultAddress.resultPosType; + m_resultFieldName = QString::fromStdString(resultAddress.fieldName); + m_resultComponentName = QString::fromStdString(resultAddress.componentName); + + m_resultPositionTypeUiField = m_resultPositionType; + m_resultVariableUiField = composeUiVarString(m_resultFieldName(), m_resultComponentName()); +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h new file mode 100644 index 0000000000..d1d58674ad --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h @@ -0,0 +1,91 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPointer.h" +#include "cafAppEnum.h" +#include "RigFemResultPosEnum.h" +#include "RigFemResultAddress.h" + +class RimGeoMechView; +class RimGeoMechPropertyFilter; +class RifGeoMechReaderInterface; +class RigGeoMechCaseData; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGeoMechResultDefinition : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimGeoMechResultDefinition(void); + virtual ~RimGeoMechResultDefinition(void); + + void setReservoirView(RimGeoMechView* ownerReservoirView); + RimGeoMechView* reservoirView(); + + RigGeoMechCaseData* ownerCaseData(); + bool hasResult(); + void loadResult(); + + RigFemResultAddress resultAddress() { return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString());} + + RigFemResultPosEnum resultPositionType() { return m_resultPositionType();} + QString resultFieldName() { return m_resultFieldName();} + QString resultComponentName() { return m_resultComponentName();} + void setResultAddress(const RigFemResultAddress& resultAddress); + + void setOwnerPropertyFilter(RimGeoMechPropertyFilter* propertyFilter); + + QString resultFieldUiName(); + QString resultComponentUiName(); + +protected: + friend class RimGeoMechPropertyFilter; // Property filter needs the ui fields + +private: + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool * useOptionsOnly); + std::map > getResultMetaDataForUIFieldSetting(); + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + static void getUiAndResultVariableStringList(QStringList* uiNames, QStringList* variableNames, + const std::map >& fieldCompNames); + static QString composeUiVarString(const QString& resultFieldName, const QString& resultComponentName); + + virtual void initAfterRead(); + + caf::PdmField > m_resultPositionType; + caf::PdmField m_resultFieldName; + caf::PdmField m_resultComponentName; + + caf::PdmField > m_resultPositionTypeUiField; + caf::PdmField m_resultVariableUiField; + + caf::PdmPointer m_reservoirView; + caf::PdmPointer m_propertyFilter; + + static QString convertToUiResultFieldName(QString resultFieldName); +}; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp index 039293c198..1da674a9e7 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp @@ -18,27 +18,8 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimGeoMechResultSlot.h" -#include "RimGeoMechView.h" #include "RimLegendConfig.h" -#include "RimDefines.h" -#include "RimGeoMechCase.h" -#include "RifGeoMechReaderInterface.h" -#include "cafPdmUiListEditor.h" -#include "RigGeoMechCaseData.h" -#include "RigFemPartResultsCollection.h" -#include "RiuMainWindow.h" - -namespace caf { - -template<> -void caf::AppEnum< RigFemResultPosEnum >::setUp() -{ - addItem(RIG_NODAL, "NODAL", "Nodal"); - addItem(RIG_ELEMENT_NODAL, "ELEMENT_NODAL", "Element Nodal"); - addItem(RIG_INTEGRATION_POINT,"INTEGRATION_POINT","Integration Point"); - setDefault(RIG_NODAL); -} -} +#include "RimView.h" CAF_PDM_SOURCE_INIT(RimGeoMechResultSlot, "GeoMechResultSlot"); @@ -49,29 +30,8 @@ CAF_PDM_SOURCE_INIT(RimGeoMechResultSlot, "GeoMechResultSlot"); //-------------------------------------------------------------------------------------------------- RimGeoMechResultSlot::RimGeoMechResultSlot(void) { - - CAF_PDM_InitObject("Color Result", ":/CellResult.png", "", ""); - CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); this->legendConfig = new RimLegendConfig(); - - CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType" , "Result Position", "", "", ""); - m_resultPositionType.setUiHidden(true); - CAF_PDM_InitField(&m_resultFieldName, "ResultFieldName", QString(""), "Field Name", "", "", ""); - m_resultFieldName.setUiHidden(true); - CAF_PDM_InitField(&m_resultComponentName, "ResultComponentName", QString(""), "Component", "", "", ""); - m_resultComponentName.setUiHidden(true); - - CAF_PDM_InitFieldNoDefault(&m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position", "", "", ""); - m_resultPositionTypeUiField.setIOWritable(false); - m_resultPositionTypeUiField.setIOReadable(false); - - CAF_PDM_InitField(&m_resultVariableUiField, "ResultVariableUI", QString(""), "Value", "", "", ""); - m_resultVariableUiField.setIOWritable(false); - m_resultVariableUiField.setIOReadable(false); - - m_resultVariableUiField.setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); - m_resultVariableUiField.setUiLabelPosition(caf::PdmUiItemInfo::TOP); } //-------------------------------------------------------------------------------------------------- @@ -80,216 +40,3 @@ RimGeoMechResultSlot::RimGeoMechResultSlot(void) RimGeoMechResultSlot::~RimGeoMechResultSlot(void) { } - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList RimGeoMechResultSlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) -{ - QList options; - *useOptionsOnly = true; - - if (m_reservoirView) - { - - - - if (&m_resultVariableUiField == fieldNeedingOptions) - { - std::map > fieldCompNames = getResultMetaDataForUIFieldSetting(); - QStringList uiVarNames; - QStringList varNames; - getUiAndResultVariableStringList(&uiVarNames, &varNames, fieldCompNames); - - for (int oIdx = 0; oIdx < uiVarNames.size(); ++oIdx) - { - options.push_back(caf::PdmOptionItemInfo(uiVarNames[oIdx], varNames[oIdx])); - } - - } - } - - return options; -} - - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGeoMechResultSlot::setReservoirView(RimGeoMechView* ownerReservoirView) -{ - m_reservoirView = ownerReservoirView; -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimGeoMechView* RimGeoMechResultSlot::reservoirView() -{ - return m_reservoirView; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGeoMechResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) -{ - if(&m_resultPositionTypeUiField == changedField) - { - std::map > fieldCompNames = getResultMetaDataForUIFieldSetting(); - QStringList uiVarNames; - QStringList varNames; - getUiAndResultVariableStringList(&uiVarNames, &varNames, fieldCompNames); - - if (m_resultPositionTypeUiField() == m_resultPositionType() - && varNames.contains(composeUiVarString(m_resultFieldName(), m_resultComponentName()))) - { - m_resultVariableUiField = composeUiVarString(m_resultFieldName(), m_resultComponentName()); - } - else - { - m_resultVariableUiField = ""; - } - - } - - if (&m_resultVariableUiField == changedField) - { - QStringList fieldComponentNames = m_resultVariableUiField().split(QRegExp("\\s+")); - if (fieldComponentNames.size() > 0) - { - m_resultPositionType = m_resultPositionTypeUiField; - m_resultFieldName = fieldComponentNames[0]; - if (fieldComponentNames.size() > 1) - { - m_resultComponentName = fieldComponentNames[1]; - } - else - { - m_resultComponentName = ""; - } - - if (m_reservoirView->geoMechCase()->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress())) - { - m_reservoirView->hasUserRequestedAnimation = true; - } - - m_reservoirView->createDisplayModelAndRedraw(); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::map > RimGeoMechResultSlot::getResultMetaDataForUIFieldSetting() -{ - RimGeoMechCase* gmCase = m_reservoirView->geoMechCase(); - if (gmCase && gmCase->geoMechData()) - { - return gmCase->geoMechData()->femPartResults()->scalarFieldAndComponentNames(m_resultPositionTypeUiField()); - } - else - { - return std::map >() ; - } -} - -void RimGeoMechResultSlot::getUiAndResultVariableStringList(QStringList* uiNames, QStringList* variableNames, - const std::map >& fieldCompNames) -{ - CVF_ASSERT(uiNames && variableNames); - - std::map >::const_iterator fieldIt; - for (fieldIt = fieldCompNames.begin(); fieldIt != fieldCompNames.end(); ++fieldIt) - { - QString resultFieldName = QString::fromStdString(fieldIt->first); - - if (resultFieldName == "E" || resultFieldName == "S") continue; // We will not show the native Stress and Strain - - QString resultFieldUiName = convertToUiResultFieldName(resultFieldName); - - uiNames->push_back(resultFieldUiName); - variableNames->push_back(resultFieldName); - - std::vector::const_iterator compIt; - for (compIt = fieldIt->second.begin(); compIt != fieldIt->second.end(); ++compIt) - { - QString resultCompName = QString::fromStdString(*compIt); - uiNames->push_back(" " + resultCompName); - variableNames->push_back(composeUiVarString(resultFieldName, resultCompName)); - } - } -} - -QString RimGeoMechResultSlot::composeUiVarString(const QString& resultFieldName, const QString& resultComponentName) -{ - return resultFieldName + " " + resultComponentName; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGeoMechResultSlot::initAfterRead() -{ - m_resultPositionTypeUiField = m_resultPositionType; - m_resultVariableUiField = composeUiVarString(m_resultFieldName(), m_resultComponentName()); - -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGeoMechResultSlot::loadResult() -{ - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigGeoMechCaseData* RimGeoMechResultSlot::ownerCaseData() -{ - return m_reservoirView->geoMechCase()->geoMechData(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimGeoMechResultSlot::hasResult() -{ - return ownerCaseData()->femPartResults()->assertResultsLoaded(this->resultAddress()); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimGeoMechResultSlot::resultFieldUiName() -{ - return convertToUiResultFieldName(m_resultFieldName()); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimGeoMechResultSlot::resultComponentUiName() -{ - return m_resultComponentName(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimGeoMechResultSlot::convertToUiResultFieldName(QString resultFieldName) -{ - if (resultFieldName == "E") return "NativeAbaqus Strain"; - if (resultFieldName == "S") return "NativeAbaqus Stess"; - if (resultFieldName == "NE") return "E"; // Make NE and NS appear as E and S - if (resultFieldName == "NS") return "S"; - - return resultFieldName; -} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.h b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.h index 1efebbaaa1..44abdc0bf6 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.h @@ -19,22 +19,17 @@ #pragma once +#include "RimGeoMechResultDefinition.h" #include "cafPdmField.h" -#include "cafPdmObject.h" -#include "cafPdmPointer.h" -#include "cafAppEnum.h" -#include "RigFemResultPosEnum.h" -#include "RigFemResultAddress.h" class RimLegendConfig; -class RimGeoMechView; -class RifGeoMechReaderInterface; -class RigGeoMechCaseData; + + //================================================================================================== /// /// //================================================================================================== -class RimGeoMechResultSlot : public caf::PdmObject +class RimGeoMechResultSlot : public RimGeoMechResultDefinition { CAF_PDM_HEADER_INIT; @@ -42,46 +37,5 @@ public: RimGeoMechResultSlot(void); virtual ~RimGeoMechResultSlot(void); - void setReservoirView(RimGeoMechView* ownerReservoirView); - RimGeoMechView* reservoirView(); - - RigGeoMechCaseData* ownerCaseData(); - bool hasResult(); - - RigFemResultAddress resultAddress() { return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString());} - - RigFemResultPosEnum resultPositionType() { return m_resultPositionType();} - QString resultFieldName() { return m_resultFieldName();} - QString resultComponentName() { return m_resultComponentName();} - - QString resultFieldUiName(); - QString resultComponentUiName(); - caf::PdmField legendConfig; - - -private: - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, - bool * useOptionsOnly); - std::map > getResultMetaDataForUIFieldSetting(); - - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - static void getUiAndResultVariableStringList(QStringList* uiNames, QStringList* variableNames, - const std::map >& fieldCompNames); - static QString composeUiVarString(const QString& resultFieldName, const QString& resultComponentName); - - virtual void initAfterRead(); - void loadResult(); - - caf::PdmField > m_resultPositionType; - caf::PdmField m_resultFieldName; - caf::PdmField m_resultComponentName; - - caf::PdmField > m_resultPositionTypeUiField; - caf::PdmField m_resultVariableUiField; - - caf::PdmPointer m_reservoirView; - - static QString convertToUiResultFieldName(QString resultFieldName); - }; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index b835a088fd..fcd8543370 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -49,6 +49,7 @@ #include "RivGeoMechVizLogic.h" #include "RigFemPartGrid.h" #include "RigFemPartResultsCollection.h" +#include "RimGeoMechPropertyFilterCollection.h" @@ -72,6 +73,9 @@ RimGeoMechView::RimGeoMechView(void) rangeFilterCollection = new RimCellRangeFilterCollection(); rangeFilterCollection->setReservoirView(this); + CAF_PDM_InitFieldNoDefault(&propertyFilterCollection, "PropertyFilters", "Property Filters", "", "", ""); + propertyFilterCollection = new RimGeoMechPropertyFilterCollection(); + propertyFilterCollection->setReservoirView(this); this->cellResult()->setReservoirView(this); this->cellResult()->legendConfig()->setPosition(cvf::Vec2ui(10, 120)); @@ -148,6 +152,7 @@ void RimGeoMechView::loadDataAndUpdate() progress.setProgressDescription("Create Display model"); updateViewerWidget(); + this->propertyFilterCollection()->loadAndInitializePropertyFilters(); createDisplayModelAndRedraw(); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index ec864472c0..22623f2bc9 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -36,7 +36,7 @@ class RimGeoMechCase; class RivGeoMechPartMgr; class RimCellRangeFilterCollection; class RivGeoMechVizLogic; - +class RimGeoMechPropertyFilterCollection; class RigFemPart; namespace cvf { @@ -62,6 +62,7 @@ public: virtual void loadDataAndUpdate(); caf::PdmField cellResult; + caf::PdmField propertyFilterCollection; bool isTimeStepDependentDataVisible(); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 92c8bf1207..aa44ef3ee2 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -27,6 +27,8 @@ #include "RimCaseCollection.h" #include "RimCellPropertyFilterCollection.h" #include "RimCellRangeFilterCollection.h" +#include "RimGeoMechPropertyFilterCollection.h" +#include "RimGeoMechPropertyFilter.h" #include "RimIdenticalGridCaseGroup.h" #include "RimInputCase.h" #include "RimInputProperty.h" @@ -50,6 +52,7 @@ #include "RimGeoMechCase.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -309,6 +312,52 @@ RimCellPropertyFilter* RimUiTreeModelPdm::addPropertyFilter(const QModelIndex& i return propertyFilter; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechPropertyFilter* RimUiTreeModelPdm::addGeoMechPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) +{ + caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); + + QModelIndex collectionIndex; + RimGeoMechPropertyFilterCollection* propertyFilterCollection = NULL; + caf::PdmUiTreeItem* propertyFilterCollectionItem = NULL; + int position = 0; + + if (dynamic_cast(currentItem->dataObject().p())) + { + RimGeoMechPropertyFilter* propertyFilter = dynamic_cast(currentItem->dataObject().p()); + propertyFilterCollection = propertyFilter->parentContainer(); + propertyFilterCollectionItem = currentItem->parent(); + position = itemIndex.row(); + collectionIndex = itemIndex.parent(); + } + else if (dynamic_cast(currentItem->dataObject().p())) + { + propertyFilterCollection = dynamic_cast(currentItem->dataObject().p()); + propertyFilterCollectionItem = currentItem; + position = propertyFilterCollectionItem->childCount(); + collectionIndex = itemIndex; + } + + beginInsertRows(collectionIndex, position, position); + + RimGeoMechPropertyFilter* propertyFilter = propertyFilterCollection->createAndAppendPropertyFilter(); + caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(propertyFilterCollectionItem, position, propertyFilter); + + endInsertRows(); + + insertedModelIndex = index(position, 0, collectionIndex); + + if (propertyFilterCollection) + { + static_cast(propertyFilterCollection->reservoirView())->scheduleGeometryRegen(PROPERTY_FILTERED); + } + + return propertyFilter; +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index 724a417a8d..81e8e97c43 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -29,6 +29,7 @@ class QFileSystemWatcher; class RimCellPropertyFilter; class RimCellRangeFilter; +class RimGeoMechPropertyFilter; class RimEclipseCase; class RimEclipseView; class RimInputProperty; @@ -58,6 +59,7 @@ public: void deleteAllWellPaths(const QModelIndex& itemIndex); RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + RimGeoMechPropertyFilter* addGeoMechPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimView* addReservoirView(const std::vector& treeSelection); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 0915ed9f81..8c36f3af07 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -52,6 +52,9 @@ #include "RimCellRangeFilterCollection.h" #include "RimCellPropertyFilterCollection.h" +#include "RimCellRangeFilterCollection.h" +#include "RimGeoMechPropertyFilter.h" +#include "RimGeoMechPropertyFilterCollection.h" #include "RimResultSlot.h" #include "RimStatisticsCaseCollection.h" #include "RimIdenticalGridCaseGroup.h" @@ -156,6 +159,16 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) menu.addSeparator(); menu.addAction(QString("Delete"), this, SLOT(slotDeletePropertyFilter())); } + else if (dynamic_cast(uiItem->dataObject().p())) + { + menu.addAction(QString("New Property Filter"), this, SLOT(slotAddGeoMechPropertyFilter())); + } + else if (dynamic_cast(uiItem->dataObject().p())) + { + menu.addAction(QString("Insert Property Filter"), this, SLOT(slotAddGeoMechPropertyFilter())); + menu.addSeparator(); + menu.addAction(QString("Delete"), this, SLOT(slotDeleteGeoMechPropertyFilter())); + } else if (dynamic_cast(uiItem->dataObject().p())) { RiaApplication* app = RiaApplication::instance(); @@ -361,6 +374,37 @@ void RimUiTreeView::slotAddPropertyFilter() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::slotAddGeoMechPropertyFilter() +{ + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + if (myModel) + { + QModelIndex insertedIndex; + RimGeoMechPropertyFilter* propFilter = myModel->addGeoMechPropertyFilter(currentIndex(), insertedIndex); + setCurrentIndex(insertedIndex); + if (propFilter) + { + propFilter->parentContainer()->reservoirView()->createDisplayModelAndRedraw(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::slotDeleteGeoMechPropertyFilter() +{ + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + if (myModel) + { + myModel->deletePropertyFilter(currentIndex()); + } +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index 1c511ed5cd..8475748e70 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -68,6 +68,8 @@ private slots: void slotAddPropertyFilter(); void slotDeletePropertyFilter(); + void slotAddGeoMechPropertyFilter(); + void slotDeleteGeoMechPropertyFilter(); void slotEditScript(); void slotNewScript();