File: AutoScaleMacro.net

package info (click to toggle)
dxsamples 4.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 26,340 kB
  • sloc: ansic: 10,079; sh: 8,445; java: 1,772; makefile: 1,102
file content (264 lines) | stat: -rw-r--r-- 8,901 bytes parent folder | download | duplicates (5)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
//
// time: Wed Feb 12 11:22:37 1997
//
// version: 3.1.1 (format), 3.1.4 (DX Beta)
//
//
// Begin MDF
// MODULE AutoScale
// CATEGORY Macros
// DESCRIPTION automatically scales an object to a user-given aspect ratio
// INPUT object; field; (none); object to be scaled
// INPUT aspect; object; (none); aspect ratio
// OUTPUT output_1; object;  
// OUTPUT scale_factor; object; scale factor applied to the object
// End MDF
//
// comment: This visual program will automatically scale an object to a user-given aspect ratio. Works for both 2D and 3D (if 2D the aspect ratio must be a two vector; if 3D a three vector).
// comment: 
// comment: The first input, object, is the object to be scaled.
// comment: 
// comment: The second input, aspect, is the aspect ratio. It should be either a two vector or a three vector, depending on the dimensionality of "object".
// page assignment: aspect	order=2, windowed=0, showing=0
// page assignment: input	order=1, windowed=0, showing=1
// page assignment: scale	order=3, windowed=0, showing=0
// workspace: width = 607, height = 608
// layout: snap = 0, width = 50, height = 50, align = NN
//
macro AutoScale(
 object
,aspect
) -> (
 output_1
,scale_factor
) {
    // 
    // node Input[1]: x = 37, y = 20, inputs = 0, label = Input
    // page group: input
    // parameter: position = 1, name = 'object', value = '(none)', descriptive = 1, description = 'object to be scaled', required = 1, visible = 1
    //
AutoScale_Input_1_out_1 = object;
    // 
    // node ShowBox[1]: x = 36, y = 133, inputs = 1, label = ShowBox
    // page group: input
    //
AutoScale_ShowBox_1_out_1,
AutoScale_ShowBox_1_out_2 = 
    ShowBox(
    AutoScale_Input_1_out_1
    ) [instance: 1, cache: 1];
    // 
    // node Transmitter[3]: x = 63, y = 380, inputs = 1, label = box
    // page group: input
    //
box = AutoScale_ShowBox_1_out_1;
    // 
    // node Receiver[5]: x = 283, y = 16, inputs = 1, label = box
    // page group: scale
    //
AutoScale_Receiver_5_out_1[cache: 0] = box;
    // 
    // node Extract[1]: x = 251, y = 86, inputs = 2, label = Extract
    // input[2]: defaulting = 0, visible = 1, type = 32, value = "box"
    // page group: scale
    //
AutoScale_Extract_1_out_1 = 
    Extract(
    AutoScale_Receiver_5_out_1,
    "box"
    ) [instance: 1, cache: 1];
    // 
    // node Select[1]: x = 200, y = 172, inputs = 3, label = Select
    // input[2]: defaulting = 0, visible = 1, type = 1, value = 0
    // page group: scale
    //
AutoScale_Select_1_out_1 = 
    Select(
    AutoScale_Extract_1_out_1,
    0,
    NULL
    ) [instance: 1, cache: 1];
    // 
    // node Select[2]: x = 263, y = 169, inputs = 3, label = Select
    // input[2]: defaulting = 0, visible = 1, type = 1, value = 7
    // page group: scale
    //
AutoScale_Select_2_out_1 = 
    Select(
    AutoScale_Extract_1_out_1,
    7,
    NULL
    ) [instance: 2, cache: 1];
    // 
    // node Input[2]: x = 20, y = 20, inputs = 0, label = Input
    // page group: aspect
    // parameter: position = 2, name = 'aspect', value = '(none)', descriptive = 1, description = 'aspect ratio', required = 1, visible = 1
    //
AutoScale_Input_2_out_1 = aspect;
    // 
    // node Transmitter[4]: x = 38, y = 107, inputs = 1, label = aspect_xcvr
    // page group: aspect
    //
aspect_xcvr = AutoScale_Input_2_out_1;
    // 
    // node Receiver[6]: x = 492, y = 34, inputs = 1, label = aspect_xcvr
    // page group: scale
    //
AutoScale_Receiver_6_out_1[cache: 0] = aspect_xcvr;
    // 
    // node Compute[2]: x = 208, y = 282, inputs = 4, label = Compute
    // input[1]: defaulting = 0, visible = 0, type = 32, value = "[(1.0/($1.x - $0.x))*$2.x, (1.0/($1.y - $0.y))*$2.y, (1.0/($1.z - $0.z))*$2.z]"
    // page group: scale
    // expression: value = [(1.0/(b.x - a.x))*aspect.x, (1.0/(b.y - a.y))*aspect.y, (1.0/(b.z - a.z))*aspect.z]
    // name[2]: value = a
    // name[3]: value = b
    // name[4]: value = aspect
    //
AutoScale_Compute_2_out_1 = 
    Compute(
    "[(1.0/($1.x - $0.x))*$2.x, (1.0/($1.y - $0.y))*$2.y, (1.0/($1.z - $0.z))*$2.z]",
    AutoScale_Select_1_out_1,
    AutoScale_Select_2_out_1,
    AutoScale_Receiver_6_out_1
    ) [instance: 2, cache: 1];
    // 
    // node Select[4]: x = 340, y = 172, inputs = 3, label = Select
    // input[2]: defaulting = 0, visible = 1, type = 1, value = 7
    // page group: scale
    //
AutoScale_Select_4_out_1 = 
    Select(
    AutoScale_Extract_1_out_1,
    7,
    NULL
    ) [instance: 4, cache: 1];
    // 
    // node Select[3]: x = 410, y = 169, inputs = 3, label = Select
    // input[2]: defaulting = 0, visible = 1, type = 1, value = 0
    // page group: scale
    //
AutoScale_Select_3_out_1 = 
    Select(
    AutoScale_Extract_1_out_1,
    0,
    NULL
    ) [instance: 3, cache: 1];
    // 
    // node Compute[3]: x = 349, y = 276, inputs = 4, label = Compute
    // input[1]: defaulting = 0, visible = 0, type = 32, value = "[(1.0/($1.x - $0.x))*$2.x, (1.0/($1.y - $0.y))*$2.y,1]"
    // page group: scale
    // expression: value = [(1.0/(b.x - a.x))*aspect.x, (1.0/(b.y - a.y))*aspect.y,1]
    // name[2]: value = a
    // name[3]: value = b
    // name[4]: value = aspect
    //
AutoScale_Compute_3_out_1 = 
    Compute(
    "[(1.0/($1.x - $0.x))*$2.x, (1.0/($1.y - $0.y))*$2.y,1]",
    AutoScale_Select_4_out_1,
    AutoScale_Select_3_out_1,
    AutoScale_Receiver_6_out_1
    ) [instance: 3, cache: 1];
    // 
    // node Inquire[1]: x = 133, y = 179, inputs = 3, label = Inquire
    // input[2]: defaulting = 0, visible = 1, type = 32, value = "is 2D positions +1"
    // page group: input
    //
AutoScale_Inquire_1_out_1 = 
    Inquire(
    AutoScale_Input_1_out_1,
    "is 2D positions +1",
    NULL
    ) [instance: 1, cache: 1];
    // 
    // node Transmitter[2]: x = 286, y = 385, inputs = 1, label = input_data
    // page group: input
    //
input_data = AutoScale_Input_1_out_1;
    // 
    // node Receiver[2]: x = 16, y = 13, inputs = 1, label = input_data
    // page group: scale
    //
AutoScale_Receiver_2_out_1[cache: 0] = input_data;
    // 
    // node Transmitter[5]: x = 181, y = 376, inputs = 1, label = TwoD
    // page group: input
    //
TwoD = AutoScale_Inquire_1_out_1;
    // 
    // node Receiver[8]: x = 131, y = 15, inputs = 1, label = TwoD
    // page group: scale
    //
AutoScale_Receiver_8_out_1[cache: 0] = TwoD;
    // 
    // node Switch[1]: x = 201, y = 446, inputs = 3, label = Switch
    // page group: scale
    //
AutoScale_Switch_1_out_1 = 
    Switch(
    AutoScale_Receiver_8_out_1,
    AutoScale_Compute_2_out_1,
    AutoScale_Compute_3_out_1
    ) [instance: 1, cache: 1];
    // 
    // node Scale[1]: x = 104, y = 455, inputs = 2, label = Scale
    // page group: scale
    //
AutoScale_Scale_1_out_1 = 
    Scale(
    AutoScale_Receiver_2_out_1,
    AutoScale_Switch_1_out_1
    ) [instance: 1, cache: 1];
    // 
    // node Output[1]: x = 80, y = 541, inputs = 1, label = Output
    // page group: scale
    // parameter: position = 1, name = 'output_1', value = ' ', descriptive = 0, description = ' ', required = 0, visible = 1
    //
output_1 = AutoScale_Scale_1_out_1;
    // 
    // node Output[2]: x = 259, y = 546, inputs = 1, label = Output
    // page group: scale
    // parameter: position = 2, name = 'scale_factor', value = ' ', descriptive = 0, description = 'scale factor applied to the object', required = 0, visible = 1
    //
scale_factor = AutoScale_Switch_1_out_1;
    //
    // decorator Annotate	pos=(316,41) size=128x28 style(Label), value = <NULL>
    // annotation user_begin: 17
    // annotation user: the "input" input
    // annotation user_end: <NULL>
    // page group: input
    //
    // decorator Annotate	pos=(188,43) size=138x28 style(Label), value = <NULL>
    // annotation user_begin: 18
    // annotation user: the "aspect" input
    // annotation user_end: <NULL>
    // page group: aspect
    //
    // decorator Annotate	pos=(290,416) size=317x28 style(Label), value = <NULL>
    // annotation user_begin: 46
    // annotation user: scale the object to the specified aspect ratio
    // annotation user_end: <NULL>
    // page group: scale
// network: end of macro body
}
AutoScale_Input_1_out_1 = NULL;
AutoScale_ShowBox_1_out_1 = NULL;
AutoScale_Transmitter_3_out_1 = NULL;
AutoScale_Receiver_5_out_1 = NULL;
AutoScale_Extract_1_out_1 = NULL;
AutoScale_Select_1_out_1 = NULL;
AutoScale_Select_2_out_1 = NULL;
AutoScale_Input_2_out_1 = NULL;
AutoScale_Transmitter_4_out_1 = NULL;
AutoScale_Receiver_6_out_1 = NULL;
AutoScale_Compute_2_out_1 = NULL;
AutoScale_Select_4_out_1 = NULL;
AutoScale_Select_3_out_1 = NULL;
AutoScale_Compute_3_out_1 = NULL;
AutoScale_Inquire_1_out_1 = NULL;
AutoScale_Transmitter_2_out_1 = NULL;
AutoScale_Receiver_2_out_1 = NULL;
AutoScale_Transmitter_5_out_1 = NULL;
AutoScale_Receiver_8_out_1 = NULL;
AutoScale_Switch_1_out_1 = NULL;
AutoScale_Scale_1_out_1 = NULL;