Sie sind nicht angemeldet.

1

Dienstag, 6. Februar 2018, 18:53

How to write code in the log window

Hello everybody,

So we know Klaus's code which shows the sphere coordinates on mouse click:

Quellcode

1
<events onclick="screentosphere(mouse.x, mouse.y, m_ath, m_atv); showlog(); trace('clicked at ath=',m_ath,' atv=',m_atv);" />


I've been trying to modify this code so that it shows something like this in the log window:

Quellcode

1
2
3
4
	<point ath="28.4" atv="57.3" />
	<point ath="23.86" atv="65.47" />
	<point ath="26.85" atv="66.45" />
	<point ath="-106.16" atv="76.07" />


This way I could simply copy-past what's shown in the log window in my tour.xml file and my polygone hotspot would be draw.

That would be very convenient when drawing complexe polygone, and much faster than copy-pasting.

The problem is that insering character like quotes (") or smaller than (<) create syntax error. How can I "escape" such a character in order to make it appear in the log window ?

Or is there an even simpler way to do what I'm trying to achieve ?

Thanks a lot *thumbup*

Beiträge: 770

Wohnort: Russian Federation

Beruf: Interpreting, Building virtual tours

  • Nachricht senden

2

Dienstag, 6. Februar 2018, 19:09

Hi)

Try to use CDATA tags inside your action.

https://krpano.com/docu/xml/#action.js

https://krpano.com/docu/xml/#data
Regards,

Alexey

Beiträge: 770

Wohnort: Russian Federation

Beruf: Interpreting, Building virtual tours

  • Nachricht senden

3

Dienstag, 6. Februar 2018, 19:21

Here's a quick example.

Try to call this action from the onclick event inside pano.

Quellcode

1
<action name="trace_spot" ><![CDATA[	 ifnot(spot_coordinates, def(spot_coordinates, string, ' '); );	 screentosphere(mouse.x, mouse.y, m_ath, m_atv);	 txtadd(spot_coordinates, 		get(spot_coordinates),'		<spot ath="', get(m_ath) , '" atv="', get(m_atv) , '" />');		showlog();		trace(spot_coordinates); ]]>	</action>
Regards,

Alexey

4

Dienstag, 6. Februar 2018, 20:34

Hey Alexey,

I've tried your action and it's working, thanks !

Though, I'm pretty beginner and I must say I don't quite understand this code. I'll have to study that a bit ;)

Thanks anyway !

Beiträge: 770

Wohnort: Russian Federation

Beruf: Interpreting, Building virtual tours

  • Nachricht senden

5

Dienstag, 6. Februar 2018, 21:21

First step is to check if there's the 'spot_coordinates' variable and if no, define it as string and set empty. Then use screentoscphere to obtain sphere coordinates at the mouse position. Then use txtadd(); action to repeatedly add new fixed text and two variables (sphere coordinates) into the 'spot_coordinates' variable and then open log and trace it.
Regards,

Alexey

jordi

Profi

Beiträge: 583

Wohnort: Barcelona

Beruf: creating ideas & coding them

  • Nachricht senden

6

Mittwoch, 7. Februar 2018, 06:14

The problem is that insering character like quotes (") or smaller than (<) create syntax error
Not in the log, create an action that txtadd or calc your chain of code, there you can use reference entities to use forbidden character in xml
> &gt; ...

then this var where you stored all your data just print in the html of a text layer
everpano.com step beyond 360

7

Mittwoch, 7. Februar 2018, 11:19

Thanks Alexey ! Now I got it *thumbup*

I understand the use of the txtadd() function.

It actually also works without the CDATA tags.

Jordi, thanks for this idea, the reference entities trick is maybe even better *smile* At least the code then is a bit shorter. I can simply use Klaus's code and replace forbidden character by the corresponding reference and it works fine !

Quellcode

1
2
3
<events onclick="screentosphere(mouse.x, mouse.y, m_ath, m_atv);
					 showlog();
					 trace('&lt;point ath=&quot;',m_ath,'&quot; atv=&quot;',m_atv,'&quot;&gt;');" />


Thanks to both of you, it solved my question well ! *thumbsup*