Draft: implement new get_param functions (step 2)

See #11677
This commit is contained in:
Roy-043
2023-12-12 14:48:09 +01:00
parent 2b9fb51067
commit b0aa33f92a
21 changed files with 290 additions and 310 deletions

View File

@@ -32,12 +32,10 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCAD as App
import FreeCADGui as Gui
import draftguitools.gui_base as gui_base
from draftutils.translate import translate
from draftguitools import gui_base
from draftutils import params
from draftutils import utils
param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
from draftutils.translate import translate
class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
@@ -94,8 +92,8 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
self.form = Gui.PySideUic.loadUi(ui_file)
# restore stored size
w = param.GetInt("AnnotationStyleEditorWidth", 450)
h = param.GetInt("AnnotationStyleEditorHeight", 450)
w = params.get_param("AnnotationStyleEditorWidth")
h = params.get_param("AnnotationStyleEditorHeight")
self.form.resize(w, h)
# center the dialog over FreeCAD window
@@ -135,8 +133,8 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
self.save_meta(self.styles)
# store dialog size
param.SetInt("AnnotationStyleEditorWidth", self.form.width())
param.SetInt("AnnotationStyleEditorHeight", self.form.height())
params.set_param("AnnotationStyleEditorWidth", self.form.width())
params.set_param("AnnotationStyleEditorHeight", self.form.height())
def read_meta(self):
"""Read the document Meta attribute and return a dict."""

View File

@@ -37,13 +37,13 @@ import FreeCADGui as Gui
import Draft
import Draft_rc
import DraftVecUtils
import draftguitools.gui_base_original as gui_base_original
import draftguitools.gui_base as gui_base
import draftguitools.gui_tool_utils as gui_tool_utils
import draftguitools.gui_trackers as trackers
import draftutils.utils as utils
from FreeCAD import Units as U
from draftguitools import gui_base
from draftguitools import gui_base_original
from draftguitools import gui_tool_utils
from draftguitools import gui_trackers as trackers
from draftutils import params
from draftutils import utils
from draftutils.messages import _err, _toolmsg
from draftutils.translate import translate
@@ -302,7 +302,7 @@ class Arc(gui_base_original.Creator):
# The command to run is built as a series of text strings
# to be committed through the `draftutils.todo.ToDo` class.
Gui.addModule("Draft")
if utils.getParam("UsePartPrimitives", False):
if params.get_param("UsePartPrimitives"):
# Insert a Part::Primitive object
_base = DraftVecUtils.toString(self.center)
_cmd = 'FreeCAD.ActiveDocument.'
@@ -348,7 +348,7 @@ class Arc(gui_base_original.Creator):
try:
Gui.addModule("Draft")
if utils.getParam("UsePartPrimitives", False):
if params.get_param("UsePartPrimitives"):
# Insert a Part::Primitive object
_base = DraftVecUtils.toString(self.center)
_cmd = 'FreeCAD.ActiveDocument.'
@@ -550,7 +550,7 @@ class Arc_3Points(gui_base.GuiCommandSimplest):
# If three points were already picked in the 3D view
# proceed with creating the final object.
# Draw a simple `Part::Feature` if the parameter is `True`.
if utils.get_param("UsePartPrimitives", False):
if params.get_param("UsePartPrimitives"):
Draft.make_arc_3points([self.points[0],
self.points[1],
self.points[2]], primitive=True)

View File

@@ -37,13 +37,13 @@ import FreeCAD as App
import FreeCADGui as Gui
import DraftVecUtils
import WorkingPlane
import draftutils.utils as utils
import draftutils.gui_utils as gui_utils
import draftutils.todo as todo
import draftguitools.gui_trackers as trackers
import draftguitools.gui_tool_utils as gui_tool_utils
from draftutils.messages import _msg, _log, _toolmsg
from draftguitools import gui_tool_utils
from draftguitools import gui_trackers as trackers
from draftutils import gui_utils
from draftutils import params
from draftutils import todo
from draftutils import utils
from draftutils.messages import _log, _msg, _toolmsg
class DraftTool:
@@ -130,7 +130,7 @@ class DraftTool:
self.wp = WorkingPlane.get_working_plane()
self.planetrack = None
if utils.get_param("showPlaneTracker", False):
if params.get_param("showPlaneTracker"):
self.planetrack = trackers.PlaneTracker()
if hasattr(Gui, "Snapper"):
Gui.Snapper.setTrackers()
@@ -220,9 +220,7 @@ class DraftTool:
qr = "({0}, {1}, {2}, {3})".format(qr[0], qr[1], qr[2], qr[3])
# Support object
_params = "User parameter:BaseApp/Preferences/Mod/Draft"
_params_group = App.ParamGet(_params)
if self.support and _params_group.GetBool("useSupport", False):
if self.support and params.get_param("useSupport"):
sup = 'FreeCAD.ActiveDocument.getObject'
sup += '("{}")'.format(self.support.Name)
else:

View File

@@ -39,14 +39,14 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCAD as App
import FreeCADGui as Gui
import draftutils.utils as utils
import draftutils.todo as todo
import draftguitools.gui_base_original as gui_base_original
import draftguitools.gui_tool_utils as gui_tool_utils
import draftguitools.gui_lines as gui_lines
import draftguitools.gui_trackers as trackers
from draftutils.messages import _msg, _toolmsg, _err
from draftguitools import gui_base_original
from draftguitools import gui_lines
from draftguitools import gui_tool_utils
from draftguitools import gui_trackers as trackers
from draftutils import params
from draftutils import todo
from draftutils import utils
from draftutils.messages import _err, _msg, _toolmsg
from draftutils.translate import translate
@@ -257,9 +257,8 @@ class CubicBezCurve(gui_lines.Line):
Activate the specific BezCurve tracker.
"""
param = App.ParamGet("User parameter:BaseApp/Preferences/View")
self.old_EnableSelection = param.GetBool("EnableSelection", True)
param.SetBool("EnableSelection", False)
self.old_EnableSelection = params.get_param_view("EnableSelection")
params.set_param_view("EnableSelection", False)
super(CubicBezCurve, self).Activated(name="CubicBezCurve",
icon="Draft_CubicBezCurve",
@@ -432,8 +431,7 @@ class CubicBezCurve(gui_lines.Line):
closed: bool, optional
Close the curve if `True`.
"""
param = App.ParamGet("User parameter:BaseApp/Preferences/View")
param.SetBool("EnableSelection", self.old_EnableSelection)
params.set_param_view("EnableSelection", self.old_EnableSelection)
if self.ui:
if hasattr(self, "bezcurvetrack"):

View File

