Make visible polygon hotspots

  • Hello,
    I'm trying to control the visibility of polygon hotspots (something like the old QTVR, where there was a button to show/hide ALL hotspots).
    I thought a good way was to change the "fillalpha" parameter.

    I CANNOT just have this(something similar to the switch(hotspot.visible) for POINT hotspot):

    Code
    onclick="set(hotspot.fillalpha,1) "


    it doesn't work!
    This works, but just for the specified hotspot:

    Code
    onclick="set(hotspot[hs1].fillalpha,1) "


    (and it doesn't work really nicely, as I have to click on the pano to see the change).

    I would like to show/hide ALL polygonal hotspots in the pano.

    Any idea?
    Thanks

    Toni

  • Normally you would be able to use a 'all' parameter, or you can parent all the hotspots to a plugin (as far as i know parenting only controls position,rotation and scale, but i can be wrong since i'm a beginner).

    there is offcourse another option to set all hotspots manually, or (i dont know it's possible) use a while-statement. You can number all hotspots like HS1, HS2, HS3... and apply the alpha.

    I think Klaus knows how to do this.

    hope this helps,

    Declan

  • Thank You, Pinsane. I have been looking for that and for some reason always overlooked that feature. I was planning on writing code for each hotspot to get that function but have been too lazy to do it. Putting something off until later paid off after all. *g*

    Having this on the plugin works great.

    onclick="switch(hotspot.visible);"

  • No Steve,
    what I would like is to show polygonal hotspots, that generally by default are invisible unless mouse rollover.
    I do not want to turn off them, just to set the parameter fillalpha for all of them.
    This because I think that is the only way to make visible a polygonal hotspot...
    ..and I don't know if it is possible...

    What you are saying is correct if you have image hotspot.
    With : onclick="switch(hotspot.visible);" you can show/hide only Image hotspots because you show/hide the embedded image...but polygonal hotspots doesn't have any image attached.

    Toni

  • I have found that if the hotspot is already visible whether it is a poly ( with the alpha something other than 0 ) or an image, it will dissapear when using that snippet of code. However, if it is not visible on start, it does not make it visible.

  • Quote

    No Steve,
    what I would like is to show polygonal hotspots, that generally by default are invisible unless mouse rollover.


    Sometimes an xml is worth a thousand words. This xml shows polygonal hotspots which have a low alpha value that is boosted when the mouse is moved over them. The star button at the bottom toggles all of the hotspots.

    If you have a mix of image hotspots and polygonal hotspots and you only want to turn off the polygonal ones, let me know. I've got a foreach function that should do the trick!

    hope this helps!

    steve

  • Thank you Steve,
    maybe I have to explain better what I would like to do, and I found a partial solution:
    here the example I mean:

    http://www.studioargento.com/examples/hotspot/

    1) I would like to have ALL hotspots to be active, visible or not.
    So I can't use switch(hotspot.visible), as it makes hotspots not working,
    even if this is a solution to hide/show them.

    2) I found that the code: switch(hotspot[hs1].fillalpha,0.5,0) works,
    but only if I add: set(update,view). *thumbsup*

    so the complete code would be:
    onclick="switch(hotspot[hs1].fillalpha,0.5,0); set(update,view);"

    This could be the solution, I can set in this way the alpha, color, bordercolor, etc of the hotspots,
    but now remains the problem that works just for 1 hotspot, the one named HS1.

    As I'm not skilled programmer, I don't know how to make a function that counts all the
    hotspots in the pano and apply the switch. Every pano has a different number of hotspots,
    and the button to hide/show hotspots is in the global.xml.

    As Declan says, "use a while-statement"...yes, but how?

    thanks all

    Toni

  • Toni,

    Okay, I think I get what you want. There is no built in looping function in the krpano action language, but it is possible to build one.

    If I understand you correctly, this xml should do what you want:

    best regards,

    steve

  • Hi Pinsane,

    Interesting piece of code that does exactly what Toni required *thumbup* ...

    I was not aware of the possibility to count the points of an hotspot. Now I am...
    It was interesting for me to try to understand how the foreach() and _foreach_action() worked...

    Thank you to share *smile* and congratulation for that code...

    SAlut.

  • THANKS A LOT STEVE,
    a nice professional piece of code! *thumbup*
    and I could easily add to the fillalpha, a fillcolor parameter.

    I'm trying to find a way to maintain the hotspots on/off also if I change panorama.

    http://www.studioargento.com/examples/hotspot/example2.html

    now, I have to admit my total ignorance on syntax, I think that it can be resolved
    by setting a variable ( on/off) when clicking the hotspot button,
    and when loading the other panorama, to read it and apply the action if the variable is (on).
    What is the best (working) method, use of set/get functions?

    Thanks again, hope this thread is useful for those who want to have the old style QTVR hotspots behavior...

    Toni

  • Hey Toni!

    I'm pleased the code solved your problem.

    Quote

    I'm trying to find a way to maintain the hotspots on/off also if I change panorama.


    I do this on my tours. You are correct, a setting a variable is a good way to solve the problem. You can test for the variable in the onxmlloaded event, and then set the alpha values accordingly.

    I've found that rather than using a toggle function (as we implemented in the code above) it's better to have two functions, a sethotspotson and a sethotspotsoff. Either strategy will work, but having separate functions is cleaner and more straightforward.

    Here's some sample code, this file should be named sethotspots1.xml:

    this file should be called sethotspots2.xml

    You'll see that the hotspot status is maintained from pano to pano.

    Good luck!

    steve

  • Steve:

    YESSS !!!! *thumbsup* *thumbsup*

    Your code is exactly what I was meaning for a Polygonal Hotspot Visibility Behavior:

    a) is possible to show/hide ALL hotspots, without taking care about how many they are for each pano, or what name they have.
    b) hotspots are still active
    c) is possible to set ALL the parameters referred to the polygonal hotspot, as fillalpha, fillcolor, borderwidth, bordercolor...
    d) hotspot hide/show state remains the same loading another pano.

    example3

    (I just detached from each sethotspots1.xml and sethotspots2.xml the common code and include it into the defaultskin.xml)

    Thanks again

    Best regards

    Toni

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!