~ubuntu-branches/ubuntu/precise/xcircuit/precise

« back to all changes in this revision

Viewing changes to formats.c

  • Committer: Bazaar Package Importer
  • Author(s): David Z Maze
  • Date: 2003-08-24 09:08:10 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20030824090810-5d6ptk9msqsbsnqv
Tags: 3.1.19-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
#include <stdio.h>
7
7
#include <stdlib.h>
8
8
#include <string.h>
9
 
#if defined(DARWIN)
10
 
#include <sys/malloc.h>
11
 
#else
12
 
#include <malloc.h>
13
 
#endif
14
9
#include <ctype.h>
15
10
#include <X11/Intrinsic.h>
16
11
#include <X11/StringDefs.h>
19
14
/* Local includes                                                         */
20
15
/*------------------------------------------------------------------------*/
21
16
 
 
17
#ifdef TCL_WRAPPER 
 
18
#include <tk.h>
 
19
#endif
 
20
 
22
21
#include "colordefs.h"
23
22
#include "xcircuit.h"
24
23
 
130
129
   /* Done with header. . . okay to clear current page now unless importing */
131
130
 
132
131
   if (mode == 0) {
133
 
      reset(objectdata, NORMAL);
134
 
      topreset(); 
 
132
      reset(topobject, NORMAL);
 
133
      pagereset(areastruct.page); 
135
134
   }
136
135
 
137
136
   /* Set up filename and object (page) name */
143
142
   /* If the filename has a path component, use only the root */
144
143
 
145
144
   if ((pdchar = strrchr(inname, '/')) != NULL)
146
 
      sprintf(objectdata->name, "%s", pdchar + 1);
 
145
      sprintf(topobject->name, "%s", pdchar + 1);
147
146
   else
148
 
      sprintf(objectdata->name, "%s", inname);
 
147
      sprintf(topobject->name, "%s", inname);
149
148
 
150
149
   renamepage(areastruct.page);
151
 
   printname(objectdata);
 
150
   printname(topobject);
152
151
 
153
152
   /* Read objects */
154
153
 
238
237
               if (tstrp != NULL) {     /* could be a blank line */
239
238
                  stringpart *strptr;
240
239
 
241
 
                  NEW_LABEL(newlabel, objectdata);
242
 
                  objectdata->parts++;
 
240
                  NEW_LABEL(newlabel, topobject);
 
241
                  topobject->parts++;
243
242
 
244
243
                  labeldefaults(*newlabel, False, xmat(pvalx), ymat(pvaly));
245
244
                  (*newlabel)->justify = TOP | NOTBOTTOM;
272
271
 
273
272
               /* Allocate wire */
274
273
 
275
 
               NEW_POLY(newwire, objectdata);
276
 
               objectdata->parts++;
 
274
               NEW_POLY(newwire, topobject);
 
275
               topobject->parts++;
277
276
 
278
277
               sscanf(lineptr, "%hd %hd %hd %hd", &pvalx, &pvaly, &pvalx2, &pvaly2);
279
278
               (*newwire)->number = 2;
324
323
                  for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
325
324
               } while (*lineptr == '\n');
326
325
 
327
 
               NEW_POLY(newpoly, objectdata);
328
 
               objectdata->parts++;
 
326
               NEW_POLY(newpoly, topobject);
 
327
               topobject->parts++;
329
328
 
330
329
               (*newpoly)->style = DASHED;
331
330
               (*newpoly)->color = DEFAULTCOLOR;
387
386
 
