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