Discussion:
[Inkscape-devel] Canvas rotate
Derek Hinchliffe
2007-04-24 14:54:39 UTC
Permalink
Hi all,

I've had an idea that I'd like to try to implement in Inkscape and I'm
hoping someone better acquainted with the code base can suggest ways
it can be done and where to start.

The idea: allow the view of the canvas to be rotated (around the
current mouse cursor position) using keystrokes. I see three
keystrokes being required: rotate anti-clockwise, rotate clockwise,
and reset to normal.

Only the view of the canvas is rotated, and I see it mainly being used
when freehand drawing with the calligraphy or pencil tools using a
tablet. My particular reason for wanting it is that I find it much
easier to draw steady freehand curves with my wrist as a pivot, so
when I am drawing on paper I often rotate the page to suit.

My questions:
1. Is the architecture of the Inkscape canvas suited to implementing
this, or would is require major changes?

2. I have tried to work my way through the source relating to canvas
drawing but I'm still not sure what layer I should be looking at. Any
hints on what object(s) I should focus on?

3. Any comments as to how to approach it? Should I focus on trying to
rotate the view of the canvas, or should I look at applying a
(temporary) rotation to the entire SVG file?

Any thoughts appreciated!

Cheers
Derek
bulia byak
2007-04-24 16:22:34 UTC
Permalink
Post by Derek Hinchliffe
The idea: allow the view of the canvas to be rotated (around the
current mouse cursor position) using keystrokes. I see three
keystrokes being required: rotate anti-clockwise, rotate clockwise,
and reset to normal.
That's a very good idea and something I always wanted to do,
eventually. The only problem is to find a free keyboard shortcut for
this :)
Post by Derek Hinchliffe
1. Is the architecture of the Inkscape canvas suited to implementing
this, or would is require major changes?
Hopefully, yes. But you can't be sure until you try :)
Post by Derek Hinchliffe
2. I have tried to work my way through the source relating to canvas
drawing but I'm still not sure what layer I should be looking at. Any
hints on what object(s) I should focus on?
Hopefully all you need to change is the SPDesktop class (corresponding
to an editing window with a document), see below
Post by Derek Hinchliffe
3. Any comments as to how to approach it? Should I focus on trying to
rotate the view of the canvas, or should I look at applying a
(temporary) rotation to the entire SVG file?
Certainly not. We already handle zooming and panning in window, and
rotating would use the same mechanism. Namely, the SPDesktop class has
the _d2w member which is a matrix that translates the desktop
coordinate system (which is the same as document except it's flipped
vertically so that Y increases downwards - but this should not concern
you) into the window's coordinate system. This matrix currently holds
the scale (zoom) and translate (pan) components. But nothing prevents
you from adding rotation to it as well. In theory, that is all that's
needed - all display and interaction use _d2w, so everything should
just work. In practice, of course, there will be some gotchas, most
likely because some code silently assumes that _d2w can only contain
scales and translates but will break with rotation. But I think these
problems will be relatively easy to fix. Try it :)
--
bulia byak
Inkscape. Draw Freely.
http://www.inkscape.org
Joshua A. Andler
2007-04-24 17:00:05 UTC
Permalink
Post by bulia byak
Post by Derek Hinchliffe
The idea: allow the view of the canvas to be rotated (around the
current mouse cursor position) using keystrokes. I see three
keystrokes being required: rotate anti-clockwise, rotate clockwise,
and reset to normal.
That's a very good idea and something I always wanted to do,
eventually. The only problem is to find a free keyboard shortcut for
this :)
What about using the bracket keys (otherwise used to rotate selections)?
If there was no selection the canvas would rotate (with maybe an
exception on if you have mousedown with pencil or calligraphy tool it
would apply then too). And maybe shift with either bracket would reset.
Also, is Alt+Mousewheel or Alt+Wheelclick used? It seems like it would
compliment the other canvas view changing operations (zooming and panning).

-Josh
bulia byak
2007-04-24 17:36:14 UTC
Permalink
Post by Joshua A. Andler
What about using the bracket keys (otherwise used to rotate selections)?
If there was no selection the canvas would rotate
No. I don't want to have to deselect if I just want to rotate canvas.
I think I like the idea of using Alt+mousewheel for this; with Shift
and Ctrl it pans and zooms, so it's logical if with Alt it would
rotate.
--
bulia byak
Inkscape. Draw Freely.
http://www.inkscape.org
Alexandre Prokoudine
2007-04-24 17:42:57 UTC
Permalink
Post by bulia byak
No. I don't want to have to deselect if I just want to rotate canvas.
I think I like the idea of using Alt+mousewheel for this; with Shift
and Ctrl it pans and zooms, so it's logical if with Alt it would
rotate.
But in Node tool mode this will quasi-disable selecting neighbour
nodes, because currently both Ctrl+Mousewheel and Alt+Mousewheel do
it.