388
387
               if (j < xobjs.numlibs || k < xobjs.userlibs[xobjs.numlibs - 1].number) {
389
388
 
390
 
                  NEW_OBJINST(newinst, objectdata);
391
 
                  objectdata->parts++;
 
389
                  NEW_OBJINST(newinst, topobject);
 
390
                  topobject->parts++;
392
391
 
393
392
                  sscanf(lineptr, "%hd %hd %hd %*d %*d %*d %d", &pvalx, &pvaly,
394
393
                        &pvalx2, &hval); 
408
407
                  if (pvalx2 >= 4) (*newinst)->rotation = -(((pvalx2 - 4) * 90) + 1);
409
408
                  else (*newinst)->rotation = (pvalx2 * 90) + 1;
410
409
                  (*newinst)->thisobject = *libobj;
 
410
                  (*newinst)->bbox.lowerleft.x = (*libobj)->bbox.lowerleft.x;
 
411
                  (*newinst)->bbox.lowerleft.y = (*libobj)->bbox.lowerleft.y;
 
412
                  (*newinst)->bbox.width = (*libobj)->bbox.width;
 
413
                  (*newinst)->bbox.height = (*libobj)->bbox.height;
411
414
 
412
415
                  /* Add label to "TO" and "FROM" */
413
416
 
422
425
                        if (signets[k] == nval) {
423
426
                           stringpart *strptr;
424
427
 
425
 
                           NEW_LABEL(newlabel, objectdata);
426
 
                           objectdata->parts++;
 
428
                           NEW_LABEL(newlabel, topobject);
 
429
                           topobject->parts++;
427
430
                           /* reconnect newinst if displaced by realloc() */
428
 
                           newinst = (objinstptr *)(objectdata->plist
429
 
                                + objectdata->parts - 2);
 
431
                           newinst = (objinstptr *)(topobject->plist
 
432
                                + topobject->parts - 2);
430
433
 
431
434
                           labeldefaults(*newlabel, False, (*newinst)->position.x,
432
435
                                (*newinst)->position.y);
434
437
#ifdef SCHEMA
435
438
                           if (areastruct.schemon){
436
439
                              (*newlabel)->pin = LOCAL;
437
 
                              (*newlabel)->color = SNAPCOLOR;
 
440
                              (*newlabel)->color = LOCALPINCOLOR;
438
441
                           }
439
442
#endif
440
443
                           if (!strcmp(tmpstring, "TO"))
512
515
 
513
516
   /* check for unattached labels and delete them */
514
517
 
515
 
   for (iolabel = objectdata->plist; iolabel < objectdata->plist +
516
 
           objectdata->parts; iolabel++)
 
518
   for (iolabel = topobject->plist; iolabel < topobject->plist +
 
519
           topobject->parts; iolabel++)
517
520
      if ((*iolabel)->type == LABEL) {
518
521
         if (TOLABEL(iolabel)->rotation == 500) {
519
522
            genericptr *tmplabel;
520
523
 
521
524
            free(TOLABEL(iolabel)->string);
522
525
            free(*iolabel);
523
 
            for (tmplabel = iolabel + 1; tmplabel < objectdata->plist +
524
 
                objectdata->parts; tmplabel++) *(tmplabel - 1) = *tmplabel;
525
 
            objectdata->parts--;
 
526
            for (tmplabel = iolabel + 1; tmplabel < topobject->plist +
 
527
                topobject->parts; tmplabel++) *(tmplabel - 1) = *tmplabel;
 
528
            topobject->parts--;
526
529
            iolabel--;
527
530
         }
528
531
      }
529
532
 
530
 
   calcbbox(objectdata);
531
 
   centerview(objectdata);
 
533
   calcbbox(areastruct.topinstance);
 
534
   centerview(areastruct.topinstance);
532
535
 
533
536
   for (i = 0; i < sigs; i++) free(signals[i]);
534
537
   free(signals);
578
581
   /* Keep same filename---overwriting file is end-user's own risk */
579
582
 
580
583
   if ((pdchar = strstr(_STR, ".ps")) != NULL) *pdchar = '\0';
581
 
   sprintf(objectdata->name, "%s", _STR);
 
584
   sprintf(topobject->name, "%s", _STR);
582
585
   sprintf(_STR, "Loaded file: %s", inname);
583
586
   Wprintf(_STR);
584
587
   renamepage(areastruct.page);
585
 
   printname(objectdata);
 
588
   printname(topobject);
586
589
 
587
590
   /* Create input string buffer */
588
591