Skip to content

Commit

Permalink
[Draft Gui_Stretch] Improve Stretch Rectangle Behaviour (FreeCAD#18063)
Browse files Browse the repository at this point in the history
* [Draft gui_stretch] Improve Stretch Rectangle Behaviour

Feature Improvement discussed at FreeCAD Forum :
- https://forum.freecad.org/viewtopic.php?t=92124#p792118  (Draft_Stretching the whole rectangle creates a new wire)

Currently, 3 cases in general, proposed PR improve Case 3 below :

1. The original object is a Rectangle, if after stretching it is no longer a rectangle, it makes a copy turning it into a Wire which reflect the result of stretching.
   - Current behanviour is good for user, no change.
2. If after stretching it is still a rectangle, the code just resize the original.
   - Current behanviour is good for user, no change.
3. Now, if the user 'stretch' the whole rectangle, the code creates a copy as DWire in the 'stretched location'.
** - Users find this not intuitive, better just move the whole rectangle.
  • Loading branch information
paullee0 authored Nov 25, 2024
1 parent 0656f19 commit 6c85c37
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Mod/Draft/draftguitools/gui_stretch.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,16 @@ def doStretch(self):
optype = 3
elif ops[1] == [True, True, False, False]:
optype = 4
elif ops[1] == [True, True, True, True]:
optype = 5
else:
optype = 0
# print("length:", ops[0].Length,
# "height:", ops[0].Height,
# " - ", ops[1],
# " - ", self.displacement)
done = False
if optype > 0:
if 0 < optype < 5:
v1 = ops[0].Placement.multVec(p2).sub(ops[0].Placement.multVec(p1))
a1 = round(self.displacement.getAngle(v1), 4)
v2 = ops[0].Placement.multVec(p4).sub(ops[0].Placement.multVec(p1))
Expand Down Expand Up @@ -443,6 +445,12 @@ def doStretch(self):
commitops.append(_cmd)
commitops.append(_pl)
done = True
elif optype == 5:
_pl = _doc + ops[0].Name
_pl += ".Placement.Base=FreeCAD."
_pl += str(ops[0].Placement.Base.add(self.displacement))
commitops.append(_pl)
done = True
if not done:
# otherwise create a wire copy and stretch it instead
_msg(translate("draft", "Turning one Rectangle into a Wire"))
Expand Down

0 comments on commit 6c85c37

Please sign in to comment.