Alexandre
bulia byak
2007-04-24 18:20:35 UTC
Permalink
Post by Alexandre Prokoudine
Post by bulia byak
No. I don't want to have to deselect if I just want to rotate canvas.
I think I like the idea of using Alt+mousewheel for this; with Shift
and Ctrl it pans and zooms, so it's logical if with Alt it would
rotate.
But in Node tool mode this will quasi-disable selecting neighbour
nodes, because currently both Ctrl+Mousewheel and Alt+Mousewheel do
it.
Nope, it's done by plain mousewheel and with Ctrl, whereas Alt is free:

http://wiki.inkscape.org/wiki/index.php/ReleaseNotes045#Node_tool

And even if it were not free, it's kinda special node that's only
active over a node anyway.
--
bulia byak
Inkscape. Draw Freely.
http://www.inkscape.org
bulia byak
2007-04-24 19:03:01 UTC
Permalink
Post by bulia byak
And even if it were not free, it's kinda special node that's only
active over a node anyway.
Err, I mean, special mode - over a node :)
--
bulia byak
Inkscape. Draw Freely.
http://www.inkscape.org
MenTaLguY
2007-04-24 19:16:50 UTC
Permalink
On a side note, one difficulty we're going to have in implementation is that SPCanvas (unlike NRArena) wasn't really designed with general transformations (e.g. rotation) in mind. We're going to have problems with stuff like the page outline in particular. One reason why I wanted to migrate everything over to NRArena, and that may still be the best way to attack things.

(we'll need to add bulia's special compositing mode to NRArena, naturally)

-mental
bulia byak
2007-04-24 19:23:42 UTC
Permalink
Post by MenTaLguY
On a side note, one difficulty we're going to have in implementation is that SPCanvas (unlike NRArena) wasn't really designed with general transformations (e.g. rotation) in mind.
Yes. So page border, selected object frames, selection rect etc will
all be non-rotated and will look funny. But it should not be too
difficult to fix.
--
bulia byak
Inkscape. Draw Freely.
http://www.inkscape.org
MenTaLguY
2007-04-24 19:48:28 UTC
Permalink
Post by bulia byak
Yes. So page border, selected object frames, selection rect etc will
all be non-rotated and will look funny.
Hmm, the rubberband and selection cue rects should probably remain oriented with the window axes (as should the individual node items), though their behavior should obviously reflect the bounds/position of the rotated objects. Only the guides, grid, and page border need rotate with the drawing.

-mental
MenTaLguY
2007-04-24 20:04:36 UTC
Permalink
Post by MenTaLguY
Hmm, the rubberband and selection cue rects should probably remain
oriented with the window axes (as should the individual node items),
though their behavior should obviously reflect the bounds/position of the
rotated objects. Only the guides, grid, and page border need rotate with
the drawing.
Hmm .. so, we can simply include the rotation in the dtw transformation, rotate the drawing's NRCavnasArena (if that is possible -- we may have to introduce transformations to NRCanvasItems), and hide the guides, grid, and page border at nonzero rotation. That should be sufficient for a first implementation.

-mental
bulia byak
2007-04-24 20:05:39 UTC
Permalink
Post by MenTaLguY
Post by bulia byak
Yes. So page border, selected object frames, selection rect etc will
all be non-rotated and will look funny.
Hmm, the rubberband and selection cue rects should probably remain oriented with the window axes (as should the individual node items),
Yes on the rubberband, but no on selection cue rects - I think they
should be rotated too, if only because the bbox function returns the
rect as min() and max() points in the desktop coords, not in window
coords.

So, Derek: one thing you'll need to do is go to
display/sodipodi-ctrlrect.cpp and enable it to display rects that are
not aligned to horizontal/vertical. There are different approaches to
this but I think the simplest is to do rendering via straightforward
non-AA slanted lines. Then you will also need to do the same for grid
and guides.

