@@ -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; | |
@@ -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,11 +494,22 void SocExplorerPlot::mousePressEvent(QM | |||||
485 | { |
|
494 | { | |
486 | if(event->button()==Qt::LeftButton) |
|
495 | if(event->button()==Qt::LeftButton) | |
487 | { |
|
496 | { | |
|
497 | if(ctrl_hold) | |||
|
498 | { | |||
|
499 | setCursor(Qt::CrossCursor); | |||
|
500 | mOrigin = event->pos(); | |||
|
501 | mRubberBand->setGeometry(QRect(mOrigin, QSize())); | |||
|
502 | mRubberBand->show(); | |||
|
503 | } | |||
|
504 | else | |||
|
505 | { | |||
|
506 | setCursor(Qt::ClosedHandCursor); | |||
488 | mDragStart = event->pos(); |
|
507 | mDragStart = event->pos(); | |
489 | this->mouse_hold = true; |
|
508 | this->mouse_hold = true; | |
490 | DragStartHorzRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Horizontal)->range(); |
|
509 | DragStartHorzRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Horizontal)->range(); | |
491 | DragStartVertRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Vertical)->range(); |
|
510 | DragStartVertRange = this->m_plot->axisRect()->rangeDragAxis(Qt::Vertical)->range(); | |
492 | } |
|
511 | } | |
|
512 | } | |||
493 | QWidget::mousePressEvent(event); |
|
513 | QWidget::mousePressEvent(event); | |
494 | } |
|
514 | } | |
495 |
|
515 | |||
@@ -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,10 +156,13 void MainWindow::updateProgress(int thre | |||||
155 | { |
|
156 | { | |
156 | if(progressThreadIds[i]==threadId) |
|
157 | if(progressThreadIds[i]==threadId) | |
157 | { |
|
158 | { | |
|
159 | if(threadId<this->progress.count()) | |||
|
160 | { | |||
158 | this->progress.at(threadId)->setValue(percentProgress); |
|
161 | this->progress.at(threadId)->setValue(percentProgress); | |
159 | updated=true; |
|
162 | updated=true; | |
160 | } |
|
163 | } | |
161 | } |
|
164 | } | |
|
165 | } | |||
162 | if(Q_UNLIKELY(updated==false)) |
|
166 | if(Q_UNLIKELY(updated==false)) | |
163 | { |
|
167 | { | |
164 | for(int i=0;i<OMP_THREADS;i++) |
|
168 | for(int i=0;i<OMP_THREADS;i++) |
@@ -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 |
|
|
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,18 +153,11 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) |
|
|||
164 | { |
|
|||
165 | threadIndex = omp_get_thread_num(); |
|
|||
166 | #pragma omp for |
|
|||
167 |
|
|
158 | for(int i=0;i<(FileSize/(58));i++) | |
168 |
|
|
159 | { | |
|
160 | // _x= i; | |||
169 |
|
|
161 | _x= __decodeTimeFromEpoch((i*58),(unsigned char*)line); | |
170 |
|
|
162 | data1.key=_x; | |
171 |
|
|
163 | data2.key=_x; | |
@@ -173,26 +165,19 void ThemisDataFile::run() | |||||
173 |
|
|
165 | data1.value=__decodeVal(((i*58)+27),(unsigned char*)line); | |
174 |
|
|
166 | data2.value=__decodeVal(((i*58)+38),(unsigned char*)line); | |
175 |
|
|
167 | data3.value=__decodeVal(((i*58)+49),(unsigned char*)line); | |
176 | #pragma omp critical |
|
|||
177 | { |
|
|||
178 |
|
|
168 | ch1->insertMulti(_x,data1); | |
179 |
|
|
169 | ch2->insertMulti(_x,data2); | |
180 |
|
|
170 | ch3->insertMulti(_x,data3); | |
181 | } |
|
|||
182 |
|
|
171 | curLine++; | |
183 |
|
|
172 | if(lastLineUpdate++>8000) | |
184 |
|
|
173 | { | |
185 |
|
|
174 | lastLineUpdate=0; | |
186 |
|
|
175 | int test=(curLine *100/ (lineCnt)); | |
187 |
|
|
176 | emit updateProgress(0,test); | |
188 |
|
|
177 | } | |
189 |
|
|
178 | } | |
190 | #pragma omp barrier |
|
179 | free(fileContent); | |
191 |
|
|
180 | } | |
192 | free(fileContent); |
|
|||
193 |
|
||||
194 | } |
|
|||
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