Basic workflow. No editing
concept dock work most functions working. made linuxcnc export work Fixed some defaults on new install fixed display label in dock
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2014 Yorik van Havre <yorik@uncreated.net> *
|
||||
# * *
|
||||
# * This program is free software; you can redistribute it and/or modify *
|
||||
@@ -42,15 +44,19 @@ PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
|
||||
LastPathToolBit = "LastPathToolBit"
|
||||
LastPathToolLibrary = "LastPathToolLibrary"
|
||||
LastPathToolShape = "LastPathToolShape"
|
||||
LastPathToolTable ="LastPathToolTable"
|
||||
LastPathToolTable = "LastPathToolTable"
|
||||
|
||||
LastFileToolBit = "LastFileToolBit"
|
||||
LastFileToolLibrary = "LastFileToolLibrary"
|
||||
LastFileToolShape = "LastFileToolShape"
|
||||
|
||||
UseLegacyTools = "UseLegacyTools"
|
||||
UseAbsoluteToolPaths = "UseAbsoluteToolPaths"
|
||||
OpenLastLibrary = "OpenLastLibrary"
|
||||
|
||||
# Linear tolerance to use when generating Paths, eg when tessellating geometry
|
||||
GeometryTolerance = "GeometryTolerance"
|
||||
LibAreaCurveAccuracy = "LibAreaCurveAccuarcy"
|
||||
GeometryTolerance = "GeometryTolerance"
|
||||
LibAreaCurveAccuracy = "LibAreaCurveAccuarcy"
|
||||
|
||||
EnableExperimentalFeatures = "EnableExperimentalFeatures"
|
||||
|
||||
@@ -58,58 +64,70 @@ EnableExperimentalFeatures = "EnableExperimentalFeatures"
|
||||
def preferences():
|
||||
return FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
|
||||
|
||||
|
||||
def pathScriptsSourcePath():
|
||||
return os.path.join(FreeCAD.getHomePath(), "Mod/Path/PathScripts/")
|
||||
|
||||
|
||||
def pathDefaultToolsPath(sub=None):
|
||||
if sub:
|
||||
return os.path.join(FreeCAD.getHomePath(), "Mod/Path/Tools/", sub)
|
||||
return os.path.join(FreeCAD.getHomePath(), "Mod/Path/Tools/")
|
||||
|
||||
|
||||
def allAvailablePostProcessors():
|
||||
allposts = []
|
||||
for path in searchPathsPost():
|
||||
posts = [ str(os.path.split(os.path.splitext(p)[0])[1][:-5]) for p in glob.glob(path + '/*_post.py')]
|
||||
posts = [str(os.path.split(os.path.splitext(p)[0])[1][:-5]) for p in glob.glob(path + '/*_post.py')]
|
||||
allposts.extend(posts)
|
||||
allposts.sort()
|
||||
return allposts
|
||||
|
||||
def allEnabledPostProcessors(include = None):
|
||||
|
||||
def allEnabledPostProcessors(include=None):
|
||||
blacklist = postProcessorBlacklist()
|
||||
enabled = [processor for processor in allAvailablePostProcessors() if not processor in blacklist]
|
||||
enabled = [processor for processor in allAvailablePostProcessors() if processor not in blacklist]
|
||||
if include:
|
||||
l = list(set(include + enabled))
|
||||
l.sort()
|
||||
return l
|
||||
postlist = list(set(include + enabled))
|
||||
postlist.sort()
|
||||
return postlist
|
||||
return enabled
|
||||
|
||||
|
||||
def defaultPostProcessor():
|
||||
pref = preferences()
|
||||
return pref.GetString(PostProcessorDefault, "")
|
||||
|
||||
|
||||
def defaultPostProcessorArgs():
|
||||
pref = preferences()
|
||||
return pref.GetString(PostProcessorDefaultArgs, "")
|
||||
|
||||
|
||||
def defaultGeometryTolerance():
|
||||
return preferences().GetFloat(GeometryTolerance, 0.01)
|
||||
|
||||
|
||||
def defaultLibAreaCurveAccuracy():
|
||||
return preferences().GetFloat(LibAreaCurveAccuracy, 0.01)
|
||||
|
||||
|
||||
def defaultFilePath():
|
||||
return preferences().GetString(DefaultFilePath)
|
||||
|
||||
|
||||
def filePath():
|
||||
path = defaultFilePath()
|
||||
if not path:
|
||||
path = macroFilePath()
|
||||
return path
|
||||
|
||||
|
||||
def macroFilePath():
|
||||
grp = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")
|
||||
return grp.GetString("MacroPath", FreeCAD.getUserMacroDir())
|
||||
|
||||
|
||||
def searchPaths():
|
||||
paths = []
|
||||
p = defaultFilePath()
|
||||
@@ -118,6 +136,7 @@ def searchPaths():
|
||||
paths.append(macroFilePath())
|
||||
return paths
|
||||
|
||||
|
||||
def searchPathsPost():
|
||||
paths = []
|
||||
p = defaultFilePath()
|
||||
@@ -128,6 +147,7 @@ def searchPathsPost():
|
||||
paths.append(pathScriptsSourcePath())
|
||||
return paths
|
||||
|
||||
|
||||
def searchPathsTool(sub='Bit'):
|
||||
paths = []
|
||||
|
||||
@@ -148,30 +168,37 @@ def searchPathsTool(sub='Bit'):
|
||||
appendPath(os.path.join(FreeCAD.getHomePath(), "Mod/Path/"), sub)
|
||||
return paths
|
||||
|
||||
|
||||
def toolsUseLegacyTools():
|
||||
return preferences().GetBool(UseLegacyTools, True)
|
||||
return preferences().GetBool(UseLegacyTools, False)
|
||||
|
||||
|
||||
def toolsReallyUseLegacyTools():
|
||||
return toolsUseLegacyTools() or not experimentalFeaturesEnabled()
|
||||
return toolsUseLegacyTools()
|
||||
|
||||
|
||||
def toolsStoreAbsolutePaths():
|
||||
return preferences().GetBool(UseAbsoluteToolPaths, False)
|
||||
|
||||
|
||||
def toolsOpenLastLibrary():
|
||||
return preferences().GetBool(OpenLastLibrary, False)
|
||||
|
||||
|
||||
def setToolsSettings(legacy, relative, lastlibrary):
|
||||
pref = preferences()
|
||||
pref.SetBool(UseLegacyTools, legacy)
|
||||
pref.SetBool(UseAbsoluteToolPaths, relative)
|
||||
pref.SetBool(OpenLastLibrary, lastlibrary)
|
||||
|
||||
|
||||
def defaultJobTemplate():
|
||||
template = preferences().GetString(DefaultJobTemplate)
|
||||
if 'xml' not in template:
|
||||
return template
|
||||
return ''
|
||||
|
||||
|
||||
def setJobDefaults(fileName, jobTemplate, geometryTolerance, curveAccuracy):
|
||||
PathLog.track("(%s='%s', %s, %s, %s)" % (DefaultFilePath, fileName, jobTemplate, geometryTolerance, curveAccuracy))
|
||||
pref = preferences()
|
||||
@@ -180,12 +207,14 @@ def setJobDefaults(fileName, jobTemplate, geometryTolerance, curveAccuracy):
|
||||
pref.SetFloat(GeometryTolerance, geometryTolerance)
|
||||
pref.SetFloat(LibAreaCurveAccuracy, curveAccuracy)
|
||||
|
||||
|
||||
def postProcessorBlacklist():
|
||||
pref = preferences()
|
||||
blacklist = pref.GetString(PostProcessorBlacklist, "")
|
||||
if not blacklist:
|
||||
return []
|
||||
return eval(blacklist) # pylint: disable=eval-used
|
||||
return eval(blacklist) # pylint: disable=eval-used
|
||||
|
||||
|
||||
def setPostProcessorDefaults(processor, args, blacklist):
|
||||
pref = preferences()
|
||||
@@ -193,54 +222,99 @@ def setPostProcessorDefaults(processor, args, blacklist):
|
||||
pref.SetString(PostProcessorDefaultArgs, args)
|
||||
pref.SetString(PostProcessorBlacklist, "%s" % (blacklist))
|
||||
|
||||
|
||||
def setOutputFileDefaults(fileName, policy):
|
||||
pref = preferences()
|
||||
pref.SetString(PostProcessorOutputFile, fileName)
|
||||
pref.SetString(PostProcessorOutputPolicy, policy)
|
||||
|
||||
|
||||
def defaultOutputFile():
|
||||
pref = preferences()
|
||||
return pref.GetString(PostProcessorOutputFile, "")
|
||||
|
||||
|
||||
def defaultOutputPolicy():
|
||||
pref = preferences()
|
||||
return pref.GetString(PostProcessorOutputPolicy, "")
|
||||
|
||||
|
||||
def defaultStockTemplate():
|
||||
return preferences().GetString(DefaultStockTemplate, "")
|
||||
|
||||
|
||||
def setDefaultStockTemplate(template):
|
||||
preferences().SetString(DefaultStockTemplate, template)
|
||||
|
||||
|
||||
def defaultTaskPanelLayout():
|
||||
return preferences().GetInt(DefaultTaskPanelLayout, 0)
|
||||
|
||||
|
||||
def setDefaultTaskPanelLayout(style):
|
||||
preferences().SetInt(DefaultTaskPanelLayout, style)
|
||||
|
||||
|
||||
def experimentalFeaturesEnabled():
|
||||
return preferences().GetBool(EnableExperimentalFeatures, False)
|
||||
|
||||
|
||||
def lastFileToolLibrary():
|
||||
filename = preferences().GetString(LastFileToolLibrary)
|
||||
if filename.endswith('.fctl') and os.path.isfile(filename):
|
||||
return filename
|
||||
|
||||
libpath = preferences().GetString(LastPathToolLibrary, pathDefaultToolsPath('Library'))
|
||||
libFiles = [f for f in glob.glob(libpath + '/*.fctl')]
|
||||
libFiles.sort()
|
||||
if len(libFiles) >= 1:
|
||||
filename = libFiles[0]
|
||||
setLastFileToolLibrary(filename)
|
||||
PathLog.track(filename)
|
||||
return filename
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def setLastFileToolLibrary(path):
|
||||
PathLog.track(path)
|
||||
if os.path.isfile(path): # keep the path and file in sync
|
||||
preferences().SetString(LastPathToolLibrary, os.path.split(path)[0])
|
||||
return preferences().SetString(LastFileToolLibrary, path)
|
||||
|
||||
|
||||
def lastPathToolBit():
|
||||
return preferences().GetString(LastPathToolBit, pathDefaultToolsPath('Bit'))
|
||||
|
||||
|
||||
def setLastPathToolBit(path):
|
||||
return preferences().SetString(LastPathToolBit, path)
|
||||
|
||||
|
||||
def lastPathToolLibrary():
|
||||
PathLog.track()
|
||||
return preferences().GetString(LastPathToolLibrary, pathDefaultToolsPath('Library'))
|
||||
|
||||
|
||||
def setLastPathToolLibrary(path):
|
||||
PathLog.track(path)
|
||||
curLib = lastFileToolLibrary()
|
||||
if os.path.split(curLib)[0] != path:
|
||||
setLastFileToolLibrary('') # a path is known but not specific file
|
||||
return preferences().SetString(LastPathToolLibrary, path)
|
||||
|
||||
|
||||
def lastPathToolShape():
|
||||
return preferences().GetString(LastPathToolShape, pathDefaultToolsPath('Shape'))
|
||||
|
||||
|
||||
def setLastPathToolShape(path):
|
||||
return preferences().SetString(LastPathToolShape, path)
|
||||
|
||||
|
||||
def lastPathToolTable():
|
||||
return preferences().GetString(LastPathToolTable, "")
|
||||
|
||||
|
||||
def setLastPathToolTable(table):
|
||||
return preferences().SetString(LastPathToolTable, table)
|
||||
|
||||
Reference in New Issue
Block a user