2018-10-23 09:32:40 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2018- Equinor ASA
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-11-09 02:04:40 -06:00
|
|
|
#include "RicNewContourMapViewFeature.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
|
2018-11-09 02:04:40 -06:00
|
|
|
#include "RimContourMapView.h"
|
|
|
|
#include "RimContourMapViewCollection.h"
|
2018-11-08 09:18:03 -06:00
|
|
|
#include "RimCellEdgeColors.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
#include "RimEclipseView.h"
|
|
|
|
#include "RimEclipseCase.h"
|
2018-11-08 09:18:03 -06:00
|
|
|
#include "RimEclipseCellColors.h"
|
2018-10-23 09:32:40 -05:00
|
|
|
#include "Rim3dView.h"
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-11-09 02:04:40 -06:00
|
|
|
bool RicNewContourMapViewFeature::isCommandEnabled()
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
|
|
|
bool selectedView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>() != nullptr;
|
|
|
|
bool selectedCase = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCase>() != nullptr;
|
2018-11-09 02:04:40 -06:00
|
|
|
bool selectedMapCollection = caf::SelectionManager::instance()->selectedItemOfType<RimContourMapViewCollection>();
|
2018-10-23 09:32:40 -05:00
|
|
|
return selectedView || selectedCase || selectedMapCollection;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-11-09 02:04:40 -06:00
|
|
|
void RicNewContourMapViewFeature::onActionTriggered(bool isChecked)
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
|
|
|
RimEclipseView* reservoirView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
|
|
|
|
RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimEclipseCase>();
|
2018-11-09 02:04:40 -06:00
|
|
|
RimContourMapView* contourMap = nullptr;
|
2018-10-23 09:32:40 -05:00
|
|
|
|
|
|
|
// Find case to insert into
|
|
|
|
if (reservoirView)
|
|
|
|
{
|
2018-11-08 09:18:03 -06:00
|
|
|
contourMap = create2dContourMapFrom3dView(eclipseCase, reservoirView);
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
|
|
|
else if (eclipseCase)
|
|
|
|
{
|
2018-11-08 09:18:03 -06:00
|
|
|
contourMap = create2dContourMap(eclipseCase);
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (contourMap)
|
|
|
|
{
|
|
|
|
// Must be run before buildViewItems, as wells are created in this function
|
|
|
|
contourMap->loadDataAndUpdate();
|
|
|
|
|
|
|
|
if (eclipseCase)
|
|
|
|
{
|
|
|
|
eclipseCase->updateConnectedEditors();
|
|
|
|
}
|
|
|
|
caf::SelectionManager::instance()->setSelectedItem(contourMap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-11-09 02:04:40 -06:00
|
|
|
void RicNewContourMapViewFeature::setupActionLook(QAction* actionToSetup)
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2018-11-09 02:04:40 -06:00
|
|
|
RimContourMapView* contourMap = caf::SelectionManager::instance()->selectedItemOfType<RimContourMapView>();
|
2018-10-23 09:32:40 -05:00
|
|
|
RimEclipseView* eclipseView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
|
|
|
|
if (contourMap)
|
|
|
|
{
|
|
|
|
actionToSetup->setText("Duplicate Contour Map");
|
|
|
|
}
|
|
|
|
else if (eclipseView)
|
|
|
|
{
|
|
|
|
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"));
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
2018-11-08 09:18:03 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-11-09 02:04:40 -06:00
|
|
|
RimContourMapView* RicNewContourMapViewFeature::create2dContourMapFrom3dView(RimEclipseCase* eclipseCase, const RimEclipseView* sourceView)
|
2018-11-08 09:18:03 -06:00
|
|
|
{
|
2018-11-09 02:04:40 -06:00
|
|
|
RimContourMapView* contourMap = dynamic_cast<RimContourMapView*>(sourceView->xmlCapability()->copyAndCastByXmlSerialization(
|
|
|
|
RimContourMapView::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
|
|
|
|
|
|
|
|
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-09 02:04:40 -06:00
|
|
|
RimContourMapView* RicNewContourMapViewFeature::create2dContourMap(RimEclipseCase* eclipseCase)
|
2018-11-08 09:18:03 -06:00
|
|
|
{
|
2018-11-09 02:04:40 -06:00
|
|
|
RimContourMapView* contourMap = new RimContourMapView();
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
contourMap->hasUserRequestedAnimation = true;
|
|
|
|
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f));
|
|
|
|
contourMap->initAfterReadRecursively();
|
|
|
|
contourMap->zoomAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
return contourMap;
|
|
|
|
}
|