Create Grid plot collection and allow creation of new combination plots

This commit is contained in:
Gaute Lindkvist
2019-10-31 13:48:40 +01:00
parent e042b2d17b
commit 30db19a1d0
55 changed files with 1208 additions and 597 deletions

View File

@@ -459,7 +459,7 @@ bool RiuDragDrop::handleGridPlotWindowDrop( Qt::DropAction action,
insertAfter = dynamic_cast<RimPlotInterface*>( visibleTracks[insertAfterPosition] );
}
}
RicWellLogPlotTrackFeatureImpl::movePlotsToGridPlotWindow( gridPlotWindow, plots, insertAfter );
gridPlotWindow->movePlotsToThis( plots, insertAfter );
return true;
}
}

View File

@@ -107,7 +107,7 @@ RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimPlotInterface* plotDefinition, QWid
this->installEventFilter( this );
this->canvas()->installEventFilter( this );
setLegendVisible( true );
setInternalQwtLegendVisible( true );
}
//--------------------------------------------------------------------------------------------------
@@ -268,9 +268,9 @@ void RiuGridCrossQwtPlot::setLegendFontSize( int fontSize )
}
//--------------------------------------------------------------------------------------------------
///
/// The internal qwt legend is not used in grid plot windows
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::setLegendVisible( bool visible )
void RiuGridCrossQwtPlot::setInternalQwtLegendVisible( bool visible )
{
if ( visible )
{

View File

@@ -61,7 +61,7 @@ public:
RimViewWindow* ownerViewWindow() const override;
void setLegendFontSize( int fontSize );
void setLegendVisible( bool visible );
void setInternalQwtLegendVisible( bool visible );
protected:
void updateLayout() override;

View File

@@ -78,8 +78,8 @@ RiuGridPlotWindow::RiuGridPlotWindow( RimGridPlotWindow* plotDefinition, QWidget
m_plotLayout->addWidget( m_plotWidgetFrame, 1 );
m_gridLayout = new QGridLayout( m_plotWidgetFrame );
m_gridLayout->setMargin( 0 );
m_gridLayout->setSpacing( 2 );
m_gridLayout->setContentsMargins( 1, 1, 1, 1 );
m_gridLayout->setSpacing( 1 );
QPalette newPalette( palette() );
newPalette.setColor( QPalette::Background, Qt::white );
@@ -87,15 +87,15 @@ RiuGridPlotWindow::RiuGridPlotWindow( RimGridPlotWindow* plotDefinition, QWidget
setAutoFillBackground( true );
m_scrollBar = new QScrollBar( nullptr );
m_scrollBar->setOrientation( Qt::Vertical );
m_scrollBar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
m_scrollBarLayout = new QVBoxLayout;
m_scrollBarLayout->addWidget( m_scrollBar, 0 );
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 );
@@ -105,6 +105,8 @@ RiuGridPlotWindow::RiuGridPlotWindow( RimGridPlotWindow* plotDefinition, QWidget
RiaApplication* app = RiaApplication::instance();
int defaultFontSize = RiaFontCache::pointSizeFromFontSizeEnum( app->preferences()->defaultPlotFontSize() );
setFontSize( defaultFontSize );
this->setObjectName( QString( "%1" ).arg( reinterpret_cast<uint64_t>( this ) ) );
}
//--------------------------------------------------------------------------------------------------
@@ -149,9 +151,12 @@ void RiuGridPlotWindow::addPlot( RiuQwtPlotWidget* plotWidget )
void RiuGridPlotWindow::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 );
QLabel* subTitle = new QLabel( plotWidget->plotDefinition()->description() );
subTitle->setAlignment( Qt::AlignRight );
m_subTitles.insert( static_cast<int>( index ), subTitle );
RiuQwtPlotLegend* legend = new RiuQwtPlotLegend( this );
int legendColumns = 1;
if ( m_plotDefinition->legendsHorizontal() )
@@ -170,6 +175,7 @@ void RiuGridPlotWindow::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
plotWidget->updateLegend();
m_legends.insert( static_cast<int>( index ), legend );
m_legendColumns.insert( static_cast<int>( index ), -1 );
scheduleUpdate();
}
@@ -202,28 +208,6 @@ void RiuGridPlotWindow::setPlotTitle( const QString& plotTitle )
m_plotTitle->setText( plotTitle );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiuGridPlotWindow::preferredWidth() const
{
int titleWidth = 0;
if ( m_plotTitle && m_plotTitle->isVisible() )
{
titleWidth = m_plotTitle->width();
}
QList<QPointer<RiuQwtPlotWidget>> visiblePlotWidgets = this->visiblePlotWidgets();
auto rowAndColumnCount = this->rowAndColumnCount( visiblePlotWidgets.size() );
int sumColumnWidths = 0;
for ( int visibleIndex = 0; visibleIndex < rowAndColumnCount.second; ++visibleIndex )
{
sumColumnWidths += visiblePlotWidgets[visibleIndex]->width();
}
return std::max( titleWidth, sumColumnWidths );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -232,14 +216,6 @@ void RiuGridPlotWindow::setTitleVisible( bool visible )
m_plotTitle->setVisible( visible );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridPlotWindow::setScrollbarVisible( bool visible )
{
m_scrollBar->setVisible( visible );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -390,8 +366,10 @@ void RiuGridPlotWindow::showEvent( QShowEvent* event )
//--------------------------------------------------------------------------------------------------
void RiuGridPlotWindow::dragEnterEvent( QDragEnterEvent* event )
{
if ( this->geometry().contains( event->pos() ) )
RiuQwtPlotWidget* source = dynamic_cast<RiuQwtPlotWidget*>( event->source() );
if ( source )
{
setWidgetState( RiuWidgetStyleSheet::DRAG_TARGET_INTO );
event->acceptProposedAction();
}
}
@@ -401,11 +379,13 @@ void RiuGridPlotWindow::dragEnterEvent( QDragEnterEvent* event )
//--------------------------------------------------------------------------------------------------
void RiuGridPlotWindow::dragMoveEvent( QDragMoveEvent* event )
{
if ( this->geometry().contains( event->pos() ) )
if ( event->answerRect().intersects( this->geometry() ) )
{
RiuQwtPlotWidget* source = dynamic_cast<RiuQwtPlotWidget*>( event->source() );
if ( source )
if ( source && willAcceptDroppedPlot( source ) )
{
setWidgetState( RiuWidgetStyleSheet::DRAG_TARGET_INTO );
QRect originalGeometry = source->geometry();
QPoint offset = source->dragStartPosition();
QRect newRect( event->pos() - offset, originalGeometry.size() );
@@ -431,9 +411,8 @@ void RiuGridPlotWindow::dragMoveEvent( QDragMoveEvent* event )
{
int insertAfterIndex = insertBeforeIndex - 1;
visiblePlotWidgets[insertAfterIndex]->setWidgetState( RiuWidgetStyleSheet::DRAG_TARGET_AFTER );
event->acceptProposedAction();
}
event->acceptProposedAction();
}
}
}
@@ -443,6 +422,8 @@ void RiuGridPlotWindow::dragMoveEvent( QDragMoveEvent* event )
//--------------------------------------------------------------------------------------------------
void RiuGridPlotWindow::dragLeaveEvent( QDragLeaveEvent* event )
{
setWidgetState( RiuWidgetStyleSheet::DEFAULT );
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
{
m_plotWidgets[tIdx]->setWidgetState( RiuWidgetStyleSheet::DEFAULT );
@@ -454,6 +435,8 @@ void RiuGridPlotWindow::dragLeaveEvent( QDragLeaveEvent* event )
//--------------------------------------------------------------------------------------------------
void RiuGridPlotWindow::dropEvent( QDropEvent* event )
{
setWidgetState( RiuWidgetStyleSheet::DEFAULT );
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
{
m_plotWidgets[tIdx]->setWidgetState( RiuWidgetStyleSheet::DEFAULT );
@@ -463,7 +446,7 @@ void RiuGridPlotWindow::dropEvent( QDropEvent* event )
{
RiuQwtPlotWidget* source = dynamic_cast<RiuQwtPlotWidget*>( event->source() );
if ( source )
if ( source && willAcceptDroppedPlot( source ) )
{
event->acceptProposedAction();
@@ -489,21 +472,34 @@ void RiuGridPlotWindow::dropEvent( QDropEvent* event )
insertAfter = m_plotWidgets[beforeIndex - 1]->plotDefinition();
}
RimPlotInterface* plotWidget = source->plotDefinition();
RimPlotInterface* plotToMove = source->plotDefinition();
if ( insertAfter != plotWidget )
if ( insertAfter != plotToMove )
{
RicWellLogPlotTrackFeatureImpl::movePlotsToGridPlotWindow( m_plotDefinition, { plotWidget }, insertAfter );
m_plotDefinition->movePlotsToThis( { plotToMove }, insertAfter );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuGridPlotWindow::willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<int, int> RiuGridPlotWindow::rowAndColumnCount( int plotWidgetCount ) const
{
if ( plotWidgetCount == 0 )
{
return std::make_pair( 0, 0 );
}
int columnCount = std::max( 1, std::min( m_plotDefinition->columnCount(), plotWidgetCount ) );
int rowCount = static_cast<int>( std::ceil( plotWidgetCount / static_cast<double>( columnCount ) ) );
return std::make_pair( rowCount, columnCount );
@@ -516,6 +512,8 @@ void RiuGridPlotWindow::onSelectionManagerSelectionChanged( const std::set<int>&
{
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
{
CAF_ASSERT( plotWidget );
bool isSelected = false;
for ( int changedLevel : changedSelectionLevels )
{
@@ -536,21 +534,115 @@ void RiuGridPlotWindow::onSelectionManagerSelectionChanged( const std::set<int>&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridPlotWindow::performUpdate()
void RiuGridPlotWindow::setWidgetState( RiuWidgetStyleSheet::StateTag widgetState )
{
reinsertPlotWidgetsAndScrollbar();
alignCanvasTopsAndScrollbar();
m_dropTargetStyleSheet.setWidgetState( m_dropTargetPlaceHolder, widgetState );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridPlotWindow::alignCanvasTopsAndScrollbar()
bool RiuGridPlotWindow::showYAxis( int row, int column ) const
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridPlotWindow::performUpdate()
{
reinsertPlotWidgets();
alignCanvasTops();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridPlotWindow::reinsertPlotWidgets()
{
clearGridLayout();
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
{
m_plotWidgets[tIdx]->hide();
m_legends[tIdx]->hide();
}
QList<QPointer<QLabel>> subTitles = this->visibleTitles();
QList<QPointer<RiuQwtPlotLegend>> legends = this->visibleLegends();
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets();
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() );
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
{
int row = visibleIndex / rowAndColumnCount.second;
int column = visibleIndex % rowAndColumnCount.second;
m_gridLayout->addWidget( subTitles[visibleIndex], 3 * row, column );
m_gridLayout->addWidget( legends[visibleIndex], 3 * row + 1, column );
m_gridLayout->addWidget( plotWidgets[visibleIndex], 3 * row + 2, column );
subTitles[visibleIndex]->setVisible( m_plotDefinition->showPlotTitles() );
if ( m_plotDefinition->legendsVisible() )
{
int legendColumns = 1;
if ( m_plotDefinition->legendsHorizontal() )
{
legendColumns = 0; // unlimited
}
legends[visibleIndex]->setMaxColumns( legendColumns );
int minimumHeight = legends[visibleIndex]->heightForWidth( plotWidgets[visibleIndex]->width() );
legends[visibleIndex]->setMinimumHeight( minimumHeight );
QFont legendFont = legends[visibleIndex]->font();
legendFont.setPointSize( m_plotDefinition->legendFontSize() );
legends[visibleIndex]->setFont( legendFont );
legends[visibleIndex]->show();
}
else
{
legends[visibleIndex]->hide();
}
plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft, showYAxis( row, column ) );
plotWidgets[visibleIndex]->setAxisTitleEnabled( QwtPlot::yLeft, showYAxis( row, column ) );
plotWidgets[visibleIndex]->show();
int widthScaleFactor = plotWidgets[visibleIndex]->widthScaleFactor();
if ( showYAxis( row, column ) )
{
widthScaleFactor += 1; // Give it a bit extra room due to axis
}
m_gridLayout->setColumnStretch( column,
std::max( m_gridLayout->columnStretch( column ),
plotWidgets[visibleIndex]->widthScaleFactor() ) );
m_gridLayout->setRowStretch( 3 * row + 2, 1 );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiuGridPlotWindow::alignCanvasTops()
{
CVF_ASSERT( m_legends.size() == m_plotWidgets.size() );
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = visiblePlotWidgets();
if ( plotWidgets.empty() ) return;
if ( plotWidgets.empty() ) return 0;
auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() );
@@ -570,73 +662,7 @@ void RiuGridPlotWindow::alignCanvasTopsAndScrollbar()
int row = visibleIndex / rowAndColumnCount.second;
plotWidgets[visibleIndex]->axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( maxExtents[row] );
}
m_scrollBarLayout->setContentsMargins( 0, maxExtents[0], 0, 0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridPlotWindow::reinsertPlotWidgetsAndScrollbar()
{
clearGridLayout();
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
{
m_plotWidgets[tIdx]->hide();
m_legends[tIdx]->hide();
}
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets();
QList<QPointer<RiuQwtPlotLegend>> legends = this->visibleLegends();
auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() );
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
{
int row = visibleIndex / rowAndColumnCount.second;
int column = visibleIndex % rowAndColumnCount.second;
m_gridLayout->addWidget( legends[visibleIndex], 2 * row, column );
m_gridLayout->addWidget( plotWidgets[visibleIndex], 2 * row + 1, column );
if ( m_plotDefinition->legendsVisible() )
{
int legendColumns = 1;
if ( m_plotDefinition->legendsHorizontal() )
{
legendColumns = 0; // unlimited
}
legends[visibleIndex]->setMaxColumns( legendColumns );
int minimumHeight = legends[visibleIndex]->heightForWidth( plotWidgets[visibleIndex]->width() );
legends[visibleIndex]->setMinimumHeight( minimumHeight );
QFont legendFont = legends[visibleIndex]->font();
legendFont.setPointSize( fontSize() - 1 );
legends[visibleIndex]->setFont( legendFont );
legends[visibleIndex]->show();
}
else
{
legends[visibleIndex]->hide();
}
plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft, column == 0 );
plotWidgets[visibleIndex]->setAxisTitleEnabled( QwtPlot::yLeft, column == 0 );
plotWidgets[visibleIndex]->show();
int widthScaleFactor = plotWidgets[visibleIndex]->widthScaleFactor();
if ( column == 0 )
{
widthScaleFactor += 1; // Give it a bit extra room due to axis
}
m_gridLayout->setColumnStretch( column,
std::max( m_gridLayout->columnStretch( column ),
plotWidgets[visibleIndex]->widthScaleFactor() ) );
m_gridLayout->setRowStretch( 2 * row + 1, 1 );
}
m_gridLayout->addLayout( m_scrollBarLayout, 1, rowAndColumnCount.second, rowAndColumnCount.first * 2 - 1, 1 );
m_gridLayout->setColumnStretch( rowAndColumnCount.second, 0 );
m_scrollBar->setVisible( plotWidgets.size() > 0 );
return maxExtents[0];
}
//--------------------------------------------------------------------------------------------------
@@ -648,6 +674,7 @@ void RiuGridPlotWindow::clearGridLayout()
{
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
{
m_gridLayout->removeWidget( m_subTitles[tIdx] );
m_gridLayout->removeWidget( m_legends[tIdx] );
m_gridLayout->removeWidget( m_plotWidgets[tIdx] );
}
@@ -662,6 +689,22 @@ void RiuGridPlotWindow::clearGridLayout()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWidgetStyleSheet RiuGridPlotWindow::createDropTargetStyleSheet()
{
RiuWidgetStyleSheet styleSheet;
styleSheet.set( "background-color", "white" );
styleSheet.set( "border", "1px dashed black" );
styleSheet.set( "font-size", "14pt" );
styleSheet.state( RiuWidgetStyleSheet::DRAG_TARGET_INTO ).set( "border", "1px dashed lime" );
styleSheet.state( RiuWidgetStyleSheet::DRAG_TARGET_INTO ).set( "background-color", "#DDFFDD" );
return styleSheet;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -693,3 +736,19 @@ QList<QPointer<RiuQwtPlotLegend>> RiuGridPlotWindow::visibleLegends() const
}
return legends;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<QPointer<QLabel>> RiuGridPlotWindow::visibleTitles() const
{
QList<QPointer<QLabel>> subTitles;
for ( int i = 0; i < m_plotWidgets.size(); ++i )
{
if ( m_plotWidgets[i]->isChecked() )
{
subTitles.push_back( m_subTitles[i] );
}
}
return subTitles;
}

View File

@@ -20,6 +20,7 @@
#pragma once
#include "RiuInterfaceToViewWindow.h"
#include "RiuWidgetStyleSheet.h"
#include "cafPdmPointer.h"
#include "cafSelectionChangedReceiver.h"
@@ -64,10 +65,8 @@ public:
void removePlot( RiuQwtPlotWidget* plotWidget );
void setPlotTitle( const QString& plotTitle );
int preferredWidth() const;
void setTitleVisible( bool visible );
void setScrollbarVisible( bool visible );
void setSelectionsVisible( bool visible );
void setFontSize( int fontSize );
@@ -84,27 +83,34 @@ protected:
void keyPressEvent( QKeyEvent* keyEvent ) override;
QLabel* createTitleLabel() const;
void resizeEvent( QResizeEvent* event ) override;
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;
void resizeEvent( QResizeEvent* event ) override;
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;
virtual bool willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const;
std::pair<int, int> rowAndColumnCount( int plotWidgetCount ) const;
virtual void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override;
private slots:
void performUpdate();
void setWidgetState( RiuWidgetStyleSheet::StateTag widgetState );
private:
void alignCanvasTopsAndScrollbar();
void reinsertPlotWidgetsAndScrollbar();
void clearGridLayout();
virtual bool showYAxis( int row, int column ) const;
void reinsertPlotWidgets();
int alignCanvasTops();
void clearGridLayout();
RiuWidgetStyleSheet createDropTargetStyleSheet();
QList<QPointer<RiuQwtPlotWidget>> visiblePlotWidgets() const;
QList<QPointer<RiuQwtPlotLegend>> visibleLegends() const;
QList<QPointer<QLabel>> visibleTitles() const;
private slots:
virtual void performUpdate();
protected:
QPointer<QVBoxLayout> m_layout;
@@ -112,12 +118,14 @@ protected:
QPointer<QFrame> m_plotWidgetFrame;
QPointer<QGridLayout> m_gridLayout;
QPointer<QLabel> m_plotTitle;
QPointer<QVBoxLayout> m_scrollBarLayout;
QScrollBar* m_scrollBar;
QList<QPointer<RiuQwtPlotLegend>> m_legends;
QList<int> m_legendColumns;
QList<QPointer<QLabel>> m_subTitles;
QList<QPointer<RiuQwtPlotLegend>> m_legends;
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
caf::PdmPointer<RimGridPlotWindow> m_plotDefinition;
QPointer<QLabel> m_dropTargetPlaceHolder;
RiuWidgetStyleSheet m_dropTargetStyleSheet;
private:
friend class RiaPlotWindowRedrawScheduler;

View File

@@ -158,6 +158,7 @@ void RiuPlotMainWindow::cleanupGuiBeforeProjectClose()
m_wellLogPlotToolBarEditor->clear();
m_summaryPlotToolBarEditor->clear();
m_gridPlotWindowToolBarEditor->clear();
setWindowTitle( "Plots - ResInsight" );
}
@@ -381,6 +382,9 @@ void RiuPlotMainWindow::createToolBars()
m_summaryPlotToolBarEditor = new caf::PdmUiToolBarEditor( "Summary Plot", this );
m_summaryPlotToolBarEditor->hide();
m_gridPlotWindowToolBarEditor = new caf::PdmUiToolBarEditor( "Combination Plot", this );
m_gridPlotWindowToolBarEditor->hide();
}
//--------------------------------------------------------------------------------------------------
@@ -546,7 +550,6 @@ void RiuPlotMainWindow::updateWellLogPlotToolBar()
{
std::vector<caf::PdmFieldHandle*> toolBarFields;
toolBarFields = wellLogPlot->commonDataSource()->fieldsToShowInToolbar();
toolBarFields.push_back( wellLogPlot->columnCountField() );
m_wellLogPlotToolBarEditor->setFields( toolBarFields );
m_wellLogPlotToolBarEditor->updateUi();
@@ -563,12 +566,39 @@ void RiuPlotMainWindow::updateWellLogPlotToolBar()
refreshToolbars();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::updateGridPlotWindowToolBar()
{
RimGridPlotWindow* plotWindow = dynamic_cast<RimGridPlotWindow*>( m_activePlotViewWindow.p() );
if ( plotWindow )
{
std::vector<caf::PdmFieldHandle*> toolBarFields = { plotWindow->columnCountField() };
m_gridPlotWindowToolBarEditor->setFields( toolBarFields );
m_gridPlotWindowToolBarEditor->updateUi();
m_gridPlotWindowToolBarEditor->show();
}
else
{
m_gridPlotWindowToolBarEditor->clear();
m_gridPlotWindowToolBarEditor->hide();
}
refreshToolbars();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::updateSummaryPlotToolBar( bool forceUpdateUi )
{
RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>( m_activePlotViewWindow.p() );
RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>( m_activePlotViewWindow.p() );
RimGridPlotWindow* gridPlotWindow = dynamic_cast<RimGridPlotWindow*>( m_activePlotViewWindow.p() );
if ( gridPlotWindow )
{
summaryPlot = caf::SelectionManager::instance()->selectedItemOfType<RimSummaryPlot>();
}
if ( summaryPlot )
{
std::vector<caf::PdmFieldHandle*> toolBarFields = summaryPlot->fieldsToShowInToolbar();
@@ -631,15 +661,7 @@ void RiuPlotMainWindow::addViewer( QWidget* viewer, const RimMdiWindowGeometry&
}
else
{
RiuGridPlotWindow* wellLogPlot = dynamic_cast<RiuGridPlotWindow*>( viewer );
if ( wellLogPlot )
{
subWindowSize = QSize( wellLogPlot->preferredWidth(), m_mdiArea->height() );
}
else
{
subWindowSize = QSize( 400, 400 );
}
subWindowSize = QSize( 400, 400 );
}
addViewerToMdiArea( m_mdiArea, viewer, subWindowPos, subWindowSize );
@@ -695,6 +717,7 @@ void RiuPlotMainWindow::slotSubWindowActivated( QMdiSubWindow* subWindow )
updateWellLogPlotToolBar();
updateSummaryPlotToolBar();
updateGridPlotWindowToolBar();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -80,6 +80,7 @@ public:
void addToTemporaryWidgets( QWidget* widget );
void updateWellLogPlotToolBar();
void updateGridPlotWindowToolBar();
void updateSummaryPlotToolBar( bool forceUpdateUi = false );
void setFocusToLineEditInSummaryToolBar();
@@ -120,6 +121,7 @@ private:
QMenu* m_windowMenu;
caf::PdmUiToolBarEditor* m_wellLogPlotToolBarEditor;
caf::PdmUiToolBarEditor* m_gridPlotWindowToolBarEditor;
caf::PdmUiToolBarEditor* m_summaryPlotToolBarEditor;
std::unique_ptr<caf::PdmUiDragDropInterface> m_dragDropInterface;

View File

@@ -61,7 +61,7 @@
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlotInterface* plotTrackDefinition, QWidget* parent )
: QwtPlot( parent )
, m_draggable( false )
, m_draggable( true )
{
m_plotOwner = dynamic_cast<caf::PdmObject*>( plotTrackDefinition );
CAF_ASSERT( m_plotOwner );
@@ -178,7 +178,6 @@ void RiuQwtPlotWidget::setEnabledAxes( const std::set<QwtPlot::Axis> enabledAxes
axisScaleDraw( axis )->setMinimumExtent( axisExtent( axis ) );
setMinimumWidth( defaultMinimumWidth() );
axisScaleDraw( axis )->enableComponent( QwtAbstractScaleDraw::Backbone, false );
axisWidget( axis )->setMargin( 0 );
m_axisTitlesEnabled[axis] = true;
}
@@ -196,13 +195,6 @@ void RiuQwtPlotWidget::setEnabledAxes( const std::set<QwtPlot::Axis> enabledAxes
void RiuQwtPlotWidget::setAxisTitleText( QwtPlot::Axis axis, const QString& title )
{
m_axisTitles[axis] = title;
QwtText axisTitleText = axisTitle( axis );
if ( title != axisTitleText.text() )
{
axisTitleText.setText( title );
setAxisTitle( axis, axisTitleText );
}
applyAxisTitleToQwt( axis );
}
@@ -568,10 +560,11 @@ void RiuQwtPlotWidget::showEvent( QShowEvent* event )
void RiuQwtPlotWidget::applyAxisTitleToQwt( QwtPlot::Axis axis )
{
QString titleToApply = m_axisTitlesEnabled[axis] ? m_axisTitles[axis] : QString( "" );
QwtText axisTitle = this->axisTitle( QwtPlot::yLeft );
QwtText axisTitle = this->axisTitle( axis );
if ( titleToApply != axisTitle.text() )
{
axisTitle.setText( titleToApply );
setAxisTitle( axis, axisTitle );
if ( axis == QwtPlot::yLeft || axis == QwtPlot::yRight )
{
@@ -613,7 +606,7 @@ void RiuQwtPlotWidget::onAxisSelected( QwtScaleWidget* scale, bool toggleItemInS
RiuWidgetStyleSheet RiuQwtPlotWidget::createPlotStyleSheet() const
{
QColor backgroundColor = QColor( "white" );
QColor highlightColor = this->palette().highlight().color();
QColor highlightColor = QApplication::palette().highlight().color();
QColor blendedHighlightColor = RiaColorTools::blendQColors( highlightColor, backgroundColor, 1, 5 );
QColor nearlyBackgroundColor = RiaColorTools::blendQColors( highlightColor, backgroundColor, 1, 30 );
@@ -645,7 +638,7 @@ RiuWidgetStyleSheet RiuQwtPlotWidget::createCanvasStyleSheet() const
{
RiuWidgetStyleSheet styleSheet;
styleSheet.set( "background-color", "#FAFAFA" );
styleSheet.set( "border", "1px solid black" );
styleSheet.set( "border", "1px solid LightGray" );
return styleSheet;
}

View File

@@ -3,6 +3,9 @@
#include "RimPlotWindow.h"
#include "RimWellLogPlot.h"
#include "RiuQwtPlotWidget.h"
#include "RiuWellLogTrack.h"
#include "cafAssert.h"
#include "cafPdmPointer.h"
@@ -14,7 +17,22 @@
RiuWellLogPlot::RiuWellLogPlot( RimWellLogPlot* plotDefinition, QWidget* parent )
: RiuGridPlotWindow( plotDefinition, parent )
{
connect( m_scrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) );
m_trackScrollBar = new QScrollBar( nullptr );
m_trackScrollBar->setOrientation( Qt::Vertical );
m_trackScrollBar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
m_trackScrollBarLayout = new QVBoxLayout;
m_trackScrollBarLayout->addWidget( m_trackScrollBar, 0 );
connect( m_trackScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuWellLogPlot::isScrollbarVisible() const
{
return m_trackScrollBar->isVisible();
}
//--------------------------------------------------------------------------------------------------
@@ -27,6 +45,14 @@ RimWellLogPlot* RiuWellLogPlot::wellLogPlotDefinition()
return wellLogPlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::setScrollbarVisible( bool visible )
{
m_trackScrollBar->setVisible( visible );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -36,14 +62,53 @@ void RiuWellLogPlot::updateVerticalScrollBar( double minVisible, double maxVisib
double visibleRange = maxVisible - minVisible;
m_scrollBar->blockSignals( true );
m_trackScrollBar->blockSignals( true );
{
m_scrollBar->setRange( (int)minAvailable, (int)( ( maxAvailable - visibleRange ) ) );
m_scrollBar->setPageStep( (int)visibleRange );
m_scrollBar->setValue( (int)minVisible );
m_scrollBar->setVisible( true );
m_trackScrollBar->setRange( (int)minAvailable, (int)( ( maxAvailable - visibleRange ) ) );
m_trackScrollBar->setPageStep( (int)visibleRange );
m_trackScrollBar->setValue( (int)minVisible );
m_trackScrollBar->setVisible( true );
}
m_scrollBar->blockSignals( false );
m_trackScrollBar->blockSignals( false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuWellLogPlot::willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const
{
return dynamic_cast<const RiuWellLogTrack*>( plotWidget ) != nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuWellLogPlot::showYAxis( int row, int column ) const
{
return column == 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::reinsertScrollbar()
{
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets();
QList<QPointer<RiuQwtPlotLegend>> legends = this->visibleLegends();
auto rowAndColumnCount = this->rowAndColumnCount( plotWidgets.size() );
m_trackScrollBar->setVisible( !plotWidgets.empty() );
m_gridLayout->addLayout( m_trackScrollBarLayout, 2, rowAndColumnCount.second, rowAndColumnCount.first * 2 - 1, 1 );
m_gridLayout->setColumnStretch( rowAndColumnCount.second, 0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::alignScrollbar( int offset )
{
m_trackScrollBarLayout->setContentsMargins( 0, offset, 0, 0 );
}
//--------------------------------------------------------------------------------------------------
@@ -59,3 +124,14 @@ void RiuWellLogPlot::slotSetMinDepth( int value )
wellLogPlotDefinition()->setDepthAxisRange( minimumDepth + delta, maximumDepth + delta );
wellLogPlotDefinition()->setAutoScaleYEnabled( false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::performUpdate()
{
reinsertPlotWidgets();
reinsertScrollbar();
int axisShift = alignCanvasTops();
alignScrollbar( axisShift );
}

View File

@@ -19,6 +19,7 @@
#include "RiuGridPlotWindow.h"
class RiuQwtPlotWidget;
class RimWellLogPlot;
class RiuWellLogPlot : public RiuGridPlotWindow
@@ -26,11 +27,26 @@ class RiuWellLogPlot : public RiuGridPlotWindow
Q_OBJECT
public:
RiuWellLogPlot( RimWellLogPlot* plotDefinition, QWidget* parent );
void updateVerticalScrollBar( double minVisible, double maxVisible, double minAvailable, double maxAvailable );
bool isScrollbarVisible() const;
void setScrollbarVisible( bool visible );
void updateVerticalScrollBar( double minVisible, double maxVisible, double minAvailable, double maxAvailable ) override;
protected:
bool willAcceptDroppedPlot( const RiuQwtPlotWidget* plotWidget ) const override;
bool showYAxis( int row, int column ) const override;
void reinsertScrollbar();
void alignScrollbar( int offset );
private:
RimWellLogPlot* wellLogPlotDefinition();
private slots:
void slotSetMinDepth( int value );
void performUpdate() override;
private:
QPointer<QVBoxLayout> m_trackScrollBarLayout;
QScrollBar* m_trackScrollBar;
};

View File

@@ -183,7 +183,7 @@ void RiuWidgetStyleSheet::refreshWidget( QWidget* widget ) const
QString RiuWidgetStyleSheet::buildStateString( StateTag state )
{
QString stateString;
if ( state > PSEUDO_STATE_LIMIT )
if ( state >= PSEUDO_STATE_LIMIT )
{
stateString += ":" + StateTagEnum::uiText( state );
}