Moved almost all translate implementations away from QtGui.

This commit is contained in:
Markus Lampert
2017-06-01 20:00:28 -07:00
parent fa9166b738
commit 3368c8682e
34 changed files with 139 additions and 371 deletions

View File

@@ -30,14 +30,8 @@ from PySide import QtCore, QtGui
"""Path Array object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Array", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectArray:
@@ -122,11 +116,11 @@ class CommandPathArray:
selection = FreeCADGui.Selection.getSelection()
if len(selection) != 1:
FreeCAD.Console.PrintError(
translate("Path_Array", "Please select exactly one path object\n"))
translate("Please select exactly one path object\n"))
return
if not(selection[0].isDerivedFrom("Path::Feature")):
FreeCAD.Console.PrintError(
translate("Path_Array", "Please select exactly one path object\n"))
translate("Please select exactly one path object\n"))
return
# if everything is ok, execute and register the transaction in the

View File

@@ -29,15 +29,8 @@ import Path
from PySide import QtCore, QtGui
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Comment", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class Comment:
@@ -118,7 +111,7 @@ class CommandPathComment:
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(
translate("Path_Comment", "Create a Comment in your CNC program"))
translate("Create a Comment in your CNC program"))
FreeCADGui.addModule("PathScripts.PathComment")
snippet = '''
import Path

View File

@@ -30,15 +30,8 @@ from PySide import QtCore, QtGui
"""Path Compound Extended object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_CompoundExtended", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectCompoundExtended:
@@ -114,7 +107,7 @@ class CommandCompoundExtended:
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(
translate("Path_CompoundExtended", "Create Compound"))
translate("Create Compound"))
FreeCADGui.addModule("PathScripts.PathCompoundExtended")
snippet = '''
import Path

View File

@@ -41,18 +41,10 @@ FreeCAD.setLogLevel('Path.Area', 0)
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtGui
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
else:
def translate(ctxt, txt):
return txt
# Qt tanslation handling
def translate(text, context = "Path", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
__title__ = "Path Contour Operation"
__author__ = "sliptonic (Brad Collette)"
@@ -318,7 +310,7 @@ class CommandPathContour:
ztop = 10.0
zbottom = 0.0
FreeCAD.ActiveDocument.openTransaction(translate("Path", "Create a Contour"))
FreeCAD.ActiveDocument.openTransaction(translate("Create a Contour"))
FreeCADGui.addModule("PathScripts.PathContour")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Contour")')
FreeCADGui.doCommand('PathScripts.PathContour.ObjectContour(obj)')

View File

@@ -29,14 +29,8 @@ from PySide import QtCore, QtGui
"""Path Copy object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Copy", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectPathCopy:
@@ -94,7 +88,7 @@ class CommandPathCopy:
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(
translate("Path_Copy", "Create Copy"))
translate("Create Copy"))
FreeCADGui.addModule("PathScripts.PathCopy")
consolecode = '''
@@ -107,11 +101,11 @@ selection = FreeCADGui.Selection.getSelection()
proj = selection[0].InList[0] #get the group that the selectied object is inside
if len(selection) != 1:
FreeCAD.Console.PrintError(translate("PathCopy","Please select one path object\\n"))
FreeCAD.Console.PrintError(translate("Please select one path object\\n"))
selGood = False
if not selection[0].isDerivedFrom("Path::Feature"):
FreeCAD.Console.PrintError(translate("PathCopy","The selected object is not a path\\n"))
FreeCAD.Console.PrintError(translate("The selected object is not a path\\n"))
selGood = False
if selGood:

View File

