You are not logged in.

a.pu

Trainee

  • "a.pu" started this thread

Posts: 93

Location: Default city, Russia

Occupation: Vtour dev, design, UX and photography

  • Send private message

1

Friday, February 14th 2020, 8:00pm

Separate layer structure from layer properties

Hi!

I feel a bit stuck with a quite simple trick which does not work...

I've got this piece of code in one file:

Source code

1
2
3
4
5
6
7
8
<!-- STRUCTURE -->
<layer name="layer1">
	<layer name="layer2"/>
</layer>

<!-- PROPERTIES -->
<layer name="layer1" keep="true" --- and all layer properties go here --- />
<layer name="layer2" keep="true" --- and all layer properties go here ---/>


It does not work!
Layer 2 does not recognize layer1 as parent

I don't want to specify parent in "properties" part like this:

Source code

1
2
3
4
5
6
7
8
<!-- STRUCTURE -->
<layer name="layer1">
	<layer name="layer2"/>
</layer>

<!-- PROPERTIES -->
<layer name="layer1" keep="true" --- and all layer properties go here --- />
<layer name="layer2" keep="true" parent="layer1" --- and all layer properties go here ---/>


because "structure" part won't make sense this way. And I'd like to have structure part as a description of parent-child relationship between two layers.

I remember about property overriding but it seems not to work here.
What am I doing wrong?

San7

Intermediate

Posts: 291

Occupation: coding in krpano

  • Send private message

2

Friday, February 14th 2020, 8:31pm

It seems to me that you need to write this way?

Source code

1
2
3
4
5
6
7
8
<!-- STRUCTURE -->
<layer name="layer1" style="layer1" >
	<layer name="layer2" style="layer2" />
</layer>

<!-- PROPERTIES -->
<style name="layer1" keep="true" --- and all layer properties go here --- />
<style name="layer2" keep="true" --- and all layer properties go here ---/>

a.pu

Trainee

  • "a.pu" started this thread

Posts: 93

Location: Default city, Russia

Occupation: Vtour dev, design, UX and photography

  • Send private message

3

Friday, February 14th 2020, 8:42pm

It seems to me that you need to write this way?

Source code

1
2
3
4
5
6
7
8
<!-- STRUCTURE -->
<layer name="layer1" style="layer1" >
	<layer name="layer2" style="layer2" />
</layer>

<!-- PROPERTIES -->
<style name="layer1" keep="true" --- and all layer properties go here --- />
<style name="layer2" keep="true" --- and all layer properties go here ---/>


Viable idea, it will work
Now we need to figure out why overriding doesn't :)

San7

Intermediate

Posts: 291

Occupation: coding in krpano

  • Send private message

4

Friday, February 14th 2020, 8:53pm

What exactly? With this entry, layer1 parent of layer2

a.pu

Trainee

  • "a.pu" started this thread

Posts: 93

Location: Default city, Russia

Occupation: Vtour dev, design, UX and photography

  • Send private message

5

Friday, February 14th 2020, 8:56pm

What exactly? With this entry, layer1 parent of layer2


I mean overriding in my sample piece of code.
Yours will work well

San7

Intermediate

Posts: 291

Occupation: coding in krpano

  • Send private message

6

Friday, February 14th 2020, 9:04pm

In your version, the lower layers will overwrite the upper ones and there is no sense in the upper record

a.pu

Trainee

  • "a.pu" started this thread

Posts: 93

Location: Default city, Russia

Occupation: Vtour dev, design, UX and photography

  • Send private message

7

Saturday, February 15th 2020, 8:22am

In your version, the lower layers will overwrite the upper ones and there is no sense in the upper record


Klaus, help! *confused*

8

Saturday, February 15th 2020, 9:19am

san7 already gave the answer

you cant define two elements with name="layer1" in the same xml, anyway. that should trigger an xml error.
that works only using two xml files, and then the second one overwrites the definition of the first one.

a.pu

Trainee

  • "a.pu" started this thread

Posts: 93

Location: Default city, Russia

Occupation: Vtour dev, design, UX and photography

  • Send private message

9

Saturday, February 15th 2020, 2:35pm

san7 already gave the answer

you cant define two elements with name="layer1" in the same xml, anyway. that should trigger an xml error.
that works only using two xml files, and then the second one overwrites the definition of the first one.


there won't be an XML error if you define two layers with same names in one file.

I've checked my code in different projects where layer data is split to different files and it seems that parent-child relationship can not be overridden, only overwritten. In each case I had to specify "parent" property to make things work correct.

Shame shame, I wished parent property to be overrideable too...

10

Monday, February 17th 2020, 12:14pm

i guess the parenting / parent attribute is maybe a special case
but you can do that by an action, ofc

a.pu

Trainee

  • "a.pu" started this thread

Posts: 93

Location: Default city, Russia

Occupation: Vtour dev, design, UX and photography

  • Send private message

11

Wednesday, February 26th 2020, 1:43pm

Klaus, can you please comment on this topic?

12

Thursday, February 27th 2020, 10:09am

Hi,

redefining xml elements to add or overwrite settings from them is possible,
but the xml tree-structure itself would need to be redefined too.

That 'flattening' of the xml structure to the named layers elements happens later after the xml parsing.

That means when you have a structure like this:

Source code

1
2
3
<layer name="layer1" style="layer1" >
	<layer name="layer2" style="layer2" />
</layer>


and want to add properites later, then the same xml structure need to be defined again:

Source code

1
2
3
<layer name="layer1" properties="here" ...>
	<layer name="layer2" properties="here" ... />
</layer>


See the 'vtourskin_design_ultra_light.xml' (in the 'tempaltes/xml/skin/' folder) as example - there this is done too.

Alternatively could use use actions to define the properties, then the xml structure doesn't matter anymore, e.g. this way:

Source code

1
2
3
4
5
<action autorun="preinit">
  set(layer[layer1], setting1=value1, setting2=value2, setting3=value3);
  set(layer[layer2], setting1=value1, setting2=value2, setting3=value3);
  ...
</action>


Best regards,
Klaus