[Feature request] Rounded slot

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
paddle
Veteran
Posts: 1412
Joined: Mon Feb 03, 2020 4:47 pm

[Feature request] Rounded slot

Post by paddle »

Hey guys,
I'm back using FreeCAD these days, which gives me plenty of ideas to share!
One feature that would be great is the rounded slot which is painful to make manually. To do something like this :
Round slot.png
Round slot.png (112.29 KiB) Viewed 4384 times
This tool usually works by selecting the center of the circle along which the slot will run.
Then select the first point of the slot
Then second point of the slot
Then select the radius of the slot.
chrisb
Veteran
Posts: 54168
Joined: Tue Mar 17, 2015 9:14 am

Re: [Feature request] Rounded slot

Post by chrisb »

Please search the forum, this was already discussed before.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
drmacro
Veteran
Posts: 8978
Joined: Sun Mar 02, 2014 4:35 pm

Re: [Feature request] Rounded slot

Post by drmacro »

Did a macro called ArcSlot a few months back:

https://github.com/macdroid53/FreeCADScripts
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
paddle
Veteran
Posts: 1412
Joined: Mon Feb 03, 2020 4:47 pm

Re: [Feature request] Rounded slot

Post by paddle »

The development of advanced slot features is done.

Three tools are added, all under the regular 'Slot' tool to avoid any bloat of the UI.
slot tool.png
slot tool.png (50.7 KiB) Viewed 3985 times
1 - Slot by 3 points is similar to the regular slot but you have a fourth click to set the radius. Instead of having an automatic radius.
2 - Arc slot is a slot around the arc of a circle.
3 - Rectangle slot is similar to arc slot but with line ends instead of arc ends.

- All tools works with preview of the curves (sketchgui->drawEdit).

- I reused the same code structure as the slot tool. Though arc slot and rectangle slot have individual classes due to the fact that the code was very different, making reusing the same class hard.

- Snap mode is not implemented because I wasn't sure how it could help. Maybe by fixing the angles to round values? Maybe in the future.

- There is only one bug. The icons of the comp don't change of color when in construction mode. The icons have been created, but it doesn't change as it should by the comp onactivated function. Strangely each individual tool has an onactivated function that I can't seem to be able to delete without build error. For other comp like polygons, only the comp as an onactivate function not the individual tools. I feel I'm missing something here.
abdullah wrote: ping
Any idea regarding the icon bug?
Also if you can review those new tools and the chamfers tools when you have a chance?
The branch to which I pushed those tools : https://github.com/PaddleStroke/FreeCAD ... CurvedSlot
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [Feature request] Rounded slot

Post by abdullah »

paddle wrote: Sat Dec 18, 2021 7:44 pm Any idea regarding the icon bug?
Have a look to: DEF_STD_CMD_A and DEF_STD_CMD_AU in src/Gui/Command.h.

You are looking for a macro that has the virtual function updateAction(int mode). This function gets called when the user changes from the construction to the normal mode a vice versa.

This mechanism is generic for any command having modes throughout FreeCAD. The enum defining the construction modes is in GeometryCreationMode.h.

This is used like in:

Code: Select all

  void CmdSketcherCarbonCopy::updateAction(int mode)
    {
        switch (mode) {
            case Normal:
                if (getAction())
                    getAction()->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CarbonCopy"));
                break;
            case Construction:
                if (getAction())
                    getAction()->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CarbonCopy_Constr"));
                break;
        }
    }
Syres
Veteran
Posts: 2898
Joined: Thu Aug 09, 2018 11:14 am

Re: [Feature request] Rounded slot

Post by Syres »

paddle wrote: Sat Dec 18, 2021 7:44 pm The development of advanced slot features is done.

The branch to which I pushed those tools : https://github.com/PaddleStroke/FreeCAD ... CurvedSlot
Thanks for efforts, this will be a nice addition to Sketcher core.
User avatar
paddle
Veteran
Posts: 1412
Joined: Mon Feb 03, 2020 4:47 pm

Re: [Feature request] Rounded slot

Post by paddle »

abdullah wrote: Sun Dec 19, 2021 6:44 am
paddle wrote: Sat Dec 18, 2021 7:44 pm Any idea regarding the icon bug?
Have a look to: DEF_STD_CMD_A and DEF_STD_CMD_AU in src/Gui/Command.h.

You are looking for a macro that has the virtual function updateAction(int mode). This function gets called when the user changes from the construction to the normal mode a vice versa.
Ok so this explained why I couldn't delete the individual updateaction functions.
I used DEF_STD_CMD_AU instead of DEF_STD_CMD_A for the individual tool.

But it still doesn't work. I can't find any difference with my comp compared to regularpolygon comp. My updateaction function seems correct :

Code: Select all

void CmdSketcherCompCreateSlot::updateAction(int mode)
{
    Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(getAction());
    if (!pcAction)
        return;

    QList<QAction*> a = pcAction->actions();
    int index = pcAction->property("defaultAction").toInt();
    switch (mode) {
    case Normal:
        a[0]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateSlot"));
        a[1]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateThreePointsSlot"));
        a[2]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateArcSlot"));
        a[3]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateRectangleSlot"));
        getAction()->setIcon(a[index]->icon());
        break;
    case Construction:
        a[0]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateSlot_Constr"));
        a[1]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateThreePointsSlot_Constr"));
        a[2]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateArcSlot_Constr"));
        a[3]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateRectangleSlot_Constr"));
        getAction()->setIcon(a[index]->icon());
        break;
    }
}
Icons are declared in sketcher.qrc. And Freecad doesn't give any error in the console.
User avatar
paddle
Veteran
Posts: 1412
Joined: Mon Feb 03, 2020 4:47 pm

Re: [Feature request] Rounded slot

Post by paddle »

I rebuilt the project and it's now working !
So the function is completely working and waiting for approval!
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Feature request] Rounded slot

Post by Kunda1 »

Does the new functionality also have some unittests for automatic testing to catch regressions etc... ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
paddle
Veteran
Posts: 1412
Joined: Mon Feb 03, 2020 4:47 pm

Re: [Feature request] Rounded slot

Post by paddle »

Sorry but I don't know what those are.
Can you please point to where I should start to have a look if that's a necessary component?
Thanks
Post Reply