def insert(filename, docname): """called when freecad imports a file""" PathLog.track(filename) gfile = pythonopen(filename) gcode = gfile.read() gfile.close() # Regular expression to match tool changes in the format 'M6 Tn' p = re.compile("[mM]+?\s?0?6\s?T\d*\s") # split the gcode on tool changes paths = re.split("([mM]+?\s?0?6\s?T\d*\s)", gcode) # iterate the gcode sections and add customs for each toolnumber = 0 for path in paths: # if the section is a tool change, extract the tool number m = p.match(path) if m: toolnumber = int(m.group().split("T")[-1]) continue # Parse the gcode and throw away any empty lists gcode = parse(path) if len(gcode) == 0: continue # Create a custom and viewobject obj = PathCustom.Create("Custom") res = PathOpGui.CommandResources( "Custom", PathCustom.Create, PathCustomGui.TaskPanelOpPage, "Path_Custom", QT_TRANSLATE_NOOP("Path_Custom", "Custom"), "", "", ) obj.ViewObject.Proxy = PathOpGui.ViewProvider(obj.ViewObject, res) obj.ViewObject.Proxy.setDeleteObjectsOnReject(False) # Set the gcode and try to match a tool controller obj.Gcode = gcode obj.ToolController = matchToolController(obj, toolnumber) FreeCAD.ActiveDocument.recompute()
def SetupOperation(name, resName, objFactory, opPageClass, pixmap, menuText, toolTip, accelKey=None): '''SetupOperation(name, objFactory, opPageClass, pixmap, menuText, toolTip, accelKey=None) Creates an instance of CommandPathOp with the given parameters and registers the command with FreeCAD. When activated it creates a model with proxy (by invoking objFactory), assigns a view provider to it (see ViewProvider in this module) and starts the editor specifically for this operation (driven by opPageClass). This is an internal function that is automatically called by the initialisation code for each operation. It is not expected to be called manually. ''' import Adaptive2_rc import PathScripts.PathOpGui as PathOpGui res = PathOpGui.CommandResources(resName, objFactory, opPageClass, pixmap, menuText, accelKey, toolTip) command = PathOpGui.CommandPathOp(res) FreeCADGui.addCommand("Path_%s" % name.replace(' ', '_'), command) return command
# *************************************************************************** import FreeCAD import PathScripts.PathMillFace as PathMillFace import PathScripts.PathOpGui as PathOpGui import PathScripts.PathPocketBaseGui as PathPocketBaseGui from PySide import QtCore __title__ = "Path Face Mill Operation UI" __author__ = "sliptonic (Brad Collette)" __url__ = "https://www.freecadweb.org" __doc__ = "Face Mill operation page controller and command implementation." class TaskPanelOpPage(PathPocketBaseGui.TaskPanelOpPage): '''Page controller class for the face milling operation.''' def pocketFeatures(self): '''pocketFeatures() ... return FeatureFacing (see PathPocketBaseGui)''' return PathPocketBaseGui.FeatureFacing Command = PathOpGui.SetupOperation( 'MillFace', PathMillFace.Create, TaskPanelOpPage, 'Path-Face', QtCore.QT_TRANSLATE_NOOP("PathFace", "Face"), QtCore.QT_TRANSLATE_NOOP("PathFace", "Create a Facing Operation from a model or face"), PathMillFace.SetupProperties) FreeCAD.Console.PrintLog("Loading PathMillFaceGui... done\n")
__author__ = "dubstar-04 (Daniel Wood)" __url__ = "http://www.freecadweb.org" __doc__ = "Gui implementation for turning profiling operations." LOGLEVEL = False if LOGLEVEL: PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) PathLog.trackModule(PathLog.thisModule()) else: PathLog.setLevel(PathLog.Level.NOTICE, PathLog.thisModule()) class TaskPanelOpPage(PathTurnBaseGui.TaskPanelTurnBase): '''Page controller class for Turning operations.''' def setOpFields(self, obj): '''setFields(obj) ... transfers obj's property values to UI''' self.form.finishPasses.setEnabled(False) Command = PathOpGui.SetupOperation( 'TurnRough', PathTurnRough.Create, TaskPanelOpPage, 'Path-TurnRough', QtCore.QT_TRANSLATE_NOOP("PathTurnRough", "Turn Rough"), QtCore.QT_TRANSLATE_NOOP( "PathTurnRough", "Creates a Path Turning Roughing object from a features of a base object" ), PathTurnRough.SetupProperties) FreeCAD.Console.PrintLog("Loading PathTurnRoughGui... done\n")
import FreeCAD import PathScripts.PathOpGui as PathOpGui import PathScripts.PathProfile as PathProfile import PathScripts.PathProfileGui as PathProfileGui from PySide import QtCore __title__ = "Path Contour Operation UI (depreciated)" __author__ = "sliptonic (Brad Collette)" __url__ = "https://www.freecadweb.org" __doc__ = "Contour operation page controller and command implementation (depreciated)." class TaskPanelOpPage(PathProfileGui.TaskPanelOpPage): '''Psuedo page controller class for Profile operation, allowing for backward compatibility with pre-existing "Contour" operations.''' pass # Eclass Command = PathOpGui.SetupOperation( 'Profile', PathProfile.Create, TaskPanelOpPage, 'Path-Contour', QtCore.QT_TRANSLATE_NOOP("PathProfile", "Profile"), QtCore.QT_TRANSLATE_NOOP( "PathProfile", "Profile entire model, selected face(s) or selected edge(s)"), PathProfile.SetupProperties) FreeCAD.Console.PrintLog("Loading PathProfileContourGui... done\n")
return signals def updateVisibility(self): if self.form.algorithmSelect.currentText() == "OCL Dropcutter": self.form.boundBoxExtraOffsetX.setEnabled(True) self.form.boundBoxExtraOffsetY.setEnabled(True) self.form.boundBoxSelect.setEnabled(True) self.form.dropCutterDirSelect.setEnabled(True) self.form.stepOver.setEnabled(True) else: self.form.boundBoxExtraOffsetX.setEnabled(False) self.form.boundBoxExtraOffsetY.setEnabled(False) self.form.boundBoxSelect.setEnabled(False) self.form.dropCutterDirSelect.setEnabled(False) self.form.stepOver.setEnabled(False) def registerSignalHandlers(self, obj): self.form.algorithmSelect.currentIndexChanged.connect( self.updateVisibility) Command = PathOpGui.SetupOperation( 'Surface', PathSurface.Create, TaskPanelOpPage, 'Path-3DSurface', QtCore.QT_TRANSLATE_NOOP("Surface", "3D Surface"), QtCore.QT_TRANSLATE_NOOP("Surface", "Create a 3D Surface Operation from a model"), PathSurface.SetupProperties) FreeCAD.Console.PrintLog("Loading PathSurfaceGui... done\n")
def getFields(self, obj): '''getFields(obj) ... transfers values from UI to obj's properties''' self.updateToolController(obj, self.form.toolController) self.updateCoolant(obj, self.form.coolantController) def setFields(self, obj): '''setFields(obj) ... transfers obj's property values to UI''' self.setupToolController(obj, self.form.toolController) self.form.txtGCode.setText("\n".join(obj.Gcode)) self.setupCoolant(obj, self.form.coolantController) def getSignalsForUpdate(self, obj): '''getSignalsForUpdate(obj) ... return list of signals for updating obj''' signals = [] signals.append(self.form.toolController.currentIndexChanged) signals.append(self.form.coolantController.currentIndexChanged) self.form.txtGCode.textChanged.connect(self.setGCode) return signals def setGCode(self): self.obj.Gcode = self.form.txtGCode.toPlainText().splitlines() Command = PathOpGui.SetupOperation( 'Custom', PathCustom.Create, TaskPanelOpPage, 'Path_Custom', QtCore.QT_TRANSLATE_NOOP("Path_Custom", "Custom"), QtCore.QT_TRANSLATE_NOOP("Path_Custom", "Create custom gcode snippet"), PathCustom.SetupProperties) FreeCAD.Console.PrintLog("Loading PathCustomGui... done\n")
signals.append(self.form.joinMiter.clicked) signals.append(self.form.joinRound.clicked) signals.append(self.form.coolantController.currentIndexChanged) signals.append(self.form.direction.currentIndexChanged) signals.append(self.form.value_W.valueChanged) signals.append(self.form.value_h.valueChanged) return signals def registerSignalHandlers(self, obj): self.form.value_W.editingFinished.connect(self.updateWidth) self.form.value_h.editingFinished.connect(self.updateExtraDepth) def taskPanelBaseGeometryPage(self, obj, features): """taskPanelBaseGeometryPage(obj, features) ... return page for adding base geometries.""" return TaskPanelBaseGeometryPage(obj, features) Command = PathOpGui.SetupOperation( "Deburr", PathDeburr.Create, TaskPanelOpPage, "Path_Deburr", QT_TRANSLATE_NOOP("Path_Deburr", "Deburr"), QT_TRANSLATE_NOOP( "Path_Deburr", "Creates a Deburr Path along Edges or around Faces" ), PathDeburr.SetupProperties, ) FreeCAD.Console.PrintLog("Loading PathDeburrGui... done\n")
obj.StepOver = self.form.StepOver.value() obj.Tolerance = 1.0 * self.form.Tolerance.value() / 100.0 obj.HelixAngle = self.form.HelixAngle.value() obj.HelixDiameterLimit = self.form.HelixDiameterLimit.value() obj.LiftDistance = self.form.LiftDistance.value() if hasattr(obj, 'KeepToolDownRatio'): obj.KeepToolDownRatio = self.form.KeepToolDownRatio.value() if hasattr(obj, 'StockToLeave'): obj.StockToLeave = self.form.StockToLeave.value() obj.ForceInsideOut = self.form.ForceInsideOut.isChecked() obj.Stopped = self.form.StopButton.isChecked() if (obj.Stopped): self.form.StopButton.setChecked(False) # reset the button obj.StopProcessing = True self.updateToolController(obj, self.form.ToolController) obj.setEditorMode('AdaptiveInputState', 2) # hide this property obj.setEditorMode('AdaptiveOutputState', 2) # hide this property obj.setEditorMode('StopProcessing', 2) # hide this property obj.setEditorMode('Stopped', 2) # hide this property Command = PathOpGui.SetupOperation( 'Adaptive', PathAdaptive.Create, TaskPanelOpPage, 'Path-Adaptive', QtCore.QT_TRANSLATE_NOOP("PathAdaptive", "Adaptive"), QtCore.QT_TRANSLATE_NOOP("PathPocket", "Adaptive clearing and profiling"))
self.form.boundaryAdjustment.show() self.form.cutPattern_label.show() self.form.boundaryAdjustment_label.show() if self.form.cutPattern.currentData() == "None": self.form.stepOver.hide() self.form.stepOver_label.hide() else: self.form.stepOver.show() self.form.stepOver_label.show() self.form.sampleInterval.hide() self.form.sampleInterval_label.hide() def registerSignalHandlers(self, obj): self.form.algorithmSelect.currentIndexChanged.connect( self.updateVisibility) self.form.cutPattern.currentIndexChanged.connect(self.updateVisibility) Command = PathOpGui.SetupOperation( "Waterline", PathWaterline.Create, TaskPanelOpPage, "Path_Waterline", QT_TRANSLATE_NOOP("Path_Waterline", "Waterline"), QT_TRANSLATE_NOOP("Path_Waterline", "Create a Waterline Operation from a model"), PathWaterline.SetupProperties, ) FreeCAD.Console.PrintLog("Loading PathWaterlineGui... done\n")
# *************************************************************************** import FreeCAD import PathScripts.PathOpGui as PathOpGui import PathScripts.PathProfileBaseGui as PathProfileBaseGui import PathScripts.PathProfileContour as PathProfileContour from PySide import QtCore __title__ = "Path Contour Operation UI" __author__ = "sliptonic (Brad Collette)" __url__ = "http://www.freecadweb.org" __doc__ = "Contour operation page controller and command implementation." class TaskPanelOpPage(PathProfileBaseGui.TaskPanelOpPage): '''Page controller for the contour operation UI.''' def profileFeatures(self): '''profileFeatues() ... return 0 - profile doesn't support any of the optional UI features.''' return 0 Command = PathOpGui.SetupOperation( 'Contour', PathProfileContour.Create, TaskPanelOpPage, 'Path-Contour', QtCore.QT_TRANSLATE_NOOP("PathProfileContour", "Contour"), QtCore.QT_TRANSLATE_NOOP("PathProfileContour", "Creates a Contour Path for the Base Object "), PathProfileContour.SetupProperties) FreeCAD.Console.PrintLog("Loading PathProfileContourGui... done\n")
("offsetPattern", "OffsetPattern"), ("boundaryShape", "BoundaryShape"), ] enumTups = PathMillFace.ObjectFace.propertyEnumerations(dataType="raw") enumTups.update( PathPocketShape.ObjectPocket.pocketPropertyEnumerations(dataType="raw") ) self.populateCombobox(form, enumTups, comboToPropertyMap) return form def pocketFeatures(self): """pocketFeatures() ... return FeatureFacing (see PathPocketBaseGui)""" return PathPocketBaseGui.FeatureFacing Command = PathOpGui.SetupOperation( "MillFace", PathMillFace.Create, TaskPanelOpPage, "Path_Face", QT_TRANSLATE_NOOP("Path_MillFace", "Face"), QT_TRANSLATE_NOOP( "Path_MillFace", "Create a Facing Operation from a model or face" ), PathMillFace.SetupProperties, ) FreeCAD.Console.PrintLog("Loading PathMillFaceGui... done\n")
# * * # *************************************************************************** import FreeCAD import PathScripts.PathOpGui as PathOpGui import PathScripts.PathPocket as PathPocket import PathScripts.PathPocketBaseGui as PathPocketBaseGui from PySide import QtCore __title__ = "Path Pocket Operation UI" __author__ = "sliptonic (Brad Collette)" __url__ = "http://www.freecadweb.org" __doc__ = "Pocket operation page controller and command implementation." class TaskPanelOpPage(PathPocketBaseGui.TaskPanelOpPage): '''Page controller class for Pocket operation''' def pocketFeatures(self): '''pocketFeatures() ... return FeaturePocket (see PathPocketBaseGui)''' return PathPocketBaseGui.FeaturePocket Command = PathOpGui.SetupOperation('Pocket 3D', PathPocket.Create, TaskPanelOpPage, 'Path-3DPocket', QtCore.QT_TRANSLATE_NOOP("PathPocket", "3D Pocket"), QtCore.QT_TRANSLATE_NOOP("PathPocket", "Creates a Path 3D Pocket object from a face or faces")) FreeCAD.Console.PrintLog("Loading PathPocketGui... done\n")
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) __title__ = "Path Pocket Operation UI" __author__ = "sliptonic (Brad Collette)" __url__ = "https://www.freecadweb.org" __doc__ = "Pocket operation page controller and command implementation." class TaskPanelOpPage(PathPocketBaseGui.TaskPanelOpPage): """Page controller class for Pocket operation""" def pocketFeatures(self): """pocketFeatures() ... return FeaturePocket (see PathPocketBaseGui)""" return PathPocketBaseGui.FeaturePocket Command = PathOpGui.SetupOperation( "Pocket3D", PathPocket.Create, TaskPanelOpPage, "Path_3DPocket", QT_TRANSLATE_NOOP("Path_Pocket3D", "3D Pocket"), QT_TRANSLATE_NOOP( "Path_Pocket3D", "Creates a Path 3D Pocket object from a face or faces" ), PathPocket.SetupProperties, ) FreeCAD.Console.PrintLog("Loading PathPocketGui... done\n")
self.form.colinearFilter.setValue(obj.Colinear) self.setupToolController(obj, self.form.toolController) self.setupCoolant(obj, self.form.coolantController) def getSignalsForUpdate(self, obj): """getSignalsForUpdate(obj) ... return list of signals for updating obj""" signals = [] signals.append(self.form.discretize.editingFinished) signals.append(self.form.colinearFilter.editingFinished) signals.append(self.form.toolController.currentIndexChanged) signals.append(self.form.coolantController.currentIndexChanged) return signals def taskPanelBaseGeometryPage(self, obj, features): """taskPanelBaseGeometryPage(obj, features) ... return page for adding base geometries.""" return TaskPanelBaseGeometryPage(obj, features) Command = PathOpGui.SetupOperation( "Vcarve", PathVcarve.Create, TaskPanelOpPage, "Path_Vcarve", QtCore.QT_TRANSLATE_NOOP("Path_Vcarve", "Vcarve"), QtCore.QT_TRANSLATE_NOOP("Path_Vcarve", "Creates a medial line engraving path"), PathVcarve.SetupProperties, ) FreeCAD.Console.PrintLog("Loading PathVcarveGui... done\n")
import PathScripts.PathProfile as PathProfile import PathScripts.PathProfileGui as PathProfileGui from PySide.QtCore import QT_TRANSLATE_NOOP __title__ = "Path Contour Operation UI (depreciated)" __author__ = "sliptonic (Brad Collette)" __url__ = "https://www.freecadweb.org" __doc__ = "Contour operation page controller and command implementation (deprecated)." class TaskPanelOpPage(PathProfileGui.TaskPanelOpPage): """Psuedo page controller class for Profile operation, allowing for backward compatibility with pre-existing "Contour" operations.""" pass Command = PathOpGui.SetupOperation( "Profile", PathProfile.Create, TaskPanelOpPage, "Path_Contour", QT_TRANSLATE_NOOP("Path_Profile", "Profile"), QT_TRANSLATE_NOOP( "Path_Profile", "Profile entire model, selected face(s) or selected edge(s)"), PathProfile.SetupProperties, ) FreeCAD.Console.PrintLog("Loading PathProfileContourGui... done\n")
def getSignalsForUpdate(self, obj): '''getSignalsForUpdate(obj) ... return list of signals for updating obj''' signals = [] signals.append(self.form.toolController.currentIndexChanged) signals.append(self.form.PointCountX.valueChanged) signals.append(self.form.PointCountY.valueChanged) signals.append(self.form.OutputFileName.editingFinished) signals.append(self.form.Xoffset.valueChanged) signals.append(self.form.Yoffset.valueChanged) self.form.SetOutputFileName.clicked.connect(self.SetOutputFileName) return signals def SetOutputFileName(self): filename = QtGui.QFileDialog.getSaveFileName( self.form, translate("Path_Probe", "Select Output File"), None, translate("Path_Probe", "All Files (*.*)")) if filename and filename[0]: self.obj.OutputFileName = str(filename[0]) self.setFields(self.obj) Command = PathOpGui.SetupOperation( 'Probe', PathProbe.Create, TaskPanelOpPage, 'Path_Probe', QtCore.QT_TRANSLATE_NOOP("Probe", "Probe"), QtCore.QT_TRANSLATE_NOOP("Probe", "Create a Probing Grid from a job stock"), PathProbe.SetupProperties) FreeCAD.Console.PrintLog("Loading PathProbeGui... done\n")
obj.UseOutline = self.form.useOutline.isChecked() obj.Stopped = self.form.StopButton.isChecked() if obj.Stopped: self.form.StopButton.setChecked(False) # reset the button obj.StopProcessing = True self.updateToolController(obj, self.form.ToolController) self.updateCoolant(obj, self.form.coolantController) obj.setEditorMode("AdaptiveInputState", 2) # hide this property obj.setEditorMode("AdaptiveOutputState", 2) # hide this property obj.setEditorMode("StopProcessing", 2) # hide this property obj.setEditorMode("Stopped", 2) # hide this property def taskPanelBaseLocationPage(self, obj, features): if not hasattr(self, "extensionsPanel"): self.extensionsPanel = PathFeatureExtensionsGui.TaskPanelExtensionPage( obj, features) # pylint: disable=attribute-defined-outside-init return self.extensionsPanel Command = PathOpGui.SetupOperation( "Adaptive", PathAdaptive.Create, TaskPanelOpPage, "Path_Adaptive", QtCore.QT_TRANSLATE_NOOP("Path_Adaptive", "Adaptive"), QtCore.QT_TRANSLATE_NOOP("Path_Adaptive", "Adaptive clearing and profiling"), PathAdaptive.SetupProperties, )
self.updateToolController(obj, self.form.toolController) self.updateCoolant(obj, self.form.coolantController) def setFields(self, obj): '''setFields(obj) ... transfers obj's property values to UI''' self.form.startVertex.setValue(obj.StartVertex) self.setupToolController(obj, self.form.toolController) self.setupCoolant(obj, self.form.coolantController) def getSignalsForUpdate(self, obj): '''getSignalsForUpdate(obj) ... return list of signals for updating obj''' signals = [] signals.append(self.form.startVertex.editingFinished) signals.append(self.form.toolController.currentIndexChanged) signals.append(self.form.coolantController.currentIndexChanged) return signals def taskPanelBaseGeometryPage(self, obj, features): '''taskPanelBaseGeometryPage(obj, features) ... return page for adding base geometries.''' return TaskPanelBaseGeometryPage(obj, features) Command = PathOpGui.SetupOperation( 'Engrave', PathEngrave.Create, TaskPanelOpPage, 'Path-Engrave', QtCore.QT_TRANSLATE_NOOP("PathEngrave", "Engrave"), QtCore.QT_TRANSLATE_NOOP( "PathEngrave", "Creates an Engraving Path around a Draft ShapeString"), PathEngrave.SetupProperties) FreeCAD.Console.PrintLog("Loading PathEngraveGui... done\n")
# Search using currentData and return if found newindex = combo.findData(name) if newindex >= 0: combo.setCurrentIndex(newindex) return # if not found, search using current text newindex = combo.findText(name, QtCore.Qt.MatchFixedString) if newindex >= 0: combo.setCurrentIndex(newindex) return # not found, return unchanged combo.setCurrentIndex(0) return Command = PathOpGui.SetupOperation( "Slot", PathSlot.Create, TaskPanelOpPage, "Path_Slot", QtCore.QT_TRANSLATE_NOOP("Path_Slot", "Slot"), QtCore.QT_TRANSLATE_NOOP( "Path_Slot", "Create a Slot operation from selected geometry or custom points." ), PathSlot.SetupProperties, ) FreeCAD.Console.PrintLog("Loading PathSlotGui... done\n")
self.form.buttonDisable.clicked.connect(self.extensionsDisable) self.form.buttonEnable.clicked.connect(self.extensionsEnable) self.model.itemChanged.connect(self.updateItemEnabled) self.selectionModel = self.form.extensionTree.selectionModel() # pylint: disable=attribute-defined-outside-init self.selectionModel.selectionChanged.connect(self.selectionChanged) self.selectionChanged() class TaskPanelOpPage(PathPocketBaseGui.TaskPanelOpPage): '''Page controller class for Pocket operation''' def pocketFeatures(self): '''pocketFeatures() ... return FeaturePocket (see PathPocketBaseGui)''' return PathPocketBaseGui.FeaturePocket | PathPocketBaseGui.FeatureOutline def taskPanelBaseLocationPage(self, obj, features): if not hasattr(self, 'extensionsPanel'): self.extensionsPanel = TaskPanelExtensionPage(obj, features) # pylint: disable=attribute-defined-outside-init return self.extensionsPanel Command = PathOpGui.SetupOperation('Pocket Shape', PathPocketShape.Create, TaskPanelOpPage, 'Path_Pocket', QtCore.QT_TRANSLATE_NOOP("Path_Pocket", "Pocket Shape"), QtCore.QT_TRANSLATE_NOOP("Path_Pocket", "Creates a Path Pocket object from a face or faces"), PathPocketShape.SetupProperties) FreeCAD.Console.PrintLog("Loading PathPocketShapeGui... done\n")
signals.append(self.form.opDirection.currentIndexChanged) signals.append(self.form.opPasses.editingFinished) signals.append(self.form.leadInOut.stateChanged) signals.append(self.form.toolController.currentIndexChanged) return signals def registerSignalHandlers(self, obj): self.form.threadType.currentIndexChanged.connect( self._updateFromThreadType) self.form.threadName.currentIndexChanged.connect( self._updateFromThreadName) self.form.threadFit.valueChanged.connect(self._updateFromThreadName) Command = PathOpGui.SetupOperation( "ThreadMilling", PathThreadMilling.Create, TaskPanelOpPage, "Path_ThreadMilling", QT_TRANSLATE_NOOP("Path_ThreadMilling", "Thread Milling"), QT_TRANSLATE_NOOP( "Path_ThreadMilling", "Creates a Path Thread Milling operation from features of a base object", ), PathThreadMilling.SetupProperties, ) FreeCAD.Console.PrintLog("Loading PathThreadMillingGui ... done\n")
import FreeCAD import PathScripts.PathOpGui as PathOpGui import PathScripts.PathProfileBaseGui as PathProfileBaseGui import PathScripts.PathProfileFaces as PathProfileFaces from PySide import QtCore __title__ = "Path Profile based on faces Operation UI" __author__ = "sliptonic (Brad Collette)" __url__ = "http://www.freecadweb.org" __doc__ = "Profile based on faces operation page controller and command implementation." class TaskPanelOpPage(PathProfileBaseGui.TaskPanelOpPage): '''Page controller for profile based on faces operation.''' def profileFeatures(self): '''profileFeatures() ... return FeatureSide | FeatureProcessing. See PathProfileBaseGui.py for details.''' return PathProfileBaseGui.FeatureSide | PathProfileBaseGui.FeatureProcessing Command = PathOpGui.SetupOperation( 'Profile Faces', PathProfileFaces.Create, TaskPanelOpPage, 'Path-Profile-Face', QtCore.QT_TRANSLATE_NOOP("PathProfile", "Face Profile"), QtCore.QT_TRANSLATE_NOOP("PathProfile", "Profile based on face or faces"), PathProfileFaces.SetupProperties) FreeCAD.Console.PrintLog("Loading PathProfileFacesGui... done\n")
self.setupToolController(obj, self.form.toolController) self.form.joinRound.setChecked('Round' == obj.Join) self.form.joinMiter.setChecked('Miter' == obj.Join) self.form.joinFrame.hide() def updateWidth(self): PathGui.updateInputField(self.obj, 'Width', self.form.value_W) def updateExtraDepth(self): PathGui.updateInputField(self.obj, 'ExtraDepth', self.form.value_h) def getSignalsForUpdate(self, obj): signals = [] signals.append(self.form.joinMiter.clicked) signals.append(self.form.joinRound.clicked) return signals def registerSignalHandlers(self, obj): self.form.value_W.editingFinished.connect(self.updateWidth) self.form.value_h.editingFinished.connect(self.updateExtraDepth) Command = PathOpGui.SetupOperation( 'Deburr', PathDeburr.Create, TaskPanelOpPage, 'Path-Deburr', QtCore.QT_TRANSLATE_NOOP("PathDeburr", "Deburr"), QtCore.QT_TRANSLATE_NOOP( "PathDeburr", "Creates a Deburr Path along Edges or around Faces"), PathDeburr.SetupProperties) FreeCAD.Console.PrintLog("Loading PathDeburrGui... done\n")
FreeCAD.Units.Quantity(obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString) def getSignalsForUpdate(self, obj): """getSignalsForUpdate(obj) ... return list of signals for updating obj""" signals = [] signals.append(self.form.stepOverPercent.editingFinished) signals.append(self.form.extraOffset.editingFinished) signals.append(self.form.direction.currentIndexChanged) signals.append(self.form.startSide.currentIndexChanged) signals.append(self.form.toolController.currentIndexChanged) signals.append(self.form.coolantController.currentIndexChanged) return signals Command = PathOpGui.SetupOperation( "Helix", PathHelix.Create, TaskPanelOpPage, "Path_Helix", QT_TRANSLATE_NOOP("Path_Helix", "Helix"), QT_TRANSLATE_NOOP( "Path_Helix", "Creates a Path Helix object from a features of a base object"), PathHelix.SetupProperties, ) FreeCAD.Console.PrintLog("Loading PathHelixGui... done\n")
self.form.sampleInterval.show() self.form.sampleInterval_label.show() elif Algorithm == 'Experimental': self.form.cutPattern.show() self.form.boundaryAdjustment.show() self.form.cutPattern_label.show() self.form.boundaryAdjustment_label.show() if self.form.cutPattern.currentText() == 'None': self.form.stepOver.hide() self.form.stepOver_label.hide() else: self.form.stepOver.show() self.form.stepOver_label.show() self.form.sampleInterval.hide() self.form.sampleInterval_label.hide() def registerSignalHandlers(self, obj): self.form.algorithmSelect.currentIndexChanged.connect( self.updateVisibility) self.form.cutPattern.currentIndexChanged.connect(self.updateVisibility) Command = PathOpGui.SetupOperation( 'Waterline', PathWaterline.Create, TaskPanelOpPage, 'Path-Waterline', QtCore.QT_TRANSLATE_NOOP("Waterline", "Waterline"), QtCore.QT_TRANSLATE_NOOP("Waterline", "Create a Waterline Operation from a model"), PathWaterline.SetupProperties) FreeCAD.Console.PrintLog("Loading PathWaterlineGui... done\n")
def setFields(self, obj): '''setFields(obj) ... transfers obj's property values to UI''' PathLog.track() self.form.stepOverPercent.setValue(obj.StepOver) self.selectInComboBox(obj.Direction, self.form.direction) self.selectInComboBox(obj.StartSide, self.form.startSide) self.setupToolController(obj, self.form.toolController) def getSignalsForUpdate(self, obj): '''getSignalsForUpdate(obj) ... return list of signals for updating obj''' signals = [] signals.append(self.form.stepOverPercent.editingFinished) signals.append(self.form.direction.currentIndexChanged) signals.append(self.form.startSide.currentIndexChanged) signals.append(self.form.toolController.currentIndexChanged) return signals Command = PathOpGui.SetupOperation('Helix', PathHelix.Create, TaskPanelOpPage, 'Path-Helix', QtCore.QT_TRANSLATE_NOOP("PathHelix", "Helix"), QtCore.QT_TRANSLATE_NOOP("PathHelix", "Creates a Path Helix object from a features of a base object")) FreeCAD.Console.PrintLog("Loading PathHelixGui... done\n")
self.setupToolController(obj, self.form.toolController) def getSignalsForUpdate(self, obj): '''getSignalsForUpdate(obj) ... return list of signals which cause the receiver to update the model''' signals = [] signals.append(self.form.peckRetractHeight.editingFinished) signals.append(self.form.peckDepth.editingFinished) signals.append(self.form.dwellTime.editingFinished) signals.append(self.form.dwellEnabled.stateChanged) signals.append(self.form.peckEnabled.stateChanged) signals.append(self.form.useTipLength.stateChanged) signals.append(self.form.toolController.currentIndexChanged) return signals def updateData(self, obj, prop): if prop in ['PeckDepth', 'RetractHeight'] and not prop in ['Base', 'Disabled']: self.updateQuantitySpinBoxes() Command = PathOpGui.SetupOperation('Drilling', PathDrilling.Create, TaskPanelOpPage, 'Path-Drilling', QtCore.QT_TRANSLATE_NOOP("PathDrilling", "Drilling"), QtCore.QT_TRANSLATE_NOOP("PathDrilling", "Creates a Path Drilling object from a features of a base object"), PathDrilling.SetupProperties) FreeCAD.Console.PrintLog("Loading PathDrillingGui... done\n")
FreeCAD.Units.Length).UserString) self.setupToolController(obj, self.form.toolController) self.form.joinRound.setChecked('Round' == obj.Join) self.form.joinMiter.setChecked('Miter' == obj.Join) self.form.joinFrame.hide() def updateWidth(self): PathGui.updateInputField(self.obj, 'Width', self.form.value_W) def updateExtraDepth(self): PathGui.updateInputField(self.obj, 'ExtraDepth', self.form.value_h) def getSignalsForUpdate(self, obj): signals = [] signals.append(self.form.joinMiter.clicked) signals.append(self.form.joinRound.clicked) return signals def registerSignalHandlers(self, obj): self.form.value_W.editingFinished.connect(self.updateWidth) self.form.value_h.editingFinished.connect(self.updateExtraDepth) Command = PathOpGui.SetupOperation( 'Chamfer', PathChamfer.Create, TaskPanelOpPage, 'Path-Chamfer', QtCore.QT_TRANSLATE_NOOP("PathChamfer", "Chamfer"), QtCore.QT_TRANSLATE_NOOP( "PathChamfer", "Creates a Chamfer Path along Edges or around Faces")) FreeCAD.Console.PrintLog("Loading PathChamferGui... done\n")
# *************************************************************************** import FreeCAD import PathScripts.PathOpGui as PathOpGui import PathScripts.PathProfileBaseGui as PathProfileBaseGui import PathScripts.PathProfileEdges as PathProfileEdges from PySide import QtCore __title__ = "Path Profile based on edges Operation UI" __author__ = "sliptonic (Brad Collette)" __url__ = "http://www.freecadweb.org" __doc__ = "Profile based on edges operation page controller and command implementation." class TaskPanelOpPage(PathProfileBaseGui.TaskPanelOpPage): '''Page controller for profile based on edges operation.''' def profileFeatures(self): '''profileFeatures() ... return FeatureSide See PathProfileBaseGui.py for details.''' return PathProfileBaseGui.FeatureSide Command = PathOpGui.SetupOperation( 'Profile Edges', PathProfileEdges.Create, TaskPanelOpPage, 'Path-Profile-Edges', QtCore.QT_TRANSLATE_NOOP("PathProfile", "Edge Profile"), QtCore.QT_TRANSLATE_NOOP("PathProfile", "Profile based on edges")) FreeCAD.Console.PrintLog("Loading PathProfileEdgesGui... done\n")