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

- fixed a division by zero error: fixed #377

Marius Stanciu 6 лет назад
Родитель
Сommit
7aea33914c
4 измененных файлов с 15 добавлено и 4 удалено
  1. 6 2
      FlatCAMApp.py
  2. 5 1
      FlatCAMObj.py
  3. 1 0
      README.md
  4. 3 1
      flatcamEditors/FlatCAMTextEditor.py

+ 6 - 2
FlatCAMApp.py

@@ -7193,8 +7193,7 @@ class App(QtCore.QObject):
         # Clear form
         self.setup_component_editor()
 
-        self.inform.emit('%s: %s' %
-                         (_("Object deleted"), name))
+        self.inform.emit('%s: %s' % (_("Object deleted"), name))
 
     def on_set_origin(self):
         """
@@ -7306,6 +7305,11 @@ class App(QtCore.QObject):
         def worker_task():
             with self.proc_container.new(_("Moving to Origin...")):
                 obj_list = self.collection.get_selected()
+
+                if not obj_list:
+                    self.inform.emit('[ERROR_NOTCL] %s' % _("Failed. No object(s) selected..."))
+                    return
+
                 xminlist = list()
                 yminlist = list()
 

+ 5 - 1
FlatCAMObj.py

@@ -4756,7 +4756,11 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             return
         tooldia = float(tool_dia_item.text())
 
-        new_cutz = (tooldia - vdia) / (2 * math.tan(math.radians(half_vangle)))
+        try:
+            new_cutz = (tooldia - vdia) / (2 * math.tan(math.radians(half_vangle)))
+        except ZeroDivisionError:
+            new_cutz = self.old_cutz
+
         new_cutz = float('%.*f' % (self.decimals, new_cutz)) * -1.0   # this value has to be negative
 
         self.ui.cutz_entry.set_value(new_cutz)

+ 1 - 0
README.md

@@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing.
 
 - added a new functionality, a variation of Set Origin named Move to Origin. It will move a selection of objects to origin such as the bottom left corner of the bounding box that fit them all is in origin.
 - fixed some bugs
+- fixed a division by zero error: fixed #377
 
 30.01.2020
 

+ 3 - 1
flatcamEditors/FlatCAMTextEditor.py

@@ -29,6 +29,8 @@ class TextEditor(QtWidgets.QWidget):
         super().__init__()
 
         self.app = app
+        self.plain_text = plain_text
+
         self.setSizePolicy(
             QtWidgets.QSizePolicy.MinimumExpanding,
             QtWidgets.QSizePolicy.MinimumExpanding
@@ -45,7 +47,7 @@ class TextEditor(QtWidgets.QWidget):
         self.work_editor_layout.setContentsMargins(2, 2, 2, 2)
         self.t_frame.setLayout(self.work_editor_layout)
 
-        if plain_text:
+        if self.plain_text:
             self.editor_class = FCTextAreaLineNumber()
             self.code_editor = self.editor_class.edit