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