OpenCurves  0.9
splitplotview.h
1 //
2 // author Kazys Stepanas
3 //
4 // Copyright (c) CSIRO 2015
5 //
6 #ifndef SPLITPLOTVIEW_H_
7 #define SPLITPLOTVIEW_H_
8 
9 #include "ocurvesconfig.h"
10 
11 #include <QList>
12 #include <QWidget>
13 
14 class Curves;
15 class PlotView;
16 class QSettings;
17 class QSplitter;
18 
33 class SplitPlotView : public QWidget
34 {
35  Q_OBJECT
36 public:
40  SplitPlotView(Curves *curves, QWidget *parent = nullptr);
41 
45  void loadSettings(QSettings &settings);
46 
72  void saveSettings(QSettings &settings);
73 
78  inline PlotView *activeView() const { return _activeView; }
79 
82  bool hasSplits() const;
83 
85  void replot();
86 
89  void collate(QVector<PlotView *> &views);
90 
95  void collateActive(QStringList &sourceNames, QStringList &curveNames, const PlotView *exclude = nullptr);
96 
97 signals:
98 
101  void viewAdded(PlotView *view);
102  //void viewRemoved(PlotView *view);
103 
107  void activeViewChanged(PlotView *newView, PlotView *oldView);
108 
117  void syncPan(int x, int y);
118 
120  void multiToolModeSet();
121 
123  void panToolModeSet();
124 
126  void zoomToolModeSet();
127 
129  void zoomXSet();
130 
132  void zoomYSet();
133 
135  void zoomXYSet();
136 
137 public slots:
139  void splitVertical();
140 
142  void splitHorizontal();
143 
145  void splitRemove();
146 
148  void splitRemoveAll();
149 
151  void setMultiTool();
152 
154  void setPanTool();
155 
157  void setZoomTool();
158 
160  void setZoomX();
161 
163  void setZoomY();
164 
166  void setZoomXY();
167 
168 private slots:
170  void viewFocusGained();
171 
181  void viewSyncChanged(bool sync);
182 
183  // Events only for internal propagation to child views.
184 
187  void viewToolModeChanged(int mode);
188 
191  void viewZoomModeChanged(int mode);
192 
193 private:
197  void setActiveView(PlotView *view);
198 
205  static PlotView *findFirstView(QWidget *widget);
206 
216  static QWidget *relevantChild(const QSplitter *split, int index);
217 
220  static inline QWidget *left(const QSplitter *split) { return relevantChild(split, 0); }
221 
224  static inline QWidget *right(const QSplitter *split) { return relevantChild(split, 1); }
225 
231  void initialiseView(PlotView *view, const PlotView *referenceView = nullptr);
232 
238  void initialiseSplit(QSplitter *split);
239 
247  void initialiseSplit(QSplitter *split, PlotView *view);
248 
253  void saveBranch(QSettings &settings, QWidget *branch);
254 
269  QWidget *loadTree(QSettings &settings, QWidget *parent, PlotView *&activeView);
270 
274  QWidget *_root;
275  PlotView *_activeView;
276  Curves *_curves;
277  QList<PlotView *> _synchedViews;
278  bool _suppressEvents;
279 };
280 
281 #endif // SPLITPLOTVIEW_H_
void setMultiTool()
Set the current tool to PlotView::MultiTool. Affects all child views.
void setZoomX()
Set the current zoom mode to PlotZoomer::ZoomX. Affects all child views.
void zoomToolModeSet()
Raised when the PlotView::ToolMode is changed to PlotView::ZoomTool.
bool hasSplits() const
Does the view have any splits?
void splitRemoveAll()
Remove all splits, keeping only the current plot view.
void loadSettings(QSettings &settings)
Load settings for the split view, as saved by saveSettings().
void saveSettings(QSettings &settings)
Saves settings for the split view supporting restoring to the same state.
void zoomYSet()
Raised when the PlotZoomer::ZoomMode is changed to PlotZoomer::ZoomY.
void zoomXSet()
Raised when the PlotZoomer::ZoomMode is changed to PlotZoomer::ZoomX.
void syncPan(int x, int y)
Signals panning from a child PlotView where PlotView::synchronised() is set.
void splitVertical()
Split the active plot view vertically.
void replot()
Re-plot all views within the splitter tree.
void splitRemove()
Remove the current split.
void collate(QVector< PlotView * > &views)
Collate all contained views.
An plot view viewing a Curves model.
Definition: plotview.h:36
void setZoomY()
Set the current zoom mode to PlotZoomer::ZoomY. Affects all child views.
void multiToolModeSet()
Raised when the PlotView::ToolMode is changed to PlotView::MultiTool.
The data model for loaded plots and curves.
Definition: curves.h:36
void activeViewChanged(PlotView *newView, PlotView *oldView)
Raised when the activeView() changes.
void panToolModeSet()
Raised when the PlotView::ToolMode is changed to PlotView::PanTool.
void collateActive(QStringList &sourceNames, QStringList &curveNames, const PlotView *exclude=nullptr)
Collates the list of source and curve names being viewed by any active view.
SplitPlotView(Curves *curves, QWidget *parent=nullptr)
Create a split view containing exactly one PlotView.
PlotView * activeView() const
Access the active view.
Definition: splitplotview.h:78
void setZoomTool()
Set the current tool to PlotView::ZoomTool. Affects all child views.
A special plotting view which can contain multiple splits, each with its own PlotView.
Definition: splitplotview.h:33
void zoomXYSet()
Raised when the PlotZoomer::ZoomMode is changed to PlotZoomer::ZoomBoth.
void setPanTool()
Set the current tool to PlotView::PanTool. Affects all child views.
void setZoomXY()
Set the current zoom mode to PlotZoomer::ZoomBoth. Affects all child views.
void splitHorizontal()
Split the active plot view horizontally.
void viewAdded(PlotView *view)
Raised when a new view is created due to a new split.