1 /*****************************************************************************
2   FILE           : $Source: /projects/higgs1/SNNS/CVS/SNNS/xgui/sources/bn_TD_bignet.c,v $
3   SHORTNAME      : bn_TD_bignet
4   SNNS VERSION   : 4.2
5 
6   PURPOSE        : Creates the BIGNET-window for TDNNs.
7   NOTES          :
8 
9   AUTHOR         : Guenter Mamier
10   DATE           : 09.02.93
11 
12   CHANGED BY     :
13   RCS VERSION    : $Revision: 2.15 $
14   LAST CHANGE    : $Date: 1998/03/03 14:09:37 $
15 
16     Copyright (c) 1990-1995  SNNS Group, IPVR, Univ. Stuttgart, FRG
17     Copyright (c) 1996-1998  SNNS Group, WSI, Univ. Tuebingen, FRG
18 
19 ******************************************************************************/
20 #include <config.h>
21 #include <stdlib.h>
22 
23 #include <X11/Intrinsic.h>
24 #include <X11/Shell.h>
25 #include <X11/Xaw3d/Box.h>
26 #include <X11/Xaw3d/Form.h>
27 
28 #include "kr_typ.h"
29 #include "kernel.h"
30 #include "ui.h"
31 #include "kr_ui.h"
32 #include "ui_utilP.h"
33 #include "ui_textP.h"
34 #include "ui_mainP.h"
35 #include "ui_xWidgets.h"
36 #include "ui_fileP.h"
37 #include "ui_display.h"
38 #include "bn_basics.h"
39 #include "bn_bignet.h"
40 #include "ui_confirmer.h"
41 
42 #include "bn_TD_bignet.ph"
43 
44 
45 
46 /*****************************************************************************
47   FUNCTION : bn_createPlanePanel
48 
49   PURPOSE  : creates the plane panel, which is part of the bignet-window
50   NOTES    :
51   RETURNS  :
52   UPDATE   : 09.02.1993
53 ******************************************************************************/
54 
bn_createPlanePannel(Widget parent)55 static void bn_createPlanePannel (Widget parent)
56 
57 {
58     Widget pannel;
59     Widget plane_edit,current_plane;
60     Widget plane_enter,plane_delete,plane_insert,plane_overwrite,
61            plane_to_edit,type,pos;
62     Widget plane_first,plane_last,plane_prev,plane_next;
63     Widget       dummy;
64     Arg          arg[25];
65     Cardinal     n;
66     int colom1 = 25, colom2 = 13, colom3 = 10;
67 
68     n = 0;
69 
70     pannel = XtCreateManagedWidget ("pannel", formWidgetClass, parent, arg, n);
71 
72     z1s1 = ui_xCreateLabelItem ("Plane                      ", pannel,
73 				colom1 * bn_fontWidth, NULL, NULL);
74     z1s2 = ui_xCreateLabelItem ("Current Plane  ", pannel,
75 				colom2 * bn_fontWidth, z1s1, NULL);
76     z1s3 = ui_xCreateLabelItem ("Edit Plane  ", pannel,
77 				colom3 * bn_fontWidth, z1s2, NULL);
78 
79     z2s1   = ui_xCreateLabelItem ("                     Plane:", pannel,
80 				  colom1 * bn_fontWidth, NULL, z1s1);
81     dummy = ui_xCreateLabelItem (" ", pannel, 3 * bn_fontWidth, z2s1, z1s1);
82     z2s2   = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,dummy,z1s1);
83 
84     z3s1  = ui_xCreateLabelItem ("                      Type: ",pannel,
85 				 colom1 * bn_fontWidth,NULL,z2s1);
86     dummy = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z3s1,z2s1);
87     z3s2  = ui_xCreateFrameLabelItem ("",pannel,td_bn_intWidth,dummy,z2s1);
88     dummy = ui_xCreateLabelItem (" ",pannel,5 * bn_fontWidth,z3s2,z2s1);
89     z3s3  = ui_xCreateFrameLabelItem (td_plane_type[TD_PLANE_type],pannel,
90 				      td_bn_intWidth,dummy,z2s1);
91 
92     z4s1  = ui_xCreateLabelItem ("      No. of feature units:",pannel,
93 				 colom1 * bn_fontWidth,NULL,z3s1);
94     dummy = ui_xCreateLabelItem (" ", pannel, 3 * bn_fontWidth,z4s1,z3s1);
95     z4s2  = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,dummy,z3s1);
96     dummy = ui_xCreateLabelItem (" ", pannel, 5 * bn_fontWidth,z4s2,z3s1);
97     z4s3  = ui_xCreateDialogItem ("z4s3", pannel,"",td_bn_intWidth,dummy,z3s1);
98 
99     z5s1  = ui_xCreateLabelItem ("        Total delay length: ",pannel,
100 				 colom1 * bn_fontWidth,NULL,z4s1);
101     dummy = ui_xCreateLabelItem (" ", pannel, 3 * bn_fontWidth,z5s1,z4s1);
102     z5s2  = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,dummy,z4s1);
103     dummy = ui_xCreateLabelItem (" ", pannel, 5 * bn_fontWidth,z5s2,z4s1);
104     z5s3  = ui_xCreateDialogItem ("z4s3",pannel, "",td_bn_intWidth,dummy,z4s1);
105 
106 
107     z6s1  = ui_xCreateLabelItem ("z-coordinates of the plane: ",pannel,
108 				 colom1 * bn_fontWidth,NULL,z5s1);
109     dummy = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z6s1,z5s1);
110     z6s2  = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,dummy,z5s1);
111     dummy = ui_xCreateLabelItem (" ",pannel,5 * bn_fontWidth,z6s2,z5s1);
112     z6s3  = ui_xCreateDialogItem ("z4s3",pannel,"",td_bn_intWidth,dummy,z5s1);
113 
114     z7s1  = ui_xCreateLabelItem ("             Rel. Position: ",pannel,
115 				 colom1 * bn_fontWidth,NULL,z6s1);
116     dummy = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z7s1,z6s1);
117     z7s2  = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,dummy,z6s1);
118     dummy = ui_xCreateLabelItem (" ",pannel,5 * bn_fontWidth,z7s2,z6s1);
119     z7s3  = ui_xCreateFrameLabelItem (td_plane_pos[TD_PLANE_pos],pannel,
120 				      td_bn_intWidth,dummy,z6s1);
121 
122     dummy         = ui_xCreateLabelItem (" ",pannel,
123 					 15 * bn_fontWidth,NULL,z7s1);
124 
125     plane_edit = ui_xCreateLabelItem ("Edit Plane: ",pannel,
126 				      15 * bn_fontWidth,NULL,dummy);
127     plane_enter = ui_xCreateButtonItem("enter",pannel,plane_edit,dummy);
128     XtAddCallback(plane_enter,XtNcallback,
129 		  (XtCallbackProc)enter_plane_PROC,NULL);
130 
131     plane_insert = ui_xCreateButtonItem ("insert",pannel,
132 						plane_enter,dummy);
133     XtAddCallback(plane_insert,XtNcallback,
134 		  (XtCallbackProc)insert_plane_PROC,NULL);
135 
136     plane_overwrite = ui_xCreateButtonItem ("overwrite",pannel,
137 						   plane_insert,dummy);
138     XtAddCallback(plane_overwrite,XtNcallback,
139 		  (XtCallbackProc)overwrite_plane_PROC,NULL);
140 
141     plane_delete = ui_xCreateButtonItem ("delete",pannel,
142 						plane_overwrite,dummy);
143     XtAddCallback(plane_delete,XtNcallback,
144 		  (XtCallbackProc)delete_plane_PROC,NULL);
145 
146     dummy = ui_xCreateLabelItem(" ",pannel,15 * bn_fontWidth,NULL,plane_edit);
147     plane_to_edit = ui_xCreateButtonItem ("plane_to_edit",pannel,
148 						 dummy,plane_edit);
149     XtAddCallback(plane_to_edit,XtNcallback,
150 		  (XtCallbackProc)current_plane_to_editor_PROC,NULL);
151 
152     type = ui_xCreateButtonItem ("type",pannel,plane_to_edit,
153 					plane_edit);
154     XtAddCallback(type,XtNcallback,(XtCallbackProc)type_PROC,NULL);
155 
156     pos = ui_xCreateButtonItem ("pos",pannel,type,plane_edit);
157     XtAddCallback(pos,XtNcallback,(XtCallbackProc)pos_PROC,NULL);
158 
159     current_plane = ui_xCreateLabelItem ("Current plane: ",pannel,
160 					 15 * bn_fontWidth,NULL,dummy);
161     plane_first = ui_xCreateButtonItem ("first",pannel,current_plane,
162 					       dummy);
163     XtAddCallback(plane_first,XtNcallback,
164 		  (XtCallbackProc)beginning_plane_PROC,NULL);
165 
166     plane_prev = ui_xCreateButtonItem("prev",pannel,plane_first,dummy);
167     XtAddCallback(plane_prev,XtNcallback,
168 		  (XtCallbackProc)backward_plane_PROC,NULL);
169 
170     plane_next = ui_xCreateButtonItem ("next",pannel,plane_prev,dummy);
171     XtAddCallback(plane_next,XtNcallback,
172 		  (XtCallbackProc)forward_plane_PROC,NULL);
173 
174     plane_last = ui_xCreateButtonItem ("last",pannel,plane_next,dummy);
175     XtAddCallback(plane_last,XtNcallback,(XtCallbackProc)end_plane_PROC,NULL);
176 }
177 
178 
179 
180 /*****************************************************************************
181   FUNCTION : bn_createLinkPanel
182 
183   PURPOSE  : creates the link panel, which is part of the bignet-window
184   NOTES    :
185   RETURNS  :
186 
187   UPDATE   : 09.02.1993
188 ******************************************************************************/
189 
bn_createLinkPannel(Widget parent)190 static void bn_createLinkPannel (Widget parent)
191 
192 {
193     Widget pannel;
194     Widget dummy,dummy1,dummy2;
195     Widget link_edit,current_link;
196     Widget link_enter,link_delete,link_overwrite,link_to_edit;
197     Widget link_first,link_last,link_prev,link_next;
198     Arg          arg[25];
199     Cardinal     n;
200 
201     n = 0;
202 
203     pannel = XtCreateManagedWidget("pannel", formWidgetClass, parent, arg, n);
204 
205 
206 
207     dummy1 = ui_xCreateLabelItem (" ",pannel,15 * bn_fontWidth,NULL,NULL);
208     z8s2   = ui_xCreateLabelItem (" Current Link ", pannel,
209 				  14*bn_fontWidth,dummy1,NULL);
210     z8s3   = ui_xCreateLabelItem ("       Edit Link", pannel,
211 				  16*bn_fontWidth,z8s2,NULL);
212     dummy2 = ui_xCreateLabelItem (" ",pannel,15 * bn_fontWidth,NULL,dummy1);
213     z9s1   = ui_xCreateLabelItem ("Source", pannel,
214 				  8*bn_fontWidth,dummy2,dummy1);
215     z9s2   = ui_xCreateLabelItem ("Target", pannel,
216 				  8*bn_fontWidth,z9s1,dummy1);
217     z9s3   = ui_xCreateLabelItem ("  Source", pannel,
218 				  8*bn_fontWidth,z9s2,dummy1);
219     z9s4   = ui_xCreateLabelItem (" Target", pannel,
220 				  8*bn_fontWidth,z9s3,dummy1);
221     z10s1  = ui_xCreateLabelItem ("Plane", pannel,
222 				  15*bn_fontWidth,NULL,dummy2);
223     z10s2  = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,z10s1,dummy2);
224     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z10s2,dummy2);
225     z10s3  = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,dummy,dummy2);
226     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z10s3,dummy2);
227     z10s4  = ui_xCreateDialogItem("z10s4", pannel,"",td_bn_intWidth,
228 				  dummy,dummy2);
229     dummy  = ui_xCreateLabelItem(" ",pannel,1 * bn_fontWidth,z10s4,dummy2);
230     z10s5  = ui_xCreateDialogItem("z10s5", pannel,"",td_bn_intWidth,
231 				  dummy,dummy2);
232     z11s1  = ui_xCreateLabelItem(" ", pannel, 15*bn_fontWidth,NULL,z10s1);
233 
234     z12s1  = ui_xCreateLabelItem ("     Receptive Field Coordinates", pannel,
235 				  30*bn_fontWidth,dummy2,z11s1);
236     z13s1  = ui_xCreateLabelItem ("1st feat. unit:", pannel,
237 				  15*bn_fontWidth,NULL,z12s1);
238     z13s2  = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,z13s1,z12s1);
239     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z13s2,z12s1);
240     z13s3  = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,dummy,z12s1);
241     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z13s3,z12s1);
242     z13s4  = ui_xCreateDialogItem("z13s4", pannel, "",td_bn_intWidth,
243 				  dummy,z12s1);
244     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z13s4,z12s1);
245     z13s5  = ui_xCreateDialogItem("z13s5", pannel, "",td_bn_intWidth,dummy,
246 				  z12s1);
247     z15s1  = ui_xCreateLabelItem ("         width:", pannel,
248 				  15*bn_fontWidth,NULL,z13s1);
249     z15s2  = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,z15s1,z13s1);
250     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z15s2,z13s1);
251     z15s3  = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,dummy,z13s1);
252     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z15s3,z13s1);
253     z15s4  = ui_xCreateDialogItem("z15s4", pannel, "",td_bn_intWidth,
254 				  dummy,z13s1);
255     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z15s4,z13s1);
256     z15s5  = ui_xCreateDialogItem("z15s5", pannel, "",td_bn_intWidth,
257 				  dummy,z13s1);
258 
259     z16s1  = ui_xCreateLabelItem ("  delay length:", pannel,
260 				  15*bn_fontWidth,NULL,z15s1);
261     z16s2  = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,z16s1,z15s1);
262     dummy  = ui_xCreateLabelItem (" ",pannel,1 * bn_fontWidth,z16s2,z15s1);
263     z16s3  = ui_xCreateFrameLabelItem ("", pannel,td_bn_intWidth,dummy,z15s1);
264     dummy  = ui_xCreateLabelItem (" ",pannel,3 * bn_fontWidth,z16s3,z15s1);
265     z16s4  = ui_xCreateDialogItem("z16s4", pannel, "",td_bn_intWidth,
266 				  dummy,z15s1);
267 
268     dummy  = ui_xCreateLabelItem (" ",pannel,15 * bn_fontWidth,NULL,z16s1);
269     link_edit = ui_xCreateLabelItem ("Edit Link: ",pannel,
270 				     15 * bn_fontWidth,NULL,dummy);
271     link_enter = ui_xCreateButtonItem ("enter",pannel,link_edit,dummy);
272     XtAddCallback(link_enter,XtNcallback,(XtCallbackProc)enter_link_PROC,NULL);
273 
274     link_overwrite = ui_xCreateButtonItem ("overwrite",pannel,
275 						  link_enter,dummy);
276     XtAddCallback(link_overwrite,XtNcallback,
277 		  (XtCallbackProc)overwrite_link_PROC,NULL);
278 
279     link_to_edit = ui_xCreateButtonItem ("link_to_edit",pannel,
280 						link_overwrite,dummy);
281     XtAddCallback(link_to_edit,XtNcallback,
282 		  (XtCallbackProc)current_link_to_editor_PROC,NULL);
283 
284     link_delete = ui_xCreateButtonItem ("delete",pannel,
285 					       link_to_edit,dummy);
286     XtAddCallback(link_delete,XtNcallback,
287 		  (XtCallbackProc)delete_link_PROC,NULL);
288 
289     dummy = ui_xCreateLabelItem (" ",pannel,15 * bn_fontWidth,NULL,link_edit);
290     current_link = ui_xCreateLabelItem ("Current Link: ",pannel,
291 					15*bn_fontWidth,NULL,link_edit);
292     link_first = ui_xCreateButtonItem ("first",pannel,
293 					      current_link,link_edit);
294     XtAddCallback(link_first,XtNcallback,
295 		  (XtCallbackProc)beginning_link_PROC,NULL);
296 
297     link_prev = ui_xCreateButtonItem ("prev",pannel,link_first,link_edit);
298     XtAddCallback(link_prev,XtNcallback,
299 		  (XtCallbackProc)backward_link_PROC,NULL);
300 
301     link_next = ui_xCreateButtonItem ("next",pannel,link_prev,link_edit);
302 
303     XtAddCallback(link_next,XtNcallback,
304 		  (XtCallbackProc)forward_link_PROC,NULL);
305 
306     link_last = ui_xCreateButtonItem ("last",pannel,link_next,link_edit);
307       XtAddCallback(link_last,XtNcallback,(XtCallbackProc)end_link_PROC,NULL);
308 
309   }
310 
311 
312 
313 /*****************************************************************************
314   FUNCTION : exit_PROC
315 
316   PURPOSE  : callback function of the exit-buttom. You are leaving bignet.
317   NOTES    :
318   RETURNS  :
319 
320   UPDATE   : 09.02.1993
321 ******************************************************************************/
322 
exit_PROC(void)323 static void exit_PROC (void)
324 
325 {
326     XtDestroyWidget (td_baseWidget);
327     td_bignet_widget_open = 0;
328 }
329 
330 
331 
332 /*****************************************************************************
333   FUNCTION : bn_create_TD_Bignet
334 
335   PURPOSE  : creates the bignet-window.
336   NOTES    :
337   RETURNS  :
338 
339   UPDATE   : 09.02.1993
340 ******************************************************************************/
341 
bn_create_TD_Bignet(void)342 void bn_create_TD_Bignet (void)
343 
344 {
345     Widget       box;
346     Widget       create_net,exit,cancel;
347     Arg          arg[25];
348     Cardinal     n;
349     char         buf[40];
350 
351     if(td_bignet_widget_open) {
352 	XRaiseWindow (XtDisplay (td_baseWidget), XtWindow (td_baseWidget));
353 	return;
354     }
355 
356 
357     sprintf (buf, "SNNS BigNet (Time Delay)");
358 
359     n = 0;
360     td_baseWidget = XtCreatePopupShell (buf, topLevelShellWidgetClass,
361 					ui_toplevel, arg, n);
362     box = XtCreateManagedWidget ("box",boxWidgetClass,td_baseWidget,arg,n);
363     bn_createPlanePannel (box);
364     bn_createLinkPannel(box);
365 
366     create_net = ui_xCreateButtonItem("create_td_net",box,NULL,NULL);
367     XtAddCallback(create_net,XtNcallback,
368 		  (XtCallbackProc)create_net_PROC,NULL);
369     exit = ui_xCreateButtonItem ("done",box,create_net,NULL);
370     XtAddCallback(exit,XtNcallback,(XtCallbackProc)exit_PROC,NULL);
371     cancel     = ui_xCreateButtonItem ("cancel",box,exit,NULL);
372     XtAddCallback(cancel,XtNcallback,(XtCallbackProc)cancel_net_PROC,NULL);
373 
374     ui_checkWindowPosition(td_baseWidget);
375     XtPopup (td_baseWidget, XtGrabNone);
376     ui_xDontResizeWidget(td_baseWidget);
377     td_bignet_widget_open = 1;
378     if(TD_PLANE_length != 0){
379 	write_current_plane();
380 	if(TD_LINK_length != 0) {
381 	    write_current_link();
382 	}
383     }
384 
385 }
386 
387 
388 /*****************************************************************************
389   FUNCTION : create_net_PROC
390 
391   PURPOSE  : creates a SNNS-net in two steps:
392              1. calls up a function, which creates SNNS-units
393              2. calls up a function, which connections the SNNS-units.
394   NOTES    : There are nine different ways
395              (PLANE_TO_PLANE, PLANE_TO_CLUSTER ...)
396              two different planes can be connected.
397   RETURNS  :
398 
399   UPDATE   : 09.02.1993
400 ******************************************************************************/
401 
create_net_PROC(void)402 static void create_net_PROC(void)
403 
404 {
405     TD_LINK  *TD_LINK_element=TD_LINK_first_element;
406     TD_LINK  *TD_LINK_test=TD_LINK_first_element;
407     TD_PLANE *source_plane,*target_plane;
408     TD_PLANE *test_plane;
409     int move,type_of_connection=1;
410     int create=1;
411     int j,k;
412     int correct = 0;
413     int overlap =0;
414     char buf1[80],buf2[80];
415 
416 
417     TD_BN_ERROR = 0;
418     TD_NET = 1;
419 
420     strcpy(buf1,"Unused feature units in Plane ");
421     strcpy(buf2,"Overlapping Receptive Field in Plane ");
422 
423 
424     /* check whether all feature units are used or any
425        receptive fields overlap in the target plane  */
426 
427 
428     TD_LINK_test = TD_LINK_first_element;
429 
430     for(k=1; k<=TD_PLANE_length; k++){           /* foreach plane        */
431 	test_plane = get_plane(k);
432 	for(j=1; j<=(*test_plane).width; j++){   /* foreach feature unit */
433 	    overlap = 0;
434 	    while(TD_LINK_test != NULL){         /* foreach link set     */
435 		if(TD_LINK_test->SOURCE.plane == k){
436 		    if((j >= (*TD_LINK_test).SOURCE.CLUSTER.x) &&
437 		       (j < ((*TD_LINK_test).SOURCE.CLUSTER.x +
438 			     (*TD_LINK_test).SOURCE.CLUSTER.width))){
439 			correct++;
440 		    }
441 		}else if(TD_LINK_test->TARGET.plane == k){
442 		    if((j >= TD_LINK_test->TARGET.CLUSTER.x) &&
443 		       (j < (TD_LINK_test->TARGET.CLUSTER.x +
444 			     TD_LINK_test->TARGET.CLUSTER.width))){
445 			overlap++;
446 			if(overlap > 1){
447 			    /* receptive fields overlap */
448 			    sprintf(buf2,"%s %d",buf2,k);
449 			    ui_confirmOk(buf2);
450 			    return;
451 			}
452 		    }
453 		}
454 		TD_LINK_test = TD_LINK_test->next;
455 	    }
456 	    if((correct < 1) && (k != TD_PLANE_length)){
457 		/* not all feature units are used */
458 		sprintf(buf1,"%s %d",buf1,k);
459 		ui_confirmOk(buf1);
460 		return;
461 	    }
462 	    TD_LINK_test = TD_LINK_first_element;
463 	    correct = 0;
464 	}
465     }
466 
467 
468     if(krui_getNoOfUnits() != 0) {
469 	if(! ui_confirmYes("Create will erase current network. Create?")) {
470 	    create = 0;
471 	}
472     }
473 
474     if(create && (TD_PLANE_length != 0)) {
475 
476 	krui_deleteNet();
477 
478 	calculate_first_snns_unit_no_of_plane();
479 	create_snns_unit();
480 
481 	while((TD_LINK_element != NULL) && (! TD_BN_ERROR)) {
482 
483 	    move               = (*TD_LINK_element).move;
484 	    type_of_connection = (*TD_LINK_element).type_of_connection;
485 	    source_plane       =  get_plane((*TD_LINK_element).SOURCE.plane);
486 	    target_plane       =  get_plane((*TD_LINK_element).TARGET.plane);
487 
488 	    switch(type_of_connection) {
489 	      case PLANE_TO_PLANE: {
490 		  make_link(source_plane,0,0,(*source_plane).width,
491 			    (*source_plane).height,target_plane,0,0,
492 			    (*target_plane).width,(*target_plane).height);
493 		  break;
494 	      }
495 	      case PLANE_TO_CLUSTER: {
496 		  make_link(source_plane,0,0,(*source_plane).width,
497 			    (*source_plane).height,target_plane,
498 			    (*TD_LINK_element).TARGET.CLUSTER.x-1,
499 			    (*TD_LINK_element).TARGET.CLUSTER.y-1,
500 			    (*TD_LINK_element).TARGET.CLUSTER.width,
501 			    (*TD_LINK_element).TARGET.CLUSTER.height);
502 		  break;
503 	      }
504 	      case PLANE_TO_UNIT: {
505 		  make_link(source_plane,0,0,
506 			    (*source_plane).width,(*source_plane).height,
507 			    target_plane,(*TD_LINK_element).TARGET.UNIT.x-1,
508 			    (*TD_LINK_element).TARGET.UNIT.y-1,1,1);
509 		  break;
510 	      }
511 	      case CLUSTER_TO_PLANE: {
512 		  make_link(source_plane,(*TD_LINK_element).SOURCE.CLUSTER.x-1,
513 			    (*TD_LINK_element).SOURCE.CLUSTER.y-1,
514 			    (*TD_LINK_element).SOURCE.CLUSTER.width,
515 			    (*TD_LINK_element).SOURCE.CLUSTER.height,
516 			    target_plane,0,0,
517 			    (*target_plane).width,(*target_plane).height);
518 		  break;
519 	      }
520 	      case CLUSTER_TO_CLUSTER: {
521 		  if(move) {
522 		      make_move_link(source_plane,
523 				     (*TD_LINK_element).SOURCE.CLUSTER.x-1,
524 				     (*TD_LINK_element).SOURCE.CLUSTER.y-1,
525 				     (*TD_LINK_element).SOURCE.CLUSTER.width,
526 				     (*TD_LINK_element).SOURCE.CLUSTER.height,
527 				     target_plane,
528 				     (*TD_LINK_element).TARGET.CLUSTER.x-1,
529 				     (*TD_LINK_element).TARGET.CLUSTER.y-1,
530 				     (*TD_LINK_element).TARGET.CLUSTER.width,
531 				     (*TD_LINK_element).TARGET.CLUSTER.height,
532 				     (*TD_LINK_element).SOURCE.MOVE.delta_x,
533 				     (*TD_LINK_element).SOURCE.MOVE.delta_y,
534 				     (*TD_LINK_element).TARGET.MOVE.delta_x,
535 				     (*TD_LINK_element).TARGET.MOVE.delta_y);
536 		  }else{
537 		      make_link(source_plane,
538 				(*TD_LINK_element).SOURCE.CLUSTER.x-1,
539 				(*TD_LINK_element).SOURCE.CLUSTER.y-1,
540 				(*TD_LINK_element).SOURCE.CLUSTER.width,
541 				(*TD_LINK_element).SOURCE.CLUSTER.height,
542 				target_plane,
543 				(*TD_LINK_element).TARGET.CLUSTER.x-1,
544 				(*TD_LINK_element).TARGET.CLUSTER.y-1,
545 				(*TD_LINK_element).TARGET.CLUSTER.width,
546 				(*TD_LINK_element).TARGET.CLUSTER.height);
547 		  }
548 		  break;
549 	      }
550 	      case CLUSTER_TO_UNIT: {
551 		  if(move) {
552 		      make_move_link(source_plane,
553 				     (*TD_LINK_element).SOURCE.CLUSTER.x-1,
554 				     (*TD_LINK_element).SOURCE.CLUSTER.y-1,
555 				     (*TD_LINK_element).SOURCE.CLUSTER.width,
556 				     (*TD_LINK_element).SOURCE.CLUSTER.height,
557 				     target_plane,
558 				     (*TD_LINK_element).TARGET.UNIT.x-1,
559 				     (*TD_LINK_element).TARGET.UNIT.y-1,1,1,
560 				     (*TD_LINK_element).SOURCE.MOVE.delta_x,
561 				     (*TD_LINK_element).SOURCE.MOVE.delta_y,
562 				     (*TD_LINK_element).TARGET.MOVE.delta_x,
563 				     (*TD_LINK_element).TARGET.MOVE.delta_y);
564 		  }else{
565 		      make_link(source_plane,
566 				(*TD_LINK_element).SOURCE.CLUSTER.x-1,
567 				(*TD_LINK_element).SOURCE.CLUSTER.y-1,
568 				(*TD_LINK_element).SOURCE.CLUSTER.width,
569 				(*TD_LINK_element).SOURCE.CLUSTER.height,
570 				target_plane,
571 				(*TD_LINK_element).TARGET.UNIT.x-1,
572 				(*TD_LINK_element).TARGET.UNIT.y-1,1,1);
573 		  }
574 		  break;
575 	      }
576 	      case UNIT_TO_PLANE: {
577 		  make_link(source_plane,(*TD_LINK_element).SOURCE.UNIT.x-1,
578 			    (*TD_LINK_element).SOURCE.UNIT.y-1,1,1,
579 			    target_plane,0,0,
580 			    (*target_plane).width,(*target_plane).height);
581 		  break;
582 	      }
583 	      case UNIT_TO_CLUSTER: {
584 		  if(move) {
585 		      make_move_link(source_plane,
586 				     (*TD_LINK_element).SOURCE.UNIT.x-1,
587 				     (*TD_LINK_element).SOURCE.UNIT.y-1,1,1,
588 				     target_plane,
589 				     (*TD_LINK_element).TARGET.CLUSTER.x-1,
590 				     (*TD_LINK_element).TARGET.CLUSTER.y-1,
591 				     (*TD_LINK_element).TARGET.CLUSTER.width,
592 				     (*TD_LINK_element).TARGET.CLUSTER.height,
593 				     (*TD_LINK_element).SOURCE.MOVE.delta_x,
594 				     (*TD_LINK_element).SOURCE.MOVE.delta_y,
595 				     (*TD_LINK_element).TARGET.MOVE.delta_x,
596 				     (*TD_LINK_element).TARGET.MOVE.delta_y);
597 		  }else{
598 		      make_link(source_plane,
599 				(*TD_LINK_element).SOURCE.UNIT.x-1,
600 				(*TD_LINK_element).SOURCE.UNIT.y-1,1,1,
601 				target_plane,
602 				(*TD_LINK_element).TARGET.CLUSTER.x-1,
603 				(*TD_LINK_element).TARGET.CLUSTER.y-1,
604 				(*TD_LINK_element).TARGET.CLUSTER.width,
605 				(*TD_LINK_element).TARGET.CLUSTER.height);
606 		  }
607 		  break;
608 	      }
609 	      case UNIT_TO_UNIT: {
610 		  if(move) {
611 		      make_move_link(source_plane,
612 				     (*TD_LINK_element).SOURCE.UNIT.x-1,
613 				     (*TD_LINK_element).SOURCE.UNIT.y-1,1,1,
614 				     target_plane,
615 				     (*TD_LINK_element).TARGET.UNIT.x-1,
616 				     (*TD_LINK_element).TARGET.UNIT.y-1,1,1,
617 				     (*TD_LINK_element).SOURCE.MOVE.delta_x,
618 				     (*TD_LINK_element).SOURCE.MOVE.delta_y,
619 				     (*TD_LINK_element).TARGET.MOVE.delta_x,
620 				     (*TD_LINK_element).TARGET.MOVE.delta_y);
621 		  }else{
622 		      make_link(source_plane,
623 				(*TD_LINK_element).SOURCE.UNIT.x-1,
624 				(*TD_LINK_element).SOURCE.UNIT.y-1,1,1,
625 				target_plane,
626 				(*TD_LINK_element).TARGET.UNIT.x-1,
627 				(*TD_LINK_element).TARGET.UNIT.y-1,1,1);
628 		  }
629 		  break;
630 	      }
631 	    }			/* switch */
632 
633 	    TD_LINK_element = (*TD_LINK_element).next;
634 
635 	}			/* while */
636 
637 	bn_basics_refresh();
638 
639     }				/* if */
640 
641 }
642 
643 
644 /*****************************************************************************
645   FUNCTION : calculate_first_snns_unit_no_of_plane
646 
647   PURPOSE  : calculates the SNNS unit no of the left upper corner of every
648              plane.
649 
650   NOTES    : relative to this unit no, knowing the width and the height of the
651              planes, all other SNNS unit numbers of every plane can be
652              calculated. That's important for the function create_snns_unit.
653   RETURNS  :
654 
655   UPDATE   : 09.02.1993
656 ******************************************************************************/
657 
calculate_first_snns_unit_no_of_plane(void)658 static void calculate_first_snns_unit_no_of_plane(void)
659 
660 {
661     TD_PLANE *TD_PLANE_element = TD_PLANE_first_element;
662 
663     (*TD_PLANE_element).begin = 1;
664     TD_PLANE_element = (*TD_PLANE_element).next;
665 
666     while(TD_PLANE_element != NULL) {
667 	(*TD_PLANE_element).begin = (*(*TD_PLANE_element).before).width *
668 	    (*(*TD_PLANE_element).before).height +
669 		(*(*TD_PLANE_element).before).begin;
670 	TD_PLANE_element = (*TD_PLANE_element).next;
671     }
672 }
673 
674 
675 
676 /*****************************************************************************
677   FUNCTION : create_snns_unit
678 
679   PURPOSE  : creates for every unit of a plane a SNNS default unit.
680 
681   NOTES    :
682   RETURNS  :
683 
684   UPDATE   : 09.02.1993
685 ******************************************************************************/
686 
create_snns_unit(void)687 static void create_snns_unit(void)
688 
689 {
690     struct PosType unit_pos;
691     struct Unit *unit_ptr;
692 
693     TD_PLANE *TD_PLANE_element = TD_PLANE_first_element;
694     TD_LINK  *TD_LINK_Element;
695     int plane_no = 1;
696     int lun = 1; /* unit_number within a plane */
697     int connection_type;
698     int x,y,width,height,unit_no,pos,ret;
699     int y_offset=0,relative_y_max=0,absolute_y_max=0,y_begin;
700     int x_max=0,old_x_begin=2,new_x_begin,x_begin;
701     Bool found;
702 
703     ret = krui_allocateUnits((*TD_PLANE_last_element).width *
704                              (*TD_PLANE_last_element).height +
705 			     (*TD_PLANE_last_element).begin-1);
706     if(ret != 0){
707 	ui_tw_errorMessage(krui_error(ret));
708 	TD_BN_ERROR = 1;
709     }
710 
711     while((! TD_BN_ERROR) && (TD_PLANE_element != NULL)) {
712 
713 	height = (*TD_PLANE_element).height;
714 	width  = (*TD_PLANE_element).width;
715 	pos    = (*TD_PLANE_element).pos;
716 
717 	y_begin = calculate_y_begin(&absolute_y_max,&relative_y_max,
718 				    &y_offset,height,pos);
719 	x_begin = calculate_x_begin(&new_x_begin,&old_x_begin,
720 				    &x_max,width,pos);
721 
722 	for(y=0;y<height;y++){
723 	    for(x=0;x<width;x++){
724 		unit_no = krui_createDefaultUnit();
725 		if(unit_no<0) ui_checkError(unit_no);
726 		unit_ptr = kr_getUnitPtr(unit_no);
727 		ret = krui_setUnitTType(unit_no,(*TD_PLANE_element).type+1);
728 		if(ret != 0){
729 		    ui_tw_errorMessage(krui_error(ret));
730 		    TD_BN_ERROR = 1;
731 		}
732 
733 		connection_type = 0;
734 		found = FALSE;
735 		TD_LINK_Element = TD_LINK_first_element;
736 		do {
737 		    if (TD_LINK_Element->TARGET.plane == plane_no) {
738 			connection_type=TD_LINK_Element->type_of_connection;
739 			found = TRUE;
740 		    }
741 		    TD_LINK_Element=TD_LINK_Element->next;
742 		} while ((TD_LINK_Element != NULL) && (!found));
743 
744 		unit_ptr->TD.target_offset = -y*width;
745 		unit_ptr->TD.source_offset = 0;
746 
747 		if (connection_type == CLUSTER_TO_CLUSTER) {
748 		    /* recept. field */
749 		    unit_ptr->TD.td_connect_typ = 1;
750 		}else{
751 		    unit_ptr->TD.td_connect_typ = 0; /* fully connected */
752 		}
753 
754 		unit_ptr->lun = lun;  /* set logical unitno. */
755 		unit_ptr->lln = plane_no;  /* set logical layerno.*/
756 
757 
758 		unit_pos.x = x_begin + x;
759 		unit_pos.y = y_begin + y;
760 		krui_setUnitPosition(unit_no,&unit_pos);
761 		lun++;
762 
763 		krui_setUnitActFunc(unit_no, "Act_TD_Logistic");
764 	    }
765 	}
766 	TD_PLANE_element = (*TD_PLANE_element).next;
767 	plane_no++;
768 	lun = 1;   /* reset logical unitnumber */
769     } /*while*/
770 }
771 
772 
773 
774 /*****************************************************************************
775   FUNCTION : make_link
776 
777   PURPOSE  : creates the links between two planes.
778 
779   NOTES    :
780   RETURNS  :
781 
782   UPDATE   : 09.02.1993
783 ******************************************************************************/
784 
make_link(TD_PLANE * TD_LINK_source_plane,int TD_LINK_source_cluster_x,int TD_LINK_source_cluster_y,int TD_LINK_source_cluster_width,int TD_LINK_source_cluster_height,TD_PLANE * TD_LINK_target_plane,int TD_LINK_target_cluster_x,int TD_LINK_target_cluster_y,int TD_LINK_target_cluster_width,int TD_LINK_target_cluster_height)785 static void make_link(TD_PLANE *TD_LINK_source_plane,
786 		      int TD_LINK_source_cluster_x,
787 		      int TD_LINK_source_cluster_y,
788 		      int TD_LINK_source_cluster_width,
789 		      int TD_LINK_source_cluster_height,
790 		      TD_PLANE *TD_LINK_target_plane,
791 		      int TD_LINK_target_cluster_x,
792 		      int TD_LINK_target_cluster_y,
793 		      int TD_LINK_target_cluster_width,
794 		      int TD_LINK_target_cluster_height)
795 
796 {
797     int i,j,k,l,ret,target_unit,source_unit;
798     int source_features;
799     struct Unit *t_ptr;
800 
801     source_features = TD_LINK_source_plane -> width;
802     for (i = 0; i < TD_LINK_target_plane->height; i++)
803 	for (j = 0; j < TD_LINK_target_plane->width; j++)
804 	{
805 	    target_unit = TD_LINK_target_plane->begin
806 		+ (i * TD_LINK_target_plane->width) + j;
807 	    ret = krui_setCurrentUnit(target_unit);
808 	    if(ret != 0)
809 	    {
810 		ui_tw_errorMessage(krui_error(ret));
811 		TD_BN_ERROR = 1;
812 		krui_deleteNet();
813 		return;
814 	    }
815 	    t_ptr = kr_getUnitPtr(target_unit);
816 	    t_ptr -> TD.source_offset = source_features * i;
817 	}
818     for(i = TD_LINK_target_cluster_y;
819 	i < TD_LINK_target_cluster_height+TD_LINK_target_cluster_y;
820 	i++)
821 	for(j = TD_LINK_target_cluster_x;
822 	    j < TD_LINK_target_cluster_width+TD_LINK_target_cluster_x;
823 	    j++){
824 
825 	    target_unit = (*TD_LINK_target_plane).begin +
826 		(*TD_LINK_target_plane).width * i + j;
827 	    ret = krui_setCurrentUnit(target_unit);
828 	    if(ret != 0){
829 		ui_tw_errorMessage(krui_error(ret));
830 		TD_BN_ERROR = 1;
831 		krui_deleteNet();
832 		return;
833 	    }
834 	    for(k = TD_LINK_source_cluster_y;
835 		k < TD_LINK_source_cluster_height+TD_LINK_source_cluster_y;
836 		k++)
837 		for(l = TD_LINK_source_cluster_x;
838 		    l < TD_LINK_source_cluster_width+TD_LINK_source_cluster_x;
839 		    l++){
840 
841 		    source_unit = (*TD_LINK_source_plane).begin +
842 			(*TD_LINK_source_plane).width * k + l;
843 		    if((ret = krui_createLink(source_unit,0.0)) != 0){
844 			ui_tw_errorMessage(krui_error(ret));
845 			TD_BN_ERROR = 1;
846 			krui_deleteNet();
847 			return;
848 		    }
849 		}
850 	}
851 }
852 
853 
854 
855 /*****************************************************************************
856   FUNCTION : make_move_link
857 
858   PURPOSE  : while "moving" (see docu)  is possible the function make_link
859              is called up.
860   NOTES    :
861   RETURNS  :
862 
863   UPDATE   : 09.02.1993
864 ******************************************************************************/
865 
make_move_link(TD_PLANE * TD_LINK_source_plane,int TD_LINK_source_cluster_x,int LINK_source_cluster_y,int TD_LINK_source_cluster_width,int TD_LINK_source_cluster_height,TD_PLANE * TD_LINK_target_plane,int TD_LINK_target_cluster_x,int LINK_target_cluster_y,int TD_LINK_target_cluster_width,int TD_LINK_target_cluster_height,int TD_LINK_source_move_delta_x,int TD_LINK_source_move_delta_y,int TD_LINK_target_move_delta_x,int TD_LINK_target_move_delta_y)866 static void make_move_link(TD_PLANE *TD_LINK_source_plane,
867 			   int TD_LINK_source_cluster_x,
868 			   int LINK_source_cluster_y,
869                            int TD_LINK_source_cluster_width,
870 			   int TD_LINK_source_cluster_height,
871                            TD_PLANE * TD_LINK_target_plane,
872 			   int TD_LINK_target_cluster_x,
873 			   int LINK_target_cluster_y,
874                            int TD_LINK_target_cluster_width,
875 			   int TD_LINK_target_cluster_height,
876                            int TD_LINK_source_move_delta_x,
877 			   int TD_LINK_source_move_delta_y,
878                            int TD_LINK_target_move_delta_x,
879 			   int TD_LINK_target_move_delta_y)
880 
881 {
882  int xs_pivot = TD_LINK_source_cluster_x;
883  int xt_pivot = TD_LINK_target_cluster_x;
884 
885  do{
886    make_link(TD_LINK_source_plane,TD_LINK_source_cluster_x,
887 	     TD_LINK_source_cluster_y,TD_LINK_source_cluster_width,
888 	     TD_LINK_source_cluster_height,TD_LINK_target_plane,
889 	     TD_LINK_target_cluster_x,TD_LINK_target_cluster_y,
890              TD_LINK_target_cluster_width,TD_LINK_target_cluster_height);
891  }while(! TD_BN_ERROR &&
892 	move_p(TD_LINK_source_plane,&TD_LINK_source_cluster_y,
893 	       &TD_LINK_source_cluster_x,TD_LINK_source_cluster_width,
894 	       TD_LINK_source_cluster_height,xs_pivot,
895 	       TD_LINK_source_move_delta_x,TD_LINK_source_move_delta_y) &&
896 	move_p(TD_LINK_target_plane,&TD_LINK_target_cluster_y,
897 	       &TD_LINK_target_cluster_x,TD_LINK_target_cluster_width,
898 	       TD_LINK_target_cluster_height,xt_pivot,
899 	       TD_LINK_target_move_delta_x,TD_LINK_target_move_delta_y));
900 }
901 
902 
903 
904 /*****************************************************************************
905   FUNCTION : move_p
906 
907   PURPOSE  : tests whether the boundaries of a plane are crossed while
908              "moving" (see docu)
909 
910   NOTES    :
911   RETURNS  :
912 
913   UPDATE   : 09.02.1993
914 ******************************************************************************/
915 
move_p(TD_PLANE * plane_no,int * y,int * x,int width,int height,int x_pivot,int x_step,int y_step)916 static int move_p(TD_PLANE *plane_no,int *y,int *x,int width,int height,
917 		  int x_pivot,int x_step,int y_step)
918 
919 {
920     if(x_step > 0 && ((*x)+width+x_step<=(*plane_no).width))
921 	(*x)+= x_step;
922     else
923 	if(y_step > 0 && ((*y)+height+y_step<=(*plane_no).height))
924 	    {
925 		(*y) += y_step;
926 		(*x) = x_pivot;
927 	    }
928 	else
929 	    return 0;
930 
931     return 1;
932 }
933 
934 
935 /*****************************************************************************
936   FUNCTION : read_link_elements
937 
938   PURPOSE  : reads the input datas of the link editor (Edit Link).
939 
940   NOTES    :
941   RETURNS  : @@@
942 
943   UPDATE   : 09.02.1993
944 ******************************************************************************/
945 
read_link_elements(void)946 static int read_link_elements(void)
947 
948 {
949     TD_LINK_source_plane          = ui_xIntFromAsciiWidget(z10s4);
950     TD_LINK_source_cluster_x      = ui_xIntFromAsciiWidget(z13s4);
951     TD_LINK_source_cluster_y      = 1;
952     TD_LINK_source_cluster_width  = ui_xIntFromAsciiWidget(z15s4);
953     TD_LINK_source_cluster_height = ui_xIntFromAsciiWidget(z16s4);
954 
955     TD_LINK_target_plane          = ui_xIntFromAsciiWidget(z10s5);
956     TD_LINK_target_cluster_x      = ui_xIntFromAsciiWidget(z13s5);
957     TD_LINK_target_cluster_y      = 1;
958     TD_LINK_target_cluster_width  = ui_xIntFromAsciiWidget(z15s5);
959     TD_LINK_target_cluster_height = 1;
960 
961 
962     return correct_link_input();
963 }
964 
965 
966 /*****************************************************************************
967   FUNCTION : write_current_link
968 
969   PURPOSE  : writes the datas of the current_element to the control part
970              (Current Link) of the link editor.
971 
972   NOTES    :
973   RETURNS  :
974 
975   UPDATE   : 09.02.1993
976 ******************************************************************************/
977 
write_current_link(void)978 static void write_current_link(void)
979 
980 {
981     char buf[10];
982 
983     sprintf(buf,"%d",(*TD_LINK_current_element).SOURCE.plane);
984     ui_xSetLabel(z10s2,td_bn_widget_output(buf));
985     sprintf(buf,"%d",(*TD_LINK_current_element).SOURCE.CLUSTER.x);
986     ui_xSetLabel(z13s2,td_bn_widget_output(buf));
987     sprintf(buf,"%d",(*TD_LINK_current_element).SOURCE.CLUSTER.width);
988     ui_xSetLabel(z15s2,td_bn_widget_output(buf));
989     sprintf(buf,"%d",(*TD_LINK_current_element).SOURCE.CLUSTER.height);
990     ui_xSetLabel(z16s2,td_bn_widget_output(buf));
991 
992     sprintf(buf,"%d",(*TD_LINK_current_element).TARGET.plane);
993     ui_xSetLabel(z10s3,td_bn_widget_output(buf));
994     sprintf(buf,"%d",(*TD_LINK_current_element).TARGET.CLUSTER.x);
995     ui_xSetLabel(z13s3,td_bn_widget_output(buf));
996     sprintf(buf,"%d",(*TD_LINK_current_element).TARGET.CLUSTER.width);
997     ui_xSetLabel(z15s3,td_bn_widget_output(buf));
998     sprintf(buf,"%d",(*TD_LINK_current_element).TARGET.CLUSTER.height);
999     ui_xSetLabel(z16s3,td_bn_widget_output(buf));
1000 
1001 }
1002 
1003 
1004 
1005 /*****************************************************************************
1006   FUNCTION : clear_current_link
1007 
1008   PURPOSE  : Deletes the datas standing in Current Link.
1009 
1010   NOTES    :
1011   RETURNS  :
1012 
1013   UPDATE   : 09.02.1993
1014 ******************************************************************************/
1015 
clear_current_link(void)1016 static void clear_current_link(void)
1017 
1018 {
1019     ui_xSetLabel(z10s2,"");
1020     ui_xSetLabel(z13s2,"");
1021     ui_xSetLabel(z15s2,"");
1022     ui_xSetLabel(z16s2,"");
1023 
1024     ui_xSetLabel(z10s3,"");
1025     ui_xSetLabel(z13s3,"");
1026     ui_xSetLabel(z15s3,"");
1027     ui_xSetLabel(z16s3,"");
1028 }
1029 
1030 
1031 
1032 /*****************************************************************************
1033   FUNCTION : write_current_link_to_editor
1034 
1035   PURPOSE  : writes the datas of Current Link to Edit Link
1036 
1037   NOTES    :
1038   RETURNS  :
1039 
1040   UPDATE   : 09.02.1993
1041 ******************************************************************************/
1042 
write_current_link_to_editor(void)1043 static void write_current_link_to_editor(void)
1044 
1045 {
1046 
1047     char buf[10];
1048 
1049     sprintf(buf,"%d",(*TD_LINK_current_element).SOURCE.plane);
1050     ui_xSetString(z10s4,td_bn_widget_output(buf));
1051     sprintf(buf,"%d",(*TD_LINK_current_element).SOURCE.CLUSTER.x);
1052     ui_xSetString(z13s4,td_bn_widget_output(buf));
1053     sprintf(buf,"%d",(*TD_LINK_current_element).SOURCE.CLUSTER.width);
1054     ui_xSetString(z15s4,td_bn_widget_output(buf));
1055     sprintf(buf,"%d",(*TD_LINK_current_element).SOURCE.CLUSTER.height);
1056     ui_xSetString(z16s4,td_bn_widget_output(buf));
1057 
1058     sprintf(buf,"%d",(*TD_LINK_current_element).TARGET.plane);
1059     ui_xSetString(z10s5,td_bn_widget_output(buf));
1060     sprintf(buf,"%d",(*TD_LINK_current_element).TARGET.CLUSTER.x);
1061     ui_xSetString(z13s5,td_bn_widget_output(buf));
1062     sprintf(buf,"%d",(*TD_LINK_current_element).TARGET.CLUSTER.width);
1063     ui_xSetString(z15s5,td_bn_widget_output(buf));
1064 
1065 }
1066 
1067 
1068 
1069 /*****************************************************************************
1070   FUNCTION : clear_edit_link
1071 
1072   PURPOSE  : Deletes the datas standing in Edit Link.
1073 
1074   NOTES    :
1075   RETURNS  :
1076 
1077   UPDATE   : 09.02.1993
1078 ******************************************************************************/
1079 
clear_edit_link(void)1080 static void clear_edit_link(void)
1081 
1082 {
1083     ui_xSetString(z10s4,"");
1084     ui_xSetString(z13s4,"");
1085     ui_xSetString(z15s4,"");
1086     ui_xSetString(z16s4,"");
1087 
1088     ui_xSetString(z10s5,"");
1089     ui_xSetString(z13s5,"");
1090     ui_xSetString(z15s5,"");
1091 }
1092 
1093 
1094 /*****************************************************************************
1095   FUNCTION : enter_link_PROC
1096 
1097   PURPOSE  : callback function, which enters a link element at the end of the
1098              link list.
1099 
1100   NOTES    : the link list contains all datas entered by the link editor.
1101              Every link element is a struct (see bn_types.c)
1102   RETURNS  :
1103 
1104   UPDATE   : 09.02.1993
1105 ******************************************************************************/
1106 
enter_link_PROC(void)1107 static void enter_link_PROC(void)
1108 
1109 {
1110     if(read_link_elements()){
1111 	enter_link();
1112 	write_current_link();
1113 	clear_edit_link();
1114     }
1115 }
1116 
1117 
1118 
1119 /*****************************************************************************
1120   FUNCTION : overwrite_link_PROC
1121 
1122   PURPOSE  : callback function, which overwrites the current link element
1123              (Current Link) with the datas of the link editor (Edit Link).
1124 
1125   NOTES    :
1126   RETURNS  :
1127 
1128   UPDATE   : 09.02.1993
1129 ******************************************************************************/
1130 
overwrite_link_PROC(void)1131 static void overwrite_link_PROC(void)
1132 
1133 {
1134     if(read_link_elements()) {
1135 	overwrite_link();
1136 	write_current_link();
1137 	clear_edit_link();
1138     }
1139 }
1140 
1141 
1142 
1143 /*****************************************************************************
1144   FUNCTION : delete_link_PROC
1145 
1146   PURPOSE  : callback function, which deletes the Currenrt Link out of
1147              the link list.
1148 
1149   NOTES    :
1150   RETURNS  :
1151 
1152   UPDATE   : 09.02.1993
1153 ******************************************************************************/
1154 
delete_link_PROC(void)1155 static void delete_link_PROC(void)
1156 
1157 {
1158     delete_current_link();
1159     if(TD_LINK_length == 0) {
1160 	clear_current_link();
1161     }else{
1162 	write_current_link();
1163     }
1164 }
1165 
1166 
1167 /*****************************************************************************
1168   FUNCTION : forward_link_PROC
1169 
1170   PURPOSE  : callback function, which moves forward one list element in the
1171              link list.
1172 
1173   NOTES    :
1174   RETURNS  :
1175 
1176   UPDATE   : 09.02.1993
1177 ******************************************************************************/
1178 
forward_link_PROC(void)1179 static void forward_link_PROC(void)
1180 
1181 {
1182     if(forward_link()){
1183 	write_current_link();
1184     }
1185 }
1186 
1187 
1188 
1189 /*****************************************************************************
1190   FUNCTION : backward_link_PROC
1191 
1192   PURPOSE  : callback function, which moves backward one list element in the
1193              link list.
1194 
1195   NOTES    :
1196   RETURNS  :
1197 
1198   UPDATE   : 09.02.1993
1199 ******************************************************************************/
1200 
backward_link_PROC(void)1201 static void backward_link_PROC(void)
1202 
1203 {
1204     if(backward_link()) {
1205 	write_current_link();
1206     }
1207 }
1208 
1209 
1210 
1211 /*****************************************************************************
1212   FUNCTION : end_link_PROC
1213 
1214   PURPOSE  : callback function, which jumps to the end of the link list.
1215 
1216   NOTES    :
1217   RETURNS  :
1218 
1219   UPDATE   : 09.02.1993
1220 ******************************************************************************/
1221 
end_link_PROC(void)1222 static void end_link_PROC(void)
1223 
1224 {
1225     if(end_link()) {
1226 	write_current_link();
1227     }
1228 }
1229 
1230 
1231 
1232 /*****************************************************************************
1233   FUNCNCTION : beginning_link_PROC
1234 
1235   PURPOSE  : callback function, which jumps to the beginning of the link list.
1236 
1237   NOTES    :
1238   RETURNS  :
1239 
1240   UPDATE   : 09.02.1993
1241 ******************************************************************************/
1242 
beginning_link_PROC(void)1243 static void beginning_link_PROC(void)
1244 
1245 {
1246     if(beginning_link()) {
1247 	write_current_link();
1248     }
1249 }
1250 
1251 
1252 
1253 /*****************************************************************************
1254   FUNCNCTION : current_link_to_editor_PROC
1255 
1256   PURPOSE  : callback function, which writes the Current Link to Edit Link
1257 
1258   NOTES    :
1259   RETURNS  :
1260 
1261   UPDATE   : 09.02.1993
1262 ******************************************************************************/
1263 
current_link_to_editor_PROC(void)1264 static void current_link_to_editor_PROC(void)
1265 
1266 {
1267     if(TD_LINK_length != 0) {
1268 	write_current_link_to_editor();
1269     }else{
1270 	clear_edit_link();
1271     }
1272 }
1273 
1274 
1275 
1276 /*****************************************************************************
1277   FUNCNCTION : correct_link_input
1278 
1279   PURPOSE  : tests whether the input datas of Edit Link are correct and decides
1280              what kind of link (PLANE_TO_PLANE, PLANE_TO_LINK...) we have.
1281 
1282   NOTES    :
1283   RETURNS  : Correct = 1 ; ERROR = 0
1284 
1285   UPDATE   : 09.02.1993
1286 ******************************************************************************/
1287 
correct_link_input(void)1288 static int correct_link_input(void)
1289 
1290 {
1291     TD_PLANE *TD_PLANE_source_no,*TD_PLANE_target_no;
1292 
1293     int link_type;
1294     int target_plane=0,
1295     source_plane=0;
1296     int target_cluster=0,
1297     source_cluster=0;
1298     int target_unit=0,
1299     source_unit=0;
1300     int a,b,c,d;
1301     char buf[200];
1302 
1303     TD_PLANE_source_no = get_plane(TD_LINK_source_plane);
1304     TD_PLANE_target_no = get_plane(TD_LINK_target_plane);
1305 
1306     TD_LINK_move = 0;
1307 
1308     if((TD_PLANE_source_no == TD_PLANE_target_no) ||
1309        TD_PLANE_source_no == NULL ||
1310        TD_PLANE_target_no == NULL) {
1311 	ui_confirmOk("Source and target plane need to be defined");
1312 	return 0;
1313     }
1314 
1315     if ((TD_LINK_source_cluster_x + TD_LINK_source_cluster_width  >
1316 	 (*TD_PLANE_source_no).width + 1) ||
1317 	(TD_LINK_source_cluster_y + TD_LINK_source_cluster_height >
1318 	 (*TD_PLANE_source_no).height + 1) ||
1319 	(TD_LINK_source_unit_x > (*TD_PLANE_source_no).width) ||
1320 	(TD_LINK_source_unit_y > (*TD_PLANE_source_no).height)) {
1321 	ui_confirmOk("Source receptive field exceeds bounds of source plane");
1322 	return 0;
1323     }
1324 
1325     if ((TD_LINK_target_cluster_x + TD_LINK_target_cluster_width  >
1326 	 (*TD_PLANE_target_no).width + 1) ||
1327 	(TD_LINK_target_cluster_y + TD_LINK_target_cluster_height >
1328 	 (*TD_PLANE_target_no).height + 1) ||
1329 	(TD_LINK_target_unit_x > (*TD_PLANE_target_no).width) ||
1330 	(TD_LINK_target_unit_y > (*TD_PLANE_target_no).height)) {
1331 	ui_confirmOk("Target receptive field exceeds bounds of target plane");
1332 	return 0;
1333     }
1334 
1335     target_plane = TD_TARGET_PLANE;
1336     source_plane = TD_SOURCE_PLANE;
1337 
1338     a=b=c=d=0;
1339 
1340     if(((a=TD_LINK_source_cluster_x) >= 1) &&
1341        ((b=TD_LINK_source_cluster_y) >= 1) &&
1342        ((c=TD_LINK_source_cluster_width) >= 1) &&
1343        ((d=TD_LINK_source_cluster_height) >= 1)) {
1344 	source_cluster = TD_SOURCE_CLUSTER;
1345     }
1346 
1347     if((! source_cluster) && a+b+c+d) {
1348 	ui_confirmOk("Source receptive field not properly defined");
1349 	return 0;
1350     }
1351 
1352     a=b=0;
1353 
1354     if(((a=TD_LINK_source_unit_x) >= 1) &&
1355        ((b=TD_LINK_source_unit_y) >= 1)) {
1356 	source_unit = TD_SOURCE_UNIT;
1357     }
1358 
1359     if((! source_unit) && a+b) {
1360 	ui_confirmOk("Source unit not properly defined");
1361 	return 0;
1362     }
1363 
1364     a=b=c=d=0;
1365 
1366     if(((a=TD_LINK_target_cluster_x) >= 1) &&
1367        ((b=TD_LINK_target_cluster_y) >= 1) &&
1368        ((c=TD_LINK_target_cluster_width) >= 1) &&
1369        ((d=TD_LINK_target_cluster_height) >= 1)) {
1370 	target_cluster = TD_TARGET_CLUSTER;
1371     }
1372 
1373     if((! target_cluster) && a+b+c+d) {
1374 	ui_confirmOk("Target receptive field not properly defined");
1375 	return 0;
1376     }
1377 
1378     a=b=0;
1379 
1380     if(((a=TD_LINK_target_unit_x) >= 1) &&
1381        ((b=TD_LINK_target_unit_y) >= 1)) {
1382 	target_unit = TD_TARGET_UNIT;
1383     }
1384 
1385     if((! target_unit) && a+b) {
1386 	ui_confirmOk("Target unit not properly defined");
1387 	return 0;
1388     }
1389 
1390 
1391     link_type =  target_plane+source_plane+
1392 	target_cluster+source_cluster+
1393 	    target_unit+source_unit;
1394 
1395     if(link_type != PLANE_TO_PLANE &&
1396        TD_LINK_source_cluster_height !=
1397        (*TD_PLANE_source_no).height - (*TD_PLANE_target_no).height + 1){
1398 	sprintf(buf, "Source delay error: should be %d",
1399 		(*TD_PLANE_source_no).height-(*TD_PLANE_target_no).height+1);
1400 	ui_confirmOk(buf);
1401 	return 0;
1402     }
1403 
1404     if(link_type == PLANE_TO_PLANE){
1405 	TD_LINK_source_cluster_height = (*TD_PLANE_source_no).height;
1406     }
1407 
1408     if((link_type == PLANE_TO_PLANE) ||
1409        (link_type == PLANE_TO_CLUSTER) ||
1410        (link_type == PLANE_TO_UNIT) ||
1411        (link_type == CLUSTER_TO_PLANE) ||
1412        (link_type == CLUSTER_TO_CLUSTER) ||
1413        (link_type == CLUSTER_TO_UNIT) ||
1414        (link_type == UNIT_TO_PLANE) ||
1415        (link_type == UNIT_TO_CLUSTER) ||
1416        (link_type == UNIT_TO_UNIT)) {
1417 
1418 	TD_LINK_type_of_connection = link_type;
1419 
1420 	if((TD_LINK_source_move_delta_x || TD_LINK_source_move_delta_y ||
1421 	    TD_LINK_target_move_delta_x || TD_LINK_target_move_delta_y) &&
1422 	   ((link_type == CLUSTER_TO_CLUSTER) ||
1423 	    (link_type == CLUSTER_TO_UNIT)    ||
1424 	    (link_type == UNIT_TO_CLUSTER)    ||
1425 	    (link_type == UNIT_TO_UNIT))) {
1426 	    TD_LINK_move = 1;
1427 	}
1428 	else {
1429 	    TD_LINK_source_move_delta_x =
1430 		TD_LINK_source_move_delta_y =
1431 		    TD_LINK_target_move_delta_x =
1432 			TD_LINK_target_move_delta_y = 0;
1433 	}
1434     }
1435     else
1436     {
1437 	ui_confirmOk("Internal Error: Impossible connection type, "
1438 		     "please report your current BIGNET setting");
1439 	return 0;
1440     }
1441 
1442     /* sucessful */
1443     return 1;
1444 }
1445 
1446 
1447 /*****************************************************************************
1448   FUNCTION : enter_link
1449 
1450   PURPOSE  : enters a link element at the end of the link list.
1451 
1452   NOTES    :
1453   RETURNS  :
1454 
1455   UPDATE   : 09.02.1993
1456 ******************************************************************************/
1457 
enter_link(void)1458 static void enter_link(void)
1459 
1460 {
1461     TD_LINK *TD_LINK_element;
1462 
1463     TD_LINK_element = (TD_LINK *)malloc(sizeof(TD_LINK));
1464 
1465     (*TD_LINK_element).SOURCE.plane          = TD_LINK_source_plane;
1466     (*TD_LINK_element).SOURCE.CLUSTER.x      = TD_LINK_source_cluster_x;
1467     (*TD_LINK_element).SOURCE.CLUSTER.y      = TD_LINK_source_cluster_y;
1468     (*TD_LINK_element).SOURCE.CLUSTER.width  = TD_LINK_source_cluster_width;
1469     (*TD_LINK_element).SOURCE.CLUSTER.height = TD_LINK_source_cluster_height;
1470     (*TD_LINK_element).SOURCE.UNIT.x         = TD_LINK_source_unit_x;
1471     (*TD_LINK_element).SOURCE.UNIT.y         = TD_LINK_source_unit_y;
1472     (*TD_LINK_element).SOURCE.MOVE.delta_x   = TD_LINK_source_move_delta_x;
1473     (*TD_LINK_element).SOURCE.MOVE.delta_y   = TD_LINK_source_move_delta_y;
1474 
1475     (*TD_LINK_element).TARGET.plane          = TD_LINK_target_plane;
1476     (*TD_LINK_element).TARGET.CLUSTER.x      = TD_LINK_target_cluster_x;
1477     (*TD_LINK_element).TARGET.CLUSTER.y      = TD_LINK_target_cluster_y;
1478     (*TD_LINK_element).TARGET.CLUSTER.width  = TD_LINK_target_cluster_width;
1479     (*TD_LINK_element).TARGET.CLUSTER.height = TD_LINK_target_cluster_height;
1480     (*TD_LINK_element).TARGET.UNIT.x         = TD_LINK_target_unit_x;
1481     (*TD_LINK_element).TARGET.UNIT.y         = TD_LINK_target_unit_y;
1482     (*TD_LINK_element).TARGET.MOVE.delta_x   = TD_LINK_target_move_delta_x;
1483     (*TD_LINK_element).TARGET.MOVE.delta_y   = TD_LINK_target_move_delta_y;
1484 
1485     (*TD_LINK_element).move                  = TD_LINK_move;
1486     (*TD_LINK_element).type_of_connection    = TD_LINK_type_of_connection;
1487 
1488     (*TD_LINK_element).next   = NULL;
1489     (*TD_LINK_element).before = TD_LINK_last_element;
1490 
1491     if(TD_LINK_last_element != NULL) {
1492 	(*TD_LINK_last_element).next = TD_LINK_element;
1493     }
1494 
1495     if(TD_LINK_first_element == NULL) {
1496 	TD_LINK_first_element = TD_LINK_element;
1497     }
1498 
1499     TD_LINK_last_element = TD_LINK_element;
1500     TD_LINK_current_element = TD_LINK_last_element;
1501 
1502     TD_LINK_length++;
1503 
1504 }
1505 
1506 
1507 
1508 
1509 /*****************************************************************************
1510   FUNCTION : overwrite_link
1511 
1512   PURPOSE  : overwrites the current link element (Current Link) with the
1513              datas of the link editor (Edit Link).
1514 
1515   NOTES    :
1516   RETURNS  :
1517 
1518   UPDATE   : 09.02.1993
1519 ******************************************************************************/
1520 
overwrite_link(void)1521 static void overwrite_link(void)
1522 
1523 {
1524     if(TD_LINK_length == 0) {
1525 	enter_link();
1526     }else{
1527 	(*TD_LINK_current_element).SOURCE.plane = TD_LINK_source_plane;
1528 	(*TD_LINK_current_element).SOURCE.CLUSTER.x = TD_LINK_source_cluster_x;
1529 	(*TD_LINK_current_element).SOURCE.CLUSTER.y = TD_LINK_source_cluster_y;
1530 	(*TD_LINK_current_element).SOURCE.CLUSTER.width =
1531 	    TD_LINK_source_cluster_width;
1532 	(*TD_LINK_current_element).SOURCE.CLUSTER.height =
1533 	    TD_LINK_source_cluster_height;
1534 	(*TD_LINK_current_element).SOURCE.UNIT.x = TD_LINK_source_unit_x;
1535 	(*TD_LINK_current_element).SOURCE.UNIT.y = TD_LINK_source_unit_y;
1536 	(*TD_LINK_current_element).SOURCE.MOVE.delta_x =
1537 	    TD_LINK_source_move_delta_x;
1538 	(*TD_LINK_current_element).SOURCE.MOVE.delta_y =
1539 	    TD_LINK_source_move_delta_y;
1540 
1541 	(*TD_LINK_current_element).TARGET.plane = TD_LINK_target_plane;
1542 	(*TD_LINK_current_element).TARGET.CLUSTER.x = TD_LINK_target_cluster_x;
1543 	(*TD_LINK_current_element).TARGET.CLUSTER.y = TD_LINK_target_cluster_y;
1544 	(*TD_LINK_current_element).TARGET.CLUSTER.width =
1545 	    TD_LINK_target_cluster_width;
1546 	(*TD_LINK_current_element).TARGET.CLUSTER.height =
1547 	    TD_LINK_target_cluster_height;
1548 	(*TD_LINK_current_element).TARGET.UNIT.x = TD_LINK_target_unit_x;
1549 	(*TD_LINK_current_element).TARGET.UNIT.y = TD_LINK_target_unit_y;
1550 	(*TD_LINK_current_element).TARGET.MOVE.delta_x =
1551 	    TD_LINK_target_move_delta_x;
1552 	(*TD_LINK_current_element).TARGET.MOVE.delta_y =
1553 	    TD_LINK_target_move_delta_y;
1554 
1555 	(*TD_LINK_current_element).move = TD_LINK_move;
1556 	(*TD_LINK_current_element).type_of_connection =
1557 	    TD_LINK_type_of_connection;
1558 
1559 
1560     }
1561 }
1562 
1563 
1564 
1565 /*****************************************************************************
1566   FUNCTION : delete_current_link
1567 
1568   PURPOSE  : deletes  Currenrt Link out of the link list.
1569 
1570   NOTES    :
1571   RETURNS  :
1572 
1573   UPDATE   : 09.02.1993
1574 ******************************************************************************/
1575 
delete_current_link(void)1576 static void delete_current_link(void)
1577 
1578 {
1579     TD_LINK *TD_LINK_element;
1580 
1581     TD_LINK_element = TD_LINK_current_element;
1582 
1583     /* Delete the element "TD_LINK_element" out of the plane-list */
1584 
1585     if(TD_LINK_length != 0) {
1586 	if((*TD_LINK_element).before != NULL) {
1587 	    (*(*TD_LINK_element).before).next = (*TD_LINK_element).next;
1588 	}
1589 	if((*TD_LINK_element).next != NULL) {
1590 	    (*(*TD_LINK_element).next).before = (*TD_LINK_element).before;
1591 	}
1592 
1593 	TD_LINK_length--;
1594 
1595 	/* Update the three pointers
1596 	   TD_LINK_current_element,
1597 	   TD_LINK_first_element,
1598 	   TD_LINK_last_element.
1599 	   */
1600 
1601 	if(TD_LINK_length == 0){
1602 	    TD_LINK_current_element = NULL;
1603 	    TD_LINK_first_element   = NULL;
1604 	    TD_LINK_last_element    = NULL;
1605 	}else if((*TD_LINK_element).next == NULL) {
1606 	    TD_LINK_current_element = (*TD_LINK_element).before;
1607 	    TD_LINK_last_element    = TD_LINK_current_element;
1608 	}else if((*TD_LINK_element).before == NULL) {
1609 	    TD_LINK_current_element = (*TD_LINK_element).next;
1610 	    TD_LINK_first_element   = TD_LINK_current_element;
1611 	}else{
1612 	    TD_LINK_current_element = (*TD_LINK_element).next;
1613 	}
1614 
1615 	free(TD_LINK_element);
1616     }
1617 }
1618 
1619 
1620 
1621 
1622 /*****************************************************************************
1623   FUNCTION : get_links_and_delete_them(plane_no)
1624 
1625   PURPOSE  : deletes all the links which are connected with the plane
1626              "plane_no"
1627 
1628   NOTES    :
1629   RETURNS  :
1630 
1631   UPDATE   : 09.02.1993
1632 ******************************************************************************/
1633 
get_links_and_delete_them(int plane_no)1634 static void get_links_and_delete_them(int plane_no)
1635 
1636 {
1637     TD_LINK *TD_LINK_element = TD_LINK_first_element;
1638 
1639     while(TD_LINK_element != NULL) {
1640 	if(((*TD_LINK_element).SOURCE.plane != plane_no) &&
1641 	   ((*TD_LINK_element).TARGET.plane != plane_no)) {
1642 	    TD_LINK_element = (*TD_LINK_element).next;
1643 	}else {
1644 	    TD_LINK_current_element = TD_LINK_element;
1645 	    TD_LINK_element = (*TD_LINK_element).next;
1646 	    delete_current_link();
1647 	}
1648     }
1649 }
1650 
1651 
1652 
1653 
1654 /*****************************************************************************
1655   FUNCTION : forward_link
1656 
1657   PURPOSE  : moves forward one list element in the link list.
1658 
1659   NOTES    :
1660   RETURNS  :  Error = 0 ; Succes = 1
1661 
1662   UPDATE   : 09.02.1993
1663 ******************************************************************************/
1664 
forward_link(void)1665 static int forward_link(void)
1666 
1667 {
1668     if(TD_LINK_length != 0) {
1669 	if((*TD_LINK_current_element).next != NULL) {
1670 	    TD_LINK_current_element = (*TD_LINK_current_element).next;
1671 	}
1672 	return 1;
1673     }
1674     return 0;
1675 }
1676 
1677 
1678 
1679 
1680 /*****************************************************************************
1681   FUNCTION : backward_link
1682 
1683   PURPOSE  : moves backward one list element in the link list.
1684   NOTES    :
1685   RETURNS  : Error = 0 ; Succes = 1
1686 
1687   UPDATE   : 09.02.1993
1688 ******************************************************************************/
1689 
backward_link(void)1690 static int backward_link(void)
1691 
1692 {
1693     if(TD_LINK_length != 0) {
1694 	if((*TD_LINK_current_element).before != NULL) {
1695 	    TD_LINK_current_element = (*TD_LINK_current_element).before;
1696 	}
1697 	return 1;
1698     }
1699     return 0;
1700 }
1701 
1702 
1703 
1704 /*****************************************************************************
1705   FUNCTION : beginning_link
1706 
1707   PURPOSE  : jumps to the beginning of the link list.
1708 
1709   NOTES    :
1710   RETURNS  : Error = 0 ; Succes = 1
1711 
1712   UPDATE   : 09.02.1993
1713 ******************************************************************************/
1714 
beginning_link(void)1715 static int beginning_link(void)
1716 
1717 {
1718     if(TD_LINK_length != 0){
1719 	TD_LINK_current_element = TD_LINK_first_element;
1720 	return 1;
1721     }
1722     return 0;
1723 }
1724 
1725 
1726 
1727 /*****************************************************************************
1728   FUNCTION : end_link
1729 
1730   PURPOSE  : jumps to the end of the link list.
1731   NOTES    :
1732   RETURNS  : Error = 0 ; Succes = 1
1733 
1734   UPDATE   : 09.02.1993
1735 ******************************************************************************/
1736 
end_link(void)1737 static int end_link(void)
1738 
1739 {
1740     if(TD_LINK_length != 0) {
1741 	TD_LINK_current_element = TD_LINK_last_element;
1742 	return 1;
1743     }
1744     return 0;
1745 }
1746 
1747 
1748 
1749 /*****************************************************************************
1750   FUNCTION : read_plane_elements
1751 
1752   PURPOSE  : reads the input datas of the plane editor (Edit Plane).
1753 
1754   NOTES    :
1755   RETURNS  :  Error = 0 ; Succes = 1
1756 
1757   UPDATE   : 09.02.1993
1758 ******************************************************************************/
1759 
read_plane_elements(void)1760 static int read_plane_elements(void)
1761 
1762 {
1763     TD_PLANE_width = ui_xIntFromAsciiWidget(z4s3);
1764     TD_PLANE_height = ui_xIntFromAsciiWidget(z5s3);
1765     if((TD_PLANE_width > 0) && (TD_PLANE_height > 0)) {
1766 	return 1;
1767     }else{
1768 	return 0;
1769     }
1770 }
1771 
1772 
1773 /*****************************************************************************
1774   FUNCTION : write_current_plane
1775 
1776   PURPOSE  : writes the datas of the current_element to the control part
1777              (Current Plane) of the plane editor.
1778 
1779   NOTES    :
1780   RETURNS  :
1781 
1782   UPDATE   : 09.02.1993
1783 ******************************************************************************/
1784 
write_current_plane(void)1785 static void write_current_plane(void)
1786 
1787 {
1788     char buf[10];
1789 
1790     sprintf(buf,"%d",TD_PLANE_no);
1791     ui_xSetLabel(z2s2,td_bn_widget_output(buf));
1792     ui_xSetLabel(z3s2,td_plane_type[(*TD_PLANE_current_element).type]);
1793     sprintf(buf,"%d",(*TD_PLANE_current_element).width);
1794     ui_xSetLabel(z4s2,td_bn_widget_output(buf));
1795     sprintf(buf,"%d",(*TD_PLANE_current_element).height);
1796     ui_xSetLabel(z5s2,td_bn_widget_output(buf));
1797     sprintf(buf,"%d",0);
1798     ui_xSetLabel(z6s2,td_bn_widget_output(buf));
1799     ui_xSetLabel(z7s2,td_plane_pos[(*TD_PLANE_current_element).pos]);
1800 }
1801 
1802 
1803 
1804 /*****************************************************************************
1805   FUNCTION : clear_current_plane
1806 
1807   PURPOSE  : Deletes the datas standing in Current Plane.
1808 
1809   NOTES    :
1810   RETURNS  :
1811 
1812   UPDATE   : 09.02.1993
1813 ******************************************************************************/
1814 
clear_current_plane(void)1815 static void clear_current_plane(void)
1816 
1817 {
1818     ui_xSetLabel(z2s2,"");
1819     ui_xSetLabel(z3s2,"");
1820     ui_xSetLabel(z4s2,"");
1821     ui_xSetLabel(z5s2,"");
1822     ui_xSetLabel(z6s2,"");
1823     ui_xSetLabel(z7s2,"");
1824 }
1825 
1826 
1827 
1828 /*****************************************************************************
1829   FUNCTION : write_current_plane_to_editor
1830 
1831   PURPOSE  : writes the datas of Current Plane to Edit Plane
1832 
1833   NOTES    :
1834   RETURNS  :
1835 
1836   UPDATE   : 09.02.1993
1837 ******************************************************************************/
1838 
write_current_plane_to_editor(void)1839 static void write_current_plane_to_editor(void)
1840 
1841 {
1842     char buf[10];
1843 
1844     TD_PLANE_type = (*TD_PLANE_current_element).type;
1845     ui_xSetLabel(z3s3,td_plane_type[TD_PLANE_type]);
1846     sprintf(buf,"%d",(*TD_PLANE_current_element).width);
1847     ui_xSetString(z4s3,td_bn_widget_output(buf));
1848     sprintf(buf,"%d",(*TD_PLANE_current_element).height);
1849     ui_xSetString(z5s3,td_bn_widget_output(buf));
1850     sprintf(buf,"%d",0);
1851     ui_xSetString(z6s3,td_bn_widget_output(buf));
1852     TD_PLANE_pos = (*TD_PLANE_current_element).pos;
1853     ui_xSetLabel(z7s3,td_plane_pos[TD_PLANE_pos]);
1854 }
1855 
1856 
1857 
1858 /*****************************************************************************
1859   FUNCTION : clear_edit_plane
1860 
1861   PURPOSE  : Deletes the datas standing in Edit Link.
1862 
1863   NOTES    :
1864   RETURNS  :
1865 
1866   UPDATE   : 09.02.1993
1867 ******************************************************************************/
1868 
clear_edit_plane(void)1869 static void clear_edit_plane(void)
1870 
1871 {
1872     ui_xSetString(z4s3,"");
1873     ui_xSetString(z5s3,"");
1874     ui_xSetString(z6s3,"");
1875 }
1876 
1877 
1878 
1879 
1880 /*****************************************************************************
1881   FUNCTION : cancel_net_PROC
1882 
1883   PURPOSE  : callback function, which deletes all the datas in the link
1884              editor and in the plane editor.
1885 
1886   NOTES    :
1887   RETURNS  :
1888 
1889   UPDATE   : 09.02.1993
1890 ******************************************************************************/
1891 
cancel_net_PROC(void)1892 static void cancel_net_PROC(void)
1893 
1894 {
1895     while(TD_PLANE_length){
1896 	delete_current_plane();
1897     }
1898     clear_current_plane();
1899     clear_current_link();
1900 }
1901 
1902 
1903 
1904 /*****************************************************************************
1905   FUNCTION : enter_plane_PROC
1906 
1907   PURPOSE  : callback function, which enters a plane element at the end of the
1908              plane list.
1909 
1910   NOTES    : the plane list contains all datas entered by the plane editor.
1911              Every plane element is a struct (see bn_types.c)
1912   RETURNS  :
1913 
1914   UPDATE   : 09.02.1993
1915 ******************************************************************************/
1916 
enter_plane_PROC(void)1917 static void enter_plane_PROC(void)
1918 
1919 {
1920     if(read_plane_elements()){
1921 	enter_plane();
1922 	write_current_plane();
1923 	clear_edit_plane();
1924     }
1925 }
1926 
1927 
1928 
1929 /*****************************************************************************
1930   FUNCTION : insert_plane_PROC
1931 
1932   PURPOSE  : callback function, which inserts the the input datas of the
1933              plane editor (Edit Plane) in front of Current Plane.
1934 
1935   NOTES    :
1936   RETURNS  :
1937 
1938   UPDATE   : 09.02.1993
1939 ******************************************************************************/
1940 
insert_plane_PROC(void)1941 static void insert_plane_PROC(void)
1942 
1943 {
1944     if(read_plane_elements()) {
1945 	insert_plane();
1946 	write_current_plane();
1947 	clear_edit_plane();
1948 	if(TD_LINK_length == 0) {
1949 	    clear_current_link();
1950 	}else{
1951 	    write_current_link();
1952 	}
1953     }
1954 }
1955 
1956 
1957 
1958 /*****************************************************************************
1959   FUNCTION : overwrite_plane_PROC
1960 
1961   PURPOSE  : callback function, which overwrites the current plane element
1962              (Current Plane) with the datas of the plane editor (Edit plane).
1963 
1964   NOTES    :
1965   RETURNS  :
1966 
1967   UPDATE   : 20.12.1991
1968 ******************************************************************************/
1969 
overwrite_plane_PROC(void)1970 static void overwrite_plane_PROC(void)
1971 
1972 {
1973     if(read_plane_elements()) {
1974 	overwrite_plane();
1975 	write_current_plane();
1976 	clear_edit_plane();
1977 	if(TD_LINK_length == 0) {
1978 	    clear_current_link();
1979 	}else{
1980 	    write_current_link();
1981 	}
1982     }
1983 }
1984 
1985 
1986 
1987 /*****************************************************************************
1988   FUNCTION : delete_plane_PROC
1989 
1990   PURPOSE  : callback function, which deletes the Currenrt Plane out of
1991              the plane list.
1992 
1993   NOTES    :
1994   RETURNS  :
1995 
1996   UPDATE   : 09.02.1993
1997 ******************************************************************************/
1998 
delete_plane_PROC(void)1999 static void delete_plane_PROC(void)
2000 
2001 {
2002     delete_current_plane();
2003     if(TD_PLANE_length == 0) {
2004 	clear_current_plane();
2005     }else{
2006 	write_current_plane();
2007     }
2008     if(TD_LINK_length == 0) {
2009 	clear_current_link();
2010     }else{
2011 	write_current_link();
2012     }
2013 }
2014 
2015 
2016 
2017 /*****************************************************************************
2018   FUNCTION : forward_plane_PROC
2019 
2020   PURPOSE  : callback function, which moves forward one list element in the
2021              plane list.
2022 
2023   NOTES    :
2024   RETURNS  :
2025 
2026   UPDATE   : 09.02.1993
2027 ******************************************************************************/
2028 
forward_plane_PROC(void)2029 static void forward_plane_PROC(void)
2030 
2031 {
2032     if(forward_plane()){
2033 	write_current_plane();
2034     }
2035 }
2036 
2037 
2038 
2039 /*****************************************************************************
2040   FUNCTION : backward_plane_PROC
2041 
2042   PURPOSE  : callback function, which moves backward one list element in the
2043              plane list.
2044 
2045   NOTES    :
2046   RETURNS  :
2047 
2048   UPDATE   : 09.02.1993
2049 ******************************************************************************/
2050 
backward_plane_PROC(void)2051 static void backward_plane_PROC(void)
2052 
2053 {
2054     if(backward_plane()) {
2055 	write_current_plane();
2056     }
2057 }
2058 
2059 
2060 
2061 /*****************************************************************************
2062   FUNCTION : end_plane_PROC
2063 
2064   PURPOSE  : callback function, which jumps to the end of the plane list.
2065 
2066   NOTES    :
2067   RETURNS  :
2068 
2069   UPDATE   : 09.02.1993
2070 ******************************************************************************/
2071 
end_plane_PROC(void)2072 static void end_plane_PROC(void)
2073 
2074 {
2075     if(end_plane()) {
2076 	write_current_plane();
2077     }
2078 }
2079 
2080 
2081 
2082 /*****************************************************************************
2083   FUNCTION : beginning_plane_PROC
2084 
2085   PURPOSE  : callback function, which jumps to the beginning of the plane list.
2086 
2087   NOTES    :
2088   RETURNS  :
2089 
2090   UPDATE   : 09.02.1993
2091 ******************************************************************************/
2092 
beginning_plane_PROC(void)2093 static void beginning_plane_PROC(void)
2094 
2095 {
2096     if(beginning_plane()) {
2097 	write_current_plane();
2098     }
2099 }
2100 
2101 
2102 
2103 /*****************************************************************************
2104   FUNCNCTION : pos_PROC
2105 
2106   PURPOSE  : callback function, which defines the position of the plane in the
2107              display window.
2108 
2109   NOTES    :
2110   RETURNS  :
2111 
2112   UPDATE   : 09.02.1993
2113 ******************************************************************************/
2114 
pos_PROC(void)2115 static void pos_PROC(void)
2116 
2117 {
2118     if(TD_PLANE_pos == TD_BN_RIGHT) {
2119 	TD_PLANE_pos = TD_BN_BELOW;
2120     }else if(TD_PLANE_pos == TD_BN_BELOW) {
2121 	TD_PLANE_pos = TD_BN_LEFT;
2122     }else{
2123 	TD_PLANE_pos = TD_BN_RIGHT;
2124     }
2125     ui_xSetLabel(z7s3,td_plane_pos[TD_PLANE_pos]);
2126 }
2127 
2128 
2129 
2130 /*****************************************************************************
2131   FUNCNCTION : current_plane_to_editor_PROC
2132 
2133   PURPOSE  : callback function, which writes the Current Plane to Edit Plane
2134 
2135   NOTES    :
2136   RETURNS  :
2137 
2138   UPDATE   : 09.02.1993
2139 ******************************************************************************/
2140 
current_plane_to_editor_PROC(void)2141 static void current_plane_to_editor_PROC(void)
2142 
2143 {
2144     if(TD_PLANE_length != 0) {
2145 	write_current_plane_to_editor();
2146     }else{
2147 	clear_edit_plane();
2148     }
2149 }
2150 
2151 
2152 
2153 /*****************************************************************************
2154   FUNCNCTION : type_PROC
2155 
2156   PURPOSE  : callback function, which defines the unit type of a plane.
2157 
2158   NOTES    :
2159   RETURNS  :
2160 
2161   UPDATE   : 09.02.1993
2162 ******************************************************************************/
2163 
type_PROC(void)2164 static void type_PROC(void)
2165 
2166 {
2167     switch(TD_PLANE_type){
2168       case TD_BN_INPUT : {TD_PLANE_type = TD_BN_HIDDEN; break;}
2169       case TD_BN_HIDDEN: {TD_PLANE_type = TD_BN_OUTPUT; break;}
2170       case TD_BN_OUTPUT: {TD_PLANE_type = TD_BN_INPUT ; break;}
2171     }
2172     ui_xSetLabel(z3s3,td_plane_type[TD_PLANE_type]);
2173 }
2174 
2175 
2176 
2177 /*****************************************************************************
2178   FUNCTION : enter_plane
2179 
2180   PURPOSE  : enters a plane element at the end of the plane list.
2181 
2182   NOTES    :
2183   RETURNS  :
2184 
2185   UPDATE   : 09.02.1993
2186 ******************************************************************************/
2187 
enter_plane(void)2188 static void enter_plane(void)
2189 
2190 {
2191     TD_PLANE *TD_PLANE_element;
2192 
2193     TD_PLANE_element = (TD_PLANE *)malloc(sizeof(TD_PLANE));
2194     (*TD_PLANE_element).width  = TD_PLANE_width;
2195     (*TD_PLANE_element).height = TD_PLANE_height;
2196     (*TD_PLANE_element).pos    = TD_PLANE_pos;
2197     (*TD_PLANE_element).type   = TD_PLANE_type;
2198     (*TD_PLANE_element).next   = NULL;
2199     (*TD_PLANE_element).before = TD_PLANE_last_element;
2200 
2201     if(TD_PLANE_last_element != NULL) {
2202 	(*TD_PLANE_last_element).next = TD_PLANE_element;
2203     }
2204 
2205     if(TD_PLANE_first_element == NULL) {
2206 	TD_PLANE_first_element = TD_PLANE_element;
2207     }
2208 
2209     TD_PLANE_last_element = TD_PLANE_element;
2210     TD_PLANE_current_element = TD_PLANE_last_element;
2211 
2212     TD_PLANE_no = ++TD_PLANE_length;
2213 
2214 }
2215 
2216 
2217 
2218 /*****************************************************************************
2219   FUNCTION : insert_plane
2220 
2221   PURPOSE  : inserts the the input datas of the plane editor (Edit Plane) in
2222              front of Current Plane.
2223 
2224   NOTES    :
2225   RETURNS  :
2226 
2227   UPDATE   : 09.02.1993
2228 ******************************************************************************/
2229 
insert_plane(void)2230 static void insert_plane(void)
2231 
2232 {
2233     TD_PLANE *TD_PLANE_element;
2234 
2235     if(TD_PLANE_length == 0) {
2236 	enter_plane();
2237     }else{
2238 	TD_PLANE_element = (TD_PLANE *)malloc(sizeof(TD_PLANE));
2239 
2240 	(*TD_PLANE_element).width  = TD_PLANE_width;
2241 	(*TD_PLANE_element).height = TD_PLANE_height;
2242 	(*TD_PLANE_element).pos    = TD_PLANE_pos;
2243 	(*TD_PLANE_element).type   = TD_PLANE_type;
2244 	(*TD_PLANE_element).next   = TD_PLANE_current_element;
2245 	(*TD_PLANE_element).before = (*TD_PLANE_current_element).before;
2246 
2247 	if((*TD_PLANE_current_element).before != 0) {
2248 	    (*(*TD_PLANE_current_element).before).next = TD_PLANE_element;
2249 	}
2250 	(*TD_PLANE_current_element).before = TD_PLANE_element;
2251 
2252 	TD_PLANE_current_element = TD_PLANE_element;
2253 
2254 	if((*TD_PLANE_element).before == NULL) {
2255 	    TD_PLANE_first_element = TD_PLANE_element;
2256 	}
2257 
2258 	TD_PLANE_length++;
2259 
2260 	TD_LINK_current_element = TD_LINK_first_element;
2261 
2262 	while(TD_LINK_current_element) {
2263 	    if((*TD_LINK_current_element).SOURCE.plane >= TD_PLANE_no) {
2264 		(*TD_LINK_current_element).SOURCE.plane++;
2265 	    }
2266 	    if((*TD_LINK_current_element).TARGET.plane >= TD_PLANE_no) {
2267 		(*TD_LINK_current_element).TARGET.plane++;
2268 	    }
2269 	    TD_LINK_current_element = (*TD_LINK_current_element).next;
2270 	}
2271 
2272 	TD_LINK_current_element = TD_LINK_last_element;
2273 
2274     }
2275 
2276 }
2277 
2278 
2279 
2280 /*****************************************************************************
2281   FUNCTION : overwrite_plane
2282 
2283   PURPOSE  : overwrites the current plane element (Current Plane) with the
2284              datas of the plane editor (Edit Plane).
2285 
2286   NOTES    :
2287   RETURNS  :
2288 
2289   UPDATE   : 09.02.1993
2290 ******************************************************************************/
2291 
overwrite_plane(void)2292 static void overwrite_plane(void)
2293 
2294 {
2295     if(TD_PLANE_length == 0) {
2296 	enter_plane();
2297     }else{
2298 	(*TD_PLANE_current_element).width  = TD_PLANE_width;
2299 	(*TD_PLANE_current_element).height = TD_PLANE_height;
2300 	(*TD_PLANE_current_element).pos    = TD_PLANE_pos;
2301 	(*TD_PLANE_current_element).type   = TD_PLANE_type;
2302 
2303 	get_links_and_delete_them(TD_PLANE_no);
2304 
2305 	TD_LINK_current_element = TD_LINK_first_element;
2306 
2307     }
2308 
2309 }
2310 
2311 
2312 
2313 /*****************************************************************************
2314   FUNCTION : delete_current_plane
2315 
2316   PURPOSE  : deletes Currenrt Plane out of the plane list.
2317 
2318   NOTES    :
2319   RETURNS  :
2320 
2321   UPDATE   : 09.02.1993
2322 ******************************************************************************/
2323 
delete_current_plane(void)2324 static void delete_current_plane(void)
2325 
2326 {
2327     TD_PLANE *TD_PLANE_element;
2328 
2329     TD_PLANE_element = TD_PLANE_current_element;
2330 
2331     /* Delete the element "TD_PLANE_element" out of the plane-list */
2332 
2333     if(TD_PLANE_length != 0) {
2334 	if((*TD_PLANE_element).before != NULL) {
2335 	    (*(*TD_PLANE_element).before).next = (*TD_PLANE_element).next;
2336 	}
2337 	if((*TD_PLANE_element).next != NULL) {
2338 	    (*(*TD_PLANE_element).next).before = (*TD_PLANE_element).before;
2339 	}
2340 
2341 	/* Delete all the links which are connected with the deleted plane */
2342 
2343 	get_links_and_delete_them(TD_PLANE_no);
2344 
2345 	TD_LINK_current_element = TD_LINK_first_element;
2346 
2347 	/* Decrement the number of the Planes */
2348 
2349 	while(TD_LINK_current_element) {
2350 	    if((*TD_LINK_current_element).SOURCE.plane > TD_PLANE_no) {
2351 		(*TD_LINK_current_element).SOURCE.plane--;
2352 	    }
2353 	    if((*TD_LINK_current_element).TARGET.plane > TD_PLANE_no) {
2354 		(*TD_LINK_current_element).TARGET.plane--;
2355 	    }
2356 	    TD_LINK_current_element = (*TD_LINK_current_element).next;
2357 	}
2358 
2359 	TD_LINK_current_element = TD_LINK_last_element;
2360 
2361 	TD_PLANE_length--;
2362 
2363 	/* Update the three pointers "PLANE_current_element",
2364 	   "PLANE_first_element" "PLANE_last_element."  */
2365 
2366 	if(TD_PLANE_length == 0){
2367 	    TD_PLANE_current_element = NULL;
2368 	    TD_PLANE_first_element   = NULL;
2369 	    TD_PLANE_last_element    = NULL;
2370 	    TD_PLANE_no--;
2371 	}else if((*TD_PLANE_element).next == NULL) {
2372 	    TD_PLANE_current_element = (*TD_PLANE_element).before;
2373 	    TD_PLANE_last_element    = TD_PLANE_current_element;
2374 	    TD_PLANE_no--;
2375 	}else if((*TD_PLANE_element).before == NULL) {
2376 	    TD_PLANE_current_element = (*TD_PLANE_element).next;
2377 	    TD_PLANE_first_element   = TD_PLANE_current_element;
2378 	}else{
2379 	    TD_PLANE_current_element = (*TD_PLANE_element).next;
2380 	}
2381 
2382 	free(TD_PLANE_element);
2383     }
2384 
2385 }
2386 
2387 
2388 
2389 /*****************************************************************************
2390   FUNCTION : forward_plane
2391 
2392   PURPOSE  : moves forward one list element in the plane list.
2393 
2394   NOTES    :
2395   RETURNS  : Error = 0 ; Succes = 1
2396 
2397   UPDATE   : 09.02.1993
2398 ******************************************************************************/
2399 
forward_plane(void)2400 static int forward_plane(void)
2401 
2402 {
2403     if(TD_PLANE_length != 0) {
2404 	if((*TD_PLANE_current_element).next != NULL) {
2405 	    TD_PLANE_current_element = (*TD_PLANE_current_element).next;
2406 	    TD_PLANE_no++;
2407 	}
2408 	return 1;
2409     }else{
2410 	return 0;
2411     }
2412 
2413 }
2414 
2415 
2416 
2417 /*****************************************************************************
2418   FUNCTION : backward_link
2419 
2420   PURPOSE  : moves backward one plane element in the link list.
2421 
2422   NOTES    :
2423   RETURNS  : Error = 0 ; Succes = 1
2424 
2425   UPDATE   : 09.02.1993
2426 ******************************************************************************/
2427 
backward_plane(void)2428 static int backward_plane(void)
2429 
2430 {
2431     if(TD_PLANE_length != 0) {
2432 	if((*TD_PLANE_current_element).before != NULL) {
2433 	    TD_PLANE_current_element = (*TD_PLANE_current_element).before;
2434 	    TD_PLANE_no--;
2435 	}
2436 	return 1;
2437     }else{
2438 	return 0;
2439     }
2440 }
2441 
2442 
2443 
2444 /*****************************************************************************
2445   FUNCTION : beginning_plane
2446 
2447   PURPOSE  : jumps to the beginning of the plane list.
2448 
2449   NOTES    :
2450   RETURNS  : Error = 0 ; Succes = 1
2451 
2452   UPDATE   : 09.02.1993
2453 ******************************************************************************/
2454 
beginning_plane(void)2455 static int beginning_plane(void)
2456 
2457 {
2458     if(TD_PLANE_length != 0){
2459 	TD_PLANE_current_element = TD_PLANE_first_element;
2460 	TD_PLANE_no = 1;
2461 	return 1;
2462     }else{
2463 	return 0;
2464     }
2465 
2466 }
2467 
2468 
2469 
2470 /*****************************************************************************
2471   FUNCTION : end_plane
2472 
2473   PURPOSE  : jumps to the end of the plane list.
2474 
2475   NOTES    :
2476   RETURNS  : Error = 0 ; Succes = 1
2477 
2478   UPDATE   : 09.02.1993
2479 ******************************************************************************/
2480 
end_plane(void)2481 static int end_plane(void)
2482 
2483 {
2484     if(TD_PLANE_length != 0) {
2485 	TD_PLANE_current_element = TD_PLANE_last_element;
2486 	TD_PLANE_no = TD_PLANE_length;
2487 	return 1;
2488     }else{
2489 	return 0;
2490     }
2491 
2492 }
2493 
2494 
2495 
2496 /*****************************************************************************
2497   FUNCTION : get_plane
2498 
2499   PURPOSE  : returns a pointer to the plane element "plane_no"
2500 
2501   NOTES    :
2502   RETURNS  : returns a pointer to the plane element "plane_no"
2503 
2504   UPDATE   : 09.02.1993
2505 ******************************************************************************/
2506 
get_plane(int plane_no)2507 static TD_PLANE *get_plane(int plane_no)
2508 
2509 {
2510     TD_PLANE *TD_PLANE_element = TD_PLANE_first_element;
2511     int counter = 1;
2512 
2513     while((TD_PLANE_element != NULL) && (counter != plane_no)) {
2514 	counter++;
2515 	TD_PLANE_element = (*TD_PLANE_element).next;
2516     }
2517     return TD_PLANE_element;
2518 
2519 }
2520 
2521 
2522 /*****************************************************************************
2523 
2524 ******************************************************************************/
2525 
2526 /* end of file */
2527 /* lines: 2644 */
2528 
2529 
2530 
2531