thatcher / openseadragon

This project has moved to its new github organization at github.com/openseadragon, please join us!
http://openseadragon,github.com/
37 stars 14 forks source link

Add Line and Polygon Overlay #3

Closed ghost closed 11 years ago

ghost commented 12 years ago

These would be great for annotating/highlighting points of interest on the image.

An example here: http://code.google.com/apis/maps/documentation/javascript/examples/polygon-simple.html

thatcher commented 11 years ago

At this point this is a feature I cant commit to making available since Id prefer to have a good overlay api and let raphaeljs or whatever be the driver. I do agree its difficult to identify areas of interest with the api currentl.

dgutman commented 11 years ago

I have some almost working code I will post tomorrow that uses raphae forked from a different project.... There's one issue related to how it attaches to the canvas I can't fix yet due to some library differences.... This version was based on sea dragon not openseadragon and some of the ways you get info about the viewport has changed which causes my code to die... On Feb 1, 2013 11:31 PM, "Chris Thatcher" notifications@github.com wrote:

At this point this is a feature I cant commit to making available since Id prefer to have a good overlay api and let raphaeljs or whatever be the driver. I do agree its difficult to identify areas of interest with the api currentl.

— Reply to this email directly or view it on GitHubhttps://github.com/thatcher/openseadragon/issues/3#issuecomment-13024591.

dgutman commented 11 years ago

So there is currently a basic implementation of this using SEADRAGON... not OpenSeadragon... however it shouldn't be impossible to get it to work..... I've just ran into some roadblocks and haven't had the time in openseadragon to fix the issue (although I know what it is).

https://github.com/rsimon/seajax-utils
This implements SVG using RAPHAEL... and works fairly well.

http://maps.no5.at/seajax-utils-demo/example.html is a nice demo.

I've been trying to get this working with openseadragon (will post it as openseajax-utils instead of seajax-utils)

http://node15.cci.emory.edu/OSD_SVG_DEMO/ It is from a library I am trying to modify ( openseajax-utils.js from seajax-utils)

To see it break.... from the console can you try to run viva_hispania()

The issue is: I am guessing the syntax used to add an event listener is different between seadragon and openseeadragon, but debugging this stuff takes me hours to days...

The problem is viewer doesn't have an addEventListener function. viewer.element does have this but does not have a source attribute (viewer has this). The attachTo tries to use variable.source to determine dimensions and variable.addEventListener to add an event handler, so passing either viewer or viewer.element to attachTo will blow up for different reasons.

Chris and / or Ian-- it seems like finding the proper object to bind this stuff to should be fairly straightforward... I just haven't been able to get my head completely around it--- as some of the events and functions were switched around (as I am sure you know).

Screenshot 2013-02-03 at 11 00 20 AM

iangilman commented 11 years ago

@dgutman, so you've built it as basically a plugin to the old Seadragon Ajax? I think that's a great approach for adding it to OpenSeadragon as well. What sorts of hooks would you need in order to support this?

dgutman commented 11 years ago

So I didn't write the original version-- but I am hoping to reuse it as it does most of what I need.. and can be added to as we move forward..

would be a rendering plugin...

Main issue I am having now is that once the SVG (or paper object) is render via Raphael... the overlay needs to be attached to the seadragon viewer....

In order for the SVG to scale properly, it reads/inherits certain properties from the viewer/viewport related to the size/aspect ratio/etc.... it seems like either the names and/or locations of those properties were moved during the seadragon--> openseadragon conversion process... and so when I try and attach it, I get a javascript error...

where in this case viewer is: viewer = new Seadragon.Viewer("container");

my_cool_picture.attachTo(viewer);

TypeError: Object [object Object] has no method 'addEventListener'

with the incredibly helpful messages below...

TypeError: Object [object Object] has no method 'addEventListener'

  1. arguments: Array[2]
    1. 0: "addEventListener"
    2. 1: $.Viewer
    3. length: 2
    4. proto: Array[0]
  2. get message: function () { [native code] }
    1. arguments: null
    2. caller: null
    3. length: 0
    4. name: ""
    5. prototype: Object
      1. constructor: function () { [native code] }
      2. proto: Object
    6. proto: function Empty() {}
  3. get stack: function () { [native code] }
    1. arguments: null
    2. caller: null
    3. length: 0
    4. name: ""
    5. prototype: Object
    6. proto: function Empty() {}
  4. set message: function () { [native code] }
    1. arguments: null
    2. caller: null
    3. length: 1
    4. name: ""
    5. prototype: Object
    6. proto: function Empty() {}
  5. set stack: function () { [native code] }
    1. arguments: null
    2. caller: null
    3. length: 1
    4. name: ""
    5. prototype: Object
    6. proto: function Empty() {}
  6. type: "undefined_method"
  7. proto: Error

On Mon, Feb 4, 2013 at 12:42 PM, iangilman notifications@github.com wrote:

@dgutman https://github.com/dgutman, so you've built it as basically a plugin to the old Seadragon Ajax? I think that's a great approach for adding it to OpenSeadragon as well. What sorts of hooks would you need in order to support this?

— Reply to this email directly or view it on GitHubhttps://github.com/thatcher/openseadragon/issues/3#issuecomment-13088971.

David A Gutman, M.D. Ph.D. Assistant Professor of Biomedical Informatics Senior Research Scientist, Center for Comprehensive Informatics Emory University School of Medicine

thatcher commented 11 years ago

Ill take a stab at fixing/adding the correct api hooks today to see if we can get this working in openseadragon. Nice work d!

thatcher commented 11 years ago

please see https://github.com/openseadragon/openseadragon/issues/14