/* SLIBDOC (SCM) -- SCM Library Documentation */ /* SLIBDOC (SCM) -- SCM-Bibliotheksdokumentation */ /* // Copyright (c) 1993-2012 Oliver Bartels F+E, Muenchen // Author: Manfred Baumeister // Changes History: // rl (120427) RELEASED FOR BAE V7.8. // rl (110719) ENHANCEMENT: // Added default value documentation option. // rl (101019) RELEASED FOR BAE V7.6. // rl (091021) RELEASED FOR BAE V7.4. // rl (081014) RELEASED FOR BAE V7.2. // rl (081014) ENHANCEMENT: // Added bae.ini settings writeback dialog button. // rl (071029) RELEASED FOR BAE V7.0. // rl (070618) ENHANCEMENT: // Added element comment creation. // rl (060829) RELEASED FOR BAE V6.8. // rl (060811) ENHANCEMENT: // Added symbol macro and pattern name documentation options. // rl (060220) BUGFIX: // Fixed placement problem for symbols placed on a different // plan in previous documentation runs. // rl (060131) ENHANCEMENT: // Added directory process mode. // Added alternate destination file option. // rl (050906) RELEASED FOR BAE V6.6. // rl (040811) RELEASED FOR BAE V6.4. // rl (030904) RELEASED FOR BAE V6.2. // rl (030604) ENHANCEMENT: // Added symbol naming by macro pattern option. // rl (021209) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (020226) ENHANCEMENT: // Added support for special name text modes. // rl (010709) RELEASED FOR BAE V5.0. // rl (010528) BUGFIX: // Fixed problem with disfunctional sheet existance check. // rl (010502) ENHANCEMENT: // Added optional parameter settings from bae.ini file. // Removed obsolete DEBUG option (pool purge problem // with scm_storepart is fixed). // rl (010118) ENHANCEMENT: // Optimized symbol placement. // Improved error handling. // rl (000710) RELEASED FOR BAE V4.6. // rl (991216) ENHANCEMENT: // Symbol numbered naming option introduced. // rl (991124) RELEASED FOR BAE V4.4. // rl (981012) RELEASED FOR BAE V4.2. // mb (980710) ENHANCEMENT: // Pulldown menu delimiters introduced. // mb (980710) ENHANCEMENT: // Dynamic multi-language support introduced. // rl (970929) RELEASED FOR BAE V4.0. // mb (970211) ENHANCEMENT: // Introduced HP-Laser, HP-GL plot output features // (psplotsheets function replaced by plotsheets), // Symbol placement with scm_storepart unless Compiler // directive DEBUG is active whereas: // Symbol placement with menu call to force pool purge // before each sheet generation (SCM symbols are kept // in pool thus provocating memory overflow on large // libraries and/or causing wrong macro access when // running slibdoc on different libraries with equal // symbol name references). // mb (970205) CHANGE/BUGFIX: // Reset default symbol placement angle and mirror mode // before placing symbols. // mb (960919) RELEASED FOR BAE V3.4. // mb (950730) IMPROVEMENT: // Changed menu items to support key selection // in Windows/Motif user interfaces. // mb (951012) IMPROVEMENT: // Run psplotsheets() only if not in BAE Demo. // mb (950911) IMPROVEMENT: // Introduced sheet naming with %02d numbering format in order // to provide sorted sheet list on subsequent sheet accesses. // mb (950911) IMPROVEMENT/BUGFIX: // Symbol placement with menu call to force pool purge // before each sheet generation (SCM symbols are kept // in pool thus provocating memory overflow on large // libraries and/or causing wrong macro access when // running slibdoc on different libraries with equal // symbol name references). // mb (95) RELEASED FOR BAE V3.2. // mb (941129) IMPROVEMENT: // Introduced feature for program abort on key hit. // mb (94) RELEASED FOR BAE V3.0. // mb (94) ENHANCEMENT: // Introduced Label type documentation facility // (additional to symbol type; type selection by menu). // Introduced Symbol Selection by Name Pattern. // mb (93) RELEASED FOR BAE V2.6. // mb (93) ORIGINAL CODING. // // DESCRIPTION // // The slibdoc User Language program is an SCM library management // program intended for documentation purposes. slibdoc automatically // places SCM symbols or SCM labels of a freely selectable DDB file // onto superior SCM database hierarchy level elements. Different // standard sheet formats are supported including automatic legend // box generation with library file name and sheet number denotion. // The symbols to be included with the library documentation can be // selected by symbol name pattern (wildcard). Symbols are aligned to // horizontal base lines and text is placed with each symbol in order to // denote the symbol name. Batch-driven plot generation may be performed // optionally in order to produce library documentation output. */ // Includes #include "mnu.ulh" // User Language menu utilities #include "scm.ulh" // User Language SCM utilities // Disable undo state request #pragma ULCALLERNOUNDO // INI file parameter name definitions #define PAR_PLOTDEV "PLOTDEV_SCM" // Online plot device name #define PAR_HPGLPEN1 "HPGLPEN_SCM" // HPGL Pen name #define PAR_PREFSYM "SNPREFSYM_SCM" // Symbols sheet name prefix #define PAR_PREFLAB "SNPREFLAB_SCM" // Labels sheet name prefix #define PAR_SYMDOUT "SYMDOUT_SCM" // Symbol output flag #define PAR_LABDOUT "LABDOUT_SCM" // Label output flag #define PAR_SYMMPAT "SYMMPAT_SCM" // Symbol macro name pattern #define PAR_SYMDEFV "SYMDEFVAL_SCM" // Symbol default value set #define PAR_SDSHEET "SDSHEET_SCM" // Symbol sheet page format #define PAR_SDPMODE "SDPMODE_SCM" // Symbol sheet process mode #define PAR_SDDEST "SDDEST_SCM" // Symbol sheet destination mode #define PAR_SYMNNAME "SYMNNAME_SCM" // Symbol numbered names flag #define PAR_SYMNDOC "SYMNDOC_SCM" // Symbol name documentation text flag #define PAR_SYMNPAT "SYMNPAT_SCM" // Symbol name pattern text flag #define PAR_SYMNPREF "SYMNNPREF_SCM" // Symbol numbered names prefix #define PAR_SHNPREFLIB "SHNPREFLIB_SCM"// Sheet names with lib.pref. flag #define PAR_FOOTERH "FOOTERH_SCM" // Footer height #define PAR_HSHIFT "PHSIFHT_SCM" // Part horizontal shift #define PAR_VSHIFT "PVSHIFT_SCM" // Part vertical shift #define PAR_FTXTS "FTXTS_SCM" // Footer text size #define PAR_LTXTS "LTXTS_SCM" // Label name text size #define PAR_BEL "BELDOC_SCM" // Boundary enlarge length #define PAR_XPLTOFF "XPLTOFF_SCM" // X online plot offset #define PAR_YPLTOFF "YPLTOFF_SCM" // Y online plot offset // Hardware specific plot device definitions string PLOTDEV = bae_inistrval(PAR_PLOTDEV,"prn") /* Online plot device name */; string HPGLPEN1 = bae_inistrval(PAR_HPGLPEN1,"1") /* HPGL Pen name */; // Messages string UPRABORT = M_UPRABORT(); string UPRPEXIT = M_UPRPEXIT(); string REPSTART = M("SCM-Bibliotheks-Dokumentation:", "SCM Library Documentation:"); string REPSHEET = M("SCM-Bibliothek '%s': %sblatt '%s' erzeugt.", "SCM Library '%s': %s Sheet '%s' generated."); string REPSYMCNT = M("%d %s platziert.","%d %s placed."); string REPLSTSYMS = M("Erzeugen der Symbol-Liste (Abbruch mit Tastendruck)...", "Building the symbol list (hit any key to abort)..."); string REPPLCSYMS = M("Platzieren der Symbole (Abbruch mit Tastendruck)...", "Placing the symbols (hit any key to abort)..."); string REPHPGLOUT = M("HP-GL-Ausgabe...", "HP-GL output in progress..."); string REPPOSTOUT = M("PostScript-Ausgabe...", "PostScript output in progress..."); string REPPCLOUT = M("HP Laser/PCL-Ausgabe...", "HP Laser/PCL output in progress..."); string UPROVERWR = M("Existierende Elemente ('%s') ueberschreiben ? ", "Overwrite existing Elements ('%s') ? "); string UPRLIBTYP = M("SCM-Datenbank-Hierarchie-Ebene waehlen!", "Select SCM Database Hierarchy Level!"); string UPRLIBSYM = M("&Symbole","&Symbols"); string UPRLIBLAB = M("&Labels","&Labels"); string UPRSYMPAT = M("Symbolnamens-Pattern (=alle) : ", "Symbol Name Pattern (=all) : "); string UPRELEMS = M("Elemente : ","Elements : "); string UPRPROCMODE = M("Bearbeitungsmodus : ","Process Mode : "); string UPRDSTMODE = M("Ziel : ","Target : "); string UPRSYMPATD = M("Elementnamens-Pattern : ", "Element Name Pattern : "); string UPRSYMNNAME = M("Symbolnamen :","Symbol Names :"); string UPRSYMNNAME1 = M("&Makroname","&Macro Name"); string UPRSYMNNAME2 = M("Laufende &Nummer","&Numbered Symbols"); string UPRSYMNNAME3 = M("&Symbolname Muster","Symbol Name &Pattern"); string UPRSYMNDOC = M("Texte mit Symbolmakronamen", "Texts with Symbol Macro Name"); string UPRSYMNPAT = M("Texte mit Symbolnamensmuster", "Texts with Symbol Name Pattern"); string UPRSYMDEFVAL = M("Defaultwerte eintragen","Set Default Values"); string UPRTEXTHEIGHT = M("Texthoehe :","Text Height :"); string UPRSELLIB = M("SCM-Bibliothek ? ","SCM Library ? "); string UPRSELALT = M("SCM-Zielbibliothek ? ","SCM Target Library ? "); string UPRLIBFILE = M("Bibliotheksdatei","Single Library"); string UPRLIBDIR = M("Bibliotheksverzeichnis","Library Directory"); string UPRALTFILE = M("Alternativdatei/-verzeichnis","Alternate Library/Directory"); string UPRSELLIBDIR = M("Bibliotheksverzeichnis ? ","Library Directory ? "); string UPRSELALTDIR = M("Ausgabeverzeichnis ? ","Output Directory ? "); string UPRSFORMAT = M("Blattformat selektieren!", "Select Sheet Format!"); string UPRSFORMATD = M("Blattformat :","Sheet Format :"); string UPRSFORMAT1 = M("&Hochformat 180*280","&Portrait 180*280"); string UPRSFORMAT2 = M("H&ochformat 160*240","P&ortrait 160*240"); string UPRSFORMAT3 = M("&Querformat 420*300","&Landscape 420*300"); string UPRSFORMAT4 = M("&Querformat 590*420","&Landscape 590*420"); string UPRSFORMAT5 = M("%Plotformat 1&80*280","%Plot Format 1&80*280"); string UPRSFORMAT6 = M("Plotformat 1&60*240","Plot Format 1&60*240"); string UPRSFORMAT7 = M("Plotformat &420*300","Plot Format &420*300"); string UPRSFORMAT8 = M("Plotformat &590*420","Plot Format &590*420"); string UPRPLOTOUT = M("Plotausgabe ? ","Plot Output ? "); string UPRPLOTFMT = M("Plotformat selektieren!","Select Plot Format!"); string UPRPLOTHPGL = M("Plot HP-&GL","Plot HP-&GL"); string UPRPLOTPS = M("Plot &PostScript","Plot &PostScript"); string UPRPLOTPCL = M("Plot &HP Laser/PCL","Plot &HP Laser/PCL"); string UPRPLOTALL = M("ALLE Plaene plotten ? ","Plot ALL Sheets ? "); string UPRPLOTDEV = M("Plot auf Online-Device '"+PLOTDEV+"' ? ", "Plot to Online Device '"+PLOTDEV+"' ? "); string UPRPLOTPLAN = M("Plotten von Plan '","Plot Sheet '"); string ERRLOAD = M("Fehler beim Laden von '%s'!", "Error loading '%s'!"); string ERRPOLY = M("Fehler bei der Polygonerzeugung!", "Error creating polygon!"); string ERRTEXT = M("Fehler bei der Texterzeugung ('%s')!", "Error creating text ('%s')!"); string ERRSYMB = M("Fehler bei der Symbolplatzierung ('%s')!", "Error placing symbol ('%s')!"); string ERRLAB = M("Fehler bei der Labelplatzierung ('%s')!", "Error placing symbol ('%s')!"); string ERRDBLDEFSYM = M("Mehrfach definiertes Symbol '%s'!", "Multiple defined symbol '%s'!"); string WRNSTART = M("WARNUNG: ","WARNING: "); string WRNFONTLOAD = WRNSTART+ M("'%s' - Zeichensatz konnte nicht geladen werden!", "'%s' - cannot load character font!"); string WRNMACROMIS = WRNSTART+ M("'%s' - Makros fehlen/sind vom falschen Typ!", "'%s' - macros are missing or of wrong type!"); string WRNSYMMISFIT = WRNSTART+ M("Symbol '%s' passt nicht auf den Plan!", "Symbol '%s' does not fit to page!"); // Output management int DDBCLASS /* Symbol or label DDB class code */; string SHNPREFSYM = bae_inistrval(PAR_PREFSYM,"sym_") /* Symbols sheet name prefix */; string sympchkpattern /* Symbol plan name check pattern */; string SHNPREFLAB = bae_inistrval(PAR_PREFLAB,"lab_") /* Labels sheet name prefix */; string labpchkpattern /* Label plan name check pattern */; int SYMNNAME = bae_iniintval(PAR_SYMNNAME,1) /* Symbol numbered names mode */; int SYMDEFVAL = bae_iniintval(PAR_SYMDEFV,0) /* Symbol default value set mode */; int SYMNDOC = bae_iniintval(PAR_SYMNDOC,0) /* Symbol name documentation text */; int SYMNPAT = bae_iniintval(PAR_SYMNPAT,0) /* Symbol name pattern text */; string SYMNPREF = bae_inistrval(PAR_SYMNPREF,"n") /* Symbol numbered names prefix */; int SHNPREFLIB = bae_iniintval(PAR_SHNPREFLIB,1) /* Sheet names with lib.pref. flag */; string SHNPREFIX /* Sheet name prefix */; string ITEMS /* Items denoter string */; int symflag = bae_iniintval(PAR_SYMDOUT,1) /* Symbol output flag */; int labflag = bae_iniintval(PAR_LABDOUT,1) /* Label output flag */; double FOOTERH = bae_inidblval(PAR_FOOTERH,0.01) /* Footer height */; #define FOOTER "%s / %s %d%c" // Footer format string #define CHRWTOH 32.0/48.0 // Char. width to height factor double HSHIFT = bae_inidblval(PAR_HSHIFT,0.005) /* Part horizontal shift */; double VSHIFT = bae_inidblval(PAR_VSHIFT,0.005) /* Part vertical shift */; double FTXTS = bae_inidblval(PAR_FTXTS,0.006) /* Footer text size */; double LTXTS = bae_inidblval(PAR_LTXTS,0.004) /* Label name text size */; double LTXTW = LTXTS*CHRWTOH /* Label name text char. width */; double SHW /* Sheet width */; double SHH /* Sheet height */; double BEL = bae_inidblval(PAR_BEL,0.005) /* Boundary enlarge length */; double XPLTOFF = bae_inidblval(PAR_XPLTOFF,-0.015) /* X online plot offset */; double YPLTOFF = bae_inidblval(PAR_YPLTOFF,-0.010) /* Y online plot offset */; double XLPLT = XPLTOFF-BEL /* X online plot lower boundary */; double YLPLT = YPLTOFF-BEL /* Y online plot lower boundary */; int PLTFMT /* Plot format flag */; // Globals string LIBFILE /* Library file name */; string LIBFILEP /* Library file name without path */; string LIBFILEU /* Library file upper case */; string DSTFILE /* Destination library file name */; string DSTFILEX /* Library file name without ext. */; string symnamepattern = bae_inistrval(PAR_SYMMPAT,"*") /* Symbol name pattern */; string symname /* Symbol name */; int placecount /* Symbol placement count */; int pltformat = bae_iniintval(PAR_SDSHEET,0) /* Plot format */; int procmode = bae_iniintval(PAR_SDPMODE,1) /* File process mode */; int dstmode = bae_iniintval(PAR_SDDEST,1) /* Destination mode */; struct sheetdes { // Sheet descriptor string sn /* Sheet name */; int frow /* Sheet first row */; } sheets[] /* Sheet list */; int sheetn /* Sheet count */; struct rowdes { // Row descriptor int shn /* Row sheet number */; int rfp /* Row first symbol index */; double rh /* Row height */; double rb /* Row base y coordinate */; } rows[] /* Row list */; int rown /* Row count */; struct symboldes { // Symbol descriptor string pn /* Symbol name */; string npat /* Symbol name pattern */; double xoff,yoff /* Symbol placement offset */; double sizex,sizey /* Symbol size */; double plcx,plcy /* Symbol placement coords */; int row /* Symbol row number */; int fitflag /* Symbol fit flag */; } symbols[] /* Symbol list */; int symboln /* Symbol count */; struct symboldes NULLSP = { // Symbol initialyzer value "","", 0.0,0.0, 0.0,0.0, 0.0,0.0, -1, 0 }; double curxs /* Current sheet x size */; double curys /* Current sheet y size */; struct defvaldes { // Default attribute value descriptor string name /* Attribute name */; string val /* Attribute value */; } defvall[] /* Default value list */; int defvaln /* Default value count */; STRINGS msgs /* Message list */; int msgn = 0 /* Message count */; // Main program void main() { string srcdir /* Scan source directory name */; string dstdir /* Destination directory name */; string sfname = "" /* Source file name */; string dfname /* Destination file name */; double pcol = 20.0 /* Parameter column */; double cy = DIAL_TOPMARG /* Dialog box current y coordinate */; int res /* Dialog box result */; int varidx /* INI variable index */; int repflag /* Dialog box repeat flag */; int symidx = (-1) /* Symbol dialog box item idx. */; int labidx = (-1) /* Label dialog box item idx. */; int fmtidx = (-1) /* Plot format dialog box item idx. */; int patidx = (-1) /* Name patt. dialog box item idx. */; int pmidx = (-1) /* File proc. dialog box item idx. */; int snidx = (-1) /* Name mode dialog box item idx. */; int mtidx = (-1) /* Macro name dialog box item idx. */; int ptidx = (-1) /* Name pattern dialog box item idx. */; int thidx = (-1) /* Text height dialog box item idx. */; int dvidx = (-1) /* Def. value dialog box item idx. */; int dstidx = (-1) /* Dest. mode dialog box item idx. */; int len /* Directory name length */; // Save current element with verification on request verifysave(); // Check if dialog box support if (bae_dialclr()) { // Ask for library object type bae_promptdialog(UPRLIBTYP); switch (bae_askmenu(3,UPRLIBSYM,UPRLIBLAB,UPRABORT)) { // SCM symbols case 0 : symflag=1; labflag=0; break; // SCM labels case 1 : symflag=0; labflag=1; break; // Abort on default default : error_abort(); } // Ask for symbol name pattern bae_setmousetext(""); if ((symnamepattern= bae_readedittext(UPRSYMPAT,"*",MAXKEYLEN))=="") // Set the all match pattern symnamepattern="*"; // Check if abort request if (symnamepattern==UINPOPABORT) error_abort(); // Ask for sheet format bae_promptdialog(UPRSFORMAT); if ((pltformat=bae_askmenu(9,UPRSFORMAT1,UPRSFORMAT2, UPRSFORMAT3,UPRSFORMAT4,UPRSFORMAT5,UPRSFORMAT6, UPRSFORMAT7,UPRSFORMAT8,UPRABORT))<0 || pltformat>7) error_abort(); } else { dial_label(0.0,cy,UPRELEMS); symidx=bae_dialaddcontrol(PA_TOGGLE,0,0,symflag, 0.0,0.0,0.0,"",0,DIAL_LEFTMARG+pcol,cy,0.0,UPRLIBSYM); labidx=bae_dialaddcontrol(PA_TOGGLE,0,0,labflag, 0.0,0.0,0.0,"",0,DIAL_LEFTMARG+pcol+15.0,cy,0.0,UPRLIBLAB); cy+=DIAL_CTRVSTEP; // Store name pattern controls dial_label(0.0,cy,UPRSYMPATD); patidx=dial_npatstring(symnamepattern,MAXKEYLEN,pcol,cy); // Store format controls dial_label(0.0,cy,UPRSFORMATD); fmtidx=dial_selbox(pltformat,pcol,cy); dial_sbentry(0,0,UPRSFORMAT1); dial_sbentry(0,1,UPRSFORMAT2); dial_sbentry(0,2,UPRSFORMAT3); dial_sbentry(0,3,UPRSFORMAT4); dial_sbentry(0,4,UPRSFORMAT5); dial_sbentry(0,5,UPRSFORMAT6); dial_sbentry(0,6,UPRSFORMAT7); dial_sbentry(0,7,UPRSFORMAT8); // Store process mode controls dial_label(0.0,cy,UPRPROCMODE); pmidx=bae_dialaddcontrol(PA_RBF,0,0,procmode,0.0,0.0,0.0, "",0,DIAL_LEFTMARG+pcol,cy,0.0,UPRLIBFILE); bae_dialaddcontrol(PA_RBN,1,0,0,0.0,0.0,0.0,"", 0,DIAL_LEFTMARG+pcol+15.0,cy,0.0,UPRLIBDIR); cy+=DIAL_CTRVSTEP; // Store destination mode controls dial_label(0.0,cy,UPRDSTMODE); dstidx=bae_dialaddcontrol(PA_RBF,0,0,dstmode,0.0,0.0,0.0, "",0,DIAL_LEFTMARG+pcol,cy,0.0,UPRLIBFILE); bae_dialaddcontrol(PA_RBN,1,0,0,0.0,0.0,0.0,"", 0,DIAL_LEFTMARG+pcol+15.0,cy,0.0,UPRALTFILE); cy+=DIAL_CTRVSTEP; // Store documentation text controls dial_hsep(cy); dial_label(0.0,cy,UPRSYMNNAME); snidx=dial_selbox(SYMNNAME,pcol,cy); dial_sbentry(0,0,UPRSYMNNAME1); dial_sbentry(0,1,UPRSYMNNAME2); dial_sbentry(0,2,UPRSYMNNAME3); mtidx=dial_toggle(SYMNDOC,pcol,cy,UPRSYMNDOC); ptidx=dial_toggle(SYMNPAT,pcol,cy,UPRSYMNPAT); dial_label(0.0,cy,UPRTEXTHEIGHT); thidx=dial_dist(5,LTXTS,pcol,cy); dvidx=dial_toggle(SYMDEFVAL,pcol,cy,UPRSYMDEFVAL); // Store the OK and abort button with seperator dial_hsep(cy); dial_okabortini(cy,pcol+35.0+DIAL_RIGHTSMARG,1); // Perform the dialog input loop repflag=1; do { // Display dialog box bae_setintpar(16,3032); switch (res=bae_dialaskparams(REPSTART, 0,DIAL_LEFTMARG+pcol+35.0+DIAL_RIGHTSMARG,cy)) { // Done case 0 : case 1 : bae_dialgetdata(symidx,symflag,0.0,""); bae_dialgetdata(labidx,labflag,0.0,""); bae_dialgetdata(patidx,0,0.0,symnamepattern); strlower(symnamepattern); bae_dialgetdata(fmtidx,pltformat,0.0,""); bae_dialgetdata(pmidx,procmode,0.0,""); bae_dialgetdata(dstidx,dstmode,0.0,""); bae_dialgetdata(snidx,SYMNNAME,0.0,""); bae_dialgetdata(mtidx,SYMNDOC,0.0,""); bae_dialgetdata(ptidx,SYMNPAT,0.0,""); bae_dialgetdata(dvidx,SYMDEFVAL,0.0,""); bae_dialgetdata(thidx,0,LTXTS,""); LTXTW=LTXTS*CHRWTOH; if (res==0) { repflag=0; break; } varidx=0; bae_iniflagset(varidx,PAR_SYMDOUT,symflag); bae_iniflagset(varidx,PAR_LABDOUT,labflag); bae_inistrset(varidx,PAR_SYMMPAT, symnamepattern); bae_iniintset(varidx,PAR_SDSHEET,pltformat); bae_iniintset(varidx,PAR_SDPMODE,procmode); bae_iniintset(varidx,PAR_SDDEST,dstmode); bae_iniintset(varidx,PAR_SYMNNAME,SYMNNAME); bae_iniflagset(varidx,PAR_SYMNDOC,SYMNDOC); bae_iniflagset(varidx,PAR_SYMNPAT,SYMNPAT); bae_iniflagset(varidx,PAR_SYMDEFV,SYMDEFVAL); bae_inidimset(varidx,PAR_LTXTS,LTXTS); bae_iniwrite(varidx); break; default : return; } // Stop if no further repeat requests } while (repflag); } // Set the sheet format switch (pltformat) { /* P 180*280 */ case 0 : SHW=0.18; SHH=0.28; PLTFMT=0; break; /* P 160*240 */ case 1 : SHW=0.16; SHH=0.24; PLTFMT=0; break; /* L 420*300 */ case 2 : SHW=0.42; SHH=0.30; PLTFMT=0; break; /* L 590*420 */ case 3 : SHW=0.59; SHH=0.42; PLTFMT=0; break; /* P 180*280 */ case 4 : SHW=0.18; SHH=0.28; PLTFMT=1; break; /* P 160*240 */ case 5 : SHW=0.16; SHH=0.24; PLTFMT=1; break; /* L 420*300 */ case 6 : SHW=0.42; SHH=0.30; PLTFMT=1; break; /* L 590*420 */ case 7 : SHW=0.59; SHH=0.42; PLTFMT=1; break; // Abort on default default : error_abort(); } // Report start msgs[msgn++]=REPSTART; msgs[msgn++]=""; if (procmode) { // Select source directory srcdir=UINPOPABORT; if (bae_askdirname(srcdir,getcwd(),UPRSELLIBDIR)!=0 || srcdir==UINPOPABORT) error_abort(); // Check if alternate destination directory if (dstmode) { dstdir=UINPOPABORT; if (bae_askdirname(dstdir,srcdir,UPRSELALTDIR)!=0 || dstdir==UINPOPABORT) error_abort(); } else { dstdir=srcdir; } // Remove trailing path delimiters len=strlen(srcdir); if (srcdir[len-1]=='\\' || srcdir[len-1]=='/') srcdir[len-1]='\0'; len=strlen(dstdir); if (dstdir[len-1]=='\\' || dstdir[len-1]=='/') dstdir[len-1]='\0'; // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Scan all library files while (scandirfnames(srcdir,DDBEXT,sfname)==1) procfile(srcdir+bae_swversion(4)+sfname, dstdir+bae_swversion(4)+sfname); } else { // Select library file if (bae_askddbfname(sfname,1,UPRSELLIB)) error_abort(); dfname=sfname; // Check if alternate destination file if (dstmode) if (bae_askddbfname(dfname,0,UPRSELALT)) error_abort(); // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); procfile(sfname,dfname); } // Display messages with popup menu if (msgn>2) { bae_setintpar(16,3056); mnu_poptext(msgs,0,0,-1,0,0); } // Plot the sheets if (procmode==0 && msgn>2 && bae_swconfig(1)!=BAE_Demo) plotsheets(); // Done bae_prtdialog(""); } void procfile(string sfn,string dfn) /* // Document file items // Parameters : // string sfn : Source file name // string dfn : Destination file name */ { string ename /* Element name */; int maxlen /* Maximum name length */; char c /* Character buffer */; int i /* Loop control variable */; // Store library file name LIBFILE=sfn; // Get path stripped library file name strlower(LIBFILEP=convstring(LIBFILE,2)); // Upper case the library file name strupper(LIBFILEU=LIBFILEP); if (SHNPREFLIB) { // Check the name prefix maxlen=MAXKEYLEN; if (symflag) maxlen=MAXKEYLEN-4-strlen(SHNPREFSYM); if (labflag && maxlen>(MAXKEYLEN-4-strlen(SHNPREFLAB))) maxlen=MAXKEYLEN-4-strlen(SHNPREFLAB); if (strlen(LIBFILEP)>maxlen) LIBFILEP[maxlen]='\0'; for (i=0;(c=LIBFILEP[i])!='\0';i++) if (isspace(c) || iscntrl(c)) LIBFILEP[i]='_'; // Get the plan name check patterns sympchkpattern=LIBFILEP+"_"+SHNPREFSYM+'*'; labpchkpattern=LIBFILEP+"_"+SHNPREFLAB+'*'; } else { // Get the plan name check patterns sympchkpattern=SHNPREFSYM+'*'; labpchkpattern=SHNPREFLAB+'*'; } // Store destination library file name DSTFILE=dfn; // Get the extension-less destination library file name DSTFILEX=convstring(DSTFILE,0); // Test if top class elements exist already ename=""; while (scanddbenames(DSTFILE,DDBCLSCM,ename)==1) { // Check if library name prefix if (symflag && strmatch(ename,sympchkpattern)) { sprintf(ename,UPROVERWR,sympchkpattern); if (!verify(ename,0)) { // Flush scan cache scanddbenames(DSTFILE,0,""); return; } break; } if (labflag && strmatch(ename,labpchkpattern)) { sprintf(ename,UPROVERWR,labpchkpattern); if (!verify(ename,0)) { // Flush scan cache scanddbenames(DSTFILE,0,""); return; } break; } } // Document symbols if (symflag) { ITEMS=bae_plainmenutext(UPRLIBSYM); DDBCLASS=DDBCLSSYM; SHNPREFIX=SHNPREFSYM; // Build the library contents file buildsymbollist(); // Place the symbols placesymbols(); // Build the sheets buildsheets(); } // Document labels if (labflag) { ITEMS=bae_plainmenutext(UPRLIBLAB); DDBCLASS=DDBCLSLAB; SHNPREFIX=SHNPREFLAB; // Build the library contents file buildsymbollist(); // Place the symbols placesymbols(); // Build the sheets buildsheets(); } } // List management and placement routines void buildsymbollist() /* // Build the symbol list */ { index C_TEXT txt /* Text index */; double namelen /* Name length */; string ename = "" /* Current element name */; double minx, miny /* Symbol frame lower corner */; double maxx, maxy /* Symbol frame upper corner */; int i /* Loop control variable */; // Message bae_prtdialog(REPLSTSYMS); symboln=0; while (scanddbenames(LIBFILE,DDBCLASS,ename)==1) { // Test on program abort request if (kbhit()) { getchr(); if (verify(UPRPEXIT,0)) { // Flush scan cache scanddbenames(LIBFILE,0,""); error_abort(); } else { bae_prtdialog(REPLSTSYMS); } } if (strmatch(ename,symnamepattern)) gcsymbol(ename); } // Get the symbols characteristics for (i=0;imaxy) maxy=txt.Y+0.5*namelen; } // Check if mirrored text else if (txt.MIRROR) { if (txt.Y-namelenmaxy) maxy=txt.Y+namelen; } break; // 180 degree case 2 : // Check if centered text if (txt.MODE&TEXTHCENT) { if (txt.X-0.5*namelenmaxx) maxx=txt.X+0.5*namelen; } else { if (txt.X-namelenmaxy) maxy=txt.Y+0.5*namelen; } // Check if mirrored text else if (txt.MIRROR) { if (txt.Y+namelen>maxx) maxx=txt.X+namelen; } else { if (txt.Y-namelenmaxx) maxx=txt.X+0.5*namelen; } else { if (txt.X+namelen>maxx) maxx=txt.X+namelen; } } } // Store symbol placement data symbols[i].xoff= bae_planwsnx()-bae_planwslx()+mmceil(bae_planwslx()-minx); symbols[i].yoff= bae_planwsny()-bae_planwsly()+mmceil(bae_planwsly()-miny); symbols[i].sizex=mmceil(maxx-minx); symbols[i].sizey=mmceil(maxy-miny)+VSHIFT; if (SYMNDOC) { if (strlen(symbols[i].pn)*LTXTW>symbols[i].sizex) symbols[i].sizex= mmceil(strlen(symbols[i].pn)*LTXTW); symbols[i].sizey+=1.5*LTXTS; } if (SYMNPAT) { scm_getstrpar(5,symbols[i].npat); strupper(symbols[i].npat); if (strlen(symbols[i].npat)*LTXTW>symbols[i].sizex) symbols[i].sizex= mmceil(strlen(symbols[i].npat)*LTXTW); symbols[i].sizey+=1.5*LTXTS; } } // Clear the dialog line bae_prtdialog(""); } void gcsymbol(string pn) /* // Get or create some symbol list entry // Parameters : // string pn : Part name */ { int idx = (-1) /* Insert index */; int i /* Loop control variable */; // Try to find the symbol if (findsymbol(pn,idx)>=0) // Error; multiple defined symbol errormsg(ERRDBLDEFSYM,pn); // Insert the new entry to the symbol list symboln++; for (i=symboln-2;i>=idx;i--) symbols[i+1]=symbols[i]; symbols[idx]=NULLSP; symbols[idx].pn=pn; // Update destination file if (DSTFILE!=LIBFILE) ddbcopyelem(LIBFILE,DSTFILE,DDBCLASS,pn,1); } int findsymbol(string pn,int insidx) /* // Binary search symbol in the symbol list // Return value : // symbol list index or (-1) if not found // Parameters : // string pn : Part name // int insidx : Insert index */ { int slb = 0 /* Search lower boundary */; int sub = symboln-1 /* Search upper boundary */; int idx /* Search index */; int compres /* Compare result */; // Init the insert index insidx=(-1); // Loop until search area empty while (slb<=sub) { // Get the search index idx=(slb+sub)>>1; // Get and test the compare result if ((compres=numstrcmp(pn,symbols[idx].pn))==0) return(idx); // Update the search area if (compres<0) sub=idx-1; else slb=idx+1; } // Set the insert index insidx=slb; // Return the not found code return(-1); } void placesymbols() /* // Place all defined symbols to the sheets */ { int i /* Loop control variables */; // Print message bae_prtdialog(REPPLCSYMS); // Init the current x placement coordinate curxs=SHW; curys=SHH-VSHIFT; rown=0; rows[rown].rh=0.0; sheetn=0; // Loop thru all symbols for (i=0;i SHW-HSHIFT || symbols[i].sizey > SHH-VSHIFT-FOOTERH) { sprintf(msgs[msgn],WRNSYMMISFIT,symbols[i].pn); msgn++; continue; } // Set the symbol fit flag symbols[i].fitflag=1; // Test if symbol or label if (DDBCLASS==DDBCLSSYM) { // Check if this symbol fits to current row if (curxs+symbols[i].sizex+HSHIFT > SHW || (rows[rown].rh!=0.0 && rows[rown].rh=FOOTERH)) { if (rows[rown].rh!=0.0 && rows[rown].rh=FOOTERH) { curys=SHH-VSHIFT; } else { if (curys-rows[rown].rh rows[rown].rh) rows[rown].rh=symbols[i].sizey; // Test if symbol object type if (DDBCLASS==DDBCLSSYM) // Update the current row x size curxs+=symbols[i].sizex+HSHIFT; } // Init the current y placement coordinate curys=0.0; // Loop thru all rows for (i=1;i<=rown;i++) { // Test on program abort request if (kbhit()) { getchr(); if (verify(UPRPEXIT,0)) error_abort(); else bae_prtdialog(REPPLCSYMS); } // Check if this row fits to current sheet if ((curys-=(rows[i].rh+VSHIFT)) < FOOTERH) { // Start new sheet sheetn++; sheets[sheetn].frow=i; if (SHNPREFLIB) // Use file name without path sprintf(sheets[sheetn].sn,"%s_%s%02d", LIBFILEP,SHNPREFIX,sheetn); else sprintf(sheets[sheetn].sn,"%s%02d", SHNPREFIX,sheetn); strlower(sheets[sheetn].sn); curys=SHH-rows[i].rh-VSHIFT; } // Place the row to the current sheet rows[i].shn=sheetn; rows[i].rb=curys; } // Clear the dialog line bae_prtdialog(""); } void buildsheets() /* // Create and place all sheets */ { index C_FIGURE fig /* Figure list index */; string planname /* Plan name */; string labname /* Label name */; string footer /* Footer string */; string firstname, lastname /* Element name range */; string ecomment /* Element comment */; double plcx,plcy /* Placement coordinates */; int namelim /* Name length limit */; int i,j,k,l /* Loop control variables */; // Reset the placement counter placecount=0; // Check the footer text length sprintf(footer,FOOTER,LIBFILEU,ITEMS,sheetn,'+'); if (strlen(footer)>MAXKEYLEN) { // Shorten file name namelim=MAXKEYLEN-3-strlen(footer)+strlen(LIBFILEU); LIBFILEU="..."+strextract(LIBFILEU,strlen(LIBFILEU)-namelim, strlen(LIBFILEU)); } // List all sheets for (i=1;i<=sheetn;i++) { // Test on program abort request if (kbhit()) { getchr(); if (verify(UPRPEXIT,0)) error_abort(); } // Delete this element (ignore errors) ddbdelelem(DSTFILE,DDBCLSCM,sheets[i].sn); // Create a new sheet bae_clriactqueue(); bae_storemenuiact(1,0,LMB); bae_storetextiact(1,DSTFILEX); bae_storetextiact(1,sheets[i].sn); if (bae_plannotsaved()) bae_storetextiact(1,M_UINYES()); bae_storemenuiact(1,14,LMB); bae_storetextiact(1,itoa(1000*SHW)); bae_storetextiact(1,itoa(1000*SHH)); bae_setintpar(22,1); call(MNU_SCMCREELEM); bae_setintpar(22,0); firstname=lastname=""; // Set default placement angle/mirror mode bae_clriactqueue(); bae_storemenuiact(1,0,LMB); call(MNU_SCMDEFANGLE); // Set source file as library bae_clriactqueue(); bae_storetextiact(1,LIBFILE); bae_callmenu(MNU_SCMPARSLIB); // Print message bae_prtdialog(REPPLCSYMS); // Create the graphic frame bae_clearpoints(); if (bae_storepoint(0.0,0.0,0) || bae_storepoint(SHW,0.0,0) || bae_storepoint(SHW,SHH,0) || bae_storepoint(0.0,SHH,0) || bae_storepoint(0.0,0.0,0) || scm_storepoly(C_POLYDOCLINE)) error(ERRPOLY); // Create the footer top line bae_clearpoints(); if (bae_storepoint(0.0,FOOTERH,0) || bae_storepoint(SHW,FOOTERH,0) || scm_storepoly(C_POLYDOCLINE)) error(ERRPOLY); // Generate and place the footer text sprintf(footer,FOOTER,LIBFILEU,ITEMS,i,(ii) break; // Loop thru all symbols of the row for (k=rows[j].rfp;kj) break; // Test if symbol fits if (!symbols[k].fitflag) continue; // Set the placement coordinates plcx=symbols[k].plcx+HSHIFT; plcy=rows[j].rb+VSHIFT; lastname=symbols[k].pn; if (firstname=="") firstname=lastname; // Test the object type if (DDBCLASS==DDBCLSSYM) { // Build the symbol name switch (SYMNNAME) { case 1 : symname=SYMNPREF+itoa(k); break; case 2 : symname=""; break; case 0 : symname=lastname; default : } // Check if old symbol was // on different plan if ((planname= cap_partplan(DSTFILE,symname))!="" && planname!=sheets[i].sn && strmatch(planname,sympchkpattern)) // Remove old symbol entry ddbdelelem(DSTFILE, -DDBCLSPLST,symname); // Place the name pattern text if (SYMNPAT) { if (scm_storetext( symbols[k].npat, plcx,plcy,0.0,LTXTS,0,0)) errormsg(ERRTEXT, symbols[k].npat); plcy+=LTXTS*1.5; } // Place the macro name text if (SYMNDOC) { strupper(labname=lastname); if (scm_storetext(labname, plcx,plcy,0.0,LTXTS,0,0)) errormsg(ERRTEXT, labname); plcy+=LTXTS*1.5; } // Place the symbol plcx+=symbols[k].xoff; plcy+=symbols[k].yoff; if (scm_storepart(symname, lastname,plcx,plcy,0,0)) errormsg(ERRSYMB, symname+"'/'"+lastname); if (SYMDEFVAL && cap_nrefsearch(symname,fig)==0) { // Scan default values defvaln=0; cap_scanfelem(fig,0.0,0.0,0.0,1, amacfunc,NULL,NULL,atextfunc); // Set default values for (l=0;lFOOTERH) { bae_clearpoints(); if (bae_storepoint(0.0,rows[j].rb,0) || bae_storepoint(SHW,rows[j].rb,0) || scm_storepoly(C_POLYDOCLINE)) error(ERRPOLY); } } // Test if plot format if (PLTFMT) { // Shift the plan/plot to fit to paper // Set the lower boundary bae_clriactqueue(); bae_storemouseiact(1,XLPLT,YLPLT,0,LMB); call(MNU_SCMPARLBND); // Set the origin bae_clriactqueue(); bae_storemouseiact(1,XPLTOFF,YPLTOFF,0,LMB); call(MNU_SCMPARORIG); } // Set element comment ecomment= firstname+(lastname==firstname ? "" : (" - "+lastname)); bae_setstrpar(0,ecomment); // Save the element bae_clriactqueue(); bae_setintpar(22,1); call(MNU_SCMSAVELEM); bae_setintpar(22,0); // Store the report message sprintf(msgs[msgn],REPSHEET,DSTFILE,ITEMS,sheets[i].sn); msgn++; } // Report the placement count if (placecount) { sprintf(msgs[msgn],REPSYMCNT,placecount,ITEMS); msgn++; msgs[msgn++]=""; } } // Attribute scan routines int amacfunc(index C_MACRO macro,index C_POOL pool,int macinws, string refname,index C_LEVEL level,index C_LEVEL buslevel) /* // Attribute scan macro function // Return value : // 0 if out of workspace, 1 if inside, 2 if unknown, or (-1) on error // Parameters : // index C_MACRO macro : Macro index // index C_POOL pool : Macro pool index // int macinws : Macro in workspace flag // string refname : Macro reference name // index C_LEVEL level : Macro level // index C_LEVEL buslevel : Macro bus level */ { return(macro.CLASS==DDBCLSSYM ? 1 : 0); } int atextfunc(index C_TEXT textp,double tx,double ty,double tangle, int mirrflag,double tsize,string tstr,int textinws,int macclass,int varattr) /* // Scan a text data block for attribute definitions // Return value : // zero if done or (-1) on error // index C_TEXT textp : Text index // double tx : Text X coordinate // double ty : Text Y coordinate // double tangle : Text rotation angle // int mirrflag : Text mirror flag // double tsize : Text size // string tstr : Text string // int textinws : Text in workspace flag // int macclass : Text macro class // int varattr : Text variant attribute flag */ { string attrcommn /* Attribute comment name */; string attrcommv /* Attribute comment value */; int attrord /* Attribute order value */; int lock /* Attribute lock flag */; int lockbase /* Attrib. locked in base var. flag */; string str /* Text string */; int i, j /* Loop control variables */; // Get text string str=textp.STR; if (scm_chkattrname(str)) // No valid attribute name return(0); // Check the rotation visibility if (textp.ROTVIS!=100 && !((textp.ROTVIS&1) && (textp.ROTVIS&0x20))) // Process only base orientation texts return(0); // Query the attribute default value if (cap_rulequery(RS_OCPOOL,textp,RS_SCMSUBJ,RS_INIVAL, "?s",defvall[defvaln].val)>0) { defvall[defvaln].name=str; defvaln++; } // Return without errors return(0); } void plotsheets() /* // Plot all sheets on request */ { int allsheets /* Plot all sheets flag */; int hwdev /* Plot to HW device flag */; int pltmenuitem /* Plot menu item number */; string msgbuf /* Message buffer */; int i /* Loop control variable */; // Verify if plotting is required if (!verify(UPRPLOTOUT,1)) // Abort return; // Select the plot format bae_promptdialog(UPRPLOTFMT); switch (bae_askmenu(4,UPRPLOTHPGL,UPRPLOTPS,UPRPLOTPCL,UPRABORT)) { // Perform HP-GL output case 0 : pltmenuitem=MNU_SCMPLTHPGL; msgbuf=REPHPGLOUT; break; // Perform PostScript output case 1 : pltmenuitem=MNU_SCMPLTPOST; msgbuf=REPPOSTOUT; break; // Perform HP-Laser/PCL output case 2 : pltmenuitem=MNU_SCMPLTPCL; msgbuf=REPPCLOUT; break; // Return on default default : return; } // Verify if all sheets plotting is required allsheets=verify(UPRPLOTALL,1); // Verify if plotting to online hardware device is required hwdev=verify(UPRPLOTDEV,1); // Loop thru all sheets for (i=1;i<=sheetn;i++) { // Verify if (!allsheets && !verify(UPRPLOTPLAN+sheets[i].sn+"' ? ",1)) continue; // Load the sheet bae_setintpar(22,1); if (bae_loadelem(LIBFILE,sheets[i].sn,DDBCLSCM)==(-1)) errormsg(ERRLOAD,sheets[i].sn); // Set the plot device bae_clriactqueue(); bae_storetextiact(1,hwdev?PLOTDEV:(DSTFILEX+"."+itoa(i))); call(MNU_SCMPLTDEV); // Set fine standard width bae_clriactqueue(); bae_storetextiact(1,"0.1"); call(MNU_SCMPLTSETW); // Plot the sheet bae_clriactqueue(); if (pltmenuitem==MNU_SCMPLTHPGL) bae_storetextiact(1,HPGLPEN1); call(pltmenuitem); // Message bae_prtdialog(msgbuf); } } // Data conversion routines double mmceil(double val) /* // Round meter input value up to next mm // Return value : // rounded value in meters // Parameters : // double val : Input value */ { // Calculate result and return it return(ceil(val*1000.0)/1000.0); } // User Language program end