/* CED_MS (CED) -- Chip Editor Mouse Action */ /* CED_MS (CED) -- Chipeditor Mausaktion */ /* -- EXECUTED AFTER LEFT MOUSE BUTTON ACTIVATION IN WORK AREA -- */ /* // Copyright (c) 2001-2013 Bartels System GmbH, Muenchen // Author: Roman Ludwig // Changes History: // rl (131029) RELEASED FOR BAE V8.0. // rl (120427) RELEASED FOR BAE V7.8. // rl (101019) RELEASED FOR BAE V7.6. // rl (091020) RELEASED FOR BAE V7.4. // rl (081014) RELEASED FOR BAE V7.2. // rl (080723) ENHANCEMENT: // Added element loop operation mode. // rl (080401) ENHANCEMENT: // Added center/pan window function. // rl (071029) RELEASED FOR BAE V7.0. // rl (060829) RELEASED FOR BAE V6.8. // rl (051208) ENHANCEMENT: // Added left/right rotate element functions. // Added support for control and alt keys. // rl (050906) RELEASED FOR BAE V6.6. // rl (040811) RELEASED FOR BAE V6.4. // rl (030904) RELEASED FOR BAE V6.2. // rl (021209) RELEASED FOR BAE V6.0. // rl (021026) ENHANCEMENT: // Added figure element type set support. // rl (020618) RELEASED FOR BAE V5.4. // rl (010731) ORIGINAL CODING. // // DESCRIPTION // // The ced_ms User Language program is automatically activated when // pressing the left mouse button in the work area while the program is idle. // Depending on the activated mouse mode ced_ms lists a menu of functions for // the element at the given mouse position or performs the specified action // for the element. */ // Includes #include "pop.ulh" // User Language popup utilities #include "std.ulh" // User Language standard include // Disable undo state request #pragma ULCALLERNOUNDO // Messages string UPRABORT = M_UPRABORT(); // Menu names string UPRSELGELEM = M("Elemente zur Gruppe selektieren/deselektieren. ESC/RMB Ende.", "Group select/deselect elements. ESC/RMB end."); string UPRSELG1ELEM = M("Element zur Gruppe selektieren/deselektieren!", "Group select/deselect element!"); string UPRSELDELEM = M("Zu loeschende Elemente selektieren. ESC/RMB Ende.", "Select elements to delete. ESC/RMB end."); string UPRSELD1ELEM = M("Zu loeschendes Element selektieren!", "Select element to delete!"); string UPRSELMELEM = M("Zu bewegende Elemente selektieren (packen). ESC/RMB Ende.", "Select elements to move (drag). ESC/RMB end."); string UPRSELM1ELEM = M("Zu bewegendes Element selektieren!", "Select element to move (drag)!"); string REPDELELEM = M("%d Elemente geloescht.","%d elements deleted"); string REPDEL1ELEM = M("1 Element geloescht.","1 element deleted."); string REPMOVELEM = M("%d Elemente bewegt.","%d elements moved"); string REPMOV1ELEM = M("1 Element bewegt.","1 element moved."); string CED_3_0 = M("Ne&ues Macro" ,"Add Mac&ro"); string CED_3_1 = M("&Bewegen Macro" ,"&Move Macro"); string CED_3_2 = M("&Loeschen Macro" ,"&Delete Macro"); string CED_3_3 = M("Nae&chstes Macro" ,"Place Ne&xt Macro"); string CED_3_4 = M("%Na&men aendern" ,"%&Change Macro Name"); string CED_3_5 = M("&Name in Netzliste","Ne&tlist Macro Name"); string CED_3_6 = M("%Pin/&Gate Swap" ,"%Pin/Gate &Swap"); string CED_4_0 = M("Ne&ue Bahn" ,"&Add Trace"); string CED_4_1 = M("%&Ecke einfuegen" ,"%Insert &Corner"); string CED_4_2 = M("E&cke(n) bewegen" ,"&Move Corner(s)"); string CED_4_13 = M("Ecke loeschen" ,"&Delete Corner"); string CED_4_3 = M("%&Segment einfuegen","%&Insert Segment"); string CED_4_4 = M("Se&gment bewegen" ,"&Move Segment"); string CED_4_5 = M("Segment &teilen" ,"&Break Segment"); string CED_4_6 = M("Segment l&oeschen" ,"Delete &Segment"); string CED_4_7 = M("%&Bahn loeschen" ,"%Delete &Trace"); string CED_4_8 = M("&Netz loeschen" ,"Delete &Net"); string CED_5_0 = M("Neue &Aktivflaeche","Add &Active Area"); string CED_5_1 = M("Neue Zeichen&linie","Add Document &Line"); string CED_5_2 = M("Neue &Sperrflaeche","Add &Keep Out Area"); string CED_5_3 = M("Neue U&mrandung" ,"Add &Board Outline"); string CED_5_4 = M("%Flaeche &bewegen" ,"%&Move Area"); string CED_5_5 = M("Flaeche kop&ieren" ,"&Copy Area"); string CED_5_6 = M("Flaeche g&roesser" ,"&Resize Area"); string CED_5_7 = M("Flaeche l&oeschen" ,"D&elete Area"); string CED_5_8 = M("%&Ecke einfuegen" ,"%I&nsert Corner"); string CED_5_9 = M("E&cke(n) bewegen" ,"Move C&orner(s)"); string CED_5_11 = M("Ecke loeschen" ,"Delete Corner"); string CED_5_10 = M("%Se&gment bewegen" ,"%Move &Segment"); string CED_6_0 = M("%Neuer Te&xt" ,"%Add &Text"); string CED_6_1 = M("Text &bewegen" ,"&Move Text"); string CED_6_2 = M("Text &kopieren" ,"&Copy Text"); string CED_6_3 = M("Text &aendern" ,"&Edit Text"); string CED_6_4 = M("Text &loeschen" ,"&Delete Text"); string CED_6_5 = M("%Nam&en bewegen" ,"%Move &Name"); string MI_NEW = M("&Neu" ,"&New"); string MI_OPEN = M("&Laden" ,"L&oad"); string MI_MACL = M("%Laden Makr&o" ,"%Load Macr&o"); string MI_ZOOMPAN = M("%Fenster &Mitte" ,"%Center/&Pan Window"); string MI_MSMOD = M("%Mausmodus" ,"%Mouse mode"); string MI_QPART = M("%Placedaten Ab&frage","%Place Data &Query"); string MI_RESETGROUP = M("%&Gruppe ruecksetzen","%Reset &Group"); string MI_MOVEGROUP = M("%Gruppe &bewegen","%&Move Group"); string MI_COPYGROUP = M("Gruppe &kopieren","&Copy Group"); // INI file parameter name definitions #define PAR_MOUSEREP "MOUSEREP_STD" // Mouse command repeat mode int MOUSEREP = bae_iniintval(PAR_MOUSEREP,0) /* Mouse command repeat mode */; typedef struct mnudes { // Menu definition descriptro string t /* Menu text */; string p /* Menu program name */; int c /* Class restriction */; } MNUITEML[] /* Menu item list */; typedef struct fmnudes { // Figure index menu def. descriptor int typ /* Figure list element type */; MNUITEML iteml /* Menu item list */; } FMNUL[] /* Figure index menu list definition */; typedef struct factdes { // Figure index action descriptor int typ /* Figure list element type */; string p /* Figure list elem. program name */; string t /* Menu text */; } FACTL[] /* Figure index action list def. */; static FMNUL fmnul = { { I_FIGNREF, { // Named reference functions { CED_3_1,"#301:ml",(-1) }, { CED_3_2,"#302:ml",(-1) }, { CED_3_4,"#304:ml",(-1) }, { CED_3_5,"#305:ml",(-1) }, { CED_6_5,"#605:ml",(-1) }, { MI_QPART,"cedpart:sl8:ml:t:mr",(-1) }, { CED_3_6,"#306:ml",(-1) }, { MI_MACL,"cedmacl:ml",(-1) }, { MI_ZOOMPAN,"#105:ml",(-1) }, { MI_MSMOD,"msmode",(-1) } } }, { I_FIGPATH, { // Trace functions { CED_4_1,"#401:ml",(-1) }, { CED_4_2,"#402:ml",(-1) }, { CED_4_13,"#413:ml",(-1) }, { CED_4_3,"#403:ml",(-1) }, { CED_4_4,"#404:ml",(-1) }, { CED_4_5,"#405:ml",(-1) }, { CED_4_6,"#406:ml",(-1) }, { CED_4_7,"#407:ml",(-1) }, { CED_4_8,"#408:ml",(-1) }, { MI_ZOOMPAN,"#105:ml",(-1) }, { MI_MSMOD,"msmode",(-1) } } }, { I_FIGPOLY, { // Polygon functions { CED_5_4,"#504:ml",(-1) }, { CED_5_5,"#505:ml",(-1) }, { CED_5_6,"#506:ml",(-1) }, { CED_5_7,"#507:ml",(-1) }, { CED_5_8,"#508:ml",(-1) }, { CED_5_9,"#509:ml",(-1) }, { CED_5_11,"#511:ml",(-1) }, { CED_5_10,"#510:ml",(-1) }, { MI_ZOOMPAN,"#105:ml",(-1) }, { MI_MSMOD,"msmode",(-1) } } }, { I_FIGUREF, { // Unnamed reference functions { CED_3_1,"#301:ml",DDBCLICELL }, { CED_3_2,"#302:ml",DDBCLICELL }, { MI_ZOOMPAN,"#105:ml",(-1) }, { MI_MSMOD,"msmode",(-1) } } }, { I_FIGTEXT, { // Text functions { CED_6_1,"#601:ml",(-1) }, { CED_6_2,"#602:ml",(-1) }, { CED_6_3,"#603:ml",(-1) }, { CED_6_4,"#604:ml",(-1) }, { MI_ZOOMPAN,"#105:ml",(-1) }, { MI_MSMOD,"msmode",(-1) } } }, { (-1), { // New element functions { CED_3_0,"#300",(-1) }, { CED_3_3,"#303",(-1) }, { CED_4_0,"#400",(-1) }, { CED_5_0,"#500",(-1) }, { CED_5_1,"#501",(-1) }, { CED_5_2,"#502",(-1) }, { CED_5_3,"#503",(-1) }, { CED_6_0,"#600",(-1) }, { MI_RESETGROUP,"#700",(-1) }, { MI_MOVEGROUP,"#703",(-1) }, { MI_COPYGROUP,"#704",(-1) }, { MI_ZOOMPAN,"#105:ml",(-1) }, { MI_MSMOD,"msmode",(-1) } } } }; static FACTL fmovl = { { I_FIGNREF,"#301:ml",CED_3_1 }, // Named reference { I_FIGPATH,"#402:ml",CED_4_2 }, // Trace { I_FIGPOLY,"#504:ml",CED_5_4 }, // Polygon { I_FIGTEXT,"#601:ml",CED_6_1 } // Text }; static FACTL fdell = { { I_FIGNREF,"#302:ml",CED_3_2 }, // Named reference { I_FIGPATH,"#407:ml",CED_4_7 }, // Trace { I_FIGPOLY,"#507:ml",CED_5_7 }, // Polygon { I_FIGTEXT,"#604:ml",CED_6_4 } // Text }; // Global variables double PI = cvtangle(180.0,1,2) /* PI-value */; double x,y /* Mouse position */; int figdis /* Figure list disable bits */; // Main program void main() { string cmdstr /* Command string */; int rangedis /* Range check disabled flag */; int lastgridlock /* Last grid lock mode */; int msmode /* Mouse context operation mode */; int oneelem = 0 /* Process one element only flag */; int cnt = 0 /* Element count */; int lastmsnodbl /* Old mouse double click mode */; int mspickdbl /* Pick mouse double click mode */; // Check if no element loaded if (bae_planddbclass()==DDBCLUNDEF) { // Query the function selection switch (bae_askmenu(4,MI_OPEN,MI_NEW,MI_MSMOD,UPRABORT)) { // Load case 0 : if (MOUSEREP&0x02) bae_storecmdbuf(0,"#200", bae_plainmenutext(MI_OPEN)); bae_callmenu(200); break; // New case 1 : if (MOUSEREP&0x02) bae_storecmdbuf(0,"#203", bae_plainmenutext(MI_NEW)); bae_callmenu(203); break; // Mouse mode case 2 : if (MOUSEREP&0x02) bae_storecmdbuf(0,"msmode", bae_plainmenutext(MI_MSMOD)); ulsystem("msmode",0); break; default : ; } bae_clriactqueue(); return; } // Get the figure list element type set if (varget(VAR_MSFIGDIS,figdis)) figdis=0; // Check if loop operation mode requested if (bae_peekiact()) { // Get the command string if ((cmdstr=askstr("",MAXKEYLEN))==UINPOPABORT) error_abort(); x=bae_planwsnx(); y=bae_planwsny(); switch (cmdstr[0]) { case 'G' : oneelem=1; case 'g' : lastgridlock=bae_getgridlock(); bae_setgridlock(0); bae_getintpar(39,lastmsnodbl); bae_getintpar(40,mspickdbl); bae_setintpar(39,mspickdbl ? 1 : 2); bae_promptdialog(oneelem ? UPRSELG1ELEM : UPRSELGELEM); while (bae_inpoint(x,y,x,y,0)==0) { bae_setgridlock(lastgridlock); if (grpfunc()==0) cnt++; if (oneelem) break; bae_setgridlock(0); } bae_setgridlock(lastgridlock); bae_setintpar(39,lastmsnodbl); if (cnt==0) error_abort(); exit(0); case 'D' : oneelem=1; case 'd' : lastgridlock=bae_getgridlock(); bae_setgridlock(0); bae_getintpar(39,lastmsnodbl); bae_getintpar(40,mspickdbl); bae_setintpar(39,mspickdbl ? 1 : 2); while ( bae_promptdialog(oneelem ? UPRSELD1ELEM : UPRSELDELEM), bae_inpoint(x,y,x,y,0)==0) { bae_setgridlock(lastgridlock); if (elfunc(fdell)==0) cnt++; if (oneelem) break; bae_setgridlock(0); } bae_setgridlock(lastgridlock); bae_setintpar(39,lastmsnodbl); if (cnt==0) error_abort(); if (cnt==1) cmdstr=REPDEL1ELEM; else sprintf(cmdstr,REPDELELEM,cnt); bae_prtdialog(cmdstr); exit(0); case 'M' : oneelem=1; case 'm' : lastgridlock=bae_getgridlock(); bae_setgridlock(0); bae_getintpar(39,lastmsnodbl); bae_getintpar(40,mspickdbl); bae_setintpar(39,mspickdbl ? 1 : 2); while ( bae_promptdialog(oneelem ? UPRSELM1ELEM : UPRSELMELEM), bae_inpoint(x,y,x,y,0)==0) { bae_setgridlock(lastgridlock); if (elfunc(fmovl)==0) cnt++; if (oneelem) break; bae_setgridlock(0); } bae_setgridlock(lastgridlock); bae_setintpar(39,lastmsnodbl); if (cnt==0) error_abort(); else { sprintf(cmdstr,REPMOVELEM,cnt); bae_prtdialog(cmdstr); } if (cnt==1) cmdstr=REPMOV1ELEM; else sprintf(cmdstr,REPMOVELEM,cnt); bae_prtdialog(cmdstr); exit(0); default : } } // Get the mouse position bae_wsmouse(x,y,0); // Check if inside work area if (xbae_planwsux() || ybae_planwsuy()) return; // Check if shift and/or ctrl activated switch (kbstate()&0x0F) { case 0 : // Get the mouse mode if (varget(VAR_MSMODE,msmode)) msmode=MS_CONT; break; // Shift button pressed case 1 : // Get the mouse mode if (varget(VAR_MSMODES,msmode)) msmode=MS_MOVE; break; // Ctrl button pressed case 2 : // Get the mouse mode if (varget(VAR_MSMODEC,msmode)) msmode=MS_DEL; break; // Shift and Ctrl buttons pressed case 3 : // Get the mouse mode if (varget(VAR_MSMODESC,msmode)) msmode=MS_GSEL; break; // Alt left button pressed case 4 : // Get the mouse mode if (varget(VAR_MSMODEAL,msmode)) msmode=MS_LROT; break; // Alt right button pressed case 8 : case 10 : // Get the mouse mode if (varget(VAR_MSMODEAR,msmode)) msmode=MS_RROT; break; default : exit(0); } // Evaluate mouse action switch (msmode) { // Context function mode case MS_CONT : contextfunc(); break; // Delete mode case MS_DEL : elfunc(fdell); break; // Move mode case MS_MOVE : elfunc(fmovl); break; // Group selection mode case MS_GSEL : case MS_GCSEL : grpfunc(); break; // Left rotate mode case MS_LROT : rotate(0.5*PI); break; // Right rotate mode case MS_RROT : rotate(-0.5*PI); break; // Center/pan window mode case MS_PANW : // Warp to given position bae_clriactqueue(); bae_storemouseiact(1,x,y,2,LMB); bae_callmenu(MNU_BAEZOOMPAN); // Disable range check bae_getintpar(0,rangedis); bae_setintpar(0,1); // Set mouse cursor to new position bae_clriactqueue(); bae_storemouseiact(1,x,y,0x06,LMB); bae_inpoint(0.0,0.0,0.0,0.0,0); // Restore old range check state bae_setintpar(0,rangedis); break; case MS_NONE : default : } bae_clriactqueue(); } void contextfunc() { index I_FIGURE fig /* Figure list index */; int typ /* Element type */; int tidx /* Type index */; int tcount /* Type count */; int icount /* Item count */; int mcount /* Menu item count */; STRINGS mnul /* Menu item list */; int mnuidxl[] /* Menu index list */; int res /* Menu selection result */; int i /* Loop control variable */; // Loop for all types tcount=arylength(fmnul); for (tidx=0;tidx=mcount) break; // Call the element program if (MOUSEREP&0x02) bae_storecmdbuf(0,fmnul[tidx].iteml[mnuidxl[res]].p, bae_plainmenutext(fmnul[tidx].iteml[mnuidxl[res]].t)); ulsystem(fmnul[tidx].iteml[mnuidxl[res]].p,0); break; } } int elfunc(FACTL fctl) /* // Element function // Return value : // zero if element found or (-1) on element not found // Parameter : // FACTL fctl : Element action list */ { index I_FIGURE fig /* Figure list index */; int typ /* Element type */; int tidx /* Type index */; int tcount /* Type count */; // Loop for all types tcount=arylength(fctl); for (tidx=0;tidx