-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathxcircuit.h
1648 lines (1377 loc) · 54.3 KB
/
xcircuit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*----------------------------------------------------------------------*/
/* xcircuit.h */
/* Copyright (c) 2002 Tim Edwards, Johns Hopkins University */
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* written by Tim Edwards, 8/20/93 */
/*----------------------------------------------------------------------*/
#ifndef HAVE_U_CHAR
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned long long u_long_long;
#endif
#ifdef XC_WIN32
#ifdef TCL_WRAPPER
#include "tkwin32.h"
#else
#include "xcwin32.h"
#endif
#endif
#ifdef HAVE_CAIRO
#include <cairo/cairo.h>
#endif
/*----------------------------------------------------------------------*/
/* portable definition to prevent unused variables warning */
/*----------------------------------------------------------------------*/
#define UNUSED(x) (void) x
/*----------------------------------------------------------------------*/
/* Graphics functions defined for X11 */
/*----------------------------------------------------------------------*/
#ifdef HAVE_CAIRO
#define SetForeground(display, gc, fg) xc_cairo_set_color(fg)
typedef cairo_surface_t xcImage;
#else /* !HAVE_CAIRO */
typedef XImage xcImage;
#define DrawLine XDrawLine
#define DrawLines XDrawLines
#define DrawPoint XDrawPoint
#define FillPolygon XFillPolygon
#define SetForeground(dpy, gc, fg) XSetForeground(dpy, gc, colorlist[fg].color.pixel)
#define SetBackground(dpy, gc, bg) XSetBackground(dpy, gc, colorlist[bg].color.pixel)
#define SetThinLineAttributes XSetLineAttributes
#define SetLineAttributes(a, b, c, d, e, f) \
XSetLineAttributes(a, b, ((c) >= 1.55 ? (int)(c + 0.45) : 0), d, e, f)
#define SetDashes XSetDashes
#define SetFillStyle XSetFillStyle
#define SetStipple(a,b,c) XSetStipple(a,b,STIPPLE[c])
#endif /* !HAVE_CAIRO */
#define flusharea()
/*----------------------------------------------------------------------*/
/* Redefinition of fprintf() allows redirection of output to a console */
/* in the Tcl interpreter-based version. */
/*----------------------------------------------------------------------*/
#ifdef TCL_WRAPPER
#define Fprintf tcl_printf
#define Flush tcl_stdflush
#else
#define Fprintf fprintf
#define Flush fflush
#endif
#ifdef TCL_WRAPPER
#define malloc Tcl_Alloc
/* (see definition of my_calloc in the asg subdirectory) */
/* #define calloc(a,b) Tcl_Alloc(a * b) */
#define free(a) Tcl_Free((char *)(a))
#define realloc(a,b) Tcl_Realloc((char *)(a), b)
#undef strdup
#define strdup Tcl_Strdup
extern char *Tcl_Strdup(const char *);
#endif
/*----------------------------------------------------------------------*/
/* Deal with 32/64 bit processors based on autoconf results. */
/*----------------------------------------------------------------------*/
#ifndef SIZEOF_VOID_P
#error "SIZEOF_VOID_P undefined!"
#endif
#ifndef SIZEOF_UNSIGNED_INT
#error "SIZEOF_UNSIGNED_INT undefined!"
#endif
#ifndef SIZEOF_UNSIGNED_LONG
#error "SIZEOF_UNSIGNED_LONG undefined!"
#endif
#ifndef SIZEOF_UNSIGNED_LONG_LONG
#error "SIZEOF_UNSIGNED_LONG_LONG undefined!"
#endif
#if SIZEOF_VOID_P == SIZEOF_UNSIGNED_INT
#define Number(a) (void *)((u_int) a)
typedef u_int pointertype;
#elif SIZEOF_VOID_P == SIZEOF_UNSIGNED_LONG
#define Number(a) (void *)((u_long) a)
typedef u_long pointertype;
#elif SIZEOF_VOID_P == SIZEOF_UNSIGNED_LONG_LONG
#define Number(a) (void *)((u_long_long) a)
typedef u_long_long pointertype;
#else
ERROR: Cannot compile without knowing the size of a pointer. See xcircuit.h.
#endif
/*----------------------------------------------------------------------*/
/* Basic element types */
/* */
/* These values determine how a genericptr should be cast into one of */
/* labelptr, polyptr, etc. To query the element type, use the macros */
/* ELEMENTTYPE(), IS_LABEL(), IS_POLYGON(), etc. These macros mask the */
/* bit field. Note that an element marked with REMOVE_TAG will not be */
/* recognized as any valid element, but otherwise, querying the type is */
/* transparent to other bit settings (such as NETLIST_INVALID). */
/*----------------------------------------------------------------------*/
/* Single-bit flags */
#define OBJINST 0x01
#define LABEL 0x02
#define POLYGON 0x04
#define ARC 0x08
#define SPLINE 0x10
#define PATH 0x20
#define GRAPHIC 0x40
#define ARRAY 0x80 /* reserved; unused, for now. */
#define REMOVE_TAG 0x100 /* element to be removed from netlist */
#define NETLIST_INVALID 0x200 /* this element invalidates the netlist */
#define SELECT_HIDE 0x400 /* this element cannot be selected */
#define DRAW_HIDE 0x800 /* this element is not drawn. */
/* Bit fields */
#define ALL_TYPES (OBJINST | LABEL | POLYGON | ARC | SPLINE | PATH \
| GRAPHIC | ARRAY)
#define VALID_TYPES (REMOVE_TAG | ALL_TYPES)
/*----------------------------------------------------------------------*/
/* Definition shortcuts */
/*----------------------------------------------------------------------*/
#define XtnSetArg(a,b) XtSetArg(wargs[n], a, b); n++
#define abs(a) ((a) < 0 ? -(a) : (a))
#define sign(a) ((a) <= 0 ? -1 : 1)
#ifndef min
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
/*----------------------------------------------------------------------*/
/* Lengthier define constructs */
/*----------------------------------------------------------------------*/
/* Names used for convenience throughout the source code */
#define eventmode areawin->event_mode
#define topobject areawin->topinstance->thisobject
#define hierobject areawin->hierstack->thisinst->thisobject
#define PLIST_INCR(a) \
(a)->plist = (genericptr *) realloc ((a)->plist, \
((a)->parts + 1) * sizeof(genericptr))
#define ENDPART topobject->plist + topobject->parts - 1
#define EDITPART topobject->plist + *areawin->selectlist
/* Type checks (argument "a" is type genericptr) */
#define ELEMENTTYPE(a) ((a)->type & VALID_TYPES)
#define IS_POLYGON(a) (ELEMENTTYPE(a) == POLYGON)
#define IS_LABEL(a) (ELEMENTTYPE(a) == LABEL)
#define IS_OBJINST(a) (ELEMENTTYPE(a) == OBJINST)
#define IS_ARC(a) (ELEMENTTYPE(a) == ARC)
#define IS_SPLINE(a) (ELEMENTTYPE(a) == SPLINE)
#define IS_PATH(a) (ELEMENTTYPE(a) == PATH)
#define IS_GRAPHIC(a) (ELEMENTTYPE(a) == GRAPHIC)
#define IS_ARRAY(a) (ELEMENTTYPE(a) == ARRAY)
/* Conversions from generic to specific types */
/* specifically, from type (genericptr *) to type (polyptr), etc. */
#define TOPOLY(a) (*((polyptr *)(a)))
#define TOLABEL(a) (*((labelptr *)(a)))
#define TOOBJINST(a) (*((objinstptr *)(a)))
#define TOARC(a) (*((arcptr *)(a)))
#define TOSPLINE(a) (*((splineptr *)(a)))
#define TOPATH(a) (*((pathptr *)(a)))
#define TOGRAPHIC(a) (*((graphicptr *)(a)))
#define TOGENERIC(a) (*((genericptr *)(a)))
/* conversions from a selection to a specific type */
#define SELTOGENERICPTR(a) ((areawin->hierstack == NULL) ? \
(topobject->plist + *(a)) : \
(hierobject->plist + *(a)))
#define SELTOPOLY(a) TOPOLY(SELTOGENERICPTR(a))
#define SELTOLABEL(a) TOLABEL(SELTOGENERICPTR(a))
#define SELTOOBJINST(a) TOOBJINST(SELTOGENERICPTR(a))
#define SELTOARC(a) TOARC(SELTOGENERICPTR(a))
#define SELTOSPLINE(a) TOSPLINE(SELTOGENERICPTR(a))
#define SELTOPATH(a) TOPATH(SELTOGENERICPTR(a))
#define SELTOGRAPHIC(a) TOGRAPHIC(SELTOGENERICPTR(a))
#define SELTOGENERIC(a) TOGENERIC(SELTOGENERICPTR(a))
#define SELECTTYPE(a) ((SELTOGENERIC(a))->type & ALL_TYPES)
#define SELTOCOLOR(a) ((SELTOGENERIC(a))->color)
/* creation of new elements */
#define NEW_POLY(a,b) \
PLIST_INCR(b); \
a = (polyptr *)b->plist + b->parts; \
*a = (polyptr) malloc(sizeof(polygon)); \
b->parts++; \
(*a)->type = POLYGON
#define NEW_LABEL(a,b) \
PLIST_INCR(b); \
a = (labelptr *)b->plist + b->parts; \
*a = (labelptr) malloc(sizeof(label)); \
b->parts++; \
(*a)->type = LABEL
#define NEW_OBJINST(a,b) \
PLIST_INCR(b); \
a = (objinstptr *)b->plist + b->parts; \
*a = (objinstptr) malloc(sizeof(objinst)); \
b->parts++; \
(*a)->type = OBJINST
#define NEW_ARC(a,b) \
PLIST_INCR(b); \
a = (arcptr *)b->plist + b->parts; \
*a = (arcptr) malloc(sizeof(arc)); \
b->parts++; \
(*a)->type = ARC
#define NEW_SPLINE(a,b) \
PLIST_INCR(b); \
a = (splineptr *)b->plist + b->parts; \
*a = (splineptr) malloc(sizeof(spline)); \
b->parts++; \
(*a)->type = SPLINE
#define NEW_PATH(a,b) \
PLIST_INCR(b); \
a = (pathptr *)b->plist + b->parts; \
*a = (pathptr) malloc(sizeof(path)); \
b->parts++; \
(*a)->type = PATH
#define NEW_GRAPHIC(a,b) \
PLIST_INCR(b); \
a = (graphicptr *)b->plist + b->parts; \
*a = (graphicptr) malloc(sizeof(graphic)); \
b->parts++; \
(*a)->type = GRAPHIC
/*----------------------------------------------------------------------*/
typedef struct {
float x, y;
} XfPoint;
typedef struct {
long x, y;
} XlPoint;
typedef struct {
short width, ascent, descent, base;
int maxwidth;
} TextExtents;
typedef struct {
float *padding; /* Allocated array of padding info per line */
XPoint *tbreak; /* Position in text to stop */
short dostop; /* Location (index) in text to stop */
short line; /* Stop line number, if using dostop or tbreak. */
} TextLinesInfo;
/*----------------------------------------------------------------------*/
/* Implementation-specific definitions */
/*----------------------------------------------------------------------*/
#define LIBS 5 /* initial number of library pages */
#define PAGES 10 /* default number of top-level pages */
#define SCALEFAC 1.5 /* zoom in/out scaling multiplier */
#define SUBSCALE 0.67 /* ratio of subscript size to normal script size */
#define SBARSIZE 13 /* Pixel size of the scrollbar */
#define RSTEPS 72 /* Number of points defining a circle approx. */
#define SPLINESEGS 20 /* Number of points per spline approximation */
#define DELBUFSIZE 10 /* Number of delete events to save for undeleting */
#define MINAUTOSCALE 0.75 /* Won't automatically scale closer than this */
#define MAXCHANGES 20 /* Number of changes to induce a temp file save */
#define STIPPLES 8 /* Number of predefined stipple patterns */
#define PADSPACE 10 /* Spacing of pinlabels from their origins */
#ifdef HAVE_XPM
#define TBBORDER 1 /* border around toolbar buttons */
#endif
#define TOPLEVEL 0
#define SINGLE 1
#define INTSEGS (SPLINESEGS - 2)
#define LASTSEG (SPLINESEGS - 3)
#define NOFILENAME (char *)(-1)
#define FONTHEIGHT(y) (y->ascent + y->descent + 6)
#define ROWHEIGHT FONTHEIGHT(appdata.xcfont)
#define FILECHARASCENT (appdata.filefont->ascent)
#define FILECHARHEIGHT (FILECHARASCENT + appdata.filefont->descent)
#define LISTHEIGHT 200
#define TEXTHEIGHT 28 /* Height of xcircuit vectored font at nominal size */
#define BASELINE 40 /* Height of baseline */
#define DEFAULTGRIDSPACE 32
#define DEFAULTSNAPSPACE 16
/*----------------------------------------------------------------------*/
#define RADFAC 0.0174532925199 /* (pi / 180) */
#define INVRFAC 57.295779 /* (180 / pi) */
/*----------------------------------------------------------------------*/
#define INCHSCALE 0.375 /* Scale of .25 inches to PostScript units */
#define CMSCALE 0.35433071 /* Scale of .5 cm to PostScript units */
#define IN_CM_CONVERT 28.3464567 /* 72 (in) / 2.54 (cm/in) */
/*----------------------------------------------------------------------*/
/* Event mode definitions (state of drawing area) */
/*----------------------------------------------------------------------*/
typedef enum editmode {
NORMAL_MODE = 0, /* On the drawing page, none of the situations below */
UNDO_MODE, /* In the process of an undo/redo operation */
MOVE_MODE, /* In the process of moving elements */
COPY_MODE, /* In the process of copying elements */
PAN_MODE, /* In the process of panning to follow the cursor */
SELAREA_MODE, /* Area selection box */
RESCALE_MODE, /* Interactive element rescaling box */
CATALOG_MODE, /* On a library page, library directory, or page directory */
CATTEXT_MODE, /* Editing an existing object name in the library */
FONTCAT_MODE, /* Accessing the font character page from TEXT_MODE */
EFONTCAT_MODE, /* Accessing the font character page from ETEXT_MODE */
TEXT_MODE, /* Creating a new label */
WIRE_MODE, /* Creating a new polygon (wire) */
BOX_MODE, /* Creating a new box */
ARC_MODE, /* Creating a new arc */
SPLINE_MODE, /* Creating a new spline */
ETEXT_MODE, /* Editing an exiting label */
EPOLY_MODE, /* Editing an existing polygon */
EARC_MODE, /* Editing an existing arc */
ESPLINE_MODE, /* Editing an existing spline */
EPATH_MODE, /* Editing an existing path */
EINST_MODE, /* Editing an instance (from the level above) */
ASSOC_MODE, /* Choosing an associated schematic or symbol */
CATMOVE_MODE /* Moving objects in or between libraries */
} event_mode_t;
/*----------------------------------------------------------------------*/
/* File loading modes */
/*----------------------------------------------------------------------*/
enum loadmodes {IMPORT = 1, PSBKGROUND, SCRIPT, RECOVER,
#ifdef ASG
IMPORTSPICE,
#endif
#ifdef HAVE_CAIRO
IMPORTGRAPHIC,
#endif
LOAD_MODES
};
/*----------------------------------------------------------------------*/
/* Text anchoring styles and other parameters (bitmask) */
/*----------------------------------------------------------------------*/
#define NOTLEFT 1 /* Center or right anchoring */
#define RIGHT 2 /* Right anchoring */
#define NOTBOTTOM 4 /* Middle or top anchoring */
#define TOP 8 /* Top anchoring */
#define FLIPINV 16 /* 1 if text is flip-invariant */
#define PINVISIBLE 32 /* 1 if pin visible outside of object */
#define PINNOOFFSET 64 /* 0 if pin label offset from position */
#define LATEXLABEL 128 /* 1 if label is in LaTeX syntax */
#define JUSTIFYRIGHT 256 /* Right text justification */
#define JUSTIFYBOTH 512 /* Right and left text justification */
#define TEXTCENTERED 1024 /* Centered text */
#define RLANCHORFIELD 3 /* right-left anchoring bit field */
#define TBANCHORFIELD 12 /* top-bottom anchoring bit field */
#define NONANCHORFIELD 2032 /* everything but anchoring fields */
#define NONJUSTIFFIELD 255 /* everything but justification fields */
/*----------------------------------------------------------------------*/
/* Text string part: types */
/*----------------------------------------------------------------------*/
#define TEXT_STRING 0 /* data is a text string */
#define SUBSCRIPT 1 /* start subscript; no data */
#define SUPERSCRIPT 2 /* start superscript; no data */
#define NORMALSCRIPT 3 /* stop super-/subscript; no data */
#define UNDERLINE 4 /* start underline; no data */
#define OVERLINE 5 /* start overline; no data */
#define NOLINE 6 /* stop over-/underline; no data */
#define TABSTOP 7 /* insert tab stop position */
#define TABFORWARD 8 /* insert tab stop position */
#define TABBACKWARD 9 /* insert tab stop position */
#define HALFSPACE 10 /* insert half-space; no data */
#define QTRSPACE 11 /* insert quarter space; no data */
#define RETURN 12 /* carriage-return character; no data */
#define FONT_NAME 13 /* inline font designator; data = font name */
#define FONT_SCALE 14 /* font scale change; data = scale */
#define FONT_COLOR 15 /* font color change; data = color */
#define MARGINSTOP 16 /* declare a width limit for the text */
#define KERN 17 /* set new kern values; data = kern x, y */
#define PARAM_START 18 /* bounds a parameter; data = param key */
#define PARAM_END 19 /* bounds a parameter; no data */
/* Actions translated to keystates (numbering continues from above) */
#define TEXT_RETURN 20
#define TEXT_HOME 21
#define TEXT_END 22
#define TEXT_SPLIT 23
#define TEXT_DOWN 24
#define TEXT_UP 25
#define TEXT_LEFT 26
#define TEXT_RIGHT 27
#define TEXT_DELETE 28
#define TEXT_DEL_PARAM 29
#define SPECIAL 63 /* used only when called from menu */
#define NULL_TYPE 255 /* used as a placeholder */
/*----------------------------------------------------------------------*/
/* Reset modes */
/*----------------------------------------------------------------------*/
#define SAVE 1
#define DESTROY 2
/*----------------------------------------------------------------------*/
/* Coordinate display types */
/*----------------------------------------------------------------------*/
#define DEC_INCH 0
#define FRAC_INCH 1
#define CM 2
#define INTERNAL 3
/*----------------------------------------------------------------------*/
/* Library types */
/*----------------------------------------------------------------------*/
#define FONTENCODING -1 /* Used only by libopen() */
#define FONTLIB 0
#define PAGELIB 1
#define LIBLIB 2
#define LIBRARY 3
#define USERLIB (xobjs.numlibs + LIBRARY - 1)
/*----------------------------------------------------------------------*/
/* Object instance styles */
/*----------------------------------------------------------------------*/
#define LINE_INVARIANT 1 /* Linewidth is invariant w.r.t. scale */
#define INST_NONETLIST 2 /* Instance is not netlistable */
/*----------------------------------------------------------------------*/
/* Box styles */
/*----------------------------------------------------------------------*/
#define NORMAL 0
#define UNCLOSED 1
#define DASHED 2
#define DOTTED 4
#define NOBORDER 8
#define FILLED 16
#define STIP0 32
#define STIP1 64
#define STIP2 128
#define FILLSOLID 224 /* = 32 + 64 + 128 */
#ifdef OPAQUE
#undef OPAQUE
#endif
#define OPAQUE 256
#define BBOX 512
#define SQUARECAP 1024
#define CLIPMASK 2048
#define FIXEDBBOX 4096
/*----------------------------------------------------------------------*/
/* Box edit styles */
/*----------------------------------------------------------------------*/
#define NONE 0
#define MANHATTAN 1
#define RHOMBOIDX 2
#define RHOMBOIDY 4
#define RHOMBOIDA 8
/*----------------------------------------------------------------------*/
/* Path edit styles */
/*----------------------------------------------------------------------*/
#define TANGENTS 1 /* (NORMAL = 0) */
/*----------------------------------------------------------------------*/
/* Cycle points (selected points) (flag bits, can be OR'd together) */
/*----------------------------------------------------------------------*/
#define EDITX 0x01
#define EDITY 0x02
#define LASTENTRY 0x04
#define PROCESS 0x08
#define REFERENCE 0x10
#define ANTIXY 0x20 /* For matched-tangent curves */
/*----------------------------------------------------------------------*/
/* Arc creation and edit styles */
/*----------------------------------------------------------------------*/
#define CENTER 1
#define RADIAL 2
/*----------------------------------------------------------------------*/
/* Delete/undelete draw-mode styles */
/*----------------------------------------------------------------------*/
#define ERASE 1
#define DRAW 1
/*----------------------------------------------------------------------*/
/* Schematic object types and pin label types */
/*----------------------------------------------------------------------*/
#define PRIMARY 0 /* Primary (master) schematic page */
#define SECONDARY 1 /* Secondary (slave) schematic page */
#define TRIVIAL 2 /* Symbol as non-schematic element */
#define SYMBOL 3 /* Symbol associated with a schematic */
#define FUNDAMENTAL 4 /* Standalone symbol */
#define NONETWORK 5 /* Do not netlist this object */
#define GLYPH 6 /* Symbol is a font glyph */
#define LOCAL 1
#define GLOBAL 2
#define INFO 3
#define HIERARCHY_LIMIT 256 /* Stop if recursion goes this deep */
/*----------------------------------------------------------------------*/
/* Save types. This list incorporates "ALL_PAGES", below. */
/*----------------------------------------------------------------------*/
#define CURRENT_PAGE 0 /* Current page + all associated pages */
#define NO_SUBCIRCUITS 1 /* Current page w/o subcircuit pages */
/*----------------------------------------------------------------------*/
/* Modes used when ennumerating page totals. */
/*----------------------------------------------------------------------*/
#define INDEPENDENT 0
#define DEPENDENT 1
#define TOTAL_PAGES 2
#define LINKED_PAGES 3
#define PAGE_DEPEND 4
#define ALL_PAGES 5
/*----------------------------------------------------------------------*/
/* Color scheme styles (other than NORMAL) */
/*----------------------------------------------------------------------*/
#define INVERSE 1
/*----------------------------------------------------------------------*/
/* Cursor definitions */
/*----------------------------------------------------------------------*/
#define NUM_CURSORS 11
#define ARROW appcursors[0]
#define CROSS appcursors[1]
#define SCISSORS appcursors[2]
#define COPYCURSOR appcursors[3]
#define ROTATECURSOR appcursors[4]
#define EDCURSOR appcursors[5]
#define TEXTPTR appcursors[6]
#define CIRCLE appcursors[7]
#define QUESTION appcursors[8]
#define WAITFOR appcursors[9]
#define HAND appcursors[10]
#define DEFAULTCURSOR (*areawin->defaultcursor)
/*----------------------------------------------------------------------*/
/* integer and floating-point coordinate list structures */
/*----------------------------------------------------------------------*/
typedef XPoint* pointlist;
typedef XfPoint* fpointlist;
/*----------------------------------------------------------------------*/
/* Allowed parameterization types */
/*----------------------------------------------------------------------*/
enum paramwhich {
P_NUMERIC = 0, /* uncommitted numeric parameter */
P_SUBSTRING,
P_POSITION_X,
P_POSITION_Y,
P_STYLE,
P_ANCHOR,
P_ANGLE1,
P_ANGLE2,
P_RADIUS,
P_MINOR_AXIS,
P_ROTATION,
P_SCALE,
P_LINEWIDTH,
P_COLOR,
P_EXPRESSION,
P_POSITION, /* mode only, not a real parameter */
NUM_PARAM_TYPES
};
/*----------------------------------------------------------------------*/
/* Labels are constructed of strings and executables */
/*----------------------------------------------------------------------*/
typedef struct _stringpart *stringptr;
typedef struct _stringpart {
stringptr nextpart;
u_char type;
union {
u_char *string;
int color;
int font;
int width;
int flags;
float scale;
short kern[2];
} data;
} stringpart;
/*----------------------------------------------------------------------*/
/* structures of all main elements which can be displayed & manipulated */
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* Object & object instance parameter structure */
/* (Add types as necessary) */
/*----------------------------------------------------------------------*/
enum paramtypes {XC_INT = 0, XC_FLOAT, XC_STRING, XC_EXPR};
/* Object parameters: general key:value parameter model */
/* Note that this really should be a hash table, not a linked list. . . */
typedef struct _oparam *oparamptr;
typedef struct _oparam {
char * key; /* name of the parameter */
u_char type; /* type is from paramtypes list above */
u_char which; /* what the parameter represents (P_*) */
union {
stringpart *string; /* xcircuit label type */
char *expr; /* TCL (string) expression */
int ivalue; /* also covers type short int by typecasting */
float fvalue;
} parameter; /* default or substitution value */
oparamptr next; /* next parameter in linked list */
} oparam;
/* Element parameters: reference back to the object's parameters */
/* These parameters are forward-substituted when descending into */
/* an object instance. */
/* Note that this really should be a hash table, not a linked list. . . */
typedef struct _eparam *eparamptr;
typedef struct _eparam {
char * key; /* name of the parameter */
u_char flags; /* namely, bit declaring an indirect parameter */
union {
int pointno; /* point number in point array, for polygons */
short pathpt[2]; /* element number and point number, for paths */
char *refkey; /* parameter reference key, for instances */
} pdata;
eparamptr next; /* next parameter in linked list */
} eparam;
#define P_INDIRECT 0x01 /* indirect parameter indicator */
/*----------------------------------------------------------------------*/
/* Generic element type is a superset of all elements. */
/*----------------------------------------------------------------------*/
typedef struct {
u_short type; /* type is LABEL, POLYGON, etc., from below */
int color;
eparamptr passed;
} generic, *genericptr; /* (convenience function for retypecasting) */
/*----------------------------------------------------------------------*/
/* selection-mechanism structures */
/*----------------------------------------------------------------------*/
typedef struct {
short number;
genericptr *element;
short *idx;
} uselection;
typedef struct {
short number;
u_char flags;
} pointselect;
/*----------------------------------------------------------------------*/
/* Bounding box */
/*----------------------------------------------------------------------*/
typedef struct {
XPoint lowerleft;
Dimension width, height;
} BBox;
/*----------------------------------------------------------------------*/
/* Object instance type */
/*----------------------------------------------------------------------*/
typedef struct _xcobject *objectptr;
typedef struct {
u_short type;
int color;
eparamptr passed; /* numerical parameters passed from above */
u_short style;
XPoint position;
float rotation;
float scale;
objectptr thisobject;
oparamptr params; /* parameter substitutions for this instance */
BBox bbox; /* per-instance bounding box information */
BBox *schembbox; /* Extra bounding box for pin labels */
} objinst, *objinstptr;
/* Linked-list for objects */
typedef struct _objlist *objlistptr;
typedef struct _objlist {
int libno; /* library in which object appears */
objectptr thisobject; /* pointer to the object */
objlistptr next;
} objlist;
/* Linked-list for object instances */
typedef struct _pushlist *pushlistptr;
typedef struct _pushlist {
objinstptr thisinst;
char *clientdata; /* general-purpose record */
pushlistptr next;
} pushlist;
/* Same as above, but for the list of instances in a library, so it */
/* needs an additional record showing whether or not the instance is */
/* "virtual" (not the primary library instance of the object) */
typedef struct _liblist *liblistptr;
typedef struct _liblist {
objinstptr thisinst;
u_char virtual;
liblistptr next;
} liblist;
/*----------------------------------------------------------------------*/
/* Generalized graphic object (Tcl/Tk only) */
/*----------------------------------------------------------------------*/
typedef struct {
u_short type;
int color; /* foreground, for bitmaps only */
eparamptr passed; /* numerical parameters passed from above */
XPoint position;
float rotation;
float scale;
xcImage *source; /* source data */
#ifndef HAVE_CAIRO
xcImage *target; /* target (scaled) data */
float trot; /* target rotation */
float tscale; /* target scale (0 = uninitialized) */
Pixmap clipmask; /* clipmask for non-manhattan rotations */
Boolean valid; /* does target need to be regenerated? */
#endif /* !HAVE_CAIRO */
} graphic, *graphicptr;
/*----------------------------------------------------------------------*/
/* Label */
/*----------------------------------------------------------------------*/
typedef struct {
u_short type;
int color;
eparamptr passed; /* numerical parameters passed from above */
pointselect *cycle; /* Edit position(s), or NULL */
XPoint position;
float rotation;
float scale;
u_short anchor;
u_char pin;
stringpart *string;
} label, *labelptr;
/*----------------------------------------------------------------------*/
/* Polygon */
/*----------------------------------------------------------------------*/
typedef struct {
u_short type;
int color;
eparamptr passed; /* numerical parameters passed from above */
u_short style;
float width;
pointselect *cycle; /* Edit position(s), or NULL */
short number;
pointlist points;
} polygon, *polyptr;
/*----------------------------------------------------------------------*/
/* Bezier Curve */
/*----------------------------------------------------------------------*/
typedef struct {
u_short type;
int color;
eparamptr passed; /* numerical parameters passed from above */
u_short style;
float width;
pointselect *cycle; /* Edit position(s), or NULL */
XPoint ctrl[4];
/* the following are for rendering only */
XfPoint points[INTSEGS];
} spline, *splineptr;
/*----------------------------------------------------------------------*/
/* Arc */
/*----------------------------------------------------------------------*/
typedef struct {
u_short type;
int color;
eparamptr passed; /* numerical parameters passed from above */
u_short style;
float width;
pointselect *cycle; /* Edit position(s), or NULL */
short radius; /* x-axis radius */
short yaxis; /* y-axis radius */
float angle1; /* endpoint angles, in degrees */
float angle2;
XPoint position;
/* the following are for rendering only */
short number;
XfPoint points[RSTEPS + 1];
} arc, *arcptr;
/*----------------------------------------------------------------------*/
/* Path */
/*----------------------------------------------------------------------*/
typedef struct {
u_short type;
int color;
eparamptr passed; /* numerical parameters passed from above */
u_short style;
float width;
short parts;
genericptr *plist; /* to be retypecast to polygon, arc, or spline */
} path, *pathptr;
/*----------------------------------------------------------------------*/
/* selection from top-level object */
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* Undo mechanism definitions */
/*----------------------------------------------------------------------*/
enum UNDO_MODES {UNDO_DONE = 0, UNDO_MORE, MODE_CONNECT, MODE_RECURSE_WIDE,
MODE_RECURSE_NARROW};
typedef struct _selection *selectionptr;
typedef struct _selection {
int selects;
short *selectlist;
objinstptr thisinst;
selectionptr next;
} selection;
#define select_element(a) recurse_select_element(a, UNDO_MORE)
#define select_add_element(a) recurse_select_element(a, UNDO_DONE)
#define easydraw(a, b) geneasydraw(a, b, topobject, areawin->topinstance)
/*----------------------------------------------------------------------*/
/* Netlist structures for schematic capture */
/*----------------------------------------------------------------------*/
/* Structure to hold net and subnet IDs for a bus */
typedef struct {
int netid;
int subnetid;
} buslist;
/* Structure mimicking the top part of a Polylist or Labellist */
/* when we just want the netlist information and don't care */
/* which one we're looking at. */
typedef struct {
union {
int id;
buslist *list;
} net;
int subnets;
} Genericlist;
/* Linked polygon list */
typedef struct _Polylist *PolylistPtr;
typedef struct _Polylist
{
union {
int id; /* A single net ID, if subnets == 0 */
buslist *list; /* List of net and subnet IDs for a bus */
} net;
int subnets; /* Number of subnets; 0 if no subnets */
objectptr cschem; /* Schematic containing the polygon */
polyptr poly;
PolylistPtr next; /* Next polygon in the linked list */
} Polylist;
/* Linked label list */
typedef struct _Labellist *LabellistPtr;
typedef struct _Labellist
{
union {
int id; /* A single net ID, if subnets == 0 */
buslist *list; /* List of net and subnet IDs for a bus */
} net;
int subnets; /* Number of subnets; 0 if no subnets */
objectptr cschem; /* Schematic containing the label */
objinstptr cinst; /* Specific label instance, if applicable */
labelptr label;
LabellistPtr next;
} Labellist;
/* List of object's networks by (flattened) name */
typedef struct _Netname *NetnamePtr;
typedef struct _Netname
{
int netid;
stringpart *localpin;
NetnamePtr next;
} Netname;
/* List of object's I/O ports */
typedef struct _Portlist *PortlistPtr;
typedef struct _Portlist
{
int portid;
int netid;
PortlistPtr next;
} Portlist;
/* List of calls to instances of objects */
/* or subcircuit objects. */
typedef struct _Calllist *CalllistPtr;