Then (if we decide to leave selection rubberband unrotated) another
thing is to change the area selection code in selector and node tool
to enable it to select objects/nodes with a rotated rect (it will be
unrotated to the user, but rotated relative to the rotated canvas) -
right now this code assumes an axis-aligned rect.
--
bulia byak
Inkscape. Draw Freely.
http://www.inkscape.org
MenTaLguY
2007-04-24 20:11:28 UTC
Permalink
Post by bulia byak
Yes on the rubberband, but no on selection cue rects - I think they
should be rotated too, if only because the bbox function returns the
rect as min() and max() points in the desktop coords, not in window
coords.
Well ... the coordinate system to use should probably be an argument, as it is for the item bbox. Adding that and passing in the window coordinate system to get the selection cue box is probably considerably less work than redoing ctrlrect up front.

-mental
bulia byak
2007-04-24 20:17:24 UTC
Permalink
Post by MenTaLguY
Well ... the coordinate system to use should probably be an argument, as it is for the item bbox. Adding that and passing in the window coordinate system to get the selection cue box is probably considerably less work than redoing ctrlrect up front.
Yes. I think it's indeed a simpler thing to do - at least for a start,
to make the new mode already usable.
--
bulia byak
Inkscape. Draw Freely.
http://www.inkscape.org
MenTaLguY
2007-04-24 18:41:04 UTC
Permalink
Post by Alexandre Prokoudine
But in Node tool mode this will quasi-disable selecting neighbour
nodes, because currently both Ctrl+Mousewheel and Alt+Mousewheel do
it.
Alt+Mousewheel was never a documented shortcut, was it? It seems wasteful to keep both shortcuts for that purpose when we need shortcuts for other things.

-mental
Alexandre Prokoudine
2007-04-24 18:51:13 UTC
Permalink
Post by MenTaLguY
Alt+Mousewheel was never a documented shortcut, was it?
It seems wasteful to keep both shortcuts for that purpose when
we need shortcuts for other things.
Definitely, and the feature is very much worth it ;-)

Alexandre
Jon A. Cruz
2007-04-24 20:12:15 UTC
Permalink
Post by bulia byak
Post by Joshua A. Andler
What about using the bracket keys (otherwise used to rotate
selections)?
If there was no selection the canvas would rotate
No. I don't want to have to deselect if I just want to rotate canvas.
I think I like the idea of using Alt+mousewheel for this; with Shift
and Ctrl it pans and zooms, so it's logical if with Alt it would
rotate.
Or...

We could leverage alternate input devices. :-)

ShuttleXpress
http://www.contourdesign.com/shuttlepro/shuttlexpress.htm

ShuttlePRO
http://www.contourdesign.com/shuttlepro/

SpaceNavigator
http://www.3dconnexion.com/products/3a1d.php

SpaceTraveler
http://www.3dconnexion.com/products/3a1.php

NuLOOQ navigator
www.logitech.com/nulooq
MenTaLguY
2007-04-24 20:15:07 UTC
Permalink
Post by Jon A. Cruz
Or...
We could leverage alternate input devices. :-)
Natural rather than exclusive or, of course -- I don't think most people would want them to be a requirement for canvas rotation. :)

-mental
Alexandre Prokoudine
2007-04-24 20:20:10 UTC
Permalink
Post by MenTaLguY
Natural rather than exclusive or, of course -- I don't think most people
would want them to be a requirement for canvas rotation. :)
However, supporting HAL in a way that would let us use more input
devices would definitely rock ;-)

Alexandre
Bill Baxter
2007-04-24 17:13:15 UTC
Permalink
Post by bulia byak
Post by Derek Hinchliffe
The idea: allow the view of the canvas to be rotated (around the
current mouse cursor position) using keystrokes. I see three
keystrokes being required: rotate anti-clockwise, rotate clockwise,
and reset to normal.
That's a very good idea and something I always wanted to do,
eventually. The only problem is to find a free keyboard shortcut for
this :)
That would be excellent. I implemented that in a little vector
drawing app of my own. It really does make a free hand things much
easier to do.

I say go for it!

As for the input control, there's that little flow wheel on the Wacom
airbrush stylus. :-) Or sooner or later I suspect these nifty
multi-finger touch panels are going to make it out of the research
labs and into the marketplace. Then the problem's solve.

