mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2840 Ensemble curve. Copy/paste og curve sets
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimFractureTemplate.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimIntersection.h"
|
||||
@@ -167,6 +168,10 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(caf::PdmObject
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (dynamic_cast<RimEnsembleCurveSet*>(pdmObject))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculator.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsembleCurveSetFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPasteEnsembleCurveSetFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -69,6 +70,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculator.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsembleCurveSetFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPasteEnsembleCurveSetFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicPasteEnsembleCurveSetFeature.h"
|
||||
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
|
||||
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
//#include "RimSummaryCurve.h"
|
||||
//#include "RimSummaryCurveFilter.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
//#include "RimSummaryCrossPlot.h"
|
||||
|
||||
#include "cafPdmDefaultObjectFactory.h"
|
||||
#include "cafPdmDocument.h"
|
||||
#include "cafPdmObjectGroup.h"
|
||||
#include "cafSelectionManagerTools.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicPasteEnsembleCurveSetFeature, "RicPasteEnsembleCurveSetFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEnsembleCurveSet* RicPasteEnsembleCurveSetFeature::copyCurveSetAndAddToCollection(RimEnsembleCurveSet *sourceCurveSet)
|
||||
{
|
||||
RimSummaryPlot* plot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot*>();
|
||||
RimEnsembleCurveSetCollection* coll = caf::firstAncestorOfTypeFromSelectedObject<RimEnsembleCurveSetCollection*>();
|
||||
|
||||
RimEnsembleCurveSet* newCurveSet = dynamic_cast<RimEnsembleCurveSet*>(sourceCurveSet->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
CVF_ASSERT(newCurveSet);
|
||||
|
||||
if (!coll) coll = plot->ensembleCurveSets();
|
||||
|
||||
coll->addCurveSet(newCurveSet);
|
||||
|
||||
// Resolve references after object has been inserted into the project data model
|
||||
newCurveSet->resolveReferencesRecursively();
|
||||
newCurveSet->initAfterReadRecursively();
|
||||
newCurveSet->loadDataAndUpdate(true);
|
||||
newCurveSet->updateConnectedEditors();
|
||||
|
||||
coll->updateConnectedEditors();
|
||||
|
||||
return newCurveSet;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPasteEnsembleCurveSetFeature::isCommandEnabled()
|
||||
{
|
||||
caf::PdmObject* destinationObject = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
|
||||
|
||||
RimSummaryPlot* plot;
|
||||
RimEnsembleCurveSetCollection* coll = nullptr;
|
||||
destinationObject->firstAncestorOrThisOfType(plot);
|
||||
destinationObject->firstAncestorOrThisOfType(coll);
|
||||
if(!coll && !plot)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ensembleCurveSetsOnClipboard().size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteEnsembleCurveSetFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
std::vector<caf::PdmPointer<RimEnsembleCurveSet> > sourceObjects = RicPasteEnsembleCurveSetFeature::ensembleCurveSetsOnClipboard();
|
||||
|
||||
for (size_t i = 0; i < sourceObjects.size(); i++)
|
||||
{
|
||||
copyCurveSetAndAddToCollection(sourceObjects[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteEnsembleCurveSetFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Paste Ensemble Curve Set");
|
||||
|
||||
RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<caf::PdmPointer<RimEnsembleCurveSet> > RicPasteEnsembleCurveSetFeature::ensembleCurveSetsOnClipboard()
|
||||
{
|
||||
caf::PdmObjectGroup objectGroup;
|
||||
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
|
||||
|
||||
std::vector<caf::PdmPointer<RimEnsembleCurveSet> > typedObjects;
|
||||
objectGroup.objectsByType(&typedObjects);
|
||||
|
||||
return typedObjects;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimEnsembleCurveSet;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicPasteEnsembleCurveSetFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static RimEnsembleCurveSet* copyCurveSetAndAddToCollection(RimEnsembleCurveSet *sourceCurveSet);
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
|
||||
static std::vector<caf::PdmPointer<RimEnsembleCurveSet> > ensembleCurveSetsOnClipboard();
|
||||
};
|
||||
@@ -423,6 +423,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicPasteSummaryCrossPlotCurveFeature";
|
||||
menuBuilder << "RicPasteSummaryPlotFeature";
|
||||
menuBuilder << "RicPasteAsciiDataToSummaryPlotFeature";
|
||||
menuBuilder << "RicPasteEnsembleCurveSetFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicEditSummaryPlotFeature";
|
||||
menuBuilder << "RicNewSummaryPlotFeature";
|
||||
@@ -469,6 +470,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
else if (dynamic_cast<RimEnsembleCurveSetCollection*>(uiItem))
|
||||
{
|
||||
menuBuilder << "RicNewSummaryEnsembleCurveSetFeature";
|
||||
menuBuilder << "RicPasteEnsembleCurveSetFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimEnsembleCurveSet*>(uiItem))
|
||||
{
|
||||
|
||||
@@ -184,36 +184,10 @@ void RimEnsembleCurveSet::setColor(cvf::Color3f color)
|
||||
void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot)
|
||||
{
|
||||
m_yValuesSelectedVariableDisplayField = QString::fromStdString(m_yValuesCurveVariable->address().uiText());
|
||||
|
||||
m_yValuesSummaryFilter->updateFromAddress(m_yValuesCurveVariable->address());
|
||||
|
||||
for (RimSummaryCurve* curve : m_curves)
|
||||
{
|
||||
curve->loadDataAndUpdate(false);
|
||||
|
||||
if (curve->qwtPlotCurve())
|
||||
{
|
||||
curve->qwtPlotCurve()->setItemAttribute(QwtPlotItem::Legend, false);
|
||||
}
|
||||
|
||||
curve->updateQwtPlotAxis();
|
||||
}
|
||||
|
||||
if (updateParentPlot)
|
||||
{
|
||||
RimSummaryPlot* parentPlot;
|
||||
firstAncestorOrThisOfTypeAsserted(parentPlot);
|
||||
if (parentPlot->qwtPlot())
|
||||
{
|
||||
parentPlot->updatePlotTitle();
|
||||
parentPlot->qwtPlot()->updateLegend();
|
||||
parentPlot->updateAxes();
|
||||
parentPlot->updateZoomInQwt();
|
||||
}
|
||||
}
|
||||
m_yValuesUiFilterResultSelection = m_yValuesCurveVariable->address();
|
||||
|
||||
m_legendConfig->initForEnsembleCurveSet(this);
|
||||
updateCurveColors();
|
||||
updateAllCurves();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -809,8 +783,6 @@ void RimEnsembleCurveSet::updateAllCurves()
|
||||
|
||||
deleteAllCurves();
|
||||
|
||||
plot->loadDataAndUpdate();
|
||||
|
||||
RimSummaryCaseCollection* group = m_yValuesSummaryGroup();
|
||||
RimSummaryAddress* addr = m_yValuesCurveVariable();
|
||||
if (group && plot && addr->address().category() != RifEclipseSummaryAddress::SUMMARY_INVALID)
|
||||
@@ -831,6 +803,7 @@ void RimEnsembleCurveSet::updateAllCurves()
|
||||
curve->qwtPlotCurve()->setItemAttribute(QwtPlotItem::Legend, false);
|
||||
}
|
||||
}
|
||||
m_yValuesSummaryFilter->updateFromAddress(addr->address());
|
||||
|
||||
RimSummaryPlot* plot;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
|
||||
Reference in New Issue
Block a user