@@ -40,17 +40,18 @@ import PySide.QtGui as QtGui
import FreeCAD as App
import FreeCADGui as Gui
import DraftVecUtils
import draftutils.utils as utils
import draftutils.gui_utils as gui_utils
import draftguitools.gui_trackers as trackers
import draftguitools.gui_base_original as gui_base_original
import draftguitools.gui_tool_utils as gui_tool_utils
import draftguitools.gui_edit_draft_objects as edit_draft
import draftguitools.gui_edit_arch_objects as edit_arch
import draftguitools.gui_edit_part_objects as edit_part
import draftguitools.gui_edit_sketcher_objects as edit_sketcher
from draftutils import gui_utils
from draftutils import params
from draftutils import utils
from draftutils.translate import translate
from draftguitools import gui_base_original
from draftguitools import gui_edit_arch_objects as edit_arch
from draftguitools import gui_edit_draft_objects as edit_draft
from draftguitools import gui_edit_part_objects as edit_part
from draftguitools import gui_edit_sketcher_objects as edit_sketcher
from draftguitools import gui_tool_utils
from draftguitools import gui_trackers as trackers
COLORS = {
"default": Gui.draftToolBar.getDefaultColor("snap"),
@@ -214,7 +215,6 @@ class Edit(gui_base_original.Modifier):
self.objs_formats = {}
# settings (get updated in Activated)
self.param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
self.max_objects = 5
self.pick_radius = 20
@@ -278,8 +278,8 @@ class Edit(gui_base_original.Modifier):
self.ui = Gui.draftToolBar
self.view = gui_utils.get_3d_view()
self.max_objects = self.param.GetInt("DraftEditMaxObjects", 5)
self.pick_radius = self.param.GetInt("DraftEditPickRadius", 20)
self.max_objects = params.get_param("DraftEditMaxObjects")
self.pick_radius = params.get_param("DraftEditPickRadius")
if Gui.Selection.getSelection():
self.proceed()
@@ -547,8 +547,7 @@ class Edit(gui_base_original.Modifier):
def resetTrackersBezier(self, obj):
# in future move tracker definition to DraftTrackers
param = App.ParamGet("User parameter:BaseApp/Preferences/View")
size = param.GetInt("MarkerSize", 9)
size = params.get_param_view("MarkerSize")
knotmarkers = (
Gui.getMarkerIndex("DIAMOND_FILLED", size), # sharp
Gui.getMarkerIndex("SQUARE_FILLED", size), # tangent

View File

@@ -36,13 +36,13 @@ import FreeCAD as App
import FreeCADGui as Gui
import Draft_rc
import DraftVecUtils
import draftutils.utils as utils
import draftguitools.gui_base_original as gui_base_original
import draftguitools.gui_tool_utils as gui_tool_utils
import draftguitools.gui_trackers as trackers
from draftguitools import gui_base_original
from draftguitools import gui_tool_utils
from draftguitools import gui_trackers as trackers
from draftutils import params
from draftutils import utils
from draftutils.messages import _err, _toolmsg
from draftutils.translate import translate
from draftutils.messages import _toolmsg, _err
# The module is used to prevent complaints from code checkers (flake8)
True if Draft_rc.__name__ else False
@@ -111,7 +111,7 @@ class Ellipse(gui_base_original.Creator):
rot2 = rot2.Rotation
rot = str((rot1.multiply(rot2)).Q)
Gui.addModule("Draft")
if utils.getParam("UsePartPrimitives", False):
if params.get_param("UsePartPrimitives"):
# Insert a Part::Primitive object
_cmd = 'FreeCAD.ActiveDocument.'
_cmd += 'addObject("Part::Ellipse", "Ellipse")'

View File

@@ -41,9 +41,10 @@ from PySide import QtGui
import FreeCAD as App
import FreeCADGui as Gui
import Draft_rc
import draftutils.utils as utils
import draftutils.groups as groups
import draftguitools.gui_base as gui_base
from draftguitools import gui_base
from draftutils import groups
from draftutils import params
from draftutils import utils
from draftutils.translate import translate
@@ -223,12 +224,11 @@ class SetAutoGroup(gui_base.GuiCommandSimplest):
# and globally initialized in the `Gui` namespace to run
# some actions.
# If there is only a group selected, it runs the `AutoGroup` method.
params = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
self.ui = Gui.draftToolBar
s = Gui.Selection.getSelection()
if len(s) == 1:
if (utils.get_type(s[0]) == "Layer"
or (params.GetBool("AutogroupAddGroups", False)
or (params.get_param("AutogroupAddGroups")
and groups.is_group(s[0]))):
self.ui.setAutoGroup(s[0].Name)
return
@@ -237,7 +237,7 @@ class SetAutoGroup(gui_base.GuiCommandSimplest):
# including the options "None" and "Add new layer".
self.groups = [translate("draft", "None")]
gn = [o.Name for o in self.doc.Objects if utils.get_type(o) == "Layer"]
if params.GetBool("AutogroupAddGroups", False):
if params.get_param("AutogroupAddGroups"):
gn.extend(groups.get_group_names())
self.groups.extend(gn)
self.labels = [translate("draft", "None")]
@@ -323,7 +323,7 @@ class AddToConstruction(gui_base.GuiCommandNeedsSelection):
grp = self.doc.getObject("Draft_Construction")
if not grp:
grp = self.doc.addObject("App::DocumentObjectGroup", "Draft_Construction")
grp.Label = utils.get_param("constructiongroupname", "Construction")
grp.Label = params.get_param("constructiongroupname")
for obj in Gui.Selection.getSelection():
grp.addObject(obj)

View File

@@ -25,9 +25,10 @@
import os
import FreeCAD
import draftguitools.gui_base as gui_base
from draftguitools import gui_base
from draftutils import params
from draftutils.translate import QT_TRANSLATE_NOOP, translate
from draftutils.translate import translate, QT_TRANSLATE_NOOP
class Draft_Hatch(gui_base.GuiCommandSimplest):
@@ -62,23 +63,21 @@ 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.p1 = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/TechDraw/PAT")
self.p2 = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
self.form.File.setFileName(self.p1.GetString("FilePattern",""))
pat = self.p1.GetString("NamePattern","")
self.form.File.setFileName(params.get_param("FilePattern", path="Mod/TechDraw/PAT"))
pat = params.get_param("NamePattern", path="Mod/TechDraw/PAT")
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(self.p2.GetFloat("HatchPatternScale",1000.0))
self.form.Rotation.setValue(self.p2.GetFloat("HatchPatternRotation",0.0))
self.form.Scale.setValue(params.get_param("HatchPatternScale"))
self.form.Rotation.setValue(params.get_param("HatchPatternRotation"))
def accept(self):
import FreeCADGui
self.p1.SetString("FilePattern",self.form.File.property("fileName"))
self.p1.SetString("NamePattern",self.form.Pattern.currentText())
self.p2.SetFloat("HatchPatternScale",self.form.Scale.value())
self.p2.SetFloat("HatchPatternRotation",self.form.Rotation.value())
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("HatchPatternScale", self.form.Scale.value())
params.set_param("HatchPatternRotation", self.form.Rotation.value())
if hasattr(self.baseobj,"File") and hasattr(self.baseobj,"Pattern"):
# modify existing hatch object
o = "FreeCAD.ActiveDocument.getObject(\""+self.baseobj.Name+"\")"

View File

@@ -41,11 +41,11 @@ import FreeCAD as App
import FreeCADGui as Gui
import Draft_rc
import DraftVecUtils
import draftguitools.gui_base_original as gui_base_original
import draftguitools.gui_tool_utils as gui_tool_utils
import draftguitools.gui_trackers as trackers
import draftutils.utils as utils
from draftguitools import gui_base_original
from draftguitools import gui_tool_utils
from draftguitools import gui_trackers as trackers
from draftutils import params
from draftutils import utils
from draftutils.messages import _toolmsg
from draftutils.translate import translate
@@ -68,7 +68,7 @@ class Label(gui_base_original.Creator):
"""Execute when the command is called."""
super().Activated(name="Label")
self.ghost = None
self.labeltype = utils.getParam("labeltype", "Custom")
self.labeltype = params.get_param("labeltype")
self.sel = Gui.Selection.getSelectionEx()
if self.sel:
self.sel = self.sel[0]

View File

@@ -35,8 +35,8 @@ import FreeCAD
import FreeCADGui as Gui
import Draft
import Draft_rc
import draftguitools.gui_base as gui_base
from draftguitools import gui_base
from draftutils import params
from draftutils.translate import translate
# The module is used to prevent complaints from code checkers (flake8)
@@ -112,9 +112,8 @@ class LayerManager:
self.dialog.buttonOK.setIcon(QtGui.QIcon(":/icons/edit_OK.svg"))
# restore window geometry from stored state
pref = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
w = pref.GetInt("LayersManagerWidth",640)
h = pref.GetInt("LayersManagerHeight",320)
w = params.get_param("LayersManagerWidth")
h = params.get_param("LayersManagerHeight")
self.dialog.resize(w,h)
# center the dialog over FreeCAD window
@@ -261,9 +260,8 @@ class LayerManager:
"when Cancel button is pressed or dialog is closed"
# save dialog size
pref = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
pref.SetInt("LayersManagerWidth",self.dialog.width())
pref.SetInt("LayersManagerHeight",self.dialog.height())
params.set_param("LayersManagerWidth", self.dialog.width())
params.set_param("LayersManagerHeight", self.dialog.height())
return True
@@ -302,18 +300,27 @@ class LayerManager:
onItem = QtGui.QStandardItem()
onItem.setCheckable(True)
onItem.setCheckState(QtCore.Qt.Checked)
nameItem = QtGui.QStandardItem(translate("Draft","New Layer"))
nameItem = QtGui.QStandardItem(translate("Draft", "New Layer"))
widthItem = QtGui.QStandardItem()
widthItem.setData(self.getPref("DefaultShapeLineWidth",2,"Integer"),QtCore.Qt.DisplayRole)
widthItem.setData(params.get_param_view("DefaultShapeLineWidth"), QtCore.Qt.DisplayRole)
styleItem = QtGui.QStandardItem("Solid")
lineColorItem = QtGui.QStandardItem()
lineColorItem.setData(self.getPref("DefaultShapeLineColor",421075455),QtCore.Qt.UserRole)
lineColorItem.setData(
utils.get_rgba_tuple(params.get_param_view("DefaultShapeLineColor"))[:3],
QtCore.Qt.UserRole
)
shapeColorItem = QtGui.QStandardItem()
shapeColorItem.setData(self.getPref("DefaultShapeColor",3435973887),QtCore.Qt.UserRole)
shapeColorItem.setData(
utils.get_rgba_tuple(params.get_param_view("DefaultShapeColor"))[:3],
QtCore.Qt.UserRole
)
transparencyItem = QtGui.QStandardItem()
transparencyItem.setData(0,QtCore.Qt.DisplayRole)
transparencyItem.setData(0, QtCore.Qt.DisplayRole)
linePrintColorItem = QtGui.QStandardItem()
linePrintColorItem.setData(self.getPref("DefaultPrintColor",0),QtCore.Qt.UserRole)
linePrintColorItem.setData(
utils.get_rgba_tuple(params.get_param("DefaultPrintColor"))[:3],
QtCore.Qt.UserRole
)
# populate with object data
if obj:
@@ -341,20 +348,6 @@ class LayerManager:
transparencyItem,
linePrintColorItem])
def getPref(self,value,default,valuetype="Unsigned"):
"retrieves a view pref value"
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View")
if valuetype == "Unsigned":
c = p.GetUnsigned(value,default)
r = float((c>>24)&0xFF)/255.0
g = float((c>>16)&0xFF)/255.0
b = float((c>>8)&0xFF)/255.0
return (r,g,b,)
elif valuetype == "Integer":
return p.GetInt(value,default)
def onDelete(self):
"delete selected rows"

View File

@@ -38,13 +38,13 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCAD as App
import FreeCADGui as Gui
import DraftVecUtils
import draftutils.utils as utils
import draftutils.gui_utils as gui_utils
import draftutils.todo as todo
import draftguitools.gui_base_original as gui_base_original
import draftguitools.gui_tool_utils as gui_tool_utils
from draftutils.messages import _msg, _err, _toolmsg
from draftguitools import gui_base_original
from draftguitools import gui_tool_utils
from draftutils import gui_utils
from draftutils import params
from draftutils import utils
from draftutils import todo
from draftutils.messages import _err, _msg, _toolmsg
from draftutils.translate import translate
@@ -141,7 +141,7 @@ class Line(gui_base_original.Creator):
# The command to run is built as a series of text strings
# to be committed through the `draftutils.todo.ToDo` class.
if (len(self.node) == 2
and utils.getParam("UsePartPrimitives", False)):
and params.get_param("UsePartPrimitives")):
# Insert a Part::Primitive object
p1 = self.node[0]
p2 = self.node[-1]

