style
[RRG-proxmark3.git] / client / src / proxguiqt.h
blob6e7f8efb134e7376ef7aadbdb8fcd44f8f8416da
1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
3 //
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.
8 //
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 //-----------------------------------------------------------------------------
16 // GUI (QT)
17 //-----------------------------------------------------------------------------
19 #ifndef PROXGUI_QT
20 #define PROXGUI_QT
22 #include <stdint.h>
23 #include <string.h>
25 #include <QApplication>
26 #include <QPushButton>
27 #include <QObject>
28 #include <QWidget>
29 #include <QPainter>
30 #include <QtGui>
32 #include "proxgui.h"
33 #include "graph.h"
34 #include "ui/ui_overlays.h"
35 #include "ui/ui_image.h"
37 class ProxWidget;
39 /**
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
45 private:
46 QWidget *master;
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);
61 public:
62 Plot(QWidget *parent = 0);
64 public slots:
65 void Zoom(double factor, uint32_t refX);
66 void MoveTo(uint32_t pos);
67 void MoveTo(int pos);
68 void Move(int offset);
70 protected:
71 void paintEvent(QPaintEvent *event);
72 void closeEvent(QCloseEvent *event);
73 void Trim(void);
74 void wheelEvent(QWheelEvent *event);
75 void mouseMoveEvent(QMouseEvent *event);
76 void mousePressEvent(QMouseEvent *event) { mouseMoveEvent(event); }
77 void keyPressEvent(QKeyEvent *event);
79 signals:
80 void startMaxChanged(uint32_t startMax);
81 void graphStartChanged(uint32_t graphStart);
83 class ProxGuiQT;
85 // Added class for SliderWidget to allow move/resize event override
86 class SliderWidget : public QWidget {
87 protected:
88 void resizeEvent(QResizeEvent *event);
89 void moveEvent(QMoveEvent *event);
90 public:
91 SliderWidget();
94 // Added class for SliderWidget to allow move/resize event override
95 class PictureWidget : public QWidget {
96 protected:
97 void closeEvent(QCloseEvent *event);
98 public:
99 PictureWidget();
103 * The window with plot and controls
106 class ProxWidget : public QWidget {
107 Q_OBJECT; //needed for slot/signal classes
109 private:
110 ProxGuiQT *master;
111 Plot *plot;
112 Ui::Form *opsController;
113 SliderWidget *controlWidget;
114 QSlider *navSlider;
116 public:
117 ProxWidget(QWidget *parent = 0, ProxGuiQT *master = NULL);
118 ~ProxWidget(void);
119 //OpsShow(void);
121 protected:
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);
131 public slots:
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 {
142 Q_OBJECT;
143 public:
144 WorkerThread(char *, char *, bool);
145 ~WorkerThread();
146 void run();
147 private:
148 char *script_cmds_file;
149 char *script_cmd;
150 bool stayInCommandLoop;
153 class ProxGuiQT : public QObject {
154 Q_OBJECT;
156 private:
157 QApplication *plotapp;
158 ProxWidget *plotwidget;
159 Ui::PictureForm *pictureController;
160 PictureWidget *pictureWidget;
162 int argc;
163 char **argv;
164 //void (*main_func)(void);
165 WorkerThread *proxmarkThread;
167 public:
168 ProxGuiQT(int argc, char **argv, WorkerThread *wthread);
169 ~ProxGuiQT(void);
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);
180 void MainLoop(void);
181 void Exit(void);
183 private slots:
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);
194 void _Exit(void);
195 void _StartProxmarkThread(void);
197 signals:
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);
210 #endif // PROXGUI_QT