Here some modification to command line input.
L50 or l50 -> left 50 distance [relative] R50or r50 -> right 50 distance [relative] U50 or u50 -> up 50 distance [relative] D50 or d50 -> down 50 distance [relative] ...\librecad\src\lib\gui\rs_eventhandler.cpp if (!e->isAccepted()) { if (cmd.at(0)=='L') { int commaPos = cmd.indexOf('L'); bool ok1; double x = RS_Math::eval(cmd.mid(commaPos+1), &ok1); if (ok1 ) { RS_CoordinateEvent ce(RS_Vector(x,0) + relative_zero); currentActions.last()->coordinateEvent(&ce); // currentActions[actionIndex]->coordinateEvent(&ce); } else { if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->commandMessage( "Expression Syntax Error"); } } e->accept(); } } if (!e->isAccepted()) { if (cmd.at(0)=='l') { int commaPos = cmd.indexOf('l'); bool ok1; double x = RS_Math::eval(cmd.mid(commaPos+1), &ok1); if (ok1 ) { RS_CoordinateEvent ce(RS_Vector(x,0) + relative_zero); currentActions.last()->coordinateEvent(&ce); // currentActions[actionIndex]->coordinateEvent(&ce); } else { if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->commandMessage( "Expression Syntax Error"); } } e->accept(); } } if (!e->isAccepted()) { if (cmd.at(0)=='R') { int commaPos = cmd.indexOf('R'); bool ok1; double x = RS_Math::eval(cmd.mid(commaPos+1), &ok1); if (ok1 ) { RS_CoordinateEvent ce(RS_Vector(-x,0) + relative_zero); currentActions.last()->coordinateEvent(&ce); // currentActions[actionIndex]->coordinateEvent(&ce); } else { if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->commandMessage( "Expression Syntax Error"); } } e->accept(); } } if (!e->isAccepted()) { if (cmd.at(0)=='r') { int commaPos = cmd.indexOf('r'); bool ok1; double x = RS_Math::eval(cmd.mid(commaPos+1), &ok1); if (ok1 ) { RS_CoordinateEvent ce(RS_Vector(-x,0) + relative_zero); currentActions.last()->coordinateEvent(&ce); // currentActions[actionIndex]->coordinateEvent(&ce); } else { if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->commandMessage( "Expression Syntax Error"); } } e->accept(); } } if (!e->isAccepted()) { if (cmd.at(0)=='U') { int commaPos = cmd.indexOf('U'); bool ok1; double y = RS_Math::eval(cmd.mid(commaPos+1), &ok1); if (ok1 ) { RS_CoordinateEvent ce(RS_Vector(0,y) + relative_zero); currentActions.last()->coordinateEvent(&ce); // currentActions[actionIndex]->coordinateEvent(&ce); } else { if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->commandMessage( "Expression Syntax Error"); } } e->accept(); } } if (!e->isAccepted()) { if (cmd.at(0)=='u') { int commaPos = cmd.indexOf('u'); bool ok1; double y = RS_Math::eval(cmd.mid(commaPos+1), &ok1); if (ok1 ) { RS_CoordinateEvent ce(RS_Vector(0,y) + relative_zero); currentActions.last()->coordinateEvent(&ce); // currentActions[actionIndex]->coordinateEvent(&ce); } else { if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->commandMessage( "Expression Syntax Error"); } } e->accept(); } } if (!e->isAccepted()) { if (cmd.at(0)=='D') { int commaPos = cmd.indexOf('D'); bool ok1; double y = RS_Math::eval(cmd.mid(commaPos+1), &ok1); if (ok1 ) { RS_CoordinateEvent ce(RS_Vector(0,-y) + relative_zero); currentActions.last()->coordinateEvent(&ce); // currentActions[actionIndex]->coordinateEvent(&ce); } else { if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->commandMessage( "Expression Syntax Error"); } } e->accept(); } } if (!e->isAccepted()) { if (cmd.at(0)=='d') { int commaPos = cmd.indexOf('d'); bool ok1; double y = RS_Math::eval(cmd.mid(commaPos+1), &ok1); if (ok1 ) { RS_CoordinateEvent ce(RS_Vector(0,-y) + relative_zero); currentActions.last()->coordinateEvent(&ce); // currentActions[actionIndex]->coordinateEvent(&ce); } else { if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->commandMessage( "Expression Syntax Error"); } } e->accept(); } } |
I'm glad to see you are starting to write code.
A big part of programming is figuring out how to avoid repeating code. Try to simplify what you posted. Some ideas: - the || (or) operator http://www.tutorialspoint.com/cplusplus/cpp_operators.htm - http://doc.qt.io/qt-4.8/qstring.html#toLower - http://doc.qt.io/qt-4.8/qregexp.html |
Now that I have changed the cal command,
and the space-bar functionality: I'd like to consider adding this and also some solution for http://forum.librecad.org/Coordinates-possibility-of-not-using-quot-quot-td5712525.html |
agreed, the 779 method will be easier than udrl keyboard dependant strokes.
(that said, thanks to jalse for his triggering proposition :) |
Thank for new feature.
Actually concept of General used Cad is different. Say example - Line. step : First we will pick first point using mouse. step 2 : next we know line length - 1000mm. We will be mouse in the direction of line. then we will enter line length [100] & press enter or space, line will generate with 1000 unit length in direction mouse position. or step 2 : if line is orthogonal, we need to switch on orthogonal snapping [usually "fn F8" shortcut used or enabling or disabling], then we will enter line length [1000] & press enter or space, line will generate with 1000 unit length in direction mouse position. But it is nowhere mentioned as line passing through a point with fixed length. But will be very easy as we need to enter only one dimension say length & keep the mouse in direction or position. so orthogonal line can be drawn very fast. just keep mouse in direction we need line, then keep entering sizes. Note : even if enable orthogonal snap, first point is free snapping for line, rectangle, polygon, circle etc. |
If it's done this way, then additionally to orthogonal snapping a new mode with stepped angles, preferably settable, for instance as often used 45°, or if you need finer steps, 15° to also cover 30 and 60°, could be created.
|
Free forum by Nabble | Edit this page |