1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2009 Michael Gernoth <michael at gernoth.net>
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
9 //-----------------------------------------------------------------------------
17 #include <QApplication>
18 #include <QPushButton>
24 #include "ui/ui_overlays.h"
29 * @brief The actual plot, black area were we paint the graph
31 class Plot
: public QWidget
{
34 uint32_t GraphStart
; // Starting point/offset for the left side of the graph
35 uint32_t GraphStop
; // Stop point/offset for the right side of the graph
36 double GraphPixelsPerPoint
; // How many visual pixels are between each sample point (x axis)
39 void PlotGraph(int *buffer
, size_t len
, QRect plotRect
, QRect annotationRect
, QPainter
*painter
, int graphNum
);
40 void PlotDemod(uint8_t *buffer
, size_t len
, QRect plotRect
, QRect annotationRect
, QPainter
*painter
, int graphNum
, uint32_t plotOffset
);
41 void plotGridLines(QPainter
*painter
, QRect r
);
42 int xCoordOf(int i
, QRect r
);
43 int yCoordOf(int v
, QRect r
, int maxVal
);
44 int valueOf_yCoord(int y
, QRect r
, int maxVal
);
45 void setMaxAndStart(int *buffer
, size_t len
, QRect plotRect
);
46 QColor
getColor(int graphNum
);
49 Plot(QWidget
*parent
= 0);
52 void paintEvent(QPaintEvent
*event
);
53 void closeEvent(QCloseEvent
*event
);
54 void Zoom(double factor
, uint32_t refX
);
55 void Move(int offset
);
57 void wheelEvent(QWheelEvent
*event
);
58 void mouseMoveEvent(QMouseEvent
*event
);
59 void mousePressEvent(QMouseEvent
*event
) { mouseMoveEvent(event
); }
60 void keyPressEvent(QKeyEvent
*event
);
64 // Added class for SliderWidget to allow move/resize event override
65 class SliderWidget
: public QWidget
{
67 void resizeEvent(QResizeEvent
*event
);
68 void moveEvent(QMoveEvent
*event
);
74 * The window with plot and controls
77 class ProxWidget
: public QWidget
{
78 Q_OBJECT
; //needed for slot/signal classes
83 Ui::Form
*opsController
;
84 // QWidget *controlWidget;
85 SliderWidget
*controlWidget
;
87 ProxWidget(QWidget
*parent
= 0, ProxGuiQT
*master
= NULL
);
92 // void paintEvent(QPaintEvent *event);
93 void closeEvent(QCloseEvent
*event
);
94 void showEvent(QShowEvent
*event
);
95 void hideEvent(QHideEvent
*event
);
96 void moveEvent(QMoveEvent
*event
);
97 void resizeEvent(QResizeEvent
*event
);
98 // void mouseMoveEvent(QMouseEvent *event);
99 // void mousePressEvent(QMouseEvent *event) { mouseMoveEvent(event); }
100 // void keyPressEvent(QKeyEvent *event);
102 void applyOperation();
103 void stickOperation();
104 void vchange_autocorr(int v
);
105 void vchange_askedge(int v
);
106 void vchange_dthr_up(int v
);
107 void vchange_dthr_down(int v
);
110 class WorkerThread
: public QThread
{
113 WorkerThread(char *, char *, bool);
117 char *script_cmds_file
;
119 bool stayInCommandLoop
;
122 class ProxGuiQT
: public QObject
{
126 QApplication
*plotapp
;
127 ProxWidget
*plotwidget
;
130 //void (*main_func)(void);
131 WorkerThread
*proxmarkThread
;
134 ProxGuiQT(int argc
, char **argv
, WorkerThread
*wthread
);
136 void ShowGraphWindow(void);
137 void RepaintGraphWindow(void);
138 void HideGraphWindow(void);
143 void _ShowGraphWindow(void);
144 void _RepaintGraphWindow(void);
145 void _HideGraphWindow(void);
147 void _StartProxmarkThread(void);
150 void ShowGraphWindowSignal(void);
151 void RepaintGraphWindowSignal(void);
152 void HideGraphWindowSignal(void);
153 void ExitSignal(void);