## Better selection system for constraints in Sketcher

A forum for research and development of the user interface of FreeCAD

Moderator: agryson

cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

### Re: Better selection system for constraints in Sketcher

NormandC wrote:Actually it's already available: just add a tangent constraint between two lines.
In FreeCAD there is always new gems to be discovered.
efyx wrote:It works fine - just to revise description "tangent / collinear"
+1
efyx wrote:Quadrant constrain, or great extrude solution?
I guess I was referring to Quadrant constraint, the extrude solution I must admit I do not understand. I do not understand why removing part of the circle is not good?
chrisb
Posts: 35373
Joined: Tue Mar 17, 2015 9:14 am

### Re: Better selection system for constraints in Sketcher

NormandC wrote: Actually it's already available: just add a tangent constraint between two lines.
Thanks Normand, this fits perfectly in the system of the other constraints. And thinking it over: knowing that the constraints work on the projection of lines as well, I could have known myself .
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
jnxd
Posts: 162
Joined: Mon Mar 30, 2015 2:30 pm

### Re: Better selection system for constraints in Sketcher

As far as I have learned, points are collinear, and not lines. I understand it'll make life much easier, but we can always just introduce a construction line and put all the coincident constraints we need. With the current implementation we are restricted to a maximum of 3 involved geometries. and more than 3 points can always be collinear. Also, if we are introducing collinear, we might as well introduce concyclic, and then concentric, et cetera. ThereThey can be implemented as convenience functions rather than separate constraints, on the lines of lock. However, I do believe it'll need quite a bit of screen space.

@efyx: so the "quadrant constraint" is to find the leftmost/rightmost/topmost/bottommost points?
Last edited by jnxd on Fri Dec 23, 2016 10:15 am, edited 1 time in total.
chrisb
Posts: 35373
Joined: Tue Mar 17, 2015 9:14 am

### Re: Better selection system for constraints in Sketcher

jnxd wrote:There can be implemented as convenience functions rather than separate constraints, on the lines of lock. However, I do believe it'll need quite a bit of screen space.
I like the idea of convenience constraints. They act like the convenience elements rectangle, hexagon, slot, etc. They create well known constraints and if necessary additional construction lines. They could live in a separate toolbar which can be hidden for those who want less stuff on the screen.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
jnxd
Posts: 162
Joined: Mon Mar 30, 2015 2:30 pm

### Re: Better selection system for constraints in Sketcher

Okay so I have hit a roadblock while implementing my idea of selecting after choosing constraints. There are a bunch of cases to handle:
1. Those applied on single geometries, like lock, vertical, and horizontal. Easiest to implement, much like the touch of Midas, constrain everything one clicks.
2. Those that apply on pairs of items of the same type at a time, but multiple items can be selected at a time and the constraint applied in one go. These include parallel, coincident and equal. The problem here is that it is probably faster to just select all and apply constraint once than select one pair at a time, in which case multiple selections have to be made. One option here would be to let the users select as many objects as they want and then click somewhere to apply all at once, but if anyone has another idea, please suggest.
3. Those that apply on 2 items of dissimilar types (say A and B), but multiple selections can be made for one type (many A's and one B or one A and many B's), like point on object and one variant of perpendicular. similar problem as earlier.
4. Those that need unique kinds of selections. pretty much easy, like all variants of tangent, the line-line variant of perpendicular, et cetera.
5. DistanceX and distanceY can be applied on a single point or between 2 points.
6. So many constraints can be applied in different variations.
Would anyone like to input how you want the interface to be?
Pauvres_honteux
Posts: 527
Joined: Sun Feb 16, 2014 12:05 am
Location: Far side of the moon

### Re: Better selection system for constraints in Sketcher

jnxd wrote: @Pauvres_honteux: I would be interested to know how the French program you mentioned handles the above issue. Could you link me to a Youtube video, perhaps?
Hi jnxd, sorry for not being able to bring forward an example video on my suggestion. I can't find a video even remotely showing this in a clear way. There are a few where one can faintly see some blue-ish lines and circles flashing by while they are sketching along.

These blue-ish visual geometry did however remind me that I did forget to mention these visual help geometries.

It's a continously running visual "constraint suggestion" that shows what possible constraints there are at the tip/position of the mouse pointer. Those visual, not applied, constraints is shown directly after one starts a geometry command, e.g. a line, point, arc and so on. They are shown in a different and fainter color for distinction.

