2017-09-08 14:49:41 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2016- Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-09-08 14:49:41 +02: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 10:40:57 +02:00
|
|
|
//
|
2017-09-08 14:49:41 +02: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 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-09-08 14:49:41 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2017-09-21 10:47:55 +02:00
|
|
|
#include "RicEditSummaryPlotFeature.h"
|
2017-09-13 13:55:28 +02:00
|
|
|
|
2021-04-28 10:29:53 +02:00
|
|
|
#include "RiaGuiApplication.h"
|
2017-11-15 07:07:26 +01:00
|
|
|
#include "RiaSummaryTools.h"
|
2017-09-13 13:55:28 +02:00
|
|
|
|
2020-02-18 12:29:13 +01:00
|
|
|
#include "RicSummaryPlotEditorDialog.h"
|
2020-02-18 13:36:07 +01:00
|
|
|
#include "RicSummaryPlotEditorUi.h"
|
2017-09-26 07:48:42 +02:00
|
|
|
|
|
|
|
|
#include "RimSummaryPlot.h"
|
2017-09-13 13:55:28 +02:00
|
|
|
|
2019-12-05 13:32:48 +01:00
|
|
|
#include "RiuPlotMainWindow.h"
|
|
|
|
|
|
2017-09-08 14:49:41 +02:00
|
|
|
#include "cafPdmUiPropertyViewDialog.h"
|
2017-09-26 07:48:42 +02:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
#include "cvfAssert.h"
|
2017-09-08 14:49:41 +02:00
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
2019-11-21 07:10:07 +01:00
|
|
|
#include <memory>
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_CMD_SOURCE_INIT( RicEditSummaryPlotFeature, "RicEditSummaryPlotFeature" );
|
2017-09-08 14:49:41 +02:00
|
|
|
|
2017-09-21 09:49:49 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-09-21 09:49:49 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 11:13:38 +01:00
|
|
|
RicEditSummaryPlotFeature::RicEditSummaryPlotFeature()
|
|
|
|
|
{
|
|
|
|
|
}
|
2017-09-21 09:49:49 +02:00
|
|
|
|
2017-09-18 07:46:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-09-18 07:46:29 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-21 10:47:55 +02:00
|
|
|
void RicEditSummaryPlotFeature::closeDialogAndResetTargetPlot()
|
2017-09-18 07:46:29 +02:00
|
|
|
{
|
2022-03-03 10:15:32 +01:00
|
|
|
auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog( false );
|
2017-09-21 09:49:49 +02:00
|
|
|
|
2021-04-05 18:18:34 +02:00
|
|
|
if ( dialog )
|
2017-09-18 07:46:29 +02:00
|
|
|
{
|
2021-04-05 18:18:34 +02:00
|
|
|
if ( dialog->isVisible() )
|
|
|
|
|
{
|
|
|
|
|
dialog->hide();
|
|
|
|
|
}
|
|
|
|
|
dialog->updateFromSummaryPlot( nullptr );
|
2017-09-18 07:46:29 +02:00
|
|
|
}
|
2017-10-27 08:26:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-10-27 08:26:20 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-03-03 10:15:32 +01:00
|
|
|
RicSummaryPlotEditorDialog* RicEditSummaryPlotFeature::curveCreatorDialog( bool createIfNotPresent )
|
2017-10-27 08:26:20 +02:00
|
|
|
{
|
2019-12-05 13:32:48 +01:00
|
|
|
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
2019-11-21 07:10:07 +01:00
|
|
|
|
2019-12-05 13:32:48 +01:00
|
|
|
if ( mainPlotWindow )
|
2019-11-21 07:10:07 +01:00
|
|
|
{
|
2022-03-03 10:15:32 +01:00
|
|
|
return mainPlotWindow->summaryCurveCreatorDialog( createIfNotPresent );
|
2019-11-21 07:10:07 +01:00
|
|
|
}
|
2017-10-27 08:26:20 +02:00
|
|
|
|
2019-12-05 13:32:48 +01:00
|
|
|
return nullptr;
|
2017-09-18 07:46:29 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-08 14:49:41 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-09-08 14:49:41 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-25 13:53:51 +02:00
|
|
|
void RicEditSummaryPlotFeature::editSummaryPlot( RimSummaryPlot* plot )
|
2017-09-08 14:49:41 +02:00
|
|
|
{
|
2022-03-03 10:15:32 +01:00
|
|
|
auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog( true );
|
2017-09-13 13:55:28 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( !dialog->isVisible() )
|
2017-09-21 15:48:00 +02:00
|
|
|
{
|
2017-09-21 09:49:49 +02:00
|
|
|
dialog->show();
|
2017-09-21 15:48:00 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dialog->raise();
|
|
|
|
|
}
|
2017-09-15 13:37:52 +02:00
|
|
|
|
2019-10-25 13:53:51 +02:00
|
|
|
if ( plot )
|
2017-09-15 13:37:52 +02:00
|
|
|
{
|
2019-10-25 13:53:51 +02:00
|
|
|
dialog->updateFromSummaryPlot( plot );
|
2017-09-15 13:37:52 +02:00
|
|
|
}
|
2017-09-08 14:49:41 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-25 13:53:51 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RicEditSummaryPlotFeature::isCommandEnabled()
|
|
|
|
|
{
|
|
|
|
|
if ( selectedSummaryPlot() ) return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RicEditSummaryPlotFeature::onActionTriggered( bool isChecked )
|
|
|
|
|
{
|
|
|
|
|
editSummaryPlot( selectedSummaryPlot() );
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 14:49:41 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-09-08 14:49:41 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicEditSummaryPlotFeature::setupActionLook( QAction* actionToSetup )
|
2017-09-08 14:49:41 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
actionToSetup->setText( "Edit Summary Plot" );
|
|
|
|
|
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
|
2017-09-08 14:49:41 +02:00
|
|
|
}
|
2017-10-02 12:48:01 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-10-02 12:48:01 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-25 13:53:51 +02:00
|
|
|
RimSummaryPlot* RicEditSummaryPlotFeature::selectedSummaryPlot()
|
2017-10-02 12:48:01 +02:00
|
|
|
{
|
|
|
|
|
RimSummaryPlot* sumPlot = nullptr;
|
|
|
|
|
|
2022-08-08 13:34:27 +02:00
|
|
|
if ( sender() )
|
|
|
|
|
{
|
|
|
|
|
QVariant userData = this->userData();
|
|
|
|
|
if ( !userData.isNull() && userData.canConvert<void*>() )
|
|
|
|
|
{
|
|
|
|
|
RimSummaryPlot* plot = static_cast<RimSummaryPlot*>( userData.value<void*>() );
|
|
|
|
|
if ( plot ) return plot;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
|
|
|
|
if ( selObj )
|
2017-10-02 12:48:01 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
sumPlot = RiaSummaryTools::parentSummaryPlot( selObj );
|
2017-10-02 12:48:01 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-13 11:14:30 +02:00
|
|
|
if ( !sumPlot )
|
|
|
|
|
{
|
|
|
|
|
RimSummaryMultiPlot* multiPlot = RiaSummaryTools::parentSummaryMultiPlot( selObj );
|
|
|
|
|
if ( multiPlot )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-02 12:48:01 +02:00
|
|
|
return sumPlot;
|
|
|
|
|
}
|