mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#901 WLP: Added copy/paste of curves
This commit is contained in:
parent
f688a89262
commit
402c629646
@ -15,6 +15,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellLogPlotCurveFeatureImpl.h
|
|||||||
${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h
|
${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.h
|
${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.h
|
${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicPasteWellLogCurveFeature.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
@ -28,6 +29,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellLogPlotCurveFeatureImpl.cpp
|
|||||||
${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.cpp
|
${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicPasteWellLogCurveFeature.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
|
@ -0,0 +1,131 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RicPasteWellLogCurveFeature.h"
|
||||||
|
|
||||||
|
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
|
||||||
|
|
||||||
|
#include "RimWellLogCurve.h"
|
||||||
|
#include "RimWellLogExtractionCurve.h"
|
||||||
|
#include "RimWellLogFileCurve.h"
|
||||||
|
#include "RimWellLogTrack.h"
|
||||||
|
|
||||||
|
#include "cafPdmObjectGroup.h"
|
||||||
|
#include "cafPdmObjectHandle.h"
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
|
#include "cvfAssert.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT(RicPasteWellLogCurveFeature, "RicPasteWellLogCurveFeature");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicPasteWellLogCurveFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
|
||||||
|
|
||||||
|
RimWellLogTrack* wellLogTrack = nullptr;
|
||||||
|
destinationObject->firstAncestorOrThisOfType(wellLogTrack);
|
||||||
|
if (!wellLogTrack)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RicPasteWellLogCurveFeature::curves().size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicPasteWellLogCurveFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
|
||||||
|
|
||||||
|
RimWellLogTrack* wellLogTrack = nullptr;
|
||||||
|
destinationObject->firstAncestorOrThisOfType(wellLogTrack);
|
||||||
|
if (!wellLogTrack)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<caf::PdmPointer<RimWellLogCurve> > sourceObjects = RicPasteWellLogCurveFeature::curves();
|
||||||
|
|
||||||
|
for (size_t i = 0; i < sourceObjects.size(); i++)
|
||||||
|
{
|
||||||
|
RimWellLogFileCurve* fileCurve = dynamic_cast<RimWellLogFileCurve*>(sourceObjects[i].p());
|
||||||
|
if (fileCurve)
|
||||||
|
{
|
||||||
|
RimWellLogFileCurve* newObject = dynamic_cast<RimWellLogFileCurve*>(sourceObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||||
|
CVF_ASSERT(newObject);
|
||||||
|
|
||||||
|
wellLogTrack->addCurve(newObject);
|
||||||
|
|
||||||
|
// Resolve references after object has been inserted into the project data model
|
||||||
|
newObject->resolveReferencesRecursively();
|
||||||
|
newObject->initAfterReadRecursively();
|
||||||
|
|
||||||
|
newObject->loadDataAndUpdate();
|
||||||
|
|
||||||
|
wellLogTrack->updateConnectedEditors();
|
||||||
|
}
|
||||||
|
|
||||||
|
RimWellLogExtractionCurve* extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>(sourceObjects[i].p());
|
||||||
|
if (extractionCurve)
|
||||||
|
{
|
||||||
|
RimWellLogExtractionCurve* newObject = dynamic_cast<RimWellLogExtractionCurve*>(sourceObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||||
|
CVF_ASSERT(newObject);
|
||||||
|
|
||||||
|
wellLogTrack->addCurve(newObject);
|
||||||
|
|
||||||
|
// Resolve references after object has been inserted into the project data model
|
||||||
|
newObject->resolveReferencesRecursively();
|
||||||
|
newObject->initAfterReadRecursively();
|
||||||
|
|
||||||
|
newObject->loadDataAndUpdate();
|
||||||
|
|
||||||
|
wellLogTrack->updateConnectedEditors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicPasteWellLogCurveFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Paste Well Log Curve");
|
||||||
|
actionToSetup->setIcon(QIcon(":/clipboard.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<caf::PdmPointer<RimWellLogCurve> > RicPasteWellLogCurveFeature::curves()
|
||||||
|
{
|
||||||
|
caf::PdmObjectGroup objectGroup;
|
||||||
|
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
|
||||||
|
|
||||||
|
std::vector<caf::PdmPointer<RimWellLogCurve> > typedObjects;
|
||||||
|
objectGroup.objectsByType(&typedObjects);
|
||||||
|
|
||||||
|
return typedObjects;
|
||||||
|
}
|
@ -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 RimWellLogCurve;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicPasteWellLogCurveFeature : 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<RimWellLogCurve> > curves();
|
||||||
|
};
|
@ -255,6 +255,8 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
|||||||
}
|
}
|
||||||
else if (dynamic_cast<RimWellLogTrack*>(uiItem))
|
else if (dynamic_cast<RimWellLogTrack*>(uiItem))
|
||||||
{
|
{
|
||||||
|
commandIds << "RicPasteWellLogCurveFeature";
|
||||||
|
commandIds << "Separator";
|
||||||
commandIds << "RicNewWellLogCurveExtractionFeature";
|
commandIds << "RicNewWellLogCurveExtractionFeature";
|
||||||
commandIds << "RicNewWellLogFileCurveFeature";
|
commandIds << "RicNewWellLogFileCurveFeature";
|
||||||
commandIds << "Separator";
|
commandIds << "Separator";
|
||||||
@ -262,7 +264,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
|||||||
}
|
}
|
||||||
else if (dynamic_cast<RimWellLogCurve*>(uiItem))
|
else if (dynamic_cast<RimWellLogCurve*>(uiItem))
|
||||||
{
|
{
|
||||||
//commandIds << "RicDeleteItemFeature";
|
commandIds << "RicPasteWellLogCurveFeature";
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<RimSummaryPlot*>(uiItem))
|
else if (dynamic_cast<RimSummaryPlot*>(uiItem))
|
||||||
{
|
{
|
||||||
@ -376,8 +378,12 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
|||||||
}
|
}
|
||||||
else if (dynamic_cast<RimWellLogCurve*>(uiItem) ||
|
else if (dynamic_cast<RimWellLogCurve*>(uiItem) ||
|
||||||
dynamic_cast<RimWellLogTrack*>(uiItem) ||
|
dynamic_cast<RimWellLogTrack*>(uiItem) ||
|
||||||
dynamic_cast<RimWellLogPlot*>(uiItem) ||
|
dynamic_cast<RimWellLogPlot*>(uiItem))
|
||||||
dynamic_cast<RimWellLogPlotCollection*>(uiItem))
|
{
|
||||||
|
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||||
|
commandIds << "RicExportToLasFileFeature";
|
||||||
|
}
|
||||||
|
else if (dynamic_cast<RimWellLogPlotCollection*>(uiItem))
|
||||||
{
|
{
|
||||||
commandIds << "RicExportToLasFileFeature";
|
commandIds << "RicExportToLasFileFeature";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user