2016-10-27 04:03:13 -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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-05-24 03:37:10 -05:00
|
|
|
#include "RimViewWindow.h"
|
2018-11-05 07:28:07 -06:00
|
|
|
|
|
|
|
#include "RiaFieldHandleTools.h"
|
2019-05-06 03:36:05 -05:00
|
|
|
#include "RiaGuiApplication.h"
|
2018-11-05 07:28:07 -06:00
|
|
|
|
2017-01-17 06:06:57 -06:00
|
|
|
#include "RimMdiWindowController.h"
|
2018-11-05 07:28:07 -06:00
|
|
|
|
2017-01-17 06:06:57 -06:00
|
|
|
#include "cvfAssert.h"
|
2018-11-05 07:28:07 -06:00
|
|
|
|
2017-01-17 06:06:57 -06:00
|
|
|
#include <QWidget>
|
2016-05-24 03:37:10 -05:00
|
|
|
|
|
|
|
CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimViewWindow, "ViewWindow"); // Do not use. Abstract class
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimViewWindow::RimViewWindow(void)
|
|
|
|
{
|
2017-01-17 06:06:57 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_windowController, "WindowController", "", "", "", "");
|
|
|
|
m_windowController.uiCapability()->setUiHidden(true);
|
2017-01-19 10:39:43 -06:00
|
|
|
m_windowController.uiCapability()->setUiTreeChildrenHidden(true);
|
2017-01-17 06:06:57 -06:00
|
|
|
|
2017-01-20 09:25:05 -06:00
|
|
|
CAF_PDM_InitField(&m_showWindow, "ShowWindow", true, "Show Window", "", "", "");
|
|
|
|
m_showWindow.uiCapability()->setUiHidden(true);
|
|
|
|
|
2017-01-17 06:06:57 -06:00
|
|
|
// Obsolete field
|
2017-01-20 04:38:18 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&obsoleteField_windowGeometry, "WindowGeometry", "", "", "", "");
|
2018-11-05 07:28:07 -06:00
|
|
|
RiaFieldhandleTools::disableWriteAndSetFieldHidden(&obsoleteField_windowGeometry);
|
2016-05-24 03:37:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimViewWindow::~RimViewWindow(void)
|
|
|
|
{
|
2017-01-17 06:06:57 -06:00
|
|
|
if ( m_windowController() ) delete m_windowController() ;
|
|
|
|
}
|
|
|
|
|
2017-10-31 06:49:14 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewWindow::loadDataAndUpdate()
|
|
|
|
{
|
|
|
|
onLoadDataAndUpdate();
|
|
|
|
}
|
|
|
|
|
2017-01-17 06:06:57 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-20 04:38:18 -06:00
|
|
|
void RimViewWindow::removeMdiWindowFromMdiArea()
|
2017-01-17 06:06:57 -06:00
|
|
|
{
|
|
|
|
if ( m_windowController() ) m_windowController->removeWindowFromMDI();
|
|
|
|
}
|
|
|
|
|
2018-06-26 03:24:29 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimViewWindow::windowTitle()
|
|
|
|
{
|
|
|
|
if (this->userDescriptionField())
|
|
|
|
{
|
|
|
|
caf::PdmUiFieldHandle* uiFieldHandle = this->userDescriptionField()->uiCapability();
|
|
|
|
if (uiFieldHandle)
|
|
|
|
{
|
|
|
|
QVariant v = uiFieldHandle->uiValue();
|
|
|
|
return v.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QString("");
|
|
|
|
}
|
|
|
|
|
2017-01-17 06:06:57 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-20 04:38:18 -06:00
|
|
|
void RimViewWindow::handleMdiWindowClosed()
|
2017-01-17 06:06:57 -06:00
|
|
|
{
|
|
|
|
if ( m_windowController() ) m_windowController->handleViewerDeletion();
|
|
|
|
}
|
2016-05-24 03:37:10 -05:00
|
|
|
|
2017-01-17 06:06:57 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-20 04:38:18 -06:00
|
|
|
void RimViewWindow::updateMdiWindowVisibility()
|
2017-01-17 06:06:57 -06:00
|
|
|
{
|
2019-05-06 03:36:05 -05:00
|
|
|
if (!RiaGuiApplication::isRunning()) return;
|
|
|
|
|
2017-01-20 09:25:05 -06:00
|
|
|
if (m_windowController())
|
|
|
|
{
|
|
|
|
m_windowController->updateViewerWidget();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (viewWidget())
|
|
|
|
{
|
2018-01-23 07:23:28 -06:00
|
|
|
if (isWindowVisible())
|
2017-01-20 09:25:05 -06:00
|
|
|
{
|
|
|
|
viewWidget()->show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
viewWidget()->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-24 03:37:10 -05:00
|
|
|
}
|
|
|
|
|
2017-02-14 08:03:54 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimViewWindow::isMdiWindow() const
|
|
|
|
{
|
|
|
|
if (m_windowController())
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-26 06:17:26 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewWindow::setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry)
|
|
|
|
{
|
2017-01-17 06:06:57 -06:00
|
|
|
CVF_ASSERT(m_windowController());
|
|
|
|
|
|
|
|
if (m_windowController()) m_windowController()->setMdiWindowGeometry(windowGeometry);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimMdiWindowGeometry RimViewWindow::mdiWindowGeometry()
|
|
|
|
{
|
|
|
|
CVF_ASSERT(m_windowController());
|
|
|
|
|
|
|
|
if (m_windowController()) return m_windowController()->mdiWindowGeometry();
|
|
|
|
else return RimMdiWindowGeometry();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-01-03 10:07:55 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewWindow::viewNavigationChanged()
|
|
|
|
{
|
|
|
|
onViewNavigationChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Default implementation of virtual method to trigger updates on view navigation (zoom, camera move, etc)
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewWindow::onViewNavigationChanged()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-20 09:25:05 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimViewWindow::objectToggleField()
|
|
|
|
{
|
|
|
|
return &m_showWindow;
|
|
|
|
}
|
|
|
|
|
2017-01-17 06:06:57 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimViewWindow::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
2017-01-20 09:25:05 -06:00
|
|
|
if ( changedField == &m_showWindow )
|
2016-05-26 06:17:26 -05:00
|
|
|
{
|
2018-01-23 07:23:28 -06:00
|
|
|
if (isWindowVisible())
|
2017-01-20 09:25:05 -06:00
|
|
|
{
|
2017-10-31 06:49:14 -05:00
|
|
|
onLoadDataAndUpdate();
|
2017-01-20 09:25:05 -06:00
|
|
|
}
|
|
|
|
else
|
2017-01-17 06:06:57 -06:00
|
|
|
{
|
2017-01-20 09:25:05 -06:00
|
|
|
updateMdiWindowVisibility();
|
2017-01-17 06:06:57 -06:00
|
|
|
}
|
2017-01-20 09:25:05 -06:00
|
|
|
uiCapability()->updateUiIconFromToggleField();
|
2016-05-26 06:17:26 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-20 04:38:18 -06:00
|
|
|
void RimViewWindow::updateMdiWindowTitle()
|
2016-05-26 06:17:26 -05:00
|
|
|
{
|
2017-01-17 06:06:57 -06:00
|
|
|
if ( viewWidget() )
|
|
|
|
{
|
2018-06-26 03:24:29 -05:00
|
|
|
viewWidget()->setWindowTitle(windowTitle());
|
2017-01-17 06:06:57 -06:00
|
|
|
}
|
|
|
|
}
|
2016-05-26 06:17:26 -05:00
|
|
|
|
2017-01-17 06:06:57 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-20 04:38:18 -06:00
|
|
|
void RimViewWindow::setAsMdiWindow(int mainWindowID)
|
2017-01-17 06:06:57 -06:00
|
|
|
{
|
|
|
|
if ( !m_windowController() )
|
2016-05-26 06:17:26 -05:00
|
|
|
{
|
2017-01-17 06:06:57 -06:00
|
|
|
m_windowController = new RimMdiWindowController;
|
|
|
|
RimMdiWindowGeometry mwg;
|
|
|
|
mwg.mainWindowID = mainWindowID;
|
|
|
|
setMdiWindowGeometry(mwg);
|
2016-05-26 06:17:26 -05:00
|
|
|
}
|
2017-01-17 06:06:57 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-09 03:11:28 -06:00
|
|
|
#include "Rim3dView.h"
|
2017-01-17 06:06:57 -06:00
|
|
|
|
|
|
|
void RimViewWindow::initAfterRead()
|
|
|
|
{
|
2017-01-20 04:38:18 -06:00
|
|
|
if (obsoleteField_windowGeometry.value().size() == 5)
|
2017-01-17 06:06:57 -06:00
|
|
|
{
|
|
|
|
RimMdiWindowGeometry wg;
|
|
|
|
int mainWindowID = -1;
|
|
|
|
|
2018-01-09 03:11:28 -06:00
|
|
|
if (dynamic_cast<Rim3dView*> (this))
|
2017-01-17 06:06:57 -06:00
|
|
|
mainWindowID = 0;
|
|
|
|
else
|
|
|
|
mainWindowID = 1;
|
|
|
|
|
|
|
|
wg.mainWindowID = mainWindowID;
|
2017-01-20 04:38:18 -06:00
|
|
|
wg.x = obsoleteField_windowGeometry.value()[0];
|
|
|
|
wg.y = obsoleteField_windowGeometry.value()[1];
|
|
|
|
wg.width = obsoleteField_windowGeometry.value()[2];
|
|
|
|
wg.height = obsoleteField_windowGeometry.value()[3];
|
|
|
|
wg.isMaximized = obsoleteField_windowGeometry.value()[4];
|
2016-05-26 06:17:26 -05:00
|
|
|
|
2017-01-20 04:38:18 -06:00
|
|
|
setAsMdiWindow(mainWindowID);
|
2017-01-17 06:06:57 -06:00
|
|
|
setMdiWindowGeometry(wg);
|
|
|
|
}
|
2016-05-26 06:17:26 -05:00
|
|
|
}
|
2016-05-24 03:37:10 -05:00
|
|
|
|