Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

Taurus

Schüler

  • »Taurus« ist der Autor dieses Themas

Beiträge: 140

Wohnort: Belarus

Beruf: photographer & virtual tour developer

  • Nachricht senden

1

Montag, 2. April 2018, 16:26

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

Quellcode

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

Quellcode

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


Quellcode

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.20

Beiträge: 770

Wohnort: Russian Federation

Beruf: Interpreting, Building virtual tours

  • Nachricht senden

2

Montag, 2. April 2018, 16:43

Hi)

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

Alexey

3

Dienstag, 3. April 2018, 18:18

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:

Quellcode

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

Schüler

  • »Taurus« ist der Autor dieses Themas

Beiträge: 140

Wohnort: Belarus

Beruf: photographer & virtual tour developer

  • Nachricht senden

4

Dienstag, 3. April 2018, 23:08

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

Quellcode

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.20

5

Mittwoch, 4. April 2018, 14:30

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

Mittwoch, 4. April 2018, 18:20

maybe it is as simple as...

Quellcode

1
parentcopeset(variable, get(value));

Taurus

Schüler

  • »Taurus« ist der Autor dieses Themas

Beiträge: 140

Wohnort: Belarus

Beruf: photographer & virtual tour developer

  • Nachricht senden

7

Samstag, 7. April 2018, 11:44

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.20

Ähnliche Themen