[ Fixed ] [ Bug ] Draft problem with coordinate input

A forum dedicated to the Draft, Arch and BIM workbenches development.
Roy_043
Posts: 883
Joined: Thu Dec 27, 2018 12:28 pm

[ Fixed ] [ Bug ] Draft problem with coordinate input

Postby Roy_043 » Thu Feb 06, 2020 8:36 am

I would like to draw attention to a problem that was reported here:
https://forum.freecadweb.org/viewtopic.php?f=3&t=42630

In a nutshell:
When entering the first point for a Draft object only the numerical portion of the coordinate input fields gets selected and you can just key in the desired coordinates. But for the X coordinate of subsequent points the whole input field is selected. This means that a user with units set to cm has to be wary because entering a coordinate without units means that the program assumes mm.

Code: Select all

OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19424 (Git)
Build type: Release
Branch: master
Hash: 899854ac5d643e991a1006ed75aeff93baf3d224
Python version: 3.7.3
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Dutch/Netherlands (nl_NL)
Attachments
DraftCoordInput.png
DraftCoordInput.png (21.85 KiB) Viewed 439 times
Last edited by Roy_043 on Mon Mar 16, 2020 10:09 am, edited 1 time in total.
carlopav
Posts: 769
Joined: Mon Dec 31, 2018 1:49 pm

Re: [ Bug ] Draft problem with coordinate input

Postby carlopav » Thu Feb 06, 2020 4:38 pm

There are also other annoying things in input fields: if preference set focus on length is set, length field does not support xyz axis locking.
vocx
Posts: 3336
Joined: Thu Oct 18, 2018 9:18 pm

Re: [ Bug ] Draft problem with coordinate input

Postby vocx » Fri Feb 07, 2020 12:45 am

I find these types of issues difficult to troubleshoot because the graphical code that creates the Draft task panel, the widgets, and handles the callbacks is inside a massive class called DraftToolBar inside DraftGui.py. Until we can split this class into more manageable pieces it's going to be difficult to pinpoint exactly which code is responsible for what behavior. We'll get there little by little.
Always add the important information to your posts if you need help.
To support the documentation effort, and code development, your donation is appreciated: paypal.
carlopav
Posts: 769
Joined: Mon Dec 31, 2018 1:49 pm

Re: [ Bug ] Draft problem with coordinate input

Postby carlopav » Sat Feb 08, 2020 1:46 pm

I had a quick look. It seems the coordinate conversion is done in InputField.cpp and DraftGui just get the value returned from it. So there's nothing much we can do in Draft about that.
Maybe it's worth to signal in other forum: if the input is unitless, user preferred coordinates should be computed, not FreeCAD default ones.
EDIT: no, i was not right, it's just a matter of setSelection... perhaps i have a solution... let's see...
carlopav
Posts: 769
Joined: Mon Dec 31, 2018 1:49 pm

Re: [ Bug ] Draft problem with coordinate input

Postby carlopav » Sat Feb 08, 2020 4:12 pm

It's done! :)
PR: https://github.com/FreeCAD/FreeCAD/pull/3023

Also, i'd like to cleanup all the DraftGui removing everything concerning Draft Edit. Since AddPoint, RemovePoint, Arc3PointEditing, BezCurveVertexOptions, are handled inside Draft Edit Context Menu.

@vocx, I noticed there are commands that use DraftToolbar, and others that have dedicated UI classes (ScaleTaskPanel, ShapeStringTaskPanel). There is not a common class inherited by others. This probably could be one source of confusion.
vocx
Posts: 3336
Joined: Thu Oct 18, 2018 9:18 pm

Re: [ Bug ] Draft problem with coordinate input

Postby vocx » Sat Feb 08, 2020 4:28 pm

carlopav wrote:
Sat Feb 08, 2020 4:12 pm
Also, i'd like to cleanup all the DraftGui removing everything concerning Draft Edit. Since AddPoint, RemovePoint, Arc3PointEditing, BezCurveVertexOptions, are handled inside Draft Edit Context Menu.
Go ahead. This is pretty complex code so I it hurts my brain to look at it. I don't want to touch it at the moment. Since you have been looking into the edit modes, maybe you have a clearer idea of what is used and what isn't used.
@vocx, I noticed there are commands that use DraftToolbar, and others that have dedicated UI classes (ScaleTaskPanel, ShapeStringTaskPanel). There is not a common class inherited by others. This probably could be one source of confusion.
Most commands use the DraftToolBar. The Scale and Shapestring seem to be special indeed. Maybe those were added not by Yorik, or at that point it was easier to use a separate interface. I do remember the Shapestring panel changed around 0.17.

I would move those to appropriate modules in "drafttaskpanels/".

The commands that I've written from scratch, Draft_PolarArray, Draft_CircularArray, etc., don't use DraftToolBar precisely because I don't want to get tangled in that old code. It works for me, but we also lose some nifty features like the tracker setup and Coin callbacks to X, Y, Z, keys, and so on. These can be added later, I think, so I don't worry too much.

The Draft_Fillet command does use DraftToolBar, but I really want to re-work this tool so it doesn't, and it follows the structure of Draft_PolarArray et al.
Always add the important information to your posts if you need help.
To support the documentation effort, and code development, your donation is appreciated: paypal.
carlopav
Posts: 769
Joined: Mon Dec 31, 2018 1:49 pm

Re: [ Bug ] Draft problem with coordinate input

Postby carlopav » Sat Feb 08, 2020 5:37 pm

I'll continue to other thread to not hijack this one.

For this topic I noticed another strange thing when drawing a line:
- if focus is on x coordinate, you just press Enter to finish the line
- if focus is on length (my preferred way), you have to press Enter twice to finish the line.

Can we change this and make it just one Enter for both?
User avatar
yorik
Site Admin
Posts: 11700
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: [ Bug ] Draft problem with coordinate input

Postby yorik » Sat Feb 08, 2020 6:48 pm

carlopav wrote:
Sat Feb 08, 2020 5:37 pm
Can we change this and make it just one Enter for both?
I would say yes, definitely!
carlopav
Posts: 769
Joined: Mon Dec 31, 2018 1:49 pm

Re: [ Bug ] Draft problem with coordinate input

Postby carlopav » Sat Feb 08, 2020 10:21 pm

Updated the PR also with this!
inplemented behaviour allow single enter to accept input if line is parallel to xyz axis also if focus is set on length.
fc_tofu
Posts: 278
Joined: Sun Jan 05, 2020 4:56 pm

Re: [ Bug ] Draft problem with coordinate input

Postby fc_tofu » Fri Feb 14, 2020 4:28 pm

Roy_043 wrote:
Thu Feb 06, 2020 8:36 am
I would like to draw attention to a problem that was reported here:
https://forum.freecadweb.org/viewtopic.php?f=3&t=42630
...
Well done and thank you, fc coders!

Other issues I thought as limitation of FC coordinate, pls give some consideration.
1. DraftWB, if you enter a unitless number, FC treat it as "mm", not prefered-unit-system, ie, MKS (Preferences>General>Unit>Unit system).
2. Most workbenches (PartWB/PartDesignWB/Sketcher/TechDraw), donnot take prefered-unit-system as a matter. They alway use "mm", or adatpive unit in some cases.
3. FC saves prefered-unit-system in Preferences ("user.cfg"), which is not as convinient as file properties (.FCStd), IMHO.