Commit Graph

73 Commits

Author SHA1 Message Date
Roy-043
3a94a42956 Draft: fix display of cross-shaped cursor
If snapping was off, and after clicking the first point of a new line (for example), the cursor would be a default arrow instead of the intended cross-shaped cursor.

Note that the arrow cursor is still displayed for a fraction of a second after this fix.

May also fix #16559.
2025-08-04 11:02:38 -05:00
Roy-043
d590fdf3e6 Draft: fix handling of MouseDelay
The MouseDelay sets a point value to None. In some cases this point was then still used resulting in attribute errors.

See:
https://github.com/FreeCAD/FreeCAD/issues/19531#issuecomment-2651341711
2025-07-28 17:52:02 +02:00
Roy-043
3b8dc20acc Draft: fix hang on snapping to large point cloud 2025-07-21 11:04:53 -05:00
Yorik van Havre
40d385859a Draft: Added snap recenter functionality (#19728)
* Allow to align the working plane on selected edge + face of a same object, which aligns the plane with the face, but positions it on the edge (the WP is positioned on the edge's first vertex, the WP's X axis is aligned with the edge, and the face's center point provides the third point to define the plane)
* Added a "Recenter" in-command shortcut. This moves the WP to be centered on the current snap position (the WorkingPlane snap button is taken into account, so one can only move the WP in the same plane or not).
2025-05-27 19:17:43 +02:00
Roy-043
cbaf1f3c01 Draft: make Near snap obey 'Always snap' setting
Fixes: #19553.

Additionally:
* Removed 2 unused attributes (`self.lastSnappedObject` and `self.active`).
* Improved the readability of `snapToObject` a little bit.
* Made the return value of that function consistent (vector or None).
2025-03-20 10:14:49 +01:00
Roy-043
2ff5bea79e Updated based on comment 2025-03-12 09:47:03 +01:00
Roy-043
c526bd9bbe Draft: Fix error in #20118
The code in #20118 would fail if only Near snap was active.
2025-03-11 15:57:37 +01:00
Roy-043
7b179f53a4 Draft: Correct Near snap override behavior
Fixes #15017.

Currently Near snap overrides all other 'on-object' snaps such as Midpoint snap and Endpoint snap. With this PR Near snap no longer 'wins' if a different snap point is within snapRange of the cursor.
2025-03-11 10:48:12 +01:00
Roy-043
11c33d897a Include other Draft commands 2024-11-30 16:48:41 +01:00
Roy-043
6c7ecda81c Draft: Fix cursor scaling for xcb platform
Forum topic:
https://forum.freecad.org/viewtopic.php?t=92281

Apparently the extra scaling for the "xcb" platform is wrong.
2024-11-28 14:01:52 +01:00
Roy-043
2543a57325 Draft: fix snapping to endpoints of dimension lines (V0.19 regression)
This fixes a regression introduced in V0.19 (!) when the type of linear dimensions was changed from "Dimension" to "LinearDimension".

Forum topic:
https://forum.freecad.org/viewtopic.php?t=90292
2024-09-05 13:18:32 +02:00
Roy-043
f851eea6a8 Draft: Fix cursor scaling (#15745)
* Draft: Fix cursor scaling

The get_cursor_with_tail function was rewritten to match the Sketcher cursor code. Hopefully this fixes the scaling issue.

Related issue:
#13696

Related forum topic:
https://forum.freecad.org/viewtopic.php?t=89494

@maxwxyz
Can you check if this code fixes the issue? Apart from the size the 'hot' pixel should be checked. If you approach a vertical line from the left or right it should get highlighted at the same distance.
2024-08-08 12:07:34 +02:00
Roy-043
2bd0a06991 Draft: fix wrong selection after commands
Fixes #10469

The code of the `end_all_events()` function is by Chris Hennes (chennes).
See https://forum.freecadweb.org/viewtopic.php?p=656362#p656362.
2024-02-12 11:32:58 -06:00
Ladislav Michl
839fb17649 Draft: Use widgets from QtWidgets 2024-01-25 14:27:38 +01:00
Roy-043
8ea799bd61 Draft: gui_snapper: setTrackers can be called if there is no 3D view 2024-01-05 10:50:46 +01:00
Roy-043
b0aa33f92a Draft: implement new get_param functions (step 2)
See #11677
2023-12-12 14:48:09 +01:00
Roy-043
770eb5e64a Draft: remove maxSnap parameter
It is superfluous. The maxSnapEdges parameter can be set to zero.
2023-12-08 12:06:36 +01:00
Roy-043
904b37b47d Draft: implement DefaultAnnoLineWidth and DefaultAnnoLineColor prefs
The format_object function in gui_utils.py still requires some work (in connection with the Draft_SetStyle command). This will be done later.
2023-11-29 23:06:17 +01:00
Roy-043
9f235c281e Draft: use clearer snap marker names 2023-11-25 19:29:12 +01:00
Roy-043
a3f285cb46 Draft: improve Snap bar show-hide preference
This PR replaces the showSnapBar and hideSnapBar preferences with a single new preference: SnapBarShowOnlyDuringCommands.

Additonally:
Improved some param observer callbacks.
2023-11-24 13:30:03 +01:00
Roy-043
59ba9146b8 Draft: improved handling of snap prefs
* Some trackers had 2 color nodes.
* Added a setColor function to some trackers.
* Added a set_snap_style function to the Snapper class.
2023-11-21 17:14:17 +01:00
Roy-043
05f064d35b Draft: constraining did not respect global mode
Fixes #10496.
2023-11-18 13:36:35 +01:00
Roy-043
50e5130060 Draft: cleanup related to PR11336
See #11336
2023-11-14 11:51:34 +01:00
Roy-043
89c967008d Draft: Improve grid behavior
This PR improves the behavior of the Draft grid:
* Options in the preferences: "Always show the grid" and "Show the grid during commands".
* The parameters are used for new views. In existing views the grid can be toggled either during a command or when no command is active.
* When switching to a different workbench all grids are hidden unless GridHideInOtherWorkbenches is set to `False`. This can be a Fine-tuning parameter IMO.

Notes:
* The defaultCameraHeight parameter becomes obsolete. It was only used in very specific circumstances.
* The code of PR #8818 becomes obsolete. It makes more sense to use `App.activeDraftCommand` instead of adding a `tool` argument to some functions. Will do some related cleanup later.
* Improved alignment for the related preference ui. The checkbox interaction has been fixed as well.
2023-11-10 14:02:38 +01:00
Roy-043
f200e8f54a Draft: Updates related to the PlaneGui class (step 4)
Related issue:
#5603.

For gui_snapper.py and gui_trackers.py an intermediate solution has been adopted. They still rely on App.DraftWorkingPlane, but now use a small function to retreive it.

Simply switching to the PlaneGui class is problematic for the trackers as this results in an endless recursion (wp->grid->wp->...). Using the old App.DraftWorkingPlane (which is kept up-to-date by PlaneGui) solves this for now. I will try to return to this later (which may be after the next release though).
2023-10-31 15:41:21 +01:00
Roy-043
3e45d030cf Draft: Fix cursor scaling issue
Fixes #6793
2023-10-09 14:01:21 +02:00
Roy-043
4d7277138b Draft: fix near snap for meshes (#9719) 2023-06-05 09:58:50 +02:00
Roy-043
a779ba3514 Draft: fix getcoords in gui_snapper.py (#9654)
The function did not handle global and relative mode properly
2023-05-26 19:45:31 +02:00
Yorik van Havre
9b3f5f102e Draft: small optimization in snapper - issue #5761 (#9239) 2023-04-25 10:16:47 +02:00
luzpaz
38a01939e0 Migrate domain name from freecadweb to freecad (#9352)
* Migrate domain name from freecadweb to freecad
* Migrate src/Mod/Material files
* Migrate Stylesheet related files
* Migrate *.svg files
* Migrate miscellaneous files
* Migrate some build files
* Migrate recently added TD AR_IRAM template files

Closes #6415
2023-04-24 15:19:20 -05:00
Yorik van Havre
53bc32b03e Draft: Fixes grid on/off behaviour - fixes #5878
- If grid is on and auto grid on: Grid always appears
- If grid is on and auto grid off: Grid off at start, on when using a tool, off afterwards
- If grid is off: Grid never appears
2023-03-10 12:19:27 +01:00
Roy-043
b5a44e6f73 Draft: housekeeping: indentation gui_snapper.py
As mentioned here: #8172
2023-01-12 16:04:31 +01:00
Roy-043
dfb5f5de4b Draft: Properly remove Snap toolbar when switching workbenches (#8172) 2023-01-12 15:29:21 +01:00
Roy-043
7951dab2bf Draft: update inspect.getargspec to inspect.getfullargspec (#8101) 2022-12-29 23:20:38 +01:00
Roy-043
6261854a50 Draft: housekeeping: rename snap icons 2022-11-11 17:33:09 +01:00
Roy-043
024c50cd4f Draft: Change Snap toolbar to standard toolbar 2022-10-27 10:45:48 +02:00
wmayer
838a91fafb Draft: fix snapper icons
* Add convenience function to get 3D views from MDI area
* Use 'inherits' instead of 'QMetaObject.className()' to check more reliably for sub-classes
2022-08-11 11:50:53 +02:00
Roy-043
d2ce02058e Update gui_snapper.py 2022-07-04 16:59:02 +02:00
Roy-043
9623cd5973 Draft: Fix near snap 2022-07-04 09:43:15 +02:00
Roy-043
f2698ac017 Draft: Fix Draft_Snap_Intersection for self-intersecting objects 2022-04-29 14:20:15 +03:00
Roy
db7b37dd1f Draft: Fix additional translation issues related to the snapping commands 2022-01-12 13:44:05 +01:00
Roy-043
ba3961574b Draft: make Draft_Snap_Angle work in 3D
Draft_Snap_Angle only worked for circular edges on a plane parallel to the XY plane of the global coordinate system.
2022-01-06 16:57:55 +01:00
Roy-043
f89078c01f Draft: fix 3 snap issues
1. Draft_Snap_Parallel only worked beyond the endpoints of the edge.
2. It was very hard to select an edge for Draft_Snap_Parallel if no other snaps were active.
3. Only two snap objects were stored.
2021-11-25 15:21:11 +01:00
Roy-043
413fff7ea2 Draft: fix toggle grid issue. 2021-11-17 19:26:36 +01:00
carlopav
967a97e9a8 Draft: fix Snapper GridSnap not working over a face
ref. https://forum.freecadweb.org/viewtopic.php?f=23&t=62274&sid=4c9d07255e4f0db219b661c345768319

If the cursor is over a Face and no SnapCenter is active, the snapToObject method returns the current cursor point instead of None. Doing so the snap() method does not check for extension and grid snaps.
It seems this is a bug since the snap() already contains the deleted code.

One note: the no snaps case was moved before the lastObj setting, since if no snap point was found, it's not right to set it to a non snapped object.
2021-09-19 14:31:44 +02:00
marioalexis
b8dee20115 Draft: Fix snap to proxy WP and BuildingParts - fixes #0004278 2021-02-23 21:40:06 -03:00
Chris Hennes
a7522c384e [DRAFT] Catch only Exception, not BaseException 2021-02-11 11:52:45 +01:00
Roy-043
b6976b3b23 [Draft] Fix snap to center of faces of solids
The code would only find a center snap on the face with index=0 of solids.

In V0.19 Part.getShape was introduced (line 399). But not all consequences were not fully implemented.

In the '# we are snapping to an edge' section (line 411) the code could be cleaned up. There is no need to check if the index of the edge is correct for the parent object since we are no longer dealing with a parent object. That portion was effectively dead code.

The '# we are snapping to a face' section (line 429 in the revised code) has been modified accordingly, which fixes the bug.

Forum discussion:
https://forum.freecadweb.org/viewtopic.php?f=23&t=54747
2021-01-25 15:33:36 +01:00
Yorik van Havre
7b10771b7c Draft: Don't snap to ImagePlanes 2021-01-12 15:31:55 +01:00
Yorik van Havre
1cce61670c Draft: better checks for no active document 2020-11-16 13:25:12 +01:00