Skip to content

Commit

Permalink
Draft: fixed wrong QT_TRANSLATE_NOOP usage in Draft Objects
Browse files Browse the repository at this point in the history
.
  • Loading branch information
carlopav authored and yorikvanhavre committed Jun 9, 2020
1 parent c0971eb commit 904f340
Show file tree
Hide file tree
Showing 22 changed files with 383 additions and 462 deletions.
109 changes: 61 additions & 48 deletions src/Mod/Draft/draftobjects/array.py
Expand Up @@ -75,15 +75,13 @@ def set_general_properties(self, obj):
properties = obj.PropertiesList

if "Base" not in properties:
_tip = "The base object that will be duplicated"
obj.addProperty("App::PropertyLink",
"Base",
"Objects",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip = QT_TRANSLATE_NOOP("App::Property", "The base object that will be duplicated")
obj.addProperty("App::PropertyLink", "Base", "Objects", _tip)
obj.Base = None

if "ArrayType" not in properties:
_tip = ("The type of array to create.\n"
_tip = QT_TRANSLATE_NOOP("App::Property",
"The type of array to create.\n"
"- Ortho: places the copies in the direction "
"of the global X, Y, Z axes.\n"
"- Polar: places the copies along a circular arc, "
Expand All @@ -94,96 +92,104 @@ def set_general_properties(self, obj):
obj.addProperty("App::PropertyEnumeration",
"ArrayType",
"Objects",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.ArrayType = ['ortho', 'polar', 'circular']

if "Fuse" not in properties:
_tip = ("Specifies if the copies should be fused together "
_tip = QT_TRANSLATE_NOOP("App::Property",
"Specifies if the copies should be fused together "
"if they touch each other (slower)")
obj.addProperty("App::PropertyBool",
"Fuse",
"Objects",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.Fuse = False

def set_ortho_properties(self, obj):
"""Set orthogonal properties only if they don't exist."""
properties = obj.PropertiesList

if "NumberX" not in properties:
_tip = "Number of copies in X direction"
_tip = QT_TRANSLATE_NOOP("App::Property",
"Number of copies in X direction")
obj.addProperty("App::PropertyInteger",
"NumberX",
"Orthogonal array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.NumberX = 2

if "NumberY" not in properties:
_tip = "Number of copies in Y direction"
_tip = QT_TRANSLATE_NOOP("App::Property",
"Number of copies in Y direction")
obj.addProperty("App::PropertyInteger",
"NumberY",
"Orthogonal array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.NumberY = 2

if "NumberZ" not in properties:
_tip = "Number of copies in Z direction"
obj.addProperty("App::PropertyInteger",
"NumberZ",
"Orthogonal array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip = QT_TRANSLATE_NOOP("App::Property",
"Number of copies in Z direction")
obj.addProperty("App::PropertyInteger", "NumberZ",
"Orthogonal array", _tip)
obj.NumberZ = 1

if "IntervalX" not in properties:
_tip = "Distance and orientation of intervals in X direction"
_tip = QT_TRANSLATE_NOOP("App::Property",
"Distance and orientation of intervals in X direction")
obj.addProperty("App::PropertyVectorDistance",
"IntervalX",
"Orthogonal array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.IntervalX = App.Vector(50, 0, 0)

if "IntervalY" not in properties:
_tip = "Distance and orientation of intervals in Y direction"
_tip = QT_TRANSLATE_NOOP("App::Property",
"Distance and orientation of intervals in Y direction")
obj.addProperty("App::PropertyVectorDistance",
"IntervalY",
"Orthogonal array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.IntervalY = App.Vector(0, 50, 0)

if "IntervalZ" not in properties:
_tip = "Distance and orientation of intervals in Z direction"
_tip = QT_TRANSLATE_NOOP("App::Property",
"Distance and orientation of intervals in Z direction")
obj.addProperty("App::PropertyVectorDistance",
"IntervalZ",
"Orthogonal array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.IntervalZ = App.Vector(0, 0, 50)

def set_polar_circular_properties(self, obj):
"""Set general polar and circular properties if they don't exist."""
properties = obj.PropertiesList

if "Axis" not in properties:
_tip = ("The axis direction around which the elements in "
_tip = QT_TRANSLATE_NOOP("App::Property",
"The axis direction around which the elements in "
"a polar or a circular array will be created")
obj.addProperty("App::PropertyVector",
"Axis",
"Polar/circular array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.Axis = App.Vector(0, 0, 1)

if "Center" not in properties:
_tip = ("Center point for polar and circular arrays.\n"
_tip = QT_TRANSLATE_NOOP("App::Property",
"Center point for polar and circular arrays.\n"
"The 'Axis' passes through this point.")
obj.addProperty("App::PropertyVectorDistance",
"Center",
"Polar/circular array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.Center = App.Vector(0, 0, 0)

# The AxisReference property must be attached after Axis and Center
# so that onChanged works properly
if "AxisReference" not in properties:
_tip = ("The axis object that overrides the value of 'Axis' "
_tip = QT_TRANSLATE_NOOP("App::Property",
"The axis object that overrides the value of 'Axis' "
"and 'Center', for example, a datum line.\n"
"Its placement, position and rotation, will be used "
"when creating polar and circular arrays.\n"
Expand All @@ -192,73 +198,78 @@ def set_polar_circular_properties(self, obj):
obj.addProperty("App::PropertyLinkGlobal",
"AxisReference",
"Objects",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.AxisReference = None

def set_polar_properties(self, obj):
"""Set polar properties only if they don't exist."""
properties = obj.PropertiesList

if "NumberPolar" not in properties:
_tip = "Number of copies in the polar direction"
_tip = QT_TRANSLATE_NOOP("App::Property",
"Number of copies in the polar direction")
obj.addProperty("App::PropertyInteger",
"NumberPolar",
"Polar array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.NumberPolar = 5

if "IntervalAxis" not in properties:
_tip = "Distance and orientation of intervals in 'Axis' direction"
_tip = QT_TRANSLATE_NOOP("App::Property",
"Distance and orientation of intervals in 'Axis' direction")
obj.addProperty("App::PropertyVectorDistance",
"IntervalAxis",
"Polar array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.IntervalAxis = App.Vector(0, 0, 0)

if "Angle" not in properties:
_tip = "Angle to cover with copies"
_tip = QT_TRANSLATE_NOOP("App::Property", "Angle to cover with copies")
obj.addProperty("App::PropertyAngle",
"Angle",
"Polar array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.Angle = 360

def set_circular_properties(self, obj):
"""Set circular properties only if they don't exist."""
properties = obj.PropertiesList

if "RadialDistance" not in properties:
_tip = "Distance between circular layers"
_tip = QT_TRANSLATE_NOOP("App::Property", "Distance between circular layers")
obj.addProperty("App::PropertyDistance",
"RadialDistance",
"Circular array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.RadialDistance = 50

if "TangentialDistance" not in properties:
_tip = "Distance between copies in the same circular layer"
_tip = QT_TRANSLATE_NOOP("App::Property",
"Distance between copies in the same circular layer")
obj.addProperty("App::PropertyDistance",
"TangentialDistance",
"Circular array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.TangentialDistance = 25

if "NumberCircles" not in properties:
_tip = ("Number of circular layers. "
_tip = QT_TRANSLATE_NOOP("App::Property",
"Number of circular layers. "
"The 'Base' object counts as one layer.")
obj.addProperty("App::PropertyInteger",
"NumberCircles",
"Circular array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.NumberCircles = 3

if "Symmetry" not in properties:
_tip = ("A parameter that determines how many symmetry planes "
_tip = QT_TRANSLATE_NOOP("App::Property",
"A parameter that determines how many symmetry planes "
" the circular array will have.")
obj.addProperty("App::PropertyInteger",
"Symmetry",
"Circular array",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.Symmetry = 1

def set_link_properties(self, obj):
Expand All @@ -267,23 +278,25 @@ def set_link_properties(self, obj):

if self.use_link:
if "Count" not in properties:
_tip = ("Total number of elements in the array.\n"
_tip = QT_TRANSLATE_NOOP("App::Property",
"Total number of elements in the array.\n"
"This property is read-only, as the number depends "
"on the parameters of the array.")
obj.addProperty("App::PropertyInteger",
"Count",
"Objects",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.Count = 0
obj.setEditorMode("Count", 1) # Read only

if "ExpandArray" not in properties:
_tip = ("Show the individual array elements "
_tip = QT_TRANSLATE_NOOP("App::Property",
"Show the individual array elements "
"(only for Link arrays)")
obj.addProperty("App::PropertyBool",
"ExpandArray",
"Objects",
QT_TRANSLATE_NOOP("App::Property", _tip))
_tip)
obj.ExpandArray = False

def linkSetup(self, obj):
Expand Down
44 changes: 22 additions & 22 deletions src/Mod/Draft/draftobjects/bezcurve.py
Expand Up @@ -41,39 +41,39 @@ class BezCurve(DraftObject):
def __init__(self, obj):
super(BezCurve, self).__init__(obj, "BezCurve")

_tip = "The points of the Bezier curve"
obj.addProperty("App::PropertyVectorList", "Points",
"Draft",QT_TRANSLATE_NOOP("App::Property", _tip))
_tip = QT_TRANSLATE_NOOP("App::Property",
"The points of the Bezier curve")
obj.addProperty("App::PropertyVectorList", "Points", "Draft", _tip)

_tip = "The degree of the Bezier function"
obj.addProperty("App::PropertyInteger", "Degree",
"Draft",QT_TRANSLATE_NOOP("App::Property", _tip))
_tip = QT_TRANSLATE_NOOP("App::Property",
"The degree of the Bezier function")
obj.addProperty("App::PropertyInteger", "Degree", "Draft", _tip)

_tip = "Continuity"
obj.addProperty("App::PropertyIntegerList", "Continuity",
"Draft",QT_TRANSLATE_NOOP("App::Property", _tip))
_tip = QT_TRANSLATE_NOOP("App::Property",
"Continuity")
obj.addProperty("App::PropertyIntegerList", "Continuity", "Draft", _tip)

_tip = "If the Bezier curve should be closed or not"
obj.addProperty("App::PropertyBool", "Closed",
"Draft",QT_TRANSLATE_NOOP("App::Property", _tip))
_tip = QT_TRANSLATE_NOOP("App::Property",
"If the Bezier curve should be closed or not")
obj.addProperty("App::PropertyBool", "Closed", "Draft", _tip)

_tip = "Create a face if this curve is closed"
obj.addProperty("App::PropertyBool", "MakeFace",
"Draft",QT_TRANSLATE_NOOP("App::Property", _tip))
_tip = QT_TRANSLATE_NOOP("App::Property",
"Create a face if this curve is closed")
obj.addProperty("App::PropertyBool", "MakeFace", "Draft", _tip)

_tip = "The length of this object"
obj.addProperty("App::PropertyLength", "Length",
"Draft",QT_TRANSLATE_NOOP("App::Property", _tip))
_tip = QT_TRANSLATE_NOOP("App::Property",
"The length of this object")
obj.addProperty("App::PropertyLength", "Length", "Draft", _tip)

_tip = "The area of this object"
obj.addProperty("App::PropertyArea", "Area",
"Draft",QT_TRANSLATE_NOOP("App::Property", _tip))
_tip = QT_TRANSLATE_NOOP("App::Property",
"The area of this object")
obj.addProperty("App::PropertyArea", "Area", "Draft", _tip)

obj.MakeFace = get_param("fillmode", True)
obj.Closed = False
obj.Degree = 3
obj.Continuity = []
#obj.setEditorMode("Degree",2)
#obj.setEditorMode("Degree", 2)
obj.setEditorMode("Continuity", 1)

def execute(self, fp):
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Draft/draftobjects/block.py
Expand Up @@ -37,9 +37,9 @@ class Block(DraftObject):
def __init__(self, obj):
super(Block, self).__init__(obj, "Block")

_tip = "The components of this block"
obj.addProperty("App::PropertyLinkList","Components",
"Draft",QT_TRANSLATE_NOOP("App::Property", _tip))
_tip = QT_TRANSLATE_NOOP("App::Property",
"The components of this block")
obj.addProperty("App::PropertyLinkList","Components", "Draft", _tip)

def execute(self, obj):
import Part
Expand Down

0 comments on commit 904f340

Please sign in to comment.