Draft: Display default file and pattern in hatch task panel

Fixes #18197.
This commit is contained in:
Roy-043
2024-11-29 23:28:19 +01:00
committed by Yorik van Havre
parent 6bf372aef6
commit fa65fcce0d
2 changed files with 12 additions and 11 deletions

View File

@@ -64,8 +64,8 @@ class Draft_Hatch_TaskPanel:
self.form = FreeCADGui.PySideUic.loadUi(":/ui/dialogHatch.ui")
self.form.setWindowIcon(QtGui.QIcon(":/icons/Draft_Hatch.svg"))
self.form.File.fileNameChanged.connect(self.onFileChanged)
self.form.File.setFileName(params.get_param("FilePattern", path="Mod/TechDraw/PAT"))
pat = params.get_param("NamePattern", path="Mod/TechDraw/PAT")
self.form.File.setFileName(params.get_param("HatchPatternFile"))
pat = params.get_param("HatchPatternName")
if pat in [self.form.Pattern.itemText(i) for i in range(self.form.Pattern.count())]:
self.form.Pattern.setCurrentText(pat)
self.form.Scale.setValue(params.get_param("HatchPatternScale"))
@@ -76,8 +76,8 @@ class Draft_Hatch_TaskPanel:
import FreeCADGui
params.set_param("FilePattern", self.form.File.property("fileName"), path="Mod/TechDraw/PAT")
params.set_param("NamePattern", self.form.Pattern.currentText(), path="Mod/TechDraw/PAT")
params.set_param("HatchPatternFile", self.form.File.property("fileName"))
params.set_param("HatchPatternName", self.form.Pattern.currentText())
params.set_param("HatchPatternScale", self.form.Scale.value())
params.set_param("HatchPatternRotation", self.form.Rotation.value())
if hasattr(self.baseobj,"File") and hasattr(self.baseobj,"Pattern"):

View File

@@ -23,6 +23,7 @@
""" Contains a parameter observer class and parameter related functions."""
import os
import PySide.QtCore as QtCore
import xml.etree.ElementTree as ET
@@ -372,6 +373,10 @@ def _get_param_dictionary():
param_dict = {}
hatch_pattern_file = os.path.join(
App.getResourceDir().replace("\\", "/"), "Mod/TechDraw/PAT/FCPAT.pat"
)
# Draft parameters that are not in the preferences:
param_dict["Mod/Draft"] = {
"AnnotationStyleEditorHeight": ("int", 450),
@@ -388,7 +393,9 @@ def _get_param_dictionary():
"fillmode": ("bool", True),
"GlobalMode": ("bool", False),
"GridHideInOtherWorkbenches": ("bool", True),
"HatchPatternResolution": ("int", 128),
"HatchPatternFile": ("string", hatch_pattern_file),
"HatchPatternName": ("string", "Diamant"),
"HatchPatternResolution": ("int", 128), # used for SVG patterns
"HatchPatternRotation": ("float", 0.0),
"HatchPatternScale": ("float", 100.0),
"labeltype": ("string", "Custom"),
@@ -482,12 +489,6 @@ def _get_param_dictionary():
"MaxDeviationExport": ("float", 0.1),
}
# For the Mod/TechDraw/PAT parameters we do not check the preferences:
param_dict["Mod/TechDraw/PAT"] = {
"FilePattern": ("string", ""),
"NamePattern": ("string", "Diamant"),
}
# For the General parameters we do not check the preferences:
param_dict["General"] = {
"ToolbarIconSize": ("int", 24),