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.

VN2009

Professional

  • "VN2009" started this thread

Posts: 1,336

Location: Duluth MN

  • Send private message

1

Wednesday, September 29th 2010, 8:14pm

dynamically remove all hotspots

i am using the addhotspot command to create 15 hotpost in a pano. is there a way i can remove them all at once without declaring each individual hotspot to remove? maybe using this type of looping i found in another thread. can it be modified to remove hotspots?

<action name="loop_all_hotspots">
set(i,0);
loop_all_hotspots_next(get(i));
</action>

<action name="loop_all_hotspots_next">
trace(hotspot[%1].name);
set(hotspot[%1].onclick, ...);
...
inc(i);
if(i LT hotspot.count, loop_all_hotspots_next(get(i)) );
</action>

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

2

Wednesday, September 29th 2010, 10:27pm

Hi VN2009 *smile* ,

At first it seems not so difficult... But it is not so easy than it seems ;-) ... The more important here is to remove the hotspot array from the greater to smaller...
So, here a code based on your:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
	<action name="loop_all_hotspots">
		showlog();
		trace('hotspot.count = ',hotspot.count);
		sub(i,hotspot.count,1);
		trace('i = ',i);
		loop_all_hotspots_next(get(i));
	</action>

	<action name="loop_all_hotspots_next">
		trace('hotspot[%1].name = ',hotspot[%1].name);
		removehotspot(%1);
		dec(i);
		trace('i = ',i);
		if(i GE 0, loop_all_hotspots_next(get(i)) );
	</action>


Hope this help...

SAlut.

VN2009

Professional

  • "VN2009" started this thread

Posts: 1,336

Location: Duluth MN

  • Send private message

3

Wednesday, September 29th 2010, 11:02pm

IT WORKS! however it logs everything to the viewer at the bottom even when is does not error out. How can I stop that from happening?

nvm i see the showlog() i removed that.

4

Friday, October 1st 2010, 11:10am

Hi, just remove the showlog() and trace() calls

VN2009

Professional

  • "VN2009" started this thread

Posts: 1,336

Location: Duluth MN

  • Send private message

5

Tuesday, October 19th 2010, 5:10pm

ok i need a slight modification to this action but i just cannot figure it out.

i now want to remove groups of hotspots based on an added attribute. for all my hotspots I added a variable called "tag" and it is set to different values based on the group the hotspot belongs to. "ground" "lakewalk" "businesses" so for the hotspots you would see tag="lw" for some and tag="gr" for others. how to modify this so that it detects the state of that variable and only deletes it if it is in the correct state.

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

6

Tuesday, October 19th 2010, 6:47pm

Hi VN2009,

Perhaps something like this:

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
	<!-- Removing Hospots action
	---- usage: removing_hotspots( attribute *  , value * );
	----  attribute = your custom attribute name in the hotspot you needs to check for...
	----  value = the value of your custom attribute name in the hotspot you needs to check for...
	----  
	----  with ( attribute *  , value * ) , only hotspots with the given arguments are removed
	----  without ( attribute *  , value * ) , all hotspots are removed
	-->
	<action name="removing_hotspots">
		sub(i,hotspot.count,1);
		if(i GE 0,removing_loop_all_hotspots(get(i),%1,%2));
	</action>

	<action name="removing_loop_all_hotspots">
		if(%2 == null,
			removehotspot(%1);
			,
			if(hotspot[%1].%2 == %3,
				removehotspot(%1);
				);
			);
		dec(i);
		if(i GE 0, removing_loop_all_hotspots(get(i),%2,%3) );
	</action>

based on your request above, it could be:
removing_hotspots(tag,ground);
This will remove all the hotspots with attribute tag="ground" and only these hotspots...

Hope this help...

SAlut.

This post has been edited 2 times, last edit by "michel" (Oct 19th 2010, 8:26pm)


VN2009

Professional

  • "VN2009" started this thread

Posts: 1,336

Location: Duluth MN

  • Send private message

7

Tuesday, October 19th 2010, 10:49pm

Another check mark in the "W" column for Michel !!! you know what that means this time right? many thank you's Michel !

Tuur

Sage

Posts: 3,769

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

8

Tuesday, October 19th 2010, 10:54pm

Great!

but were is that ground thing?? is that typo count?

i try to understand this placeholder thing with the maths... very difficult..

Tuur *thumbsup*

VN2009

Professional

  • "VN2009" started this thread

Posts: 1,336

Location: Duluth MN

  • Send private message

9

Tuesday, October 19th 2010, 11:17pm

tuur he based that off of my original description. i have tags called ground and lakewalk. he was just providing an example of the code used to delete hotspots based off the tag.

