mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#869) Datastructures for right y-axis
This commit is contained in:
@@ -10,6 +10,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -17,6 +18,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- Statoil 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 "RicSummaryCurveSwitchAxisFeature.h"
|
||||
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveFilter.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicSummaryCurveSwitchAxisFeature, "RicSummaryCurveSwitchAxisFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicSummaryCurveSwitchAxisFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveSwitchAxisFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimSummaryCurve* summaryCurve = RicSummaryCurveSwitchAxisFeature::selectedSummaryCurve();
|
||||
RimSummaryCurveFilter* summaryCurveFilter = RicSummaryCurveSwitchAxisFeature::selectedSummaryCurveFilter();
|
||||
if (summaryCurve)
|
||||
{
|
||||
RimDefines::PlotAxis plotAxis = summaryCurve->associatedPlotAxis();
|
||||
|
||||
if (plotAxis == RimDefines::PLOT_AXIS_LEFT)
|
||||
{
|
||||
summaryCurve->setPlotAxis(RimDefines::PLOT_AXIS_RIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
summaryCurve->setPlotAxis(RimDefines::PLOT_AXIS_LEFT);
|
||||
}
|
||||
|
||||
summaryCurve->updateQwtPlotAxis();
|
||||
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
summaryCurve->firstAncestorOrThisOfType(plot);
|
||||
if (plot) plot->updateLeftAndRightYAxis();
|
||||
}
|
||||
else if (summaryCurveFilter)
|
||||
{
|
||||
RimDefines::PlotAxis plotAxis = summaryCurveFilter->associatedPlotAxis();
|
||||
|
||||
if (plotAxis == RimDefines::PLOT_AXIS_LEFT)
|
||||
{
|
||||
summaryCurveFilter->setPlotAxis(RimDefines::PLOT_AXIS_RIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
summaryCurveFilter->setPlotAxis(RimDefines::PLOT_AXIS_LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveSwitchAxisFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Switch Plot Axis");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurve* RicSummaryCurveSwitchAxisFeature::selectedSummaryCurve()
|
||||
{
|
||||
std::vector<RimSummaryCurve*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
return selection.size() > 0 ? selection[0] : nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurveFilter* RicSummaryCurveSwitchAxisFeature::selectedSummaryCurveFilter()
|
||||
{
|
||||
std::vector<RimSummaryCurveFilter*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
return selection.size() > 0 ? selection[0] : nullptr;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- Statoil 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 RimSummaryCurve;
|
||||
class RimSummaryCurveFilter;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSummaryCurveSwitchAxisFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
static RimSummaryCurve* selectedSummaryCurve();
|
||||
static RimSummaryCurveFilter* selectedSummaryCurveFilter();
|
||||
};
|
||||
Reference in New Issue
Block a user