/* SCMDUMP (CAP) -- SCM ASCII Dump */ /* SCMDUMP (CAP) -- SCM-ASCII-Dump */ /* // Copyright (c) 1994-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 (091021) RELEASED FOR BAE V7.4. // rl (081014) RELEASED FOR BAE V7.2. // rl (080804) ENHANCEMENT: // Added import function. // Changed output to laydump style. // rl (071029) RELEASED FOR BAE V7.0. // 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 (040522) ENHANCEMENT: // Added optional output to window and optional restriction to // rl (030904) RELEASED FOR BAE V6.2. // rl (021209) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (011019) ENHANCEMENT: // Added output of rule attachments. // rl (010625) RELEASED FOR BAE V5.0. // rl (010320) ENHANCEMENT: // Added optional parameter settings from bae.ini file. // rl (000509) RELEASED FOR BAE V4.6. // rl (990625) 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 (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 (94) RELEASED FOR BAE V3.0. // mb (94) ORIGINAL CODING. // // DESCRIPTION // // The scmdump User Language program generates a dump of // the currently loaded SCM element. The output is directed // to an ASCII file. */ // Includes #include "baeparam.ulh" // User Language BAE param. access #include "pop.ulh" // User Language popup utilities #include "scm.ulh" // User Language SCM utilities // Disable undo state request #pragma ULCALLERNOUNDO // INI file parameter name definitions #define PAR_DUMPFEXT "DUMPFEXT_SCM" // Output file name extension #define PAR_DUMPPOLY "DUMPPOLY_SCM" // Polygon point list output style #define PAR_SYMLIB "SYMGRPLIB_SCM" // Symbol library #define PAR_SYMGRP "SYMGRPNAME_SCM"// Symbol group // Messages string UPRABORT = M_UPRABORT(); string REPDDONE = M("SCM-Libary-Dump ausgegeben auf Datei '%s'.", "SCM 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 UPRPROCDIR = M("&Verzeichnis konvertieren","Convert &Folder"); string UPRPROCSFILE = M("&Einzeldatei konvertieren","Convert &Project"); string UNITSMM = M("M&illimeter [mm]","M&illimetre [mm]"); string UPRELEM = M("Ausgabemodus selektieren!", "Select Output Mode!"); string UPRELEM1 = M("&SCM-Projekt in Datei","SCM p&roject to file"); string UPRELEM2 = M("Plan mit Bibliothe&k in Datei", "Pl&an with library to file"); string UPRELEM3 = M("Nur &Plan in Datei","Only &plan to file"); string UPRELEM4 = M("%S&CM-Projekt in Fenster", "%SCM pr&oject to screen"); string UPRELEM5 = M("Plan mit Bibliothek in &Fenster", "Plan with library to &screen"); string UPRELEM6 = 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 ERRPLCCON = M("[%s/%d]: Fehler bei der Verbindungserzeugung!\n", "[%s/%d]: Error generating connection!\n"); string ERRPLCTEXT = M("[%s/%d]: Fehler bei der Texterzeugung '%s'!\n", "[%s/%d]: Error generating text '%s'!\n"); string ERRPLCSYMBOL = M("[%s/%d]: Fehler bei der Symbolplatzierung '%s'/'%s'!\n", "[%s/%d]: Error placing symbol '%s'/'%s'!\n"); string ITMUNDEF = M("*** UNDEFINIERT ***","*** UNDEFINED ***"); // Format strings #define FMTHEADER "SCM DUMP '%s' {\n" #define FMTLUNITS "\tLENGTH UNITS = %d ; /* %s */\n" #define FMTAUNITS "\tANGLE UNITS = %d ; /* %s */\n" #define FMTELEMHD "\n%s ( '%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 FMTSBLOCK "\tSINGLE BLOCK NAME = '%s' ;\n" #define FMTBLOCK "\tBLOCK NAME = '%s' ;\n" #define FMTCOMM "\tCOMMENT = '%s' ;\n" #define FMTNAMEPAT "\tNAMEPATTERN = \"%s\" ;\n" #define FMTNREF "\t%s {\n" #define FMTTEXT "\tTEXT {\n" #define FMTCONSEG "\tSEGMENT {\n" #define FMTBUSTAP "\tBUSTAP {\n" #define FMTCONSEGTYPE "\t\tTYPE = %s ;\n" #define FMTPOLY "\tPOLYGON {\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 FMTMODE "\t\tMODE = %d ;\t/* %s */\n" #define FMTSIZE "\t\tSIZE = %12.*f ;\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 FMTCONSEGSTART "\t\tSTART ( %12.*f , %12.*f ) ;\n" #define FMTCONSEGEND "\t\tEND ( %12.*f , %12.*f ) ;\n" #define FMTATTFT "\t\t}\n" #define FMTELEMFT "\t}\n" #define FMTATTR "\t\tATTRIBUTE \"%s\" = \"%s\" ;\n" #define FMTVATTR "\t\tATTRIBUTE \"%s\" VARIANT %d = \"%s\" ;\n" #define FMTNAMEMOVE "\t\tNAMEMOVE {\n" #define FMTATTRMOVE "\t\tATTRMOVE \"%s\" {\n" #define FMTMSIZE "\t\t\tSIZE = %7.3f ;\n" #define FMTMPOSX "\t\t\tXOFFSET = %7.3f ;\n" #define FMTMPOSY "\t\t\tYOFFSET = %7.3f ;\n" #define FMTMANGLE "\t\t\tANGLEOFFSET = %7.3f ;\n" #define FMTMMIRROR "\t\t\tMIRROROFFSET = %d ;\t/* %s */\n" #define FMTPRULES "\tPROJECT RULES {\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 = 4 /* Double output precision */; int POLYSTYLE = bae_iniintval(PAR_DUMPPOLY,0) /* Polygon point list output style */; #define ITMAUNITS "DEGREE" #define ITMPLAN "SHEET" #define ITMSYMBOL "SYMBOL" #define ITMLABEL "LABEL" #define ITMMARKER "MARKER" #define ITMBUS "BUS" #define ITMSTD "STD" #define ITMCMT "CMT" #define ITMMIRRON "MIRROR ON" #define ITMMIRROFF "MIRROR OFF" #define POINTTYP0 "STANDARD" // Point type standard #define POINTTYP1 "ARC CENTER LEFT" // Point type arc left #define POINTTYP2 "ARC CENTER RIGHT" // Point type arc right #define POLYTYP1 "GRAPHIC LINE" // Polygon type graphic line #define POLYTYP2 "GRAPHIC AREA" // Polygon type graphic area #define POLYTYP3 "CONTACT AREA" // Polygon type contact area #define POLYTYP4 "DOT LINE" // Polygon type dotted line // Globals string DMPEXT = bae_inistrval(PAR_DUMPFEXT,".dmp") /* File name extension */; string SYMGRP = bae_inistrval(PAR_SYMGRP,"") /* Symbol group name */; string SYMLIB = bae_inistrval(PAR_SYMLIB,"") /* Symbol group library file */; int outfh /* Output file handle */; STRINGS m_names /* Macro name list */; int m_classes[] /* Macro plan 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 curxs, curys /* Current start coordinates */; double curxe, curye /* Current end coordinates */; double currx, curry /* Current reference coordinates */; double curra /* Current reference angle */; int currmirror /* Current reference mirror flag */; int curptyp /* Current point type */; double cura = 0.0 /* Current angle (default: 0.0) */; STRINGS rl /* Current rule list */; int rn /* Current rule count */; STRINGS nilsl = {""} /* Initialyzed string list */; int curint /* Current integer value */; int curflag /* Current boolean value */; int curtmode /* Current text mode */; int curcontyp /* Current connection type */; int curpolytyp /* Current polygon typ */; int curmirror /* Current mirror flag */; int curabsmove /* Current absolute move 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 */; struct attrdes { // Attribute value descriptor string name /* Attribute name */; string val /* Attribute value */; } attrl[] /* Attribute list */; int attrn = 0 /* Attribute 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) */; #define MSGEXT "_s.lst" // Message file name extension #define DEFEXT ".def" // Definition 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 */; // Main program void main() { string msg /* Message string */; string jobfname /* Job file name */; string jobename /* Job element name */; int jobclass /* Job class */; string outfname /* Output file name */; int outelem /* Output elements */; index C_MACRO macro /* Macro index */; int editcap /* Edit capability flag */; int opmode /* Operation mode */; int filemode /* File mode */; string startdir /* Start directory */; string fname /* File name */; string ename = "" /* Current element name */; string macname /* Macro name */; int macclass /* Macro class */; int autoproj /* Automatic project processing */; int len /* String length */; int i /* Loop control variable */; 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 symbol library name if (SYMLIB=="") SYMLIB=scm_deflibname(); // Get and check the process mode bae_promptdialog(UPRPROCMODE); switch (bae_askmenu(3,UPRPROCDIR,UPRPROCSFILE,UPRABORT)) { case 0 : // Select source directory startdir=UINPOPABORT; if (bae_askdirname(startdir,getcwd(),UPRTDIR)!=0 || startdir==UINPOPABORT) error_abort(); // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Scan the directory len=strlen(startdir)-1; if (startdir[len]=='/' || startdir[len]=='\\') startdir[len]='\0'; fname=""; while (scandirfnames(startdir,DMPEXT,fname)==1) // Process the dump file procfile(startdir+bae_swversion(4)+fname,0); break; case 1 : // Check if automatic project processing autoproj= bae_peekiact() ? 1 : 0 ; // Get the BAE ASCII dump file name if (bae_askfilename(dmpfname,DMPEXT,UPRDMPFILE) || dmpfname=="") error_abort(); // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Process the file procfile(dmpfname,autoproj); break; default : error_abort(); } // Print done message bae_prtdialog(REPDONE); exit(0); } // Abort if invalid plan class if ((jobclass=bae_planddbclass())==DDBCLUNDEF) error_class(); // Perform BAE Demo check with abort option BAE_Demo_check(2); // Get the plan file and element names jobfname=bae_planfname(); jobename=bae_planename(); // Check if text edit window support editcap= bae_swconfig(3)==BAE_StdScreen ? 0 : 1; // Select the output elements and destination bae_promptdialog(UPRELEM); switch (bae_askmenu(editcap ? 7 : 4,UPRELEM1,UPRELEM2,UPRELEM3, editcap ? UPRELEM4 : UPRABORT,UPRELEM5,UPRELEM6,UPRABORT)) { // Project to file case 0 : outmode=1; outelem=1; filemode=1; break; // Plan with library to file case 1 : outmode=1; outelem=1; filemode=0; break; // Plan to file case 2 : outmode=1; outelem=0; filemode=0; break; // Project to screen case 3 : if (!editcap) exit(0); outmode=0; outelem=1; filemode=1; break; // Plan with library to screen case 4 : if (!editcap) exit(0); outmode=0; outelem=1; filemode=0; break; // Plan to screen case 5 : if (!editcap) exit(0); outmode=0; outelem=0; filemode=0; break; // Abort default : exit(0); } if (outelem || filemode) // Save current element with verification on request verifysave(); // Check output mode if (outmode) { // Build the output file name outfname=convstring(jobfname,0)+DMPEXT; // Open the output file outfh=bae_fopen(outfname,1); } // Print the output file header if (outmode) fprintf(outfh,FMTHEADER,jobfname); else sprintf(outstr,FMTHEADER,jobfname); // Print the units definition if (outmode) { fprintf(outfh,FMTLUNITS,2,bae_plainmenutext(UNITSMM)); fprintf(outfh,FMTAUNITS,1,ITMAUNITS); } else { sprintf(outbuf,FMTLUNITS,2,bae_plainmenutext(UNITSMM)); outstr+=outbuf; sprintf(outbuf,FMTAUNITS,1,ITMAUNITS); outstr+=outbuf; } // Close header block if (outmode) fprintf(outfh,FMTELEMFT); else outstr+=FMTELEMFT; // Loop for all plans while (filemode==0 || scanddbenames(jobfname,DDBCLSCM,ename)==1) { // Load next plan if (filemode && bae_planename()!=ename) { bae_setintpar(22,1); loadddbelem(bae_planfname(),ename,DDBCLSCM); } // Update the macro list if (outelem) forall (macro) { // Check if macro already defined macname=macro.NAME; macclass=macro.CLASS; for (i=0;i=m_cnt) { // Store the macro name m_names[m_cnt]=macro.NAME; // Store the macro plan class m_classes[m_cnt]=macro.CLASS; // Increment the macro count m_cnt++; } } // Dump the current element dumpelem(outfh); // Check if single sheet process mode if (!filemode) break; } // Loop thru the macro list for (i=0;i=0) dispfigrules(fh,fig); if (outmode) { fprintf(fh,FMTATTFT); } else { docstr+=FMTATTFT; outstr+=docstr; } } // Loop thru the named reference label list forall (fig where fig.TYP==C_FIGNREF && fig.NREF.MACRO.CLASS==DDBCLSLAB) { n=fig.NREF; // Print the info if (outmode) fprintf(fh,FMTNREF,macclname(n.MACRO.CLASS)); else sprintf(docstr,FMTNREF,macclname(n.MACRO.CLASS)); // Print the glued info if (fig.FIXED&2) { if (outmode) fprintf(fh,FMTGLUED); else docstr+=FMTGLUED; } if (outmode) { fprintf(fh,FMTMACRO,n.MACRO.NAME); fprintf(fh,FMTNAME,n.NAME); fprintf(fh,FMTPOSX,PREC,cvtl(n.X-nx)); fprintf(fh,FMTPOSY,PREC,cvtl(n.Y-ny)); fprintf(fh,FMTANGLE,cvtangle(n.ANGLE,0,1)); fprintf(fh,FMTMIRROR,n.MIRROR, (n.MIRROR ? ITMMIRRON : ITMMIRROFF)); } else { sprintf(outbuf,FMTMACRO,n.MACRO.NAME); docstr+=outbuf; sprintf(outbuf,FMTNAME,n.NAME); docstr+=outbuf; sprintf(outbuf,FMTPOSX,PREC,cvtl(n.X-nx)); docstr+=outbuf; sprintf(outbuf,FMTPOSY,PREC,cvtl(n.Y-ny)); docstr+=outbuf; sprintf(outbuf,FMTANGLE,cvtangle(n.ANGLE,0,1)); docstr+=outbuf; sprintf(outbuf,FMTMIRROR,n.MIRROR, (n.MIRROR ? ITMMIRRON : ITMMIRROFF)); docstr+=outbuf; } forall (rtm of n) { if (outmode) { if (rtm.MODE==0) fprintf(fh,FMTNAMEMOVE); else fprintf(fh,FMTATTRMOVE,rtm.STR); fprintf(fh,FMTMSIZE,cvtl(rtm.SIZE)); fprintf(fh,FMTMPOSX,cvtl(rtm.X-nx)); fprintf(fh,FMTMPOSY,cvtl(rtm.Y-ny)); fprintf(fh,FMTMANGLE,cvtangle(rtm.ANGLE,0,1)); fprintf(fh,FMTMMIRROR,rtm.MIRROR, (rtm.MIRROR ? ITMMIRRON : ITMMIRROFF)); fprintf(fh,FMTRULESEND); } else { if (rtm.MODE==0) { docstr+=FMTNAMEMOVE; } else { sprintf(outbuf,FMTATTRMOVE,rtm.STR); docstr+=outbuf; } sprintf(outbuf,FMTMSIZE, cvtl(fabs(rtm.SIZE))); docstr+=outbuf; sprintf(outbuf,FMTMPOSX,cvtl(rtm.X-nx)); docstr+=outbuf; sprintf(outbuf,FMTMPOSY,cvtl(rtm.Y-ny)); docstr+=outbuf; sprintf(outbuf,FMTMANGLE, cvtangle(rtm.ANGLE,0,1)); docstr+=outbuf; sprintf(outbuf,FMTMMIRROR,rtm.MIRROR, (rtm.MIRROR ? ITMMIRRON : ITMMIRROFF)); docstr+=outbuf; docstr+=FMTRULESEND; } } 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 C_FIGURE fig /* Figure list index */; index C_TEXT t /* Text index */; // Loop thru the text list forall (fig where fig.TYP==C_FIGTEXT) { t=fig.TEXT; // Print the info if (outmode) fprintf(fh,FMTTEXT); else docstr=FMTTEXT; // 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, (t.MODE&TEXTCOMM) ? ITMCMT : ITMSTD); 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, (t.MODE&TEXTCOMM) ? ITMCMT : ITMSTD); 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 conlist(int fh,double nx,double ny) /* // Connection element list function // Parameters : // int fh : Output file handle // double nx : Origin X coordinate // double ny : Origin Y coordinate */ { index C_CONSEG seg /* Connection segment index */; index C_BUSTAP bustap /* Connection bus tap */; // Loop thru the segment list forall (seg) { // Print the info if (outmode) fprintf(fh,FMTCONSEG); else docstr=FMTCONSEG; // Print the glued info if (seg.ATTRIB&0x40) { if (outmode) fprintf(fh,FMTGLUED); else docstr+=FMTGLUED; } if (outmode) { fprintf(fh,FMTCONSEGTYPE,seg.BUSFLAG ? ITMBUS : ITMSTD); fprintf(fh,FMTCONSEGSTART, PREC,cvtl(seg.X1-nx),PREC,cvtl(seg.Y1-ny)); fprintf(fh,FMTCONSEGEND, PREC,cvtl(seg.X2-nx),PREC,cvtl(seg.Y2-ny)); } else { sprintf(outbuf,FMTCONSEGTYPE, seg.BUSFLAG ? ITMBUS : ITMSTD); outstr+=outbuf; sprintf(outbuf,FMTCONSEGSTART, PREC,cvtl(seg.X1-nx),PREC,cvtl(seg.Y1-ny)); outstr+=outbuf; sprintf(outbuf,FMTCONSEGEND, PREC,cvtl(seg.X2-nx),PREC,cvtl(seg.Y2-ny)); outstr+=outbuf; } if (seg.RULEOBJID>=0) dispconrules(fh,seg); if (outmode) { fprintf(fh,FMTATTFT); } else { docstr+=FMTATTFT; outstr+=docstr; } } // Loop thru all bus taps forall (bustap) { // Print the info if (outmode) { fprintf(fh,FMTBUSTAP); fprintf(fh,FMTMACRO,bustap.MACRO.NAME); fprintf(fh,FMTNAME,bustap.NAME); fprintf(fh,FMTPOSX,PREC,cvtl(bustap.X-nx)); fprintf(fh,FMTPOSY,PREC,cvtl(bustap.Y-ny)); fprintf(fh,FMTANGLE,cvtangle(bustap.ANGLE,0,1)); fprintf(fh,FMTMIRROR,bustap.MIRROR, (bustap.MIRROR ? ITMMIRRON : ITMMIRROFF)); fprintf(fh,FMTATTFT); } else { docstr=FMTBUSTAP; sprintf(outbuf,FMTMACRO,bustap.MACRO.NAME); docstr+=outbuf; sprintf(outbuf,FMTNAME,bustap.NAME); docstr+=outbuf; sprintf(outbuf,FMTPOSX,PREC,cvtl(bustap.X-nx)); docstr+=outbuf; sprintf(outbuf,FMTPOSY,PREC,cvtl(bustap.Y-ny)); docstr+=outbuf; sprintf(outbuf,FMTANGLE,cvtangle(bustap.ANGLE,0,1)); docstr+=outbuf; sprintf(outbuf,FMTMIRROR,bustap.MIRROR, (bustap.MIRROR ? ITMMIRRON : ITMMIRROFF)); 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 C_FIGURE fig /* Figure list index */; index C_POLY poly /* Polygon index */; index C_POINT p /* Point index */; // Loop thru the polygon list forall (fig where fig.TYP==C_FIGPOLY) { poly=fig.POLY; // Print the info if (outmode) fprintf(fh,FMTPOLY,poly.TYP,poly.PN); else sprintf(docstr,FMTPOLY,poly.TYP,poly.PN); // 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)); } else { sprintf(outbuf,FMTPOLYTYPE,poly.TYP,polytype(poly.TYP)); 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 (!outmode) outstr+=docstr; if (fig.RULEOBJID>=0) dispfigrules(fh,fig); if (outmode) { fprintf(fh,FMTATTFT); } else { docstr+=FMTATTFT; outstr+=docstr; } } } 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 (bae_planddbclass()==DDBCLSCM && (rnc=cap_getrulecnt(RS_OCSCMDB,0))>0) { if (outmode) fprintf(fh,FMTPRULES); else docstr=FMTPRULES; // Scan the rule name list for (i=0;i0) { 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;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 an element start // 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(); switch (elemclass) { case DDBCLSSYM : bae_storemenuiact(1,1,LMB); break; case DDBCLSLAB : bae_storemenuiact(1,2,LMB); break; case DDBCLSMRK : bae_storemenuiact(1,3,LMB); break; case DDBCLSCM : default : bae_storemenuiact(1,0,LMB); } bae_storetextiact(1,ddbfname); bae_storetextiact(1,curname); if (bae_plannotsaved()) bae_storetextiact(1,M_UINYES()); switch (elemclass) { case DDBCLSSYM : case DDBCLSLAB : bae_storetextiact(1,"m"); break; case DDBCLSMRK : break; case DDBCLSCM : default : bae_storemenuiact(1,14,LMB); } bae_storetextiact(1,"1"); bae_storetextiact(1,"1"); bae_setintpar(22,1); call(MNU_SCMCREELEM); bae_setintpar(22,0); // Set own file as library to avoid label macro mismatch bae_clriactqueue(); bae_storetextiact(1,ddbfname); bae_callmenu(MNU_SCMPARSLIB); // 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_SCMPARUBND); // Set element origin bae_storemouseiact(1,curnx,curny,2,LMB); bae_callmenu(MNU_SCMPARORIG); // Set lower element boundary bae_storemouseiact(1,curlx+curnx,curly+curny,2,LMB); bae_callmenu(MNU_SCMPARLBND); // Set upper element boundary bae_storemouseiact(1,curux+curnx,curuy+curny,2,LMB); bae_callmenu(MNU_SCMPARUBND); // Perform the create element call if (elemclass==DDBCLSSYM && SYMGRP!="") { bae_clriactqueue(); bae_storetextiact(1,SYMLIB); bae_storetextiact(1,SYMGRP); bae_storemouseiact(1,curnx,curny,0,LMB); call(MNU_SCMLOADGRP); call(MNU_SCMGRPRESE); } 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_SCMSAVELEM); 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_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=""; // Reset rule list rl=nilsl; rn=0; rmodn=0; attrn=0; bae_clearpoints(); // 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; curabsmove=absmove; curstr=""; // Return without errors return(0); } int p_rule() /* // Receive a rule definition // Return value : // zero if done or (-1) on error */ { if (rn>0 && curstr=="';") { rl[rn-1]+="\"\"';"; } else { rl[rn]=curstr; rn++; } // 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 0 : lenconv=cvtlength(1.0,0,0); break; // Inch case 1 : lenconv=cvtlength(1.0,1,0); break; // mm case 2 : lenconv=cvtlength(1.0,2,0); break; // mil case 3 : lenconv=cvtlength(1.0,3,0); break; // um case 4 : lenconv=cvtlength(1.0,4,0); break; // Implementation gap default : return(-1); } // 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_xs() /* // Receive a start X coordinate // Return value : // zero if done or (-1) on error */ { // Store the current X coordinate curxs=curcoord+curnx; // Return without errors return(0); } int p_ys() /* // Receive a start Y coordinate // Return value : // zero if done or (-1) on error */ { // Store the current Y coordinate curys=curcoord+curny; // Return without errors return(0); } int p_xe() /* // Receive a end X coordinate // Return value : // zero if done or (-1) on error */ { // Store the current X coordinate curxe=curcoord+curnx; // Return without errors return(0); } int p_ye() /* // Receive a end Y coordinate // Return value : // zero if done or (-1) on error */ { // Store the current Y coordinate curye=curcoord+curny; // 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_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_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_textmode(int textmode) /* // Receive a text mode // Return value : // zero if done or (-1) on error // Parameter : // int textmode : Text mode */ { curtmode= textmode==2 ? curint : textmode ; // 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_mirror() /* // Receive a mirror mode // Return value : // zero if done or (-1) on error */ { curmirror=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_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_symbol() /* // Receive a symbol end // Return value : // zero if done or (-1) on error */ { if (!curproc) // Return without errors return(0); if (scm_storepart(currefname,curmacro,currx,curry,curra,currmirror)) fprintf(mfh,ERRPLCSYMBOL, dmpfname,synscanline(),currefname,curmacro); else endplc(); // Return without errors return(0); } int p_label(int labtyp) /* // Receive a label end // Return value : // zero if done or (-1) on error // Parameter : // int labtyp : Label type */ { string oldmacname /* Old label macro name */; if (!curproc) // Return without errors return(0); oldmacname= baepar_strval(labtyp==0 ? SCMPAR_LABELMACRO : SCMPAR_BUSTAPMACRO); bae_clriactqueue(); bae_storetextiact(1,curmacro); bae_callmenu(labtyp==0 ? 809 : 810); if (scm_storelabel(currefname,labtyp,currx,curry,curra,currmirror)) fprintf(mfh,ERRPLCSYMBOL, dmpfname,synscanline(),currefname,curmacro); else endplc(); bae_clriactqueue(); bae_storetextiact(1,oldmacname); bae_callmenu(labtyp==0 ? 809 : 810); // 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) // 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_SCMSUBJ,RS_MTEXTID,textid,mtextcnt); sprintf(rl[brn+2],":%s:%s=%d;", RS_SCMSUBJ,RS_MTEXTROW,0); sprintf(rl[brn+3],":%s:%s=%.2f;", RS_SCMSUBJ,RS_MTEXTLS,1.0); rn+=4; mtextcnt++; } sprintf(rl[brn+1],":%s:%s=%d;",RS_SCMSUBJ,RS_MTEXTCOL,textcol); // Get the length limited substring substr=strextract(curtext,0,MAXKEYLEN-1); // Store the text if (scm_storetext( substr,curx,cury,cura,cursize,curmirror,curtmode)) 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_SCMSUBJ,RS_MTEXTCOL,textcol); if (scm_storetext(curtext,curx,cury,cura,cursize, curmirror,curtmode)) 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 */ { if (!curproc) // Return without errors return(0); if (scm_storepoly(curpolytyp)) fprintf(mfh,ERRPLCPOLY,dmpfname,synscanline()); else endplc(); // Return without errors return(0); } int p_connection() /* // Receive a path end // Return value : // zero if done or (-1) on error */ { if (!curproc) // Return without errors return(0); bae_clearpoints(); bae_storepoint(curxs,curys,curcontyp); bae_storepoint(curxe,curye,0); if (scm_storecon()) fprintf(mfh,ERRPLCCON,dmpfname,synscanline()); // Return without errors return(0); } int p_contyp(int contyp) /* // Receive a connection segment type // Return value : // zero if done or (-1) on error // Parameter : // int contyp : Connection segment type */ { curcontyp=contyp; // Return without errors return(0); } int p_block(int blktyp) /* // Receive a block name and type // Return value : // zero if done or (-1) on error // Parameter : // int blktyp : Block type */ { if (!curproc) // Return without errors return(0); // Set block data bae_clriactqueue(); bae_storemenuiact(1,blktyp,LMB); bae_storetextiact(1,curstr); call(801); // Return without errors return(0); } int p_namepattern() /* // Receive a name pattern // Return value : // zero if done or (-1) on error */ { if (curproc) { // Set new symbol name pattern bae_clriactqueue(); bae_storetextiact(1,curstr); bae_callmenu(MNU_SCMPNAMPAT); } // Return without errors return(0); } int p_comment() /* // Receive an element comment // Return value : // zero if done or (-1) on error */ { if (curproc) bae_setstrpar(0,curstr); // Return without errors return(0); } int p_planrules(int globflag) /* // Receive plan rules // Return value : // zero if done or (-1) on error // Parameter : // int globflag : Global rules flag */ { if (curproc && rn>0) // Attach rules cap_ruleplanatt(rl,globflag); // Return without errors return(0); } int p_attrname() /* // Receive an attribute name // Return value : // zero if done or (-1) on error */ { if (curproc) attrl[attrn].name=curstr; // Return without errors return(0); } int p_attrvar() /* // Receive an attribute variant spec. // Return value : // zero if done or (-1) on error */ { if (curproc) attrl[attrn].name=varattrname(attrl[attrn].name,curint); // Return without errors return(0); } int p_attrval() /* // Receive an attribute value // Return value : // zero if done or (-1) on error */ { if (curproc) { attrl[attrn].val=curstr; attrn++; } // 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].str= attrmove ? curstr : "$" ; rmodl[rmodn].x=curx; rmodl[rmodn].y=cury; rmodl[rmodn].ang=cura; rmodl[rmodn].mirr=curmirror; rmodl[rmodn].size=cursize; rmodl[rmodn].absmove=curabsmove; rmodn++; } // Return without errors return(0); } void endplc() // End element placement { index C_FIGURE nfig /* New figure list index */; index C_NREF nref /* Named reference */; index C_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 (rn>0 && cap_lastfigelem(nfig)==0) // Attach rules cap_rulefigatt(nfig,rl); for (i=0;i