Subversion Repositories wimsdev

Rev

Rev 17173 | Rev 17788 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17173 Rev 17732
Line 11... Line 11...
11
:proc
11
:proc
12
 
12
 
13
!distribute item $wims_read_parm into slib_N,slib_s,slib_h,slib_text
13
!distribute item $wims_read_parm into slib_N,slib_s,slib_h,slib_text
14
slib_option = !item 5 to -1 of $wims_read_parm
14
slib_option = !item 5 to -1 of $wims_read_parm
15
!default slib_s=5
15
!default slib_s=5
16
!default slib_h =8
16
!default slib_h=8
17
!default slib_color1=blue
17
!default slib_color1=blue
18
!default slib_color2=green
18
!default slib_color2=green
19
!default slib_color3 = yellow
19
!default slib_color3=yellow
20
slib_text=!declosing $slib_text
20
slib_text=!declosing $slib_text
21
slib_G = 1
21
slib_G = 1
22
slib_cnt = 1
22
slib_cnt = 1
23
slib_n = $[2*$slib_N]
23
slib_n = $[2*$slib_N]
24
slib_A1 =0
24
slib_A1 =0
25
slib_height1 =1
25
slib_height1=1
26
slib_sizey =1
26
slib_sizey=1
27
slib_cnt1 = 0
27
slib_cnt1=0
28
slib_width1 =15
28
slib_width1=15
29
slib_Sizey = $[$slib_h+1]
29
slib_Sizey=$[$slib_h+1]
30
slib_choix1=!values 1 for x = 1 to $[$slib_s+3]
30
slib_choix1=!values 1 for x=1 to $[$slib_s+3]
31
slib_choix0=!values 0 for x = 1 to $[$slib_s-3]
31
slib_choix0=!values 0 for x=1 to $[$slib_s-3]
32
slib_noeud= !random 0,1 repeat $n
32
slib_noeud= !random 0,1 repeat $n
33
#permet d'assurer que l'arbre ne part pas avec une seule branche (inutile dans le cas parfait)
33
#permet d'assurer que l'arbre ne part pas avec une seule branche (inutile dans le cas parfait)
34
slib_noeud = 1,$slib_noeud
34
slib_noeud=1,$slib_noeud
35
slib_choix=$slib_choix1, $slib_choix0
35
slib_choix=$slib_choix1, $slib_choix0
36
slib_position =$empty
36
slib_position=$empty
37
slib_milieu =0,-1
37
slib_milieu=0,-1
38
!for slib_k = 1 to $slib_n
38
!for slib_k=1 to $slib_n
39
  slib_L = !line $slib_k of $slib_G
39
  slib_L=!line $slib_k of $slib_G
40
  !if $slib_L<>$empty
40
  !if $slib_L<>$empty
41
    slib_i=!item 1 of $slib_L
41
    slib_i=!item 1 of $slib_L
42
    slib_position_prov=$(slib_A$slib_i),$[-$(slib_height$slib_i)]
42
    slib_position_prov=$(slib_A$slib_i),$[-$(slib_height$slib_i)]
43
    slib_position = !append line $slib_position_prov to $slib_position
43
    slib_position=!append line $slib_position_prov to $slib_position
44
    !if $slib_cnt > $[$slib_N] or $slib_sizey > $slib_Sizey
44
    !if $slib_cnt > $[$slib_N] or $slib_sizey > $slib_Sizey
45
 
45
 
46
    !else
46
    !else
47
      #choix des fils (position et nombre : la position est-elle intéressante pour un arbre non binaire ? )
47
      #choix des fils (position et nombre : la position est-elle intéressante pour un arbre non binaire ? )
48
      slib_c=!item $slib_k of $slib_noeud
48
      slib_c=!item $slib_k of $slib_noeud
49
      !if perfect iswordof of $slib_option or $slib_c = 1
49
      !if perfect iswordof of $slib_option or $slib_c=1
50
        slib_a =!item 1 to $slib_s of $slib_choix1
50
        slib_a=!item 1 to $slib_s of $slib_choix1
51
      !else
51
      !else
52
        slib_a =!shuffle $slib_choix
52
        slib_a=!shuffle $slib_choix
53
        slib_a=!item 1 to $slib_s of $slib_a
53
        slib_a=!item 1 to $slib_s of $slib_a
54
      !endif
54
      !endif
55
      slib_Li =
55
      slib_Li=
56
      !for slib_j = 1 to $slib_s
56
      !for slib_j=1 to $slib_s
57
        slib_b=!item $slib_j of $slib_a
57
        slib_b=!item $slib_j of $slib_a
58
        !if $slib_b <> 0
58
        !if $slib_b <> 0
59
          #creation d'un fils
59
          #creation d'un fils
60
          slib_jj =$[$slib_cnt+1]
60
          slib_jj=$[$slib_cnt+1]
61
          #sa hauteur
61
          #sa hauteur
62
          slib_height$slib_jj= $[$(slib_height$slib_i)+1]
62
          slib_height$slib_jj= $[$(slib_height$slib_i)+1]
63
          #la hauteur de l'arbre
63
          #la hauteur de l'arbre
64
          slib_sizey=$[max($slib_sizey, $(slib_height$slib_jj))]
