QtPdWidgets  2.3.1
Graph.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2009 - 2012 Florian Pose <fp@igh-essen.com>
4  *
5  * This file is part of the QtPdWidgets library.
6  *
7  * The QtPdWidgets library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation, either version 3 of the License,
10  * or (at your option) any later version.
11  *
12  * The QtPdWidgets library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with the QtPdWidgets Library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  *
21  ****************************************************************************/
22 
23 #ifndef PD_GRAPH_H
24 #define PD_GRAPH_H
25 
26 #include "Export.h"
27 #include <QtPdCom1/Transmission.h>
28 
29 #include <pdcom5/Variable.h>
30 #include <pdcom5/Process.h>
31 #include <pdcom5/Subscription.h>
32 
33 #include <QFrame>
34 #include <QIcon>
35 #include <QAction>
36 
37 namespace Pd {
38 
39 /****************************************************************************/
40 
43 class PD_PUBLIC Graph: public QFrame
44 {
45  Q_OBJECT
46  Q_ENUMS(Mode TriggerLevelMode)
47  Q_PROPERTY(Mode mode
48  READ getMode WRITE setMode RESET resetMode)
50  Q_PROPERTY(double timeRange
51  READ getTimeRange WRITE setTimeRange RESET resetTimeRange)
53  Q_PROPERTY(double scaleMin
54  READ getScaleMin WRITE setScaleMin RESET resetScaleMin)
56  Q_PROPERTY(double scaleMax
57  READ getScaleMax WRITE setScaleMax RESET resetScaleMax)
58  Q_PROPERTY(TriggerLevelMode triggerLevelMode
59  READ getTriggerLevelMode WRITE setTriggerLevelMode
60  RESET resetTriggerLevelMode)
61  Q_PROPERTY(double manualTriggerLevel
62  READ getManualTriggerLevel WRITE setManualTriggerLevel
63  RESET resetManualTriggerLevel)
64  Q_PROPERTY(double triggerPosition
65  READ getTriggerPosition WRITE setTriggerPosition
66  RESET resetTriggerPosition)
67  Q_PROPERTY(double triggerTimeout
68  READ getTriggerTimeout WRITE setTriggerTimeout
69  RESET resetTriggerTimeout)
70  Q_PROPERTY(QString suffix
71  READ getSuffix WRITE setSuffix RESET resetSuffix)
72  Q_PROPERTY(QColor gridColor
73  READ getGridColor WRITE setGridColor RESET resetGridColor)
74  Q_PROPERTY(bool autoScaleWidth
75  READ getAutoScaleWidth WRITE setAutoScaleWidth
76  RESET resetAutoScaleWidth)
77 
78  public:
79  Graph(QWidget *parent = 0);
80  virtual ~Graph();
81 
84  void setVariable(
85  PdCom::Variable pv,
86  const PdCom::Selector &selector = {},
87  const QtPdCom::Transmission & = QtPdCom::event_mode,
88  double scale = 1.0,
89  double offset = 0.0,
90  double tau = 0.0,
93  QColor color = Qt::blue
94  );
95  void setVariable(
96  PdCom::Process *process,
97  const QString &path,
98  const PdCom::Selector &selector = {},
99  const QtPdCom::Transmission & = QtPdCom::event_mode,
100  double scale = 1.0,
101  double offset = 0.0,
102  double tau = 0.0,
105  QColor color = Qt::blue
106  );
107  void addVariable(
108  PdCom::Variable pv,
109  const PdCom::Selector &selector = {},
110  const QtPdCom::Transmission & = QtPdCom::event_mode,
111  double scale = 1.0,
112  double offset = 0.0,
113  double tau = 0.0,
116  QColor color = Qt::blue
117  );
118  void addVariable(
119  PdCom::Process *process,
120  const QString &path,
121  const PdCom::Selector &selector = {},
122  const QtPdCom::Transmission & = QtPdCom::event_mode,
123  double scale = 1.0,
124  double offset = 0.0,
125  double tau = 0.0,
128  QColor color = Qt::blue
129  );
130  void clearVariables();
131  void clearData();
132 
135  void setTriggerVariable(
136  PdCom::Variable pv,
137  const PdCom::Selector &selector = {},
138  const QtPdCom::Transmission & = QtPdCom::event_mode,
139  double scale = 1.0,
140  double offset = 0.0,
141  double tau = 0.0
144  );
147  void setTriggerVariable(
148  PdCom::Process *process,
149  const QString &path,
150  const PdCom::Selector &selector = {},
151  const QtPdCom::Transmission & = QtPdCom::event_mode,
152  double scale = 1.0,
153  double offset = 0.0,
154  double tau = 0.0
157  );
158  void clearTriggerVariable();
159 
164  enum Mode {
165  Roll,
168  Trigger
173  };
174  Mode getMode() const;
175  void setMode(Mode);
176  void resetMode();
177  double getTimeRange() const;
178  void setTimeRange(double);
179  void resetTimeRange();
180  double getScaleMin() const;
181  void setScaleMin(double);
182  void resetScaleMin();
183  double getScaleMax() const;
184  void setScaleMax(double);
185  void resetScaleMax();
192  ManualLevel
193  };
194  TriggerLevelMode getTriggerLevelMode() const;
195  void setTriggerLevelMode(TriggerLevelMode);
196  void resetTriggerLevelMode();
197  double getManualTriggerLevel() const;
198  void setManualTriggerLevel(double);
199  void resetManualTriggerLevel();
200  double getTriggerPosition() const;
201  void setTriggerPosition(double);
202  void resetTriggerPosition();
203  double getTriggerTimeout() const;
204  void setTriggerTimeout(double);
205  void resetTriggerTimeout();
206  QString getSuffix() const;
207  void setSuffix(const QString &);
208  void resetSuffix();
209  QColor getGridColor() const;
210  void setGridColor(const QColor &);
211  void resetGridColor();
212  bool getAutoScaleWidth() const;
213  void setAutoScaleWidth(bool);
214  void resetAutoScaleWidth();
215 
216  Mode getEffectiveMode() const;
217 
218  virtual QSize sizeHint() const;
219 
222  enum State {
223  Run,
224  Stop,
226  };
227  bool getState() const;
228  void setState(State);
229  void toggleState();
230 
231  protected:
232  bool event(QEvent *) override;
233  void resizeEvent(QResizeEvent *) override;
234  void paintEvent(QPaintEvent *) override;
235  void contextMenuEvent(QContextMenuEvent *) override;
236 
237  private slots:
238  PD_PRIVATE void redrawEvent();
239  PD_PRIVATE void run();
240  PD_PRIVATE void stop();
241 
242  private:
243  struct PD_PRIVATE Impl;
244  std::unique_ptr<Impl> impl;
245 
247  friend class Layer;
248 
249  PD_PRIVATE void setRedraw();
250  PD_PRIVATE void notifySampled();
251 
253  friend class TriggerDetector;
254 
255  PD_PRIVATE void triggerConditionDetected(std::chrono::nanoseconds);
256  PD_PRIVATE void triggerIdle();
257 };
258 
259 /****************************************************************************/
260 
261 } // namespace
262 
263 #endif
Definition: Graph.cpp:436
Automatic trigger level calculation.
Definition: Graph.h:191
Definition: Bar.h:36
#define PD_PRIVATE
Definition: Export.h:28
Definition: Graph.cpp:61
#define PD_PUBLIC
Definition: Export.h:33
std::unique_ptr< Impl > impl
Definition: Graph.h:244
Graph widget.
Definition: Graph.h:43
Incoming data shall be displayed immediately.
Definition: Graph.h:223
State
Graph state.
Definition: Graph.h:222
Definition: Graph.cpp:594
TriggerLevelMode
Trigger level mode.
Definition: Graph.h:190
Mode
Graph mode.
Definition: Graph.h:164