Customize shortcut/hotkeys

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Customize shortcut/hotkeys

VyasG_007
I would like to customize shortcut keys of commands as per my needs or similar to AutoCAD.

Is there any 'Preferences' or 'Settings' available for the same??

As far as I know, this is subjected to re-defining of source code.

I WISH, IF I WAS DEVELOPER (if the solutions will not sort out, I am going to C++ academy) so that frequently raised question will be solved within my OS at least....

By the way I am a professional AutoCAD user, 5+ years of experience as CAD Designer...(I was wondering how can I give suggestion to develop this software for upcoming updates)
Reply | Threaded
Open this post in threaded view
|

Re: Customize shortcut/hotkeys

fa201
You can check the documentation for 'alias' :
https://librecad.readthedocs.io/en/latest/guides/cmdline.html#command-aliases
I suggest to keep a copy of default alias file...
Fabrice

French hobbyist interested in 2D design.
Reply | Threaded
Open this post in threaded view
|

Re: Customize shortcut/hotkeys

VyasG_007
It seems that I did modify few commands and it was successfully worked.

BUT I AM UNABLE TO ADD NEW COMMAND IN ALIAS!!!!
see the image below and let me know how to add this Tangential 2 Circles,Radius to alias
(I edited 'alias' in WordPad and it works on the other hand I am unable to add new command such as below image into 'alias'

 

P.S.: I did make a copy of the default 'alias' file and then edited successfully.
ACL
Reply | Threaded
Open this post in threaded view
|

Re: Customize shortcut/hotkeys

ACL
Is the problem that you don't know what the command is, in cases where it's not already listed in the alias file? I ran into the same thing when I was investigating the various snap modes. For instance drawing a line from point to tangent was listed in the alias file (tangentpc) but tangent to tangent (I assume it would be tangentcc) wasn't. Even in the reference https://librecad.readthedocs.io/en/latest/ref/tools.html most commands are only shown in their full form if there is also an alias.

I would be happy to help with this documentation if I knew the commands. I see some of them in rs_commands.cpp but they seem to only be the ones with aliases. In fact it seems redundant to me that the default aliases are hard-coded into that file and also listed in the aliases file. Seems you'd want the file to have only the true command and the aliases to be only in the aliases file. What happens if you remove an alias from the file because you are used to it doing something different? Will it still work because it's hard-coded?

Anyway, I didn't see "circle tangent to two existing circles" in the rs_commands.cpp file so maybe I haven't helped much yet. I'll keep looking around.
ACL
Reply | Threaded
Open this post in threaded view
|

Re: Customize shortcut/hotkeys

ACL
I'm getting lost in all of the source code but let me add a bit more. It seems that the commands are listed in the qg_actionhandler.cpp file. The circle-related ones are:

rs_actiondrawcircle  * circle, ci
rs_actiondrawcircle2p   * circle2, c2
lc_actiondrawcircle2pr
rs_actiondrawcircle3p   * circle3, c3
rs_actiondrawcircletan1_2p
rs_actiondrawcircletan2_1p
rs_actiondrawcirclecr   * circlecr, cc
rs_actiondrawcircleinscribe
rs_actiondrawcircletan2
rs_actiondrawcircletan3   * tan3, ct3

Only the commands with existing aliases (with stars and aliases, above) are in the file I mentioned previously, so on the other five, maybe we have no immediate way to access them with an alias because there isn't already an alias. What is listed as the "command-untranslated" in the alias file is really just an alias anyway?

There is also a file rs_circle.cpp which has subroutines for different circle types. I think the one you want is this one but I don't know the link between the commands above and this function. Maybe it is called by rs_actiondrawcircletan2?


/**
  * create a circle of radius r and tangential to two given entities
  */
RS_VectorSolutions RS_Circle::createTan2(const std::vector<RS_AtomicEntity*>& circles, const double& r)
{
    if(circles.size()<2) return false;
        auto e0=circles[0]->offsetTwoSides(r);
        auto e1=circles[1]->offsetTwoSides(r);
    RS_VectorSolutions centers;
        if(e0.size() && e1.size()) {
        for(auto it0=e0.begin();it0!=e0.end();it0++){
            for(auto it1=e1.begin();it1!=e1.end();it1++){
                centers.push_back(RS_Information::getIntersection(*it0,*it1));
            }
        }
    }
    for(auto it0=e0.begin();it0!=e0.end();it0++){
        delete *it0;
    }
    for(auto it0=e1.begin();it0!=e1.end();it0++){
        delete *it0;
        }
    return centers;

}
Reply | Threaded
Open this post in threaded view
|

Re: Customize shortcut/hotkeys

LordOfBikes
Administrator
I created an issue on github for this and linked the involved source files there.
https://github.com/LibreCAD/LibreCAD/issues/1225

Armin
ACL
Reply | Threaded
Open this post in threaded view
|

Re: Customize shortcut/hotkeys

ACL
Cool. I'll look into how I can help.

Do you think the aliases should be taken out of the rs_commands.cpp file? It seems like duplication; there should be one and only one place for them. I'm guessing their presence in that file predates the separate aliases file.
Reply | Threaded
Open this post in threaded view
|

Re: Customize shortcut/hotkeys

flywire
@ACL your suggestion sounds reasonable. Add it to https://github.com/LibreCAD/LibreCAD/issues/1225, or perhaps even contribute a pull request.
Reply | Threaded
Open this post in threaded view
|

Re: Customize shortcut/hotkeys

LordOfBikes
Administrator
In reply to this post by ACL
@ACL, I wouldn't say duplication, because the commands have to be mapped to actions somewhere.
But the implementation is not optimal, it is error-prone. For new actions it is not obvious nor mandatory to add a command. And that's why some are missing.
So that's the way it currently works. The fastest way is to iterate trough both files and add missing commands in rs_command.cpp.

A refactoring of this implementation is a bigger task for sure.
I can imagine to use an abstract base class for actions which requires to implement a command definition method.
At least this only moves the instantiation of the command into the action class to which it belongs.
Maybe this allows a clearer mapping in rs_command.cpp by iterating over the ActionType enum somehow.
But finally, the mapping has to be done somewhere and until it runs totally transparent and automatically, it has always the issue that actions may be forgotten.
So I'm not sure from top off my head if this is possible at all. We have to check the underlying construction of classes to see if there is a chance to change it without too much effort.

If you have further questions or want to battle this challenge, don't hesitate to ask, preferred in the github issue linked above.

Armin
ACL
Reply | Threaded
Open this post in threaded view
|

Re: Customize shortcut/hotkeys

ACL
This post was updated on .
All I mean is that in rs_commands we only would have one command-line command which is considered the native one. Beyond that there would be an alias in the alias file. What we have now is that rs_commands has (for instance) "line" and "li" both called out as available commands, AND the alias file has "li" as an alias for "line."  *

I assume this was from before there was a separate alias file; aliases/shortcuts were hard-coded into the command.

To me, the unintended consequence of this is that the user can't delete an alias that he doesn't want because it's also a real command. For instance if a user has it in his brain from long ago that "li" means "list" or something, he may not be able to stop it from being "line."


*Now it could be that I misunderstand this, and that the second definitions need to be in rs_commands because of Keycode Mode.
Reply | Threaded
Open this post in threaded view
|

Re: Customize shortcut/hotkeys

LordOfBikes
Administrator
I got your point.
Don't nail me down on following statements, all from top off my head, no time to check the code myself yet.
I think the alias file isn't deployed, it's generated from these codes in rs_command.cpp on startup.
It may be also needed for the clear settings feature in application preferences.
At least, the commands and aliases are extracted by translation tools for localization.
And yes, Keycode mode is also involved there.

This initialization in rs_command.cpp can be very irritating because of all the curly braces.
Basically each mapping contains 3 elements, a list of command words, a list of aliases and the ActionType enum.
Each command or alias itself is a pair of strings, where the first string is the base and the second string is the localized version. The second string inside QObject::tr() is only a comment shown to the translator.
For example find "draw parallel line", it has 2 commands and 2 aliases. Or "draw rectangle" which has only one command but 3 aliases.
But most commands have only one command and one alias.

Also I don't want to exclude, that there are some inconsistencies, where different commands have the same aliases. I think I remember this from my earlier translation tasks.
This is another issue, but I think it's worth to investigate.
Reply | Threaded
Open this post in threaded view
|

Re: Customize shortcut/hotkeys

VyasG_007
In reply to this post by ACL
Well it works at some extent though, after making some minor adjustments.

For instance, in alias, untranslated command 'Trim' and its shortcut key changed from tm to tr.

I wonder how and where can I give suggestions about few changes that are required with the commands like Lines and Circles, because it is 90% used during drawing creations

Like any tool (Circle or Line) should be able to enter along with the cursor movement (which can be seen under Command Line) rather than going to TOOLS OPTIONS every single time (enter values into the box located at toolbar) which is time consuming process if there are multiple parts drawing. Because as Professional CAD engineer, it bothers me that going to tool option every time to input the value, start-middle-end snap points.

Hope to get this feature will update in next upcoming releases, I guess.
ACL
Reply | Threaded
Open this post in threaded view
|

Re: Customize shortcut/hotkeys

ACL
In reply to this post by LordOfBikes
The aliases file could be generated upon installation by rs_command.pp, but after that it persists through updates. My custom edits remained when I went from 2.1.3 to 2.2.0, and when I reset application preferences.

If the two-letter aliases in rs_commands need to be there for Keycode Mode, I need to think about that a bit. That would mean that we will have a complete and permanent set of aliases, that must be two letters, for KM. That may become very limiting. I just tested this, changing the alias "li" to alias to "circle" in my alias file. Opened LC, turned KM off, used li, and it made a line. So the definition of "li" in rs_commands overrides any alias that is set on the user side. Fully populating the rs_commands file with two-letter aliases will block a LOT of aliases out from user customization.

Thanks for the insight into the structure of the rs_commands file.