2021-01-05 07:01:10 -06: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 03:12:19 -06:00
|
|
|
#include "RimPlot.h"
|
|
|
|
|
2020-02-24 08:42:23 -06:00
|
|
|
#include "RicfCommandObject.h"
|
2020-09-16 12:33:44 -05:00
|
|
|
|
|
|
|
#include "RimAbstractPlotCollection.h"
|
2020-01-16 05:32:40 -06:00
|
|
|
#include "RimMultiPlot.h"
|
|
|
|
#include "RimPlotCurve.h"
|
2019-11-15 03:12:19 -06:00
|
|
|
#include "RimPlotWindow.h"
|
|
|
|
|
2020-01-16 05:32:40 -06:00
|
|
|
#include "RiuPlotMainWindowTools.h"
|
2022-01-17 06:14:21 -06:00
|
|
|
#include "RiuPlotWidget.h"
|
2019-11-15 03:12:19 -06:00
|
|
|
|
|
|
|
#include "cafPdmObject.h"
|
|
|
|
|
2022-03-23 07:07:08 -05:00
|
|
|
#include "qwt_legend_data.h"
|
|
|
|
|
2019-11-15 03:12:19 -06:00
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
template <>
|
|
|
|
void RimPlot::RowOrColSpanEnum::setUp()
|
|
|
|
{
|
|
|
|
addItem( RimPlot::UNLIMITED, "UNLIMITED", "Unlimited" );
|
|
|
|
addItem( RimPlot::ONE, "ONE", "1" );
|
|
|
|
addItem( RimPlot::TWO, "TWO", "2" );
|
|
|
|
addItem( RimPlot::THREE, "THREE", "3" );
|
|
|
|
addItem( RimPlot::FOUR, "FOUR", "4" );
|
|
|
|
addItem( RimPlot::FIVE, "FIVE", "5" );
|
2020-02-07 03:38:31 -06:00
|
|
|
addItem( RimPlot::SIX, "SIX", "6" );
|
2019-11-15 03:12:19 -06:00
|
|
|
setDefault( RimPlot::ONE );
|
|
|
|
}
|
|
|
|
} // namespace caf
|
|
|
|
|
2020-02-24 08:42:23 -06:00
|
|
|
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlot, "RimPlot" ); // Do not use. Abstract class
|
2019-11-15 03:12:19 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimPlot::RimPlot()
|
|
|
|
{
|
2020-03-03 03:43:07 -06:00
|
|
|
CAF_PDM_InitScriptableObjectWithNameAndComment( "Plot", "", "", "", "Plot", "The Abstract Base Class for all Plot Objects" );
|
2019-11-15 03:12:19 -06:00
|
|
|
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_rowSpan, "RowSpan", "Row Span" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_colSpan, "ColSpan", "Col Span" );
|
2019-11-15 03:12:19 -06:00
|
|
|
}
|
|
|
|
|
2019-11-15 06:35:39 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-02-12 04:13:38 -06:00
|
|
|
RimPlot::~RimPlot()
|
|
|
|
{
|
|
|
|
}
|
2019-11-15 06:35:39 -06:00
|
|
|
|
2019-11-15 03:12:19 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-01-16 05:32:40 -06:00
|
|
|
QWidget* RimPlot::createViewWidget( QWidget* parent /*= nullptr */ )
|
2019-11-15 03:12:19 -06:00
|
|
|
{
|
2022-01-17 06:14:21 -06:00
|
|
|
RiuPlotWidget* plotWidget = doCreatePlotViewWidget( parent );
|
2020-01-16 05:32:40 -06:00
|
|
|
|
|
|
|
updateWindowVisibility();
|
|
|
|
plotWidget->scheduleReplot();
|
|
|
|
|
|
|
|
return plotWidget;
|
|
|
|
}
|
|
|
|
|
2020-05-09 04:23:58 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::updateFonts()
|
|
|
|
{
|
2022-01-17 06:14:21 -06:00
|
|
|
if ( plotWidget() )
|
2020-05-09 04:23:58 -05:00
|
|
|
{
|
2022-01-17 06:14:21 -06:00
|
|
|
plotWidget()->setPlotTitleFontSize( titleFontSize() );
|
|
|
|
plotWidget()->setLegendFontSize( legendFontSize() );
|
2020-05-09 04:23:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-16 05:32:40 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QWidget* RimPlot::createPlotWidget( QWidget* parent )
|
|
|
|
{
|
|
|
|
return createViewWidget( parent );
|
2019-11-15 03:12:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimPlot::RowOrColSpan RimPlot::rowSpan() const
|
|
|
|
{
|
|
|
|
return m_rowSpan();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimPlot::RowOrColSpan RimPlot::colSpan() const
|
|
|
|
{
|
|
|
|
return m_colSpan();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::setRowSpan( RowOrColSpan rowSpan )
|
|
|
|
{
|
|
|
|
m_rowSpan = rowSpan;
|
2020-01-16 05:32:40 -06:00
|
|
|
updateParentLayout();
|
2019-11-15 03:12:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::setColSpan( RowOrColSpan colSpan )
|
|
|
|
{
|
|
|
|
m_colSpan = colSpan;
|
2020-01-16 05:32:40 -06:00
|
|
|
updateParentLayout();
|
2019-11-15 03:12:19 -06:00
|
|
|
}
|
|
|
|
|
2019-11-15 06:35:39 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::removeFromMdiAreaAndCollection()
|
|
|
|
{
|
|
|
|
if ( isMdiWindow() )
|
|
|
|
{
|
|
|
|
revokeMdiWindowStatus();
|
|
|
|
}
|
2020-09-16 12:33:44 -05:00
|
|
|
|
|
|
|
RimAbstractPlotCollection* plotCollection = nullptr;
|
|
|
|
this->firstAncestorOfType( plotCollection );
|
|
|
|
if ( plotCollection )
|
|
|
|
{
|
|
|
|
plotCollection->removeRimPlot( this );
|
|
|
|
}
|
2019-11-15 06:35:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::updateAfterInsertingIntoMultiPlot()
|
|
|
|
{
|
2020-09-17 03:02:58 -05:00
|
|
|
loadDataAndUpdate();
|
2019-11-15 06:35:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
|
|
|
{
|
|
|
|
if ( !isMdiWindow() )
|
|
|
|
{
|
|
|
|
uiOrdering.add( &m_rowSpan );
|
|
|
|
uiOrdering.add( &m_colSpan );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-15 03:12:19 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
|
|
|
{
|
2020-01-16 05:32:40 -06:00
|
|
|
RimPlotWindow::fieldChangedByUi( changedField, oldValue, newValue );
|
|
|
|
|
|
|
|
if ( changedField == &m_showWindow )
|
2019-11-15 03:12:19 -06:00
|
|
|
{
|
|
|
|
updateParentLayout();
|
|
|
|
}
|
2020-01-16 05:32:40 -06:00
|
|
|
else if ( changedField == &m_colSpan || changedField == &m_rowSpan )
|
|
|
|
{
|
|
|
|
updateParentLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-18 05:25:19 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-12-19 03:34:23 -06:00
|
|
|
void RimPlot::doRenderWindowContent( QPaintDevice* paintDevice )
|
2019-12-18 05:25:19 -06:00
|
|
|
{
|
2022-01-17 06:14:21 -06:00
|
|
|
if ( plotWidget() )
|
2019-12-18 05:25:19 -06:00
|
|
|
{
|
2022-01-17 06:14:21 -06:00
|
|
|
plotWidget()->renderTo( paintDevice, plotWidget()->frameGeometry() );
|
2019-12-18 05:25:19 -06:00
|
|
|
}
|
|
|
|
}
|
2020-01-16 05:32:40 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::onPlotSelected( bool toggle )
|
|
|
|
{
|
2022-05-24 08:24:38 -05:00
|
|
|
RiuPlotMainWindowTools::selectOrToggleObject( this, toggle );
|
2020-01-16 05:32:40 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::onViewerDestroyed()
|
|
|
|
{
|
2020-01-24 08:35:17 -06:00
|
|
|
RimPlotWindow* parent = nullptr;
|
|
|
|
this->firstAncestorOfType( parent );
|
|
|
|
|
|
|
|
bool isIndependentPlot = parent == nullptr;
|
|
|
|
bool hasVisibleParent = parent && parent->showWindow();
|
|
|
|
if ( isIndependentPlot || hasVisibleParent )
|
|
|
|
{
|
|
|
|
m_showWindow = false;
|
|
|
|
updateConnectedEditors();
|
|
|
|
updateUiIconFromToggleField();
|
|
|
|
}
|
2020-01-16 05:32:40 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::onKeyPressEvent( QKeyEvent* event )
|
|
|
|
{
|
|
|
|
handleKeyPressEvent( event );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::onWheelEvent( QWheelEvent* event )
|
|
|
|
{
|
|
|
|
handleWheelEvent( event );
|
|
|
|
}
|
2020-05-18 09:02:27 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
|
|
|
|
std::vector<caf::PdmObjectHandle*>& referringObjects )
|
|
|
|
{
|
|
|
|
loadDataAndUpdate();
|
|
|
|
}
|
2022-01-17 06:14:21 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::updateZoomInParentPlot()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::updateZoomFromParentPlot()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-01-21 07:32:51 -06:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmObject* RimPlot::findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::handleDroppedObjects( const std::vector<caf::PdmObjectHandle*>& objects )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-03-23 07:07:08 -05:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimPlotCurve*> RimPlot::visibleCurvesForLegend()
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-01-17 06:14:21 -06:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::handleKeyPressEvent( QKeyEvent* event )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::handleWheelEvent( QWheelEvent* event )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::onPlotItemSelected( std::shared_ptr<RiuPlotItem>, bool, int )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-04-01 08:57:11 -05:00
|
|
|
void RimPlot::onAxisSelected( RiuPlotAxis axis, bool toggle )
|
2022-01-17 06:14:21 -06:00
|
|
|
{
|
|
|
|
}
|