- replaced the testing if instance of FlatCAMObj with testing the obj.kind attribute
- removed the import of the whole FlatCAMApp file only for the usage of GracefulException - remove the import of FlatCAMApp and used alternate ways - optimized the imports in some files - moved the Bookmarksmanager and ToolDB classes into their own files - solved some bugs that were not so visible in the Editors and HPGL parser - split the FlatCAMObj file into multiple files located in the flatcamObjects folder and renamed the contained classes with names more suggestive - updated the Google Translation for the German language
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import collections
|
||||
from tclCommands.TclCommand import TclCommandSignaled
|
||||
from FlatCAMObj import FlatCAMGeometry, FlatCAMGerber, FlatCAMExcellon
|
||||
|
||||
from shapely.geometry import Point
|
||||
import shapely.affinity as affinity
|
||||
@@ -89,9 +88,7 @@ class TclCommandAlignDrill(TclCommandSignaled):
|
||||
if obj is None:
|
||||
return "Object not found: %s" % name
|
||||
|
||||
if not isinstance(obj, FlatCAMGeometry) and \
|
||||
not isinstance(obj, FlatCAMGerber) and \
|
||||
not isinstance(obj, FlatCAMExcellon):
|
||||
if obj.kind != "geometry" and obj.kind != 'gerber' and obj.kind != 'excellon':
|
||||
return "ERROR: Only Gerber, Geometry and Excellon objects can be used."
|
||||
|
||||
# Axis
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import collections
|
||||
from tclCommands.TclCommand import TclCommand
|
||||
from FlatCAMObj import FlatCAMGeometry, FlatCAMGerber
|
||||
|
||||
from shapely.ops import cascaded_union
|
||||
|
||||
@@ -73,7 +72,7 @@ class TclCommandBbox(TclCommand):
|
||||
|
||||
if not isinstance(obj, FlatCAMGerber) and not isinstance(obj, FlatCAMGeometry):
|
||||
self.raise_tcl_error('%s %s: %s.' % (
|
||||
_("Expected FlatCAMGerber or FlatCAMGeometry, got"), name, type(obj)))
|
||||
_("Expected GerberObject or GeometryObject, got"), name, type(obj)))
|
||||
|
||||
if 'margin' not in args:
|
||||
args['margin'] = float(self.app.defaults["gerber_bboxmargin"])
|
||||
@@ -92,7 +91,7 @@ class TclCommandBbox(TclCommand):
|
||||
|
||||
try:
|
||||
def geo_init(geo_obj, app_obj):
|
||||
assert isinstance(geo_obj, FlatCAMGeometry)
|
||||
# assert geo_obj.kind == 'geometry'
|
||||
|
||||
# Bounding box with rounded corners
|
||||
geo = cascaded_union(obj.solid_geometry)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from tclCommands.TclCommand import TclCommandSignaled
|
||||
from FlatCAMObj import FlatCAMGeometry
|
||||
|
||||
import collections
|
||||
from copy import deepcopy
|
||||
@@ -119,9 +118,9 @@ class TclCommandCncjob(TclCommandSignaled):
|
||||
else:
|
||||
return "fail"
|
||||
|
||||
if not isinstance(obj, FlatCAMGeometry):
|
||||
if obj.kind != 'geometry':
|
||||
if muted is False:
|
||||
self.raise_tcl_error('Expected FlatCAMGeometry, got %s %s.' % (str(name), type(obj)))
|
||||
self.raise_tcl_error('Expected GeometryObject, got %s %s.' % (str(name), type(obj)))
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from tclCommands.TclCommand import TclCommandSignaled
|
||||
from FlatCAMObj import FlatCAMExcellon
|
||||
|
||||
import collections
|
||||
import math
|
||||
@@ -125,9 +124,9 @@ class TclCommandDrillcncjob(TclCommandSignaled):
|
||||
else:
|
||||
return "fail"
|
||||
|
||||
if not isinstance(obj, FlatCAMExcellon):
|
||||
if obj.kind != 'excellon':
|
||||
if muted is False:
|
||||
self.raise_tcl_error('Expected FlatCAMExcellon, got %s %s.' % (name, type(obj)))
|
||||
self.raise_tcl_error('Expected ExcellonObject, got %s %s.' % (name, type(obj)))
|
||||
else:
|
||||
return "fail"
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from tclCommands.TclCommand import TclCommandSignaled
|
||||
from FlatCAMObj import FlatCAMGerber
|
||||
|
||||
import collections
|
||||
|
||||
@@ -56,8 +55,8 @@ class TclCommandFollow(TclCommandSignaled):
|
||||
if obj is None:
|
||||
self.raise_tcl_error("Object not found: %s" % name)
|
||||
|
||||
if not isinstance(obj, FlatCAMGerber):
|
||||
self.raise_tcl_error('Expected FlatCAMGerber, got %s %s.' % (name, type(obj)))
|
||||
if obj.kind != 'gerber':
|
||||
self.raise_tcl_error('Expected GerberObject, got %s %s.' % (name, type(obj)))
|
||||
|
||||
del args['name']
|
||||
try:
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from tclCommands.TclCommand import TclCommandSignaled
|
||||
from FlatCAMObj import FlatCAMGerber, FlatCAMGeometry
|
||||
|
||||
import logging
|
||||
import collections
|
||||
@@ -209,7 +208,7 @@ class TclCommandGeoCutout(TclCommandSignaled):
|
||||
except ValueError:
|
||||
gaps_u = gaps
|
||||
|
||||
if isinstance(cutout_obj, FlatCAMGeometry):
|
||||
if cutout_obj.kind == 'geometry':
|
||||
# rename the obj name so it can be identified as cutout
|
||||
# cutout_obj.options["name"] += "_cutout"
|
||||
|
||||
@@ -306,7 +305,7 @@ class TclCommandGeoCutout(TclCommandSignaled):
|
||||
# cutout_obj.plot()
|
||||
# self.app.inform.emit("[success] Any-form Cutout operation finished.")
|
||||
# self.app.plots_updated.emit()
|
||||
elif isinstance(cutout_obj, FlatCAMGerber):
|
||||
elif cutout_obj.kind == 'gerber':
|
||||
|
||||
def geo_init(geo_obj, app_obj):
|
||||
try:
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from tclCommands.TclCommand import TclCommandSignaled
|
||||
from FlatCAMObj import FlatCAMGerber
|
||||
|
||||
import collections
|
||||
|
||||
@@ -96,8 +95,8 @@ class TclCommandIsolate(TclCommandSignaled):
|
||||
if obj is None:
|
||||
self.raise_tcl_error("Object not found: %s" % name)
|
||||
|
||||
if not isinstance(obj, FlatCAMGerber):
|
||||
self.raise_tcl_error('Expected FlatCAMGerber, got %s %s.' % (name, type(obj)))
|
||||
if obj.kind != 'gerber':
|
||||
self.raise_tcl_error('Expected GerberObject, got %s %s.' % (name, type(obj)))
|
||||
|
||||
del args['name']
|
||||
obj.isolate(plot=False, **args)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from tclCommands.TclCommand import TclCommand
|
||||
from FlatCAMObj import FlatCAMExcellon
|
||||
from flatcamObjects.FlatCAMExcellon import ExcellonObject
|
||||
|
||||
import collections
|
||||
|
||||
@@ -62,7 +62,7 @@ class TclCommandJoinExcellon(TclCommand):
|
||||
objs.append(obj)
|
||||
|
||||
def initialize(obj_, app):
|
||||
FlatCAMExcellon.merge(self, objs, obj_)
|
||||
ExcellonObject.merge(self, objs, obj_)
|
||||
|
||||
if objs and len(objs) >= 2:
|
||||
self.app.new_object("excellon", outname, initialize, plot=False)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from tclCommands.TclCommand import TclCommand
|
||||
from FlatCAMObj import FlatCAMGeometry
|
||||
from flatcamObjects.FlatCAMGeometry import GeometryObject
|
||||
|
||||
import collections
|
||||
|
||||
@@ -62,7 +62,7 @@ class TclCommandJoinGeometry(TclCommand):
|
||||
objs.append(obj)
|
||||
|
||||
def initialize(obj_, app):
|
||||
FlatCAMGeometry.merge(self, objs, obj_)
|
||||
GeometryObject.merge(self, objs, obj_)
|
||||
|
||||
if objs and len(objs) >= 2:
|
||||
self.app.new_object("geometry", outname, initialize, plot=False)
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
# ##########################################################
|
||||
|
||||
from tclCommands.TclCommand import TclCommandSignaled
|
||||
from FlatCAMObj import FlatCAMExcellon
|
||||
|
||||
import math
|
||||
import collections
|
||||
@@ -138,7 +137,7 @@ class TclCommandMillDrills(TclCommandSignaled):
|
||||
except Exception as e:
|
||||
self.raise_tcl_error("Bad tools: %s" % str(e))
|
||||
|
||||
if not isinstance(obj, FlatCAMExcellon):
|
||||
if obj.kind != 'excellon':
|
||||
self.raise_tcl_error('Only Excellon objects can be mill-drilled, got %s %s.' % (name, type(obj)))
|
||||
|
||||
if self.app.collection.has_promises():
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
# ##########################################################
|
||||
|
||||
from tclCommands.TclCommand import TclCommandSignaled
|
||||
from FlatCAMObj import FlatCAMExcellon
|
||||
|
||||
import collections
|
||||
import math
|
||||
@@ -139,7 +138,7 @@ class TclCommandMillSlots(TclCommandSignaled):
|
||||
except Exception as e:
|
||||
self.raise_tcl_error("Bad tools: %s" % str(e))
|
||||
|
||||
if not isinstance(obj, FlatCAMExcellon):
|
||||
if obj.kind != 'excellon':
|
||||
self.raise_tcl_error('Only Excellon objects can have mill-slots, got %s %s.' % (name, type(obj)))
|
||||
|
||||
if self.app.collection.has_promises():
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from tclCommands.TclCommand import TclCommandSignaled
|
||||
from FlatCAMObj import FlatCAMExcellon, FlatCAMGeometry, FlatCAMGerber
|
||||
|
||||
import collections
|
||||
|
||||
@@ -68,9 +67,7 @@ class TclCommandMirror(TclCommandSignaled):
|
||||
if obj is None:
|
||||
return "Object not found: %s" % name
|
||||
|
||||
if not isinstance(obj, FlatCAMGerber) and \
|
||||
not isinstance(obj, FlatCAMExcellon) and \
|
||||
not isinstance(obj, FlatCAMGeometry):
|
||||
if obj.kind != 'gerber' and obj.kind != 'geometry' and obj.kind != 'excellon':
|
||||
return "ERROR: Only Gerber, Excellon and Geometry objects can be mirrored."
|
||||
|
||||
# Axis
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from tclCommands.TclCommand import TclCommand
|
||||
from FlatCAMObj import FlatCAMGeometry, FlatCAMGerber
|
||||
|
||||
from shapely.ops import cascaded_union
|
||||
|
||||
@@ -71,8 +70,8 @@ class TclCommandNregions(TclCommand):
|
||||
if obj is None:
|
||||
self.raise_tcl_error("%s: %s" % (_("Object not found"), name))
|
||||
|
||||
if not isinstance(obj, FlatCAMGerber) and not isinstance(obj, FlatCAMGeometry):
|
||||
self.raise_tcl_error('%s %s: %s.' % (_("Expected FlatCAMGerber or FlatCAMGeometry, got"), name, type(obj)))
|
||||
if obj.kind != 'gerber' and obj.kind != 'geometry':
|
||||
self.raise_tcl_error('%s %s: %s.' % (_("Expected GerberObject or GeometryObject, got"), name, type(obj)))
|
||||
|
||||
if 'margin' not in args:
|
||||
args['margin'] = float(self.app.defaults["gerber_noncoppermargin"])
|
||||
@@ -91,7 +90,7 @@ class TclCommandNregions(TclCommand):
|
||||
|
||||
try:
|
||||
def geo_init(geo_obj, app_obj):
|
||||
assert isinstance(geo_obj, FlatCAMGeometry)
|
||||
assert geo_obj.kind == 'geometry'
|
||||
|
||||
geo = cascaded_union(obj.solid_geometry)
|
||||
bounding_box = geo.envelope.buffer(float(margin))
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from tclCommands.TclCommand import TclCommandSignaled
|
||||
from camlib import ParseError
|
||||
from FlatCAMObj import FlatCAMGerber
|
||||
|
||||
import collections
|
||||
|
||||
@@ -53,8 +52,8 @@ class TclCommandOpenGerber(TclCommandSignaled):
|
||||
# How the object should be initialized
|
||||
def obj_init(gerber_obj, app_obj):
|
||||
|
||||
if not isinstance(gerber_obj, FlatCAMGerber):
|
||||
self.raise_tcl_error('Expected FlatCAMGerber, got %s %s.' % (outname, type(gerber_obj)))
|
||||
if gerber_obj.kind != 'gerber':
|
||||
self.raise_tcl_error('Expected GerberObject, got %s %s.' % (outname, type(gerber_obj)))
|
||||
|
||||
# Opening the file happens here
|
||||
try:
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from tclCommands.TclCommand import TclCommand
|
||||
from FlatCAMObj import FlatCAMGeometry, FlatCAMExcellon
|
||||
|
||||
import shapely.affinity as affinity
|
||||
|
||||
@@ -153,12 +152,12 @@ class TclCommandPanelize(TclCommand):
|
||||
# objs.append(obj_init)
|
||||
#
|
||||
# def initialize_geometry(obj_init, app):
|
||||
# FlatCAMGeometry.merge(objs, obj_init)
|
||||
# GeometryObject.merge(objs, obj_init)
|
||||
#
|
||||
# def initialize_excellon(obj_init, app):
|
||||
# # merge expects tools to exist in the target object
|
||||
# obj_init.tools = obj.tools.copy()
|
||||
# FlatCAMExcellon.merge(objs, obj_init)
|
||||
# ExcellonObject.merge(objs, obj_init)
|
||||
#
|
||||
# objs = []
|
||||
# if obj is not None:
|
||||
@@ -167,7 +166,7 @@ class TclCommandPanelize(TclCommand):
|
||||
# currentx = 0
|
||||
# for col in range(columns):
|
||||
# local_outname = outname + ".tmp." + str(col) + "." + str(row)
|
||||
# if isinstance(obj, FlatCAMExcellon):
|
||||
# if isinstance(obj, ExcellonObject):
|
||||
# self.app.new_object("excellon", local_outname, initialize_local_excellon, plot=False,
|
||||
# autoselected=False)
|
||||
# else:
|
||||
@@ -177,7 +176,7 @@ class TclCommandPanelize(TclCommand):
|
||||
# currentx += lenghtx
|
||||
# currenty += lenghty
|
||||
#
|
||||
# if isinstance(obj, FlatCAMExcellon):
|
||||
# if isinstance(obj, ExcellonObject):
|
||||
# self.app.new_object("excellon", outname, initialize_excellon)
|
||||
# else:
|
||||
# self.app.new_object("geometry", outname, initialize_geometry)
|
||||
@@ -258,7 +257,7 @@ class TclCommandPanelize(TclCommand):
|
||||
|
||||
obj_fin.solid_geometry = []
|
||||
|
||||
if isinstance(obj, FlatCAMGeometry):
|
||||
if obj.kind == 'geometry':
|
||||
obj_fin.multigeo = obj.multigeo
|
||||
obj_fin.tools = deepcopy(obj.tools)
|
||||
if obj.multigeo is True:
|
||||
@@ -269,7 +268,7 @@ class TclCommandPanelize(TclCommand):
|
||||
currentx = 0.0
|
||||
|
||||
for col in range(columns):
|
||||
if isinstance(obj, FlatCAMGeometry):
|
||||
if obj.kind == 'geometry':
|
||||
if obj.multigeo is True:
|
||||
for tool in obj.tools:
|
||||
obj_fin.tools[tool]['solid_geometry'].append(translate_recursion(
|
||||
@@ -287,7 +286,7 @@ class TclCommandPanelize(TclCommand):
|
||||
currentx += lenghtx
|
||||
currenty += lenghty
|
||||
|
||||
if isinstance(obj, FlatCAMExcellon):
|
||||
if obj.kind == 'excellon':
|
||||
self.app.new_object("excellon", outname, job_init_excellon, plot=False, autoselected=True)
|
||||
else:
|
||||
self.app.new_object("geometry", outname, job_init_geometry, plot=False, autoselected=True)
|
||||
|
||||
Reference in New Issue
Block a user