make naming of Logarithmic Conversion Function intelligible

This commit is contained in:
Tim Kuipers 2019-05-20 14:27:51 +02:00
parent beaa5e0b7a
commit 5b9a18f5df
3 changed files with 13 additions and 13 deletions

View file

@ -146,21 +146,21 @@ UM.Dialog
UM.TooltipArea { UM.TooltipArea {
Layout.fillWidth:true Layout.fillWidth:true
height: childrenRect.height height: childrenRect.height
text: catalog.i18nc("@info:tooltip","For lithophanes a logarithmic function is more appropriate for most materials. For height maps the pixel values correspond to heights linearly.") text: catalog.i18nc("@info:tooltip","For lithophanes a simple logarithmic model for translucency is available. For height maps the pixel values correspond to heights linearly.")
Row { Row {
width: parent.width width: parent.width
Label { Label {
text: "Conversion" text: "Color Model"
width: 150 * screenScaleFactor width: 150 * screenScaleFactor
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
ComboBox { ComboBox {
id: conversion id: color_model
objectName: "Conversion" objectName: "ColorModel"
model: [ catalog.i18nc("@item:inlistbox","Logarithmic"), catalog.i18nc("@item:inlistbox","Linear") ] model: [ catalog.i18nc("@item:inlistbox","Translucency"), catalog.i18nc("@item:inlistbox","Linear") ]
width: 180 * screenScaleFactor width: 180 * screenScaleFactor
onCurrentIndexChanged: { manager.onConvertFunctionChanged(currentIndex) } onCurrentIndexChanged: { manager.onColorModelChanged(currentIndex) }
} }
} }
} }

View file

@ -48,9 +48,9 @@ class ImageReader(MeshReader):
def _read(self, file_name): def _read(self, file_name):
size = max(self._ui.getWidth(), self._ui.getDepth()) size = max(self._ui.getWidth(), self._ui.getDepth())
return self._generateSceneNode(file_name, size, self._ui.peak_height, self._ui.base_height, self._ui.smoothing, 512, self._ui.lighter_is_higher, self._ui.use_logarithmic_function, self._ui.transmittance_1mm) return self._generateSceneNode(file_name, size, self._ui.peak_height, self._ui.base_height, self._ui.smoothing, 512, self._ui.lighter_is_higher, self._ui.use_transparency_model, self._ui.transmittance_1mm)
def _generateSceneNode(self, file_name, xz_size, peak_height, base_height, blur_iterations, max_size, lighter_is_higher, use_logarithmic_function, transmittance_1mm): def _generateSceneNode(self, file_name, xz_size, peak_height, base_height, blur_iterations, max_size, lighter_is_higher, use_transparency_model, transmittance_1mm):
scene_node = SceneNode() scene_node = SceneNode()
mesh = MeshBuilder() mesh = MeshBuilder()
@ -101,7 +101,7 @@ class ImageReader(MeshReader):
for x in range(0, width): for x in range(0, width):
for y in range(0, height): for y in range(0, height):
qrgb = img.pixel(x, y) qrgb = img.pixel(x, y)
if use_logarithmic_function: if use_transparency_model:
height_data[y, x] = (0.299 * math.pow(qRed(qrgb) / 255.0, 2.2) + 0.587 * math.pow(qGreen(qrgb) / 255.0, 2.2) + 0.114 * math.pow(qBlue(qrgb) / 255.0, 2.2)) height_data[y, x] = (0.299 * math.pow(qRed(qrgb) / 255.0, 2.2) + 0.587 * math.pow(qGreen(qrgb) / 255.0, 2.2) + 0.114 * math.pow(qBlue(qrgb) / 255.0, 2.2))
else: else:
height_data[y, x] = (0.212655 * qRed(qrgb) + 0.715158 * qGreen(qrgb) + 0.072187 * qBlue(qrgb)) / 255 # fast computation ignoring gamma and degamma height_data[y, x] = (0.212655 * qRed(qrgb) + 0.715158 * qGreen(qrgb) + 0.072187 * qBlue(qrgb)) / 255 # fast computation ignoring gamma and degamma
@ -128,7 +128,7 @@ class ImageReader(MeshReader):
Job.yieldThread() Job.yieldThread()
if use_logarithmic_function: if use_transparency_model:
p = 1.0 / math.log(transmittance_1mm / 100.0, 2) p = 1.0 / math.log(transmittance_1mm / 100.0, 2)
min_luminance = 2.0 ** ((peak_height - base_height) / p) min_luminance = 2.0 ** ((peak_height - base_height) / p)
for (y, x) in numpy.ndindex(height_data.shape): for (y, x) in numpy.ndindex(height_data.shape):

View file

@ -34,7 +34,7 @@ class ImageReaderUI(QObject):
self.peak_height = 2.5 self.peak_height = 2.5
self.smoothing = 1 self.smoothing = 1
self.lighter_is_higher = False; self.lighter_is_higher = False;
self.use_logarithmic_function = False; self.use_transparency_model = True;
self.transmittance_1mm = 40.0; self.transmittance_1mm = 40.0;
self._ui_lock = threading.Lock() self._ui_lock = threading.Lock()
@ -149,8 +149,8 @@ class ImageReaderUI(QObject):
self.lighter_is_higher = (value == 1) self.lighter_is_higher = (value == 1)
@pyqtSlot(int) @pyqtSlot(int)
def onConvertFunctionChanged(self, value): def onColorModelChanged(self, value):
self.use_logarithmic_function = (value == 0) self.use_transparency_model = (value == 0)
@pyqtSlot(int) @pyqtSlot(int)
def onTransmittanceChanged(self, value): def onTransmittanceChanged(self, value):