Sketcher: Bezier curves

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

triplus wrote:Ideally i guess right click would do it. But if you are facing technical challenges preventing you to implement such behaviour i can understand that.
Well, I think we have to decide what we want. It does not mean it has to be this way, only that we have not come yet with a better idea.

For example, it may be possible to actually create points at each click, so that if the last point is the same as the first, it closes. We only have to delete the introduced points before creating the BSpline.

We can also modify ViewProviderSketch to change the current ESC/right click behaviour for ViewProviderSketch...

Code: Select all

   else if (Button == 2) {
        if (!pressed) {
            switch (Mode) {
                case STATUS_SKETCH_UseHandler:
                    // make the handler quit
                    edit->sketchHandler->quit();
                    return true;
for example by adding a special case in quit() for BSpline...

Code: Select all

void DrawSketchHandler::quit(void)
Maybe I even came with some preliminary idea...
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher: Bezier curves

Post by triplus »

How does the polyline creation process differ? As that basically works in the way we are after?
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Sketcher: Bezier curves

Post by microelly2 »

Thanks for this tool,
here my first application https://youtu.be/wul_QMwTPZ8
create 3 bsplines with sketcher
and use them to create a soft corner (i call it hood https://www.youtube.com/watch?v=Q8ot6eAMUQs)
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

triplus wrote:How does the polyline creation process differ? As that basically works in the way we are after?
Select polyline in FC. Click point 1. Click point 2. Now you have a geometry line created while you head to click on point 3. Click on point 3. Now you have two lines created while you head to click on point 4. Now you right click and the creation that is cancelled is the one from point 3 to the not-yet-clicked point 4. The first two lines are not canceled as they were already created.

This you can not do with B-Spline, as you can not create it until you have the last pole.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

microelly2 wrote:Thanks for this tool,
here my first application https://youtu.be/wul_QMwTPZ8
create 3 bsplines with sketcher
and use them to create a soft corner (i call it hood https://www.youtube.com/watch?v=Q8ot6eAMUQs)
I appreciate seeing an application...although I have only seen a couple of frames... my internet today is peaking at 5 KB/s (it reminds me of the days with the 33.6 kbps modem)... hopefully tomorrow it will go at a speed more of this century...
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher: Bezier curves

Post by triplus »

abdullah wrote:
triplus wrote:How does the polyline creation process differ? As that basically works in the way we are after?
Select polyline in FC. Click point 1. Click point 2. Now you have a geometry line created while you head to click on point 3. Click on point 3. Now you have two lines created while you head to click on point 4. Now you right click and the creation that is cancelled is the one from point 3 to the not-yet-clicked point 4. The first two lines are not canceled as they were already created.

This you can not do with B-Spline, as you can not create it until you have the last pole.
I see. Thanks for the explanation.

And i am guessing when user is creating the poles. For that purpose polyline couldn't be used instead? And only after the right click action to convert the polyline to spline. By reusing polyline points as spline poles and removing the polyline altogether?
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

triplus wrote:And i am guessing when user is creating the poles. For that purpose polyline couldn't be used instead? And only after the right click action to convert the polyline to spline. By reusing polyline points as spline poles and removing the polyline altogether?
It goes in the direction of adding points as I indicated above, but this has to be done in conjuntion with doing something "special" when right-clicking i.e. remove whatever it was introduced and create the bspline... I think this is probably the best direction to go... let's see if something comes out of it...
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher: Bezier curves

Post by triplus »

Now i feel i understand the mentioned technical obstacle. Currently you don't have that "special" right click behaviour available. You'll need to inject it somewhere to after do the right thing. :)

P.S. Well wish i could help you further but on the other hand i am confident you'll find the solution needed!
jean.thil
Posts: 209
Joined: Tue Jul 28, 2015 7:28 am

Re: Sketcher: Bezier curves

Post by jean.thil »

This you can not do with B-Spline, as you can not create it until you have the last pole.
Is that sure ?
On SW and SE, you as soon as you click on one point, a spline is drawn using the position of the mouse as the last pole.
So with one click, you have a line, two , a parabola, and so on.
This way of doing probably needs a " add one pole " method.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Bezier curves

Post by abdullah »

jean.thil wrote:
This you can not do with B-Spline, as you can not create it until you have the last pole.
Is that sure ?
On SW and SE, you as soon as you click on one point, a spline is drawn using the position of the mouse as the last pole.
So with one click, you have a line, two , a parabola, and so on.
This way of doing probably needs a " add one pole " method.
What I meant is that you can not create the one B-Spline you want to create. You can create a B-Spline with less number of poles that will go in another trajectory. However, yes, that could be another approach.
triplus wrote:Now i feel i understand the mentioned technical obstacle. Currently you don't have that "special" right click behaviour available. You'll need to inject it somewhere to after do the right thing. :)
Well, apparently implementing the right-click behaviour users expect was much easier than I anticipated.

Somebody interested could compile this branch and give me feedback if this is it:

https://github.com/abdullahtahiriyo/Fre ... age1b_2017

This does not support closing on clicking the start point (non-periodic case) yet. That is a different problem to tackle separately.
Post Reply