@@ -29,14 +29,8 @@ from PySide import QtCore, QtGui
"""Path Custom object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Custom", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectCustom:

View File

@@ -31,17 +31,8 @@ from PySide import QtCore, QtGui
"""Path Dressup object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Dressup", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectDressup:
@@ -126,17 +117,17 @@ class CommandPathDressup:
# check that the selection contains exactly what we want
selection = FreeCADGui.Selection.getSelection()
if len(selection) != 1:
FreeCAD.Console.PrintError(translate("Path_Dressup", "Please select one path object\n"))
FreeCAD.Console.PrintError(translate("Please select one path object\n"))
return
if not selection[0].isDerivedFrom("Path::Feature"):
FreeCAD.Console.PrintError(translate("Path_Dressup", "The selected object is not a path\n"))
FreeCAD.Console.PrintError(translate("The selected object is not a path\n"))
return
if selection[0].isDerivedFrom("Path::FeatureCompoundPython"):
FreeCAD.Console.PrintError(translate("Path_Dressup", "Please select a Path object"))
FreeCAD.Console.PrintError(translate("Please select a Path object"))
return
# everything ok!
FreeCAD.ActiveDocument.openTransaction(translate("Path_Dressup", "Create Dress-up"))
FreeCAD.ActiveDocument.openTransaction(translate("Create Dress-up"))
FreeCADGui.addModule("PathScripts.PathDressup")
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Dressup")')

View File

@@ -35,14 +35,8 @@ import PathScripts.PathUtils as P
"""Dragknife Dressup object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "PathDressup_DragKnife", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
movecommands = ['G1', 'G01', 'G2', 'G02', 'G3', 'G03']
rapidcommands = ['G0', 'G00']
@@ -488,19 +482,19 @@ class CommandDressupDragknife:
selection = FreeCADGui.Selection.getSelection()
if len(selection) != 1:
FreeCAD.Console.PrintError(
translate("PathDressup_DragKnife", "Please select one path object\n"))
translate("Please select one path object\n"))
return
if not selection[0].isDerivedFrom("Path::Feature"):
FreeCAD.Console.PrintError(
translate("PathDressup_DragKnife", "The selected object is not a path\n"))
translate("The selected object is not a path\n"))
return
if selection[0].isDerivedFrom("Path::FeatureCompoundPython"):
FreeCAD.Console.PrintError(
translate("PathDressup_DragKnife", "Please select a Path object"))
translate("Please select a Path object"))
return
# everything ok!
FreeCAD.ActiveDocument.openTransaction(translate("PathDressup_DragKnife", "Create Dress-up"))
FreeCAD.ActiveDocument.openTransaction(translate("Create Dress-up"))
FreeCADGui.addModule("PathScripts.PathDressupDragknife")
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","DragknifeDressup")')

View File

@@ -48,14 +48,8 @@ if FreeCAD.GuiUp:
"""Path Drilling object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Drilling", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectDrilling:
@@ -326,7 +320,7 @@ class CommandPathDrilling:
def Activated(self):
# if everything is ok, execute and register the transaction in the undo/redo stack
FreeCAD.ActiveDocument.openTransaction(translate("Path_Drilling", "Create Drilling"))
FreeCAD.ActiveDocument.openTransaction(translate("Create Drilling"))
FreeCADGui.addModule("PathScripts.PathDrilling")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Drilling")')
FreeCADGui.doCommand('PathScripts.PathDrilling.ObjectDrilling(obj)')

View File

@@ -40,15 +40,8 @@ PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE)
# PathLog.trackModule('PathEngrave')
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Engrave", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectPathEngrave:

View File

@@ -29,14 +29,8 @@ from PySide import QtCore, QtGui
"""Path Pocket object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_FacePocket", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectFacePocket:
@@ -162,26 +156,22 @@ class CommandPathFacePocket:
# check that the selection contains exactly what we want
selection = FreeCADGui.Selection.getSelectionEx()
if len(selection) != 1:
FreeCAD.Console.PrintError(translate(
"Path_FacePocket", "Please select an edges loop from one object, or a single face\n"))
FreeCAD.Console.PrintError(translate("Please select an edges loop from one object, or a single face\n"))
return
if len(selection[0].SubObjects) == 0:
FreeCAD.Console.PrintError(translate(
"Path_FacePocket", "Please select an edges loop from one object, or a single face\n"))
FreeCAD.Console.PrintError(translate("Please select an edges loop from one object, or a single face\n"))
return
for s in selection[0].SubObjects:
if s.ShapeType != "Edge":
if (s.ShapeType != "Face") or (len(selection[0].SubObjects) != 1):
FreeCAD.Console.PrintError(
translate("Path_FacePocket", "Please select only edges or a single face\n"))
FreeCAD.Console.PrintError(translate("Please select only edges or a single face\n"))
return
if selection[0].SubObjects[0].ShapeType == "Edge":
try:
import Part
# w = Part.Wire(selection[0].SubObjects)
except:
FreeCAD.Console.PrintError(
translate("Path_FacePocket", "The selected edges don't form a loop\n"))
FreeCAD.Console.PrintError(translate("The selected edges don't form a loop\n"))
return
# if everything is ok, execute and register the transaction in the

View File

@@ -29,14 +29,8 @@ from PySide import QtCore, QtGui
"""Path Profile object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_FaceProfile", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectFaceProfile:
@@ -129,16 +123,13 @@ class CommandPathFaceProfile:
# check that the selection contains exactly what we want
selection = FreeCADGui.Selection.getSelectionEx()
if len(selection) != 1:
FreeCAD.Console.PrintError(
translate("Path_FaceProfile", "Please select one face or wire\n"))
FreeCAD.Console.PrintError(translate("Please select one face or wire\n"))
return
if len(selection[0].SubObjects) != 1:
FreeCAD.Console.PrintError(
translate("Path_FaceProfile", "Please select only one face or wire\n"))
FreeCAD.Console.PrintError(translate("Please select only one face or wire\n"))
return
if not selection[0].SubObjects[0].ShapeType in ["Face", "Wire"]:
FreeCAD.Console.PrintError(
translate("Path_FaceProfile", "Please select only a face or a wire\n"))
FreeCAD.Console.PrintError(translate("Please select only a face or a wire\n"))
return
# if everything is ok, execute and register the transaction in the

View File

@@ -28,15 +28,8 @@ import Path
from PySide import QtCore, QtGui
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Fixture", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class Fixture:
def __init__(self,obj):
@@ -130,8 +123,7 @@ class CommandPathFixture:
return False
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(
translate("Path_Fixture", "Create a Fixture Offset"))
FreeCAD.ActiveDocument.openTransaction(translate("Create a Fixture Offset"))
FreeCADGui.addModule("PathScripts.PathFixture")
snippet = '''
import Path

View File

@@ -27,15 +27,8 @@ import FreeCADGui
from PySide import QtCore, QtGui
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_FromShape", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
# TODO make the shape parametric
@@ -91,15 +84,15 @@ class CommandFromShape:
selection = FreeCADGui.Selection.getSelection()
if len(selection) != 1:
FreeCAD.Console.PrintError(
translate("Path_FromShape", "Please select exactly one Part-based object\n"))
translate("Please select exactly one Part-based object\n"))
return
if not(selection[0].isDerivedFrom("Part::Feature")):
FreeCAD.Console.PrintError(
translate("Path_FromShape", "Please select exactly one Part-based object\n"))
translate("Please select exactly one Part-based object\n"))
return
FreeCAD.ActiveDocument.openTransaction(
translate("Path_FromShape", "Create path from shape"))
translate("Create path from shape"))
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand(
"obj = FreeCAD.activeDocument().addObject('Path::FeatureShape','PathShape')")

View File

@@ -30,15 +30,8 @@ from PySide import QtCore, QtGui
"""Path Hop object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Hop", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectHop:
@@ -117,15 +110,15 @@ class CommandPathHop:
selection = FreeCADGui.Selection.getSelection()
if len(selection) != 1:
FreeCAD.Console.PrintError(
translate("Path_Hop", "Please select one path object\n"))
translate("Please select one path object\n"))
return
if not selection[0].isDerivedFrom("Path::Feature"):
FreeCAD.Console.PrintError(
translate("Path_Hop", "The selected object is not a path\n"))
translate("The selected object is not a path\n"))
return
FreeCAD.ActiveDocument.openTransaction(
translate("Path_Hop", "Create Hop"))
translate("Create Hop"))
FreeCADGui.addModule("PathScripts.PathHop")
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand(

View File

@@ -26,16 +26,10 @@ from PySide import QtCore, QtGui
import FreeCAD
import FreeCADGui
import Path
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Inspect", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
# class OldHighlighter(QtGui.QSyntaxHighlighter):
@@ -138,7 +132,7 @@ class GCodeEditorDialog(QtGui.QDialog):
# Note
lab = QtGui.QLabel()
lab.setText(translate("PathInspect", "<b>Note</b>: Pressing OK will commit any change you make above to the object, but if the object is parametric, these changes will be overridden on recompute."))
lab.setText(translate("<b>Note</b>: Pressing OK will commit any change you make above to the object, but if the object is parametric, these changes will be overridden on recompute."))
lab.setWordWrap(True)
layout.addWidget(lab)
@@ -236,11 +230,11 @@ class CommandPathInspect:
selection = FreeCADGui.Selection.getSelection()
if len(selection) != 1:
FreeCAD.Console.PrintError(
translate("Path_Inspect", "Please select exactly one path object\n"))
translate("Please select exactly one path object\n"))
return
if not(selection[0].isDerivedFrom("Path::Feature")):
FreeCAD.Console.PrintError(
translate("Path_Inspect", "Please select exactly one path object\n"))
translate("Please select exactly one path object\n"))
return
# if everything is ok, execute

View File

@@ -46,14 +46,8 @@ if FreeCAD.GuiUp:
"""Path Job object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Job", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectPathJob:
@@ -182,7 +176,7 @@ class CommandJob:
@staticmethod
def Create():
FreeCAD.ActiveDocument.openTransaction(translate("Path_Job", "Create Job"))
FreeCAD.ActiveDocument.openTransaction(translate("Create Job"))
FreeCADGui.addModule('PathScripts.PathUtils')
FreeCADGui.addModule('PathScripts.PathLoadTool')
snippet = '''
@@ -199,7 +193,7 @@ obj.ViewObject.startEditing()
class TaskPanel:
def __init__(self, obj, deleteOnReject):
FreeCAD.ActiveDocument.openTransaction(translate("Path_Job", "Edit Job"))
FreeCAD.ActiveDocument.openTransaction(translate("Edit Job"))
self.obj = obj
self.deleteOnReject = deleteOnReject
self.form = FreeCADGui.PySideUic.loadUi(":/panels/JobEdit.ui")
@@ -233,7 +227,7 @@ class TaskPanel:
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.abortTransaction()
if self.deleteOnReject:
FreeCAD.ActiveDocument.openTransaction(translate("Path_Job", "Uncreate Job"))
FreeCAD.ActiveDocument.openTransaction(translate("Uncreate Job"))
for child in self.obj.Group:
FreeCAD.ActiveDocument.removeObject(child.Name)
FreeCAD.ActiveDocument.removeObject(self.obj.Name)
@@ -315,7 +309,7 @@ class TaskPanel:
pass
def setFile(self):
filename = QtGui.QFileDialog.getSaveFileName(self.form, translate("PathJob", "Select Output File", None), None, translate("Path Job", "All Files (*.*)", None))
filename = QtGui.QFileDialog.getSaveFileName(self.form, translate("Select Output File"), None, translate("All Files (*.*)"))
if filename and filename[0]:
self.obj.PostProcessorOutputFile = str(filename[0])
self.setFields()

View File

@@ -38,14 +38,8 @@ PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE)
#PathLog.trackModule('PathLoadTool')
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_LoadTool", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class LoadTool():
@@ -184,7 +178,7 @@ class CommandPathLoadTool:
PathLog.track()
self.Create()
# FreeCAD.ActiveDocument.openTransaction(translate("Path_LoadTool", "Create Tool Controller Object"))
# FreeCAD.ActiveDocument.openTransaction(translate("Create Tool Controller Object"))
# obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "TC")
# PathScripts.PathLoadTool.LoadTool(obj)

View File

@@ -45,14 +45,8 @@ if FreeCAD.GuiUp:
"""Path Face object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectFace:

View File

@@ -29,14 +29,8 @@ import Path
from PySide import QtCore, QtGui
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Plane", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class Plane:
@@ -126,7 +120,7 @@ class CommandPathPlane:
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(
translate("Path_Plane", "Create a Selection Plane object"))
translate("Create a Selection Plane object"))
FreeCADGui.addModule("PathScripts.PathPlane")
snippet = '''
import Path

View File

@@ -39,15 +39,8 @@ PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE)
# PathLog.trackModule('PathPocket')
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectPocket:

View File

@@ -44,14 +44,8 @@ PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE)
PathLog.trackModule(LOG_MODULE)
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Post", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class DlgSelectPostProcessor:
@@ -202,7 +196,7 @@ class CommandPathPost:
def Activated(self):
PathLog.track()
FreeCAD.ActiveDocument.openTransaction(
translate("Path_Post", "Post Process the Selected path(s)"))
translate("Post Process the Selected path(s)"))
FreeCADGui.addModule("PathScripts.PathPost")
# Attempt to figure out what the user wants to post-process

View File

@@ -28,16 +28,8 @@ from PySide import QtCore, QtGui
from PathScripts.PathPreferences import PathPreferences
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_PreferencesPathDressup", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
_dressups = []
@@ -47,7 +39,7 @@ def RegisterDressup(dressup):
class DressupPreferencesPage:
def __init__(self, parent=None):
self.form = QtGui.QToolBox()
self.form.setWindowTitle(translate('PathPreferencesPathDressup', 'Dressups'))
self.form.setWindowTitle(translate('Dressups'))
pages = []
for dressup in _dressups:
page = dressup.preferencesPage()

View File

@@ -40,18 +40,10 @@ PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE)
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
else:
def translate(ctxt, txt):
return txt
# Qt tanslation handling
def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
__title__ = "Path Profile Operation"
__author__ = "sliptonic (Brad Collette)"

View File

@@ -39,18 +39,10 @@ PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE)
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
else:
def translate(ctxt, txt):
return txt
# Qt tanslation handling
def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
__title__ = "Path Profile Edges Operation"
__author__ = "sliptonic (Brad Collette)"

View File

@@ -32,13 +32,8 @@ import FreeCADGui
import PathScripts.PathUtils as PU
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Sanity", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
def review(obj):
@@ -46,31 +41,31 @@ def review(obj):
toolcontrolcount = 0
if len(obj.Tooltable.Tools) == 0:
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Machine: " + str(obj.Label) + " has no tools defined in the tool table\n"))
FreeCAD.Console.PrintWarning(translate("Machine: " + str(obj.Label) + " has no tools defined in the tool table\n"))
if obj.X_Max == obj.X_Min or obj.Y_Max == obj.Y_Min:
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "It appears the machine limits haven't been set. Not able to check path extents.\n"))
FreeCAD.Console.PrintWarning(translate("It appears the machine limits haven't been set. Not able to check path extents.\n"))
for item in obj.Group:
print("Checking: " + item.Label)
if item.Name[:2] == "TC":
toolcontrolcount += 1
if item.ToolNumber == 0:
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " is using ID 0 which the undefined default. Please set a real tool.\n"))
FreeCAD.Console.PrintWarning(translate("Tool Controller: " + str(item.Label) + " is using ID 0 which the undefined default. Please set a real tool.\n"))
else:
tool = PU.getTool(item, item.ToolNumber)
if tool is None:
FreeCAD.Console.PrintError(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " is using tool: " + str(item.ToolNumber) + " which is invalid\n"))
FreeCAD.Console.PrintError(translate("Tool Controller: " + str(item.Label) + " is using tool: " + str(item.ToolNumber) + " which is invalid\n"))
elif tool.Diameter == 0:
FreeCAD.Console.PrintError(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " is using tool: " + str(item.ToolNumber) + " which has a zero diameter\n"))
FreeCAD.Console.PrintError(translate("Tool Controller: " + str(item.Label) + " is using tool: " + str(item.ToolNumber) + " which has a zero diameter\n"))
if item.HorizFeed == 0:
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " has a 0 value for the Horizontal feed rate\n"))
FreeCAD.Console.PrintWarning(translate("Tool Controller: " + str(item.Label) + " has a 0 value for the Horizontal feed rate\n"))
if item.VertFeed == 0:
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " has a 0 value for the Vertical feed rate\n"))
FreeCAD.Console.PrintWarning(translate("Tool Controller: " + str(item.Label) + " has a 0 value for the Vertical feed rate\n"))
if item.SpindleSpeed == 0:
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " has a 0 value for the spindle speed\n"))
FreeCAD.Console.PrintWarning(translate("Tool Controller: " + str(item.Label) + " has a 0 value for the spindle speed\n"))
if toolcontrolcount == 0:
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "A Tool Controller was not found. Default values are used which is dangerous. Please add a Tool Controller.\n"))
FreeCAD.Console.PrintWarning(translate("A Tool Controller was not found. Default values are used which is dangerous. Please add a Tool Controller.\n"))
class CommandPathSanity:
@@ -91,10 +86,10 @@ class CommandPathSanity:
# check that the selection contains exactly what we want
selection = FreeCADGui.Selection.getSelection()
if len(selection) != 1:
FreeCAD.Console.PrintError(translate("Path_Sanity","Please select a path Project to check\n"))
FreeCAD.Console.PrintError(translate("Please select a path Project to check\n"))
return
if not(selection[0].TypeId == "Path::FeatureCompoundPython"):
FreeCAD.Console.PrintError(translate("Path_Sanity","Please select a path project to check\n"))
FreeCAD.Console.PrintError(translate("Please select a path project to check\n"))
return
# if everything is ok, execute

View File

@@ -28,15 +28,8 @@ from PySide import QtCore, QtGui
"""Path SimpleCopy command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_SimpleCopy", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class CommandPathSimpleCopy:
@@ -58,15 +51,15 @@ class CommandPathSimpleCopy:
selection = FreeCADGui.Selection.getSelection()
if len(selection) != 1:
FreeCAD.Console.PrintError(
translate("Path_SimpleCopy", "Please select exactly one path object\n"))
translate("Please select exactly one path object\n"))
return
if not(selection[0].isDerivedFrom("Path::Feature")):
FreeCAD.Console.PrintError(
translate("Path_SimpleCopy", "Please select exactly one path object\n"))
translate("Please select exactly one path object\n"))
return
FreeCAD.ActiveDocument.openTransaction(
translate("Path_SimpleCopy", "Simple Copy"))
translate("Simple Copy"))
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand(
'obj = FreeCAD.ActiveDocument.addObject("Path::Feature","' + selection[0].Name + '_copy")')