View File

@@ -40,12 +40,12 @@ import FreeCAD as App
import FreeCADGui as Gui
import Draft_rc
import DraftVecUtils
import draftutils.utils as utils
import draftguitools.gui_base_original as gui_base_original
import draftguitools.gui_tool_utils as gui_tool_utils
import draftguitools.gui_trackers as trackers
from draftutils.messages import _msg, _wrn, _err, _toolmsg
from draftguitools import gui_base_original
from draftguitools import gui_tool_utils
from draftguitools import gui_trackers as trackers
from draftutils import params
from draftutils import utils
from draftutils.messages import _err, _msg, _toolmsg, _wrn
from draftutils.translate import translate
# The module is used to prevent complaints from code checkers (flake8)
@@ -55,9 +55,6 @@ True if Draft_rc.__name__ else False
class Offset(gui_base_original.Modifier):
"""Gui Command for the Offset tool."""
def __init__(self):
self.param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
def GetResources(self):
"""Set icon, menu and tooltip."""
@@ -101,7 +98,7 @@ class Offset(gui_base_original.Modifier):
self.constrainSeg = None
self.ui.offsetUi()
occmode = self.param.GetBool("Offset_OCC", False)
occmode = params.get_param("Offset_OCC")
self.ui.occOffset.setChecked(occmode)
self.linetrack = trackers.lineTracker()
@@ -185,7 +182,7 @@ class Offset(gui_base_original.Modifier):
a = -DraftVecUtils.angle(v1, v2, self.wp.axis)
self.dvec = DraftVecUtils.rotate(d, a, self.wp.axis)
occmode = self.ui.occOffset.isChecked()
self.param.SetBool("Offset_OCC", occmode)
params.set_param("Offset_OCC", occmode)
_wire = DraftGeomUtils.offsetWire(self.shape,
self.dvec,
occ=occmode)
@@ -226,7 +223,7 @@ class Offset(gui_base_original.Modifier):
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
copymode = False
occmode = self.ui.occOffset.isChecked()
self.param.SetBool("Offset_OCC", occmode)
params.set_param("Offset_OCC", occmode)
if (gui_tool_utils.hasMod(arg, gui_tool_utils.get_mod_alt_key())
or self.ui.isCopy.isChecked()):
copymode = True
@@ -308,7 +305,7 @@ class Offset(gui_base_original.Modifier):
delta = DraftVecUtils.toString(self.dvec)
copymode = False
occmode = self.ui.occOffset.isChecked()
self.param.SetBool("Offset_OCC", occmode)
params.set_param("Offset_OCC", occmode)
if self.ui.isCopy.isChecked():
copymode = True

