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
On 4/24/07, Derek Hinchliffe <derek@...1264...> wrote:
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 :)
My questions:
- 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 :)
- 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
- 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 wrote:
On 4/24/07, Derek Hinchliffe <derek@...1264...> wrote:
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
On 4/24/07, Joshua A. Andler <joshua@...533...> wrote:
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.
On 4/24/07, bulia byak wrote:
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
On 4/24/07, Alexandre Prokoudine <alexandre.prokoudine@...400...> wrote:
On 4/24/07, bulia byak wrote:
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.
On 4/24/07, bulia byak <buliabyak@...400...> wrote:
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 :)
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
On 4/24/07, MenTaLguY <mental@...3...> wrote:
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.
On Tue, 24 Apr 2007 16:23:42 -0300, "bulia byak" <buliabyak@...400...> wrote:
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
On Tue, 24 Apr 2007 12:48:28 -0700, MenTaLguY <mental@...3...> wrote:
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
On 4/24/07, MenTaLguY <mental@...3...> wrote:
On Tue, 24 Apr 2007 16:23:42 -0300, "bulia byak" <buliabyak@...400...> wrote:
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.
On Tue, 24 Apr 2007 17:05:39 -0300, "bulia byak" <buliabyak@...400...> wrote:
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
On 4/24/07, MenTaLguY <mental@...3...> wrote:
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.
On Tue, 24 Apr 2007 21:42:57 +0400, "Alexandre Prokoudine" <alexandre.prokoudine@...400...> wrote:
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
On Apr 24, 2007, at 10:36 AM, bulia byak wrote:
On 4/24/07, Joshua A. Andler <joshua@...533...> wrote:
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
On 4/25/07, bulia byak <buliabyak@...400...> wrote:
On 4/24/07, Derek Hinchliffe <derek@...1264...> wrote:
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
Bill Baxter said:
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
On 4/24/07, John Bintz <jcoswell@...1414...> wrote:
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.
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.
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
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.
On 4/25/07, bulia byak <buliabyak@...400...> wrote:
On 4/24/07, Derek Hinchliffe <derek@...1264...> wrote:
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
On Wed, 2007-04-25 at 09:49 +0800, Derek Hinchliffe wrote:
On 4/25/07, bulia byak <buliabyak@...400...> wrote:
On 4/24/07, Derek Hinchliffe <derek@...1264...> wrote:
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
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 Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
participants (9)
-
Alexandre Prokoudine
-
Bill Baxter
-
bulia byak
-
Derek Hinchliffe
-
John Bintz
-
Jon A. Cruz
-
Jon Phillips
-
Joshua A. Andler
-
MenTaLguY