Not a solution, but the reason that Cairo allows for bypassing the adjustment is because I needed that for supporting gtk. i felt like my original implementation was quite hacky, but I think Brent cleaned it up a bit.
Personally I think the possibility for bypassing adjustments should be added to all backends. The problem with auto scaling is that it makes it impossible to match query positions with canvas locations because you don't know the applied adjustment. If there were an alternative though, that would probably be ok.
--
You received this message because you are subscribed to the Google Groups "diagrams-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diagrams-discu...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
First of all, let me just mention that yes, there is a better way to
do this, using the 'view' function:
http://hackage.haskell.org/packages/archive/diagrams-lib/0.7/doc/html/Diagrams-TwoD-Combinators.html#v:view
It directly sets the envelope without having to use invisible lines.
In any case, after staring at your test code a bit, I think I now see
what is going on. Here's the story. You might want to get some
popcorn first.
In diagrams, the positive y-axis points *up* (because this is
standard mathematical practice, and as much as possible I want
diagrams to be semantically elegant and abstracted from concrete
representation details). In many graphics systems such as cairo and
SVG, the positive y-axis points *down*. So both the cairo and SVG
backends perform a 'reflectX' operation before handing off a diagram
to the adjustDia2D function.
Now, when the cairo bypass option selected, it actually *does NOT do
the reflection*, in addition to not calling adjustDia2D. The point of
the bypass option is to have the logical diagram coordinates
correspond to the cairo device coordinates, so you can e.g. easily
match up mouse clicks from a GTK window to your diagram. I actually
hadn't thought about this a whole lot up until now, but this is very
weird --- constructing a diagram in an upside-down coordinate system
means that e.g. (===) and vcat will appear to produce upside-down
results, and rotations will go in the wrong direction. In fact I
wonder how John dealt with these issues in his application! I rather
think we ought to get rid of the bypass option, and I have some ideas
for a nice way to still support John's use case. But that's for
another email.
Here's my interpretation of what happened: since Chart was based on
cairo, it uses cairo's y-axis-points-down coordinate system. (I notice
in your test that you say the line p2 (50, 50 ) ~~ p2 (450, 50) is
"above" the line p2 (50, 100) ~~ p2 (450, 100), but typically in
diagrams it would be the reverse!) Since you already have explicit
coordinates for everything calculated by Chart, you just draw all the
paths in their correct location directly, so you never noticed that
(===), vcat, rotate, etc. would have given strange results, because
you don't use them (?). You then enabled the cairo bypass option which
just so happened to NOT flip the diagram over, giving you the proper
behavior with cairo. However, the SVG backend does do a flip, so the
produced diagram is "upside down"... or perhaps it's the one which is
right side up, and you have been drawing upside down diagrams the
whole time. ;) It all depends on your point of view.
Here's my suggestion: use the 'view' function to get the desired area,
not the bypass, and then flip your diagram with reflectY at the very
end, before handing it to any backend. (Yes, this means reflectY will
be called twice in a row. That's life.)
I don't think I understand. Why cannot runBackend figure out the
correct width and height to use? Also, what does the default image
output by diagrams look like, vs. what it should look like (after
using the view function)? Is it just adding extra space around the
edges?