]> git.zerfleddert.de Git - proxmark3-svn/blame - client/proxguiqt.cpp
combine autocorr, dirth functions
[proxmark3-svn] / client / proxguiqt.cpp
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
6658905f 11#include <iostream>
12#include <QPainterPath>
13#include <QBrush>
14#include <QPen>
15#include <QTimer>
16#include <QCloseEvent>
17#include <QMouseEvent>
18#include <QKeyEvent>
19#include <math.h>
20#include <limits.h>
c86cc308 21#include <stdio.h>
9fe4507c 22#include <QSlider>
b8fdac9e 23#include <QHBoxLayout>
24#include <string.h>
6658905f 25#include "proxguiqt.h"
26#include "proxgui.h"
b8fdac9e 27#include <QtGui>
28//#include <ctime>
29
6658905f 30
7ddb9900 31int startMax;
18856d88 32int PageWidth;
7ddb9900 33
6658905f 34void ProxGuiQT::ShowGraphWindow(void)
35{
36 emit ShowGraphWindowSignal();
37}
38
39void ProxGuiQT::RepaintGraphWindow(void)
40{
41 emit RepaintGraphWindowSignal();
42}
43
44void ProxGuiQT::HideGraphWindow(void)
45{
46 emit HideGraphWindowSignal();
47}
48
49void ProxGuiQT::_ShowGraphWindow(void)
50{
51 if(!plotapp)
52 return;
53
54 if (!plotwidget)
55 plotwidget = new ProxWidget();
56
57 plotwidget->show();
58}
59
60void ProxGuiQT::_RepaintGraphWindow(void)
61{
62 if (!plotapp || !plotwidget)
63 return;
64
65 plotwidget->update();
66}
67
68void ProxGuiQT::_HideGraphWindow(void)
69{
70 if (!plotapp || !plotwidget)
71 return;
72
73 plotwidget->hide();
74}
75
76void ProxGuiQT::MainLoop()
77{
78 plotapp = new QApplication(argc, argv);
79
80 connect(this, SIGNAL(ShowGraphWindowSignal()), this, SLOT(_ShowGraphWindow()));
81 connect(this, SIGNAL(RepaintGraphWindowSignal()), this, SLOT(_RepaintGraphWindow()));
82 connect(this, SIGNAL(HideGraphWindowSignal()), this, SLOT(_HideGraphWindow()));
83
84 plotapp->exec();
85}
86
87ProxGuiQT::ProxGuiQT(int argc, char **argv) : plotapp(NULL), plotwidget(NULL),
88 argc(argc), argv(argv)
89{
90}
91
92ProxGuiQT::~ProxGuiQT(void)
93{
94 if (plotwidget) {
b8fdac9e 95 //plotwidget->close();
6658905f 96 delete plotwidget;
97 plotwidget = NULL;
98 }
99
100 if (plotapp) {
101 plotapp->quit();
102 delete plotapp;
103 plotapp = NULL;
104 }
105}
106
b8fdac9e 107//--------------------
108void ProxWidget::applyOperation()
6658905f 109{
b8fdac9e 110 printf("ApplyOperation()");
111 save_restoreGB(1);
c4f51073 112 memcpy(GraphBuffer, s_Buff, sizeof(int) * GraphTraceLen);
b8fdac9e 113 RepaintGraphWindow();
6658905f 114
b8fdac9e 115}
116void ProxWidget::stickOperation()
117{
118 save_restoreGB(0);
119 printf("stickOperation()");
120}
121void ProxWidget::vchange_autocorr(int v)
122{
c4f51073 123 int ans;
124 ans = AutoCorrelate(GraphBuffer, s_Buff, GraphTraceLen, v, true, false);
125 printf("vchange_autocorr(w:%d): %d\n", v, ans);
126 RepaintGraphWindow();
127}
128void ProxWidget::vchange_askedge(int v)
129{
130 int ans;
131 //extern int AskEdgeDetect(const int *in, int *out, int len, int threshold);
132 ans = AskEdgeDetect(GraphBuffer, s_Buff, GraphTraceLen, v);
133 printf("vchange_askedge(w:%d)\n", v);
b8fdac9e 134 RepaintGraphWindow();
135}
136void ProxWidget::vchange_dthr_up(int v)
137{
138 int down = opsController->horizontalSlider_dirthr_down->value();
c4f51073 139 directionalThreshold(GraphBuffer, s_Buff, GraphTraceLen, v, down);
b8fdac9e 140 printf("vchange_dthr_up(%d)", v);
141 RepaintGraphWindow();
6658905f 142
b8fdac9e 143}
144void ProxWidget::vchange_dthr_down(int v)
145{
146 printf("vchange_dthr_down(%d)", v);
147 int up = opsController->horizontalSlider_dirthr_up->value();
148 directionalThreshold(GraphBuffer,s_Buff, GraphTraceLen, v, up);
149 RepaintGraphWindow();
150
151}
152ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent)
153{
154 this->master = master;
155 resize(800,500);
156
157 /** Setup the controller widget **/
158
159 QWidget* controlWidget = new QWidget();
160 opsController = new Ui::Form();
161 opsController->setupUi(controlWidget);
162 //Due to quirks in QT Designer, we need to fiddle a bit
163 opsController->horizontalSlider_dirthr_down->setMinimum(-128);
164 opsController->horizontalSlider_dirthr_down->setMaximum(0);
165 opsController->horizontalSlider_dirthr_down->setValue(-20);
166
167
168 QObject::connect(opsController->pushButton_apply, SIGNAL(clicked()), this, SLOT(applyOperation()));
169 QObject::connect(opsController->pushButton_sticky, SIGNAL(clicked()), this, SLOT(stickOperation()));
170 QObject::connect(opsController->horizontalSlider_window, SIGNAL(valueChanged(int)), this, SLOT(vchange_autocorr(int)));
171 QObject::connect(opsController->horizontalSlider_dirthr_up, SIGNAL(valueChanged(int)), this, SLOT(vchange_dthr_up(int)));
172 QObject::connect(opsController->horizontalSlider_dirthr_down, SIGNAL(valueChanged(int)), this, SLOT(vchange_dthr_down(int)));
c4f51073 173 QObject::connect(opsController->horizontalSlider_askedge, SIGNAL(valueChanged(int)), this, SLOT(vchange_askedge(int)));
b8fdac9e 174
175 controlWidget->show();
176
177 // Set up the plot widget, which does the actual plotting
178
179 plot = new Plot(this);
180 /*
181 QSlider* slider = new QSlider(Qt::Horizontal);
182 slider->setFocusPolicy(Qt::StrongFocus);
183 slider->setTickPosition(QSlider::TicksBothSides);
184 slider->setTickInterval(10);
185 slider->setSingleStep(1);
186 */
187 QVBoxLayout *layout = new QVBoxLayout;
188 //layout->addWidget(slider);
189 layout->addWidget(plot);
190 setLayout(layout);
c4f51073 191 printf("Proxwidget Constructor just set layout\r\n");
b8fdac9e 192}
193
194
195//----------- Plotting
196
197int Plot::xCoordOf(int i, QRect r )
198{
199 return r.left() + (int)((i - GraphStart)*GraphPixelsPerPoint);
200}
201
202int Plot::yCoordOf(int v, QRect r, int maxVal)
203{
204 int z = (r.bottom() - r.top())/2;
205 return -(z * v) / maxVal + z;
206}
207
208int Plot::valueOf_yCoord(int y, QRect r, int maxVal)
209{
210 int z = (r.bottom() - r.top())/2;
211 return (y-z) * maxVal / z;
212}
213static const QColor GREEN = QColor(100,255,100);
214static const QColor RED = QColor(255,100,100);
215static const QColor BLUE = QColor(100,100,255);
216static const QColor GRAY = QColor(240,240,240);
217
218QColor Plot::getColor(int graphNum)
219{
220 switch (graphNum) {
221 case 0: return GREEN; //Green
222 case 1: return RED; //Red
223 case 2: return BLUE; //Blue
224 default: return GRAY; //Gray
6658905f 225 }
b8fdac9e 226}
6658905f 227
b8fdac9e 228void Plot::PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotationRect, QPainter *painter, int graphNum, int plotOffset)
229{
230 if (len == 0 || PlotGridX <= 0) return;
231 //clock_t begin = clock();
232 QPainterPath penPath;
233
234 int grid_delta_x = PlotGridX;
235 int first_delta_x = grid_delta_x; //(plotOffset > 0) ? PlotGridX : (PlotGridX +);
236 if (GraphStart > plotOffset) first_delta_x -= (GraphStart-plotOffset);
237 int DemodStart = GraphStart;
238 if (plotOffset > GraphStart) DemodStart = plotOffset;
239
240 int BitStart = 0;
241 // round down
242 if (DemodStart-plotOffset > 0) BitStart = (int)(((DemodStart-plotOffset)+(PlotGridX-1))/PlotGridX)-1;
243 first_delta_x += BitStart * PlotGridX;
244 if (BitStart > len) return;
245 int delta_x = 0;
246 int v = 0;
247 //printf("first_delta_x %i, grid_delta_x %i, DemodStart %i, BitStart %i\n",first_delta_x,grid_delta_x,DemodStart, BitStart);
248
249 painter->setPen(getColor(graphNum));
250 char str[5];
251 int absVMax = (int)(100*1.05+1);
252 int x = xCoordOf(DemodStart, plotRect);
253 int y = yCoordOf((buffer[BitStart]*200-100)*-1,plotRect,absVMax);
254 penPath.moveTo(x, y);
255 delta_x = 0;
256 int clk = first_delta_x;
257 for(int i = BitStart; i < len && xCoordOf(delta_x+DemodStart, plotRect) < plotRect.right(); i++) {
258 for (int ii = 0; ii < (clk) && i < len && xCoordOf(DemodStart+delta_x+ii, plotRect) < plotRect.right() ; ii++ ) {
259 x = xCoordOf(DemodStart+delta_x+ii, plotRect);
260 v = buffer[i]*200-100;
261
262 y = yCoordOf( v, plotRect, absVMax);
0bf5872f 263
b8fdac9e 264 penPath.lineTo(x, y);
6658905f 265
b8fdac9e 266 if(GraphPixelsPerPoint > 10) {
267 QRect f(QPoint(x - 3, y - 3),QPoint(x + 3, y + 3));
268 painter->fillRect(f, QColor(100, 255, 100));
269 }
270 if (ii == (int)clk/2) {
271 //print label
272 sprintf(str, "%u",buffer[i]);
273 painter->drawText(x-8, y + ((buffer[i] > 0) ? 18 : -6), str);
274 }
275 }
276 delta_x += clk;
277 clk = grid_delta_x;
278 }
6658905f 279
b8fdac9e 280 //Graph annotations
281 painter->drawPath(penPath);
282}
6658905f 283
b8fdac9e 284void Plot::PlotGraph(int *buffer, int len, QRect plotRect, QRect annotationRect, QPainter *painter, int graphNum)
285{
286 if (len == 0) return;
287 //clock_t begin = clock();
288 QPainterPath penPath;
6658905f 289
b8fdac9e 290 startMax = (len - (int)((plotRect.right() - plotRect.left() - 40) / GraphPixelsPerPoint));
6658905f 291 if(startMax < 0) {
292 startMax = 0;
293 }
294 if(GraphStart > startMax) {
295 GraphStart = startMax;
296 }
b8fdac9e 297 if (GraphStart > len) return;
298 int vMin = INT_MAX, vMax = INT_MIN, vMean = 0, v = 0, absVMax = 0;
299 int sample_index = GraphStart ;
300 for( ; sample_index < len && xCoordOf(sample_index,plotRect) < plotRect.right() ; sample_index++) {
301
302 v = buffer[sample_index];
303 if(v < vMin) vMin = v;
304 if(v > vMax) vMax = v;
305 vMean += v;
6658905f 306 }
307
b8fdac9e 308 vMean /= (sample_index - GraphStart);
309
310 if(fabs( (double) vMin) > absVMax) absVMax = (int)fabs( (double) vMin);
311 if(fabs( (double) vMax) > absVMax) absVMax = (int)fabs( (double) vMax);
312 absVMax = (int)(absVMax*1.25 + 1);
6658905f 313 // number of points that will be plotted
b8fdac9e 314 int span = (int)((plotRect.right() - plotRect.left()) / GraphPixelsPerPoint);
6658905f 315 // one label every 100 pixels, let us say
b8fdac9e 316 int labels = (plotRect.right() - plotRect.left() - 40) / 100;
6658905f 317 if(labels <= 0) labels = 1;
318 int pointsPerLabel = span / labels;
319 if(pointsPerLabel <= 0) pointsPerLabel = 1;
320
b8fdac9e 321 int x = xCoordOf(GraphStart, plotRect);
322 int y = yCoordOf(buffer[GraphStart],plotRect,absVMax);
323 penPath.moveTo(x, y);
324 for(int i = GraphStart; i < len && xCoordOf(i, plotRect) < plotRect.right(); i++) {
6658905f 325
b8fdac9e 326 x = xCoordOf(i, plotRect);
327 v = buffer[i];
6658905f 328
b8fdac9e 329 y = yCoordOf( v, plotRect, absVMax);//(y * (r.top() - r.bottom()) / (2*absYMax)) + zeroHeight;
6658905f 330
b8fdac9e 331 penPath.lineTo(x, y);
6658905f 332
333 if(GraphPixelsPerPoint > 10) {
334 QRect f(QPoint(x - 3, y - 3),QPoint(x + 3, y + 3));
b8fdac9e 335 painter->fillRect(f, QColor(100, 255, 100));
6658905f 336 }
b8fdac9e 337 }
6658905f 338
b8fdac9e 339 painter->setPen(getColor(graphNum));
6658905f 340
b8fdac9e 341 //Draw y-axis
342 int xo = 5+(graphNum*40);
343 painter->drawLine(xo, plotRect.top(),xo, plotRect.bottom());
6658905f 344
b8fdac9e 345 int vMarkers = (absVMax - (absVMax % 10)) / 5;
346 int minYDist = 40; //Minimum pixel-distance between markers
6658905f 347
b8fdac9e 348 char yLbl[20];
6658905f 349
b8fdac9e 350 int n = 0;
351 int lasty0 = 65535;
6658905f 352
b8fdac9e 353 for(int v = vMarkers; yCoordOf(v,plotRect,absVMax) > plotRect.top() && n < 20; v+= vMarkers ,n++)
354 {
355 int y0 = yCoordOf(v,plotRect,absVMax);
356 int y1 = yCoordOf(-v,plotRect,absVMax);
357
358 if(lasty0 - y0 < minYDist) continue;
359
360 painter->drawLine(xo-5,y0, xo+5, y0);
361
362 sprintf(yLbl, "%d", v);
363 painter->drawText(xo+8,y0+7,yLbl);
364
365 painter->drawLine(xo-5, y1, xo+5, y1);
366 sprintf(yLbl, "%d",-v);
367 painter->drawText(xo+8, y1+5 , yLbl);
368 lasty0 = y0;
369 }
370
371 //Graph annotations
372 painter->drawPath(penPath);
373 char str[200];
374 sprintf(str, "max=%d min=%d mean=%d n=%d/%d CursorAVal=[%d] CursorBVal=[%d]",
375 vMax, vMin, vMean, sample_index, len, buffer[CursorAPos], buffer[CursorBPos]);
376 painter->drawText(20, annotationRect.bottom() - 23 - 20 * graphNum, str);
377
378 //clock_t end = clock();
379 //double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
380 //printf("Plot time %f\n", elapsed_secs);
381}
382
383void Plot::plotGridLines(QPainter* painter,QRect r)
384{
385 int zeroHeight = r.top() + (r.bottom() - r.top()) / 2;
386
387 int i;
388 int grid_delta_x = (int) (PlotGridX * GraphPixelsPerPoint);
389 int grid_delta_y = (int) (PlotGridY * GraphPixelsPerPoint);
390 if ((PlotGridX > 0) && ((PlotGridX * GraphPixelsPerPoint) > 1)) {
391 for(i = (GridOffset * GraphPixelsPerPoint); i < r.right(); i += grid_delta_x) {
392 painter->drawLine(r.left()+i, r.top(), r.left()+i, r.bottom());
393 }
394 }
395 if ((PlotGridY > 0) && ((PlotGridY * GraphPixelsPerPoint) > 1)){
396 for(i = 0; i < ((r.top() + r.bottom())>>1); i += grid_delta_y) {
397 painter->drawLine(r.left(),zeroHeight + i,r.right(),zeroHeight + i);
398 painter->drawLine(r.left(),zeroHeight - i,r.right(),zeroHeight - i);
6658905f 399 }
400 }
b8fdac9e 401}
402
403#define HEIGHT_INFO 60
404#define WIDTH_AXES 80
405
406void Plot::paintEvent(QPaintEvent *event)
407{
408 QPainter painter(this);
409 //QPainterPath penPath, whitePath, greyPath, lightgreyPath, cursorAPath, cursorBPath, cursorCPath, cursorDPath;
410 //QRect r;
411 QBrush brush(QColor(100, 255, 100));
412 QPen pen(QColor(100, 255, 100));
413
414 painter.setFont(QFont("Courier New", 10));
415
416 if(GraphStart < 0) {
417 GraphStart = 0;
418 }
6658905f 419
b8fdac9e 420 if (CursorAPos > GraphTraceLen)
421 CursorAPos= 0;
422 if(CursorBPos > GraphTraceLen)
423 CursorBPos= 0;
424 if(CursorCPos > GraphTraceLen)
425 CursorCPos= 0;
426 if(CursorDPos > GraphTraceLen)
427 CursorDPos= 0;
428
429 QRect plotRect(WIDTH_AXES, 0, width()-WIDTH_AXES, height()-HEIGHT_INFO);
430 QRect infoRect(0, height()-HEIGHT_INFO, width(), HEIGHT_INFO);
431
432 //Grey background
433 painter.fillRect(rect(), QColor(60, 60, 60));
434 //Black foreground
435 painter.fillRect(plotRect, QColor(0, 0, 0));
436
437 // center line
438 int zeroHeight = plotRect.top() + (plotRect.bottom() - plotRect.top()) / 2;
439 painter.setPen(QColor(100, 100, 100));
440 painter.drawLine(plotRect.left(), zeroHeight, plotRect.right(), zeroHeight);
441 // plot X and Y grid lines
442 plotGridLines(&painter, plotRect);
443
444 //Start painting graph
b8fdac9e 445 if (showDemod && DemodBufferLen > 8) {
446 PlotDemod(DemodBuffer, DemodBufferLen,plotRect,infoRect,&painter,2,g_DemodStartIdx);
6658905f 447 }
9fe4507c 448 PlotGraph(s_Buff, GraphTraceLen,plotRect,infoRect,&painter,1);
449 PlotGraph(GraphBuffer, GraphTraceLen,plotRect,infoRect,&painter,0);
b8fdac9e 450 // End graph drawing
6658905f 451
b8fdac9e 452 //Draw the cursors
453 if(CursorAPos > GraphStart && xCoordOf(CursorAPos, plotRect) < plotRect.right())
454 {
455 painter.setPen(QColor(255, 255, 0));
456 painter.drawLine(xCoordOf(CursorAPos, plotRect),plotRect.top(),xCoordOf(CursorAPos, plotRect),plotRect.bottom());
457 }
458 if(CursorBPos > GraphStart && xCoordOf(CursorBPos, plotRect) < plotRect.right())
459 {
460 painter.setPen(QColor(255, 0, 255));
461 painter.drawLine(xCoordOf(CursorBPos, plotRect),plotRect.top(),xCoordOf(CursorBPos, plotRect),plotRect.bottom());
462 }
463 if(CursorCPos > GraphStart && xCoordOf(CursorCPos, plotRect) < plotRect.right())
464 {
465 painter.setPen(QColor(255, 153, 0)); //orange
466 painter.drawLine(xCoordOf(CursorCPos, plotRect),plotRect.top(),xCoordOf(CursorCPos, plotRect),plotRect.bottom());
467 }
468 if(CursorDPos > GraphStart && xCoordOf(CursorDPos, plotRect) < plotRect.right())
469 {
470 painter.setPen(QColor(0, 0, 205)); //light blue
471 painter.drawLine(xCoordOf(CursorDPos, plotRect),plotRect.top(),xCoordOf(CursorDPos, plotRect),plotRect.bottom());
472 }
6658905f 473
b8fdac9e 474 //Draw annotations
346ad5fb 475 char str[200];
b8fdac9e 476 sprintf(str, "@%d dt=%d [%2.2f] zoom=%2.2f CursorAPos=%d CursorBPos=%d GridX=%d GridY=%d (%s) GridXoffset=%d",
477 GraphStart, CursorBPos - CursorAPos, (CursorBPos - CursorAPos)/CursorScaleFactor,
478 GraphPixelsPerPoint,CursorAPos,CursorBPos,PlotGridXdefault,PlotGridYdefault,GridLocked?"Locked":"Unlocked",GridOffset);
6658905f 479 painter.setPen(QColor(255, 255, 255));
b8fdac9e 480 painter.drawText(20, infoRect.bottom() - 3, str);
481
6658905f 482}
483
b8fdac9e 484Plot::Plot(QWidget *parent) : QWidget(parent), GraphStart(0), GraphPixelsPerPoint(1)
6658905f 485{
9fe4507c 486 //Need to set this, otherwise we don't receive keypress events
b8fdac9e 487 setFocusPolicy( Qt::StrongFocus);
9484ff3d 488 resize(600, 300);
6658905f 489
490 QPalette palette(QColor(0,0,0,0));
491 palette.setColor(QPalette::WindowText, QColor(255,255,255));
492 palette.setColor(QPalette::Text, QColor(255,255,255));
493 palette.setColor(QPalette::Button, QColor(100, 100, 100));
494 setPalette(palette);
495 setAutoFillBackground(true);
cee48e2b 496 CursorAPos = 0;
497 CursorBPos = 0;
b8fdac9e 498
499 setWindowTitle(tr("Sliders"));
6658905f 500}
501
b8fdac9e 502void Plot::closeEvent(QCloseEvent *event)
6658905f 503{
504 event->ignore();
505 this->hide();
506}
507
b8fdac9e 508void Plot::mouseMoveEvent(QMouseEvent *event)
6658905f 509{
510 int x = event->x();
b8fdac9e 511 x -= WIDTH_AXES;
6658905f 512 x = (int)(x / GraphPixelsPerPoint);
513 x += GraphStart;
514 if((event->buttons() & Qt::LeftButton)) {
515 CursorAPos = x;
516 } else if (event->buttons() & Qt::RightButton) {
517 CursorBPos = x;
518 }
519
520
521 this->update();
522}
523
b8fdac9e 524void Plot::keyPressEvent(QKeyEvent *event)
6658905f 525{
18856d88 526 int offset;
527 int gridchanged;
528
529 gridchanged= 0;
530
531 if(event->modifiers() & Qt::ShiftModifier) {
532 if (PlotGridX)
533 offset= PageWidth - (PageWidth % PlotGridX);
534 else
535 offset= PageWidth;
ff2e9c1c 536 } else
537 if(event->modifiers() & Qt::ControlModifier)
538 offset= 1;
539 else
540 offset= (int)(20 / GraphPixelsPerPoint);
18856d88 541
6658905f 542 switch(event->key()) {
543 case Qt::Key_Down:
544 if(GraphPixelsPerPoint <= 50) {
545 GraphPixelsPerPoint *= 2;
546 }
547 break;
548
549 case Qt::Key_Up:
550 if(GraphPixelsPerPoint >= 0.02) {
551 GraphPixelsPerPoint /= 2;
552 }
553 break;
554
555 case Qt::Key_Right:
556 if(GraphPixelsPerPoint < 20) {
18856d88 557 if (PlotGridX && GridLocked && GraphStart < startMax){
558 GridOffset -= offset;
559 GridOffset %= PlotGridX;
560 gridchanged= 1;
561 }
562 GraphStart += offset;
6658905f 563 } else {
18856d88 564 if (PlotGridX && GridLocked && GraphStart < startMax){
7ddb9900 565 GridOffset--;
18856d88 566 GridOffset %= PlotGridX;
567 gridchanged= 1;
568 }
3bc2349d 569 GraphStart++;
6658905f 570 }
18856d88 571 if(GridOffset < 0) {
7ddb9900 572 GridOffset += PlotGridX;
18856d88 573 }
574 if (gridchanged)
575 if (GraphStart > startMax) {
576 GridOffset += (GraphStart - startMax);
577 GridOffset %= PlotGridX;
578 }
6658905f 579 break;
580
581 case Qt::Key_Left:
582 if(GraphPixelsPerPoint < 20) {
18856d88 583 if (PlotGridX && GridLocked && GraphStart > 0){
584 GridOffset += offset;
585 GridOffset %= PlotGridX;
586 gridchanged= 1;
587 }
588 GraphStart -= offset;
6658905f 589 } else {
18856d88 590 if (PlotGridX && GridLocked && GraphStart > 0){
7ddb9900 591 GridOffset++;
18856d88 592 GridOffset %= PlotGridX;
593 gridchanged= 1;
594 }
3bc2349d 595 GraphStart--;
6658905f 596 }
18856d88 597 if (gridchanged){
598 if (GraphStart < 0)
599 GridOffset += GraphStart;
600 if(GridOffset < 0)
601 GridOffset += PlotGridX;
602 GridOffset %= PlotGridX;
603 }
7ddb9900 604 break;
605
606 case Qt::Key_G:
607 if(PlotGridX || PlotGridY) {
608 PlotGridX= 0;
609 PlotGridY= 0;
610 } else {
611 PlotGridX= PlotGridXdefault;
612 PlotGridY= PlotGridYdefault;
613 }
614 break;
615
616 case Qt::Key_H:
617 puts("Plot Window Keystrokes:\n");
ff2e9c1c 618 puts(" Key Action\n");
619 puts(" DOWN Zoom in");
620 puts(" G Toggle grid display");
621 puts(" H Show help");
622 puts(" L Toggle lock grid relative to samples");
623 puts(" LEFT Move left");
624 puts(" <CTL>LEFT Move left 1 sample");
625 puts(" <SHIFT>LEFT Page left");
626 puts(" LEFT-MOUSE-CLICK Set yellow cursor");
627 puts(" Q Hide window");
628 puts(" RIGHT Move right");
629 puts(" <CTL>RIGHT Move right 1 sample");
630 puts(" <SHIFT>RIGHT Page right");
631 puts(" RIGHT-MOUSE-CLICK Set purple cursor");
632 puts(" UP Zoom out");
7ddb9900 633 puts("");
634 puts("Use client window 'data help' for more plot commands\n");
635 break;
636
637 case Qt::Key_L:
638 GridLocked= !GridLocked;
639 break;
640
641 case Qt::Key_Q:
642 this->hide();
6658905f 643 break;
644
645 default:
646 QWidget::keyPressEvent(event);
647 return;
648 break;
649 }
650
651 this->update();
652}
Impressum, Datenschutz