mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-22 05:26:29 +02:00
[ui] CsvData: fix data update
This commit is contained in:
parent
de93f795fb
commit
baaccb0562
2 changed files with 33 additions and 14 deletions
|
@ -23,6 +23,10 @@ class CsvData(QObject):
|
||||||
def getFilepath(self):
|
def getFilepath(self):
|
||||||
return self._filepath
|
return self._filepath
|
||||||
|
|
||||||
|
@Slot(result=int)
|
||||||
|
def getNbColumns(self):
|
||||||
|
return len(self._data) if self._ready else 0
|
||||||
|
|
||||||
def setFilepath(self, filepath):
|
def setFilepath(self, filepath):
|
||||||
if self._filepath == filepath:
|
if self._filepath == filepath:
|
||||||
return
|
return
|
||||||
|
@ -42,7 +46,7 @@ class CsvData(QObject):
|
||||||
newColumns = self.read()
|
newColumns = self.read()
|
||||||
if newColumns:
|
if newColumns:
|
||||||
self._data.setObjectList(newColumns)
|
self._data.setObjectList(newColumns)
|
||||||
self.setReady(True)
|
self.setReady(True)
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
"""Read the CSV file and return a list containing CsvColumn objects."""
|
"""Read the CSV file and return a list containing CsvColumn objects."""
|
||||||
|
@ -73,7 +77,8 @@ class CsvData(QObject):
|
||||||
filepath = Property(str, getFilepath, setFilepath, notify=filepathChanged)
|
filepath = Property(str, getFilepath, setFilepath, notify=filepathChanged)
|
||||||
readyChanged = Signal()
|
readyChanged = Signal()
|
||||||
ready = Property(bool, lambda self: self._ready, notify=readyChanged)
|
ready = Property(bool, lambda self: self._ready, notify=readyChanged)
|
||||||
data = Property(QObject, lambda self: self._data, constant=True)
|
data = Property(QObject, lambda self: self._data, notify=readyChanged)
|
||||||
|
nbColumns = Property(int, getNbColumns, notify=readyChanged)
|
||||||
|
|
||||||
|
|
||||||
class CsvColumn(QObject):
|
class CsvColumn(QObject):
|
||||||
|
|
|
@ -34,7 +34,24 @@ FloatingPane {
|
||||||
onWheel: {}
|
onWheel: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
property bool ready: csvData.ready
|
property bool crfReady: csvData.ready && csvData.nbColumns >= 4
|
||||||
|
onCrfReadyChanged: {
|
||||||
|
if(crfReady)
|
||||||
|
{
|
||||||
|
redCurve.clear()
|
||||||
|
greenCurve.clear()
|
||||||
|
blueCurve.clear()
|
||||||
|
csvData.getColumn(1).fillChartSerie(redCurve)
|
||||||
|
csvData.getColumn(2).fillChartSerie(greenCurve)
|
||||||
|
csvData.getColumn(3).fillChartSerie(blueCurve)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
redCurve.clear()
|
||||||
|
greenCurve.clear()
|
||||||
|
blueCurve.clear()
|
||||||
|
}
|
||||||
|
}
|
||||||
Item {
|
Item {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
@ -54,8 +71,8 @@ FloatingPane {
|
||||||
id: valueAxisX
|
id: valueAxisX
|
||||||
labelFormat: "%i"
|
labelFormat: "%i"
|
||||||
titleText: "Camera Brightness"
|
titleText: "Camera Brightness"
|
||||||
min: ready ? csvData.getColumn(0).getFirst() : 0
|
min: crfReady ? csvData.getColumn(0).getFirst() : 0
|
||||||
max: ready ? csvData.getColumn(0).getLast() : 1
|
max: crfReady ? csvData.getColumn(0).getLast() : 1
|
||||||
}
|
}
|
||||||
ValueAxis {
|
ValueAxis {
|
||||||
id: valueAxisY
|
id: valueAxisY
|
||||||
|
@ -67,30 +84,27 @@ FloatingPane {
|
||||||
// We cannot use a Repeater with these Components so we need to instantiate them one by one
|
// We cannot use a Repeater with these Components so we need to instantiate them one by one
|
||||||
// Red curve
|
// Red curve
|
||||||
LineSeries {
|
LineSeries {
|
||||||
|
id: redCurve
|
||||||
axisX: valueAxisX
|
axisX: valueAxisX
|
||||||
axisY: valueAxisY
|
axisY: valueAxisY
|
||||||
name: ready ? csvData.getColumn(1).title : ""
|
name: crfReady ? csvData.getColumn(1).title : ""
|
||||||
color: name.toLowerCase()
|
color: name.toLowerCase()
|
||||||
|
|
||||||
Component.onCompleted: if(ready) csvData.getColumn(1).fillChartSerie(this)
|
|
||||||
}
|
}
|
||||||
// Green curve
|
// Green curve
|
||||||
LineSeries {
|
LineSeries {
|
||||||
|
id: greenCurve
|
||||||
axisX: valueAxisX
|
axisX: valueAxisX
|
||||||
axisY: valueAxisY
|
axisY: valueAxisY
|
||||||
name: ready ? csvData.getColumn(2).title : ""
|
name: crfReady ? csvData.getColumn(2).title : ""
|
||||||
color: name.toLowerCase()
|
color: name.toLowerCase()
|
||||||
|
|
||||||
Component.onCompleted: if(ready) csvData.getColumn(2).fillChartSerie(this)
|
|
||||||
}
|
}
|
||||||
// Blue curve
|
// Blue curve
|
||||||
LineSeries {
|
LineSeries {
|
||||||
|
id: blueCurve
|
||||||
axisX: valueAxisX
|
axisX: valueAxisX
|
||||||
axisY: valueAxisY
|
axisY: valueAxisY
|
||||||
name: ready ? csvData.getColumn(3).title : ""
|
name: crfReady ? csvData.getColumn(3).title : ""
|
||||||
color: name.toLowerCase()
|
color: name.toLowerCase()
|
||||||
|
|
||||||
Component.onCompleted: if(ready) csvData.getColumn(3).fillChartSerie(this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue