- overwritten the Beta_8.995 branch with the Gerber_Editor_Upgrade branch
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
# Modified by Marius Stanciu (2020) #
|
||||
# ###########################################################
|
||||
|
||||
from appObjects.ObjectCollection import *
|
||||
from PyQt6 import QtCore
|
||||
|
||||
from appObjects.CNCJobObject import CNCJobObject
|
||||
from appObjects.DocumentObject import DocumentObject
|
||||
from appObjects.ExcellonObject import ExcellonObject
|
||||
@@ -17,6 +18,7 @@ from appObjects.ScriptObject import ScriptObject
|
||||
|
||||
import time
|
||||
import traceback
|
||||
from copy import deepcopy
|
||||
|
||||
# FlatCAM Translation
|
||||
import gettext
|
||||
@@ -336,11 +338,6 @@ class AppObject(QtCore.QObject):
|
||||
except Exception as e:
|
||||
self.app.log.error("AppObject.new_object() -> setting colors error. %s" % str(e))
|
||||
|
||||
# #############################################################################################################
|
||||
# update the SHELL auto-completer model with the name of the new object
|
||||
# #############################################################################################################
|
||||
self.app.shell.command_line().set_model_data(self.app.myKeywords)
|
||||
|
||||
if auto_select or self.app.ui.notebook.currentWidget() is self.app.ui.properties_tab:
|
||||
# select the just opened object but deselect the previous ones
|
||||
self.app.collection.set_all_inactive()
|
||||
|
||||
@@ -10,20 +10,20 @@
|
||||
# File modified by: Marius Stanciu #
|
||||
# ##########################################################
|
||||
|
||||
# import inspect
|
||||
|
||||
from appGUI.ObjectUI import *
|
||||
from PyQt6 import QtCore, QtGui
|
||||
|
||||
from appGUI.ObjectUI import ObjectUI
|
||||
from appCommon.Common import LoudDict
|
||||
from appGUI.PlotCanvasLegacy import ShapeCollectionLegacy
|
||||
from appGUI.VisPyVisuals import ShapeCollection
|
||||
|
||||
from shapely.ops import unary_union
|
||||
from shapely.geometry import Polygon, MultiPolygon, Point, LineString
|
||||
from shapely import Polygon, MultiPolygon, Point, LineString
|
||||
|
||||
from copy import deepcopy
|
||||
from copy import deepcopy, copy
|
||||
import sys
|
||||
import math
|
||||
import inspect
|
||||
|
||||
import gettext
|
||||
import appTranslation as fcTranslate
|
||||
@@ -94,7 +94,8 @@ class FlatCAMObj(QtCore.QObject):
|
||||
|
||||
if self.app.use_3d_engine:
|
||||
self.shapes = self.app.plotcanvas.new_shape_group()
|
||||
self.mark_shapes = ShapeCollection(parent=self.app.plotcanvas.view.scene, layers=1, pool=self.app.pool)
|
||||
self.mark_shapes = ShapeCollection(parent=self.app.plotcanvas.view.scene, layers=1, pool=self.app.pool,
|
||||
fcoptions=self.app.options)
|
||||
else:
|
||||
self.shapes = ShapeCollectionLegacy(obj=self, app=self.app, name=name)
|
||||
self.mark_shapes = ShapeCollectionLegacy(obj=self, app=self.app, name=name + "_mark_shapes")
|
||||
@@ -210,12 +211,12 @@ class FlatCAMObj(QtCore.QObject):
|
||||
|
||||
@property
|
||||
def visible(self):
|
||||
'''
|
||||
"""
|
||||
This property is used by Editors to turn off plotting for the original object that is edited,
|
||||
such that when deleting certain elements there is no background plot in place to confuse things.
|
||||
:return:
|
||||
:rtype:
|
||||
'''
|
||||
"""
|
||||
return self.shapes.visible
|
||||
|
||||
@visible.setter
|
||||
@@ -226,6 +227,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
|
||||
current_visibility = self.shapes.visible
|
||||
self.shapes.visible = current_visibility # maybe this is slower in VisPy? use enabled property?
|
||||
|
||||
def task(visibility):
|
||||
if visibility is True:
|
||||
if value is False:
|
||||
@@ -331,10 +333,9 @@ class FlatCAMObj(QtCore.QObject):
|
||||
if new_name != old_name:
|
||||
# update the SHELL auto-completer model data
|
||||
try:
|
||||
self.app.myKeywords.remove(old_name)
|
||||
self.app.myKeywords.append(new_name)
|
||||
self.app.shell._edit.set_model_data(self.app.myKeywords)
|
||||
self.app.ui.code_editor.set_model_data(self.app.myKeywords)
|
||||
self.app.regFK.remove_keyword(old_name, update=False)
|
||||
self.app.regFK.prepend_keyword(new_name)
|
||||
self.app.ui.code_editor.set_model_data(self.app.regFK.myKeywords)
|
||||
except Exception:
|
||||
self.app.log.debug(
|
||||
"on_name_activate() --> Could not remove the old object name from auto-completer model list")
|
||||
@@ -666,7 +667,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
if isinstance(geo, list) and geo[0] is not None:
|
||||
if isinstance(geo, MultiPolygon):
|
||||
env_obj = geo.convex_hull
|
||||
elif (isinstance(geo, MultiPolygon) and len(geo) == 1) or \
|
||||
elif (isinstance(geo, MultiPolygon) and len(geo.geoms) == 1) or \
|
||||
(isinstance(geo, list) and len(geo) == 1) and isinstance(geo[0], Polygon):
|
||||
env_obj = unary_union(geo)
|
||||
env_obj = env_obj.convex_hull
|
||||
|
||||
@@ -10,17 +10,22 @@
|
||||
# File modified by: Marius Stanciu #
|
||||
# ##########################################################
|
||||
|
||||
from io import StringIO
|
||||
from datetime import datetime
|
||||
from PyQt6 import QtCore, QtWidgets
|
||||
|
||||
from appEditors.AppTextEditor import AppTextEditor
|
||||
from appObjects.AppObjectTemplate import *
|
||||
|
||||
from appObjects.AppObjectTemplate import FlatCAMObj, ObjectDeleted
|
||||
from appGUI.GUIElements import FCFileSaveDialog, FCCheckBox
|
||||
from appGUI.ObjectUI import CNCObjectUI
|
||||
from camlib import CNCjob
|
||||
|
||||
import os
|
||||
import sys
|
||||
import math
|
||||
import re
|
||||
|
||||
from io import StringIO
|
||||
from datetime import datetime as dt
|
||||
from copy import deepcopy
|
||||
|
||||
import gettext
|
||||
import appTranslation as fcTranslate
|
||||
@@ -855,7 +860,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
"""
|
||||
|
||||
self.app.log.debug("FlatCAMCNCJob.gcode_header()")
|
||||
time_str = "{:%A, %d %B %Y at %H:%M}".format(datetime.now())
|
||||
time_str = "{:%A, %d %B %Y at %H:%M}".format(dt.now())
|
||||
marlin = False
|
||||
hpgl = False
|
||||
probe_pp = False
|
||||
|
||||
@@ -9,8 +9,12 @@
|
||||
# ##########################################################
|
||||
# File modified by: Marius Stanciu #
|
||||
# ##########################################################
|
||||
|
||||
from PyQt6.QtCore import Qt
|
||||
|
||||
from appEditors.AppTextEditor import AppTextEditor
|
||||
from appObjects.AppObjectTemplate import *
|
||||
from appGUI.ObjectUI import DocumentObjectUI
|
||||
|
||||
import gettext
|
||||
import appTranslation as fcTranslate
|
||||
|
||||
@@ -10,14 +10,18 @@
|
||||
# File modified by: Marius Stanciu #
|
||||
# ##########################################################
|
||||
|
||||
|
||||
from shapely.geometry import LineString
|
||||
from PyQt6 import QtWidgets, QtCore, QtGui
|
||||
|
||||
from appParsers.ParseExcellon import Excellon
|
||||
from appObjects.AppObjectTemplate import *
|
||||
from appObjects.AppObjectTemplate import FlatCAMObj, ObjectDeleted
|
||||
from appGUI.GUIElements import FCCheckBox
|
||||
from appGUI.ObjectUI import ExcellonObjectUI
|
||||
|
||||
import itertools
|
||||
import numpy as np
|
||||
from copy import deepcopy
|
||||
|
||||
from shapely import LineString
|
||||
|
||||
import gettext
|
||||
import appTranslation as fcTranslate
|
||||
|
||||
@@ -10,17 +10,22 @@
|
||||
# File modified by: Marius Stanciu #
|
||||
# ##########################################################
|
||||
|
||||
from shapely.geometry import MultiLineString, LinearRing
|
||||
import shapely.affinity as affinity
|
||||
from PyQt6 import QtWidgets, QtCore
|
||||
from appObjects.AppObjectTemplate import FlatCAMObj, ObjectDeleted
|
||||
from appGUI.GUIElements import FCCheckBox
|
||||
from appGUI.ObjectUI import GeometryObjectUI
|
||||
|
||||
from shapely import MultiLineString, LinearRing, Polygon, MultiPolygon, LineString
|
||||
from shapely.affinity import scale, translate
|
||||
from shapely.ops import unary_union
|
||||
|
||||
from camlib import Geometry, flatten_shapely_geometry
|
||||
|
||||
from appObjects.AppObjectTemplate import *
|
||||
|
||||
import re
|
||||
import ezdxf
|
||||
import numpy as np
|
||||
from copy import deepcopy
|
||||
import traceback
|
||||
from copy import deepcopy
|
||||
from collections import defaultdict
|
||||
from functools import reduce
|
||||
|
||||
@@ -1193,7 +1198,7 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
self.app.proc_container.update_view_text(' %d%%' % disp_number)
|
||||
self.old_disp_number = disp_number
|
||||
|
||||
return affinity.scale(geom, xfactor, yfactor, origin=(px, py))
|
||||
return scale(geom, xfactor, yfactor, origin=(px, py))
|
||||
except AttributeError:
|
||||
return geom
|
||||
|
||||
@@ -1269,7 +1274,7 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
self.app.proc_container.update_view_text(' %d%%' % disp_number)
|
||||
self.old_disp_number = disp_number
|
||||
|
||||
return affinity.translate(geom, xoff=dx, yoff=dy)
|
||||
return translate(geom, xoff=dx, yoff=dy)
|
||||
except AttributeError:
|
||||
return geom
|
||||
|
||||
|
||||
@@ -10,12 +10,16 @@
|
||||
# File modified by: Marius Stanciu #
|
||||
# ##########################################################
|
||||
|
||||
from PyQt6 import QtWidgets, QtCore
|
||||
from appGUI.GUIElements import FCCheckBox
|
||||
from appGUI.ObjectUI import GerberObjectUI
|
||||
from appParsers.ParseGerber import Gerber
|
||||
from appObjects.AppObjectTemplate import FlatCAMObj, ObjectDeleted, ValidationError
|
||||
|
||||
from shapely.geometry import MultiLineString, LinearRing
|
||||
from camlib import flatten_shapely_geometry
|
||||
|
||||
from appParsers.ParseGerber import Gerber
|
||||
from appObjects.AppObjectTemplate import *
|
||||
from shapely import MultiLineString, LinearRing, MultiPolygon, Polygon, LineString, Point
|
||||
from shapely.ops import unary_union
|
||||
|
||||
import numpy as np
|
||||
from copy import deepcopy
|
||||
@@ -903,7 +907,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
|
||||
Gerber.convert_units(self, units)
|
||||
|
||||
# self.obj_options['isotooldia'] = float(self.obj_options['isotooldia']) * factor
|
||||
# self.obj_options['isotd_list'] = float(self.obj_options['isotd_list']) * factor
|
||||
# self.obj_options['bboxmargin'] = float(self.obj_options['bboxmargin']) * factor
|
||||
|
||||
def plot(self, kind=None, **kwargs):
|
||||
|
||||
@@ -154,35 +154,35 @@ class EventSensitiveListView(QtWidgets.QTreeView):
|
||||
if self.filename == "":
|
||||
self.app.inform.emit(_("Cancelled."))
|
||||
else:
|
||||
if self.filename.lower().rpartition('.')[-1] in self.app.grb_list:
|
||||
if self.filename.lower().rpartition('.')[-1] in self.app.regFK.grb_list:
|
||||
self.app.worker_task.emit({'fcn': self.app.f_handlers.open_gerber,
|
||||
'params': [self.filename]})
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
if self.filename.lower().rpartition('.')[-1] in self.app.exc_list:
|
||||
if self.filename.lower().rpartition('.')[-1] in self.app.regFK.exc_list:
|
||||
self.app.worker_task.emit({'fcn': self.app.f_handlers.open_excellon,
|
||||
'params': [self.filename]})
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
if self.filename.lower().rpartition('.')[-1] in self.app.gcode_list:
|
||||
if self.filename.lower().rpartition('.')[-1] in self.app.regFK.gcode_list:
|
||||
self.app.worker_task.emit({'fcn': self.app.f_handlers.open_gcode,
|
||||
'params': [self.filename]})
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
if self.filename.lower().rpartition('.')[-1] in self.app.svg_list:
|
||||
if self.filename.lower().rpartition('.')[-1] in self.app.regFK.svg_list:
|
||||
object_type = 'geometry'
|
||||
self.app.worker_task.emit({'fcn': self.app.f_handlers.import_svg,
|
||||
'params': [self.filename, object_type, None]})
|
||||
|
||||
if self.filename.lower().rpartition('.')[-1] in self.app.dxf_list:
|
||||
if self.filename.lower().rpartition('.')[-1] in self.app.regFK.dxf_list:
|
||||
object_type = 'geometry'
|
||||
self.app.worker_task.emit({'fcn': self.app.f_handlers.import_dxf,
|
||||
'params': [self.filename, object_type, None]})
|
||||
|
||||
if self.filename.lower().rpartition('.')[-1] in self.app.prj_list:
|
||||
if self.filename.lower().rpartition('.')[-1] in self.app.regFK.prj_list:
|
||||
# self.app.open_project() is not Thread Safe
|
||||
self.app.f_handlers.open_project(self.filename)
|
||||
else:
|
||||
@@ -351,7 +351,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
# self.view.setAcceptDrops(True)
|
||||
# self.view.setDropIndicatorShown(True)
|
||||
|
||||
settings = QSettings("Open Source", "FlatCAM")
|
||||
settings = QSettings("Open Source", "FlatCAM_EVO")
|
||||
if settings.contains("notebook_font_size"):
|
||||
fsize = settings.value('notebook_font_size', type=int)
|
||||
else:
|
||||
@@ -363,7 +363,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
self.view.setFont(font)
|
||||
|
||||
# ## GUI Events
|
||||
self.view.selectionModel().selectionChanged.connect(self.on_list_selection_change)
|
||||
self.view.selectionModel().selectionChanged.connect(self.on_list_selection_change) # noqa
|
||||
# self.view.activated.connect(self.on_item_activated)
|
||||
self.view.keyPressed.connect(self.app.ui.keyPressEvent)
|
||||
self.view.mouseReleased.connect(self.on_list_click_release)
|
||||
@@ -504,7 +504,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
return index.internalPointer().data(index.column())
|
||||
|
||||
if role == Qt.ItemDataRole.ForegroundRole:
|
||||
theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
|
||||
theme_settings = QtCore.QSettings("Open Source", "FlatCAM_EVO")
|
||||
theme = theme_settings.value('theme', type=str)
|
||||
|
||||
if theme == 'dark':
|
||||
@@ -556,9 +556,9 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
|
||||
# update the SHELL auto-completer model data
|
||||
try:
|
||||
self.app.myKeywords.remove(old_name)
|
||||
self.app.myKeywords.append(new_name)
|
||||
self.app.shell._edit.set_model_data(self.app.myKeywords)
|
||||
self.app.regFK.remove_keyword(old_name, update=False)
|
||||
self.app.regFK.prepend_keyword(new_name)
|
||||
self.app.shell._edit.set_model_data(self.app.regFK.myKeywords)
|
||||
except Exception as e:
|
||||
self.app.log.error(
|
||||
"setData() --> Could not remove the old object name from auto-completer model list. %s" %
|
||||
@@ -567,7 +567,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
msg = "%s: <b>%s</b> %s: <b>%s</b>" % (_("Object renamed from"), old_name, _("to"), new_name)
|
||||
self.app.inform.emit(msg)
|
||||
|
||||
self.dataChanged.emit(index, index)
|
||||
self.dataChanged.emit(index, index) # noqa
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@@ -620,7 +620,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
# ############################################################################################################
|
||||
# update the KeyWords list with the name of the file
|
||||
# ############################################################################################################
|
||||
self.app.myKeywords.append(name)
|
||||
self.app.regFK.prepend_keyword(name)
|
||||
|
||||
# ############################################################################################################
|
||||
# ############################# Set the Object UI (Properties Tab) ###########################################
|
||||
@@ -737,15 +737,15 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
# some objects add a Tab on creation, close it here
|
||||
for idx in range(self.app.ui.plot_tab_area.count()):
|
||||
widget_name = self.app.ui.plot_tab_area.widget(idx).objectName()
|
||||
if widget_name == active.obj.obj_options['name'] or widget_name == (active.obj.obj_options['name'] + "_editor_tab"):
|
||||
if widget_name == active.obj.obj_options['name'] or \
|
||||
widget_name == (active.obj.obj_options['name'] + "_editor_tab"):
|
||||
self.app.ui.plot_tab_area.removeTab(idx)
|
||||
break
|
||||
|
||||
# update the SHELL auto-completer model data
|
||||
name = active.obj.obj_options['name']
|
||||
try:
|
||||
self.app.myKeywords.remove(name)
|
||||
self.app.shell._edit.set_model_data(self.app.myKeywords)
|
||||
self.app.regFK.remove_keyword(name)
|
||||
# this is not needed any more because now the code editor is created on demand
|
||||
# self.app.ui.code_editor.set_model_data(self.app.myKeywords)
|
||||
except Exception as e:
|
||||
@@ -791,15 +791,15 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
# some objects add a Tab on creation, close it here
|
||||
for idx in range(self.app.ui.plot_tab_area.count()):
|
||||
wdg_name = self.app.ui.plot_tab_area.widget(idx).objectName()
|
||||
if wdg_name == deleted.obj.obj_options['name'] or wdg_name == (deleted.obj.obj_options['name'] + "_editor_tab"):
|
||||
if wdg_name == deleted.obj.obj_options['name'] or \
|
||||
wdg_name == (deleted.obj.obj_options['name'] + "_editor_tab"):
|
||||
self.app.ui.plot_tab_area.removeTab(idx)
|
||||
break
|
||||
|
||||
# update the SHELL auto-completer model data
|
||||
name = deleted.obj.obj_options['name']
|
||||
try:
|
||||
self.app.myKeywords.remove(name)
|
||||
self.app.shell._edit.set_model_data(self.app.myKeywords)
|
||||
self.app.regFK.remove_keyword(name)
|
||||
# this is not needed any more because now the code editor is created on demand
|
||||
# self.app.ui.code_editor.set_model_data(self.app.myKeywords)
|
||||
except Exception as e:
|
||||
@@ -1080,7 +1080,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
return obj_list
|
||||
|
||||
def update_view(self):
|
||||
self.dataChanged.emit(QtCore.QModelIndex(), QtCore.QModelIndex())
|
||||
self.dataChanged.emit(QtCore.QModelIndex(), QtCore.QModelIndex()) # noqa
|
||||
|
||||
def on_row_activated(self, index):
|
||||
if index.isValid():
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
# File modified by: Marius Stanciu #
|
||||
# ##########################################################
|
||||
|
||||
from PyQt6 import QtCore
|
||||
|
||||
from appEditors.AppTextEditor import AppTextEditor
|
||||
from appObjects.AppObjectTemplate import *
|
||||
from appGUI.ObjectUI import *
|
||||
from appObjects.AppObjectTemplate import FlatCAMObj
|
||||
from appGUI.ObjectUI import ScriptObjectUI
|
||||
|
||||
import gettext
|
||||
import appTranslation as fcTranslate
|
||||
|
||||
Reference in New Issue
Block a user