Added the 3D view to the geomech stuff

This commit is contained in:
Jacob Støren 2015-04-20 16:56:26 +02:00
parent 27f6bd9eb5
commit 27c2c040fe
8 changed files with 273 additions and 6 deletions

View File

@ -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())
//{

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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<caf::PdmOptionItemInfo> RimGeoMechResultSlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> 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;
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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<RimLegendConfig*> legendConfig;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly);
private:
caf::PdmField<QString> m_resultVariable;
};

View File

@ -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<RimGeoMechView::MeshModeType> 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();
}

View File

@ -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<RimResultSlot*> cellResult;
caf::PdmField<RimGeoMechResultSlot*> cellResult;
caf::PdmField<Rim3dOverlayInfoConfig*> overlayInfoConfig;
// Fields:
caf::PdmField<QString> name;
caf::PdmField<double> scaleZ;
caf::PdmField<bool> showWindow;
caf::PdmField<cvf::Mat4d> 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<RiuViewer> m_viewer;
};

View File

@ -62,6 +62,25 @@
#include <limits.h>
CAF_PDM_SOURCE_INIT(RimView, "GenericView");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimView::RimView(void)
{
CAF_PDM_InitObject("Generic View", ":/ReservoirView.png", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimView::~RimView(void)
{
}
namespace caf {

View File

@ -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();