2019-02-21 05:52:23 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2019- Equinor 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 "RicCreateGridCrossPlotFeature.h"
|
|
|
|
|
2019-05-06 03:36:05 -05:00
|
|
|
#include "RiaGuiApplication.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-03-01 08:49:02 -06:00
|
|
|
#include "RimEclipseView.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
#include "RimGridCrossPlot.h"
|
|
|
|
#include "RimGridCrossPlotCollection.h"
|
2019-03-29 07:17:39 -05:00
|
|
|
#include "RimGridCrossPlotDataSet.h"
|
2019-03-01 08:49:02 -06:00
|
|
|
#include "RimGridView.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
|
|
|
|
#include "RiuPlotMainWindowTools.h"
|
2019-10-22 08:15:25 -05:00
|
|
|
#include "RiuViewer.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
|
2019-10-22 08:15:25 -05:00
|
|
|
#include "cafCmdFeatureManager.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
#include "cafSelectionManager.h"
|
2023-05-12 14:41:34 -05:00
|
|
|
#include "cafSelectionManagerTools.h"
|
2019-02-21 05:52:23 -06:00
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicCreateGridCrossPlotFeature, "RicCreateGridCrossPlotFeature" );
|
2019-02-21 05:52:23 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicCreateGridCrossPlotFeature::onActionTriggered( bool isChecked )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2023-02-26 03:48:40 -06:00
|
|
|
RimGridCrossPlotCollection* collection = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimGridCrossPlotCollection>();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !collection )
|
2019-03-01 08:49:02 -06:00
|
|
|
{
|
2022-08-19 07:30:25 -05:00
|
|
|
collection = RimMainPlotCollection::current()->gridCrossPlotCollection();
|
2019-03-01 08:49:02 -06:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
RimGridCrossPlot* plot = collection->createGridCrossPlot();
|
2019-03-29 07:17:39 -05:00
|
|
|
RimGridCrossPlotDataSet* dataSet = plot->createDataSet();
|
2019-03-01 08:49:02 -06:00
|
|
|
|
2019-10-22 08:15:25 -05:00
|
|
|
auto contextViewer = dynamic_cast<RiuViewer*>( caf::CmdFeatureManager::instance()->currentContextMenuTargetWidget() );
|
|
|
|
if ( contextViewer != nullptr )
|
|
|
|
{
|
|
|
|
// Command is triggered from viewer
|
|
|
|
dataSet->setCellFilterView( RiaApplication::instance()->activeMainOrComparisonGridView() );
|
|
|
|
}
|
|
|
|
else
|
2019-03-01 08:49:02 -06:00
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
auto cellFilterView = caf::firstAncestorOfTypeFromSelectedObject<RimGridView>();
|
2022-06-08 16:17:16 -05:00
|
|
|
if ( cellFilterView ) dataSet->setCellFilterView( cellFilterView );
|
2019-03-01 08:49:02 -06:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2019-02-21 05:52:23 -06:00
|
|
|
plot->loadDataAndUpdate();
|
2019-02-25 07:54:36 -06:00
|
|
|
plot->zoomAll();
|
2019-02-21 05:52:23 -06:00
|
|
|
plot->updateConnectedEditors();
|
|
|
|
|
2019-03-04 03:19:02 -06:00
|
|
|
collection->updateAllRequiredEditors();
|
2019-05-06 03:36:05 -05:00
|
|
|
RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow();
|
2022-08-18 05:37:51 -05:00
|
|
|
|
|
|
|
RiuPlotMainWindowTools::onObjectAppended( dataSet );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicCreateGridCrossPlotFeature::setupActionLook( QAction* actionToSetup )
|
2019-02-21 05:52:23 -06:00
|
|
|
{
|
2019-10-22 08:15:25 -05:00
|
|
|
auto contextViewer = dynamic_cast<RiuViewer*>( caf::CmdFeatureManager::instance()->currentContextMenuTargetWidget() );
|
|
|
|
if ( contextViewer != nullptr )
|
2019-03-01 08:49:02 -06:00
|
|
|
{
|
2019-10-22 08:15:25 -05:00
|
|
|
// Command is triggered from viewer
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Create Grid Cross Plot from 3d View" );
|
2019-03-01 08:49:02 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-22 08:15:25 -05:00
|
|
|
// Command triggered from project tree or file menu
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Create Grid Cross Plot" );
|
2019-03-01 08:49:02 -06:00
|
|
|
}
|
2019-10-22 08:15:25 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/SummaryXPlotsLight16x16.png" ) );
|
2019-02-21 05:52:23 -06:00
|
|
|
}
|