Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix home bounds with clipping. Fix #891 #910

Merged
merged 8 commits into from Apr 22, 2016

Conversation

avandecreme
Copy link
Member

I had to modify the Viewport.viewportToImage conversion methods to always use the TiledImage.viewportToImage methods in order for clipping to be taken into account.

@iangilman
Copy link
Member

The code looks reasonable, but I don't understand how TiledImage.viewportToImage... is taking clipping into account and thus helping Viewport.viewportToImage...... there doesn't seem to be any connection. What am I missing?

Also, I don't think those functions should be taking clipping into account anyway...we need to still mostly think in terms of the whole unclipped image, unless we want to dramatically change how we do things.

Anyway, set me straight :)

@avandecreme
Copy link
Member Author

Ha yes this is hard to spot in the diff.
The issue is that now viewport._setContentBounds is passed the world bounds with clipping taken into account.

So, all the viewport._contentXXX fields now take clipping into account. As you said we don't want the conversion methods to take clipping into account so we can't rely on them (at least for conversion, they are still useful to compute viewport constraints and default zoom). So I modified the viewport/image conversion methods to always call the tiledImage ones.
I still left the previous conversions when the viewport as no viewer but I am not sure if that ever happen.

@avandecreme
Copy link
Member Author

avandecreme commented Apr 15, 2016

@iangilman
Copy link
Member

I see! That makes a lot of sense... pretty subtle!

Yeah, I'm not sure where the idea that there could be a viewport without a viewer came in... that was before I got back on the project. I kinda feel like we don't really need to support that scenario, though I suppose it could be handy if you just wanted to use our viewport but do all of your own drawing. What do you think?

@avandecreme
Copy link
Member Author

I really don't have much opinion on this. I can't think of a case where I would use just the viewport in a project but I don't mind adding the missing tests or removing all of them (and add an assert in the constructor that a viewer is specified).

@avandecreme avandecreme mentioned this pull request Apr 18, 2016
@iangilman
Copy link
Member

Well, looks like I do in fact use a viewport without a viewer here:

http://www.driftory.com/

... but that was written before we had multi-image; if I were to do it today I would just use multi-image instead.

Anyway, since there are so few tests to add, we might as well keep it up, for now at least. Sound fair?

@iangilman iangilman added this to the 2.2.0 milestone Apr 18, 2016
@avandecreme
Copy link
Member Author

I added a test in setMargins.
Should I add one for the others? What should I do if this.viewer is not defined?

  1. Throw error
  2. Log an error and return an incorrect value
  3. ??

@iangilman
Copy link
Member

I think I'm in favor of logging an error and returning an incorrect value (i.e. 0). Calling those if you don't have a viewer is a programmer error.

@iangilman
Copy link
Member

... Or you could just stick a $.console.assert at the top of the function and let the function do whatever it will (presumably throw once it hits the unprotected viewer reference). Basically the goal here is just to give the developer a little more info as to what they did wrong, so an assert with a meaningful message should be sufficient.

@avandecreme
Copy link
Member Author

Done!

@iangilman
Copy link
Member

Excellent :)

@iangilman iangilman merged commit 5785d10 into openseadragon:master Apr 22, 2016
iangilman added a commit that referenced this pull request Apr 22, 2016
@avandecreme avandecreme deleted the home-clip branch April 22, 2016 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants