예제 #1
0
    def __init__(self, obj):
        #        obj.addProperty("App::PropertyFile", "PostProcessor", "CodeOutput", "Select the Post Processor file for this project")
        obj.addProperty("App::PropertyFile", "OutputFile", "CodeOutput", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project"))
        obj.OutputFile = PathPreferences.defaultOutputFile()
        obj.setEditorMode("OutputFile", 0)  # set to default mode

        obj.addProperty("App::PropertyString", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional description for this job"))
        obj.addProperty("App::PropertyEnumeration", "PostProcessor", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Select the Post Processor"))
        obj.PostProcessor = PathPreferences.allEnabledPostProcessors([''])
        obj.PostProcessor = PathPreferences.defaultPostProcessor()
        obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)"))
        obj.PostProcessorArgs = PathPreferences.defaultPostProcessorArgs()
        obj.addProperty("App::PropertyString",    "MachineName", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Name of the Machine that will use the CNC program"))

        obj.addProperty("Path::PropertyTooltable", "Tooltable", "Base", QtCore.QT_TRANSLATE_NOOP("App::Property","The tooltable used for this CNC program"))

        obj.addProperty("App::PropertyEnumeration", "MachineUnits", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Units that the machine works in, ie Metric or Inch"))
        obj.MachineUnits = ['Metric', 'Inch']

        obj.addProperty("App::PropertyDistance", "X_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel"))
        obj.addProperty("App::PropertyDistance", "Y_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel"))
        obj.addProperty("App::PropertyDistance", "Z_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel"))

        obj.addProperty("App::PropertyDistance", "X_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel"))
        obj.addProperty("App::PropertyDistance", "Y_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel"))
        obj.addProperty("App::PropertyDistance", "Z_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel"))

        obj.addProperty("App::PropertyLink", "Base", "Base", "The base object for all operations")

        obj.Proxy = self

        if FreeCAD.GuiUp:
            ViewProviderJob(obj.ViewObject)
예제 #2
0
 def saveStockSettings(self):
     if self.form.stockGroup.isChecked():
         attrs = {}
         attrs['version'] = 1
         typ = [PathStock.StockType.CreateBox, PathStock.StockType.CreateCylinder, PathStock.StockType.FromBase][self.form.stock.currentIndex()]
         attrs['create'] = typ
         if typ == PathStock.StockType.CreateBox:
             attrs['length'] = FreeCAD.Units.Quantity(self.form.stockBoxLength.text()).UserString
             attrs['width'] = FreeCAD.Units.Quantity(self.form.stockBoxWidth.text()).UserString
             attrs['height'] = FreeCAD.Units.Quantity(self.form.stockBoxHeight.text()).UserString
         if typ == PathStock.StockType.CreateCylinder:
             attrs['radius'] = FreeCAD.Units.Quantity(self.form.stockCylinderRadius.text()).UserString
             attrs['height'] = FreeCAD.Units.Quantity(self.form.stockCylinderHeight.text()).UserString
         if typ == PathStock.StockType.FromBase:
             attrs['xneg'] = FreeCAD.Units.Quantity(self.form.stockExtXneg.text()).UserString
             attrs['xpos'] = FreeCAD.Units.Quantity(self.form.stockExtXpos.text()).UserString
             attrs['yneg'] = FreeCAD.Units.Quantity(self.form.stockExtYneg.text()).UserString
             attrs['ypos'] = FreeCAD.Units.Quantity(self.form.stockExtYpos.text()).UserString
             attrs['zneg'] = FreeCAD.Units.Quantity(self.form.stockExtZneg.text()).UserString
             attrs['zpos'] = FreeCAD.Units.Quantity(self.form.stockExtZpos.text()).UserString
         if self.form.stockPlacementGroup.isChecked():
             angle = FreeCAD.Units.Quantity(self.form.stockAngle.text()).Value
             axis = FreeCAD.Vector(self.form.stockAxisX.value(), self.form.stockAxisY.value(), self.form.stockAxisZ.value())
             rot = FreeCAD.Rotation(axis, angle)
             attrs['rotX'] = rot.Q[0]
             attrs['rotY'] = rot.Q[1]
             attrs['rotZ'] = rot.Q[2]
             attrs['rotW'] = rot.Q[3]
             attrs['posX'] = FreeCAD.Units.Quantity(self.form.stockPositionX.text()).Value
             attrs['posY'] = FreeCAD.Units.Quantity(self.form.stockPositionY.text()).Value
             attrs['posZ'] = FreeCAD.Units.Quantity(self.form.stockPositionZ.text()).Value
         PathPreferences.setDefaultStockTemplate(json.dumps(attrs))
     else:
         PathPreferences.setDefaultStockTemplate('')
예제 #3
0
 def saveStockSettings(self):
     if self.form.stockGroup.isChecked():
         attrs = {}
         attrs['version'] = 1
         typ = [PathStock.StockType.CreateBox, PathStock.StockType.CreateCylinder, PathStock.StockType.FromBase][self.form.stock.currentIndex()]
         attrs['create'] = typ
         if typ == PathStock.StockType.CreateBox:
             attrs['length'] = FreeCAD.Units.Quantity(self.form.stockBoxLength.text()).UserString
             attrs['width'] = FreeCAD.Units.Quantity(self.form.stockBoxWidth.text()).UserString
             attrs['height'] = FreeCAD.Units.Quantity(self.form.stockBoxHeight.text()).UserString
         if typ == PathStock.StockType.CreateCylinder:
             attrs['radius'] = FreeCAD.Units.Quantity(self.form.stockCylinderRadius.text()).UserString
             attrs['height'] = FreeCAD.Units.Quantity(self.form.stockCylinderHeight.text()).UserString
         if typ == PathStock.StockType.FromBase:
             attrs['xneg'] = FreeCAD.Units.Quantity(self.form.stockExtXneg.text()).UserString
             attrs['xpos'] = FreeCAD.Units.Quantity(self.form.stockExtXpos.text()).UserString
             attrs['yneg'] = FreeCAD.Units.Quantity(self.form.stockExtYneg.text()).UserString
             attrs['ypos'] = FreeCAD.Units.Quantity(self.form.stockExtYpos.text()).UserString
             attrs['zneg'] = FreeCAD.Units.Quantity(self.form.stockExtZneg.text()).UserString
             attrs['zpos'] = FreeCAD.Units.Quantity(self.form.stockExtZpos.text()).UserString
         if self.form.stockPlacementGroup.isChecked():
             angle = FreeCAD.Units.Quantity(self.form.stockAngle.text()).Value
             axis = FreeCAD.Vector(self.form.stockAxisX.value(), self.form.stockAxisY.value(), self.form.stockAxisZ.value())
             rot = FreeCAD.Rotation(axis, angle)
             attrs['rotX'] = rot.Q[0]
             attrs['rotY'] = rot.Q[1]
             attrs['rotZ'] = rot.Q[2]
             attrs['rotW'] = rot.Q[3]
             attrs['posX'] = FreeCAD.Units.Quantity(self.form.stockPositionX.text()).Value
             attrs['posY'] = FreeCAD.Units.Quantity(self.form.stockPositionY.text()).Value
             attrs['posZ'] = FreeCAD.Units.Quantity(self.form.stockPositionZ.text()).Value
         PathPreferences.setDefaultStockTemplate(json.dumps(attrs))
     else:
         PathPreferences.setDefaultStockTemplate('')
예제 #4
0
    def loadSettings(self):
        self.form.leDefaultFilePath.setText(PathPreferences.defaultFilePath())
        self.form.leDefaultJobTemplate.setText(PathPreferences.defaultJobTemplate())

        blacklist = PathPreferences.postProcessorBlacklist()
        for processor in PathPreferences.allAvailablePostProcessors():
            item = QtGui.QListWidgetItem(processor)
            if processor in blacklist:
                item.setCheckState(QtCore.Qt.CheckState.Unchecked)
            else:
                item.setCheckState(QtCore.Qt.CheckState.Checked)
            item.setFlags( QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled | QtCore.Qt.ItemFlag.ItemIsUserCheckable)
            self.form.postProcessorList.addItem(item)
        self.verifyAndUpdateDefaultPostProcessorWith(PathPreferences.defaultPostProcessor())

        self.form.defaultPostProcessorArgs.setText(PathPreferences.defaultPostProcessorArgs())

        geomTol = Units.Quantity(PathPreferences.defaultGeometryTolerance(), Units.Length)
        self.form.geometryTolerance.setText(geomTol.UserString)
        self.form.curveAccuracy.setText(Units.Quantity(PathPreferences.defaultLibAreaCurveAccuracy(), Units.Length).UserString)

        self.form.leOutputFile.setText(PathPreferences.defaultOutputFile())
        self.selectComboEntry(self.form.cboOutputPolicy, PathPreferences.defaultOutputPolicy())

        self.form.tbDefaultFilePath.clicked.connect(self.browseDefaultFilePath)
        self.form.tbDefaultJobTemplate.clicked.connect(self.browseDefaultJobTemplate)
        self.form.postProcessorList.itemEntered.connect(self.setProcessorListTooltip)
        self.form.postProcessorList.itemChanged.connect(self.verifyAndUpdateDefaultPostProcessor)
        self.form.defaultPostProcessor.currentIndexChanged.connect(self.updateDefaultPostProcessorToolTip)
        self.form.tbOutputFile.clicked.connect(self.browseOutputFile)

        self.loadStockSettings()
예제 #5
0
    def __init__(self, obj):
        obj.addProperty("App::PropertyFile", "PostProcessorOutputFile", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project"))
        obj.PostProcessorOutputFile = PathPreferences.defaultOutputFile()
        obj.setEditorMode("PostProcessorOutputFile", 0)  # set to default mode

        obj.addProperty("App::PropertyEnumeration", "PostProcessor", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Select the Post Processor"))
        obj.PostProcessor = postProcessors = PathPreferences.allEnabledPostProcessors()
        defaultPostProcessor = PathPreferences.defaultPostProcessor()
        # Check to see if default post processor hasn't been 'lost' (This can happen when Macro dir has changed)
        if defaultPostProcessor in postProcessors:
            obj.PostProcessor = defaultPostProcessor
        else:
            obj.PostProcessor = postProcessors[0]
        obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)"))
        obj.PostProcessorArgs = PathPreferences.defaultPostProcessorArgs()

        obj.addProperty("App::PropertyString", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional description for this job"))
        obj.addProperty("App::PropertyDistance", "GeometryTolerance", "Geometry",
                QtCore.QT_TRANSLATE_NOOP("App::Property", "For computing Paths; smaller increases accuracy, but slows down computation"))
        obj.GeometryTolerance = PathPreferences.defaultGeometryTolerance()

        obj.addProperty("App::PropertyLink", "Base", "Base", "The base object for all operations")

        obj.Proxy = self

        if FreeCAD.GuiUp:
            ViewProviderJob(obj.ViewObject)
예제 #6
0
    def __init__(self, obj):
        #        obj.addProperty("App::PropertyFile", "PostProcessor", "CodeOutput", "Select the Post Processor file for this project")
        obj.addProperty("App::PropertyFile", "OutputFile", "CodeOutput", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project"))
        obj.OutputFile = PathPreferences.defaultOutputFile()
        obj.setEditorMode("OutputFile", 0)  # set to default mode

        obj.addProperty("App::PropertyString", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional description for this job"))
        obj.addProperty("App::PropertyEnumeration", "PostProcessor", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Select the Post Processor"))
        obj.PostProcessor = PathPreferences.allEnabledPostProcessors([''])
        obj.PostProcessor = PathPreferences.defaultPostProcessor()
        obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)"))
        obj.PostProcessorArgs = PathPreferences.defaultPostProcessorArgs()
        obj.addProperty("App::PropertyString",    "MachineName", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Name of the Machine that will use the CNC program"))

        obj.addProperty("Path::PropertyTooltable", "Tooltable", "Base", QtCore.QT_TRANSLATE_NOOP("App::Property","The tooltable used for this CNC program"))

        obj.addProperty("App::PropertyEnumeration", "MachineUnits", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Units that the machine works in, ie Metric or Inch"))
        obj.MachineUnits = ['Metric', 'Inch']

        obj.addProperty("App::PropertyDistance", "X_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel"))
        obj.addProperty("App::PropertyDistance", "Y_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel"))
        obj.addProperty("App::PropertyDistance", "Z_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel"))

        obj.addProperty("App::PropertyDistance", "X_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel"))
        obj.addProperty("App::PropertyDistance", "Y_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel"))
        obj.addProperty("App::PropertyDistance", "Z_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel"))

        obj.addProperty("App::PropertyLink", "Base", "Base", "The base object for all operations")

        obj.Proxy = self

        if FreeCAD.GuiUp:
            ViewProviderJob(obj.ViewObject)
예제 #7
0
    def resolveFileName(self, job):
        path = PathPreferences.defaultOutputFile()
        if job.OutputFile:
            path = job.OutputFile
        filename = path
        if '%D' in filename:
            D = FreeCAD.ActiveDocument.FileName
            if D:
                D = os.path.dirname(D)
            else:
                FreeCAD.Console.PrintError(
                    "Please save document in order to resolve output path!\n")
                return None
            filename = filename.replace('%D', D)

        if '%d' in filename:
            d = FreeCAD.ActiveDocument.Label
            filename = filename.replace('%d', d)

        if '%j' in filename:
            j = job.Label
            filename = filename.replace('%j', j)

        if '%M' in filename:
            pref = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")
            M = pref.GetString("MacroPath", FreeCAD.getUserAppDataDir())
            filename = filename.replace('%M', M)

        policy = PathPreferences.defaultOutputPolicy()

        openDialog = policy == 'Open File Dialog'
        if os.path.isdir(filename) or not os.path.isdir(
                os.path.dirname(filename)):
            # Either the entire filename resolves into a directory or the parent directory doesn't exist.
            # Either way I don't know what to do - ask for help
            openDialog = True

        if os.path.isfile(filename) and not openDialog:
            if policy == 'Open File Dialog on conflict':
                openDialog = True
            elif policy == 'Append Unique ID on conflict':
                fn, ext = os.path.splitext(filename)
                nr = fn[-3:]
                n = 1
                if nr.isdigit():
                    n = int(nr)
                while os.path.isfile("%s%03d%s" % (fn, n, ext)):
                    n = n + 1
                filename = "%s%03d%s" % (fn, n, ext)

        if openDialog:
            foo = QtGui.QFileDialog.getSaveFileName(QtGui.qApp.activeWindow(),
                                                    "Output File", filename)
            if foo:
                filename = foo[0]
            else:
                filename = None

        return filename
예제 #8
0
    def resolveFileName(self, job):
        path = PathPreferences.defaultOutputFile()
        if job.PostProcessorOutputFile:
            path = job.PostProcessorOutputFile
        filename = path
        if '%D' in filename:
            D = FreeCAD.ActiveDocument.FileName
            if D:
                D = os.path.dirname(D)
                # in case the document is in the current working directory
                if not D:
                    D = '.'
            else:
                FreeCAD.Console.PrintError("Please save document in order to resolve output path!\n")
                return None
            filename = filename.replace('%D', D)

        if '%d' in filename:
            d = FreeCAD.ActiveDocument.Label
            filename = filename.replace('%d', d)

        if '%j' in filename:
            j = job.Label
            filename = filename.replace('%j', j)

        if '%M' in filename:
            pref = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")
            M = pref.GetString("MacroPath", FreeCAD.getUserAppDataDir())
            filename = filename.replace('%M', M)

        policy = PathPreferences.defaultOutputPolicy()

        openDialog = policy == 'Open File Dialog'
        if os.path.isdir(filename) or not os.path.isdir(os.path.dirname(filename)):
            # Either the entire filename resolves into a directory or the parent directory doesn't exist.
            # Either way I don't know what to do - ask for help
            openDialog = True

        if os.path.isfile(filename) and not openDialog:
            if policy == 'Open File Dialog on conflict':
                openDialog = True
            elif policy == 'Append Unique ID on conflict':
                fn, ext = os.path.splitext(filename)
                nr = fn[-3:]
                n = 1
                if nr.isdigit():
                    n = int(nr)
                while os.path.isfile("%s%03d%s" % (fn, n, ext)):
                    n = n + 1
                filename = "%s%03d%s" % (fn, n, ext)

        if openDialog:
            foo = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(), "Output File", filename)
            if foo:
                filename = foo[0]
            else:
                filename = None

        return filename
예제 #9
0
    def resolveFileName(self, job):
        # print("resolveFileName(%s)" % job.Label)
        path = PathPreferences.defaultOutputFile()
        if job.OutputFile:
            path = job.OutputFile
        filename = path
        if "%D" in filename:
            D = FreeCAD.ActiveDocument.FileName
            if D:
                D = os.path.dirname(D)
            else:
                FreeCAD.Console.PrintError("Please save document in order to resolve output path!\n")
                return None
            filename = filename.replace("%D", D)

        if "%d" in filename:
            d = FreeCAD.ActiveDocument.Label
            filename = filename.replace("%d", d)

        if "%j" in filename:
            j = job.Label
            filename = filename.replace("%j", j)

        if "%M" in filename:
            pref = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")
            M = pref.GetString("MacroPath", FreeCAD.getUserAppDataDir())
            filename = filename.replace("%M", M)

        policy = PathPreferences.defaultOutputPolicy()

        openDialog = policy == "Open File Dialog"
        if os.path.isdir(filename) or not os.path.isdir(os.path.dirname(filename)):
            # Either the entire filename resolves into a directory or the parent directory doesn't exist.
            # Either way I don't know what to do - ask for help
            openDialog = True

        if os.path.isfile(filename) and not openDialog:
            if policy == "Open File Dialog on conflict":
                openDialog = True
            elif policy == "Append Unique ID on conflict":
                fn, ext = os.path.splitext(filename)
                nr = fn[-3:]
                n = 1
                if nr.isdigit():
                    n = int(nr)
                while os.path.isfile("%s%03d%s" % (fn, n, ext)):
                    n = n + 1
                filename = "%s%03d%s" % (fn, n, ext)

        if openDialog:
            foo = QtGui.QFileDialog.getSaveFileName(QtGui.qApp.activeWindow(), "Output File", filename)
            if foo:
                filename = foo[0]
            else:
                filename = None

        # print("resolveFileName(%s, %s) -> '%s'" % (path, policy, filename))
        return filename
    def saveSettings(self):
        processor = str(self.form.defaultPostProcessor.currentText())
        args = str(self.form.defaultPostProcessorArgs.text())
        blacklist = []
        for i in range(0, self.form.postProcessorList.count()):
            item = self.form.postProcessorList.item(i)
            if item.checkState() == QtCore.Qt.CheckState.Unchecked:
                blacklist.append(item.text())
        PathPreferences.savePostProcessorDefaults(processor, args, blacklist)

        path = str(self.form.leOutputFile.text())
        policy = str(self.form.cboOutputPolicy.currentText())
        PathPreferences.saveOutputFileDefaults(path, policy)
