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