Просмотр исходного кода

- fixed a bug in SolderPaste Tool that did not allow to view the GCode

Marius Stanciu 6 лет назад
Родитель
Сommit
d2d5371148
3 измененных файлов с 20 добавлено и 15 удалено
  1. 4 2
      FlatCAMObj.py
  2. 1 0
      README.md
  3. 15 13
      flatcamTools/ToolSolderPaste.py

+ 4 - 2
FlatCAMObj.py

@@ -5644,6 +5644,8 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
 
         FlatCAMApp.App.log.debug("Creating CNCJob object...")
 
+        self.decimals = 4
+
         CNCjob.__init__(self, units=units, kind=kind, z_move=z_move,
                         feedrate=feedrate, feedrate_rapid=feedrate_rapid, z_cut=z_cut, tooldia=tooldia,
                         spindlespeed=spindlespeed, steps_per_circle=int(self.app.defaults["cncjob_steps_per_circle"]))
@@ -5735,13 +5737,13 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
         # from predecessors.
         self.ser_attrs += ['options', 'kind', 'cnc_tools', 'multitool']
 
-        self.decimals = 4
-
         if self.app.is_legacy is False:
             self.text_col = self.app.plotcanvas.new_text_collection()
             self.text_col.enabled = True
             self.annotation = self.app.plotcanvas.new_text_group(collection=self.text_col)
 
+        self.gcode_editor_tab = None
+
     def build_ui(self):
         self.ui_disconnect()
 

+ 1 - 0
README.md

@@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing.
 30.10.2019
 
 - converted SolderPaste Tool to usage of SpinBoxes; changed the SolderPaste Tool UI in Preferences too
+- fixed a bug in SolderPaste Tool that did not allow to view the GCode
 
 29.10.2019
 

+ 15 - 13
flatcamTools/ToolSolderPaste.py

@@ -11,6 +11,7 @@ from flatcamGUI.GUIElements import FCComboBox, FCEntry, FCTable, FCInputDialog,
 from FlatCAMApp import log
 from camlib import distance
 from FlatCAMObj import FlatCAMCNCjob
+from flatcamEditors.FlatCAMTextEditor import TextEditor
 
 from PyQt5 import QtGui, QtCore, QtWidgets
 from PyQt5.QtCore import Qt
@@ -37,6 +38,8 @@ class SolderPaste(FlatCAMTool):
 
     def __init__(self, app):
         FlatCAMTool.__init__(self, app)
+
+        # Number of decimals to be used for tools/nozzles in this FlatCAM Tool
         self.decimals = 4
 
         # ## Title
@@ -451,8 +454,7 @@ class SolderPaste(FlatCAMTool):
         self.units = ''
         self.name = ""
 
-        # Number of decimals to be used for tools/nozzles in this FlatCAM Tool
-        self.decimals = 4
+        self.text_editor_tab = None
 
         # this will be used in the combobox context menu, for delete entry
         self.obj_to_be_deleted_name = ''
@@ -1285,9 +1287,9 @@ class SolderPaste(FlatCAMTool):
             xmax = obj.options['xmax']
             ymax = obj.options['ymax']
         except Exception as e:
-            log.debug("FlatCAMObj.FlatCAMGeometry.mtool_gen_cncjob() --> %s\n" % str(e))
+            log.debug("SolderPaste.on_create_gcode() --> %s\n" % str(e))
             msg = '[ERROR] %s' % _("An internal error has ocurred. See shell.\n")
-            msg += 'FlatCAMObj.FlatCAMGeometry.mtool_gen_cncjob() --> %s' % str(e)
+            msg += 'SolderPaste.on_create_gcode() --> %s' % str(e)
             msg += traceback.format_exc()
             self.app.inform.emit(msg)
             return
@@ -1375,14 +1377,14 @@ class SolderPaste(FlatCAMTool):
         """
         time_str = "{:%A, %d %B %Y at %H:%M}".format(datetime.now())
 
-        # add the tab if it was closed
-        self.app.ui.plot_tab_area.addTab(self.app.ui.text_editor_tab, _("Code Editor"))
+        self.text_editor_tab = TextEditor(app=self.app)
 
-        # first clear previous text in text editor (if any)
-        self.app.ui.code_editor.clear()
+        # add the tab if it was closed
+        self.app.ui.plot_tab_area.addTab(self.text_editor_tab, _("SP GCode Editor"))
+        self.text_editor_tab.setObjectName('solderpaste_gcode_editor_tab')
 
         # Switch plot_area to CNCJob tab
-        self.app.ui.plot_tab_area.setCurrentWidget(self.app.ui.text_editor_tab)
+        self.app.ui.plot_tab_area.setCurrentWidget(self.text_editor_tab)
 
         name = self.cnc_obj_combo.currentText()
         obj = self.app.collection.get_by_name(name)
@@ -1426,17 +1428,17 @@ class SolderPaste(FlatCAMTool):
         try:
             for line in lines:
                 proc_line = str(line).strip('\n')
-                self.app.ui.code_editor.append(proc_line)
+                self.text_editor_tab.code_editor.append(proc_line)
         except Exception as e:
             log.debug('ToolSolderPaste.on_view_gcode() -->%s' % str(e))
             self.app.inform.emit('[ERROR] %s --> %s' %
                                  ('ToolSolderPaste.on_view_gcode()', str(e)))
             return
 
-        self.app.ui.code_editor.moveCursor(QtGui.QTextCursor.Start)
+        self.text_editor_tab.code_editor.moveCursor(QtGui.QTextCursor.Start)
 
-        self.app.handleTextChanged()
-        self.app.ui.show()
+        self.text_editor_tab.handleTextChanged()
+        # self.app.ui.show()
 
     def on_save_gcode(self):
         """