/* SCMGROUP (SCM) -- SCM Group Functions */ /* SCMGROUP (SCM) -- SCM-Gruppenfunktionen */ /* -- INTENDED FOR KEY-CALL USE -- */ /* // Copyright (c) 1993-2012 Oliver Bartels F+E, Muenchen // Author: Manfred Baumeister // Changes History: // rl (120427) RELEASED FOR BAE V7.8. // rl (110531) ENHANCEMENT: // Added text selection function. // rl (110520) ENHANCEMENT: // Added coordinate list clipboard copy function. // rl (110426) ENHANCEMENT: // Added negated attribute/macro selection options. // rl (110311) ENHANCEMENT: // Added group element report function. // rl (110126) ENHANCEMENT: // Added symbol attribute evalution to hierarchy less group load. // rl (100831) ENHANCEMENT: // Added net group selection function. // rl (100823) ENHANCEMENT: // Added part layout group placement function. // rl (091113) BUGFIX: // Fixed problem with attribute nilval selection. // rl (091027) RELEASED FOR BAE V7.4. // rl (090522) ENHANCEMENT: // Added line to connection conversion function. // rl (090320) ENHANCEMENT: // Added unset attribute selection support. // rl (090319) ENHANCEMENT: // Added $noplc dependant plot visibility autochange option. // rl (081014) RELEASED FOR BAE V7.2. // rl (071029) RELEASED FOR BAE V7.0. // rl (060920) RELEASED FOR BAE V6.8. // rl (060920) ENHANCEMENT: // Added group default attribute value set option. // rl (060814) ENHANCEMENT: // Added graphical matrix size definition option. // Added group matrix autoselection option. // rl (060614) ENHANCEMENT: // Added attribute deselection option. // rl (060405) ENHANCEMENT: // Added attribute lock flag evaluation. // rl (060403) BUGFIX: // Fixed problem text class faded out attributes. // rl (051206) BUGFIX: // Fixed #-name selection problem. // rl (051021) BUGFIX: // Fixed problem with erroneous macro class selection. // rl (050906) RELEASED FOR BAE V6.6. // rl (050301) ENHANCEMENT: // Added part text reset function. // rl (040824) RELEASED FOR BAE V6.4. // rl (040706) ENHANCEMENT: // Added group selection status preservation to label functions. // rl (040225) ENHANCEMENT: // Added label selection function. // rl (040213) ENHANCEMENT: // Added name/attribute move transfer function. // rl (031204) ENHANCEMENT: // Added macro name list sorting. // rl (030912) RELEASED FOR BAE V6.2. // rl (030613) ENHANCEMENT: // Added group nil attribute assignment option. // rl (030408) ENHANCEMENT: // Added rule preservation in hierarchy less load. // rl (030407) ENHANCEMENT: // Added group matrix copy function. // rl (021211) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (020320) ENHANCEMENT: // Added group name support functions. // rl (020315) ENHANCEMENT: // Added group label macro exchange function. // Added group selection by symbol name(s) function. // rl (010627) RELEASED FOR BAE V5.0. // rl (010627) ENHANCEMENT: // Added group selection by part attribute value. // rl (010427) ENHANCEMENT: // Added group symbols to layout part set include function. // rl (000525) RELEASED FOR BAE V4.6. // rl (990924) RELEASED FOR BAE V4.4. // rl (990924) ENHANCEMENT: // Added load group command with different hierarchy level // support. // rl (981014) RELEASED FOR BAE V4.2. // rl (981014) ENHANCEMENT: // Message system functions introduced. // mb (980710) ENHANCEMENT: // Pulldown menu delimiters introduced. // mb (980710) ENHANCEMENT: // Dynamic multi-language support introduced. // rl (980331) ENHANCEMENT: // Added macro name pattern selection. // rl (980318) BUGFIX: // Fixed problem in select group by macro function. // rl (980116) IMPROVEMENT: // Added unset attributes to group attribute list. // rl (971125) IMPROVEMENT: // Added label rename function. // rl (970929) RELEASED FOR BAE V4.0. // mb (970604) CHANGE: // Applied figure list cross reference index access. // mb (970114) ENHANCEMENT: // New option for (de)selecting macro types/macros. // mb (960919) RELEASED FOR BAE V3.4. // mb (960215) ENHANCEMENT: // Introduced new function for assigning values to // selectable attribute of group-selected parts. // mb (95) RELEASED FOR BAE V3.2. // mb (950209) ENHANCEMENT/NEW: // Introduced option for changing size of group-selected texts. // mb (94) RELEASED FOR BAE V3.0. // mb (94) IMPROVEMENT: // Introduced single element selection/deselection facilities. // mb (93) RELEASED FOR BAE V2.6. // mb (93) ORIGINAL CODING. // // DESCRIPTION // // The scmgroup User Language program provides a menu with // advanced SCM group functions such as automatic selection // and/or de-selection of all objects of a selectable type, // changing the size of group-selected texts, and global // attribute value assignments to group-selected parts. */ // Includes #include "baeparam.ulh" // User Language BAE param. access #include "pop.ulh" // User Language popup utilities #include "mnu.ulh" // User Language menu utilities #include "scm.ulh" // User Language SCM utilities // Disable undo state request #pragma ULCALLERNOUNDO // Messages string UPRABORT = M_UPRABORT(); string UPRFEXIT = M_UPRFEXIT(); string ERRINPVAL = M_ERRINPVAL(); string REPDONE = M("Es wurden keine Fehler festgestellt.", "Operation completed without errors."); string REPSCTEXT = M("Text-Groessen aendern...", "Changing text sizes..."); string REPSCTDONE = M(" Groessenaenderungen durchgefuehrt.", " size changes performed."); string REPNMTDONE = M(" Namens-/Attributverschiebungen durchgefuehrt.", " name/attribute moves performed."); string REPSCLABN = M("Labelnamen aendern...", "Changing label names..."); string REPSCLABM = M("Labelmakronamen aendern...", "Changing label macro names..."); string REPSCANATT = M("Scannen Symbole/Attribute...", "Scanning symbols/attributes..."); string REPGRPNSCAN = M("Scannen Gruppennamen...", "Scanning group names..."); string REPATTL = M("Definierte Attribute :","Defined Attributes : "); string REPATTVALL = M("Attributwerte zu '%s' :", "Attribute values for '%s' : "); string REPGRPATTL = M("Symbolattribute in aktueller Gruppe :", "Symbol Attributes currently selected to group : "); string REPGRPATTP = M("Selektierte Symbole mit Attribut '%s' :", "Currently selected Symbols with Attribute '%s' :"); string REPATTSET = M(" Symbolattributwerte gesetzt.", " symbol attribute values set."); string REPATTRESET = M(" Symbolattributwerte zurueckgesetzt.", " symbol attribute values reset."); string REPNILATT = M("!nicht_gesetzt!","!not_set!"); string REPATTRERR = M("%s %d Fehler bei der Zuweisung (z.B. %s)!", "%s %d errors during assignment (e.g. %s)."); string REPATTRLOCK = M(" %d gesperrte Attribute '%s' nicht gesetzt (z.B. %s)!", " %d locked attributes '%s' not set (e.g. %s)."); string REPSYMSEL = M("%d Symbol(e) selektiert. Jetzt %d Elemente in Gruppe.", "%d symbol(s) selected. Now %d elements in group. Now %d elements in group."); string REPSYMDSEL = M("%d Symbol(e) deselektiert. Jetzt %d Elemente in Gruppe.", "%d symbol(s) deselected. Now %d elements in group."); string REPPOLYSEL = M("%d %sn selektiert. Jetzt %d Elemente in Gruppe.", "%d %ss selected. Now %d elements in group. Now %d elements in group."); string REPPOLYDSEL = M("%d %sn deselektiert. Jetzt %d Elemente in Gruppe.", "%d %ss deselected. Now %d elements in group."); string REPLABSEL = M("%d Label(s) selektiert. Jetzt %d Elemente in Gruppe.", "%d label(s) selected. Now %d elements in group."); string REPLABDSEL = M("%d Label(s) deselektiert. Jetzt %d Elemente in Gruppe.", "%d label(s) deselected. Now %d elements in group."); string REPTXTSEL = M("%d Text(e) selektiert. Jetzt %d Elemente in Gruppe.", "%d text(s) selected. Now %d elements in group."); string REPTXTDSEL = M("%d Text(e) deselektiert. Jetzt %d Elemente in Gruppe.", "%d text(s) deselected. Now %d elements in group."); string REPELEMSEL = M("%d Element(e) hinzuselektiert. Jetzt %d Elemente in Gruppe.", "%d element(s) selected. Now %d elements in group."); string REPELEMDSEL = M("%d Element(e) deselektiert. Jetzt %d Elemente in Gruppe.", "%d element(s) deselected. Now %d elements in group."); string REPMACLIST = M("Auswahl Makrotyp %s :", "Menu Macro Type %s Selection :"); string REPNAMELIST = M("Auswahl Name :","Name Selection :"); string REPTEXTLIST = M("Auswahl Text :","Text Selection :"); string REPLABNDONE = M(" Labelumbenennungen durchgefuehrt.", " label renames performed."); string REPLABMDONE = M(" Labelmakroaenderungen durchgefuehrt.", " label macro changes performed."); string REPLINECON = M("%d Grafiklinien in Verbindungen umgewandelt.", "Converted %d graphic lines to connections."); string REPLCONERR = M("%d Grafiklinien umgewandelt. %d Linien mit Diagonalen/Boegen nicht bearbeitet.", "Converted %d graphic lines. %d lines with diagonals/arcs unchanged"); string UPRGRPFCT = M("%d Elemente in Gruppe. Gruppenfunktion selektieren!", "%d Elements in Group. Select Group Function!"); string UPRGRPFCTN = M("Gruppenfunktion selektieren!", "Select Group Function!"); string UPRFCT1 = M("&Selektieren","&Select"); string UPRFCT2 = M("&Deselektieren","&Deselect"); string UPRFCT3 = M("&Rechteck selektieren","Select &Rectangle"); string UPRFCT4 = M("Re&chteck deselektieren","Deselect Re&ctangle"); string UPRFCT5 = M("%&Textgroessen aendern","%Change &Text Sizes"); string UPRFCT6 = M("%Attr&ibute setzen","%Set &Group Attributes"); string UPRFCT7 = M("Attri&but selektieren","Select Attri&bute"); string UPRFCT8 = M("%&Labels umbenennen","%Rename &Labels"); string UPRFCT9 = M("Labelma&kros setzen","%Set Label &Macros"); string UPRFCT10 = M("%Matri&x-Kopie","%Copy Matri&x"); string UPRFCT11 = M("%Gr&uppennamen setzen","Set Gr&oup Name"); string UPRFCT12 = M("%Laden ohne &Hierarchie","Load without &Hierarchy"); string UPRFCT13 = M("%&Namens-/Attributpositionen uebernehmen", "%Trans&fer Name/Attribute Positions"); string UPRFCT14 = M("Symbolt&exte Reset","R&eset Symbol Texts"); string UPRFCT15 = M("%Gruppe nach L&ayout","%Group in L&ayout"); string UPRFCT16 = M("La&youtbauteil selektieren","Select La&yout Part"); string UPRFCT17 = M("Layoutgruppe &platzieren","Place Layout Gro&up"); string UPRFCT18 = M("%Layoutbauteil&menge","%Layout &Part Set"); string UPRFCT19 = M("%&Grafiklinien zu Verbindungen", "%Graphic Li&nes to Connections"); string UPRFCT20 = M("%Gruppenreport","%Group Report"); string UPRSELSPRT = M("&Bauteile","&Parts"); string UPRSELSCON = M("&Verbindungen","&Connections"); string UPRSELSGRF = M("&Grafik","&Graphik"); string UPRSELSTXT = M("&Texte","&Texts"); string UPRSELALL = M("%A&lles","%A&ll"); string UPRSELAPRT = M("Alle Bau&teile","All Part&s"); string UPRSELACON = M("Alle Verbi&ndungen","All Co&nnections"); string UPRSELAGRF = M("Alle Gra&fik","All Grap&hics"); string UPRSELATXT = M("Alle Te&xte","All Te&xts"); string UPRSELMAC = M("%&Makros","%&Macros"); string UPRSELNAM = M("%N&amen","%N&ames"); string UPRSELGNAM = M("Gru&ppenname","&Group Name"); string UPRSELATTR = M("%Att&ribute","%A&ttributes"); string UPRSELPTYP = M("%P&olygontyp","%&Polygon Type"); string UPRSELNET = M("%Net&z","%N&et"); string UPRSELSYM = M("&Symbole","&Symbols"); string UPRSELLAB = M("&Labels","&Labels"); string UPRSELPIN = M("&Pins","&Pins"); string UPRSELTXT = M("&Texte","&Texts"); string UPRPICKCON = M("Netzverbindung selektieren!", "Select Net Connection!"); string UPRSELORG = M("Gruppennullpunkt waehlen!","Select Group Origin!"); string UPRSELMVEC = M("Diagonalecke erstes Matrixrechteck waehlen!", "Select First Matrix Rectangle Diagonal Vertice!"); string UPRSELMEND = M("Matrix Position Endkopie waehlen!", "Select Matrix End Copy Position!"); string UPRSELNEND = M("Matrix Begrenzungsposition waehlen!", "Select Matrix Border Position!"); string UPRSELWINS = M("Gruppenrechteck Startpunkt waehlen!", "Select Group Rectangle Start Point!"); string UPRSELWINE = M("Gruppenrechteck Endpunkt waehlen!", "Select Group Rectangle End Point!"); string UPRTSIZEM = M("Neue Textgroesse [mm] ? ", "New Text Size [mm] ? "); string UPRTSIZEI = M("Neue Textgroesse [Inch] ? ", "New Text Size [Inch] ? "); string UPRGRPMATC = M("Gruppe Matrixkopie","Group Matrix Copy"); string UPRGRPMATGS = M("Groesse mit Fadenkreuz","Crosshair Size Input"); string UPRGRPMATNS = M("Anzahl mit Fadenkreuz","Crosshair Count Input"); string UPRGRPMATRS = M("Autoselektion 1. Rechteck", "Autoselect 1st Rectangle"); string UPRGRPXCNTD = M("Matrixelemente X-Richtung :", "Matrix X Count :"); string UPRGRPYCNTD = M("Matrixelemente Y-Richtung :", "Matrix Y Count :"); string UPRGRPXCNT = M("Anzahl Matrixelemente X-Richtung ? ", "Matrix X Count ? "); string UPRGRPYCNT = M("Anzahl Matrixelemente Y-Richtung ? ", "Matrix Y Count ? "); string UPRSELANAM = M("Attributname ? ","Attribute Name ?"); string UPRSELAVAL = M("Attributwert(e) ? ","Attribute Value(s) ?"); string UPRSELVAL = M("Attributwert ? ","Attribute Value ?"); string UPRNOVAL = M("&Kein Wert","&No Value"); string UPRDEFAULT = M("&Default","&Default"); string UPRBROWSE = M("&Browse","&Browse"); string UPRGRPANAM = M("Gruppenattribut fuer Aenderung waehlen!", "Select Group Attribute to be set/changed!"); string UPRGRPAVAL = M("Wert fuer Gruppenattribut '%s' ? ", "Value for Group Attribute '%s' ? "); string UPRPLNAME = M("Gehaeusename ('%s') ? ","Package Name ('%s') ?"); string UPRGRPATTOK = M("Wert '%s' an alle '%s'-Attribute zuweisen [J|N] ? ", "Assign value '%s' to all '%s' attributes [Y|N] ? "); string UPRGRPATTROK = M("Alle '%s'-Attribute zuruecksetzen [J|N] ? ", "Reset all '%s' attributes [Y|N] ? "); string UPRGRPATTDOK = M("Alle '%s'-Attribute auf Default setzen [J|N] ? ", "Default all '%s' attributes [Y|N] ? "); string UPRSELMACTP = M("Makrotyp fuer Selektion waehlen!", "Select Macro Type to select!"); string UPRDSELMACTP = M("Makrotyp fuer Deselektion waehlen!", "Select Macro Type to deselect!"); string UPRMACSYM = M("&Symbol","&Symbol"); string UPRMACNSYM = M("%Symbol &negiert","%Symbol &Negated"); string UPRMACLAB = M("&Label","&Label"); string UPRMACNLAB = M("Label n&egiert","Label N&egated"); string UPRMACMRK = M("&Marker","&Marker"); string UPRMACNMRK = M("Marker &negiert","Marker &Negated"); string UPRSELMACRO = M("Makroname(nsmuster) fuer Selektion ? ", "Macro name (or pattern) to select ? "); string UPRDSELMACRO = M("Makroname(nsmuster) fuer Deselektion ? ", "Macro name (or pattern) to deselect ? "); string UPRSELNAME = M("Name(n) fuer Selektion ? ","Name(s) to select ? "); string UPRDSELNAME = M("Name(n) fuer Deselektion ? ", "Name(s) to deselect ? "); string UPRSELTEXT = M("Text(e) fuer Selektion ? ","Text(s) to select ? "); string UPRDSELTEXT = M("Text(e) fuer Deselektion ? ", "Text(s) to deselect ? "); string UPRSELGNAME = M("Gruppenname fuer Selektion ? ", "Group name to select ? "); string UPRDSELGNAME = M("Gruppenname fuer Deselektion ? ", "Group name to deselect ? "); string UPRGRPNAME = M("Gruppenname ? ","Group Name ? "); string UPRGRPRESET = M("Gruppenname zuruecksetzen ?", "Reset Group Name ?"); string UPRLOCKASET = M("Gesperrte Attribute setzen ?", "Set Locked Attributes ?"); string UPRNLABMAC = M("Neuer Labelmakroname ? ", "New label macro name ? "); string UPRSELPART = M("Symbol selektieren!","Select Symbol!"); string UPRSELMPART = M("Mastersymbol selektieren!", "Select Master Symbol!"); string UPRFILE = M("Dateiname ? ","File Name ? "); string UPRCLSCM = M("&Plan","S&heet"); #define UPRCLSSYM "&Symbol" #define UPRCLSLAB "&Label" #define UPRCLSMRK "&Marker" string UPRPOLYTYPE = M("Polygontyp selektieren!","Select Polygon Type!"); string UPRPOLYLINE = M("Grafik&linie","Graphic &Line"); string UPRPOLYDLIN = M("&Punktlinie","&Dot Line"); string UPRPOLYAREA = M("Grafik&flaeche","&Graphic Area"); string UPRPOLYCAREA = M("Ko&ntaktbereich","Co&ntact Area"); string REPGRPCNT = M("%d Elemente in der Gruppe","%d Group Elements"); string REPSYMCNT = M("%6d Symbole","%6d Symbols"); string REPLABCNT = M("%6d Labels","%6d Labels"); string REPPINCNT = M("%6d Pins","%6d Pins"); string REPTEXTCNT = M("%6d Standardtexte","%6d Standard Texts"); string REPCTEXTCNT = M("%6d Kommentartexte","%6d Commentary Texts"); string REPPOLYCNT = M("%6d %s","%6d %s"); string REPCONCNT = M("%6d Verbindungssegmente", "%6d Connection Segments"); string REPBUSCNT = M("%6d Bussegmente", "%6d Bus Segments"); string REPSYMHD = M("Gruppensymbole:","Group Symbols:"); string REPLABHD = M("Gruppenlabels:","Group Labels:"); string REPPINHD = M("Gruppenpins:","Group Pins:"); string REPTEXTHD = M("Gruppenstandardtexte:","Group Standard Texts:"); string REPCTEXTHD = M("Gruppenkommentartexte:","Group Commentary Texts:"); string REPCENTRY = M("%6d %s","%6d %s"); string REPENTRY = M(" %s"," %s"); string WRNSGLUED = M(" Gruppensymbol(e) wegen Verankerung nicht bearbeitet!", " glued group symbol(s) not processed!"); string WRNNOATTRDEF = M("Keine Attributdefinitionen gefunden!", "No attribute definitions found!"); string WRNNOATTRVAL = M("Keine Werte fuer Attribut '%s' definiert!", "No attribute value definitions for '%s' found!"); string WRNNOPATTR = M("Keine Bauteile/Attribute in aktueller Gruppe!", "No parts/attributes selected to current group!"); string WRNNOATTR = M("Attribut '%s' nicht in aktueller Gruppe!", "Attribute '%s' not found in current group!"); string ERRNOGRP = M("Gruppe enthaelt kein Element von Interesse!", "Group contains no element of interest!"); string ERRNOMGRP = M("Gruppe enthaelt kein Symbolmakro '%s'!", "Group contains no symbol macro '%s'!"); string ERRSCTEXT = M("Fehler beim Aendern der Textgroesse!", "Error changing text size!"); string ERRNOHBLK = M("Die Funktion wird fuer hierarchische Bloecke nicht unterstuetzt!", "Function not supported for hierarchical blocks!"); string ERRCOORD = M("Ungueltige Koordinaten!","Invalid coordinates!"); string ERRCREATE = M("Fehler beim Erzeugen eines neuen Elementes!", "Error creating new element!"); string ERRPLCLABEL = M("Fehler bei der Labelplatzierung '%s'!", "Error placing label '%s'!"); string ERRAVALSET = M( "Fehler bei Wertzuweisung Bauteil '%s' Attribut '%s'!", "Error assigning value to part '%s' attribute '%s'!"); string ERRATTRLOCK = M("Bauteil '%s' Attribut '%s' gesperrt!", "Part '%s' attribute '%s' locked!"); string ERRNOFGRP = M("%s '%s' in Datei '%s' not gefunden!", "%s '%s' not found in file '%s'!"); string ERRNOPICK = M_ERRNOPICK(); // INI file parameter name definitions #define PAR_GPARTSUF "GPARTSUF_SCM" // Group part name suffix #define PAR_GPRECTSEL "GPRECTSEL_SCM" // Group rectangle selection flag #define PAR_ATTRUPPER "SATTRUPPER_SCM"// Attribute automatic upper conv. #define PAR_DISPPLNAME "DISPPLNAME_SCM"// $plname part display flag #define PAR_ATTRSETP "ATTR_SET_STD" // Attribute set program #define PAR_NOPLCPVIS "NOPLCPVIS_SCM" // $noplc/plot visibilty relationship // Global definitions #define C_FIGALL 0 // Figure list type all #define PA_DEFVAL "\002" // Default attribute value #define SMALLVAL 0.00000001 // Small compare value #define FONTASP (2.0/3.0) // Font aspect ratio #define DBUTWIDTH 6.5 // Dialog box button width #define DBUTSPACE 8.5 // Dialog box button hor. spacing string PARTSUFFIX = bae_inistrval(PAR_GPARTSUF,"gpcp") /* Group part name suffix */; int GPRECTSEL = bae_iniintval(PAR_GPRECTSEL,0) /* Group rectangle selection mode */; int ATTRUPPER = bae_iniintval(PAR_ATTRUPPER,0) /* Automatic attr. upper case conv. */; int NOPLCPVIS = bae_iniintval(PAR_NOPLCPVIS,3) /* $noplc/plot vis. relationship */; #define GV_GRPXCNT "grpmat_x" // Matrix X count variable #define GV_GRPYCNT "grpmat_y" // Matrix Y count variable #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 ddbclass = bae_planddbclass() /* Layout plan DDB class */; int plcelems = 0 /* Placed element bit field */; int grpelems = 0 /* Group element bit field */; int grpelemn = 0 /* Group element count */; int scandone = 0 /* Group element scan done flag */; string g_dis = "" /* Group empty disable */; string gc_dis = "" /* Group connection empty disable */; string dgc_dis = "" /* Connection empty disable */; string gp_dis = "" /* Group polygon empty disable */; string dgp_dis = "" /* Polygon empty disable */; string gt_dis = "" /* Group text empty disable */; string dgt_dis = "" /* Text empty disable */; string gs_dis = "" /* Group symbol empty disable */; string dgs_dis = "" /* Symbol empty disable */; int selectmode /* Select mode : 0 = deselect 1 = select */; struct ppoint { // Polygon point structure double x,y /* Point coordinates */; int typ /* Point type */; } pplist[] /* Polygon point list */; int ppcnt /* Polygon point count */; int cursearchclass /* Current macro search class */; typedef struct { // Attribute descriptor string anam /* Attribute name */; index C_NREF pl[] /* Attribute part list */; int pn /* Attribute part count */; int textflag /* Attribute text flag */; } ATTDES /* Attribute descriptor */; ATTDES attl[] /* Attribute list */; int attn = 0 /* Attribute count */; index C_NREF attrnref /* Current attribute scan part */; string curattr /* Current attribute name */; STRINGS curdefvall /* Current default value */; int curdefvaln /* Current default value count */; string curattval /* Current attribute value */; int curlock /* Current attribute lock flag */; int curafound /* Current attribute found flag */; int varl[] /* Variant list */; int varn = 0 /* Variant count */; int act_var = 0 /* Active variant */; int act_flag /* Active variant defined flag */; STRINGS namel /* Name list */; int namen = 0 /* Name count */; string curname /* Current scan name */; string curpinname /* Current scan pin name */; string grpfname /* Group file name */; int grpeclass /* Group element class */; index C_CONSEG pickconseg /* Pick connection segment index */; index C_LEVEL picklevel /* Pick connection level index */; int netmatch /* Pick net match flag */; double gx,gy /* Group placement position */; int dispmode /* Bus display mode */; int changes = 0 /* Changes count */; string msg /* Message string */; // SQL command definitions #define V_SELECTA "select variant from varinfo;" // Main program void main() { index C_FIGURE fig /* Figure list index */; string hs_dis = "," /* HighEnd symbol functions disable */; string hgs_dis = "," /* HighEnd group sym.funct. disable */; string gl_dis = "," /* Group label empty disable */; // Test the plan class if (ddbclass==DDBCLUNDEF) error_class(); // Check if coordinate copy call if (bae_peekiact()==2 && askstr("",MAXTEXTLEN)=="coordcopy") { coordcopy(); exit(0); } // Check if call inside function check_fctactive(); // Check if element type scan if (bae_iniintval(PAR_METYPSCAN,1)==1 && !bae_peekiact()) { groupscan(); if (grpelems==0) g_dis=","; if ((plcelems&(1<4) // Abort on default error_abort(); // Disable range check bae_getintpar(0,rangedis); bae_setintpar(0,1); // Free grid lock gridlock=bae_getgridlock(); bae_setgridlock(0); // Get the rectangle points bae_promptdialog(UPRSELWINS); if (bae_inpoint(bae_planwsnx(),bae_planwsny(),x1,y1,0)) { // Restore old range check state bae_setintpar(0,rangedis); // Restore grid lock bae_setgridlock(gridlock); error_abort(); } bae_promptdialog(UPRSELWINE); if (bae_inpoint(x1,y1,x2,y2,1)) { // Restore old range check state bae_setintpar(0,rangedis); // Restore grid lock bae_setgridlock(gridlock); error_abort(); } // Restore old range check state bae_setintpar(0,rangedis); // Restore grid lock bae_setgridlock(gridlock); // Setup the interaction queue bae_clriactqueue(); bae_storemenuiact(1,elemtyp,LMB); bae_storemenuiact(1,selectmode ? 0 : 1,LMB); bae_storemouseiact(1,x1,y1,0,LMB); bae_storemouseiact(1,x2,y1,0,LMB); bae_storemouseiact(1,x2,y2,0,LMB); bae_storemouseiact(1,x1,y2,0,LMB); bae_storemouseiact(1,0.0,0.0,0,RMB); bae_storemenuiact(1,0,LMB); bae_callmenu(MNU_SCMGRPPOLY); } // Group element functions static void selectall(int etyp) /* // Group polygon select/deselect all // Parameters : // int etyp : Element type */ { index C_FIGURE fig /* Figure list index */; int seltype /* Select type */; int gridlock /* Grid lock flag */; int anglelock /* Angle lock flag */; int rangedis /* Range check disabled flag */; // Test if not SCM plan if (ddbclass!=DDBCLSCM) { groupscan(); // Test if all select request if (etyp==C_FIGALL) { // Loop for all elements forall (fig where fig.GROUP!=selectmode) { // Select/deselect element to group scm_elemgrpchg(fig,selectmode); changes++; } prtgrpcount(changes); // Done return; } // Loop for all elements of given type forall (fig where fig.TYP==etyp && fig.GROUP!=selectmode) { // Select/deselect element to group scm_elemgrpchg(fig,selectmode); changes++; } prtgrpcount(changes); // Done return; } // Test if group reset is requested if (!selectmode && etyp==C_FIGALL) { // Reset group bae_clriactqueue(); call(MNU_SCMGRPRESE); // Done return; } // Map the element to the menu type code switch (etyp) { /* All */ case C_FIGALL : seltype=4; break; /* Areas */ case C_FIGPOLY : seltype=2; break; /* Traces */ case C_FIGCON : seltype=1; break; /* Parts */ case C_FIGNREF : seltype=0; break; /* Texts */ case C_FIGTEXT : seltype=3; break; /* All */ default : seltype=4; break; } // Get grid/angle lock gridlock=bae_getgridlock(); anglelock=bae_getanglelock(); bae_getintpar(0,rangedis); // Free grid lock bae_setgridlock(0); // Fix angle lock bae_setanglelock(1); // Disable range check bae_setintpar(0,1); // Perform the group polygon call bae_clriactqueue(); bae_storemenuiact(1,seltype,LMB); bae_storemenuiact(1,selectmode?0:1,LMB); bae_storemouseiact(1,bae_planwslx(),bae_planwsly(),0,LMB); bae_storemouseiact(1,bae_planwsux(),bae_planwsly(),0,LMB); bae_storemouseiact(1,bae_planwsux(),bae_planwsuy(),0,LMB); bae_storemouseiact(1,bae_planwslx(),bae_planwsuy(),0,LMB); bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,0,LMB); call(MNU_SCMGRPPOLY); // Restore grid/angle lock bae_setgridlock(gridlock); bae_setanglelock(anglelock); bae_setintpar(0,rangedis); // Redraw screen screenredraw(); } // Group macro functions static void selectmacros() /* // Select macros on current element */ { index C_MACRO macro /* Macro index */; index C_FIGURE fig /* Figure element index */; string selmacroname /* Selected macro name */; STRINGS hl /* Popup header list */; STRINGS ml /* Macro name list */; int mn = 0 /* Macro count */; string macname /* Macro name */; string s_dis = "," /* Symbol function disable */; string l_dis = "," /* Label function disable */; int negsel = 0 /* Negative selection */; int i /* Loop control variable */; // Select macro type to be selected switch (ddbclass) { // Select symbols/labels on plan level case DDBCLSCM : forall (fig where fig.GROUP!=selectmode && fig.TYP==C_FIGNREF && fig.NREF.MACRO.CLASS==DDBCLSLAB) { l_dis=""; break; } forall (fig where fig.GROUP!=selectmode && fig.TYP==C_FIGNREF && fig.NREF.MACRO.CLASS!=DDBCLSLAB) { s_dis=""; break; } bae_promptdialog(selectmode ? UPRSELMACTP : UPRDSELMACTP); switch (bae_askmenu(5,s_dis+UPRMACSYM,l_dis+UPRMACLAB, s_dis+UPRMACNSYM,l_dis+UPRMACNLAB,UPRABORT)) { // Symbol macros case 0 : cursearchclass=DDBCLSSYM; negsel=0; break; // Label macros case 1 : cursearchclass=DDBCLSLAB; negsel=0; break; // Symbol negated macros case 2 : cursearchclass=DDBCLSSYM; negsel=1; break; // Label negated macros case 3 : cursearchclass=DDBCLSLAB; negsel=1; break; // Abort on default default : error_abort(); } break; // Select markers on symbol/label level case DDBCLSSYM : case DDBCLSLAB : cursearchclass=DDBCLSMRK; bae_promptdialog(selectmode ? UPRSELMACTP : UPRDSELMACTP); switch (bae_askmenu(3,UPRMACMRK,UPRMACNMRK,UPRABORT)) { // Marker macros case 0 : negsel=0; break; // Marker negated macros case 1 : negsel=1; break; // Abort on default default : error_abort(); } break; // Select done on default default : return; } // Build the macro name list forall (macro where macro.CLASS==cursearchclass) { macname=macro.NAME; for (i=mn;i>0;i--) if (ml[i-1]>macname) ml[i]=ml[i-1]; else break; ml[i]=macname; mn++; } // Select macro name with popup menu hl[1]=""; sprintf(hl[0],REPMACLIST,ddbclassname(cursearchclass)); bae_setintpar(16,3061); if ((selmacroname=popupmenu(1,selectmode ? UPRSELMACRO : UPRDSELMACRO, hl,2,ml,mn,UINPOPABORT,0,-1,-1,0,0,0,""))=="" || selmacroname==UINPOPABORT) error_abort(); // Select all figure list elements with selected macro name forall (fig where fig.TYP==C_FIGNREF && fig.GROUP!=selectmode && fig.NREF.MACRO.CLASS==cursearchclass) { macname=fig.NREF.MACRO.NAME; if ((!negsel && strmatch(macname,selmacroname)) || (negsel && !strmatch(macname,selmacroname))) { scm_elemgrpchg(fig,selectmode); changes++; } } // Done if (selectmode) sprintf(msg,cursearchclass==DDBCLSLAB ? REPLABSEL : REPSYMSEL,changes,grpelemn+changes); else sprintf(msg,cursearchclass==DDBCLSLAB ? REPLABDSEL : REPSYMDSEL,changes,grpelemn-changes); bae_prtdialog(msg); } // Group name functions static void selectnames() /* // Select named symbols on current element */ { index C_FIGURE fig /* Figure element index */; STRINGS hl /* Popup header list */; STRINGS nl /* Name list */; int nn = 0 /* Name count */; int elemtyp /* Selection element type */; string selname /* Selection name */; STRINGS selentryl /* Selected entry string list */; int selentryn = 0 /* Selected entry count */; string s_dis = "," /* Symbol function disable */; string l_dis = "," /* Label function disable */; string t_dis = "," /* Text function disable */; int i /* Loop control variable */; // Check if label environment if (ddbclass==DDBCLSCM) { forall (fig where fig.GROUP!=selectmode && fig.TYP==C_FIGNREF && fig.NREF.MACRO.CLASS==DDBCLSLAB) { l_dis=""; break; } forall (fig where fig.GROUP!=selectmode && fig.TYP==C_FIGNREF && fig.NREF.MACRO.CLASS!=DDBCLSLAB) { s_dis=""; break; } forall (fig where fig.GROUP!=selectmode && fig.TYP==C_FIGTEXT) { t_dis=""; break; } // Get selection element class if ((elemtyp=bae_askmenu(4,s_dis+UPRSELSYM,l_dis+UPRSELLAB, t_dis+UPRSELTXT,UPRABORT))<0 || elemtyp>2) error_abort(); } else { forall (fig where fig.GROUP!=selectmode && fig.TYP==C_FIGNREF) { s_dis=""; break; } forall (fig where fig.GROUP!=selectmode && fig.TYP==C_FIGTEXT) { t_dis=""; break; } // Get selection element class if ((elemtyp=bae_askmenu(3,s_dis+UPRSELPIN, t_dis+UPRSELTXT,UPRABORT))<0 || elemtyp>1) error_abort(); if (elemtyp==1) elemtyp=2; } bae_nameclr(); switch (elemtyp) { // Labels case 1 : forall (fig where fig.GROUP!=selectmode && fig.TYP==C_FIGNREF && fig.NREF.MACRO.CLASS==DDBCLSLAB) bae_nameadd(fig.NAME,"","","",2); break; // Texts case 2 : forall (fig where fig.GROUP!=selectmode && fig.TYP==C_FIGTEXT) bae_nameadd(fig.NAME,"","","",2); break; // Symbols/pins default : forall (fig where fig.GROUP!=selectmode && fig.TYP==C_FIGNREF && fig.NREF.MACRO.CLASS!=DDBCLSLAB) bae_nameadd(fig.NAME,"","","",2); } while (bae_nameget(nn,nl[nn],"","","",0)==0) nn++; // Select name with popup menu hl[0]=elemtyp==2 ? REPTEXTLIST : REPNAMELIST; hl[1]=""; // Show the multiple selection menu bae_setintpar(16,3050); popupmulmenu(1,0,elemtyp==2 ? (selectmode ? UPRSELTEXT : UPRDSELTEXT) : (selectmode ? UPRSELNAME : UPRDSELNAME),hl,2,nl,nn, 0,-1,nn+4,100,selentryl,selentryn,0); // Abort if no elements selected if (selentryn<=0) error_abort(); switch (elemtyp) { // Labels case 1 : // Mark all selected figure list elements for (i=0;i=0) { // Query group name predicate if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_GROUPNAME, "?s",grpname)<1) continue; bae_nameadd(grpname,"","","",2); } forall (conseg where conseg.GROUP!=selectmode && conseg.RULEOBJID>=0) { // Query group name predicate if (cap_rulequery(RS_OCCON,conseg,RS_SCMSUBJ,RS_GROUPNAME, "?s",grpname)<1) continue; bae_nameadd(grpname,"","","",2); } // Select group name bae_setintpar(16,3136); if (bae_askname(selgrpname, selectmode ? UPRSELGNAME : UPRDSELGNAME,MAXKEYLEN)) // Aborted error_abort(); groupscan(); // Change selection state forall (fig where fig.GROUP!=selectmode && fig.TYP!=C_FIGCON) { // Query group name predicate if (fig.RULEOBJID<0 || cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ, RS_GROUPNAME,"?s",grpname)<1) grpname=""; if (grpname!=selgrpname) continue; // Select/deselect element to group scm_elemgrpchg(fig,selectmode); changes++; } forall (conseg where conseg.GROUP!=selectmode) { // Query group name predicate if (conseg.RULEOBJID<0 || cap_rulequery(RS_OCCON,conseg, RS_SCMSUBJ,RS_GROUPNAME,"?s",grpname)<1) grpname=""; if (grpname!=selgrpname) continue; // Select/deselect element to group scm_conseggrpchg(conseg,selectmode); changes++; } prtgrpcount(changes); } static void groupselnet() /* // Select elements by net name */ { index C_FIGURE fig /* Figure list index */; // Pick connection segment bae_promptdialog(UPRPICKCON); if (scm_pickconseg(pickconseg)) error(ERRNOPICK); // Scan for pick segment connection level netmatch=0; forall (fig where fig.TYP==C_FIGCON) // Scan the connection segments if (cap_scanfelem(fig,0.0,0.0,0.0,1,NULL,netpickcon,NULL,NULL)) error_scan(); if (netmatch==0) error_scan(); groupscan(); // Change selection state forall (fig where fig.GROUP!=selectmode && fig.TYP==C_FIGNREF) { // Scan the pins netmatch=0; if (cap_scanfelem(fig,0.0,0.0,0.0,1, pinnetscanfunc,NULL,NULL,NULL)) error_scan(); if (netmatch) { // Select/deselect element to group scm_elemgrpchg(fig,selectmode); changes++; } } // Change selection state forall (fig where fig.TYP==C_FIGCON) // Scan the connection segments if (cap_scanfelem(fig,0.0,0.0,0.0,1,NULL,netconfunc,NULL,NULL)) error_scan(); prtgrpcount(changes); } int pinnetscanfunc(index C_MACRO macro,index C_POOL pool, int macinws,string refname,index C_LEVEL level,index C_LEVEL buslevel) /* // Pin net scan function // Return value : // ( 0) if macro out of workspace, // ( 1) if macro inside workspace, // ( 2) if unknown macro, // (-1) on error // Parameters : // index C_MACRO macro : Macro index // index C_POOL pool : Macro pool element index // int macinws : Macro in workspace flag // string refname : Macro reference name // index C_LEVEL level : Macro level index // index C_LEVEL buslevel : Macro bus level index */ { // Check if pin macro if (macro.CLASS!=DDBCLSMRK) // Continue scan return(1); if (levcmp(level,picklevel)==0) netmatch=1; // Abort scan return(0); } int netpickcon(index C_CONBASE conbase,int segidx, int contyp,double lx,double ly,double ux,double uy, int busconflag,int coninws,index C_LEVEL level) /* // Scan connection data block for net level match // Return value : // zero if done or (-1) on error // Parameters : // index C_CONBASE conbase : Connection base // int segidx : Connection segment index // int contyp : Connection type // double lx : Lower X coordinate // double ly : Lower Y coordinate // double ux : Upper X coordinate // double uy : Upper Y coordinate // int busconflag : Connection bus flag // int coninws : Connection in workspace flag // index C_LEVEL level : Connection level */ { index C_CONSEG conseg /* Connection segment index */; int scanidx = 0 /* Scan index */; // Check if connection crosspoint if (contyp==1) // Return without errors return(0); // Search connection segment forall (conseg of conbase) { if (scanidx==segidx) { if (conseg==pickconseg) { picklevel=level; netmatch=1; } break; } else if (scanidx>segidx) break; scanidx++; } // Return without errors return(0); } int netconfunc(index C_CONBASE conbase,int segidx, int contyp,double lx,double ly,double ux,double uy, int busconflag,int coninws,index C_LEVEL level) /* // Scan connection data block for net level match // Return value : // zero if done or (-1) on error // Parameters : // index C_CONBASE conbase : Connection base // int segidx : Connection segment index // int contyp : Connection type // double lx : Lower X coordinate // double ly : Lower Y coordinate // double ux : Upper X coordinate // double uy : Upper Y coordinate // int busconflag : Connection bus flag // int coninws : Connection in workspace flag // index C_LEVEL level : Connection level */ { index C_CONSEG conseg /* Connection segment index */; int scanidx = 0 /* Scan index */; // Check if connection crosspoint if (contyp==1) // Return without errors return(0); // Search connection segment forall (conseg of conbase) { if (scanidx==segidx) { if (levcmp(level,picklevel)==0 && conseg.GROUP!=selectmode) { scm_conseggrpchg(conseg,selectmode); changes++; } break; } else if (scanidx>segidx) break; scanidx++; } // Return without errors return(0); } int levcmp(index C_LEVEL lev1,index C_LEVEL lev2) /* // Compare to levels // Return value : // zero if level net match, else (-1) // Parameters : // index C_LEVEL lev1 : 1st compare level // index C_LEVEL lev2 : 2nd compare level */ { index C_CNET net1, net2 /* Level net indices */; // Compare all level nets forall (net1 of lev1) forall (net2 of lev2) if (net1.NUMBER==net2.NUMBER) // Level match return(0); // No level match return(-1); } static void groupnameassign() /* // Assign group name to group-selected elements */ { index C_FIGURE fig /* Figure list index */; index C_CONSEG conseg /* Connection segment index */; string grpname /* Current group name */; // Scan group names bae_prtdialog(REPGRPNSCAN); bae_nameclr(); forall (fig where fig.TYP!=C_FIGCON && fig.RULEOBJID>=0) { // Query group name predicate if (cap_rulequery(RS_OCFIG,fig,RS_SCMSUBJ,RS_GROUPNAME, "?s",grpname)<1) continue; bae_nameadd(grpname,"","","",2); } forall (conseg where conseg.RULEOBJID>=0) { // Query group name predicate if (cap_rulequery(RS_OCCON,conseg,RS_SCMSUBJ,RS_GROUPNAME, "?s",grpname)<1) continue; bae_nameadd(grpname,"","","",2); } // Select group name grpname=""; bae_setintpar(16,3136); if (bae_askname(grpname,UPRGRPNAME,MAXKEYLEN)) // Aborted error_abort(); // Check if group reset request if (grpname=="" && bae_msgboxverify(UPRGRPRESET,"")!=1) // Aborted error_abort(); // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Loop for all group elements forall (fig where fig.GROUP && fig.TYP!=C_FIGCON) // Assign the group name predicate rule rsc_assfigstrpred(fig,RS_GROUPNAME,grpname,"",""); forall (conseg where conseg.GROUP) // Assign the group name predicate rule rsc_assconstrpred(conseg,RS_GROUPNAME,grpname,"",""); } static void grouptranstextpos() /* // Transfer name/attribute moves of group symbols */ { index C_FIGURE sfig /* Source figure list index */; index C_FIGURE fig /* Figure list index */; index C_NREF nref /* Named reference index */; index C_MACRO macro /* Macro index */; index C_REFTEXT rmod /* Ref. text modifier index */; double ang /* Element angle */; double tang /* Text angle */; double btx, bty /* Back transf. text coords. */; double asin, acos /* Angle sin, cos values */; int mirr /* Element mirror mode */; int tmirr /* Text mirror mode */; string lastname = "" /* Last processed name */; varcheck(); // Pick symbol bae_promptdialog(UPRSELMPART); if (scm_pickelem(sfig,C_FIGNREF)==0) { // Get the macro name nref=sfig.NREF; macro=nref.MACRO; // Check if label if (macro.CLASS==DDBCLSLAB) return; // Get part data ang=sfig.ANGLE; mirr=sfig.MIRROR; nref=sfig.NREF; asin=sin(mirr ? -ang : ang); acos=cos(mirr ? -ang : ang); forall (fig where fig.GROUP && fig!=sfig && lastname!=fig.NAME && fig.NREF.MACRO==macro) { lastname=fig.NAME; // First reset any name move if (scm_attachtextpos(fig,"",0.0,0.0,0.0,0.0,0)==0) cap_nrefsearch("",fig); // Transfer name moves forall (rmod of nref) { // Transform rel. to abs. position btx=acos*(rmod.X-macro.MNX)- asin*(rmod.Y-macro.MNY); bty=asin*(rmod.X-macro.MNX)+ acos*(rmod.Y-macro.MNY); bty= mirr ? (-bty) : bty ; tmirr= (rmod.MIRROR!=0)!=(mirr!=0) ? 1 : 0 ; tang=rmod.ANGLE; tang+=tmirr ? -ang : ang ; // Save current state for undo if (changes==0) bae_callmenu(MNU_BAESAVESTATE); // Store the text position if (scm_attachtextpos(fig,rmod.STR, fig.X+btx,fig.Y+bty,tang,rmod.SIZE,tmirr)==0) cap_nrefsearch("",fig); // Increment the changes count changes++; } } // Check the changes count if (!changes) // No element in group/changed errormsg(ERRNOMGRP,macro.NAME); } else { // No valid pick bae_prtdialog(ERRNOPICK); } // Done bae_prtdialog(itoa(changes)+REPNMTDONE); } void resetparttexts() /* // Reset text positions of mouse-selectable parts */ { index C_FIGURE fig /* Figure list index */; int gluecnt = 0 /* Glued parts count */; int cflag = 0 /* Change flag */; varcheck(); // Abort if invalid plan class if (ddbclass!=DDBCLSCM && ddbclass!=DDBCLSSYM) error_class(); // Count glued symbols/parts forall (fig where fig.TYP==C_FIGNREF && fig.GROUP && (fig.FIXED&2)) gluecnt++; // Loop for all unglued group parts forall (fig where fig.TYP==C_FIGNREF && fig.GROUP && !(fig.FIXED&2)) { // Save current state for undo if (cflag==0) { bae_callmenu(MNU_BAESAVESTATE); cflag=1; } scm_elemgrpchg(fig,0); scm_attachtextpos(fig,"",0.0,0.0,0.0,0.0,0); } if (gluecnt) // Display glued symbols message perror(itoa(gluecnt)+WRNSGLUED); } /*________________________________________________________________*/ // Group size change routines static void line2con() /* // Convert lines to connections */ { index C_FIGURE fig /* Figure list element */; index C_FIGURE dfig[] /* Delete figure list */; int dfign = 0 /* Delete figure count */; index C_POLY poly /* Polygon index */; index C_POINT p /* Point index */; int errors = 0 /* Error count */; int i /* Loop control variable */; forall (fig where fig.GROUP && fig.TYP==C_FIGPOLY) { poly=fig.POLY; if (poly.TYP!=C_POLYDOCLINE) continue; // Store polygon bae_clearpoints(); forall (p of poly) bae_storepoint(p.X,p.Y,p.TYP); // Store connection segments if (scm_storecon()) { errors++; } else { // Mark old graphic line for delete dfig[dfign]=fig; dfign++; // Increment the changes count changes++; } } // Delete old graphic lines for (i=0;i=attn) { sprintf(prompt,WRNNOATTR,answer); popupmessage(1,-1,-1,prompt,"",""); return; } // Ask for attribute value sprintf(prompt,UPRGRPAVAL,selatt.anam); // Check if obsolete attribute if (!selatt.textflag) { curattval=PA_NILVAL; } // Check for dialog support else if (bae_dialclr()) { curattval=bae_readedittext(prompt,"",MAXKEYLEN); // Check if abort request if (curattval==UINPOPABORT) error_abort(); } else { bae_nameclr(); forall (nref where nref.MACRO.CLASS==DDBCLSSYM && cap_nrefsearch(nref.NAME,fig)==0 && fig.GROUP && !(fig.FIXED&2)) { curattr=selatt.anam; if (cap_nrefsearch(symname,fig)==0) if (cap_scanpool(fig.NREF.MACRO,0.0,0.0,0.0,0, amacfunc,NULL,NULL,defattrfunc)!=0) error_scan(); } // Create the dialog box controls cy=DIAL_TOPMARG; // Store text edit controls editidx=dial_string("",MAXTEXTLEN,0.0,cy); // Store the OK and abort button bae_dialaddcontrol(PA_OK,0,0,0,0.0,0.0,0.0,"",0, DIAL_LEFTMARG,cy,0.0,""); bae_dialaddcontrol(PA_ABORT,0,0,0,0.0,0.0,0.0,"",0, DIAL_LEFTMARG+5.0,cy,0.0,""); cx=DIAL_LEFTMARG+20.0; bae_dialaddcontrol(PA_ACT,0,1,0,0.0,0.0,0.0,"",0, cx,cy,10.0,UPRNOVAL); cx+=11.0; bae_dialaddcontrol(PA_ACT,0,4,0,0.0,0.0,0.0,"",0, DIAL_LEFTMARG+31.0,cy,10.0,UPRDEFAULT); cx+=11.0; switch (selatt.anam) { case "$plname" : bae_dialaddcontrol(PA_ACT,0,2,0,0.0,0.0,0.0,"",0, cx,cy,10.0,UPRBROWSE); cx+=11.0; // Get the layout library name libname=strgetvarfilename(scm_defloglname()); catext(libname,DDBEXT); break; case "$rlname" : bae_dialaddcontrol(PA_ACT,0,3,0,0.0,0.0,0.0,"",0, cx,cy,10.0,UPRBROWSE); cx+=11.0; // Get the layout library name libname=strgetvarfilename(scm_defloglname()); catext(libname,DDBEXT); break; default : if (bae_nameget(0,"","","","",0)!=0) break; bae_dialaddcontrol(PA_ACT,0,5,0,0.0,0.0,0.0,"",0, cx,cy,10.0,UPRBROWSE); cx+=11.0; } do { // Call the dialog function bae_setintpar(16,3024); switch (bae_dialaskparams(prompt,0, DIAL_LEFTMARG+cx-0.2+DIAL_RIGHTSMARG,cy+1.6)) { // Done case 0 : bae_dialgetdata(editidx,0,0.0,curattval); repflag=0; break; case 1 : // Store reset value attribute curattval=PA_NILVAL; repflag=0; break; // Browse $plname case 2 : bae_dialgetdata(editidx,0,0.0,curattval); if (curattval==PA_NILVAL) curattval=""; if (ATTRUPPER) strlower(curattval); if (bae_askddbename(curattval,libname,DDBCLLPRT, msgstring(UPRPLNAME,convstring(libname,1)))!=0) break; // Check if display request enabled if (bae_swconfig(0)==BAE_HighEnd && bae_iniintval(PAR_DISPPLNAME,0)) { // Build the load part macro // request message sprintf(msg,"%d %s\"%s",MSGID_LLPRTMAC, libname,curattval); // Send the message bae_sendmsg(msg,0); } if (ATTRUPPER) strupper(curattval); repflag=0; break; // Browse $rlname case 3 : bae_dialgetdata(editidx,0,0.0,curattval); if (curattval==PA_NILVAL) curattval=""; if (ATTRUPPER) strlower(curattval); if (bae_askddbename( curattval,libname,DDBCLLLIB,"")!=0) break; if (ATTRUPPER) strupper(curattval); repflag=0; break; case 4 : // Store default value attribute curattval=PA_DEFVAL; repflag=0; break; // Browse default values case 5 : bae_dialgetdata(editidx,0,0.0,curattval); if (curattval==PA_NILVAL) curattval=""; // Select value bae_setintpar(16,3127); if (bae_askname(curattval,UPRSELVAL,MAXTEXTLEN)) // Aborted break; repflag=0; break; // Fail/abort case (-1) : error_abort(); } } // Stop if no further repeat requests while (repflag); } // Query the current active variant if (cap_rulequery(RS_OCSCMDB,0,RS_SCMSUBJ,RS_VARIANT,"?d",act_var)<1) // Set default variant act_var=0; // Select all variant table entries varn=0; act_flag=0; sqlcmd(bae_planfname(),V_SELECTA,datafunc); // Check if active variant defined if (!act_flag) { for (i=varn;i>0;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,""); // Build verification menu if (curattval==PA_DEFVAL) sprintf(prompt,UPRGRPATTDOK,selatt.anam); else if (curattval==PA_NILVAL) sprintf(prompt,UPRGRPATTROK,selatt.anam); else sprintf(prompt,UPRGRPATTOK,curattval,selatt.anam); sprintf(hl[0],REPGRPATTP,selatt.anam); hn=2; for (en=0;en0) { bae_setintpar(16,3063); if ((answer=popupmenu(4,prompt, hl,hn,el,en,UINPOPABORT,0,-1,-1,0,0,2,""))==UINPOPABORT) break; // Check on no answer if (answer==UINNO) // Abort/done break; // Check on yes answer if (answer==M_UINYES()) { // Set all attributes while ((selatt.pn--)>0) { symname=selatt.pl[selatt.pn].NAME; curattr=selatt.anam; curdefvall[0]=PA_NILVAL; curdefvaln=1; curlock=0; if (cap_nrefsearch(symname,fig)==0) if (cap_scanpool(fig.NREF.MACRO,0.0,0.0,0.0,0, amacfunc,NULL,NULL,chkattrfunc)!=0) error_scan(); // Check if default value request if (curattval==PA_DEFVAL) setval=curdefvall[0]; if (curlock && curattval!=PA_DEFVAL && lockignore==2) lockignore=bae_msgboxverify(UPRLOCKASET,""); // Check if locked attribute if (curlock && curattval!=PA_DEFVAL && !lockignore) { lockcnt++; sprintf(lockstring,REPATTRLOCK, lockcnt,curattr,symname); } else { // Save current state for undo if (cflag==0) { bae_callmenu(MNU_BAESAVESTATE); cflag=1; } if (attrulp!="") if (cap_getpartattrib( symname,curattr,oldval)!=0) oldval=PA_NILVAL; // Set the attribute if (scm_setpartattrib( symname,curattr,setval,3)) { // Update the error count errcnt++; errstring=symname+"/"+curattr; } else { // Check if extra program call if (attrulp!="") { varset(GV_SATTRSYM,symname); varset(GV_SOATTRN,1); varset(GV_SOATTRNL+"0",curattr); varset(GV_SOATTRVL+"0",oldval); runulprog(attrulp); vardelete(GV_SATTRSYM); vardelete(GV_SOATTRNL+"0"); vardelete(GV_SOATTRVL+"0"); vardelete(GV_SOATTRN); } if (curattr=="$noplc" && (NOPLCPVIS&2)==2) { if (act_var==0) { for (i=0;i=0;i--) if (rulel[i]==rulename) { // Delete the old rule for (j=i;j0) { if (cap_rulefigdet(fig)) rsc_error(-1); } } static void groupselpattrib() /* // Group select parts by attribute values */ { index C_MACRO macro /* Macro index */; index C_NREF nref /* Named reference index */; index C_FIGURE fig /* Figure list index */; index C_ATTRIBUTE attr /* Attribute index */; string vattnam /* Variant attribute name */; STRINGS hl /* Popup menu header list */; int hn = 0 /* Popup menu header count */; STRINGS selentryl /* Selected entry string list */; int selentryn = 0 /* Selected entry count */; string prompt = "" /* Prompt string */; int found /* Attribute found flag */; int afound /* Any attribute value found flag */; int negsel = 0 /* Negative selection */; int i /* Loop control variable */; // Build attribute name list bae_prtdialog(REPSCANATT); forall (nref) forall (attr of nref) gcname(strmatch(attr.NAME,"*\003*\003") ? strextract(attr.NAME,0,strlen(attr.NAME)-5) : attr.NAME); forall (macro where macro.CLASS==DDBCLSSYM) // Scan object data cap_scanpool(macro,0.0,0.0,0.0,1,amacfunc,NULL,NULL,atextfunc); // Abort with warning if attributes found if (namen==0) { popupmessage(1,-1,-1,WRNNOATTRDEF,"",""); return; } // Build the attribute selection popup menu hl[0]=REPATTL; hl[1]=""; hn=2; // Select group attribute to be selected bae_setintpar(16,3062); if ((curattr=popupmenu(4,UPRSELANAM,hl,hn,namel,namen, UINPOPABORT,0,-1,-1,0,0,0,UINPOPABORT))=="" || curattr==UINPOPABORT || curattr[0]!='$') error_abort(); // Query the current active variant if (cap_rulequery(RS_OCSCMDB,0,RS_SCMSUBJ,RS_VARIANT,"?d",act_var)<1) // Set default variant act_var=0; // Build attribute value list bae_prtdialog(REPSCANATT); namen=0; vattnam=varattrname(curattr,act_var); forall (fig where fig.TYP==L_FIGNREF && fig.GROUP!=selectmode) { nref=fig.NREF; found=0; if (act_var) forall (attr of nref where attr.NAME==vattnam) { gcname(attr.VALUE); found=1; break; } if (found) continue; forall (attr of nref where attr.NAME==curattr) { gcname(attr.VALUE); found=1; } if (found) continue; curafound=0; cap_scanpool(nref.MACRO,0.0,0.0,0.0,0,amacfunc,NULL,NULL, chkattrfunc); if (curafound) gcname(REPNILATT); } // Abort with warning if no attribute values found if (namen==0) { sprintf(prompt,WRNNOATTRVAL,curattr); popupmessage(1,-1,-1,prompt,"",""); return; } // Build the attribute selection popup menu sprintf(hl[0],REPATTVALL,curattr); // Select group attribute value to be selected bae_setintpar(16,3063); popupmulmenu(5,0,UPRSELAVAL,hl,hn,namel,namen, 0,-1,hn+namen+2,100,selentryl,selentryn,negsel); // Abort if no values selected if (selentryn<=0) error_abort(); // Loop for all parts forall (nref where nref.MACRO.CLASS==DDBCLSSYM) { found=afound=0; if (act_var) forall (attr of nref where attr.NAME==vattnam) { found=afound=1; for (i=0;i=selentryn)) && cap_nrefsearch(nref.NAME,fig)==0 && fig.GROUP!=selectmode) { scm_elemgrpchg(fig,selectmode); changes++; } break; } if (found) continue; // Search attribute forall (attr of nref where attr.NAME==curattr) { afound=1; for (i=0;i=selentryn)) && cap_nrefsearch(nref.NAME,fig)==0 && fig.GROUP!=selectmode) { scm_elemgrpchg(fig,selectmode); changes++; } break; } if (afound) continue; for (i=0;i0 && lock) curlock=1; // Query the attribute base variant lock state if (curlock==0 && act_var!=0) if (cap_rulequery(RS_OCPOOL, textp,RS_SCMSUBJ,RS_ATTVAR0,"?d",lock)>0 && lock) curlock=1; // Query the attribute default value if (cap_rulequery(RS_OCPOOL,textp,RS_SCMSUBJ,RS_INIVAL, "?s",curdefvall[0])<1) curdefvall[0]=PA_NILVAL; curdefvaln=1; for (curdefvaln=1;curdefvaln<100;curdefvaln++) if (cap_rulequery(RS_OCPOOL,textp, RS_SCMSUBJ,RS_INIVAL+itoa(curdefvaln),"?s", curdefvall[curdefvaln])<1) break; if (curlock) // Check if valid default attribute for (i=0;i0) bae_nameadd(defval,"","","",2); for (i=1;i<100;i++) { if (cap_rulequery(RS_OCPOOL,textp, RS_SCMSUBJ,RS_INIVAL+itoa(i),"?s",defval)<1) break; bae_nameadd(defval,"","","",2); } } // Return without errors return(0); } void addattr(string attrname,index C_NREF nref,int textflag) /* // Add attribute/part combination to attribute list // Parameters : // string attrname : Attribute name // index C_NREF nref : Attribute named reference // int textflag : Attribute text flag */ { int slb /* Search lower boundary */; int sub /* Search upper boundary */; int sidx /* Search index */; int compres /* Compare result */; int i /* Loop control variable */; // Check if variant attribute if (attrname[strlen(attrname)-1]=='\003') // Ignore variant attribute return; // Store the attribute // Init the search area slb=0; sub=attn-1; compres=(-1); // Loop until search area empty while (slb<=sub) { // Get the search index sidx=(slb+sub)>>1; // Test if entry found // Update the search area if ((compres=numstrcmp(attrname,attl[sidx].anam))==0) { slb=sidx; break; } if (compres<0) sub=sidx-1; else slb=sidx+1; } // Insert new entry to attribute list if (compres!=0) { // This is a new attribute entry for (i=attn;i>slb;i--) attl[i]=attl[i-1]; attl[slb].pn=0; attl[slb].textflag=0; attn++; } // Store the current part to the attribute part list attl[slb].anam=attrname; attl[slb].textflag|=textflag; // Avoid double storage of same part if (attl[slb].pn==0 || attl[slb].pl[attl[slb].pn-1]!=nref) { attl[slb].pl[attl[slb].pn]=nref; attl[slb].pn++; } } /*________________________________________________________________*/ // Group label functions static void grouplabrename() /* // Rename group-selected labels */ { index C_FIGURE fig /* Figure list element */; index C_FIGURE dfig /* Delete figure list element */; index C_FIGURE nfig /* New figure list element */; index C_FIGURE grpml[] /* Group mark request list */; index C_NREF nref /* Named reference index */; index C_REFTEXT rmod /* Ref. text modifier index */; index C_MACRO macro /* Macro index */; double ang /* Symbol angle */; double x, y /* Symbol coords. */; double tang /* Text angle */; double btx, bty /* Back transf. text coords. */; double asin, acos /* Angle sin, cos values */; int mirr /* Symbol mirror mode */; int tmirr /* Text mirror mode */; string newname /* New net name */; STRINGS rl /* Rule list */; int i /* Loop control variable */; // Select new label name if (scm_asktreename(newname)!=0) // Abort error_abort(); // Loop thru all group selected labels bae_prtdialog(REPSCLABN); forall (fig where fig.GROUP && fig.TYP==C_FIGNREF && fig.NREF.MACRO.CLASS==DDBCLSLAB && fig.NAME!=newname && !(fig.FIXED&2)) { // Save current state for undo if (changes==0) bae_callmenu(MNU_BAESAVESTATE); // Place the label if (scm_storelabel(newname,0,fig.X,fig.Y,fig.ANGLE,0)) errormsg(ERRPLCLABEL,newname); // Transfer rules if (fig.RULEOBJID>=0 && cap_nrefsearch("",nfig)==0) // Get rules if (rsc_getfigrules(fig,rl)>0) // Attach rules if (cap_rulefigatt(nfig,rl)) rsc_error(-1); cap_nrefsearch("",grpml[changes]); // Get label data nref=fig.NREF; x=fig.X; y=fig.Y; ang=fig.ANGLE; mirr=fig.MIRROR; macro=nref.MACRO; // Transfer name moves forall (rmod of nref) if (cap_nrefsearch("",nfig)==0) { // Transform rel. to abs. position asin=sin(mirr ? -ang : ang); acos=cos(mirr ? -ang : ang); btx=acos*(rmod.X-macro.MNX)-asin*(rmod.Y-macro.MNY); bty=asin*(rmod.X-macro.MNX)+acos*(rmod.Y-macro.MNY); bty= mirr ? (-bty) : bty ; tmirr=(rmod.MIRROR!=0)!=(mirr!=0) ? 1 : 0 ; tang=rmod.ANGLE; tang+=tmirr ? -ang : ang ; // Store the text position scm_attachtextpos(nfig,rmod.STR, x+btx,y+bty,tang,rmod.SIZE,tmirr); } dfig=fig; scm_delelem(dfig); // Increment the changes count changes++; } // Check the changes count if (!changes) // No element in group/changed error(ERRNOGRP); // Reselect to group for (i=0;i=0 && cap_nrefsearch("",nfig)==0) // Get rules if (rsc_getfigrules(fig,rl)>0) // Attach rules if (cap_rulefigatt(nfig,rl)) rsc_error(-1); cap_nrefsearch("",grpml[changes]); dfig=fig; scm_delelem(dfig); // Increment the changes count changes++; } // Check the changes count if (!changes) // No element in group/changed error(ERRNOGRP); // Reselect to group for (i=0;ix1) grpxcnt=floor((x2-x1+SMALLVAL)/fabs(xstep)); else grpxcnt=floor((x1-x2+SMALLVAL)/fabs(xstep)); if (sizemode==2) grpxcnt++; if (ystep==0.0) grpycnt=0; else if (y2>y1) grpycnt=floor((y2-y1+SMALLVAL)/fabs(ystep)); else grpycnt=floor((y1-y2+SMALLVAL)/fabs(ystep)); if (sizemode==2) grpycnt++; if (grpxcnt<=0 || grpycnt<=0) error(ERRCOORD); } // Save current state for undo bae_callmenu(MNU_BAESAVESTATE); // Loop for all matrix elements for (i=0;i=0 && cap_nrefsearch("",nfig)==0) // Get rules if (rsc_getfigrules(fig,rl)>0) // Attach rules if (cap_rulefigatt(nfig,rl)) rsc_error(-1); // Transfer attributes if (planclass==DDBCLSCM && cap_nrefsearch("",nfig)==0) { lastidx=0; forall (att of nref where scm_chkattrname(att.NAME)==0 && att.NAME!="$spname") lastidx++; // Copy the part attributes attidx=0; forall (att of nref where scm_chkattrname(att.NAME)==0 && att.NAME!="$spname") { attidx++; scm_setpartattrib(nfig.NAME,att.NAME, att.VALUE,4|(attidx==1 ? 1 : 0)| (attidx==lastidx ? 2 : 0)); } } // Transfer name moves forall (rmod of nref) if (cap_nrefsearch("",nfig)==0) { // Transform rel. to abs. position btx=acos*(rmod.X-macro.MNX)- asin*(rmod.Y-macro.MNY); bty=asin*(rmod.X-macro.MNX)+ acos*(rmod.Y-macro.MNY); bty= mirr ? (-bty) : bty ; tmirr= (rmod.MIRROR!=0)!=(mirr!=0) ? 1 : 0 ; tang=rmod.ANGLE; tang+=tmirr ? -ang : ang ; // Store the text position scm_attachtextpos(nfig,rmod.STR, x+btx+i*xstep,y+bty+j*ystep, tang,rmod.SIZE,tmirr); } } } // Deselect all symbol elements forall (fig where fig.GROUP && fig.TYP==C_FIGNREF && fig.NREF.MACRO.CLASS!=DDBCLSLAB) scm_elemgrpchg(fig,0); // Get grid/angle lock gridlock=bae_getgridlock(); anglelock=bae_getanglelock(); // Free grid lock bae_setgridlock(0); // Free angle lock bae_setanglelock(0); // Loop for all matrix elements bae_setintpar(2,1); for (i=0;i0) // Attach rules if (cap_rulefigatt(fig,rl)) rsc_error(-1); // Return without errors return(0); } int textfunc(index C_POOL textp,double tx,double ty,double tangle, int mirrflag,double tsize,string tstr,int textinws,int macclass,int varattr) /* // Text place function // Return value : // zero if done or (-1) on error // index C_POOL 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 */ { index C_FIGURE fig /* Figure list index */; STRINGS rl /* Rule list */; string attr /* Attribute value */; double flen /* Text frame length */; double vx,vy /* Text angle vector */; // Check if horizontal center vector back translation if (textp.TEXT.MODE&TEXTHCENT) { // Get the text correction length flen=0.5*tsize*FONTASP*strlen(tstr); // Get the text angle vector vx=cos(tangle); vy=sin(tangle); // Get the corrected text coordinates tx+=vx*flen; ty+=vy*flen; } // Check if vertical center vector back translation if (textp.TEXT.MODE&TEXTVCENT) { // Get the text correction length flen=0.5*tsize; // Get the text angle vector vx=cos(tangle); vy=sin(tangle); // Get the corrected text coordinates tx-=vy*flen; ty+=vx*flen; } if (textp.TEXT.STR[0]=='$' && grpeclass==DDBCLSCM) switch (macclass) { case DDBCLSSYM : if (con_getddbpattrib( grpfname,curname,"",textp.TEXT.STR,attr)==1) tstr=attr; break; case DDBCLSMRK : if (con_getddbpattrib( grpfname,curname,curpinname,textp.TEXT.STR,attr)==1) tstr=attr; break; } if (tstr=="") return(0); // Store the text scm_storetext(tstr,tx,ty,tangle,tsize,mirrflag,textp.TEXT.MODE); // Select new text to group if (cap_lastfigelem(fig)==0) scm_elemgrpchg(fig,1); if (cap_lastfigelem(fig)==0) if (rsc_getpoolrules(textp,rl)>0) // Attach rules if (cap_rulefigatt(fig,rl)) rsc_error(-1); // Return without errors return(0); } int gcname(string name) /* // Get or create a name list entry // Return value : // entry index // Parameters : // string name : Name */ { int slb = 0 /* Search lower boundary */; int sub = namen-1 /* Search upper boundary */; int sidx /* Search index */; int compres /* Compare result */; // Loop until search area empty while (slb<=sub) { // Get the search index sidx=(slb+sub)>>1; // Get the comparison result if ((compres=strcmp(name,namel[sidx]))==0) // Name found return(sidx); // Update the search area if (compres<0) sub=sidx-1; else slb=sidx+1; } // Update the name list for (sidx=namen;sidx>slb;sidx--) namel[sidx]=namel[sidx-1]; // Insert name namel[slb]=name; namen++; // Return sheet index return(slb); } static int groupempty() /* // Test if group is empty // Return value : // zero if group not empty or nonzero if empty */ { index C_FIGURE fig /* Figure list index */; // Loop thru the figure list forall (fig where fig.GROUP) // Return the group not empty code return(0); // Group contains no element; return the group empty code return(1); } static void groupscan() /* // Scan group element types */ { index C_FIGURE fig /* Figure list index */; index C_CONSEG conseg /* Connection segment index */; // Count group elements forall (fig where fig.GROUP && fig.TYP!=C_FIGCON) grpelemn++; forall (conseg where conseg.GROUP) grpelemn++; if (grpelemn!=0) { forall (fig where fig.GROUP && fig.TYP==C_FIGNREF) { grpelems|=(1<0;i--) if (varl[i-1]