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