mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-05 04:12:15 +02:00
[ui] Camera Response Function display: make it safer
More checks on file content and catch exception. Check nbColumns using a slot instead of using the property. Use a workaround on the CVS loader to avoid a crash (do not set active to False).
This commit is contained in:
parent
04c21fffe4
commit
b295242576
4 changed files with 38 additions and 22 deletions
|
@ -499,6 +499,7 @@ class BaseNode(BaseObject):
|
|||
def getAttributes(self):
|
||||
return self._attributes
|
||||
|
||||
@Slot(str, result=bool)
|
||||
def hasAttribute(self, name):
|
||||
return name in self._attributes.keys()
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from meshroom.common.qt import QObjectListModel
|
||||
|
||||
from PySide2.QtCore import QObject, Slot, Signal, Property
|
||||
from PySide2.QtCore import QObject, Slot, Signal, Property, Qt
|
||||
from PySide2.QtCharts import QtCharts
|
||||
|
||||
import csv
|
||||
import os
|
||||
import logging
|
||||
|
||||
|
||||
class CsvData(QObject):
|
||||
"""Store data from a CSV file."""
|
||||
|
@ -20,13 +22,18 @@ class CsvData(QObject):
|
|||
def getColumn(self, index):
|
||||
return self._data.at(index)
|
||||
|
||||
@Slot(result=str)
|
||||
def getFilepath(self):
|
||||
return self._filepath
|
||||
|
||||
@Slot(result=int)
|
||||
def getNbColumns(self):
|
||||
return len(self._data) if self._ready else 0
|
||||
if self._ready:
|
||||
return len(self._data)
|
||||
else:
|
||||
return 0
|
||||
|
||||
@Slot(str)
|
||||
def setFilepath(self, filepath):
|
||||
if self._filepath == filepath:
|
||||
return
|
||||
|
@ -40,6 +47,7 @@ class CsvData(QObject):
|
|||
self._ready = ready
|
||||
self.readyChanged.emit()
|
||||
|
||||
@Slot()
|
||||
def updateData(self):
|
||||
self.setReady(False)
|
||||
self._data.clear()
|
||||
|
@ -53,23 +61,23 @@ class CsvData(QObject):
|
|||
if not self._filepath or not self._filepath.lower().endswith(".csv") or not os.path.isfile(self._filepath):
|
||||
return []
|
||||
|
||||
csvRows = []
|
||||
with open(self._filepath, "r") as fp:
|
||||
reader = csv.reader(fp)
|
||||
for row in reader:
|
||||
csvRows.append(row)
|
||||
|
||||
dataList = []
|
||||
|
||||
# Create the objects in dataList
|
||||
# with the first line elements as objects' title
|
||||
for elt in csvRows[0]:
|
||||
dataList.append(CsvColumn(elt, parent=self._data))
|
||||
|
||||
# Populate the content attribute
|
||||
for elt in csvRows[1:]:
|
||||
for idx, value in enumerate(elt):
|
||||
dataList[idx].appendValue(value)
|
||||
try:
|
||||
csvRows = []
|
||||
with open(self._filepath, "r") as fp:
|
||||
reader = csv.reader(fp)
|
||||
for row in reader:
|
||||
csvRows.append(row)
|
||||
# Create the objects in dataList
|
||||
# with the first line elements as objects' title
|
||||
for elt in csvRows[0]:
|
||||
dataList.append(CsvColumn(elt)) # , parent=self._data
|
||||
# Populate the content attribute
|
||||
for elt in csvRows[1:]:
|
||||
for idx, value in enumerate(elt):
|
||||
dataList[idx].appendValue(value)
|
||||
except:
|
||||
logging.error("CsvData: Failed to load file: {}".format(self._filepath))
|
||||
|
||||
return dataList
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ FloatingPane {
|
|||
|
||||
CsvData {
|
||||
id: csvData
|
||||
filepath: ldrHdrCalibrationNode ? ldrHdrCalibrationNode.attribute("response").value : ""
|
||||
property bool hasAttr: (ldrHdrCalibrationNode && ldrHdrCalibrationNode.hasAttribute("response"))
|
||||
filepath: hasAttr ? ldrHdrCalibrationNode.attribute("response").value : ""
|
||||
}
|
||||
|
||||
// To avoid interaction with components in background
|
||||
|
@ -34,7 +35,8 @@ FloatingPane {
|
|||
onWheel: {}
|
||||
}
|
||||
|
||||
property bool crfReady: csvData.ready && csvData.nbColumns >= 4
|
||||
// note: We need to use csvData.getNbColumns() slot instead of the csvData.nbColumns property to avoid a crash on linux.
|
||||
property bool crfReady: csvData.ready && (csvData.getNbColumns() >= 4)
|
||||
onCrfReadyChanged: {
|
||||
if(crfReady)
|
||||
{
|
||||
|
|
|
@ -558,10 +558,15 @@ FocusScope {
|
|||
anchors.fill: parent
|
||||
|
||||
property var activeNode: _reconstruction.activeNodes.get('LdrToHdrCalibration').node
|
||||
active: activeNode && activeNode.isComputed && displayLdrHdrCalibrationGraph.checked
|
||||
property var isEnabled: displayLdrHdrCalibrationGraph.checked && activeNode && activeNode.isComputed
|
||||
// active: isEnabled
|
||||
// Setting "active" from true to false creates a crash on linux with Qt 5.14.2.
|
||||
// As a workaround, we clear the CameraResponseGraph with an empty node
|
||||
// and hide the loader content.
|
||||
visible: isEnabled
|
||||
|
||||
sourceComponent: CameraResponseGraph {
|
||||
ldrHdrCalibrationNode: activeNode
|
||||
ldrHdrCalibrationNode: isEnabled ? activeNode : null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue