SOC 2008 - project - Transformations Anchors
Hello
After a brief discussion on the list I did a small research for the Transformation Anchors idea. So, I 'd like to ask about the validity of the things I found.
* SVG 1.1 has a "transform" attribute which is used for some of the transformations.
Inkscape stores the transformation in the file as following: * "move", "scale" doesn't apply a trans matrix but simply moves, scales the coordinates. It also adds a second inkscape:perspective element. This one include a property "persp3d". This is related to the src/persp3d.cpp and the Persp3D class. * "rotate", "skew" applies a transformation matrix with the SVG:transform attribute. * "matrix" depends on the matrix's values. It could lead to one of the above situations.
The Transformation UI is implemented in ui/dialogs/transformations.cpp * sp_desktop_selection() is used in order to get the things the user has selected from the "drawing area". (I don't know if you have a specific name for the area on which the inkscape user draws and selects graphics from. I called it "drawing area"). * The functions Transformation::applyPage(Move|Rotate|Scale|...) are responsible for the transformation of the selection.
I then tried to figure out how "move" transformation works: updatePageMove() takes the bounding box from the selection. This is a NR::Rect object (NR::Maybe template). NR stands for "new renderer" right? I follow up to here but then I get a bit confused in this line: double x = bbox->min()[NR::X]; NR::Rect::min() returns a member of the NR::Rect class. It returns a Point instance. This class has overloaded the [] operators. With this overloading we return the [i]-th element of a Coord member. And this Coord is an array with 2 elements (for x and y). I think I think I lost the logic of it a bit...
Then we take the value which updatePageMove() had set and we apply it with applyPageMove(). This calls sp_selection_move_relative() and then sp_selection_apply_affine(). That's as far as I have seen.
So, it boils down to pass sp_selection_apply_affine() an argument about the center of the tranformation and change things in there so that the argument is used correctly?
Sorry for the lengthy mail. I just want to make sure that I get how things work in order to estimate the size of the project and the extend of changes in the base code.
Regards Vangelis Katsikaros
__________________________________________________ ×ñçóéìïðïéåßôå Yahoo!; ÂáñåèÞêáôå ôá åíï÷ëçôéêÜ ìçíýìáôá (spam); Ôï Yahoo! Mail äéáèÝôåé ôçí êáëýôåñç äõíáôÞ ðñïóôáóßá êáôÜ ôùí åíï÷ëçôéêþí ìçíõìÜôùí http://mail.yahoo.gr
Hi,
a quick note to two of the things you mentioned. Maybe someone can elaborate on the rest in detail.
Inkscape stores the transformation in the file as following:
- "move", "scale" doesn't apply a trans matrix but simply moves, scales
the coordinates. It also adds a second inkscape:perspective element. This one include a property "persp3d". This is related to the src/persp3d.cpp and the Persp3D class.
The persp3d reference only applies to 3D boxes (it points to a perspective stored in the defs which controls how 3D boxes appear on the screen). It has nothing to do with transformations in general so you can neglect it for your purposes.
I then tried to figure out how "move" transformation works: updatePageMove() takes the bounding box from the selection. This is a NR::Rect object (NR::Maybe template). NR stands for "new renderer" right? I follow up to here but then I get a bit confused in this line: double x = bbox->min()[NR::X]; NR::Rect::min() returns a member of the NR::Rect class.
No, NR::Rect::min() returns a NR::Point(). Namely, min() and max() respectively return the lower left and upper right corner of a rectangle (could also be the upper left and lower right, I don't know offhand), i.e. diagonally opposite corners. And NR::X/NR::Y are just enums with values 0/1 which are used as indices for the two coordinates of a point (see libnr/nr-dim2.h for their definition). So the above line simply stores the x-coordinate of the lower left corner of the bounding box (bbox) in a variable named 'x'.
Cheers, Max
participants (2)
-
Maximilian Albert
-
Vangelis Katsikaros