OpenCurves  0.9
plotviewtoolbar.h
1 //
2 // author Kazys Stepanas
3 //
4 // Copyright (c) CSIRO 2015
5 //
6 #ifndef PLOTVIEWTOOLBAR_H_
7 #define PLOTVIEWTOOLBAR_H_
8 
9 #include "ocurvesui.h"
10 
11 #include <QToolBar>
12 
21 class PlotViewToolbar : public QToolBar
22 {
23  Q_OBJECT
24 public:
26  enum GroupId
27  {
28  GroupNone = -1,
29  GroupZoom = 0,
31  GroupCount
32  };
33 
35  enum ActionId
36  {
37  ActionInvalid = -1,
41 
45 
46  ActionCount
47  };
48 
51  explicit PlotViewToolbar(QWidget *parent = 0);
54 
58  QAction *action(ActionId actionId) const;
59 
64  ActionId actionId(const QAction *action) const;
65 
66 public slots:
72 
73 signals:
76  void active(ActionId actionId);
77 
78 private slots:
81  void actionChecked(bool checked);
82 
83 private:
85  struct CheckGroup
86  {
87  enum { Max = 4 };
88  QAction *actions[Max];
89 
91  inline CheckGroup()
92  {
93  actions[0] = nullptr;
94  }
95  };
96 
99  void initialiseActions();
100 
109  QAction *initialiseAction(QAction *action, ActionId actionId, GroupId groupId = GroupNone);
110 
115  CheckGroup *checkGroupFor(QAction *action);
116 
123  void ensureChecked(CheckGroup &group, ActionId defaultActionId);
124 
125  CheckGroup _checkGroups[GroupCount];
126 };
127 
128 #endif // PLOTVIEWTOOLBAR_H_
ActionId actionId(const QAction *action) const
Get the ActionId of the given action.
Select zoom and pan multi-tool.
Definition: plotviewtoolbar.h:42
~PlotViewToolbar()
Destructor.
A toolbar for use with PlotView objects.
Definition: plotviewtoolbar.h:21
Set zoom to Y axis only.
Definition: plotviewtoolbar.h:40
void active(ActionId actionId)
Signal emitted when an action becomes active.
Exclusive interaction tools.
Definition: plotviewtoolbar.h:30
GroupId
Various tool groupings for actions on the toolbar.
Definition: plotviewtoolbar.h:26
Select pan only tool.
Definition: plotviewtoolbar.h:44
Select zoom only tool.
Definition: plotviewtoolbar.h:43
Set zoom to X axis only.
Definition: plotviewtoolbar.h:39
PlotViewToolbar(QWidget *parent=0)
Constructor.
Set the zoom mode to X and Y.
Definition: plotviewtoolbar.h:38
Various zoom settings.
Definition: plotviewtoolbar.h:29
ActionId
IDs for the various actions on the toolbar.
Definition: plotviewtoolbar.h:35
QAction * action(ActionId actionId) const
Access an action on the toolbar by ActionId.
bool setActive(ActionId actionId)
Set the action associated with actionId to be active.