You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Taurus

Trainee

  • "Taurus" started this thread

Posts: 133

Location: Belarus

Occupation: photographer & virtual tour developer

  • Send private message

1

Monday, April 2nd 2018, 4:26pm

conflict of names in krpano on the example of the combobox plugin

Hello colleagues!
Thanks to Klaus for the great work!

by applying this code

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<include url="%SWFPATH%/plugins/combobox.xml" />

<events name="combo_refresh" keep="true" onloadcomplete="layer[cb1].selectItem(get(scene[get(xml.scene)].name))" />

<action name="create_box">
    addComboboxLayer(cb1, vtour);
    set(layer[cb1].align, 'leftbottom');
    set(layer[cb1].keep, true);
    set(layer[cb1].x, 20);
    set(layer[cb1].y, 20);
    layer[cb1].addItem(get(scene[get(xml.scene)].name));
    for(set(box_cnt,0), box_cnt LE scene.count, inc(box_cnt),  create_box2(get(box_cnt)));
</action>
<action name="create_box2">     
    layer[cb1].addItem(get(scene[%1].name), loadscene(get(scene[%1].name)) );
</action>

I found that the combobox on my tour did not work, showing such warnings

Source code

1
2
3
4
5
WARNING: Unknown action: cb.loadstyle 
WARNING: Unknown action: cb.createarray 
WARNING: Unknown action: layer[cb1].additem 

WARNING: Unknown action: layer[get(cbname)].scrollarea.update

By sequentially deleting parts of the program, I defined a module that prevented the operation of the combo box
then I found a conflicting piece of code in this module, it turned out to be an action, counting the coordinates of the hotspot insertion
this action is taken from the example, which is contained both in the original assembly of 1.14 pr15, and in earlier versions


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
        <action name="calc_pos_from_hfov_yaw_pitch_roll">
		calc(deg2rad, Math.PI / 180.0);

		<!-- calc the hotspot size -->
		calc(hfov, 0.5 * (%1) * deg2rad);
		Math.tan(hfov);
		set(width, calc(hfov * 1000));
		set(height, 'prop');

		<!-- calc the ath, atv and rotate settings -->
		calc(yaw, -(%2) * deg2rad);
		calc(pitch, (%3) * deg2rad);
		calc(roll, -(%4) * deg2rad);
		Math.cos(ch, yaw);
		Math.sin(sh, yaw);
		Math.cos(ca, pitch);
		Math.sin(sa, pitch);
		Math.cos(cb, roll);
		Math.sin(sb, roll);
		Math.atan2(yaw,  calc(cb*sh - sb*sa*ch), calc(ca*ch));
		Math.atan2(roll, calc(sb*ch - cb*sa*sh), calc(cb*ca));
		Math.asin(pitch, calc(cb*sa*ch + sb*sh));
		calc(ath, yaw / deg2rad);
		calc(atv, pitch / deg2rad);
		calc(rotate, roll / deg2rad);
	</action>

in order for the combo box to work fine, I had to change the names of the variables ch, sh, ca, sa, cb, sb

developing very complex virtual tours, I try to make sure that there are no conflicts with the old code in the new program modules, and I succeed
However, from time to time there are situations that are shown above
I believe that the documentation for the krpano should have a list of reserved words etc
--
in order to comply the word with the affairs, you need to keep quiet and do nothing!

Virtual tour Gomel
Virtual tour
Virtual tour
Elbrus
...

Windows 10x64 & krpano 1.19pr16

Alexey Tkachenko

Professional

Posts: 741

Location: Sevastopol, Crimea, Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

2

Monday, April 2nd 2018, 4:43pm

Hi)

That's why Klaus introduced actions with local scope - so that variables were not mixed or messed up.
Regards,

Alexey

3

Tuesday, April 3rd 2018, 6:18pm

Hi,

thanks for reporting!
I will improve the combobox.xml to make it better independent of other existing variables.