Actually I think the way to go for the UI is not keys for rotate left
and right, but key to go into rotate mode then drag to rotate around
the current center of the screen. I'm fond of dual-action toggle
keys where a long press gives you the mode only while the key is down,
and goes back to the previous mode on release, or full switch if you
just tap the key. But that doesn't seem to be a very popular sort of
UI for some reason.

In general I don't think current apps take maximal advantage of keys.
Every key is a button. With mice buttons we make a distinction
between click and double-click. Why not with keys on the keyboard?
And any key has the potential to serve as a modifier when you think
about it. Why should Ctrl-alt-shift-meta-option get all the fun? If
you make 'z' act like a modifier key too then you've almost just
doubled the number of keys at your disposal. Clearly you can go
overboard, but i believe there are creative ways to get more bang for
the buck out of the keys we have.

--bb
John Bintz
2007-04-24 17:42:26 UTC
Permalink
Post by Bill Baxter
Actually I think the way to go for the UI is not keys for rotate left
and right, but key to go into rotate mode then drag to rotate around the
current center of the screen.

With a modal keyboard shortcut, you now have to have an additional
indicator on screen that you are in a new "mode," something beyond a
cursor or toolbar icon. This could over-complicate the interface for what
is really a simple operation.

I think we should try and make canvas rotation work the same as zoom.
Since both affect the "camera" that looks upon the Inkscape document,
they should function the same, as well.

You can set the zoom precisely, or you can use the Zoom tool for a balance
between speed and precision, but if you're aiming for pure speed (like how
I work), using the keyboard with preset angles, or a modifier on the
scroll wheel as buila suggested, gets you close enough for most purposes.

Having a keyboard shortcut to perform a rotation at a set increment (10-15
degrees) would be sufficient for most purposes, since perfect precision of
the rotate angle isn't necessary for most illustration work. This would
work the same as the +/- keys or [ctrl]-wheel. The next step would be
having something to allow setting the rotation "free hand" as you've
described, by holding some key down and dragging the mouse. This is
similar to the Zoom tool. Finally, having a widget/dialog to set the
canvas rotation the same way that the zoom can be set would take care of
the precision aspect.

By the way, canvas rotation is something I infinitely miss from Toon Boom
when I'm working in Inkscape. :)

John
bulia byak
2007-04-24 21:42:44 UTC
Permalink
Post by John Bintz
With a modal keyboard shortcut, you now have to have an additional
indicator on screen that you are in a new "mode," something beyond a
cursor or toolbar icon. This could over-complicate the interface for what
is really a simple operation.
I agree.

I also notice that Alt+middle drag is currently free. So I think it
would make sense to enable it to rotate the canvas as well,
push-style, in addition to Alt+mousewheel that would rotate it by
increments (especially since in at least some devices, the mousewheel
is the same as middle button). Alt+double middle click could then
reset it back to zero angle.
Post by John Bintz
Having a keyboard shortcut to perform a rotation at a set increment (10-15
degrees) would be sufficient for most purposes, since perfect precision of
the rotate angle isn't necessary for most illustration work.
Yes.
Post by John Bintz
This would
work the same as the +/- keys or [ctrl]-wheel. The next step would be
having something to allow setting the rotation "free hand" as you've
described, by holding some key down and dragging the mouse.
Yes, Alt+middle drag as described above
Post by John Bintz
This is
similar to the Zoom tool. Finally, having a widget/dialog to set the
canvas rotation the same way that the zoom can be set would take care of
the precision aspect.
Just one more spinbutton marked R: next to the Z: spinbutton in the
statusbar would be perfect. However it must be hidden by default; only
when you rotate the canvas to any angle, it should be shown, and when
you reset angle it's again hidden.
--
bulia byak
Inkscape. Draw Freely.
http://www.inkscape.org
Derek Hinchliffe
2007-04-25 01:49:23 UTC
Permalink
Post by bulia byak
Post by Derek Hinchliffe
The idea: allow the view of the canvas to be rotated (around the
current mouse cursor position) using keystrokes. I see three
keystrokes being required: rotate anti-clockwise, rotate clockwise,
and reset to normal.
That's a very good idea and something I always wanted to do,
eventually. The only problem is to find a free keyboard shortcut for
this :)
I like this - fire off a quick email before going to bed, get up in
the morning and I have a nice long thread full off good ideas and
tips! Thanks bulia and everyone else for your help.

I'm going to start working on this today - will see how far I get.

