Removed PathPreferences class and moved functionality into the module interface.
This commit is contained in:
@@ -36,7 +36,7 @@ class PathWorkbench (Workbench):
|
||||
FreeCADGui.addPreferencePage(PathPreferencesPathDressup.DressupPreferencesPage, "Path")
|
||||
|
||||
# Check enablement of experimental features
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
from PathScripts import PathPreferences
|
||||
|
||||
# load the builtin modules
|
||||
import Path
|
||||
|
||||
@@ -31,9 +31,9 @@ import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathGetPoint as PathGetPoint
|
||||
import PathScripts.PathDressupHoldingTags as PathDressupTag
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
from PySide import QtCore, QtGui
|
||||
from pivy import coin
|
||||
|
||||
|
||||
@@ -24,8 +24,9 @@
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathPreferencesPathDressup as PathPreferencesPathDressup
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
|
||||
from PySide import QtCore
|
||||
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ import Path
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathOp as PathOp
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import TechDraw
|
||||
import traceback
|
||||
|
||||
from DraftGeomUtils import geomType
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
from PySide import QtCore
|
||||
|
||||
__doc__ = "Class and implementation of Path Engrave operation"
|
||||
|
||||
@@ -27,13 +27,13 @@ import Draft
|
||||
import FreeCAD
|
||||
import PathScripts.PathIconViewProvider as PathIconViewProvider
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathSetupSheet as PathSetupSheet
|
||||
import PathScripts.PathStock as PathStock
|
||||
import PathScripts.PathToolController as PathToolController
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import json
|
||||
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
from PathScripts.PathPostProcessor import PostProcessor
|
||||
from PySide import QtCore
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ import FreeCAD
|
||||
import FreeCADGui
|
||||
import PathScripts.PathJob as PathJob
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathStock as PathStock
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
# Qt tanslation handling
|
||||
|
||||
@@ -30,6 +30,7 @@ import PathScripts.PathJob as PathJob
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathGui as PathGui
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathStock as PathStock
|
||||
import PathScripts.PathToolController as PathToolController
|
||||
import PathScripts.PathToolLibraryManager as PathToolLibraryManager
|
||||
@@ -38,7 +39,6 @@ import PathScripts.PathUtils as PathUtils
|
||||
import math
|
||||
import sys
|
||||
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
from PySide import QtCore, QtGui
|
||||
from pivy import coin
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathGetPoint as PathGetPoint
|
||||
import PathScripts.PathGui as PathGui
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathSelection as PathSelection
|
||||
import PathScripts.PathOp as PathOp
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathSelection as PathSelection
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import importlib
|
||||
|
||||
from PySide import QtCore, QtGui
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
|
||||
__title__ = "Path Operation UI base classes"
|
||||
__author__ = "sliptonic (Brad Collette)"
|
||||
|
||||
@@ -27,15 +27,15 @@ from __future__ import print_function
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import PathScripts.PathJob as PathJob
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathToolController as PathToolController
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import os
|
||||
|
||||
from PathScripts import PathJob
|
||||
from PathScripts import PathToolController
|
||||
from PathScripts import PathUtils
|
||||
from PathScripts.PathPostProcessor import PostProcessor
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
|
||||
|
||||
@@ -24,10 +24,9 @@
|
||||
|
||||
import FreeCAD
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import sys
|
||||
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
|
||||
class PostProcessor:
|
||||
|
||||
@@ -30,165 +30,139 @@ import PathScripts.PathLog as PathLog
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
#PathLog.trackModule()
|
||||
|
||||
class PathPreferences:
|
||||
DefaultFilePath = "DefaultFilePath"
|
||||
DefaultJobTemplate = "DefaultJobTemplate"
|
||||
DefaultStockTemplate = "DefaultStockTemplate"
|
||||
DefaultTaskPanelLayout = "DefaultTaskPanelLayout"
|
||||
DefaultFilePath = "DefaultFilePath"
|
||||
DefaultJobTemplate = "DefaultJobTemplate"
|
||||
DefaultStockTemplate = "DefaultStockTemplate"
|
||||
DefaultTaskPanelLayout = "DefaultTaskPanelLayout"
|
||||
|
||||
PostProcessorDefault = "PostProcessorDefault"
|
||||
PostProcessorDefaultArgs = "PostProcessorDefaultArgs"
|
||||
PostProcessorBlacklist = "PostProcessorBlacklist"
|
||||
PostProcessorOutputFile = "PostProcessorOutputFile"
|
||||
PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
|
||||
PostProcessorDefault = "PostProcessorDefault"
|
||||
PostProcessorDefaultArgs = "PostProcessorDefaultArgs"
|
||||
PostProcessorBlacklist = "PostProcessorBlacklist"
|
||||
PostProcessorOutputFile = "PostProcessorOutputFile"
|
||||
PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
|
||||
|
||||
# Linear tolerance to use when generating Paths, eg when tessellating geometry
|
||||
GeometryTolerance = "GeometryTolerance"
|
||||
LibAreaCurveAccuracy = "LibAreaCurveAccuarcy"
|
||||
# Linear tolerance to use when generating Paths, eg when tessellating geometry
|
||||
GeometryTolerance = "GeometryTolerance"
|
||||
LibAreaCurveAccuracy = "LibAreaCurveAccuarcy"
|
||||
|
||||
EnableExperimentalFeatures = "EnableExperimentalFeatures"
|
||||
EnableExperimentalFeatures = "EnableExperimentalFeatures"
|
||||
|
||||
|
||||
@classmethod
|
||||
def preferences(cls):
|
||||
return FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
|
||||
def preferences():
|
||||
return FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
|
||||
|
||||
@classmethod
|
||||
def pathScriptsSourcePath(cls):
|
||||
return FreeCAD.getHomePath() + ("Mod/Path/PathScripts/")
|
||||
def pathScriptsSourcePath():
|
||||
return FreeCAD.getHomePath() + ("Mod/Path/PathScripts/")
|
||||
|
||||
@classmethod
|
||||
def pathScriptsPostSourcePath(cls):
|
||||
return cls.pathScriptsSourcePath() + ("/post/")
|
||||
def pathScriptsPostSourcePath():
|
||||
return pathScriptsSourcePath() + ("/post/")
|
||||
|
||||
@classmethod
|
||||
def allAvailablePostProcessors(cls):
|
||||
allposts = []
|
||||
for path in cls.searchPaths():
|
||||
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 allAvailablePostProcessors():
|
||||
allposts = []
|
||||
for path in searchPaths():
|
||||
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
|
||||
|
||||
@classmethod
|
||||
def allEnabledPostProcessors(cls, include = None):
|
||||
blacklist = cls.postProcessorBlacklist()
|
||||
enabled = [processor for processor in cls.allAvailablePostProcessors() if not processor in blacklist]
|
||||
if include:
|
||||
l = list(set(include + enabled))
|
||||
l.sort()
|
||||
return l
|
||||
return enabled
|
||||
def allEnabledPostProcessors(include = None):
|
||||
blacklist = postProcessorBlacklist()
|
||||
enabled = [processor for processor in allAvailablePostProcessors() if not processor in blacklist]
|
||||
if include:
|
||||
l = list(set(include + enabled))
|
||||
l.sort()
|
||||
return l
|
||||
return enabled
|
||||
|
||||
|
||||
@classmethod
|
||||
def defaultPostProcessor(cls):
|
||||
pref = cls.preferences()
|
||||
return pref.GetString(cls.PostProcessorDefault, "")
|
||||
def defaultPostProcessor():
|
||||
pref = preferences()
|
||||
return pref.GetString(PostProcessorDefault, "")
|
||||
|
||||
@classmethod
|
||||
def defaultPostProcessorArgs(cls):
|
||||
pref = cls.preferences()
|
||||
return pref.GetString(cls.PostProcessorDefaultArgs, "")
|
||||
def defaultPostProcessorArgs():
|
||||
pref = preferences()
|
||||
return pref.GetString(PostProcessorDefaultArgs, "")
|
||||
|
||||
@classmethod
|
||||
def defaultGeometryTolerance(cls):
|
||||
return cls.preferences().GetFloat(cls.GeometryTolerance, 0.01)
|
||||
def defaultGeometryTolerance():
|
||||
return preferences().GetFloat(GeometryTolerance, 0.01)
|
||||
|
||||
@classmethod
|
||||
def defaultLibAreaCurveAccuracy(cls):
|
||||
return cls.preferences().GetFloat(cls.LibAreaCurveAccuracy, 0.01)
|
||||
def defaultLibAreaCurveAccuracy():
|
||||
return preferences().GetFloat(LibAreaCurveAccuracy, 0.01)
|
||||
|
||||
@classmethod
|
||||
def defaultFilePath(cls):
|
||||
return cls.preferences().GetString(cls.DefaultFilePath)
|
||||
def defaultFilePath():
|
||||
return preferences().GetString(DefaultFilePath)
|
||||
|
||||
@classmethod
|
||||
def filePath(cls):
|
||||
path = cls.defaultFilePath()
|
||||
if not path:
|
||||
path = cls.macroFilePath()
|
||||
return path
|
||||
def filePath():
|
||||
path = defaultFilePath()
|
||||
if not path:
|
||||
path = macroFilePath()
|
||||
return path
|
||||
|
||||
@classmethod
|
||||
def macroFilePath(cls):
|
||||
grp = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")
|
||||
return grp.GetString("MacroPath", FreeCAD.getUserMacroDir())
|
||||
def macroFilePath():
|
||||
grp = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")
|
||||
return grp.GetString("MacroPath", FreeCAD.getUserMacroDir())
|
||||
|
||||
@classmethod
|
||||
def searchPaths(cls):
|
||||
paths = []
|
||||
p = cls.defaultFilePath()
|
||||
if p:
|
||||
paths.append(p)
|
||||
paths.append(cls.macroFilePath())
|
||||
paths.append(cls.pathScriptsPostSourcePath())
|
||||
paths.append(cls.pathScriptsSourcePath())
|
||||
return paths
|
||||
def searchPaths():
|
||||
paths = []
|
||||
p = defaultFilePath()
|
||||
if p:
|
||||
paths.append(p)
|
||||
paths.append(macroFilePath())
|
||||
paths.append(pathScriptsPostSourcePath())
|
||||
paths.append(pathScriptsSourcePath())
|
||||
return paths
|
||||
|
||||
@classmethod
|
||||
def defaultJobTemplate(cls):
|
||||
template = cls.preferences().GetString(cls.DefaultJobTemplate)
|
||||
if 'xml' not in template:
|
||||
return template
|
||||
return ''
|
||||
def defaultJobTemplate():
|
||||
template = preferences().GetString(DefaultJobTemplate)
|
||||
if 'xml' not in template:
|
||||
return template
|
||||
return ''
|
||||
|
||||
@classmethod
|
||||
def setJobDefaults(cls, filePath, jobTemplate, geometryTolerance, curveAccuracy):
|
||||
PathLog.track("(%s='%s', %s, %s, %s)" % (cls.DefaultFilePath, filePath, jobTemplate, geometryTolerance, curveAccuracy))
|
||||
pref = cls.preferences()
|
||||
pref.SetString(cls.DefaultFilePath, filePath)
|
||||
pref.SetString(cls.DefaultJobTemplate, jobTemplate)
|
||||
pref.SetFloat(cls.GeometryTolerance, geometryTolerance)
|
||||
pref.SetFloat(cls.LibAreaCurveAccuracy, curveAccuracy)
|
||||
def setJobDefaults(filePath, jobTemplate, geometryTolerance, curveAccuracy):
|
||||
PathLog.track("(%s='%s', %s, %s, %s)" % (DefaultFilePath, filePath, jobTemplate, geometryTolerance, curveAccuracy))
|
||||
pref = preferences()
|
||||
pref.SetString(DefaultFilePath, filePath)
|
||||
pref.SetString(DefaultJobTemplate, jobTemplate)
|
||||
pref.SetFloat(GeometryTolerance, geometryTolerance)
|
||||
pref.SetFloat(LibAreaCurveAccuracy, curveAccuracy)
|
||||
|
||||
@classmethod
|
||||
def postProcessorBlacklist(cls):
|
||||
pref = cls.preferences()
|
||||
blacklist = pref.GetString(cls.PostProcessorBlacklist, "")
|
||||
if not blacklist:
|
||||
return []
|
||||
return eval(blacklist)
|
||||
def postProcessorBlacklist():
|
||||
pref = preferences()
|
||||
blacklist = pref.GetString(PostProcessorBlacklist, "")
|
||||
if not blacklist:
|
||||
return []
|
||||
return eval(blacklist)
|
||||
|
||||
@classmethod
|
||||
def setPostProcessorDefaults(cls, processor, args, blacklist):
|
||||
pref = cls.preferences()
|
||||
pref.SetString(cls.PostProcessorDefault, processor)
|
||||
pref.SetString(cls.PostProcessorDefaultArgs, args)
|
||||
pref.SetString(cls.PostProcessorBlacklist, "%s" % (blacklist))
|
||||
def setPostProcessorDefaults(processor, args, blacklist):
|
||||
pref = preferences()
|
||||
pref.SetString(PostProcessorDefault, processor)
|
||||
pref.SetString(PostProcessorDefaultArgs, args)
|
||||
pref.SetString(PostProcessorBlacklist, "%s" % (blacklist))
|
||||
|
||||
|
||||
@classmethod
|
||||
def setOutputFileDefaults(cls, file, policy):
|
||||
pref = cls.preferences()
|
||||
pref.SetString(cls.PostProcessorOutputFile, file)
|
||||
pref.SetString(cls.PostProcessorOutputPolicy, policy)
|
||||
def setOutputFileDefaults(file, policy):
|
||||
pref = preferences()
|
||||
pref.SetString(PostProcessorOutputFile, file)
|
||||
pref.SetString(PostProcessorOutputPolicy, policy)
|
||||
|
||||
@classmethod
|
||||
def defaultOutputFile(cls):
|
||||
pref = cls.preferences()
|
||||
return pref.GetString(cls.PostProcessorOutputFile, "")
|
||||
def defaultOutputFile():
|
||||
pref = preferences()
|
||||
return pref.GetString(PostProcessorOutputFile, "")
|
||||
|
||||
@classmethod
|
||||
def defaultOutputPolicy(cls):
|
||||
pref = cls.preferences()
|
||||
return pref.GetString(cls.PostProcessorOutputPolicy, "")
|
||||
def defaultOutputPolicy():
|
||||
pref = preferences()
|
||||
return pref.GetString(PostProcessorOutputPolicy, "")
|
||||
|
||||
@classmethod
|
||||
def defaultStockTemplate(cls):
|
||||
return cls.preferences().GetString(cls.DefaultStockTemplate, "")
|
||||
@classmethod
|
||||
def setDefaultStockTemplate(cls, template):
|
||||
cls.preferences().SetString(cls.DefaultStockTemplate, template)
|
||||
def defaultStockTemplate():
|
||||
return preferences().GetString(DefaultStockTemplate, "")
|
||||
def setDefaultStockTemplate(template):
|
||||
preferences().SetString(DefaultStockTemplate, template)
|
||||
|
||||
@classmethod
|
||||
def defaultTaskPanelLayout(cls):
|
||||
return cls.preferences().GetInt(cls.DefaultTaskPanelLayout, 0)
|
||||
@classmethod
|
||||
def setDefaultTaskPanelLayout(cls, style):
|
||||
cls.preferences().SetInt(cls.DefaultTaskPanelLayout, style)
|
||||
def defaultTaskPanelLayout():
|
||||
return preferences().GetInt(DefaultTaskPanelLayout, 0)
|
||||
def setDefaultTaskPanelLayout(style):
|
||||
preferences().SetInt(DefaultTaskPanelLayout, style)
|
||||
|
||||
@classmethod
|
||||
def experimentalFeaturesEnabled(cls):
|
||||
return cls.preferences().GetBool(cls.EnableExperimentalFeatures, False)
|
||||
def experimentalFeaturesEnabled():
|
||||
return preferences().GetBool(EnableExperimentalFeatures, False)
|
||||
|
||||
|
||||
@@ -24,8 +24,9 @@
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
|
||||
from PySide import QtCore, QtGui
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
|
||||
# Qt tanslation handling
|
||||
def translate(context, text, disambig=None):
|
||||
|
||||
@@ -26,12 +26,12 @@ import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathStock as PathStock
|
||||
import json
|
||||
|
||||
from FreeCAD import Units
|
||||
from PySide import QtCore, QtGui
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
from PathScripts.PathPostProcessor import PostProcessor
|
||||
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class ObjectSurface(PathOp.ObjectOp):
|
||||
try:
|
||||
deflection = parentJob.GeometryTolerance
|
||||
except AttributeError:
|
||||
from PathScripts.PathPreferences import PathPreferences
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
deflection = PathPreferences.defaultGeometryTolerance()
|
||||
self.baseobject.Shape.tessellate(0.5)
|
||||
mesh = MeshPart.meshFromShape(self.baseobject.Shape, Deflection=deflection)
|
||||
|
||||
@@ -49,6 +49,8 @@ EXTERNAL_MODULES+=' DraftGeomUtils'
|
||||
EXTERNAL_MODULES+=' DraftVecUtils'
|
||||
EXTERNAL_MODULES+=' FreeCAD'
|
||||
EXTERNAL_MODULES+=' FreeCADGui'
|
||||
EXTERNAL_MODULES+=' Mesh'
|
||||
EXTERNAL_MODULES+=' MeshPart'
|
||||
EXTERNAL_MODULES+=' Part'
|
||||
EXTERNAL_MODULES+=' Path'
|
||||
EXTERNAL_MODULES+=' PySide.QtCore'
|
||||
|
||||
Reference in New Issue
Block a user