1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
/*
* Analog and Digital Trace Viewing Widget
*
* This program 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.
*
* This program 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 for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (c) 2012-2019 Timothy Pearson
* Raptor Engineering
* http://www.raptorengineeringinc.com
*/
#ifndef REMOTELAB_TRACEWIDGET_H
#define REMOTELAB_TRACEWIDGET_H
#include <tqvbox.h>
#include <tqwidget.h>
#include <tqpushbutton.h>
#include <tqscrollview.h>
#include <tqtrla.h>
class TQPixmap;
class TQLabel;
class TQVBoxLayout;
class TQGridLayout;
class TraceWidgetPushButton;
class TQToolButton;
class TraceWidget;
class TraceLabelLayout;
class TraceCursorLabelLayout;
class TQRectF
{
public:
TQRectF();
TQRectF(double x, double y, double w, double h);
double x() const;
double y() const;
double width() const;
double height() const;
bool isNull() const;
bool operator!() const;
bool operator==(const TQRectF &r1);
bool operator!=(const TQRectF &r1);
void setX(double);
void setY(double);
void setWidth(double);
void setHeight(double);
private:
bool m_valid;
double m_x;
double m_y;
double m_w;
double m_h;
};
class TraceWidgetPushButton : public TQPushButton
{
Q_OBJECT
public:
TraceWidgetPushButton(TQWidget *parent, const char* name=0);
TraceWidgetPushButton(const TQString &text, TQWidget *parent, const char* name=0);
TraceWidgetPushButton(const TQIconSet& icon, const TQString &text, TQWidget *parent, const char* name=0);
~TraceWidgetPushButton();
public:
TQSize sizeHint() const;
};
typedef TQValueList<int> TraceNumberList;
class TraceData : public TQObject
{
Q_OBJECT
public:
TraceData(TraceWidget* parent, TQWidget* labelParent=0);
~TraceData();
void drawTrace(TQPainter* p, int graticule_width, int graticule_height, int virtual_width, int virtual_height);
public slots:
void movePosOneTick();
void moveNegOneTick();
void resetVPosition();
void setVPosition();
signals:
void offsetChanged(double offset);
private:
TQDoubleArray sampleArray;
TQDoubleArray positionArray;
unsigned int numberOfSamples;
double sampleMax;
double sampleMin;
double sampleAverage;
double minIndex;
double maxIndex;
long leftEdgeIndex;
long rightEdgeIndex;
double offset;
double textOffset;
TQColor color;
bool enabled;
double leftEdge;
double rightEdge;
double topEdge;
double bottomEdge;
TQString traceName;
TQString horizontalUnits;
TQString verticalUnits;
bool m_digitalTraceDrawing;
unsigned int m_digitalShaderDarkness;
bool m_suppressNameInCursorText;
TQLabel* paramLabel;
TQLabel* leftLabel;
TQLabel* leftCursorLabel;
TQLabel* graphStatusLabel;
TQLabel* graphStatusLabelInner;
TQToolButton* singleIncrBtn;
TQToolButton* singleDecrBtn;
TQToolButton* posResetBtn;
TQToolButton* posSetBtn;
TraceWidget* parentWidget;
friend class TraceWidget;
friend class GraticuleWidget;
friend class TraceLabelLayout;
friend class TraceCursorLabelLayout;
};
typedef TQMemArray<TraceData*> TraceList;
class CursorData : public TQObject
{
Q_OBJECT
public:
CursorData(TraceWidget* parent, TQWidget* labelParent=0);
~CursorData();
void drawCursor(TQPainter* p, int graticule_width, int graticule_height, int virtual_width, int virtual_height, int offset);
public slots:
void movePosOneTick();
void moveNegOneTick();
void movePosMultiTicks();
void moveNegMultiTicks();
protected:
virtual bool eventFilter(TQObject *o, TQEvent *e);
signals:
void positionChanged(double newPosition);
private:
TQColor color;
TQColor highlightColor;
bool highlighted;
bool enabled;
TQt::Orientation orientation;
double position;
TraceNumberList activeTraceLabelList;
TQString cursorName;
TQLabel* paramLabel;
TraceWidgetPushButton* singleIncrBtn;
TraceWidgetPushButton* singleDecrBtn;
TraceWidgetPushButton* multiIncrBtn;
TraceWidgetPushButton* multiDecrBtn;
TraceWidget* parentWidget;
friend class TraceWidget;
friend class GraticuleWidget;
};
typedef TQMemArray<CursorData*> CursorList;
class GraticuleWidget : public TQWidget
{
Q_OBJECT
public:
GraticuleWidget(TraceWidget*, const char* = 0);
~GraticuleWidget();
public:
virtual TQSizePolicy sizePolicy() const;
int virtualWidth();
bool userIsInteractingWithCursor();
protected:
virtual void paintEvent(TQPaintEvent*);
virtual void resizeEvent(TQResizeEvent *);
virtual void mousePressEvent(TQMouseEvent *);
virtual void mouseReleaseEvent(TQMouseEvent *);
virtual void mouseDoubleClickEvent(TQMouseEvent *);
virtual void mouseMoveEvent(TQMouseEvent *);
virtual void enterEvent(TQEvent *);
virtual void leaveEvent(TQEvent *);
signals:
void cursorPositionChanged(uint cursorNumber, double newPosition);
private slots:
void updateGraticule();
void horizScrollValueChanged(int value);
private:
TraceWidget* m_base;
TQPixmap* m_graticulePixmap;
int m_prevWidgetWidth;
int m_virtualWidth;
bool m_leftMouseDown;
bool m_middleMouseDown;
int m_closestCursor;
unsigned int m_closestCursorDistance;
int m_movingCursor;
double m_prevCursorPos;
TQPoint m_prevDownPos;
TQRectF m_prevCursorRect;
friend class TraceWidget;
friend class TraceData;
friend class CursorData;
};
class TraceWidget : public TQWidget
{
Q_OBJECT
public:
enum TextDisplayType {
FullText,
SummaryText,
NoText
};
public:
TraceWidget(TQWidget* = 0, const char* = 0);
~TraceWidget();
void setNumberOfSamples(uint traceNumber, unsigned int samples, bool deferUpdate=false);
void setNumberOfHorizontalDivisions(unsigned int divisions);
void setNumberOfVerticalDivisions(unsigned int divisions);
void setDisplayLimits(uint traceNumber, TQRectF limits, bool deferUpdate=false);
TQRectF displayLimits(uint traceNumber);
void setNumberOfTraces(uint traceNumber);
void setNumberOfCursors(uint traceNumber);
TQDoubleArray& samples(uint traceNumber);
void setSamples(uint traceNumber, TQDoubleArray&, bool deferUpdate=false);
TQDoubleArray& positions(uint traceNumber);
void setPositions(uint traceNumber, TQDoubleArray&, bool deferUpdate=false);
TQColor traceColor(uint traceNumber);
void setTraceColor(uint traceNumber, TQColor);
bool traceEnabled(uint traceNumber);
void setTraceEnabled(uint traceNumber, bool enabled, TextDisplayType showText=FullText, bool deferUpdate=false);
TQString traceName(uint traceNumber);
void setTraceName(uint traceNumber, TQString name, bool deferUpdate=false);
TQString traceHorizontalUnits(uint traceNumber);
void setTraceHorizontalUnits(uint traceNumber, TQString units, bool deferUpdate=false);
TQString traceVerticalUnits(uint traceNumber);
void setTraceVerticalUnits(uint traceNumber, TQString units, bool deferUpdate=false);
void setDigitalTraceMode(uint traceNumber, bool enabled, bool deferUpdate=false);
void suppressNameInCursorText(uint traceNumber, bool suppress, bool deferUpdate=false);
double cursorPosition(uint cursorNumber);
void setCursorPosition(uint cursorNumber, double position);
TQColor cursorColor(uint cursorNumber);
void setCursorColor(uint cursorNumber, TQColor);
TQColor cursorHighlightColor(uint cursorNumber);
void setCursorHighlightColor(uint cursorNumber, TQColor);
void setCursorActiveTraceList(uint cursorNumber, TraceNumberList list);
bool cursorEnabled(uint cursorNumber);
void setCursorEnabled(uint cursorNumber, bool enabled);
TQString cursorName(uint cursorNumber);
void setCursorName(uint cursorNumber, TQString name);
TQt::Orientation cursorOrientation(uint cursorNumber);
void setCursorOrientation(uint cursorNumber, TQt::Orientation orient);
void setTraceInfoCursor(uint cursorNumber);
void setHoverCursor(uint cursorNumber);
void setForegroundColor(const TQColor color);
void setBackgroundColor(const TQColor color);
TQRectF zoomBox();
void setZoomBoxEnabled(bool enabled);
TQRectF zoomCursorBox();
void setZoomCursorBox(const TQRectF rect);
unsigned int zoomCursorStartIndex();
void setZoomCursorStartIndex(unsigned int index);
void showLeftTraceInfoArea(bool show);
void showLeftCursorTraceInfoArea(bool show);
void fitLeftTraceInfoArea(bool fit);
void setLeftTraceInfoAreaFitSpacing(int spacing);
void showLeftCursorInfoArea(bool show);
void setMinimumPixelsPerHorizDiv(unsigned int pixels);
void setHorizCursorDirectClickEnabled(bool enabled);
double traceOffset(uint traceNumber);
void setTraceOffset(uint traceNumber, double offset, bool deferUpdate);
double traceTextOffset(uint traceNumber);
void setTraceTextOffset(uint traceNumber, double offset, bool deferUpdate);
bool userIsInteractingWithCursor();
static TQString prettyFormat(double value, double rangeDetectValue, TQString baseUnits, unsigned int precision=3);
virtual TQSize sizeHint() const;
virtual TQSize minimumSizeHint() const;
public slots:
void setTraceOffset(uint traceNumber, double offset);
void setTraceTextOffset(uint traceNumber, double offset);
private slots:
void updateTraceText();
void updateCursorText();
void processChangedOffset(double offset);
void processChangedCursor(uint cursorNumber, double newPosition);
void processChangedCusorPosition(double position);
signals:
void zoomBoxChanged(const TQRectF&);
void offsetChanged(uint traceNumber, double offset);
void cursorPositionChanged(uint cursorNumber, double newPosition);
void cursorDragged(uint cursorNumber, double newPosition);
private:
void resizeTraceArray(uint newsize);
void resizeCursorArray(uint newsize);
int horizScrollOffset();
private:
unsigned int m_horizDivs;
unsigned int m_vertDivs;
unsigned int m_cursorDarkness;
unsigned int m_zoomBoxDarkness;
unsigned int m_zoomCursorStartIndex;
bool m_zoomBoxEnabled;
bool m_horizCursorDirectClickEnabled;
TQRectF m_zoomBoxPrev;
TraceList m_traceArray;
CursorList m_cursorArray;
TQGridLayout* m_primaryLayout;
TQGridLayout* m_rightPaneLayout;
TQGridLayout* m_leftPaneLayout;
TQGridLayout* m_traceLabelLayout;
TQGridLayout* m_infoLabelLayout;
TQGridLayout* m_cursorLabelLayout;
TraceLabelLayout* m_traceLeftLabelLayout;
TraceCursorLabelLayout* m_traceLeftCursorLabelLayout;
TQVBoxLayout* m_statusLabelLayout;
TQVBoxLayout* m_statusLabelLayoutInner;
GraticuleWidget* m_graticuleWidget;
TQScrollBar* m_horizScrollBar;
bool m_useAbsoluteHorizontalRange;
bool m_showLeftTraceInfoArea;
bool m_showLeftCursorInfoArea;
unsigned int m_traceInfoCursor;
int m_hoverCursor;
bool m_leftTraceInfoLabelsFit;
int m_leftTraceInfoAreaFitSpacing;
unsigned int m_minimumPixelsPerHorizDiv;
friend class GraticuleWidget;
friend class TraceData;
friend class CursorData;
friend class TraceLabelLayout;
friend class TraceCursorLabelLayout;
friend class TraceScrollView;
friend class TraceScrollWidget;
};
class TraceScrollView : public TQScrollView
{
Q_OBJECT
public:
TraceScrollView(TQWidget* = 0, const char* = 0);
~TraceScrollView();
TraceWidget* traceWidget();
virtual TQSize sizeHint() const;
virtual TQSize minimumSizeHint() const;
private:
TraceWidget* m_traceWidget;
friend class TraceScrollWidget;
};
class TraceScrollWidget : public TQVBox
{
Q_OBJECT
public:
TraceScrollWidget(TQWidget* = 0, const char* = 0);
~TraceScrollWidget();
void setHScrollBarMode(TQScrollView::ScrollBarMode);
void setVScrollBarMode(TQScrollView::ScrollBarMode);
void setResizePolicy(TQScrollView::ResizePolicy);
TQScrollView::ResizePolicy resizePolicy() const;
TraceWidget* traceWidget();
private:
TraceScrollView* m_traceScrollView;
TQScrollBar* m_horizScrollBar;
TQScrollView::ScrollBarMode m_horizScrollBarMode;
};
#endif
|