mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Refactor RimPlotWindow and RimPlotInterface
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimMimeData.h"
|
||||
#include "RimMultiPlot.h"
|
||||
#include "RimPlotInterface.h"
|
||||
#include "RimPlot.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
@@ -163,7 +163,7 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const
|
||||
}
|
||||
|
||||
if ( dynamic_cast<RimEclipseCase*>( uiItem ) || dynamic_cast<RimWellLogCurve*>( uiItem ) ||
|
||||
dynamic_cast<RimWellLogFileChannel*>( uiItem ) || dynamic_cast<RimPlotInterface*>( uiItem ) ||
|
||||
dynamic_cast<RimWellLogFileChannel*>( uiItem ) || dynamic_cast<RimPlot*>( uiItem ) ||
|
||||
dynamic_cast<RimSummaryCase*>( uiItem ) )
|
||||
{
|
||||
// TODO: Remember to handle reservoir holding the main grid
|
||||
@@ -188,14 +188,14 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const
|
||||
}
|
||||
else if ( dynamic_cast<RimMultiPlot*>( uiItem ) )
|
||||
{
|
||||
if ( RiuTypedPdmObjects<RimPlotInterface>::containsTypedObjects( m_dragItems ) )
|
||||
if ( RiuTypedPdmObjects<RimPlot>::containsTypedObjects( m_dragItems ) )
|
||||
{
|
||||
itemflags |= Qt::ItemIsDropEnabled;
|
||||
}
|
||||
}
|
||||
else if ( dynamic_cast<RimPlotInterface*>( uiItem ) )
|
||||
else if ( dynamic_cast<RimPlot*>( uiItem ) )
|
||||
{
|
||||
if ( RiuTypedPdmObjects<RimPlotInterface>::containsTypedObjects( m_dragItems ) )
|
||||
if ( RiuTypedPdmObjects<RimPlot>::containsTypedObjects( m_dragItems ) )
|
||||
{
|
||||
itemflags |= Qt::ItemIsDropEnabled;
|
||||
}
|
||||
@@ -459,19 +459,19 @@ bool RiuDragDrop::handleMultiPlotDrop( Qt::DropAction action,
|
||||
RimMultiPlot* multiPlot,
|
||||
int insertAtPosition )
|
||||
{
|
||||
std::vector<RimPlotInterface*> plots = RiuTypedPdmObjects<RimPlotInterface>::typedObjectsFromGroup( draggedObjects );
|
||||
std::vector<RimPlot*> plots = RiuTypedPdmObjects<RimPlot>::typedObjectsFromGroup( draggedObjects );
|
||||
if ( plots.size() > 0 )
|
||||
{
|
||||
if ( action == Qt::MoveAction )
|
||||
{
|
||||
RimPlotInterface* insertAfter = nullptr;
|
||||
RimPlot* insertAfter = nullptr;
|
||||
if ( insertAtPosition > 0 )
|
||||
{
|
||||
auto visibleTracks = multiPlot->visiblePlots();
|
||||
if ( !visibleTracks.empty() )
|
||||
{
|
||||
int insertAfterPosition = std::min( insertAtPosition - 1, (int)visibleTracks.size() - 1 );
|
||||
insertAfter = dynamic_cast<RimPlotInterface*>( visibleTracks[insertAfterPosition] );
|
||||
insertAfter = dynamic_cast<RimPlot*>( visibleTracks[insertAfterPosition] );
|
||||
}
|
||||
}
|
||||
multiPlot->movePlotsToThis( plots, insertAfter );
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "RimGridCrossPlot.h"
|
||||
#include "RimGridCrossPlotCurve.h"
|
||||
#include "RimGridCrossPlotDataSet.h"
|
||||
#include "RimPlotInterface.h"
|
||||
#include "RimPlot.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
@@ -58,7 +58,7 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimPlotInterface* plotDefinition, QWidget* parent /*= nullptr*/ )
|
||||
RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimPlot* plotDefinition, QWidget* parent /*= nullptr*/ )
|
||||
: RiuQwtPlotWidget( plotDefinition, parent )
|
||||
{
|
||||
// LeftButton for the zooming
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
class RimGridCrossPlotDataSet;
|
||||
class RimPlotAxisProperties;
|
||||
class RimPlotInterface;
|
||||
class RimPlot;
|
||||
class RiuCvfOverlayItemWidget;
|
||||
class RiuDraggableOverlayFrame;
|
||||
class RiuPlotAnnotationTool;
|
||||
@@ -50,7 +50,7 @@ class RiuGridCrossQwtPlot : public RiuQwtPlotWidget, public RiuInterfaceToViewWi
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
RiuGridCrossQwtPlot( RimPlotInterface* plotDefinition, QWidget* parent = nullptr );
|
||||
RiuGridCrossQwtPlot( RimPlot* plotDefinition, QWidget* parent = nullptr );
|
||||
~RiuGridCrossQwtPlot();
|
||||
|
||||
RiuGridCrossQwtPlot( const RiuGridCrossQwtPlot& ) = delete;
|
||||
|
||||
@@ -223,7 +223,7 @@ void RiuMultiPlotWindow::setSelectionsVisible( bool visible )
|
||||
{
|
||||
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
|
||||
{
|
||||
if ( visible && caf::SelectionManager::instance()->isSelected( plotWidget->plotOwner(), 0 ) )
|
||||
if ( visible && caf::SelectionManager::instance()->isSelected( plotWidget->plotDefinition(), 0 ) )
|
||||
{
|
||||
plotWidget->setWidgetState( RiuWidgetStyleSheet::SELECTED );
|
||||
}
|
||||
@@ -302,14 +302,6 @@ void RiuMultiPlotWindow::contextMenuEvent( QContextMenuEvent* event )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotWindow::keyPressEvent( QKeyEvent* keyEvent )
|
||||
{
|
||||
m_plotDefinition->handleKeyPressEvent( keyEvent );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -466,13 +458,13 @@ void RiuMultiPlotWindow::dropEvent( QDropEvent* event )
|
||||
}
|
||||
}
|
||||
}
|
||||
RimPlotInterface* insertAfter = nullptr;
|
||||
RimPlot* insertAfter = nullptr;
|
||||
if ( beforeIndex > 0 )
|
||||
{
|
||||
insertAfter = m_plotWidgets[beforeIndex - 1]->plotDefinition();
|
||||
}
|
||||
|
||||
RimPlotInterface* plotToMove = source->plotDefinition();
|
||||
RimPlot* plotToMove = source->plotDefinition();
|
||||
|
||||
if ( insertAfter != plotToMove )
|
||||
{
|
||||
@@ -518,7 +510,7 @@ void RiuMultiPlotWindow::onSelectionManagerSelectionChanged( const std::set<int>
|
||||
for ( int changedLevel : changedSelectionLevels )
|
||||
{
|
||||
isSelected = isSelected ||
|
||||
caf::SelectionManager::instance()->isSelected( plotWidget->plotOwner(), changedLevel );
|
||||
caf::SelectionManager::instance()->isSelected( plotWidget->plotDefinition(), changedLevel );
|
||||
}
|
||||
if ( isSelected )
|
||||
{
|
||||
@@ -590,8 +582,9 @@ void RiuMultiPlotWindow::reinsertPlotWidgets()
|
||||
int column = 0;
|
||||
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
|
||||
{
|
||||
int colSpan = std::min( plotWidgets[visibleIndex]->plotDefinition()->colSpan(), rowAndColumnCount.second );
|
||||
int rowSpan = plotWidgets[visibleIndex]->plotDefinition()->rowSpan();
|
||||
int expextedColSpan = static_cast<int>( plotWidgets[visibleIndex]->plotDefinition()->colSpan() );
|
||||
int colSpan = std::min( expextedColSpan, rowAndColumnCount.second );
|
||||
int rowSpan = plotWidgets[visibleIndex]->plotDefinition()->rowSpan();
|
||||
|
||||
std::tie( row, column ) = findAvailableRowAndColumn( row, column, colSpan, rowAndColumnCount.second );
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ public:
|
||||
|
||||
protected:
|
||||
void contextMenuEvent( QContextMenuEvent* ) override;
|
||||
void keyPressEvent( QKeyEvent* keyEvent ) override;
|
||||
QLabel* createTitleLabel() const;
|
||||
|
||||
void resizeEvent( QResizeEvent* event ) override;
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include "RiaColorTools.h"
|
||||
#include "RiaPlotWindowRedrawScheduler.h"
|
||||
|
||||
#include "RimPlot.h"
|
||||
#include "RimPlotCurve.h"
|
||||
#include "RimPlotInterface.h"
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuQwtCurvePointTracker.h"
|
||||
@@ -60,13 +60,11 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlotInterface* plotTrackDefinition, QWidget* parent )
|
||||
RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlot* plot, QWidget* parent )
|
||||
: QwtPlot( parent )
|
||||
, m_plotDefinition( plot )
|
||||
, m_draggable( true )
|
||||
{
|
||||
m_plotOwner = dynamic_cast<caf::PdmObject*>( plotTrackDefinition );
|
||||
CAF_ASSERT( m_plotOwner );
|
||||
|
||||
setDefaults();
|
||||
|
||||
this->installEventFilter( this );
|
||||
@@ -78,9 +76,9 @@ RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlotInterface* plotTrackDefinition, QWidg
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQwtPlotWidget::~RiuQwtPlotWidget()
|
||||
{
|
||||
if ( plotDefinition() )
|
||||
if ( m_plotDefinition )
|
||||
{
|
||||
plotDefinition()->detachAllCurves();
|
||||
m_plotDefinition->detachAllCurves();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,9 +87,9 @@ RiuQwtPlotWidget::~RiuQwtPlotWidget()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuQwtPlotWidget::isChecked() const
|
||||
{
|
||||
if ( plotDefinition() )
|
||||
if ( m_plotDefinition )
|
||||
{
|
||||
return plotDefinition()->isChecked();
|
||||
return m_plotDefinition->showWindow();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -158,17 +156,9 @@ void RiuQwtPlotWidget::setAxisFontsAndAlignment( QwtPlot::Axis axis,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPlotInterface* RiuQwtPlotWidget::plotDefinition() const
|
||||
RimPlot* RiuQwtPlotWidget::plotDefinition() const
|
||||
{
|
||||
return dynamic_cast<RimPlotInterface*>( m_plotOwner.p() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObject* RiuQwtPlotWidget::plotOwner() const
|
||||
{
|
||||
return m_plotOwner.p();
|
||||
return m_plotDefinition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -611,7 +601,7 @@ void RiuQwtPlotWidget::onAxisSelected( QwtScaleWidget* scale, bool toggleItemInS
|
||||
axisId = i;
|
||||
}
|
||||
}
|
||||
plotDefinition()->onAxisSelected( axisId, toggleItemInSelection );
|
||||
m_plotDefinition->onAxisSelected( axisId, toggleItemInSelection );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -671,11 +661,11 @@ void RiuQwtPlotWidget::selectPlotOwner( bool toggleItemInSelection )
|
||||
{
|
||||
if ( toggleItemInSelection )
|
||||
{
|
||||
RiuPlotMainWindowTools::toggleItemInSelection( plotOwner() );
|
||||
RiuPlotMainWindowTools::toggleItemInSelection( m_plotDefinition );
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( plotOwner() );
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( m_plotDefinition );
|
||||
}
|
||||
scheduleReplot();
|
||||
}
|
||||
@@ -710,10 +700,10 @@ void RiuQwtPlotWidget::selectClosestCurve( const QPoint& pos, bool toggleItemInS
|
||||
resetCurveHighlighting();
|
||||
if ( closestCurve && distMin < 20 )
|
||||
{
|
||||
if ( plotDefinition() )
|
||||
if ( m_plotDefinition )
|
||||
{
|
||||
RimPlotCurve* selectedCurve = dynamic_cast<RimPlotCurve*>(
|
||||
plotDefinition()->findPdmObjectFromQwtCurve( closestCurve ) );
|
||||
m_plotDefinition->findPdmObjectFromQwtCurve( closestCurve ) );
|
||||
if ( selectedCurve )
|
||||
{
|
||||
if ( toggleItemInSelection )
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <set>
|
||||
|
||||
class RiaPlotWindowRedrawScheduler;
|
||||
class RimPlotInterface;
|
||||
class RimPlot;
|
||||
|
||||
class QwtLegend;
|
||||
class QwtPicker;
|
||||
@@ -53,11 +53,10 @@ class RiuQwtPlotWidget : public QwtPlot
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RiuQwtPlotWidget( RimPlotInterface* plotTrackDefinition, QWidget* parent = nullptr );
|
||||
RiuQwtPlotWidget( RimPlot* plotTrackDefinition, QWidget* parent = nullptr );
|
||||
~RiuQwtPlotWidget() override;
|
||||
|
||||
RimPlotInterface* plotDefinition() const;
|
||||
caf::PdmObject* plotOwner() const;
|
||||
RimPlot* plotDefinition() const;
|
||||
|
||||
bool isChecked() const;
|
||||
|
||||
@@ -130,7 +129,7 @@ private:
|
||||
RiuWidgetStyleSheet createCanvasStyleSheet() const;
|
||||
|
||||
private:
|
||||
caf::PdmPointer<caf::PdmObject> m_plotOwner;
|
||||
caf::PdmPointer<RimPlot> m_plotDefinition;
|
||||
QPoint m_clickPosition;
|
||||
std::map<QwtPlot::Axis, QString> m_axisTitles;
|
||||
std::map<QwtPlot::Axis, bool> m_axisTitlesEnabled;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimPlotInterface.h"
|
||||
#include "RimPlot.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
@@ -92,7 +92,7 @@ static EnsembleCurveInfoTextProvider ensembleCurveInfoTextProvider;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimPlotInterface* plotDefinition, QWidget* parent /*= nullptr*/ )
|
||||
RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimPlot* plotDefinition, QWidget* parent /*= nullptr*/ )
|
||||
: RiuQwtPlotWidget( plotDefinition, parent )
|
||||
{
|
||||
// LeftButton for the zooming
|
||||
@@ -131,6 +131,11 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimPlotInterface* plotDefinition, QWidget*
|
||||
setLegendVisible( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuSummaryQwtPlot::~RiuSummaryQwtPlot() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -261,7 +266,7 @@ void RiuSummaryQwtPlot::contextMenuEvent( QContextMenuEvent* event )
|
||||
QMenu menu;
|
||||
caf::CmdFeatureMenuBuilder menuBuilder;
|
||||
|
||||
caf::SelectionManager::instance()->setSelectedItem( plotOwner() );
|
||||
caf::SelectionManager::instance()->setSelectedItem( plotDefinition() );
|
||||
|
||||
menuBuilder << "RicShowPlotDataFeature";
|
||||
menuBuilder << "RicSavePlotTemplateFeature";
|
||||
|
||||
@@ -40,7 +40,8 @@ class RiuSummaryQwtPlot : public RiuQwtPlotWidget, public RiuInterfaceToViewWind
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
RiuSummaryQwtPlot( RimPlotInterface* plotDefinition, QWidget* parent = nullptr );
|
||||
RiuSummaryQwtPlot( RimPlot* plotDefinition, QWidget* parent = nullptr );
|
||||
~RiuSummaryQwtPlot() override;
|
||||
|
||||
void useDateBasedTimeAxis(
|
||||
const QString& dateFormat,
|
||||
|
||||
@@ -72,6 +72,14 @@ void RiuWellLogPlot::updateVerticalScrollBar( double minVisible, double maxVisib
|
||||
m_trackScrollBar->blockSignals( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::keyPressEvent( QKeyEvent* event )
|
||||
{
|
||||
wellLogPlotDefinition()->handleKeyPressEvent( event );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
void updateVerticalScrollBar( double minVisible, double maxVisible, double minAvailable, double maxAvailable ) override;
|
||||
|
||||
protected:
|
||||
void keyPressEvent( QKeyEvent* event ) override;
|
||||
bool willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const override;
|
||||
bool showYAxis( int row, int column ) const override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user