2019-10-11 08:54:19 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2019- Equinor ASA
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
2019-11-15 06:35:39 -06:00
|
|
|
#include "RimMultiPlotWindow.h"
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2019-11-15 03:12:19 -06:00
|
|
|
#include "RimPlot.h"
|
|
|
|
|
2019-12-19 04:37:40 -06:00
|
|
|
#include "RiuMultiPlotWindow.h"
|
2019-10-11 08:54:19 -05:00
|
|
|
#include "RiuPlotMainWindow.h"
|
|
|
|
#include "RiuPlotMainWindowTools.h"
|
|
|
|
|
2019-12-19 04:37:40 -06:00
|
|
|
#include <QPaintDevice>
|
2019-10-11 08:54:19 -05:00
|
|
|
#include <QRegularExpression>
|
|
|
|
|
|
|
|
#include <cvfAssert.h>
|
|
|
|
|
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
template <>
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::ColumnCountEnum::setUp()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-15 06:35:39 -06:00
|
|
|
addItem( RimMultiPlotWindow::COLUMNS_1, "1", "1 Column" );
|
|
|
|
addItem( RimMultiPlotWindow::COLUMNS_2, "2", "2 Columns" );
|
|
|
|
addItem( RimMultiPlotWindow::COLUMNS_3, "3", "3 Columns" );
|
|
|
|
addItem( RimMultiPlotWindow::COLUMNS_4, "4", "4 Columns" );
|
|
|
|
addItem( RimMultiPlotWindow::COLUMNS_UNLIMITED, "UNLIMITED", "Unlimited" );
|
|
|
|
setDefault( RimMultiPlotWindow::COLUMNS_2 );
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
2019-12-19 04:37:40 -06:00
|
|
|
template <>
|
|
|
|
void RimMultiPlotWindow::RowCountEnum::setUp()
|
|
|
|
{
|
|
|
|
addItem( RimMultiPlotWindow::ROWS_1, "1", "1 Row" );
|
|
|
|
addItem( RimMultiPlotWindow::ROWS_2, "2", "2 Rows" );
|
|
|
|
addItem( RimMultiPlotWindow::ROWS_3, "3", "3 Rows" );
|
|
|
|
addItem( RimMultiPlotWindow::ROWS_4, "4", "4 Rows" );
|
|
|
|
setDefault( RimMultiPlotWindow::ROWS_2 );
|
|
|
|
}
|
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
} // namespace caf
|
|
|
|
|
2019-11-15 06:35:39 -06:00
|
|
|
CAF_PDM_SOURCE_INIT( RimMultiPlotWindow, "MultiPlot" );
|
2019-10-11 08:54:19 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-12-17 02:07:33 -06:00
|
|
|
RimMultiPlotWindow::RimMultiPlotWindow( bool hidePlotsInTreeView )
|
2019-11-15 06:35:39 -06:00
|
|
|
: m_acceptDrops( true )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-13 04:48:21 -06:00
|
|
|
CAF_PDM_InitObject( "Multi Plot", ":/WellLogPlot16x16.png", "", "" );
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2019-11-13 04:44:54 -06:00
|
|
|
CAF_PDM_InitField( &m_showPlotWindowTitle, "ShowTitleInPlot", true, "Show Title", "", "", "" );
|
|
|
|
CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "" ), "Name", "", "", "" );
|
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_plots, "Tracks", "", "", "", "" );
|
|
|
|
m_plots.uiCapability()->setUiHidden( true );
|
2019-12-17 02:07:33 -06:00
|
|
|
m_plots.uiCapability()->setUiTreeChildrenHidden( hidePlotsInTreeView );
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2019-12-19 04:37:40 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_columnCount, "NumberOfColumns", "Number of Columns", "", "", "" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_rowsPerPage, "RowsPerPage", "Rows per Page", "", "", "" );
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2019-10-31 07:48:40 -05:00
|
|
|
CAF_PDM_InitField( &m_showIndividualPlotTitles, "ShowPlotTitles", false, "Show Sub Plot Titles", "", "", "" );
|
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
m_viewer = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
RimMultiPlotWindow::~RimMultiPlotWindow()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
removeMdiWindowFromMdiArea();
|
|
|
|
m_plots.deleteAllChildObjects();
|
|
|
|
|
2019-11-07 01:48:11 -06:00
|
|
|
cleanupBeforeClose();
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Move-assignment operator. Argument has to be passed with std::move()
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
RimMultiPlotWindow& RimMultiPlotWindow::operator=( RimMultiPlotWindow&& rhs )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
RimPlotWindow::operator=( std::move( rhs ) );
|
|
|
|
|
|
|
|
// Move all tracks
|
2019-11-15 03:12:19 -06:00
|
|
|
std::vector<RimPlot*> plots = rhs.m_plots.childObjects();
|
2019-10-11 08:54:19 -05:00
|
|
|
rhs.m_plots.clear();
|
2019-11-15 03:12:19 -06:00
|
|
|
for ( RimPlot* plot : plots )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
m_plots.push_back( plot );
|
|
|
|
}
|
|
|
|
|
2020-01-08 07:08:58 -06:00
|
|
|
// Deliberately don't set m_plotWindowTitle. This operator is used for copying parameters from children.
|
|
|
|
// This only happens for some plots that used to own a plot but now inherits the plot.
|
|
|
|
// These all had their own description at top level which we don't want to overwrite.
|
|
|
|
|
2019-12-19 04:37:40 -06:00
|
|
|
m_showPlotWindowTitle = rhs.m_showPlotWindowTitle;
|
|
|
|
m_columnCount = rhs.m_columnCount;
|
|
|
|
m_rowsPerPage = rhs.m_rowsPerPage;
|
|
|
|
m_showIndividualPlotTitles = rhs.m_showIndividualPlotTitles;
|
|
|
|
|
|
|
|
m_acceptDrops = rhs.m_acceptDrops;
|
2019-10-11 08:54:19 -05:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
QWidget* RimMultiPlotWindow::viewWidget()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
return m_viewer;
|
|
|
|
}
|
|
|
|
|
2019-11-15 03:12:19 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
QString RimMultiPlotWindow::description() const
|
2019-11-15 03:12:19 -06:00
|
|
|
{
|
|
|
|
return multiPlotTitle();
|
|
|
|
}
|
|
|
|
|
2019-11-13 04:44:54 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
bool RimMultiPlotWindow::isMultiPlotTitleVisible() const
|
2019-11-13 04:44:54 -06:00
|
|
|
{
|
|
|
|
return m_showPlotWindowTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::setMultiPlotTitleVisible( bool visible )
|
2019-11-13 04:44:54 -06:00
|
|
|
{
|
|
|
|
m_showPlotWindowTitle = visible;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
QString RimMultiPlotWindow::multiPlotTitle() const
|
2019-11-13 04:44:54 -06:00
|
|
|
{
|
|
|
|
return m_plotWindowTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::setMultiPlotTitle( const QString& title )
|
2019-11-13 04:44:54 -06:00
|
|
|
{
|
|
|
|
m_plotWindowTitle = title;
|
|
|
|
}
|
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::addPlot( RimPlot* plot )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
insertPlot( plot, m_plots.size() );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::insertPlot( RimPlot* plot, size_t index )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
if ( plot )
|
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
m_plots.insert( index, plot );
|
2019-10-11 08:54:19 -05:00
|
|
|
|
|
|
|
if ( m_viewer )
|
|
|
|
{
|
|
|
|
plot->createPlotWidget();
|
|
|
|
m_viewer->insertPlot( plot->viewer(), index );
|
|
|
|
}
|
2020-01-06 05:43:33 -06:00
|
|
|
plot->setShowWindow( true );
|
2019-11-15 06:35:39 -06:00
|
|
|
plot->setLegendsVisible( false );
|
2019-10-11 08:54:19 -05:00
|
|
|
|
|
|
|
onPlotAdditionOrRemoval();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::removePlot( RimPlot* plot )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
if ( plot )
|
|
|
|
{
|
|
|
|
if ( m_viewer )
|
|
|
|
{
|
|
|
|
m_viewer->removePlot( plot->viewer() );
|
|
|
|
}
|
2019-11-15 03:12:19 -06:00
|
|
|
m_plots.removeChildObject( plot );
|
2019-10-11 08:54:19 -05:00
|
|
|
|
|
|
|
onPlotAdditionOrRemoval();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-31 07:48:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::movePlotsToThis( const std::vector<RimPlot*>& plotsToMove, RimPlot* plotToInsertAfter )
|
2019-10-31 07:48:40 -05:00
|
|
|
{
|
|
|
|
for ( size_t tIdx = 0; tIdx < plotsToMove.size(); tIdx++ )
|
|
|
|
{
|
2019-11-28 13:43:49 -06:00
|
|
|
RimMultiPlotWindow* previousMultiPlotWindow = nullptr;
|
|
|
|
plotsToMove[tIdx]->firstAncestorOrThisOfType( previousMultiPlotWindow );
|
|
|
|
if ( previousMultiPlotWindow )
|
|
|
|
{
|
|
|
|
previousMultiPlotWindow->removePlot( plotsToMove[tIdx] );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
plotsToMove[tIdx]->removeFromMdiAreaAndCollection();
|
|
|
|
}
|
2019-10-31 07:48:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t insertionStartIndex = 0;
|
|
|
|
if ( plotToInsertAfter ) insertionStartIndex = this->plotIndex( plotToInsertAfter ) + 1;
|
|
|
|
|
|
|
|
for ( size_t tIdx = 0; tIdx < plotsToMove.size(); tIdx++ )
|
|
|
|
{
|
|
|
|
this->insertPlot( plotsToMove[tIdx], insertionStartIndex + tIdx );
|
|
|
|
}
|
|
|
|
|
|
|
|
this->updateLayout();
|
|
|
|
this->updateAllRequiredEditors();
|
|
|
|
}
|
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
size_t RimMultiPlotWindow::plotCount() const
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
return m_plots.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
size_t RimMultiPlotWindow::plotIndex( const RimPlot* plot ) const
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
return m_plots.index( plot );
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
RimPlot* RimMultiPlotWindow::plotByIndex( size_t index ) const
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
return m_plots[index];
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
std::vector<RimPlot*> RimMultiPlotWindow::plots() const
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
return m_plots.childObjects();
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
std::vector<RimPlot*> RimMultiPlotWindow::visiblePlots() const
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
std::vector<RimPlot*> allVisiblePlots;
|
|
|
|
for ( RimPlot* plot : m_plots() )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
if ( plot->showWindow() )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
allVisiblePlots.push_back( plot );
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
}
|
2019-11-15 03:12:19 -06:00
|
|
|
return allVisiblePlots;
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::doUpdateLayout()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-12-19 04:37:40 -06:00
|
|
|
if ( m_showWindow && m_viewer )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
m_viewer->scheduleUpdate();
|
2020-01-06 06:03:53 -06:00
|
|
|
m_viewer->adjustSize();
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-24 07:01:16 -05:00
|
|
|
/// Empty default implementation
|
2019-10-11 08:54:19 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-26 01:45:17 -06:00
|
|
|
void RimMultiPlotWindow::updateSubPlotNames() {}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Empty default implementation
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimMultiPlotWindow::updatePlotWindowTitle() {}
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2019-11-27 04:44:56 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimMultiPlotWindow::doSetAutoScaleYEnabled( bool enabled )
|
|
|
|
{
|
|
|
|
for ( RimPlot* plot : plots() )
|
|
|
|
{
|
|
|
|
plot->setAutoScaleYEnabled( enabled );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-18 05:25:19 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-12-19 03:34:23 -06:00
|
|
|
void RimMultiPlotWindow::doRenderWindowContent( QPaintDevice* paintDevice )
|
2019-12-18 05:25:19 -06:00
|
|
|
{
|
|
|
|
if ( m_viewer )
|
|
|
|
{
|
2019-12-19 03:34:23 -06:00
|
|
|
m_viewer->renderTo( paintDevice );
|
2019-12-18 05:25:19 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::updatePlotOrderFromGridWidget()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
std::sort( m_plots.begin(), m_plots.end(), [this]( RimPlot* lhs, RimPlot* rhs ) {
|
|
|
|
auto indexLhs = m_viewer->indexOfPlotWidget( lhs->viewer() );
|
|
|
|
auto indexRhs = m_viewer->indexOfPlotWidget( rhs->viewer() );
|
2019-10-11 08:54:19 -05:00
|
|
|
return indexLhs < indexRhs;
|
|
|
|
} );
|
2019-11-26 01:45:17 -06:00
|
|
|
updateSubPlotNames();
|
2019-10-11 08:54:19 -05:00
|
|
|
updateConnectedEditors();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::setAutoScaleXEnabled( bool enabled )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
for ( RimPlot* plot : plots() )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
plot->setAutoScaleXEnabled( enabled );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::setAutoScaleYEnabled( bool enabled )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-27 04:44:56 -06:00
|
|
|
doSetAutoScaleYEnabled( enabled );
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
int RimMultiPlotWindow::columnCount() const
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-12-19 04:37:40 -06:00
|
|
|
if ( m_columnCount() == COLUMNS_UNLIMITED )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-05 08:47:29 -06:00
|
|
|
return std::numeric_limits<int>::max();
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
2019-12-19 04:37:40 -06:00
|
|
|
return static_cast<int>( m_columnCount() );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RimMultiPlotWindow::rowsPerPage() const
|
|
|
|
{
|
|
|
|
return static_cast<int>( m_rowsPerPage() );
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
caf::PdmFieldHandle* RimMultiPlotWindow::columnCountField()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-12-19 04:37:40 -06:00
|
|
|
return &m_columnCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimMultiPlotWindow::rowsPerPageField()
|
|
|
|
{
|
|
|
|
return &m_rowsPerPage;
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
bool RimMultiPlotWindow::showPlotTitles() const
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-10-31 07:48:40 -05:00
|
|
|
return m_showIndividualPlotTitles;
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::zoomAll()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-10-31 07:48:40 -05:00
|
|
|
setAutoScaleXEnabled( true );
|
|
|
|
setAutoScaleYEnabled( true );
|
|
|
|
updateZoom();
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
QString RimMultiPlotWindow::asciiDataForPlotExport() const
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-13 04:44:54 -06:00
|
|
|
QString out = multiPlotTitle() + "\n";
|
2019-10-11 08:54:19 -05:00
|
|
|
|
2019-11-15 03:12:19 -06:00
|
|
|
for ( RimPlot* plot : plots() )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
if ( plot->showWindow() )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
out += plot->asciiDataForPlotExport();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::onPlotAdditionOrRemoval()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-26 01:45:17 -06:00
|
|
|
updateSubPlotNames();
|
|
|
|
updatePlotWindowTitle();
|
|
|
|
applyPlotWindowTitleToWidgets();
|
2019-10-11 08:54:19 -05:00
|
|
|
updateConnectedEditors();
|
|
|
|
updateLayout();
|
2019-10-24 07:01:16 -05:00
|
|
|
RiuPlotMainWindowTools::refreshToolbars();
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::setAcceptDrops( bool acceptDrops )
|
|
|
|
{
|
|
|
|
m_acceptDrops = acceptDrops;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimMultiPlotWindow::acceptDrops() const
|
|
|
|
{
|
|
|
|
return m_acceptDrops;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-01-08 01:53:06 -06:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimMultiPlotWindow::previewModeEnabled() const
|
|
|
|
{
|
|
|
|
if ( m_viewer )
|
|
|
|
{
|
|
|
|
return m_viewer->previewModeEnabled();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QImage RimMultiPlotWindow::snapshotWindowContent()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
QImage image;
|
|
|
|
|
|
|
|
if ( m_viewer )
|
|
|
|
{
|
2019-12-19 03:34:23 -06:00
|
|
|
QPixmap pix( m_viewer->size() );
|
|
|
|
m_viewer->renderTo( &pix );
|
2019-12-18 05:25:19 -06:00
|
|
|
image = pix.toImage();
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
QWidget* RimMultiPlotWindow::createViewWidget( QWidget* mainWindowParent )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-20 06:38:50 -06:00
|
|
|
if ( m_viewer.isNull() )
|
|
|
|
{
|
|
|
|
m_viewer = new RiuMultiPlotWindow( this, mainWindowParent );
|
|
|
|
}
|
2019-10-11 08:54:19 -05:00
|
|
|
recreatePlotWidgets();
|
|
|
|
return m_viewer;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::deleteViewWidget()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-07 01:48:11 -06:00
|
|
|
cleanupBeforeClose();
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 04:44:54 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
caf::PdmFieldHandle* RimMultiPlotWindow::userDescriptionField()
|
2019-11-13 04:44:54 -06:00
|
|
|
{
|
|
|
|
return &m_plotWindowTitle;
|
|
|
|
}
|
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|
|
|
const QVariant& oldValue,
|
|
|
|
const QVariant& newValue )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
RimPlotWindow::fieldChangedByUi( changedField, oldValue, newValue );
|
|
|
|
|
2019-10-31 07:48:40 -05:00
|
|
|
if ( changedField == &m_showIndividualPlotTitles )
|
|
|
|
{
|
|
|
|
updateLayout();
|
|
|
|
}
|
2019-11-13 04:44:54 -06:00
|
|
|
else if ( changedField == &m_showPlotWindowTitle || changedField == &m_plotWindowTitle )
|
|
|
|
{
|
2019-11-26 01:45:17 -06:00
|
|
|
updatePlotWindowTitle();
|
|
|
|
applyPlotWindowTitleToWidgets();
|
2019-11-13 04:44:54 -06:00
|
|
|
}
|
2019-12-19 04:37:40 -06:00
|
|
|
else if ( changedField == &m_columnCount || changedField == &m_rowsPerPage )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
updateLayout();
|
2019-10-24 07:01:16 -05:00
|
|
|
RiuPlotMainWindowTools::refreshToolbars();
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
updateConnectedEditors();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-10-31 07:48:40 -05:00
|
|
|
caf::PdmUiGroup* titleAndLegendsGroup = uiOrdering.addNewGroup( "Plot Layout" );
|
2020-01-08 03:31:01 -06:00
|
|
|
uiOrderingForMultiPlotLayout( uiConfigName, *titleAndLegendsGroup );
|
2019-10-31 07:48:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-01-08 03:31:01 -06:00
|
|
|
void RimMultiPlotWindow::uiOrderingForMultiPlotLayout( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
2019-10-31 07:48:40 -05:00
|
|
|
{
|
2019-11-13 04:44:54 -06:00
|
|
|
uiOrdering.add( &m_showPlotWindowTitle );
|
|
|
|
uiOrdering.add( &m_plotWindowTitle );
|
2019-10-31 07:48:40 -05:00
|
|
|
uiOrdering.add( &m_showIndividualPlotTitles );
|
2020-01-08 03:31:01 -06:00
|
|
|
RimPlotWindow::uiOrderingForPlotLayout( uiConfigName, uiOrdering );
|
2019-12-19 04:37:40 -06:00
|
|
|
uiOrdering.add( &m_columnCount );
|
|
|
|
uiOrdering.add( &m_rowsPerPage );
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
QList<caf::PdmOptionItemInfo> RimMultiPlotWindow::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
|
|
|
bool* useOptionsOnly )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options = RimPlotWindow::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
|
|
|
|
|
2019-12-19 04:37:40 -06:00
|
|
|
if ( fieldNeedingOptions == &m_columnCount )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
for ( size_t i = 0; i < ColumnCountEnum::size(); ++i )
|
|
|
|
{
|
|
|
|
ColumnCount enumVal = ColumnCountEnum::fromIndex( i );
|
|
|
|
if ( enumVal == COLUMNS_UNLIMITED )
|
|
|
|
{
|
|
|
|
QString iconPath( ":/ColumnsUnlimited.png" );
|
|
|
|
options.push_back( caf::PdmOptionItemInfo( ColumnCountEnum::uiText( enumVal ),
|
|
|
|
enumVal,
|
|
|
|
false,
|
|
|
|
caf::QIconProvider( iconPath ) ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QString iconPath = QString( ":/Columns%1.png" ).arg( static_cast<int>( enumVal ) );
|
|
|
|
options.push_back( caf::PdmOptionItemInfo( ColumnCountEnum::uiText( enumVal ),
|
|
|
|
enumVal,
|
|
|
|
false,
|
|
|
|
caf::QIconProvider( iconPath ) ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::onLoadDataAndUpdate()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
updateMdiWindowVisibility();
|
2019-11-26 01:45:17 -06:00
|
|
|
updatePlotWindowTitle();
|
|
|
|
applyPlotWindowTitleToWidgets();
|
2019-10-11 08:54:19 -05:00
|
|
|
updatePlots();
|
|
|
|
updateLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::initAfterRead()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
RimPlotWindow::initAfterRead();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-26 01:45:17 -06:00
|
|
|
void RimMultiPlotWindow::applyPlotWindowTitleToWidgets()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
if ( m_viewer )
|
|
|
|
{
|
2019-11-13 04:44:54 -06:00
|
|
|
m_viewer->setTitleVisible( m_showPlotWindowTitle() );
|
|
|
|
m_viewer->setPlotTitle( multiPlotTitle() );
|
2019-10-11 08:54:19 -05:00
|
|
|
}
|
|
|
|
updateMdiWindowTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::updatePlots()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
if ( m_showWindow )
|
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
for ( RimPlot* plot : plots() )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
plot->loadDataAndUpdate();
|
|
|
|
}
|
|
|
|
this->updateZoom();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::updateZoom()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
2019-11-15 03:12:19 -06:00
|
|
|
for ( RimPlot* plot : plots() )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
plot->updateZoomInQwt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::recreatePlotWidgets()
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
CVF_ASSERT( m_viewer );
|
|
|
|
|
|
|
|
auto plotVector = plots();
|
|
|
|
|
|
|
|
for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx )
|
|
|
|
{
|
|
|
|
plotVector[tIdx]->createPlotWidget();
|
|
|
|
m_viewer->addPlot( plotVector[tIdx]->viewer() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
bool RimMultiPlotWindow::hasCustomFontSizes( RiaDefines::FontSettingType fontSettingType, int defaultFontSize ) const
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
if ( fontSettingType == RiaDefines::PLOT_FONT && m_viewer )
|
|
|
|
{
|
|
|
|
if ( m_viewer->fontSize() != defaultFontSize )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2019-10-31 07:48:40 -05:00
|
|
|
if ( m_legendFontSize() != defaultFontSize )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2019-11-15 03:12:19 -06:00
|
|
|
for ( const RimPlot* plot : plots() )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
if ( plot->hasCustomFontSizes( fontSettingType, defaultFontSize ) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
bool RimMultiPlotWindow::applyFontSize( RiaDefines::FontSettingType fontSettingType,
|
|
|
|
int oldFontSize,
|
|
|
|
int fontSize,
|
|
|
|
bool forceChange /*= false */ )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
bool somethingChanged = false;
|
|
|
|
if ( fontSettingType == RiaDefines::PLOT_FONT && m_viewer )
|
|
|
|
{
|
|
|
|
if ( oldFontSize == m_viewer->fontSize() || forceChange )
|
|
|
|
{
|
|
|
|
m_viewer->setFontSize( fontSize );
|
|
|
|
somethingChanged = true;
|
|
|
|
}
|
|
|
|
|
2019-10-31 07:48:40 -05:00
|
|
|
if ( oldFontSize == m_legendFontSize() || forceChange )
|
|
|
|
{
|
|
|
|
m_legendFontSize = fontSize;
|
|
|
|
somethingChanged = true;
|
|
|
|
}
|
|
|
|
|
2019-11-15 03:12:19 -06:00
|
|
|
for ( RimPlot* plot : plots() )
|
2019-10-11 08:54:19 -05:00
|
|
|
{
|
|
|
|
if ( plot->applyFontSize( fontSettingType, oldFontSize, fontSize, forceChange ) )
|
|
|
|
{
|
|
|
|
somethingChanged = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( somethingChanged )
|
|
|
|
{
|
|
|
|
m_viewer->scheduleUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return somethingChanged;
|
|
|
|
}
|
|
|
|
|
2019-11-07 01:48:11 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-15 06:35:39 -06:00
|
|
|
void RimMultiPlotWindow::cleanupBeforeClose()
|
2019-11-07 01:48:11 -06:00
|
|
|
{
|
|
|
|
auto plotVector = plots();
|
|
|
|
for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx )
|
|
|
|
{
|
|
|
|
plotVector[tIdx]->detachAllCurves();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_viewer )
|
|
|
|
{
|
2019-12-04 02:13:54 -06:00
|
|
|
m_viewer->setParent( nullptr );
|
|
|
|
delete m_viewer;
|
2019-11-07 01:48:11 -06:00
|
|
|
m_viewer = nullptr;
|
|
|
|
}
|
|
|
|
}
|