2015-04-20 09:02:33 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// 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 "RimGeoMechView.h"
|
|
|
|
|
|
|
|
|
|
#include "Rim3dOverlayInfoConfig.h"
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
#include "RiaPreferences.h"
|
2015-04-20 16:56:26 +02:00
|
|
|
#include "RimGeoMechResultSlot.h"
|
2015-04-20 09:02:33 +02:00
|
|
|
|
2015-04-20 16:56:26 +02:00
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
|
#include "cafCeetronPlusNavigation.h"
|
|
|
|
|
#include "cafCadNavigation.h"
|
|
|
|
|
#include "RimLegendConfig.h"
|
|
|
|
|
#include "cvfOverlayScalarMapperLegend.h"
|
2015-04-20 09:02:33 +02:00
|
|
|
|
2015-04-27 13:51:22 +02:00
|
|
|
#include "RimGeoMechCase.h"
|
|
|
|
|
#include "cvfPart.h"
|
2015-04-20 16:56:26 +02:00
|
|
|
#include "cvfViewport.h"
|
2015-04-27 13:51:22 +02:00
|
|
|
#include "cvfModelBasicList.h"
|
|
|
|
|
#include "cvfScene.h"
|
|
|
|
|
#include "RimReservoirView.h"
|
|
|
|
|
#include "RiuViewer.h"
|
|
|
|
|
#include "RivGeoMechPartMgr.h"
|
|
|
|
|
#include "RigGeoMechCaseData.h"
|
2015-05-04 18:16:57 +02:00
|
|
|
#include "cvfqtUtils.h"
|
2015-04-27 13:51:22 +02:00
|
|
|
|
2015-04-20 09:02:33 +02:00
|
|
|
|
|
|
|
|
namespace caf {
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
void caf::AppEnum< RimGeoMechView::MeshModeType >::setUp()
|
|
|
|
|
{
|
|
|
|
|
addItem(RimGeoMechView::FULL_MESH, "FULL_MESH", "All");
|
|
|
|
|
addItem(RimGeoMechView::FAULTS_MESH, "FAULTS_MESH", "Faults only");
|
|
|
|
|
addItem(RimGeoMechView::NO_MESH, "NO_MESH", "None");
|
|
|
|
|
setDefault(RimGeoMechView::FULL_MESH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
void caf::AppEnum< RimGeoMechView::SurfaceModeType >::setUp()
|
|
|
|
|
{
|
|
|
|
|
addItem(RimGeoMechView::SURFACE, "SURFACE", "All");
|
|
|
|
|
addItem(RimGeoMechView::FAULTS, "FAULTS", "Faults only");
|
|
|
|
|
addItem(RimGeoMechView::NO_SURFACE, "NO_SURFACE", "None");
|
|
|
|
|
setDefault(RimGeoMechView::SURFACE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // End namespace caf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimGeoMechView, "GeoMechView");
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimGeoMechView::RimGeoMechView(void)
|
|
|
|
|
{
|
|
|
|
|
RiaApplication* app = RiaApplication::instance();
|
|
|
|
|
RiaPreferences* preferences = app->preferences();
|
|
|
|
|
CVF_ASSERT(preferences);
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitObject("Geomechanical View", ":/ReservoirView.png", "", "");
|
|
|
|
|
|
2015-04-20 16:56:26 +02:00
|
|
|
CAF_PDM_InitFieldNoDefault(&cellResult, "GridCellResult", "Color Result", ":/CellResult.png", "", "");
|
|
|
|
|
cellResult = new RimGeoMechResultSlot();
|
2015-04-29 22:19:49 +02:00
|
|
|
|
2015-04-20 09:02:33 +02:00
|
|
|
caf::AppEnum<RimGeoMechView::MeshModeType> defaultMeshType = NO_MESH;
|
|
|
|
|
if (preferences->defaultGridLines) defaultMeshType = FULL_MESH;
|
|
|
|
|
CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid lines", "", "", "");
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid surface", "", "", "");
|
|
|
|
|
|
2015-04-30 17:06:01 +02:00
|
|
|
this->cellResult()->setReservoirView(this);
|
2015-04-30 10:34:15 +02:00
|
|
|
this->cellResult()->legendConfig()->setPosition(cvf::Vec2ui(10, 120));
|
|
|
|
|
this->cellResult()->legendConfig()->setReservoirView(this);
|
2015-04-20 09:02:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimGeoMechView::~RimGeoMechView(void)
|
|
|
|
|
{
|
2015-04-30 10:34:15 +02:00
|
|
|
m_geomechCase = NULL;
|
2015-04-20 09:02:33 +02:00
|
|
|
}
|
|
|
|
|
|
2015-04-20 16:56:26 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimGeoMechView::updateViewerWidgetWindowTitle()
|
|
|
|
|
{
|
|
|
|
|
if (m_viewer)
|
|
|
|
|
{
|
|
|
|
|
QString windowTitle;
|
2015-04-30 10:34:15 +02:00
|
|
|
if (m_geomechCase.notNull())
|
2015-04-20 16:56:26 +02:00
|
|
|
{
|
2015-04-30 10:34:15 +02:00
|
|
|
windowTitle = QString("%1 - %2").arg(m_geomechCase->caseUserDescription()).arg(name);
|
2015-04-20 16:56:26 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
windowTitle = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_viewer->layoutWidget()->setWindowTitle(windowTitle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimGeoMechView::loadDataAndUpdate()
|
|
|
|
|
{
|
2015-04-27 13:51:22 +02:00
|
|
|
if (m_geomechCase)
|
|
|
|
|
{
|
|
|
|
|
m_geomechCase->openGeoMechCase();
|
|
|
|
|
|
|
|
|
|
}
|
2015-04-20 16:56:26 +02:00
|
|
|
updateViewerWidget();
|
2015-04-27 13:51:22 +02:00
|
|
|
|
|
|
|
|
createDisplayModelAndRedraw();
|
|
|
|
|
|
2015-04-20 16:56:26 +02:00
|
|
|
}
|
|
|
|
|
|
2015-04-27 13:51:22 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimGeoMechView::createDisplayModelAndRedraw()
|
|
|
|
|
{
|
|
|
|
|
if (m_viewer && m_geomechCase)
|
|
|
|
|
{
|
2015-04-29 09:26:29 +02:00
|
|
|
int partCount = 0;
|
|
|
|
|
if (m_geomechCase->geoMechData() && m_geomechCase->geoMechData()->femParts())
|
2015-04-27 13:51:22 +02:00
|
|
|
{
|
2015-04-29 09:26:29 +02:00
|
|
|
partCount = m_geomechCase->geoMechData()->femParts()->partCount();
|
2015-04-27 13:51:22 +02:00
|
|
|
}
|
|
|
|
|
|
2015-04-29 09:26:29 +02:00
|
|
|
if (partCount >= 0)
|
|
|
|
|
{
|
|
|
|
|
cvf::ref<cvf::Transform> scaleTransform = new cvf::Transform();
|
|
|
|
|
scaleTransform->setLocalTransform(cvf::Mat4d::IDENTITY);
|
2015-04-27 13:51:22 +02:00
|
|
|
|
2015-04-29 09:26:29 +02:00
|
|
|
cvf::ref<cvf::ModelBasicList> cvfModel = new cvf::ModelBasicList;
|
|
|
|
|
m_geoMechVizModel = new RivGeoMechPartMgr();
|
|
|
|
|
m_geoMechVizModel->clearAndSetReservoir(m_geomechCase->geoMechData(), this);
|
|
|
|
|
|
|
|
|
|
for (int femPartIdx = 0; femPartIdx < partCount; ++femPartIdx)
|
|
|
|
|
{
|
|
|
|
|
cvf::ref<cvf::UByteArray> elmVisibility = m_geoMechVizModel->cellVisibility(femPartIdx);
|
|
|
|
|
m_geoMechVizModel->setTransform(scaleTransform.p());
|
|
|
|
|
RivElmVisibilityCalculator::computeAllVisible(elmVisibility.p(), m_geomechCase->geoMechData()->femParts()->part(femPartIdx));
|
|
|
|
|
m_geoMechVizModel->setCellVisibility(femPartIdx, elmVisibility.p());
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-29 10:50:25 +02:00
|
|
|
m_geoMechVizModel->updateCellColor(cvf::Color4f(cvf::Color3f::ORANGE));
|
2015-05-04 18:16:57 +02:00
|
|
|
if (cellResult()->resultFieldName() != "")
|
|
|
|
|
{
|
|
|
|
|
m_geoMechVizModel->updateCellResultColor(m_currentTimeStep(), this->cellResult());
|
|
|
|
|
}
|
2015-04-29 09:26:29 +02:00
|
|
|
m_geoMechVizModel->appendGridPartsToModel(cvfModel.p());
|
|
|
|
|
|
|
|
|
|
cvf::ref<cvf::Scene> scene = new cvf::Scene;
|
|
|
|
|
scene->addModel(cvfModel.p());
|
|
|
|
|
scene->updateBoundingBoxesRecursive();
|
|
|
|
|
|
|
|
|
|
m_viewer->setMainScene(scene.p());
|
|
|
|
|
m_viewer->zoomAll();
|
|
|
|
|
m_viewer->update();
|
|
|
|
|
|
2015-04-30 10:59:39 +02:00
|
|
|
updateLegends();
|
|
|
|
|
overlayInfoConfig()->update3DInfo();
|
2015-04-29 09:26:29 +02:00
|
|
|
}
|
2015-04-27 13:51:22 +02:00
|
|
|
}
|
|
|
|
|
RiuMainWindow::instance()->refreshAnimationActions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimGeoMechView::setGeoMechCase(RimGeoMechCase* gmCase)
|
|
|
|
|
{
|
|
|
|
|
m_geomechCase = gmCase;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-30 10:34:15 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimGeoMechView::resetLegendsInViewer()
|
|
|
|
|
{
|
|
|
|
|
this->cellResult()->legendConfig->recreateLegend();
|
|
|
|
|
|
|
|
|
|
m_viewer->removeAllColorLegends();
|
|
|
|
|
m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend());
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-30 10:59:39 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimGeoMechView::updateLegends()
|
|
|
|
|
{
|
2015-05-04 18:16:57 +02:00
|
|
|
if (m_viewer)
|
2015-04-30 10:59:39 +02:00
|
|
|
{
|
|
|
|
|
m_viewer->removeAllColorLegends();
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-04 18:16:57 +02:00
|
|
|
if (!m_geomechCase || !m_viewer || !m_geomechCase->geoMechData() )
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData();
|
|
|
|
|
CVF_ASSERT(gmCase);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double localMin, localMax;
|
|
|
|
|
double localPosClosestToZero, localNegClosestToZero;
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
|
|
RigCaseCellResultsData* results = gmCase->results(porosityModel);
|
|
|
|
|
CVF_ASSERT(results);
|
|
|
|
|
|
|
|
|
|
if (cellResult->hasDynamicResult())
|
|
|
|
|
{
|
|
|
|
|
cellResultsData->minMaxCellScalarValues(cellResult->scalarResultIndex(), m_currentTimeStep, localMin, localMax);
|
|
|
|
|
cellResultsData->posNegClosestToZero(cellResult->scalarResultIndex(), m_currentTimeStep, localPosClosestToZero, localNegClosestToZero);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
localMin = globalMin;
|
|
|
|
|
localMax = globalMax;
|
|
|
|
|
|
|
|
|
|
localPosClosestToZero = globalPosClosestToZero;
|
|
|
|
|
localNegClosestToZero = globalNegClosestToZero;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cellResult->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
|
|
|
|
|
cellResult->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
|
|
|
|
|
#endif
|
|
|
|
|
caf::AppEnum<RimGeoMechResultSlot::ResultPositionEnum> resPosType = cellResult->resultPositionType();
|
|
|
|
|
QString fieldName = cellResult->resultFieldName();
|
|
|
|
|
QString compName = cellResult->resultComponentName();
|
|
|
|
|
|
|
|
|
|
m_viewer->addColorLegendToBottomLeftCorner(cellResult->legendConfig->legend());
|
|
|
|
|
|
|
|
|
|
cellResult->legendConfig->legend()->setTitle(cvfqt::Utils::toString( resPosType.text() + "\n" + fieldName + " " + compName));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-30 10:59:39 +02:00
|
|
|
}
|
|
|
|
|
|
2015-04-30 14:19:43 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimGeoMechCase* RimGeoMechView::geoMechCase()
|
|
|
|
|
{
|
|
|
|
|
return m_geomechCase;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-27 13:51:22 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RivElmVisibilityCalculator::computeAllVisible(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart)
|
|
|
|
|
{
|
|
|
|
|
elmVisibilities->resize(femPart->elementCount());
|
|
|
|
|
elmVisibilities->setAll(true);
|
|
|
|
|
}
|