예제 #11
0
    def saveSettings(self):
        processor = str(self.form.defaultPostProcessor.currentText())
        args = str(self.form.defaultPostProcessorArgs.text())
        blacklist = []
        for i in range(0, self.form.postProcessorList.count()):
            item = self.form.postProcessorList.item(i)
            if item.checkState() == QtCore.Qt.CheckState.Unchecked:
                blacklist.append(item.text())
        PathPreferences.savePostProcessorDefaults(processor, args, blacklist)

        path = str(self.form.leOutputFile.text())
        policy = str(self.form.cboOutputPolicy.currentText())
        PathPreferences.saveOutputFileDefaults(path, policy)
예제 #12
0
 def saveSettings(self):
     pref = PathPreferences.preferences()
     pref.SetFloat(self.DefaultHoldingTagWidth, FreeCAD.Units.Quantity(self.form.ifWidth.text()).Value)
     pref.SetFloat(self.DefaultHoldingTagHeight, FreeCAD.Units.Quantity(self.form.ifHeight.text()).Value)
     pref.SetFloat(self.DefaultHoldingTagAngle, self.form.dsbAngle.value())
     pref.SetFloat(self.DefaultHoldingTagRadius, FreeCAD.Units.Quantity(self.form.ifRadius.text()))
     pref.SetUnsigned(self.DefaultHoldingTagCount, self.form.sbCount.value())
예제 #13
0
    def opExecute(self, obj):
        '''opExecute(obj) ... process engraving operation'''
        PathLog.track()

        output = ""
        if obj.Comment != "":
            output += '(' + str(obj.Comment) + ')\n'

        output += "(" + obj.Label + ")"
        output += "(Compensated Tool Path. Diameter: " + str(
            obj.ToolController.Tool.Diameter) + ")"

        parentJob = PathUtils.findParentJob(obj)
        if parentJob is None:
            return

        print("base object: " + self.baseobject.Name)

        if obj.Algorithm in ['OCL Dropcutter', 'OCL Waterline']:
            try:
                import ocl
            except:
                FreeCAD.Console.PrintError(
                    translate(
                        "Path_Surface",
                        "This operation requires OpenCamLib to be installed.")
                    + "\n")
                return

        if self.baseobject.TypeId.startswith('Mesh'):
            mesh = self.baseobject.Mesh
        else:
            # try/except is for Path Jobs created before GeometryTolerance
            try:
                deflection = parentJob.GeometryTolerance
            except AttributeError:
                from PathScripts.PathPreferences import PathPreferences
                deflection = PathPreferences.defaultGeometryTolerance()
            self.baseobject.Shape.tessellate(0.5)
            mesh = MeshPart.meshFromShape(self.baseobject.Shape,
                                          Deflection=deflection)

        bb = mesh.BoundBox

        s = ocl.STLSurf()
        for f in mesh.Facets:
            p = f.Points[0]
            q = f.Points[1]
            r = f.Points[2]
            t = ocl.Triangle(ocl.Point(p[0], p[1], p[2]),
                             ocl.Point(q[0], q[1], q[2]),
                             ocl.Point(r[0], r[1], r[2]))
            s.addTriangle(t)

        if obj.Algorithm == 'OCL Dropcutter':
            output = self._dropcutter(obj, s, bb)
        elif obj.Algorithm == 'OCL Waterline':
            output = self._waterline(obj, s, bb)

        self.commandlist.extend(output)
예제 #14
0
    def __init__(self, obj, deleteOnReject):
        FreeCAD.ActiveDocument.openTransaction(
            translate("Path_Job", "Edit Job"))
        self.obj = obj
        self.deleteOnReject = deleteOnReject
        self.form = FreeCADGui.PySideUic.loadUi(":/panels/JobEdit.ui")
        #self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/JobEdit.ui")

        currentPostProcessor = obj.PostProcessor
        postProcessors = PathPreferences.allEnabledPostProcessors(
            ['', currentPostProcessor])
        for post in postProcessors:
            self.form.cboPostProcessor.addItem(post)
        # update the enumeration values, just to make sure all selections are valid
        self.obj.PostProcessor = postProcessors
        self.obj.PostProcessor = currentPostProcessor

        self.form.cboBaseObject.addItem("")
        for o in FreeCAD.ActiveDocument.Objects:
            if hasattr(o, "Shape"):
                self.form.cboBaseObject.addItem(o.Name)

        self.postProcessorDefaultTooltip = self.form.cboPostProcessor.toolTip()
        self.postProcessorArgsDefaultTooltip = self.form.cboPostProcessorArgs.toolTip(
        )
예제 #15
0
    def load(cls, processor):
        PathLog.track(processor)
        syspath = sys.path
        paths = PathPreferences.searchPaths()
        paths.extend(sys.path)
        sys.path = paths

        postname = processor + "_post"
        namespace = {}
        
        #can't modify function local scope with exec in python3
        exec("import %s as current_post" % postname, namespace)
        current_post = namespace['current_post']
        
        # make sure the script is reloaded if it was previously loaded
        # should the script have been imported for the first time above
        # then the initialization code of the script gets executed twice
        # resulting in 2 load messages if the script outputs one of those.
        try:
            # Python 2.7
            exec("reload(%s)" % 'current_post')
        except NameError:
            # Python 3.4+
            from importlib import reload
            exec("reload(%s)" % 'current_post')

        sys.path = syspath

        instance = PostProcessor(current_post)
        instance.units = None
        if hasattr(current_post, "UNITS"):
            if current_post.UNITS == "G21":
                instance.units = "Metric"
            else:
                instance.units = "Inch"

        instance.machineName = None
        if hasattr(current_post, "MACHINE_NAME"):
            instance.machineName = current_post.MACHINE_NAME

        instance.cornerMax = None
        if hasattr(current_post, "CORNER_MAX"):
            instance.cornerMax = {'x': current_post.CORNER_MAX['x'],
                    'y': current_post.CORNER_MAX['y'],
                    'z': current_post.CORNER_MAX['z']}

        instance.cornerMin = None
        if hasattr(current_post, "CORNER_MIN"):
            instance.cornerMin = {'x': current_post.CORNER_MIN['x'],
                    'y': current_post.CORNER_MIN['y'],
                    'z': current_post.CORNER_MIN['z']}

        instance.tooltip = None
        instance.tooltipArgs = None
        if hasattr(current_post, "TOOLTIP"):
            instance.tooltip = current_post.TOOLTIP
            if hasattr(current_post, "TOOLTIP_ARGS"):
                instance.tooltipArgs = current_post.TOOLTIP_ARGS
        return instance
예제 #16
0
파일: PathJob.py 프로젝트: nabilbk/FreeCAD
 def Activated(self):
     job = FreeCADGui.Selection.getSelection()[0]
     foo = QtGui.QFileDialog.getSaveFileName(QtGui.qApp.activeWindow(),
             "Path - Job Template",
             PathPreferences.filePath(),
             "job_*.xml")[0]
     if foo: 
         self.Execute(job, foo)
예제 #17
0
 def Activated(self):
     job = self.GetJob()
     dialog = DlgJobTemplateExport(job)
     if dialog.exec_() == 1:
         foo = QtGui.QFileDialog.getSaveFileName(
             QtGui.QApplication.activeWindow(), "Path - Job Template",
             PathPreferences.filePath(), "job_*.json")[0]
         if foo:
             self.Execute(job, foo, dialog)
예제 #18
0
 def resolvePostProcessor(self, job):
     if hasattr(job, "PostProcessor"):
         post = PathPreferences.defaultPostProcessor()
         if job.PostProcessor:
             post = job.PostProcessor
         if post and PostProcessor.exists(post):
             return post
     dlg = DlgSelectPostProcessor()
     return dlg.exec_()
예제 #19
0
 def resolvePostProcessor(self, job):
     if hasattr(job, "PostProcessor"):
         post = PathPreferences.defaultPostProcessor()
         if job.PostProcessor:
             post = job.PostProcessor
         if post and PostProcessor.exists(post):
             return post
     dlg = DlgSelectPostProcessor()
     return dlg.exec_()
예제 #20
0
    def opExecute(self, obj):
        '''opExecute(obj) ... process engraving operation'''
        PathLog.track()

        output = ""
        if obj.Comment != "":
            output += '(' + str(obj.Comment)+')\n'


        output += "(" + obj.Label + ")"
        output += "(Compensated Tool Path. Diameter: " + str(obj.ToolController.Tool.Diameter) + ")"


        parentJob = PathUtils.findParentJob(obj)
        if parentJob is None:
            return

        print("base object: " + self.baseobject.Name)

        if obj.Algorithm in ['OCL Dropcutter', 'OCL Waterline']:
            try:
                import ocl
            except:
                FreeCAD.Console.PrintError(
                        translate("Path_Surface", "This operation requires OpenCamLib to be installed.\n"))
                return

        if self.baseobject.TypeId.startswith('Mesh'):
            mesh = self.baseobject.Mesh
        else:
            # try/except is for Path Jobs created before GeometryTolerance
            try:
                deflection = parentJob.GeometryTolerance
            except AttributeError:
                from PathScripts.PathPreferences import PathPreferences
                deflection = PathPreferences.defaultGeometryTolerance()
            self.baseobject.Shape.tessellate(0.5)
            mesh = MeshPart.meshFromShape(self.baseobject.Shape, Deflection=deflection)

        bb = mesh.BoundBox

        s = ocl.STLSurf()
        for f in mesh.Facets:
            p = f.Points[0]
            q = f.Points[1]
            r = f.Points[2]
            t = ocl.Triangle(ocl.Point(p[0], p[1], p[2]), ocl.Point(
                q[0], q[1], q[2]), ocl.Point(r[0], r[1], r[2]))
            s.addTriangle(t)

        if obj.Algorithm == 'OCL Dropcutter':
            output = self._dropcutter(obj, s, bb)
        elif obj.Algorithm == 'OCL Waterline':
            output = self._waterline(obj, s, bb)

        self.commandlist.extend(output)
