2018-10-23 09:32:40 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2018- Equinor ASA
|
2019-01-09 05:48:56 -06:00
|
|
|
//
|
2018-10-23 09:32:40 -05:00
|
|
|
// 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.
|
2019-01-09 05:48:56 -06:00
|
|
|
//
|
2018-10-23 09:32:40 -05:00
|
|
|
// 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.
|
2019-01-09 05:48:56 -06:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-10-23 09:32:40 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-11-09 02:04:40 -06:00
|
|
|
#include "RicNewContourMapViewFeature.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
|
2019-01-09 05:48:42 -06:00
|
|
|
#include "Rim3dView.h"
|
|
|
|
#include "RimCellEdgeColors.h"
|
2019-01-11 06:56:35 -06:00
|
|
|
#include "RimEclipseContourMapView.h"
|
2019-01-16 03:51:43 -06:00
|
|
|
#include "RimEclipseContourMapViewCollection.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
#include "RimEclipseCase.h"
|
2018-11-08 09:18:03 -06:00
|
|
|
#include "RimEclipseCellColors.h"
|
2019-01-09 05:48:42 -06:00
|
|
|
#include "RimEclipseView.h"
|
2019-01-16 03:51:43 -06:00
|
|
|
#include "RimGeoMechContourMapView.h"
|
|
|
|
#include "RimGeoMechContourMapViewCollection.h"
|
|
|
|
#include "RimGeoMechCase.h"
|
|
|
|
#include "RimGeoMechCellColors.h"
|
|
|
|
#include "RimGeoMechView.h"
|
|
|
|
|
2019-01-09 05:48:42 -06:00
|
|
|
#include "RimFaultInViewCollection.h"
|
|
|
|
#include "RimSimWellInViewCollection.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
|
|
|
|
#include "Riu3DMainWindowTools.h"
|
2018-11-08 09:18:03 -06:00
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
#include "RiaLogging.h"
|
2018-11-08 09:18:03 -06:00
|
|
|
#include "RiaPreferences.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
|
2018-11-08 09:18:03 -06:00
|
|
|
#include "cafPdmDocument.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2018-11-09 02:04:40 -06:00
|
|
|
CAF_CMD_SOURCE_INIT(RicNewContourMapViewFeature, "RicNewContourMapViewFeature");
|
2018-10-23 09:32:40 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-09 05:48:56 -06:00
|
|
|
///
|
2018-10-23 09:32:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-11-09 02:04:40 -06:00
|
|
|
bool RicNewContourMapViewFeature::isCommandEnabled()
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2019-01-16 03:51:43 -06:00
|
|
|
bool selectedView = caf::SelectionManager::instance()->selectedItemOfType<RimGridView>() != nullptr;
|
|
|
|
bool selectedCase = caf::SelectionManager::instance()->selectedItemOfType<RimCase>() != nullptr;
|
|
|
|
bool selectedEclipseContourMapCollection = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapViewCollection>();
|
|
|
|
bool selectedGeoMechContourMapCollection = caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechContourMapViewCollection>();
|
|
|
|
return selectedView || selectedCase || selectedEclipseContourMapCollection || selectedGeoMechContourMapCollection;
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-09 05:48:56 -06:00
|
|
|
///
|
2018-10-23 09:32:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-11-09 02:04:40 -06:00
|
|
|
void RicNewContourMapViewFeature::onActionTriggered(bool isChecked)
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2019-01-16 03:51:43 -06:00
|
|
|
RimEclipseView* reservoirView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
|
|
|
|
RimEclipseContourMapView* existingEclipseContourMap =
|
|
|
|
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapView>();
|
|
|
|
RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimEclipseCase>();
|
|
|
|
RimEclipseContourMapView* eclipseContourMap = nullptr;
|
|
|
|
|
|
|
|
RimGeoMechView* geoMechView = caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechView>();
|
|
|
|
RimGeoMechContourMapView* existingGeoMechContourMap =
|
|
|
|
caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechContourMapView>();
|
|
|
|
RimGeoMechCase* geoMechCase = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimGeoMechCase>();
|
|
|
|
RimGeoMechContourMapView* geoMechContourMap = nullptr;
|
2018-10-23 09:32:40 -05:00
|
|
|
|
|
|
|
// Find case to insert into
|
2019-01-16 03:51:43 -06:00
|
|
|
if (existingEclipseContourMap)
|
2018-11-09 04:44:03 -06:00
|
|
|
{
|
2019-01-16 03:51:43 -06:00
|
|
|
eclipseContourMap = createEclipseContourMapFromExistingContourMap(eclipseCase, existingEclipseContourMap);
|
2018-11-09 04:44:03 -06:00
|
|
|
}
|
|
|
|
else if (reservoirView)
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2019-01-16 03:51:43 -06:00
|
|
|
eclipseContourMap = createEclipseContourMapFrom3dView(eclipseCase, reservoirView);
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
|
|
|
else if (eclipseCase)
|
|
|
|
{
|
2019-01-16 03:51:43 -06:00
|
|
|
eclipseContourMap = createEclipseContourMap(eclipseCase);
|
|
|
|
}
|
|
|
|
else if (existingGeoMechContourMap)
|
|
|
|
{
|
|
|
|
geoMechContourMap = createGeoMechContourMapFromExistingContourMap(geoMechCase, existingGeoMechContourMap);
|
|
|
|
}
|
|
|
|
else if (geoMechView)
|
|
|
|
{
|
|
|
|
geoMechContourMap = createGeoMechContourMapFrom3dView(geoMechCase, geoMechView);
|
|
|
|
}
|
|
|
|
else if (geoMechCase)
|
|
|
|
{
|
|
|
|
geoMechContourMap = createGeoMechContourMap(geoMechCase);
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
|
|
|
|
2019-01-16 03:51:43 -06:00
|
|
|
if (eclipseContourMap)
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
|
|
|
// Must be run before buildViewItems, as wells are created in this function
|
2019-01-16 03:51:43 -06:00
|
|
|
eclipseContourMap->loadDataAndUpdate();
|
2018-10-23 09:32:40 -05:00
|
|
|
|
|
|
|
if (eclipseCase)
|
|
|
|
{
|
|
|
|
eclipseCase->updateConnectedEditors();
|
|
|
|
}
|
2019-01-16 03:51:43 -06:00
|
|
|
caf::SelectionManager::instance()->setSelectedItem(eclipseContourMap);
|
2018-11-09 04:44:03 -06:00
|
|
|
|
2019-01-16 03:51:43 -06:00
|
|
|
eclipseContourMap->createDisplayModelAndRedraw();
|
|
|
|
eclipseContourMap->zoomAll();
|
2018-11-09 04:44:03 -06:00
|
|
|
|
2019-01-16 03:51:43 -06:00
|
|
|
Riu3DMainWindowTools::setExpanded(eclipseContourMap);
|
|
|
|
}
|
|
|
|
else if (geoMechContourMap)
|
|
|
|
{
|
|
|
|
geoMechContourMap->loadDataAndUpdate();
|
|
|
|
if (geoMechCase)
|
|
|
|
{
|
|
|
|
geoMechCase->updateConnectedEditors();
|
|
|
|
caf::SelectionManager::instance()->setSelectedItem(geoMechContourMap);
|
|
|
|
geoMechContourMap->createDisplayModelAndRedraw();
|
|
|
|
geoMechContourMap->zoomAll();
|
|
|
|
Riu3DMainWindowTools::setExpanded(geoMechContourMap);
|
|
|
|
}
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-09 05:48:56 -06:00
|
|
|
///
|
2018-10-23 09:32:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-11-09 02:04:40 -06:00
|
|
|
void RicNewContourMapViewFeature::setupActionLook(QAction* actionToSetup)
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2019-01-16 03:51:43 -06:00
|
|
|
bool contourMapSelected = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapView>() != nullptr ||
|
|
|
|
caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechContourMapView>() != nullptr;
|
|
|
|
|
|
|
|
bool viewSelected = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>() != nullptr ||
|
|
|
|
caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechView>() != nullptr;
|
|
|
|
|
|
|
|
if (contourMapSelected)
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
|
|
|
actionToSetup->setText("Duplicate Contour Map");
|
|
|
|
}
|
2019-01-16 03:51:43 -06:00
|
|
|
else if (viewSelected)
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
|
|
|
actionToSetup->setText("New Contour Map From 3d View");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
actionToSetup->setText("New Contour Map");
|
|
|
|
}
|
2018-10-30 11:26:30 -05:00
|
|
|
actionToSetup->setIcon(QIcon(":/2DMap16x16.png"));
|
2019-01-09 05:48:56 -06:00
|
|
|
}
|
2018-11-08 09:18:03 -06:00
|
|
|
|
2018-11-09 04:44:03 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-16 03:51:43 -06:00
|
|
|
RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFromExistingContourMap(RimEclipseCase* eclipseCase,
|
2019-01-11 06:56:35 -06:00
|
|
|
RimEclipseContourMapView* existingContourMap)
|
2018-11-09 04:44:03 -06:00
|
|
|
{
|
2019-01-11 06:56:35 -06:00
|
|
|
RimEclipseContourMapView* contourMap = dynamic_cast<RimEclipseContourMapView*>(
|
2019-01-09 05:48:56 -06:00
|
|
|
existingContourMap->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
2018-11-09 04:44:03 -06:00
|
|
|
CVF_ASSERT(contourMap);
|
|
|
|
|
|
|
|
contourMap->setEclipseCase(eclipseCase);
|
|
|
|
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f)); // Ignore original view background
|
|
|
|
|
|
|
|
caf::PdmDocument::updateUiIconStateRecursively(contourMap);
|
|
|
|
|
|
|
|
size_t i = eclipseCase->contourMapCollection()->views().size();
|
|
|
|
contourMap->setName(QString("Contour Map %1").arg(i + 1));
|
|
|
|
eclipseCase->contourMapCollection()->push_back(contourMap);
|
|
|
|
|
|
|
|
// Resolve references after contour map has been inserted into Rim structures
|
|
|
|
contourMap->resolveReferencesRecursively();
|
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
|
|
|
|
return contourMap;
|
|
|
|
}
|
|
|
|
|
2018-11-08 09:18:03 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-16 03:51:43 -06:00
|
|
|
RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFrom3dView(RimEclipseCase* eclipseCase,
|
2019-01-09 05:48:56 -06:00
|
|
|
const RimEclipseView* sourceView)
|
2018-11-08 09:18:03 -06:00
|
|
|
{
|
2019-01-11 06:56:35 -06:00
|
|
|
RimEclipseContourMapView* contourMap = dynamic_cast<RimEclipseContourMapView*>(sourceView->xmlCapability()->copyAndCastByXmlSerialization(
|
|
|
|
RimEclipseContourMapView::classKeywordStatic(), sourceView->classKeyword(), caf::PdmDefaultObjectFactory::instance()));
|
2018-11-08 09:18:03 -06:00
|
|
|
CVF_ASSERT(contourMap);
|
|
|
|
|
|
|
|
contourMap->setEclipseCase(eclipseCase);
|
|
|
|
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f)); // Ignore original view background
|
2018-12-14 06:41:35 -06:00
|
|
|
contourMap->setDefaultCustomName();
|
2019-01-09 05:48:42 -06:00
|
|
|
contourMap->faultCollection()->showFaultCollection = false;
|
2019-01-09 05:48:56 -06:00
|
|
|
contourMap->wellCollection()->isActive = false;
|
2018-11-08 09:18:03 -06:00
|
|
|
|
|
|
|
caf::PdmDocument::updateUiIconStateRecursively(contourMap);
|
|
|
|
|
|
|
|
eclipseCase->contourMapCollection()->push_back(contourMap);
|
|
|
|
|
2018-12-04 07:33:14 -06:00
|
|
|
contourMap->syncronizeLocalAnnotationsFromGlobal();
|
|
|
|
|
2018-11-08 09:18:03 -06:00
|
|
|
// Resolve references after contour map has been inserted into Rim structures
|
2018-12-04 07:33:14 -06:00
|
|
|
std::vector<caf::PdmFieldHandle*> fieldsWithFailingResolve;
|
|
|
|
contourMap->resolveReferencesRecursively(&fieldsWithFailingResolve);
|
2018-12-05 00:36:57 -06:00
|
|
|
|
2018-12-13 07:28:14 -06:00
|
|
|
// TODO: Introduce the assert when code is stable
|
|
|
|
// If we have intersections on well paths, the resolving is now failing
|
2019-01-09 05:48:56 -06:00
|
|
|
// CVF_ASSERT(fieldsWithFailingResolve.empty());
|
2018-12-04 07:33:14 -06:00
|
|
|
|
2018-11-08 09:18:03 -06:00
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
|
|
|
|
return contourMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-16 03:51:43 -06:00
|
|
|
RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMap(RimEclipseCase* eclipseCase)
|
2018-11-08 09:18:03 -06:00
|
|
|
{
|
2019-01-11 06:56:35 -06:00
|
|
|
RimEclipseContourMapView* contourMap = new RimEclipseContourMapView();
|
2018-11-08 09:18:03 -06:00
|
|
|
contourMap->setEclipseCase(eclipseCase);
|
|
|
|
|
|
|
|
// Set default values
|
|
|
|
{
|
|
|
|
contourMap->cellResult()->setResultType(RiaDefines::DYNAMIC_NATIVE);
|
|
|
|
|
|
|
|
if (RiaApplication::instance()->preferences()->loadAndShowSoil)
|
|
|
|
{
|
|
|
|
contourMap->cellResult()->setResultVariable("SOIL");
|
2019-01-09 05:48:56 -06:00
|
|
|
}
|
2018-11-08 09:18:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
caf::PdmDocument::updateUiIconStateRecursively(contourMap);
|
|
|
|
|
|
|
|
size_t i = eclipseCase->contourMapCollection()->views().size();
|
|
|
|
contourMap->setName(QString("Contour Map %1").arg(i + 1));
|
|
|
|
eclipseCase->contourMapCollection()->push_back(contourMap);
|
|
|
|
|
2018-11-14 05:53:44 -06:00
|
|
|
contourMap->hasUserRequestedAnimation = true;
|
|
|
|
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f));
|
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
|
2018-11-08 09:18:03 -06:00
|
|
|
return contourMap;
|
|
|
|
}
|
2019-01-16 03:51:43 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGeoMechContourMapView*
|
|
|
|
RicNewContourMapViewFeature::createGeoMechContourMapFromExistingContourMap(RimGeoMechCase* geoMechCase,
|
|
|
|
RimGeoMechContourMapView* existingContourMap)
|
|
|
|
{
|
|
|
|
RimGeoMechContourMapView* contourMap = dynamic_cast<RimGeoMechContourMapView*>(
|
|
|
|
existingContourMap->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
|
|
|
CVF_ASSERT(contourMap);
|
|
|
|
|
|
|
|
contourMap->setGeoMechCase(geoMechCase);
|
|
|
|
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f)); // Ignore original view background
|
|
|
|
|
|
|
|
caf::PdmDocument::updateUiIconStateRecursively(contourMap);
|
|
|
|
|
|
|
|
size_t i = geoMechCase->contourMapCollection()->views().size();
|
|
|
|
contourMap->setName(QString("Contour Map %1").arg(i + 1));
|
|
|
|
geoMechCase->contourMapCollection()->push_back(contourMap);
|
|
|
|
|
|
|
|
// Resolve references after contour map has been inserted into Rim structures
|
|
|
|
contourMap->resolveReferencesRecursively();
|
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
|
|
|
|
return contourMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGeoMechContourMapView* RicNewContourMapViewFeature::createGeoMechContourMapFrom3dView(RimGeoMechCase* geoMechCase,
|
|
|
|
const RimGeoMechView* sourceView)
|
|
|
|
{
|
|
|
|
RimGeoMechContourMapView* contourMap = dynamic_cast<RimGeoMechContourMapView*>(
|
|
|
|
sourceView->xmlCapability()->copyAndCastByXmlSerialization(RimGeoMechContourMapView::classKeywordStatic(),
|
|
|
|
sourceView->classKeyword(),
|
|
|
|
caf::PdmDefaultObjectFactory::instance()));
|
|
|
|
CVF_ASSERT(contourMap);
|
|
|
|
|
|
|
|
contourMap->setGeoMechCase(geoMechCase);
|
|
|
|
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f)); // Ignore original view background
|
|
|
|
contourMap->setDefaultCustomName();
|
|
|
|
|
|
|
|
caf::PdmDocument::updateUiIconStateRecursively(contourMap);
|
|
|
|
|
|
|
|
geoMechCase->contourMapCollection()->push_back(contourMap);
|
|
|
|
|
|
|
|
// Resolve references after contour map has been inserted into Rim structures
|
|
|
|
std::vector<caf::PdmFieldHandle*> fieldsWithFailingResolve;
|
|
|
|
contourMap->resolveReferencesRecursively(&fieldsWithFailingResolve);
|
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
|
|
|
|
return contourMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimGeoMechContourMapView* RicNewContourMapViewFeature::createGeoMechContourMap(RimGeoMechCase* geoMechCase)
|
|
|
|
{
|
|
|
|
RimGeoMechContourMapView* contourMap = new RimGeoMechContourMapView();
|
|
|
|
contourMap->setGeoMechCase(geoMechCase);
|
|
|
|
|
|
|
|
caf::PdmDocument::updateUiIconStateRecursively(contourMap);
|
|
|
|
|
|
|
|
size_t i = geoMechCase->contourMapCollection()->views().size();
|
|
|
|
contourMap->setName(QString("Contour Map %1").arg(i + 1));
|
|
|
|
geoMechCase->contourMapCollection()->push_back(contourMap);
|
|
|
|
|
|
|
|
contourMap->hasUserRequestedAnimation = true;
|
|
|
|
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f));
|
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
|
|
|
|
return contourMap;
|
|
|
|
}
|