2019-11-15 03:12:19 -06:00
|
|
|
#include "RimPlot.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"
|
2019-11-15 03:12:19 -06:00
|
|
|
#include "RiuQwtPlotWidget.h"
|
|
|
|
|
|
|
|
#include "cafPdmObject.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" );
|
|
|
|
setDefault( RimPlot::ONE );
|
|
|
|
}
|
|
|
|
} // namespace caf
|
|
|
|
|
|
|
|
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimPlot, "RimPlot" ); // Do not use. Abstract class
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimPlot::RimPlot()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject( "Plot", "", "", "" );
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_rowSpan, "RowSpan", "Row Span", "", "", "" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_colSpan, "ColSpan", "Col Span", "", "", "" );
|
|
|
|
}
|
|
|
|
|
2019-11-15 06:35:39 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimPlot::~RimPlot() {}
|
|
|
|
|
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
|
|
|
{
|
2020-01-16 05:32:40 -06:00
|
|
|
RiuQwtPlotWidget* plotWidget = doCreatePlotViewWidget( parent );
|
|
|
|
|
|
|
|
RimPlot::attachPlotWidgetSignals( this, plotWidget );
|
|
|
|
|
|
|
|
updateWindowVisibility();
|
|
|
|
plotWidget->scheduleReplot();
|
|
|
|
|
|
|
|
return plotWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
doRemoveFromCollection();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::updateAfterInsertingIntoMultiPlot()
|
|
|
|
{
|
|
|
|
updateLegend();
|
|
|
|
updateAxes();
|
2020-01-16 05:32:40 -06:00
|
|
|
updateLayout();
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::attachPlotWidgetSignals( RimPlot* plot, RiuQwtPlotWidget* plotWidget )
|
|
|
|
{
|
|
|
|
CAF_ASSERT( plot && plotWidget );
|
|
|
|
plot->connect( plotWidget, SIGNAL( plotSelected( bool ) ), SLOT( onPlotSelected( bool ) ) );
|
|
|
|
plot->connect( plotWidget, SIGNAL( axisSelected( int, bool ) ), SLOT( onAxisSelected( int, bool ) ) );
|
|
|
|
plot->connect( plotWidget,
|
|
|
|
SIGNAL( curveSelected( QwtPlotCurve*, bool ) ),
|
|
|
|
SLOT( onCurveSelected( QwtPlotCurve*, bool ) ) );
|
|
|
|
plot->connect( plotWidget, SIGNAL( onKeyPressEvent( QKeyEvent* ) ), SLOT( onKeyPressEvent( QKeyEvent* ) ) );
|
|
|
|
plot->connect( plotWidget, SIGNAL( onWheelEvent( QWheelEvent* ) ), SLOT( onWheelEvent( QWheelEvent* ) ) );
|
|
|
|
plot->connect( plotWidget, SIGNAL( destroyed() ), SLOT( onViewerDestroyed() ) );
|
2019-11-15 03:12:19 -06:00
|
|
|
}
|
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
|
|
|
{
|
|
|
|
if ( viewer() )
|
|
|
|
{
|
2019-12-19 03:34:23 -06:00
|
|
|
viewer()->renderTo( paintDevice, viewer()->frameGeometry() );
|
2019-12-18 05:25:19 -06:00
|
|
|
}
|
|
|
|
}
|
2020-01-16 05:32:40 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::onPlotSelected( bool toggle )
|
|
|
|
{
|
|
|
|
if ( toggle )
|
|
|
|
{
|
|
|
|
RiuPlotMainWindowTools::toggleItemInSelection( this );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RiuPlotMainWindowTools::selectAsCurrentItem( this );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::onCurveSelected( QwtPlotCurve* curve, bool toggle )
|
|
|
|
{
|
|
|
|
RimPlotCurve* selectedCurve = dynamic_cast<RimPlotCurve*>( this->findPdmObjectFromQwtCurve( curve ) );
|
|
|
|
if ( selectedCurve )
|
|
|
|
{
|
|
|
|
if ( toggle )
|
|
|
|
{
|
|
|
|
RiuPlotMainWindowTools::toggleItemInSelection( selectedCurve );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RiuPlotMainWindowTools::selectAsCurrentItem( selectedCurve );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::onViewerDestroyed()
|
|
|
|
{
|
|
|
|
m_showWindow = false;
|
|
|
|
updateConnectedEditors();
|
|
|
|
updateUiIconFromToggleField();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::onKeyPressEvent( QKeyEvent* event )
|
|
|
|
{
|
|
|
|
handleKeyPressEvent( event );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimPlot::onWheelEvent( QWheelEvent* event )
|
|
|
|
{
|
|
|
|
handleWheelEvent( event );
|
|
|
|
}
|