예제 #21
0
 def Activated(self):
     job = FreeCADGui.Selection.getSelection()[0]
     dialog = DlgJobTemplateExport(job)
     if dialog.exec_() == 1:
         foo = QtGui.QFileDialog.getSaveFileName(QtGui.qApp.activeWindow(),
                                                 "Path - Job Template",
                                                 PathPreferences.filePath(),
                                                 "job_*.json")[0]
         if foo:
             self.Execute(job, foo, dialog)
예제 #22
0
파일: PathJobCmd.py 프로젝트: itain/FreeCAD
 def Activated(self):
     job = FreeCADGui.Selection.getSelection()[0]
     dialog = DlgJobTemplateExport(job)
     if dialog.exec_() == 1:
         foo = QtGui.QFileDialog.getSaveFileName(QtGui.qApp.activeWindow(),
                 "Path - Job Template",
                 PathPreferences.filePath(),
                 "job_*.xml")[0]
         if foo: 
             self.Execute(job, foo, dialog)
예제 #23
0
 def Activated(self):
     job = self.GetJob()
     dialog = DlgJobTemplateExport(job)
     if dialog.exec_() == 1:
         foo = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(),
                 "Path - Job Template",
                 PathPreferences.filePath(),
                 "job_*.json")[0]
         if foo: 
             self.Execute(job, foo, dialog)
예제 #24
0
    def __init__(self, obj):
        #        obj.addProperty("App::PropertyFile", "PostProcessor", "CodeOutput", "Select the Post Processor file for this project")
        obj.addProperty("App::PropertyFile", "OutputFile", "CodeOutput", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project"))
        obj.OutputFile = PathPreferences.defaultOutputFile()
        obj.setEditorMode("OutputFile", 0)  # set to default mode

        obj.addProperty("App::PropertyString", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional description for this job"))
        obj.addProperty("App::PropertyEnumeration", "PostProcessor", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Select the Post Processor"))
        obj.PostProcessor = postProcessors = PathPreferences.allEnabledPostProcessors()
        defaultPostProcessor = PathPreferences.defaultPostProcessor()
        # Check to see if default post processor hasn't been 'lost' (This can happen when Macro dir has changed)
        if defaultPostProcessor in postProcessors:
            obj.PostProcessor = defaultPostProcessor
        else:
            obj.PostProcessor = postProcessors[0]
        obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)"))
        obj.PostProcessorArgs = PathPreferences.defaultPostProcessorArgs()
        obj.addProperty("App::PropertyString",    "MachineName", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Name of the Machine that will use the CNC program"))

        #obj.addProperty("Path::PropertyTooltable", "Tooltable", "Base", QtCore.QT_TRANSLATE_NOOP("App::Property","The tooltable used for this CNC program"))

        obj.addProperty("App::PropertyEnumeration", "MachineUnits", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Units that the machine works in, ie Metric or Inch"))
        obj.MachineUnits = ['Metric', 'Inch']

        obj.addProperty("App::PropertyDistance", "GeometryTolerance", "Geometry",
                QtCore.QT_TRANSLATE_NOOP("App::Property", "For computing Paths; smaller increases accuracy, but slows down computation"))
        obj.GeometryTolerance = PathPreferences.defaultGeometryTolerance()

        obj.addProperty("App::PropertyDistance", "X_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel"))
        obj.addProperty("App::PropertyDistance", "Y_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel"))
        obj.addProperty("App::PropertyDistance", "Z_Max", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Maximum distance in X the machine can travel"))

        obj.addProperty("App::PropertyDistance", "X_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel"))
        obj.addProperty("App::PropertyDistance", "Y_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel"))
        obj.addProperty("App::PropertyDistance", "Z_Min", "Limits", QtCore.QT_TRANSLATE_NOOP("App::Property","The Minimum distance in X the machine can travel"))

        obj.addProperty("App::PropertyLink", "Base", "Base", "The base object for all operations")

        obj.Proxy = self

        if FreeCAD.GuiUp:
            ViewProviderJob(obj.ViewObject)
예제 #25
0
    def setupColors(self):
        def colorForColorValue(val):
            v = [((val >> n) & 0xff) / 255. for n in [24, 16, 8, 0]]
            return coin.SbColor(v[0], v[1], v[2])

        pref = PathPreferences.preferences()
        #                                                      R         G          B          A
        npc = pref.GetUnsigned('DefaultPathMarkerColor', ((85*256 + 255)*256 + 0) * 256 + 255)
        hpc = pref.GetUnsigned('DefaultHighlightPathColor', ((255*256 + 125)*256 + 0)*256 + 255)
        dpc = pref.GetUnsigned('DefaultDisabledPathColor', ((205*256 + 205)*256 + 205)*256 + 154)
        self.colors = [colorForColorValue(npc), colorForColorValue(dpc), colorForColorValue(hpc)]
예제 #26
0
 def saveSettings(self):
     pref = PathPreferences.preferences()
     pref.SetFloat(self.DefaultHoldingTagWidth,
                   FreeCAD.Units.Quantity(self.form.ifWidth.text()).Value)
     pref.SetFloat(self.DefaultHoldingTagHeight,
                   FreeCAD.Units.Quantity(self.form.ifHeight.text()).Value)
     pref.SetFloat(self.DefaultHoldingTagAngle, self.form.dsbAngle.value())
     pref.SetFloat(self.DefaultHoldingTagRadius,
                   FreeCAD.Units.Quantity(self.form.ifRadius.text()))
     pref.SetUnsigned(self.DefaultHoldingTagCount,
                      self.form.sbCount.value())
예제 #27
0
    def loadSettings(self):
        blacklist = PathPreferences.postProcessorBlacklist()
        for processor in PathPreferences.allAvailablePostProcessors():
            item = QtGui.QListWidgetItem(processor)
            if processor in blacklist:
                item.setCheckState(QtCore.Qt.CheckState.Unchecked)
            else:
                item.setCheckState(QtCore.Qt.CheckState.Checked)
            item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable
                          | QtCore.Qt.ItemFlag.ItemIsEnabled
                          | QtCore.Qt.ItemFlag.ItemIsUserCheckable)
            self.form.postProcessorList.addItem(item)
        self.verifyAndUpdateDefaultPostProcessorWith(
            PathPreferences.defaultPostProcessor())

        self.form.defaultPostProcessorArgs.setText(
            PathPreferences.defaultPostProcessorArgs())
        self.form.leOutputFile.setText(PathPreferences.defaultOutputFile())
        self.selectComboEntry(self.form.cboOutputPolicy,
                              PathPreferences.defaultOutputPolicy())

        self.form.postProcessorList.itemEntered.connect(
            self.setProcessorListTooltip)
        self.form.postProcessorList.itemChanged.connect(
            self.verifyAndUpdateDefaultPostProcessor)
        self.form.defaultPostProcessor.currentIndexChanged.connect(
            self.updateDefaultPostProcessorToolTip)
        self.form.pbBrowseFileSystem.clicked.connect(self.browseFileSystem)
예제 #28
0
    def __init__(self, vobj, deleteOnReject):
        FreeCAD.ActiveDocument.openTransaction(
            translate("Path_Job", "Edit Job"))
        self.vobj = vobj
        self.obj = vobj.Object
        self.deleteOnReject = deleteOnReject
        self.form = FreeCADGui.PySideUic.loadUi(":/panels/PathEdit.ui")

        vUnit = FreeCAD.Units.Quantity(
            1, FreeCAD.Units.Velocity).getUserPreferred()[2]
        self.form.toolControllerList.horizontalHeaderItem(1).setText('#')
        self.form.toolControllerList.horizontalHeaderItem(2).setText(vUnit)
        self.form.toolControllerList.horizontalHeaderItem(3).setText(vUnit)
        self.form.toolControllerList.horizontalHeader().setResizeMode(
            0, QtGui.QHeaderView.Stretch)
        self.form.toolControllerList.resizeColumnsToContents()

        currentPostProcessor = self.obj.PostProcessor
        postProcessors = PathPreferences.allEnabledPostProcessors(
            ['', currentPostProcessor])
        for post in postProcessors:
            self.form.postProcessor.addItem(post)
        # update the enumeration values, just to make sure all selections are valid
        self.obj.PostProcessor = postProcessors
        self.obj.PostProcessor = currentPostProcessor

        for o in PathJob.ObjectJob.baseCandidates():
            if o != self.obj.Base:
                self.form.jobModel.addItem(o.Label, o)
        self.selectComboBoxText(self.form.jobModel,
                                self.obj.Proxy.baseObject(self.obj).Label)

        self.postProcessorDefaultTooltip = self.form.postProcessor.toolTip()
        self.postProcessorArgsDefaultTooltip = self.form.postProcessorArguments.toolTip(
        )

        self.baseVisibility = False
        self.baseOrigVisibilty = False
        if self.obj.Base and self.obj.Base.ViewObject:
            self.baseVisibility = self.obj.Base.ViewObject.Visibility
            self.baseObjectSaveVisibility(self.obj)

        self.stockVisibility = False
        if self.obj.Stock and self.obj.Stock.ViewObject:
            self.stockVisibility = self.obj.Stock.ViewObject.Visibility
            self.obj.Stock.ViewObject.Visibility = True

        self.stockFromBase = None
        self.stockFromExisting = None
        self.stockCreateBox = None
        self.stockCreateCylinder = None
        self.stockEdit = None
