/* MIRRON (STD) -- Mirror Pick Element, Change Edit Direction */ /* MIRRON (STD) -- Pickelement Spiegelung, Editierrichtung wechseln */ /* -- INTENDED FOR KEY-CALL USE (:Mirror On) -- */ /* // Copyright (c) 1995-2012 Oliver Bartels F+E, Muenchen // Author: Manfred Baumeister // Changes History: // rl (120427) RELEASED FOR BAE V7.8. // rl (101019) RELEASED FOR BAE V7.6. // rl (100706) ENHANCEMENT: // Added group element mirroring options. // rl (091021) RELEASED FOR BAE V7.4. // rl (091009) ENHANCEMENT: // Added trace/polygon edit direction toggle option. // rl (081014) RELEASED FOR BAE V7.2. // rl (071029) RELEASED FOR BAE V7.0. // rl (060829) RELEASED FOR BAE V6.8. // rl (050920) RELEASED FOR BAE V6.6. // rl (050307) ENHANCEMENT: // Introdcued toggle mirror mode. // rl (040811) RELEASED FOR BAE V6.4. // rl (030904) RELEASED FOR BAE V6.2. // rl (021209) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (010625) RELEASED FOR BAE V5.0. // rl (000509) RELEASED FOR BAE V4.6. // rl (991103) RELEASED FOR BAE V4.4. // rl (980910) RELEASED FOR BAE V4.2. // rl (970929) RELEASED FOR BAE V4.0. // mb (960919) RELEASED FOR BAE V3.4. // mb (95) RELEASED FOR BAE V3.2. // mb (950103) ORIGINAL CODING. // // DESCRIPTION // // The mirron User Language program designates the currently // active BAE menu function and performs a submenu interaction // for mirroring the currently processed object (if an object // is picked and if mirroring is permitted). This program // must be configured for implicit hotkey program call // (e.g. or ). */ // Includes #include "pop.ulh" // User Language popup include // Enforce standard caller type #pragma ULCALLERSTD // Disable undo state request #pragma ULCALLERNOUNDO // INI file parameter name definitions #define PAR_MIRRTOGGLE "MIRRTOGGLE_STD"// Mirror toggle flag // Globals int MIRR_TOGGLE = bae_iniintval(PAR_MIRRTOGGLE,1); // Mirror toggle flag int ddbclass = bae_planddbclass() /* Plan DDB class */; // Messages string UPRABORT = M_UPRABORT(); string UPRMFCT = M("Spiegelungsfunktion selektieren!", "Select mirror function!"); string UPRSFCT1 = M("&Symbole/Labels Spiegeln", "&Symbols/Labels mirroring"); string UPRSFCT2 = M("&Texte Spiegeln","&Texts mirroring"); string UPRSFCT3 = M("&Elemente Spiegeln","&Element mirroring"); string UPRSFCT4 = M("Gruppens&ymbole/labels Spiegeln", "Group S&ymbols/Labels mirroring"); string UPRSFCT5 = M("Gruppente&xte Spiegeln","Group te&xts mirroring"); string UPRSFCT6 = M("%Spiegelungs&modus setzen","%Set &Mirror Mode"); string UPRGFCT1 = M("&Bauteile Spiegeln","&Parts mirroring"); string UPRGFCT2 = M("&Texte Spiegeln","&Texts mirroring"); string UPRGFCT3 = M("&Elemente Spiegeln","&Element mirroring"); string UPRGFCT4 = M("Gruppenb&auteile Spiegeln", "Group p&arts mirroring"); string UPRGFCT5 = M("Gruppente&xte Spiegeln","Group te&xts mirroring"); string UPRGFCT6 = M("%Spiegelungs&modus setzen","%Set &Mirror Mode"); string UPRMMODE = M("Spiegelungsmodus selektieren!", "Select mirror mode!"); string UPRMODE1 = M("Spiegeln &Ein" ,"Mirror &On"); string UPRMODE2 = M("Spiegeln &wechseln" ,"&Toggle Mirror"); string UPRSELELEM = M("Elemente selektieren!","Select Elements!"); string UPRSELPART = M("Bauteile selektieren!","Select Parts!"); string UPRSELSYMBOL = M("Symbole/Labels selektieren!", "Select Symbols/Labels!"); string UPRSELTEXT = M("Texte selektieren!","Select Texts!"); string REPSYMMIRR = M("%d Gruppensymbole/labels gespiegelt.", "Mirrored %d group symbols/labels."); string REPPARTMIRR = M("%d Gruppenbauteile gespiegelt.", "Mirrored %d group parts."); string REPTEXTMIRR = M("%d Gruppentexte gespiegelt.", "Mirrored %d group texts."); string ERRELEMGLUED = M("Element '%s' ist verankert!", "Element '%s' is glued!"); string ERRMIRROR = M("Elementspiegelung '%s' konnte nicht zurueckgesetzt werden!", "Error unmirroring element '%s'!"); string ERRNOPICK = M_ERRNOPICK(); // Main program void main() { // Test the interpreter type switch (uliptype()) { /* SCM */ case ULIPSCM : mirron_scm(); break; /* GED */ case ULIPGED : mirron_ged(); break; /* CED */ case ULIPCED : mirron_ced(); break; // Ignore on default default : break; } // Done } void mirron_scm() /* // Mirror picked SCM object */ { index C_FIGURE fig /* Figure list index */; index C_NREF nref /* Named reference index */; index C_TEXT text /* Text index */; index C_CONSEG conseg /* Connection segment index */; index C_BUSTAP bustap /* Bustap index */; string s_dis = "," /* Symbol function disable */; string t_dis = "," /* Text function disable */; string gs_dis = "," /* Group symbol function disable */; string gt_dis = "," /* Group text function disable */; string e_dis = "," /* Element function disable */; string elemmsg /* Element pick message */; int elemtyp /* Element type */; int atyp1, atyp2 /* Arc types */; int cnt = 0 /* Element count */; int mirr /* Group mirror flag */; // Check if standalone call if (ulproginfo("",0,0)<=1 && bae_getactmenu()<0) { // Check if element type scan if (bae_iniintval(PAR_METYPSCAN,1)==1 && !bae_peekiact()) { forall (text) { t_dis=e_dis=""; break; } forall (nref) { s_dis=e_dis=""; break; } forall (fig where fig.GROUP && fig.TYP==C_FIGNREF && !fig.MIRROR) { gs_dis=""; break; } forall (fig where fig.GROUP && fig.TYP==C_FIGTEXT && !fig.MIRROR) { gt_dis=""; break; } } else { // Enable all menu items t_dis=s_dis=e_dis=gs_dis=gt_dis=""; } // Select the mirror function bae_promptdialog(UPRMFCT); switch (bae_askmenu(7,s_dis+UPRSFCT1,t_dis+UPRSFCT2, e_dis+UPRSFCT3,gs_dis+UPRSFCT4,gt_dis+UPRSFCT5,UPRSFCT6, UPRABORT)) { case 0 : // Abort if invalid plan class if (ddbclass==DDBCLUNDEF || ddbclass==DDBCLSMRK) error_class(); elemmsg=UPRSELSYMBOL; elemtyp=1<1) error_abort(); // Store the new mirror mode to global variable varset(PAR_MIRRTOGGLE,MIRR_TOGGLE); exit(0); default : error_abort(); } // Repetitively pick elements bae_prtdialog(elemmsg); while (scm_pickanyelem(fig,conseg,bustap,0,elemtyp)==0) { if (fig.FIXED&2) errormsg(ERRELEMGLUED,fig.NAME); if (!MIRR_TOGGLE && fig.MIRROR) continue; // Save current state for undo if (cnt==0) bae_callmenu(MNU_BAESAVESTATE); // Unmirror the picked element if (scm_elemmirrchg(fig, MIRR_TOGGLE ? (fig.MIRROR ? 0 : 1) : 1)) errormsg(ERRMIRROR,fig.NAME); bae_postprocess(); cnt++; } // No pick if (cnt) bae_prtdialog(ERRNOPICK); else error(ERRNOPICK); exit(0); } // Get the currently active menu switch (bae_getactmenu()) { // Symbol movement functions case MNU_SCMADDSYM : case MNU_SCMADDLAB : case MNU_SCMADDPORT : case MNU_SCMNEXTSYM : case MNU_SCMMOVESYM : case MNU_SCMMOVEPIN : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,(!MIRR_TOGGLE || scm_getinputdata(0.0,0.0, 0.0,0,0.0,0.0,0.0,0,nref,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0, 0)!=0 || !nref.MIRROR) ? 8 : 7,LMB); break; // Connections movement functions case MNU_SCMTAPBUS : case MNU_SCMMOVETAP : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,2,LMB); break; // Polygon edit functions case 500 : case 501 : case 502 : case 503 : case 507 : case 508 : case MNU_SCMGRPPOLY : if (scm_getinputdata(0.0,0.0,0.0,0,0.0,0.0,0.0,0,0,0.0,0.0, 0.0,0.0,atyp1,0.0,0.0,0.0,0.0,atyp2)==0 && (atyp1>0 || atyp2>0)) { bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,7-(atyp1>0 ? atyp1 : atyp2),LMB); break; } bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,7,LMB); break; // Polygon movement functions case MNU_SCMMOVEPOLY : case MNU_SCMCOPYPOLY : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,7,LMB); break; // Text movement functions case MNU_SCMADDTEXT : case MNU_SCMMOVETEXT : case MNU_SCMCOPYTEXT : case MNU_SCMMOVENAME : case MNU_SCMMOVEATTR : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,(!MIRR_TOGGLE || scm_getinputdata(0.0,0.0, 0.0,0,0.0,0.0,0.0,0,text,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0, 0)!=0 || !text.MIRROR) ? 9 : 8,LMB); break; // Group movement functions case MNU_SCMMOVEGRP : case MNU_SCMCOPYGRP : case MNU_SCMLOADGRP : case MNU_BAEGRPPASTE : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,(!MIRR_TOGGLE || scm_getgroupdata(0.0,0.0, 0.0,0.0,mirr,0.0,0.0,0,0)!=0 || !mirr) ? 8 : 7,LMB); break; // Ignore on default default : ; } // Done } void mirron_ged() /* // Mirror picked GED object */ { index L_FIGURE fig /* Figure list index */; index L_NREF nref /* Named reference index */; index L_UREF uref /* Unnamed reference index */; index L_TEXT text /* Text index */; string p_dis = "," /* Part function disable */; string t_dis = "," /* Text function disable */; string gp_dis = "," /* Group part function disable */; string gt_dis = "," /* Group text function disable */; string e_dis = "," /* Element function disable */; string elemmsg /* Element pick message */; int elemtyp /* Element type */; int atyp1, atyp2 /* Arc types */; int cnt = 0 /* Element count */; int mirr /* Group mirror flag */; // Check if standalone call if (ulproginfo("",0,0)<=1 && bae_getactmenu()<0) { // Check if element type scan if (bae_iniintval(PAR_METYPSCAN,1)==1 && !bae_peekiact()) { forall (text) { t_dis=e_dis=""; break; } forall (nref) { p_dis=e_dis=""; break; } forall (fig where fig.GROUP && fig.TYP==L_FIGNREF && !fig.MIRROR) { gp_dis=""; break; } forall (fig where fig.GROUP && fig.TYP==L_FIGTEXT && !fig.MIRROR) { gt_dis=""; break; } } else { // Enable all menu items t_dis=p_dis=e_dis=gp_dis=gt_dis=""; } // Select the mirror function bae_promptdialog(UPRMFCT); switch (bae_askmenu(7,p_dis+UPRGFCT1,t_dis+UPRGFCT2, e_dis+UPRGFCT3,gp_dis+UPRGFCT4,gt_dis+UPRGFCT5,UPRGFCT6, UPRABORT)) { case 0 : // Abort if invalid plan class if (ddbclass!=DDBCLLAY && ddbclass!=DDBCLLPRT) error_class(); elemmsg=UPRSELPART; elemtyp=1<1) error_abort(); // Store the new mirror mode to global variable varset(PAR_MIRRTOGGLE,MIRR_TOGGLE); exit(0); default : error_abort(); } // Repetitively pick elements bae_prtdialog(elemmsg); while (ged_pickanyelem(fig,elemtyp)==0) { if (fig.FIXED&2) errormsg(ERRELEMGLUED,fig.NAME); if (!MIRR_TOGGLE && fig.MIRROR) continue; // Save current state for undo if (cnt==0) bae_callmenu(MNU_BAESAVESTATE); // Unmirror the picked element if (ged_elemmirrchg(fig, MIRR_TOGGLE ? (fig.MIRROR ? 0 : 1) : 1)) errormsg(ERRMIRROR,fig.NAME); bae_postprocess(); cnt++; } // No pick if (cnt) bae_prtdialog(ERRNOPICK); else error(ERRNOPICK); exit(0); } // Get the currently active menu switch (bae_getactmenu()) { // Part movement functions case MNU_GEDADDPART : case MNU_GEDMOVEPART : case MNU_GEDNEXTPART : case MNU_GEDMOVEPIN : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,(!MIRR_TOGGLE || ged_getinputdata(0.0,0.0, 0.0,0,0.0,0.0,0.0,0,nref,0,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0, 0)!=0 || !nref.MIRROR) ? 8 : 7,LMB); break; // Trace edit functions case MNU_GEDADDTRC : case MNU_GEDADDFTRC : case MNU_GEDTRCINSC : case MNU_GEDTRCMDC : if (ged_getinputdata(0.0,0.0,0.0,0,0.0,0.0,0.0,0,0,0,0.0,0.0, 0.0,0.0,atyp1,0.0,0.0,0.0,0.0,atyp2)==0 && (atyp1>0 || atyp2>0)) { bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,14+lay_menulaylinecnt()- (atyp1>0 ? atyp1 : atyp2),LMB); break; } bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,lay_menulaylinecnt()+5,LMB); break; // Polygon edit functions case 500 : case 501 : case 502 : case 503 : case MNU_GEDADDDLINE : case 505 : case MNU_GEDPOLYINSC : case MNU_GEDPOLYMDC : case MNU_GEDGRPPOLY : case 5007 : case 5014 : if (ged_getinputdata(0.0,0.0,0.0,0,0.0,0.0,0.0,0,0,0,0.0,0.0, 0.0,0.0,atyp1,0.0,0.0,0.0,0.0,atyp2)==0 && (atyp1>0 || atyp2>0)) { bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,7-(atyp1>0 ? atyp1 : atyp2),LMB); break; } bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,7,LMB); break; // Via movement functions case 413 : case 414 : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,(!MIRR_TOGGLE || ged_getinputdata(0.0,0.0, 0.0,0,0.0,0.0,0.0,0,uref,0,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0, 0)!=0 || !uref.MIRROR) ? 8 : 7,LMB); break; // Polygon movement functions case MNU_GEDMOVEPOLY : case MNU_GEDCOPYPOLY : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,7,LMB); break; // Text movement functions case MNU_GEDADDTEXT : case MNU_GEDMOVETEXT : case MNU_GEDCOPYTEXT : case MNU_GEDMOVENAME : case MNU_GEDMOVEATTR : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,(!MIRR_TOGGLE || ged_getinputdata(0.0,0.0, 0.0,0,0.0,0.0,0.0,0,text,0,0.0,0.0,0.0,0.0,0,0.0,0.0,0.0,0.0, 0)!=0 || !text.MIRROR) ? 9 : 8,LMB); break; // Group movement functions case MNU_GEDMOVEGRP : case MNU_GEDCOPYGRP : case MNU_GEDLOADGRP : case MNU_BAEGRPPASTE : case 415 : case 416 : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,(!MIRR_TOGGLE || ged_getgroupdata(0.0,0.0, 0.0,0.0,mirr,0.0,0.0,0,0)!=0 || !mirr) ? 8 : 7,LMB); break; // Ignore on default default : ; } // Done } void mirron_ced() /* // Mirror picked CED object */ { // Get the currently active menu switch (bae_getactmenu()) { // Macro movement functions case MNU_CEDADDMAC : case MNU_CEDMOVEMAC : case MNU_CEDNEXTMAC : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,7,LMB); /* 6:7 */ break; // Text movement functions case MNU_CEDADDTEXT : case MNU_CEDMOVETEXT : case MNU_CEDCOPYTEXT : case MNU_CEDMOVENAME : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,8,LMB); /* 7:8 */ break; // Group movement functions case MNU_CEDMOVEGRP : case MNU_CEDCOPYGRP : case MNU_CEDLOADGRP : case MNU_BAEGRPPASTE : bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,8,LMB); /* 7:8 */ break; // Ignore on default default : ; } // Done } // User Language program end