#901 WLP: Added copy/paste of plots

This commit is contained in:
Magne Sjaastad 2016-11-22 09:31:48 +01:00
parent 9a7adb2904
commit 3a0e7d098f
4 changed files with 163 additions and 0 deletions

View File

@ -17,6 +17,7 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.h
${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.h
${CEE_CURRENT_LIST_DIR}RicPasteWellLogCurveFeature.h
${CEE_CURRENT_LIST_DIR}RicPasteWellLogTrackFeature.h
${CEE_CURRENT_LIST_DIR}RicPasteWellLogPlotFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -32,6 +33,7 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.cpp
${CEE_CURRENT_LIST_DIR}RicPasteWellLogCurveFeature.cpp
${CEE_CURRENT_LIST_DIR}RicPasteWellLogTrackFeature.cpp
${CEE_CURRENT_LIST_DIR}RicPasteWellLogPlotFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,115 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteWellLogPlotFeature.h"
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotCollection.h"
#include "cafPdmObjectGroup.h"
#include "cafPdmObjectHandle.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicPasteWellLogPlotFeature, "RicPasteWellLogPlotFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteWellLogPlotFeature::isCommandEnabled()
{
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
RimWellLogPlotCollection* wellLogPlotCollection = nullptr;
destinationObject->firstAncestorOrThisOfType(wellLogPlotCollection);
if (!wellLogPlotCollection)
{
return false;
}
return RicPasteWellLogPlotFeature::plots().size() > 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteWellLogPlotFeature::onActionTriggered(bool isChecked)
{
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
RimWellLogPlotCollection* wellLogPlotCollection = nullptr;
destinationObject->firstAncestorOrThisOfType(wellLogPlotCollection);
if (!wellLogPlotCollection)
{
return;
}
std::vector<caf::PdmPointer<RimWellLogPlot> > sourceObjects = RicPasteWellLogPlotFeature::plots();
for (size_t i = 0; i < sourceObjects.size(); i++)
{
RimWellLogPlot* fileCurve = sourceObjects[i];
if (fileCurve)
{
RimWellLogPlot* newObject = dynamic_cast<RimWellLogPlot*>(fileCurve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
CVF_ASSERT(newObject);
wellLogPlotCollection->wellLogPlots.push_back(newObject);
// Resolve references after object has been inserted into the project data model
newObject->resolveReferencesRecursively();
newObject->initAfterReadRecursively();
QString description = "Copy of " + newObject->description();
newObject->setDescription(description);
newObject->loadDataAndUpdate();
wellLogPlotCollection->updateConnectedEditors();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteWellLogPlotFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Paste Well Log Plot");
actionToSetup->setIcon(QIcon(":/clipboard.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmPointer<RimWellLogPlot> > RicPasteWellLogPlotFeature::plots()
{
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
std::vector<caf::PdmPointer<RimWellLogPlot> > typedObjects;
objectGroup.objectsByType(&typedObjects);
return typedObjects;
}

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 "cafCmdFeature.h"
#include "cafPdmPointer.h"
#include <vector>
class RimWellLogPlot;
//==================================================================================================
///
//==================================================================================================
class RicPasteWellLogPlotFeature : 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<RimWellLogPlot> > plots();
};

View File

@ -241,6 +241,8 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
}
else if (dynamic_cast<RimWellLogPlotCollection*>(uiItem))
{
commandIds << "RicPasteWellLogPlotFeature";
commandIds << "Separator";
commandIds << "RicNewWellLogPlotFeature";
}
else if (dynamic_cast<RimSummaryPlotCollection*>(uiItem))
@ -251,6 +253,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
}
else if (dynamic_cast<RimWellLogPlot*>(uiItem))
{
commandIds << "RicPasteWellLogPlotFeature";
commandIds << "RicPasteWellLogTrackFeature";
commandIds << "Separator";
commandIds << "RicNewWellLogPlotTrackFeature";