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