diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index cc53b60eac..b5769f123e 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -80,7 +80,6 @@ bool RimGeoMechCase::openGeoMechCase() if (this->m_geoMechCaseData.notNull()) return true; - cvf::ref readerInterface; if (!QFile::exists(m_caseFileName())) { @@ -89,10 +88,10 @@ bool RimGeoMechCase::openGeoMechCase() #ifdef USE_ODB_API - readerInterface = new RifOdbReader; + m_readerInterface = new RifOdbReader; m_geoMechCaseData = new RigGeoMechCaseData; - if (readerInterface->readFemParts(m_caseFileName().toStdString(), m_geoMechCaseData->femParts())) + if (m_readerInterface->readFemParts(m_caseFileName().toStdString(), m_geoMechCaseData->femParts())) { // Todo: Default Results stuff, if needed @@ -105,3 +104,11 @@ bool RimGeoMechCase::openGeoMechCase() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifGeoMechReaderInterface* RimGeoMechCase::readerInterface() +{ + return m_readerInterface.p(); +} + diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index 346d436d45..e1e21e6f62 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -26,6 +26,8 @@ class RimGeoMechView; class RigGeoMechCaseData; +class RifGeoMechReaderInterface; + //================================================================================================== /// /// @@ -47,7 +49,7 @@ public: RimGeoMechView* createAndAddReservoirView(); virtual caf::PdmFieldHandle* userDescriptionField(); - + RifGeoMechReaderInterface* readerInterface(); // Fields: caf::PdmField caseUserDescription; caf::PdmPointersField geoMechViews; @@ -55,4 +57,6 @@ public: private: cvf::ref m_geoMechCaseData; caf::PdmField m_caseFileName; + + cvf::ref m_readerInterface; }; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp index 59e84ea4f4..75443e86fb 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp @@ -21,8 +21,20 @@ #include "RimGeoMechView.h" #include "RimLegendConfig.h" #include "RimDefines.h" +#include "RimGeoMechCase.h" +#include "RifGeoMechReaderInterface.h" +namespace caf { +template<> +void caf::AppEnum< RimGeoMechResultSlot::ResultPositionEnum >::setUp() +{ + addItem(RimGeoMechResultSlot::NODAL, "NODAL", "Nodal"); + addItem(RimGeoMechResultSlot::ELEMENT_NODAL, "ELEMENT_NODAL", "Element Nodal"); + addItem(RimGeoMechResultSlot::INTEGRATION_POINT,"INTEGRATION_POINT","Integration Point"); + setDefault(RimGeoMechResultSlot::NODAL); +} +} CAF_PDM_SOURCE_INIT(RimGeoMechResultSlot, "GeoMechResultSlot"); @@ -39,7 +51,9 @@ RimGeoMechResultSlot::RimGeoMechResultSlot(void) CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); this->legendConfig = new RimLegendConfig(); - CAF_PDM_InitField(&m_resultVariable, "ResultVariable", RimDefines::undefinedResultName(), "Variable", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType" , "Result Position", "", "", ""); + CAF_PDM_InitField(&m_resultFieldName, "ResultFieldName", RimDefines::undefinedResultName(), "Field Name", "", "", ""); + CAF_PDM_InitField(&m_resultComponentName, "ResultComponentName", RimDefines::undefinedResultName(), "Component", "", "", ""); } @@ -60,17 +74,41 @@ QList RimGeoMechResultSlot::calculateValueOptions(const if (m_reservoirView) { - // RimGeoMechCase* gmCase = m_reservoirView->geoMechCase(); + RimGeoMechCase* gmCase = m_reservoirView->geoMechCase(); + cvf::ref reader = gmCase->readerInterface(); + if (reader.notNull()) + { + std::map > fieldCompNames; + if (m_resultPositionType == NODAL) + { + fieldCompNames = reader->scalarNodeFieldAndComponentNames(); + } + + if (&m_resultFieldName == fieldNeedingOptions) + { + for (auto it = fieldCompNames.begin(); it != fieldCompNames.end(); ++it) + { + options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(it->first), QString::fromStdString(it->first))); + } + } + + if (&m_resultComponentName == fieldNeedingOptions) + { + auto fieldIt = fieldCompNames.find(m_resultFieldName().toAscii().data()); + if (fieldIt != fieldCompNames.end()) + { + for (auto compIt = fieldIt->second.begin(); compIt != fieldIt->second.end(); ++compIt) + { + options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(*compIt), QString::fromStdString(*compIt))); + } + } + + if (!options.size()) options.push_back(caf::PdmOptionItemInfo("Undefined", "Undefined")); + } + } } - if (&m_resultVariable == fieldNeedingOptions) - { - options.push_back(caf::PdmOptionItemInfo("Von Mises", QString("VonMises")) ); - options.push_back(caf::PdmOptionItemInfo("Sigma XX", QString("SIGXX")) ); - options.push_back(caf::PdmOptionItemInfo("Sigma YY", QString("SIGYY")) ); - - } return options; } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.h b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.h index 8486b2d7e9..497b569f22 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.h @@ -22,6 +22,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmPointer.h" +#include "cafAppEnum.h" class RimLegendConfig; class RimGeoMechView; @@ -42,13 +43,20 @@ public: caf::PdmField legendConfig; - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); + + enum ResultPositionEnum { + NODAL, + ELEMENT_NODAL, + INTEGRATION_POINT + }; private: + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); - caf::PdmField m_resultType; - caf::PdmField m_resultVariable; - caf::PdmField m_componentName; + + caf::PdmField > m_resultPositionType; + caf::PdmField m_resultFieldName; + caf::PdmField m_resultComponentName; caf::PdmPointer m_reservoirView; }; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 925342126d..0ab596c708 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -87,7 +87,7 @@ RimGeoMechView::RimGeoMechView(void) CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid lines", "", "", ""); CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid surface", "", "", ""); - //this->cellResult()->setReservoirView(this); + this->cellResult()->setReservoirView(this); this->cellResult()->legendConfig()->setPosition(cvf::Vec2ui(10, 120)); this->cellResult()->legendConfig()->setReservoirView(this); }