These are chat archives for msalsbery/OpenSeadragonImaging

30th
Nov 2015
Ian Gilman
@iangilman
Nov 30 2015 17:14
@MereHappyJaZZ Might be good to file an issue with that suggestion :)
MereHappyJaZZ
@MereHappyJaZZ
Nov 30 2015 22:25
Okay! I've not spend much time with github and the likes before, so I thought "issues" was only with actual bugs, etc. =)
Ian Gilman
@iangilman
Nov 30 2015 22:26
I suppose it depends on who's in charge of the repository; even just questions are ok for some. At any rate, feature requests are generally fair game, and they'll probably be seen by more people (who might contribute) in the issues
MereHappyJaZZ
@MereHappyJaZZ
Nov 30 2015 22:30
Okay! I added an issue, thanks for the advice! =)
Ian Gilman
@iangilman
Nov 30 2015 22:33
Awesome :)
MereHappyJaZZ
@MereHappyJaZZ
Nov 30 2015 22:34
Are you also in charge of the SVG plugin?
Ian Gilman
@iangilman
Nov 30 2015 22:34
I am
(I'm not in charge of this plugin though)
MereHappyJaZZ
@MereHappyJaZZ
Nov 30 2015 22:35
Neat =) Is it possible to somehow overlay actual SVG files?
Ian Gilman
@iangilman
Nov 30 2015 22:36
Sure...once you have an SVG surface you can add whatever you want to it, including SVG from files.
I recommend using a library like D3 or Snap
MereHappyJaZZ
@MereHappyJaZZ
Nov 30 2015 22:36
I do a lot of data-extraction from the raw files going into my pyramids, and those can be plotted and saved in vector formats (.svg) - however, I only saw some kind of in-line adding of SVG in the online documentation (once again, I might have missed it)
I'll look into D3 and snap!
Ian Gilman
@iangilman
Nov 30 2015 22:38
Either one should have utilities for adding an SVG file to an SVG element
svg-overlay just provides you the SVG element for you to do with as you please
MereHappyJaZZ
@MereHappyJaZZ
Nov 30 2015 22:41
Aha - I will try to read up on it a bit better. So if I got an image-pyramid in OSD (I usually use the DZI format), I can, in principle, load a single big SVG file as an overlay, and it will correctly add elements to the right (x,y) coordinates?
What I'm kinda hinting at, is that I do a lot of data-analysis of the files going into the pyramids, and I'm looking for a neat way to overlay that data to the pyramid
Ian Gilman
@iangilman
Nov 30 2015 22:48
@MereHappyJaZZ Yup, should definitely be able to do that sort of thing with svg-overlay. Once you have the file lined up properly it'll stay that way as you zoom and pan
MereHappyJaZZ
@MereHappyJaZZ
Nov 30 2015 22:52
@iangilman Any chance you could provide a minimal working example of loading a .SVG file as an overlay? Sorry for being bit useless, I'm a materials engineer, so I don't actually know much about this kind of programming - I usually just brute-force the provided examples until I get some decent behaviour! =)
Ian Gilman
@iangilman
Nov 30 2015 22:58
Sure, just a sec
MereHappyJaZZ
@MereHappyJaZZ
Nov 30 2015 23:11
<3
I recommend Snap; it's less complicated than D3
Once you have snap loaded on your page, you can attach it to the svg-overlay like so:
                    var overlay = viewer.svgOverlay();
                    var snap = Snap(overlay.node());
And then loading an image and attaching it is something like:
Snap.load("my.svg", function (fragment) {
    var group = fragment.select("g");
    snap.append(group);
});
That's assuming that the top level element of your SVG file is a g element.
You'll probably find that the image coordinates don't line up with the coordinates of your SVG file...you'll have to do some transforming to make that work out
MereHappyJaZZ
@MereHappyJaZZ
Nov 30 2015 23:18
That was my next question! But in principle I can write my own custom SVG files, so I'll look into that! Thanks a bunch!
Ian Gilman
@iangilman
Nov 30 2015 23:18
Cool
Actually, probably the easiest thing is to specify the OSD image width to match whatever's in the SVG, like so in the options when creating the viewer:
                        tileSources: [{
                            tileSource: tileSource,
                            width: 500
                        }]
That's saying no matter how big the image actually is, display it at 500 width (assuming your SVG is 500 across)
You can also change the x and y of the OSD image as well
Anyway, it's either that or do some transforming on the SVG
@msalsbery Sorry to hijack your chatroom! ;)
MereHappyJaZZ
@MereHappyJaZZ
Nov 30 2015 23:21
That's a bit interesting. What's the effect of changing the width of my tileSource? Would I need to rescale the tileSize and tileOverlap to match?
Haha, yes, sorry =) Should I ask these things somewhere else?
Ian Gilman
@iangilman
Nov 30 2015 23:23
Perhaps, but I'm sure he doesn't mind :)
And no, the image size you specify when creating the viewer has nothing to do with actual pixels or tiles, it's just for the viewport coordinate system. See here: http://openseadragon.github.io/examples/viewport-coordinates/
MereHappyJaZZ
@MereHappyJaZZ
Nov 30 2015 23:24
Ah! So if I scale all my viewport coordinates to match my input SVG, it should make life easier
Ian Gilman
@iangilman
Nov 30 2015 23:24
Exactly :)
MereHappyJaZZ
@MereHappyJaZZ
Nov 30 2015 23:24
Nice =)