They also loosley snaps at these constraint positions, so if one whishes to utilise that particular, suggested, constraint one just click and "sketch" on to the next position. N.B. no constraints are set yet.

These "constrain suggestions" are always running as soon as one does any type of sketching. I don't think about them any more, it's probably why I forgot to mention it before. Sorry for that.

One can also turn on "running auto constraints" similar to what we already have and get all those suggested constraints immortalised as real constraints with a mouse click. With that click we're back at my original suggestion!

This system/principle allows for very few clicks and hand movements for the user.

Whatever system/principle you choose, please do not involve the keyboard, as one then must rise up from the really low, cosy, position of yours and find the key(s) before sinking back again into that nice dozed off posture!

And Merry Christmas to ye all !!!
jnxd
Posts: 162
Joined: Mon Mar 30, 2015 2:30 pm

### Re: Better selection system for constraints in Sketcher

I am sorry Pauvres_honteux, but I don't think I will be able to follow anything without pictures. Maybe just name the software and generate a few screenshots/casts yourself?
Pauvres_honteux wrote: Whatever system/principle you choose, please do not involve the keyboard, as one then must rise up from the really low, cosy, position of yours and find the key(s) before sinking back again into that nice dozed off posture!
Oh indeed! I would hate to interrupt the keyboardless flow some might choose to have. Also, I do want to see freecad come to tablets! However, I do opine that when one is active, a keyboard comes as a reallt handy tool, much like when playing a pc game!

I will implement whatever I can, but am leaving certain decisions to the community. I am currently thinking of certain commonalities within the constrainting system to make use of. Hopefully a parser-like tool that will act as soon as sufficiently many elements are selected.
jnxd
Posts: 162
Joined: Mon Mar 30, 2015 2:30 pm

### Re: Better selection system for constraints in Sketcher

Now I moved to the coincident constraint. As I mentioned earlier there is an ambiguity about what to do about applying coincident constraints on more than two points at once. For now I resolved this by keeping one of the points saved once the constraint is applied as one of the points for the next constraint. Thus, successively selecting points will make them all coincident with one another. Clicking on a non-point region will clear the selection completely, allowing one to start afresh. If people want a different option, please do tell.

Currently I am not able to get one of the points to be the origin, which is valid selection for coincident constraint. If anyone can help me out with it, it'd be great.

I can quickly see that making new modes for constraints will drastically add to the already large file CreateConstraints.cpp. Perhaps we should split this file, say into simple and dimensional constraints, and further we add the convenience constraints as a yet separate file, if we implement it? Also, a smarter way to implement these constraint creation modes could be useful that exploits the similarities between different constraints.

Finally, does anyone think I should continue this discussion on development forum?
bejant
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

### Re: Better selection system for constraints in Sketcher

jnxd wrote:Currently I am not able to get one of the points to be the origin, which is valid selection for coincident constraint. If anyone can help me out with it, it'd be great.
I'm not sure if this will help or not, but when I click on Part Design pull-down menu > Sketcher Tools > Select Origin (or Crtl + Shift + O) in 0.16.6707 I get this in the Report View:

Code: Select all

``Sel : Add Selection "Unnamed.Sketch.RootPoint(0.000000,0.000000,0.000000)"``
I didn't get any message about it in my 0.17 daily build.

OS: Ubuntu 16.04.1 LTS
Word size of OS: 32-bit
Version: 0.16.6707 (Git)
Build type: None
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

OS: Ubuntu 16.04.1 LTS
Word size of OS: 32-bit
Version: 0.17.9341 (Git)
Build type: None
Branch: master
Hash: 21f430da2cf3db06ddf7160fbd235170a49cc3ac
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
jnxd
Posts: 162
Joined: Mon Mar 30, 2015 2:30 pm

### Re: Better selection system for constraints in Sketcher

@bejant: A more precise statement of my problem is the following:
• I make the constraint modes by subclassing DrawSketchHandler. The pressButton and releaseButton methods of this class replace the default selection mechanism of FreeCAD with whatever you want (On an aside they return bool rather than void, which I suspect means something but I can't figure out what). So I have to reimplement selection.
• The preselect tools come in 3 flavors: point, cross and curve. Out of them point is what I need, but it just returns vertex IDs that start from 0. It returns -1 when cursor is not on a vertex, but it also returns that value when the cursor is on origin! Thus I cannot tell that I am on the root and thus cannot manually add it to the selection or do anything else that is necessary.
I believe the getPreselectPoint method must return saying it's on origin when it is, but I don't know how to get it to do so.