#4166 Add feature for swapping cross plot axes + tweaks to legend

* Also put x and y property side by side in property editor
This commit is contained in:
Gaute Lindkvist
2019-03-08 09:59:29 +01:00
parent 1e777eaea0
commit e00f983360
16 changed files with 210 additions and 35 deletions

View File

@@ -2,11 +2,13 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCrossPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCrossPlotCurveSetFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSwapGridCrossPlotCurveSetAxesFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCrossPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCrossPlotCurveSetFeature.cpp)
${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCrossPlotCurveSetFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSwapGridCrossPlotCurveSetAxesFeature.cpp)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}

View File

@@ -19,8 +19,6 @@
#include "cafCmdFeature.h"
#include <vector>
//==================================================================================================
///
//==================================================================================================

View File

@@ -0,0 +1,61 @@
#include "RicSwapGridCrossPlotCurveSetAxesFeature.h"
#include "RimGridCrossPlot.h"
#include "RimGridCrossPlotCurveSet.h"
#include <cafSelectionManager.h>
#include <QAction>
CAF_CMD_SOURCE_INIT(RicSwapGridCrossPlotCurveSetAxesFeature, "RicSwapGridCrossPlotCurveSetAxesFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSwapGridCrossPlotCurveSetAxesFeature::isCommandEnabled()
{
if (caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlotCurveSet>())
{
return true;
}
else if (caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlot>())
{
auto plot = caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlot>();
if (!plot->curveSets().empty())
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSwapGridCrossPlotCurveSetAxesFeature::onActionTriggered(bool isChecked)
{
if (caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlotCurveSet>())
{
auto curveSet = caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlotCurveSet>();
curveSet->swapAxisProperties(true);
}
else if (caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlot>())
{
auto plot = caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlot>();
plot->swapAllAxisProperties();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSwapGridCrossPlotCurveSetAxesFeature::setupActionLook(QAction* actionToSetup)
{
if (caf::SelectionManager::instance()->selectedItemOfType<RimGridCrossPlotCurveSet>())
{
actionToSetup->setText("Swap Axis Properties");
}
else
{
actionToSetup->setText("Swap Axis Properties for all Data Sets in Plot");
}
actionToSetup->setIcon(QIcon(":/Swap.png"));
}

View File

@@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicSwapGridCrossPlotCurveSetAxesFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override;
};