#851 Added "Open 3D Window" tool button in plot window. Raise mainWindow when activated from toolbar

This commit is contained in:
Magne Sjaastad 2016-10-04 09:29:45 +02:00
parent 0fc1d9cbf8
commit 3a2454cba0
10 changed files with 151 additions and 25 deletions

View File

@ -1387,10 +1387,8 @@ RiuMainPlotWindow* RiaApplication::getOrCreateAndShowMainPlotWindow()
createMainPlotWindow();
}
if (!m_mainPlotWindow->isVisible())
{
m_mainPlotWindow->show();
}
m_mainPlotWindow->show();
m_mainPlotWindow->raise();
return m_mainPlotWindow;
}
@ -1440,6 +1438,37 @@ RimViewWindow* RiaApplication::activeViewWindow()
return viewWindow;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication::tryCloseMainWindow()
{
RiuMainWindow* mainWindow = RiuMainWindow::instance();
if (mainWindow && !mainWindow->isVisible())
{
mainWindow->close();
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication::tryClosePlotWindow()
{
if (m_mainPlotWindow && !m_mainPlotWindow->isVisible())
{
m_mainPlotWindow->close();
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -182,6 +182,9 @@ public:
static RimViewWindow* activeViewWindow();
bool tryCloseMainWindow();
bool tryClosePlotWindow();
private:
enum ProjectLoadAction
{

View File

@ -48,6 +48,7 @@ ${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.h
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.h
${CEE_CURRENT_LIST_DIR}RicShowMainWindowFeature.h
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.h
@ -104,6 +105,7 @@ ${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.cpp
${CEE_CURRENT_LIST_DIR}RicShowMainWindowFeature.cpp
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.cpp

View File

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicShowMainWindowFeature.h"
#include "RiaApplication.h"
#include "RiuMainWindow.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicShowMainWindowFeature, "RicShowMainWindowFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicShowMainWindowFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicShowMainWindowFeature::onActionTriggered(bool isChecked)
{
RiuMainWindow* mainWnd = RiuMainWindow::instance();
mainWnd->show();
mainWnd->raise();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicShowMainWindowFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Open 3D Window");
actionToSetup->setIcon(QIcon(":/ReservoirView.png"));
}

View File

@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicShowMainWindowFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
};

View File

@ -45,6 +45,6 @@ void RicShowPlotWindowFeature::onActionTriggered(bool isChecked)
//--------------------------------------------------------------------------------------------------
void RicShowPlotWindowFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Show Plot Window");
actionToSetup->setText("Open Plot Window");
actionToSetup->setIcon(QIcon(":/SummaryPlots16x16.png"));
}

View File

@ -80,7 +80,7 @@ RiuMainPlotWindow::RiuMainPlotWindow()
// Store the layout so we can offer reset option
m_initialDockAndToolbarLayout = saveState(0);
m_dragDropInterface = new RiuDragDrop;
m_dragDropInterface = std::make_unique<RiuDragDrop>();
initializeGuiNewProjectLoaded();
@ -90,14 +90,6 @@ RiuMainPlotWindow::RiuMainPlotWindow()
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMainPlotWindow::~RiuMainPlotWindow()
{
delete m_dragDropInterface;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -126,6 +118,8 @@ void RiuMainPlotWindow::cleanupGuiBeforeProjectClose()
void RiuMainPlotWindow::closeEvent(QCloseEvent* event)
{
saveWinGeoAndDockToolBarLayout();
RiaApplication::instance()->tryClosePlotWindow();
}
//--------------------------------------------------------------------------------------------------
@ -189,6 +183,7 @@ void RiuMainPlotWindow::createToolBars()
QToolBar* toolbar = addToolBar(tr("Window Management"));
toolbar->setObjectName(toolbar->windowTitle());
toolbar->addAction(cmdFeatureMgr->action("RicTilePlotWindowsFeature"));
toolbar->addAction(cmdFeatureMgr->action("RicShowMainWindowFeature"));
}
}
@ -358,7 +353,7 @@ void RiuMainPlotWindow::setPdmRoot(caf::PdmObject* pdmRoot)
m_projectTreeView->setPdmItem(pdmRoot);
// For debug only : m_projectTreeView->treeView()->expandAll();
m_projectTreeView->setDragDropInterface(m_dragDropInterface);
m_projectTreeView->setDragDropInterface(m_dragDropInterface.get());
}
//--------------------------------------------------------------------------------------------------

View File

@ -22,6 +22,8 @@
#include <QMdiArea>
#include <memory>
class QMdiSubWindow;
class RiuViewer;
@ -48,7 +50,6 @@ class RiuMainPlotWindow : public RiuMainWindowBase
public:
RiuMainPlotWindow();
~RiuMainPlotWindow();
virtual QString mainWindowName() { return "RiuMainPlotWindow"; }
@ -125,7 +126,7 @@ public:
private:
caf::PdmUiTreeView* m_projectTreeView;
caf::PdmUiDragDropInterface* m_dragDropInterface;
std::unique_ptr<caf::PdmUiDragDropInterface> m_dragDropInterface;
caf::PdmObject* m_pdmRoot;
caf::PdmUiPropertyView* m_pdmUiPropertyView;

View File

@ -139,7 +139,7 @@ RiuMainWindow::RiuMainWindow()
sm_mainWindowInstance = this;
m_dragDropInterface = new RiuDragDrop;
m_dragDropInterface = std::make_unique<RiuDragDrop>();
initializeGuiNewProjectLoaded();
@ -215,16 +215,17 @@ void RiuMainWindow::cleanupGuiBeforeProjectClose()
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::closeEvent(QCloseEvent* event)
{
saveWinGeoAndDockToolBarLayout();
RiaApplication* app = RiaApplication::instance();
if (!app->tryClosePlotWindow()) return;
if (!RiaApplication::instance()->closeProject(true))
{
event->ignore();
return;
}
delete m_dragDropInterface;
saveWinGeoAndDockToolBarLayout();
event->accept();
}
@ -1212,7 +1213,7 @@ void RiuMainWindow::setPdmRoot(caf::PdmObject* pdmRoot)
m_projectTreeView->setPdmItem(pdmRoot);
// For debug only : m_projectTreeView->treeView()->expandAll();
m_projectTreeView->setDragDropInterface(m_dragDropInterface);
m_projectTreeView->setDragDropInterface(m_dragDropInterface.get());
for (size_t i = 0; i < additionalProjectViews.size(); i++)
{

View File

@ -26,6 +26,8 @@
#include <QPointer>
#include <QMdiArea>
#include <memory>
class QActionGroup;
class QComboBox;
class QFrame;
@ -74,6 +76,7 @@ class RiuMainWindow : public RiuMainWindowBase
public:
RiuMainWindow();
static RiuMainWindow* instance();
virtual QString mainWindowName() { return "RiuMainWindow"; }
@ -292,7 +295,7 @@ public:
private:
caf::PdmUiTreeView* m_projectTreeView;
caf::PdmUiDragDropInterface* m_dragDropInterface;
std::unique_ptr<caf::PdmUiDragDropInterface> m_dragDropInterface;
QUndoView* m_undoView;