#2199, #2245 Summary plots. Add paste commands for cross plot. Add duplicate summary plots and curves

This commit is contained in:
Bjørn Erik Jensen 2017-12-12 13:22:16 +01:00
parent b7bdce1d9e
commit 9769d391e1
23 changed files with 880 additions and 65 deletions

View File

@ -130,3 +130,11 @@ RimSummaryCrossPlotCollection* RiaSummaryTools::parentCrossPlotCollection(caf::P
return crossPlotColl;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaSummaryTools::isSummaryCrossPlot(const RimSummaryPlot* plot)
{
return dynamic_cast<const RimSummaryCrossPlot*>(plot);
}

View File

@ -44,4 +44,5 @@ public:
static RimSummaryCrossPlot* parentCrossPlot(caf::PdmObject* object);
static RimSummaryCrossPlotCollection* parentCrossPlotCollection(caf::PdmObject* object);
static bool isSummaryCrossPlot(const RimSummaryPlot* plot);
};

View File

@ -9,12 +9,18 @@ set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.h
${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotFeature.h
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.h
${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryPlotFeature.h
${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCurveFeature.h
${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotFeature.h
${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotCurveFeature.h
${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeature.h
${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeatureUi.h
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.h
${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.h
${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotFeature.h
${CEE_CURRENT_LIST_DIR}RicPasteSummaryCurveFeature.h
${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotCurveFeature.h
${CEE_CURRENT_LIST_DIR}RicPasteSummaryCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicAsciiExportSummaryPlotFeature.h
${CEE_CURRENT_LIST_DIR}RicNewGridTimeHistoryCurveFeature.h
@ -38,12 +44,18 @@ set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.cpp
${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryPlotFeature.cpp
${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCurveFeature.cpp
${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotFeature.cpp
${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotCurveFeature.cpp
${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeature.cpp
${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeatureUi.cpp
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.cpp
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.cpp
${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.cpp
${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotFeature.cpp
${CEE_CURRENT_LIST_DIR}RicPasteSummaryCurveFeature.cpp
${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotCurveFeature.cpp
${CEE_CURRENT_LIST_DIR}RicPasteSummaryCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicAsciiExportSummaryPlotFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewGridTimeHistoryCurveFeature.cpp

View File

@ -0,0 +1,63 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicDuplicateSummaryCrossPlotCurveFeature.h"
#include "RiaApplication.h"
#include "RicPasteSummaryCurveFeature.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RiaSummaryTools.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCrossPlot.h"
#include "RimSummaryCrossPlotCollection.h"
#include "RiuMainPlotWindow.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicDuplicateSummaryCrossPlotCurveFeature, "RicDuplicateSummaryCrossPlotCurveFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDuplicateSummaryCrossPlotCurveFeature::isCommandEnabled()
{
RimSummaryCrossPlot* selectedPlot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryCrossPlot*>();
return (selectedPlot);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryCrossPlotCurveFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Duplicate Summary Cross Plot Curve");
actionToSetup->setIcon(QIcon(":/SummaryCurve16x16.png"));
}

View File

@ -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 "RicDuplicateSummaryCurveFeature.h"
#include "cafCmdFeature.h"
#include <vector>
class RimSummaryCrossPlot;
//==================================================================================================
///
//==================================================================================================
class RicDuplicateSummaryCrossPlotCurveFeature : public RicDuplicateSummaryCurveFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void setupActionLook( QAction* actionToSetup );
};

View File

@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicDuplicateSummaryCrossPlotFeature.h"
#include "RiaSummaryTools.h"
#include "RicPasteSummaryCrossPlotFeature.h"
#include "RimSummaryCrossPlot.h"
#include "RimSummaryCrossPlotCollection.h"
#include "cvfAssert.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicDuplicateSummaryCrossPlotFeature, "RicDuplicateSummaryCrossPlotFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDuplicateSummaryCrossPlotFeature::isCommandEnabled()
{
RimSummaryCrossPlotCollection* sumPlotColl = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
if (selObj)
{
sumPlotColl = RiaSummaryTools::parentCrossPlotCollection(selObj);
}
if (sumPlotColl) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryCrossPlotFeature::onActionTriggered(bool isChecked)
{
std::vector<RimSummaryCrossPlot*> selectedObjects = caf::selectedObjectsByType<RimSummaryCrossPlot*>();
if (selectedObjects.size() == 1)
{
RicPasteSummaryCrossPlotFeature::copyPlotAndAddToCollection(selectedObjects[0]);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryCrossPlotFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Duplicate Summary Cross Plot");
actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png"));
}

View File

@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RimSummaryPlotCollection;
class RimSummaryCase;
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicDuplicateSummaryCrossPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook(QAction* actionToSetup);
};

View File

@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicDuplicateSummaryCurveFeature.h"
#include "RiaApplication.h"
#include "RicPasteSummaryCurveFeature.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RiaSummaryTools.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RiuMainPlotWindow.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicDuplicateSummaryCurveFeature, "RicDuplicateSummaryCurveFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDuplicateSummaryCurveFeature::isCommandEnabled()
{
RimSummaryPlot* selectedPlot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot*>();
return (selectedPlot && !RiaSummaryTools::isSummaryCrossPlot(selectedPlot));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryCurveFeature::onActionTriggered(bool isChecked)
{
RimProject* project = RiaApplication::instance()->project();
CVF_ASSERT(project);
RimSummaryCurve* curve = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryCurve*>();
if (curve)
{
RimSummaryCurve* newCurve = RicPasteSummaryCurveFeature::copyCurveAndAddToPlot(curve);
RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryCurveFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Duplicate Summary Curve");
actionToSetup->setIcon(QIcon(":/SummaryCurve16x16.png"));
}

View File

@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <vector>
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicDuplicateSummaryCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
};

View File

@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicDuplicateSummaryPlotFeature.h"
#include "RiaSummaryTools.h"
#include "RicPasteSummaryPlotFeature.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "cvfAssert.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicDuplicateSummaryPlotFeature, "RicDuplicateSummaryPlotFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDuplicateSummaryPlotFeature::isCommandEnabled()
{
RimSummaryPlotCollection* sumPlotColl = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
if (selObj)
{
sumPlotColl = RiaSummaryTools::parentSummaryPlotCollection(selObj);
}
if (sumPlotColl) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryPlotFeature::onActionTriggered(bool isChecked)
{
std::vector<RimSummaryPlot*> selectedObjects = caf::selectedObjectsByType<RimSummaryPlot*>();
if (selectedObjects.size() == 1)
{
RicPasteSummaryPlotFeature::copyPlotAndAddToCollection(selectedObjects[0]);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDuplicateSummaryPlotFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Duplicate Summary Plot");
actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png"));
}

View File

@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RimSummaryPlotCollection;
class RimSummaryCase;
class RimSummaryPlot;
//==================================================================================================
///
//==================================================================================================
class RicDuplicateSummaryPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook(QAction* actionToSetup);
};

View File

@ -57,8 +57,9 @@ void RicNewSummaryCrossPlotFeature::onActionTriggered(bool isChecked)
CVF_ASSERT(project);
RimSummaryCrossPlotCollection* summaryCrossPlotColl = project->mainPlotCollection()->summaryCrossPlotCollection();
RimSummaryPlot* summaryPlot = summaryCrossPlotColl->addSummaryPlot();
RimSummaryPlot* summaryPlot = summaryCrossPlotColl->createSummaryPlot();
summaryCrossPlotColl->addSummaryPlot(summaryPlot);
if (summaryPlot)
{
summaryCrossPlotColl->updateConnectedEditors();

View File

@ -0,0 +1,91 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteSummaryCrossPlotCurveFeature.h"
#include "RiaSummaryTools.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveFilter.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(RicPasteSummaryCrossPlotCurveFeature, "RicPasteSummaryCrossPlotCurveFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteSummaryCrossPlotCurveFeature::isCommandEnabled()
{
caf::PdmObject* destinationObject = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
if(!RiaSummaryTools::parentCrossPlot(destinationObject))
{
return false;
}
if (summaryCurvesOnClipboard().size() == 0)
{
return false;
}
for (caf::PdmPointer<RimSummaryCurve> curve : summaryCurvesOnClipboard())
{
// Check that owner plot is correct type
RimSummaryCrossPlot* ownerPlot = nullptr;
curve->firstAncestorOrThisOfType(ownerPlot);
if (!ownerPlot) return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
//void RicPasteSummaryCrossPlotCurveFeature::onActionTriggered(bool isChecked)
//{
// std::vector<caf::PdmPointer<RimSummaryCurve> > sourceObjects = RicPasteSummaryCurveFeature::summaryCurves();
//
// for (size_t i = 0; i < sourceObjects.size(); i++)
// {
// copyCurveAndAddToPlot(sourceObjects[i]);
// }
//}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCrossPlotCurveFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Paste Summary Cross Plot Curve");
RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup);
}

View File

@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteSummaryCurveFeature.h"
#include "cafCmdFeature.h"
#include "cafPdmPointer.h"
#include <vector>
class RimSummaryCurve;
class RimSummaryCurveFilter;
//==================================================================================================
///
//==================================================================================================
class RicPasteSummaryCrossPlotCurveFeature : public RicPasteSummaryCurveFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled() override;
//virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook(QAction* actionToSetup) override;
};

View File

@ -0,0 +1,120 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteSummaryCrossPlotFeature.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RimSummaryCrossPlot.h"
#include "RimSummaryCrossPlotCollection.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicPasteSummaryCrossPlotFeature, "RicPasteSummaryCrossPlotFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCrossPlotFeature::copyPlotAndAddToCollection(RimSummaryCrossPlot *sourcePlot)
{
RimSummaryCrossPlotCollection* plotColl = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryCrossPlotCollection*>();
if (plotColl)
{
RimSummaryCrossPlot* newSummaryPlot = dynamic_cast<RimSummaryCrossPlot*>(sourcePlot->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
CVF_ASSERT(newSummaryPlot);
plotColl->addSummaryPlot(newSummaryPlot);
// Resolve references after object has been inserted into the data model
newSummaryPlot->resolveReferencesRecursively();
newSummaryPlot->initAfterReadRecursively();
QString nameOfCopy = QString("Copy of ") + newSummaryPlot->description();
newSummaryPlot->setDescription(nameOfCopy);
plotColl->updateConnectedEditors();
newSummaryPlot->loadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteSummaryCrossPlotFeature::isCommandEnabled()
{
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
RimSummaryCrossPlotCollection* plotColl = nullptr;
destinationObject->firstAncestorOrThisOfType(plotColl);
if (!plotColl)
{
return false;
}
return RicPasteSummaryCrossPlotFeature::summaryPlots().size() > 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCrossPlotFeature::onActionTriggered(bool isChecked)
{
std::vector<caf::PdmPointer<RimSummaryCrossPlot> > sourceObjects = RicPasteSummaryCrossPlotFeature::summaryPlots();
for (size_t i = 0; i < sourceObjects.size(); i++)
{
copyPlotAndAddToCollection(sourceObjects[i]);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCrossPlotFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Paste Summary Cross Plot");
RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmPointer<RimSummaryCrossPlot> > RicPasteSummaryCrossPlotFeature::summaryPlots()
{
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
std::vector<caf::PdmPointer<RimSummaryCrossPlot> > typedObjects;
objectGroup.objectsByType(&typedObjects);
return typedObjects;
}

View File

@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RimSummaryCrossPlot;
//==================================================================================================
///
//==================================================================================================
class RicPasteSummaryCrossPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void copyPlotAndAddToCollection(RimSummaryCrossPlot *sourcePlot);
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook(QAction* actionToSetup) override;
private:
static std::vector<caf::PdmPointer<RimSummaryCrossPlot> > summaryPlots();
};

View File

@ -18,16 +18,19 @@
#include "RicPasteSummaryCurveFeature.h"
#include "RiaSummaryTools.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveFilter.h"
#include "RimSummaryPlot.h"
#include "RimSummaryCrossPlot.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
@ -36,21 +39,62 @@
CAF_CMD_SOURCE_INIT(RicPasteSummaryCurveFeature, "RicPasteSummaryCurveFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCurve* RicPasteSummaryCurveFeature::copyCurveAndAddToPlot(RimSummaryCurve *sourceCurve)
{
RimSummaryPlot* summaryPlot = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot*>();
RimSummaryCurve* newCurve = dynamic_cast<RimSummaryCurve*>(sourceCurve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
CVF_ASSERT(newCurve);
summaryPlot->addCurveAndUpdate(newCurve);
// Resolve references after object has been inserted into the project data model
newCurve->resolveReferencesRecursively();
// If source curve is part of a curve filter, resolve of references to the summary case does not
// work when pasting the new curve into a plot. Must set summary case manually.
newCurve->setSummaryCaseY(sourceCurve->summaryCaseY());
newCurve->initAfterReadRecursively();
newCurve->loadDataAndUpdate(true);
newCurve->updateConnectedEditors();
summaryPlot->updateConnectedEditors();
return newCurve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteSummaryCurveFeature::isCommandEnabled()
{
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
caf::PdmObject* destinationObject = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
RimSummaryPlot* summaryPlot = nullptr;
destinationObject->firstAncestorOrThisOfType(summaryPlot);
if (!summaryPlot)
if(!RiaSummaryTools::parentSummaryPlot(destinationObject))
{
return false;
}
return RicPasteSummaryCurveFeature::summaryCurves().size() > 0;
if (summaryCurvesOnClipboard().size() == 0)
{
return false;
}
for (caf::PdmPointer<RimSummaryCurve> curve : summaryCurvesOnClipboard())
{
// Check that owner plot is correct type
RimSummaryPlot* ownerPlot = RiaSummaryTools::parentSummaryPlot(curve);
if (!ownerPlot) return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
@ -58,37 +102,11 @@ bool RicPasteSummaryCurveFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryCurveFeature::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 = RicPasteSummaryCurveFeature::summaryCurves();
std::vector<caf::PdmPointer<RimSummaryCurve> > sourceObjects = RicPasteSummaryCurveFeature::summaryCurvesOnClipboard();
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->addCurveAndUpdate(newObject);
// Resolve references after object has been inserted into the project data model
newObject->resolveReferencesRecursively();
// If source curve is part of a curve filter, resolve of references to the summary case does not
// work when pasting the new curve into a plot. Must set summary case manually.
newObject->setSummaryCaseY(sourceObjects[i]->summaryCaseY());
newObject->initAfterReadRecursively();
newObject->loadDataAndUpdate(true);
newObject->updateConnectedEditors();
summaryPlot->updateConnectedEditors();
copyCurveAndAddToPlot(sourceObjects[i]);
}
}
@ -105,7 +123,7 @@ void RicPasteSummaryCurveFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmPointer<RimSummaryCurve> > RicPasteSummaryCurveFeature::summaryCurves()
std::vector<caf::PdmPointer<RimSummaryCurve> > RicPasteSummaryCurveFeature::summaryCurvesOnClipboard()
{
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);

View File

@ -33,12 +33,14 @@ class RicPasteSummaryCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static RimSummaryCurve* copyCurveAndAddToPlot(RimSummaryCurve *sourceCurve);
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();
static std::vector<caf::PdmPointer<RimSummaryCurve> > summaryCurvesOnClipboard();
};

View File

@ -27,7 +27,7 @@
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManager.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
@ -36,6 +36,34 @@
CAF_CMD_SOURCE_INIT(RicPasteSummaryPlotFeature, "RicPasteSummaryPlotFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteSummaryPlotFeature::copyPlotAndAddToCollection(RimSummaryPlot *sourcePlot)
{
RimSummaryPlotCollection* plotColl = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlotCollection*>();
if (plotColl)
{
RimSummaryPlot* newSummaryPlot = dynamic_cast<RimSummaryPlot*>(sourcePlot->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
CVF_ASSERT(newSummaryPlot);
plotColl->summaryPlots.push_back(newSummaryPlot);
// Resolve references after object has been inserted into the data model
newSummaryPlot->resolveReferencesRecursively();
newSummaryPlot->initAfterReadRecursively();
QString nameOfCopy = QString("Copy of ") + newSummaryPlot->description();
newSummaryPlot->setDescription(nameOfCopy);
plotColl->updateConnectedEditors();
newSummaryPlot->loadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -58,34 +86,11 @@ bool RicPasteSummaryPlotFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
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);
plotColl->summaryPlots.push_back(newSummaryPlot);
// Resolve references after object has been inserted into the data model
newSummaryPlot->resolveReferencesRecursively();
newSummaryPlot->initAfterReadRecursively();
QString nameOfCopy = QString("Copy of ") + newSummaryPlot->description();
newSummaryPlot->setDescription(nameOfCopy);
plotColl->updateConnectedEditors();
newSummaryPlot->loadDataAndUpdate();
copyPlotAndAddToCollection(sourceObjects[i]);
}
}

View File

@ -32,6 +32,9 @@ class RicPasteSummaryPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void copyPlotAndAddToCollection(RimSummaryPlot *sourcePlot);
protected:
// Overrides
virtual bool isCommandEnabled() override;

View File

@ -330,6 +330,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
}
else if (dynamic_cast<RimSummaryCrossPlotCollection*>(uiItem))
{
menuBuilder << "RicPasteSummaryCrossPlotFeature";
menuBuilder << "Separator";
menuBuilder << "RicNewSummaryCrossPlotFeature";
}
else if (dynamic_cast<RimWellLogPlot*>(uiItem))
@ -358,12 +360,15 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
else if (dynamic_cast<RimSummaryPlot*>(uiItem)) // This is also the definition for RimSummaryCrossPlot
{
menuBuilder << "RicPasteSummaryCurveFeature";
menuBuilder << "RicPasteSummaryCrossPlotCurveFeature";
menuBuilder << "RicPasteSummaryPlotFeature";
menuBuilder << "RicPasteAsciiDataToSummaryPlotFeature";
menuBuilder << "Separator";
menuBuilder << "RicEditSummaryPlotFeature";
menuBuilder << "RicNewSummaryPlotFeature";
menuBuilder << "RicDuplicateSummaryPlotFeature";
menuBuilder << "RicNewSummaryCurveFeature";
menuBuilder << "RicDuplicateSummaryCrossPlotFeature";
menuBuilder << "RicNewSummaryCrossPlotCurveFeature";
menuBuilder << "Separator";
menuBuilder << "RicShowSummaryCurveCalculatorFeature";
@ -377,9 +382,12 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
else if (dynamic_cast<RimSummaryCurve*>(uiItem))
{
menuBuilder << "RicPasteSummaryCurveFeature";
menuBuilder << "RicPasteSummaryCrossPlotCurveFeature";
menuBuilder << "Separator";
menuBuilder << "RicNewSummaryCurveFeature";
menuBuilder << "RicDuplicateSummaryCurveFeature";
menuBuilder << "RicNewSummaryCrossPlotCurveFeature";
menuBuilder << "RicDuplicateSummaryCrossPlotCurveFeature";
menuBuilder << "Separator";
menuBuilder << "RicCopyReferencesToClipboardFeature";
menuBuilder << "Separator";
@ -388,6 +396,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
else if (dynamic_cast<RimSummaryCurveCollection*>(uiItem))
{
menuBuilder << "RicPasteSummaryCurveFeature";
menuBuilder << "RicPasteSummaryCrossPlotCurveFeature";
menuBuilder << "Separator";
menuBuilder << "RicEditSummaryPlotFeature";
menuBuilder << "RicNewSummaryCurveFeature";

View File

@ -86,13 +86,19 @@ void RimSummaryCrossPlotCollection::summaryPlotItemInfos(QList<caf::PdmOptionIte
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot* RimSummaryCrossPlotCollection::addSummaryPlot()
RimSummaryPlot* RimSummaryCrossPlotCollection::createSummaryPlot()
{
RimSummaryPlot* plot = new RimSummaryCrossPlot();
m_summaryCrossPlots().push_back(plot);
plot->setDescription(QString("Summary Cross Plot %1").arg(m_summaryCrossPlots.size()));
return plot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCrossPlotCollection::addSummaryPlot(RimSummaryPlot *plot)
{
m_summaryCrossPlots().push_back(plot);
}

View File

@ -37,7 +37,8 @@ public:
void deleteAllChildObjects();
std::vector<RimSummaryPlot*> summaryPlots() const;
RimSummaryPlot* addSummaryPlot();
RimSummaryPlot* createSummaryPlot();
void addSummaryPlot(RimSummaryPlot *plot);
void updateSummaryNameHasChanged();
void summaryPlotItemInfos(QList<caf::PdmOptionItemInfo>* optionInfos) const;