How to write code in the log window

  • Hello everybody,

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

    Code
    <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:

    Code
    <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*

  • Here's a quick example.

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

    Code
    <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>
  • 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 !

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

  • 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 !

    Code
    <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*

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!