/* ADJORIG (STD) -- Adjust Origin */ /* ADJORIG (STD) -- Nullpunkt justieren */ /* // Copyright (c) 1996-2006 Oliver Bartels F+E, Erding // Author: Manfred Baumeister // Changes History: // mb (980910) ADAPTED TO BAE V4.2. // mb (980713) ENHANCEMENT: Dynamic multi-language support. // mb (971211) ADAPTED TO BAE V4.0. // mb (960710) CHANGE: Program name changed from ORIGZERO to ADJZERO; // mb (960704) ORIGINAL CODING. // // DESCRIPTION // // The adjorig User Language programs moves the origin of the currently // loaded element to the original system origin. adjorig also moves all // objects placed on the currently loaded element accordingly. The // purpose of adjorig is to snap the design data to the original system // grid when editing in different (non-default) grids. */ // Includes #include "pop.ulh" // User Language popup utilities // Messages string REPDONE = M("Es wurden keine Fehler festgestellt.", "Operation completed without errors."); // Globals static int ddbclass; // Plan DDB class static double nx = bae_planwsnx(); // Plan origin X coordinate static double ny = bae_planwsny(); // Plan origin Y coordinate static double lx = bae_planwslx(); // Plan lower boundary X coord. static double ly = bae_planwsly(); // Plan lower boundary Y coord. static double ux = bae_planwsux(); // Plan upper boundary X coord. static double uy = bae_planwsuy(); // Plan upper boundary Y coord. static double cx = lx+0.5*(ux-lx); // Plan center X coordinate static double cy = ly+0.5*(uy-ly); // Plan center Y coordinate // Main program main() { #define SD 0.00000001 // Small distance value // Abort if invalid plan class if ((ddbclass=bae_planddbclass())==DDBCLUNDEF) { error_class(); } // Test if not group-applicable element if (ddbclass!=DDBCLSCM && ddbclass!=DDBCLSSYM && ddbclass!=DDBCLLAY && ddbclass!=DDBCLLPRT && ddbclass!=DDBCLILAY && ddbclass!=DDBCLICELL) { // Issue command not allowed error error_class(); } // Done if origin is already at zero coordinates if (nx==0.0 && ny==0.0) { error(REPDONE); } // Enlarge boundary to enable group polygon selection paramwsresize(2*SD); // Select all to group groupselectall(); // Move group groupmove(cx,cy,cx-nx,cy-ny); // Reset group groupreset(); // Set boundary paramsetbnd(lx-nx,ly-ny,ux-nx,uy-ny); // Set origin paramsetorig(0.0,0.0); // Re-shrink previously enlarged workspace boundary paramwsresize(-2.0*SD); // Zoom all zoomall(); // Done perror(REPDONE); } //____________________________________________________________________ // BAE Parameter functions void paramsetorig(double x,double y) // Set plan origin of currently loaded element // Parameters: // double x : Origin X coordinate // double y : Origin Y coordinate { int menuitem; // Menu item number int gridlock; // Grid lock flag // Check interpreter type switch (uliptype()) { case ULIPSCM : menuitem=MNU_SCMPARORIG; break; case ULIPGED : menuitem=MNU_GEDPARORIG; break; case ULIPCED : menuitem=MNU_CEDPARORIG; break; default : error_class(); } // Free grid if locked if (gridlock=bae_getgridlock()) { bae_setgridlock(0); } // Perform set origin call bae_clriactqueue(); bae_storemouseiact(1,x,y,0,LMB); call(menuitem); // Restore grid lock bae_setgridlock(gridlock); } void paramwsresize(double resize) // Resize workspace of currently loaded element // Parameters: // double resize : Requested resize value (in DSU) // >0 enlarge workspace // <0 shrink workspace { // Set plan upper boundary paramsetubnd(bae_planwsux()+resize,bae_planwsuy()+resize); // Set plan lower boundary paramsetlbnd(bae_planwslx()-resize,bae_planwsly()-resize); } void paramsetbnd(double lx,double ly,double ux,double uy) // Set plan lower and upper boundary of currently loaded element // Parameters: // double lx : Lower boundary X coordinate // double ly : Lower boundary Y coordinate // double ux : Upper boundary X coordinate // double uy : Upper boundary Y coordinate { // Set plan upper boundary paramsetubnd(ux,uy); // Set plan lower boundary paramsetlbnd(lx,ly); } void paramsetlbnd(double x,double y) // Set plan lower boundary of currently loaded element // Parameters: // double x : Upper lower X coordinate // double y : Upper lower Y coordinate { int menuitem; // Menu item number int gridlock; // Grid lock flag // Check interpreter type switch (uliptype()) { case ULIPSCM : menuitem=MNU_SCMPARLBND; break; case ULIPGED : menuitem=MNU_GEDPARLBND; break; case ULIPCED : menuitem=MNU_CEDPARLBND; break; default : error_class(); } // Free grid if locked if (gridlock=bae_getgridlock()) { bae_setgridlock(0); } // Perform set origin call bae_clriactqueue(); bae_storemouseiact(1,x,y,0,LMB); call(menuitem); // Restore grid lock bae_setgridlock(gridlock); } void paramsetubnd(double x,double y) // Set plan upper boundary of currently loaded element // Parameters: // double x : Upper boundary X coordinate // double y : Upper boundary Y coordinate { int menuitem; // Menu item number int gridlock; // Grid lock flag // Check interpreter type switch (uliptype()) { case ULIPSCM : menuitem=MNU_SCMPARUBND; break; case ULIPGED : menuitem=MNU_GEDPARUBND; break; case ULIPCED : menuitem=MNU_CEDPARUBND; break; default : error_class(); } // Free grid if locked if (gridlock=bae_getgridlock()) bae_setgridlock(0); // Perform set origin call bae_clriactqueue(); bae_storemouseiact(1,x,y,0,LMB); call(menuitem); // Restore grid lock bae_setgridlock(gridlock); } //____________________________________________________________________ // BAE Group functions void groupreset() // Reset currently selected group { int menuitem; // Menu item number // Check interpreter type switch (uliptype()) { case ULIPSCM : menuitem=MNU_SCMGRPRESE; break; case ULIPGED : menuitem=MNU_GEDGRPRESE; break; case ULIPCED : menuitem=MNU_CEDGRPRESE; break; default : error_class(); } // Perform the group reset call bae_clriactqueue(); call(menuitem); } void groupmove(double xs,double ys,double xe,double ye) // Move currently selected group // Parameters: // double xs : Group move start X coordinate // double ys : Group move start Y coordinate // double xe : Group move end X coordinate // double ye : Group move end Y coordinate { int menuitem; // Menu item number int gridlock; // Grid lock flag int anglelock; // Angle lock flag // Check interpreter type switch (uliptype()) { case ULIPSCM : menuitem=MNU_SCMMOVEGRP; break; case ULIPGED : menuitem=MNU_GEDMOVEGRP; break; case ULIPCED : menuitem=MNU_CEDMOVEGRP; break; default : error_class(); } // Get grid/angle lock gridlock=bae_getgridlock(); anglelock=bae_getanglelock(); // Free grid lock bae_setgridlock(0); // Free angle lock bae_setanglelock(0); // Perform group move call bae_clriactqueue(); bae_storemouseiact(1,xs,ys,0,LMB); bae_storemouseiact(1,xe,ye,0,LMB); call(menuitem); // Restore grid/angle lock bae_setgridlock(gridlock); bae_setanglelock(anglelock); } void groupselectall() // Group polygon select all { #define SD 0.00000001 // Small distance value #define SELALL 4 // Select all menu item number int menuitem; // Menu item number int gridlock; // Grid lock flag int anglelock; // Angle lock flag // Check interpreter type switch (uliptype()) { case ULIPSCM : menuitem=MNU_SCMGRPPOLY; break; case ULIPGED : menuitem=MNU_GEDGRPPOLY; break; case ULIPCED : menuitem=MNU_CEDGRPPOLY; break; default : error_class(); } // Test if not group-applicable element if (ddbclass!=DDBCLSCM && ddbclass!=DDBCLSSYM && ddbclass!=DDBCLLAY && ddbclass!=DDBCLLPRT && ddbclass!=DDBCLILAY && ddbclass!=DDBCLICELL) { // Issue command not allowed error error_class(); } // Get grid/angle lock gridlock=bae_getgridlock(); anglelock=bae_getanglelock(); // Free grid lock bae_setgridlock(0); // Fix angle lock bae_setanglelock(1); // Perform group polygon/select/all call bae_clriactqueue(); bae_storemenuiact(1,SELALL,LMB); bae_storemenuiact(1,0,LMB); bae_storemouseiact(1,bae_planwslx()+SD,bae_planwsly()+SD,0,LMB); bae_storemouseiact(1,bae_planwsux()-SD,bae_planwsly()+SD,0,LMB); bae_storemouseiact(1,bae_planwsux()-SD,bae_planwsuy()-SD,0,LMB); bae_storemouseiact(1,bae_planwslx()+SD,bae_planwsuy()-SD,0,LMB); bae_storemouseiact(1,0.0,0.0,1,RMB); bae_storemenuiact(1,0,LMB); call(menuitem); // Restore grid/angle lock bae_setgridlock(gridlock); bae_setanglelock(anglelock); // Redraw screen screenredraw(); } //__________________________________________________________________ // User Language program end