Commit Graph

131 Commits

Author SHA1 Message Date
Roy-043
b3f7639016 Draft: Tweak working plane code (#21672)
* The new align_to_face_and_edge functions would align the Y axis to the edge. This should be the X axis.
* The align_to_point_and_axis functions did not accept a zero length upvec.
* Added a return value to the _next function for compatibilty with its counterpart the _previous function.
2025-06-01 09:13:19 +02:00
tetektoza
8ec6605fc4 BIM: Add support for deactivation active object to BIM Views Tree (#21570)
* BIM: Use checkbox in model tree for Activation/Deactivation of WP

* BIM: Set active object after deactivating current object if it exists

Currently we can get into a scenario where user can activate two working
planes, one after another. For example, Level, and  then Level001. If
they activate both, and then deactivate Level001, working plane switches
back to Level. But, we didn't set the object as the active one, so user
didn't have clear information that they can deactivate it, only the
working plane was switching it.

So this patch sets the object as the active one, if it exists.

* BIM: Add support for deactivation active object to BIM Views Tree

As the title says - it adds the checkbox that's similarly done in Part
workbench, so user can select/deselect the item and if they had previous
active object, it will also fall back to the previous object.

Also, moved out part of the common logic from ArchBuildingPart and
BimViews to utils.

* BIM: Handle correct context on activating WP for NativeIFC/BIM

* BIM: Remove redundant logic from BIM Views upon double click

As all of the logic is being handled now in `activate` function in
BimViews, this logic is redundant

* BIM: Rename button for taskbar and BIM Views from Activate to Active
2025-05-28 11:27:11 +02:00
Yorik van Havre
1f6ecf83b2 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
9dffe0d9b4 Draft: Simplify working plane view observer callback
The old callback contained unnecessary checks that prevented the working plane from working correctly if the Tray was missing.
2025-04-14 11:01:48 -05:00
Roy-043
83db2c260c Draft: make Draft_SelectPlane recognize the new Part_DatumPlane object
Forum topic:
https://forum.freecad.org/viewtopic.php?t=96058
2025-04-04 14:26:28 +02:00
Yorik van Havre
7913280486 BIM: Support for NativeIFC in BimViews 2024-12-11 09:23:59 +01:00
Roy-043
da2ae11ca0 Draft: revert #14206 to fix WP alignment (#14665)
#14206 was an intermediate solution. Now that  `Part.getShape` can handle the new `SubElementNames` it needs to be removed as it breaks the handling of subelements in links.
2024-06-16 16:53:02 +02:00
Roy-043
30f7f26889 Removed WP related change 2024-06-14 10:41:35 +02:00
Roy-043
a02d4a3cff Draft: revert #14206 to fix WP alignment
#14206 was an intermediate solution. Now that  `Part.getShape` can handle the new `SubElementNames` it needs to be removed as it breaks the handling of subelements in links.
2024-06-14 10:41:35 +02:00
Yorik van Havre
b057e6eb74 Draft: Enable TPN in SelectPlane - fixes #14196 2024-05-27 11:29:29 -05:00
Roy-043
10a25ebf98 Draft: Update v0.22 references to v1.0 (#13934) 2024-05-12 09:47:51 +02:00
Ladislav Michl
a6c43278a7 Draft: Do not specifically import PySide2 2024-01-25 13:13:39 +01:00
Roy-043
c2e16f2525 Draft: implement new get_param functions (step 5)
See #11677

Last bits...
2023-12-14 15:53:45 +01:00
Roy-043
d0a87b24d9 Draft: implement new get_param functions (step 4)
See #11677
2023-12-13 19:39:35 +01:00
Roy-043
d72df2f3e2 Draft: PlaneGui: view observer to update the Tray
Related issue:
#5603.

The view observer starts/stops when the Draft workbench is activated/deactivated.

Additionally:
* Minor improvements to _update_grid and _update_gui.
2023-11-05 21:42:44 +01:00
Roy-043
bccba05d20 Draft: PlaneGui: update wp._view earlier
Update wp._view before call to set_to_default, set_to_auto requires a 3D view.
2023-10-27 10:33:07 +02:00
Roy-043
28593e4658 Draft: PlaneGui: some minor fixes
Related issue:
#5603.

* The history idx value was not handled properly.
* Part.getShape() ignores the Placement of a selected BuildingPart. Have to use `place * obj.Placement`.
2023-10-22 19:48:31 +02:00
Roy-043
345df4b399 Draft: PlaneGui: minor fixes (#11115)
Related issue:
#5603.

* An 'auto' WP should not be added to the history if the previous WP in the history is also 'auto'.
* The `get_working_plane` function should only call `set_to_default` if the GUI is up. The axis of the returned WP should match global +Z if the GUI is not up.
2023-10-20 12:28:00 +02:00
Roy-043
8ad5c6ca94 Draft: PlaneGui: minor fix (#11049)
* Draft: PlaneGui: minor fix

Related issue:
#5603.

* Typo
2023-10-15 14:28:02 +02:00
Roy-043
b4186745c4 Draft: PlaneGui: some updates and fixes. (#11040)
Related issue:
#5603.
2023-10-14 21:50:14 +02:00
Roy-043
a0af13ad2c Draft: Introduction of the PlaneGui class
Related issue:
#5603.

Previous PRs:
#10766
#10838
#10931

Short explanation:
* The PlaneGui class handles several GUI related aspects of the WP including a WP history.
* The `get_working_plane` function should be used to get a WP.
* Some of the code was taken from gui_selectplane.py. The intention is to remove almost all WP related code from that file. The icon, tooltip and label for the draftToolBar are also handled by PlaneGui.
* The tooltip shows extended information about the WP (position and axes vectors). An asteriks is appended to the label if the origin does not match the global origin.
* The `_update_all` function still updates FreeCAD.DraftWorkingPlane for compatibility.
* Some confusing names from the Plane class have been changed: `weak` -> `auto`, `reset` -> `set_to_auto`, `setup` -> `auto_align`.

Next step:
Implementing PlaneGui in Draft and Arch. The gui_selectplane.py file will be updated first.
2023-10-12 13:11:57 +02:00
Roy-043
c2484914f2 Draft: Update the Plane class (step 2)
Related issue:
#5603.

Previous PRs:
#10766
#10838

The remaining Plane class functions have been processed (some are unchanged):

`setup`
* Updated to use new functions.
* The `direction` etc. arguments are never used AFAICT.
* Added `from draftutils import gui_utils`.

`reset`
* Unchanged.

`setTop`
* Calls `super().set_to_top()`. That function does not use `align_to_point_and_axis` but specifies exact vectors for improved accuracy.
* `import FreeCADGui` already happens at the top of the file.
* The code block after `if FreeCAD.GuiUp:` was kept for now.

`setFront`
* Idem.

`setSide`
* This function sets the WP to the left side position, and not to the right side postion as in the Draft_SelectPlane command.
* Idem.

`getRotation`
* Revised.
* The function has an akward name as it returns a Placement.
* The special code for Arch active container is obsolete (was already commented out in other functions).

`getPlacement`
* The `rotated argument` is ignored now. It was only used in the context of the old `placement_from_face` algorithm. See `DraftGeomUtils.placement_from_face` for the new implementation.
* Calls `super().get_placement()`.

`getNormal`
* Basically unchanged.

`setFromPlacement`
* Revised to call `super()` functions.

`inverse`
* Unchanged.

`save`
* Unchanged.

`restore`
* More compact code, but basically unchanged.

`getLocalCoords`
* Calls `super().get_local_coords()` which does not rely on Draft code, but creates a matrix and returns `mtx.inverse().multVec(point)`.

`getGlobalCoords`
* Calls `super().get_global_coords()` which creates a matrix and returns `mtx.multVec(point)`.

`getLocalRot`
* Calls `super().get_local_coords()`.

`getGlobalRot`
* Calls `super().get_global_coords()`.

`getClosestAxis`
* Calls `super().get_closest_axis(vec)` which translates the vector to the WP coordinate system and then finds the closest axis by comparing the absolute coordinates of the vector.

`isGlobal`
* Not used anywhere AFAICT.
* Calls `super().is_global()` which also checks the `position` attribute.
* As before the function works without any tolerance.

`isOrtho`
* Not used anywhere AFAICT.
* The original algorithm did not work properly (there was a comment). All angles were measured relative to the global Y axis. If the WP was randomly rotated around that axis the function would still return `True`. The new algorithm, `super().is_ortho()`, uses rounded Yaw, Pitch and Roll angles to check for orthogonality.

`getDeviation`
* Not used anywhere AFAICT.
* Unchanged.

`getParameters`
* Calls `super().get_parameters()` which uses the local `_get_prop_list` function.

`setFromParameters`
* Calls `super().set_parameters()` which uses the local `_get_prop_list` function.

`_get_prop_list`
* Function used internally. Returns a list of attribute.
2023-10-04 14:40:33 +02:00
Roy-043
92c6a36925 Draft: Update the Plane class (step 1)
After this PR the `Plane` class inherits from the `PlaneBase` class.

Related issue:
#5603.

Previous PR:
#10766

The following functions have been updated:

`__init__`
* `u` argument can be a WP now.
* Input vectors are copied.
* Added the `weak` argument.
* the `doc` attribute was not used and has been removed.

`__repr__`
* Inherited.
* The `position` is now also shown.

`copy`
* Uses `match` from the parent class which uses the local `_get_prop_list` function. Again vectors are copied.

`offsetToPoint`
* I could not find evidence that this function is used anywhere.
* The `direction` argument did not make a lot of sense (only worked in 2D). It is now ignored.
* Removed the overly long docstring.
* The function now uses an external function: `DraftGeomUtils.distance_to_plane`.

`projectPoint`
* The function calls `super().project_point` which in turn calls `DraftGeomUtils.project_point_on_plane`.
* `from sys import float_info` is no longer required.

`projectPointOld`
* Obsolete and removed.

`align*`
* All align* functions now have an `offset` argument.
* All align* functions return `True` or `False`.

`alignToPointAndAxis`
* The function ignored `upvec` if `axis` was parallel to the global X axis. This meant that the "Set WP" button of the Draft_Wire command did not work properly if the WP was aligned with the Right or Left view.
* The function calls `align_to_point_and_axis` which determines the rotation with `FreeCAD.Rotation(Vector(), upvec, axis, "ZYX")`.

`alignToPointAndAxis_SVG`
* The function calls `super().align_to_point_and_axis_svg` which contains the code from the old function.

`alignToCurve`
* Was not implemented.

`alignToEdges`
* Original code required two parallel edges (for example from an axis system), else the `u` and `v` vectors would not be perpendicular.
* The function calls `super().align_to_edges_vertexes` now.

`alignToFace`
* The function now uses an external function: `DraftGeomUtils.placement_from_face`. The rotation algorithm for the `u` and `v` vectors has been moved there.

`alignTo3Points`
* Basically unchanged. `Part` is already imported at the top of the file.

`alignToSelection`
* Basically unchanged. Will be replaced in the `PlaneGui` class.
2023-09-27 11:25:04 +02:00
Roy-043
6528eef858 Draft: Introduction of the PlaneBase class
This PR introduces the new PlaneBase class.

Most of its functions are rewritten versions of the functions in the original Plane class, with the exception of align_to_point_and_axis_svg.

Note that after this PR the original Plane class does not yet inherit from PlaneBase. This will be done in several following PRs. I will then also explain the reasons behind some of the revised functions in PlaneBase.

The introduction of the PlaneGui class will follow after that.

Issue: #5603.
2023-09-21 15:20:48 +02:00
Roy-043
a60c9c2cf1 Draft: Fix error in PR10327 (#10329) 2023-08-23 13:32:37 +02:00
Roy-043
29339d7197 Draft: Add placement_from_face to geometry.py (#10327)
Changed getPlacementFromFace function in WorkingPlane.py to a compatibility function that calls placement_from_face.
2023-08-23 12:05:34 +02:00
Roy-043
5c4d8730d9 Draft: Add placement_from_points to geometry.py
Changed getPlacementFromPoints function in WorkingPlane.py to a compatibility function that calls placement_from_points.
2023-08-23 11:17:17 +02:00
Roy-043
1d7e2c3de0 Draft: Auto workingplane ignored rotation around axis (#9955) 2023-07-20 18:46:10 +02:00
luzpaz
129d5882a7 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
Jolbas
3c3800acd0 Draft: fix error in PR #8698 (#9160)
fix for mistake in pr https://github.com/FreeCAD/FreeCAD/pull/8698
see comment 649857b58f (r1155160709)
2023-04-02 11:23:59 +02:00
Jolbas
649857b58f return pure rotation from getPlaneRotation() 2023-02-28 01:07:56 +01:00
Roy-043
0179afbe8a Draft: Fix workingplane auto alignment to Front view 2022-09-01 09:54:09 +02:00
Roy-043
75d6804555 Draft: Improve alignToFace in WorkingPlane.py 2022-07-24 18:52:41 +02:00
marioalexis
e62496b636 Draft: Fix orientWP method used by in Draft_Line command 2022-04-20 14:12:26 -03:00
marioalexis
04fe4ef695 Draft: Fix WorkingPlane setup in automatic mode - fixes #6060 2022-04-10 16:17:16 +02:00
marioalexis
1cd01248e0 Draft: Fix projectPoint method 2022-01-08 23:16:15 -03:00
luzpaz
b488071a55 Add requested revision by @chennes
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2021-10-30 15:20:28 -04:00
luzpaz
30a3ccde46 Add requested revision by @chennes
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2021-10-30 15:20:28 -04:00
luz paz
580a52f75c Draft: Fix superfluous whitespace in translations + misc. typos 2021-10-30 15:20:28 -04:00
Roy-043
25c3da4f0b Draft: Fix Draft_SelectPlane ignores nesting 2021-10-20 10:15:12 +02:00
Yorik van Havre
835e326652 Draft: Fixed working plane set on non-coin view 2021-06-22 16:12:59 +02:00
marioalexis
1c918e9d9e Draft: Improve alignToSelection method on WorkingPlane 2021-06-06 21:30:20 -03:00
Yorik van Havre
bff31175cb Draft: better checks for no active document 2020-11-16 13:25:12 +01:00
carlopav
fd79e3e3a9 Draft: possibility to set the working plane to an App::Part placement 2020-07-07 10:13:23 +02:00
Yorik van Havre
fda11ed717 Draft: Added convenience methods to the Draft Working Plane to set top, front and side positions 2020-04-09 16:59:01 +02:00
vocx-fc
033d0091e5 Draft: WorkingPlane.py clean up imports and docstrings
Small spacing fixes like imports in separate lines
for more clarity, and the position of the license.

Cleaned up the class docstring, so it is in only one place
below the class definition. Also small fixes
in the docstrings of the class methods.

The class is now in upper case `Plane` to conform with Python
guidelines. An alias in lowercase `plane` is still provided
for compatibility purposes; this will be deprecated
in the future.
2020-04-07 18:12:06 +02:00
luz.paz
ae7cb9e300 Draft: [skip ci] Fix header uniformity
This PR fixes header uniformity across all Draft files
2019-12-27 00:16:12 +01:00
Yorik van Havre
864619fcec Draft: Moved SelectPlane stuff from DraftGui to its own ui file 2019-09-02 22:15:58 -03:00
luz.paz
050ac16f1c Fix misc. typos
Found via `codespell -q 3 -I ../fc-word-whitelist.txt -S ./.git,*.po,*.ts,./ChangeLog.txt,./src/3rdParty,./src/Mod/Assembly/App/opendcm,./src/CXX,./src/zipios++,./src/Base/swig*,./src/Mod/Robot/App/kdl_cp,./src/Mod/Import/App/SCL,./src/WindowsInstaller -L od,orign,orginx,orginy`
2019-08-14 14:36:53 -03:00
vocx-fc
445538c7dd Draft: WorkingPlane, improved Pythonic style, line length < 79 characters; shorter variables
to save space and have line lengths < 79 characters; added whitespace to comments
and used the self.__repr__() method to shorten the impression to the terminal;
broke the line inside parentheses to make the line shorter; inside alignToSelection() test for faces first
to use alignToFace(), which actually works; leave alignToCurve() for later,
as it doesn't actually do anything at the moment; improved docstrings in isOrtho(),
the orthogonality is tested for u, v, and axis, on the global axis +Y only;
removed wrongly placed comment in restore() method;
improved file docstring at the top.
2019-08-14 14:31:56 -03:00