And here also the 'calc_pos_from_hfov_yaw_pitch_roll' action ported to local-scope usage to avoid any external conflicts:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<action name="calc_pos_from_hfov_yaw_pitch_roll" scope="localonly" args="hfov, yaw, pitch, roll">
    calc(deg2rad, Math.PI / 180.0);
    
    <!-- calc the hotspot size -->
    calc(hfov, 0.5 * hfov * deg2rad);
    Math.tan(hfov);
    set(caller.width, calc(hfov * 1000));
    set(caller.height, 'prop');

    <!-- calc the ath, atv and rotate settings -->
    calc(yaw, -yaw * deg2rad);
    calc(pitch, pitch * deg2rad);
    calc(roll, -roll * deg2rad);
    Math.cos(ch, yaw);
    Math.sin(sh, yaw);
    Math.cos(ca, pitch);
    Math.sin(sa, pitch);
    Math.cos(cb, roll);
    Math.sin(sb, roll);
    Math.atan2(yaw,  calc(cb*sh - sb*sa*ch), calc(ca*ch));
    Math.atan2(roll, calc(sb*ch - cb*sa*sh), calc(cb*ca));
    Math.asin(pitch, calc(cb*sa*ch + sb*sh));
    calc(caller.ath, yaw / deg2rad);
    calc(caller.atv, pitch / deg2rad);
    calc(caller.rotate, roll / deg2rad);
</action>


Best regards,
Klaus

Taurus

Trainee

  • "Taurus" started this thread

Posts: 133

Location: Belarus

Occupation: photographer & virtual tour developer

  • Send private message

4

Tuesday, April 3rd 2018, 11:08pm

Klaus, thank you for a great example of the localization of the action! *thumbsup*
I tried using

Source code

1
parentcopeset(variable, value)
and I did not succeed..

---
and yet, what do you think about drawing up a list of reserved words? *whistling*

Thanks
--
in order to comply the word with the affairs, you need to keep quiet and do nothing!

Virtual tour Gomel
Virtual tour
Virtual tour
Elbrus
...

Windows 10x64 & krpano 1.19pr16

5

Wednesday, April 4th 2018, 2:30pm

Hi,

I tried using
parentcopeset(variable, value)
and I did not succeed..
Sorry, not sure what you mean...


and yet, what do you think about drawing up a list of reserved words?
That would be here:
https://krpano.com/docu/xml/#top
https://krpano.com/docu/actions/#top

Beside of the elements defined there, there should be no other special 'reserved words'...

The problem in the first post was that a 'cb' named Number variable gets defined globally and in the combobox.xml also a 'cb' named variable was used, but there as Object - and when trying to save the Object into the existing and Number-typed variable, it fails and leads to the following errors.

When all actions would use scope="local" this wouldn't happen, because then all actions would define their new variables only in their own local scope.
But as long there are also actions without local scope there can be still problematic cases, because actions with scope="local" still have access to the global scope when a variable wasn't found in the local one. To avoid also such cases there is also the possibility to use scope="localonly" - then all variable access is limited to the local scope of the action and an unintended variable mixing or conflicts with same named variables not possible anymore.

With the new 1.19-pr16 release I have already updated the combobox.xml plugin now to use scope="localonly" in all actions and all other krpano xml plugins and xml skin files will also get updated too over time.

Best regards,
Klaus

6

Wednesday, April 4th 2018, 6:20pm

maybe it is as simple as...

Source code

1
parentcopeset(variable, get(value));

Taurus

Trainee

  • "Taurus" started this thread

Posts: 133

Location: Belarus

Occupation: photographer & virtual tour developer

  • Send private message

7

Saturday, April 7th 2018, 11:44am

Klaus, thanks for the clarification
unfortunately, in the documentation this topic is described very little
--
in order to comply the word with the affairs, you need to keep quiet and do nothing!

Virtual tour Gomel
Virtual tour
Virtual tour
Elbrus
...

Windows 10x64 & krpano 1.19pr16

Similar threads