/* BAE_RECT (STD) -- Mouse Rectangle Frame Action */ /* BAE_RECT (STD) -- Mausrahmenaktion */ /* // Copyright (c) 2000-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 (080401) ENHANCEMENT: // Added center/pan window function. // rl (071029) RELEASED FOR BAE V7.0. // rl (060829) RELEASED FOR BAE V6.8. // rl (050906) RELEASED FOR BAE V6.6. // rl (041129) ENHANCEMENT: // Added element type disable support. // rl (040831) 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 (020225) ENHANCEMENT: // Removed grid and angle lock dependancy. // rl (010625) RELEASED FOR BAE V5.0. // rl (001113) ORIGINAL CODING. // // DESCRIPTION // // The bae_rect User Language program is automatically activated when // pressing the left mouse button and drawing a rectangular frame of more // than 10 pixels width in in the work area whithout releasing the mouse // button if the program is idle. // Depending on the activated mouse mode ged_rect performs the specified // function for the elements inside the frame rectangle via the group // functions. */ // Includes #include "std.ulh" // User Language standard include // Enforce standard caller type #pragma ULCALLERSTD // Disable undo state request #pragma ULCALLERNOUNDO // Messages string UPRSELWINS = M("Rechteck Startpunkt waehlen!", "Select Rectangle Start Point!"); string UPRSELWINE = M("Rechteck Endpunkt waehlen!", "Select Rectangle End Point!"); string ERRRUTMODE = M("Funktion im Routermodus nicht erlaubt!", "Function not permitted in Router mode!"); // Globals double PI = cvtangle(180.0,1,2) /* PI-value */; int rutmode = 0 /* Autorouter active flag */; // Main program void main() { double x1,y1 /* Rectangle first corner */; double x2,y2 /* Rectangle second corner */; double rotang /* Rotation angle */; int gridlock /* Grid lock flag */; int anglock /* Angle lock flag */; int rangedis /* Range check disabled flag */; int grpreset /* Group reset menu code */; int grpdel /* Group delete menu code */; int grppoly /* Group polygon menu code */; int grpmove /* Group move menu code */; int msmode /* Mouse context operation mode */; int mswarp /* Mouse warp mode */; // Get the old grid and angle lock gridlock=bae_getgridlock(); anglock=bae_getanglelock(); // Release grid and angle lock if (!bae_peekiact()) { bae_setgridlock(0); bae_setanglelock(0); } // Disable range check bae_getintpar(0,rangedis); bae_setintpar(0,1); // Get first rectangle corner bae_promptdialog(UPRSELWINS); if (bae_inpoint(bae_planwsnx(),bae_planwsny(),x1,y1,0)) { // Restore the old grid and angle lock bae_setgridlock(gridlock); bae_setanglelock(anglock); // Restore old range check state bae_setintpar(0,rangedis); return; } // Get second rectangle corner bae_promptdialog(UPRSELWINE); if (bae_inpoint(x1,y1,x2,y2,1)) { // Restore the old grid and angle lock bae_setgridlock(gridlock); bae_setanglelock(anglock); // Restore old range check state bae_setintpar(0,rangedis); return; } // Restore the old grid and angle lock bae_setgridlock(gridlock); bae_setanglelock(anglock); // Restore old range check state bae_setintpar(0,rangedis); // Check if no element loaded if (bae_planddbclass()==DDBCLUNDEF) 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); } // Get the menu action codes // Test the interpreter type switch (uliptype()) { /* SCM */ case ULIPSCM : grpreset=MNU_SCMGRPRESE; grpdel=MNU_SCMDELGRP; grpmove=MNU_SCMMOVEGRP; grppoly=MNU_SCMGRPPOLY; break; /* GED */ case ULIPGED : grpreset=MNU_GEDGRPRESE; grpdel=MNU_GEDDELGRP; grpmove=MNU_GEDMOVEGRP; grppoly=MNU_GEDGRPPOLY; ged_getintpar(107,rutmode); break; /* CED */ case ULIPCED : grpreset=MNU_CEDGRPRESE; grpdel=MNU_CEDDELGRP; grpmove=MNU_CEDMOVEGRP; grppoly=MNU_CEDGRPPOLY; break; // Other environments default : msmode=MS_CONT; } // Evaluate mouse action bae_clriactqueue(); switch (msmode) { // Context function mode case MS_CONT : bae_storemouseiact(1,x1,y1,0,LMB); bae_storemouseiact(1,x2,y2,0,LMB); bae_callmenu(MNU_BAEZOOMWND); // Check if mouse warp to zoom position bae_getintpar(12,mswarp); if (mswarp&0x08) { // Disable range check bae_getintpar(0,rangedis); bae_setintpar(0,1); // Set mouse cursor to window center bae_clriactqueue(); bae_storemouseiact(1,0.5*(x1+x2),0.5*(y1+y2),0x06,LMB); bae_inpoint(0.0,0.0,0.0,0.0,0); // Restore old range check state bae_setintpar(0,rangedis); } break; // Delete mode case MS_DEL : chkrutmode(); bae_callmenu(grpreset); selectrect(grppoly,0,x1,y1,x2,y2); bae_callmenu(grpdel); break; // Move mode case MS_MOVE : chkrutmode(); bae_callmenu(grpreset); selectrect(grppoly,0,x1,y1,x2,y2); bae_callmenu(grpmove); bae_callmenu(grpreset); break; // Group selection mode case MS_GSEL : selectrect(grppoly,0,x1,y1,x2,y2); break; // Group (crossing) selection mode case MS_GCSEL : selectrect(grppoly,1,x1,y1,x2,y2); break; // Left rotate mode case MS_LROT : chkrutmode(); bae_callmenu(grpreset); selectrect(grppoly,0,x1,y1,x2,y2); if (varget(VAR_ROTANGLE,rotang)!=0) rotang=90.0; rotate(cvtangle(rotang,1,0)); bae_callmenu(grpreset); break; // Right rotate mode case MS_RROT : chkrutmode(); bae_callmenu(grpreset); selectrect(grppoly,0,x1,y1,x2,y2); if (varget(VAR_ROTANGLE,rotang)!=0) rotang=90.0; rotate(-cvtangle(rotang,1,0)); bae_callmenu(grpreset); break; // Center/pan window mode case MS_PANW : bae_storemouseiact(1,x1,y1,0,LMB); bae_storemouseiact(1,x2,y2,0,LMB); bae_callmenu(MNU_BAEZOOMWND); // Check if mouse warp to zoom position bae_getintpar(12,mswarp); if (mswarp&0x08) { // Disable range check bae_getintpar(0,rangedis); bae_setintpar(0,1); // Set mouse cursor to window center bae_clriactqueue(); bae_storemouseiact(1,0.5*(x1+x2),0.5*(y1+y2),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 : } } void selectrect(int grppoly,int cross,double x1,double y1,double x2,double y2) /* // Select elements within given rectangle to group // Parameter : // int grppoly : Group polygon function // int cross : Group polygon crossing elements flag // double x1,y1 : Rectangle first corner coordinate // double x2,y2 : Rectangle second corner coordinate */ { int figdis /* Figure list disable bits */; // Get the figure list element type set if (varget(VAR_MSFIGDIS,figdis)) figdis=0; if (figdis==0) { selectrectelements(grppoly,cross,4,x1,y1,x2,y2); } else { // Test the interpreter type switch (uliptype()) { /* SCM */ case ULIPSCM : if (!(figdis&(1<