View File

@@ -41,11 +41,11 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCAD as App
import FreeCADGui as Gui
import Draft_rc
import draftutils.utils as utils
import draftutils.gui_utils as gui_utils
import draftguitools.gui_base_original as gui_base_original
import draftutils.todo as todo
from draftguitools import gui_base_original
from draftutils import gui_utils
from draftutils import params
from draftutils import todo
from draftutils import utils
from draftutils.translate import translate
# The module is used to prevent complaints from code checkers (flake8)
@@ -114,7 +114,7 @@ class Point(gui_base_original.Creator):
# to be committed through the `draftutils.todo.ToDo` class.
commitlist = []
Gui.addModule("Draft")
if utils.getParam("UsePartPrimitives", False):
if params.get_param("UsePartPrimitives"):
# Insert a Part::Primitive object
_cmd = 'FreeCAD.ActiveDocument.'
_cmd += 'addObject("Part::Vertex", "Point")'

View File

@@ -37,11 +37,11 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCAD as App
import FreeCADGui as Gui
import DraftVecUtils
import draftutils.utils as utils
import draftguitools.gui_base_original as gui_base_original
import draftguitools.gui_tool_utils as gui_tool_utils
import draftguitools.gui_trackers as trackers
from draftguitools import gui_base_original
from draftguitools import gui_tool_utils
from draftguitools import gui_trackers as trackers
from draftutils import params
from draftutils import utils
from draftutils.messages import _toolmsg
from draftutils.translate import translate
@@ -214,7 +214,7 @@ class Polygon(gui_base_original.Creator):
"""Draw the actual object."""
rot, sup, pts, fil = self.getStrings()
Gui.addModule("Draft")
if utils.getParam("UsePartPrimitives", False):
if params.get_param("UsePartPrimitives"):
# Insert a Part::Primitive object
Gui.addModule("Part")
_cmd = 'FreeCAD.ActiveDocument.'

View File

@@ -34,12 +34,12 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCAD as App
import FreeCADGui as Gui
import DraftVecUtils
import draftutils.utils as utils
import draftguitools.gui_base_original as gui_base_original
import draftguitools.gui_tool_utils as gui_tool_utils
import draftguitools.gui_trackers as trackers
from draftutils.messages import _toolmsg, _err
from draftguitools import gui_base_original
from draftguitools import gui_tool_utils
from draftguitools import gui_trackers as trackers
from draftutils import params
from draftutils import utils
from draftutils.messages import _err, _toolmsg
from draftutils.translate import translate
@@ -61,7 +61,7 @@ class Rectangle(gui_base_original.Creator):
self.refpoint = None
self.ui.pointUi(title=translate("draft", "Rectangle"), icon="Draft_Rectangle")
self.ui.extUi()
if utils.getParam("UsePartPrimitives", False):
if params.get_param("UsePartPrimitives"):
self.fillstate = self.ui.hasFill.isChecked()
self.ui.hasFill.setChecked(True)
self.call = self.view.addEventCallback("SoEvent", self.action)
@@ -112,7 +112,7 @@ class Rectangle(gui_base_original.Creator):
height = -height
base = base.add((p1.sub(p2)).negative())
Gui.addModule("Draft")
if utils.getParam("UsePartPrimitives", False):
if params.get_param("UsePartPrimitives"):
# Insert a Part::Primitive object
_cmd = 'FreeCAD.ActiveDocument.'
_cmd += 'addObject("Part::Plane", "Plane")'

View File

