mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4578 Add commands for create and clone view
This commit is contained in:
@@ -31,6 +31,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfCreateSaturationPressurePlots.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportFlowCharacteristics.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfCreateGridCaseGroup.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfCreateStatisticsCase.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfCreateView.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfCloneView.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -65,6 +67,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfCreateSaturationPressurePlots.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportFlowCharacteristics.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfCreateGridCaseGroup.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfCreateStatisticsCase.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfCreateView.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfCloneView.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
80
ApplicationCode/CommandFileInterface/RicfCloneView.cpp
Normal file
80
ApplicationCode/CommandFileInterface/RicfCloneView.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "RicfCloneView.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RicfCreateView.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicfCloneView, "cloneView");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfCloneView::RicfCloneView()
|
||||
{
|
||||
RICF_InitField(&m_viewId, "viewId", -1, "View Id", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfCommandResponse RicfCloneView::execute()
|
||||
{
|
||||
RimProject* project = RiaApplication::instance()->project();
|
||||
std::vector<Rim3dView*> allViews;
|
||||
project->descendantsIncludingThisOfType(allViews);
|
||||
|
||||
for (Rim3dView* view : allViews)
|
||||
{
|
||||
if (view->id() == m_viewId())
|
||||
{
|
||||
const RimEclipseView* eclipseView = dynamic_cast<const RimEclipseView*>(view);
|
||||
const RimGeoMechView* geoMechView = dynamic_cast<const RimGeoMechView*>(view);
|
||||
|
||||
int newViewId = -1;
|
||||
if (eclipseView)
|
||||
{
|
||||
RimEclipseCase* eclipseCase = eclipseView->eclipseCase();
|
||||
RimEclipseView* newEclipseView = eclipseCase->createCopyAndAddView(eclipseView);
|
||||
newViewId = newEclipseView->id();
|
||||
newEclipseView->loadDataAndUpdate();
|
||||
eclipseCase->updateConnectedEditors();
|
||||
Riu3DMainWindowTools::setExpanded(newEclipseView);
|
||||
}
|
||||
else if (geoMechView)
|
||||
{
|
||||
RimGeoMechCase* geoMechCase = geoMechView->geoMechCase();
|
||||
RimGeoMechView* newGeoMechView = geoMechCase->createCopyAndAddView(geoMechView);
|
||||
newViewId = newGeoMechView->id();
|
||||
view->loadDataAndUpdate();
|
||||
geoMechCase->updateConnectedEditors();
|
||||
Riu3DMainWindowTools::setExpanded(view);
|
||||
}
|
||||
|
||||
if (newViewId)
|
||||
{
|
||||
RicfCommandResponse response;
|
||||
response.setResult(new RicfCreateViewResult(newViewId));
|
||||
return response;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString error = QString("cloneView: Could not clone view with id %1").arg(m_viewId());
|
||||
RiaLogging::error(error);
|
||||
return RicfCommandResponse(RicfCommandResponse::COMMAND_ERROR, error);
|
||||
}
|
||||
41
ApplicationCode/CommandFileInterface/RicfCloneView.h
Normal file
41
ApplicationCode/CommandFileInterface/RicfCloneView.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RicfCommandObject.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RicfCloneView : public RicfCommandObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicfCloneView();
|
||||
|
||||
RicfCommandResponse execute() override;
|
||||
|
||||
private:
|
||||
caf::PdmField<int> m_viewId;
|
||||
};
|
||||
85
ApplicationCode/CommandFileInterface/RicfCreateView.cpp
Normal file
85
ApplicationCode/CommandFileInterface/RicfCreateView.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
#include "RicfCreateView.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicfCreateViewResult, "createViewResult");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfCreateViewResult::RicfCreateViewResult(int viewId /*= -1*/)
|
||||
{
|
||||
CAF_PDM_InitObject("view_result", "", "", "");
|
||||
CAF_PDM_InitField(&this->viewId, "viewId", viewId, "", "", "", "");
|
||||
}
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicfCreateView, "createView");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfCreateView::RicfCreateView()
|
||||
{
|
||||
RICF_InitField(&m_caseId, "caseId", -1, "Case Id", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicfCommandResponse RicfCreateView::execute()
|
||||
{
|
||||
RimProject* project = RiaApplication::instance()->project();
|
||||
std::vector<RimCase*> allCases;
|
||||
project->allCases(allCases);
|
||||
|
||||
for (RimCase* rimCase : allCases)
|
||||
{
|
||||
if (rimCase->caseId == m_caseId())
|
||||
{
|
||||
int viewId = -1;
|
||||
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(rimCase);
|
||||
RimGeoMechCase* geoMechCase = dynamic_cast<RimGeoMechCase*>(rimCase);
|
||||
if (eclipseCase)
|
||||
{
|
||||
RimEclipseView* view = eclipseCase->createAndAddReservoirView();
|
||||
viewId = view->id();
|
||||
view->loadDataAndUpdate();
|
||||
eclipseCase->updateConnectedEditors();
|
||||
Riu3DMainWindowTools::setExpanded(view);
|
||||
}
|
||||
else if (geoMechCase)
|
||||
{
|
||||
RimGeoMechView* view = geoMechCase->createAndAddReservoirView();
|
||||
viewId = view->id();
|
||||
view->loadDataAndUpdate();
|
||||
geoMechCase->updateConnectedEditors();
|
||||
Riu3DMainWindowTools::setExpanded(view);
|
||||
}
|
||||
|
||||
if (viewId >= 0)
|
||||
{
|
||||
RicfCommandResponse response;
|
||||
response.setResult(new RicfCreateViewResult(viewId));
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString error = QString("createView: Could not create view for case id %1").arg(m_caseId());
|
||||
RiaLogging::error(error);
|
||||
return RicfCommandResponse(RicfCommandResponse::COMMAND_ERROR, error);
|
||||
}
|
||||
52
ApplicationCode/CommandFileInterface/RicfCreateView.h
Normal file
52
ApplicationCode/CommandFileInterface/RicfCreateView.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RicfCommandObject.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
|
||||
class RicfCreateViewResult : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicfCreateViewResult(int viewId = -1);
|
||||
|
||||
public:
|
||||
caf::PdmField<int> viewId;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RicfCreateView : public RicfCommandObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicfCreateView();
|
||||
|
||||
RicfCommandResponse execute() override;
|
||||
|
||||
private:
|
||||
caf::PdmField<int> m_caseId;
|
||||
};
|
||||
@@ -70,7 +70,6 @@ RicfCommandResponse RicfLoadCase::execute()
|
||||
return RicfCommandResponse(RicfCommandResponse::COMMAND_ERROR, error);
|
||||
}
|
||||
CAF_ASSERT(fileCaseIdMap.size() == 1u);
|
||||
RicfLoadCaseResult result;
|
||||
RicfCommandResponse response;
|
||||
response.setResult(new RicfLoadCaseResult(fileCaseIdMap.begin()->second));
|
||||
return response;
|
||||
|
||||
Reference in New Issue
Block a user