2012-05-18 02:45:23 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2014-09-23 08:04:57 -05:00
|
|
|
// Copyright (C) 2011- Statoil ASA
|
|
|
|
// Copyright (C) 2013- Ceetron Solutions AS
|
|
|
|
// Copyright (C) 2011-2012 Ceetron AS
|
2019-01-02 02:45:48 -06:00
|
|
|
//
|
2012-05-18 02:45:23 -05:00
|
|
|
// 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.
|
2019-01-02 02:45:48 -06:00
|
|
|
//
|
2012-05-18 02:45:23 -05:00
|
|
|
// 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.
|
2019-01-02 02:45:48 -06:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2012-05-18 02:45:23 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-03-22 11:30:50 -05:00
|
|
|
#include "RiuViewer.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
|
2013-03-22 10:24:42 -05:00
|
|
|
#include "RiaApplication.h"
|
2015-08-28 14:32:51 -05:00
|
|
|
#include "RiaBaseDefs.h"
|
2017-11-07 08:08:28 -06:00
|
|
|
#include "RiaColorTools.h"
|
2021-04-28 03:29:53 -05:00
|
|
|
#include "RiaGuiApplication.h"
|
2018-04-05 08:25:33 -05:00
|
|
|
#include "RiaPreferences.h"
|
2018-03-08 03:10:15 -06:00
|
|
|
#include "RiaRegressionTestRunner.h"
|
2015-07-02 05:44:57 -05:00
|
|
|
|
2015-11-16 07:08:17 -06:00
|
|
|
#include "RimCase.h"
|
2018-01-16 02:37:08 -06:00
|
|
|
#include "RimGridView.h"
|
2019-01-02 02:45:48 -06:00
|
|
|
#include "RimProject.h"
|
2015-10-13 03:24:11 -05:00
|
|
|
#include "RimViewController.h"
|
2015-09-07 07:29:46 -05:00
|
|
|
#include "RimViewLinker.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
|
2015-11-12 05:00:51 -06:00
|
|
|
#include "RivGridBoxGenerator.h"
|
2017-11-07 08:08:28 -06:00
|
|
|
#include "RivTernarySaturationOverlayItem.h"
|
2019-01-02 02:45:48 -06:00
|
|
|
#include "WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h"
|
2015-11-12 05:00:51 -06:00
|
|
|
|
2015-08-28 14:32:51 -05:00
|
|
|
#include "RiuCadNavigation.h"
|
2019-10-11 02:12:58 -05:00
|
|
|
#include "RiuComparisonViewMover.h"
|
2015-08-28 14:32:51 -05:00
|
|
|
#include "RiuGeoQuestNavigation.h"
|
2020-09-30 01:32:20 -05:00
|
|
|
#include "RiuGuiTheme.h"
|
2015-08-28 14:32:51 -05:00
|
|
|
#include "RiuRmsNavigation.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
#include "RiuSimpleHistogramWidget.h"
|
2015-08-28 14:32:51 -05:00
|
|
|
#include "RiuViewerCommands.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
|
2018-11-27 03:31:54 -06:00
|
|
|
#include "cafPdmUiSelection3dEditorVisualizer.h"
|
|
|
|
|
2016-08-02 03:25:55 -05:00
|
|
|
#include "cafCategoryLegend.h"
|
2015-08-28 14:32:51 -05:00
|
|
|
#include "cafCeetronPlusNavigation.h"
|
2016-12-15 11:20:43 -06:00
|
|
|
#include "cafDisplayCoordTransform.h"
|
2015-08-28 14:32:51 -05:00
|
|
|
#include "cafEffectGenerator.h"
|
2016-12-14 03:35:28 -06:00
|
|
|
#include "cafFrameAnimationControl.h"
|
2019-01-02 02:45:48 -06:00
|
|
|
#include "cafOverlayScalarMapperLegend.h"
|
2018-11-15 04:24:09 -06:00
|
|
|
#include "cafOverlayScaleLegend.h"
|
2019-04-05 12:10:46 -05:00
|
|
|
#include "cafQStyledProgressBar.h"
|
2019-04-07 11:16:31 -05:00
|
|
|
#include "cafStyleSheetTools.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "cafTitledOverlayFrame.h"
|
2015-11-16 14:17:12 -06:00
|
|
|
|
2015-09-01 11:21:20 -05:00
|
|
|
#include "cvfCamera.h"
|
|
|
|
#include "cvfFont.h"
|
2015-11-23 06:31:01 -06:00
|
|
|
#include "cvfOpenGLResourceManager.h"
|
2015-09-01 11:21:20 -05:00
|
|
|
#include "cvfOverlayAxisCross.h"
|
2018-11-16 06:50:15 -06:00
|
|
|
#include "cvfOverlayItem.h"
|
2018-09-21 05:57:49 -05:00
|
|
|
#include "cvfPartRenderHintCollection.h"
|
2015-11-16 03:01:50 -06:00
|
|
|
#include "cvfRenderQueueSorter.h"
|
2015-09-01 11:21:20 -05:00
|
|
|
#include "cvfRenderSequence.h"
|
|
|
|
#include "cvfRendering.h"
|
|
|
|
#include "cvfScene.h"
|
|
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QMouseEvent>
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2019-01-02 02:45:48 -06:00
|
|
|
#include <algorithm>
|
2018-08-16 08:38:34 -05:00
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
using cvf::ManipulatorTrackball;
|
|
|
|
|
|
|
|
const double RI_MIN_NEARPLANE_DISTANCE = 0.1;
|
|
|
|
|
2019-03-22 09:55:51 -05:00
|
|
|
std::unique_ptr<QCursor> RiuViewer::s_hoverCursor;
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
//==================================================================================================
|
|
|
|
///
|
2013-03-22 11:30:50 -05:00
|
|
|
/// \class RiuViewer
|
2012-05-18 02:45:23 -05:00
|
|
|
/// \ingroup ResInsight
|
|
|
|
///
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-05-18 02:45:23 -05:00
|
|
|
///
|
|
|
|
//==================================================================================================
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuViewer::RiuViewer( const QGLFormat& format, QWidget* parent )
|
|
|
|
: caf::Viewer( format, parent )
|
|
|
|
, m_isNavigationRotationEnabled( true )
|
2019-11-04 10:11:31 -06:00
|
|
|
, m_zScale( 1.0 )
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2019-05-06 03:36:05 -05:00
|
|
|
cvf::Font* standardFont = RiaGuiApplication::instance()->defaultSceneFont();
|
|
|
|
QFont font = RiaGuiApplication::instance()->font();
|
2020-05-09 04:23:58 -05:00
|
|
|
|
|
|
|
auto viewFontSize = RiaPreferences::current()->defaultSceneFontSize();
|
|
|
|
font.setPointSize( caf::FontTools::absolutePointSize( viewFontSize ) );
|
2019-04-10 05:49:20 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_axisCross = new cvf::OverlayAxisCross( m_mainCamera.p(), standardFont );
|
|
|
|
m_axisCross->setAxisLabels( "X", "Y", "Z" );
|
|
|
|
m_axisCross->setLayout( cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_RIGHT );
|
2019-10-11 02:12:58 -05:00
|
|
|
overlayItemsRendering()->addOverlayItem( m_axisCross.p() );
|
2018-02-09 06:30:18 -06:00
|
|
|
m_showAxisCross = true;
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
this->enableOverlayPainting( true );
|
|
|
|
this->setReleaseOGLResourcesEachFrame( true );
|
2012-09-11 02:22:36 -05:00
|
|
|
|
|
|
|
// Info Text
|
2015-12-07 02:59:19 -06:00
|
|
|
m_infoLabel = new QLabel();
|
2019-09-06 03:40:57 -05:00
|
|
|
m_infoLabel->setObjectName( "InfoLabel" );
|
|
|
|
m_infoLabel->setFrameShape( QFrame::Box );
|
|
|
|
m_infoLabel->setFrameShadow( QFrame::Plain );
|
|
|
|
m_infoLabel->setMinimumWidth( 275 );
|
|
|
|
m_infoLabel->setFont( font );
|
2012-09-11 02:22:36 -05:00
|
|
|
m_showInfoText = true;
|
|
|
|
|
2019-11-08 03:39:40 -06:00
|
|
|
m_shortInfoLabel = new QLabel();
|
|
|
|
m_shortInfoLabel->setObjectName( "ShortInfoLabel" );
|
|
|
|
m_shortInfoLabel->setFrameShape( QFrame::Box );
|
|
|
|
m_shortInfoLabel->setFrameShadow( QFrame::Plain );
|
|
|
|
m_shortInfoLabel->setMinimumWidth( 100 );
|
|
|
|
m_shortInfoLabel->setFont( font );
|
|
|
|
|
|
|
|
m_shortInfoLabelCompView = new QLabel();
|
|
|
|
m_shortInfoLabelCompView->setObjectName( "ShortInfoLabelCompView" );
|
|
|
|
m_shortInfoLabelCompView->setFrameShape( QFrame::Box );
|
|
|
|
m_shortInfoLabelCompView->setFrameShadow( QFrame::Plain );
|
|
|
|
m_shortInfoLabelCompView->setMinimumWidth( 100 );
|
|
|
|
m_shortInfoLabelCompView->setFont( font );
|
|
|
|
|
2015-06-24 06:44:42 -05:00
|
|
|
// Version info label
|
|
|
|
m_versionInfoLabel = new QLabel();
|
2019-09-06 03:40:57 -05:00
|
|
|
m_versionInfoLabel->setFrameShape( QFrame::NoFrame );
|
|
|
|
m_versionInfoLabel->setAlignment( Qt::AlignRight );
|
2020-10-02 08:25:15 -05:00
|
|
|
m_versionInfoLabel->setObjectName( "VersionInfo" );
|
2019-09-06 03:40:57 -05:00
|
|
|
m_versionInfoLabel->setText(
|
|
|
|
QString( "%1 v%2" ).arg( RI_APPLICATION_NAME, RiaApplication::getVersionStringApp( false ) ) );
|
|
|
|
m_versionInfoLabel->setFont( font );
|
2019-02-20 07:40:25 -06:00
|
|
|
m_showVersionInfo = true;
|
2019-01-02 02:45:48 -06:00
|
|
|
|
2018-12-10 06:03:53 -06:00
|
|
|
// Z scale label
|
|
|
|
m_zScaleLabel = new QLabel();
|
2019-09-06 03:40:57 -05:00
|
|
|
m_zScaleLabel->setFrameShape( QFrame::NoFrame );
|
|
|
|
m_zScaleLabel->setAlignment( Qt::AlignLeft );
|
2020-10-02 08:25:15 -05:00
|
|
|
m_zScaleLabel->setObjectName( "ZScaleLabel" );
|
2019-09-06 03:40:57 -05:00
|
|
|
m_zScaleLabel->setText( QString( "Z: " ) );
|
|
|
|
m_zScaleLabel->setFont( font );
|
2019-01-02 02:45:48 -06:00
|
|
|
m_showZScaleLabel = true;
|
2018-12-13 06:20:49 -06:00
|
|
|
m_hideZScaleCheckbox = false;
|
2018-12-10 06:03:53 -06:00
|
|
|
|
2012-09-11 02:22:36 -05:00
|
|
|
// Animation progress bar
|
2019-09-06 03:40:57 -05:00
|
|
|
m_animationProgress = new caf::QStyledProgressBar( "AnimationProgress" );
|
|
|
|
m_animationProgress->setFormat( "Time Step: %v/%m" );
|
|
|
|
m_animationProgress->setTextVisible( true );
|
|
|
|
m_animationProgress->setAlignment( Qt::AlignCenter );
|
|
|
|
m_animationProgress->setObjectName( "AnimationProgress" );
|
|
|
|
m_animationProgress->setFont( font );
|
2012-10-23 06:36:48 -05:00
|
|
|
|
2019-11-08 03:39:40 -06:00
|
|
|
m_animationProgressCompView = new caf::QStyledProgressBar( "AnimationProgress" );
|
|
|
|
m_animationProgressCompView->setFormat( "Time Step: %v/%m" );
|
|
|
|
m_animationProgressCompView->setTextVisible( true );
|
|
|
|
m_animationProgressCompView->setAlignment( Qt::AlignCenter );
|
|
|
|
m_animationProgressCompView->setObjectName( "AnimationProgress" );
|
|
|
|
m_animationProgressCompView->setFont( font );
|
|
|
|
|
2012-09-11 02:22:36 -05:00
|
|
|
m_showAnimProgress = false;
|
|
|
|
|
|
|
|
// Histogram
|
2019-09-06 03:40:57 -05:00
|
|
|
m_histogramWidget = new RiuSimpleHistogramWidget( "HistogramWidget" );
|
2019-02-18 14:01:37 -06:00
|
|
|
m_showHistogram = false;
|
2012-09-11 02:22:36 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_viewerCommands = new RiuViewerCommands( this );
|
2015-06-11 04:38:51 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
|
2015-06-26 06:47:33 -05:00
|
|
|
{
|
2015-12-07 02:59:19 -06:00
|
|
|
QFont regTestFont = m_infoLabel->font();
|
2019-09-06 03:40:57 -05:00
|
|
|
regTestFont.setPixelSize( 11 );
|
2015-06-26 06:47:33 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_infoLabel->setFont( regTestFont );
|
2019-11-08 03:39:40 -06:00
|
|
|
m_shortInfoLabel->setFont( regTestFont );
|
|
|
|
m_shortInfoLabelCompView->setFont( regTestFont );
|
2019-09-06 03:40:57 -05:00
|
|
|
m_versionInfoLabel->setFont( regTestFont );
|
|
|
|
m_animationProgress->setFont( regTestFont );
|
|
|
|
m_histogramWidget->setFont( regTestFont );
|
|
|
|
m_zScaleLabel->setFont( regTestFont );
|
2015-06-26 06:47:33 -05:00
|
|
|
}
|
2015-10-21 06:15:38 -05:00
|
|
|
|
|
|
|
// When a context menu is created in the viewer is, and the action triggered is displaying a dialog,
|
|
|
|
// the context menu of QMainWindow is displayed after the action has finished
|
|
|
|
// Setting this policy will make sure the handling is not deferred to the widget's parent,
|
|
|
|
// which solves the problem
|
2019-09-06 03:40:57 -05:00
|
|
|
setContextMenuPolicy( Qt::PreventContextMenu );
|
2015-11-12 05:00:51 -06:00
|
|
|
|
2019-10-11 02:12:58 -05:00
|
|
|
m_gridBoxGenerator = new RivGridBoxGenerator;
|
|
|
|
m_comparisonGridBoxGenerator = new RivGridBoxGenerator;
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2016-12-15 11:20:43 -06:00
|
|
|
m_cursorPositionDomainCoords = cvf::Vec3d::UNDEFINED;
|
2019-09-06 03:40:57 -05:00
|
|
|
m_windowEdgeAxisOverlay = new RivWindowEdgeAxesOverlayItem( standardFont );
|
2019-01-02 02:45:48 -06:00
|
|
|
m_showWindowEdgeAxes = false;
|
2018-02-08 12:42:34 -06:00
|
|
|
|
2020-10-02 04:12:25 -05:00
|
|
|
auto backgroundColor = RiuGuiTheme::getColorByVariableName( "backgroundColor1" );
|
2020-09-30 01:32:20 -05:00
|
|
|
auto textColor = RiuGuiTheme::getColorByVariableName( "textColor" );
|
|
|
|
m_windowEdgeAxisOverlay->setFrameColor( cvf::Color4f( RiaColorTools::fromQColorTo3f( backgroundColor ) ) );
|
|
|
|
m_windowEdgeAxisOverlay->setTextColor( RiaColorTools::fromQColorTo3f( textColor ) );
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_selectionVisualizerManager = new caf::PdmUiSelection3dEditorVisualizer( this );
|
2018-11-15 04:24:09 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_scaleLegend = new caf::OverlayScaleLegend( standardFont );
|
|
|
|
m_scaleLegend->setOrientation( caf::OverlayScaleLegend::HORIZONTAL );
|
2019-10-11 02:12:58 -05:00
|
|
|
|
|
|
|
m_comparisonWindowMover = new RiuComparisonViewMover( this );
|
2019-11-04 04:34:34 -06:00
|
|
|
this->setComparisonViewToFollowAnimation( false );
|
2020-05-09 04:23:58 -05:00
|
|
|
|
2020-06-08 04:09:11 -05:00
|
|
|
m_fontPointSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultSceneFontSize() );
|
2016-12-15 11:20:43 -06:00
|
|
|
}
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 11:17:56 -05:00
|
|
|
RiuViewer::~RiuViewer()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_rimView )
|
2015-04-21 01:37:32 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_rimView->setCameraPosition( m_mainCamera->viewMatrix() );
|
|
|
|
m_rimView->setCameraPointOfInterest( pointOfInterest() );
|
2015-04-21 01:37:32 -05:00
|
|
|
}
|
2018-01-11 05:59:52 -06:00
|
|
|
|
2015-12-07 02:59:19 -06:00
|
|
|
delete m_infoLabel;
|
2019-11-08 03:39:40 -06:00
|
|
|
delete m_shortInfoLabel;
|
|
|
|
delete m_shortInfoLabelCompView;
|
2012-10-23 03:42:46 -05:00
|
|
|
delete m_animationProgress;
|
2019-11-08 03:39:40 -06:00
|
|
|
delete m_animationProgressCompView;
|
2012-10-23 03:42:46 -05:00
|
|
|
delete m_histogramWidget;
|
2015-11-12 05:00:51 -06:00
|
|
|
delete m_gridBoxGenerator;
|
2019-10-11 02:12:58 -05:00
|
|
|
delete m_comparisonGridBoxGenerator;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
2018-11-27 10:04:55 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuViewer::clearRimView()
|
|
|
|
{
|
|
|
|
m_rimView = nullptr;
|
|
|
|
}
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 11:17:56 -05:00
|
|
|
void RiuViewer::setDefaultView()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2016-09-07 05:49:01 -05:00
|
|
|
cvf::BoundingBox bb = m_mainRendering->boundingBox();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !bb.isValid() )
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
bb.add( cvf::Vec3d( -1, -1, -1 ) );
|
|
|
|
bb.add( cvf::Vec3d( 1, 1, 1 ) );
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_mainCamera->projection() == cvf::Camera::PERSPECTIVE )
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_mainCamera->setProjectionAsPerspective( 40.0, RI_MIN_NEARPLANE_DISTANCE, 1000 );
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( bb.isValid() )
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_mainCamera->setProjectionAsOrtho( bb.extent().length(), RI_MIN_NEARPLANE_DISTANCE, 1000 );
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_mainCamera->fitView( bb, -cvf::Vec3d::Z_AXIS, cvf::Vec3d::Y_AXIS );
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::mouseReleaseEvent( QMouseEvent* event )
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !this->canRender() ) return;
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( event->button() == Qt::LeftButton )
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-12-10 02:27:43 -06:00
|
|
|
QPoint diffPoint = event->pos() - m_lastMousePressPosition;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( diffPoint.manhattanLength() > 3 )
|
2015-12-10 02:27:43 -06:00
|
|
|
{
|
|
|
|
// We are possibly in navigation mode, only clean press event will launch
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-08 03:39:40 -06:00
|
|
|
if ( !m_infoPickArea.isNull() )
|
2015-12-07 02:59:19 -06:00
|
|
|
{
|
2019-11-08 03:39:40 -06:00
|
|
|
if ( m_infoPickArea.contains( event->x(), event->y() ) )
|
2015-12-07 02:59:19 -06:00
|
|
|
{
|
|
|
|
m_rimView->selectOverlayInfoConfig();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-08 03:39:40 -06:00
|
|
|
if ( !m_infoPickAreaCompView.isNull() )
|
|
|
|
{
|
|
|
|
if ( m_infoPickAreaCompView.contains( event->x(), event->y() ) )
|
|
|
|
{
|
|
|
|
Rim3dView* compView = dynamic_cast<Rim3dView*>( m_rimView.p() )->activeComparisonView();
|
|
|
|
|
|
|
|
if ( compView ) compView->selectOverlayInfoConfig();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_viewerCommands->handlePickAction( event->x(), event->y(), event->modifiers() );
|
2015-12-10 02:27:43 -06:00
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
return;
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( event->button() == Qt::RightButton )
|
2013-04-23 00:29:37 -05:00
|
|
|
{
|
2013-06-24 15:23:33 -05:00
|
|
|
QPoint diffPoint = event->pos() - m_lastMousePressPosition;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( diffPoint.manhattanLength() > 3 )
|
2013-06-24 15:23:33 -05:00
|
|
|
{
|
|
|
|
// We are possibly in navigation mode, only clean press event will launch
|
|
|
|
return;
|
|
|
|
}
|
2013-04-23 00:29:37 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_viewerCommands->displayContextMenu( event );
|
2015-06-05 08:17:02 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-04-23 00:29:37 -05:00
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 11:17:56 -05:00
|
|
|
void RiuViewer::slotEndAnimation()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( m_mainRendering.notNull() );
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_rimView ) m_rimView->endAnimation();
|
2019-01-02 02:45:48 -06:00
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
caf::Viewer::slotEndAnimation();
|
2012-08-31 12:12:47 -05:00
|
|
|
|
|
|
|
caf::EffectGenerator::releaseUnreferencedEffects();
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::slotSetCurrentFrame( int frameIndex )
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
setCurrentFrame( frameIndex );
|
2015-08-25 05:40:55 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_rimView )
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-11-16 00:16:30 -06:00
|
|
|
RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( viewLinker )
|
2015-09-01 10:14:22 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
viewLinker->updateTimeStep( dynamic_cast<RimGridView*>( m_rimView.p() ), frameIndex );
|
2015-09-01 10:14:22 -05:00
|
|
|
}
|
2019-10-22 06:39:18 -05:00
|
|
|
|
|
|
|
// Update views using this as comparison
|
|
|
|
Rim3dView* view = dynamic_cast<Rim3dView*>( m_rimView.p() );
|
2019-11-04 04:34:34 -06:00
|
|
|
if ( view )
|
2019-10-22 06:39:18 -05:00
|
|
|
{
|
|
|
|
std::set<Rim3dView*> containingViews = view->viewsUsingThisAsComparisonView();
|
|
|
|
|
2019-10-22 06:54:10 -05:00
|
|
|
for ( auto contView : containingViews )
|
2019-10-22 06:39:18 -05:00
|
|
|
{
|
2019-11-01 04:13:32 -05:00
|
|
|
contView->updateDisplayModelForCurrentTimeStepAndRedraw();
|
2019-10-22 06:39:18 -05:00
|
|
|
}
|
|
|
|
}
|
2015-08-25 05:40:55 -05:00
|
|
|
}
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 11:17:56 -05:00
|
|
|
cvf::Vec3d RiuViewer::pointOfInterest()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
return m_navigationPolicy->pointOfInterest();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::setPointOfInterest( cvf::Vec3d poi )
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_navigationPolicy->setPointOfInterest( poi );
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-05-18 02:45:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::setOwnerReservoirView( RiuViewerToViewInterface* owner )
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-11-16 00:16:30 -06:00
|
|
|
m_rimView = owner;
|
2015-11-23 00:24:50 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_viewerCommands->setOwnerView( dynamic_cast<Rim3dView*>( owner ) );
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
2012-09-11 02:22:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-09-11 02:22:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::paintOverlayItems( QPainter* painter )
|
2012-09-11 02:22:36 -05:00
|
|
|
{
|
2019-11-04 04:34:34 -06:00
|
|
|
// Update the legend layout on every redraw as the legends stores their own position,
|
2019-10-11 02:12:58 -05:00
|
|
|
// and when they are shared between views the positions are overwritten.
|
|
|
|
updateLegendLayout();
|
|
|
|
|
2012-09-11 02:22:36 -05:00
|
|
|
int columnWidth = 200;
|
2018-03-07 05:47:48 -06:00
|
|
|
|
2019-01-02 02:45:48 -06:00
|
|
|
int edgeAxisFrameBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth() : 0;
|
|
|
|
int edgeAxisFrameBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight() : 0;
|
2018-03-07 05:47:48 -06:00
|
|
|
|
2019-11-08 03:39:40 -06:00
|
|
|
int margin = 5;
|
|
|
|
int startYPos = margin + edgeAxisFrameBorderHeight;
|
|
|
|
int yPos = startYPos;
|
2012-09-11 02:22:36 -05:00
|
|
|
|
|
|
|
bool showAnimBar = false;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( isAnimationActive() && frameCount() > 1 ) showAnimBar = true;
|
2012-09-11 02:22:36 -05:00
|
|
|
|
2020-08-31 08:52:36 -05:00
|
|
|
if ( m_showInfoText ) columnWidth = std::max( columnWidth, m_infoLabel->sizeHint().width() );
|
2012-09-11 02:22:36 -05:00
|
|
|
|
2018-02-09 06:30:18 -06:00
|
|
|
int columnPos = this->width() - columnWidth - margin - edgeAxisFrameBorderWidth;
|
2012-09-11 02:22:36 -05:00
|
|
|
|
2019-11-08 03:39:40 -06:00
|
|
|
if ( this->isComparisonViewActive() )
|
|
|
|
{
|
|
|
|
Rim3dView* compView = dynamic_cast<Rim3dView*>( m_rimView.p() )->activeComparisonView();
|
2020-11-20 06:05:31 -06:00
|
|
|
if ( compView )
|
|
|
|
{
|
|
|
|
columnWidth = 200;
|
2019-11-08 03:39:40 -06:00
|
|
|
|
2020-11-20 06:05:31 -06:00
|
|
|
// int sliderPos = this->width() * this->comparisonViewVisibleNormalizedRect().min().x();
|
|
|
|
int sliderPos = 0.5 * this->width();
|
|
|
|
int compViewItemsXPos = sliderPos + 0.5 * ( this->width() - sliderPos ) - 0.5 * columnWidth;
|
|
|
|
columnPos = 0.5 * sliderPos - 0.5 * columnWidth;
|
2019-11-08 03:39:40 -06:00
|
|
|
|
2020-11-20 06:05:31 -06:00
|
|
|
if ( m_showInfoText )
|
2019-11-08 03:39:40 -06:00
|
|
|
{
|
2020-11-20 06:05:31 -06:00
|
|
|
{
|
|
|
|
Rim3dView* view = dynamic_cast<Rim3dView*>( m_rimView.p() );
|
|
|
|
m_shortInfoLabel->setText( "<center>" + view->ownerCase()->caseUserDescription() + "</center>" );
|
|
|
|
|
|
|
|
QPoint topLeft = QPoint( columnPos, yPos );
|
|
|
|
m_shortInfoLabel->resize( columnWidth, m_shortInfoLabel->sizeHint().height() );
|
|
|
|
m_shortInfoLabel->render( painter, topLeft );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
m_shortInfoLabelCompView->setText( "<center>" + compView->ownerCase()->caseUserDescription() +
|
|
|
|
"</center>" );
|
|
|
|
QPoint topLeft = QPoint( compViewItemsXPos, yPos );
|
|
|
|
m_shortInfoLabelCompView->resize( columnWidth, m_shortInfoLabelCompView->sizeHint().height() );
|
|
|
|
m_shortInfoLabelCompView->render( painter, topLeft );
|
|
|
|
}
|
|
|
|
|
|
|
|
yPos += m_shortInfoLabel->height();
|
2019-11-08 03:39:40 -06:00
|
|
|
}
|
|
|
|
|
2020-11-20 06:05:31 -06:00
|
|
|
int pickAreaHeight = yPos - startYPos;
|
|
|
|
if ( m_showAnimProgress && isAnimationActive( true ) && compView->timeStepCount() > 1 )
|
2019-11-08 03:39:40 -06:00
|
|
|
{
|
2020-11-20 06:05:31 -06:00
|
|
|
QString stepName = compView->timeStepName( compView->currentTimeStep() );
|
2019-11-08 03:39:40 -06:00
|
|
|
|
2020-11-20 06:05:31 -06:00
|
|
|
m_animationProgressCompView->setFormat( "Time Step: %v/%m " + stepName );
|
|
|
|
m_animationProgressCompView->setMinimum( 0 );
|
|
|
|
m_animationProgressCompView->setMaximum( static_cast<int>( compView->timeStepCount() ) - 1 );
|
|
|
|
m_animationProgressCompView->setValue( compView->currentTimeStep() );
|
2019-11-08 03:39:40 -06:00
|
|
|
|
2020-11-20 06:05:31 -06:00
|
|
|
m_animationProgressCompView->resize( columnWidth, m_animationProgressCompView->sizeHint().height() );
|
2019-11-08 03:39:40 -06:00
|
|
|
|
2020-11-20 06:05:31 -06:00
|
|
|
m_animationProgressCompView->render( painter, QPoint( compViewItemsXPos, yPos ) );
|
2019-11-08 03:39:40 -06:00
|
|
|
|
2020-11-20 06:05:31 -06:00
|
|
|
pickAreaHeight += m_animationProgressCompView->height();
|
|
|
|
}
|
2019-11-08 03:39:40 -06:00
|
|
|
|
2020-11-20 06:05:31 -06:00
|
|
|
m_infoPickArea.setLeft( columnPos );
|
|
|
|
m_infoPickArea.setWidth( columnWidth );
|
|
|
|
m_infoPickArea.setHeight( pickAreaHeight );
|
|
|
|
m_infoPickArea.setTop( startYPos );
|
2019-11-08 03:39:40 -06:00
|
|
|
|
2020-11-20 06:05:31 -06:00
|
|
|
m_infoPickAreaCompView.setLeft( compViewItemsXPos );
|
|
|
|
m_infoPickAreaCompView.setWidth( columnWidth );
|
|
|
|
m_infoPickAreaCompView.setHeight( pickAreaHeight );
|
|
|
|
m_infoPickAreaCompView.setTop( startYPos );
|
2019-11-08 03:39:40 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( showAnimBar && m_showAnimProgress )
|
2012-09-11 02:22:36 -05:00
|
|
|
{
|
2019-11-08 03:39:40 -06:00
|
|
|
Rim3dView* view = dynamic_cast<Rim3dView*>( m_rimView.p() );
|
|
|
|
|
|
|
|
QString stepName = view->timeStepName( view->currentTimeStep() );
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_animationProgress->setFormat( "Time Step: %v/%m " + stepName );
|
|
|
|
m_animationProgress->setMinimum( 0 );
|
2019-11-08 03:39:40 -06:00
|
|
|
m_animationProgress->setMaximum( static_cast<int>( view->timeStepCount() ) - 1 );
|
|
|
|
m_animationProgress->setValue( view->currentTimeStep() );
|
2019-09-06 03:40:57 -05:00
|
|
|
|
2019-11-08 03:39:40 -06:00
|
|
|
m_animationProgress->resize( columnWidth, m_animationProgress->sizeHint().height() );
|
2019-09-06 03:40:57 -05:00
|
|
|
m_animationProgress->render( painter, QPoint( columnPos, yPos ) );
|
2019-11-08 03:39:40 -06:00
|
|
|
|
2019-01-02 02:45:48 -06:00
|
|
|
yPos += m_animationProgress->height() + margin;
|
2012-09-11 02:22:36 -05:00
|
|
|
}
|
|
|
|
|
2019-11-08 03:39:40 -06:00
|
|
|
if ( m_showInfoText && !this->isComparisonViewActive() )
|
2012-09-11 02:22:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QPoint topLeft = QPoint( columnPos, yPos );
|
|
|
|
m_infoLabel->resize( columnWidth, m_infoLabel->sizeHint().height() );
|
|
|
|
m_infoLabel->render( painter, topLeft );
|
2015-12-07 02:59:19 -06:00
|
|
|
|
2019-11-08 03:39:40 -06:00
|
|
|
m_infoPickArea.setTopLeft( topLeft );
|
|
|
|
m_infoPickArea.setBottom( yPos + m_infoLabel->height() );
|
|
|
|
m_infoPickArea.setRight( columnPos + columnWidth );
|
2015-12-07 02:59:19 -06:00
|
|
|
|
2019-01-02 02:45:48 -06:00
|
|
|
yPos += m_infoLabel->height() + margin;
|
2015-12-07 02:59:19 -06:00
|
|
|
}
|
2019-11-08 03:39:40 -06:00
|
|
|
else if ( !this->isComparisonViewActive() )
|
2015-12-07 02:59:19 -06:00
|
|
|
{
|
2019-11-08 03:39:40 -06:00
|
|
|
m_infoPickArea = QRect();
|
2012-09-11 02:22:36 -05:00
|
|
|
}
|
|
|
|
|
2019-11-08 03:39:40 -06:00
|
|
|
if ( m_showHistogram && !this->isComparisonViewActive() )
|
2012-09-11 02:22:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_histogramWidget->resize( columnWidth, 40 );
|
|
|
|
m_histogramWidget->render( painter, QPoint( columnPos, yPos ) );
|
2019-01-02 02:45:48 -06:00
|
|
|
// yPos += m_histogramWidget->height() + margin;
|
2015-06-24 06:44:42 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_showVersionInfo ) // Version Label
|
2015-06-24 06:44:42 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QSize size( m_versionInfoLabel->sizeHint().width(), m_versionInfoLabel->sizeHint().height() );
|
|
|
|
QPoint pos( this->width() - size.width() - margin - edgeAxisFrameBorderWidth,
|
|
|
|
this->height() - size.height() - margin - edgeAxisFrameBorderHeight );
|
|
|
|
m_versionInfoLabel->resize( size.width(), size.height() );
|
|
|
|
m_versionInfoLabel->render( painter, pos );
|
2012-09-11 02:22:36 -05:00
|
|
|
}
|
2016-12-15 11:20:43 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_showZScaleLabel ) // Z scale Label
|
2018-12-10 06:03:53 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QSize size( m_zScaleLabel->sizeHint().width(), m_zScaleLabel->sizeHint().height() );
|
|
|
|
QPoint pos( margin + edgeAxisFrameBorderWidth, margin + edgeAxisFrameBorderHeight );
|
|
|
|
m_zScaleLabel->resize( size.width(), size.height() );
|
|
|
|
m_zScaleLabel->render( painter, pos );
|
2018-12-10 06:03:53 -06:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !m_cursorPositionDomainCoords.isUndefined() )
|
2016-12-15 11:20:43 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( mainCamera() )
|
2016-12-15 11:20:43 -06:00
|
|
|
{
|
|
|
|
cvf::ref<caf::DisplayCoordTransform> trans = m_rimView->displayCoordTransform();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Vec3d displayCoord = trans->transformToDisplayCoord( m_cursorPositionDomainCoords );
|
2016-12-15 11:20:43 -06:00
|
|
|
|
|
|
|
cvf::Vec3d screenCoords;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( mainCamera()->project( displayCoord, &screenCoords ) )
|
2016-12-15 11:20:43 -06:00
|
|
|
{
|
2019-01-02 02:45:48 -06:00
|
|
|
int translatedMousePosY = height() - screenCoords.y();
|
2019-09-06 03:40:57 -05:00
|
|
|
QPoint centerPos( screenCoords.x(), translatedMousePosY );
|
2016-12-15 11:45:10 -06:00
|
|
|
|
|
|
|
// Draw a cross hair marker
|
|
|
|
int markerHalfLength = 6;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
painter->drawLine( centerPos.x(),
|
|
|
|
centerPos.y() - markerHalfLength,
|
|
|
|
centerPos.x(),
|
|
|
|
centerPos.y() + markerHalfLength );
|
|
|
|
painter->drawLine( centerPos.x() - markerHalfLength,
|
|
|
|
centerPos.y(),
|
|
|
|
centerPos.x() + markerHalfLength,
|
|
|
|
centerPos.y() );
|
2016-12-15 11:20:43 -06:00
|
|
|
}
|
|
|
|
}
|
2019-01-02 02:45:48 -06:00
|
|
|
}
|
2019-10-11 02:12:58 -05:00
|
|
|
|
|
|
|
m_comparisonWindowMover->paintMoverHandles( painter );
|
2012-09-11 02:22:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-09-11 02:22:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::setInfoText( QString text )
|
2012-09-11 02:22:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_infoLabel->setText( text );
|
2012-09-11 02:22:36 -05:00
|
|
|
}
|
|
|
|
|
2018-12-13 06:20:49 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::hideZScaleCheckbox( bool hide )
|
2018-12-13 06:20:49 -06:00
|
|
|
{
|
|
|
|
m_hideZScaleCheckbox = hide;
|
|
|
|
}
|
|
|
|
|
2018-12-10 06:03:53 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::showZScaleLabel( bool enable )
|
2018-12-10 06:03:53 -06:00
|
|
|
{
|
|
|
|
m_showZScaleLabel = enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::setZScale( int scale )
|
2018-12-10 06:03:53 -06:00
|
|
|
{
|
2019-11-04 10:11:31 -06:00
|
|
|
bool isScaleChanged = m_zScale != scale;
|
|
|
|
m_zScale = scale;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_zScaleLabel->setText( QString( "Z: %1" ).arg( scale ) );
|
2019-11-04 10:11:31 -06:00
|
|
|
|
|
|
|
if ( isScaleChanged ) m_selectionVisualizerManager->updateVisibleEditors();
|
2018-12-10 06:03:53 -06:00
|
|
|
}
|
|
|
|
|
2012-09-11 02:22:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-09-11 02:22:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::showInfoText( bool enable )
|
2012-09-11 02:22:36 -05:00
|
|
|
{
|
|
|
|
m_showInfoText = enable;
|
|
|
|
}
|
|
|
|
|
2019-02-20 07:40:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2019-02-20 07:40:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::showVersionInfo( bool enable )
|
2019-02-20 07:40:25 -06:00
|
|
|
{
|
|
|
|
m_showVersionInfo = enable;
|
|
|
|
}
|
|
|
|
|
2012-09-11 02:22:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-09-11 02:22:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::setHistogram( double min, double max, const std::vector<size_t>& histogram )
|
2012-09-11 02:22:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_histogramWidget->setHistogramData( min, max, histogram );
|
2012-09-11 02:22:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-09-11 02:22:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::setHistogramPercentiles( double pmin, double pmax, double mean )
|
2012-09-11 02:22:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_histogramWidget->setPercentiles( pmin, pmax );
|
|
|
|
m_histogramWidget->setMean( mean );
|
2012-09-11 02:22:36 -05:00
|
|
|
}
|
|
|
|
|
2018-01-11 05:59:52 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2018-01-11 05:59:52 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::showGridBox( bool enable )
|
2018-01-11 05:59:52 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( enable )
|
2018-01-11 05:59:52 -06:00
|
|
|
{
|
2019-10-11 02:12:58 -05:00
|
|
|
this->addStaticModelOnce( m_gridBoxGenerator->model(), false );
|
|
|
|
this->addStaticModelOnce( m_comparisonGridBoxGenerator->model(), true );
|
2018-01-11 05:59:52 -06:00
|
|
|
}
|
2019-11-04 10:11:31 -06:00
|
|
|
else
|
|
|
|
{
|
|
|
|
this->removeStaticModel( m_gridBoxGenerator->model() );
|
|
|
|
this->removeStaticModel( m_comparisonGridBoxGenerator->model() );
|
|
|
|
}
|
2018-01-11 05:59:52 -06:00
|
|
|
}
|
|
|
|
|
2012-09-11 02:22:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-09-11 02:22:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::showAnimationProgress( bool enable )
|
2012-09-11 02:22:36 -05:00
|
|
|
{
|
|
|
|
m_showAnimProgress = enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2012-09-11 02:22:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::showHistogram( bool enable )
|
2012-09-11 02:22:36 -05:00
|
|
|
{
|
|
|
|
m_showHistogram = enable;
|
|
|
|
}
|
2013-04-23 00:29:37 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2013-04-23 00:29:37 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::mousePressEvent( QMouseEvent* event )
|
2013-04-23 00:29:37 -05:00
|
|
|
{
|
|
|
|
m_lastMousePressPosition = event->pos();
|
|
|
|
}
|
|
|
|
|
2014-04-07 06:18:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2014-04-07 06:18:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2014-07-30 03:54:46 -05:00
|
|
|
void RiuViewer::removeAllColorLegends()
|
2014-04-07 06:18:39 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t i = 0; i < m_visibleLegends.size(); i++ )
|
2014-07-30 03:54:46 -05:00
|
|
|
{
|
2019-10-11 02:12:58 -05:00
|
|
|
overlayItemsRendering()->removeOverlayItem( m_visibleLegends[i].p() );
|
2014-07-30 03:54:46 -05:00
|
|
|
}
|
2019-11-07 03:49:16 -06:00
|
|
|
for ( auto legend : m_visibleComparisonLegends )
|
|
|
|
{
|
|
|
|
overlayItemsRendering()->removeOverlayItem( legend.p() );
|
|
|
|
}
|
2014-07-30 03:54:46 -05:00
|
|
|
|
|
|
|
m_visibleLegends.clear();
|
2019-11-07 03:49:16 -06:00
|
|
|
m_visibleComparisonLegends.clear();
|
2014-04-07 06:18:39 -05:00
|
|
|
}
|
|
|
|
|
2014-07-25 07:48:37 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2014-07-25 07:48:37 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-07 03:49:16 -06:00
|
|
|
void RiuViewer::addColorLegendToBottomLeftCorner( caf::TitledOverlayFrame* addedLegend, bool isForComparisonView )
|
2014-07-25 07:48:37 -05:00
|
|
|
{
|
2019-11-06 12:01:53 -06:00
|
|
|
if ( !addedLegend || m_visibleLegends.contains( addedLegend ) ) return;
|
|
|
|
|
|
|
|
RiaGuiApplication* app = RiaGuiApplication::instance();
|
|
|
|
cvf::Rendering* overlayRendering = overlayItemsRendering();
|
2019-10-11 02:12:58 -05:00
|
|
|
CVF_ASSERT( overlayRendering );
|
2014-07-30 03:54:46 -05:00
|
|
|
|
2019-11-06 12:01:53 -06:00
|
|
|
cvf::Color4f backgroundColor = mainCamera()->viewport()->clearColor();
|
|
|
|
backgroundColor.a() = 0.8f;
|
|
|
|
|
|
|
|
cvf::Color3f backgroundColor3f( backgroundColor.r(), backgroundColor.g(), backgroundColor.b() );
|
|
|
|
cvf::Color4f frameColor = cvf::Color4f( RiaColorTools::computeOffsetColor( backgroundColor3f, 0.3f ), 0.9f );
|
|
|
|
|
|
|
|
updateLegendTextAndTickMarkColor( addedLegend );
|
|
|
|
|
2021-04-28 03:29:53 -05:00
|
|
|
addedLegend->enableBackground( RiaPreferences::current()->showLegendBackground() );
|
2019-11-06 12:01:53 -06:00
|
|
|
addedLegend->setBackgroundColor( backgroundColor );
|
|
|
|
addedLegend->setBackgroundFrameColor( frameColor );
|
2020-06-08 04:09:11 -05:00
|
|
|
addedLegend->setFont( app->sceneFont( m_fontPointSize ) );
|
2019-11-06 12:01:53 -06:00
|
|
|
|
|
|
|
overlayRendering->addOverlayItem( addedLegend );
|
2019-11-07 03:49:16 -06:00
|
|
|
|
|
|
|
if ( isForComparisonView )
|
|
|
|
{
|
|
|
|
m_visibleComparisonLegends.push_back( addedLegend );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_visibleLegends.push_back( addedLegend );
|
|
|
|
}
|
2019-10-11 02:12:58 -05:00
|
|
|
}
|
2016-09-12 04:11:25 -05:00
|
|
|
|
2019-10-11 02:12:58 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuViewer::removeColorLegend( caf::TitledOverlayFrame* legend )
|
|
|
|
{
|
|
|
|
overlayItemsRendering()->removeOverlayItem( legend );
|
|
|
|
m_visibleLegends.erase( legend );
|
2019-11-07 03:49:16 -06:00
|
|
|
m_visibleComparisonLegends.erase( legend );
|
2018-05-04 06:32:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2018-05-04 06:32:41 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuViewer::updateLegendLayout()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
int viewPortHeight = static_cast<int>( m_mainCamera->viewport()->height() );
|
2018-05-04 06:32:41 -05:00
|
|
|
|
2019-01-02 02:45:48 -06:00
|
|
|
const float maxFreeLegendHeight = 0.7f * viewPortHeight;
|
|
|
|
const int border = 3;
|
|
|
|
int edgeAxisBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth() : 0;
|
|
|
|
int edgeAxisBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight() : 0;
|
2016-09-22 08:31:21 -05:00
|
|
|
|
2019-11-07 03:49:16 -06:00
|
|
|
// Place the main view legends from left to right
|
2019-01-02 03:39:11 -06:00
|
|
|
{
|
|
|
|
int xPos = border + edgeAxisBorderWidth;
|
|
|
|
int yPos = border + edgeAxisBorderHeight;
|
2018-02-09 06:30:18 -06:00
|
|
|
|
2019-01-02 03:39:11 -06:00
|
|
|
std::vector<caf::TitledOverlayFrame*> standardHeightLegends;
|
2019-01-02 02:45:48 -06:00
|
|
|
|
2019-01-02 03:39:11 -06:00
|
|
|
// Place the legends needing the full height, and sort out the standard height legends
|
2018-05-04 06:32:41 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( cvf::ref<caf::TitledOverlayFrame> legend : m_visibleLegends )
|
2016-09-12 04:11:25 -05:00
|
|
|
{
|
2019-01-02 03:39:11 -06:00
|
|
|
cvf::Vec2ui prefSize = legend->preferredSize();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( prefSize.y() > maxFreeLegendHeight )
|
2019-01-02 03:39:11 -06:00
|
|
|
{
|
|
|
|
int legendWidth = prefSize.x();
|
2019-09-06 03:40:57 -05:00
|
|
|
legend->setLayoutFixedPosition( cvf::Vec2i( xPos, yPos ) );
|
2020-02-12 04:43:15 -06:00
|
|
|
legend->setRenderSize( cvf::Vec2ui( legendWidth, viewPortHeight - 2 * border - 2 * edgeAxisBorderHeight ) );
|
2019-01-02 03:39:11 -06:00
|
|
|
xPos += legendWidth + border;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
standardHeightLegends.push_back( legend.p() );
|
2019-01-02 03:39:11 -06:00
|
|
|
}
|
2016-09-12 04:11:25 -05:00
|
|
|
}
|
|
|
|
|
2019-01-02 03:39:11 -06:00
|
|
|
// Place the rest of the legends in columns that fits within the screen height
|
2019-01-02 02:45:48 -06:00
|
|
|
|
2019-01-02 03:39:11 -06:00
|
|
|
int maxColumnWidht = 0;
|
|
|
|
std::vector<caf::TitledOverlayFrame*> columnLegends;
|
2016-09-12 04:11:25 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( caf::TitledOverlayFrame* legend : standardHeightLegends )
|
2016-09-12 04:11:25 -05:00
|
|
|
{
|
2019-01-02 03:39:11 -06:00
|
|
|
cvf::Vec2ui prefSize = legend->preferredSize();
|
2016-09-12 04:11:25 -05:00
|
|
|
|
2019-01-02 03:39:11 -06:00
|
|
|
// Check if we need a new column
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( ( yPos + (int)prefSize.y() + border ) > viewPortHeight )
|
2018-03-13 07:26:12 -05:00
|
|
|
{
|
2019-01-02 03:39:11 -06:00
|
|
|
xPos += border + maxColumnWidht;
|
|
|
|
yPos = border + edgeAxisBorderHeight;
|
|
|
|
|
|
|
|
// Set same width to all legends in the column
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( caf::TitledOverlayFrame* columnLegend : columnLegends )
|
2019-01-02 03:39:11 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
columnLegend->setRenderSize( cvf::Vec2ui( maxColumnWidht, columnLegend->renderSize().y() ) );
|
2019-01-02 03:39:11 -06:00
|
|
|
}
|
|
|
|
maxColumnWidht = 0;
|
|
|
|
columnLegends.clear();
|
2018-03-13 07:26:12 -05:00
|
|
|
}
|
2019-01-02 03:39:11 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
legend->setLayoutFixedPosition( cvf::Vec2i( xPos, yPos ) );
|
|
|
|
legend->setRenderSize( cvf::Vec2ui( prefSize.x(), prefSize.y() ) );
|
|
|
|
columnLegends.push_back( legend );
|
2019-01-02 03:39:11 -06:00
|
|
|
|
|
|
|
yPos += legend->renderSize().y() + border;
|
2019-09-06 03:40:57 -05:00
|
|
|
maxColumnWidht = std::max( maxColumnWidht, (int)prefSize.x() );
|
2016-09-12 04:11:25 -05:00
|
|
|
}
|
|
|
|
|
2019-01-02 03:39:11 -06:00
|
|
|
// Set same width to all legends in the last column
|
2016-09-12 04:11:25 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( caf::TitledOverlayFrame* legend : columnLegends )
|
2019-01-02 03:39:11 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
legend->setRenderSize( cvf::Vec2ui( maxColumnWidht, legend->renderSize().y() ) );
|
2019-01-02 03:39:11 -06:00
|
|
|
}
|
2016-09-12 04:11:25 -05:00
|
|
|
}
|
2018-04-06 07:07:00 -05:00
|
|
|
|
2019-11-07 03:49:16 -06:00
|
|
|
// Place the comparison view legends from right to left
|
|
|
|
{
|
|
|
|
int viewPortWidth = static_cast<int>( m_mainCamera->viewport()->width() );
|
|
|
|
|
|
|
|
int xPos = viewPortWidth - border + edgeAxisBorderWidth;
|
|
|
|
int yPosStart = border + edgeAxisBorderHeight + m_versionInfoLabel->sizeHint().height() + 5;
|
|
|
|
int yPos = yPosStart;
|
|
|
|
|
|
|
|
std::vector<caf::TitledOverlayFrame*> standardHeightLegends;
|
|
|
|
|
|
|
|
// Place the legends needing the full height, and sort out the standard height legends
|
|
|
|
|
|
|
|
for ( cvf::ref<caf::TitledOverlayFrame> legend : m_visibleComparisonLegends )
|
|
|
|
{
|
|
|
|
cvf::Vec2ui prefSize = legend->preferredSize();
|
|
|
|
if ( prefSize.y() > maxFreeLegendHeight )
|
|
|
|
{
|
|
|
|
int legendWidth = prefSize.x();
|
|
|
|
legend->setLayoutFixedPosition( cvf::Vec2i( xPos - legendWidth, yPos ) );
|
|
|
|
legend->setRenderSize(
|
|
|
|
cvf::Vec2ui( legendWidth, viewPortHeight - yPosStart - border - edgeAxisBorderHeight ) );
|
|
|
|
xPos -= legendWidth + border;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
standardHeightLegends.push_back( legend.p() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Place the rest of the legends in columns that fits within the screen height
|
|
|
|
|
|
|
|
std::vector<caf::TitledOverlayFrame*> columnLegends;
|
|
|
|
|
|
|
|
int maxColumnWidht = 0;
|
|
|
|
|
|
|
|
for ( caf::TitledOverlayFrame* legend : standardHeightLegends )
|
|
|
|
{
|
|
|
|
cvf::Vec2ui prefSize = legend->preferredSize();
|
|
|
|
|
|
|
|
// Check if we need a new column
|
|
|
|
if ( ( yPos + (int)prefSize.y() + border ) > viewPortHeight )
|
|
|
|
{
|
|
|
|
// Finish the previous column setting same width to all legends and correcting the xposition accordingly
|
|
|
|
for ( caf::TitledOverlayFrame* columnLegend : columnLegends )
|
|
|
|
{
|
|
|
|
columnLegend->setRenderSize( cvf::Vec2ui( maxColumnWidht, columnLegend->renderSize().y() ) );
|
|
|
|
columnLegend->setLayoutFixedPosition(
|
|
|
|
cvf::Vec2i( xPos - maxColumnWidht, columnLegend->fixedPosition().y() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Increment to make ready for a new column
|
|
|
|
xPos -= border + maxColumnWidht;
|
|
|
|
yPos = yPosStart;
|
|
|
|
|
|
|
|
maxColumnWidht = 0;
|
|
|
|
columnLegends.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
legend->setLayoutFixedPosition( cvf::Vec2i( xPos - prefSize.x(), yPos ) );
|
|
|
|
legend->setRenderSize( cvf::Vec2ui( prefSize.x(), prefSize.y() ) );
|
|
|
|
columnLegends.push_back( legend );
|
|
|
|
|
|
|
|
yPos += legend->renderSize().y() + border;
|
|
|
|
maxColumnWidht = std::max( maxColumnWidht, (int)prefSize.x() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finish the last column setting same width to all legends and correcting the xposition accordingly
|
|
|
|
|
|
|
|
for ( caf::TitledOverlayFrame* columnLegend : columnLegends )
|
|
|
|
{
|
|
|
|
columnLegend->setRenderSize( cvf::Vec2ui( maxColumnWidht, columnLegend->renderSize().y() ) );
|
|
|
|
columnLegend->setLayoutFixedPosition( cvf::Vec2i( xPos - maxColumnWidht, columnLegend->fixedPosition().y() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
xPos -= maxColumnWidht;
|
|
|
|
|
|
|
|
// Set axis cross position at the bottom besides the last column
|
|
|
|
{
|
|
|
|
m_axisCross->setLayoutFixedPosition(
|
|
|
|
cvf::Vec2i( xPos + border - m_axisCross->sizeHint().x(), edgeAxisBorderHeight ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the position of the scale bar used in contour map views
|
2018-04-06 07:07:00 -05:00
|
|
|
{
|
2019-01-02 03:39:11 -06:00
|
|
|
int margin = 5;
|
|
|
|
auto scaleLegendSize = m_scaleLegend->renderSize();
|
|
|
|
auto otherItemsHeight = m_versionInfoLabel->sizeHint().height();
|
2018-11-16 06:50:15 -06:00
|
|
|
|
2019-01-02 03:39:11 -06:00
|
|
|
const int xPos = width() - (int)scaleLegendSize.x() - margin - edgeAxisBorderWidth;
|
|
|
|
const int yPos = margin + edgeAxisBorderHeight + margin + otherItemsHeight;
|
|
|
|
|
2020-11-09 06:44:29 -06:00
|
|
|
m_scaleLegend->setLayoutFixedPosition( { xPos, yPos } );
|
2019-01-02 03:39:11 -06:00
|
|
|
}
|
2014-07-25 07:48:37 -05:00
|
|
|
}
|
2015-07-02 05:44:57 -05:00
|
|
|
|
2018-01-26 07:33:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2018-01-26 07:33:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::enableNavigationRotation( bool enable )
|
2018-01-26 07:33:32 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto tbNavPol = dynamic_cast<caf::TrackBallBasedNavigation*>( m_navigationPolicy.p() );
|
2018-01-26 07:33:32 -06:00
|
|
|
m_isNavigationRotationEnabled = enable;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( tbNavPol ) tbNavPol->enableRotation( m_isNavigationRotationEnabled );
|
2018-01-26 07:33:32 -06:00
|
|
|
}
|
|
|
|
|
2015-07-02 05:44:57 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2015-07-02 05:44:57 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuViewer::updateNavigationPolicy()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
switch ( RiaGuiApplication::instance()->navigationPolicy() )
|
2015-07-02 05:44:57 -05:00
|
|
|
{
|
2021-04-28 03:29:53 -05:00
|
|
|
case RiaDefines::RINavigationPolicy::NAVIGATION_POLICY_CAD:
|
2019-09-06 03:40:57 -05:00
|
|
|
setNavigationPolicy( new RiuCadNavigation );
|
2015-07-02 05:44:57 -05:00
|
|
|
break;
|
|
|
|
|
2021-04-28 03:29:53 -05:00
|
|
|
case RiaDefines::RINavigationPolicy::NAVIGATION_POLICY_CEETRON:
|
2019-09-06 03:40:57 -05:00
|
|
|
setNavigationPolicy( new caf::CeetronPlusNavigation );
|
2015-07-02 05:44:57 -05:00
|
|
|
break;
|
|
|
|
|
2021-04-28 03:29:53 -05:00
|
|
|
case RiaDefines::RINavigationPolicy::NAVIGATION_POLICY_GEOQUEST:
|
2019-09-06 03:40:57 -05:00
|
|
|
setNavigationPolicy( new RiuGeoQuestNavigation );
|
2015-07-02 05:44:57 -05:00
|
|
|
break;
|
|
|
|
|
2021-04-28 03:29:53 -05:00
|
|
|
case RiaDefines::RINavigationPolicy::NAVIGATION_POLICY_RMS:
|
2019-09-06 03:40:57 -05:00
|
|
|
setNavigationPolicy( new RiuRmsNavigation );
|
2015-07-02 05:44:57 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( 0 );
|
2015-07-02 05:44:57 -05:00
|
|
|
break;
|
|
|
|
}
|
2018-01-26 07:33:32 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
enableNavigationRotation( m_isNavigationRotationEnabled );
|
2015-07-02 05:44:57 -05:00
|
|
|
}
|
2015-08-25 05:40:55 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2015-08-25 05:40:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-01 11:04:35 -05:00
|
|
|
void RiuViewer::navigationPolicyUpdate()
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-09-23 05:50:06 -05:00
|
|
|
caf::Viewer::navigationPolicyUpdate();
|
2019-01-03 10:07:55 -06:00
|
|
|
ownerViewWindow()->viewNavigationChanged();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_rimView )
|
2015-08-25 05:40:55 -05:00
|
|
|
{
|
2015-11-16 00:16:30 -06:00
|
|
|
RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( viewLinker )
|
2015-09-23 05:23:21 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
viewLinker->updateCamera( dynamic_cast<RimGridView*>( m_rimView.p() ) );
|
2015-11-12 05:00:51 -06:00
|
|
|
}
|
2015-08-28 14:32:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-01 10:14:22 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2015-09-01 10:14:22 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::setCurrentFrame( int frameIndex )
|
2015-09-01 10:14:22 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( m_mainRendering.notNull() );
|
2015-09-01 10:14:22 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_rimView ) m_rimView->setCurrentTimeStepAndUpdate( frameIndex );
|
2019-01-02 02:45:48 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
animationControl()->setCurrentFrameOnly( frameIndex );
|
2015-09-01 10:14:22 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::Viewer::slotSetCurrentFrame( frameIndex );
|
2015-09-01 10:14:22 -05:00
|
|
|
}
|
2015-09-10 01:14:28 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2015-09-10 01:14:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::showAxisCross( bool enable )
|
2018-01-11 05:59:52 -06:00
|
|
|
{
|
2019-10-11 02:12:58 -05:00
|
|
|
overlayItemsRendering()->removeOverlayItem( m_axisCross.p() );
|
2018-01-11 05:59:52 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( enable )
|
2018-01-11 05:59:52 -06:00
|
|
|
{
|
2019-10-11 02:12:58 -05:00
|
|
|
overlayItemsRendering()->addOverlayItem( m_axisCross.p() );
|
2018-01-11 05:59:52 -06:00
|
|
|
}
|
2018-02-09 06:30:18 -06:00
|
|
|
m_showAxisCross = enable;
|
2018-01-11 05:59:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2018-01-11 05:59:52 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiuViewerToViewInterface* RiuViewer::ownerReservoirView()
|
2015-09-10 01:14:28 -05:00
|
|
|
{
|
2015-11-16 00:16:30 -06:00
|
|
|
return m_rimView;
|
2015-09-10 01:14:28 -05:00
|
|
|
}
|
2015-11-12 05:00:51 -06:00
|
|
|
|
2017-03-31 02:17:49 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2017-03-31 02:17:49 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimViewWindow* RiuViewer::ownerViewWindow() const
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return dynamic_cast<RimViewWindow*>( m_rimView.p() );
|
2017-03-31 02:17:49 -05:00
|
|
|
}
|
|
|
|
|
2015-11-16 03:01:50 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2015-11-16 03:01:50 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuViewer::optimizeClippingPlanes()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_showWindowEdgeAxes )
|
2018-02-12 02:05:58 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_windowEdgeAxisOverlay->setDisplayCoordTransform( m_rimView->displayCoordTransform().p() );
|
|
|
|
m_windowEdgeAxisOverlay->updateFromCamera( this->mainCamera() );
|
2018-02-12 02:05:58 -06:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_gridBoxGenerator->updateFromCamera( mainCamera() );
|
2019-10-11 02:12:58 -05:00
|
|
|
m_comparisonGridBoxGenerator->updateFromCamera( comparisonMainCamera() );
|
2018-11-15 04:24:09 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_scaleLegend->setDisplayCoordTransform( m_rimView->displayCoordTransform().p() );
|
|
|
|
m_scaleLegend->updateFromCamera( mainCamera() );
|
2018-11-15 04:24:09 -06:00
|
|
|
|
2015-12-03 07:02:36 -06:00
|
|
|
caf::Viewer::optimizeClippingPlanes();
|
2015-11-16 03:01:50 -06:00
|
|
|
}
|
2015-11-16 07:08:17 -06:00
|
|
|
|
2016-09-12 04:11:25 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2016-09-12 04:11:25 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::resizeGL( int width, int height )
|
2016-09-12 04:11:25 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::Viewer::resizeGL( width, height );
|
2016-09-12 04:11:25 -05:00
|
|
|
}
|
|
|
|
|
2016-12-15 11:20:43 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2016-12-15 11:20:43 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::mouseMoveEvent( QMouseEvent* mouseEvent )
|
2016-12-15 11:20:43 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_rimView )
|
2016-12-15 11:20:43 -06:00
|
|
|
{
|
2016-12-15 12:00:36 -06:00
|
|
|
RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( viewLinker )
|
2016-12-15 11:20:43 -06:00
|
|
|
{
|
2016-12-15 12:00:36 -06:00
|
|
|
int translatedMousePosX = mouseEvent->pos().x();
|
|
|
|
int translatedMousePosY = height() - mouseEvent->pos().y();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Vec3d displayCoord( 0, 0, 0 );
|
|
|
|
if ( mainCamera()->unproject( cvf::Vec3d( static_cast<double>( translatedMousePosX ),
|
|
|
|
static_cast<double>( translatedMousePosY ),
|
|
|
|
0 ),
|
|
|
|
&displayCoord ) )
|
2016-12-15 11:20:43 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_cursorPositionDomainCoords != cvf::Vec3d::UNDEFINED )
|
2016-12-15 11:20:43 -06:00
|
|
|
{
|
2016-12-15 12:00:36 -06:00
|
|
|
// Reset the extra cursor if the view currently is receiving mouse cursor events
|
|
|
|
// Set undefined and redraw to remove the previously displayed cursor
|
2016-12-15 11:20:43 -06:00
|
|
|
m_cursorPositionDomainCoords = cvf::Vec3d::UNDEFINED;
|
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2019-01-02 02:45:48 -06:00
|
|
|
cvf::ref<caf::DisplayCoordTransform> trans = m_rimView->displayCoordTransform();
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Vec3d domainCoord = trans->transformToDomainCoord( displayCoord );
|
2016-12-15 11:20:43 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
viewLinker->updateCursorPosition( dynamic_cast<RimGridView*>( m_rimView.p() ), domainCoord );
|
2016-12-15 11:20:43 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::Viewer::mouseMoveEvent( mouseEvent );
|
2016-12-15 11:20:43 -06:00
|
|
|
}
|
|
|
|
|
2019-03-22 09:55:51 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::enterEvent( QEvent* e )
|
2019-03-22 09:55:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( s_hoverCursor )
|
2019-03-22 09:55:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QApplication::setOverrideCursor( *s_hoverCursor );
|
2019-03-22 09:55:51 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::Viewer::enterEvent( e );
|
2019-03-22 09:55:51 -05:00
|
|
|
}
|
|
|
|
|
2016-12-16 07:53:19 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2016-12-16 07:53:19 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::leaveEvent( QEvent* )
|
2016-12-16 07:53:19 -06:00
|
|
|
{
|
2019-03-22 09:55:51 -05:00
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_rimView && m_rimView->assosiatedViewLinker() )
|
2016-12-16 07:53:19 -06:00
|
|
|
{
|
|
|
|
RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker();
|
2019-09-06 03:40:57 -05:00
|
|
|
viewLinker->updateCursorPosition( dynamic_cast<RimGridView*>( m_rimView.p() ), cvf::Vec3d::UNDEFINED );
|
2016-12-16 07:53:19 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-16 07:08:17 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2015-11-16 07:08:17 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-06-08 04:09:11 -05:00
|
|
|
void RiuViewer::updateGridBoxData( double scaleZ,
|
|
|
|
const cvf::Vec3d& displayModelOffset,
|
|
|
|
const cvf::Color3f& backgroundColor,
|
2020-05-09 04:23:58 -05:00
|
|
|
const cvf::BoundingBox& domainCoordBoundingBox,
|
2020-06-08 04:09:11 -05:00
|
|
|
int fontPointSize )
|
2015-11-16 07:08:17 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_gridBoxGenerator->setScaleZ( scaleZ );
|
|
|
|
m_gridBoxGenerator->setDisplayModelOffset( displayModelOffset );
|
|
|
|
m_gridBoxGenerator->updateFromBackgroundColor( backgroundColor );
|
|
|
|
m_gridBoxGenerator->setGridBoxDomainCoordBoundingBox( domainCoordBoundingBox );
|
2020-06-08 04:09:11 -05:00
|
|
|
m_gridBoxGenerator->setGridLabelFontSize( fontPointSize );
|
2015-11-23 06:31:01 -06:00
|
|
|
|
2018-01-11 05:59:52 -06:00
|
|
|
m_gridBoxGenerator->createGridBoxParts();
|
2018-10-02 09:29:58 -05:00
|
|
|
|
2019-10-11 02:12:58 -05:00
|
|
|
m_comparisonGridBoxGenerator->setScaleZ( scaleZ );
|
|
|
|
cvf::Vec3d unscaledComparisonOffset = comparisonViewEyePointOffset();
|
|
|
|
|
|
|
|
unscaledComparisonOffset.z() /= scaleZ;
|
|
|
|
|
|
|
|
m_comparisonGridBoxGenerator->setDisplayModelOffset( displayModelOffset - unscaledComparisonOffset );
|
|
|
|
m_comparisonGridBoxGenerator->updateFromBackgroundColor( backgroundColor );
|
|
|
|
m_comparisonGridBoxGenerator->setGridBoxDomainCoordBoundingBox( domainCoordBoundingBox );
|
|
|
|
|
|
|
|
m_comparisonGridBoxGenerator->createGridBoxParts();
|
2015-11-16 07:08:17 -06:00
|
|
|
}
|
|
|
|
|
2018-10-23 09:32:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::showEdgeTickMarksXY( bool enable, bool showAxisLines )
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2019-10-11 02:12:58 -05:00
|
|
|
overlayItemsRendering()->removeOverlayItem( m_windowEdgeAxisOverlay.p() );
|
2018-10-23 09:32:40 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( enable )
|
2018-10-23 09:32:40 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_windowEdgeAxisOverlay->setDomainAxes( RivWindowEdgeAxesOverlayItem::XY_AXES );
|
|
|
|
m_windowEdgeAxisOverlay->setIsSwitchingYAxisSign( false );
|
|
|
|
m_windowEdgeAxisOverlay->setShowAxisLines( showAxisLines );
|
2019-10-11 02:12:58 -05:00
|
|
|
overlayItemsRendering()->addOverlayItem( m_windowEdgeAxisOverlay.p() );
|
2018-10-23 09:32:40 -05:00
|
|
|
}
|
2019-01-02 03:39:11 -06:00
|
|
|
|
2018-10-23 09:32:40 -05:00
|
|
|
m_showWindowEdgeAxes = enable;
|
|
|
|
}
|
|
|
|
|
2015-11-16 07:08:17 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2018-02-08 12:42:34 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::showEdgeTickMarksXZ( bool enable, bool showAxisLines )
|
2018-02-08 12:42:34 -06:00
|
|
|
{
|
2019-10-11 02:12:58 -05:00
|
|
|
overlayItemsRendering()->removeOverlayItem( m_windowEdgeAxisOverlay.p() );
|
2018-02-08 12:42:34 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( enable )
|
2018-02-08 12:42:34 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_windowEdgeAxisOverlay->setDomainAxes( RivWindowEdgeAxesOverlayItem::XZ_AXES );
|
|
|
|
m_windowEdgeAxisOverlay->setIsSwitchingYAxisSign( true );
|
|
|
|
m_windowEdgeAxisOverlay->setShowAxisLines( showAxisLines );
|
2019-10-11 02:12:58 -05:00
|
|
|
overlayItemsRendering()->addOverlayItem( m_windowEdgeAxisOverlay.p() );
|
2018-02-08 12:42:34 -06:00
|
|
|
}
|
2019-01-02 03:39:11 -06:00
|
|
|
|
2018-02-09 06:30:18 -06:00
|
|
|
m_showWindowEdgeAxes = enable;
|
2018-02-08 12:42:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2015-11-16 07:08:17 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-11-08 02:07:30 -06:00
|
|
|
void RiuViewer::updateAnnotationItems()
|
2015-11-16 07:08:17 -06:00
|
|
|
{
|
2017-11-08 02:07:30 -06:00
|
|
|
updateTextAndTickMarkColorForOverlayItems();
|
2017-11-07 09:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2015-11-20 02:12:07 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::setAxisLabels( const cvf::String& xLabel, const cvf::String& yLabel, const cvf::String& zLabel )
|
2015-11-20 02:12:07 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_axisCross->setAxisLabels( xLabel, yLabel, zLabel );
|
2015-11-23 06:31:01 -06:00
|
|
|
}
|
|
|
|
|
2016-09-23 09:12:19 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-04 04:34:34 -06:00
|
|
|
///
|
2016-09-23 09:12:19 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-17 03:35:01 -05:00
|
|
|
RiuViewerCommands* RiuViewer::viewerCommands() const
|
2016-09-23 09:12:19 -05:00
|
|
|
{
|
2019-10-17 03:35:01 -05:00
|
|
|
return m_viewerCommands;
|
2016-09-23 09:12:19 -05:00
|
|
|
}
|
|
|
|
|
2016-10-17 04:51:25 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2016-10-17 04:51:25 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::OverlayItem* RiuViewer::pickFixedPositionedLegend( int winPosX, int winPosY )
|
2016-10-17 04:51:25 -05:00
|
|
|
{
|
|
|
|
int translatedMousePosX = winPosX;
|
|
|
|
int translatedMousePosY = height() - winPosY;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto overlayItem : m_visibleLegends )
|
2016-10-17 04:51:25 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( overlayItem->layoutScheme() == cvf::OverlayItem::FIXED_POSITION &&
|
|
|
|
overlayItem->pick( translatedMousePosX,
|
|
|
|
translatedMousePosY,
|
|
|
|
overlayItem->fixedPosition(),
|
|
|
|
overlayItem->renderSize() ) )
|
2016-10-17 04:51:25 -05:00
|
|
|
{
|
|
|
|
return overlayItem.p();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-07 03:49:16 -06:00
|
|
|
for ( auto overlayItem : m_visibleComparisonLegends )
|
|
|
|
{
|
|
|
|
if ( overlayItem->layoutScheme() == cvf::OverlayItem::FIXED_POSITION &&
|
|
|
|
overlayItem->pick( translatedMousePosX,
|
|
|
|
translatedMousePosY,
|
|
|
|
overlayItem->fixedPosition(),
|
|
|
|
overlayItem->renderSize() ) )
|
|
|
|
{
|
|
|
|
return overlayItem.p();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-17 04:51:25 -05:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-12-15 11:20:43 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2016-12-15 11:20:43 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::setCursorPosition( const cvf::Vec3d& domainCoord )
|
2016-12-15 11:20:43 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_cursorPositionDomainCoords != domainCoord )
|
2016-12-15 11:20:43 -06:00
|
|
|
{
|
|
|
|
m_cursorPositionDomainCoords = domainCoord;
|
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-21 05:57:49 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2018-09-21 05:57:49 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<cvf::ref<cvf::Part>> RiuViewer::visibleParts()
|
|
|
|
{
|
|
|
|
std::vector<cvf::ref<cvf::Part>> partsMatchingEnableMask;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_mainRendering.notNull() )
|
2018-09-21 05:57:49 -05:00
|
|
|
{
|
2019-01-02 02:45:48 -06:00
|
|
|
auto enableMask = m_mainRendering->enableMask();
|
|
|
|
cvf::Scene* scene = currentScene();
|
2018-09-21 05:57:49 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( cvf::uint i = 0; i < scene->modelCount(); i++ )
|
2018-09-21 05:57:49 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Model* model = scene->model( i );
|
|
|
|
if ( enableMask & model->partEnableMask() )
|
2018-09-21 05:57:49 -05:00
|
|
|
{
|
|
|
|
cvf::Collection<cvf::Part> partCollection;
|
2019-09-06 03:40:57 -05:00
|
|
|
model->allParts( &partCollection );
|
2018-09-21 05:57:49 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( const auto& p : partCollection )
|
2018-09-21 05:57:49 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( enableMask & p->enableMask() )
|
2018-09-21 05:57:49 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
partsMatchingEnableMask.push_back( p );
|
2018-09-21 05:57:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return partsMatchingEnableMask;
|
|
|
|
}
|
|
|
|
|
2018-11-15 04:24:09 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::showScaleLegend( bool show )
|
2018-11-15 04:24:09 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( show )
|
2018-11-15 04:24:09 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_scaleLegend->orientation() == caf::OverlayScaleLegend::HORIZONTAL )
|
2020-11-09 06:44:29 -06:00
|
|
|
m_scaleLegend->setRenderSize( { 280, 45 } );
|
2018-11-16 06:50:15 -06:00
|
|
|
else
|
2020-11-09 06:44:29 -06:00
|
|
|
m_scaleLegend->setRenderSize( { 50, 280 } );
|
2018-11-16 06:50:15 -06:00
|
|
|
|
2019-10-11 02:12:58 -05:00
|
|
|
overlayItemsRendering()->addOverlayItem( m_scaleLegend.p() );
|
2018-11-15 04:24:09 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-11 02:12:58 -05:00
|
|
|
overlayItemsRendering()->removeOverlayItem( m_scaleLegend.p() );
|
2018-11-15 04:24:09 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-22 09:55:51 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::setHoverCursor( const QCursor& cursor )
|
2019-03-22 09:55:51 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
s_hoverCursor.reset( new QCursor( cursor ) );
|
2019-03-22 09:55:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuViewer::clearHoverCursor()
|
|
|
|
{
|
|
|
|
s_hoverCursor.reset();
|
|
|
|
}
|
|
|
|
|
2019-04-10 05:49:20 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-06-08 04:09:11 -05:00
|
|
|
void RiuViewer::updateFonts( int fontPointSize )
|
2019-04-10 05:49:20 -05:00
|
|
|
{
|
2020-05-09 04:23:58 -05:00
|
|
|
m_fontPointSize = fontPointSize;
|
2019-04-10 05:49:20 -05:00
|
|
|
|
2020-05-09 04:23:58 -05:00
|
|
|
auto defaultFontSize = RiaApplication::instance()->preferences()->defaultSceneFontSize();
|
|
|
|
cvf::Font* axisFont = RiaGuiApplication::instance()->defaultSceneFont();
|
|
|
|
QFont font = QApplication::font();
|
2020-06-08 04:09:11 -05:00
|
|
|
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( m_fontPointSize ) );
|
2020-05-09 04:23:58 -05:00
|
|
|
|
2020-06-08 04:09:11 -05:00
|
|
|
if ( caf::FontTools::absolutePointSize( defaultFontSize ) != m_fontPointSize )
|
2020-05-09 04:23:58 -05:00
|
|
|
{
|
|
|
|
axisFont = RiaFontCache::getFont( m_fontPointSize ).p();
|
|
|
|
}
|
|
|
|
|
|
|
|
overlayItemsRendering()->removeOverlayItem( m_axisCross.p() );
|
2020-06-08 04:09:11 -05:00
|
|
|
|
2020-05-09 04:23:58 -05:00
|
|
|
m_axisCross = new cvf::OverlayAxisCross( m_mainCamera.p(), axisFont );
|
2019-09-06 03:40:57 -05:00
|
|
|
m_axisCross->setAxisLabels( "X", "Y", "Z" );
|
|
|
|
m_axisCross->setLayout( cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_RIGHT );
|
2019-10-11 02:12:58 -05:00
|
|
|
overlayItemsRendering()->addOverlayItem( m_axisCross.p() );
|
2019-04-10 05:49:20 -05:00
|
|
|
m_showAxisCross = true;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_zScaleLabel->setFont( font );
|
|
|
|
m_infoLabel->setFont( font );
|
2019-11-08 03:39:40 -06:00
|
|
|
m_shortInfoLabel->setFont( font );
|
|
|
|
m_shortInfoLabelCompView->setFont( font );
|
2019-09-06 03:40:57 -05:00
|
|
|
m_animationProgress->setFont( font );
|
2019-11-08 03:39:40 -06:00
|
|
|
m_animationProgressCompView->setFont( font );
|
2019-09-06 03:40:57 -05:00
|
|
|
m_versionInfoLabel->setFont( font );
|
2020-05-09 04:23:58 -05:00
|
|
|
|
2020-06-08 04:09:11 -05:00
|
|
|
m_gridBoxGenerator->setGridLabelFontSize( m_fontPointSize );
|
2019-04-10 05:49:20 -05:00
|
|
|
}
|
|
|
|
|
2015-11-23 06:31:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2015-11-23 06:31:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RiuViewer::updateLegendTextAndTickMarkColor( cvf::OverlayItem* legend )
|
2015-11-23 06:31:01 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_rimView.isNull() ) return;
|
2015-11-20 02:12:07 -06:00
|
|
|
|
2015-11-23 06:31:01 -06:00
|
|
|
cvf::Color3f contrastColor = computeContrastColor();
|
2015-11-20 02:12:07 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::OverlayScalarMapperLegend* scalarMapperLegend = dynamic_cast<caf::OverlayScalarMapperLegend*>( legend );
|
|
|
|
if ( scalarMapperLegend )
|
2015-11-23 06:31:01 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
scalarMapperLegend->setTextColor( contrastColor );
|
|
|
|
scalarMapperLegend->setLineColor( contrastColor );
|
2015-11-23 06:31:01 -06:00
|
|
|
}
|
2016-08-02 03:25:55 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::CategoryLegend* categoryLegend = dynamic_cast<caf::CategoryLegend*>( legend );
|
|
|
|
if ( categoryLegend )
|
2016-08-02 03:25:55 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
categoryLegend->setTextColor( contrastColor );
|
|
|
|
categoryLegend->setLineColor( contrastColor );
|
2016-08-02 03:25:55 -05:00
|
|
|
}
|
2017-11-07 08:08:28 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RivTernarySaturationOverlayItem* ternaryItem = dynamic_cast<RivTernarySaturationOverlayItem*>( legend );
|
|
|
|
if ( ternaryItem )
|
2017-11-07 08:08:28 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
ternaryItem->setAxisLabelsColor( contrastColor );
|
2017-11-07 08:08:28 -06:00
|
|
|
}
|
2015-11-23 06:31:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2015-11-23 06:31:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuViewer::updateTextAndTickMarkColorForOverlayItems()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( size_t i = 0; i < m_visibleLegends.size(); i++ )
|
2015-11-23 06:31:01 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
updateLegendTextAndTickMarkColor( m_visibleLegends.at( i ) );
|
2015-11-23 06:31:01 -06:00
|
|
|
}
|
|
|
|
|
2019-11-07 03:49:16 -06:00
|
|
|
for ( auto legend : m_visibleComparisonLegends )
|
|
|
|
{
|
|
|
|
updateLegendTextAndTickMarkColor( legend.p() );
|
|
|
|
}
|
|
|
|
|
2015-11-23 06:31:01 -06:00
|
|
|
updateAxisCrossTextColor();
|
2019-02-18 14:01:37 -06:00
|
|
|
|
2019-04-07 11:16:31 -05:00
|
|
|
updateOverlayItemsStyle();
|
2015-11-23 06:31:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2015-11-23 06:31:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuViewer::updateAxisCrossTextColor()
|
|
|
|
{
|
|
|
|
cvf::Color3f contrastColor = computeContrastColor();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_axisCross->setAxisLabelsColor( contrastColor );
|
2015-11-23 06:31:01 -06:00
|
|
|
}
|
|
|
|
|
2019-02-18 14:01:37 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-04-07 11:16:31 -05:00
|
|
|
void RiuViewer::updateOverlayItemsStyle()
|
2019-02-18 14:01:37 -06:00
|
|
|
{
|
|
|
|
QColor backgroundColor;
|
|
|
|
QColor backgroundFrameColor;
|
|
|
|
QColor contrastColor;
|
|
|
|
{
|
|
|
|
cvf::Color4f cvf_backgroundColor = mainCamera()->viewport()->clearColor();
|
2019-04-07 11:16:31 -05:00
|
|
|
cvf_backgroundColor.a() = 0.65f;
|
2019-02-18 14:01:37 -06:00
|
|
|
|
|
|
|
cvf::Color4f cvf_backgroundFrameColor =
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::Color4f( RiaColorTools::computeOffsetColor( cvf_backgroundColor.toColor3f(), 0.3f ), 0.9f );
|
2019-02-18 14:01:37 -06:00
|
|
|
|
|
|
|
cvf::Color3f cvf_contrastColor = computeContrastColor();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
backgroundColor = RiaColorTools::toQColor( cvf_backgroundColor );
|
|
|
|
backgroundFrameColor = RiaColorTools::toQColor( cvf_backgroundFrameColor );
|
|
|
|
contrastColor = RiaColorTools::toQColor( cvf_contrastColor );
|
2019-02-18 14:01:37 -06:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_infoLabel->setStyleSheet( caf::StyleSheetTools::createFrameStyleSheet( "QLabel",
|
|
|
|
"InfoLabel",
|
|
|
|
contrastColor,
|
|
|
|
backgroundColor,
|
|
|
|
backgroundFrameColor ) );
|
2019-11-08 03:39:40 -06:00
|
|
|
m_shortInfoLabel->setStyleSheet( caf::StyleSheetTools::createFrameStyleSheet( "QLabel",
|
|
|
|
"ShortInfoLabel",
|
|
|
|
contrastColor,
|
|
|
|
backgroundColor,
|
|
|
|
backgroundFrameColor ) );
|
|
|
|
m_shortInfoLabelCompView->setStyleSheet( caf::StyleSheetTools::createFrameStyleSheet( "QLabel",
|
|
|
|
"ShortInfoLabelCompView",
|
|
|
|
contrastColor,
|
|
|
|
backgroundColor,
|
|
|
|
backgroundFrameColor ) );
|
2020-10-02 08:25:15 -05:00
|
|
|
m_versionInfoLabel->setStyleSheet(
|
|
|
|
caf::StyleSheetTools::createFrameStyleSheet( "QLabel", "VersionInfo", contrastColor, backgroundColor, backgroundColor ) );
|
|
|
|
m_zScaleLabel->setStyleSheet(
|
|
|
|
caf::StyleSheetTools::createFrameStyleSheet( "QLabel", "ZScaleLabel", contrastColor, backgroundColor, backgroundColor ) );
|
|
|
|
m_histogramWidget->setStyleSheet( caf::StyleSheetTools::createFrameStyleSheet( "QWidget",
|
2019-09-06 03:40:57 -05:00
|
|
|
"HistogramWidget",
|
|
|
|
contrastColor,
|
|
|
|
backgroundColor,
|
|
|
|
backgroundFrameColor ) );
|
|
|
|
|
|
|
|
QColor progressColor( Qt::green );
|
|
|
|
progressColor.setAlphaF( 0.8f );
|
|
|
|
backgroundColor.setAlphaF( 0.8f );
|
2020-02-12 04:43:15 -06:00
|
|
|
m_animationProgress->setTextBackgroundAndProgressColor( contrastColor, backgroundColor, backgroundFrameColor, progressColor );
|
2019-11-08 03:39:40 -06:00
|
|
|
m_animationProgressCompView->setTextBackgroundAndProgressColor( contrastColor,
|
|
|
|
backgroundColor,
|
|
|
|
backgroundFrameColor,
|
|
|
|
progressColor );
|
2019-02-18 14:01:37 -06:00
|
|
|
}
|
|
|
|
|
2015-11-23 06:31:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 02:45:48 -06:00
|
|
|
///
|
2015-11-23 06:31:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::Color3f RiuViewer::computeContrastColor() const
|
|
|
|
{
|
2017-11-07 08:08:28 -06:00
|
|
|
cvf::Color3f contrastColor = RiaColorTools::brightContrastColor();
|
2015-11-23 06:31:01 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_rimView.notNull() )
|
2015-11-23 06:31:01 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
contrastColor = RiaColorTools::contrastColor( m_rimView->backgroundColor() );
|
2015-11-23 06:31:01 -06:00
|
|
|
}
|
2019-01-02 02:45:48 -06:00
|
|
|
|
2015-11-23 06:31:01 -06:00
|
|
|
return contrastColor;
|
2015-11-20 02:12:07 -06:00
|
|
|
}
|