mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added paste of geo mech views feature
This commit is contained in:
@@ -10,6 +10,7 @@ ${CEE_CURRENT_LIST_DIR}RicPasteFeatureImpl.h
|
|||||||
|
|
||||||
${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.h
|
${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicPasteEclipseViewsFeature.h
|
${CEE_CURRENT_LIST_DIR}RicPasteEclipseViewsFeature.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicPasteGeoMechViewsFeature.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
@@ -18,6 +19,7 @@ ${CEE_CURRENT_LIST_DIR}RicPasteFeatureImpl.cpp
|
|||||||
|
|
||||||
${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicPasteEclipseViewsFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicPasteEclipseViewsFeature.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicPasteGeoMechViewsFeature.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include "RimCaseCollection.h"
|
#include "RimCaseCollection.h"
|
||||||
#include "RimEclipseCase.h"
|
#include "RimEclipseCase.h"
|
||||||
|
#include "RimGeoMechCase.h"
|
||||||
|
#include "RimGeoMechView.h"
|
||||||
#include "RimIdenticalGridCaseGroup.h"
|
#include "RimIdenticalGridCaseGroup.h"
|
||||||
#include "RimMimeData.h"
|
#include "RimMimeData.h"
|
||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
@@ -124,4 +126,19 @@ RimEclipseCase* RicPasteFeatureImpl::findEclipseCase(PdmObjectHandle* objectHand
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RimGeoMechCase* RicPasteFeatureImpl::findGeoMechCase(PdmObjectHandle* objectHandle)
|
||||||
|
{
|
||||||
|
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(objectHandle);
|
||||||
|
if (!geomCase)
|
||||||
|
{
|
||||||
|
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(objectHandle);
|
||||||
|
if (geomView) geomCase = geomView->geoMechCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
return geomCase;
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace caf
|
} // end namespace caf
|
||||||
|
|||||||
@@ -25,8 +25,9 @@
|
|||||||
|
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
class RimIdenticalGridCaseGroup;
|
|
||||||
class RimEclipseCase;
|
class RimEclipseCase;
|
||||||
|
class RimGeoMechCase;
|
||||||
|
class RimIdenticalGridCaseGroup;
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
@@ -44,7 +45,7 @@ public:
|
|||||||
|
|
||||||
static RimIdenticalGridCaseGroup* findGridCaseGroup(PdmObjectHandle* objectHandle);
|
static RimIdenticalGridCaseGroup* findGridCaseGroup(PdmObjectHandle* objectHandle);
|
||||||
static RimEclipseCase* findEclipseCase(PdmObjectHandle* objectHandle);
|
static RimEclipseCase* findEclipseCase(PdmObjectHandle* objectHandle);
|
||||||
|
static RimGeoMechCase* findGeoMechCase(PdmObjectHandle* objectHandle);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void populateObjectGroupFromReferences(const std::vector<QString>& referenceList, caf::PdmObjectGroup* objectGroup);
|
static void populateObjectGroupFromReferences(const std::vector<QString>& referenceList, caf::PdmObjectGroup* objectGroup);
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RicPasteGeoMechViewsFeature.h"
|
||||||
|
|
||||||
|
#include "RicPasteFeatureImpl.h"
|
||||||
|
|
||||||
|
#include "RimGeoMechView.h"
|
||||||
|
#include "RimGeoMechCase.h"
|
||||||
|
|
||||||
|
#include "cafPdmDocument.h"
|
||||||
|
#include "cafPdmObjectGroup.h"
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT(RicPasteGeoMechViewsFeature, "RicPasteGeoMechViewsFeature");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicPasteGeoMechViewsFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
PdmObjectGroup objectGroup;
|
||||||
|
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
|
||||||
|
|
||||||
|
std::vector<caf::PdmPointer<RimGeoMechView> > typedObjects;
|
||||||
|
objectGroup.objectsByType(&typedObjects);
|
||||||
|
|
||||||
|
if (typedObjects.size() == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
|
||||||
|
|
||||||
|
RimGeoMechCase* geoMechCase = RicPasteFeatureImpl::findGeoMechCase(destinationObject);
|
||||||
|
if (geoMechCase) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicPasteGeoMechViewsFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
|
||||||
|
|
||||||
|
RimGeoMechCase* geomCase = RicPasteFeatureImpl::findGeoMechCase(destinationObject);
|
||||||
|
assert(geomCase);
|
||||||
|
|
||||||
|
PdmObjectGroup objectGroup;
|
||||||
|
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
|
||||||
|
|
||||||
|
if (objectGroup.objects.size() == 0) return;
|
||||||
|
|
||||||
|
std::vector<caf::PdmPointer<RimGeoMechView> > geomViews;
|
||||||
|
objectGroup.createCopyByType(&geomViews, PdmDefaultObjectFactory::instance());
|
||||||
|
|
||||||
|
if (geomViews.size() != 0)
|
||||||
|
{
|
||||||
|
// Add cases to case group
|
||||||
|
for (size_t i = 0; i < geomViews.size(); i++)
|
||||||
|
{
|
||||||
|
RimGeoMechView* rimReservoirView = geomViews[i];
|
||||||
|
QString nameOfCopy = QString("Copy of ") + rimReservoirView->name;
|
||||||
|
rimReservoirView->name = nameOfCopy;
|
||||||
|
geomCase->geoMechViews().push_back(rimReservoirView);
|
||||||
|
|
||||||
|
caf::PdmDocument::initAfterReadTraversal(rimReservoirView);
|
||||||
|
rimReservoirView->setGeoMechCase(geomCase);
|
||||||
|
|
||||||
|
caf::PdmDocument::updateUiIconStateRecursively(rimReservoirView);
|
||||||
|
|
||||||
|
rimReservoirView->loadDataAndUpdate();
|
||||||
|
|
||||||
|
geomCase->updateConnectedEditors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicPasteGeoMechViewsFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Paste (Geo Mech Views)");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // end namespace caf
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicPasteGeoMechViewsFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Overrides
|
||||||
|
virtual bool isCommandEnabled();
|
||||||
|
virtual void onActionTriggered(bool isChecked);
|
||||||
|
virtual void setupActionLook(QAction* actionToSetup);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // end namespace caf
|
||||||
@@ -549,7 +549,18 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
|||||||
|
|
||||||
if (dynamic_cast<RimGeoMechView*>(uiItem))
|
if (dynamic_cast<RimGeoMechView*>(uiItem))
|
||||||
{
|
{
|
||||||
|
//commandIds << "RicEclipseViewNew";
|
||||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||||
|
commandIds << "RicPasteGeoMechViewsFeature";
|
||||||
|
//commandIds << "RicEclipseViewDelete";
|
||||||
|
}
|
||||||
|
else if (dynamic_cast<RimEclipseView*>(uiItem))
|
||||||
|
{
|
||||||
|
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||||
|
commandIds << "RicPasteEclipseViewsFeature";
|
||||||
|
|
||||||
|
commandIds << "RicEclipseViewNew";
|
||||||
|
commandIds << "RicEclipseViewDelete";
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<RimEclipseCase*>(uiItem))
|
else if (dynamic_cast<RimEclipseCase*>(uiItem))
|
||||||
{
|
{
|
||||||
@@ -563,6 +574,12 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
|||||||
commandIds << "RicEclipseCaseNewGroup";
|
commandIds << "RicEclipseCaseNewGroup";
|
||||||
commandIds << "RicEclipseCaseExecuteScript";
|
commandIds << "RicEclipseCaseExecuteScript";
|
||||||
}
|
}
|
||||||
|
else if (dynamic_cast<RimGeoMechCase*>(uiItem))
|
||||||
|
{
|
||||||
|
commandIds << "RicPasteGeoMechViewsFeature";
|
||||||
|
//commandIds << "RicEclipseCaseClose";
|
||||||
|
//commandIds << "RicEclipseCaseNewView";
|
||||||
|
}
|
||||||
else if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem))
|
else if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem))
|
||||||
{
|
{
|
||||||
commandIds << "RicEclipseCaseNewView";
|
commandIds << "RicEclipseCaseNewView";
|
||||||
@@ -574,14 +591,7 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
|||||||
{
|
{
|
||||||
commandIds << "RicPasteEclipseCasesFeature";
|
commandIds << "RicPasteEclipseCasesFeature";
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<RimEclipseView*>(uiItem))
|
|
||||||
{
|
|
||||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
|
||||||
commandIds << "RicPasteEclipseViewsFeature";
|
|
||||||
|
|
||||||
commandIds << "RicEclipseViewNew";
|
|
||||||
commandIds << "RicEclipseViewDelete";
|
|
||||||
}
|
|
||||||
else if (dynamic_cast<RimEclipseCellColors*>(uiItem))
|
else if (dynamic_cast<RimEclipseCellColors*>(uiItem))
|
||||||
{
|
{
|
||||||
commandIds << "RicSaveEclipseResultAsInputProperty";
|
commandIds << "RicSaveEclipseResultAsInputProperty";
|
||||||
|
|||||||
Reference in New Issue
Block a user