2016-06-24 08:10:18 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2016 Statoil ASA
|
2019-03-26 10:19:56 -05:00
|
|
|
//
|
2016-06-24 08:10:18 -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.
|
2019-03-26 10:19:56 -05:00
|
|
|
//
|
2016-06-24 08:10:18 -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.
|
2019-03-26 10:19:56 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2016-06-24 08:10:18 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RiuMdiSubWindow.h"
|
|
|
|
|
2019-05-06 03:36:05 -05:00
|
|
|
#include "RiaGuiApplication.h"
|
2016-06-27 04:07:01 -05:00
|
|
|
|
2018-01-09 03:11:28 -06:00
|
|
|
#include "Rim3dView.h"
|
2019-03-26 10:19:56 -05:00
|
|
|
#include "RimSummaryPlot.h"
|
2016-06-24 08:10:18 -05:00
|
|
|
#include "RimWellLogPlot.h"
|
|
|
|
|
2016-06-27 04:07:01 -05:00
|
|
|
#include "RiuMainWindow.h"
|
2019-03-26 10:19:56 -05:00
|
|
|
#include "RiuPlotMainWindow.h"
|
2016-06-24 08:10:18 -05:00
|
|
|
#include "RiuViewer.h"
|
|
|
|
#include "RiuWellLogPlot.h"
|
|
|
|
|
2019-03-29 06:00:29 -05:00
|
|
|
#include <QWindowStateChangeEvent>
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
2016-06-24 08:10:18 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-26 10:19:56 -05:00
|
|
|
///
|
2016-06-24 08:10:18 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-26 10:19:56 -05:00
|
|
|
RiuMdiSubWindow::RiuMdiSubWindow(QWidget* parent /*= 0*/, Qt::WindowFlags flags /*= 0*/)
|
|
|
|
: QMdiSubWindow(parent, flags)
|
2019-03-29 06:00:29 -05:00
|
|
|
, m_normalWindowGeometry(QRect())
|
2019-04-02 12:18:00 -05:00
|
|
|
, m_blockTilingChanges(false)
|
2016-06-24 08:10:18 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-26 10:19:56 -05:00
|
|
|
///
|
2016-06-24 08:10:18 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiuMdiSubWindow::~RiuMdiSubWindow()
|
|
|
|
{
|
2016-06-27 04:07:01 -05:00
|
|
|
RiuMainWindow::instance()->slotRefreshViewActions();
|
2016-06-24 08:10:18 -05:00
|
|
|
}
|
|
|
|
|
2019-03-29 06:00:29 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimMdiWindowGeometry RiuMdiSubWindow::windowGeometry() const
|
|
|
|
{
|
|
|
|
RimMdiWindowGeometry geo;
|
|
|
|
|
|
|
|
int mainWinID = 0;
|
2019-05-06 03:36:05 -05:00
|
|
|
if (window() == RiaGuiApplication::instance()->mainPlotWindow())
|
2019-03-29 06:00:29 -05:00
|
|
|
{
|
|
|
|
mainWinID = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
geo.mainWindowID = mainWinID;
|
|
|
|
geo.isMaximized = isMaximized();
|
|
|
|
|
|
|
|
// Save normal/non-maximized size and position so this can be restored
|
|
|
|
QRect currentGeometry = frameGeometry();
|
|
|
|
if (isMaximized() && !m_normalWindowGeometry.isNull())
|
|
|
|
{
|
|
|
|
currentGeometry = m_normalWindowGeometry;
|
|
|
|
}
|
|
|
|
|
|
|
|
geo.x = currentGeometry.topLeft().x();
|
|
|
|
geo.y = currentGeometry.topLeft().y();
|
|
|
|
geo.width = currentGeometry.width();
|
|
|
|
geo.height = currentGeometry.height();
|
|
|
|
|
|
|
|
return geo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-02 12:18:00 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuMdiSubWindow::blockTilingChanges(bool block)
|
|
|
|
{
|
|
|
|
m_blockTilingChanges = block;
|
|
|
|
}
|
|
|
|
|
2016-06-24 08:10:18 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-26 10:19:56 -05:00
|
|
|
///
|
2016-06-24 08:10:18 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuMdiSubWindow::closeEvent(QCloseEvent* event)
|
|
|
|
{
|
|
|
|
QWidget* mainWidget = widget();
|
|
|
|
|
2019-04-16 03:41:03 -05:00
|
|
|
RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget(mainWidget);
|
|
|
|
if (!viewWindow)
|
2016-06-24 08:10:18 -05:00
|
|
|
{
|
|
|
|
RiuViewer* viewer = mainWidget->findChild<RiuViewer*>();
|
|
|
|
if (viewer)
|
|
|
|
{
|
2019-04-16 03:41:03 -05:00
|
|
|
viewWindow = viewer->ownerViewWindow();
|
2016-06-24 08:10:18 -05:00
|
|
|
}
|
|
|
|
}
|
2019-04-02 12:18:00 -05:00
|
|
|
|
2019-04-16 03:41:03 -05:00
|
|
|
if (viewWindow)
|
2019-04-02 12:18:00 -05:00
|
|
|
{
|
2019-04-16 03:41:03 -05:00
|
|
|
viewWindow->setMdiWindowGeometry(windowGeometry());
|
|
|
|
viewWindow->handleMdiWindowClosed();
|
|
|
|
event->accept();
|
2019-04-02 12:18:00 -05:00
|
|
|
}
|
2019-04-16 03:41:03 -05:00
|
|
|
else
|
2019-04-02 12:18:00 -05:00
|
|
|
{
|
2019-04-16 03:41:03 -05:00
|
|
|
QMdiSubWindow::closeEvent(event);
|
2019-04-02 12:18:00 -05:00
|
|
|
}
|
2016-06-24 08:10:18 -05:00
|
|
|
}
|
2017-03-31 08:10:39 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-26 10:19:56 -05:00
|
|
|
///
|
2017-03-31 08:10:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-29 06:00:29 -05:00
|
|
|
void RiuMdiSubWindow::resizeEvent(QResizeEvent* resizeEvent)
|
2017-03-31 08:10:39 -05:00
|
|
|
{
|
2019-03-29 06:00:29 -05:00
|
|
|
if (!isMaximized())
|
2017-03-31 08:10:39 -05:00
|
|
|
{
|
2019-03-29 06:00:29 -05:00
|
|
|
m_normalWindowGeometry = frameGeometry();
|
|
|
|
}
|
2019-04-02 12:18:00 -05:00
|
|
|
|
|
|
|
if (!m_blockTilingChanges)
|
|
|
|
{
|
2019-05-06 03:36:05 -05:00
|
|
|
if (window() == RiaGuiApplication::instance()->mainWindow())
|
2019-04-02 12:18:00 -05:00
|
|
|
{
|
2019-05-06 03:36:05 -05:00
|
|
|
RiaGuiApplication::instance()->mainWindow()->storeSubWindowTiling(false);
|
2019-04-02 12:18:00 -05:00
|
|
|
}
|
2019-05-06 03:36:05 -05:00
|
|
|
else if (window() == RiaGuiApplication::instance()->mainPlotWindow())
|
2019-04-02 12:18:00 -05:00
|
|
|
{
|
2019-05-06 03:36:05 -05:00
|
|
|
RiaGuiApplication::instance()->mainPlotWindow()->storeSubWindowTiling(false);
|
2019-04-02 12:18:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-29 06:00:29 -05:00
|
|
|
QMdiSubWindow::resizeEvent(resizeEvent);
|
|
|
|
}
|
2019-03-26 10:19:56 -05:00
|
|
|
|
2019-03-29 06:00:29 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuMdiSubWindow::moveEvent(QMoveEvent* moveEvent)
|
|
|
|
{
|
|
|
|
if (!isMaximized())
|
|
|
|
{
|
|
|
|
m_normalWindowGeometry = frameGeometry();
|
2019-03-26 10:19:56 -05:00
|
|
|
}
|
2019-04-02 12:18:00 -05:00
|
|
|
|
|
|
|
if (!m_blockTilingChanges)
|
|
|
|
{
|
2019-05-06 03:36:05 -05:00
|
|
|
if (window() == RiaGuiApplication::instance()->mainWindow())
|
2019-04-02 12:18:00 -05:00
|
|
|
{
|
2019-05-06 03:36:05 -05:00
|
|
|
RiaGuiApplication::instance()->mainWindow()->storeSubWindowTiling(false);
|
2019-04-02 12:18:00 -05:00
|
|
|
}
|
2019-05-06 03:36:05 -05:00
|
|
|
else if (window() == RiaGuiApplication::instance()->mainPlotWindow())
|
2019-04-02 12:18:00 -05:00
|
|
|
{
|
2019-05-06 03:36:05 -05:00
|
|
|
RiaGuiApplication::instance()->mainPlotWindow()->storeSubWindowTiling(false);
|
2019-04-02 12:18:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-29 06:00:29 -05:00
|
|
|
QMdiSubWindow::moveEvent(moveEvent);
|
2017-03-31 08:10:39 -05:00
|
|
|
}
|