1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
17 //-----------------------------------------------------------------------------
25 #include <QApplication>
26 #include <QPushButton>
34 #include "ui/ui_overlays.h"
35 #include "ui/ui_image.h"
40 * @brief The actual plot, black area were we paint the graph
42 class Plot
: public QWidget
{
43 Q_OBJECT
; //needed for slot/signal classes
47 double g_GraphPixelsPerPoint
; // How many visual pixels are between each sample point (x axis)
48 void PlotGraph(int *buffer
, size_t len
, QRect plotRect
, QRect annotationRect
, QPainter
*painter
, int graphNum
);
49 void PlotDemod(uint8_t *buffer
, size_t len
, QRect plotRect
, QRect annotationRect
, QPainter
*painter
, int graphNum
, uint32_t plotOffset
);
50 void plotGridLines(QPainter
*painter
, QRect r
);
51 void plotOperations(int *buffer
, size_t len
, QPainter
*painter
, QRect rect
);
52 void drawAnnotations(QRect annotationRect
, QPainter
*painter
);
53 void draw_marker(marker_t marker
, QRect plotRect
, QColor color
, QPainter
*painter
);
54 int xCoordOf(int i
, QRect r
);
55 int yCoordOf(int v
, QRect r
, int maxVal
);
56 int valueOf_yCoord(int y
, QRect r
, int maxVal
);
57 void setMaxAndStart(int *buffer
, size_t len
, QRect plotRect
);
58 void appendMax(int *buffer
, size_t len
, QRect plotRect
);
59 QColor
getColor(int graphNum
);
62 Plot(QWidget
*parent
= 0);
65 void Zoom(double factor
, uint32_t refX
);
66 void MoveTo(uint32_t pos
);
68 void Move(int offset
);
71 void paintEvent(QPaintEvent
*event
);
72 void closeEvent(QCloseEvent
*event
);
74 void wheelEvent(QWheelEvent
*event
);
75 void mouseMoveEvent(QMouseEvent
*event
);
76 void mousePressEvent(QMouseEvent
*event
) { mouseMoveEvent(event
); }
77 void keyPressEvent(QKeyEvent
*event
);
80 void startMaxChanged(uint32_t startMax
);
81 void graphStartChanged(uint32_t graphStart
);
85 // Added class for SliderWidget to allow move/resize event override
86 class SliderWidget
: public QWidget
{
88 void resizeEvent(QResizeEvent
*event
);
89 void moveEvent(QMoveEvent
*event
);
94 // Added class for SliderWidget to allow move/resize event override
95 class PictureWidget
: public QWidget
{
97 void closeEvent(QCloseEvent
*event
);
103 * The window with plot and controls
106 class ProxWidget
: public QWidget
{
107 Q_OBJECT
; //needed for slot/signal classes
112 Ui::Form
*opsController
;
113 SliderWidget
*controlWidget
;
117 ProxWidget(QWidget
*parent
= 0, ProxGuiQT
*master
= NULL
);
122 // void paintEvent(QPaintEvent *event);
123 void closeEvent(QCloseEvent
*event
);
124 void showEvent(QShowEvent
*event
);
125 void hideEvent(QHideEvent
*event
);
126 void moveEvent(QMoveEvent
*event
);
127 void resizeEvent(QResizeEvent
*event
);
128 // void mouseMoveEvent(QMouseEvent *event);
129 // void mousePressEvent(QMouseEvent *event) { mouseMoveEvent(event); }
130 // void keyPressEvent(QKeyEvent *event);
132 void applyOperation();
133 void stickOperation();
134 void vchange_autocorr(int v
);
135 void vchange_askedge(int v
);
136 void vchange_dthr_up(int v
);
137 void vchange_dthr_down(int v
);
138 void updateNavSlider(void);
141 class WorkerThread
: public QThread
{
144 WorkerThread(char *, char *, bool);
148 char *script_cmds_file
;
150 bool stayInCommandLoop
;
153 class ProxGuiQT
: public QObject
{
157 QApplication
*plotapp
;
158 ProxWidget
*plotwidget
;
159 Ui::PictureForm
*pictureController
;
160 PictureWidget
*pictureWidget
;
164 //void (*main_func)(void);
165 WorkerThread
*proxmarkThread
;
168 ProxGuiQT(int argc
, char **argv
, WorkerThread
*wthread
);
170 void ShowGraphWindow(void);
171 void RepaintGraphWindow(void);
172 void HideGraphWindow(void);
174 // hook up picture viewer
175 void ShowPictureWindow(const QImage
&img
);
176 void ShowBase64PictureWindow(char *b64
);
177 void HidePictureWindow(void);
178 void RepaintPictureWindow(void);
184 void _ShowGraphWindow(void);
185 void _RepaintGraphWindow(void);
186 void _HideGraphWindow(void);
188 // hook up picture viewer
189 void _ShowPictureWindow(const QImage
&img
);
190 void _ShowBase64PictureWindow(char *b64
);
191 void _HidePictureWindow(void);
192 void _RepaintPictureWindow(void);
195 void _StartProxmarkThread(void);
198 void ShowGraphWindowSignal(void);
199 void RepaintGraphWindowSignal(void);
200 void HideGraphWindowSignal(void);
201 void ExitSignal(void);
203 // hook up picture viewer signals
204 void ShowPictureWindowSignal(const QImage
&img
);
205 void ShowBase64PictureWindowSignal(char *b64
);
206 void HidePictureWindowSignal(void);
207 void RepaintPictureWindowSignal(void);