Closed tcstewar closed 10 years ago
Note: by "centre of the screen" I meant "centre of the graph"
This is quite tricky, as 0,0 may not be anywhere near the middle of the network. The zoomCenter function that I wrote will put the model itself in the middle of the screen (and zoomed to mostly fill it). We could think about 'renormalizing' the positions at some point (maybe on such a zoom?) by centering the whole model on 0,0. You would basically just set the svg.g translate vector to 0,0 when centering the model. Should I do that?
I think something like the zoomCenter function makes sense, if I understand it correctly. Basically, I just want that when you save a layout and re-load it, it is about in the same place even if you load it in a window with a different resolution.
This isn't a high priority item, since it'll be fairly close anyway. I was just thinking of the problems we have with the current interactive plots visualizer when you make a nice gui display and then try to open it up during a presentation when the projector resolution is low, and all of a sudden all your graphs are off the screen. It'd be nice to avoid that with the html display.
Ok. Can you think of a good way to figure out when to do it (users can always make it happen by double clicking the background)? If we want it to be automatic maybe we should only do it on initial load (e.g. set a flag when the file manager is used to initiate the load)? (this would then effectively ignore the last view someone had when they saved the file).
Hmm, I think we're talking about different things. All I'm saying is that it'd be nice if the coordinate system we used was consistent. Right now, if something is in the top-left corner on your computer, when I open the same file, it'll be in the top-left corner of my screen. That's the consistent origin point right now. All I was saying is that we should use the centre of the screen as the consistent origin point instead.
Well the coordinate system isn't actually the screen, it's some point on the svg, which can be moved anywhere by user drags (even well off the screen). So, you can have huge translate and position vectors, and everything still looks nice on your (or any) screen. I think perhaps my first suggestion (of normalizing to 0,0 at some points) is more along the lines of what you're thinking. There I was saying to make the svg 0,0 the center of the screen (and model) every once in a while. I'm not sure exactly when we'd want to do that (save? center? something else?)
So, you can have huge translate and position vectors, and everything still looks nice on your (or any) screen
That's exactly what I'm saying doesn't happen right now. Try making a layout look nice when you're running at full screen, and save it. Now shrink your browser window and reload. You don't get the same display -- half your stuff is off the screen.
That said, it's not really important right now, since you can just scroll over (and maybe resize), but it's not how it should be long-term.
Ah, this is a different issue than the translate vectors and svg origin (their size or position won't change the behaviour you describe). Note that in your example, if you did that even without reloading/saving (ie just resized the screen) the same thing would happen. This is because svgs are independent of the view port you're looking at them through. Now, to do what you want, you could do something like save/track the current viewport size and if it changes, change the translate vector on the svg that would make it stay centered on the new viewport (you could also auto-scale it to make it fill the same proportion of the screen if you wanted). Very doable.
PS It might also be a good idea to also do the 'renormalize' thing just to keep the number smaller, less likely to get wired numerical errors after lots of editing.
Actually, it looks like the auto-zoom function now means that if you start with an empty network, that gets zoomed to the centre of the screen, which is a pretty good start for this.
There should be some initial transform that puts 0,0 in a reasonable location (I think the centre of the screen is best).
Two things this would help with: