ResInsight/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp

86 lines
3.0 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 "RiaGuiApplication.h"
2016-07-05 03:47:03 -05:00
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
//--------------------------------------------------------------------------------------------------
///
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 )
2016-07-05 03:47:03 -05:00
{
this->disableModelChangeContribution();
QWidget* topLevelWidget = RiaGuiApplication::activeWindow();
2016-07-05 03:47:03 -05:00
if ( dynamic_cast<RiuMainWindow*>( topLevelWidget ) )
2016-07-05 03:47:03 -05:00
{
RimViewWindow* viewWindow = RiaGuiApplication::instance()->activeReservoirView();
if ( viewWindow )
2018-05-14 02:53:26 -05:00
{
viewWindow->zoomAll();
}
2016-07-05 03:47:03 -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 )
2016-07-05 03:47:03 -05:00
{
actionToSetup->setText( "Zoom All" );
actionToSetup->setToolTip( "Zoom All (Ctrl+Alt+A)" );
actionToSetup->setIcon( QIcon( ":/ZoomAll16x16.png" ) );
applyShortcutWithHintToAction( actionToSetup, QKeySequence( tr( "Ctrl+Alt+A" ) ) );
2016-07-05 03:47:03 -05:00
}