ResInsight/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp

84 lines
2.8 KiB
C++
Raw Normal View History

2016-07-05 03:47:03 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
//
2016-07-05 03:47:03 -05: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.
//
2016-07-05 03:47:03 -05: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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
2016-07-05 03:47:03 -05:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicViewZoomAllFeature.h"
#include "RiaApplication.h"
2018-01-09 03:11:28 -06:00
#include "Rim3dView.h"
2016-07-05 03:47:03 -05:00
#include "RimViewWindow.h"
#include "RiuInterfaceToViewWindow.h"
2016-07-05 03:47:03 -05:00
#include "RiuMainWindow.h"
#include "RiuPlotMainWindow.h"
2016-07-05 03:47:03 -05:00
#include <QAction>
#include <QMdiSubWindow>
CAF_CMD_SOURCE_INIT(RicViewZoomAllFeature, "RicViewZoomAllFeature");
//--------------------------------------------------------------------------------------------------
///
2016-07-05 03:47:03 -05:00
//--------------------------------------------------------------------------------------------------
bool RicViewZoomAllFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
2016-07-05 03:47:03 -05:00
//--------------------------------------------------------------------------------------------------
void RicViewZoomAllFeature::onActionTriggered(bool isChecked)
{
this->disableModelChangeContribution();
2016-07-05 03:47:03 -05:00
QWidget* topLevelWidget = RiaApplication::activeWindow();
if (dynamic_cast<RiuMainWindow*>(topLevelWidget))
{
RimViewWindow* viewWindow = RiaApplication::instance()->activeReservoirView();
2018-05-14 02:53:26 -05:00
if (viewWindow)
{
viewWindow->zoomAll();
}
2016-07-05 03:47:03 -05:00
}
2018-04-26 23:28:08 -05:00
else if (dynamic_cast<RiuPlotMainWindow*>(topLevelWidget))
2016-07-05 03:47:03 -05:00
{
RiuPlotMainWindow* mainPlotWindow = dynamic_cast<RiuPlotMainWindow*>(topLevelWidget);
QList<QMdiSubWindow*> subwindows = mainPlotWindow->subWindowList(QMdiArea::StackingOrder);
if (!subwindows.empty())
2016-07-05 03:47:03 -05:00
{
RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget(subwindows.back()->widget());
if (viewWindow)
{
viewWindow->zoomAll();
2017-03-28 16:30:01 -05:00
}
2016-07-05 03:47:03 -05:00
}
}
}
//--------------------------------------------------------------------------------------------------
///
2016-07-05 03:47:03 -05:00
//--------------------------------------------------------------------------------------------------
void RicViewZoomAllFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Zoom All");
actionToSetup->setIcon(QIcon(":/ZoomAll16x16.png"));
}