-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #795 from alicevision/dev_addAVImageViewer
[ui] Add a new FloatImageViewer
- Loading branch information
Showing
4 changed files
with
479 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import QtQuick 2.11 | ||
import Utils 1.0 | ||
|
||
import AliceVision 1.0 as AliceVision | ||
|
||
/** | ||
* FloatImage displays an Image with gamma / offset / channel controls | ||
* Requires QtAliceVision plugin. | ||
*/ | ||
|
||
AliceVision.FloatImageViewer { | ||
id: root | ||
|
||
width: textureSize.width | ||
height: textureSize.height | ||
visible: (status === Image.Ready) | ||
|
||
// paintedWidth / paintedHeight / status for compatibility with standard Image | ||
property int paintedWidth: textureSize.width | ||
property int paintedHeight: textureSize.height | ||
property var status: { | ||
if(root.loading) | ||
return Image.Loading; | ||
else if((root.source === "") || | ||
(root.sourceSize.height <= 0) || | ||
(root.sourceSize.height <= 0)) | ||
return Image.Null; | ||
return Image.Ready; | ||
} | ||
|
||
property string channelModeString : "rgba" | ||
|
||
channelMode: { | ||
switch(channelModeString) | ||
{ | ||
case "rgb": return AliceVision.FloatImageViewer.EChannelMode.RGB | ||
case "r": return AliceVision.FloatImageViewer.EChannelMode.R | ||
case "g": return AliceVision.FloatImageViewer.EChannelMode.G | ||
case "b": return AliceVision.FloatImageViewer.EChannelMode.B | ||
case "a": return AliceVision.FloatImageViewer.EChannelMode.A | ||
default: return AliceVision.FloatImageViewer.EChannelMode.RGBA | ||
} | ||
} | ||
clearBeforeLoad: true | ||
|
||
property alias containsMouse: mouseArea.containsMouse | ||
property alias mouseX: mouseArea.mouseX | ||
property alias mouseY: mouseArea.mouseY | ||
MouseArea { | ||
id: mouseArea | ||
anchors.fill: parent | ||
hoverEnabled: true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,237 @@ | ||
import QtQuick 2.11 | ||
import QtQuick.Controls 2.0 | ||
import QtQuick.Layouts 1.3 | ||
import MaterialIcons 2.2 | ||
import Controls 1.0 | ||
|
||
FloatingPane { | ||
id: root | ||
anchors.margins: 0 | ||
padding: 5 | ||
radius: 0 | ||
|
||
property real gammaDefaultValue: 1 | ||
property real offsetDefaultValue: 0 | ||
property real gammaValue: gammaCtrl.value | ||
property real offsetValue: offsetCtrl.value | ||
property string channelModeValue: channelsCtrl.value | ||
property variant colorRGBA: null | ||
|
||
background: Rectangle { color: root.palette.window } | ||
|
||
DoubleValidator { | ||
id: doubleValidator | ||
locale: 'C' // use '.' decimal separator disregarding of the system locale | ||
} | ||
|
||
RowLayout { | ||
id: toolLayout | ||
// anchors.verticalCenter: parent | ||
anchors.fill: parent | ||
|
||
// channel mode | ||
ComboBox { | ||
id: channelsCtrl | ||
|
||
// set min size to 4 characters + one margin for the combobox | ||
Layout.minimumWidth: 5.0 * Qt.application.font.pixelSize | ||
Layout.preferredWidth: Layout.minimumWidth | ||
flat: true | ||
|
||
property var channels: ["rgba", "rgb", "r", "g", "b","a"] | ||
property string value: channels[currentIndex] | ||
|
||
model: channels | ||
} | ||
|
||
// offset slider | ||
RowLayout { | ||
spacing: 5 | ||
|
||
ToolButton { | ||
text: "Gain" | ||
|
||
ToolTip.visible: ToolTip.text && hovered | ||
ToolTip.delay: 100 | ||
ToolTip.text: "Reset Gain" | ||
|
||
onClicked: { | ||
offsetCtrl.value = offsetDefaultValue; | ||
} | ||
} | ||
TextField { | ||
id: offsetLabel | ||
|
||
ToolTip.visible: ToolTip.text && hovered | ||
ToolTip.delay: 100 | ||
ToolTip.text: "Color Gain (in linear colorspace)" | ||
|
||
text: offsetValue.toFixed(2) | ||
Layout.preferredWidth: textMetrics_offsetValue.width | ||
selectByMouse: true | ||
validator: doubleValidator | ||
onAccepted: { | ||
offsetCtrl.value = Number(offsetLabel.text) | ||
} | ||
} | ||
Slider { | ||
id: offsetCtrl | ||
Layout.fillWidth: true | ||
from: -1 | ||
to: 1 | ||
value: 0 | ||
stepSize: 0.01 | ||
} | ||
} | ||
|
||
// gamma slider | ||
RowLayout { | ||
spacing: 5 | ||
|
||
ToolButton { | ||
text: "γ" | ||
|
||
ToolTip.visible: ToolTip.text && hovered | ||
ToolTip.delay: 100 | ||
ToolTip.text: "Reset Gamma" | ||
|
||
onClicked: { | ||
gammaCtrl.value = gammaDefaultValue; | ||
} | ||
} | ||
TextField { | ||
id: gammaLabel | ||
|
||
ToolTip.visible: ToolTip.text && hovered | ||
ToolTip.delay: 100 | ||
ToolTip.text: "Apply Gamma (after Gain and in linear colorspace)" | ||
|
||
text: gammaValue.toFixed(2) | ||
Layout.preferredWidth: textMetrics_offsetValue.width | ||
selectByMouse: true | ||
validator: doubleValidator | ||
onAccepted: { | ||
gammaCtrl.value = Number(offsetLabel.text) | ||
} | ||
} | ||
Slider { | ||
id: gammaCtrl | ||
Layout.fillWidth: true | ||
from: 0 | ||
to: 3 | ||
value: 1 | ||
stepSize: 0.01 | ||
} | ||
} | ||
|
||
Rectangle { | ||
Layout.preferredWidth: 20 | ||
implicitWidth: 20 | ||
implicitHeight: parent.height | ||
color: root.colorRGBA ? Qt.rgba(red.value_gamma, green.value_gamma, blue.value_gamma, 1.0) : "black" | ||
} | ||
|
||
// gamma slider | ||
RowLayout { | ||
spacing: 1 | ||
TextField { | ||
id: red | ||
property real value: root.colorRGBA ? root.colorRGBA.x : 0.0 | ||
property real value_gamma: Math.pow(value, 1.0/2.2) | ||
text: root.colorRGBA ? value.toFixed(6) : "--" | ||
|
||
Layout.preferredWidth: textMetrics_colorValue.width | ||
selectByMouse: true | ||
validator: doubleValidator | ||
horizontalAlignment: TextInput.AlignLeft | ||
readOnly: true | ||
// autoScroll: When the text is too long, display the left part | ||
// (with the most important values and cut the floating point details) | ||
autoScroll: false | ||
|
||
Rectangle { | ||
anchors.verticalCenter: parent.bottom | ||
width: parent.width | ||
height: 3 | ||
color: Qt.rgba(red.value_gamma, 0.0, 0.0, 1.0) | ||
} | ||
} | ||
TextField { | ||
id: green | ||
property real value: root.colorRGBA ? root.colorRGBA.y : 0.0 | ||
property real value_gamma: Math.pow(value, 1.0/2.2) | ||
text: root.colorRGBA ? value.toFixed(6) : "--" | ||
|
||
Layout.preferredWidth: textMetrics_colorValue.width | ||
selectByMouse: true | ||
validator: doubleValidator | ||
horizontalAlignment: TextInput.AlignLeft | ||
readOnly: true | ||
// autoScroll: When the text is too long, display the left part | ||
// (with the most important values and cut the floating point details) | ||
autoScroll: false | ||
|
||
Rectangle { | ||
anchors.verticalCenter: parent.bottom | ||
width: parent.width | ||
height: 3 | ||
color: Qt.rgba(0.0, green.value_gamma, 0.0, 1.0) | ||
} | ||
} | ||
TextField { | ||
id: blue | ||
property real value: root.colorRGBA ? root.colorRGBA.z : 0.0 | ||
property real value_gamma: Math.pow(value, 1.0/2.2) | ||
text: root.colorRGBA ? value.toFixed(6) : "--" | ||
|
||
Layout.preferredWidth: textMetrics_colorValue.width | ||
selectByMouse: true | ||
validator: doubleValidator | ||
horizontalAlignment: TextInput.AlignLeft | ||
readOnly: true | ||
// autoScroll: When the text is too long, display the left part | ||
// (with the most important values and cut the floating point details) | ||
autoScroll: false | ||
|
||
Rectangle { | ||
anchors.verticalCenter: parent.bottom | ||
width: parent.width | ||
height: 3 | ||
color: Qt.rgba(0.0, 0.0, blue.value_gamma, 1.0) | ||
} | ||
} | ||
TextField { | ||
id: alpha | ||
property real value: root.colorRGBA ? root.colorRGBA.w : 0.0 | ||
property real value_gamma: Math.pow(value, 1.0/2.2) | ||
text: root.colorRGBA ? value.toFixed(6) : "--" | ||
|
||
Layout.preferredWidth: textMetrics_colorValue.width | ||
selectByMouse: true | ||
validator: doubleValidator | ||
horizontalAlignment: TextInput.AlignLeft | ||
readOnly: true | ||
// autoScroll: When the text is too long, display the left part | ||
// (with the most important values and cut the floating point details) | ||
autoScroll: false | ||
|
||
Rectangle { | ||
anchors.verticalCenter: parent.bottom | ||
width: parent.width | ||
height: 3 | ||
color: Qt.rgba(alpha.value_gamma, alpha.value_gamma, alpha.value_gamma, 1.0) | ||
} | ||
} | ||
} | ||
} | ||
TextMetrics { | ||
id: textMetrics_colorValue | ||
font: red.font | ||
text: "1.2345" // use one more than expected to get the correct value (probably needed due to TextField margin) | ||
} | ||
TextMetrics { | ||
id: textMetrics_offsetValue | ||
font: offsetLabel.font | ||
text: "-10.01" | ||
} | ||
} |
Oops, something went wrong.