1 /*****************************************************************************
2   FILE           : $Source: /projects/higgs1/SNNS/CVS/SNNS/xgui/sources/ui.h,v $
3   SHORTNAME      : ui.h
4   SNNS VERSION   : 4.2
5 
6   PURPOSE        : general header file
7   NOTES          : This file is to include in all ui_*.c files.
8                    There is another "general" include file for use of files
9 	            using X.
10 
11   AUTHOR         : Tilman Sommer
12   VERSION        : 2.1
13   DATE           : 18.5.1990
14 
15   CHANGED BY     : Sven Doering
16   RCS VERSION    : $Revision: 2.15 $
17   LAST CHANGE    : $Date: 1998/04/20 11:54:57 $
18 
19     Copyright (c) 1990-1995  SNNS Group, IPVR, Univ. Stuttgart, FRG
20     Copyright (c) 1996-1998  SNNS Group, WSI, Univ. Tuebingen, FRG
21 
22 ******************************************************************************/
23 
24 #ifndef snns_ui
25 #define snns_ui
26 
27 /* X11 */
28 
29 #include <X11/StringDefs.h>
30 #include <X11/Intrinsic.h>
31 
32 
33 
34 /* kernel */
35 #include "glob_typ.h"
36 
37 
38 /***************************** boolean ********************************/
39 
40 
41 #ifndef FALSE
42 
43 #define FALSE (0==1)
44 #define TRUE  (0==0)
45 
46 #endif
47 
48 #define NOT !
49 #define not !
50 #define OR ||
51 #define or ||
52 #define AND &&
53 #define and &&
54 
55 #define BIT_AND &
56 #define BIT_OR |
57 #define BIT_NOT ~
58 #define BIT_XOR ^
59 
60 /***************************** integer ********************************/
61 
62 #define MOD %
63 #define mod %
64 #define DIV /
65 /* #define div / */ /* not used */
66 
67 /***************************** misc    ********************************/
68 
69 #define MAX_NAME_LENGTH 4096
70 
71 #define UI_ASCII_BLANK   32
72 
73 /* used for testing return value of krui_setCurrent...() */
74 #define UI_SET_OK  0
75 
76 
77 /*****************************************************************************/
78 /*****************************************************************************/
79 /*****************************************************************************/
80 
81 
82 typedef  int FlagType;
83 typedef  int StateType;
84 
85 
86 #ifndef Bool
87 
88 typedef int Bool;
89 
90 #endif
91 
92 /* setup panel */
93 struct SetupDataType {
94     Bool          showValueFlg;
95     Bool          showValue;
96     Bool          showTitleFlg;
97     Bool          showTitle;
98     Bool          showLinkFlg;
99     Bool          showDirectionFlg;
100     Bool          showWeightFlg;
101     FlintType     linkPosTrigger, linkNegTrigger;
102     FlintType     unitScaleFactor;
103     FlintType     linkScaleFactor;
104     char          siteName[80];
105     int           backgroundColorIndex;
106     int           selectionColorIndex;
107     int           textColorIndex;
108 };
109 
110 /* selection list item */
111 struct SelectionType {
112     struct SelectionType     *nextPtr;
113     struct PosType           gridPos;  /* grid position of unit */
114     int                      subNetNo;
115     int                      unitNo;   /* and unit no.          */
116     int                      copyNo;   /* no of new created copy */
117                                        /* Used during structure copy */
118     int                      flags;
119   	/* bit  0 - selected
120 	   bit  1 - reserved. not used. last operation failed for
121 	            this unit.
122            bit  3 - UI_ALREADY_MOVED
123 	   bit  4 - UI_ALREADY_REVERSED
124 	   The last two bits are used to remember whether this unit was
125 	   already touched by a move or reverse operation. */
126 };
127 
128 
129 /* unit (info panel) */
130 struct UnitAttributeType {
131     int             no;
132     int             subnetNo;
133     Bool            frozen;
134     struct PosType  gridPos;
135     unsigned short  layers;
136     char            name[MAX_NAME_LENGTH];
137     char            ftype[MAX_NAME_LENGTH];
138     char            actFuncName[MAX_NAME_LENGTH];
139     char            outFuncName[MAX_NAME_LENGTH];
140     int             iotype;
141     FlintType       act;
142     FlintType       i_act;
143     FlintType       out;
144     FlintType       bias;
145 };
146 
147 
148 /* link (info panel) */
149 struct LinkAttributeType {
150     FlintType       weight;
151     FlintType       siteValue;
152     char            siteName[MAX_NAME_LENGTH];
153     char            siteFuncName[MAX_NAME_LENGTH];
154 };
155 
156 
157 struct ErrorValuesType {
158     FlintType       SSE;
159     FlintType       MSE;
160     FlintType       SSE_div_Out;
161 };
162 
163 
164 /*****************************************************************************/
165 /*****************************************************************************/
166 /*****************************************************************************/
167 
168 /* ui_mainP.c */
169 
170 #define UI_POPUP_DUMMY   1
171 #define UI_POPUP_SETUP   2
172 #define UI_POPUP_FILE    3
173 #define UI_POPUP_CANVAS  4
174 #define UI_POPUP_HELP    5
175 #define UI_POPUP_LIST    6
176 #define UI_POPUP_LAYER   7
177 #define UI_POPUP_EDIT    8
178 #define UI_POPUP_CONTROL  9
179 #define UI_POPUP_WEIGHTS_DONE   10
180 #define UI_POPUP_WEIGHTS_CANCEL 11
181 #define UI_POPUP_RESULT  12
182 #define UI_POPUP_SUBPATTERN  13
183 #define UI_POPUP_INFO  16
184 
185 #define SEARCH_WORD_MAXLEN 40
186 
187 #define UI_RANDOM 1
188 #define UI_JOG    2
189 
190 /* mainProcs */
191 
192 struct HelpType {
193     Widget          shellWidget;
194     Widget          textWidget;
195     int             no;
196     Bool            unmapped;
197     struct HelpType *nextPtr;
198 };
199 
200 
201 /* lists */
202 
203 struct SimpleListType {
204     Widget  widgetPtr;     /* in the center of this widget the window will occur */
205     Widget  listWidget;    /* contains the actual list */
206     String  *listPtr;      /* pointer to a array of strings */
207     int     noOfAllocItems;/* size of this array */
208     int     noOfItems;     /* used items in this array */
209     char    msg[100];      /* title */
210     struct UnitAttributeType *unitPtr;
211     int     listType;
212 };
213 
214 /* 1 to 6 are not used in the final release ! The corresponding values
215 are taken from the kernel file glob_typ.h. The other constants are
216 starting with a value of 20 to be open for further extesions of the
217 kernel. */
218 
219 #define UI_LIST_OUT_FUNC    1
220 #define UI_LIST_ACT_FUNC    2
221 #define UI_LIST_SITE_FUNC   3
222 #define UI_LIST_LEARN_FUNC  4
223 #define UI_LIST_UPDATE_FUNC 5
224 #define UI_LIST_INIT_FUNC   6
225 #define UI_LIST_PRUN_FUNC   10
226 #define UI_LIST_FF_LEARN_FUNC  0x0404
227 #define UI_LIST_REMAP_FUNC  12
228 
229 #define UI_LIST_IOTYPE         20
230 #define UI_LIST_SITE           21
231 #define UI_LIST_FTYPE_SITE     22
232 #define UI_LIST_UNIT_SITE      23
233 #define UI_LIST_FTYPE_OUT_FUNC 24
234 #define UI_LIST_FTYPE_ACT_FUNC 25
235 #define UI_LIST_FTYPE_NAME     26
236 #define UI_LIST_FTYPE          27
237 
238 
239 
240 /* layers */
241 
242 
243 #define MAX_NO_LAYERS 8
244 
245 
246 /* colors */
247 
248 #define UI_COL_BLACK  0
249 #define UI_COL_RED    1
250 #define UI_COL_GREEN  2
251 #define UI_COL_YELLOW 3
252 #define UI_COL_BLUE   4
253 #define UI_COL_WHITE  7
254 #define UI_COL_BROWN  8
255 #define UI_COL_SEA    9
256 
257 #define UI_COL_DARK   0
258 #define UI_COL_NORM   1
259 #define UI_COL_BRIGHT 2
260 
261 
262 #define UI_BLACK  56
263 #define UI_RED    57
264 #define UI_GREEN  58
265 #define UI_BLUE   59
266 #define UI_WHITE  63
267 #define UI_BROWN  36
268 #define UI_YELLOW 60
269 #define UI_CYAN   62
270 #define UI_SEA    21
271 
272 
273 #define UI_PALETTE_MONO                               0
274 #define UI_PALETTE_MONO_INVERSE                       1
275 
276 #define ui_textColor        ui_editColor[displayPtr->setup.textColorIndex]
277 #define ui_selectionColor   ui_editColor[displayPtr->setup.selectionColorIndex]
278 #define ui_backgroundColor  ui_editColor[displayPtr->setup.backgroundColorIndex]
279 
280 #define UI_MAXCOLORSTEPS 15
281 
282 #define UI_MAX_EDIT_COLS 64
283 #define UI_VERT_COLS 8
284 #define UI_HORIZ_COLS 8
285 
286 #define UI_SELECT_TEXT_COLOR   0
287 #define UI_SELECT_BACK_COLOR   1
288 #define UI_SELECT_SEL_COLOR    2
289 
290 
291 /* displays */
292 
293 
294 #define UI_LOCAL   1
295 #define UI_GLOBAL  2
296 
297 
298 #define  UI_CLOSED      0
299 #define  UI_OPEN        1
300 
301 #define  UI_ALWAYS_FULL 1
302 #define  UI_INTELLIGENT 2
303 
304 
305 struct Ui_DisplayType {
306     Widget                widget;          /* drawable widget */
307     Window                drawable;        /* drawable window*/
308     Widget                frameWidget;     /* widget containing the
309 					      setup button */
310     int                   displayNo;       /* unique number */
311     Position              x,y;             /* Window coordinates */
312     Dimension             width, height;   /* Window dimensions */
313     struct PosType        origin;          /* upper left corner */
314     int                   gridSize;        /* in pixel */
315     int                   unitsInX;
316     int                   unitsInY;
317     Bool                  frozen;          /* no update in this display */
318     Bool                  raster;          /* draw points on positions - not used*/
319     Bool                  refreshNeeded;   /* a refresh is needed
320 					      Used after command: Graphic Direction.
321 					      move and copy actions need now a full
322 					      refresh */
323     int                   subNetNo;        /* visible in this display */
324     struct SetupDataType  setup;           /* all setup datas */
325     FlagType              flags;
326     unsigned short        layers;          /* visible in this display */
327     FlagType              updateType;
328                           /* can be:
329 			        UI_ALWAYS_FULL  = draw everything
330 				UI_INTELLIGENT  = decide what is better
331 				*/
332     struct Ui_DisplayType  *nextPtr;
333 };
334 
335 
336 
337 
338 /* control */
339 
340 #define UI_LEARN_SINGLE  1
341 #define UI_LEARN_ALL     2
342 
343 #define UI_NO_LEARN_PARAMS  5
344 #define UI_NO_UPDATE_PARAMS 5
345 #define UI_NO_INIT_PARAMS   5
346 #define UI_NO_REMAP_PARAMS   5
347 /* !!!!!! ATTENTION !!!!!
348    When changing the following value, always make sure that
349    NO_OF_LEARN_PARAMS = UI_NO_LEARN_PARAMS + UI_NO_OF_CASCADE_PARAMS
350    remains true!! NO_OF_LEARN_PARAMS is declared in kernel/sources/glob_typ.h
351    Also note, that the file kernel/sources/cc_mac.h assumes that
352    NO_OF_LEARN_PARAMS >= 27 !!!!!
353 */
354 #define UI_NO_OF_CASCADE_PARAMS 23
355 
356 #define UI_STEPS         1
357 #define UI_LEARN         2
358 
359 #define UI_FIRST         1
360 #define UI_PREVIOUS      2
361 #define UI_NEXT          3
362 #define UI_LAST          4
363 #define UI_JUMP          5
364 
365 /* file */
366 
367 
368 #define UI_FILE_TXT     4
369 #define UI_FILE_PAT     2
370 #define UI_FILE_NET     1
371 #define UI_FILE_CFG     3
372 #define UI_FILE_RES     5
373 
374 
375 /* setup */
376 
377 #define UI_ACTIVATION         1
378 #define UI_INITIAL_ACTIVATION 2
379 #define UI_OUTPUT             3
380 #define UI_BIAS               4
381 #define UI_NUMBER             5
382 #define UI_NAME               6
383 #define UI_ZVALUE             7
384 #define UI_WINNER             11
385 
386 #define  UI_UNIT_BOTTOM_GENERAL 1
387 #define  UI_UNIT_TOP_GENERAL    2
388 #define  UI_LINK_GENERAL        3
389 #define  UI_LINK_VALUE          4
390 #define  UI_LINK_DIRECTION      5
391 
392 /* Triggers */
393 #define  UI_LINKS_POS        3
394 #define  UI_LINKS_NEG        4
395 #define  UI_SCALE_FACTOR     5
396 #define  UI_SCALE_LINKS      6
397 
398 
399 /* info */
400 
401 struct UnitWidgetType {
402     Widget    no;                       /* label */
403     Widget    subnetNo;                 /* label */
404     Widget    frozen;                   /* toggle */
405     Widget    name;                     /* asciiText */
406     Widget    ftype;                    /* label */
407     Widget    actFuncName, outFuncName; /* label */
408     Widget    iotype;                   /* label */
409     Widget    act, i_act, out, bias;    /* asciiText */
410 };
411 
412 struct LinkWidgetType {
413     Widget    weight;                   /* asciiText */
414     Widget    siteValue;                /* label */
415     Widget    siteName;                 /* label */
416     Widget    siteFuncName;             /* label */
417 };
418 
419 
420 
421 
422 struct InfoCallLayerStruct {
423     Widget    widget;
424     int       unitType;
425 };
426 
427 #define UI_SOURCE   0
428 #define UI_TARGET   1
429 #define UI_DEFAULT  2
430 
431 
432 
433 
434 /* graphic_ui.c */
435 
436 #define  UI_WHITE_COLOR 0
437 #define  UI_BLACK_COLOR 1
438              /* pixel unset or set */
439 
440 #define  UI_ERASE_BOTTOM  2  /* signal to erase the text at unit bottom */
441 #define  UI_DRAW          1  /* signal to draw a unit/link  */
442 #define  UI_ERASE         0  /* signal to erase a unit/link */
443 
444 #define  UI_WEIGHT_OFF      0
445 #define  UI_WEIGHT_START    1
446 #define  UI_WEIGHT_END      2
447 #define  UI_WEIGHT_MIDDLE   3
448 
449 /* size in pixels of icons (big = 64  and small = 16) and cursors = 16 */
450 #define  UI_ICON_SIZE        64
451 #define  UI_CURSOR_SIZE      16
452 
453 #define  UI_UNIT_SIZE        16
454 
455                         /* the graphic view to a unit is max 16x16 pixels */
456 
457 /****************************************************************************/
458 /* key_ui.c */
459 
460 #define  UI_INPUT              1   /* bit 1 set       */
461 #define  UI_OUT                2   /* bit 2 set       */
462 #define  UI_ALL                3   /* bit 1 and 2 set */
463 #define  UI_FORWARD_BINDING    4   /* bit 3           */
464 #define  UI_BACKWARD_BINDING   8   /* bit 4           */
465 #define  UI_TWOWAY_BINDING    12   /* bit 3 and 4 set */
466 #define  UI_ENVIRONMENT       32   /* bit 6 set       */
467 #define  UI_STRUCTURE_COPY    64   /* bit 7 set       */
468 #define  UI_SAFETY           128   /* bit 8 set       */
469 
470 
471 
472 /****************************************************************************/
473 /* selection_ui.c */
474 
475 #define UI_NO_FLAG           0
476 #define UI_SELECTED          1   /* bit 1 */
477 #define UI_ALREADY_MOVED     4   /* bit 3 */
478 #define UI_ALREADY_REVERSED  8   /* bit 4 */
479 
480 /* size of the square around a unit to indicate the selection */
481 #define UI_SELECTION_SIZE 34
482 #define UI_OCCUPIED       6
483 
484 
485 
486 
487 /****************************************************************************/
488 /* ui_pix_deleteRect() */
489 
490 #define UI_ALIGN      1
491 #define UI_NO_ALIGN   0
492 
493 /****************************************************************************/
494 /* textwin */
495 
496 #define UI_MAX_TW_BUFFER_SIZE 250
497 
498 /****************************************************************************/
499 /* help_popup */
500 
501 
502 #define    UI_FORWARD        0
503 #define    UI_BACKWARD       1
504 
505 #define    UI_FROM_BEGINNING 1
506 
507 #define    UI_HELP_MOUSE     0
508 #define    UI_HELP_KEY       1
509 #define    UI_HELP_STATUS    2
510 #define    UI_HELP_FILE      3
511 #define    UI_HELP_HELP      4
512 #define    UI_HELP_TEXT      5
513 #define    UI_HELP_SETUP     6
514 #define    UI_HELP_INFO      7
515 #define    UI_HELP_CONTROL    8
516 
517 /****************************************************************************/
518 
519 /* edit */
520 
521 #define  UI_EDIT_SITE              1
522 #define  UI_EDIT_FTYPE             2
523 
524 #define  UI_EDIT_SITE_FUNC         1
525 #define  UI_EDIT_ACT_FUNC          2
526 #define  UI_EDIT_OUT_FUNC          3
527 
528 /* key */
529 
530 #define  UI_SET_NAME          1
531 #define  UI_SET_IOTYPE        2
532 #define  UI_SET_FTYPE         3
533 #define  UI_SET_ACT           4
534 #define  UI_SET_I_ACT         5
535 #define  UI_SET_OUT           6
536 #define  UI_SET_BIAS          7
537 #define  UI_SET_ACT_FUNC      8
538 #define  UI_SET_IACT_FUNC     9
539 #define  UI_SET_OUT_FUNC      10
540 
541 #define  UI_START_STATE                  0
542 #define  UI_STATE_MODE                   1
543 #define  UI_STATE_UNITS                  2
544 #define  UI_STATE_LINKS                  3
545 #define  UI_STATE_FLAG                   4
546 #define  UI_STATE_LINKS_MAKE             5
547 #define  UI_STATE_UNITS_COPY             6
548 #define  UI_STATE_LINKS_COPY             7
549 #define  UI_STATE_LINKS_DELETE           8
550 #define  UI_STATE_UNITS_SET              9
551 #define  UI_STATE_UNITS_COPY_STRUCTURE  10
552 #define  UI_STATE_GRAPHIC               11
553 #define  UI_STATE_UNITS_SET_FUNCTION    12
554 #define  UI_STATE_UNITS_INSERT          13
555 #define  UI_STATE_GETDEST               14
556 #define  UI_STATE_SITES                 15
557 #define  UI_STATE_SITES_COPY            16
558 #define  UI_STATE_UNITS_3D              17
559 
560 /* action */
561 
562 
563 #define UI_INSERT_DEFAULT 1
564 #define UI_INSERT_TARGET  2
565 #define UI_INSERT_FTYPE   3
566 
567 
568 #define UI_ACTION_MOVE    1
569 #define UI_ACTION_COPY    2
570 
571 
572 #define UI_FREEZE    11
573 #define UI_UNFREEZE  12
574 
575 
576 /****************************************************************************/
577 /* update_whole_net_ui.c */
578 
579 #define UI_DRAW_UNITS         1
580 #define UI_DRAW_LINKS         2
581 
582 
583 
584 /****************************************************************************/
585 
586 
587 
588 /****************************************************************************/
589 /* ui_print.c */
590 
591 
592 #define UI_FORMAT_POSTSCRIPT    0
593 #define UI_FORMAT_EPSF          1
594 
595 #define UI_DEST_PRINTER         0
596 #define UI_DEST_FILE            1
597 
598 #define UI_PAPER_DINA4          0
599 #define UI_PAPER_DINA3          1
600 #define UI_PAPER_USLETTER       2
601 
602 #define UI_CLIP_ON              0
603 #define UI_CLIP_OFF             1
604 
605 #define UI_COLOR_ON             0
606 #define UI_COLOR_OFF            1
607 
608 #define UI_AUTOSCALE_ON         0
609 #define UI_AUTOSCALE_OFF        1
610 
611 #define UI_AUTOUNI_ON           0
612 #define UI_AUTOUNI_OFF          1
613 
614 #define UI_ORIENTATION_PORTAIT   0
615 #define UI_ORIENTATION_LANDSCAPE 1
616 
617 #define UI_UNITSIZE_FIXED       0
618 #define UI_UNITSIZE_VALUE       1
619 
620 #define UI_SHAPE_RECT           0
621 #define UI_SHAPE_CIRCLE         1
622 
623 #define UI_TEXT_SOLID           0
624 #define UI_TEXT_TRANS           1
625 
626 #define UI_BORDER_ON            0
627 #define UI_BORDER_OFF           1
628 
629 
630 typedef struct {
631     int dest;                           /*  printer or file                          */
632     int format;                         /*  fileformat ps or eps                     */
633     int paper;                          /*  paperformat DIN A4 ...                   */
634     int autoScale;                      /*  scale to maximum                         */
635     int clip;                           /*  clip at border                           */
636     int color;                          /*  color postscript                         */
637     int orient;                         /*  landscape or portrait                    */
638     int autoUni;                        /*  scale uniformly in x and y direction     */
639     int size;                           /*  unit has fixed size or size by a value   */
640     int shape;                          /*  unit shape is circle or rectangle        */
641     int text;                           /*  text is solid or transparent             */
642     int border;                         /*  draw border                              */
643     int resolution;                     /*  printers resolution in dpi               */
644     int displayToPrint;                 /*  number of associated display             */
645     float borderHoriz;                  /*  horizontal border in cm                  */
646     float borderVert;                   /*  vertical border in cm                    */
647     float scaleValX;                    /*  x scale if not autoscale                 */
648     float scaleValY;                    /*  y scale if not autoscale                 */
649     float unitGray;                     /*  grayvalue (0..1) to fill the units       */
650     char fileNameStr[MAX_NAME_LENGTH];  /*  default filename                         */
651     char cmdLineStr[MAX_NAME_LENGTH];   /*  default command line                     */
652 } Ui_printerValType;
653 
654 
655 /****************************************************************************/
656 
657 
658 /* Macros */
659 
660 
661 /* chars */
662 
663 #define ui_isCapLetter(arg)                ((arg >= 'A') && (arg<= 'Z'))
664 #define ui_isNonCapLetter(arg)             ((arg >= 'a') && (arg<= 'z'))
665 
666 
667 
668 /* flags */
669 
670 #define ui_utilIsSet(flag_word,flags)    ((flag_word & (flags)) == (flags))
671 #define ui_utilIsNotSet(flag_word,flags) ((flag_word & (flags)) != (flags))
672 #define ui_utilSetFlag(flag_word,flag)   (flag_word = flag_word | (flag))
673 #define ui_utilResetFlag(flag_word,flag) (flag_word = flag_word & (~ (flag)))
674 
675 
676 #define ui_utilGetIOTypeName(iotype)    (ui_list_iotypes[iotype])
677 
678 #define ui_isUnitVisibleInDisplay(displayPtr, unitNo) ((krui_getUnitSubnetNo(unitNo) == displayPtr->subNetNo) && (krui_getUnitLayerNo(unitNo) & displayPtr->layers))
679 
680 
681 #define ui_utilAreEqualPositions(pos1,pos2)     ((pos1.x == pos2.x) && (pos1.y == pos2.y))
682 #define ui_utilAreDifferentPositions(pos1,pos2) ((pos1.x != pos2.x) || (pos1.y != pos2.y))
683 
684 
685 
686 /****************************************************************************/
687 /****************************************************************************/
688 /****************************************************************************/
689 /****************************************************************************/
690 
691 
692 
693 
694 
695 
696 #endif
697 
698 
699 /* end of file */
700 /* lines: 599 */
701