Modified the UGetCursor() routine to return a valid response if the
[xcircuit.git] / asg / asg.c
blob8f9c49f8ff67d501e06c074ab0ab68afa14c924a
1 /*----------------------------------------------------------------------*/
2 /* asg.c --- Glue code between xcircuit and SPAR */
3 /*----------------------------------------------------------------------*/
5 #ifdef ASG
7 #include <stdio.h>
8 #include "externs.h" /* Local ASG definitions */
10 extern void spar_destructor();
11 extern void spar_constructor();
13 /*--------------------------------------------------------------------- */
15 int xc_print_sym(XCWindowData *areastruct, char *sym, char*name,
16 int x, int y, int x_dis, int y_dis, int rot)
18 asg_make_instance(areastruct, sym, x, y, x_dis, y_dis);
19 asg_make_label(areastruct, NORMAL, x, y, name);
21 return(1);
25 /*----------------------------------------------------------------------*/
26 /* This function is used to draw an ASG module as an xcircuit object */
27 /* instance. */
28 /*----------------------------------------------------------------------*/
30 int asg_make_instance(XCWindowData *clientData, char *keyword, int x,
31 int y, int x_size, int y_size)
33 objectptr pobj;
34 objinstptr pinst, *newinst;
35 XPoint newpos;
37 // Set Position for newly created object
38 newpos.x = (short)(x * 15.0);
39 newpos.y = (short)(y * 15.0);
41 // Create Space for Object Instances...
42 NEW_OBJINST(newinst, clientData->topinstance->thisobject);
44 // Find Object instance in the library...
45 pobj = NameToObject(keyword, &pinst, FALSE);
47 // If object specified by keyword, it must exist in a loaded library.
48 // (need to develop this code)
50 if (pobj == NULL) {
51 /* sprintf(_STR, "Cannot Find %s in any existing library.", keyword); */
52 /* Wprintf(_STR); */
53 return -1;
56 // Copy values from the library instance into the new instance
57 instcopy(*newinst, pinst);
58 (*newinst)->scale = 1.0;
60 // Rotated objects should be using the rotated instances.
61 // Instances at rotation = 0 in the asg_spice.lps library should
62 // match the orientations of devices in the original SPAR
63 // definitions, or vice versa.
65 if (!strcmp(keyword, "arrow")) (*newinst)->rotation += 90;
66 else if (!strcmp(keyword, "RESTR")) (*newinst)->rotation += 270;
67 else if (!strcmp(keyword, "INDR")) (*newinst)->rotation += 270;
68 else if (!strcmp(keyword, "CAPC")) (*newinst)->rotation += 270;
69 else if (!strcmp(keyword, "IAMP")) (*newinst)->rotation += 270;
71 // Eventually all drawing parameters need to be overridden.
72 // Assign just position for now
74 (*newinst)->position = newpos;
75 return 0;
78 /*----------------------------------------------------------------------*/
79 /* This function draws the path connecting the object on the screen */
80 /*----------------------------------------------------------------------*/
82 void asg_make_polygon(XCWindowData *clientData, int npoints, int x[], int y[])
84 polyptr *newpoly;
85 int j;
87 NEW_POLY(newpoly, clientData->topinstance->thisobject);
88 polydefaults(*newpoly, npoints, 0, 0);
89 (*newpoly)->style = UNCLOSED;
90 for (j = 0; j < npoints; j++) {
91 (*newpoly)->points[j].x = x[j];
92 (*newpoly)->points[j].y = y[j];
94 /* singlebbox((genericptr *)newpoly); */
95 incr_changes(clientData->topinstance->thisobject);
98 /*----------------------------------------------------------------------*/
99 /* This function helps print the label of the object on the screen */
100 /*----------------------------------------------------------------------*/
102 void asg_make_label(XCWindowData *clientData, u_char dopin, int x, int y, char *data)
104 labelptr *newlab;
105 stringpart *strptr;
107 NEW_LABEL(newlab, clientData->topinstance->thisobject);
108 labeldefaults(*newlab, dopin, x - 20, y - 30);
110 // (*newlab)->justify = PINVISIBLE;
111 strptr = makesegment(&((*newlab)->string), NULL);
112 strptr->type = TEXT_STRING;
113 strptr->data.string = data;
114 singlebbox((genericptr *)newlab);
115 incr_changes(clientData->topinstance->thisobject);
118 /*----------------------------------------------------------------------*/
119 /* Free memory for SPAR structures */
120 /*----------------------------------------------------------------------*/
122 void spar_destructor()
124 free_list(modules);
125 free_list(nets);
128 /*----------------------------------------------------------------------*/
129 /* Generate SPAR structures */
130 /*----------------------------------------------------------------------*/
132 void spar_constructor()
134 newnode("$0");
135 newnode("$1");
136 newnode("_DUMMY_SIGNAL_");
139 #endif /* ASG */