allow zooming and panning...
This commit is contained in:
parent
6d76db329c
commit
6cc3b6c5b2
@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.6.2, 2018-08-29T14:49:31. -->
|
||||
<!-- Written by QtCreator 4.5.1, 2018-09-03T10:04:13. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{8b523b8d-f5ce-4be4-a9bd-780a0aec766f}</value>
|
||||
<value type="QByteArray">{854dd791-5ef0-48c7-a29e-c0b69b1d5eac}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
@ -59,14 +59,14 @@
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{d7263c99-5355-4486-be71-56523c5d259f}</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 5.10.1 (5.10.1)</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 5.10.1 (5.10.1)</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{3a0db74d-7ece-40c0-8cf4-3c58a6999fdf}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/grewe/zwischenlager/event_queue/build-DataService-Desktop-Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/jan/zwischenlager/threading_test/build-DataService-Qt_5_10_1_5_10_1-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@ -112,7 +112,7 @@
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
@ -120,13 +120,13 @@
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/grewe/zwischenlager/event_queue/build-DataService-Desktop-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/jan/zwischenlager/threading_test/build-DataService-Qt_5_10_1_5_10_1-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@ -172,7 +172,7 @@
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
@ -180,13 +180,13 @@
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/grewe/zwischenlager/event_queue/build-DataService-Desktop-Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/jan/zwischenlager/threading_test/build-DataService-Qt_5_10_1_5_10_1-Profile</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@ -232,7 +232,7 @@
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
@ -240,7 +240,7 @@
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
@ -249,12 +249,12 @@
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deployment</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy Configuration</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Lokales Deployment</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
@ -302,15 +302,12 @@
|
||||
</valuelist>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">DataService</value>
|
||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
|
||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
|
||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Benutzerdefinierte ausführbare Datei</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/grewe/zwischenlager/event_queue/DataService/DataService.pro</value>
|
||||
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">DataService.pro</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/grewe/zwischenlager/event_queue/build-DataService-Desktop-Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
|
47
chart.cpp
Normal file
47
chart.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include "chart.h"
|
||||
#include <QtWidgets/QGesture>
|
||||
#include <QtWidgets/QGraphicsScene>
|
||||
#include <QtWidgets/QGraphicsView>
|
||||
#include <QLineSeries>
|
||||
#include <iostream>
|
||||
|
||||
Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
||||
: QChart(QChart::ChartTypeCartesian, parent, wFlags)
|
||||
{
|
||||
// Seems that QGraphicsView (QChartView) does not grab gestures.
|
||||
// They can only be grabbed here in the QGraphicsWidget (QChart).
|
||||
grabGesture(Qt::PinchGesture);
|
||||
grabGesture(Qt::PanGesture);
|
||||
}
|
||||
|
||||
Chart::~Chart() {
|
||||
|
||||
}
|
||||
|
||||
bool Chart::sceneEvent(QEvent *event) {
|
||||
if (event->type() == QEvent::Gesture)
|
||||
return gestureEvent(static_cast<QGestureEvent *>(event));
|
||||
return QChart::event(event);
|
||||
}
|
||||
|
||||
bool Chart::gestureEvent(QGestureEvent *event) {
|
||||
if (QGesture *gesture = event->gesture(Qt::PanGesture)) {
|
||||
QPanGesture *pan = static_cast<QPanGesture *>(gesture);
|
||||
QChart::scroll(-(pan->delta().x()), pan->delta().y());
|
||||
}
|
||||
if (QGesture *gesture = event->gesture(Qt::PinchGesture)) {
|
||||
QPinchGesture *pinch = static_cast<QPinchGesture *>(gesture);
|
||||
if (pinch->changeFlags() & QPinchGesture::ScaleFactorChanged)
|
||||
QChart::zoom(pinch->scaleFactor());
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Chart::XRangeChanged(qreal min, qreal max) {
|
||||
std::cerr << "XRangeChanged" << min << "\t"<< max << std::endl;
|
||||
if (series().at(0)->type() == QtCharts::QAbstractSeries::SeriesTypeLine) {
|
||||
QLineSeries *s = static_cast<QLineSeries *>(series().at(0));
|
||||
std::cerr << s->at(0).x() << "\t"<< s->at(s->count()-1).x() << std::endl;
|
||||
}
|
||||
}
|
28
chart.h
Normal file
28
chart.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef CHART_H
|
||||
#define CHART_H
|
||||
|
||||
|
||||
#include <QtCharts/QChart>
|
||||
|
||||
class QGestureEvent;
|
||||
|
||||
QT_CHARTS_USE_NAMESPACE
|
||||
|
||||
class Chart : public QChart
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
|
||||
~Chart();
|
||||
|
||||
protected:
|
||||
bool sceneEvent(QEvent *event);
|
||||
|
||||
private:
|
||||
bool gestureEvent(QGestureEvent *event);
|
||||
|
||||
public slots:
|
||||
void XRangeChanged(qreal min, qreal max);
|
||||
};
|
||||
#endif // CHART_H
|
85
chartview.cpp
Normal file
85
chartview.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
#include "chartview.h"
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QScrollBar>
|
||||
|
||||
ChartView::ChartView(QChart *chart, QWidget *parent) :
|
||||
QChartView(chart, parent),
|
||||
m_isTouching(false)
|
||||
{
|
||||
setRubberBand(QChartView::RectangleRubberBand);
|
||||
addScrollBarWidget(bar, Qt::AlignBottom);
|
||||
}
|
||||
|
||||
|
||||
bool ChartView::viewportEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::TouchBegin) {
|
||||
// By default touch events are converted to mouse events. So
|
||||
// after this event we will get a mouse event also but we want
|
||||
// to handle touch events as gestures only. So we need this safeguard
|
||||
// to block mouse events that are actually generated from touch.
|
||||
m_isTouching = true;
|
||||
|
||||
// Turn off animations when handling gestures they
|
||||
// will only slow us down.
|
||||
chart()->setAnimationOptions(QChart::NoAnimation);
|
||||
}
|
||||
return QChartView::viewportEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void ChartView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_isTouching)
|
||||
return;
|
||||
QChartView::mousePressEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void ChartView::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_isTouching)
|
||||
return;
|
||||
QChartView::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void ChartView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_isTouching)
|
||||
m_isTouching = false;
|
||||
|
||||
// Because we disabled animations when touch event was detected
|
||||
// we must put them back on.
|
||||
//chart()->setAnimationOptions(QChart::SeriesAnimations);
|
||||
|
||||
QChartView::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void ChartView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Plus:
|
||||
chart()->zoomIn();
|
||||
break;
|
||||
case Qt::Key_Minus:
|
||||
chart()->zoomOut();
|
||||
break;
|
||||
case Qt::Key_Left:
|
||||
chart()->scroll(-10, 0);
|
||||
break;
|
||||
case Qt::Key_Right:
|
||||
chart()->scroll(10, 0);
|
||||
break;
|
||||
case Qt::Key_Up:
|
||||
chart()->scroll(0, 10);
|
||||
break;
|
||||
case Qt::Key_Down:
|
||||
chart()->scroll(0, -10);
|
||||
break;
|
||||
default:
|
||||
QGraphicsView::keyPressEvent(event);
|
||||
break;
|
||||
}
|
||||
}
|
25
chartview.h
Normal file
25
chartview.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef CHARTVIEW_H
|
||||
#define CHARTVIEW_H
|
||||
|
||||
#include <QtCharts/QChartView>
|
||||
#include <QtWidgets/QRubberBand>
|
||||
|
||||
QT_CHARTS_USE_NAMESPACE
|
||||
|
||||
class ChartView : public QChartView
|
||||
{
|
||||
public:
|
||||
ChartView(QChart *chart, QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
bool viewportEvent(QEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
private:
|
||||
bool m_isTouching;
|
||||
};
|
||||
|
||||
#endif // CHARTVIEW_H
|
@ -8,11 +8,17 @@ ConvertToSeries::ConvertToSeries(QObject *parent) : QObject(parent)
|
||||
|
||||
void ConvertToSeries::run() {
|
||||
mutex.lock();
|
||||
double min = data.ydata[0];
|
||||
double max = data.ydata[0];
|
||||
if (dataPresent) {
|
||||
for (size_t i = 0; i < data.xdata.size(); ++i) {
|
||||
this->series->append(data.xdata[i], data.ydata[i]);
|
||||
if (data.ydata[i] < min)
|
||||
min = data.ydata[i];
|
||||
if (data.ydata[i] > max)
|
||||
max = data.ydata[i];
|
||||
}
|
||||
emit dataConverted(series, QString::fromStdString(data.entityId));
|
||||
emit dataConverted(series, QString::fromStdString(data.entityId), min, max);
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
void setData(QLineSeries *series, const DataResult1D &data);
|
||||
|
||||
signals:
|
||||
void dataConverted(QLineSeries *series, QString entityId);
|
||||
void dataConverted(QLineSeries *series, QString entityId, double, double);
|
||||
|
||||
};
|
||||
|
||||
|
4
main.cpp
4
main.cpp
@ -8,6 +8,8 @@ int main(int argc, char *argv[])
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
w.grabGesture(Qt::PanGesture);
|
||||
w.grabGesture(Qt::PinchGesture);
|
||||
w.grabGesture(Qt::SwipeGesture);
|
||||
return a.exec();
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include "ui_mainwindow.h"
|
||||
#include "converttoseries.h"
|
||||
#include <iostream>
|
||||
#include "chart.h"
|
||||
#include "chartview.h"
|
||||
|
||||
using namespace QtCharts;
|
||||
|
||||
@ -25,26 +27,26 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
dataQueue.start();
|
||||
|
||||
connect(ui->requestDataBtn, SIGNAL(clicked(bool)), this, SLOT(requestData()));
|
||||
file = nix::File::open("/home/grewe/zwischenlager/2017-08-17-af-invivo-1/2017-08-17-af-invivo-1.nix",
|
||||
nix::FileMode::ReadOnly);
|
||||
//file = nix::File::open("/home/grewe/zwischenlager/2017-08-17-af-invivo-1/2017-08-17-af-invivo-1.nix",
|
||||
// nix::FileMode::ReadOnly);
|
||||
|
||||
//file = nix::File::open("/Users/jan/zwischenlager/threading_test/event_queue/DataService/data/2017-08-17-af-invivo-1.nix",
|
||||
// nix::FileMode::ReadOnly);
|
||||
file = nix::File::open("/Users/jan/zwischenlager/threading_test/dataservice/data/2017-08-17-af-invivo-1.nix",
|
||||
nix::FileMode::ReadOnly);
|
||||
nix::Block b = file.getBlock(0);
|
||||
this->voltage = b.getDataArray("V-1");
|
||||
this->eod = b.getDataArray("EOD");
|
||||
|
||||
voltageChart = new QChart();
|
||||
voltageChart = new Chart();
|
||||
voltageChart->legend()->hide();
|
||||
//voltageChart->createDefaultAxes();
|
||||
voltageChart->createDefaultAxes();
|
||||
|
||||
eodChart = new QChart();
|
||||
eodChart = new Chart();
|
||||
eodChart->legend()->hide();
|
||||
//eodChart->createDefaultAxes();
|
||||
eodChart->createDefaultAxes();
|
||||
|
||||
|
||||
chartMap.insert(std::pair<std::string, QChart*>(voltage.id(), voltageChart));
|
||||
chartMap.insert(std::pair<std::string, QChart*>(eod.id(), eodChart));
|
||||
chartMap.insert(std::pair<std::string, Chart*>(voltage.id(), voltageChart));
|
||||
chartMap.insert(std::pair<std::string, Chart*>(eod.id(), eodChart));
|
||||
|
||||
voltageChart->setTitle(QString::fromStdString(this->voltage.name()));
|
||||
eodChart->setTitle(QString::fromStdString(this->eod.name()));
|
||||
@ -52,9 +54,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
int marg1 = margins.left();
|
||||
margins.setLeft(marg1 * 4);
|
||||
eodChart->setMargins(margins);
|
||||
voltageView = new QtCharts::QChartView(voltageChart);
|
||||
eodView = new QtCharts::QChartView(eodChart);
|
||||
|
||||
voltageView = new ChartView(voltageChart);
|
||||
//voltageView->setRubberBand(QChartView::HorizontalRubberBand);
|
||||
voltageView->setLineWidth(1);
|
||||
eodView = new ChartView(eodChart);
|
||||
//eodView->setRubberBand(QChartView::HorizontalRubberBand);
|
||||
eodView->setLineWidth(1);
|
||||
voltageView->setRenderHint(QPainter::Antialiasing);
|
||||
eodView->setRenderHint(QPainter::Antialiasing);
|
||||
ui->vbox->addWidget(voltageView);
|
||||
@ -83,22 +88,41 @@ void MainWindow::dataReady(QString requestId) {
|
||||
ConvertToSeries *task = new ConvertToSeries();
|
||||
QLineSeries *series = new QLineSeries();
|
||||
task->setData(series, data);
|
||||
connect(task, SIGNAL(dataConverted(QLineSeries*,QString)), this, SLOT(dataConverted(QLineSeries*,QString)));
|
||||
connect(task, SIGNAL(dataConverted(QLineSeries*,QString, double, double)), this, SLOT(dataConverted(QLineSeries*,QString, double, double)));
|
||||
QThreadPool::globalInstance()->start(task);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::dataConverted(QLineSeries *series, QString entityId) {
|
||||
void MainWindow::dataConverted(QLineSeries *series, QString entityId, double ymin, double ymax) {
|
||||
Chart *chart = chartMap[entityId.toStdString()];
|
||||
series->setUseOpenGL(true);
|
||||
chart->addSeries(series);
|
||||
|
||||
QValueAxis *axisY = new QValueAxis;
|
||||
double range = ymax - ymin;
|
||||
axisY->setRange(ymin - 0.2 * range, ymax + 0.2 * range);
|
||||
axisY->setTickCount(10);
|
||||
axisY->applyNiceNumbers();
|
||||
axisY->setTitleText("Test");
|
||||
chart->setAxisY(axisY, series);
|
||||
|
||||
QValueAxis *axisX = new QValueAxis;
|
||||
axisX->setRange(series->at(0).x(), series->at(series->count()-1).x());
|
||||
axisX->setTickCount(10);
|
||||
axisX->setLabelFormat("%.4f");
|
||||
axisX->applyNiceNumbers();
|
||||
chart->setAxisX(axisX, series);
|
||||
connect(axisX, SIGNAL(rangeChanged(qreal,qreal)), chart, SLOT(XRangeChanged(qreal,qreal)));
|
||||
|
||||
QPen pen = series->pen();
|
||||
pen.setWidth(1);
|
||||
series->setPen(pen);
|
||||
chartMap[entityId.toStdString()]->addSeries(series);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::requestData() {
|
||||
if (voltage && eod) {
|
||||
nix::NDSize count(1, 10000);
|
||||
nix::NDSize count(1, 100000);
|
||||
nix::NDSize start(1, 0);
|
||||
std::string vId, eodId;
|
||||
dataQueue.requestData(voltage, count, start, vId);
|
||||
|
15
mainwindow.h
15
mainwindow.h
@ -2,13 +2,14 @@
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
//#include <QThread>
|
||||
#include <QtCharts>
|
||||
#include <nix.hpp>
|
||||
|
||||
#include "dataservice.h"
|
||||
#include "dataqueue.h"
|
||||
#include "dataresult1d.h"
|
||||
#include "chart.h"
|
||||
#include "chartview.h"
|
||||
|
||||
Q_DECLARE_METATYPE(DataResult1D)
|
||||
|
||||
@ -27,7 +28,7 @@ public:
|
||||
public slots:
|
||||
void requestData();
|
||||
void dataReady(QString requestId);
|
||||
void dataConverted(QLineSeries *series, QString entityId);
|
||||
void dataConverted(QLineSeries *series, QString entityId, double ymin, double ymax);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
@ -36,11 +37,11 @@ private:
|
||||
DataQueue dataQueue;
|
||||
nix::DataArray voltage, eod;
|
||||
nix::File file;
|
||||
QtCharts::QChartView *voltageView;
|
||||
QtCharts::QChartView *eodView;
|
||||
QtCharts::QChart *voltageChart;
|
||||
QtCharts::QChart *eodChart;
|
||||
std::map<std::string, QtCharts::QChart*> chartMap;
|
||||
ChartView *voltageView;
|
||||
ChartView *eodView;
|
||||
Chart *voltageChart;
|
||||
Chart *eodChart;
|
||||
std::map<std::string, Chart*> chartMap;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
Loading…
Reference in New Issue
Block a user