fix little endian vs big endian in the macros... again... but this time correct
[RRG-proxmark3.git] / client / src / proxguiqt.h
blob168b1b9ebd5bd59aac621d7ada824aa78c92228b
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 //-----------------------------------------------------------------------------
11 #ifndef PROXGUI_QT
12 #define PROXGUI_QT
14 #include <stdint.h>
15 #include <string.h>
17 #include <QApplication>
18 #include <QPushButton>
19 #include <QObject>
20 #include <QWidget>
21 #include <QPainter>
22 #include <QtGui>
24 #include "ui/ui_overlays.h"
26 class ProxWidget;
28 /**
29 * @brief The actual plot, black area were we paint the graph
31 class Plot: public QWidget {
32 private:
33 QWidget *master;
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)
37 uint32_t CursorAPos;
38 uint32_t CursorBPos;
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);
48 public:
49 Plot(QWidget *parent = 0);
51 protected:
52 void paintEvent(QPaintEvent *event);
53 void closeEvent(QCloseEvent *event);
54 void Zoom(double factor, uint32_t refX);
55 void Move(int offset);
56 void Trim(void);
57 void wheelEvent(QWheelEvent *event);
58 void mouseMoveEvent(QMouseEvent *event);
59 void mousePressEvent(QMouseEvent *event) { mouseMoveEvent(event); }
60 void keyPressEvent(QKeyEvent *event);
62 class ProxGuiQT;
64 // Added class for SliderWidget to allow move/resize event override
65 class SliderWidget : public QWidget {
66 protected:
67 void resizeEvent(QResizeEvent *event);
68 void moveEvent(QMoveEvent *event);
69 public:
70 SliderWidget();
73 /**
74 * The window with plot and controls
77 class ProxWidget : public QWidget {
78 Q_OBJECT; //needed for slot/signal classes
80 private:
81 ProxGuiQT *master;
82 Plot *plot;
83 Ui::Form *opsController;
84 // QWidget *controlWidget;
85 SliderWidget *controlWidget;
86 public:
87 ProxWidget(QWidget *parent = 0, ProxGuiQT *master = NULL);
88 ~ProxWidget(void);
89 //OpsShow(void);
91 protected:
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);
101 public slots:
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 {
111 Q_OBJECT;
112 public:
113 WorkerThread(char *, char *, bool);
114 ~WorkerThread();
115 void run();
116 private:
117 char *script_cmds_file;
118 char *script_cmd;
119 bool stayInCommandLoop;
122 class ProxGuiQT : public QObject {
123 Q_OBJECT;
125 private:
126 QApplication *plotapp;
127 ProxWidget *plotwidget;
128 int argc;
129 char **argv;
130 //void (*main_func)(void);
131 WorkerThread *proxmarkThread;
133 public:
134 ProxGuiQT(int argc, char **argv, WorkerThread *wthread);
135 ~ProxGuiQT(void);
136 void ShowGraphWindow(void);
137 void RepaintGraphWindow(void);
138 void HideGraphWindow(void);
139 void MainLoop(void);
140 void Exit(void);
142 private slots:
143 void _ShowGraphWindow(void);
144 void _RepaintGraphWindow(void);
145 void _HideGraphWindow(void);
146 void _Exit(void);
147 void _StartProxmarkThread(void);
149 signals:
150 void ShowGraphWindowSignal(void);
151 void RepaintGraphWindowSignal(void);
152 void HideGraphWindowSignal(void);
153 void ExitSignal(void);
156 #endif // PROXGUI_QT