/* LAYDUMP (LAY) -- Layout ASCII Dump Import/Export */ /* LAYDUMP (LAY) -- Layout-ASCII-Dump Ein-/Ausgabe */ /* // Copyright (c) 1993-2012 Oliver Bartels F+E, Muenchen // Author: Manfred Baumeister // Changes History: // rl (120427) RELEASED FOR BAE V7.8. // rl (101019) RELEASED FOR BAE V7.6. // rl (100910) ENHANCEMENT: // Added power layer definition import. // rl (100120) BUGFIX: // Fixed problem with non default drill symbol library. // rl (091027) RELEASED FOR BAE V7.4. // rl (091020) ENHANCEMENT: // Added drill symbol pad placement option. // rl (081014) RELEASED FOR BAE V7.2. // rl (080804) ENHANCEMENT: // Added import function. // rl (071029) RELEASED FOR BAE V7.0. // rl (070822) ENHANCEMENT: // Added mirror drill class support. // rl (070216) ENHANCEMENT: // Suppressed output of undefined documentary layers in header. // rl (060829) RELEASED FOR BAE V6.8. // rl (050906) RELEASED FOR BAE V6.6. // rl (050726) ENHANCEMENT: // Added name/attribute text move positions to output. // rl (040811) RELEASED FOR BAE V6.4. // rl (030915) RELEASED FOR BAE V6.2. // rl (030915) BUGFIX: // Fixed problem with double output of elements on low // hierarchy levels. // rl (021209) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (011207) ENHANCEMENT: // Added output of rule attachments. // rl (010625) RELEASED FOR BAE V5.0. // rl (010405) ENHANCEMENT: // Added optional output to window and optional restriction to // top level elements. // rl (010320) ENHANCEMENT: // Added optional parameter settings from bae.ini file. // rl (000508) RELEASED FOR BAE V4.6. // rl (990803) RELEASED FOR BAE V4.4. // rl (980910) RELEASED FOR BAE V4.2. // mb (980711) ENHANCEMENT: // Dynamic multi-language support introduced. // rl (970929) RELEASED FOR BAE V4.0. // mb (970325) CHANGE: // Output format considerably changed. // mb (960919) RELEASED FOR BAE V3.4. // mb (951012) IMPROVEMENT: // Performing BAE_Demo_check(2) before starting output. // mb (95) RELEASED FOR BAE V3.2. // mb (941214) IMPROVEMENT: // Introduced lay_nrefsearch() call to partplaced() function // (in order to replace slow L_NREF loop scan!). // mb (941211) CHANGE: // Featuring layername() call from lay.ulh for // layer name designation. // mb (94) RELEASED FOR BAE V3.0. // mb (94) IMPROVEMENT: // Introduced option for output length units selection. // mb (93) RELEASED FOR BAE V2.6. // mb (93) ORIGINAL CODING. // // DESCRIPTION // // The laydump User Language program provides functions for exporting // and importing layout element data in a generic format ASCII file // suitable for processing with BNF parsers. // The output processes the currently loaded layout element with selectable // output length units. The output is directed to an ASCII file. */ // Includes #include "pop.ulh" // User Language popup utilities #include "lay.ulh" // User Language layout utilities // Enforce LAY caller type #pragma ULCALLERLAY // Disable undo state request #pragma ULCALLERNOUNDO // INI file parameter name definitions #define PAR_DUMPFEXT "DUMPFEXT_LAY" // Output file name extension #define PAR_DUMPPOLY "DUMPPOLY_LAY" // Polygon point list output style #define PAR_DMPLAYASSL "DMPLAYASSL_LAY"// Default layer assignment list #define PAR_DRLSYMLIB "DRLSYMLIB_LAY" // Drill symbol pad library #define PAR_DRLSYMNPAT "DRLSYMNPAT_LAY"// Drill symbol pad name pattern #define PAR_DRLSYMLAY "DRLSYMLAY_LAY" // Drill symbol pad layer // Messages string UPRABORT = M_UPRABORT(); string REPDDONE = M("Layout-Libary-Dump ausgegeben auf Datei '%s'.", "Layout Libary Dump written to File '%s'."); string REPDUMP = M("Dump %s '%s'...","Dump %s '%s'..."); string REPPARSE = M("Lesen BAE-ASCII-Daten '%s'...", "Reading BAE ASCII data '%s'..."); string REPDONE = M("Es wurden keine Fehler festgestellt.", "Operation completed."); string UPRIOFCT = M("Ein-/Ausgabefunktion selektieren!", "Select Import/Export Function!"); string UPRFCTDUMP = M("&BAE/ASCII-Ausgabe","&BAE/ASCII Output"); string UPRFCTIMP = M("BAE/ASCII-Import","&BAE/ASCII Input"); string UPRDMPFILE = M("BAE-ASCII-Eingabedatei ? ", "BAE-ASCII Data File ? "); string UPRTDIR = M("BAE-ASCII-Eingabeverzeichnis ? ", "BAE-ASCII Data Directory ? "); string UPRPROCMODE = M("Bearbeitungsmodus selektieren!", "Select Process Mode!"); string UPRPROCALL = M("&Alles","&All"); string UPRPROCLIB = M("Nur &Bibliothek","&Library Only"); string UPRPROCSALL = M("%&Einzeldatei alles","%&Single Project All"); string UPRPROCSLIB = M("Einzel&datei nur Bibliothek", "S&ingle Project Library Only"); string UPRPROCPROJ = M("&Komplettprojekt","&Complete Project"); string UPRLUNITS = M("Ausgabe-Laengeneinheiten selektieren!", "Select Output Length Units!"); string UNITSINCH = M("&Zoll [\"]","I&nch [\"]"); string UNITSMIL = M("Mi&l [1/1000\"]","Mi&l [1/1000\"]"); string UNITSMM = M("M&illimeter [mm]","M&illimetre [mm]"); string UNITSM = M("&Meter [m]","&Metre [m]"); string UNITSUM = M("Mi&krometer [um]","Mi&crometre [um]"); string UPRELEM = M("Ausgabemodus selektieren!", "Select Output Mode!"); string UPRELEM1 = M("&Komplett in Datei","&All to file"); string UPRELEM2 = M("Nur &Plan in Datei","Only &plan to file"); string UPRELEM3 = M("Komplett in &Fenster","All to &screen"); string UPRELEM4 = M("Nur Plan in F&enster","Only plan to s&creen"); string ERRLOAD = M("Fehler beim Laden des Elementes '%s'!", "Error loading element '%s'!"); string ERRPLCPOLY = M("[%s/%d]: Fehler bei der Polygonerzeugung!\n", "[%s/%d]: Error generating polygon!\n"); string ERRPLCPATH = M("[%s/%d]: Fehler bei der Leiterbahnerzeugung!\n", "[%s/%d]: Error generating trace!\n"); string ERRPLCVIA = M("[%s/%d]: Fehler bei der Viaplatzierung '%s'!\n", "[%s/%d]: Error placing via '%s'!\n"); string ERRPLCPAD = M("[%s/%d]: Fehler bei der Padplatzierung '%s'!\n", "[%s/%d]: Error placing pad '%s'!\n"); string ERRPLCTEXT = M("[%s/%d]: Fehler bei der Texterzeugung '%s'!\n", "[%s/%d]: Error generating text '%s'!\n"); string ERRPLCPART = M("[%s/%d]: Fehler bei der Bauteilplatzierung '%s'/'%s'!\n", "[%s/%d]: Error placing part '%s'/'%s'!\n"); string ERRPLCPIN = M("[%s/%d]: Fehler bei der Pinplatzierung '%s'/'%s'!\n", "[%s/%d]: Error placing pin '%s'/'%s'!\n"); string ITMUNDEF = M("*** UNDEFINIERT ***","*** UNDEFINED ***"); // Items #define LUNITM 0 // Length unit metre code #define LUNITIN 1 // Length unit inch code #define LUNITMM 2 // Length unit millimetre code #define LUNITMIL 3 // Length unit mil code #define LUNITUM 4 // Length unit micrometre code #define AUNITRAD 0 // Angle unit radians code #define AUNITDEG 1 // Angle unit degree code #define AUNITGRA 3 // Angle unit grad code int LUNITS /* Length units code */; string ITMLUNITS /* Length units */; #define AUNITS 1 // Angle units code #define ITMAUNITS "DEGREE" #define ITMLAYOUT "LAYOUT" #define ITMPART "PART" #define ITMSTACK "PADSTACK" #define ITMPAD "PAD" #define ITMMIRRON "MIRROR ON" #define ITMMIRROFF "MIRROR OFF" // Format strings #define FMTHEADER "LAYOUT DUMP '%s' {\n" #define FMTLUNITS "\tLENGTH UNITS = %d ; /* %s */\n" #define FMTAUNITS "\tANGLE UNITS = %d ; /* %s */\n" #define FMTDOCLAY "\tDOCUMENTARY LAYER = ( %2d , '%s' , %s , %s ) ;\n" #define FMTELEMHD "\n%s ( '%s' ) {\n" #define FMTCOMM "\tCOMMENT = '%s' ;\n" #define FMTNX "\tNX = %12.*f ;\n" #define FMTNY "\tNY = %12.*f ;\n" #define FMTLX "\tLX = %12.*f ;\n" #define FMTUX "\tUX = %12.*f ;\n" #define FMTLY "\tLY = %12.*f ;\n" #define FMTUY "\tUY = %12.*f ;\n" #define FMTPWIDTH "\tWIDTH = %12.*f ;\n" #define FMTPHEIGHT "\tHEIGHT = %12.*f ;\n" #define FMTTOPLAYER "\tTOP LAYER = %d ;\t/* %s */\n" #define FMTBTWLAYERS "\tINNER LAYERS = %d ;\n" #define FMTVIADEF "\tVIA MACRO = \"%s\" ;\n" #define FMTPOWLAY "\tPOWERLAYER {\n" #define FMTNREF "\t%s {\n" #define FMTUREF "\t%s {\n" #define FMTDRILL "\tDRILL {\n" #define FMTTEXT "\tTEXT {\n" #define FMTPATH "\tPATH {\n" #define FMTPOLY "\tPOLYGON {\n" #define FMTFIXED "\t\tFIXED\n" #define FMTGLUED "\t\tGLUED\n" #define FMTNAME "\t\tNAME = \"%s\" ;\n" #define FMTMACRO "\t\tMACRO = \"%s\" ;\n" #define FMTTEXTSTR "\t\tSTRING = \"%s\" ;\n" #define FMTPOLYTYPE "\t\tTYPE = %d ;\t/* %s */\n" #define FMTCLASS "\t\tCLASS = %d ;\t/* %s */\n" #define FMTMODE "\t\tMODE = %d ;\t/* %s */\n" #define FMTSIZE "\t\tSIZE = %12.*f ;\n" #define FMTWIDTH "\t\tWIDTH = %12.*f ;\n" #define FMTDIA "\t\tDIAMETER = %12.*f ;\n" #define FMTLAYER "\t\tLAYER = %d ;\t/* %s */\n" #define FMTTREE "\t\tTREE = %d ;\n" #define FMTNET "\t\tNET = \"%s\" ;\n" #define FMTPOSX "\t\tX = %12.*f ;\n" #define FMTPOSY "\t\tY = %12.*f ;\n" #define FMTANGLE "\t\tANGLE = %12.6f ;\n" #define FMTMIRROR "\t\tMIRROR = %d ;\t/* %s */\n" #define FMTPOINTN "\t\tPOINTN = %d :\n" #define FMTPOINTSHD "\t\tPOINTS = {\n" #define FMTPOINT "\t\t\t( %12.*f , %12.*f , %d ) ;\t/* %s */\n" #define FMTPOINTSFT "\t\t\t}\n" #define FMTOPOINTCNT "\t\tPOINTN = %d :\n" #define FMTOPOINT "\t\tPOINT = ( %12.*f , %12.*f , %d ) ;\t/* %s */\n" #define FMTATTFT "\t\t}\n" #define FMTELEMFT "\t}\n" #define FMTNAMEMOVE "\t\tNAMEMOVE {\n" #define FMTATTRMOVE "\t\tATTRMOVE \"%s\" {\n" #define FMTMLAYER "\t\t\tLAYER = %d ;\t/* %s */\n" #define FMTMSIZE "\t\t\tSIZE = %12.*f ;\n" #define FMTMPOSX "\t\t\tXOFFSET = %12.*f ;\n" #define FMTMPOSY "\t\t\tYOFFSET = %12.*f ;\n" #define FMTMANGLE "\t\t\tANGLEOFFSET = %12.6f ;\n" #define FMTMMIRROR "\t\t\tMIRROROFFSET = %d ;\t/* %s */\n" #define FMTMLINEON "\t\t\tLINEDISP = ON ;\n" #define FMTMLINEOFF "\t\t\tLINEDISP = OFF ;\n" #define FMTERULES "\tPLAN RULES {\n" #define FMTTRULE "\t\t\"%s\"\n" #define FMTRULES "\t\tRULES {\n" #define FMTRULE "\t\t\t\"%s\"\n" #define FMTRULESEND "\t\t\t}\n" #define FMTLISTEND "\t\t}\n" int PREC /* Double output precision */; int POLYSTYLE = bae_iniintval(PAR_DUMPPOLY,0) /* Polygon point list output style */; // Special items #define DOCLAYTXTP "PHYSICAL" // Doc layer text physical #define DOCLAYTXTL "LOGICAL" // Doc layer text logical #define DOCLAYTXTN "NOROTATE" // Doc layer text norotate #define POLYTYP1 "PASSIVE COPPER AREA" // Polygon type passive copper #define POLYTYP2 "KEEP OUT AREA" // Polygon type keep out area #define POLYTYP3 "BOARD OUTLINE" // Polygon type board outline #define POLYTYP4 "ACTIVE COPPER AREA" // Polygon type active copper #define POLYTYP5 "DOCUMENTARY LINE" // Polygon type documentary line #define POLYTYP6 "DOCUMENTARY AREA" // Polygon type documentary area #define POLYTYP7 "COPPER FILL AREA" // Polygon type copper fill area #define POLYTYP8 "HATCHED COPPER AREA" // Polygon type hatched copper #define POLYTYP9 "POWER PLANE AREA" // Polygon type power plane area #define POLYVIS0 "VISIBLE ALWAYS" // Polygon visible always #define POLYVIS1 "VISIBLE UNMIRRORED" // Polygon visible unmirrored #define POLYVIS2 "VISIBLE MIRRORED" // Polygon visible mirrored #define POLYVIS3 "FIXED VISIBLE UNMIRRORED" // Polygon visible unmirrored #define POLYVIS4 "FIXED VISIBLE MIRRORED" // Polygon visible mirrored #define POINTTYP0 "STANDARD" // Point type standard #define POINTTYP1 "ARC CENTER LEFT" // Point type arc left #define POINTTYP2 "ARC CENTER RIGHT" // Point type arc right // File handling string DMPEXT = bae_inistrval(PAR_DUMPFEXT,".dmp") /* File name extension */; #define MSGEXT "_l.lst" // Message file name extension string dmpfname /* BAE ASCII dump input file name */; string ddbfname /* Output database file name */; string msgfname /* Message file name */; int mfh /* Message file handle */; // Layer assignment struct layass { // Layer assignment descriptor string name /* Layer name */; int code /* Layer code */; }; struct layass deflayassl[] = { // Default layer assignment list { "Bottom", 0 }, { "Top", -5 }, { "Route2", 1 }, { "Route3", 2 }, { "Route4", 3 }, { "Route5", 4 }, { "Route6", 5 }, { "Route7", 6 }, { "Route8", 7 }, { "Route9", 8 }, { "Route10", 9 }, { "Route11", 10 }, { "Route12", 11 }, { "Route13", 12 }, { "Route14", 13 }, { "Dimension", 0x442 }, { "tPlace", 0x401 }, { "bPlace", 0x400 }, { "tNames", 0x401 }, { "bNames", 0x400 }, { "tValues", 0x401 }, { "bValues", 0x400 }, { "tStop", 0x411 }, { "bStop", 0x410 }, { "tCream", 0x471 }, { "bCream", 0x470 }, { "tKeepout", 0x451 }, { "bKeepout", 0x450 }, { "Measures", 0x480 }, { "Document", 0x442 }, { "tRestrict", -5 }, { "bRestrict", 0 }, { "Drills", 0x422 }, { "Reference", 0x432 } }; struct layass layassl[] /* Layer assignment list */; int layidxl[] /* Layer index list */; int layassn /* Layer assignment count */; string deflibname = lay_deflibname() /* Default library name */; int DRLSYMLAY = bae_iniintval(PAR_DRLSYMLAY,0x422) /* Drill symbol pad layer */; string DRLSYMNPAT = bae_inistrval(PAR_DRLSYMNPAT,"") /* Drill symbol pad name pattern */; string DRLSYMLIB = bae_inistrval(PAR_DRLSYMLIB,"") /* Drill symbol pad library file */; // Macro list STRINGS m_names /* Macro name list */; int m_classes[] /* Macro plan DDB class list */; int m_cnt = 0 /* Macro count */; int outmode /* Output destination */; string outbuf /* Output buffer string */; string outstr = "" /* Output string list */; string docstr = "" /* Documentation string */; // Scanner variables int procclass /* Current database element class */; int curproc = 0 /* Current processing active */; double curlx, curly /* Current lower boundary */; double curux, curuy /* Current lower boundary */; double curnx, curny /* Current lower boundary */; string curid /* Current identifier */; string curstr /* Current string value */; string curtext /* Current text string */; double cursize /* Current size */; string curname /* Current name */; string currefname /* Current reference name */; string curmacro /* Current macro name */; double curcoord /* Current coordinate */; double curx /* Current X coordinate */; double cury /* Current Y coordinate */; double currx, curry /* Current reference coordinate */; double curra /* Current reference angle */; int currmirror /* Current reference mirror flag */; int curptyp /* Current point type */; double curdia /* Current diameter */; int curdrlclass /* Current drill class */; double curwidth /* Current width */; double cura = 0.0 /* Current angle (default: 0.0) */; string curnetname /* Current net name */; int curlayer /* Current layer code */; STRINGS rl /* Current rule list */; int rn /* Current rule count */; STRINGS nilsl = {""} /* Initialyzed string list */; int libonly = 0 /* Current library process flag */; int sfileflag = 0 /* Single file process flag */; int autoproj = 0 /* Automatic project process flag */; int curint /* Current integer value */; int curflag /* Current boolean value */; int curtmode /* Current text mode */; int curpolymode /* Current polygon mode */; int curpolytyp /* Current polygon typ */; int curfixed /* Current fixed flag */; int curmirror /* Current mirror flag */; int curabsmove /* Current absolute move flag */; int curlinedisp /* Current line display flag */; double curflt /* Current float value */; struct rmoddes { // Reference modifier descriptor int layer /* Layer code */; string str /* Attribute string */; double x,y /* Coordinates */; double ang /* Angle */; double size /* Size */; int mirr /* Mirror flag */; int absmove /* Absolute movement flag */; } rmodl[] /* Reference modifier list */; int rmodn = 0 /* Reference modifier count */; string textid = creatextid() /* Get multiline text base ID */; int mtextcnt = 0 /* Multiline text count */; double lenconv = 1.0/cvtlength(1.0,0,2) /* Length conv. fact. (default mm) */; double angconv = 1.0/cvtangle(1.0,0,1) /* Angle conv. fact. (def. degree) */; // Main program void main() { string scandir /* Scan directory */; string scanfname /* Scan file name */; string jobfname /* Job file name */; string jobename /* Job element name */; int jobclass /* Job class */; string outfname /* Output file name */; string msg /* Message string */; int outfh /* Output file handle */; int outelem /* Output elements */; index L_MACRO macro /* Macro index */; int editcap /* Edit capability flag */; int opmode /* Operation mode */; int len /* String length */; int i /* Loop control variable */; // Get the operation mode if (uliptype()!=ULIPGED) { opmode=0; } else { bae_promptdialog(UPRIOFCT); if ((opmode=bae_askmenu(3,UPRFCTDUMP,UPRFCTIMP,UPRABORT))<0 || opmode>1) error_abort(); } // Check if import if (opmode) { // Save current element with verification on request verifysave(); // Get the drill symbol pad library name if (DRLSYMLIB=="") DRLSYMLIB=deflibname; // Get and check the process mode bae_promptdialog(UPRPROCMODE); switch (bae_askmenu(6,UPRPROCALL,UPRPROCLIB,UPRPROCSALL, UPRPROCSLIB,UPRPROCPROJ,UPRABORT)) { // Complete case 0 : libonly=0; break; // Library only case 1 : libonly=1; break; // Single project complete case 2 : libonly=0; sfileflag=1; break; // Single project library only case 3 : libonly=1; sfileflag=1; break; // Complete project run case 4 : libonly=1; sfileflag=1; autoproj=1; break; default : error_abort(); } // Get the layer assignment list for (layassn=0;layassn<1000;layassn++) { if ((layassl[layassn].name=bae_inistrval( bae_inifieldvarname(PAR_DMPLAYASSL,layassn,0), ""))=="") { // Check if list defined at all if (layassn==0) { // Use default layer assignment list layassl=deflayassl; layassn=arylength(layassl); } break; } layassl[layassn].code=bae_iniintval( bae_inifieldvarname(PAR_DMPLAYASSL,layassn,1),0x401); } // Sort the layers for (i=0;iidx2 // Parameters : // int idx1 : First compare index // int idx2 : Second compare index */ { // Get the comparison result return(strcmp(layassl[idx1].name,layassl[idx2].name)); } // Output routines void dumpdoclays(int fh) /* // Dumps documentary layer definitions // Parameters : // int fh : File handle */ { string name /* Documentary layer name */; int i /* Loop control variable */; // Loop thru all doc layers for (i=0;i=0) dispfigrules(fh,fig); if (outmode) { fprintf(fh,FMTATTFT); } else { docstr+=FMTATTFT; outstr+=docstr; } } } void ureflist(int fh,double nx,double ny) /* // Unnamed reference list function // Parameters : // int fh : Output file handle // double nx : Origin X coordinate // double ny : Origin Y coordinate */ { index L_FIGURE fig /* Figure list index */; index L_UREF u /* Unnamed reference index */; // Loop thru the unnamed reference list forall (fig where fig.TYP==L_FIGUREF) { u=fig.UREF; // Print the info if (outmode) fprintf(fh,FMTUREF,macclname(u.MACRO.CLASS)); else sprintf(docstr,FMTUREF, macclname(u.MACRO.CLASS)); // Print the fixed info if (fig.FIXED&1) { if (outmode) fprintf(fh,FMTFIXED); else docstr+=FMTFIXED; } // Print the glued info if (fig.FIXED&2) { if (outmode) fprintf(fh,FMTGLUED); else docstr+=FMTGLUED; } if (outmode) { fprintf(fh,FMTMACRO,u.MACRO.NAME); fprintf(fh,FMTLAYER,u.LAYOFF,layername(u.LAYOFF)); fprintf(fh,FMTPOSX,PREC,cvtl(u.X-nx)); fprintf(fh,FMTPOSY,PREC,cvtl(u.Y-ny)); fprintf(fh,FMTANGLE,cvtangle(u.ANGLE,0,1)); fprintf(fh,FMTMIRROR,u.MIRROR, (u.MIRROR ? ITMMIRRON : ITMMIRROFF)); } else { sprintf(outbuf,FMTMACRO,u.MACRO.NAME); docstr+=outbuf; sprintf(outbuf,FMTLAYER,u.LAYOFF, layername(u.LAYOFF)); docstr+=outbuf; sprintf(outbuf,FMTPOSX,PREC,cvtl(u.X-nx)); docstr+=outbuf; sprintf(outbuf,FMTPOSY,PREC,cvtl(u.Y-ny)); docstr+=outbuf; sprintf(outbuf,FMTANGLE,cvtangle(u.ANGLE,0,1)); docstr+=outbuf; sprintf(outbuf,FMTMIRROR,u.MIRROR, (u.MIRROR ? ITMMIRRON : ITMMIRROFF)); docstr+=outbuf; } if (fig.RULEOBJID>=0) dispfigrules(fh,fig); if (outmode) fprintf(fh,FMTATTFT); else { docstr+=FMTATTFT; outstr+=docstr; } } } void drilllist(int fh,double nx,double ny) /* // Drill list function // Parameters : // int fh : Output file handle // double nx : Origin X coordinate // double ny : Origin Y coordinate */ { index L_FIGURE fig /* Figure list index */; index L_DRILL d /* Drill index */; // Loop thru the drill list forall (fig where fig.TYP==L_FIGDRILL) { d=fig.DRILL; // Print the info if (outmode) fprintf(fh,FMTDRILL); else docstr=FMTDRILL; // Print the fixed info if (fig.FIXED&1) { if (outmode) fprintf(fh,FMTFIXED); else docstr+=FMTFIXED; } // Print the glued info if (fig.FIXED&2) { if (outmode) fprintf(fh,FMTGLUED); else docstr+=FMTGLUED; } if (outmode) { fprintf(fh,FMTCLASS,d.CLASS,drillclass(d.CLASS)); fprintf(fh,FMTDIA,PREC,cvtl(2*d.RAD)); fprintf(fh,FMTPOSX,PREC,cvtl(d.X-nx)); fprintf(fh,FMTPOSY,PREC,cvtl(d.Y-ny)); } else { sprintf(outbuf,FMTCLASS, d.CLASS,drillclass(d.CLASS)); docstr+=outbuf; sprintf(outbuf,FMTDIA,PREC,cvtl(2*d.RAD)); docstr+=outbuf; sprintf(outbuf,FMTPOSX,PREC,cvtl(d.X-nx)); docstr+=outbuf; sprintf(outbuf,FMTPOSY,PREC,cvtl(d.Y-ny)); docstr+=outbuf; } if (fig.RULEOBJID>=0) dispfigrules(fh,fig); if (outmode) fprintf(fh,FMTATTFT); else { docstr+=FMTATTFT; outstr+=docstr; } } } void textlist(int fh,double nx,double ny) /* // Text list function // Parameters : // int fh : Output file handle // double nx : Origin X coordinate // double ny : Origin Y coordinate */ { index L_FIGURE fig /* Figure list index */; index L_TEXT t /* Text index */; // Loop thru the text list forall (fig where fig.TYP==L_FIGTEXT) { t=fig.TEXT; // Print the info if (outmode) fprintf(fh,FMTTEXT); else docstr=FMTTEXT; // Print the fixed info if (fig.FIXED&1) { if (outmode) fprintf(fh,FMTFIXED); else docstr+=FMTFIXED; } // Print the glued info if (fig.FIXED&2) { if (outmode) fprintf(fh,FMTGLUED); else docstr+=FMTGLUED; } if (outmode) { fprintf(fh,FMTTEXTSTR,t.STR); fprintf(fh,FMTMODE,t.MODE,doclaytext(t.MODE)); fprintf(fh,FMTLAYER,t.LAYER,layername(t.LAYER)); fprintf(fh,FMTSIZE,PREC,cvtl(t.SIZE)); fprintf(fh,FMTPOSX,PREC,cvtl(t.X-nx)); fprintf(fh,FMTPOSY,PREC,cvtl(t.Y-ny)); fprintf(fh,FMTANGLE,cvtangle(t.ANGLE,0,1)); fprintf(fh,FMTMIRROR,t.MIRROR, (t.MIRROR ? ITMMIRRON : ITMMIRROFF)); } else { sprintf(outbuf,FMTTEXTSTR,t.STR); docstr+=outbuf; sprintf(outbuf,FMTMODE,t.MODE, doclaytext(t.MODE)); docstr+=outbuf; sprintf(outbuf,FMTLAYER,t.LAYER, layername(t.LAYER)); docstr+=outbuf; sprintf(outbuf,FMTSIZE,PREC,cvtl(t.SIZE)); docstr+=outbuf; sprintf(outbuf,FMTPOSX,PREC,cvtl(t.X-nx)); docstr+=outbuf; sprintf(outbuf,FMTPOSY,PREC,cvtl(t.Y-ny)); docstr+=outbuf; sprintf(outbuf,FMTANGLE,cvtangle(t.ANGLE,0,1)); docstr+=outbuf; sprintf(outbuf,FMTMIRROR,t.MIRROR, (t.MIRROR ? ITMMIRRON : ITMMIRROFF)); docstr+=outbuf; } if (fig.RULEOBJID>=0) dispfigrules(fh,fig); if (outmode) { fprintf(fh,FMTATTFT); } else { docstr+=FMTATTFT; outstr+=docstr; } } } void pathlist(int fh,double nx,double ny) /* // Path list function // Parameters : // int fh : Output file handle // double nx : Origin X coordinate // double ny : Origin Y coordinate */ { index L_FIGURE fig /* Figure list index */; index L_LINE path /* Line/Path index */; index L_POINT p /* Point index */; // Loop thru the path list forall (fig where fig.TYP==L_FIGPATH) { path=fig.LINE; // Print the info if (outmode) fprintf(fh,FMTPATH); else docstr=FMTPATH; // Print the fixed info if (fig.FIXED&1) { if (outmode) fprintf(fh,FMTFIXED); else docstr+=FMTFIXED; } // Print the glued info if (fig.FIXED&2) { if (outmode) fprintf(fh,FMTGLUED); else docstr+=FMTGLUED; } if (outmode) { fprintf(fh,FMTTREE,path.TREE); fprintf(fh,FMTNET,treename(path.TREE)); fprintf(fh,FMTLAYER,path.LAYER,layername(path.LAYER)); fprintf(fh,FMTWIDTH,PREC,cvtl(path.WIDTH)); } else { sprintf(outbuf,FMTTREE,path.TREE); docstr+=outbuf; sprintf(outbuf,FMTNET,treename(path.TREE)); docstr+=outbuf; sprintf(outbuf,FMTLAYER,path.LAYER, layername(path.LAYER)); docstr+=outbuf; sprintf(outbuf,FMTWIDTH,PREC,cvtl(path.WIDTH)); docstr+=outbuf; } if (POLYSTYLE) { if (outmode) { fprintf(fh,FMTPOINTN,path.PN); } else { sprintf(outbuf,FMTPOINTN,path.PN); docstr+=outbuf; } if (path.PN>0) if (outmode) fprintf(fh,FMTPOINTSHD); else docstr+=FMTPOINTSHD; // Loop thru the point list forall (p of path) // Print the info if (outmode) fprintf(fh,FMTPOINT,PREC,cvtl(p.X-nx), PREC,cvtl(p.Y-ny),p.TYP, pointtype(p.TYP)); else { sprintf(outbuf,FMTPOINT,PREC, cvtl(p.X-nx),PREC,cvtl(p.Y-ny), p.TYP,pointtype(p.TYP)); docstr+=outbuf; } if (path.PN>0) if (outmode) fprintf(fh,FMTPOINTSFT); else docstr+=FMTPOINTSFT; } else { if (outmode) { fprintf(fh,FMTOPOINTCNT,path.PN); } else { sprintf(outbuf,FMTOPOINTCNT,path.PN); docstr+=outbuf; } // Loop thru the point list forall (p of path) // Print the info if (outmode) fprintf(fh,FMTOPOINT,PREC, cvtl(p.X-nx),PREC,cvtl(p.Y-ny), p.TYP,pointtype(p.TYP)); else { sprintf(outbuf,FMTOPOINT,PREC, cvtl(p.X-nx),PREC,cvtl(p.Y-ny), p.TYP,pointtype(p.TYP)); docstr+=outbuf; } } if (fig.RULEOBJID>=0) dispfigrules(fh,fig); if (outmode) { fprintf(fh,FMTATTFT); } else { docstr+=FMTATTFT; outstr+=docstr; } } } void polylist(int fh,double nx,double ny) /* // Polygon list function // Parameters : // int fh : Output file handle // double nx : Origin X coordinate // double ny : Origin Y coordinate */ { index L_FIGURE fig /* Figure list index */; index L_POLY poly /* Polygon index */; index L_POINT p /* Point index */; // Loop thru the polygon list forall (fig where fig.TYP==L_FIGPOLY) { poly=fig.POLY; // Print the info if (outmode) fprintf(fh,FMTPOLY); else docstr=FMTPOLY; // Print the fixed info if (fig.FIXED&1) { if (outmode) fprintf(fh,FMTFIXED); else docstr+=FMTFIXED; } // Print the glued info if (fig.FIXED&2) { if (outmode) fprintf(fh,FMTGLUED); else docstr+=FMTGLUED; } if (outmode) { fprintf(fh,FMTPOLYTYPE,poly.TYP,polytype(poly.TYP)); fprintf(fh,FMTMODE,poly.MVIS,polymvis(poly.MVIS)); fprintf(fh,FMTLAYER,poly.LAYER,layername(poly.LAYER)); fprintf(fh,FMTTREE,poly.TREE); fprintf(fh,FMTNET,treename(poly.TREE)); } else { sprintf(outbuf,FMTPOLYTYPE,poly.TYP,polytype(poly.TYP)); docstr+=outbuf; sprintf(outbuf,FMTMODE,poly.MVIS,polymvis(poly.MVIS)); docstr+=outbuf; sprintf(outbuf,FMTLAYER,poly.LAYER, layername(poly.LAYER)); docstr+=outbuf; sprintf(outbuf,FMTTREE,poly.TREE); docstr+=outbuf; sprintf(outbuf,FMTNET,treename(poly.TREE)); docstr+=outbuf; } if (POLYSTYLE) { if (outmode) { fprintf(fh,FMTPOINTN,poly.PN); } else { sprintf(outbuf,FMTPOINTN,poly.PN); docstr+=outbuf; } if (poly.PN>0) if (outmode) fprintf(fh,FMTPOINTSHD); else docstr+=FMTPOINTSHD; // Loop thru the point list forall (p of poly) // Print the info if (outmode) { fprintf(fh,FMTPOINT,PREC,cvtl(p.X-nx), PREC,cvtl(p.Y-ny),p.TYP, pointtype(p.TYP)); } else { sprintf(outbuf,FMTPOINT,PREC, cvtl(p.X-nx),PREC,cvtl(p.Y-ny), p.TYP,pointtype(p.TYP)); docstr+=outbuf; } if (poly.PN>0) { if (outmode) fprintf(fh,FMTPOINTSFT); else docstr+=FMTPOINTSFT; } } else { if (outmode) { fprintf(fh,FMTOPOINTCNT,poly.PN); } else { sprintf(outbuf,FMTOPOINTCNT,poly.PN); docstr+=outbuf; } // Loop thru the point list forall (p of poly) // Print the info if (outmode) { fprintf(fh,FMTOPOINT,PREC, cvtl(p.X-nx),PREC,cvtl(p.Y-ny), p.TYP,pointtype(p.TYP)); } else { sprintf(outbuf,FMTOPOINT,PREC, cvtl(p.X-nx),PREC,cvtl(p.Y-ny), p.TYP,pointtype(p.TYP)); docstr+=outbuf; } } if (fig.RULEOBJID>=0) dispfigrules(fh,fig); if (outmode) { fprintf(fh,FMTATTFT); } else { docstr+=FMTATTFT; outstr+=docstr; } } } // Data conversion routines string macclname(int c) /* // Return value : class name for the given macro class code // Parameters : // int c : Macro DDB class code */ { // Get the class name switch (c) { case DDBCLLAY : return(ITMLAYOUT); case DDBCLLPRT : return(ITMPART); case DDBCLLSTK : return(ITMSTACK); case DDBCLLPAD : return(ITMPAD); } // Undefined return(ITMUNDEF); } string doclayside(int code) /* // Convert documentary layer side code to item string // Return value : // side denote string // Parameters : // int code : Side code */ { // Evaluate the code switch (code) { case (-1) : return(DOCLAYSIDN); case 0 : return(DOCLAYSID1); case 1 : return(DOCLAYSID2); case 2 : return(DOCLAYSIDB); } // Undefined return(ITMUNDEF); } string doclaytext(int code) /* // Convert documentary layer text mode code to item string // Return value : // text mode denote string // Parameters : // int code : Text mode code */ { // Evaluate the code switch (code&TEXTOMSK) { case TEXTPHYS : return(DOCLAYTXTP); case TEXTLOG : return(DOCLAYTXTL); case TEXTNOROT : return(DOCLAYTXTN); } // Undefined return(ITMUNDEF); } string polytype(int code) /* // Convert polygon type code to item string // Return value : // polygon type denote string // Parameters : // int code : Polygon type code */ { // Evaluate the code switch (code) { case L_POLYCOPPASS : return(POLYTYP1); case L_POLYKEEPOUT : return(POLYTYP2); case L_POLYBRDOUT : return(POLYTYP3); case L_POLYCOPACT : return(POLYTYP4); case L_POLYDOCLINE : return(POLYTYP5); case L_POLYDOCAREA : return(POLYTYP6); case L_POLYCOPFILL : return(POLYTYP7); case L_POLYHTCHCOP : return(POLYTYP8); case L_POLYSPPAREA : return(POLYTYP9); } // Undefined return(ITMUNDEF); } string polymvis(int code) /* // Convert polygon mirror visibility mode code to item string // Return value : // polygon mirror visibility mode denote string // Parameters : // int code : Polygon mirror visibility mode code */ { // Evaluate the code switch (code&0x13) { case 0 : return(POLYVIS0); case 1 : return(POLYVIS1); case 2 : return(POLYVIS2); case 17 : return(POLYVIS3); case 18 : return(POLYVIS4); } // Undefined return(ITMUNDEF); } string pointtype(int code) /* // Convert point type code to item string // Return value : // point type denote string // Parameters : // int code : Point type code */ { // Evaluate the code switch (code) { case 0 : return(POINTTYP0); case 1 : return(POINTTYP1); case 2 : return(POINTTYP2); } // Undefined return(ITMUNDEF); } string treename(int treenum) /* // Get tree name from tree number // Return value : // tree name or empty string if not found // Parameters : // int treenum : Tree number */ { index L_CNET cnet /* Connection net index */; // Find the net with given tree number if (lay_gettreeidx(treenum,cnet)==0) // Net found; return the net name return(cnet.NAME); // Net not found return(""); } string drillclass(int code) /* // Convert drill class code to item character // Return value : // drill class code denote character // Parameters : // int code : Drill class code */ { string cstr /* Drill class string */; int class /* Drill class */; int mclass /* Mirrored drill class */; // Get the class codes class= (code&DRLCMASK1); mclass= (code&DRLCMIRR) ? ((code&DRLCMASK2)>>DRLCSHFT2) : class; // Check the class codes if (class<0 || class>26 || mclass<0 || mclass>26) // Undefined return(ITMUNDEF[0]); if (class==mclass) sprintf(cstr,"'%c'",class==0 ? '-' : (class+'A'-1)); else sprintf(cstr,"'%c'/'%c'",class==0 ? '-' : (class+'A'-1), mclass==0 ? '-' : ( mclass+'A'-1)); return(cstr); } void dispplanrules(int fh) /* // Dumps the rule attachments of the current element // Parameters : // int fh : Output file handle */ { string rn /* Rule name buffer */; int rnc /* Rule name count */; int i /* Loop control variable */; // Get rule count if ((rnc=lay_getrulecnt(RS_OCPLAN,0))>0) { if (outmode) fprintf(fh,FMTERULES); else docstr=FMTERULES; // Scan the rule name list for (i=0;i0) { if (outmode) fprintf(fh,FMTRULES); else docstr+=FMTRULES; // Scan the rule name list for (i=0;i=arylength(ERRS)) sprintf(msg,ERRS[arylength(ERRS)-1],status); else sprintf(msg,ERRS[status], fn,synscanline(),synscanstring()); // Print the error message error(msg); } // Parser action routines int p_ident() /* // Receive an identifier // Return value : // zero if done or (-1) on error */ { // Store the current string curid=curstr; strlower(curid); // Return without errors return(0); } int p_name() /* // Receive a name // Return value : // zero if done or (-1) on error */ { // Store the current string curname=curid; // Return without errors return(0); } int p_refname() /* // Receive a reference name // Return value : // zero if done or (-1) on error */ { // Store the current name currefname=curid; // Return without errors return(0); } int p_macro() /* // Receive a macro name // Return value : // zero if done or (-1) on error */ { // Store the current name curmacro=curid; // Return without errors return(0); } int p_string() /* // Receive a quoted string // Return value : // zero if done or (-1) on error */ { // Get the scanned string curstr=synscanstring(); // Return without errors return(0); } int p_startelem(int elemclass) /* // Receive a start element flag // Return value : // zero if done or (-1) on error // Parameters : // int flag : Boolean flag */ { double ex, ey /* Coordinate extrema */; if (elemclass==procclass && existddbelem(ddbfname,elemclass,curname)!=1) { // Perform the create element call bae_clriactqueue(); bae_storemenuiact(1,elemclass-100,LMB); bae_storetextiact(1,ddbfname); bae_storetextiact(1,curname); bae_storetextiact(1,"1"); bae_storetextiact(1,"1"); bae_setintpar(22,1); call(MNU_GEDCREELEM); bae_setintpar(22,0); // Set lower element boundary bae_clriactqueue(); ex=curlx+curnx; if (bae_planwslx()ex) ex=bae_planwsux(); if (curnx>ex) ex=curnx; ey=curuy+curny; if (bae_planwsuy()>ey) ey=bae_planwsuy(); if (curny>ey) ey=curny; bae_storemouseiact(1,ex,ey,2,LMB); bae_callmenu(MNU_GEDPARUBND); // Set element origin bae_storemouseiact(1,curnx,curny,2,LMB); bae_callmenu(MNU_GEDPARORIG); // Set lower element boundary bae_storemouseiact(1,curlx+curnx,curly+curny,2,LMB); bae_callmenu(MNU_GEDPARLBND); // Set upper element boundary bae_storemouseiact(1,curux+curnx,curuy+curny,2,LMB); bae_callmenu(MNU_GEDPARUBND); bae_setintpar(22,2); call(MNU_BAEZOOMALL); bae_setintpar(22,0); curproc=1; // Reset rule list rl=nilsl; rn=0; } // Return without errors return(0); } int p_endelem() /* // Receive a boolean flag value // Return value : // zero if done or (-1) on error */ { if (curproc) { bae_setintpar(22,1); call(MNU_GEDSAVELEM); bae_setintpar(22,0); curproc=0; } // Return without errors return(0); } int p_flag(int flag) /* // Receive a boolean flag value // Return value : // zero if done or (-1) on error // Parameters : // int flag : Boolean flag */ { curflag=flag==2 ? curint : flag; // Return without errors return(0); } int p_moveinit(int absmove) /* // Receive a name move data initialization // Return value : // zero if done or (-1) on error // Parameters : // int absmove : Absolute move flag */ { cura=0.0; curx=cury=0.0; curmirror=0; curlinedisp=0; curabsmove=absmove; curlayer=LAYERINV; curstr=""; // Return without errors return(0); } int p_init() /* // Receive a data initialization // Return value : // zero if done or (-1) on error */ { cura=curra=0.0; curx=currx=cury=curry=0.0; curmirror=currmirror=0; curflag=0; curmacro=""; currefname=""; curnetname=""; curwidth=0.0; curdia=0.0; // Reset fixed flag curfixed=0; // Reset rule list rl=nilsl; rn=0; rmodn=0; // Reset layer curlayer=LAYERINV; bae_clearpoints(); // Return without errors return(0); } int p_rule() /* // Receive a rule definition // Return value : // zero if done or (-1) on error */ { rl[rn]=curstr; rn++; // Return without errors return(0); } int p_fixed() /* // Receive a fixed flag // Return value : // zero if done or (-1) on error */ { curfixed=1; // Return without errors return(0); } int p_intval(int val) /* // Receive an integer value // Return value : // zero if done or (-1) on error // Parameters : // int val : Integer value */ { // Get the integer value curint=val; // Return without errors return(0); } int p_intnum(int negflag) /* // Receive an integer value // Return value : // zero if done or (-1) on error // Parameters : // int negflag : Negative number flag */ { // Get the current integer value curint=atoi(synscanstring()); // Set negative on request if (negflag) curint*=(-1); // Return without errors return(0); } int p_fltnum(int negflag) /* // Receive a float value // Return value : // zero if done or (-1) on error // Parameters : // int negflag : Negative number flag */ { // Get the current float value curflt=atof(synscanstring()); // Set negative on request if (negflag) curflt*=(-1); // Return without errors return(0); } int p_angnum(int negflag) /* // Receive an angle value // Return value : // zero if done or (-1) on error // Parameters : // int negflag : Negative number flag */ { // Get the current float value cura=atof(synscanstring()); // Set negative on request if (negflag) cura*=(-1.0); // Adjust arc range to [0,360[ while (cura<0.0) cura+=360.0; while (cura>=360.0) cura-=360.0; // Convert to internal units cura*=angconv; // Return without errors return(0); } int p_unitl(int code) /* // Handle the length units definition request // Return value : // zero if done or (-1) on error // Parameters : // int code : Length units code */ { if (code==10) code=curint; // Set the length conversion factor switch (code) { // Meter case LUNITM : lenconv=cvtlength(1.0,0,0); break; // Inch case LUNITIN : lenconv=cvtlength(1.0,1,0); break; // mm case LUNITMM : lenconv=cvtlength(1.0,2,0); break; // mil case LUNITMIL : lenconv=cvtlength(1.0,3,0); break; // um case LUNITUM : lenconv=cvtlength(1.0,4,0); break; // Implementation gap default : return(-1); } // Return without errors return(0); } int p_width() /* // Receive a width value // Return value : // zero if done or (-1) on error */ { // Store the current dimension curwidth=curcoord; // Return without errors return(0); } int p_diameter() /* // Receive a diameter value // Return value : // zero if done or (-1) on error */ { // Store the current dimension curdia=curcoord; // Return without errors return(0); } int p_coord(int code) /* // Receive a coordinate value // Return value : // zero if done or (-1) on error // Parameters : // int code : Length units code */ { switch (code) { // Inch case 1 : curcoord=cvtlength(curflt,1,0); break; // mm case 2 : curcoord=cvtlength(curflt,2,0); break; // mil case 3 : curcoord=cvtlength(curflt,3,0); break; // Default case 0 : default : // Store the current coordinate curcoord=curflt*lenconv; } // Return without errors return(0); } int p_nx() /* // Receive a origin X coordinate // Return value : // zero if done or (-1) on error */ { // Store the current X coordinate curnx=curcoord; // Return without errors return(0); } int p_ny() /* // Receive a origin Y coordinate // Return value : // zero if done or (-1) on error */ { // Store the current Y coordinate curny=curcoord; // Return without errors return(0); } int p_lx() /* // Receive a lower boundary X coordinate // Return value : // zero if done or (-1) on error */ { // Store the current X coordinate curlx=curcoord; // Return without errors return(0); } int p_ly() /* // Receive a lower boundary Y coordinate // Return value : // zero if done or (-1) on error */ { // Store the current Y coordinate curly=curcoord; // Return without errors return(0); } int p_ux() /* // Receive a upper boundary X coordinate // Return value : // zero if done or (-1) on error */ { // Store the current X coordinate curux=curcoord; // Return without errors return(0); } int p_uy() /* // Receive a upper boundary Y coordinate // Return value : // zero if done or (-1) on error */ { // Store the current Y coordinate curuy=curcoord; // Return without errors return(0); } int p_x() /* // Receive a X coordinate // Return value : // zero if done or (-1) on error */ { // Store the current X coordinate curx=curcoord+curnx; // Return without errors return(0); } int p_y() /* // Receive a Y coordinate // Return value : // zero if done or (-1) on error */ { // Store the current Y coordinate cury=curcoord+curny; // Return without errors return(0); } int p_refmirror() /* // Receive a reference mirror flag // Return value : // zero if done or (-1) on error */ { // Store the current mirror flag currmirror=curmirror; // Return without errors return(0); } int p_refang() /* // Receive a reference angle // Return value : // zero if done or (-1) on error */ { // Store the current angle curra=cura; // Return without errors return(0); } int p_refx() /* // Receive a reference X coordinate // Return value : // zero if done or (-1) on error */ { // Store the current X coordinate currx=curx; // Return without errors return(0); } int p_refy() /* // Receive a reference Y coordinate // Return value : // zero if done or (-1) on error */ { // Store the current Y coordinate curry=cury; // Return without errors return(0); } int p_size() /* // Receive a size // Return value : // zero if done or (-1) on error */ { // Store the current size cursize=curcoord; // Return without errors return(0); } int p_drillclass() /* // Receive a drill class // Return value : // zero if done or (-1) on error */ { curdrlclass=curint; // Return without errors return(0); } int p_textmode() /* // Receive a text mode // Return value : // zero if done or (-1) on error */ { curtmode=curint; // Return without errors return(0); } int p_textstr() /* // Receive a text string // Return value : // zero if done or (-1) on error */ { curtext=curstr; // Return without errors return(0); } int p_laynum() /* // Receive a layer number // Return value : // zero if done or (-1) on error */ { curlayer=curint; // Return without errors return(0); } int p_layname() /* // Receive a layer name // Return value : // zero if done or (-1) on error */ { int slb = 0 /* Search lower boundary */; int sub = layassn-1 /* Search upper boundary */; int sidx /* Search index */; int compres /* Compare result */; // Loop until search area empty while (slb<=sub) { // Get the search index sidx=(slb+sub)>>1; // Get the comparison result if ((compres=strcmp(curstr,layassl[layidxl[sidx]].name))==0) { // Layer found curlayer=layassl[layidxl[sidx]].code; // Return without errors return(0); } // Update the search area if (compres<0) sub=sidx-1; else slb=sidx+1; } curlayer=LAYERINV; // Return without errors return(0); } int p_mirror() /* // Receive a mirror mode // Return value : // zero if done or (-1) on error */ { curmirror=curflag; // Return without errors return(0); } int p_linedisp() /* // Receive a line display mode // Return value : // zero if done or (-1) on error */ { curlinedisp=curflag; // Return without errors return(0); } int p_pointtype(int ptyp) /* // Receive a point type // Return value : // zero if done or (-1) on error // Parameters : // int ptyp : Point type */ { curptyp= ptyp==10 ? curint : ptyp ; // Return without errors return(0); } int p_polytype() /* // Receive a polygon type // Return value : // zero if done or (-1) on error */ { curpolytyp=curint; // Return without errors return(0); } int p_polymode() /* // Receive a polygon mode // Return value : // zero if done or (-1) on error */ { curpolymode=curint; // Return without errors return(0); } int p_point() /* // Receive a point end // Return value : // zero if done or (-1) on error */ { // Check if part was created if (!curproc) // Return without errors return(0); bae_storepoint(curx,cury,curptyp); // Return without errors return(0); } int p_drill() /* // Receive a padstack drill // Return value : // zero if done or (-1) on error */ { string padname /* Pad name */; // Check if padstack was created if (!curproc || curdia==0.0) // Return without errors return(0); // Store the drill ged_storedrill(curx,cury,0.5*curdia,curdrlclass); if (DRLSYMNPAT!="") { // Set drill symbol library bae_clriactqueue(); bae_storetextiact(1,DRLSYMLIB); bae_callmenu(MNU_GEDPARSLIB); sprintf(padname,DRLSYMNPAT,cvtlength(curdia,0,2)); if (ged_storeuref(padname,curx,cury,0.0,DRLSYMLAY,0)) fprintf(mfh,ERRPLCPAD,dmpfname,synscanline(),padname); // Restore default library bae_clriactqueue(); bae_storetextiact(1,deflibname); bae_callmenu(MNU_GEDPARSLIB); } // Return without errors return(0); } int p_part() /* // Receive a part end // Return value : // zero if done or (-1) on error */ { if (!curproc) // Return without errors return(0); if (ged_storepart(currefname,curmacro,currx,curry,curra,currmirror)) fprintf(mfh,ERRPLCPART, dmpfname,synscanline(),currefname,curmacro); else endplc(); // Return without errors return(0); } int p_padstack() /* // Receive a padstack placement end // Return value : // zero if done or (-1) on error */ { if (!curproc) // Return without errors return(0); if (currefname!="") { if (ged_storepart( currefname,curmacro,currx,curry,curra,currmirror)) fprintf(mfh,ERRPLCPIN, dmpfname,synscanline(),currefname,curmacro); else endplc(); } else { if (ged_storeuref( curmacro,currx,curry,curra,curlayer,currmirror)) fprintf(mfh,ERRPLCVIA,dmpfname,synscanline(),curmacro); else endplc(); } // Return without errors return(0); } int p_pad() /* // Receive a padplacement end // Return value : // zero if done or (-1) on error */ { if (!curproc) // Return without errors return(0); if (ged_storeuref(curmacro,currx,curry,curra,curlayer,currmirror)) fprintf(mfh,ERRPLCPAD,dmpfname,synscanline(),curmacro); else endplc(); // Return without errors return(0); } int p_text() /* // Receive a text end // Return value : // zero if done or (-1) on error */ { string substr /* Text sub string */; double cosa,sina /* Trigonometric values */; int textcol = 0 /* Text column */; int brn = rn /* Base rule count */; if (!curproc || curlayer==LAYERINV) // Return without errors return(0); // Check if oversized text while (strlen(curtext)>MAXKEYLEN) { // Get the text direction vector sina=sin(cura); cosa=cos(cura); if (textcol==0) { // Build the multiline text rules sprintf(rl[brn],":%s:%s='%s_%d';", RS_PCBSUBJ,RS_MTEXTID,textid,mtextcnt); sprintf(rl[brn+2],":%s:%s=%d;", RS_PCBSUBJ,RS_MTEXTROW,0); sprintf(rl[brn+3],":%s:%s=%.2f;", RS_PCBSUBJ,RS_MTEXTLS,1.0); mtextcnt++; rn+=4; } sprintf(rl[brn+1],":%s:%s=%d;",RS_PCBSUBJ,RS_MTEXTCOL,textcol); // Get the length limited substring substr=strextract(curtext,0,MAXKEYLEN-1); // Store the text if (ged_storetext(substr,curx,cury,cura,cursize,curlayer, curmirror|(curtmode&TEXTEMSK))) fprintf(mfh,ERRPLCTEXT,dmpfname,synscanline(),curstr); else // Assign any rules endplc(); // Get remaining text data curtext=strextract(curtext,MAXKEYLEN,strlen(curtext)); curx+=cosa*80.0*cursize/3.0; cury+=sina*80.0*cursize/3.0; textcol++; } if (textcol) sprintf(rl[brn+1],":%s:%s=%d;",RS_PCBSUBJ,RS_MTEXTCOL,textcol); if (ged_storetext(curtext,curx,cury,cura,cursize,curlayer, curmirror|(curtmode&TEXTEMSK))) fprintf(mfh,ERRPLCTEXT,dmpfname,synscanline(),curstr); else endplc(); // Return without errors return(0); } int p_polygon() /* // Receive a polygon end // Return value : // zero if done or (-1) on error */ { index L_FIGURE nfig /* New figure list index */; if (!curproc || curlayer==LAYERINV) // Return without errors return(0); if (ged_storepoly(curlayer,curpolytyp,curnetname,curpolymode)) { fprintf(mfh,ERRPLCPOLY,dmpfname,synscanline()); } else { endplc(); if (curwidth>0.0 && lay_lastfigelem(nfig)==0) // Assign the width predicate rule rs_assfigdblpred(nfig,RS_PLOTWIDTH,curwidth,0.0,""); } // Return without errors return(0); } int p_path() /* // Receive a path end // Return value : // zero if done or (-1) on error */ { if (!curproc || curlayer==LAYERINV) // Return without errors return(0); if (ged_storepath(curlayer,curwidth)) fprintf(mfh,ERRPLCPATH,dmpfname,synscanline()); else endplc(); // Return without errors return(0); } int p_netname() /* // Receive a net name // Return value : // zero if done or (-1) on error */ { curnetname=curid; // Return without errors return(0); } int p_toplayer() /* // Receive a top layer definition // Return value : // zero if done or (-1) on error */ { if (curproc) ged_setplantoplay(curlayer); // Return without errors return(0); } int p_btwlayers() /* // Receive an inner layers count definition // Return value : // zero if done or (-1) on error */ { if (curproc) ged_setplantoplay(SIGLAYMAX+curint); // Return without errors return(0); } int p_powlayer() /* // Receive a power layer definition // Return value : // zero if done or (-1) on error */ { if (curproc && curlayer>=POWLAYBASE && curlayer<(POWLAYBASE+POWLAYMAX)) { // Define power layer bae_clriactqueue(); bae_storemenuiact(1,curlayer-POWLAYBASE,LMB); bae_storetextiact(1,curnetname); bae_storemenuiact(1,POWLAYMAX,LMB); call(MNU_GEDPARPOWL); ged_setplantoplay(SIGLAYMAX+curint); } // Return without errors return(0); } int p_viadef() /* // Receive a standard via definition // Return value : // zero if done or (-1) on error */ { if (!curproc) // Return without errors return(0); // Define via bae_clriactqueue(); bae_storetextiact(1,curmacro); bae_storetextiact(1,""); call(MNU_GEDSELVIA); // Return without errors return(0); } int p_comment() /* // Receive an element comment // Return value : // zero if done or (-1) on error // Parameter : // int contyp : Connection segment type */ { if (curproc) bae_setstrpar(0,curstr); // Return without errors return(0); } int p_planrules() /* // Receive plan rules // Return value : // zero if done or (-1) on error */ { if (curproc && rn>0) // Attach rules if (lay_ruleplanatt(rl)) rs_error(-1); // Return without errors return(0); } int p_namemove(int attrmove) /* // Receive name move // Return value : // zero if done or (-1) on error // Parameters : // int attrmove : Attribute move flag */ { if (curproc) { rmodl[rmodn].layer= attrmove ? curlayer : LAYERINV ; rmodl[rmodn].str=curstr; rmodl[rmodn].x=curx; rmodl[rmodn].y=cury; rmodl[rmodn].ang=cura; rmodl[rmodn].mirr=curmirror; rmodl[rmodn].size= curlinedisp ? -cursize : cursize ; rmodl[rmodn].absmove=curabsmove; rmodn++; } // Return without errors return(0); } void endplc() // End element placement { index L_FIGURE nfig /* New figure list index */; index L_NREF nref /* Named reference */; index L_MACRO macro /* Macro index */; double x,y /* Element coordinates */; double ang /* Element angle */; double tang /* Text angle */; double btx, bty /* Back transf. text coords. */; double asin, acos /* Angle sin, cos values */; int mirr /* Element mirror mode */; int tmirr /* Text mirror mode */; int i /* Loop control variable */; if (curfixed && lay_lastfigelem(nfig)==0) ged_elemfixchg(nfig,1); if (rn>0 && lay_lastfigelem(nfig)==0) // Attach rules if (lay_rulefigatt(nfig,rl)) rs_error(-1); for (i=0;i