objects in group can occupy different Z-layers

This is NOT a support forum. You are welcome to discuss software issues here, but all issues should be reported on Launchpad if you want them fixed.
User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

objects in group can occupy different Z-layers

Postby brynn » Sun Nov 16, 2008 4:23 pm

Interesting...to me, anyway :roll:
I'm sure this is not a problem, because I've seen it many times. But for some reason, it now strikes me as curious, why individual objects in a group can occupy different layers in the Z-Order. Because they cannot occupy different regular layers.

Why is it that grouping objects forces them into the same regular layer, yet not the same layer in the Z-Order? It just seems more logical that groups should behave in the z order, as they do in regular layers, i.e. - the objects in a group should occupy the same z layer, and grouping objects should force them into the same z layer (as in regular layers). I hope that wasnt' too redundant :P

Can anyone offer an explanation for this behavior? It's not that I have any issue with this. I just want to understnad Inkscape better.

Thanks for any comments :D

User avatar
kelan
Posts: 178
Joined: Thu Sep 06, 2007 12:55 am
Location: Unicorn of Open Source
Contact:

Re: objects in group can occupy different Z-layers

Postby kelan » Tue Nov 18, 2008 1:14 am

What do you mean by "z-layer" or "occupy different layers in the z-order"?

Anway, maybe I can just explain how z-order and layers work and that will answer your question.

As you probably know, SVG is an XML file format. Objects are made up of tags with particular attributes. The z-order of the objects is defined by the order that the tags appear in the XML. Earlier tags are rendered below later tags. As far as I know, every object has a distinct place in the z-order; no two objects can be at the same z-level.

Since it is XML, some tags can be nested within other tags. This is how groups work. The tags for all objects in a particular group are nested within the same SVG group tag. Groups behave the same as other objects with respect to z-order. So if you were reading the XML and saw:
  • rectangle
  • group
    • star
    • circle
  • text
you'd know that, from bottom to top, the z-order would be: rectangle, star, circle, text. The only thing groups do in regards to z-order is force all of the group members to appear together. In the above example, there's no way to put an object between the star and circle in the z-order without it being in the same group they are in.

In Inkscape, layers are implemented as regular SVG groups. There's an additional attribute that lets Inkscape present them differently in the UI, but really they're just groups. That's why a group of objects can't span layers: a group is treated as one SVG object (one XML tag, that happens to contain some other tags), and an object can't be a member of two disparate groups (because XML doesn't let you put one tag in two separate places).

User avatar
microUgly
Site Admin
Posts: 2985
Joined: Sat Jun 02, 2007 3:13 pm
Contact:

Re: objects in group can occupy different Z-layers

Postby microUgly » Tue Nov 18, 2008 8:57 am

Taking Kelans description a little further. If you have the following object
  • Red
  • Green
  • Blue
And you select Red and Blue and group them, you'll get
  • group
    • Red
    • Blue
  • Green

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

Re: objects in group can occupy different Z-layers

Postby brynn » Wed Nov 19, 2008 12:29 am

