Well Log Plot and Well Distribution Plots no longer inherit Multiplot

* Also cleaned up RiuQwtPlotWidget
This commit is contained in:
Gaute Lindkvist
2020-01-16 12:32:40 +01:00
parent 2044b99818
commit edc276db4d
70 changed files with 1568 additions and 1215 deletions

View File

@@ -52,10 +52,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuCellAndNncPickEventHandler.h
${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotInterface.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotWindow.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.h
${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.h
@@ -148,7 +146,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotWindow.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.cpp
@@ -213,9 +211,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.h
${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotInterface.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotPage.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotWindow.h
${CMAKE_CURRENT_LIST_DIR}/RiuMultiPlotBook.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWidget.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotLegend.h
${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.h

View File

@@ -29,7 +29,7 @@
#include "RimEclipseResultCase.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimMimeData.h"
#include "RimMultiPlotWindow.h"
#include "RimMultiPlot.h"
#include "RimPlot.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
@@ -186,7 +186,7 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const
itemflags |= Qt::ItemIsDropEnabled;
}
}
else if ( dynamic_cast<RimMultiPlotWindow*>( uiItem ) )
else if ( dynamic_cast<RimMultiPlot*>( uiItem ) )
{
if ( RiuTypedPdmObjects<RimPlot>::containsTypedObjects( m_dragItems ) )
{
@@ -297,14 +297,7 @@ bool RiuDragDrop::dropMimeData( const QMimeData* data, Qt::DropAction action, in
return handleWellLogPlotCurveDrop( action, draggedObjects, wellLogPlotCurve );
}
RimWellLogTrack* wellLogPlotTrack;
dropTarget->firstAncestorOrThisOfType( wellLogPlotTrack );
if ( wellLogPlotTrack )
{
return handleWellLogPlotTrackDrop( action, draggedObjects, wellLogPlotTrack, row );
}
RimMultiPlotWindow* multiPlot;
RimMultiPlot* multiPlot;
dropTarget->firstAncestorOrThisOfType( multiPlot );
if ( multiPlot )
{
@@ -396,67 +389,12 @@ bool RiuDragDrop::handleGridCaseGroupDrop( Qt::DropAction action,
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleWellLogPlotTrackDrop( Qt::DropAction action,
caf::PdmObjectGroup& draggedObjects,
RimWellLogTrack* trackTarget,
int insertAtPosition )
{
std::vector<RimWellLogFileChannel*> wellLogFileChannels =
RiuTypedPdmObjects<RimWellLogFileChannel>::typedObjectsFromGroup( draggedObjects );
if ( wellLogFileChannels.size() > 0 )
{
if ( action == Qt::CopyAction )
{
RicWellLogTools::addWellLogChannelsToPlotTrack( trackTarget, wellLogFileChannels );
return true;
}
}
std::vector<RimWellLogCurve*> wellLogPlotCurves = RiuTypedPdmObjects<RimWellLogCurve>::typedObjectsFromGroup(
draggedObjects );
if ( wellLogPlotCurves.size() > 0 )
{
if ( action == Qt::MoveAction )
{
RimWellLogCurve* insertAfter = nullptr;
if ( insertAtPosition > 0 )
{
auto visibleCurves = trackTarget->visibleCurves();
if ( !visibleCurves.empty() )
{
int insertAfterPosition = std::min( insertAtPosition - 1, (int)visibleCurves.size() - 1 );
insertAfter = visibleCurves[insertAfterPosition];
}
}
RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack( trackTarget, wellLogPlotCurves, insertAfter );
return true;
}
}
std::vector<RimWellLogTrack*> wellLogPlotTracks = RiuTypedPdmObjects<RimWellLogTrack>::typedObjectsFromGroup(
draggedObjects );
if ( wellLogPlotTracks.size() > 0 )
{
if ( action == Qt::MoveAction )
{
RimWellLogPlot* wellLogPlot;
trackTarget->firstAncestorOrThisOfType( wellLogPlot );
return handleMultiPlotDrop( action, draggedObjects, wellLogPlot, insertAtPosition );
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleMultiPlotDrop( Qt::DropAction action,
caf::PdmObjectGroup& draggedObjects,
RimMultiPlotWindow* multiPlot,
RimMultiPlot* multiPlot,
int insertAtPosition )
{
std::vector<RimPlot*> plots = RiuTypedPdmObjects<RimPlot>::typedObjectsFromGroup( draggedObjects );

View File

@@ -29,7 +29,7 @@ namespace caf
class PdmObjectHandle;
}
class RimMultiPlotWindow;
class RimMultiPlot;
class RimIdenticalGridCaseGroup;
class RimSummaryCaseCollection;
class RimSummaryCaseMainCollection;
@@ -67,7 +67,7 @@ private:
int insertAtPosition );
bool handleMultiPlotDrop( Qt::DropAction action,
caf::PdmObjectGroup& objectGroup,
RimMultiPlotWindow* multiPlot,
RimMultiPlot* multiPlot,
int insertAtPosition );
bool handleWellLogPlotCurveDrop( Qt::DropAction action,
caf::PdmObjectGroup& objectGroup,

View File

@@ -58,8 +58,8 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimPlot* plotDefinition, QWidget* parent /*= nullptr*/ )
: RiuQwtPlotWidget( plotDefinition, parent )
RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimGridCrossPlot* plot, QWidget* parent /*= nullptr*/ )
: RiuQwtPlotWidget( plot, parent )
{
// LeftButton for the zooming
m_zoomerLeft = new RiuQwtPlotZoomer( canvas() );
@@ -132,14 +132,6 @@ void RiuGridCrossQwtPlot::updateAnnotationObjects( RimPlotAxisProperties* axisPr
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewWindow* RiuGridCrossQwtPlot::ownerViewWindow() const
{
return dynamic_cast<RimViewWindow*>( plotDefinition() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -182,7 +174,7 @@ void RiuGridCrossQwtPlot::contextMenuEvent( QContextMenuEvent* event )
QMenu menu;
caf::CmdFeatureMenuBuilder menuBuilder;
caf::SelectionManager::instance()->setSelectedItem( ownerViewWindow() );
emit plotSelected( false );
menuBuilder << "RicSwapGridCrossPlotDataSetAxesFeature";
menuBuilder << "Separator";
@@ -281,5 +273,5 @@ void RiuGridCrossQwtPlot::endZoomOperations()
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::onZoomedSlot()
{
plotDefinition()->updateZoomFromQwt();
emit plotZoomed();
}

View File

@@ -27,6 +27,7 @@
#include <memory>
class RimGridCrossPlot;
class RimGridCrossPlotDataSet;
class RimPlotAxisProperties;
class RimPlot;
@@ -45,23 +46,24 @@ class TitledOverlayFrame;
//
//
//==================================================================================================
class RiuGridCrossQwtPlot : public RiuQwtPlotWidget, public RiuInterfaceToViewWindow
class RiuGridCrossQwtPlot : public RiuQwtPlotWidget
{
Q_OBJECT;
public:
RiuGridCrossQwtPlot( RimPlot* plotDefinition, QWidget* parent = nullptr );
RiuGridCrossQwtPlot( RimGridCrossPlot* crossPlot, QWidget* parent = nullptr );
~RiuGridCrossQwtPlot();
RiuGridCrossQwtPlot( const RiuGridCrossQwtPlot& ) = delete;
void updateAnnotationObjects( RimPlotAxisProperties* axisProperties );
RimViewWindow* ownerViewWindow() const override;
void setLegendFontSize( int fontSize );
void setInternalQwtLegendVisible( bool visible );
signals:
void plotZoomed();
protected:
void contextMenuEvent( QContextMenuEvent* ) override;

View File

@@ -15,14 +15,14 @@
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuMultiPlotWindow.h"
#include "RiuMultiPlotBook.h"
#include "RiaGuiApplication.h"
#include "RiaPlotWindowRedrawScheduler.h"
#include "RiaPreferences.h"
#include "RimContextCommandBuilder.h"
#include "RimMultiPlotWindow.h"
#include "RimMultiPlot.h"
#include "RimWellLogTrack.h"
#include "RiuMainWindow.h"
@@ -98,16 +98,14 @@ private:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMultiPlotWindow::RiuMultiPlotWindow( RimMultiPlotWindow* plotDefinition, QWidget* parent )
: RiuMultiPlotInterface( parent )
RiuMultiPlotBook::RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* parent )
: QWidget( parent )
, m_plotDefinition( plotDefinition )
, m_plotTitle( "Multi Plot" )
, m_titleVisible( true )
, m_subTitlesVisible( true )
, m_previewMode( true )
{
Q_ASSERT( plotDefinition );
m_plotDefinition = plotDefinition;
const int spacing = 8;
this->setBackgroundRole( QPalette::Dark );
@@ -147,12 +145,12 @@ RiuMultiPlotWindow::RiuMultiPlotWindow( RimMultiPlotWindow* plotDefinition, QWid
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMultiPlotWindow::~RiuMultiPlotWindow() {}
RiuMultiPlotBook::~RiuMultiPlotBook() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMultiPlotWindow* RiuMultiPlotWindow::ownerPlotDefinition()
RimViewWindow* RiuMultiPlotBook::ownerViewWindow() const
{
return m_plotDefinition;
}
@@ -160,15 +158,7 @@ RimMultiPlotWindow* RiuMultiPlotWindow::ownerPlotDefinition()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewWindow* RiuMultiPlotWindow::ownerViewWindow() const
{
return m_plotDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::addPlot( RiuQwtPlotWidget* plotWidget )
void RiuMultiPlotBook::addPlot( RiuQwtPlotWidget* plotWidget )
{
// Push the plot to the back of the list
insertPlot( plotWidget, m_plotWidgets.size() );
@@ -177,9 +167,8 @@ void RiuMultiPlotWindow::addPlot( RiuQwtPlotWidget* plotWidget )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
void RiuMultiPlotBook::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
{
plotWidget->setDraggable( true ); // Becomes draggable when added to a grid plot window
m_plotWidgets.insert( static_cast<int>( index ), plotWidget );
scheduleUpdate();
}
@@ -187,7 +176,7 @@ void RiuMultiPlotWindow::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::removePlot( RiuQwtPlotWidget* plotWidget )
void RiuMultiPlotBook::removePlot( RiuQwtPlotWidget* plotWidget )
{
if ( !plotWidget ) return;
@@ -202,7 +191,7 @@ void RiuMultiPlotWindow::removePlot( RiuQwtPlotWidget* plotWidget )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::setPlotTitle( const QString& plotTitle )
void RiuMultiPlotBook::setPlotTitle( const QString& plotTitle )
{
m_plotTitle = plotTitle;
for ( int i = 0; i < m_pages.size(); ++i )
@@ -214,7 +203,7 @@ void RiuMultiPlotWindow::setPlotTitle( const QString& plotTitle )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::setTitleVisible( bool visible )
void RiuMultiPlotBook::setTitleVisible( bool visible )
{
m_titleVisible = visible;
for ( auto page : m_pages )
@@ -226,25 +215,19 @@ void RiuMultiPlotWindow::setTitleVisible( bool visible )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::setSelectionsVisible( bool visible )
void RiuMultiPlotBook::setSubTitlesVisible( bool visible )
{
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
m_subTitlesVisible = visible;
for ( auto page : m_pages )
{
if ( visible && caf::SelectionManager::instance()->isSelected( plotWidget->plotDefinition(), 0 ) )
{
plotWidget->setWidgetState( "selected" );
}
else
{
caf::UiStyleSheet::clearWidgetStates( plotWidget );
}
page->setSubTitlesVisible( visible );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::setFontSize( int fontSize )
void RiuMultiPlotBook::setFontSize( int fontSize )
{
QFont font = this->font();
int pixelSize = RiaFontCache::pointSizeToPixelSize( fontSize );
@@ -256,14 +239,12 @@ void RiuMultiPlotWindow::setFontSize( int fontSize )
{
page->setFontSize( fontSize );
}
scheduleUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiuMultiPlotWindow::fontSize() const
int RiuMultiPlotBook::fontSize() const
{
return RiaFontCache::pixelSizeToPointSize( this->font().pixelSize() );
}
@@ -271,7 +252,7 @@ int RiuMultiPlotWindow::fontSize() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiuMultiPlotWindow::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget )
int RiuMultiPlotBook::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget )
{
return m_plotWidgets.indexOf( plotWidget );
}
@@ -279,7 +260,7 @@ int RiuMultiPlotWindow::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuMultiPlotWindow::previewModeEnabled() const
bool RiuMultiPlotBook::previewModeEnabled() const
{
return m_previewMode;
}
@@ -287,7 +268,7 @@ bool RiuMultiPlotWindow::previewModeEnabled() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::setPreviewModeEnabled( bool previewMode )
void RiuMultiPlotBook::setPreviewModeEnabled( bool previewMode )
{
m_previewMode = previewMode;
@@ -295,14 +276,12 @@ void RiuMultiPlotWindow::setPreviewModeEnabled( bool previewMode )
{
page->setPreviewModeEnabled( previewModeEnabled() );
}
scheduleUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::scheduleUpdate()
void RiuMultiPlotBook::scheduleUpdate()
{
RiaPlotWindowRedrawScheduler::instance()->scheduleMultiPlotWindowUpdate( this );
}
@@ -310,7 +289,7 @@ void RiuMultiPlotWindow::scheduleUpdate()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::scheduleReplotOfAllPlots()
void RiuMultiPlotBook::scheduleReplotOfAllPlots()
{
for ( RiuQwtPlotWidget* plotWidget : visiblePlotWidgets() )
{
@@ -321,9 +300,12 @@ void RiuMultiPlotWindow::scheduleReplotOfAllPlots()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::renderTo( QPaintDevice* paintDevice )
void RiuMultiPlotBook::renderTo( QPaintDevice* paintDevice )
{
setSelectionsVisible( false );
for ( auto page : m_pages )
{
page->stashWidgetStates();
}
int resolution = paintDevice->logicalDpiX();
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
@@ -344,18 +326,21 @@ void RiuMultiPlotWindow::renderTo( QPaintDevice* paintDevice )
firstPage = false;
}
setSelectionsVisible( true );
for ( auto page : m_pages )
{
page->restoreWidgetStates();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::contextMenuEvent( QContextMenuEvent* event )
void RiuMultiPlotBook::contextMenuEvent( QContextMenuEvent* event )
{
QMenu menu;
caf::CmdFeatureMenuBuilder menuBuilder;
caf::SelectionManager::instance()->setSelectedItem( ownerPlotDefinition() );
caf::SelectionManager::instance()->setSelectedItem( ownerViewWindow() );
menuBuilder << "RicShowPlotDataFeature";
menuBuilder << "RicShowContributingWellsFromPlotFeature";
@@ -371,7 +356,7 @@ void RiuMultiPlotWindow::contextMenuEvent( QContextMenuEvent* event )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::showEvent( QShowEvent* event )
void RiuMultiPlotBook::showEvent( QShowEvent* event )
{
QWidget::showEvent( event );
performUpdate();
@@ -381,7 +366,7 @@ void RiuMultiPlotWindow::showEvent( QShowEvent* event )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::resizeEvent( QResizeEvent* event )
void RiuMultiPlotBook::resizeEvent( QResizeEvent* event )
{
setBookSize( event->size().width() );
QWidget::resizeEvent( event );
@@ -390,7 +375,7 @@ void RiuMultiPlotWindow::resizeEvent( QResizeEvent* event )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::setBookSize( int frameWidth )
void RiuMultiPlotBook::setBookSize( int frameWidth )
{
for ( auto page : m_pages )
{
@@ -404,7 +389,7 @@ void RiuMultiPlotWindow::setBookSize( int frameWidth )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<int, int> RiuMultiPlotWindow::rowAndColumnCount( int plotWidgetCount ) const
std::pair<int, int> RiuMultiPlotBook::rowAndColumnCount( int plotWidgetCount ) const
{
if ( plotWidgetCount == 0 )
{
@@ -419,7 +404,7 @@ std::pair<int, int> RiuMultiPlotWindow::rowAndColumnCount( int plotWidgetCount )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuMultiPlotWindow::showYAxis( int row, int column ) const
bool RiuMultiPlotBook::showYAxis( int row, int column ) const
{
return true;
}
@@ -427,7 +412,7 @@ bool RiuMultiPlotWindow::showYAxis( int row, int column ) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::performUpdate()
void RiuMultiPlotBook::performUpdate()
{
deleteAllPages();
createPages();
@@ -437,7 +422,7 @@ void RiuMultiPlotWindow::performUpdate()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<QPointer<RiuQwtPlotWidget>> RiuMultiPlotWindow::visiblePlotWidgets() const
QList<QPointer<RiuQwtPlotWidget>> RiuMultiPlotBook::visiblePlotWidgets() const
{
QList<QPointer<RiuQwtPlotWidget>> plotWidgets;
for ( QPointer<RiuQwtPlotWidget> plotWidget : m_plotWidgets )
@@ -453,7 +438,7 @@ QList<QPointer<RiuQwtPlotWidget>> RiuMultiPlotWindow::visiblePlotWidgets() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::deleteAllPages()
void RiuMultiPlotBook::deleteAllPages()
{
for ( RiuMultiPlotPage* page : m_pages )
{
@@ -467,8 +452,10 @@ void RiuMultiPlotWindow::deleteAllPages()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::createPages()
void RiuMultiPlotBook::createPages()
{
CAF_ASSERT( m_plotDefinition );
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets();
auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() );
@@ -476,41 +463,53 @@ void RiuMultiPlotWindow::createPages()
int row = 0;
int column = 0;
RiuMultiPlotPage* page = new RiuMultiPlotPage( m_plotDefinition, this );
m_pages.push_back( page );
m_bookLayout->addWidget( page );
// Make sure we always add a page. For empty multi-plots we'll have an empty page with a drop target.
RiuMultiPlotPage* page = createPage();
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
{
int expextedColSpan = static_cast<int>( plotWidgets[visibleIndex]->plotDefinition()->colSpan() );
int expextedColSpan = static_cast<int>( plotWidgets[visibleIndex]->colSpan() );
int colSpan = std::min( expextedColSpan, rowAndColumnCount.second );
std::tie( row, column ) = page->findAvailableRowAndColumn( row, column, colSpan, rowAndColumnCount.second );
if ( row >= rowsPerPage )
{
page = new RiuMultiPlotPage( m_plotDefinition, this );
m_pages.push_back( page );
m_bookLayout->addWidget( page );
page = createPage();
row = 0;
column = 0;
}
page->addPlot( plotWidgets[visibleIndex] );
page->setVisible( true );
page->performUpdate();
}
// Reapply plot settings
setPlotTitle( m_plotTitle );
setFontSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() );
setTitleVisible( m_titleVisible );
setPreviewModeEnabled( m_previewMode );
m_book->adjustSize();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QList<QPointer<RiuMultiPlotPage>>& RiuMultiPlotWindow::pages() const
const QList<QPointer<RiuMultiPlotPage>>& RiuMultiPlotBook::pages() const
{
return m_pages;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMultiPlotPage* RiuMultiPlotBook::createPage()
{
RiuMultiPlotPage* page = new RiuMultiPlotPage( m_plotDefinition, this );
// Reapply plot settings
size_t pageNumber = m_pages.size() + 1;
page->setPlotTitle( QString( "%1 %2/%3" ).arg( m_plotTitle ).arg( pageNumber ).arg( pageNumber ) );
page->setFontSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() );
page->setTitleVisible( m_titleVisible );
page->setSubTitlesVisible( m_subTitlesVisible );
page->setPreviewModeEnabled( m_previewMode );
m_pages.push_back( page );
m_bookLayout->addWidget( page );
page->setVisible( true );
return page;
}

View File

@@ -18,8 +18,7 @@
#pragma once
#include "RiuInterfaceToViewWindow.h"
#include "RiuMultiPlotInterface.h"
#include "RiuMultiPlotPage.h"
#include "cafUiStyleSheet.h"
#include "cafPdmPointer.h"
@@ -35,7 +34,7 @@
#include <map>
class RiaPlotWindowRedrawScheduler;
class RimMultiPlotWindow;
class RimMultiPlot;
class RiuMultiPlotPage;
class RiuQwtPlotWidget;
@@ -49,42 +48,43 @@ class QwtPlot;
//==================================================================================================
//
// RiuMultiPlotWidget
// RiuMultiPlotWindow
//
//==================================================================================================
class RiuMultiPlotWindow : public RiuMultiPlotInterface, public RiuInterfaceToViewWindow
class RiuMultiPlotBook : public QWidget, public RiuInterfaceToViewWindow
{
Q_OBJECT
public:
RiuMultiPlotWindow( RimMultiPlotWindow* plotDefinition, QWidget* parent = nullptr );
~RiuMultiPlotWindow() override;
using ColumnCount = RiuMultiPlotPage::ColumnCount;
RimMultiPlotWindow* ownerPlotDefinition();
RimViewWindow* ownerViewWindow() const override;
public:
RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* parent = nullptr );
~RiuMultiPlotBook() override;
void addPlot( RiuQwtPlotWidget* plotWidget ) override;
void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) override;
void removePlot( RiuQwtPlotWidget* plotWidget ) override;
RimViewWindow* ownerViewWindow() const override;
void setPlotTitle( const QString& plotTitle ) override;
void addPlot( RiuQwtPlotWidget* plotWidget );
void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index );
void removePlot( RiuQwtPlotWidget* plotWidget );
void setTitleVisible( bool visible ) override;
void setSelectionsVisible( bool visible );
void setPlotTitle( const QString& plotTitle );
void setTitleVisible( bool visible );
void setSubTitlesVisible( bool visible );
void setFontSize( int fontSize );
int fontSize() const;
int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget );
bool previewModeEnabled() const override;
void setPreviewModeEnabled( bool previewMode ) override;
bool previewModeEnabled() const;
void setPreviewModeEnabled( bool previewMode );
void scheduleUpdate();
void scheduleReplotOfAllPlots();
void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) override {}
void renderTo( QPaintDevice* painter ) override;
void renderTo( QPaintDevice* painter );
protected:
void contextMenuEvent( QContextMenuEvent* ) override;
@@ -104,6 +104,7 @@ private:
void deleteAllPages();
void createPages();
const QList<QPointer<RiuMultiPlotPage>>& pages() const;
RiuMultiPlotPage* createPage();
private slots:
virtual void performUpdate();
@@ -116,10 +117,11 @@ protected:
QPointer<BookFrame> m_book;
QPointer<QVBoxLayout> m_bookLayout;
QList<QPointer<RiuMultiPlotPage>> m_pages;
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
caf::PdmPointer<RimMultiPlotWindow> m_plotDefinition;
QString m_plotTitle;
bool m_titleVisible;
bool m_previewMode;
QList<QPointer<RiuMultiPlotPage>> m_pages;
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
caf::PdmPointer<RimMultiPlot> m_plotDefinition;
QString m_plotTitle;
bool m_titleVisible;
bool m_subTitlesVisible;
bool m_previewMode;
};

View File

@@ -1,61 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QWidget>
class RiuQwtPlotWidget;
class QPaintDevice;
class QScrollBar;
//==================================================================================================
//
// RiuMultiPlotInterface
//
//==================================================================================================
class RiuMultiPlotInterface : public QWidget
{
Q_OBJECT
public:
RiuMultiPlotInterface( QWidget* parent = nullptr )
: QWidget( parent )
{
}
virtual ~RiuMultiPlotInterface() {}
virtual void addPlot( RiuQwtPlotWidget* plotWidget ) = 0;
virtual void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) = 0;
virtual void removePlot( RiuQwtPlotWidget* plotWidget ) = 0;
virtual int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget ) = 0;
virtual void setPlotTitle( const QString& plotTitle ) = 0;
virtual void setTitleVisible( bool visible ) = 0;
virtual void setFontSize( int fontSize ) = 0;
virtual int fontSize() const = 0;
virtual bool previewModeEnabled() const = 0;
virtual void setPreviewModeEnabled( bool previewMode ) = 0;
virtual void scheduleUpdate() = 0;
virtual void scheduleReplotOfAllPlots() = 0;
virtual void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) = 0;
virtual void renderTo( QPaintDevice* paintDevice ) = 0;
};

View File

@@ -28,7 +28,7 @@
#include "RiaGuiApplication.h"
#include "RimContextCommandBuilder.h"
#include "RimMultiPlotWindow.h"
#include "RimMultiPlot.h"
#include "RimWellLogTrack.h"
#include "RiuMainWindow.h"
@@ -63,13 +63,13 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMultiPlotPage::RiuMultiPlotPage( RimMultiPlotWindow* plotDefinition, QWidget* parent )
: RiuMultiPlotInterface( parent )
RiuMultiPlotPage::RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* parent )
: QWidget( parent )
, m_plotDefinition( plotDefinition )
, m_previewMode( false )
, m_showSubTitles( false )
{
Q_ASSERT( plotDefinition );
m_plotDefinition = plotDefinition;
CAF_ASSERT( m_plotDefinition );
m_layout = new QVBoxLayout( this );
m_layout->setMargin( 0 );
@@ -77,7 +77,7 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimMultiPlotWindow* plotDefinition, QWidget*
m_plotTitle = createTitleLabel();
m_layout->addWidget( m_plotTitle );
m_plotTitle->setVisible( m_plotDefinition->isMultiPlotTitleVisible() );
m_plotTitle->setVisible( true );
m_plotLayout = new QHBoxLayout;
m_layout->addLayout( m_plotLayout );
@@ -98,19 +98,10 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimMultiPlotWindow* plotDefinition, QWidget*
new RiuPlotObjectPicker( m_plotTitle, m_plotDefinition );
m_dropTargetPlaceHolder = new QLabel( "Drag plots here" );
m_dropTargetPlaceHolder->setAlignment( Qt::AlignCenter );
m_dropTargetPlaceHolder->setObjectName(
QString( "%1" ).arg( reinterpret_cast<uint64_t>( m_dropTargetPlaceHolder.data() ) ) );
m_dropTargetStyleSheet = createDropTargetStyleSheet();
m_dropTargetStyleSheet.applyToWidget( m_dropTargetPlaceHolder );
this->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding );
setFocusPolicy( Qt::StrongFocus );
setAcceptDrops( m_plotDefinition->acceptDrops() );
RiaApplication* app = RiaApplication::instance();
int defaultFontSize = app->preferences()->defaultPlotFontSize();
setFontSize( defaultFontSize );
@@ -136,7 +127,15 @@ RiuMultiPlotPage::~RiuMultiPlotPage() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMultiPlotWindow* RiuMultiPlotPage::ownerPlotDefinition()
RimViewWindow* RiuMultiPlotPage::ownerViewWindow() const
{
return m_plotDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotWindow* RiuMultiPlotPage::ownerPlotDefinition()
{
return m_plotDefinition;
}
@@ -155,11 +154,11 @@ void RiuMultiPlotPage::addPlot( RiuQwtPlotWidget* plotWidget )
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
{
plotWidget->setDraggable( true ); // Becomes draggable when added to a grid plot window
m_plotWidgets.insert( static_cast<int>( index ), plotWidget );
plotWidget->setVisible( false );
QLabel* subTitle = new QLabel( plotWidget->plotDefinition()->description() );
QString subTitleText = plotWidget->plotTitle();
QLabel* subTitle = new QLabel( subTitleText );
subTitle->setAlignment( Qt::AlignHCenter );
subTitle->setVisible( false );
m_subTitles.insert( static_cast<int>( index ), subTitle );
@@ -240,24 +239,6 @@ void RiuMultiPlotPage::setTitleVisible( bool visible )
m_plotTitle->setVisible( visible );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::setSelectionsVisible( bool visible )
{
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
{
if ( visible && caf::SelectionManager::instance()->isSelected( plotWidget->plotDefinition(), 0 ) )
{
plotWidget->setWidgetState( "selected" );
}
else
{
caf::UiStyleSheet::clearWidgetStates( plotWidget );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -289,6 +270,14 @@ int RiuMultiPlotPage::fontSize() const
return m_plotTitle->font().pointSize() - 2;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::setSubTitlesVisible( bool visible )
{
m_showSubTitles = visible;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -318,6 +307,7 @@ int RiuMultiPlotPage::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget )
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::scheduleUpdate()
{
CAF_ASSERT( m_plotDefinition );
RiaPlotWindowRedrawScheduler::instance()->scheduleMultiPlotPageUpdate( this );
}
@@ -349,7 +339,7 @@ void RiuMultiPlotPage::renderTo( QPaintDevice* paintDevice )
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::renderTo( QPainter* painter, double scalingFactor )
{
setSelectionsVisible( false );
stashWidgetStates();
painter->fillRect( painter->viewport(), Qt::white );
m_plotTitle->render( painter );
@@ -381,7 +371,7 @@ void RiuMultiPlotPage::renderTo( QPainter* painter, double scalingFactor )
plotWidget->renderTo( painter, plotWidgetGeometry, scalingFactor );
}
setSelectionsVisible( true );
restoreWidgetStates();
}
//--------------------------------------------------------------------------------------------------
@@ -410,7 +400,7 @@ void RiuMultiPlotPage::contextMenuEvent( QContextMenuEvent* event )
//--------------------------------------------------------------------------------------------------
QLabel* RiuMultiPlotPage::createTitleLabel() const
{
QLabel* plotTitle = new QLabel( "PLOT TITLE HERE", nullptr );
QLabel* plotTitle = new QLabel( "", nullptr );
plotTitle->setAlignment( Qt::AlignHCenter );
plotTitle->setWordWrap( true );
plotTitle->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
@@ -423,128 +413,7 @@ QLabel* RiuMultiPlotPage::createTitleLabel() const
void RiuMultiPlotPage::showEvent( QShowEvent* event )
{
QWidget::showEvent( event );
scheduleUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::dragEnterEvent( QDragEnterEvent* event )
{
RiuQwtPlotWidget* source = dynamic_cast<RiuQwtPlotWidget*>( event->source() );
if ( source )
{
setWidgetState( "dragTargetInto" );
event->acceptProposedAction();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::dragMoveEvent( QDragMoveEvent* event )
{
if ( event->answerRect().intersects( this->geometry() ) )
{
RiuQwtPlotWidget* source = dynamic_cast<RiuQwtPlotWidget*>( event->source() );
if ( source && willAcceptDroppedPlot( source ) )
{
setWidgetState( "dragTargetInto" );
QRect originalGeometry = source->geometry();
QPoint offset = source->dragStartPosition();
QRect newRect( event->pos() - offset, originalGeometry.size() );
QList<QPointer<RiuQwtPlotWidget>> visiblePlotWidgets = this->visiblePlotWidgets();
int insertBeforeIndex = visiblePlotWidgets.size();
for ( int visibleIndex = 0; visibleIndex < visiblePlotWidgets.size(); ++visibleIndex )
{
caf::UiStyleSheet::clearWidgetStates( visiblePlotWidgets[visibleIndex] );
if ( visiblePlotWidgets[visibleIndex]->frameIsInFrontOfThis( newRect ) )
{
insertBeforeIndex = std::min( insertBeforeIndex, visibleIndex );
}
}
if ( insertBeforeIndex >= 0 && insertBeforeIndex < visiblePlotWidgets.size() )
{
visiblePlotWidgets[insertBeforeIndex]->setWidgetState( "dragTargetBefore" );
}
if ( insertBeforeIndex > 0 )
{
int insertAfterIndex = insertBeforeIndex - 1;
visiblePlotWidgets[insertAfterIndex]->setWidgetState( "dragTargetAfter" );
}
event->acceptProposedAction();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::dragLeaveEvent( QDragLeaveEvent* event )
{
caf::UiStyleSheet::clearWidgetStates( this );
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
{
caf::UiStyleSheet::clearWidgetStates( m_plotWidgets[tIdx] );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::dropEvent( QDropEvent* event )
{
caf::UiStyleSheet::clearWidgetStates( this );
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
{
caf::UiStyleSheet::clearWidgetStates( m_plotWidgets[tIdx] );
}
if ( this->geometry().contains( event->pos() ) )
{
RiuQwtPlotWidget* source = dynamic_cast<RiuQwtPlotWidget*>( event->source() );
if ( source && willAcceptDroppedPlot( source ) )
{
event->acceptProposedAction();
QRect originalGeometry = source->geometry();
QPoint offset = source->dragStartPosition();
QRect newRect( event->pos() - offset, originalGeometry.size() );
int beforeIndex = m_plotWidgets.size();
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
{
if ( m_plotWidgets[tIdx]->isVisible() )
{
if ( m_plotWidgets[tIdx]->frameIsInFrontOfThis( newRect ) )
{
beforeIndex = tIdx;
break;
}
}
}
RimPlot* insertAfter = nullptr;
if ( beforeIndex > 0 )
{
insertAfter = m_plotWidgets[beforeIndex - 1]->plotDefinition();
}
RimPlot* plotToMove = source->plotDefinition();
if ( insertAfter != plotToMove )
{
m_plotDefinition->movePlotsToThis( {plotToMove}, insertAfter );
}
}
}
performUpdate();
}
//--------------------------------------------------------------------------------------------------
@@ -590,13 +459,16 @@ void RiuMultiPlotPage::updateMarginsFromPageLayout()
//--------------------------------------------------------------------------------------------------
QSize RiuMultiPlotPage::sizeHint() const
{
QPageLayout pageLayout = m_plotDefinition->pageLayout();
const int resolution = RiaGuiApplication::applicationResolution();
QRect rect = pageLayout.fullRectPixels( resolution );
QPageLayout pageLayout = RiaApplication::instance()->preferences()->defaultPageLayout();
if ( m_plotDefinition )
{
pageLayout = m_plotDefinition->pageLayout();
}
const int resolution = RiaGuiApplication::applicationResolution();
QRect rect = pageLayout.fullRectPixels( resolution );
return rect.size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -606,14 +478,6 @@ QSize RiuMultiPlotPage::minimumSizeHint() const
return QSize( fullSizeHint.width() / 2, fullSizeHint.height() / 2 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuMultiPlotPage::willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -634,15 +498,18 @@ std::pair<int, int> RiuMultiPlotPage::rowAndColumnCount( int plotWidgetCount ) c
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels )
{
if ( !m_plotDefinition ) return;
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
{
CAF_ASSERT( plotWidget );
RimPlot* plot = plotWidget->plotDefinition();
if ( !plot ) continue;
bool isSelected = false;
for ( int changedLevel : changedSelectionLevels )
{
isSelected = isSelected ||
caf::SelectionManager::instance()->isSelected( plotWidget->plotDefinition(), changedLevel );
isSelected = isSelected || caf::SelectionManager::instance()->isSelected( plot, changedLevel );
}
if ( isSelected )
{
@@ -655,14 +522,6 @@ void RiuMultiPlotPage::onSelectionManagerSelectionChanged( const std::set<int>&
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::setWidgetState( const QString& widgetState )
{
m_dropTargetStyleSheet.setWidgetState( m_dropTargetPlaceHolder, widgetState );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -716,25 +575,17 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
QList<QPointer<RiuQwtPlotLegend>> legends = this->legendsForVisiblePlots();
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets();
if ( plotWidgets.empty() && acceptDrops() )
if ( !plotWidgets.empty() )
{
m_gridLayout->addWidget( m_dropTargetPlaceHolder, 0, 0 );
m_gridLayout->setRowStretch( 0, 1 );
m_dropTargetPlaceHolder->setVisible( true );
}
else
{
m_dropTargetPlaceHolder->setVisible( false );
auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() );
int row = 0;
int column = 0;
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
{
int expextedColSpan = static_cast<int>( plotWidgets[visibleIndex]->plotDefinition()->colSpan() );
int colSpan = std::min( expextedColSpan, rowAndColumnCount.second );
int rowSpan = plotWidgets[visibleIndex]->plotDefinition()->rowSpan();
int expectedColSpan = static_cast<int>( plotWidgets[visibleIndex]->colSpan() );
int colSpan = std::min( expectedColSpan, rowAndColumnCount.second );
int rowSpan = plotWidgets[visibleIndex]->rowSpan();
std::tie( row, column ) = findAvailableRowAndColumn( row, column, colSpan, rowAndColumnCount.second );
@@ -743,7 +594,7 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
->addWidget( legends[visibleIndex], 3 * row + 1, column, 1, colSpan, Qt::AlignHCenter | Qt::AlignBottom );
m_gridLayout->addWidget( plotWidgets[visibleIndex], 3 * row + 2, column, 1 + ( rowSpan - 1 ) * 3, colSpan );
subTitles[visibleIndex]->setVisible( m_plotDefinition->showPlotTitles() );
subTitles[visibleIndex]->setVisible( m_showSubTitles );
plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft, showYAxis( row, column ) );
plotWidgets[visibleIndex]->setAxisTitleEnabled( QwtPlot::yLeft, showYAxis( row, column ) );
@@ -775,7 +626,7 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
}
for ( int c = column; c < column + colSpan; ++c )
{
int colStretch = 1;
int colStretch = 6;
if ( showYAxis( row, column ) ) colStretch += 1;
m_gridLayout->setColumnStretch( c, std::max( colStretch, m_gridLayout->columnStretch( c ) ) );
}
@@ -840,22 +691,6 @@ void RiuMultiPlotPage::clearGridLayout()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::UiStyleSheet RiuMultiPlotPage::createDropTargetStyleSheet()
{
caf::UiStyleSheet styleSheet;
styleSheet.set( "background-color", "white" );
styleSheet.set( "border", "1px dashed black" );
styleSheet.set( "font-size", "14pt" );
styleSheet.property( "dragTargetInto" ).set( "border", "1px dashed lime" );
styleSheet.property( "dragTargetInto" ).set( "background-color", "#DDFFDD" );
return styleSheet;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -939,3 +774,25 @@ std::pair<int, int>
}
return std::make_pair( availableRow, availableColumn );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::stashWidgetStates()
{
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
{
plotWidget->stashWidgetStates();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::restoreWidgetStates()
{
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
{
plotWidget->restoreWidgetStates();
}
}

View File

@@ -17,12 +17,11 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiuMultiPlotInterface.h"
#include "cafUiStyleSheet.h"
#include "RiuInterfaceToViewWindow.h"
#include "cafPdmPointer.h"
#include "cafSelectionChangedReceiver.h"
#include "cafUiStyleSheet.h"
#include <QFrame>
#include <QGridLayout>
@@ -34,7 +33,7 @@
#include <map>
class RiaPlotWindowRedrawScheduler;
class RimMultiPlotWindow;
class RimPlotWindow;
class RiuQwtPlotLegend;
class RiuQwtPlotWidget;
@@ -51,38 +50,48 @@ class QwtPlot;
// RiuMultiPlotPage
//
//==================================================================================================
class RiuMultiPlotPage : public RiuMultiPlotInterface, public caf::SelectionChangedReceiver
class RiuMultiPlotPage : public QWidget, public caf::SelectionChangedReceiver, public RiuInterfaceToViewWindow
{
Q_OBJECT
public:
RiuMultiPlotPage( RimMultiPlotWindow* plotDefinition, QWidget* parent = nullptr );
enum class ColumnCount
{
COLUMNS_1 = 1,
COLUMNS_2 = 2,
COLUMNS_3 = 3,
COLUMNS_4 = 4,
COLUMNS_UNLIMITED = 1000,
};
public:
RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* parent = nullptr );
~RiuMultiPlotPage() override;
RimMultiPlotWindow* ownerPlotDefinition();
RimViewWindow* ownerViewWindow() const override;
RimPlotWindow* ownerPlotDefinition();
void addPlot( RiuQwtPlotWidget* plotWidget ) override;
void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ) override;
void removePlot( RiuQwtPlotWidget* plotWidget ) override;
void addPlot( RiuQwtPlotWidget* plotWidget );
void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index );
void removePlot( RiuQwtPlotWidget* plotWidget );
void removeAllPlots();
int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget ) override;
int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget );
void setSelectionsVisible( bool visible );
void setPlotTitle( const QString& plotTitle );
void setTitleVisible( bool visible );
void setFontSize( int fontSize );
int fontSize() const;
void setSubTitlesVisible( bool visible );
void setPlotTitle( const QString& plotTitle ) override;
void setTitleVisible( bool visible ) override;
void setFontSize( int fontSize ) override;
int fontSize() const override;
bool previewModeEnabled() const;
void setPreviewModeEnabled( bool previewMode );
bool previewModeEnabled() const override;
void setPreviewModeEnabled( bool previewMode ) override;
void scheduleUpdate();
void scheduleReplotOfAllPlots();
virtual void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) {}
void scheduleUpdate() override;
void scheduleReplotOfAllPlots() override;
void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) override {}
void renderTo( QPaintDevice* paintDevice ) override;
void renderTo( QPainter* painter, double scalingFactor );
virtual void renderTo( QPaintDevice* paintDevice );
void renderTo( QPainter* painter, double scalingFactor );
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
@@ -93,28 +102,19 @@ protected:
QLabel* createTitleLabel() const;
void showEvent( QShowEvent* event ) override;
void dragEnterEvent( QDragEnterEvent* event ) override;
void dragMoveEvent( QDragMoveEvent* event ) override;
void dragLeaveEvent( QDragLeaveEvent* event ) override;
void dropEvent( QDropEvent* event ) override;
bool hasHeightForWidth() const override;
void updateMarginsFromPageLayout();
virtual bool willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const;
std::pair<int, int> rowAndColumnCount( int plotWidgetCount ) const;
virtual void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override;
void setWidgetState( const QString& widgetState );
virtual bool showYAxis( int row, int column ) const;
void reinsertPlotWidgets();
int alignCanvasTops();
void clearGridLayout();
caf::UiStyleSheet createDropTargetStyleSheet();
void clearGridLayout();
QList<QPointer<RiuQwtPlotWidget>> visiblePlotWidgets() const;
QList<QPointer<RiuQwtPlotLegend>> legendsForVisiblePlots() const;
@@ -122,26 +122,28 @@ protected:
std::pair<int, int> findAvailableRowAndColumn( int startRow, int startColumn, int columnSpan, int columnCount ) const;
void stashWidgetStates();
void restoreWidgetStates();
private slots:
virtual void performUpdate();
void onLegendUpdated();
protected:
friend class RiuMultiPlotWindow;
friend class RiuMultiPlotBook;
QPointer<QVBoxLayout> m_layout;
QPointer<QHBoxLayout> m_plotLayout;
QPointer<QFrame> m_plotWidgetFrame;
QPointer<QGridLayout> m_gridLayout;
QPointer<QLabel> m_plotTitle;
QList<QPointer<QLabel>> m_subTitles;
QList<QPointer<RiuQwtPlotLegend>> m_legends;
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
caf::PdmPointer<RimMultiPlotWindow> m_plotDefinition;
QPointer<QLabel> m_dropTargetPlaceHolder;
bool m_previewMode;
QPointer<QVBoxLayout> m_layout;
QPointer<QHBoxLayout> m_plotLayout;
QPointer<QFrame> m_plotWidgetFrame;
QPointer<QGridLayout> m_gridLayout;
QPointer<QLabel> m_plotTitle;
QList<QPointer<QLabel>> m_subTitles;
QList<QPointer<RiuQwtPlotLegend>> m_legends;
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
caf::PdmPointer<RimPlotWindow> m_plotDefinition;
caf::UiStyleSheet m_dropTargetStyleSheet;
bool m_previewMode;
bool m_showSubTitles;
private:
friend class RiaPlotWindowRedrawScheduler;

View File

@@ -25,6 +25,7 @@
#include "RiaSummaryTools.h"
#include "RimEnsembleCurveSetCollection.h"
#include "RimMultiPlot.h"
#include "RimProject.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurveCollection.h"
@@ -576,7 +577,7 @@ void RiuPlotMainWindow::updateWellLogPlotToolBar()
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::updateMultiPlotToolBar()
{
RimMultiPlotWindow* plotWindow = dynamic_cast<RimMultiPlotWindow*>( m_activePlotViewWindow.p() );
RimMultiPlot* plotWindow = dynamic_cast<RimMultiPlot*>( m_activePlotViewWindow.p() );
if ( plotWindow )
{
std::vector<caf::PdmFieldHandle*> toolBarFields = {plotWindow->columnCountField()};
@@ -597,8 +598,8 @@ void RiuPlotMainWindow::updateMultiPlotToolBar()
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::updateSummaryPlotToolBar( bool forceUpdateUi )
{
RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>( m_activePlotViewWindow.p() );
RimMultiPlotWindow* multiPlot = dynamic_cast<RimMultiPlotWindow*>( m_activePlotViewWindow.p() );
RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>( m_activePlotViewWindow.p() );
RimMultiPlot* multiPlot = dynamic_cast<RimMultiPlot*>( m_activePlotViewWindow.p() );
if ( multiPlot )
{
summaryPlot = caf::SelectionManager::instance()->selectedItemOfType<RimSummaryPlot>();

View File

@@ -23,9 +23,7 @@
#include "RiaFontCache.h"
#include "RiaGuiApplication.h"
#include "RiaPlotWindowRedrawScheduler.h"
#include "RimPlot.h"
#include "RimPlotCurve.h"
#include "RiuDraggableOverlayFrame.h"
#include "RiuPlotMainWindowTools.h"
@@ -66,12 +64,12 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlot* plot, QWidget* parent )
RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlot* plotDefinition, QWidget* parent )
: QwtPlot( parent )
, m_plotDefinition( plot )
, m_draggable( true )
, m_plotDefinition( plotDefinition )
, m_overlayMargins( 5 )
{
CAF_ASSERT( m_plotDefinition );
RiuQwtPlotTools::setCommonPlotBehaviour( this );
this->installEventFilter( this );
@@ -89,6 +87,14 @@ RiuQwtPlotWidget::~RiuQwtPlotWidget()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlot* RiuQwtPlotWidget::plotDefinition()
{
return m_plotDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -98,16 +104,31 @@ bool RiuQwtPlotWidget::isChecked() const
{
return m_plotDefinition->showWindow();
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setDraggable( bool draggable )
int RiuQwtPlotWidget::colSpan() const
{
m_draggable = draggable;
if ( m_plotDefinition )
{
return m_plotDefinition->colSpan();
}
return 1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiuQwtPlotWidget::rowSpan() const
{
if ( m_plotDefinition )
{
return m_plotDefinition->rowSpan();
}
return 1;
}
//--------------------------------------------------------------------------------------------------
@@ -160,14 +181,6 @@ void RiuQwtPlotWidget::setAxisFontsAndAlignment( QwtPlot::Axis axis,
setAxisTitle( axis, axisTitle );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlot* RiuQwtPlotWidget::plotDefinition() const
{
return m_plotDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -186,6 +199,40 @@ void RiuQwtPlotWidget::setAxisTitleEnabled( QwtPlot::Axis axis, bool enable )
applyAxisTitleToQwt( axis );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setPlotTitle( const QString& plotTitle )
{
m_plotTitle = plotTitle;
applyPlotTitleToQwt();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QString& RiuQwtPlotWidget::plotTitle() const
{
return m_plotTitle;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setPlotTitleEnabled( bool enabled )
{
m_plotTitleEnabled = enabled;
applyPlotTitleToQwt();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuQwtPlotWidget::plotTitleEnabled() const
{
return m_plotTitleEnabled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -399,6 +446,22 @@ void RiuQwtPlotWidget::scheduleReplot()
RiaPlotWindowRedrawScheduler::instance()->schedulePlotWidgetReplot( this );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::stashWidgetStates()
{
m_plotStyleSheet.stashWidgetStates();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::restoreWidgetStates()
{
m_plotStyleSheet.restoreWidgetStates();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -442,27 +505,20 @@ void RiuQwtPlotWidget::updateLayout()
updateOverlayFrameLayout();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QSize RiuQwtPlotWidget::sizeHint() const
{
return QSize( 0, 0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QSize RiuQwtPlotWidget::minimumSizeHint() const
{
return QSize( 0, 0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event )
{
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>( event );
if ( wheelEvent && watched == canvas() )
{
event->accept();
emit onWheelEvent( wheelEvent );
return true;
}
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>( event );
if ( mouseEvent )
{
@@ -470,48 +526,32 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event )
bool toggleItemInSelection = ( mouseEvent->modifiers() & Qt::ControlModifier ) != 0;
if ( m_draggable && mouseEvent->type() == QMouseEvent::MouseButtonPress && mouseEvent->button() == Qt::LeftButton )
if ( mouseEvent->type() == QMouseEvent::MouseButtonPress && mouseEvent->button() == Qt::LeftButton )
{
m_clickPosition = mouseEvent->pos();
}
if ( watched == this && !this->canvas()->geometry().contains( mouseEvent->pos() ) )
{
if ( m_draggable && mouseEvent->type() == QMouseEvent::MouseMove &&
( mouseEvent->buttons() & Qt::LeftButton ) && !m_clickPosition.isNull() )
{
int dragLength = ( mouseEvent->pos() - m_clickPosition ).manhattanLength();
if ( dragLength >= QApplication::startDragDistance() )
{
QPixmap pixmap = this->grab();
QDrag* drag = new QDrag( this );
QMimeData* mimeData = new QMimeData;
mimeData->setImageData( pixmap );
drag->setMimeData( mimeData );
drag->setPixmap( pixmap );
drag->setHotSpot( mouseEvent->pos() );
drag->exec( Qt::MoveAction );
return true;
}
}
else if ( mouseEvent->type() == QMouseEvent::MouseButtonRelease &&
( mouseEvent->button() == Qt::LeftButton ) && !m_clickPosition.isNull() )
if ( mouseEvent->type() == QMouseEvent::MouseButtonRelease && ( mouseEvent->button() == Qt::LeftButton ) &&
!m_clickPosition.isNull() )
{
QWidget* childClicked = this->childAt( m_clickPosition );
if ( childClicked )
{
QwtScaleWidget* scaleWidget = qobject_cast<QwtScaleWidget*>( childClicked );
if ( scaleWidget )
{
onAxisSelected( scaleWidget, toggleItemInSelection );
m_clickPosition = QPoint();
return true;
}
}
else
{
selectPlotOwner( toggleItemInSelection );
endZoomOperations();
emit plotSelected( toggleItemInSelection );
m_clickPosition = QPoint();
return true;
}
}
@@ -521,8 +561,9 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event )
if ( mouseEvent->type() == QMouseEvent::MouseButtonRelease && mouseEvent->button() == Qt::LeftButton &&
!m_clickPosition.isNull() )
{
selectClosestCurve( mouseEvent->pos(), toggleItemInSelection );
endZoomOperations();
selectClosestCurve( mouseEvent->pos(), toggleItemInSelection );
m_clickPosition = QPoint();
return true;
}
}
@@ -563,6 +604,28 @@ void RiuQwtPlotWidget::resizeEvent( QResizeEvent* event )
event->accept();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::keyPressEvent( QKeyEvent* event )
{
emit onKeyPressEvent( event );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::applyPlotTitleToQwt()
{
QString plotTitleToApply = m_plotTitleEnabled ? m_plotTitle : QString( "" );
QwtText plotTitle = this->title();
if ( plotTitleToApply != plotTitle.text() )
{
plotTitle.setText( plotTitleToApply );
setTitle( plotTitle );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -687,7 +750,7 @@ void RiuQwtPlotWidget::onAxisSelected( QwtScaleWidget* scale, bool toggleItemInS
axisId = i;
}
}
m_plotDefinition->onAxisSelected( axisId, toggleItemInSelection );
emit axisSelected( axisId, toggleItemInSelection );
}
//--------------------------------------------------------------------------------------------------
@@ -706,19 +769,6 @@ caf::UiStyleSheet RiuQwtPlotWidget::createPlotStyleSheet() const
styleSheet.property( "selected" ).set( "border", QString( "1px solid %1" ).arg( highlightColor.name() ) );
if ( m_draggable )
{
QString backgroundGradient = QString( QString( "qlineargradient( x1 : 1, y1 : 0, x2 : 1, y2 : 1,"
"stop: 0 %1, stop: 0.02 %2, stop:1 %3 )" )
.arg( blendedHighlightColor.name() )
.arg( nearlyBackgroundColor.name() )
.arg( backgroundColor.name() ) );
styleSheet.pseudoState( "hover" ).set( "background", backgroundGradient );
styleSheet.pseudoState( "hover" ).set( "border", QString( "1px dashed %1" ).arg( blendedHighlightColor.name() ) );
}
styleSheet.property( "dropTargetBefore" ).set( "border-left", "1px solid lime" );
styleSheet.property( "dropTargetAfter" ).set( "border-right", "1px solid lime" );
return styleSheet;
}
@@ -784,22 +834,6 @@ void RiuQwtPlotWidget::updateOverlayFrameLayout()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::selectPlotOwner( bool toggleItemInSelection )
{
if ( toggleItemInSelection )
{
RiuPlotMainWindowTools::toggleItemInSelection( m_plotDefinition );
}
else
{
RiuPlotMainWindowTools::selectAsCurrentItem( m_plotDefinition );
}
scheduleReplot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -830,24 +864,10 @@ void RiuQwtPlotWidget::selectClosestCurve( const QPoint& pos, bool toggleItemInS
resetCurveHighlighting();
if ( closestCurve && distMin < 20 )
{
if ( m_plotDefinition )
{
RimPlotCurve* selectedCurve = dynamic_cast<RimPlotCurve*>(
m_plotDefinition->findPdmObjectFromQwtCurve( closestCurve ) );
if ( selectedCurve )
{
if ( toggleItemInSelection )
{
RiuPlotMainWindowTools::toggleItemInSelection( selectedCurve );
}
else
{
RiuPlotMainWindowTools::selectAsCurrentItem( selectedCurve );
}
// TODO: highlight all selected curves
highlightCurve( closestCurve );
}
}
// TODO: highlight all selected curves
highlightCurve( closestCurve );
emit curveSelected( closestCurve, toggleItemInSelection );
if ( distMin < 10 )
{
selectPoint( closestCurve, closestCurvePoint );
@@ -860,7 +880,7 @@ void RiuQwtPlotWidget::selectClosestCurve( const QPoint& pos, bool toggleItemInS
}
else
{
selectPlotOwner( toggleItemInSelection );
emit plotSelected( toggleItemInSelection );
}
}

View File

@@ -45,6 +45,7 @@ class QEvent;
class QLabel;
class QPainter;
class QPaintDevice;
class QWheelEvent;
//==================================================================================================
//
@@ -56,14 +57,15 @@ class RiuQwtPlotWidget : public QwtPlot
Q_OBJECT
public:
RiuQwtPlotWidget( RimPlot* plotTrackDefinition, QWidget* parent = nullptr );
RiuQwtPlotWidget( RimPlot* plotDefinition, QWidget* parent = nullptr );
~RiuQwtPlotWidget() override;
RimPlot* plotDefinition() const;
RimPlot* plotDefinition();
bool isChecked() const;
void setDraggable( bool draggable );
int colSpan() const;
int rowSpan() const;
int axisTitleFontSize( QwtPlot::Axis axis ) const;
int axisValueFontSize( QwtPlot::Axis axis ) const;
@@ -76,6 +78,11 @@ public:
void setAxisTitleText( QwtPlot::Axis axis, const QString& title );
void setAxisTitleEnabled( QwtPlot::Axis axis, bool enable );
void setPlotTitle( const QString& plotTitle );
const QString& plotTitle() const;
void setPlotTitleEnabled( bool enabled );
bool plotTitleEnabled() const;
QwtInterval axisRange( QwtPlot::Axis axis );
void setAxisRange( QwtPlot::Axis axis, double min, double max );
@@ -99,6 +106,8 @@ public:
QPoint dragStartPosition() const;
void scheduleReplot();
void stashWidgetStates();
void restoreWidgetStates();
void setWidgetState( const QString& widgetState );
void addOverlayFrame( RiuDraggableOverlayFrame* overlayWidget );
@@ -109,14 +118,21 @@ public:
void renderTo( QPaintDevice* painter, const QRect& targetRect );
int overlayMargins() const;
protected:
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
bool eventFilter( QObject* watched, QEvent* event ) override;
void hideEvent( QHideEvent* event ) override;
void showEvent( QShowEvent* event ) override;
void resizeEvent( QResizeEvent* event ) override;
signals:
void plotSelected( bool toggleSelection );
void axisSelected( int axisId, bool toggleSelection );
void curveSelected( QwtPlotCurve* curve, bool toggleSelection );
void onKeyPressEvent( QKeyEvent* event );
void onWheelEvent( QWheelEvent* event );
protected:
bool eventFilter( QObject* watched, QEvent* event ) override;
void hideEvent( QHideEvent* event ) override;
void showEvent( QShowEvent* event ) override;
void resizeEvent( QResizeEvent* event ) override;
void keyPressEvent( QKeyEvent* event ) override;
void applyPlotTitleToQwt();
void applyAxisTitleToQwt( QwtPlot::Axis axis );
virtual void selectPoint( QwtPlotCurve* curve, int pointNumber );
@@ -125,7 +141,6 @@ protected:
virtual void endZoomOperations();
private:
void selectPlotOwner( bool toggleItemInSelection = false );
void selectClosestCurve( const QPoint& pos, bool toggleItemInSelection = false );
static int defaultMinimumWidth();
void replot() override;
@@ -145,8 +160,9 @@ private:
std::map<QwtPlot::Axis, QString> m_axisTitles;
std::map<QwtPlot::Axis, bool> m_axisTitlesEnabled;
QPointer<QwtPlotPicker> m_plotPicker;
bool m_draggable;
const int m_overlayMargins;
QString m_plotTitle;
bool m_plotTitleEnabled;
QList<QPointer<RiuDraggableOverlayFrame>> m_overlayFrames;

View File

@@ -92,8 +92,8 @@ static EnsembleCurveInfoTextProvider ensembleCurveInfoTextProvider;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimPlot* plotDefinition, QWidget* parent /*= nullptr*/ )
: RiuQwtPlotWidget( plotDefinition, parent )
RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*= nullptr*/ )
: RiuQwtPlotWidget( plot, parent )
{
// LeftButton for the zooming
m_zoomerLeft = new RiuQwtPlotZoomer( canvas() );
@@ -125,9 +125,6 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimPlot* plotDefinition, QWidget* parent /
RiuQwtPlotTools::setCommonPlotBehaviour( this );
RiuQwtPlotTools::setDefaultAxes( this );
this->installEventFilter( this );
this->canvas()->installEventFilter( this );
setLegendVisible( true );
}
@@ -156,14 +153,6 @@ void RiuSummaryQwtPlot::useTimeBasedTimeAxis()
setAxisScaleDraw( QwtPlot::xBottom, new QwtScaleDraw() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewWindow* RiuSummaryQwtPlot::ownerViewWindow() const
{
return dynamic_cast<RimViewWindow*>( plotDefinition() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -207,19 +196,6 @@ void RiuSummaryQwtPlot::setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithm
if ( m_wheelZoomer ) m_wheelZoomer->setAxisIsLogarithmic( axis, logarithmic );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuSummaryQwtPlot::keyPressEvent( QKeyEvent* keyEvent )
{
RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>( plotDefinition() );
if ( summaryPlot )
{
summaryPlot->handleKeyPressEvent( keyEvent );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -228,7 +204,7 @@ void RiuSummaryQwtPlot::contextMenuEvent( QContextMenuEvent* event )
QMenu menu;
caf::CmdFeatureMenuBuilder menuBuilder;
caf::SelectionManager::instance()->setSelectedItem( plotDefinition() );
emit plotSelected( false );
menuBuilder << "RicShowPlotDataFeature";
menuBuilder << "RicSavePlotTemplateFeature";
@@ -274,7 +250,5 @@ void RiuSummaryQwtPlot::endZoomOperations()
//--------------------------------------------------------------------------------------------------
void RiuSummaryQwtPlot::onZoomedSlot()
{
plotDefinition()->setAutoScaleXEnabled( false );
plotDefinition()->setAutoScaleYEnabled( false );
plotDefinition()->updateZoomFromQwt();
emit plotZoomed();
}

View File

@@ -27,6 +27,7 @@
#include <QPointer>
class RimEnsembleParameterColorHandlerInterface;
class RimSummaryPlot;
class RiuCvfOverlayItemWidget;
class RiuQwtPlotZoomer;
class RiuQwtPlotWheelZoomer;
@@ -36,12 +37,12 @@ class RiuQwtPlotWheelZoomer;
//
//
//==================================================================================================
class RiuSummaryQwtPlot : public RiuQwtPlotWidget, public RiuInterfaceToViewWindow
class RiuSummaryQwtPlot : public RiuQwtPlotWidget
{
Q_OBJECT;
public:
RiuSummaryQwtPlot( RimPlot* plotDefinition, QWidget* parent = nullptr );
RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent = nullptr );
~RiuSummaryQwtPlot() override;
void useDateBasedTimeAxis(
@@ -52,15 +53,15 @@ public:
void useTimeBasedTimeAxis();
RimViewWindow* ownerViewWindow() const override;
void setLegendFontSize( int fontSize );
void setLegendVisible( bool visible );
void setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithmic );
signals:
void plotZoomed();
protected:
void keyPressEvent( QKeyEvent* ) override;
void contextMenuEvent( QContextMenuEvent* ) override;
void setDefaults();
bool isZoomerActive() const override;

View File

@@ -73,22 +73,6 @@ void RiuWellLogPlot::renderTo( QPaintDevice* paintDevice )
m_trackScrollBar->setVisible( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::keyPressEvent( QKeyEvent* event )
{
wellLogPlotDefinition()->handleKeyPressEvent( event );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuWellLogPlot::willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const
{
return dynamic_cast<const RiuWellLogTrack*>( plotWidget ) != nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -131,7 +115,7 @@ void RiuWellLogPlot::slotSetMinDepth( int value )
double delta = value - minimumDepth;
wellLogPlotDefinition()->setDepthAxisRange( minimumDepth + delta, maximumDepth + delta );
wellLogPlotDefinition()->setAutoScaleYEnabled( false );
wellLogPlotDefinition()->setAutoScaleDepthEnabled( false );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -23,7 +23,7 @@
class RiuQwtPlotWidget;
class RimWellLogPlot;
class RiuWellLogPlot : public RiuMultiPlotPage, public RiuInterfaceToViewWindow
class RiuWellLogPlot : public RiuMultiPlotPage
{
Q_OBJECT
public:
@@ -35,8 +35,6 @@ public:
void renderTo( QPaintDevice* paintDevice ) override;
protected:
void keyPressEvent( QKeyEvent* event ) override;
bool willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const override;
bool showYAxis( int row, int column ) const override;
void reinsertScrollbar();

View File

@@ -27,14 +27,11 @@
#include <QWheelEvent>
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
#define RIU_SCROLLWHEEL_PANFACTOR 0.1
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget* parent /*= nullptr */ )
: RiuQwtPlotWidget( plotTrackDefinition, parent )
RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* track, QWidget* parent /*= nullptr */ )
: RiuQwtPlotWidget( track, parent )
{
setAxisEnabled( QwtPlot::yLeft, true );
setAxisEnabled( QwtPlot::yRight, false );
@@ -47,49 +44,6 @@ RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget*
//--------------------------------------------------------------------------------------------------
RiuWellLogTrack::~RiuWellLogTrack() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuWellLogTrack::eventFilter( QObject* watched, QEvent* event )
{
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>( event );
if ( wheelEvent && watched == canvas() )
{
RimWellLogTrack* track = dynamic_cast<RimWellLogTrack*>( plotDefinition() );
CAF_ASSERT( track );
RimWellLogPlot* wellLogPlot = nullptr;
track->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot )
{
if ( wheelEvent->modifiers() & Qt::ControlModifier )
{
QwtScaleMap scaleMap = canvasMap( QwtPlot::yLeft );
double zoomCenter = scaleMap.invTransform( wheelEvent->pos().y() );
if ( wheelEvent->delta() > 0 )
{
wellLogPlot->setDepthAxisRangeByFactorAndCenter( RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
}
else
{
wellLogPlot->setDepthAxisRangeByFactorAndCenter( 1.0 / RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
}
}
else
{
wellLogPlot->setDepthAxisRangeByPanDepth( wheelEvent->delta() < 0 ? RIU_SCROLLWHEEL_PANFACTOR
: -RIU_SCROLLWHEEL_PANFACTOR );
}
event->accept();
return true;
}
}
return RiuQwtPlotWidget::eventFilter( watched, event );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -21,6 +21,7 @@
#include "RiuQwtPlotWidget.h"
class RimWellLogTrack;
class QWheelEvent;
//==================================================================================================
//
@@ -32,12 +33,9 @@ class RiuWellLogTrack : public RiuQwtPlotWidget
Q_OBJECT
public:
RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget* parent = nullptr );
RiuWellLogTrack( RimWellLogTrack* track, QWidget* parent = nullptr );
~RiuWellLogTrack() override;
protected:
bool eventFilter( QObject* watched, QEvent* event ) override;
private:
void setAxisEnabled( QwtPlot::Axis axis, bool enabled );
};