##// END OF EJS Templates
added zoom box.
jeandet -
r2:a262e3a4f8e7 default
parent child
Show More
@@ -13,8 +13,8 TEMPLATE = app
13
13
14 INCLUDEPATH += src/QCustomPlot src
14 INCLUDEPATH += src/QCustomPlot src
15
15
16 QMAKE_CXXFLAGS += -fopenmp
16 QMAKE_CXXFLAGS += -O5 -fopenmp -march=corei7-avx -mtune=corei7-avx -mavx
17 QMAKE_LFLAGS += -fopenmp
17 QMAKE_LFLAGS += -O5 -fopenmp -march=corei7-avx -mtune=corei7-avx -mavx
18
18
19 SOURCES += src/main.cpp\
19 SOURCES += src/main.cpp\
20 src/mainwindow.cpp \
20 src/mainwindow.cpp \
@@ -24,7 +24,7
24
24
25
25
26 SocExplorerPlot::SocExplorerPlot(QWidget *parent) :
26 SocExplorerPlot::SocExplorerPlot(QWidget *parent) :
27 QWidget(parent)
27 QWidget(parent), mRubberBand(new QRubberBand(QRubberBand::Rectangle, this))
28 {
28 {
29 this->m_plot = new QCustomPlot(this);
29 this->m_plot = new QCustomPlot(this);
30 this->m_plot->setInteractions(QCP::iRangeDrag | QCP::iSelectAxes |
30 this->m_plot->setInteractions(QCP::iRangeDrag | QCP::iSelectAxes |
@@ -46,6 +46,11 SocExplorerPlot::SocExplorerPlot(QWidget
46
46
47 }
47 }
48
48
49 SocExplorerPlot::~SocExplorerPlot()
50 {
51 delete mRubberBand;
52 }
53
49 void SocExplorerPlot::show()
54 void SocExplorerPlot::show()
50 {
55 {
51 QWidget::show();
56 QWidget::show();
@@ -379,6 +384,7 void SocExplorerPlot::keyPressEvent(QKey
379 {
384 {
380 case Qt::Key_Control:
385 case Qt::Key_Control:
381 this->ctrl_hold = true;
386 this->ctrl_hold = true;
387 setCursor(Qt::CrossCursor);
382 break;
388 break;
383 case Qt::Key_Shift:
389 case Qt::Key_Shift:
384 this->shift_hold = true;
390 this->shift_hold = true;
@@ -389,7 +395,7 void SocExplorerPlot::keyPressEvent(QKey
389 case Qt::Key_Left:
395 case Qt::Key_Left:
390 if(!ctrl_hold)
396 if(!ctrl_hold)
391 {
397 {
392 move(-0.1,Qt::Horizontal);
398 move(-0.1,Qt::Horizontal);
393 }
399 }
394 else
400 else
395 {
401 {
@@ -399,7 +405,7 void SocExplorerPlot::keyPressEvent(QKey
399 case Qt::Key_Right:
405 case Qt::Key_Right:
400 if(!ctrl_hold)
406 if(!ctrl_hold)
401 {
407 {
402 move(0.1,Qt::Horizontal);
408 move(0.1,Qt::Horizontal);
403 }
409 }
404 else
410 else
405 {
411 {
@@ -409,7 +415,7 void SocExplorerPlot::keyPressEvent(QKey
409 case Qt::Key_Up:
415 case Qt::Key_Up:
410 if(!ctrl_hold)
416 if(!ctrl_hold)
411 {
417 {
412 move(0.1,Qt::Vertical);
418 move(0.1,Qt::Vertical);
413 }
419 }
414 else
420 else
415 {
421 {
@@ -419,7 +425,7 void SocExplorerPlot::keyPressEvent(QKey
419 case Qt::Key_Down:
425 case Qt::Key_Down:
420 if(!ctrl_hold)
426 if(!ctrl_hold)
421 {
427 {
422 move(-0.1,Qt::Vertical);
428 move(-0.1,Qt::Vertical);
423 }
429 }
424 else
430 else
425 {
431 {
@@ -448,6 +454,7 void SocExplorerPlot::keyReleaseEvent(QK
448 QWidget::keyReleaseEvent(event);
454 QWidget::keyReleaseEvent(event);
449 break;
455 break;
450 }
456 }
457 setCursor(Qt::ArrowCursor);
451 }
458 }
452
459
453 void SocExplorerPlot::wheelEvent(QWheelEvent * event)
460 void SocExplorerPlot::wheelEvent(QWheelEvent * event)
@@ -458,6 +465,7 void SocExplorerPlot::wheelEvent(QWheelE
458 {
465 {
459 if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical))
466 if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical))
460 {
467 {
468 setCursor(Qt::SizeVerCursor);
461 factor = pow(this->m_plot->axisRect()->rangeZoomFactor(Qt::Vertical), wheelSteps);
469 factor = pow(this->m_plot->axisRect()->rangeZoomFactor(Qt::Vertical), wheelSteps);
462 zoom(factor,event->pos().y(),Qt::Vertical);
470 zoom(factor,event->pos().y(),Qt::Vertical);
463 }
471 }
@@ -468,6 +476,7 void SocExplorerPlot::wheelEvent(QWheelE
468 {
476 {
469 if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical))
477 if (event->orientation()==Qt::Vertical)//mRangeZoom.testFlag(Qt::Vertical))
470 {
478 {
479 setCursor(Qt::SizeHorCursor);
471 factor = pow(this->m_plot->axisRect()->rangeZoomFactor(Qt::Horizontal), wheelSteps);
480 factor = pow(this->m_plot->axisRect()->rangeZoomFactor(Qt::Horizontal), wheelSteps);
472 zoom(factor,event->pos().x(),Qt::Horizontal);
481 zoom(factor,event->pos().x(),Qt::Horizontal);
473 }
482 }
@@ -485,10 +494,21 void SocExplorerPlot::mousePressEvent(QM
485 {
494 {
486 if(event->button()==Qt::LeftButton)
495 if(event->button()==Qt::LeftButton)
487 {
496 {
488 mDragStart = event->pos();
497 if(ctrl_hold)
489 this->mouse_hold = true;
498 {
490 DragStartHorzRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Horizontal)->range();
499 setCursor(Qt::CrossCursor);
491 DragStartVertRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Vertical)->range();
500 mOrigin = event->pos();
501 mRubberBand->setGeometry(QRect(mOrigin, QSize()));
502 mRubberBand->show();
503 }
504 else
505 {
506 setCursor(Qt::ClosedHandCursor);
507 mDragStart = event->pos();
508 this->mouse_hold = true;
509 DragStartHorzRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Horizontal)->range();
510 DragStartVertRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Vertical)->range();
511 }
492 }
512 }
493 QWidget::mousePressEvent(event);
513 QWidget::mousePressEvent(event);
494 }
514 }
@@ -499,6 +519,23 void SocExplorerPlot::mouseReleaseEvent(
499 {
519 {
500 this->mouse_hold = false;
520 this->mouse_hold = false;
501 }
521 }
522 if (mRubberBand->isVisible())
523 {
524 const QRect & zoomRect = mRubberBand->geometry();
525 int xp1, yp1, xp2, yp2;
526 zoomRect.getCoords(&xp1, &yp1, &xp2, &yp2);
527 double x1 = this->m_plot->xAxis->pixelToCoord(xp1);
528 double x2 = this->m_plot->xAxis->pixelToCoord(xp2);
529 double y1 = this->m_plot->yAxis->pixelToCoord(yp1);
530 double y2 = this->m_plot->yAxis->pixelToCoord(yp2);
531
532 this->m_plot->xAxis->setRange(x1, x2);
533 this->m_plot->yAxis->setRange(y1, y2);
534
535 mRubberBand->hide();
536 this->m_plot->replot();
537 }
538 setCursor(Qt::ArrowCursor);
502 QWidget::mouseReleaseEvent(event);
539 QWidget::mouseReleaseEvent(event);
503 }
540 }
504
541
@@ -530,6 +567,10 void SocExplorerPlot::mouseMoveEvent(QMo
530 Vaxis->setRange(DragStartVertRange.lower+diff, DragStartVertRange.upper+diff);
567 Vaxis->setRange(DragStartVertRange.lower+diff, DragStartVertRange.upper+diff);
531 this->m_plot->replot();
568 this->m_plot->replot();
532 }
569 }
570 if (mRubberBand->isVisible())
571 {
572 mRubberBand->setGeometry(QRect(mOrigin, event->pos()).normalized());
573 }
533 QWidget::mouseMoveEvent(event);
574 QWidget::mouseMoveEvent(event);
534 }
575 }
535
576
@@ -25,12 +25,15
25 #include <QWidget>
25 #include <QWidget>
26 #include <QGridLayout>
26 #include <QGridLayout>
27 #include <qcustomplot.h>
27 #include <qcustomplot.h>
28 #include <QRubberBand>
29 #include <QPoint>
28
30
29 class SocExplorerPlot : public QWidget
31 class SocExplorerPlot : public QWidget
30 {
32 {
31 Q_OBJECT
33 Q_OBJECT
32 public:
34 public:
33 explicit SocExplorerPlot(QWidget *parent = 0);
35 explicit SocExplorerPlot(QWidget *parent = 0);
36 ~SocExplorerPlot();
34 void setTitle(QString title);
37 void setTitle(QString title);
35 void setXaxisLabel(QString label);
38 void setXaxisLabel(QString label);
36 void setXaxisRange(double lower, double upper);
39 void setXaxisRange(double lower, double upper);
@@ -80,6 +83,9 private:
80 QCPRange DragStartHorzRange;
83 QCPRange DragStartHorzRange;
81 QCPRange DragStartVertRange;
84 QCPRange DragStartVertRange;
82 QPoint mDragStart;
85 QPoint mDragStart;
86 bool mZoomMode;
87 QRubberBand * mRubberBand;
88 QPoint mOrigin;
83 };
89 };
84
90
85 #endif // SOCEXPLORERPLOT_H
91 #endif // SOCEXPLORERPLOT_H
@@ -103,6 +103,7 void MainWindow::plotFile(const QString
103 }
103 }
104 this->progressWidget->show();
104 this->progressWidget->show();
105 fileReader.parseFile(File);
105 fileReader.parseFile(File);
106 this->ui->Plot->setTitle(File);
106 }
107 }
107 }
108 }
108
109
@@ -155,8 +156,11 void MainWindow::updateProgress(int thre
155 {
156 {
156 if(progressThreadIds[i]==threadId)
157 if(progressThreadIds[i]==threadId)
157 {
158 {
158 this->progress.at(threadId)->setValue(percentProgress);
159 if(threadId<this->progress.count())
159 updated=true;
160 {
161 this->progress.at(threadId)->setValue(percentProgress);
162 updated=true;
163 }
160 }
164 }
161 }
165 }
162 if(Q_UNLIKELY(updated==false))
166 if(Q_UNLIKELY(updated==false))
@@ -28,7 +28,7
28 #include <omp.h>
28 #include <omp.h>
29 #include <QTimer>
29 #include <QTimer>
30 #include <QElapsedTimer>
30 #include <QElapsedTimer>
31 #include <time.h>
31 #include <sys/time.h>
32
32
33 ThemisDataFile::ThemisDataFile(QObject *parent) : QThread(parent)
33 ThemisDataFile::ThemisDataFile(QObject *parent) : QThread(parent)
34 {
34 {
@@ -121,9 +121,9 double __decodeTimeFromEpoch(int ofset,u
121 t.tm_hour=(10*(data[ofset+11] & 0x0F)) + ((data[ofset+12] & 0x0F));
121 t.tm_hour=(10*(data[ofset+11] & 0x0F)) + ((data[ofset+12] & 0x0F));
122 t.tm_min=(10*(data[ofset+14] & 0x0F)) + ((data[ofset+15] & 0x0F));
122 t.tm_min=(10*(data[ofset+14] & 0x0F)) + ((data[ofset+15] & 0x0F));
123 t.tm_sec=(10*(data[ofset+17] & 0x0F)) + ((data[ofset+18] & 0x0F));
123 t.tm_sec=(10*(data[ofset+17] & 0x0F)) + ((data[ofset+18] & 0x0F));
124 int ms=(100*(data[ofset+20] & 0x0F)) + (10*(data[ofset+21] & 0x0F)) + ((data[ofset+22] & 0x0F));
124 double ms=(100*(data[ofset+20] & 0x0F)) + (10*(data[ofset+21] & 0x0F)) + ((data[ofset+22] & 0x0F));
125 t_of_day = mktime(&t);
125 t_of_day = mktime(&t);
126 return t_of_day+(ms*0.001);
126 return (double)t_of_day+((double)ms*(double)0.001);
127 }
127 }
128 void ThemisDataFile::run()
128 void ThemisDataFile::run()
129 {
129 {
@@ -144,7 +144,6 void ThemisDataFile::run()
144 int lineCnt = FileSize/58;
144 int lineCnt = FileSize/58;
145 int curLine=0;
145 int curLine=0;
146 int lastLineUpdate=0;
146 int lastLineUpdate=0;
147 int threadIndex,numThreads=omp_get_num_threads();
148 char* fileContent=(char*)malloc(FileSize);
147 char* fileContent=(char*)malloc(FileSize);
149 if(Q_UNLIKELY(fileContent==NULL))return;
148 if(Q_UNLIKELY(fileContent==NULL))return;
150 fseek(dataFile, 0L, SEEK_SET);
149 fseek(dataFile, 0L, SEEK_SET);
@@ -154,45 +153,31 void ThemisDataFile::run()
154 if(fread(fileContent,1,FileSize,dataFile))
153 if(fread(fileContent,1,FileSize,dataFile))
155 {
154 {
156 line = fileContent;
155 line = fileContent;
157 if(FileSize > 10000000)
158 {
159 lineCnt/=numThreads;
160 }
161 QDateTime date;
156 QDateTime date;
162 timr.start();
157 timr.start();
163 #pragma omp parallel if ((FileSize > 10000000)) private(date,data1,data2,data3,_x,threadIndex,lastLineUpdate) shared(ch1,ch2,ch3,lineCnt)
158 for(int i=0;i<(FileSize/(58));i++)
164 {
159 {
165 threadIndex = omp_get_thread_num();
160 // _x= i;
166 #pragma omp for
161 _x= __decodeTimeFromEpoch((i*58),(unsigned char*)line);
167 for(int i=0;i<(FileSize/(58));i++)
162 data1.key=_x;
168 {
163 data2.key=_x;
169 _x=__decodeTimeFromEpoch((i*58),(unsigned char*)line);
164 data3.key=_x;
170 data1.key=_x;
165 data1.value=__decodeVal(((i*58)+27),(unsigned char*)line);
171 data2.key=_x;
166 data2.value=__decodeVal(((i*58)+38),(unsigned char*)line);
172 data3.key=_x;
167 data3.value=__decodeVal(((i*58)+49),(unsigned char*)line);
173 data1.value=__decodeVal(((i*58)+27),(unsigned char*)line);
168 ch1->insertMulti(_x,data1);
174 data2.value=__decodeVal(((i*58)+38),(unsigned char*)line);
169 ch2->insertMulti(_x,data2);
175 data3.value=__decodeVal(((i*58)+49),(unsigned char*)line);
170 ch3->insertMulti(_x,data3);
176 #pragma omp critical
171 curLine++;
172 if(lastLineUpdate++>8000)
177 {
173 {
178 ch1->insertMulti(_x,data1);
174 lastLineUpdate=0;
179 ch2->insertMulti(_x,data2);
175 int test=(curLine *100/ (lineCnt));
180 ch3->insertMulti(_x,data3);
176 emit updateProgress(0,test);
181 }
177 }
182 curLine++;
178 }
183 if(lastLineUpdate++>8000)
184 {
185 lastLineUpdate=0;
186 int test=(curLine *100/ (lineCnt));
187 emit updateProgress(threadIndex,test);
188 }
189 }
190 #pragma omp barrier
191 }
192 free(fileContent);
179 free(fileContent);
193
194 }
180 }
195
196 qDebug()<<timr.elapsed();
181 qDebug()<<timr.elapsed();
197 setlocale(LC_NUMERIC,svglocale);
182 setlocale(LC_NUMERIC,svglocale);
198 emit dataReady(ch1,ch2,ch3);
183 emit dataReady(ch1,ch2,ch3);
General Comments 0
You need to be logged in to leave comments. Login now