2019-08-23 04:25:00 -05:00
|
|
|
#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()
|
|
|
|
{
|
2019-08-26 02:57:50 -05:00
|
|
|
RimProject* project = RiaApplication::instance()->project();
|
|
|
|
std::vector<Rim3dView*> allViews;
|
|
|
|
project->descendantsIncludingThisOfType(allViews);
|
2019-08-23 04:25:00 -05:00
|
|
|
|
|
|
|
for (Rim3dView* view : allViews)
|
|
|
|
{
|
2019-08-26 02:57:50 -05:00
|
|
|
if (view->id() == m_viewId())
|
|
|
|
{
|
|
|
|
const RimEclipseView* eclipseView = dynamic_cast<const RimEclipseView*>(view);
|
|
|
|
const RimGeoMechView* geoMechView = dynamic_cast<const RimGeoMechView*>(view);
|
2019-08-23 04:25:00 -05:00
|
|
|
|
2019-08-26 02:57:50 -05:00
|
|
|
int newViewId = -1;
|
|
|
|
if (eclipseView)
|
|
|
|
{
|
|
|
|
RimEclipseCase* eclipseCase = eclipseView->eclipseCase();
|
|
|
|
RimEclipseView* newEclipseView = eclipseCase->createCopyAndAddView(eclipseView);
|
|
|
|
newViewId = newEclipseView->id();
|
2019-08-23 04:25:00 -05:00
|
|
|
newEclipseView->loadDataAndUpdate();
|
|
|
|
eclipseCase->updateConnectedEditors();
|
|
|
|
Riu3DMainWindowTools::setExpanded(newEclipseView);
|
2019-08-26 02:57:50 -05:00
|
|
|
}
|
|
|
|
else if (geoMechView)
|
|
|
|
{
|
|
|
|
RimGeoMechCase* geoMechCase = geoMechView->geoMechCase();
|
|
|
|
RimGeoMechView* newGeoMechView = geoMechCase->createCopyAndAddView(geoMechView);
|
|
|
|
newViewId = newGeoMechView->id();
|
2019-08-23 04:25:00 -05:00
|
|
|
view->loadDataAndUpdate();
|
|
|
|
geoMechCase->updateConnectedEditors();
|
|
|
|
Riu3DMainWindowTools::setExpanded(view);
|
2019-08-26 02:57:50 -05:00
|
|
|
}
|
2019-08-23 04:25:00 -05:00
|
|
|
|
2019-08-26 03:01:40 -05:00
|
|
|
if (newViewId >= 0)
|
2019-08-26 02:57:50 -05:00
|
|
|
{
|
2019-08-23 04:25:00 -05:00
|
|
|
RicfCommandResponse response;
|
|
|
|
response.setResult(new RicfCreateViewResult(newViewId));
|
|
|
|
return response;
|
2019-08-26 02:57:50 -05:00
|
|
|
}
|
|
|
|
}
|
2019-08-23 04:25:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
QString error = QString("cloneView: Could not clone view with id %1").arg(m_viewId());
|
|
|
|
RiaLogging::error(error);
|
|
|
|
return RicfCommandResponse(RicfCommandResponse::COMMAND_ERROR, error);
|
|
|
|
}
|