]> git.zerfleddert.de Git - proxmark3-svn/blob - client/proxguiqt.h
73f9286c39440ce9e58d2b3b8eff4bf68dbe73ca
[proxmark3-svn] / client / proxguiqt.h
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2009 Michael Gernoth <michael at gernoth.net>
3 //
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
6 // the license.
7 //-----------------------------------------------------------------------------
8 // GUI (QT)
9 //-----------------------------------------------------------------------------
10
11 #ifndef PROXGUI_QT
12 #define PROXGUI_QT
13
14 #include <stdint.h>
15 #include <string.h>
16
17 #include <QApplication>
18 #include <QPushButton>
19 #include <QObject>
20 #include <QWidget>
21 #include <QPainter>
22 #include <QtGui>
23
24 #include "ui/ui_overlays.h"
25 /**
26 * @brief The actual plot, black area were we paint the graph
27 */
28 class Plot: public QWidget
29 {
30 private:
31 int GraphStart;
32 double GraphPixelsPerPoint;
33 int CursorAPos;
34 int CursorBPos;
35 void PlotGraph(int *buffer, int len, QRect r,QRect r2, QPainter* painter, int graphNum);
36 void PlotDemod(uint8_t *buffer, size_t len, QRect r,QRect r2, QPainter* painter, int graphNum, int plotOffset);
37 void plotGridLines(QPainter* painter,QRect r);
38 int xCoordOf(int i, QRect r );
39 int yCoordOf(int v, QRect r, int maxVal);
40 int valueOf_yCoord(int y, QRect r, int maxVal);
41 void setMaxAndStart(int *buffer, int len, QRect plotRect);
42 QColor getColor(int graphNum);
43 public:
44 Plot(QWidget *parent = 0);
45
46 protected:
47 void paintEvent(QPaintEvent *event);
48 void closeEvent(QCloseEvent *event);
49 void mouseMoveEvent(QMouseEvent *event);
50 void mousePressEvent(QMouseEvent *event) { mouseMoveEvent(event); }
51 void keyPressEvent(QKeyEvent *event);
52
53 };
54 class ProxGuiQT;
55
56 /**
57 * The window with plot and controls
58 */
59 class ProxWidget : public QWidget
60 {
61 Q_OBJECT; //needed for slot/signal classes
62
63 private:
64 ProxGuiQT *master;
65 Plot *plot;
66 Ui::Form *opsController;
67 QWidget* controlWidget;
68
69 public:
70 ProxWidget(QWidget *parent = 0, ProxGuiQT *master = NULL);
71 ~ProxWidget(void);
72 //OpsShow(void);
73
74 protected:
75 // void paintEvent(QPaintEvent *event);
76 void closeEvent(QCloseEvent *event);
77 void showEvent(QShowEvent *event);
78 void hideEvent(QHideEvent *event);
79 // void mouseMoveEvent(QMouseEvent *event);
80 // void mousePressEvent(QMouseEvent *event) { mouseMoveEvent(event); }
81 // void keyPressEvent(QKeyEvent *event);
82 public slots:
83 void applyOperation();
84 void stickOperation();
85 void vchange_autocorr(int v);
86 void vchange_askedge(int v);
87 void vchange_dthr_up(int v);
88 void vchange_dthr_down(int v);
89 };
90
91 class ProxGuiQT : public QObject
92 {
93 Q_OBJECT;
94
95 private:
96 QApplication *plotapp;
97 ProxWidget *plotwidget;
98 int argc;
99 char **argv;
100 void (*main_func)(void);
101
102 public:
103 ProxGuiQT(int argc, char **argv);
104 ~ProxGuiQT(void);
105 void ShowGraphWindow(void);
106 void RepaintGraphWindow(void);
107 void HideGraphWindow(void);
108 void MainLoop(void);
109 void Exit(void);
110 private slots:
111 void _ShowGraphWindow(void);
112 void _RepaintGraphWindow(void);
113 void _HideGraphWindow(void);
114 void _Exit(void);
115 signals:
116 void ShowGraphWindowSignal(void);
117 void RepaintGraphWindowSignal(void);
118 void HideGraphWindowSignal(void);
119 void ExitSignal(void);
120 };
121
122
123 class WorkerThread : public QThread {
124 Q_OBJECT;
125 public:
126 WorkerThread(char*, bool);
127 ~WorkerThread();
128 void run();
129 private:
130 char *script_cmds_file = NULL;
131 bool usb_present = false;
132 };
133
134 #endif // PROXGUI_QT
Impressum, Datenschutz