Subversion Repositories wimsdev

Rev

Rev 13585 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 reyssat 1
!if $wims_read_parm!=slib_header
13585 bpr 2
  !goto proc
20 reyssat 3
!endif
4158 bpr 4
 
4349 bpr 5
slib_author=Gang, XIAO
4158 bpr 6
 
20 reyssat 7
slib_example=5/br2out,,,acsrc,diode,cap,res
4158 bpr 8
 
20 reyssat 9
!exit
10
 
11
:proc
12
!distribute items $wims_read_parm into \
13
	slib_type,slib_dotwidth,slib_color,slib_textsize
14
slib_c=!char 1 of $slib_type
15
!if $slib_c isin 123456789
13585 bpr 16
  slib_prefix=data/circuits
20 reyssat 17
!else
13585 bpr 18
  slib_prefix=
20 reyssat 19
!endif
20
slib_out=
21
!default slib_x0=0
22
!default slib_y0=0
23
!default slib_dotwidth=6
24
!default slib_color=black
25
!default slib_textsize=medium
26
slib_comp=!item 5 to -1 of $wims_read_parm
27
!if / notin $slib_type
13585 bpr 28
  !exit
20 reyssat 29
!endif
30
slib_rec=$slib_prefix/$slib_type.data
31
slib_t=!recordcnt $slib_rec
32
!if $slib_t<2
13585 bpr 33
  !exit
20 reyssat 34
!endif
35
slib_xyr=!record 2 of $slib_rec
36
slib_n1=!item 3 of $slib_xyr
37
slib_n2=!itemcnt $slib_comp
38
slib_n=$[min($slib_n1,$slib_n2)]
39
slib_pairs=!item 4 of $slib_xyr
40
slib_pairs=!declosing $slib_pairs
41
 
42
slib_out=trange 0,1
43
slib_cdata=!record 3 of $slib_rec
44
 
45
!read data/circuits/compdata
46
 
47
slib_paired=-1
48
!for slib_i=1 to $slib_n
13585 bpr 49
  slib_l=!item $slib_i of $slib_comp
50
  slib_name=!word 1 of $slib_l
51
  !if $slib_name!=
52
    slib_text=!word 2 to -1 of $slib_l
53
    slib_text=!translate internal @ to $ $ in $slib_text
54
    slib_tlen=!charcnt $slib_text
55
    !if " notin $slib_text
56
      slib_text="$slib_text"
57
    !endif
58
    slib_ct=!line $slib_i of $slib_cdata
59
    !if $slib_name=color
60
      !default slib_text=grey
61
    !endif
62
    !distribute item $slib_ct into \
63
      slib_x,slib_y,slib_xt,slib_yt,slib_orient,slib_e1,slib_e2
64
    !if R isin $slib_name
65
      slib_t=-1
66
    !else
67
      slib_t=1
68
    !endif
69
    slib_name=!text delete R in $slib_name
70
    slib_cmd=$slib_name
71
    !if $slib_orient=1 and $slib_name notwordof $comp_norotate
72
      slib_matrix=0,-($slib_t),$slib_t,0
73
    !else
74
      slib_matrix=$slib_t,0,0,$slib_t
75
    !endif
76
    slib_extender=
77
    slib_ee=!nonempty items $slib_e1,$slib_e2
78
    !if $slib_ee!= \
79
	    ($(comp_$slib_cmd)!= or $slib_cmd=wire) and \
80
	      $slib_cmd notwordof none num
81
      !if $slib_orient=1
82
        slib_extender=$\
20 reyssat 83
affine 0,-1,1,0,$slib_x,$slib_y
13585 bpr 84
      !else
85
        slib_extender=$\
20 reyssat 86
affine 1,0,0,1,$slib_x,$slib_y
13585 bpr 87
      !endif
88
      !for slib_e in $slib_ee
89
        !if $slib_e<-1
90
          slib_extender=$slib_extender\
20 reyssat 91
disk $slib_e,0,$slib_dotwidth,_color_\
15531 bpr 92
segment $slib_e,0,-1,0,_color_
13585 bpr 93
        !endif
94
        !if $slib_e>1
95
          slib_extender=$slib_extender\
20 reyssat 96
disk $slib_e,0,$slib_dotwidth,_color_\
15531 bpr 97
segment $slib_e,0,1,0,_color_
13585 bpr 98
        !endif
99
      !next slib_e
20 reyssat 100
    !endif
13585 bpr 101
    !if $slib_i isitemof $slib_pairs
102
      !if $slib_orient=0
103
        slib_mat2=1,0,0,1
104
      !else
105
        slib_mat2=0,1,-1,0
106
      !endif
107
      !if $slib_name=wire
108
        slib_paired=$[$slib_i+1]
109
        slib_out=$slib_out\
20 reyssat 110
affine $slib_mat2,$slib_x,$slib_y\
111
parallel -1,0,0.5,0,3.5,0,2,_color_$slib_extender
13585 bpr 112
        !goto loopend
113
      !else
114
        slib_out=$slib_out\
20 reyssat 115
affine $slib_mat2,$slib_x,$slib_y\
15531 bpr 116
segment 1,0,2,0,_color_
13585 bpr 117
      !endif
20 reyssat 118
    !endif
13585 bpr 119
    !if $slib_i=$slib_paired
120
      !if $slib_orient=0
121
        slib_x=$[$slib_x-1.5]
122
        slib_xt=$[$slib_xt-1.5]
123
      !else
124
        slib_y=$[$slib_y+1.5]
125
        slib_yt=$[$slib_yt+1.5]
126
      !endif
127
    !endif
128
    slib_out=$slib_out\
129
    affine $slib_matrix,$slib_x,$slib_y\
130
    $(comp_$slib_cmd)$slib_extender
131
    !if $slib_tlen>0 and $slib_name notwordof $comp_notext
132
      !ifval $slib_tlen=1 and $slib_cmd iswordof src
133
        slib_xt=$[$slib_x-0.15]
134
        slib_yt=$[$slib_y+0.4]
135
      !endif
136
      !if $slib_name iswordof voltmeterN ammeterN lampN
137
        slib_xt=$[$slib_x+0.30]
138
        slib_yt=$[$slib_y+0.30]
139
      !endif
140
      slib_out=$slib_out\
20 reyssat 141
killaffine\
142
text _color_,$slib_xt,$slib_yt,$slib_textsize,$slib_text
13585 bpr 143
    !endif
20 reyssat 144
  !endif
13585 bpr 145
  :loopend
20 reyssat 146
!next slib_i
147
 
148
slib_out=!replace internal _color_ by $slib_color in $slib_out\
149
killaffine