/* SCMTEXT (SCM) -- SCM Text Functions */ /* SCMTEXT (SCM) -- SCM-Textfunktionen */ /* -- INTENDED FOR KEY-CALL USE -- */ /* // Copyright (c) 1995-2012 Oliver Bartels F+E, Muenchen // Author: Manfred Baumeister // Changes History: // rl (120427) RELEASED FOR BAE V7.8. // rl (110616) ENHANCEMENT: // Added clipboard attribute assignment support. // rl (101019) RELEASED FOR BAE V7.6. // rl (100119) BUGFIX: // Fixed multiline text edit rule loss problem. // rl (091021) RELEASED FOR BAE V7.4. // rl (090603) ENHANCEMENT: // Added clipboard text placement support. // rl (081014) RELEASED FOR BAE V7.2. // rl (071029) RELEASED FOR BAE V7.0. // rl (060829) RELEASED FOR BAE V6.8. // rl (051103) ENHANCEMENT: // Added multiline text alternate origin support. // rl (051019) ENHANCEMENT: // Added multiline text table import function. // rl (050906) RELEASED FOR BAE V6.6. // rl (040811) RELEASED FOR BAE V6.4. // rl (040331) ENHANCEMENT: // Added group symbol text class mask assignment function. // rl (040325) ENHANCEMENT: // Added text sheet load function. // rl (030912) RELEASED FOR BAE V6.2. // rl (030507) ENHANCEMENT: // Added text plot line width set function. // rl (030408) ENHANCEMENT: // Added group text class assignment function. // rl (030207) BUGFIX: // Fixed problem with multiline text copy function. // rl (021209) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (010626) RELEASED FOR BAE V5.0. // rl (010106) ENHANCEMENT: // Added preservation of advanced text attributes in text mode // setting functions. // rl (000525) RELEASED FOR BAE V4.6. // rl (990625) RELEASED FOR BAE V4.4. // rl (980929) 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 (970604) CHANGE: // Applied figure list cross reference index access. // mb (970408) ENHANCEMENT: // New functions for changing mouse-selectable text // strings to upper case and/or lower case. // mb (970408) IMPROVEMENT: // Introduced screen redraw call for each change. // mb (960919) RELEASED FOR BAE V3.4. // mb (95) RELEASED FOR BAE V3.2. // mb (950222) IMPROVEMENT: // Avoid blank character creation during arc text generation. // mb (941116) ORIGINAL CODING. // // DESCRIPTION // // The scmtext User Language program provides a menu with a series // of advanced text processing functions such as setting text sizes, // changing standard to comment text (and vice versa), lower case text // strings, upper case text strings, converting texts to areas or lines, // writing texts on arcs, deleting texts with repetitive selection, etc. */ // 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 // Messages string UPRABORT = M_UPRABORT(); string UPRFCT = M("Text-Funktion selektieren!", "Select Text Function!"); string UPRFCT1 = M("Text&groesse setzen","Set Text &Size"); string UPRFCT2 = M("Text&modus setzen","Set Text &Mode"); string UPRFCT3 = M("%Text->&Flaeche","%Text->A&rea"); string UPRFCT4 = M("Text->&Linie","Text->&Line"); string UPRFCT5 = M("Text auf &Kreis","Text on Ar&c"); string UPRFCT6 = M("%Text Gro&ssschreibung","%Text &Upper Case"); string UPRFCT7 = M("Text Klei&nschreibung","Text L&ower Case"); string UPRFCT8 = M("%Texte l&oeschen","%&Delete Texts"); string UPRFCT9 = M("Texte &ersetzen","&Replace Texts"); string UPRFCT10 = M("Texte &aendern","C&hange Texts"); string UPRFCT11 = M("%Te&xtklasse","%Te&xt Class"); string UPRFCT12 = M("%Me&hrzeilentext","%&Multi L&ine Text"); string UPRFCT13 = M("%Text St&iftbreite setzen", "%Set Text Plot &Width"); string UPRFCT14 = M("%Text&plan laden","%Load &Text Sheet"); string UPRFCT15 = M("Link zu ex&terner Datei","Li&nk to External File"); string UPRFCT16 = M("%Text aus &Zwischenablage", "%&Place Clipboard Text"); string UPRMTEXTFCT = M("Mehrzeilentextfunktion selektieren!", "Select Multi Line Text Function!"); string UPRMFCT1 = M("&Neu","&Add"); string UPRMFCT2 = M("&Bewegen","&Move"); string UPRMFCT3 = M("&Kopieren","&Copy"); string UPRMFCT4 = M("&Aendern","&Edit"); string UPRMFCT5 = M("&Loeschen","&Delete"); string UPRMFCT6 = M("%&Groesse setzen","%Set Si&ze"); string UPRMFCT7 = M("&Modus setzen","Set M&ode"); string UPRMFCT8 = M("%&Selektieren","%&Select"); string UPRMFCT9 = M("D&eselektieren","Dese&lect"); string UPRMFCT10 = M("T&oggle","&Toggle"); string UPRMFCT11 = M("%&Tabelle einlesen","%&Import Table"); string UPRDPMODE = M("Linienbreitenfunktion waehlen!", "Select Text Line Width Function!"); string UPRDMODE1 = M("&Aendern","&Change"); string UPRDMODE2 = M("&Setzen","&Set"); string UPRDMODE3 = M("&Gruppe setzen","Set &Group"); string UPRTABFILE = M("Texttabellendatei ? ","Text Table File ? "); string UPRSELTNAME = M("Tabellendefinition ? ","Table Definition ? "); string UPRSELTEXT = M("Text waehlen!","Select Text!"); string UPRTSIZEM = M("Textgroesse [mm] ? ","Text Size [mm] ? "); string UPRTSIZEI = M("Textgroesse [Inch] ? ","Text Size [Inch] ? "); string UPRTEXTWM = M("Text Stiftbreite [mm] ? ", "Text Pen Width [mm] ? "); string UPRTEXTWI = M("Text Stiftbreite [Inch] ? ", "Text Pen Width [Inch] ? "); string UPRTPWIDM = M("Text Stiftbreite (%.2fmm) ? ", "Text Pen Width (%.2fmm) ? "); string UPRTPWIDI = M("Text Stiftbreite [%.3f Inch] ? ", "Text Pen Width [Inch] ? "); string UPRTEXT = M("Text ? ","Text ? "); string UPRNEWTEXT = M("Neuer Text ? ","New Text ? "); string UPREDIT = M("!Neuer Text","!New Text"); string UPRTCENTER = M("Bogen-Mittelpunkt waehlen!", "Select Arc Center!"); string UPRTSTART = M("Text-Startposition waehlen!", "Select Text Start Position!"); string UPRACLOCK = M("&Gegen Uhrzeigersinn","C&ounter-Clockwise"); string UPRCLOCK = M("&Im Uhrzeigersinn","&Clockwise"); string UPRTMODE = M("Modus fuer Text waehlen!","Select Text Mode!"); string UPRNTEXT = M("&Standardtext","&Standard Text"); string UPRDTEXT = M("&Kommentartext","&Commentary Text"); string UPRTCLASS = M("&Text zuweisen","&Text Assignment"); string UPRTCLASSGRP = M("&Gruppe zuweisen","&Group Assignment"); string UPRTCLASSPDIS = M("&Symbolmaske","&Symbol Mask"); string UPRTCLASSDIS = M("&Planmaske","&Sheet Mask"); string UPRSELSYM = M("Symbol waehlen!","Select Symbol!"); string UPRSELSYMA = M("Symbol fuer Attributzuweisungen waehlen!", "Select symbol for attribute assignments!"); string UPRTXTCLASS = M("Text '%s' Klassenzugehoerigkeit", "Text '%s' Class Assignment"); string UPRGTXTCLASS = M("Gruppentexte Klassenzugehoerigkeit", "Group Texts Class Assignment"); string UPRSTCLASS = M("Symbol '%s' Textausblendung", "Symbol '%s' Text Fade Out"); string UPRGSYMCLASS = M("Gruppensymbole Textausblendung", "Group Texts Text Fade Out"); string UPRPTCLASS = M("Plan Textausblendung","Sheet Text Fade Out"); string UPRRBYES = M("ja","yes"); string UPRRBNO = M("nein","no"); string UPRNEXTDIAL = M("&Weitere","&Next"); string UPRPREVDIAL = M("&Vorherige","&Previous"); string UPREXTFILE = M("Link Zieldatei ? ","Link Target File ? "); string UPRFCTRPLC = M("Funktion '%s' ersetzen ?", "Replace function '%s' ?"); string REPTABLIST = M("Auswahl Tabellendefinition :", "Table Definition Selection :"); string REPCLASS = M("Klasse %d","Class %d"); string ERRTEXT = M("Fehler beim Erzeugen des Textes '%s'!", "Error creating text '%s'!"); string ERRMTEXT = M("Text '%s' ist kein Mehrzeilentext!", "Text '%s' not part of a multi line text!"); string ERRDELETE = M("Fehler beim Loeschen des Textes!", "Error deleting text!"); string ERRPOLY = M("Fehler beim Erzeugen der Flaechen!", "Error creating areas!"); string ERRTEXTGLUED = M("Text ist verankert!","Text is glued!"); string ERRNOTABDEF = M("Tabellendefinition '%s' nicht gefunden!", "Table definition '%s' not found!"); string ERRNOMTEXT = M("Funktion fuer Mehrzeilentexte nicht unterstuetzt!", "Function not supported for multi line texts!"); string ERRCLIPEMPTY = M("Zwischenablage enthaelt keinen Text!", "Clipboard contains no text!"); string ERRSETATT = M("Fehler bei der Attributzuweisung '%s'!", "Error setting attribute '%s'!"); string ERRNOPICK = M_ERRNOPICK(); string ERRINPVAL = M_ERRINPVAL(); // INI file parameter name definitions #define PAR_CLASSDCNT "TCLASSDCNT_SCM"// Class max. dialog items count #define PAR_MAXEDIT "MTMAXEDIT_SCM" // Max. multi line edit length #define PAR_TXTLSPC "TXTLSPACE_SCM" // Text line relativ spacing #define PAR_MTEXTORIG "MTEXTORIG_STD" // Multi line text origin mode #define PAR_TEXTTABL "TEXTTABL_STD" // Text table definition #define PAR_TCLASSNAME "TEXTCLASS%d_SCM" // Text class name #define PAR_TCLASSCNT "TCLASSCNT_SCM" // Text class name count #define PAR_ZOOMEXP "SYMZOOMEXP_SCM"// Symbol zoom expansion value #define PAR_ATTRSETP "ATTR_SET_STD" // Attribute set program #define PAR_NOPLCPVIS "NOPLCPVIS_SCM" // $noplc/plot visibilty relationship #define TCLASSMAX 31 // Max. text class name count // Globals double lastx,lasty /* Last vector coordinates */; struct tpoint { // Text point descriptor double x,y /* Point coordinates */; }; struct tpoint textdata[][] /* Text polygon data field */; int tpointcnt[] /* Text poly. points count field */; int tpolycnt = 0 /* Text polygon count */; string textstr /* Current text string */; double angle /* Text size */; double x,y /* Text coordinates */; double size /* Text size */; double width /* Text width */; int mirr /* Text mirroring */; int mode /* Text mode (unused) */; int MAXMENUCLASS = bae_iniintval(PAR_CLASSDCNT,12) /* Max. class menu list length */; int TCLASSCNT = bae_iniintval(PAR_TCLASSCNT,31) /* Text class count */; int MAXEDIT = bae_iniintval(PAR_MAXEDIT,60000); // Max. multi line edit length double LINESPC = bae_inidblval(PAR_TXTLSPC,1.0); // Text rel. line spacing int MTEXTORIG = bae_iniintval(PAR_MTEXTORIG,0); // Multi line text origin mode int NOPLCPVIS = bae_iniintval(PAR_NOPLCPVIS,3) /* $noplc/plot vis. relationship */; #define GV_SATTRSYM "set_attrsym" // Set symbol name #define GV_SOATTRN "set_oattrn" // Set original attribute count #define GV_SOATTRNL "set_oattrnl" // Set original attribute name list #define GV_SOATTRVL "set_oattrvl" // Set original attribute value list int varl[] /* Variant list */; int varn = 0 /* Variant count */; int act_var = 0 /* Active variant */; int act_flag /* Active variant defined flag */; int ddbclass = bae_planddbclass() /* Plan DDB class */; static int WINDOWS = bae_swconfig(3)==BAE_WinStd || bae_swconfig(3)==BAE_WinPulldwn /* BAE Windows software flag */; // SQL command definitions #define V_SELECTA "select variant from varinfo;" // Main program void main() { index C_FIGURE fig /* Figure list index */; index C_NREF nref /* Named reference index */; index C_TEXT text /* Text index */; string t_dis = "," /* Text items disable */; string gt_dis = "," /* Group text items plan disable */; string s_dis = "," /* Symbol items plan disable */; int i /* Loop control variable */; // Test the plan class if (ddbclass==DDBCLUNDEF) error_class(); // Check if call inside function check_fctactive(); // Check if element type scan if (bae_iniintval(PAR_METYPSCAN,1)==1 && !bae_peekiact()) { forall (text) { t_dis=""; forall (fig where fig.GROUP && fig.TYP==C_FIGTEXT) { gt_dis=""; break; } break; } } else { // Enable all menu items t_dis=gt_dis=""; } // Ask for text function type bae_defmenusel(-1); bae_promptdialog(UPRFCT); switch (bae_askmenu(17,t_dis+UPRFCT1,t_dis+UPRFCT2,t_dis+UPRFCT3, t_dis+UPRFCT4,UPRFCT5,t_dis+UPRFCT6,t_dis+UPRFCT7,t_dis+UPRFCT8, t_dis+UPRFCT9,t_dis+UPRFCT10,UPRFCT11,UPRFCT12,t_dis+UPRFCT13, t_dis+UPRFCT14,t_dis+UPRFCT15,(WINDOWS ? t_dis : ",")+UPRFCT16, UPRABORT)) { // Set text size case 0 : settextsize(); break; // Set text documentary mode case 1 : settextmode(); break; // Text to area conversion case 2 : texttoarea(); break; // Text to line conversion case 3 : texttoline(); break; // Arc text case 4 : arctext(); break; // Text upper case case 5 : textuppercase(); break; // Text lower case case 6 : textlowercase(); break; // Delete texts case 7 : deletetext(); break; // Change texts case 8 : changetext(); break; // Replace texts case 9 : replacetext(); break; // Text class case 10 : // Select text class function if (ddbclass==DDBCLSCM) { // Check if element type scan if (bae_iniintval(PAR_METYPSCAN,1)==1 && !bae_peekiact()) { forall (nref) { s_dis=""; break; } } else { // Enable all menu items s_dis=""; } } bae_defmenusel(-1); switch (bae_askmenu(5,t_dis+UPRTCLASS,gt_dis+UPRTCLASSGRP, s_dis+UPRTCLASSPDIS,UPRTCLASSDIS,UPRABORT)) { // Text class assignment case 0 : textclass(); break; // Group text class assignment case 1 : grouptextclass(); break; // Part text class mask assignment case 2 : symtextclass(); break; // Plan text class case 3 : plantextclass(); break; default : error_abort(); } break; // Multi line text functions case 11 : bae_defmenusel(-1); bae_promptdialog(UPRMTEXTFCT); switch (bae_askmenu(12,UPRMFCT1,t_dis+UPRMFCT2,t_dis+UPRMFCT3, t_dis+UPRMFCT4,t_dis+UPRMFCT5,t_dis+UPRMFCT6,t_dis+UPRMFCT7, t_dis+UPRMFCT8,gt_dis+UPRMFCT9,t_dis+UPRMFCT10,UPRMFCT11, UPRABORT)) { // Add text case 0 : mtextadd(1); break; // Move text case 1 : mtextmove(); break; // Copy text case 2 : mtextcopy(); break; // Edit text case 3 : mtextedit(); break; // Delete text case 4 : mtextdelete(); break; // Set text size case 5 : mtextsize(); break; // Set text mode case 6 : mtextmode(); break; // Select text case 7 : mtextselect(1); break; // Deselect text case 8 : mtextselect(0); break; // Toggle text case 9 : mtextselect(2); break; // Import table text case 10 : mtexttable(); break; default : error_abort(); } break; // Set text plot width case 12 : bae_defmenusel(-1); bae_promptdialog(UPRDPMODE); switch (bae_askmenu(4,t_dis+UPRDMODE1,t_dis+UPRDMODE2, gt_dis+UPRDMODE3,UPRABORT)) { // Change mouse selectable texts case 0 : settextpwidth(0); break; // Set mouse selectable texts case 1 : settextpwidth(1); break; // Set group texts case 2 : settextpwidth(2); break; default : error_abort(); } break; // Load text sheet plan case 13 : loadtextsheet(); break; // Link to external file case 14 : linkfile(); break; // Place clipboard text case 15 : if (bae_getstrpar(10,textstr)!=0 || textstr=="") error(ERRCLIPEMPTY); // Check if text contains attribute assignments if (ddbclass==DDBCLSCM && symattrpaste()) break; // Check if text contains linefeeds for (i=strlen(textstr)-1;i>=0;i--) if (textstr[i]==0x0a) break; if (i>=0) { mtextadd(0); } else { scm_setintpar(25,1); bae_callmenu(MNU_SCMADDTEXT); scm_setintpar(25,0); } break; // Abort on default default : } } // Text functions void settextsize() /* // Set size of mouse-selectable texts */ { index C_FIGURE nfig /* New figure list index */; index C_FIGURE fig /* Figure list element */; STRINGS rl /* Rule list */; double textsize /* Text size */; int cnt = 0 /* Element count */; // Get the text size textsize=baepar_dblval(SCMPAR_DEFTEXTSIZE); if (askdist(textsize,bae_getcoorddisp()?UPRTSIZEI:UPRTSIZEM,0)) // Invalid input value error(ERRINPVAL); // Loop while pick element found while (bae_promptdialog(UPRSELTEXT),scm_pickelem(fig,C_FIGTEXT)==0) { if (fig.FIXED&2) error(ERRTEXTGLUED); // Save current state for undo if (cnt==0) bae_callmenu(MNU_BAESAVESTATE); // Store text with new size if (scm_storetext(fig.NAME, fig.X,fig.Y,fig.ANGLE,textsize,fig.MIRROR,fig.TEXT.MODE)) errormsg(ERRTEXT,fig.NAME); // Transfer rules if (fig.RULEOBJID>=0 && cap_lastfigelem(nfig)==0) { // Get rules if (rsc_getfigrules(fig,rl)>0) // Attach rules if (cap_rulefigatt(nfig,rl)) rsc_error(-1); } // Delete old text element if (scm_delelem(fig)) error(ERRDELETE); // Perform screen redraw screenredraw(); cnt++; } // No pick if (cnt) bae_prtdialog(ERRNOPICK); else perror(ERRNOPICK); } void settextmode() /* // Change mode of mouse-selectable texts */ { int newmode /* New mode code */; index C_FIGURE fig /* Figure list element */; index C_FIGURE nfig /* New figure list index */; STRINGS rl /* Rule list */; int cnt = 0 /* Element count */; // Select text mode bae_defmenusel(-1); bae_promptdialog(UPRTMODE); if ((newmode=bae_askmenu(3,UPRNTEXT,UPRDTEXT,UPRABORT))<0 || newmode>1) error_abort(); // Loop while pick element found while (bae_promptdialog(UPRSELTEXT),scm_pickelem(fig,C_FIGTEXT)==0) { if (fig.FIXED&2) error(ERRTEXTGLUED); // Save current state for undo if (cnt==0) bae_callmenu(MNU_BAESAVESTATE); // Store text with new mode if (scm_storetext(fig.TEXT.STR, fig.X,fig.Y,fig.ANGLE,fig.SIZE,fig.MIRROR, (fig.TEXT.MODE&~TEXTCOMM)|newmode)) errormsg(ERRTEXT,fig.TEXT.STR); // Transfer rules if (fig.RULEOBJID>=0 && cap_lastfigelem(nfig)==0) { // Get rules if (rsc_getfigrules(fig,rl)>0) // Attach rules if (cap_rulefigatt(nfig,rl)) rsc_error(-1); } // Delete old text element if (scm_delelem(fig)) error(ERRDELETE); // Perform screen redraw screenredraw(); cnt++; } // No pick if (cnt) bae_prtdialog(ERRNOPICK); else perror(ERRNOPICK); } void textuppercase() /* // Upper case mouse-selectable texts */ { index C_FIGURE fig /* Figure list element */; index C_FIGURE nfig /* New figure list index */; STRINGS rl /* Rule list */; string newstr /* New text string */; int cnt = 0 /* Element count */; // Loop while pick element found while (bae_promptdialog(UPRSELTEXT),scm_pickelem(fig,C_FIGTEXT)==0) { if (fig.FIXED&2) error(ERRTEXTGLUED); // Get new text string strupper(newstr=fig.NAME); // Continue if no text string change request if (newstr==fig.NAME) continue; // Save current state for undo if (cnt==0) bae_callmenu(MNU_BAESAVESTATE); // Store text with new string if (scm_storetext(newstr, fig.X,fig.Y,fig.ANGLE,fig.SIZE,fig.MIRROR,fig.TEXT.MODE)) errormsg(ERRTEXT,newstr); // Transfer rules if (fig.RULEOBJID>=0 && cap_lastfigelem(nfig)==0) { // Get rules if (rsc_getfigrules(fig,rl)>0) // Attach rules if (cap_rulefigatt(nfig,rl)) rsc_error(-1); } // Delete old text element if (scm_delelem(fig)) error(ERRDELETE); // Perform screen redraw screenredraw(); cnt++; } // No pick if (cnt) bae_prtdialog(ERRNOPICK); else perror(ERRNOPICK); } void textlowercase() /* // Lower case mouse-selectable texts */ { index C_FIGURE fig /* Figure list element */; index C_FIGURE nfig /* New figure list index */; STRINGS rl /* Rule list */; string newstr /* New text string */; int cnt = 0 /* Element count */; // Loop while pick element found while (bae_promptdialog(UPRSELTEXT),scm_pickelem(fig,C_FIGTEXT)==0) { if (fig.FIXED&2) error(ERRTEXTGLUED); // Get lower case text string strlower(newstr=fig.NAME); // Continue if no text string change request if (newstr==fig.NAME) continue; // Save current state for undo if (cnt==0) bae_callmenu(MNU_BAESAVESTATE); // Store text with new string if (scm_storetext(newstr, fig.X,fig.Y,fig.ANGLE,fig.SIZE,fig.MIRROR,fig.TEXT.MODE)) errormsg(ERRTEXT,newstr); // Transfer rules if (fig.RULEOBJID>=0 && cap_lastfigelem(nfig)==0) { // Get rules if (rsc_getfigrules(fig,rl)>0) // Attach rules if (cap_rulefigatt(nfig,rl)) rsc_error(-1); } // Delete old text element if (scm_delelem(fig)) error(ERRDELETE); // Perform screen redraw screenredraw(); cnt++; } // No pick if (cnt) bae_prtdialog(ERRNOPICK); else perror(ERRNOPICK); } void deletetext() /* // Delete mouse-selectable texts */ { index C_FIGURE fig /* Figure list element */; int cnt = 0 /* Element count */; // Loop while pick element found bae_prtdialog(UPRSELTEXT); while (scm_pickelem(fig,C_FIGTEXT)==0) { if (fig.FIXED&2) error(ERRTEXTGLUED); // Save current state for undo if (cnt==0) bae_callmenu(MNU_BAESAVESTATE); // Delete element if (scm_delelem(fig)) error(ERRDELETE); // Perform screen redraw screenredraw(); cnt++; } // No pick if (cnt) bae_prtdialog(ERRNOPICK); else perror(ERRNOPICK); } void changetext() /* // Change mouse-selectable texts to a new string */ { index C_FIGURE fig /* Figure list element */; index C_FIGURE nfig /* New figure list index */; STRINGS rl /* Rule list */; string newstr /* New text string */; int cnt = 0 /* Element count */; if (scm_getstrpar(4,textstr)) textstr=""; // Get text string bae_setmousetext(""); if ((newstr=bae_readedittext(UPRNEWTEXT,textstr,MAXTEXTLEN))=="" || newstr==UINPOPABORT) error_abort(); scm_setstrpar(4,textstr); // Loop while pick element found while (bae_promptdialog(UPRSELTEXT),scm_pickelem(fig,C_FIGTEXT)==0) { // Continue if no text string change request if (newstr==fig.NAME) continue; if (fig.FIXED&2) error(ERRTEXTGLUED); // Save current state for undo if (cnt==0) bae_callmenu(MNU_BAESAVESTATE); // Store text with new string if (scm_storetext(newstr, fig.X,fig.Y,fig.ANGLE,fig.SIZE,fig.MIRROR,fig.TEXT.MODE)) errormsg(ERRTEXT,newstr); // Transfer rules if (fig.RULEOBJID>=0 && cap_lastfigelem(nfig)==0) { // Get rules if (rsc_getfigrules(fig,rl)>0) // Attach rules if (cap_rulefigatt(nfig,rl)) rsc_error(-1); } // Delete old text element if (scm_delelem(fig)) error(ERRDELETE); // Perform screen redraw screenredraw(); cnt++; } // No pick if (cnt) bae_prtdialog(ERRNOPICK); else perror(ERRNOPICK); } void replacetext() /* // Replace texts with a new string */ { index C_FIGURE fig /* Figure list element */; index C_FIGURE dfig /* Delete figure list element */; index C_FIGURE nfig /* New figure list index */; STRINGS rl /* Rule list */; string oldstr /* Old text string */; string newstr /* New text string */; int cflag = 0 /* Change flag */; // Get old text sample bae_promptdialog(UPRSELTEXT); if (scm_pickelem(fig,C_FIGTEXT)) error(ERRNOPICK); // Get the old text string oldstr=fig.NAME; // Get new text string bae_setmousetext(""); if ((newstr=bae_readedittext(UPRNEWTEXT,oldstr,MAXTEXTLEN))=="" || newstr==UINPOPABORT) error_abort(); // Check if string change if (newstr==oldstr) return; // Loop while pick element found forall (fig where fig.TYP==C_FIGTEXT && fig.NAME==oldstr) { if (fig.FIXED&2) error(ERRTEXTGLUED); // Save current state for undo if (cflag==0) { bae_callmenu(MNU_BAESAVESTATE); cflag=1; } // Store text with new string if (scm_storetext(newstr, fig.X,fig.Y,fig.ANGLE,fig.SIZE,fig.MIRROR,fig.TEXT.MODE)) errormsg(ERRTEXT,newstr); // Transfer rules if (fig.RULEOBJID>=0 && cap_lastfigelem(nfig)==0) { // Get rules if (rsc_getfigrules(fig,rl)>0) // Attach rules if (cap_rulefigatt(nfig,rl)) rsc_error(-1); } // Delete old text element dfig=fig; if (scm_delelem(dfig)) error(ERRDELETE); } // Perform screen redraw screenredraw(); } void loadtextsheet() /* // Load project sheet element specified in text string */ { double ZOOMEXP = bae_inidblval(PAR_ZOOMEXP,0.0001) /* Symbol zoom window expansion */; index C_FIGURE fig /* Figure list element */; index C_NREF nref /* Named reference element */; STRINGS wordl /* Text word list */; int wordn = 0 /* Text word count */; STRINGS sheetl /* Project sheet list */; int sheetn = 0 /* Project sheet count */; string sheetname = "" /* Sheet element name */; string fname = bae_planfname() /* Database file name */; string ename /* Element name */; string symname = "" /* Symbol name */; string partname /* Part name */; string s /* Scan string */; int sl /* String length */; int dst /* Destination string index */; int i, j /* Loop control variables */; // Abort if invalid plan class if (ddbclass!=DDBCLSCM) error_class(); // Get text sample bae_promptdialog(UPRSELTEXT); if (scm_pickelem(fig,C_FIGTEXT)) error(ERRNOPICK); // Scan the text words s=fig.NAME; strlower(s); sl=strlen(s); // Skip leading blanks for (i=0;i=0 && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s","")>0) error(ERRNOMTEXT); // Query current function sprintf(predname,RS_FCTSEQ,0); if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,predname,"?s",seq)<1) seq==""; // Check if context function defined if (seq!="") { // Check if not external file reference if (strmatch(seq,"#9049:\"$extappl:.*: *\"")==0) { // Query the menu text sprintf(predname,RS_FCTNAME,0); if (cap_rulequery( RS_OCFIG,fig,RS_SCMSUBJ,predname,"?s",menu)<1) menu=""; // Verify command replacement sprintf(msg,UPRFCTRPLC,bae_plainmenutext(menu)); if (bae_msgboxverify(msg,"")!=1) error_abort(); } else { // Extract file name from command sequence for (i=0;(c=seq[i])!='\0';i++) if (c==' ') { if (seq[i+1]=='\\') extfile=strextract( seq,i+3,strlen(seq)-4); else extfile=strextract( seq,i+1,strlen(seq)-2); break; } } } // Query the file name if (bae_askfilename(extfile,"",UPREXTFILE)) error_abort(); // Get the file name extension fext=strextract(extfile,strlen(convstring(extfile,0)),strlen(extfile)); // Assign the external file call context function sprintf(seq,"#9049:\"$extappl:%s: \\\"%s\\\"\"",fext,extfile); sprintf(predname,RS_FCTSEQ,0); rsc_assfigstrpred(fig,predname,seq,"",""); sprintf(predname,RS_FCTNAME,0); rsc_assfigstrpred(fig,predname,UPRFCT15,"",""); } void textclass() /* // Set class bits of mouse-selectable texts */ { index C_FIGURE fig /* Figure list element */; string prompt /* Prompt message */; int textclass /* Text class */; int cnt = 0 /* Element count */; int autoflag = bae_peekiact() /* Automatic interaction flag */; // Loop while pick element found while (bae_promptdialog(UPRSELTEXT),scm_pickelem(fig,C_FIGTEXT)==0) { if (fig.FIXED&2) error(ERRTEXTGLUED); // Query the text class mask if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_TXTCLASS,"?d",textclass)<1) // Set default mask textclass=0; // Get the new text class mask sprintf(prompt,UPRTXTCLASS,fig.TEXT.STR); textclass=edittextclassmask(prompt,textclass); // Save current state for undo if (cnt==0) bae_callmenu(MNU_BAESAVESTATE); // Assign the text class predicate rule rsc_assfigintpred(fig,RS_TXTCLASS,textclass,0,""); // Perform screen redraw screenredraw(); cnt++; } // No pick if (!autoflag) { if (cnt) bae_prtdialog(ERRNOPICK); else perror(ERRNOPICK); } } void grouptextclass() /* // Set class bits of mouse-selectable texts */ { index C_FIGURE fig /* Figure list element */; int textclass = 0 /* Text class */; int grpmode /* Group mode */; int cflag = 0 /* Change flag */; // Select text class function if (ddbclass==DDBCLSCM) { if ((grpmode=bae_askmenu( 3,UPRTCLASS,UPRTCLASSPDIS,UPRABORT))<0 || grpmode>1) error_abort(); } else { // Text assignment grpmode=0; } // Check if symbol mask assignment if (grpmode) { // Get the group symbol class mask textclass=edittextclassmask(UPRGSYMCLASS,textclass); // Loop while pick element found forall (fig where fig.GROUP && fig.TYP==C_FIGNREF && !(fig.FIXED&2)) { // Save current state for undo if (cflag==0) { bae_callmenu(MNU_BAESAVESTATE); cflag=1; } // Assign the text class predicate rule rsc_assfigintpred(fig,RS_TXTCDIS,textclass,0,""); } } else { // Get the group text class mask textclass=edittextclassmask(UPRGTXTCLASS,textclass); // Loop while pick element found forall (fig where fig.GROUP && fig.TYP==C_FIGTEXT && !(fig.FIXED&2)) { // Save current state for undo if (cflag==0) { bae_callmenu(MNU_BAESAVESTATE); cflag=1; } // Assign the text class predicate rule rsc_assfigintpred(fig,RS_TXTCLASS,textclass,0,""); } } // Perform screen redraw screenredraw(); } void symtextclass() /* // Set text class mask bits of mouse-selectable symbols */ { index C_FIGURE fig /* Figure list element */; string prompt /* Prompt message */; int classmask /* Text class disable mask */; int cnt = 0 /* Element count */; // Abort if invalid plan class if (ddbclass!=DDBCLSCM) error_class(); // Loop while pick element found while (bae_promptdialog(UPRSELSYM),scm_pickelem(fig,C_FIGSREF)==0) { if (fig.FIXED&2) error(ERRTEXTGLUED); // Query the text class mask if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_TXTCDIS,"?d",classmask)<1) // Set default mask classmask=0; // Get the new text class mask sprintf(prompt,UPRSTCLASS,fig.NAME); classmask=edittextclassmask(prompt,classmask); // Save current state for undo if (cnt==0) bae_callmenu(MNU_BAESAVESTATE); // Assign the text class mask predicate rule rsc_assfigintpred(fig,RS_TXTCDIS,classmask,0,""); // Perform screen redraw screenredraw(); cnt++; } // No pick if (cnt) bae_prtdialog(ERRNOPICK); else perror(ERRNOPICK); } void plantextclass() /* // Set text class mask bits for current project */ { int classmask /* Text class disable mask */; int obj /* Rule object */; int dbflag /* Rule database flag */; // Check element level if (ddbclass!=DDBCLSCM) { obj=RS_OCPLAN; dbflag=0; } else { obj=RS_OCSCMDB; dbflag=1; } // Query the text class disable mask if (cap_rulequery(obj,0,RS_SCMSUBJ,RS_TXTCDIS,"?d",classmask)<1) // Set default mask classmask=0; // Get the new text class mask classmask=edittextclassmask(UPRPTCLASS,classmask); // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Assign the text class mask predicate rule rsc_assplanintpred(dbflag,RS_TXTCDIS,classmask,0,""); // Perform screen redraw screenredraw(); } int edittextclassmask(string prompt,int classmask) /* // Edit text class mask // Return value : // zero if done or (-1) on error // Parameters : // string prompt : Prompt message // int classmask : Text class mask */ { string varname /* Variable name */; string classnl[] /* Class name list */; double cy = 0.0 /* Current y value */; int nbutidx /* Next button index */; int pbutidx /* Previous button index */; int dfl[] /* Disable flag list */; int clsbl[] /* Class bit button index list */; int clssl[] /* Class bit 2nd button index list */; int clsll[] /* Class label index list */; int mlsidx = 0 /* Menu attr. list start idx. */; int menuidx /* Menu item index */; int repflag = 1 /* Repeat flag */; int i /* Loop control variable */; // Check for dialog support if (bae_dialclr()) { // Ask for direct mask input if (askint(classmask,prompt+" ? ",10)) error_abort(); // Return class mask return(classmask); } // Build the class disable flag list for (i=0;i=TCLASSCNT) TCLASSCNT=i+1; } else { dfl[i]=0; } // Build the class name list for (i=0;i0 ? PA_ACT : PA_NIL,0,0.0,""); bae_dialsetdata(nbutidx,(mlsidx+MAXMENUCLASS)1) error_abort(); // Get the text size tsize=baepar_dblval(SCMPAR_DEFTEXTSIZE); if (askdist(tsize,bae_getcoorddisp()?UPRTSIZEI:UPRTSIZEM,0) || tsize<=0.0) error_abort(); if (scm_getstrpar(4,textstr)) textstr=""; // Get text string bae_setmousetext(""); if ((textstr=bae_readedittext(UPRTEXT,textstr,MAXTEXTLEN))=="" || textstr==UINPOPABORT) error_abort(); scm_setstrpar(4,textstr); // Select arc center bae_promptdialog(UPRTCENTER); if (bae_inpoint(bae_planwsnx(),bae_planwsny(),xc,yc,0)) error_abort(); // Select text start coordinate bae_promptdialog(UPRTSTART); if (bae_inpoint(xc,yc,xs,ys,2)) error_abort(); if (xc==xs && yc==ys) error(ERRINPVAL); // Select rotation orientation if ((rotflag=bae_askmenu(3,UPRACLOCK,UPRCLOCK,UPRABORT))<0 || rotflag>1) error_abort(); // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Get center vector xv=xs-xc; yv=ys-yc; // Get arc radius rad=sqrt(xv*xv+yv*yv); // Get rotation step angle rotang=tsize/(1.5*rad); if (rotflag) rotang*=(-1.0); // Get rotation angle data angsin=sin(rotang); angcos=cos(rotang); // Check if text base shift required if (!rotflag) { // Shift text center vector xv*=(rad+tsize)/rad; yv*=(rad+tsize)/rad; rad+=tsize; } // Rotate center vector by half angle xvn=cos(rotang/2.0)*xv-sin(rotang/2.0)*yv; yv=sin(rotang/2.0)*xv+cos(rotang/2.0)*yv; xv=xvn; // Get text base vector xt=(-tsize*yv/(3.0*rad)); yt=tsize*xv/(3.0*rad); // Check if text base rotation required if (!rotflag) { // Rotate text base by 180 degrees xt*=(-1.0); yt*=(-1.0); } // Create text strings for (i=0;i=0;linen--) { col=0; text=strextract(lines[linen],0,MAXKEYLEN-1); while (strlen(text)>0) { // Store text with new string if (scm_storetext(text, bx+size*col*MAXKEYLEN*2.0/3.0,by,0.0,size,0,0)) errormsg(ERRTEXT,lines[linen]); // Attach rules if (cap_lastfigelem(fig)==0) { sprintf(rulel[0], ":%s:%s='%s';",RS_SCMSUBJ,RS_MTEXTID,textid); sprintf(rulel[1],":%s:%s=%d;", RS_SCMSUBJ,RS_MTEXTCOL,col); sprintf(rulel[2],":%s:%s=%d;", RS_SCMSUBJ,RS_MTEXTROW,linen); sprintf(rulel[3],":%s:%s=%.2f;", RS_SCMSUBJ,RS_MTEXTLS,LINESPC); if (cap_rulefigatt(fig,rulel)) rsc_error(-1); } // Select to group if (cap_lastfigelem(fig)==0) scm_elemgrpchg(fig,1); // Advance to next line col++; text=strextract( lines[linen],col*MAXKEYLEN,(col+1)*MAXKEYLEN-1); } // Advance to next line by+=size*LINESPC; } cap_lastfigelem(lfig); // Shift base point for upper left alignment by=bae_planwsny()+(MTEXTORIG ? (maxline*size*LINESPC) : 0.0); // Move the group anglock=bae_getanglelock(); bae_setanglelock(0); scm_getintpar(24,grpdisp); scm_setintpar(24,2); bae_clriactqueue(); bae_storemouseiact(1,bx,by,0,LMB); bae_callmenu(MNU_SCMMOVEGRP); if (bae_getanglelock()==0) bae_setanglelock(anglock); scm_setintpar(24,grpdisp); cap_lastfigelem(fig); // Reset the group bae_callmenu(fig==lfig ? MNU_SCMDELGRP : MNU_SCMGRPRESE); } void mtextmove() /* // Move a mouse-selectable multi line text */ { index C_FIGURE fig /* Figure list element */; string movtextid /* Move text ID */; string textid /* Text ID */; double bx, by /* Text base line coordinates */; int anglock /* Old angle lock value */; int grpdisp /* Old group display mode */; int maxline = (-1) /* Max. text line */; int col /* Text column */; int row /* Text row */; double linespc /* Text line spacing */; double lsx, lsy /* Text line spacing vector */; // Abort if invalid plan class if (ddbclass==DDBCLUNDEF) error_class(); // Pick text bae_promptdialog(UPRSELTEXT); if (scm_pickelem(fig,C_FIGTEXT)) error(ERRNOPICK); if (fig.FIXED&2) error(ERRTEXTGLUED); // Query the text ID if (fig.RULEOBJID<0 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",movtextid)<1 || movtextid=="") errormsg(ERRMTEXT,fig.NAME); // Set first guess for text base point bx=fig.X; by=fig.Y; // Get text line spacing if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTLS,"?f",linespc)<1) linespc=LINESPC; lsx=-sin(fig.ANGLE)*fig.SIZE*linespc; lsy=cos(fig.ANGLE)*fig.SIZE*linespc; // Reset the group bae_callmenu(MNU_SCMGRPRESE); // Scan all related multiline texts for movement forall (fig where fig.RULEOBJID>=0 && fig.TYP==C_FIGTEXT && !(fig.FIXED&2) && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",textid)>0 && textid==movtextid) { // Check if new best base point found if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTCOL,"?d",col)>0 && col==0 && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTROW,"?d",row)>0 && row>maxline) { // Set text base point bx=fig.X; by=fig.Y; maxline=row; } // Select to group scm_elemgrpchg(fig,1); } if (MTEXTORIG) { // Shift base point for upper left alignment maxline++; bx+=maxline*lsx; by+=maxline*lsy; } // Move the group anglock=bae_getanglelock(); bae_setanglelock(0); scm_getintpar(24,grpdisp); scm_setintpar(24,2); bae_clriactqueue(); bae_storemouseiact(1,bx,by,0,LMB); bae_callmenu(MNU_SCMMOVEGRP); if (bae_getanglelock()==0) bae_setanglelock(anglock); scm_setintpar(24,grpdisp); // Reset the group bae_callmenu(MNU_SCMGRPRESE); } void mtextcopy() /* // Copy a mouse-selectable multi line text */ { index C_FIGURE fig /* Figure list element */; index C_FIGURE l1fig, l2fig /* Last figure list elements */; string cpytextid /* Copy text ID */; string newtextid /* New text ID */; string textid /* Text ID */; int anglock /* Old angle lock value */; int grpdisp /* Old group display mode */; int maxline = (-1) /* Max. text line */; int col /* Text column */; int row /* Text row */; double linespc /* Text line spacing */; double lsx, lsy /* Text line spacing vector */; double bx, by /* Text base line coordinates */; // Abort if invalid plan class if (ddbclass==DDBCLUNDEF) error_class(); // Pick text bae_promptdialog(UPRSELTEXT); if (scm_pickelem(fig,C_FIGTEXT)) error(ERRNOPICK); // Query the text ID if (fig.RULEOBJID<0 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",cpytextid)<1 || cpytextid=="") errormsg(ERRMTEXT,fig.NAME); // Set first guess for text base point bx=fig.X; by=fig.Y; // Get text line spacing if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTLS,"?f",linespc)<1) linespc=LINESPC; lsx=-sin(fig.ANGLE)*fig.SIZE*linespc; lsy=cos(fig.ANGLE)*fig.SIZE*linespc; // Reset the group bae_callmenu(MNU_SCMGRPRESE); // Scan all related multiline texts for copy forall (fig where fig.RULEOBJID>=0 && fig.TYP==C_FIGTEXT && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",textid)>0 && textid==cpytextid) { // Check if new best base point found if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTCOL,"?d",col)>0 && col==0 && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTROW,"?d",row)>0 && row>maxline) { // Set text base point bx=fig.X; by=fig.Y; maxline=row; } // Select to group scm_elemgrpchg(fig,1); } if (MTEXTORIG) { // Shift base point for upper left alignment maxline++; bx+=maxline*lsx; by+=maxline*lsy; } cap_lastfigelem(l1fig); // Copy the group anglock=bae_getanglelock(); bae_setanglelock(0); scm_getintpar(24,grpdisp); scm_setintpar(24,2); bae_clriactqueue(); bae_storemouseiact(1,bx,by,0,LMB); bae_callmenu(MNU_SCMCOPYGRP); if (bae_getanglelock()==0) bae_setanglelock(anglock); scm_setintpar(24,grpdisp); // Check if copy aborted if (cap_lastfigelem(l2fig)!=0 || l1fig==l2fig) { bae_callmenu(MNU_SCMGRPRESE); return; } newtextid=creatextid(); // Scan all new multiline texts for ID reassignment forall (fig where fig.RULEOBJID>=0 && fig.TYP==C_FIGTEXT && fig.GROUP && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",textid)>0 && textid==cpytextid) rsc_assfigstrpred(fig,RS_MTEXTID,newtextid,"",""); // Reset the group bae_callmenu(MNU_SCMGRPRESE); } void mtextedit() /* // Edit a mouse-selectable multi line text */ { index C_FIGURE fig /* Figure list element */; index C_FIGURE dfig /* Delete figure list element */; STRINGS stext[] /* Scan text */; string text /* Text string */; string edttextid /* Edit text ID */; string textid /* Text ID */; STRINGS lines /* Text lines */; int linen /* Line count */; string rulename /* Rule name */; STRINGS mrulel /* Multiline text rule list */; int mrulen /* Multiline text rule count */; STRINGS rulel /* Text rules */; int rulen /* Text rule count */; double size /* Text size */; double angle /* Text angle */; int mode /* Text mode */; int mirr /* Text mirror mode */; double bx, by /* Text base line coordinates */; double lsx, lsy /* Text line spacing vector */; double lcx, lcy /* Text line column vector */; double linespc /* Text line spacing */; int maxline = (-1) /* Max. text line */; int maxcol = (-1) /* Max. text column */; int col /* Text column */; int row /* Text row */; int i /* Loop control variable */; // Abort if invalid plan class if (ddbclass==DDBCLUNDEF) error_class(); // Pick text bae_promptdialog(UPRSELTEXT); if (scm_pickelem(fig,C_FIGTEXT)) error(ERRNOPICK); if (fig.FIXED&2) error(ERRTEXTGLUED); // Query the text ID if (fig.RULEOBJID<0 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",edttextid)<1 || edttextid=="") errormsg(ERRMTEXT,fig.NAME); // Set first guess for text base point bx=fig.X; by=fig.Y; size=fig.SIZE; mode=fig.TEXT.MODE; mirr=fig.MIRROR; angle=fig.ANGLE; // Get the old rule count rulen=rsc_getfigrules(fig,rulel); // Get text line spacing if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTLS,"?f",linespc)<1) linespc=LINESPC; // Scan all related multiline texts for text retrival forall (fig where fig.RULEOBJID>=0 && fig.TYP==C_FIGTEXT && !(fig.FIXED&2) && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",textid)>0 && textid==edttextid) { // Get text position if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTCOL,"?d",col)<1) continue; if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTROW,"?d",row)<1) continue; // Check if new best base point found if (col==0 && row>maxline) { // Set text base point bx=fig.X; by=fig.Y; maxline=row; } if (col>maxcol) maxcol=col; stext[col][row]=fig.NAME; } // Build the text edit string text=""; for (row=0;row<=maxline;row++) { for (col=0;col<=maxcol;col++) text+=stext[col][row]; text+="\n"; } // Edit the text if ((text=bae_readedittext(UPREDIT,text,MAXEDIT))=="" || text==UINPOPABORT) error_abort(); lsx=-sin(angle)*size*linespc; lsy=cos(angle)*size*linespc; lcx=cos(angle)*size*MAXKEYLEN*2.0/3.0; lcy=sin(angle)*size*MAXKEYLEN*2.0/3.0; // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Scan all related multiline texts for deletion forall (fig where fig.RULEOBJID>=0 && fig.TYP==C_FIGTEXT && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",textid)>0 && textid==edttextid && !(fig.FIXED&2)) { dfig=fig; scm_delelem(dfig); } // Split text into lines linen=splitstring(text,lines); if (MTEXTORIG) { // Shift base point for upper left alignment bx+=(maxline-linen+1)*lsx; by+=(maxline-linen+1)*lsy; } textid=creatextid(); // Get the base rules mrulen=4; sprintf(mrulel[0],":%s:%s='%s';",RS_SCMSUBJ,RS_MTEXTID,textid); sprintf(mrulel[3],":%s:%s=%.2f;",RS_SCMSUBJ,RS_MTEXTLS,linespc); for (i=0;i=0;linen--) { col=0; text=strextract(lines[linen],0,MAXKEYLEN-1); while (strlen(text)>0) { // Store text with new string if (scm_storetext(text, bx+col*lcx,by+col*lcy,angle,size,mirr,mode)) errormsg(ERRTEXT,text); // Attach rules if (cap_lastfigelem(fig)==0) { sprintf(mrulel[1],":%s:%s=%d;", RS_SCMSUBJ,RS_MTEXTCOL,col); sprintf(mrulel[2],":%s:%s=%d;", RS_SCMSUBJ,RS_MTEXTROW,linen); if (cap_rulefigatt(fig,mrulel)) rsc_error(-1); } // Advance to next column col++; text=strextract( lines[linen],col*MAXKEYLEN,(col+1)*MAXKEYLEN-1); } // Advance to next line bx+=lsx; by+=lsy; } } void mtextdelete() /* // Delete a mouse-selectable multi line text */ { index C_FIGURE fig /* Figure list element */; index C_FIGURE dfig /* Delete figure list element */; string deltextid /* Delete text ID */; string textid /* Text ID */; // Abort if invalid plan class if (ddbclass==DDBCLUNDEF) error_class(); // Pick text bae_promptdialog(UPRSELTEXT); if (scm_pickelem(fig,C_FIGTEXT)) error(ERRNOPICK); if (fig.FIXED&2) error(ERRTEXTGLUED); // Query the text ID if (fig.RULEOBJID<0 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",deltextid)<1 || deltextid=="") errormsg(ERRMTEXT,fig.NAME); // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Scan all related multiline texts for deletion forall (fig where fig.RULEOBJID>=0 && fig.TYP==C_FIGTEXT && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",textid)>0 && textid==deltextid && !(fig.FIXED&2)) { dfig=fig; scm_delelem(dfig); } } void mtextsize() /* // Set size of a mouse-selectable multi line text */ { index C_FIGURE fig /* Figure list element */; index C_FIGURE dfig /* Delete figure list element */; STRINGS stext[] /* Scan text */; string seltextid /* Select text ID */; string textid /* Text ID */; STRINGS rulel /* Text rules */; double size /* Text size */; double oldsize /* Old text size */; double angle /* Text angle */; int mode /* Text mode */; int mirr /* Text mirror mode */; double bx, by /* Text base line coordinates */; double lsx, lsy /* Text line spacing vector */; double lcx, lcy /* Text line column vector */; int maxline = (-1) /* Max. text line */; int maxcol = (-1) /* Max. text column */; int col /* Text column */; int row /* Text row */; // Abort if invalid plan class if (ddbclass==DDBCLUNDEF) error_class(); // Pick text bae_promptdialog(UPRSELTEXT); if (scm_pickelem(fig,C_FIGTEXT)) error(ERRNOPICK); if (fig.FIXED&2) error(ERRTEXTGLUED); // Query the text ID if (fig.RULEOBJID<0 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",seltextid)<1 || seltextid=="") errormsg(ERRMTEXT,fig.NAME); // Get the text size oldsize=size=fig.SIZE; if (askdist(size,bae_getcoorddisp()?UPRTSIZEI:UPRTSIZEM,0) || size==0.0) // Invalid input value error(ERRINPVAL); // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Set first guess for text base point bx=fig.X; by=fig.Y; mode=fig.TEXT.MODE; mirr=fig.MIRROR; angle=fig.ANGLE; lsx=-sin(angle)*size*LINESPC; lsy=cos(angle)*size*LINESPC; lcx=cos(angle)*size*MAXKEYLEN*2.0/3.0; lcy=sin(angle)*size*MAXKEYLEN*2.0/3.0; // Scan all related multiline texts for text retrival forall (fig where fig.RULEOBJID>=0 && fig.TYP==C_FIGTEXT && !(fig.FIXED&2) && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",textid)>0 && textid==seltextid) { // Get text position if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTCOL,"?d",col)<1) continue; if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTROW,"?d",row)<1) continue; // Check if new best base point found if (col==0 && row>maxline) { // Set text base point bx=fig.X; by=fig.Y; maxline=row; } if (col>maxcol) maxcol=col; stext[col][row]=fig.NAME; dfig=fig; scm_delelem(dfig); } if (MTEXTORIG) { // Shift base point for upper left alignment bx-=(maxline+1)*(size-oldsize)*lsx/size; by-=(maxline+1)*(size-oldsize)*lsy/size; } // Place the text lines textid=creatextid(); for (row=maxline;row>=0;row--) { for (col=0;col<=maxcol;col++) { if (strlen(stext[col][row])==0) continue; // Store text string if (scm_storetext(stext[col][row], bx+col*lcx,by+col*lcy,angle,size,mirr,mode)) errormsg(ERRTEXT,stext[col][row]); // Attach rules if (cap_lastfigelem(fig)==0) { sprintf(rulel[0], ":%s:%s='%s';",RS_SCMSUBJ,RS_MTEXTID,textid); sprintf(rulel[1], ":%s:%s=%d;",RS_SCMSUBJ,RS_MTEXTCOL,col); sprintf(rulel[2], ":%s:%s=%d;",RS_SCMSUBJ,RS_MTEXTROW,row); if (cap_rulefigatt(fig,rulel)) rsc_error(-1); } } // Advance to next line bx+=lsx; by+=lsy; } } void mtextmode() /* // Set mode of a mouse-selectable multi line text */ { index C_FIGURE fig /* Figure list element */; index C_FIGURE dfig /* Delete figure list element */; index C_FIGURE nfig /* New figure list index */; STRINGS rl /* Rule list */; string seltextid /* Select text ID */; string textid /* Text ID */; int newmode /* New mode code */; int cflag = 0 /* Change flag */; // Abort if invalid plan class if (ddbclass==DDBCLUNDEF) error_class(); // Pick text bae_promptdialog(UPRSELTEXT); if (scm_pickelem(fig,C_FIGTEXT)) error(ERRNOPICK); if (fig.FIXED&2) error(ERRTEXTGLUED); // Query the text ID if (fig.RULEOBJID<0 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",seltextid)<1 || seltextid=="") errormsg(ERRMTEXT,fig.NAME); // Select text mode bae_promptdialog(UPRTMODE); bae_defmenusel(fig.TEXT.MODE&0x01 ? 1 : 0); if ((newmode=bae_askmenu(3,UPRNTEXT,UPRDTEXT,UPRABORT))<0 || newmode>1) error_abort(); // Reset the group bae_callmenu(MNU_SCMGRPRESE); // Scan all related multiline texts for selection forall (fig where fig.RULEOBJID>=0 && fig.TYP==C_FIGTEXT && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",textid)>0 && textid==seltextid) scm_elemgrpchg(fig,1); // Scan all group elements for mode change forall (fig where fig.GROUP && !(fig.FIXED&2)) { // Save current state for undo if (cflag==0) { bae_callmenu(MNU_BAESAVESTATE); cflag=1; } // Store text with new mode if (scm_storetext(fig.TEXT.STR, fig.X,fig.Y,fig.ANGLE,fig.SIZE,fig.MIRROR, (fig.TEXT.MODE&~TEXTCOMM)|newmode)) errormsg(ERRTEXT,fig.TEXT.STR); // Transfer rules if (fig.RULEOBJID>=0 && cap_lastfigelem(nfig)==0) { // Get rules if (rsc_getfigrules(fig,rl)>0) // Attach rules if (cap_rulefigatt(nfig,rl)) rsc_error(-1); } // Delete old text element dfig=fig; if (scm_delelem(dfig)) error(ERRDELETE); if (cap_lastfigelem(nfig)==0) scm_drawelem(nfig,DM_SET); } } void mtextselect(int grpmode) /* // Group select a mouse-selectable multi line text // Parameters : // int grpmode : Group selection mode */ { index C_FIGURE fig /* Figure list element */; string seltextid /* Select text ID */; string textid /* Text ID */; // Abort if invalid plan class if (ddbclass==DDBCLUNDEF) error_class(); // Pick text bae_promptdialog(UPRSELTEXT); if (scm_pickelem(fig,C_FIGTEXT)) error(ERRNOPICK); // Query the text ID if (fig.RULEOBJID<0 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",seltextid)<1 || seltextid=="") errormsg(ERRMTEXT,fig.NAME); // Scan all related multiline texts for selection forall (fig where fig.RULEOBJID>=0 && fig.GROUP!=grpmode && fig.TYP==C_FIGTEXT && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",textid)>0 && textid==seltextid) scm_elemgrpchg(fig,grpmode); } void mtexttable() /* // Import a multi line text table */ { index C_FIGURE fig /* Figure list element */; struct tabdes { // Table entry descriptor int typ /* Table entry type */; int slen /* Table entry source length */; int dlen /* Table entry destination length */; int col /* Table entry destination column */; string sep /* Table entry seperator */; string patl[] /* Table entry pattern list */; string datl[] /* Table entry data list */; int datn /* Table entry data count */; } tdl[] /* Table entry list */; int tdn = 0 /* Table entry count */; int tidx /* Table index */; string table[][] /* Text table */; int tsl[] /* Table entry size list */; int skiplinen /* Header skip line count */; int linen = 0 /* Line count */; int col /* Text column */; int tcol = 0 /* Table column count */; int maxcol /* Maximum table column length */; STRINGS headl /* Header list */; int headn = 0 /* Header count */; STRINGS entryl /* Entry list */; int entryn = 0 /* Entry count */; string text /* Text string */; string entry /* Text table entry */; string varname /* Variable name */; string textid /* Text id */; string textcid /* Text column id */; double size /* Text size */; double bx, by /* Text base line coordinates */; STRINGS rulel /* Text rules */; int anglock /* Old angle lock value */; int grpdisp /* Old group display mode */; STRINGS extlist = {bae_swversion(3)} /* File name extension list */; string seltabname /* Selection table name */; string readbuf /* Read buffer */; string ifname /* Input file name */; int ifh /* Input file handle */; int popcols /* Requested popup columns */; int i, j /* Loop control variables */; // Abort if invalid plan class if (ddbclass==DDBCLUNDEF) error_class(); // Get the text size size=baepar_dblval(SCMPAR_DEFTEXTSIZE); if (askdist(size,bae_getcoorddisp()?UPRTSIZEI:UPRTSIZEM,0) || size==0.0) // Invalid input value error(ERRINPVAL); // Select file to convert if ((ifname=askfile(UPRTABFILE,extlist,0))=="") error_abort(); for (entryn=0;entryn<1000;entryn++) { if ((entryl[entryn]=bae_inistrval( bae_inifieldvarname(PAR_TEXTTABL,entryn,0),""))=="") break; } // Check if table definitions found if (entryn==0) { // Create default table description skiplinen=0; for (tdn=0;tdn<20;tdn++) { tdl[tdn].typ=5; tdl[tdn].col=tdn; tdl[tdn].slen=0; tdl[tdn].dlen=0; tdl[tdn].sep=";"; tdl[tdn].datn=0; } tcol=tdn; } else { // Build the table definition menu headl[0]=REPTABLIST; headn=2; popcols=strlen(headl[0])+1; // Select group name bae_setintpar(16,3074); if ((seltabname=popupmenu(1,UPRSELTNAME, headl,headn,entryl,entryn,UINPOPABORT,0,1,1,headn+entryn+2, popcols,0,""))=="" || seltabname==UINPOPABORT) // Aborted error_abort(); for (tidx=0;tidx=entryn) errormsg(ERRNOTABDEF,seltabname); // Get the table definition skiplinen= bae_iniintval(bae_inifieldvarname(PAR_TEXTTABL,tidx,1),0); tidx++; for (tdn=0;tdn<1000;tdn++) { // Get table type sprintf(varname,"%s_%d_3_%d_1", PAR_TEXTTABL,tidx,tdn+1); if ((tdl[tdn].typ=bae_iniintval(varname,-1))==(-1)) // End of table definitions reached break; // Get table entry source length or seperator sprintf(varname,"%s_%d_3_%d_2", PAR_TEXTTABL,tidx,tdn+1); if ((tdl[tdn].typ&3)==1) { tdl[tdn].slen=0; tdl[tdn].sep=bae_inistrval(varname,";"); } else { tdl[tdn].slen=bae_iniintval(varname,1); tdl[tdn].sep=""; } // Get table entry destination length sprintf(varname,"%s_%d_3_%d_3", PAR_TEXTTABL,tidx,tdn+1); tdl[tdn].dlen=bae_iniintval(varname,0); // Get table entry destination column sprintf(varname,"%s_%d_3_%d_4", PAR_TEXTTABL,tidx,tdn+1); // Update max. column if ((tdl[tdn].col=bae_iniintval(varname,-1))>(tcol-1)) tcol=tdl[tdn].col+1; if (tdl[tdn].col>=0) tsl[tdl[tdn].col]=tdl[tdn].dlen; for (tdl[tdn].datn=0;tdl[tdn].datn<999;tdl[tdn].datn++) if ((tdl[tdn].typ&3)==2) { // Get table entry fix value list sprintf(varname,"%s_%d_3_%d_5_1_%d", PAR_TEXTTABL,tidx,tdn+1,tdl[tdn].datn+1); if ((tdl[tdn].datl[tdl[tdn].datn]= bae_inistrval(varname,UINPOPABORT))== UINPOPABORT) break; } else { // Get table entry value rep. pattern list sprintf(varname,"%s_%d_3_%d_5_%d_1", PAR_TEXTTABL,tidx,tdn+1,tdl[tdn].datn+1); if ((tdl[tdn].patl[tdl[tdn].datn]= bae_inistrval(varname,UINPOPABORT))== UINPOPABORT) break; sprintf(varname,"%s_%d_3_%d_5_%d_2", PAR_TEXTTABL,tidx,tdn+1,tdl[tdn].datn+1); tdl[tdn].datl[tdl[tdn].datn]= bae_inistrval(varname,""); } } } // Open the input file ifh=bae_fopen(ifname,0); // Skip file header for (i=0;i=0) table[tdl[i].col][linen]=entry; } linen++; } fclose(ifh); textid=creatextid(); // Reset the group bae_callmenu(MNU_SCMGRPRESE); // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Place the text lines bx=bae_planwsnx(); for (i=0;i=0;j--) { col=0; entry=table[i][j]; text=strextract(entry,0,MAXKEYLEN-1); if (strlen(text)>maxcol) maxcol=strlen(text); while (strlen(text)>0) { // Store text with new string if (scm_storetext(text, bx+size*col*MAXKEYLEN*2.0/3.0,by,0.0,size,0,0)) errormsg(ERRTEXT,text); // Attach rules if (cap_lastfigelem(fig)==0) { sprintf(rulel[0], ":%s:%s='%s';",RS_SCMSUBJ,RS_MTEXTID,textcid); sprintf(rulel[1],":%s:%s=%d;", RS_SCMSUBJ,RS_MTEXTCOL,col); sprintf(rulel[2],":%s:%s=%d;", RS_SCMSUBJ,RS_MTEXTROW,j); sprintf(rulel[3],":%s:%s=%.2f;", RS_SCMSUBJ,RS_MTEXTLS,LINESPC); if (cap_rulefigatt(fig,rulel)) rsc_error(-1); } // Select to group if (cap_lastfigelem(fig)==0) scm_elemgrpchg(fig,1); // Advance to next column col++; text=strextract( entry,col*MAXKEYLEN,(col+1)*MAXKEYLEN-1); } // Advance to next line by+=size*LINESPC; } bx+=size*(maxcol+1)*2.0/3.0; } // Shift base point for upper left alignment bx=bae_planwsnx(); by=bae_planwsny()+(MTEXTORIG ? (linen*size*LINESPC) : 0.0); // Move the group anglock=bae_getanglelock(); bae_setanglelock(0); scm_getintpar(24,grpdisp); scm_setintpar(24,2); bae_clriactqueue(); bae_storemouseiact(1,bx,by,0,LMB); bae_callmenu(MNU_SCMMOVEGRP); if (bae_getanglelock()==0) bae_setanglelock(anglock); scm_setintpar(24,grpdisp); // Reset the group bae_callmenu(MNU_SCMGRPRESE); } int splitstring(string s,STRINGS ssl) /* // Split string into lines // Return value : // number of substrings // Parameters : // string s : Input string // STRINGS ssl : Substring list */ { int ssn = 0 /* Substring count */; int sl = strlen(s) /* String length */; int pos1 = 1 /* String position buffer 1 */; int pos2 /* String position buffer 2 */; int i /* Loop controo variable */; // Repetively scan string while ((pos2=strscannext(s,"\n",pos1,1))pos1 ? strextract(s,pos1-1,pos2-2) : ""; // Update the scan start position pos1=pos2+1; } // Extract last substring if last char not delimiter if (pos1=0 && isspace(s[i])) ; // Extract and return substring return(i<0 ? "" : strextract(s,0,i)); } string strtrim(string s) /* // Trim string (skip leading and trailing white spaces) // Return value : // string without leading and trailing white spaces // Parameters : // string s : Input string */ { // Extract and return substring return(strrtrim(strltrim(s))); } void settextpwidth(int opmode) /* // Set text plot width of mouse-selectable texts // Parameter : // int opmode : Operating mode */ { index C_FIGURE fig /* Figure list element */; double pwidth /* Plot width */; string msg /* Message string */; string rulel[] /* Rule list */; int rulen /* Rule count */; string mrulel[] /* Multiline text rule list */; int mrulen /* Multiline text rule count */; string mtextid = "" /* Multiline text ID */; string textid /* Current text ID */; double linespc /* Multiline text line spacing */; int col /* Multiline text column */; int row /* Multiline text row */; int i /* Loop control variable */; switch (opmode) { // Change texts case 0 : // Loop while pick element found while ( bae_promptdialog(UPRSELTEXT),scm_pickelem(fig,C_FIGTEXT)==0) { if (fig.FIXED&2) error(ERRTEXTGLUED); // Query the text line width if (fig.RULEOBJID<0 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_PLOTWIDTH,"?f",pwidth)<1) // Query last used plot width if (varget(VAR_PLOTW,pwidth)) pwidth=0.0; // Get plot width if (askdist(pwidth,bae_getcoorddisp()? UPRTPWIDI:UPRTPWIDM,1)) error_abort(); // Assign the plot width predicate rule rsc_assfigdblpred(fig,RS_PLOTWIDTH,pwidth,0.0,""); // Query the multiline text status if (fig.RULEOBJID>=0 && cap_rulequery( RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",mtextid)>0 && mtextid!="") { // Get the rule count rulen=rsc_getfigrules(fig,rulel); // Get the base rules mrulen=4; sprintf(mrulel[0],":%s:%s='%s';", RS_SCMSUBJ,RS_MTEXTID,mtextid); for (i=0;i=0 && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTID,"?s",textid)>0 && textid==mtextid) { // Get multiline text data if (cap_rulequery(RS_OCFIG,fig, RS_SCMSUBJ,RS_MTEXTCOL,"?d",col)<1 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTROW,"?d",row)<1 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTLS,"?f",linespc)<1) continue; sprintf(mrulel[1],":%s:%s=%d;", RS_SCMSUBJ,RS_MTEXTCOL,col); sprintf(mrulel[2],":%s:%s=%d;", RS_SCMSUBJ,RS_MTEXTROW,row); sprintf(mrulel[3],":%s:%s=%.2f;", RS_SCMSUBJ,RS_MTEXTLS,linespc); if (cap_rulefigatt(fig,mrulel)) rsc_error(-1); } } // Redraw the screen bae_callmenu(MNU_BAEREDISPL); } break; // Set texts case 1 : // Query last used plot width if (varget(VAR_PLOTW,pwidth)) // Use default path width pwidth=0.0; // Get plot width if (askdist(pwidth,bae_getcoorddisp()? UPRTPWIDI:UPRTPWIDM,1)) error_abort(); // Loop while pick element found while ( bae_promptdialog(UPRSELTEXT),scm_pickelem(fig,C_FIGTEXT)==0) { if (fig.FIXED&2) error(ERRTEXTGLUED); // Assign the plot width predicate rule rsc_assfigdblpred(fig,RS_PLOTWIDTH,pwidth,0.0,""); // Query the multiline text status if (fig.RULEOBJID>=0 && cap_rulequery( RS_OCFIG,fig,RS_SCMSUBJ,RS_MTEXTID,"?s",mtextid)>0 && mtextid!="") { // Get the rule count rulen=rsc_getfigrules(fig,rulel); // Get the base rules mrulen=4; sprintf(mrulel[0],":%s:%s='%s';", RS_SCMSUBJ,RS_MTEXTID,mtextid); for (i=0;i=0 && cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTID,"?s",textid)>0 && textid==mtextid) { // Get multiline text data if (cap_rulequery(RS_OCFIG,fig, RS_SCMSUBJ,RS_MTEXTCOL,"?d",col)<1 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTROW,"?d",row)<1 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_MTEXTLS,"?f",linespc)<1) continue; sprintf(mrulel[1],":%s:%s=%d;", RS_SCMSUBJ,RS_MTEXTCOL,col); sprintf(mrulel[2],":%s:%s=%d;", RS_SCMSUBJ,RS_MTEXTROW,row); sprintf(mrulel[3],":%s:%s=%.2f;", RS_SCMSUBJ,RS_MTEXTLS,linespc); if (cap_rulefigatt(fig,mrulel)) rsc_error(-1); } } // Redraw the screen bae_callmenu(MNU_BAEREDISPL); } break; // Set group texts case 2 : // Query last used plot width if (varget(VAR_PLOTW,pwidth)) // Use default path width pwidth=0.0; // Get plot width if (askdist(pwidth,bae_getcoorddisp()? UPRTPWIDI:UPRTPWIDM,1)) error_abort(); // Loop for all group elements of interest forall (fig where fig.GROUP && fig.TYP==C_FIGTEXT && !(fig.FIXED&2)) // Assign the plot width predicate rule rsc_assfigdblpred(fig,RS_PLOTWIDTH,pwidth,0.0,""); // Redraw the screen bae_callmenu(MNU_BAEREDISPL); break; } // Preserve width data for next call varset(VAR_PLOTW,pwidth); // Done bae_prtdialog(""); } int symattrpaste() /* // Paste attributes defined in clipboard text string // Return value : // one if attributes pasted, else zero */ { index C_FIGURE fig /* Figure index */; string attrulp /* Attribute change ULC program name */; string symname /* Symbol name */; string oldval /* Old value */; struct attrdef { // Attribute definition string name /* Attribute name */; string val /* Attribute value */; } attrl[] /* Attribute list */; int attrn = 0 /* Attribute count */; int sidx = 0 /* String scan index */; int didx /* String destination index */; char c /* Character buffer */; int cnt = 0 /* Element count */; int i /* Loop control variable */; // Scan all text lines while ((c=textstr[sidx])!='\0') { // Check if attribute definition start if (c!='$') return(0); // Get the attribute name attrl[attrn].name[0]='$'; didx=1; sidx++; while ((c=textstr[sidx])!='=') { if (c=='\0' || (c!='_' && !isalnum(c))) return(0); attrl[attrn].name[didx]=c; didx++; if (didx>MAXKEYLEN) return(0); sidx++; } attrl[attrn].name[didx]='\0'; sidx++; // Get the attribute value didx=0; while ((c=textstr[sidx])!='\0' && c!=0x0a && c!=0x0d) { if (didx0;i--) if (varl[i-1]0;i--) varl[i]=varl[i-1]; // Insert variant data varl[0]=0; varn++; } // Check if extra program call needed attrulp=bae_inistrval(PAR_ATTRSETP,""); // Repetitively pick named references bae_prtdialog(UPRSELSYMA); while (scm_pickelem(fig,C_FIGNREF)==0) { // Save current state for undo if (cnt==0) bae_callmenu(MNU_BAESAVESTATE); symname=fig.NAME; for (sidx=0;sidx=0;i--) if (rulel[i]==rulename) { // Delete the old rule for (j=i;j0) { if (cap_rulefigdet(fig)) rsc_error(-1); } } int datafunc(string dstr,int dint,double ddbl, int dval,int dtype,string dtable,string dfield,int didx) /* // Data query callback function // Return value : // zero if done or (-1) on data error // Parameters : // string dstr : String/Date data // int dint : Integer/Boolean data // double ddbl : Float data // int dval : Data valid flag // int dtype : Data type // string dtable : Data table name // string dfield : Data field name // int didx : Data output field index */ { int i /* Loop control variable */; // Search the insert position for (i=varn;i>0;i--) if (varl[i-1]