#168 Added Perspective/parallel view tool button

This commit is contained in:
Jacob Støren 2016-08-16 22:43:22 +02:00
parent 4eddcc859a
commit 27830dcbeb
7 changed files with 117 additions and 1 deletions

View File

@ -41,6 +41,7 @@ ${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.h
${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h
${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.h
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.h
@ -92,6 +93,7 @@ ${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.cpp

View File

@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicTogglePerspectiveViewFeature.h"
#include "RiuViewer.h"
#include "RimView.h"
#include "RiuMainWindow.h"
#include "RiaApplication.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicTogglePerspectiveViewFeature, "RicTogglePerspectiveViewFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicTogglePerspectiveViewFeature::isCommandEnabled()
{
this->action(); // Retrieve the action to update the looks
return RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicTogglePerspectiveViewFeature::onActionTriggered(bool isChecked)
{
if(RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer())
{
bool isPerspective = RiaApplication::instance()->activeReservoirView()->isPerspectiveView();
RiaApplication::instance()->activeReservoirView()->isPerspectiveView = !isPerspective;
RiaApplication::instance()->activeReservoirView()->viewer()->enableParallelProjection(isPerspective);
RiaApplication::instance()->activeReservoirView()->isPerspectiveView.uiCapability()->updateConnectedEditors();
this->action(); // Retrieve the action to update the looks
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicTogglePerspectiveViewFeature::setupActionLook(QAction* actionToSetup)
{
if(RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer())
{
if (RiaApplication::instance()->activeReservoirView()->isPerspectiveView())
{
actionToSetup->setText("Parallel View");
actionToSetup->setIcon(QIcon(":/Parallel16x16.png"));
return;
}
}
actionToSetup->setText("Perspective View");
actionToSetup->setIcon(QIcon(":/Perspective16x16.png"));
}

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

View File

@ -61,6 +61,8 @@
<file>SummaryPlots16x16.png</file>
<file>SummaryCurve16x16.png</file>
<file>SummaryCurveFilter16x16.png</file>
<file>Parallel16x16.png</file>
<file>Perspective16x16.png</file>
</qresource>
<qresource prefix="/Shader/">

View File

@ -513,6 +513,7 @@ void RiuMainWindow::createToolBars()
// View toolbar
m_viewToolBar = addToolBar(tr("View"));
m_viewToolBar->setObjectName(m_viewToolBar->windowTitle());
m_viewToolBar->addAction(cmdFeatureMgr->action("RicTogglePerspectiveViewFeature"));
m_viewToolBar->addAction(m_zoomAll);
m_viewToolBar->addAction(m_viewFromNorth);
m_viewToolBar->addAction(m_viewFromSouth);
@ -721,7 +722,7 @@ void RiuMainWindow::slotRefreshViewActions()
updateScaleValue();
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature" << "RicTileWindowsFeature");
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature" << "RicTileWindowsFeature" << "RicTogglePerspectiveViewFeature");
}
//--------------------------------------------------------------------------------------------------