View File

@@ -27,15 +27,10 @@ import FreeCADGui
from FreeCAD import Vector
from PySide import QtCore, QtGui
import Part
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
# Qt tanslation handling
def translate(text, context = "Path_Stock", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class Stock:
@@ -105,8 +100,7 @@ class CommandPathStock:
return FreeCAD.ActiveDocument is not None
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(translate(
"PathStock", "Creates a 3D object to represent raw stock to mill the part out of"))
FreeCAD.ActiveDocument.openTransaction(translate("Creates a 3D object to represent raw stock to mill the part out of"))
FreeCADGui.addModule("PathScripts.PathStock")
snippet = '''
import FreeCADGui

View File

@@ -28,15 +28,8 @@ import Path
from PySide import QtCore, QtGui
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Stop", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class Stop:
def __init__(self,obj):
@@ -123,7 +116,7 @@ class CommandPathStop:
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(
translate("Path_Stop", "Add Optional or Mandatory Stop to the program"))
translate("Add Optional or Mandatory Stop to the program"))
FreeCADGui.addModule("PathScripts.PathStop")
snippet = '''
import Path

View File

@@ -49,15 +49,8 @@ __url__ = "http://www.freecadweb.org"
"""Path surface object and FreeCAD command"""
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_Surface", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ObjectSurface:
@@ -266,7 +259,7 @@ class ObjectSurface:
def execute(self, obj):
import MeshPart
FreeCAD.Console.PrintWarning(
translate("PathSurface", "Hold on. This might take a minute.\n"))
translate("Hold on. This might take a minute.\n"))
output = ""
if obj.Comment != "":
output += '(' + str(obj.Comment)+')\n'
@@ -305,7 +298,7 @@ class ObjectSurface:
import ocl
except:
FreeCAD.Console.PrintError(translate(
"PathSurface", "This operation requires OpenCamLib to be installed.\n"))
"This operation requires OpenCamLib to be installed.\n"))
return
if mesh.TypeId.startswith('Mesh'):
@@ -404,7 +397,7 @@ class CommandPathSurfacing:
zbottom = 0
FreeCAD.ActiveDocument.openTransaction(
translate("Path_Surfacing", "Create Surface"))
translate("Create Surface"))
FreeCADGui.addModule("PathScripts.PathSurface")
FreeCADGui.doCommand(
'obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Surface")')
@@ -516,12 +509,12 @@ class TaskPanel:
selection = FreeCADGui.Selection.getSelectionEx()
if len(selection) != 1:
FreeCAD.Console.PrintError(translate(
"PathSurface", "Please select a single solid object from the project tree\n"))
"Please select a single solid object from the project tree\n"))
return
if not len(selection[0].SubObjects) == 0:
FreeCAD.Console.PrintError(translate(
"PathSurface", "Please select a single solid object from the project tree\n"))
"Please select a single solid object from the project tree\n"))
return
sel = selection[0].Object
@@ -538,7 +531,7 @@ class TaskPanel:
else:
FreeCAD.Console.PrintError(
translate("PathSurface", "Cannot work with this object\n"))
translate("Cannot work with this object\n"))
return
self.obj.Proxy.addsurfacebase(self.obj, sel)

View File

@@ -29,14 +29,8 @@ from PathScripts import PathUtils
from PySide import QtCore, QtGui
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_ToolLenOffset", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class ToolLenOffset:
@@ -139,7 +133,7 @@ class CommandPathToolLenOffset:
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(
translate("Path_ToolLenOffset", "Create a Selection Plane object"))
translate("Create a Selection Plane object"))
FreeCADGui.addModule("PathScripts.PathToolLenOffset")
snippet = '''
import Path

View File

@@ -38,15 +38,8 @@ LOG_MODULE = 'PathToolLibraryManager'
PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE)
#PathLog.trackModule('PathToolLibraryManager')
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_ToolLibraryManager", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
# Tooltable XML readers
class FreeCADTooltableHandler(xml.sax.ContentHandler):

View File

@@ -26,13 +26,8 @@ import FreeCAD,FreeCADGui
from PySide import QtCore,QtGui
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_ToolTableEdit", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
class CommandPathToolTableEdit:
def GetResources(self):
@@ -45,7 +40,7 @@ class CommandPathToolTableEdit:
return not FreeCAD.ActiveDocument is None
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(translate("Path_ToolTableEdit","Edits a Tool Table in a selected Project"))
FreeCAD.ActiveDocument.openTransaction(translate("Edits a Tool Table in a selected Project"))
FreeCADGui.doCommand("from PathScripts import TooltableEditor")
FreeCADGui.doCommand("from PathScripts import PathUtils")
FreeCADGui.doCommand('machine = PathUtils.findMachine()')

View File

@@ -38,15 +38,9 @@ try:
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
def translate(text, context = "Path_ToolTableEditor", disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
# Tooltable XML readers