64
          slib_sizey=$[max($slib_sizey, $(slib_height$slib_jj))]
65
          # Ne sert à rien ?
65
          # Ne sert à rien ?
66
          slib_cnt$(slib_height$slib_jj)=$[$(slib_cnt$(slib_height$slib_jj))+1]
66
          slib_cnt$(slib_height$slib_jj)=$[$(slib_cnt$(slib_height$slib_jj))+1]
67
          #on rajoute une ligne pour le fils
67
          #on rajoute une ligne pour le fils
68
          slib_G =!append line $slib_jj to $slib_G
68
          slib_G=!append line $slib_jj to $slib_G
69
          #nombre de sommets
69
          #nombre de sommets
70
          slib_cnt = $[$slib_cnt +1]
70
          slib_cnt=$[$slib_cnt +1]
71
        !else
71
        !else
72
          slib_jj=sentinelle
72
          slib_jj=sentinelle
73
        !endif
73
        !endif
74
        #on rajoute le fils sur la ligne du père, rien s'il n'y a rien à cette position
74
        #on rajoute le fils sur la ligne du père, rien s'il n'y a rien à cette position
75
        slib_Li =!append item $slib_jj to $slib_Li
75
        slib_Li=!append item $slib_jj to $slib_Li
76
        #le calcul suivant sert pour le dessin. Faut-il le mettre ici ?
76
        #le calcul suivant sert pour le dessin. Faut-il le mettre ici ?
77
        !if $slib_b <> 0
77
        !if $slib_b <> 0
78
          #position
78
          #position
79
          slib_A$slib_jj=$[$(slib_A$slib_i)+($slib_j-($slib_s+1)/2)*$(slib_width$slib_i)]
79
          slib_A$slib_jj=$[$(slib_A$slib_i)+($slib_j-($slib_s+1)/2)*$(slib_width$slib_i)]
80
          #calcul de la largeur donnée au sommet $slib_jj pour ses fils éventuels
80
          #calcul de la largeur donnée au sommet $slib_jj pour ses fils éventuels
81
          slib_width$slib_jj=$[$(slib_width$slib_i)/min($slib_s,$slib_s+1)]
81
          slib_width$slib_jj=$[$(slib_width$slib_i)/min($slib_s,$slib_s+1)]
82
          slib_milieu_prov=$[($(slib_A$slib_i)+2*$(slib_A$slib_jj))/3],$[-($(slib_height$slib_i) +2*$(slib_height$slib_jj))/3]
82
          slib_milieu_prov=$[($(slib_A$slib_i)+2*$(slib_A$slib_jj))/3],$[-($(slib_height$slib_i) +2*$(slib_height$slib_jj))/3]
83
          slib_milieu = !append line $slib_milieu_prov to $slib_milieu
83
          slib_milieu=!append line $slib_milieu_prov to $slib_milieu
84
        !endif
84
        !endif
85
      !next slib_j
85
      !next slib_j
86
      #on met la ligne $slib_k définitive
86
      #on met la ligne $slib_k définitive
87
      slib_G = !replace line number $slib_k by $slib_L,$slib_Li in $slib_G
87
      slib_G=!replace line number $slib_k by $slib_L,$slib_Li in $slib_G
88
    !endif
88
    !endif
89
  !endif
89
  !endif
90
!next slib_k
90
!next slib_k
91
 
91
 
92
#Trace du dessin
92
#Trace du dessin
93
slib_dessin =xrange $[-$slib_s*$slib_width1/2],$[$slib_s*$slib_width1/2]\
93
!set slib_xrange=$[-$slib_s*$slib_width1/2],$[$slib_s*$slib_width1/2]
94
yrange $[-$slib_Sizey-0.5],-0.5\
94
!set slib_yrange=$[-$slib_Sizey-0.5],-0.5
-
 
95
slib_dessin=xrange $slib_xrange\
-
 
96
yrange $slib_yrange\
95
linewidth 2
97
linewidth 2
96
slib_cnt =!linecnt $slib_G
98
slib_cnt=!linecnt $slib_G
97
 
99
 
98
!for slib_k= 1 to $slib_cnt
100
!for slib_k= 1 to $slib_cnt
99
  slib_u =!line $slib_k of $slib_G
101
  slib_u =!line $slib_k of $slib_G
100
  slib_i=!item 1 of $slib_u
102
  slib_i=!item 1 of $slib_u
101
  slib_position_prov=!line $slib_k of $slib_position
103
  slib_position_prov=!line $slib_k of $slib_position
Line 124... Line 126...
124
!next slib_k
126
!next slib_k
125
 
127
 
126
slib_out=$slib_dessin
128
slib_out=$slib_dessin
127
 
129
 
128
!if url iswordof $slib_option or html iswordof $slib_option
130
!if url iswordof $slib_option or html iswordof $slib_option
129
  insdraw_size=300,300
131
  !set insdraw_size=300,300
130
  !insdraw $slib_out
132
  !insdraw $slib_out
131
  slib_out=$ins_url
133
  slib_out=$ins_url
132
  !if html iswordof $slib_option
134
  !if html iswordof $slib_option
133
    slib_out=<img src="$ins_url" alt="">
135
    slib_out=<img src="$ins_url" alt="">
134
  !else
136
  !else