Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] Camera Response Function display: fix instabilities on linux #1041

Merged
merged 3 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ def attribute(self, name):
def getAttributes(self):
return self._attributes

@Slot(str, result=bool)
def hasAttribute(self, name):
return name in self._attributes.keys()

Expand Down
44 changes: 26 additions & 18 deletions meshroom/ui/components/csvData.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import csv
import os
import logging


class CsvData(QObject):
"""Store data from a CSV file."""
Expand All @@ -20,13 +22,18 @@ def __init__(self, parent=None):
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
Expand All @@ -40,6 +47,7 @@ def setReady(self, ready):
self._ready = ready
self.readyChanged.emit()

@Slot()
def updateData(self):
self.setReady(False)
self._data.clear()
Expand All @@ -53,23 +61,23 @@ def read(self):
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 Exception as e:
logging.error("CsvData: Failed to load file: {}\n{}".format(self._filepath, str(e)))

return dataList

Expand Down Expand Up @@ -114,4 +122,4 @@ def fillChartSerie(self, serie):
serie.append(float(index), float(value))

title = Property(str, lambda self: self._title, constant=True)
content = Property("QStringList", lambda self: self._content, constant=True)
content = Property("QStringList", lambda self: self._content, constant=True)
6 changes: 4 additions & 2 deletions meshroom/ui/qml/Viewer/CameraResponseGraph.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 && csvData.ready && (csvData.getNbColumns() >= 4)
onCrfReadyChanged: {
if(crfReady)
{
Expand Down
9 changes: 7 additions & 2 deletions meshroom/ui/qml/Viewer/Viewer2D.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down