Compare commits
2 Commits
6619fbbbb6
...
23f96c214b
| Author | SHA1 | Date | |
|---|---|---|---|
| 23f96c214b | |||
| c62bbb8ef4 |
@ -2,7 +2,8 @@ import enum
|
|||||||
import csv
|
import csv
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from PySide6.QtCore import QObject, Signal, QTimer
|
from PySide6.QtCore import QObject, Signal, Slot, QTimer, QPointF
|
||||||
|
from PySide6.QtCharts import QLineSeries
|
||||||
|
|
||||||
|
|
||||||
class ProfileState(enum.Enum):
|
class ProfileState(enum.Enum):
|
||||||
@ -50,6 +51,14 @@ class ProfileHandler(QObject):
|
|||||||
self.profileChanged.emit(result)
|
self.profileChanged.emit(result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@Slot(QLineSeries)
|
||||||
|
def fill_series(self, series: QLineSeries):
|
||||||
|
points = []
|
||||||
|
for x, y in self._profile:
|
||||||
|
points.append(QPointF(x, y))
|
||||||
|
series.replace(points)
|
||||||
|
pass
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
assert self.state == ProfileState.STOPPED
|
assert self.state == ProfileState.STOPPED
|
||||||
|
|
||||||
|
|||||||
@ -29,21 +29,23 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onProfileChanged(data) {
|
function onProfileChanged(data) {
|
||||||
profileSeries.clear();
|
profile_handler.fill_series(profileSeries);
|
||||||
var last_x = 0;
|
var x_max = data[data.length - 1][0];
|
||||||
for (var point of data) {
|
axisX.max = x_max;
|
||||||
profileSeries.append(point[0], point[1]);
|
|
||||||
last_x = point[0];
|
|
||||||
}
|
|
||||||
axisX.max = last_x;
|
|
||||||
axisX.applyNiceNumbers();
|
axisX.applyNiceNumbers();
|
||||||
|
profileView.zoomReset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onProfileTimeChanged: {
|
onProfileTimeChanged: {
|
||||||
|
var old_x = profileView.mapToPosition(currentTimeSeries.at(0)).x;
|
||||||
currentTimeSeries.clear()
|
currentTimeSeries.clear()
|
||||||
currentTimeSeries.append(profileTime, 0)
|
currentTimeSeries.append(profileTime, 0)
|
||||||
currentTimeSeries.append(profileTime, 100)
|
currentTimeSeries.append(profileTime, 100)
|
||||||
|
var new_x = profileView.mapToPosition(currentTimeSeries.at(0)).x;
|
||||||
|
if (new_x > profileView.plotArea.width / 2) {
|
||||||
|
profileView.scrollRight(new_x - old_x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onBmsErrorChanged: {
|
onBmsErrorChanged: {
|
||||||
@ -68,6 +70,8 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ChartView {
|
ChartView {
|
||||||
|
id: profileView
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.minimumWidth: 400
|
Layout.minimumWidth: 400
|
||||||
@ -102,6 +106,28 @@ ApplicationWindow {
|
|||||||
visible: true
|
visible: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RowLayout {
|
||||||
|
Button {
|
||||||
|
text: "+"
|
||||||
|
onClicked: {
|
||||||
|
var r = Qt.rect(profileView.plotArea.x, profileView.plotArea.y, profileView.plotArea.width / 2, profileView.plotArea.height);
|
||||||
|
profileView.zoomIn(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: "-"
|
||||||
|
onClicked: {
|
||||||
|
var r = Qt.rect(profileView.plotArea.x, profileView.plotArea.y, profileView.plotArea.width * 2, profileView.plotArea.height);
|
||||||
|
profileView.zoomIn(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: "Reset zoom"
|
||||||
|
onClicked: {
|
||||||
|
profileView.zoomReset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Button {
|
Button {
|
||||||
objectName: "start_pause"
|
objectName: "start_pause"
|
||||||
|
|||||||
Reference in New Issue
Block a user