2016-11-22 01:48:11 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2016 Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2016-11-22 01:48:11 -06:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2016-11-22 01:48:11 -06:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2016-11-22 01:48:11 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicPasteWellLogCurveFeature.h"
|
2017-02-07 02:34:11 -06:00
|
|
|
#include "RicWellLogPlotCurveFeatureImpl.h"
|
2016-11-22 01:48:11 -06:00
|
|
|
|
|
|
|
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
|
|
|
|
|
2020-02-10 06:10:25 -06:00
|
|
|
#include "RimWellBoreStabilityPlot.h"
|
2016-11-22 01:48:11 -06:00
|
|
|
#include "RimWellLogCurve.h"
|
|
|
|
#include "RimWellLogExtractionCurve.h"
|
|
|
|
#include "RimWellLogFileCurve.h"
|
2022-02-23 06:57:02 -06:00
|
|
|
#include "RimWellLogRftCurve.h"
|
2016-11-22 01:48:11 -06:00
|
|
|
#include "RimWellLogTrack.h"
|
2020-04-27 23:36:17 -05:00
|
|
|
#include "RimWellMeasurementCurve.h"
|
2016-11-22 01:48:11 -06:00
|
|
|
|
|
|
|
#include "cafPdmObjectGroup.h"
|
|
|
|
#include "cafPdmObjectHandle.h"
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicPasteWellLogCurveFeature, "RicPasteWellLogCurveFeature" );
|
2016-11-22 01:48:11 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-11-22 01:48:11 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicPasteWellLogCurveFeature::isCommandEnabled()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return false;
|
|
|
|
if ( RicWellLogPlotCurveFeatureImpl::parentWellRftPlot() ) return false;
|
2017-02-07 02:34:11 -06:00
|
|
|
|
2022-02-23 06:57:02 -06:00
|
|
|
auto* destinationObject = dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
|
2019-11-27 03:17:31 -06:00
|
|
|
if ( !destinationObject ) return false;
|
2016-11-22 01:48:11 -06:00
|
|
|
|
2023-05-12 14:41:34 -05:00
|
|
|
RimWellLogTrack* wellLogTrack = destinationObject->firstAncestorOrThisOfType<RimWellLogTrack>();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !wellLogTrack )
|
2016-11-22 01:48:11 -06:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-05-12 14:41:34 -05:00
|
|
|
RimWellBoreStabilityPlot* wbsPlotToPasteInto = wellLogTrack->firstAncestorOrThisOfType<RimWellBoreStabilityPlot>();
|
2020-02-10 06:10:25 -06:00
|
|
|
|
|
|
|
std::vector<caf::PdmPointer<RimWellLogCurve>> sourceObjects = RicPasteWellLogCurveFeature::curves();
|
|
|
|
|
2022-02-23 06:57:02 -06:00
|
|
|
for ( const auto& sourceObject : sourceObjects )
|
2020-02-10 06:10:25 -06:00
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
RimWellBoreStabilityPlot* originalWbsPlot = sourceObject->firstAncestorOrThisOfType<RimWellBoreStabilityPlot>();
|
2020-02-10 06:10:25 -06:00
|
|
|
if ( originalWbsPlot && originalWbsPlot != wbsPlotToPasteInto )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2022-02-23 06:57:02 -06:00
|
|
|
return !RicPasteWellLogCurveFeature::curves().empty();
|
2016-11-22 01:48:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-11-22 01:48:11 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicPasteWellLogCurveFeature::onActionTriggered( bool isChecked )
|
2016-11-22 01:48:11 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return;
|
2017-02-07 02:34:11 -06:00
|
|
|
|
2022-02-23 06:57:02 -06:00
|
|
|
auto* destinationObject = dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
|
2019-11-27 03:17:31 -06:00
|
|
|
if ( !destinationObject ) return;
|
2016-11-22 01:48:11 -06:00
|
|
|
|
2023-05-12 14:41:34 -05:00
|
|
|
RimWellLogTrack* wellLogTrack = destinationObject->firstAncestorOrThisOfType<RimWellLogTrack>();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !wellLogTrack )
|
2016-11-22 01:48:11 -06:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-05-12 14:41:34 -05:00
|
|
|
RimWellBoreStabilityPlot* wbsPlotToPasteInto = wellLogTrack->firstAncestorOrThisOfType<RimWellBoreStabilityPlot>();
|
2020-02-10 06:10:25 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<caf::PdmPointer<RimWellLogCurve>> sourceObjects = RicPasteWellLogCurveFeature::curves();
|
2016-11-22 01:48:11 -06:00
|
|
|
|
2022-02-23 06:57:02 -06:00
|
|
|
for ( const auto& sourceObject : sourceObjects )
|
2016-11-22 01:48:11 -06:00
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
RimWellBoreStabilityPlot* originalWbsPlot = sourceObject->firstAncestorOrThisOfType<RimWellBoreStabilityPlot>();
|
2020-02-10 06:10:25 -06:00
|
|
|
if ( originalWbsPlot && originalWbsPlot != wbsPlotToPasteInto )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-02-23 06:57:02 -06:00
|
|
|
auto* fileCurve = dynamic_cast<RimWellLogCurve*>( sourceObject.p() );
|
|
|
|
auto* measurementCurve = dynamic_cast<RimWellMeasurementCurve*>( sourceObject.p() );
|
|
|
|
auto* extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>( sourceObject.p() );
|
|
|
|
auto* rftCurve = dynamic_cast<RimWellLogRftCurve*>( sourceObject.p() );
|
|
|
|
if ( fileCurve || measurementCurve || extractionCurve || rftCurve )
|
2016-11-22 01:48:11 -06:00
|
|
|
{
|
2022-02-23 06:57:02 -06:00
|
|
|
auto* newObject = dynamic_cast<RimWellLogCurve*>(
|
|
|
|
sourceObject->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( newObject );
|
2016-11-22 01:48:11 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
wellLogTrack->addCurve( newObject );
|
2016-11-22 01:48:11 -06:00
|
|
|
|
|
|
|
// Resolve references after object has been inserted into the project data model
|
|
|
|
newObject->resolveReferencesRecursively();
|
|
|
|
newObject->initAfterReadRecursively();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
newObject->loadDataAndUpdate( true );
|
2016-11-22 01:48:11 -06:00
|
|
|
|
|
|
|
wellLogTrack->updateConnectedEditors();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-11-22 01:48:11 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicPasteWellLogCurveFeature::setupActionLook( QAction* actionToSetup )
|
2016-11-22 01:48:11 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Paste Well Log Curve" );
|
2016-11-24 01:22:36 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup );
|
2016-11-22 01:48:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-11-22 01:48:11 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<caf::PdmPointer<RimWellLogCurve>> RicPasteWellLogCurveFeature::curves()
|
2016-11-22 01:48:11 -06:00
|
|
|
{
|
|
|
|
caf::PdmObjectGroup objectGroup;
|
2019-09-06 03:40:57 -05:00
|
|
|
RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup );
|
2016-11-22 01:48:11 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
std::vector<caf::PdmPointer<RimWellLogCurve>> typedObjects;
|
|
|
|
objectGroup.objectsByType( &typedObjects );
|
2016-11-22 01:48:11 -06:00
|
|
|
|
|
|
|
return typedObjects;
|
|
|
|
}
|