#901 WLP: Added copy/paste of tracks

This commit is contained in:
Magne Sjaastad 2016-11-22 09:11:25 +01:00
parent 402c629646
commit 9a7adb2904
4 changed files with 160 additions and 0 deletions

View File

@ -16,6 +16,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h
${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.h
${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.h
${CEE_CURRENT_LIST_DIR}RicPasteWellLogCurveFeature.h
${CEE_CURRENT_LIST_DIR}RicPasteWellLogTrackFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -30,6 +31,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.cpp
${CEE_CURRENT_LIST_DIR}RicPasteWellLogCurveFeature.cpp
${CEE_CURRENT_LIST_DIR}RicPasteWellLogTrackFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

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

View File

@ -251,10 +251,13 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
}
else if (dynamic_cast<RimWellLogPlot*>(uiItem))
{
commandIds << "RicPasteWellLogTrackFeature";
commandIds << "Separator";
commandIds << "RicNewWellLogPlotTrackFeature";
}
else if (dynamic_cast<RimWellLogTrack*>(uiItem))
{
commandIds << "RicPasteWellLogTrackFeature";
commandIds << "RicPasteWellLogCurveFeature";
commandIds << "Separator";
commandIds << "RicNewWellLogCurveExtractionFeature";