surface and waterline translation
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
# ***************************************************************************
|
||||
|
||||
from __future__ import print_function
|
||||
from PySide import QtCore
|
||||
import FreeCAD
|
||||
|
||||
__title__ = "Path Waterline Operation"
|
||||
__author__ = "russ4262 (Russell Johnson), sliptonic (Brad Collette)"
|
||||
@@ -29,28 +31,24 @@ __url__ = "http://www.freecadweb.org"
|
||||
__doc__ = "Class and implementation of Waterline operation."
|
||||
__contributors__ = ""
|
||||
|
||||
import FreeCAD
|
||||
from PySide import QtCore
|
||||
|
||||
# OCL must be installed
|
||||
try:
|
||||
import ocl
|
||||
except ImportError:
|
||||
msg = QtCore.QCoreApplication.translate(
|
||||
"PathWaterline", "This operation requires OpenCamLib to be installed."
|
||||
"path_waterline", "This operation requires OpenCamLib to be installed."
|
||||
)
|
||||
FreeCAD.Console.PrintError(msg + "\n")
|
||||
raise ImportError
|
||||
# import sys
|
||||
# sys.exit(msg)
|
||||
|
||||
import Path
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import PathScripts.PathOp as PathOp
|
||||
import PathScripts.PathSurfaceSupport as PathSurfaceSupport
|
||||
import time
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import math
|
||||
import time
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
# lazily loaded modules
|
||||
from lazy_loader.lazy_loader import LazyLoader
|
||||
@@ -60,13 +58,13 @@ Part = LazyLoader("Part", globals(), "Part")
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
# PathLog.trackModule(PathLog.thisModule())
|
||||
if False:
|
||||
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
|
||||
PathLog.trackModule(PathLog.thisModule())
|
||||
else:
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
|
||||
|
||||
# Qt translation handling
|
||||
def translate(context, text, disambig=None):
|
||||
return QtCore.QCoreApplication.translate(context, text, disambig)
|
||||
translate = FreeCAD.Qt.translate
|
||||
|
||||
|
||||
class ObjectWaterline(PathOp.ObjectOp):
|
||||
@@ -83,6 +81,79 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
| PathOp.FeatureBaseFaces
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def propertyEnumerations(self, dataType="data"):
|
||||
"""propertyEnumerations(dataType="data")... return property enumeration lists of specified dataType.
|
||||
Args:
|
||||
dataType = 'data', 'raw', 'translated'
|
||||
Notes:
|
||||
'data' is list of internal string literals used in code
|
||||
'raw' is list of (translated_text, data_string) tuples
|
||||
'translated' is list of translated string literals
|
||||
"""
|
||||
|
||||
# Enumeration lists for App::PropertyEnumeration properties
|
||||
enums = {
|
||||
"Algorithm": [
|
||||
(translate("path_waterline", "OCL Dropcutter"), "OCL Dropcutter"),
|
||||
(translate("path_waterline", "Experimental"), "Experimental"),
|
||||
],
|
||||
"BoundBox": [
|
||||
(translate("path_waterline", "BaseBoundBox"), "BaseBoundBox"),
|
||||
(translate("path_waterline", "Stock"), "Stock"),
|
||||
],
|
||||
"PatternCenterAt": [
|
||||
(translate("path_waterline", "CenterOfMass"), "CenterOfMass"),
|
||||
(translate("path_waterline", "CenterOfBoundBox"), "CenterOfBoundBox"),
|
||||
(translate("path_waterline", "XminYmin"), "XminYmin"),
|
||||
(translate("path_waterline", "Custom"), "Custom"),
|
||||
],
|
||||
"ClearLastLayer": [
|
||||
(translate("path_waterline", "Off"), "Off"),
|
||||
(translate("path_waterline", "Circular"), "Circular"),
|
||||
(translate("path_waterline", "CircularZigZag"), "CircularZigZag"),
|
||||
(translate("path_waterline", "Line"), "Line"),
|
||||
(translate("path_waterline", "Offset"), "Offset"),
|
||||
(translate("path_waterline", "Spiral"), "Spiral"),
|
||||
(translate("path_waterline", "ZigZag"), "ZigZag"),
|
||||
],
|
||||
"CutMode": [
|
||||
(translate("path_waterline", "Conventional"), "Conventional"),
|
||||
(translate("path_waterline", "Climb"), "Climb"),
|
||||
],
|
||||
"CutPattern": [
|
||||
(translate("path_waterline", "None"), "None"),
|
||||
(translate("path_waterline", "Circular"), "Circular"),
|
||||
(translate("path_waterline", "CircularZigZag"), "CircularZigZag"),
|
||||
(translate("path_waterline", "Line"), "Line"),
|
||||
(translate("path_waterline", "Offset"), "Offset"),
|
||||
(translate("path_waterline", "Spiral"), "Spiral"),
|
||||
(translate("path_waterline", "ZigZag"), "ZigZag"),
|
||||
],
|
||||
"HandleMultipleFeatures": [
|
||||
(translate("path_waterline", "Collectively"), "Collectively"),
|
||||
(translate("path_waterline", "Individually"), "Individually"),
|
||||
],
|
||||
"LayerMode": [
|
||||
(translate("path_waterline", "Single-pass"), "Single-pass"),
|
||||
(translate("path_waterline", "Multi-pass"), "Multi-pass"),
|
||||
],
|
||||
}
|
||||
|
||||
if dataType == "raw":
|
||||
return enums
|
||||
|
||||
data = list()
|
||||
idx = 0 if dataType == "translated" else 1
|
||||
|
||||
PathLog.debug(enums)
|
||||
|
||||
for k, v in enumerate(enums):
|
||||
data.append((v, [tup[idx] for tup in enums[v]]))
|
||||
PathLog.debug(data)
|
||||
|
||||
return data
|
||||
|
||||
def initOperation(self, obj):
|
||||
"""initOperation(obj) ... Initialize the operation by
|
||||
managing property creation and property editor status."""
|
||||
@@ -108,10 +179,10 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
|
||||
# Set enumeration lists for enumeration properties
|
||||
if len(self.addNewProps) > 0:
|
||||
ENUMS = self.opPropertyEnumerations()
|
||||
ENUMS = self.propertyEnumerations()
|
||||
for n in ENUMS:
|
||||
if n in self.addNewProps:
|
||||
setattr(obj, n, ENUMS[n])
|
||||
if n[0] in self.addNewProps:
|
||||
setattr(obj, n[0], n[1])
|
||||
|
||||
if warn:
|
||||
newPropMsg = translate("PathWaterline", "New property added to")
|
||||
@@ -128,7 +199,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyBool",
|
||||
"ShowTempObjects",
|
||||
"Debug",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Show the temporary path construction objects when module is in DEBUG mode.",
|
||||
),
|
||||
@@ -137,7 +208,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyDistance",
|
||||
"AngularDeflection",
|
||||
"Mesh Conversion",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Smaller values yield a finer, more accurate the mesh. Smaller values increase processing time a lot.",
|
||||
),
|
||||
@@ -146,7 +217,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyDistance",
|
||||
"LinearDeflection",
|
||||
"Mesh Conversion",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Smaller values yield a finer, more accurate the mesh. Smaller values do not increase processing time much.",
|
||||
),
|
||||
@@ -155,7 +226,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyInteger",
|
||||
"AvoidLastX_Faces",
|
||||
"Selected Geometry Settings",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Avoid cutting the last 'N' faces in the Base Geometry list of selected faces.",
|
||||
),
|
||||
@@ -164,7 +235,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyBool",
|
||||
"AvoidLastX_InternalFeatures",
|
||||
"Selected Geometry Settings",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property", "Do not cut internal features on avoided faces."
|
||||
),
|
||||
),
|
||||
@@ -172,7 +243,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyDistance",
|
||||
"BoundaryAdjustment",
|
||||
"Selected Geometry Settings",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Positive values push the cutter toward, or beyond, the boundary. Negative values retract the cutter away from the boundary.",
|
||||
),
|
||||
@@ -181,7 +252,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyBool",
|
||||
"BoundaryEnforcement",
|
||||
"Selected Geometry Settings",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"If true, the cutter will remain inside the boundaries of the model or selected face(s).",
|
||||
),
|
||||
@@ -190,7 +261,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyEnumeration",
|
||||
"HandleMultipleFeatures",
|
||||
"Selected Geometry Settings",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Choose how to process multiple Base Geometry features.",
|
||||
),
|
||||
@@ -199,7 +270,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyDistance",
|
||||
"InternalFeaturesAdjustment",
|
||||
"Selected Geometry Settings",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Positive values push the cutter toward, or into, the feature. Negative values retract the cutter away from the feature.",
|
||||
),
|
||||
@@ -208,7 +279,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyBool",
|
||||
"InternalFeaturesCut",
|
||||
"Selected Geometry Settings",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Cut internal feature areas within a larger selected face.",
|
||||
),
|
||||
@@ -217,7 +288,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyEnumeration",
|
||||
"Algorithm",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Select the algorithm to use: OCL Dropcutter*, or Experimental (Not OCL based).",
|
||||
),
|
||||
@@ -226,7 +297,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyEnumeration",
|
||||
"BoundBox",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property", "Select the overall boundary for the operation."
|
||||
),
|
||||
),
|
||||
@@ -234,7 +305,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyEnumeration",
|
||||
"ClearLastLayer",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Set to clear last layer in a `Multi-pass` operation.",
|
||||
),
|
||||
@@ -243,7 +314,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyEnumeration",
|
||||
"CutMode",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Set the direction for the cutting tool to engage the material: Climb (ClockWise) or Conventional (CounterClockWise)",
|
||||
),
|
||||
@@ -252,7 +323,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyEnumeration",
|
||||
"CutPattern",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Set the geometric clearing pattern to use for the operation.",
|
||||
),
|
||||
@@ -261,7 +332,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyFloat",
|
||||
"CutPatternAngle",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property", "The yaw angle used for certain clearing patterns"
|
||||
),
|
||||
),
|
||||
@@ -269,7 +340,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyBool",
|
||||
"CutPatternReversed",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Reverse the cut order of the stepover paths. For circular cut patterns, begin at the outside and work toward the center.",
|
||||
),
|
||||
@@ -278,7 +349,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyDistance",
|
||||
"DepthOffset",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Set the Z-axis depth offset from the target surface.",
|
||||
),
|
||||
@@ -287,7 +358,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyDistance",
|
||||
"IgnoreOuterAbove",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property", "Ignore outer waterlines above this height."
|
||||
),
|
||||
),
|
||||
@@ -295,7 +366,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyEnumeration",
|
||||
"LayerMode",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Complete the operation in a single pass at depth, or mulitiple passes to final depth.",
|
||||
),
|
||||
@@ -304,7 +375,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyVectorDistance",
|
||||
"PatternCenterCustom",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property", "Set the start point for the cut pattern."
|
||||
),
|
||||
),
|
||||
@@ -312,7 +383,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyEnumeration",
|
||||
"PatternCenterAt",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Choose location of the center point for starting the cut pattern.",
|
||||
),
|
||||
@@ -321,7 +392,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyDistance",
|
||||
"SampleInterval",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Set the sampling resolution. Smaller values quickly increase processing time.",
|
||||
),
|
||||
@@ -330,7 +401,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyFloat",
|
||||
"StepOver",
|
||||
"Clearing Options",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Set the stepover percentage, based on the tool's diameter.",
|
||||
),
|
||||
@@ -339,7 +410,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyBool",
|
||||
"OptimizeLinearPaths",
|
||||
"Optimization",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Enable optimization of linear paths (co-linear points). Removes unnecessary co-linear points from G-Code output.",
|
||||
),
|
||||
@@ -348,7 +419,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyBool",
|
||||
"OptimizeStepOverTransitions",
|
||||
"Optimization",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Enable separate optimization of transitions between, and breaks within, each step over path.",
|
||||
),
|
||||
@@ -357,7 +428,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyDistance",
|
||||
"GapThreshold",
|
||||
"Optimization",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Collinear and co-radial artifact gaps that are smaller than this threshold are closed in the path.",
|
||||
),
|
||||
@@ -366,7 +437,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyString",
|
||||
"GapSizes",
|
||||
"Optimization",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"Feedback: three smallest gaps identified in the path geometry.",
|
||||
),
|
||||
@@ -375,7 +446,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyVectorDistance",
|
||||
"StartPoint",
|
||||
"Start Point",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"The custom start point for the path of this operation",
|
||||
),
|
||||
@@ -384,46 +455,12 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
"App::PropertyBool",
|
||||
"UseStartPoint",
|
||||
"Start Point",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property", "Make True, if specifying a Start Point"
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
def opPropertyEnumerations(self):
|
||||
# Enumeration lists for App::PropertyEnumeration properties
|
||||
return {
|
||||
"Algorithm": ["OCL Dropcutter", "Experimental"],
|
||||
"BoundBox": ["BaseBoundBox", "Stock"],
|
||||
"PatternCenterAt": [
|
||||
"CenterOfMass",
|
||||
"CenterOfBoundBox",
|
||||
"XminYmin",
|
||||
"Custom",
|
||||
],
|
||||
"ClearLastLayer": [
|
||||
"Off",
|
||||
"Circular",
|
||||
"CircularZigZag",
|
||||
"Line",
|
||||
"Offset",
|
||||
"Spiral",
|
||||
"ZigZag",
|
||||
],
|
||||
"CutMode": ["Conventional", "Climb"],
|
||||
"CutPattern": [
|
||||
"None",
|
||||
"Circular",
|
||||
"CircularZigZag",
|
||||
"Line",
|
||||
"Offset",
|
||||
"Spiral",
|
||||
"ZigZag",
|
||||
], # Additional goals ['Offset', 'Spiral', 'ZigZagOffset', 'Grid', 'Triangle']
|
||||
"HandleMultipleFeatures": ["Collectively", "Individually"],
|
||||
"LayerMode": ["Single-pass", "Multi-pass"],
|
||||
}
|
||||
|
||||
def opPropertyDefaults(self, obj, job):
|
||||
"""opPropertyDefaults(obj, job) ... returns a dictionary
|
||||
of default values for the operation's properties."""
|
||||
@@ -543,15 +580,16 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
obj.setEditorMode("ShowTempObjects", mode)
|
||||
|
||||
# Repopulate enumerations in case of changes
|
||||
ENUMS = self.opPropertyEnumerations()
|
||||
|
||||
ENUMS = self.propertyEnumerations()
|
||||
for n in ENUMS:
|
||||
restore = False
|
||||
if hasattr(obj, n):
|
||||
val = obj.getPropertyByName(n)
|
||||
if hasattr(obj, n[0]):
|
||||
val = obj.getPropertyByName(n[0])
|
||||
restore = True
|
||||
setattr(obj, n, ENUMS[n])
|
||||
setattr(obj, n[0], n[1])
|
||||
if restore:
|
||||
setattr(obj, n, val)
|
||||
setattr(obj, n[0], val)
|
||||
|
||||
self.setEditorProperties(obj)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user