mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-04 01:08:26 +02:00
[Distortion Viewer] refactoring lens distortion related files
This commit is contained in:
parent
bab5e71a71
commit
6f002d9a0d
4 changed files with 9 additions and 196 deletions
|
@ -138,7 +138,8 @@ AliceVision.FloatImageViewer {
|
|||
id: principalPoint
|
||||
Rectangle {
|
||||
id: ppRect
|
||||
width: root.sourceSize.width/100; height: width
|
||||
width: root.sourceSize.width/150; height: width
|
||||
radius : width/2
|
||||
x: 0
|
||||
y: 0
|
||||
color: "red"
|
||||
|
@ -158,7 +159,7 @@ AliceVision.FloatImageViewer {
|
|||
* Controls Points
|
||||
*/
|
||||
Item {
|
||||
id: grid
|
||||
id: points
|
||||
width: root.width
|
||||
height: root.height
|
||||
|
||||
|
@ -166,8 +167,8 @@ AliceVision.FloatImageViewer {
|
|||
target: root
|
||||
onVerticesChanged : {
|
||||
if (reinit){
|
||||
grid.recalculateCP();
|
||||
grid.generateControlPoints();
|
||||
points.recalculateCP();
|
||||
points.generateControlPoints();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +194,7 @@ AliceVision.FloatImageViewer {
|
|||
}
|
||||
|
||||
Component {
|
||||
id: rectGrid
|
||||
id: point
|
||||
Rectangle {
|
||||
id: rect
|
||||
width: root.sourceSize.width/100; height: width
|
||||
|
@ -220,7 +221,7 @@ AliceVision.FloatImageViewer {
|
|||
Repeater {
|
||||
id: repeater
|
||||
model: pointsNumber
|
||||
delegate: rectGrid
|
||||
delegate: point
|
||||
function displayControlPoints(state) {
|
||||
for (let i = 0; i < model; i++) {
|
||||
if (repeater.itemAt(i) !== null)
|
||||
|
|
|
@ -36,7 +36,6 @@ FloatingPane {
|
|||
|
||||
RowLayout {
|
||||
id: toolLayout
|
||||
// anchors.verticalCenter: parent
|
||||
anchors.fill: parent
|
||||
|
||||
MaterialToolButton {
|
||||
|
@ -149,8 +148,8 @@ FloatingPane {
|
|||
|
||||
//Fill rectangle to have a better UI
|
||||
Rectangle {
|
||||
color: root.palette.window
|
||||
Layout.fillWidth: true
|
||||
color: root.palette.window
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,158 +0,0 @@
|
|||
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.PanoramaViewer {
|
||||
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.width <= 0))
|
||||
return Image.Null;
|
||||
|
||||
root.defaultControlPoints();
|
||||
|
||||
return Image.Ready;
|
||||
}
|
||||
|
||||
property string channelModeString : "rgba"
|
||||
|
||||
property bool isCtrlPointsDisplayed : true;
|
||||
property bool isGridDisplayed : false;
|
||||
property int gridOpacity : 100;
|
||||
property color gridColor : "#FF0000";
|
||||
|
||||
onIsCtrlPointsDisplayedChanged: {
|
||||
repeater.displayControlPoints()
|
||||
}
|
||||
|
||||
onIsGridDisplayedChanged: {
|
||||
root.displayGrid()
|
||||
}
|
||||
|
||||
onGridOpacityChanged: {
|
||||
root.setGridColorQML(Qt.rgba(gridColor.r, gridColor.g, gridColor.b, gridOpacity/100));
|
||||
}
|
||||
|
||||
onGridColorChanged: {
|
||||
root.setGridColorQML(Qt.rgba(gridColor.r, gridColor.g, gridColor.b, gridOpacity/100));
|
||||
}
|
||||
|
||||
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
|
||||
// Do not intercept mouse events, only get the mouse over information
|
||||
acceptedButtons: Qt.NoButton
|
||||
}
|
||||
|
||||
Item {
|
||||
id: points
|
||||
width: root.width
|
||||
height: root.height
|
||||
|
||||
Connections {
|
||||
target: root
|
||||
onVerticesChanged : {
|
||||
if (reinit){
|
||||
grid.recalculateCP();
|
||||
grid.generateControlPoints();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function generateControlPoints() {
|
||||
if(repeater.model === 121){
|
||||
repeater.model = 0;
|
||||
}
|
||||
repeater.model = 121;
|
||||
}
|
||||
|
||||
function recalculateCP() {
|
||||
if (repeater.model === 0)
|
||||
return
|
||||
|
||||
var width = repeater.itemAt(0).width;
|
||||
var height = repeater.itemAt(0).height;
|
||||
|
||||
for (let i = 0; i < repeater.model; i++) {
|
||||
repeater.itemAt(i).x = root.getVertex(i).x - (width / 2);
|
||||
repeater.itemAt(i).y = root.getVertex(i).y - (height / 2);
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: rectGrid
|
||||
Rectangle {
|
||||
id: rect
|
||||
width: root.sourceSize.width/100; height: width
|
||||
radius: width/2
|
||||
x: root.getVertex(model.index).x - (width / 2)
|
||||
y: root.getVertex(model.index).y - (height / 2)
|
||||
color: "yellow"
|
||||
visible: true
|
||||
MouseArea {
|
||||
id: mouseAreaCP
|
||||
anchors.fill : parent;
|
||||
acceptedButtons: Qt.LeftButton
|
||||
|
||||
drag.target: rect
|
||||
drag.smoothed: false
|
||||
drag.axis: Drag.XAndYAxis
|
||||
onReleased: {
|
||||
root.setVertex(index, rect.x + (width / 2), rect.y + (height / 2))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: repeater
|
||||
model: 121
|
||||
delegate: rectGrid
|
||||
function displayControlPoints() {
|
||||
for (let i = 0; i < model; i++) {
|
||||
if (repeater.itemAt(i).visible) {
|
||||
repeater.itemAt(i).visible = false;
|
||||
}
|
||||
else {
|
||||
repeater.itemAt(i).visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -243,35 +243,6 @@ FocusScope {
|
|||
|
||||
}
|
||||
|
||||
// qtAliceVision Panorama Viewer
|
||||
// Loader {
|
||||
// id: lensDistortionViewerLoader
|
||||
// active: root.aliceVisionPluginAvailable && root.useLensDistortionViewer && !floatImageViewerLoader.active
|
||||
// visible: (lensDistortionViewerLoader.status === Loader.Ready)
|
||||
// anchors.centerIn: parent
|
||||
|
||||
// onActiveChanged: {
|
||||
// if(active) {
|
||||
// // instantiate and initialize a FeaturesViewer component dynamically using Loader.setSource
|
||||
// // Note: It does not work to use previously created component, so we re-create it with setSource.
|
||||
// // floatViewerComp.createObject(floatImageViewerLoader, {
|
||||
// setSource("LensDistortionViewer.qml", {
|
||||
// 'source': Qt.binding(function() { return getImageFile(imageType.type); }),
|
||||
// 'gamma': Qt.binding(function() { return lensDistortionImageToolbar.gammaValue; }),
|
||||
// 'gain': Qt.binding(function() { return lensDistortionImageToolbar.gainValue; }),
|
||||
// 'channelModeString': Qt.binding(function() { return lensDistortionImageToolbar.channelModeValue; }),
|
||||
// 'isCtrlPointsDisplayed' : Qt.binding(function(){ return lensDistortionImageToolbar.displayPoints;}),
|
||||
// 'isGridDisplayed' : Qt.binding(function(){ return lensDistortionImageToolbar.displayGrid;}),
|
||||
// 'gridOpacity' : Qt.binding(function(){ return lensDistortionImageToolbar.opacityValue;}),
|
||||
// 'gridColor' : Qt.binding(function(){ return lensDistortionImageToolbar.color;}),
|
||||
// })
|
||||
// } else {
|
||||
// // Force the unload (instead of using Component.onCompleted to load it once and for all) is necessary since Qt 5.14
|
||||
// setSource("", {})
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Simple QML Image Viewer (using Qt or qtOIIO to load images)
|
||||
Loader {
|
||||
id: qtImageViewerLoader
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue