///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2015- Statoil ASA // Copyright (C) 2015- Ceetron Solutions AS // // 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 // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include "RiuInterfaceToViewWindow.h" #include "cafPdmPointer.h" #include "cafSelectionChangedReceiver.h" #include #include #include #include #include #include #include class RiaPlotWindowRedrawScheduler; class RimGridPlotWindow; class RiuQwtPlotLegend; class RiuQwtPlotWidget; class QFocusEvent; class QLabel; class QScrollBar; //================================================================================================== // // RiuGridPlotWindow // //================================================================================================== class RiuGridPlotWindow : public QWidget, public RiuInterfaceToViewWindow, public caf::SelectionChangedReceiver { Q_OBJECT public: RiuGridPlotWindow( RimGridPlotWindow* plotDefinition, QWidget* parent = nullptr ); ~RiuGridPlotWindow() override; RimGridPlotWindow* ownerPlotDefinition(); RimViewWindow* ownerViewWindow() const override; void addPlot( RiuQwtPlotWidget* plotWidget ); void insertPlot( RiuQwtPlotWidget* plotWidget, size_t index ); 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 ); int fontSize() const; int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget ); void scheduleUpdate(); void scheduleReplotOfAllPlots(); virtual void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) {} protected: void contextMenuEvent( QContextMenuEvent* ) override; 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; std::pair rowAndColumnCount( int plotWidgetCount ) const; virtual void onSelectionManagerSelectionChanged( const std::set& changedSelectionLevels ) override; private slots: void performUpdate(); private: void alignCanvasTopsAndScrollbar(); void reinsertPlotWidgetsAndScrollbar(); void clearGridLayout(); QList> visiblePlotWidgets() const; QList> visibleLegends() const; protected: QPointer m_layout; QPointer m_plotLayout; QPointer m_plotWidgetFrame; QPointer m_gridLayout; QPointer m_plotTitle; QPointer m_scrollBarLayout; QScrollBar* m_scrollBar; QList> m_legends; QList m_legendColumns; QList> m_plotWidgets; caf::PdmPointer m_plotDefinition; private: friend class RiaPlotWindowRedrawScheduler; };