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:
@@ -11,6 +11,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.h
|
||||
)
|
||||
|
||||
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}RicViewZoomAllFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.cpp
|
||||
)
|
||||
|
||||
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();
|
||||
};
|
||||
Reference in New Issue
Block a user