예제 #29
0
    def __init__(self, obj, base, template = None):
        self.obj = obj
        obj.addProperty("App::PropertyFile", "PostProcessorOutputFile", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project"))
        obj.addProperty("App::PropertyEnumeration", "PostProcessor", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property","Select the Post Processor"))
        obj.addProperty("App::PropertyString", "PostProcessorArgs", "Output", QtCore.QT_TRANSLATE_NOOP("App::Property", "Arguments for the Post Processor (specific to the script)"))

        obj.addProperty("App::PropertyString", "Description", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional description for this job"))
        obj.addProperty("App::PropertyDistance", "GeometryTolerance", "Geometry", QtCore.QT_TRANSLATE_NOOP("App::Property", "For computing Paths; smaller increases accuracy, but slows down computation"))

        obj.addProperty("App::PropertyLink", "Base", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "The base object for all operations"))
        obj.addProperty("App::PropertyLink", "Stock", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Solid object to be used as stock."))
        obj.addProperty("App::PropertyLink", "Operations", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Compound path of all operations in the order they are processed."))
        obj.addProperty("App::PropertyLinkList", "ToolController", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Collection of tool controllers available for this job."))

        obj.PostProcessorOutputFile = PathPreferences.defaultOutputFile()
        #obj.setEditorMode("PostProcessorOutputFile", 0)  # set to default mode
        obj.PostProcessor = postProcessors = PathPreferences.allEnabledPostProcessors()
        defaultPostProcessor = PathPreferences.defaultPostProcessor()
        # Check to see if default post processor hasn't been 'lost' (This can happen when Macro dir has changed)
        if defaultPostProcessor in postProcessors:
            obj.PostProcessor = defaultPostProcessor
        else:
            obj.PostProcessor = postProcessors[0]
        obj.PostProcessorArgs = PathPreferences.defaultPostProcessorArgs()
        obj.GeometryTolerance = PathPreferences.defaultGeometryTolerance()

        ops = FreeCAD.ActiveDocument.addObject("Path::FeatureCompoundPython", "Operations")
        obj.Operations = ops
        obj.setEditorMode('Operations', 2) # hide
        obj.setEditorMode('Placement', 2)

        obj.Base = createResourceClone(obj, base, 'Base', 'BaseGeometry')
        obj.Proxy = self

        self.assignTemplate(obj, template)
        if not obj.Stock:
            obj.Stock = PathStock.CreateFromBase(obj)
        if obj.Stock.ViewObject:
            obj.Stock.ViewObject.Visibility = False
예제 #30
0
    def __init__(self, parent=None):
        self.dialog = FreeCADGui.PySideUic.loadUi(":/panels/DlgJobCreate.ui")
        sel = FreeCADGui.Selection.getSelection()
        if sel:
            selected = sel[0].Label
        else:
            selected = None
        index = 0
        for base in PathJob.ObjectJob.baseCandidates():
            if base.Label == selected:
                index = self.dialog.cbModel.count()
            self.dialog.cbModel.addItem(base.Label)
        self.dialog.cbModel.setCurrentIndex(index)

        templateFiles = []
        for path in PathPreferences.searchPaths():
            templateFiles.extend(self.templateFilesIn(path))

        template = {}
        for tFile in templateFiles:
            name = os.path.split(os.path.splitext(tFile)[0])[1][4:]
            if name in template:
                basename = name
                i = 0
                while name in template:
                    i = i + 1
                    name = basename + " (%s)" % i
            PathLog.track(name, tFile)
            template[name] = tFile
        selectTemplate = PathPreferences.defaultJobTemplate()
        index = 0
        self.dialog.cbTemplate.addItem('<none>', '')
        for name in sorted(template.keys()):
            if template[name] == selectTemplate:
                index = self.dialog.cbTemplate.count()
            self.dialog.cbTemplate.addItem(name, template[name])
        self.dialog.cbTemplate.setCurrentIndex(index)
예제 #31
0
    def __init__(self, parent=None):
        self.dialog = FreeCADGui.PySideUic.loadUi(":/panels/DlgJobCreate.ui")
        sel = FreeCADGui.Selection.getSelection()
        if sel:
            selected = sel[0].Label
        else:
            selected = None
        index = 0
        for base in PathJob.ObjectJob.baseCandidates():
            if base.Label == selected:
                index = self.dialog.cbModel.count()
            self.dialog.cbModel.addItem(base.Label)
        self.dialog.cbModel.setCurrentIndex(index)

        templateFiles = []
        for path in PathPreferences.searchPaths():
            templateFiles.extend(self.templateFilesIn(path))

        template = {}
        for tFile in templateFiles:
            name = os.path.split(os.path.splitext(tFile)[0])[1][4:]
            if name in template:
                basename = name
                i = 0
                while name in template:
                    i = i + 1
                    name = basename + " (%s)" % i
            PathLog.track(name, tFile)
            template[name] = tFile
        selectTemplate = PathPreferences.defaultJobTemplate()
        index = 0
        self.dialog.cbTemplate.addItem('<none>', '')
        for name in sorted(template.keys()):
            if template[name] == selectTemplate:
                index = self.dialog.cbTemplate.count()
            self.dialog.cbTemplate.addItem(name, template[name])
        self.dialog.cbTemplate.setCurrentIndex(index)
예제 #32
0
 def __init__(self, parent=None):
     self.dialog = FreeCADGui.PySideUic.loadUi(":/panels/DlgSelectPostProcessor.ui")
     firstItem = None
     for post in PathPreferences.allEnabledPostProcessors():
         item = QtGui.QListWidgetItem(post)
         item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
         self.dialog.lwPostProcessor.addItem(item)
         if not firstItem:
             firstItem = item
     if firstItem:
         self.dialog.lwPostProcessor.setCurrentItem(firstItem)
     else:
         self.dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)
     self.tooltips = {}
     self.dialog.lwPostProcessor.itemDoubleClicked.connect(self.dialog.accept)
     self.dialog.lwPostProcessor.setMouseTracking(True)
     self.dialog.lwPostProcessor.itemEntered.connect(self.updateTooltip)
예제 #33
0
 def __init__(self, parent=None):
     self.dialog = FreeCADGui.PySideUic.loadUi(":/panels/DlgSelectPostProcessor.ui")
     firstItem = None
     for post in PathPreferences.allEnabledPostProcessors():
         item = QtGui.QListWidgetItem(post)
         item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
         self.dialog.lwPostProcessor.addItem(item)
         if not firstItem:
             firstItem = item
     if firstItem:
         self.dialog.lwPostProcessor.setCurrentItem(firstItem)
     else:
         self.dialog.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(False)
     self.tooltips = {}
     self.dialog.lwPostProcessor.itemDoubleClicked.connect(self.dialog.accept)
     self.dialog.lwPostProcessor.setMouseTracking(True)
     self.dialog.lwPostProcessor.itemEntered.connect(self.updateTooltip)
예제 #34
0
    def Activated(self):
        FreeCAD.ActiveDocument.openTransaction(
            translate("Path_Post", "Post Process the Selected path(s)"))
        FreeCADGui.addModule("PathScripts.PathPost")
        # select the Path Job that you want to post output from
        selected = FreeCADGui.Selection.getCompleteSelection()
        print "in activated %s" % (selected)

        # try to find the job, if it's not directly selected ...
        jobs = set()
        for obj in selected:
            if hasattr(obj, 'OutputFile') or hasattr(obj, 'PostProcessor'):
                jobs.add(obj)
            elif hasattr(obj, 'Path') or hasattr(obj, 'ToolNumber'):
                job = PathUtils.findParentJob(obj)
                if job:
                    jobs.add(job)
        if len(jobs) != 1:
            FreeCAD.Console.PrintError(
                "Please select a single job or other path object\n")
            FreeCAD.ActiveDocument.abortTransaction()
        else:
            job = jobs.pop()
            print("Job for selected objects = %s" % job.Name)

            # check if the user has a project and has set the default post and
            # output filename
            postArgs = PathPreferences.defaultPostProcessorArgs()
            if hasattr(job, "PostProcessorArgs") and job.PostProcessorArgs:
                postArgs = job.PostProcessorArgs
            elif hasattr(job, "PostProcessor") and job.PostProcessor:
                postArgs = ''

            postname = self.resolvePostProcessor(job)
            if postname:
                filename = self.resolveFileName(job)

            if postname and filename:
                print("post: %s(%s, %s)" % (postname, filename, postArgs))
                processor = PostProcessor.load(postname)
                processor.export(selected, filename, postArgs)

                FreeCAD.ActiveDocument.commitTransaction()
            else:
                FreeCAD.ActiveDocument.abortTransaction()
        FreeCAD.ActiveDocument.recompute()
예제 #35
0
파일: PathJobGui.py 프로젝트: itain/FreeCAD
    def __init__(self, vobj, deleteOnReject):
        FreeCAD.ActiveDocument.openTransaction(translate("Path_Job", "Edit Job"))
        self.vobj = vobj
        self.obj = vobj.Object
        self.deleteOnReject = deleteOnReject
        self.form = FreeCADGui.PySideUic.loadUi(":/panels/PathEdit.ui")

        vUnit = FreeCAD.Units.Quantity(1, FreeCAD.Units.Velocity).getUserPreferred()[2]
        self.form.toolControllerList.horizontalHeaderItem(1).setText('#')
        self.form.toolControllerList.horizontalHeaderItem(2).setText(vUnit)
        self.form.toolControllerList.horizontalHeaderItem(3).setText(vUnit)
        self.form.toolControllerList.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.Stretch)
        self.form.toolControllerList.resizeColumnsToContents()

        currentPostProcessor = self.obj.PostProcessor
        postProcessors = PathPreferences.allEnabledPostProcessors(['', currentPostProcessor])
        for post in postProcessors:
            self.form.postProcessor.addItem(post)
        # update the enumeration values, just to make sure all selections are valid
        self.obj.PostProcessor = postProcessors
        self.obj.PostProcessor = currentPostProcessor

        for o in PathJob.ObjectJob.baseCandidates():
            if o != self.obj.Base:
                self.form.jobModel.addItem(o.Label, o)
        self.selectComboBoxText(self.form.jobModel, self.obj.Proxy.baseObject(self.obj).Label)

        self.postProcessorDefaultTooltip = self.form.postProcessor.toolTip()
        self.postProcessorArgsDefaultTooltip = self.form.postProcessorArguments.toolTip()

        self.baseVisibility = False
        self.baseOrigVisibilty = False
        if self.obj.Base and self.obj.Base.ViewObject:
            self.baseVisibility = self.obj.Base.ViewObject.Visibility
            self.baseObjectSaveVisibility(self.obj)

        self.stockVisibility = False
        if self.obj.Stock and self.obj.Stock.ViewObject:
            self.stockVisibility = self.obj.Stock.ViewObject.Visibility
            self.obj.Stock.ViewObject.Visibility = True

        self.stockFromBase = None
        self.stockFromExisting = None
        self.stockCreateBox = None
        self.stockCreateCylinder = None
        self.stockEdit = None
예제 #36
0
    def Activated(self):
        FreeCAD.ActiveDocument.openTransaction(
            translate("Path_Post", "Post Process the Selected path(s)"))
        FreeCADGui.addModule("PathScripts.PathPost")
        # select the Path Job that you want to post output from
        selected = FreeCADGui.Selection.getCompleteSelection()
        print "in activated %s" %(selected)

        # try to find the job, if it's not directly selected ...
        jobs = set()
        for obj in selected:
            if hasattr(obj, 'OutputFile') or hasattr(obj, 'PostProcessor'):
                jobs.add(obj)
            elif hasattr(obj, 'Path') or hasattr(obj, 'ToolNumber'):
                job = PathUtils.findParentJob(obj)
                if job:
                    jobs.add(job)
        if len(jobs) != 1:
            FreeCAD.Console.PrintError("Please select a single job or other path object\n")
            FreeCAD.ActiveDocument.abortTransaction()
        else:
            job = jobs.pop()
            print("Job for selected objects = %s" % job.Name)

            # check if the user has a project and has set the default post and
            # output filename
            postArgs = PathPreferences.defaultPostProcessorArgs()
            if hasattr(job, "PostProcessorArgs") and job.PostProcessorArgs:
                postArgs = job.PostProcessorArgs
            elif hasattr(job, "PostProcessor") and job.PostProcessor:
                postArgs = ''

            postname = self.resolvePostProcessor(job)
            if postname:
                filename = self.resolveFileName(job)

            if postname and filename:
                print("post: %s(%s, %s)" % (postname, filename, postArgs))
                processor = PostProcessor.load(postname)
                processor.export(selected, filename, postArgs)

                FreeCAD.ActiveDocument.commitTransaction()
            else:
                FreeCAD.ActiveDocument.abortTransaction()
        FreeCAD.ActiveDocument.recompute()
예제 #37
0
    def exportObjectsWith(self, objs, job, needFilename=True):
        # check if the user has a project and has set the default post and
        # output filename
        postArgs = PathPreferences.defaultPostProcessorArgs()
        if hasattr(job, "PostProcessorArgs") and job.PostProcessorArgs:
            postArgs = job.PostProcessorArgs
        elif hasattr(job, "PostProcessor") and job.PostProcessor:
            postArgs = ''

        postname = self.resolvePostProcessor(job)
        filename = '-'
        if postname and needFilename:
            filename = self.resolveFileName(job)

        if postname and filename:
            print("post: %s(%s, %s)" % (postname, filename, postArgs))
            processor = PostProcessor.load(postname)
            gcode = processor.export(objs, filename, postArgs)
            return (False, gcode)
        else:
            return (True, '')
예제 #38
0
    def exportObjectsWith(self, objs, job, needFilename = True):
        # check if the user has a project and has set the default post and
        # output filename
        postArgs = PathPreferences.defaultPostProcessorArgs()
        if hasattr(job, "PostProcessorArgs") and job.PostProcessorArgs:
            postArgs = job.PostProcessorArgs
        elif hasattr(job, "PostProcessor") and job.PostProcessor:
            postArgs = ''

        postname = self.resolvePostProcessor(job)
        filename = '-'
        if postname and needFilename:
            filename = self.resolveFileName(job)

        if postname and filename:
            print("post: %s(%s, %s)" % (postname, filename, postArgs))
            processor = PostProcessor.load(postname)
            gcode = processor.export(objs, filename, postArgs)
            return (False, gcode)
        else:
            return (True, '')
예제 #39
0
    def __init__(self, obj, deleteOnReject):
        FreeCAD.ActiveDocument.openTransaction(translate("Path_Job", "Edit Job"))
        self.obj = obj
        self.deleteOnReject = deleteOnReject
        self.form = FreeCADGui.PySideUic.loadUi(":/panels/JobEdit.ui")
        #self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/JobEdit.ui")

        currentPostProcessor = obj.PostProcessor
        postProcessors = PathPreferences.allEnabledPostProcessors(['', currentPostProcessor])
        for post in postProcessors:
            self.form.cboPostProcessor.addItem(post)
        # update the enumeration values, just to make sure all selections are valid
        self.obj.PostProcessor = postProcessors
        self.obj.PostProcessor = currentPostProcessor

        self.form.cboBaseObject.addItem("")
        for o in FreeCAD.ActiveDocument.Objects:
            if hasattr(o, "Shape"):
                self.form.cboBaseObject.addItem(o.Name)


        self.postProcessorDefaultTooltip = self.form.cboPostProcessor.toolTip()
        self.postProcessorArgsDefaultTooltip = self.form.cboPostProcessorArgs.toolTip()
예제 #40
0
    def saveSettings(self):
        filePath = self.form.leDefaultFilePath.text()
        jobTemplate = self.form.leDefaultJobTemplate.text()
        geometryTolerance = Units.Quantity(self.form.geometryTolerance.text())
        PathPreferences.setJobDefaults(filePath, jobTemplate, geometryTolerance)

        processor = str(self.form.defaultPostProcessor.currentText())
        args = str(self.form.defaultPostProcessorArgs.text())
        blacklist = []
        for i in range(0, self.form.postProcessorList.count()):
            item = self.form.postProcessorList.item(i)
            if item.checkState() == QtCore.Qt.CheckState.Unchecked:
                blacklist.append(item.text())
        PathPreferences.setPostProcessorDefaults(processor, args, blacklist)

        path = str(self.form.leOutputFile.text())
        policy = str(self.form.cboOutputPolicy.currentText())
        PathPreferences.setOutputFileDefaults(path, policy)
예제 #41
0
    def saveSettings(self):
        filePath = self.form.leDefaultFilePath.text()
        jobTemplate = self.form.leDefaultJobTemplate.text()
        geometryTolerance = Units.Quantity(self.form.geometryTolerance.text())
        PathPreferences.setJobDefaults(filePath, jobTemplate,
                                       geometryTolerance)

        processor = str(self.form.defaultPostProcessor.currentText())
        args = str(self.form.defaultPostProcessorArgs.text())
        blacklist = []
        for i in range(0, self.form.postProcessorList.count()):
            item = self.form.postProcessorList.item(i)
            if item.checkState() == QtCore.Qt.CheckState.Unchecked:
                blacklist.append(item.text())
        PathPreferences.setPostProcessorDefaults(processor, args, blacklist)

        path = str(self.form.leOutputFile.text())
        policy = str(self.form.cboOutputPolicy.currentText())
        PathPreferences.setOutputFileDefaults(path, policy)
    def loadSettings(self):
        blacklist = PathPreferences.postProcessorBlacklist()
        for processor in PathPreferences.allAvailablePostProcessors():
            item = QtGui.QListWidgetItem(processor)
            if processor in blacklist:
                item.setCheckState(QtCore.Qt.CheckState.Unchecked)
            else:
                item.setCheckState(QtCore.Qt.CheckState.Checked)
            item.setFlags( QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled | QtCore.Qt.ItemFlag.ItemIsUserCheckable)
            self.form.postProcessorList.addItem(item)
        self.verifyAndUpdateDefaultPostProcessorWith(PathPreferences.defaultPostProcessor())

        self.form.defaultPostProcessorArgs.setText(PathPreferences.defaultPostProcessorArgs())
        self.form.leOutputFile.setText(PathPreferences.defaultOutputFile())
        self.selectComboEntry(self.form.cboOutputPolicy, PathPreferences.defaultOutputPolicy())

        self.form.postProcessorList.itemEntered.connect(self.setProcessorListTooltip)
        self.form.postProcessorList.itemChanged.connect(self.verifyAndUpdateDefaultPostProcessor)
        self.form.defaultPostProcessor.currentIndexChanged.connect(self.updateDefaultPostProcessorToolTip)
        self.form.pbBrowseFileSystem.clicked.connect(self.browseFileSystem)
예제 #43
0
 def bestGuessForFilePath(self):
     path = self.form.leDefaultFilePath.text()
     if not path:
         path = PathPreferences.filePath()
     return path
예제 #44
0
    def loadStockSettings(self):
        stock = PathPreferences.defaultStockTemplate()
        index = -1
        if stock:
            attrs = json.loads(stock)
            if attrs.get('version') and 1 == int(attrs['version']):
                stockType = attrs.get('create')
                if stockType == PathStock.StockType.FromBase:
                    index = 2
                elif stockType == PathStock.StockType.CreateBox:
                    index = 0
                elif stockType == PathStock.StockType.CreateCylinder:
                    index = 1
                else:
                    index = -1
        if -1 == index:
            attrs = {}
            self.form.stockGroup.setChecked(False)
        else:
            self.form.stockGroup.setChecked(True)
            self.form.stock.setCurrentIndex(index)

        # this either sets the default value or the value from the template for each field
        self.form.stockExtXneg.setText(attrs.get('xneg', '1 mm'))
        self.form.stockExtXpos.setText(attrs.get('xpos', '1 mm'))
        self.form.stockExtYneg.setText(attrs.get('yneg', '1 mm'))
        self.form.stockExtYpos.setText(attrs.get('ypos', '1 mm'))
        self.form.stockExtZneg.setText(attrs.get('zneg', '1 mm'))
        self.form.stockExtZpos.setText(attrs.get('zpos', '1 mm'))
        self.form.stockBoxLength.setText(attrs.get('length', '10 mm'))
        self.form.stockBoxWidth.setText(attrs.get('width', '10 mm'))
        self.form.stockBoxHeight.setText(attrs.get('height', '10 mm'))
        self.form.stockCylinderRadius.setText(attrs.get('radius', '5 mm'))
        self.form.stockCylinderHeight.setText(attrs.get('height', '10 mm'))

        posX = attrs.get('posX')
        posY = attrs.get('posY')
        posZ = attrs.get('posZ')
        rotX = attrs.get('rotX')
        rotY = attrs.get('rotY')
        rotZ = attrs.get('rotZ')
        rotW = attrs.get('rotW')
        if posX is not None and posY is not None and posZ is not None and rotX is not None and rotY is not None and rotZ is not None and rotW is not None:
            pos = FreeCAD.Vector(float(posX), float(posY), float(posZ)) 
            rot = FreeCAD.Rotation(float(rotX), float(rotY), float(rotZ), float(rotW))
            placement = FreeCAD.Placement(pos, rot)
            self.form.stockPlacementGroup.setChecked(True)
        else:
            placement = FreeCAD.Placement()
            self.form.stockPlacementGroup.setChecked(False)

        self.form.stockAngle.setText(FreeCAD.Units.Quantity("%f rad" % placement.Rotation.Angle).UserString)
        self.form.stockAxisX.setValue(placement.Rotation.Axis.x)
        self.form.stockAxisY.setValue(placement.Rotation.Axis.y)
        self.form.stockAxisZ.setValue(placement.Rotation.Axis.z)
        self.form.stockPositionX.setText(FreeCAD.Units.Quantity(placement.Base.x, FreeCAD.Units.Length).UserString)
        self.form.stockPositionY.setText(FreeCAD.Units.Quantity(placement.Base.y, FreeCAD.Units.Length).UserString)
        self.form.stockPositionZ.setText(FreeCAD.Units.Quantity(placement.Base.z, FreeCAD.Units.Length).UserString)

        self.setupStock(index)
        self.form.stock.currentIndexChanged.connect(self.setupStock)
예제 #45
0
    def Initialize(self):
        # Add preferences pages - before loading PathGui to properly order pages of Path group
        from PathScripts import PathPreferencesPathJob, PathPreferencesPathDressup
        FreeCADGui.addPreferencePage(PathPreferencesPathJob.JobPreferencesPage, "Path")
        FreeCADGui.addPreferencePage(PathPreferencesPathDressup.DressupPreferencesPage, "Path")

        # Check enablement of experimental features
        from PathScripts.PathPreferences import PathPreferences

        # load the builtin modules
        import Path
        import PathScripts
        import PathGui
        from PySide import QtGui
        FreeCADGui.addLanguagePath(":/translations")
        FreeCADGui.addIconPath(":/icons")
        # load python modules
        from PathScripts import PathArray
        from PathScripts import PathComment
        from PathScripts import PathCustom
        from PathScripts import PathDressupDogbone
        from PathScripts import PathDressupDragknife
        from PathScripts import PathDressupRampEntry
        from PathScripts import PathDressupTagGui
        from PathScripts import PathDressupLeadInOut
        from PathScripts import PathDrillingGui
        from PathScripts import PathEngraveGui
        from PathScripts import PathFixture
        from PathScripts import PathHelixGui
        from PathScripts import PathHop
        from PathScripts import PathInspect
        from PathScripts import PathJobCmd
        from PathScripts import PathMillFaceGui
        from PathScripts import PathPocketGui
        from PathScripts import PathPocketShapeGui
        from PathScripts import PathPost
        from PathScripts import PathProfileContourGui
        from PathScripts import PathProfileEdgesGui
        from PathScripts import PathProfileFacesGui
        from PathScripts import PathSanity
        from PathScripts import PathSimpleCopy
        from PathScripts import PathStop
        from PathScripts import PathSurfaceGui
        from PathScripts import PathToolController
        from PathScripts import PathToolLibraryManager
        from PathScripts import PathSimulatorGui
        import PathCommands

        # build commands list
        projcmdlist = ["Path_Job", "Path_Post"]
        toolcmdlist = ["Path_Inspect", "Path_Simulator", "Path_ToolLibraryEdit", "Path_SelectLoop"]
        prepcmdlist = ["Path_Fixture", "Path_Comment", "Path_Stop", "Path_Custom"]
        twodopcmdlist = ["Path_Contour", "Path_Profile_Faces", "Path_Profile_Edges", "Path_Pocket_Shape", "Path_Drilling", "Path_Engrave", "Path_MillFace", "Path_Helix"]
        threedopcmdlist = ["Path_Pocket_3D"]
        modcmdlist = ["Path_OperationCopy", "Path_Array", "Path_SimpleCopy" ]
        dressupcmdlist = ["Path_DressupDogbone", "Path_DressupDragKnife", "Path_DressupLeadInOut", "Path_DressupRampEntry", "Path_DressupTag"]
        extracmdlist = []
        #modcmdmore = ["Path_Hop",]
        #remotecmdlist = ["Path_Remote"]

        # Add commands to menu and toolbar
        def QT_TRANSLATE_NOOP(scope, text):
            return text

        class ThreeDCommandGroup:
            def GetCommands(self):
                return tuple(threedopcmdlist)

            def GetResources(self):
                return { 'MenuText': QT_TRANSLATE_NOOP("Path",'3D Operations'),
                         'ToolTip': QT_TRANSLATE_NOOP("Path",'3D Operations')
                       }
            def IsActive(self):
                if FreeCAD.ActiveDocument is not None:
                    for o in FreeCAD.ActiveDocument.Objects:
                        if o.Name[:3] == "Job":
                                return True
                return False

        if PathPreferences.experimentalFeaturesEnabled():
            projcmdlist.append("Path_Sanity")
            prepcmdlist.append("Path_Shape")
            threedopcmdlist.append("Path_Surface")
            extracmdlist.extend(["Path_Area", "Path_Area_Workplane"])
            FreeCADGui.addCommand('Path_3dTools', ThreeDCommandGroup())
            threedcmdgroup = ['Path_3dTools']
        else:
            threedcmdgroup = threedopcmdlist

        self.appendToolbar(QT_TRANSLATE_NOOP("Path", "Project Setup"), projcmdlist)
        self.appendToolbar(QT_TRANSLATE_NOOP("Path", "Tool Commands"), toolcmdlist)
        self.appendToolbar(QT_TRANSLATE_NOOP("Path", "New Operations"), twodopcmdlist+threedcmdgroup)
        self.appendToolbar(QT_TRANSLATE_NOOP("Path", "Path Modification"), modcmdlist)
        if extracmdlist:
            self.appendToolbar(QT_TRANSLATE_NOOP("Path", "Helpful Tools"), extracmdlist)

        self.appendMenu([QT_TRANSLATE_NOOP("Path", "&Path")], projcmdlist +["Path_ExportTemplate", "Separator"] + toolcmdlist +["Separator"] +twodopcmdlist +["Separator"] +threedopcmdlist +["Separator"])
        self.appendMenu([QT_TRANSLATE_NOOP("Path", "&Path"), QT_TRANSLATE_NOOP(
            "Path", "Path Dressup")], dressupcmdlist)
        self.appendMenu([QT_TRANSLATE_NOOP("Path", "&Path"), QT_TRANSLATE_NOOP(
            "Path", "Supplemental Commands")], prepcmdlist)
        self.appendMenu([QT_TRANSLATE_NOOP("Path", "&Path"), QT_TRANSLATE_NOOP(
            "Path", "Path Modification")], modcmdlist)
        if extracmdlist:
            self.appendMenu([QT_TRANSLATE_NOOP("Path", "&Path")], extracmdlist)

        self.dressupcmds = dressupcmdlist

        curveAccuracy = PathPreferences.defaultLibAreaCurveAccuracy()
        if curveAccuracy:
            Path.Area.setDefaultParams(curveAccuracy)

        Log('Loading Path workbench... done\n')
예제 #46
0
 def defaultRadius(cls, ifNotSet=0.0):
     return PathPreferences.preferences().GetFloat(
         cls.DefaultHoldingTagRadius, ifNotSet)
예제 #47
0
 def defaultCount(cls, ifNotSet = 4):
     value = PathPreferences.preferences().GetUnsigned(cls.DefaultHoldingTagCount, ifNotSet)
     if value < 2:
         return float(ifNotSet)
     return float(value)
예제 #48
0
 def defaultAngle(cls, ifNotSet = 45.0):
     value = PathPreferences.preferences().GetFloat(cls.DefaultHoldingTagAngle, ifNotSet)
     if value < 10.0:
         return ifNotSet
     return value
예제 #49
0
 def defaultHeight(cls, ifNotSet):
     value = PathPreferences.preferences().GetFloat(cls.DefaultHoldingTagHeight, ifNotSet)
     if value == 0.0:
         return ifNotSet
     return value
예제 #50
0
 def bestGuessForFilePath(self):
     path = self.form.leDefaultFilePath.text()
     if not path:
         path = PathPreferences.filePath()
     return path
예제 #51
0
파일: PathOpGui.py 프로젝트: lanigb/FreeCAD
    def __init__(self, obj, deleteOnReject, opPage, selectionFactory):
        PathLog.track(obj.Label, deleteOnReject, opPage, selectionFactory)
        FreeCAD.ActiveDocument.openTransaction(translate("Path", "AreaOp Operation"))
        self.deleteOnReject = deleteOnReject
        self.featurePages = []

        features = obj.Proxy.opFeatures(obj)
        opPage.features = features

        if PathOp.FeatureBaseGeometry & features:
            if hasattr(opPage, 'taskPanelBaseGeometryPage'):
                self.featurePages.append(opPage.taskPanelBaseGeometryPage(obj, features))
            else:
                self.featurePages.append(TaskPanelBaseGeometryPage(obj, features))

        if PathOp.FeatureLocations & features:
            if hasattr(opPage, 'taskPanelBaseLocationPage'):
                self.featurePages.append(opPage.taskPanelBaseLocationPage(obj, features))
            else:
                self.featurePages.append(TaskPanelBaseLocationPage(obj, features))

        if PathOp.FeatureDepths & features:
            if hasattr(opPage, 'taskPanelDepthsPage'):
                self.featurePages.append(opPage.taskPanelDepthsPage(obj, features))
            else:
                self.featurePages.append(TaskPanelDepthsPage(obj, features))

        if PathOp.FeatureHeights & features:
            if hasattr(opPage, 'taskPanelHeightsPage'):
                self.featurePages.append(opPage.taskPanelHeightsPage(obj, features))
            else:
                self.featurePages.append(TaskPanelHeightsPage(obj, features))

        self.featurePages.append(opPage)

        for page in self.featurePages:
            page.initPage(obj)
            page.onDirtyChanged(self.pageDirtyChanged)

        taskPanelLayout = PathPreferences.defaultTaskPanelLayout()

        if taskPanelLayout < 2:
            opTitle = opPage.getTitle(obj)
            opPage.setTitle(translate('PathOp', 'Operation'))
            toolbox = QtGui.QToolBox()
            if taskPanelLayout == 0:
                for page in self.featurePages:
                    toolbox.addItem(page.form, page.getTitle(obj))
                toolbox.setCurrentIndex(len(self.featurePages)-1)
            else:
                for page in reversed(self.featurePages):
                    toolbox.addItem(page.form, page.getTitle(obj))
            PathLog.info("Title: '%s'" % opTitle)
            toolbox.setWindowTitle(opTitle)
            if opPage.getIcon(obj):
                toolbox.setWindowIcon(QtGui.QIcon(opPage.getIcon(obj)))

            self.form = toolbox
        elif taskPanelLayout == 2:
            forms = []
            for page in self.featurePages:
                page.form.setWindowTitle(page.getTitle(obj))
                forms.append(page.form)
            self.form = forms
        elif taskPanelLayout == 3:
            forms = []
            for page in reversed(self.featurePages):
                page.form.setWindowTitle(page.getTitle(obj))
                forms.append(page.form)
            self.form = forms

        self.selectionFactory = selectionFactory
        self.obj = obj
        self.isdirty = deleteOnReject
예제 #52
0
 def exists(cls, processor):
     return processor in PathPreferences.allAvailablePostProcessors()
예제 #53
0
    def __init__(self, obj, deleteOnReject, opPage, selectionFactory):
        PathLog.track(obj.Label, deleteOnReject, opPage, selectionFactory)
        FreeCAD.ActiveDocument.openTransaction(
            translate("Path", "AreaOp Operation"))
        self.deleteOnReject = deleteOnReject
        self.featurePages = []

        features = obj.Proxy.opFeatures(obj)
        opPage.features = features

        if PathOp.FeatureBaseGeometry & features:
            if hasattr(opPage, 'taskPanelBaseGeometryPage'):
                self.featurePages.append(
                    opPage.taskPanelBaseGeometryPage(obj, features))
            else:
                self.featurePages.append(
                    TaskPanelBaseGeometryPage(obj, features))

        if PathOp.FeatureLocations & features:
            if hasattr(opPage, 'taskPanelBaseLocationPage'):
                self.featurePages.append(
                    opPage.taskPanelBaseLocationPage(obj, features))
            else:
                self.featurePages.append(
                    TaskPanelBaseLocationPage(obj, features))

        if PathOp.FeatureDepths & features:
            if hasattr(opPage, 'taskPanelDepthsPage'):
                self.featurePages.append(
                    opPage.taskPanelDepthsPage(obj, features))
            else:
                self.featurePages.append(TaskPanelDepthsPage(obj, features))

        if PathOp.FeatureHeights & features:
            if hasattr(opPage, 'taskPanelHeightsPage'):
                self.featurePages.append(
                    opPage.taskPanelHeightsPage(obj, features))
            else:
                self.featurePages.append(TaskPanelHeightsPage(obj, features))

        self.featurePages.append(opPage)

        for page in self.featurePages:
            page.initPage(obj)
            page.onDirtyChanged(self.pageDirtyChanged)

        taskPanelLayout = PathPreferences.defaultTaskPanelLayout()

        if taskPanelLayout < 2:
            opTitle = opPage.getTitle(obj)
            opPage.setTitle(translate('PathOp', 'Operation'))
            toolbox = QtGui.QToolBox()
            if taskPanelLayout == 0:
                for page in self.featurePages:
                    toolbox.addItem(page.form, page.getTitle(obj))
                toolbox.setCurrentIndex(len(self.featurePages) - 1)
            else:
                for page in reversed(self.featurePages):
                    toolbox.addItem(page.form, page.getTitle(obj))
            PathLog.info("Title: '%s'" % opTitle)
            toolbox.setWindowTitle(opTitle)
            if opPage.getIcon(obj):
                toolbox.setWindowIcon(QtGui.QIcon(opPage.getIcon(obj)))

            self.form = toolbox
        elif taskPanelLayout == 2:
            forms = []
            for page in self.featurePages:
                page.form.setWindowTitle(page.getTitle(obj))
                forms.append(page.form)
            self.form = forms
        elif taskPanelLayout == 3:
            forms = []
            for page in reversed(self.featurePages):
                page.form.setWindowTitle(page.getTitle(obj))
                forms.append(page.form)
            self.form = forms

        self.selectionFactory = selectionFactory
        self.obj = obj
        self.isdirty = deleteOnReject
예제 #54
0
    def loadStockSettings(self):
        stock = PathPreferences.defaultStockTemplate()
        index = -1
        if stock:
            attrs = json.loads(stock)
            if attrs.get('version') and 1 == int(attrs['version']):
                stockType = attrs.get('create')
                if stockType == PathStock.StockType.FromBase:
                    index = 2
                elif stockType == PathStock.StockType.CreateBox:
                    index = 0
                elif stockType == PathStock.StockType.CreateCylinder:
                    index = 1
                else:
                    index = -1
        if -1 == index:
            attrs = {}
            self.form.stockGroup.setChecked(False)
        else:
            self.form.stockGroup.setChecked(True)
            self.form.stock.setCurrentIndex(index)

        # this either sets the default value or the value from the template for each field
        self.form.stockExtXneg.setText(attrs.get('xneg', '1 mm'))
        self.form.stockExtXpos.setText(attrs.get('xpos', '1 mm'))
        self.form.stockExtYneg.setText(attrs.get('yneg', '1 mm'))
        self.form.stockExtYpos.setText(attrs.get('ypos', '1 mm'))
        self.form.stockExtZneg.setText(attrs.get('zneg', '1 mm'))
        self.form.stockExtZpos.setText(attrs.get('zpos', '1 mm'))
        self.form.stockBoxLength.setText(attrs.get('length', '10 mm'))
        self.form.stockBoxWidth.setText(attrs.get('width', '10 mm'))
        self.form.stockBoxHeight.setText(attrs.get('height', '10 mm'))
        self.form.stockCylinderRadius.setText(attrs.get('radius', '5 mm'))
        self.form.stockCylinderHeight.setText(attrs.get('height', '10 mm'))

        posX = attrs.get('posX')
        posY = attrs.get('posY')
        posZ = attrs.get('posZ')
        rotX = attrs.get('rotX')
        rotY = attrs.get('rotY')
        rotZ = attrs.get('rotZ')
        rotW = attrs.get('rotW')
        if posX is not None and posY is not None and posZ is not None and rotX is not None and rotY is not None and rotZ is not None and rotW is not None:
            pos = FreeCAD.Vector(float(posX), float(posY), float(posZ))
            rot = FreeCAD.Rotation(float(rotX), float(rotY), float(rotZ),
                                   float(rotW))
            placement = FreeCAD.Placement(pos, rot)
            self.form.stockPlacementGroup.setChecked(True)
        else:
            placement = FreeCAD.Placement()
            self.form.stockPlacementGroup.setChecked(False)

        self.form.stockAngle.setText(
            FreeCAD.Units.Quantity("%f rad" %
                                   placement.Rotation.Angle).UserString)
        self.form.stockAxisX.setValue(placement.Rotation.Axis.x)
        self.form.stockAxisY.setValue(placement.Rotation.Axis.y)
        self.form.stockAxisZ.setValue(placement.Rotation.Axis.z)
        self.form.stockPositionX.setText(
            FreeCAD.Units.Quantity(placement.Base.x,
                                   FreeCAD.Units.Length).UserString)
        self.form.stockPositionY.setText(
            FreeCAD.Units.Quantity(placement.Base.y,
                                   FreeCAD.Units.Length).UserString)
        self.form.stockPositionZ.setText(
            FreeCAD.Units.Quantity(placement.Base.z,
                                   FreeCAD.Units.Length).UserString)

        self.setupStock(index)
        self.form.stock.currentIndexChanged.connect(self.setupStock)
예제 #55
0
 def defaultRadius(cls, ifNotSet = 0.0):
     return PathPreferences.preferences().GetFloat(cls.DefaultHoldingTagRadius, ifNotSet)