@@ -36,8 +36,9 @@ import WorkingPlane
from FreeCAD import Units
from drafttaskpanels import task_selectplane
from draftutils.todo import todo
from draftutils import params
from draftutils.messages import _msg
from draftutils.todo import todo
from draftutils.translate import translate
__title__ = "FreeCAD Draft Workbench GUI Tools - Working plane-related tools"
@@ -49,9 +50,6 @@ __url__ = "https://www.freecad.org"
class Draft_SelectPlane:
"""The Draft_SelectPlane FreeCAD command definition."""
def __init__(self):
self.param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
def GetResources(self):
"""Set icon, menu and tooltip."""
return {"Pixmap": "Draft_SelectPlane",
@@ -83,7 +81,7 @@ class Draft_SelectPlane:
Gui.Snapper.setTrackers()
self.grid = Gui.Snapper.grid
self.offset = 0
self.center = self.param.GetBool("CenterPlaneOnView", False)
self.center = params.get_param("CenterPlaneOnView")
# Create task panel
self.taskd = task_selectplane.SelectPlaneTaskPanel()
@@ -94,13 +92,13 @@ class Draft_SelectPlane:
form.fieldOffset.setText(Units.Quantity(self.offset, Units.Length).UserString)
form.checkCenter.setChecked(self.center)
try:
q = Units.Quantity(self.param.GetString("gridSpacing", "1 mm"))
q = Units.Quantity(params.get_param("gridSpacing"))
except ValueError:
q = Units.Quantity("1 mm")
form.fieldGridSpacing.setText(q.UserString)
form.fieldGridMainLine.setValue(self.param.GetInt("gridEvery", 10))
form.fieldGridExtension.setValue(self.param.GetInt("gridSize", 100))
form.fieldSnapRadius.setValue(self.param.GetInt("snapRange", 8))
form.fieldGridMainLine.setValue(params.get_param("gridEvery"))
form.fieldGridExtension.setValue(params.get_param("gridSize"))
form.fieldSnapRadius.setValue(params.get_param("snapRange"))
# Set icons
form.setWindowIcon(QtGui.QIcon(":/icons/Draft_SelectPlane.svg"))
@@ -243,7 +241,7 @@ class Draft_SelectPlane:
def on_set_center(self, val):
self.center = bool(val)
self.param.SetBool("CenterPlaneOnView", self.center)
params.set_param("CenterPlaneOnView", self.center)
def on_set_grid_size(self, text):
try:
@@ -251,7 +249,7 @@ class Draft_SelectPlane:
except Exception:
pass
else:
self.param.SetString("gridSpacing", q.UserString)
params.set_param("gridSpacing", q.UserString)
# ParamObserver handles grid changes. See params.py.
if self.grid is not None:
self.grid.show_during_command = True
@@ -259,7 +257,7 @@ class Draft_SelectPlane:
def on_set_main_line(self, i):
if i > 1:
self.param.SetInt("gridEvery", i)
params.set_param("gridEvery", i)
# ParamObserver handles grid changes. See params.py.
if self.grid is not None:
self.grid.show_during_command = True
@@ -267,14 +265,14 @@ class Draft_SelectPlane:
def on_set_extension(self, i):
if i > 1:
self.param.SetInt("gridSize", i)
params.set_param("gridSize", i)
# ParamObserver handles grid changes. See params.py.
if self.grid is not None:
self.grid.show_during_command = True
self.grid.on()
def on_set_snap_radius(self, i):
self.param.SetInt("snapRange", i)
params.set_param("snapRange", i)
if hasattr(Gui, "Snapper"):
Gui.Snapper.showradius()

View File

@@ -28,15 +28,15 @@
## \addtogroup draftguitools
# @{
import os
from PySide import QtCore
from PySide import QtGui
import FreeCAD as App
import FreeCADGui as Gui
import Draft_rc
import os
from FreeCAD import Units as U
from draftutils import params
from draftutils import utils
def QT_TRANSLATE_NOOP(ctx,txt):
@@ -74,10 +74,6 @@ class Draft_SetStyle_TaskPanel:
def __init__(self):
self.p = "User parameter:BaseApp/Preferences/"
param_draft = App.ParamGet(self.p + "Mod/Draft")
param_view = App.ParamGet(self.p + "View")
self.form = Gui.PySideUic.loadUi(":/ui/TaskPanel_SetStyle.ui")
self.form.setWindowIcon(QtGui.QIcon.fromTheme("gtk-apply", QtGui.QIcon(":/icons/Draft_Apply.svg")))
@@ -85,29 +81,29 @@ class Draft_SetStyle_TaskPanel:
self.form.applyButton.setIcon(QtGui.QIcon.fromTheme("gtk-apply", QtGui.QIcon(":/icons/Draft_Apply.svg")))
self.form.annotButton.setIcon(QtGui.QIcon(":/icons/Draft_Text.svg"))
self.form.ShapeColor.setProperty("color", self.getColor(param_view.GetUnsigned("DefaultShapeColor", 3435973887)))
self.form.Transparency.setValue(param_view.GetInt("DefaultShapeTransparency", 0))
self.form.LineColor.setProperty("color", self.getColor(param_view.GetUnsigned("DefaultShapeLineColor", 255)))
self.form.LineWidth.setValue(param_view.GetInt("DefaultShapeLineWidth", 2))
self.form.PointColor.setProperty("color", self.getColor(param_view.GetUnsigned("DefaultShapeVertexColor", 255)))
self.form.PointSize.setValue(param_view.GetInt("DefaultShapePointSize", 2))
self.form.DrawStyle.setCurrentIndex(param_draft.GetInt("DefaultDrawStyle", 0))
self.form.DisplayMode.setCurrentIndex(param_draft.GetInt("DefaultDisplayMode", 0))
self.form.TextColor.setProperty("color", self.getColor(param_draft.GetUnsigned("DefaultTextColor", 255)))
self.form.TextFont.setCurrentFont(QtGui.QFont(param_draft.GetString("textfont", "Sans")))
self.form.TextSize.setText(U.Quantity(param_draft.GetFloat("textheight", 3.5), U.Length).UserString)
self.form.LineSpacing.setValue(param_draft.GetFloat("LineSpacing", 1))
self.form.ScaleMultiplier.setValue(param_draft.GetFloat("DefaultAnnoScaleMultiplier", 1))
self.form.AnnoLineColor.setProperty("color", self.getColor(param_draft.GetUnsigned("DefaultAnnoLineColor", 255)))
self.form.AnnoLineWidth.setValue(param_draft.GetInt("DefaultAnnoLineWidth", 2))
self.form.ArrowStyle.setCurrentIndex(param_draft.GetInt("dimsymbol", 0))
self.form.ArrowSize.setText(U.Quantity(param_draft.GetFloat("arrowsize", 1), U.Length).UserString)
self.form.ShowUnit.setChecked(param_draft.GetBool("showUnit", True))
self.form.UnitOverride.setText(param_draft.GetString("overrideUnit", ""))
self.form.DimOvershoot.setText(U.Quantity(param_draft.GetFloat("dimovershoot", 0), U.Length).UserString)
self.form.ExtLines.setText(U.Quantity(param_draft.GetFloat("extlines", -0.5), U.Length).UserString)
self.form.ExtOvershoot.setText(U.Quantity(param_draft.GetFloat("extovershoot", 2), U.Length).UserString)
self.form.TextSpacing.setText(U.Quantity(param_draft.GetFloat("dimspacing", 1), U.Length).UserString)
self.form.ShapeColor.setProperty("color", self.getColor(params.get_param_view("DefaultShapeColor")))
self.form.Transparency.setValue(params.get_param_view("DefaultShapeTransparency"))
self.form.LineColor.setProperty("color", self.getColor(params.get_param_view("DefaultShapeLineColor")))
self.form.LineWidth.setValue(params.get_param_view("DefaultShapeLineWidth"))
self.form.PointColor.setProperty("color", self.getColor(params.get_param_view("DefaultShapeVertexColor")))
self.form.PointSize.setValue(params.get_param_view("DefaultShapePointSize"))
self.form.DrawStyle.setCurrentIndex(params.get_param("DefaultDrawStyle"))
self.form.DisplayMode.setCurrentIndex(params.get_param("DefaultDisplayMode"))
self.form.TextColor.setProperty("color", self.getColor(params.get_param("DefaultTextColor")))
self.form.TextFont.setCurrentFont(QtGui.QFont(params.get_param("textfont")))
self.form.TextSize.setText(U.Quantity(params.get_param("textheight"), U.Length).UserString)
self.form.LineSpacing.setValue(params.get_param("LineSpacing"))
self.form.ScaleMultiplier.setValue(params.get_param("DefaultAnnoScaleMultiplier"))
self.form.AnnoLineColor.setProperty("color", self.getColor(params.get_param("DefaultAnnoLineColor")))
self.form.AnnoLineWidth.setValue(params.get_param("DefaultAnnoLineWidth"))
self.form.ArrowStyle.setCurrentIndex(params.get_param("dimsymbol"))
self.form.ArrowSize.setText(U.Quantity(params.get_param("arrowsize"), U.Length).UserString)
self.form.ShowUnit.setChecked(params.get_param("showUnit"))
self.form.UnitOverride.setText(params.get_param("overrideUnit"))
self.form.DimOvershoot.setText(U.Quantity(params.get_param("dimovershoot"), U.Length).UserString)
self.form.ExtLines.setText(U.Quantity(params.get_param("extlines"), U.Length).UserString)
self.form.ExtOvershoot.setText(U.Quantity(params.get_param("extovershoot"), U.Length).UserString)
self.form.TextSpacing.setText(U.Quantity(params.get_param("dimspacing"), U.Length).UserString)
self.form.saveButton.clicked.connect(self.onSaveStyle)
self.form.applyButton.clicked.connect(self.onApplyStyle)
@@ -201,32 +197,29 @@ class Draft_SetStyle_TaskPanel:
def accept(self):
param_draft = App.ParamGet(self.p + "Mod/Draft")
param_view = App.ParamGet(self.p + "View")
param_view.SetUnsigned("DefaultShapeColor", utils.argb_to_rgba(self.form.ShapeColor.property("color").rgba()))
param_view.SetInt("DefaultShapeTransparency", self.form.Transparency.value())
param_view.SetUnsigned("DefaultShapeLineColor", utils.argb_to_rgba(self.form.LineColor.property("color").rgba()))
param_view.SetInt("DefaultShapeLineWidth", self.form.LineWidth.value())
param_view.SetUnsigned("DefaultShapeVertexColor", utils.argb_to_rgba(self.form.PointColor.property("color").rgba()))
param_view.SetInt("DefaultShapePointSize", self.form.PointSize.value())
param_draft.SetInt("DefaultDrawStyle", self.form.DrawStyle.currentIndex())
param_draft.SetInt("DefaultDisplayMode", self.form.DisplayMode.currentIndex())
param_draft.SetUnsigned("DefaultTextColor", utils.argb_to_rgba(self.form.TextColor.property("color").rgba()))
param_draft.SetString("textfont", self.form.TextFont.currentFont().family())
param_draft.SetFloat("textheight", U.Quantity(self.form.TextSize.text()).Value)
param_draft.SetFloat("LineSpacing", self.form.LineSpacing.value())
param_draft.SetFloat("DefaultAnnoScaleMultiplier", self.form.ScaleMultiplier.value())
param_draft.SetUnsigned("DefaultAnnoLineColor", utils.argb_to_rgba(self.form.AnnoLineColor.property("color").rgba()))
param_draft.SetInt("DefaultAnnoLineWidth", self.form.AnnoLineWidth.value())
param_draft.SetInt("dimsymbol", self.form.ArrowStyle.currentIndex())
param_draft.SetFloat("arrowsize", U.Quantity(self.form.ArrowSize.text()).Value)
param_draft.SetBool("showUnit", self.form.ShowUnit.isChecked())
param_draft.SetString("overrideUnit", self.form.UnitOverride.text())
param_draft.SetFloat("dimovershoot", U.Quantity(self.form.DimOvershoot.text()).Value)
param_draft.SetFloat("extlines", U.Quantity(self.form.ExtLines.text()).Value)
param_draft.SetFloat("extovershoot", U.Quantity(self.form.ExtOvershoot.text()).Value)
param_draft.SetFloat("dimspacing", U.Quantity(self.form.TextSpacing.text()).Value)
params.set_param_view("DefaultShapeColor", utils.argb_to_rgba(self.form.ShapeColor.property("color").rgba()))
params.set_param_view("DefaultShapeTransparency", self.form.Transparency.value())
params.set_param_view("DefaultShapeLineColor", utils.argb_to_rgba(self.form.LineColor.property("color").rgba()))
params.set_param_view("DefaultShapeLineWidth", self.form.LineWidth.value())
params.set_param_view("DefaultShapeVertexColor", utils.argb_to_rgba(self.form.PointColor.property("color").rgba()))
params.set_param_view("DefaultShapePointSize", self.form.PointSize.value())
params.set_param("DefaultDrawStyle", self.form.DrawStyle.currentIndex())
params.set_param("DefaultDisplayMode", self.form.DisplayMode.currentIndex())
params.set_param("DefaultTextColor", utils.argb_to_rgba(self.form.TextColor.property("color").rgba()))
params.set_param("textfont", self.form.TextFont.currentFont().family())
params.set_param("textheight", U.Quantity(self.form.TextSize.text()).Value)
params.set_param("LineSpacing", self.form.LineSpacing.value())
params.set_param("DefaultAnnoScaleMultiplier", self.form.ScaleMultiplier.value())
params.set_param("DefaultAnnoLineColor", utils.argb_to_rgba(self.form.AnnoLineColor.property("color").rgba()))
params.set_param("DefaultAnnoLineWidth", self.form.AnnoLineWidth.value())
params.set_param("dimsymbol", self.form.ArrowStyle.currentIndex())
params.set_param("arrowsize", U.Quantity(self.form.ArrowSize.text()).Value)
params.set_param("showUnit", self.form.ShowUnit.isChecked())
params.set_param("overrideUnit", self.form.UnitOverride.text())
params.set_param("dimovershoot", U.Quantity(self.form.DimOvershoot.text()).Value)
params.set_param("extlines", U.Quantity(self.form.ExtLines.text()).Value)
params.set_param("extovershoot", U.Quantity(self.form.ExtOvershoot.text()).Value)
params.set_param("dimspacing", U.Quantity(self.form.TextSpacing.text()).Value)
self.reject()
def onApplyStyle(self):

View File

@@ -48,8 +48,8 @@ import Part
import Draft
import DraftVecUtils
import DraftGeomUtils
import draftguitools.gui_trackers as trackers
from draftguitools import gui_trackers as trackers
from draftutils import params
from draftutils.init_tools import get_draft_snap_commands
from draftutils.messages import _wrn
from draftutils.translate import translate
@@ -91,7 +91,7 @@ class Snapper:
self.affinity = None
self.mask = None
self.cursorMode = None
self.maxEdges = Draft.getParam("maxSnapEdges", 0)
self.maxEdges = params.get_param("maxSnapEdges")
# we still have no 3D view when the draft module initializes
self.tracker = None
@@ -167,8 +167,7 @@ class Snapper:
set self.active_snaps according to user prefs
"""
self.active_snaps = []
param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
snap_modes = param.GetString("snapModes", "100000000000000") # default value: only lock is ON
snap_modes = params.get_param("snapModes")
i = 0
for snap in snap_modes:
if bool(int(snap)):
@@ -177,7 +176,7 @@ class Snapper:
def set_snap_style(self):
self.snapStyle = Draft.getParam("snapStyle", 0)
self.snapStyle = params.get_param("snapStyle")
if self.snapStyle:
self.mk = coll.OrderedDict([("passive", "SQUARE_LINE"),
("extension", "SQUARE_LINE"),
@@ -241,7 +240,7 @@ class Snapper:
self.spoint = None
if Draft.getParam("SnapBarShowOnlyDuringCommands", False):
if params.get_param("SnapBarShowOnlyDuringCommands"):
toolbar = self.get_snap_toolbar()
if toolbar:
toolbar.show()
@@ -262,14 +261,14 @@ class Snapper:
self.setTrackers()
# Get current snap radius
self.radius = self.getScreenDist(Draft.getParam("snapRange", 8),
self.radius = self.getScreenDist(params.get_param("snapRange"),
screenpos)
if self.radiusTracker:
self.radiusTracker.update(self.radius)
self.radiusTracker.off()
# Activate snap
if Draft.getParam("alwaysSnap", True):
if params.get_param("alwaysSnap"):
active = True
if not self.active:
active = False
@@ -1227,7 +1226,7 @@ class Snapper:
self.unconstrain()
self.radius = 0
self.setCursor()
if Draft.getParam("SnapBarShowOnlyDuringCommands", False):
if params.get_param("SnapBarShowOnlyDuringCommands"):
toolbar = self.get_snap_toolbar()
if toolbar:
toolbar.hide()
@@ -1486,7 +1485,7 @@ class Snapper:
def showradius(self):
"""Show the snap radius indicator."""
self.radius = self.getScreenDist(Draft.getParam("snapRange", 8),
self.radius = self.getScreenDist(params.get_param("snapRange"),
(400, 300))
if self.radiusTracker:
self.radiusTracker.update(self.radius)
@@ -1527,14 +1526,13 @@ class Snapper:
"""
Save snap state to user preferences to be restored in next session.
"""
param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
snap_modes = ""
for snap in self.snaps:
if snap in self.active_snaps:
snap_modes += "1"
else:
snap_modes += "0"
param.SetString("snapModes",snap_modes)
params.set_param("snapModes", snap_modes)
def show_hide_grids(self, show=True):
@@ -1544,8 +1542,7 @@ class Snapper:
Hiding the grid can be prevented by setting the GridHideInOtherWorkbenches
preference to `False`.
"""
param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
if (not show) and (not param.GetBool("GridHideInOtherWorkbenches", True)):
if (not show) and (not params.get_param("GridHideInOtherWorkbenches")):
return
mw = Gui.getMainWindow()
views = mw.getWindowsOfType(App.Base.TypeId.fromName("Gui::View3DInventor")) # All 3D views.
@@ -1593,9 +1590,9 @@ class Snapper:
self.holdTracker = self.trackers[9][i]
else:
self.grid = trackers.gridTracker()
if Draft.getParam("alwaysShowGrid", True):
if params.get_param("alwaysShowGrid"):
self.grid.show_always = True
if Draft.getParam("grid", True):
if params.get_param("grid"):
self.grid.show_during_command = True
self.tracker = trackers.snapTracker()
self.trackLine = trackers.lineTracker()

View File

@@ -37,9 +37,9 @@ as they operate on selections and graphical properties.
import FreeCAD as App
import FreeCADGui as Gui
import WorkingPlane
import draftutils.gui_utils as gui_utils
import draftutils.utils as utils
from draftutils import gui_utils
from draftutils import params
from draftutils import utils
from draftutils.messages import _wrn
# Set modifier keys from the parameter database
@@ -47,15 +47,15 @@ MODS = ["shift", "ctrl", "alt"]
def get_mod_constrain_key():
return MODS[utils.get_param("modconstrain", 0)]
return MODS[params.get_param("modconstrain")]
def get_mod_snap_key():
return MODS[utils.get_param("modsnap", 1)]
return MODS[params.get_param("modsnap")]
def get_mod_alt_key():
return MODS[utils.get_param("modalt", 2)]
return MODS[params.get_param("modalt")]
def format_unit(exp, unit="mm"):

View File

@@ -42,11 +42,11 @@ import FreeCAD
import FreeCADGui
import Draft
import DraftVecUtils
from FreeCAD import Vector
from draftutils import params
from draftutils import utils
from draftutils.todo import ToDo
from draftutils.messages import _msg
from draftutils.todo import ToDo
__title__ = "FreeCAD Draft Trackers"
__author__ = "Yorik van Havre"
@@ -148,7 +148,7 @@ class Tracker:
elif hasattr(FreeCAD, "activeDraftCommand") \
and FreeCAD.activeDraftCommand is not None \
and FreeCAD.activeDraftCommand.featureName in ("Dimension", "Label", "Text"):
color = utils.get_rgba_tuple(utils.get_param("DefaultAnnoLineColor", 255))[:3]
color = utils.get_rgba_tuple(params.get_param("DefaultAnnoLineColor"))[:3]
self.color.rgb = color
else:
self.color.rgb = FreeCADGui.draftToolBar.getDefaultColor("line")
@@ -162,8 +162,7 @@ class snapTracker(Tracker):
def __init__(self):
self.marker = coin.SoMarkerSet() # this is the marker symbol
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View")
self.marker.markerIndex = FreeCADGui.getMarkerIndex("CIRCLE_FILLED", param.GetInt("MarkerSize", 9))
self.marker.markerIndex = FreeCADGui.getMarkerIndex("CIRCLE_FILLED", params.get_param_view("MarkerSize"))
self.coords = coin.SoCoordinate3() # this is the coordinate
self.coords.point.setValue((0, 0, 0))
node = coin.SoAnnotation()
@@ -174,8 +173,7 @@ class snapTracker(Tracker):
def setMarker(self, style):
"""Set the marker index."""
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View")
self.marker.markerIndex = FreeCADGui.getMarkerIndex(style, param.GetInt("MarkerSize", 9))
self.marker.markerIndex = FreeCADGui.getMarkerIndex(style, params.get_param_view("MarkerSize"))
def setColor(self, color=None):
"""Set the color."""
@@ -699,8 +697,7 @@ class ghostTracker(Tracker):
self.coords = coin.SoCoordinate3()
self.coords.point.setValue((obj.X, obj.Y, obj.Z))
self.marker = coin.SoMarkerSet() # this is the marker symbol
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View")
self.marker.markerIndex = FreeCADGui.getMarkerIndex("SQUARE_FILLED", param.GetInt("MarkerSize", 9))
self.marker.markerIndex = FreeCADGui.getMarkerIndex("SQUARE_FILLED", params.get_param_view("MarkerSize"))
node = coin.SoAnnotation()
selnode = coin.SoSeparator()
selnode.addChild(self.coords)
@@ -839,8 +836,7 @@ class editTracker(Tracker):
marker=None, inactive=False):
self.marker = coin.SoMarkerSet() # this is the marker symbol
if marker is None:
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/View")
self.marker.markerIndex = FreeCADGui.getMarkerIndex("SQUARE_FILLED", param.GetInt("MarkerSize", 9))
self.marker.markerIndex = FreeCADGui.getMarkerIndex("SQUARE_FILLED", params.get_param_view("MarkerSize"))
else:
self.marker.markerIndex = marker
self.coords = coin.SoCoordinate3() # this is the coordinate
@@ -914,7 +910,7 @@ class PlaneTracker(Tracker):
# getting screen distance
p1 = Draft.get3DView().getPoint((100, 100))
p2 = Draft.get3DView().getPoint((110, 100))
bl = (p2.sub(p1)).Length * (Draft.getParam("snapRange", 8)/2.0)
bl = (p2.sub(p1)).Length * (params.get_param("snapRange")/2.0)
pick = coin.SoPickStyle()
pick.style.setValue(coin.SoPickStyle.UNPICKABLE)
self.trans = coin.SoTransform()
@@ -1005,9 +1001,9 @@ class gridTracker(Tracker):
def __init__(self):
gtrans = Draft.getParam("gridTransparency",0)
col = self.getGridColor()
if Draft.getParam("coloredGridAxes",True):
gtrans = params.get_param("gridTransparency")
col = utils.get_rgba_tuple(params.get_param("gridColor"))[:3]
if params.get_param("coloredGridAxes"):
red = ((1.0+col[0])/2,0.0,0.0)
green = (0.0,(1.0+col[1])/2,0.0)
blue = (0.0,0.0,(1.0+col[2])/2)
@@ -1096,14 +1092,6 @@ class gridTracker(Tracker):
self.show_always = False
self.reset()
def getGridColor(self):
"""Get the grid color from the parameter editor."""
color = Draft.getParam("gridColor", 842157055)
r = ((color >> 24) & 0xFF) / 255
g = ((color >> 16) & 0xFF) / 255
b = ((color >> 8) & 0xFF) / 255
return [r, g, b]
def update(self):
"""Redraw the grid."""
# Resize the grid to make sure it fits
@@ -1163,7 +1151,7 @@ class gridTracker(Tracker):
for cp in range(0, len(cpts),2):
cidx.append(2)
if Draft.getParam("gridBorder", True):
if params.get_param("gridBorder"):
# extra border
border = (numlines//2 + self.mainlines/2) * self.space
mpts.extend([[-border, -border, z], [border, -border, z], [border, border, z], [-border, border, z], [-border, -border, z]])
@@ -1173,7 +1161,7 @@ class gridTracker(Tracker):
midx.extend(cidx)
# texts
self.font.size = self.space*(self.mainlines//4) or 1
self.font.name = Draft.getParam("textfont","Sans")
self.font.name = params.get_param("textfont")
txt = FreeCAD.Units.Quantity(self.space*self.mainlines,FreeCAD.Units.Length).UserString
self.text1.string = txt
self.text2.string = txt
@@ -1206,9 +1194,8 @@ class gridTracker(Tracker):
bound = (numlines // 2) * self.space
pts = []
pidx = []
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
if param.GetBool("gridBorder", True) \
and param.GetBool("gridShowHuman", True) \
if params.get_param("gridBorder") \
and params.get_param("gridShowHuman") \
and wp.axis.getAngle(FreeCAD.Vector(0,0,1)) < 0.001:
try:
import BimProjectManager
@@ -1226,7 +1213,7 @@ class gridTracker(Tracker):
def setAxesColor(self, wp):
"""set axes color"""
cols = [0,0]
if Draft.getParam("coloredGridAxes",True):
if params.get_param("coloredGridAxes"):
if round(wp.u.getAngle(FreeCAD.Vector(1,0,0)),2) in (0,3.14):
cols[0] = 1
elif round(wp.u.getAngle(FreeCAD.Vector(0,1,0)),2) in (0,3.14):
@@ -1259,11 +1246,11 @@ class gridTracker(Tracker):
def reset(self):
"""Reset the grid according to preferences settings."""
try:
self.space = FreeCAD.Units.Quantity(Draft.getParam("gridSpacing", "1 mm")).Value
self.space = FreeCAD.Units.Quantity(params.get_param("gridSpacing")).Value
except ValueError:
self.space = 1
self.mainlines = Draft.getParam("gridEvery", 10)
self.numlines = Draft.getParam("gridSize", 100)
self.mainlines = params.get_param("gridEvery")
self.numlines = params.get_param("gridSize")
self.update()
def set(self):

View File

@@ -345,16 +345,27 @@ def _get_param_dictionary():
# Draft parameters that are not in the preferences:
param_dict["Mod/Draft"] = {
"DefaultAnnoDisplayMode": ("int", 0),
"DefaultDisplayMode": ("int", 0),
"DefaultDrawStyle": ("int", 0),
"Draft_array_fuse": ("bool", False),
"Draft_array_Link": ("bool", True),
"fillmode": ("bool", True),
"HatchPatternResolution": ("int", 128),
"labeltype": ("string", "Custom"),
"snapModes": ("string", "100000000000000"),
"snapRange": ("int", 8),
"AnnotationStyleEditorHeight": ("int", 450),
"AnnotationStyleEditorWidth": ("int", 450),
"CenterPlaneOnView": ("bool", False),
"DefaultAnnoDisplayMode": ("int", 0),
"DefaultDisplayMode": ("int", 0),
"DefaultDrawStyle": ("int", 0),
"DefaultPrintColor": ("unsigned", 255),
"Draft_array_fuse": ("bool", False),
"Draft_array_Link": ("bool", True),
"fillmode": ("bool", True),
"HatchPatternResolution": ("int", 128),
"HatchPatternRotation": ("float", 0.0),
"HatchPatternScale": ("float", 100.0),
"labeltype": ("string", "Custom"),
"LayersManagerHeight": ("int", 320),
"LayersManagerWidth": ("int", 640),
"maxSnapEdges": ("int", 0),
"Offset_OCC": ("bool", False),
"snapModes": ("string", "100000000000000"),
"snapRange": ("int", 8),
"useSupport": ("bool", False),
}
@@ -367,13 +378,25 @@ def _get_param_dictionary():
# For the View parameters we do not check the preferences:
param_dict["View"] = {
"DefaultShapeColor": ("unsigned", 3435973887),
"DefaultShapeLineColor": ("unsigned", 421075455),
"DefaultShapeLineWidth": ("int", 2),
"DefaultShapePointSize": ("int", 2),
"DefaultShapeTransparency": ("int", 0),
"DefaultShapeVertexColor": ("unsigned", 421075455),
"DefaultShapeColor": ("unsigned", 3435973887),
"DefaultShapeLineColor": ("unsigned", 421075455),
"DefaultShapeLineWidth": ("int", 2),
"DefaultShapePointSize": ("int", 2),
"DefaultShapeTransparency": ("int", 0),
"DefaultShapeVertexColor": ("unsigned", 421075455),
"EnableSelection": ("bool", True),
"MarkerSize": ("int", 9),
}
# For the Mod/TechDraw/PAT parameters we do not check the preferences:
param_dict["Mod/TechDraw/PAT"] = {
"FilePattern": ("string", ""),
"NamePattern": ("string", "Diamant"),
}
# Preferences ui files are stored in resource files.
# For the Draft Workbench: /Mod/Draft/Draft_rc.py
@@ -477,18 +500,18 @@ def get_param(entry, path="Mod/Draft"):
return None
if entry not in PARAM_DICT[path]:
return None
param = App.ParamGet("User parameter:BaseApp/Preferences/" + path)
param_grp = App.ParamGet("User parameter:BaseApp/Preferences/" + path)
typ, default = PARAM_DICT[path][entry]
if typ == "bool":
return param.GetBool(entry, default)
return param_grp.GetBool(entry, default)
if typ == "float":
return param.GetFloat(entry, default)
return param_grp.GetFloat(entry, default)
if typ == "int":
return param.GetInt(entry, default)
return param_grp.GetInt(entry, default)
if typ == "string":
return param.GetString(entry, default)
return param_grp.GetString(entry, default)
if typ == "unsigned":
return param.GetUnsigned(entry, default)
return param_grp.GetUnsigned(entry, default)
return None
@@ -522,19 +545,19 @@ def set_param(entry, value, path="Mod/Draft"):
return False
if entry not in PARAM_DICT[path]:
return False
param = App.ParamGet("User parameter:BaseApp/Preferences/" + path)
param_grp = App.ParamGet("User parameter:BaseApp/Preferences/" + path)
typ = PARAM_DICT[path][entry][0]
ret = True
if typ == "bool":
param.SetBool(entry, value)
param_grp.SetBool(entry, value)
elif typ == "float":
param.SetFloat(entry, value)
param_grp.SetFloat(entry, value)
elif typ == "int":
param.SetInt(entry, value)
param_grp.SetInt(entry, value)
elif typ == "string":
param.SetString(entry, value)
param_grp.SetString(entry, value)
elif typ == "unsigned":
param.SetUnsigned(entry, value)
param_grp.SetUnsigned(entry, value)
else:
ret = False
return ret