Draft: Implementation of 'Align to face' checkbox in Hatch task panel (#21332)
This commit is contained in:
@@ -75,6 +75,25 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Align to face:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="Translate">
|
||||
<property name="toolTip">
|
||||
<string>If checked, the pattern aligns with the base object.
|
||||
If unchecked, the pattern aligns with the global coordinate system.
|
||||
This setting modifies the Translate property.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
||||
@@ -70,6 +70,7 @@ class Draft_Hatch_TaskPanel:
|
||||
self.form.Pattern.setCurrentText(pat)
|
||||
self.form.Scale.setValue(params.get_param("HatchPatternScale"))
|
||||
self.form.Rotation.setValue(params.get_param("HatchPatternRotation"))
|
||||
self.form.Translate.setChecked(params.get_param("HatchPatternTranslate"))
|
||||
todo.delay(self.form.setFocus, None) # Make sure using Esc works.
|
||||
|
||||
def accept(self):
|
||||
@@ -80,6 +81,7 @@ class Draft_Hatch_TaskPanel:
|
||||
params.set_param("HatchPatternName", self.form.Pattern.currentText())
|
||||
params.set_param("HatchPatternScale", self.form.Scale.value())
|
||||
params.set_param("HatchPatternRotation", self.form.Rotation.value())
|
||||
params.set_param("HatchPatternTranslate", self.form.Translate.isChecked())
|
||||
if hasattr(self.baseobj,"File") and hasattr(self.baseobj,"Pattern"):
|
||||
# modify existing hatch object
|
||||
o = "FreeCAD.ActiveDocument.getObject(\""+self.baseobj.Name+"\")"
|
||||
@@ -87,6 +89,7 @@ class Draft_Hatch_TaskPanel:
|
||||
FreeCADGui.doCommand(o+".Pattern=\""+self.form.Pattern.currentText()+"\"")
|
||||
FreeCADGui.doCommand(o+".Scale="+str(self.form.Scale.value()))
|
||||
FreeCADGui.doCommand(o+".Rotation="+str(self.form.Rotation.value()))
|
||||
FreeCADGui.doCommand(o+".Translate="+str(self.form.Translate.isChecked()))
|
||||
else:
|
||||
# create new hatch object
|
||||
FreeCAD.ActiveDocument.openTransaction("Create Hatch")
|
||||
@@ -96,7 +99,8 @@ class Draft_Hatch_TaskPanel:
|
||||
cmd += "\"),filename=\""+self.form.File.property("fileName")
|
||||
cmd += "\",pattern=\""+self.form.Pattern.currentText()
|
||||
cmd += "\",scale="+str(self.form.Scale.value())
|
||||
cmd += ",rotation="+str(self.form.Rotation.value())+")"
|
||||
cmd += ",rotation="+str(self.form.Rotation.value())
|
||||
cmd += ",translate="+str(self.form.Translate.isChecked())+")"
|
||||
FreeCADGui.doCommand(cmd)
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
FreeCADGui.doCommand("FreeCAD.ActiveDocument.recompute()")
|
||||
|
||||
@@ -27,11 +27,11 @@ from draftobjects.hatch import Hatch
|
||||
if FreeCAD.GuiUp:
|
||||
from draftviewproviders.view_hatch import ViewProviderDraftHatch
|
||||
|
||||
def make_hatch(baseobject, filename, pattern, scale, rotation):
|
||||
def make_hatch(baseobject, filename, pattern, scale, rotation, translate=True):
|
||||
|
||||
"""make_hatch(baseobject, filename, pattern, scale, rotation): Creates and returns a
|
||||
"""make_hatch(baseobject, filename, pattern, scale, rotation, translate): Creates and returns a
|
||||
hatch object made by applying the given pattern of the given PAT file to the faces of
|
||||
the given base object. Given scale and rotation factors are applied to the hatch object.
|
||||
the given base object. Given scale, rotation and translate factors are applied to the hatch object.
|
||||
The result is a Part-based object created in the active document."""
|
||||
|
||||
if not FreeCAD.ActiveDocument:
|
||||
@@ -43,6 +43,7 @@ def make_hatch(baseobject, filename, pattern, scale, rotation):
|
||||
obj.Pattern = pattern
|
||||
obj.Scale = scale
|
||||
obj.Rotation = rotation
|
||||
obj.Translate = translate
|
||||
if FreeCAD.GuiUp:
|
||||
ViewProviderDraftHatch(obj.ViewObject)
|
||||
return obj
|
||||
|
||||
@@ -454,6 +454,7 @@ def _get_param_dictionary():
|
||||
"HatchPatternResolution": ("int", 128), # used for SVG patterns
|
||||
"HatchPatternRotation": ("float", 0.0),
|
||||
"HatchPatternScale": ("float", 100.0),
|
||||
"HatchPatternTranslate": ("bool", True),
|
||||
"labeltype": ("string", "Custom"),
|
||||
"LayersManagerHeight": ("int", 320),
|
||||
"LayersManagerWidth": ("int", 640),
|
||||
|
||||
@@ -67,6 +67,7 @@ class ViewProviderDraftHatch:
|
||||
taskd.form.Pattern.setCurrentText(vobj.Object.Pattern)
|
||||
taskd.form.Scale.setValue(vobj.Object.Scale)
|
||||
taskd.form.Rotation.setValue(vobj.Object.Rotation)
|
||||
taskd.form.Translate.setChecked(vobj.Object.Translate)
|
||||
Gui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user