VN2009

Professional

  • "VN2009" started this thread

Posts: 1,336

Location: Duluth MN

  • Send private message

10

Monday, October 25th 2010, 5:50pm

ok how to modify this code to set certain plugins visible="false" based off the "tag" again. I tried this and it does not work.

<action name="invisible_hotspots">
sub(i,hotspot.count,1);
if(i GE 0,invisible_loop_all_hotspots(get(i),%1,%2));
</action>

<action name="invisible_loop_all_hotspots">
if(%2 == null,
set(hotspot[%1].visible,false);
,
if(hotspot[%1].%2 == %3,
set(hotspot[%1].visible,false));
);
);
dec(i);
if(i GE 0, invisible_loop_all_hotspots(get(i),%2,%3) );
</action>

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

11

Monday, October 25th 2010, 9:25pm

Hi VN2009,

Perhaps something like this:

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
27
	<!-- Setting Hospots OR plugins attribute  with the given value where attribute2 == value2...
	----  usage: set_hotspots/plugin(  hotspots/plugin , attribute , value , attribute2 * , value2 * );
	----  hotspots/plugin = hotspots OR plugin ...
	----  attribute = attribute to be set ...
	----  value = the value to set the attribute with...
	----  attribute2 = your custom attribute name in the hotspots/plugin you needs to check for...
	----  value2 = the value of your custom attribute name in the hotspots/plugin you needs to check for...
	----  
	----  with ( attribute2 *  , value2 * ) , only hotspots/plugin with the given arguments are set...
	----  without ( attribute2 *  , value2 * ) , all hotspots/plugin are set...
	-->
	<action name="set_hotspots/plugin">
		sub(i,%1.count,1);
		if(i GE 0,set_loop_all_hotspots/plugin(get(i),%1,%2,%3,%4,%5));
	</action>

	<action name="set_loop_all_hotspots/plugin">
		if(%5 == null,
			set(%2[%1].%3,%4);
			,
			if(%2[%1].%5 == %6,
				set(%2[%1].%3,%4);
				);
			);
		dec(i);
		if(i GE 0, set_loop_all_hotspots/plugin(get(i),%2,%3,%4,%5,%6) );
	</action>

ex: this should set all plugins to scale = 1...
set_hotspots/plugin(plugin,scale,1);
ex: this should set only hotspots with custom attribute tag="ground" to visible = false...
set_hotspots/plugin(hotspot,visible,false,tag,ground);

Hope this help...

SAlut.

VN2009

Professional

  • "VN2009" started this thread

Posts: 1,336

Location: Duluth MN

  • Send private message

12

Monday, October 25th 2010, 9:50pm

Is it wrong to loave another man? cause I love you Michel !!! Totally kidding. I have been checking this post every 15 min since I posted it waiting for you to debug it for me.

Thank You again!

VN2009

Professional

  • "VN2009" started this thread

Posts: 1,336

Location: Duluth MN

  • Send private message

13

Monday, October 25th 2010, 9:56pm

Michel this has turned out to be one hell of a script. By setting tags on all hotspots and plugins with this code we essentially have a way so set variables on groups of hotspots and plugins all at the same time. This can be used over and over again in numerous ways.

Ariel

Beginner

Posts: 45

Location: Argentina

  • Send private message

14

Monday, January 3rd 2011, 6:33pm

EDIT:
IT IS WORKING HAHA!!! SORRY!!!
AND THANKS FOR THIS CODE! I LOVE IT!



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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
	<plugin name="info-on"  ...  visible="false"  keep="true" onclick="turn-info-ON();" />
	<plugin name="info-off"  ...  keep="true"  onclick="turn-info-OFF();" />

	<plugin name="camera-on"  ...  visible="false"  keep="true" onclick="turn-camera-ON();" />
	<plugin name="camera-off"  ...  keep="true" onclick="turn-camera-OFF();" />


		<hotspot name="cam1" tag="camspots"  style="camera" ... ... />
		<hotspot name="cam2" tag="camspots"  style="camera" ... ... />

		<hotspot name="info1" tag="infospots"  style="info" ... ... />
		<hotspot name="info2" tag="infospots"  style="info" ... ... />


