mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-05 21:53:27 -06:00
358 lines
14 KiB
C++
358 lines
14 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2015- Statoil ASA
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
//
|
|
// 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 "RicTileWindowsFeature.h"
|
|
|
|
#include "RiaGuiApplication.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RiuMainWindow.h"
|
|
#include "RiuMdiArea.h"
|
|
#include "RiuPlotMainWindow.h"
|
|
|
|
#include <QAction>
|
|
#include <QApplication>
|
|
|
|
CAF_CMD_SOURCE_INIT( RicTileWindowsFeature, "RicTileWindowsFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTileWindowsFeature::applyTiling( RiuMainWindow* mainWindow, RiaDefines::WindowTileMode requestedTileMode )
|
|
{
|
|
auto mode = requestedTileMode;
|
|
|
|
if ( auto proj = RimProject::current() )
|
|
{
|
|
// If requested mode is set, reset tiling mode to undefined
|
|
if ( proj->subWindowsTileMode3DWindow() == requestedTileMode ) mode = RiaDefines::WindowTileMode::UNDEFINED;
|
|
|
|
proj->setSubWindowsTileMode3DWindow( mode );
|
|
}
|
|
|
|
if ( mainWindow )
|
|
{
|
|
mainWindow->mdiArea()->applyTiling();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTileWindowsFeature::isCommandEnabled() const
|
|
{
|
|
auto* mainWindow = RiuMainWindow::instance();
|
|
if ( mainWindow )
|
|
{
|
|
return mainWindow->isAnyMdiSubWindowVisible();
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTileWindowsFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
disableModelChangeContribution();
|
|
|
|
auto* mainWindow = RiuMainWindow::instance();
|
|
applyTiling( mainWindow, RiaDefines::WindowTileMode::DEFAULT );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTileWindowsFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setText( "Tile Windows" );
|
|
actionToSetup->setIcon( QIcon( ":/TileWindows.svg" ) );
|
|
actionToSetup->setCheckable( true );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTileWindowsFeature::isCommandChecked() const
|
|
{
|
|
auto proj = RimProject::current();
|
|
|
|
return proj ? ( proj->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::DEFAULT ) : false;
|
|
}
|
|
|
|
CAF_CMD_SOURCE_INIT( RicTilePlotWindowsFeature, "RicTilePlotWindowsFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTilePlotWindowsFeature::applyTiling( RiuPlotMainWindow* mainWindow, RiaDefines::WindowTileMode requestedTileMode )
|
|
{
|
|
auto mode = requestedTileMode;
|
|
|
|
if ( auto proj = RimProject::current() )
|
|
{
|
|
// If requested mode is set, reset tiling mode to undefined
|
|
if ( proj->subWindowsTileModePlotWindow() == requestedTileMode ) mode = RiaDefines::WindowTileMode::UNDEFINED;
|
|
|
|
proj->setSubWindowsTileModePlotWindow( mode );
|
|
}
|
|
|
|
if ( mainWindow )
|
|
{
|
|
mainWindow->mdiArea()->applyTiling();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTilePlotWindowsFeature::isCommandEnabled() const
|
|
{
|
|
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
|
if ( mainPlotWindow )
|
|
{
|
|
return mainPlotWindow->isAnyMdiSubWindowVisible();
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTilePlotWindowsFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
disableModelChangeContribution();
|
|
|
|
auto* mainWindow = RiuPlotMainWindow::instance();
|
|
RicTilePlotWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::DEFAULT );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTilePlotWindowsFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setText( "Tile Windows" );
|
|
actionToSetup->setIcon( QIcon( ":/TileWindows.svg" ) );
|
|
actionToSetup->setCheckable( true );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTilePlotWindowsFeature::isCommandChecked() const
|
|
{
|
|
auto proj = RimProject::current();
|
|
|
|
return proj ? ( proj->subWindowsTileModePlotWindow() == RiaDefines::WindowTileMode::DEFAULT ) : false;
|
|
}
|
|
|
|
CAF_CMD_SOURCE_INIT( RicTileWindowsVerticallyFeature, "RicTileWindowsVerticallyFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTileWindowsVerticallyFeature::isCommandEnabled() const
|
|
{
|
|
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
|
if ( mainWindow )
|
|
{
|
|
return mainWindow->isAnyMdiSubWindowVisible();
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTileWindowsVerticallyFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
disableModelChangeContribution();
|
|
|
|
auto* mainWindow = RiuMainWindow::instance();
|
|
RicTileWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::VERTICAL );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTileWindowsVerticallyFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setText( "Tile Windows Vertically" );
|
|
actionToSetup->setIcon( QIcon( ":/TileWindows.svg" ) );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTileWindowsVerticallyFeature::isCommandChecked() const
|
|
{
|
|
auto proj = RimProject::current();
|
|
|
|
return proj ? ( proj->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::VERTICAL ) : false;
|
|
}
|
|
|
|
CAF_CMD_SOURCE_INIT( RicTileWindowsHorizontallyFeature, "RicTileWindowsHorizontallyFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTileWindowsHorizontallyFeature::isCommandEnabled() const
|
|
{
|
|
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
|
if ( mainWindow )
|
|
{
|
|
return mainWindow->isAnyMdiSubWindowVisible();
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTileWindowsHorizontallyFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
disableModelChangeContribution();
|
|
|
|
auto* mainWindow = RiuMainWindow::instance();
|
|
RicTileWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::HORIZONTAL );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTileWindowsHorizontallyFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setText( "Tile Windows Horizontally" );
|
|
actionToSetup->setIcon( QIcon( ":/TileWindows.svg" ) );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTileWindowsHorizontallyFeature::isCommandChecked() const
|
|
{
|
|
auto proj = RimProject::current();
|
|
|
|
return proj ? ( proj->subWindowsTileMode3DWindow() == RiaDefines::WindowTileMode::HORIZONTAL ) : false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
/// Main Plot window features
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
CAF_CMD_SOURCE_INIT( RicTilePlotWindowsVerticallyFeature, "RicTilePlotWindowsVerticallyFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTilePlotWindowsVerticallyFeature::isCommandEnabled() const
|
|
{
|
|
auto* mainWindow = RiuPlotMainWindow::instance();
|
|
if ( mainWindow )
|
|
{
|
|
return mainWindow->isAnyMdiSubWindowVisible();
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTilePlotWindowsVerticallyFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
disableModelChangeContribution();
|
|
|
|
auto* mainWindow = RiuPlotMainWindow::instance();
|
|
RicTilePlotWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::VERTICAL );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTilePlotWindowsVerticallyFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setText( "Tile Windows Vertically" );
|
|
actionToSetup->setIcon( QIcon( ":/TileWindows.svg" ) );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTilePlotWindowsVerticallyFeature::isCommandChecked() const
|
|
{
|
|
auto proj = RimProject::current();
|
|
|
|
return proj ? ( proj->subWindowsTileModePlotWindow() == RiaDefines::WindowTileMode::VERTICAL ) : false;
|
|
}
|
|
|
|
CAF_CMD_SOURCE_INIT( RicTilePlotWindowsHorizontallyFeature, "RicTilePlotWindowsHorizontallyFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTilePlotWindowsHorizontallyFeature::isCommandEnabled() const
|
|
{
|
|
auto* mainWindow = RiuPlotMainWindow::instance();
|
|
if ( mainWindow )
|
|
{
|
|
return mainWindow->isAnyMdiSubWindowVisible();
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTilePlotWindowsHorizontallyFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
disableModelChangeContribution();
|
|
|
|
auto* mainWindow = RiuPlotMainWindow::instance();
|
|
RicTilePlotWindowsFeature::applyTiling( mainWindow, RiaDefines::WindowTileMode::HORIZONTAL );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTilePlotWindowsHorizontallyFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setText( "Tile Windows Horizontally" );
|
|
actionToSetup->setIcon( QIcon( ":/TileWindows.svg" ) );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTilePlotWindowsHorizontallyFeature::isCommandChecked() const
|
|
{
|
|
auto proj = RimProject::current();
|
|
|
|
return proj ? ( proj->subWindowsTileModePlotWindow() == RiaDefines::WindowTileMode::HORIZONTAL ) : false;
|
|
}
|