Thank you for all that interesting info, kelan. I'm sure it will help me to understand this issue. Unfortunately at this point, I can't make the connection to my question. (All I know about XML is that it's a source code for webpages. I did not know that svg is an xml file format.)

By Z-Order (which I find in one of the Help menu tutorials, I think 'Basic'), I mean the order in which objects are stacked up. Here, I'll put up an example.

Image

In this image, everything is all in the same regular layer. There is the grid of blue on top of a grid of purple, in the z-order. They are identical other than their color.

I want to lower all the blue squares with a red dot, below the purple squares. I have already lowered 6 of them (they are below the 6 numbered purple squares). So instead of moving them one at a time, I thought if I grouped them, I could lower them all in one click.

So all the blue squares with a red dot, plus the 6 that are already below purple squares, are in a group. I had to click Lower 5 times before the 1st blue square moved, revealing the purple square with the number "1". 2 more clicks, and the purple square with "2" is revealed. Then it took 4 clicks of the Lower button, to move the 3rd blue square below purple "3". Then it took 2 more clicks to get purple "4". Etc.

I'm pretty sure that the reason I have to click so many times, before something moves, illustrates your comment that each object occupies its own Z-Layer. And I suppose that's part of the answer to my question! Each object occupies one z-layer.

So in a group, there are as many Z-Layers as there are objects, right?
But those z layers aren't a group? Meaning that other objects can get between the z layers of grouped objects?

I still don't get how those purple squares can be between the blue squares' z layers.... Until now, I've thought of the z-order as something like sublayers, and expected they should behave like regular layers. So I still don't understand your comment:
The only thing groups do in regards to z-order is force all of the group members to appear together.

because the blue squares in my group are not appearing together. Some of them are below purple squares, and some are above. I expected that they should be either all above or all below the purple.

I know that in this case, I could use the Lower to bottom button, and move them all at once. And I may be able to manipulate things in my image, to allow me to do that. But the question is still nagging me, how some squares in the group can be below the purple squares, while some are still on top, and why they don't get lowered all at once.

Sorry if I seem dense -- it's really more like I don't have the right perspective to approach my question. I'm sure I'll get it, once I find the right approach.

Thanks for your help and patience :D

Slow Dog
Posts: 180
Joined: Wed Sep 24, 2008 7:51 pm

Re: objects in group can occupy different Z-layers

Postby Slow Dog » Wed Nov 19, 2008 1:06 am

brynn wrote: Each object occupies one z-layer.

Yes.

So in a group, there are as many Z-Layers as there are objects, right?
But those z layers aren't a group? Meaning that other objects can get between the z layers of grouped objects?

Yes, a group has layers. But other objects can't get between those layers.

I still don't get how those purple squares can be between the blue squares' z layers....

They aren't. The problem is you've got a hard-to-understand example, with lots of objects that don't overlap.

You start with layers like this:

Code: Select all

BlueSquareGroup
   BlueSquare1
   BlueSquare2
   BlueSquare3
BlueSquare4
BlueSquare5
BlueSquare6
PurpleSquare1
PurpleSquare2
PurpleSquare3

Where things overlap, see the top one. As blue squares overlap all purple squares, and are higher in the z-order, you see no purple.

Moving the group down once gets you

Code: Select all

BlueSquare4
BlueSquareGroup
   BlueSquare1
   BlueSquare2
   BlueSquare3
BlueSquare5
BlueSquare6
PurpleSquare1
PurpleSquare2
PurpleSquare3

Which looks just the same, because none of your blue squares overlap one another, and there are still blue squares over all purple ones.

Three more moves gets you

Code: Select all

BlueSquare4
BlueSquare5
BlueSquare6
PurpleSquare1
BlueSquareGroup
   BlueSquare1
   BlueSquare2
   BlueSquare3
PurpleSquare2
PurpleSquare3

And your first purple square has appeared, because it's now higher than the group. The other two purples are still lower.

User avatar
kelan
Posts: 178
Joined: Thu Sep 06, 2007 12:55 am
Location: Unicorn of Open Source
Contact:

Re: objects in group can occupy different Z-layers

Postby kelan » Wed Nov 19, 2008 1:41 am

brynn wrote:So in a group, there are as many Z-Layers as there are objects, right?
But those z layers aren't a group? Meaning that other objects can get between the z layers of grouped objects?

Within a group, the objects in that group still have a z-order, and objects outside the group cannot get inbetween the z-layers of objects in the group.

brynn wrote:So I still don't understand your comment:
The only thing groups do in regards to z-order is force all of the group members to appear together.

because the blue squares in my group are not appearing together. Some of them are below purple squares, and some are above. I expected that they should be either all above or all below the purple.

I can't be 100% sure without seeing the SVG, but I strongly suspect that it's because the purple squares are not grouped. The purple squares aren't getting between the grouped blue squares, it's the other way around. Whenever you lower your blue square group, it gets lowered below one more ungrouped blue square or purple square. So you get the effect that purple squares "float to the top" one at a time, since they aren't grouped. When it looks like nothing is happening, that's because the ungrouped blue squares are already visible, so nothing changes visibly when their position in the z-order changes. You'd see your expected behavior if you created three (maybe four?) groups: blue squares with dots, blue squares without dots, purple squares, (and maybe purple squares without dots, since you said the grid is identical). Then you'd be able to move all squares in one group below all squares in another group all at once.

Simarilius
Posts: 626
Joined: Wed Jun 06, 2007 2:37 am

Re: objects in group can occupy different Z-layers

Postby Simarilius » Wed Nov 19, 2008 3:16 am

Like the others have said, its not to do with the group of blues having multiple independant Zs, its that everything else still does.
The best way to think of it that I've found is to think of the individual items as a stack of transparancies like you'd use on an overhead projector. even if they dont have anything drawn on them the z-order is clearly there. Grouping is like putting several of them in a clear wallet, they then have an order inside that group, but the group as a whole acts as one object in the main stack.
Your example has still got a lot of individual blue and purple squares, and your group is still having to move about relative to them, if you see no change on a pgdn its because the shape its just dropped below in the zorder doesnt overlap the group and so there is no visible change in the image, although there is still a structural change in the XML tree.

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

Re: objects in group can occupy different Z-layers

Postby brynn » Thu Nov 20, 2008 4:47 am

Thanks for all your comments.
I still don't get it though.
Well, I get some of it. Why nothing appears to happen when I click, I get that. One object per z layer.

But
I can't be 100% sure without seeing the SVG, but I strongly suspect that it's because the purple squares are not grouped.

I thought of that! But when I grouped the purple squares, the grouped blue squares still moved one at a time.

I'll put up a svg file for everyone's convenience. BRB

[Edit] Whoops! Well this time, when I grouped the purple squares, the blue ones DID move all at once. I must have done something wrong when I tried it before.

I think I at least have a handle on the issue, even if I don't completely understand. I have something to go on, and I think everything will become more clear over time.

Thanks again for everyones comments, and efforts to help me learn. I really appreciate it!

All best :D :D


Return to “Discuss Software Issues”