<action name="turn-info-ON" >
set_hotspots/plugin(hotspot,visible,true,tag,infospots);
set(plugin[info-on].visible,false); set(plugin[info-off].visible,true);
</action>
<action name="turn-info-OFF" >
set_hotspots/plugin(hotspot,visible,false,tag,infospots);
set(plugin[info-off].visible,false); set(plugin[info-on].visible,true);
</action>
<action name="turn-camera-ON" >
set_hotspots/plugin(hotspot,visible,true,tag,camspots);
set(plugin[camera-on].visible,false); set(plugin[camera-off].visible,true);
</action>
<action name="turn-camera-OFF" >
set_hotspots/plugin(hotspot,visible,false,tag,camspots);
set(plugin[camera-off].visible,false); set(plugin[camera-on].visible,true);
</action>


	<action name="set_hotspots/plugin">
		sub(i,%1.count,1);
		if(i GE 0,set_loop_all_hotspots/plugin(get(i),%1,%2,%3,%4,%5));
	</action>
	<action name="set_loop_all_hotspots/plugin">
		if(%5 == null,
			set(%2[%1].%3,%4);
			,
			if(%2[%1].%5 == %6,
				set(%2[%1].%3,%4);
				);
			);
		dec(i);
		if(i GE 0, set_loop_all_hotspots/plugin(get(i),%2,%3,%4,%5,%6) );
	</action>
Ariel M.
Build and Customize your virtual tours with Spinattic
www.spinattic.com

My profile in Spinattic

This post has been edited 3 times, last edit by "Ariel" (Jan 3rd 2011, 6:55pm)


VN2009

Professional

  • "VN2009" started this thread

Posts: 1,336

Location: Duluth MN

  • Send private message

15

Monday, January 3rd 2011, 6:50pm

hmmm your code looks right. here is the code I use.

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
	<style name="attract"
	         keep="false" alturl="icons/attract.png"
	         visible="false" enabled="true" usecontentsize="false" handcursor="true" capture="true" children="true"
 	         zorder="0"
	         fillcolor     ="0x1f2efd" fillalpha     ="0.40" borderwidth     ="2.0" bordercolor     ="0x1f2efd" borderalpha     ="0.75"
	         fillcolorhover="0x1f2efd" fillalphahover="0.80" borderwidthhover="3.0" bordercolorhover="0x1f2efd" borderalphahover="1"
	         fadeintime="0.150" fadeouttime="0.300" fadeincurve="1.100" 		 fadeoutcurve="0.700"
	         tag="attract" devices="all"
		onout="hide_hover_image();"
		ondown="set(plugin[remember].inmini, 1);"
		/>

	<hotspot name="a1"
	         ath="-30.4966" atv=" 41.4530"
	         onover="show_hover_image(data:adventure);"
	         onhover="showtext(adventurezone)"
	         style="attract"
	         onclick="action(goinside,a1,xmls/adventure/tour.xml,a1)"
		>
		<point ath="-30.4966" atv=" 41.4530" />
		<point ath="-24.5829" atv=" 36.9070" />
		<point ath=" -9.5239" atv=" 40.3506" />
		<point ath="-11.6395" atv=" 43.8208" />
		<point ath="-21.3755" atv=" 41.4817" />
		<point ath="-23.7034" atv=" 43.8323" />
	</hotspot>


along with "set_hotspots/plugin(hotspot,visible,false,tag,attract);"

are you sure you are using the latest krpano version?

Ariel

Beginner

Posts: 45

Location: Argentina

  • Send private message

16

Monday, January 3rd 2011, 6:54pm

hmmm your code looks right. here is the code I use.
haha! yes... see my edit... it was working... I just forgot to change false to true in one of the actions...
thank you!!! =)
Ariel M.
Build and Customize your virtual tours with Spinattic
www.spinattic.com

My profile in Spinattic

Posts: 1,857

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

17

Friday, April 22nd 2011, 1:22am

"Tweening!! duh"

4 more arguments

%6 "tween" if set to tween will tween
%7 %8 %9
time*,tweentype*,donecall*)



sub(i,%1.count,1);
if(i GE 0,set_loop_all_hotspots/plugin(get(i),%1,%2,%3,%4,%5,%6,%7,%8,%9));
</action>

if(%5 == null,
set(%2[%1].%3,%4);
,
if(%2[%1].%5 == %6,
if(%7 == tween,
tween(%2[%1].%3,%4,%8,%9,%10);

,
set(%2[%1].%3,%4);

);
);
);
dec(i);
if(i GE 0, set_loop_all_hotspots/plugin(get(i),%2,%3,%4,%5,%6,%7,%8,%9,%10));
</action>
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

VN2011

Professional

  • "VN2011" started this thread

Posts: 1,336

Location: Duluth MN

  • Send private message

18

Friday, April 22nd 2011, 9:34am

have you tested this? where does the %10 come from shouldnt this line be

tween(%2[%1].%3,%4,%7,%8,%9); ?

this is a great addition if it works i am not in a postion to test this right now.

Posts: 1,857

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

19

Friday, April 22nd 2011, 2:50pm

No cause one action sends all 9 arguments to the other action plus the index.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour