groups and z order

Post questions on how to use or achieve an effect in Inkscape.
User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

groups and z order

Postby brynn » Tue Aug 09, 2011 10:08 pm

Hi Friends,
Well I thought I would find this in the Guide, but it's not mentioned.

I'm wondering if you group items, does everything in that group occupy one level in the z order? I have noticed that when I group items, that they no longer occupy their original places in the z order. But I'm not sure if they become sequential in the z order, or if they all actually occupy one level in the z order.

Do I need to make a quick illustration, or was that a clear enough question?

Thanks for your help :D

User avatar
RobA
Posts: 335
Joined: Fri Aug 10, 2007 1:22 am

Re: groups and z order

Postby RobA » Tue Aug 09, 2011 11:38 pm

Me testing shows the group ends up in the z position of the top object grouped (see attached)

-Rob A>
Attachments
GROUPING.png
GROUPING.png (41.97 KiB) Viewed 4465 times

User avatar
prkos
Posts: 1625
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: groups and z order

Postby prkos » Wed Aug 10, 2011 1:14 am

The group is also an object, so it will take some z-position in relation to other objects around it. Objects inside the group aren't "aware" of the objects outside the group, but there are positioned z-wise to one another. This comes from the text nature of SVG, z-order is determined by where in the SVG file the object is "written down". In SVG objects at the top of the document are drawn first, as you go down you see more objects and they are drawn on top of the "old" ones. So it's not possible for two objects to have the same z-index, even if you give them the same z-index in code the object that comes later in the document will be on top.
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: groups and z order

Postby brynn » Wed Aug 10, 2011 5:09 am

Yes RobA, I've also observed that the group takes the position in z order of the object in the group that was originally the topmost of all the grouped objects. That's not exactly what I'm asking.

prkos, so if a group is an object, then the whole group takes up one position in the z order?

Argh, let me do a quick illustration....
Image
On the left is 7 overlapping shapes/objects, and then to the right of that, I've pulled out each object in their z order, just for clarity. On the far right, I've grouped the red rectangle, blue ellipse and green ellipse. Thus they are moved from their original positions as 2nd, 4th and 6th in the z order to new positions. Then in the column to the left of that, with the black rectangle around it, I've again pulled out each object in their z order. So in that column, on the left side is one sequence of numbers, and on the right is another. Which way does it work? The numbers represent the z order.

When those 3 objects are grouped, do they now all 3 occupy the 2nd level in the z order, because a group is an object? (the left side) Or do they now occupy the 2nd, 3rd and 4th level in the z order? (the right side) Because when they are ungrouped, they do then occupy the 2nd, 3rd and 4th levels of the z order. So when objects are grouped and ungrouped, doesn't that cause the z order to be shuffled? Or should the objects return to their original positions after ungrouping, but that's not possible yet (hasn't been coded yet)?

I hope that helps.... :? rather then make it more confusing :D

User avatar
prkos
Posts: 1625
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: groups and z order

Postby prkos » Wed Aug 10, 2011 6:21 am

I guess I should first make it clear where I'm coming from - z-index is a CSS property, its value is a number, the higher the number the higher the objects gets in relation with other objects (so it's opposite of your labels), z is actually the third dimension (x, y, z), that's why the z-index behaves that way. When assigning z-order to consecutive objects the numbers don't have to be consecutive, usually when building websites and there's a need to z-order some elements I set them to 100, 200, 300, so if I ever have to insert some new elements in between them in z-order I don't have to change them, I just set the new element to 250 for example.

But we can use your example here with your numbering. I guess both of your cases are true, if you look at the group as an object and disregard its contents then the left column illustrates the objects order. If you take the inner objects into consideration you can "split" your numbering to show how the inside objects relate to one another, but because they're grouped they will always act as one towards the outside objects.

The objects aren't really shuffled when ungrouping, but when grouping, and as far as I know Inkscape doesn't use the actual z-index to reorder objects, but changes their position inside the document.

Try opening your example with the XML editor, see how objects are positioned within the document, how groups contain objects within them, try grouping and ungrouping and see how the text changes. This should give you a better idea about what's happening.
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

User avatar
RobA
Posts: 335
Joined: Fri Aug 10, 2007 1:22 am

Re: groups and z order

Postby RobA » Thu Aug 11, 2011 1:04 am

Apples and oranges.

In the current SVG spec, z order is determined by the order of objects in the DOM, not an attribute (like is CSS). To change the z-order (i.e. with javascript) you need to move the items of the DOM, not just change the z-index attribute and let the renderrer take care of it:

http://www.w3.org/TR/SVG/render.html#RenderingOrder

There is a proposal for the SVG group to change this that has had a positive reception:

http://lists.w3.org/Archives/Public/www ... /0042.html

-Rob A>

User avatar
prkos
Posts: 1625
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: groups and z order

Postby prkos » Thu Aug 11, 2011 7:19 pm

Thanx Rob A, I should have been more clear about where the web example stops and Inkscape discussion starts.

Brynn I hope I didn't confuse you too much :) what you should take from all this is that the order of the objects within the document is important and you should try some z-operations while XML editor is open to see how the objects are shuffled within text. Let us know how it goes!
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: groups and z order

Postby brynn » Fri Aug 12, 2011 2:52 am

Oh, interesting about using the XML editor to help keep track of things. That will be helpful indeed!

But now that brings up a whole new line of questions about the XML editor, lol. I will check out the Guide, to learn more about it. But really quickly, the green ellipse IS an ellipse, according to the status bar, but in the XML editor, it's called a path. Oh, ok all the ellipses are called paths. And the star is also called path too. But the rectangles are called rect. Well never mind, I'm sure the Guide will explain it.

Ok, if an object is not overlapping anything, and I select and click 'Raise selection one step' button, it doesn't move. But if it does overlap an object, and I click that button, it jumps past several other objects in the XML editor to be above (below in the editor) the object that it's overlapping. I thought "raise one step" meant that it would move down one line in the editor.

And that might explain why I have so much trouble with those extensions where one thing has to be above another. Because if they're not touching each other, it looks like they don't move when clicking the raise or lower buttons. However, I see that the raise to top button does move them to the bottom of the list, even if they are not overlapping anything.

And when they are overlapping, they move above or below whatever they are touching, even if that skips over several other objects in the z order.

Yeah, the part about using the z order on websites, well that's a whole new world for me. Someday I hope to be able to make a nice website. But for now, Rob's comments are way over my head :roll:

Well anyway, thanks for your help. I think things will go much easier for me, now that I understand that the z order is the same order as the list of objects in the XML editor. Even if I don't understand the whys and hows, the XML editor shows me where things are.

OH hey! If I have an object that I have to move to the top, for selection purposes (for example, but for whatever reason, move it to the top or bottom) then need to put it back where it was, but there's like a million z levels, could I just select it in the XML editor, and cut/paste back to its original position in z order? THAT would be awesome!

User avatar
prkos
Posts: 1625
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: groups and z order

Postby prkos » Fri Aug 12, 2011 7:00 am

brynn wrote:But now that brings up a whole new line of questions about the XML editor, lol. I will check out the Guide, to learn more about it. But really quickly, the green ellipse IS an ellipse, according to the status bar, but in the XML editor, it's called a path. Oh, ok all the ellipses are called paths. And the star is also called path too. But the rectangles are called rect. Well never mind, I'm sure the Guide will explain it.

Inkscape only has rectangles implemented, all other objects are paths :) It may come in the future.

Anyway I'm glad it's a bit more clear now :)

brynn wrote:OH hey! If I have an object that I have to move to the top, for selection purposes (for example, but for whatever reason, move it to the top or bottom) then need to put it back where it was, but there's like a million z levels, could I just select it in the XML editor, and cut/paste back to its original position in z order? THAT would be awesome!