Cheers
Derek
Jon Phillips
2007-04-25 04:24:11 UTC
Permalink
Post by Derek Hinchliffe
Post by bulia byak
Post by Derek Hinchliffe
The idea: allow the view of the canvas to be rotated (around the
current mouse cursor position) using keystrokes. I see three
keystrokes being required: rotate anti-clockwise, rotate clockwise,
and reset to normal.
That's a very good idea and something I always wanted to do,
eventually. The only problem is to find a free keyboard shortcut for
this :)
I like this - fire off a quick email before going to bed, get up in
the morning and I have a nice long thread full off good ideas and
tips! Thanks bulia and everyone else for your help.
I'm going to start working on this today - will see how far I get.
Cheers
Derek
Yep, that is the fun of Inkscape-style development :) Welcome aboard and
good luck! Personally, what I would like as well is custom document
sizes, possibly from the outlines of SVG ie, weird shapes that can be
folded into packaging, t-shirt designs, etc...cheers!

Jon
Post by Derek Hinchliffe
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Inkscape-devel mailing list
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
--
Jon Phillips

San Francisco, CA
USA PH 510.499.0894
***@rejon.org
http://www.rejon.org

MSN, AIM, Yahoo Chat: kidproto
Jabber Chat: ***@gristle.org
IRC: ***@irc.freenode.net
Alexandre Prokoudine
2007-04-25 09:18:42 UTC
Permalink
Post by Derek Hinchliffe
I'm going to start working on this today - will see how far I get.
If you get far enough, there is another long time awaited feature that
would make a perfect sense when canvas rotation is implemented --
arbitrary guides ;-)

Alexandre
Tom Lechner
2007-04-25 15:32:31 UTC
Permalink
Hi,
Post by bulia byak
I also notice that Alt+middle drag is currently free. So I think it
would make sense to enable it to rotate the canvas as well,
push-style, in addition to Alt+mousewheel that would rotate it by
increments (especially since in at least some devices, the mousewheel
is the same as middle button). Alt+double middle click could then
reset it back to zero angle.
I have alt-(various mouse buttons) currently set to do window and
workspace management things. Makes node sculpting a little troublesome
sometimes (but if I click first, then press alt, seems to work ok).

To not use alt for such things, from the beginning I've programmed my
Laidout program to have:
plain-right-click be context sensitive help,
shift-right-drag shifts (pans) the canvas around
control-right-drag scales the canvas (centered on mouse)
shift-control-right-drag rotates the canvas (centered on mouse)

Right now in Inkscape, control-R-drag seems to pan, (shift or
control)-R click without dragging zooms in and out. What if it was more
like the above?
Post by bulia byak
Yep, that is the fun of Inkscape-style development :) Welcome aboard
and good luck! Personally, what I would like as well is custom
document sizes, possibly from the outlines of SVG ie, weird shapes
that can be folded into packaging, t-shirt designs, etc...cheers!
Another thing I'm designing into Laidout! Though right now, it can only
do polygonal non-rectangular pages. Someday it'll be any bezier path,
so I can do layout on, for instance, the shape formed by the
intersection of several cylinders, which makes faces whose sides are
sine waves. Of course, objects going over page boundaries is rather a
chore to make work in an expected way, but it's worth it in the end.
Post by bulia byak
If you get far enough, there is another long time awaited feature
arbitrary guides ;-)
Another future Laidout feature! If by arbitrary guides you mean
arbitrary bezier paths, especially for text. Whenever I make up a new
resume, I find myself wanting to make tabstops lie along some funky
curve, rather than a boring old straight vertical line.

Another guide idea I'm working on is "2-d guides" for help in importing
multiple images, a kind of a distribution tool, to distribute into 1 or
more specified regions with specified orientations, whether to rescale
objects to fit, and whether to dump objects into a space as a kind of
stream. One application of this is dumping in 4 photos into 4 sections
on a page, so that each image is the maximum size it can be within each
section, rotating the photo if need be.

All of these things would be awesome in Inkscape!

Tom
http://www.tomlechner.com
http://www.laidout.org
Alexandre Prokoudine
2007-04-25 16:01:10 UTC
Permalink
Post by Tom Lechner
Another future Laidout feature! If by arbitrary guides you mean
arbitrary bezier paths, especially for text.
I mean guides like horizontal and vertical ones, just diagonal under
ome angle. Current workaround is using straight Bezier paths and
snapping objects to them. But I can't slide those paths the way I can
slide horizontal and vertical guides.

Alexandre

Loading...