Draft: Edit support for Part Sphere

.
This commit is contained in:
carlopav
2020-05-24 12:28:38 +02:00
committed by Yorik van Havre
parent 4507a5a21b
commit 8926651c0e
2 changed files with 27 additions and 2 deletions

View File

@@ -983,6 +983,9 @@ class Edit(gui_base_original.Modifier):
elif objectType == "Part" and obj.TypeId == "Part::Cone":
eps = edit_part.getPartConePts(obj)
elif objectType == "Part" and obj.TypeId == "Part::Sphere":
eps = edit_part.getPartSpherePts(obj)
elif objectType == "Sketch":
eps = edit_sketcher.getSketchPts(obj)
@@ -1072,6 +1075,9 @@ class Edit(gui_base_original.Modifier):
elif objectType == "Part" and obj.TypeId == "Part::Cone":
edit_part.updatePartCone(obj, nodeIndex, v)
elif objectType == "Part" and obj.TypeId == "Part::Sphere":
edit_part.updatePartSphere(obj, nodeIndex, v)
obj.recompute()

View File

@@ -33,7 +33,8 @@ import FreeCAD as App
import DraftVecUtils
def get_supported_part_objects():
return ["Part", "Part::Line", "Part::Box", "Part::Cylinder", "Part::Cone"
return ["Part", "Part::Line", "Part::Box",
"Part::Sphere", "Part::Cylinder", "Part::Cone"
]
# PART::LINE--------------------------------------------------------------
@@ -91,11 +92,13 @@ def updatePartCylinder(obj, nodeIndex, v):
if nodeIndex == 0:
obj.Placement.Base = obj.Placement.Base + v
elif nodeIndex == 1:
obj.Radius = v.Length
if v.Length > 0.0:
obj.Radius = v.Length
elif nodeIndex == 2:
_vector = DraftVecUtils.project(v, App.Vector(0, 0, 1))
obj.Height = _vector.Length
# Part::Cone --------------------------------------------------------------
def getPartConePts(obj):
@@ -117,3 +120,19 @@ def updatePartCone(obj, nodeIndex, v):
elif nodeIndex == 3: # Height is last to have the priority on the radius
_vector = DraftVecUtils.project(v, App.Vector(0, 0, 1))
obj.Height = _vector.Length
# Part::Sphere --------------------------------------------------------------
def getPartSpherePts(obj):
editpoints = []
editpoints.append(App.Vector(0, 0, 0))
editpoints.append(App.Vector(obj.Radius, 0, 0))
return editpoints
def updatePartSphere(obj, nodeIndex, v):
if nodeIndex == 0:
obj.Placement.Base = obj.Placement.Base + v
elif nodeIndex == 1:
if v.Length > 0.0:
obj.Radius = v.Length # TODO: Perhaps better to project on the face?