mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-24 15:26:48 -06:00
f91fe41f1d
* #8947 Plot Template : Split export dialog into file path and name * #8946 Update multi plot title when curve is appended by copy/paste * #8946 Separate axis object name and axis title text * If multi plot auto name is empty, use plot title "Plot N" * QwtPlotWidget: Double click activates Zoom All * More testing on valid main window before use * Return false if event is not handeled * Improve fallback plot name * Tree View Editor: Early exit if selected object is unchanged Resetting selection causes flickering * Summary Plot : Select curve object in project tree when clicking on curve
319 lines
11 KiB
C++
319 lines
11 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// 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.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RimPlot.h"
|
|
|
|
#include "RicfCommandObject.h"
|
|
|
|
#include "RimAbstractPlotCollection.h"
|
|
#include "RimMultiPlot.h"
|
|
#include "RimPlotCurve.h"
|
|
#include "RimPlotWindow.h"
|
|
|
|
#include "RiuPlotMainWindowTools.h"
|
|
#include "RiuPlotWidget.h"
|
|
|
|
#include "cafPdmObject.h"
|
|
|
|
#include "qwt_legend_data.h"
|
|
|
|
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" );
|
|
addItem( RimPlot::SIX, "SIX", "6" );
|
|
setDefault( RimPlot::ONE );
|
|
}
|
|
} // namespace caf
|
|
|
|
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlot, "RimPlot" ); // Do not use. Abstract class
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimPlot::RimPlot()
|
|
{
|
|
CAF_PDM_InitScriptableObjectWithNameAndComment( "Plot", "", "", "", "Plot", "The Abstract Base Class for all Plot Objects" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_rowSpan, "RowSpan", "Row Span" );
|
|
CAF_PDM_InitFieldNoDefault( &m_colSpan, "ColSpan", "Col Span" );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimPlot::~RimPlot()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QWidget* RimPlot::createViewWidget( QWidget* parent /*= nullptr */ )
|
|
{
|
|
RiuPlotWidget* plotWidget = doCreatePlotViewWidget( parent );
|
|
|
|
updateWindowVisibility();
|
|
plotWidget->scheduleReplot();
|
|
|
|
return plotWidget;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::updateFonts()
|
|
{
|
|
if ( plotWidget() )
|
|
{
|
|
plotWidget()->setPlotTitleFontSize( titleFontSize() );
|
|
plotWidget()->setLegendFontSize( legendFontSize() );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QWidget* RimPlot::createPlotWidget( QWidget* parent )
|
|
{
|
|
return createViewWidget( parent );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimPlot::RowOrColSpan RimPlot::rowSpan() const
|
|
{
|
|
return m_rowSpan();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimPlot::RowOrColSpan RimPlot::colSpan() const
|
|
{
|
|
return m_colSpan();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::setRowSpan( RowOrColSpan rowSpan )
|
|
{
|
|
m_rowSpan = rowSpan;
|
|
updateParentLayout();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::setColSpan( RowOrColSpan colSpan )
|
|
{
|
|
m_colSpan = colSpan;
|
|
updateParentLayout();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::removeFromMdiAreaAndCollection()
|
|
{
|
|
if ( isMdiWindow() )
|
|
{
|
|
revokeMdiWindowStatus();
|
|
}
|
|
|
|
RimAbstractPlotCollection* plotCollection = nullptr;
|
|
this->firstAncestorOfType( plotCollection );
|
|
if ( plotCollection )
|
|
{
|
|
plotCollection->removeRimPlot( this );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::updateAfterInsertingIntoMultiPlot()
|
|
{
|
|
loadDataAndUpdate();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
|
{
|
|
if ( !isMdiWindow() )
|
|
{
|
|
uiOrdering.add( &m_rowSpan );
|
|
uiOrdering.add( &m_colSpan );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
|
{
|
|
RimPlotWindow::fieldChangedByUi( changedField, oldValue, newValue );
|
|
|
|
if ( changedField == &m_showWindow )
|
|
{
|
|
updateParentLayout();
|
|
}
|
|
else if ( changedField == &m_colSpan || changedField == &m_rowSpan )
|
|
{
|
|
updateParentLayout();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::doRenderWindowContent( QPaintDevice* paintDevice )
|
|
{
|
|
if ( plotWidget() )
|
|
{
|
|
plotWidget()->renderTo( paintDevice, plotWidget()->frameGeometry() );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::onPlotSelected( bool toggle )
|
|
{
|
|
RiuPlotMainWindowTools::selectOrToggleObject( this, toggle );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::onViewerDestroyed()
|
|
{
|
|
RimPlotWindow* parent = nullptr;
|
|
this->firstAncestorOfType( parent );
|
|
|
|
bool isIndependentPlot = parent == nullptr;
|
|
bool hasVisibleParent = parent && parent->showWindow();
|
|
if ( isIndependentPlot || hasVisibleParent )
|
|
{
|
|
m_showWindow = false;
|
|
updateConnectedEditors();
|
|
updateUiIconFromToggleField();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::onKeyPressEvent( QKeyEvent* event )
|
|
{
|
|
handleKeyPressEvent( event );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::onWheelEvent( QWheelEvent* event )
|
|
{
|
|
handleWheelEvent( event );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
|
|
std::vector<caf::PdmObjectHandle*>& referringObjects )
|
|
{
|
|
loadDataAndUpdate();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::updateZoomInParentPlot()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::updateZoomFromParentPlot()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
caf::PdmObject* RimPlot::findPdmObjectFromPlotCurve( const RiuPlotCurve* curve ) const
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::handleDroppedObjects( const std::vector<caf::PdmObjectHandle*>& objects )
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimPlotCurve*> RimPlot::visibleCurvesForLegend()
|
|
{
|
|
return {};
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::handleKeyPressEvent( QKeyEvent* event )
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::handleWheelEvent( QWheelEvent* event )
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::onPlotItemSelected( std::shared_ptr<RiuPlotItem>, bool, int )
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimPlot::onAxisSelected( RiuPlotAxis axis, bool toggle )
|
|
{
|
|
}
|