ResInsight/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp

111 lines
3.5 KiB
C++
Raw Normal View History

2016-06-24 08:10:18 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiuMdiSubWindow.h"
#include "RiaApplication.h"
2016-06-24 08:10:18 -05:00
#include "RimSummaryPlot.h"
2018-01-09 03:11:28 -06:00
#include "Rim3dView.h"
2016-06-24 08:10:18 -05:00
#include "RimWellLogPlot.h"
2018-04-26 23:28:08 -05:00
#include "RiuPlotMainWindow.h"
#include "RiuMainWindow.h"
2016-06-24 08:10:18 -05:00
#include "RiuSummaryQwtPlot.h"
#include "RiuViewer.h"
#include "RiuWellLogPlot.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMdiSubWindow::RiuMdiSubWindow(QWidget* parent /*= 0*/, Qt::WindowFlags flags /*= 0*/) : QMdiSubWindow(parent, flags)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMdiSubWindow::~RiuMdiSubWindow()
{
RiuMainWindow::instance()->slotRefreshViewActions();
2016-06-24 08:10:18 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMdiSubWindow::closeEvent(QCloseEvent* event)
{
QWidget* mainWidget = widget();
RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget(mainWidget);
if ( viewWindow )
2016-06-24 08:10:18 -05:00
{
viewWindow->setMdiWindowGeometry(windowGeometryForWidget(this));
2016-06-24 08:10:18 -05:00
}
else
{
RiuViewer* viewer = mainWidget->findChild<RiuViewer*>();
if (viewer)
{
viewer->ownerReservoirView()->setMdiWindowGeometry(windowGeometryForWidget(this));
2016-06-24 08:10:18 -05:00
}
}
QMdiSubWindow::closeEvent(event);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMdiWindowGeometry RiuMdiSubWindow::windowGeometryForWidget(QWidget* widget)
{
RimMdiWindowGeometry geo;
if (widget)
{
// Find topmost parent
QWidget* nextParent = widget->parentWidget();
QWidget* parent = nullptr;
while (nextParent)
{
parent = nextParent;
nextParent = nextParent->parentWidget();
}
int mainWinID = 0;
if (parent)
{
if (parent == RiaApplication::instance()->mainPlotWindow())
{
mainWinID = 1;
}
}
geo.mainWindowID = mainWinID;
geo.x = widget->pos().x();
geo.y = widget->pos().y();
geo.width = widget->size().width();
geo.height = widget->size().height();
geo.isMaximized = widget->isMaximized();
}
return geo;
}