mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#867 Added paste of summary plot
This commit is contained in:
parent
8821d231e5
commit
032b16ea3f
@ -37,23 +37,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace caf
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicPasteFeatureImpl::populateObjectGroupFromReferences(const std::vector<QString>& referenceList, caf::PdmObjectGroup* objectGroup)
|
void RicPasteFeatureImpl::populateObjectGroupFromReferences(const std::vector<QString>& referenceList, caf::PdmObjectGroup* objectGroup)
|
||||||
{
|
{
|
||||||
PdmObjectHandle* referenceRoot = RiaApplication::instance()->project();
|
caf::PdmObjectHandle* referenceRoot = RiaApplication::instance()->project();
|
||||||
|
|
||||||
for (size_t i = 0; i < referenceList.size(); i++)
|
for (size_t i = 0; i < referenceList.size(); i++)
|
||||||
{
|
{
|
||||||
QString reference = referenceList[i];
|
QString reference = referenceList[i];
|
||||||
|
|
||||||
PdmObjectHandle* pdmObj = PdmReferenceHelper::objectFromReference(referenceRoot, reference);
|
caf::PdmObjectHandle* pdmObj = caf::PdmReferenceHelper::objectFromReference(referenceRoot, reference);
|
||||||
if (pdmObj)
|
if (pdmObj)
|
||||||
{
|
{
|
||||||
objectGroup->objects.push_back(pdmObj);
|
objectGroup->objects.push_back(pdmObj);
|
||||||
@ -89,7 +84,7 @@ void RicPasteFeatureImpl::findObjectsFromClipboardRefs(caf::PdmObjectGroup* obje
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RimIdenticalGridCaseGroup* RicPasteFeatureImpl::findGridCaseGroup(PdmObjectHandle* objectHandle)
|
RimIdenticalGridCaseGroup* RicPasteFeatureImpl::findGridCaseGroup(caf::PdmObjectHandle* objectHandle)
|
||||||
{
|
{
|
||||||
if (dynamic_cast<RimIdenticalGridCaseGroup*>(objectHandle))
|
if (dynamic_cast<RimIdenticalGridCaseGroup*>(objectHandle))
|
||||||
{
|
{
|
||||||
@ -110,7 +105,7 @@ RimIdenticalGridCaseGroup* RicPasteFeatureImpl::findGridCaseGroup(PdmObjectHandl
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RimEclipseCase* RicPasteFeatureImpl::findEclipseCase(PdmObjectHandle* objectHandle)
|
RimEclipseCase* RicPasteFeatureImpl::findEclipseCase(caf::PdmObjectHandle* objectHandle)
|
||||||
{
|
{
|
||||||
if (dynamic_cast<RimEclipseCase*>(objectHandle))
|
if (dynamic_cast<RimEclipseCase*>(objectHandle))
|
||||||
{
|
{
|
||||||
@ -129,7 +124,7 @@ RimEclipseCase* RicPasteFeatureImpl::findEclipseCase(PdmObjectHandle* objectHand
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RimGeoMechCase* RicPasteFeatureImpl::findGeoMechCase(PdmObjectHandle* objectHandle)
|
RimGeoMechCase* RicPasteFeatureImpl::findGeoMechCase(caf::PdmObjectHandle* objectHandle)
|
||||||
{
|
{
|
||||||
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(objectHandle);
|
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(objectHandle);
|
||||||
if (!geomCase)
|
if (!geomCase)
|
||||||
@ -140,5 +135,3 @@ RimGeoMechCase* RicPasteFeatureImpl::findGeoMechCase(PdmObjectHandle* objectHand
|
|||||||
|
|
||||||
return geomCase;
|
return geomCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace caf
|
|
||||||
|
@ -31,9 +31,9 @@ class RimIdenticalGridCaseGroup;
|
|||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
|
class PdmObjectGroup;
|
||||||
class PdmObjectGroup;
|
class PdmObjectHandle;
|
||||||
class PdmObjectHandle;
|
}
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@ -43,9 +43,9 @@ class RicPasteFeatureImpl
|
|||||||
public:
|
public:
|
||||||
static void findObjectsFromClipboardRefs(caf::PdmObjectGroup* objectGroup);
|
static void findObjectsFromClipboardRefs(caf::PdmObjectGroup* objectGroup);
|
||||||
|
|
||||||
static RimIdenticalGridCaseGroup* findGridCaseGroup(PdmObjectHandle* objectHandle);
|
static RimIdenticalGridCaseGroup* findGridCaseGroup(caf::PdmObjectHandle* objectHandle);
|
||||||
static RimEclipseCase* findEclipseCase(PdmObjectHandle* objectHandle);
|
static RimEclipseCase* findEclipseCase(caf::PdmObjectHandle* objectHandle);
|
||||||
static RimGeoMechCase* findGeoMechCase(PdmObjectHandle* objectHandle);
|
static RimGeoMechCase* findGeoMechCase(caf::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);
|
||||||
@ -54,4 +54,3 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace caf
|
|
||||||
|
@ -11,6 +11,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.h
|
|||||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.h
|
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h
|
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.h
|
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
@ -19,6 +20,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.cpp
|
|||||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
|
@ -0,0 +1,108 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016- Statoil 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.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "RicPasteSummaryPlotFeature.h"
|
||||||
|
|
||||||
|
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
|
||||||
|
|
||||||
|
#include "RimSummaryPlot.h"
|
||||||
|
|
||||||
|
#include "cafPdmDefaultObjectFactory.h"
|
||||||
|
#include "cafPdmDocument.h"
|
||||||
|
#include "cafPdmObjectGroup.h"
|
||||||
|
#include "cafPdmObjectGroup.h"
|
||||||
|
|
||||||
|
#include "cvfAssert.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include "RimSummaryPlotCollection.h"
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT(RicPasteSummaryPlotFeature, "RicPasteSummaryPlotFeature");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicPasteSummaryPlotFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
|
||||||
|
|
||||||
|
RimSummaryPlotCollection* plotColl = nullptr;
|
||||||
|
destinationObject->firstAncestorOrThisOfType(plotColl);
|
||||||
|
if (!plotColl)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RicPasteSummaryPlotFeature::summaryPlots().size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicPasteSummaryPlotFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
|
||||||
|
|
||||||
|
RimSummaryPlotCollection* plotColl = nullptr;
|
||||||
|
destinationObject->firstAncestorOrThisOfType(plotColl);
|
||||||
|
if (!plotColl)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<caf::PdmPointer<RimSummaryPlot> > sourceObjects = RicPasteSummaryPlotFeature::summaryPlots();
|
||||||
|
|
||||||
|
for (size_t i = 0; i < sourceObjects.size(); i++)
|
||||||
|
{
|
||||||
|
RimSummaryPlot* newSummaryPlot = dynamic_cast<RimSummaryPlot*>(sourceObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||||
|
CVF_ASSERT(newSummaryPlot);
|
||||||
|
|
||||||
|
QString nameOfCopy = QString("Copy of ") + newSummaryPlot->description();
|
||||||
|
newSummaryPlot->setDescription(nameOfCopy);
|
||||||
|
|
||||||
|
plotColl->m_summaryPlots.push_back(newSummaryPlot);
|
||||||
|
plotColl->updateConnectedEditors();
|
||||||
|
|
||||||
|
newSummaryPlot->loadDataAndUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicPasteSummaryPlotFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Paste Summary Plot");
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<caf::PdmPointer<RimSummaryPlot> > RicPasteSummaryPlotFeature::summaryPlots()
|
||||||
|
{
|
||||||
|
caf::PdmObjectGroup objectGroup;
|
||||||
|
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
|
||||||
|
|
||||||
|
std::vector<caf::PdmPointer<RimSummaryPlot> > typedObjects;
|
||||||
|
objectGroup.objectsByType(&typedObjects);
|
||||||
|
|
||||||
|
return typedObjects;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016- Statoil 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 "cafCmdFeature.h"
|
||||||
|
|
||||||
|
class RimSummaryPlot;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicPasteSummaryPlotFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Overrides
|
||||||
|
virtual bool isCommandEnabled() override;
|
||||||
|
virtual void onActionTriggered( bool isChecked ) override;
|
||||||
|
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::vector<caf::PdmPointer<RimSummaryPlot> > summaryPlots();
|
||||||
|
};
|
@ -249,6 +249,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
|||||||
else if (dynamic_cast<RimSummaryPlotCollection*>(uiItem))
|
else if (dynamic_cast<RimSummaryPlotCollection*>(uiItem))
|
||||||
{
|
{
|
||||||
commandIds << "RicNewSummaryPlotFeature";
|
commandIds << "RicNewSummaryPlotFeature";
|
||||||
|
commandIds << "RicPasteSummaryPlotFeature";
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<RimWellLogPlot*>(uiItem))
|
else if (dynamic_cast<RimWellLogPlot*>(uiItem))
|
||||||
{
|
{
|
||||||
@ -275,6 +276,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
|||||||
commandIds << "RicViewZoomAllFeature";
|
commandIds << "RicViewZoomAllFeature";
|
||||||
commandIds << "Separator";
|
commandIds << "Separator";
|
||||||
commandIds << "RicDeleteItemFeature";
|
commandIds << "RicDeleteItemFeature";
|
||||||
|
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<RimSummaryCurve*>(uiItem))
|
else if (dynamic_cast<RimSummaryCurve*>(uiItem))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user