[ui] GraphEditor: use maxZoom to fit on nodes (#1865)

This commit is contained in:
Sarah Brood 2023-01-18 12:49:03 +01:00 committed by GitHub
parent 2c7547e493
commit 56fe514582
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,6 +14,8 @@ Item {
property variant uigraph: null /// Meshroom ui graph (UIGraph)
readonly property variant graph: uigraph ? uigraph.graph : null /// core graph contained in ui graph
property variant nodeTypesModel: null /// the list of node types that can be instantiated
property real maxZoom: 2.0
property real minZoom: 0.1
property var edgeAboutToBeRemoved: undefined
@ -151,8 +153,6 @@ Item {
id: mouseArea
anchors.fill: parent
property double factor: 1.15
property real minZoom: 0.1
property real maxZoom: 2.0
// Activate multisampling for edges antialiasing
layer.enabled: true
layer.samples: 8
@ -799,8 +799,8 @@ Item {
function fit() {
// compute bounding box
var bbox = boundingBox()
// rescale
draggable.scale = Math.min(root.width/bbox.width, root.height/bbox.height)
// rescale to fit the bounding box in the view, zoom is limited to prevent huge text
draggable.scale = Math.min(Math.min(root.width/bbox.width, root.height/bbox.height),maxZoom)
// recenter
draggable.x = bbox.x*draggable.scale*-1 + (root.width-bbox.width*draggable.scale)*0.5
draggable.y = bbox.y*draggable.scale*-1 + (root.height-bbox.height*draggable.scale)*0.5