Having looked into this, the spinbox uses the locale of the computer it is running on, unless a specific locale has been assigned to the spinbox. The decimal point character can't be changed or overwritten, and changing the specific locale would not be a simple matter for users. As Andrew suggested, using an RMathLineEdit box is the easiest way to solve this.I have attached the two affected files - Line2PEx.ui, and Line2PEx.js. Replace these two files in Draw->Line->Line2PEx.Using an RMathLineEdit input, you can type any value into the box, or even an expression. If you enter a negative number then the restrict changes it to a positive number.I have included the options in a group box so you can toggle them on and off using Alt-Z. When toggled off they won't interfere with existing shortcuts. Because other commands can change the position of relativezero I store its position when using another command, and restore it when control is returned to this command.

For this reason, we actually use a version control system (git) which manages changes over time and allows merging. Perhaps that is something to look into in the future? Version control systems are among those tools you never wish to miss anymore once you start using them

I have changed Line2PEx.js, as I found two issues.First, trying to use a groupBox in the options toolbar is just too problematic. So I changed the key sequence 'Alt-Z' to disable the options toolbar. Once disabled, you can then type any shortcut without it conflicting with the line options. (If the shortcut doesn't start with 'C', 'U', 'R', 'T' or 'D' then you can just type the shortcut). If you type a shortcut then the option toolbar is re-enabled, and the position of relativezero is saved. When you return to the line command, the toolbar is enabled and relativezero is put back to where it was.The second issue concerns returning to the line command. If, for example, you draw a circle and then return to the line command, and the undo button is enabled, then undo uses the system undo, so instead of deleting the last line segment, it will delete the circle and move relativezero to the previous position. So now you've deleted the circle you just drew and relativezero is in the wrong position.I changed undo to use transactions instead of the system undo. So now when you press undo it will delete the last line segment and not the circle.I have attached the file 'Line2PEx.js'. Replace the existing file with this one.

QCAD 3.6.0 comes with a new snap restriction tool which was designed to offer similar functionality as the Line2PEx to all tools:Snap > Restrict Angle or Length

The new tool can be used similarly like Line2PEx:- Start the regular line drawing tool Draw > Line > Line from 2 Points- Set the start point of the line- Click the restrict tool button in the line options tool bar (or the same button in the CAD tool bar at the left or choose menu Snap > Restrict Angle or Length or enter the key code EA):

Screen Shot 2014-06-20 at 13.13.21.png (18.21 KiB) Viewed 2171 times

- You can now enter a restriction angle (and optionally a restriction distance):

Screen Shot 2014-06-20 at 13.18.16.png (14.34 KiB) Viewed 2171 times

QCAD snaps to multiples of the given angle and distance.

This tool can be used in combination with any drawing or modification tool, whenever a coordinate is requested.

I've decided against displaying the angle / length inside the drawing space for now, although the code is still in Viewport.js, commented out under '// snap restriction info:' if someone wants to try it.The angle and distance used are always visible in the status bar of course:

Screen Shot 2014-06-20 at 13.26.55.png (12.15 KiB) Viewed 2171 times

I understand that this a bit of a compromise, compared to the Line2PEx tool, so the original Line2PEx tool is still available under Misc > Drawing, same keycode as before.

Your two new entities, Ray and XLine, are great, and combining them with the line command is an excellent idea.'Snap to Angle or Distance' is also great. I briefly thought about trying to do a similar thing when adding Restrict to the 'line' command, but my knowledge of the inner workings of QCAD is limited, and I realised it would be too dificult for me to do. So, I took the easy way out and resorted to using ECMAScript. As you point out, your new restriction applies to all commands expecting coordinate input, which is far better. (By the way, I was just about to post 'DrawPolylineEx', which has the same additions as 'Line2PEx'. ). I think your new line command is the way to go.Your hard work is much appreciated.

Now, I don't want to rain on your parade, but has anyone pointed out that the shortcut EA conflicts with 'Ellipse Arc'?

Playing with the line command, I noticed that the 'close' function doesn't move relativezero. This may be by design, but I would prefer it to move to the first point.Similarly, if you start another command while in the line command, and relativezero is moved, when you exit that command, relativezero isn't returned to its original position.Could I suggest, as an alternative to using single letter shortcuts, that you add two letter shortcuts to the Close, Undo and Redo buttons in the options toolbar? My suggestions would be CL, UN and RD (RE is already used for rectangle).Could I also suggest adding the check for the 'enter' or 'return' key being pressed, and If the current prompt is 'First point', then pressing enter or return causes the first point to be set to the last position in the drawing? Husky, at least, thought this was a good idea.I noticed that you added the distance to 'Display Angle', which is good. However, adding the code to 'snap info' means that the display is always on, which as I said might be annoying at times. Would it be possible for me to add a toggle button to the 'restrict to angle or distance' options toolbar, and add the display code to 'RestrictAngleLength.js'? Perhaps you could have a vote on whether or not users want this feature.Finally, if the restriction is active when trying to select the first point, it can stop you selecting the exact point you want. (This is also the same for the 'orthogonal', 'horizontal' and 'vertical' restrictions). Now I know you can easily switch it off using the button, but would it be better to switch off restrictions while selecting the first point?

I would be quite willing to make these changes and send them to you. Perhaps you could let me know what you think?

riverbuoy wrote:Your two new entities, Ray and XLine, are great, and combining them with the line command is an excellent idea.

Thanks.

(By the way, I was just about to post 'DrawPolylineEx', which has the same additions as 'Line2PEx'. ).

Sorry about that. I should have let you know that I'm working towards that direction.

Now, I don't want to rain on your parade, but has anyone pointed out that the shortcut EA conflicts with 'Ellipse Arc'?

Thanks for pointing that out. I've changed that to 'EG'.

Playing with the line command, I noticed that the 'close' function doesn't move relativezero. This may be by design, but I would prefer it to move to the first point.

Yes, makes sense. I've adjusted that as well.

Similarly, if you start another command while in the line command, and relativezero is moved, when you exit that command, relativezero isn't returned to its original position.

Yes, that is not the case in general. This would take some refactoring to restore the relative zero position when an action resumes. This should be the case for all actions or none to be consistent.

Could I suggest, as an alternative to using single letter shortcuts, that you add two letter shortcuts to the Close, Undo and Redo buttons in the options toolbar? My suggestions would be CL, UN and RD (RE is already used for rectangle).

Yes, why not. Can you try this to get a feel if that makes sense when working with the tool?Another idea would be to use a fixed first character for all options toolbar tools. E.g. '.C' for close and '.U', '.R' or '/C', '/U', '/R' or something like that.

Could I also suggest adding the check for the 'enter' or 'return' key being pressed, and If the current prompt is 'First point', then pressing enter or return causes the first point to be set to the last position in the drawing? Husky, at least, thought this was a good idea.

OK, can you try to port this over from Line2PEx? I think I missed that.

I noticed that you added the distance to 'Display Angle', which is good. However, adding the code to 'snap info' means that the display is always on, which as I said might be annoying at times.

Yes..

Would it be possible for me to add a toggle button to the 'restrict to angle or distance' options toolbar, and add the display code to 'RestrictAngleLength.js'?

Yes, sure. I'm not sure if the display code can be move there easily though.

Perhaps you could have a vote on whether or not users want this feature.

I think either an application preference or a tool bar toggle button would be fine. Users could then provide feedback based on that.

Finally, if the restriction is active when trying to select the first point, it can stop you selecting the exact point you want. (This is also the same for the 'orthogonal', 'horizontal' and 'vertical' restrictions). Now I know you can easily switch it off using the button, but would it be better to switch off restrictions while selecting the first point?

That's one of those tricky questions. When starting a new tool, all restrictions are switched off automatically. I think switching on / off snaps or restrictions automatically while in process of using a tool might be confusing. I guess it boils down to the question of whether QCAD can predict what the user wants to do.

I would be quite willing to make these changes and send them to you. Perhaps you could let me know what you think?

Yes, sure, feel free to experiment with the other ideas and submit patches or feedback.

Andrew wrote:Another idea would be to use a fixed first character for all options toolbar tools. E.g. '.C' for close and '.U', '.R' or '/C', '/U', '/R' or something like that.

I had another look at the international keyboard layouts. The stroke character (/) requires the shift key to be pressed in quite a few layouts. The dot character (.) requires the shift key to be pressed in fewer layouts. However, the comma character (,) is directly accessible in all layouts except for some russian layouts. So I decided to use the comma character as the fixed first character for all option toolbar tools. So the shortcuts are ',C' for the close button, ',U' for undo, and ',R' for redo. I have attached the altered file 'Line2P.ui'.

I have also attached 'Line2P.js', which has the following changes.If the current prompt is 'First point', then pressing enter or return causes the first point to be set to the last position in the drawing. This is in the 'keyPressEvent' function.I also added the 'hideUiOptions' function. This stores the position of relativezero. Then I added code to 'showUiOptions' to restore the position of relativezero. To add this functionality to all commands, I would assume you could just change the default functions, 'hideUiOptions' and 'showUiOptions' and have them save and restore relativezero. I don't know if this is correct, or even easy.

Anyway, this now has the same functionality as Line2PEx, except for the displaying of angles. But displaying angles would be controlled by 'restrict to angle/length', which I haven't tried as yet.

Finally, I discovered that if you choose Line2P as the very first command you run on starting QCAD, and you enable the restrict to angle or length function, then you can't select a first point. This is because 'getRelativeZero()' returns an invalid point. This means relativezero is not initialised on startup. Setting it to point 0,0 would be useful.

I also added the 'hideUiOptions' function. This stores the position of relativezero. Then I added code to 'showUiOptions' to restore the position of relativezero. To add this functionality to all commands, I would assume you could just change the default functions, 'hideUiOptions' and 'showUiOptions' and have them save and restore relativezero. I don't know if this is correct, or even easy.

Finally, I discovered that if you choose Line2P as the very first command you run on starting QCAD, and you enable the restrict to angle or length function, then you can't select a first point. This is because 'getRelativeZero()' returns an invalid point. This means relativezero is not initialised on startup. Setting it to point 0,0 would be useful.

I downloaded the latest Line2P.js and EAction.js, and they are working great. Except for one slight problem. If you draw some line segments, then use another command (Circle for example), and then exit from the command, relativezero returns to its original position as expected. If you now draw another one or more line segments and then select 'restrict to angle/length', relativezero is moved to where it was when you returned from the other command.I added the following line:-

to the end of the resumeEvent function in EAction.js. This seems to have solved the problem, so I have attached the file EAction.js with the line added.

OK. Eventually, that first key for tools in the options tool bar could even be configurable to some extent.

I agree that it could be changed. It could be an option in 'Application Preferences' under 'Widgets->Toolbars'. However the shortcuts are in the ui file (xml format), and they would all have to be changed. Seems quite diffcult and time consuming unless ther is a better/easier way of doing this.

riverbuoy wrote:This seems to have solved the problem, so I have attached the file EAction.js with the line added.

Great, thanks for the fix!

It could be an option in 'Application Preferences' under 'Widgets->Toolbars'. However the shortcuts are in the ui file (xml format), and they would all have to be changed. Seems quite diffcult and time consuming unless ther is a better/easier way of doing this.

The key codes could be set / adjusted programmatically (QAction::shortcut, QAction::setShortcut), so it might be possible to simply replace the comma with something user configurable.

This replaces the shortcut when the ui options are shown, but the ui file is not chaged. Obviously the prefix character would be set/stored somewhere in Application->Preferences. The disadvantage is each command that has toolbar options would need to write an 'initUiOptions' function if they wanted to allow the user to change the shortcuts.Andrew, Is this the kind of thing you were thinking about?

riverbuoy wrote:Andrew, Is this the kind of thing you were thinking about?

Yes, exactly!

riverbuoy wrote:The disadvantage is each command that has toolbar options would need to write an 'initUiOptions' function if they wanted to allow the user to change the shortcuts.

It should be possible to do that in EAction.prototype.initUiOptions by iterating though all children (optionsToolbar.children() ). Then one could check for each child if it has a keycode starting with a ',' and if so, replace it. What do you think?

It would be nice to also have the option of relative angle-increments.

What I mean is: When starting with a horizontal line and then the next line is 15° up, it would be nice, if the shown angle of the next line would also be 15° (thus relative to the previous line angle).

Andrew wrote:It should be possible to do that in EAction.prototype.initUiOptions by iterating though all children (optionsToolbar.children() ). Then one could check for each child if it has a keycode starting with a ',' and if so, replace it. What do you think?

Yes, I agree. This actually ocurred to me after I posted it. This is what I came up with.

// if first key is Ctrl then the string starts with Ctrl+ // so check for a + sign, which indicates a modifier key has been used // '+' and '-' should not be used as prefix, as they zoom in and out if (str.indexOf('+') === -1) { // no plus sign if (firstChar >= '!' && firstChar <= '~') { // isgraph() str = str.replace(firstChar, prefixChar); child.shortcut = new QKeySequence(str); } } } }};

Instead of checking if the first character of the shortcut is a comma, I check to see if it is a printable character, and if so, replace it. However, if there is a plus sign(+) in the shortcut, that would indicate that a modifier key is part of the shortcut (Ctrl, Alt, Shift etc), so it doesn't change it. As I commented, the plus(+) and minus(-) keys should not be used as prefix because they are one key shortcuts which zoom in and out.If you define 'initUiOptions' in a command, that overrides this function. I tested this with 'Line2P'. So if you didn't want shortcuts to be overridden, then you would define the function in the command. It can even be empty.So, Andrew, you need to decide if you want to implement this, and if so, where it should be in 'Application->Preferences' and what it should be called.The obvious place for the pro version is in the 'Shortcuts and Commands' option. But in the source code version it would need to be elsewhere. I'm not sure that it would be a good idea to have the option in different places.