Subversion Repositories wimsdev

Rev

Rev 20 | Rev 4158 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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