2019-03-29 13:17:39 +01:00
|
|
|
#include "RicSwapGridCrossPlotDataSetAxesFeature.h"
|
2019-03-08 09:59:29 +01:00
|
|
|
|
|
|
|
|
#include "RimGridCrossPlot.h"
|
2019-03-29 13:17:39 +01:00
|
|
|
#include "RimGridCrossPlotDataSet.h"
|
2019-03-08 09:59:29 +01:00
|
|
|
|
|
|
|
|
#include <cafSelectionManager.h>
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_CMD_SOURCE_INIT( RicSwapGridCrossPlotDataSetAxesFeature, "RicSwapGridCrossPlotDataSetAxesFeature" );
|
2019-03-08 09:59:29 +01:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-29 13:17:39 +01:00
|
|
|
bool RicSwapGridCrossPlotDataSetAxesFeature::isCommandEnabled()
|
2019-03-08 09:59:29 +01:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlotDataSet>() )
|
2019-03-08 09:59:29 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-09-06 10:40:57 +02:00
|
|
|
else if ( caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlot>() )
|
2019-03-08 09:59:29 +01:00
|
|
|
{
|
|
|
|
|
auto plot = caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlot>();
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( !plot->dataSets().empty() ) return true;
|
2019-03-08 09:59:29 +01:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicSwapGridCrossPlotDataSetAxesFeature::onActionTriggered( bool isChecked )
|
2019-03-08 09:59:29 +01:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlotDataSet>() )
|
2019-03-08 09:59:29 +01:00
|
|
|
{
|
2019-03-29 13:17:39 +01:00
|
|
|
auto dataSet = caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlotDataSet>();
|
2019-09-06 10:40:57 +02:00
|
|
|
dataSet->swapAxisProperties( true );
|
2019-03-08 09:59:29 +01:00
|
|
|
}
|
2019-09-06 10:40:57 +02:00
|
|
|
else if ( caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlot>() )
|
2019-03-08 09:59:29 +01:00
|
|
|
{
|
|
|
|
|
auto plot = caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlot>();
|
2019-03-13 08:38:18 +01:00
|
|
|
plot->swapAxes();
|
2019-03-08 09:59:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicSwapGridCrossPlotDataSetAxesFeature::setupActionLook( QAction* actionToSetup )
|
2019-03-08 09:59:29 +01:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlotDataSet>() )
|
2019-03-08 09:59:29 +01:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
actionToSetup->setText( "Swap Axis Properties" );
|
2019-03-08 09:59:29 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
actionToSetup->setText( "Swap Axis Properties for all Data Sets in Plot" );
|
2019-03-08 09:59:29 +01:00
|
|
|
}
|
2019-09-06 10:40:57 +02:00
|
|
|
actionToSetup->setIcon( QIcon( ":/Swap.png" ) );
|
2019-03-08 09:59:29 +01:00
|
|
|
}
|