diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 5602847442..42842191df 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -86,6 +86,7 @@ #include "RimGeoMechCase.h" #include "RimGeoMechModels.h" #include "RimGeoMechView.h" +#include "RimGeoMechResultSlot.h" namespace caf @@ -731,7 +732,7 @@ bool RiaApplication::openOdbCaseFromFile(const QString& fileName) RimGeoMechView* riv = geoMechCase->createAndAddReservoirView(); - // riv->loadDataAndUpdate(); + riv->loadDataAndUpdate(); //if (!riv->cellResult()->hasResult()) //{ diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index b6ef70a581..99b1bf6f4b 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -54,6 +54,7 @@ ${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}RimGeoMechResultSlot.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -106,6 +107,7 @@ ${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}RimGeoMechResultSlot.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp new file mode 100644 index 0000000000..5f000e2921 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.cpp @@ -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. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimGeoMechResultSlot.h" +#include "RimReservoirView.h" +#include "RimLegendConfig.h" +#include "RimDefines.h" + + + + +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_InitField(&m_resultVariable, "ResultVariable", RimDefines::undefinedResultName(), "Variable", "", "", ""); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechResultSlot::~RimGeoMechResultSlot(void) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimGeoMechResultSlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +{ + QList options; + + 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 new file mode 100644 index 0000000000..dcc9e8b8e0 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultSlot.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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" + +class RimLegendConfig; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGeoMechResultSlot : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimGeoMechResultSlot(void); + virtual ~RimGeoMechResultSlot(void); + + caf::PdmField legendConfig; + + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); + +private: + + caf::PdmField m_resultVariable; +}; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index e489379c66..03d9ee39e9 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -23,9 +23,16 @@ #include "Rim3dOverlayInfoConfig.h" #include "RiaApplication.h" #include "RiaPreferences.h" -#include "RimResultSlot.h" +#include "RimGeoMechResultSlot.h" +#include "RiuViewer.h" +#include "RiuMainWindow.h" +#include "cafCeetronPlusNavigation.h" +#include "cafCadNavigation.h" +#include "RimLegendConfig.h" +#include "cvfOverlayScalarMapperLegend.h" +#include "cvfViewport.h" namespace caf { @@ -65,8 +72,8 @@ RimGeoMechView::RimGeoMechView(void) CAF_PDM_InitObject("Geomechanical View", ":/ReservoirView.png", "", ""); - CAF_PDM_InitFieldNoDefault(&cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", ""); - cellResult = new RimResultSlot(); + CAF_PDM_InitFieldNoDefault(&cellResult, "GridCellResult", "Color Result", ":/CellResult.png", "", ""); + cellResult = new RimGeoMechResultSlot(); CAF_PDM_InitFieldNoDefault(&overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); overlayInfoConfig = new Rim3dOverlayInfoConfig(); @@ -76,6 +83,11 @@ RimGeoMechView::RimGeoMechView(void) double defaultScaleFactor = 1.0; if (preferences) defaultScaleFactor = preferences->defaultScaleFactorZ; CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", ""); + + CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", ""); + showWindow.setUiHidden(true); + + CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", ""); caf::AppEnum defaultMeshType = NO_MESH; if (preferences->defaultGridLines) defaultMeshType = FULL_MESH; @@ -102,3 +114,96 @@ caf::PdmFieldHandle* RimGeoMechView::userDescriptionField() return &name; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateViewerWidget() +{ + if (showWindow()) + { + bool isViewerCreated = false; + if (!m_viewer) + { + QGLFormat glFormat; + glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); + + m_viewer = new RiuViewer(glFormat, NULL); + //m_viewer->setOwnerReservoirView(this); + + RiuMainWindow::instance()->addViewer(m_viewer); + m_viewer->setMinNearPlaneDistance(10); + + + m_viewer->removeAllColorLegends(); + m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend()); + + if (RiaApplication::instance()->navigationPolicy() == RiaApplication::NAVIGATION_POLICY_CEETRON) + { + m_viewer->setNavigationPolicy(new caf::CeetronPlusNavigation); + } + else + { + m_viewer->setNavigationPolicy(new caf::CadNavigation); + } + + m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo()); + + //m_viewer->layoutWidget()->showMaximized(); + + isViewerCreated = true; + } + + RiuMainWindow::instance()->setActiveViewer(m_viewer); + + if (isViewerCreated) m_viewer->mainCamera()->setViewMatrix(cameraPosition); + m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); + + m_viewer->update(); + } + else + { + if (m_viewer) + { + if (m_viewer->layoutWidget()->parentWidget()) + { + m_viewer->layoutWidget()->parentWidget()->hide(); + } + else + { + m_viewer->layoutWidget()->hide(); + } + } + } + + updateViewerWidgetWindowTitle(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateViewerWidgetWindowTitle() +{ + if (m_viewer) + { + QString windowTitle; + if (false)//m_reservoir.notNull()) + { + // windowTitle = QString("%1 - %2").arg(m_reservoir->caseUserDescription()).arg(name); + } + else + { + windowTitle = name; + } + + m_viewer->layoutWidget()->setWindowTitle(windowTitle); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::loadDataAndUpdate() +{ + updateViewerWidget(); +} + diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 7b9659c7da..345792b666 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -24,9 +24,11 @@ #include "cafPdmPointer.h" #include "cafAppEnum.h" #include "cafPdmFieldCvfColor.h" +#include "cafPdmFieldCvfMat4d.h" -class RimResultSlot; +class RimGeoMechResultSlot; class Rim3dOverlayInfoConfig; +class RiuViewer; //================================================================================================== /// @@ -54,13 +56,17 @@ public: FAULTS, NO_SURFACE }; + void loadDataAndUpdate(); - caf::PdmField cellResult; + caf::PdmField cellResult; caf::PdmField overlayInfoConfig; // Fields: caf::PdmField name; caf::PdmField scaleZ; + caf::PdmField showWindow; + caf::PdmField cameraPosition; + caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; @@ -70,4 +76,7 @@ protected: virtual caf::PdmFieldHandle* userDescriptionField(); private: + void updateViewerWidget(); + void updateViewerWidgetWindowTitle(); + QPointer m_viewer; }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 76a37bda57..99b085cf91 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -62,6 +62,25 @@ #include +CAF_PDM_SOURCE_INIT(RimView, "GenericView"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimView::RimView(void) +{ + CAF_PDM_InitObject("Generic View", ":/ReservoirView.png", "", ""); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimView::~RimView(void) +{ + +} + namespace caf { diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index 8b82ba0296..773c24cac6 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -69,6 +69,19 @@ enum PartRenderMaskEnum faultBit = 0x00000004, meshFaultBit = 0x00000008, }; +//================================================================================================== +/// +/// +//================================================================================================== +class RimView : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimView(void); + virtual ~RimView(void); + + +}; //================================================================================================== @@ -149,10 +162,12 @@ public: // 3D Viewer RiuViewer* viewer(); +private: void updateViewerWidget(); void updateViewerWidgetWindowTitle(); void setDefaultView(); +public: void setMeshOnlyDrawstyle(); void setMeshSurfDrawstyle(); void setSurfOnlyDrawstyle();