We already had a lot of requests to temporarily bring the object to top, edit it and send back where it came from, but we don't have it yet. You can always duplicate the object, it will appear on top, edit it, then send back to the original and delete the original.
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

User avatar
RobA
Posts: 335
Joined: Fri Aug 10, 2007 1:22 am

Re: groups and z order

Postby RobA » Fri Aug 12, 2011 9:11 am

prkos wrote:We already had a lot of requests to temporarily bring the object to top, edit it and send back where it came from, but we don't have it yet. You can always duplicate the object, it will appear on top, edit it, then send back to the original and delete the original.


I bought Serif Drawplus X5 to complement my work in Inkscape. It has an interesting mode called "solo mode" that you activate and only the selected object remains visible - everything else is hidden - and you are editing the objects components. Imagine in Inkscape when you right click and "enter group" that everything else was set to hidden and you would have the same net effect.

-Rob A>

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: groups and z order

Postby brynn » Fri Aug 12, 2011 10:15 am

Well, for selecting was just one example. I often find I have to move an object out of its z position, and then have to click and click and click to get it back there where it started. Can I use copy/paste in the XML editor to accomplish it?

...then send back to the original...

But there's not a "send back to the original" button, is there? Because otherwise one could use it on the original rather than the duplicate. Right? Or is there a feature that I don't know about here?

User avatar
prkos
Posts: 1625
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: groups and z order

Postby prkos » Fri Aug 12, 2011 10:58 am

That's right, there isn't any "send back to the original" button, if only there were :)

Yes you can use the original of course, I suggested making a duplicate so it's easier to find where you need to push it after editing, the original becomes a bookmark :)
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: groups and z order

Postby brynn » Fri Aug 12, 2011 8:07 pm

....the original becomes a bookmark

Oh, you mean in the XML editor?

User avatar
prkos
Posts: 1625
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: groups and z order

Postby prkos » Fri Aug 12, 2011 8:48 pm

brynn wrote:
....the original becomes a bookmark

Oh, you mean in the XML editor?

eeer, no, in your mind actually :lol:
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: groups and z order

Postby druban » Sat Aug 13, 2011 1:24 am

Well, you can kind of mark the location of the original object by enclosing it in a group of one. Then when you want to copy, edit and replace, you just doubleclick on the original and open the group. Now when you paste the object, it will be pasted into the original group, and therefore back in its original location in the z-stack.
Although I do think it would be very useful to have a command in the edit > paste section, "Paste on top of / Paste above", available when one or more objects are selected ...

One can (well, I can, at any rate) envision, in a future Inkscape, such entities as Z-GUIDES: non-printing markers that can be inserted at any z-level that objects can thereafter be snapped to, sending the object to that place in the z-order where the guide was created... Just an analogue of the X and Y guides we now use...
Your mind is what you think it is.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: groups and z order

Postby brynn » Sun Aug 14, 2011 9:58 am

eeer, no, in your mind actually :lol:

Image

Z-Guides, that's an interesting concept!
I know there have been many requests for a sort of object manager, which would allow users a dialog, sort of like the Layers dialog, where users could just move objects in the list, which automatically changes their z order, without any horizontal or vertical movement. THAT would be the ideal solution, to my way of thinking.

But if such a thing as Z-Guide could be implemented quickly and easily, perhaps something to slip into Inkscape, until the object manager can be created, it would be nice. I don't know though, because my lack of knowledge about coding, for all I know, a z-guide might be more work than an object manager.

Since I see "snap" in druban's decription, maybe dvlierop would have a comment about the difficulty of creating such a feature? (If he happens to see this.)

I don't know about the idea of grouping the original (group of one). Because the reason the duplicate was made in the first place, was because (in my example) it was difficult to select. So double clicking it later would be equally difficult. But there are other reasons for needing to move an object out of the z order, or back to its original z position.

Anyway, thanks for everyone's comments :D


Return to “Help with using Inkscape”