mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-01 03:37:15 -06:00
79 lines
3.4 KiB
C++
79 lines
3.4 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// 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 "RiaApplication.h"
|
|
#include "Rim3dView.h"
|
|
#include "RimEclipseContourMapView.h"
|
|
#include "RimGridView.h"
|
|
#include "RiuMainWindow.h"
|
|
#include "RiuViewer.h"
|
|
|
|
#include <QAction>
|
|
|
|
CAF_CMD_SOURCE_INIT( RicTogglePerspectiveViewFeature, "RicTogglePerspectiveViewFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTogglePerspectiveViewFeature::isCommandEnabled() const
|
|
{
|
|
RimGridView* activeGridView = RiaApplication::instance()->activeGridView();
|
|
RimEclipseContourMapView* view2d = dynamic_cast<RimEclipseContourMapView*>( activeGridView );
|
|
return !view2d && activeGridView && RiaApplication::instance()->activeReservoirView()->viewer();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTogglePerspectiveViewFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
if ( RiaApplication::instance()->activeGridView() && RiaApplication::instance()->activeReservoirView()->viewer() )
|
|
{
|
|
bool isPerspective = RiaApplication::instance()->activeReservoirView()->isPerspectiveView();
|
|
RiaApplication::instance()->activeReservoirView()->isPerspectiveView = !isPerspective;
|
|
RiaApplication::instance()->activeReservoirView()->isPerspectiveView.uiCapability()->updateConnectedEditors();
|
|
|
|
RiaApplication::instance()->activeReservoirView()->viewer()->enableParallelProjection( isPerspective );
|
|
RiaApplication::instance()->activeReservoirView()->viewer()->navigationPolicyUpdate();
|
|
|
|
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( ":/Parallel.svg" ) );
|
|
return;
|
|
}
|
|
}
|
|
|
|
actionToSetup->setText( "Perspective View" );
|
|
actionToSetup->setIcon( QIcon( ":/Perspective.svg" ) );
|
|
}
|