mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#868 Added paste of curve
This commit is contained in:
parent
009df71913
commit
60d64fbe77
@ -12,6 +12,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteCurveFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -21,6 +22,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteCurveFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,111 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicPasteCurveFeature.h"
|
||||
|
||||
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
|
||||
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "cafPdmDefaultObjectFactory.h"
|
||||
#include "cafPdmDocument.h"
|
||||
#include "cafPdmObjectGroup.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QAction>
|
||||
#include "RimSummaryCurve.h"
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicPasteCurveFeature, "RicPasteCurveFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPasteCurveFeature::isCommandEnabled()
|
||||
{
|
||||
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
destinationObject->firstAncestorOrThisOfType(summaryPlot);
|
||||
if (!summaryPlot)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return RicPasteCurveFeature::summaryCurves().size() > 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteCurveFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
destinationObject->firstAncestorOrThisOfType(summaryPlot);
|
||||
if (!summaryPlot)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<caf::PdmPointer<RimSummaryCurve> > sourceObjects = RicPasteCurveFeature::summaryCurves();
|
||||
|
||||
for (size_t i = 0; i < sourceObjects.size(); i++)
|
||||
{
|
||||
RimSummaryCurve* newObject = dynamic_cast<RimSummaryCurve*>(sourceObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
CVF_ASSERT(newObject);
|
||||
|
||||
summaryPlot->addCurve(newObject);
|
||||
|
||||
// Resolve references after object has been inserted into the project data model
|
||||
newObject->resolveReferencesRecursively();
|
||||
newObject->initAfterReadRecursively();
|
||||
|
||||
newObject->loadDataAndUpdate();
|
||||
newObject->updateConnectedEditors();
|
||||
|
||||
summaryPlot->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteCurveFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Paste Summary Curve");
|
||||
actionToSetup->setIcon(QIcon(":/SummaryCurve16x16.png"));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<caf::PdmPointer<RimSummaryCurve> > RicPasteCurveFeature::summaryCurves()
|
||||
{
|
||||
caf::PdmObjectGroup objectGroup;
|
||||
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
|
||||
|
||||
std::vector<caf::PdmPointer<RimSummaryCurve> > 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 RimSummaryCurve;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicPasteCurveFeature : 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<RimSummaryCurve> > summaryCurves();
|
||||
};
|
@ -277,6 +277,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
commandIds << "Separator";
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||
commandIds << "RicPasteCurveFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimSummaryCurve*>(uiItem))
|
||||
{
|
||||
@ -285,6 +286,8 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
commandIds << "RicSummaryCurveSwitchAxisFeature";
|
||||
commandIds << "Separator";
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||
commandIds << "RicPasteCurveFeature";
|
||||
}
|
||||
else if(dynamic_cast<RimSummaryCurveFilter*>(uiItem))
|
||||
{
|
||||
|
@ -372,6 +372,7 @@ void RimSummaryCurve::onLoadDataAndUpdate()
|
||||
if (allAddresses[i].uiText() == m_curveVariable->address().uiText())
|
||||
{
|
||||
m_uiFilterResultSelection = static_cast<int>(i);
|
||||
updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user