Browse Source

- commented the camlib.alpha_shape() as it is not needed but require a huge package (scipy)

Marius Stanciu 6 years ago
parent
commit
8fcd75a8e4
5 changed files with 53 additions and 34 deletions
  1. 5 3
      FlatCAMApp.py
  2. 2 1
      README.md
  3. 18 3
      flatcamGUI/FlatCAMGUI.py
  4. 1 1
      flatcamTools/ToolCalculators.py
  5. 27 26
      flatcamTools/ToolSilk.py

+ 5 - 3
FlatCAMApp.py

@@ -2143,8 +2143,9 @@ class App(QtCore.QObject):
             # set call source to the Editor we go into
             self.call_source = 'grb_editor'
 
-        # make sure that we can't select another object while in Editor Mode:
-        self.collection.view.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
+        # # make sure that we can't select another object while in Editor Mode:
+        # self.collection.view.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
+        self.ui.project_frame.setDisabled(True)
 
         # delete any selection shape that might be active as they are not relevant in Editor
         self.delete_selection_shape()
@@ -2273,7 +2274,8 @@ class App(QtCore.QObject):
             self.ui.plot_tab_area.protectTab(0)
 
             # make sure that we reenable the selection on Project Tab after returning from Editor Mode:
-            self.collection.view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
+            # self.collection.view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
+            self.ui.project_frame.setDisabled(False)
 
     def get_last_folder(self):
         return self.defaults["global_last_folder"]

+ 2 - 1
README.md

@@ -11,7 +11,8 @@ CAD program, and create G-Code for Isolation routing.
 
 26.04.2019
 
-- small changes in GUI
+- small changes in GUI; optimized contextual menu display
+- made sure that the Project Tab is disabled while one of the Editors is active and it is restored after returning to app
 
 25.04.2019
 

+ 18 - 3
flatcamGUI/FlatCAMGUI.py

@@ -753,12 +753,27 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         ################
 
         ### Project ###
+        # self.project_tab = QtWidgets.QWidget()
+        # self.project_tab.setObjectName("project_tab")
+        # # project_tab.setMinimumWidth(250)  # Hack
+        # self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_tab)
+        # self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
+        # self.notebook.addTab(self.project_tab,_( "Project"))
+
         self.project_tab = QtWidgets.QWidget()
         self.project_tab.setObjectName("project_tab")
-        # project_tab.setMinimumWidth(250)  # Hack
-        self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_tab)
+
+        self.project_frame_lay = QtWidgets.QVBoxLayout(self.project_tab)
+        self.project_frame_lay.setContentsMargins(0, 0, 0, 0)
+
+        self.project_frame = QtWidgets.QFrame()
+        self.project_frame.setContentsMargins(0, 0, 0, 0)
+        self.project_frame_lay.addWidget(self.project_frame)
+
+        self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_frame)
         self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
-        self.notebook.addTab(self.project_tab,_( "Project"))
+        self.notebook.addTab(self.project_tab, _("Project"))
+        self.project_frame.setDisabled(False)
 
         ### Selected ###
         self.selected_tab = QtWidgets.QWidget()

+ 1 - 1
flatcamTools/ToolCalculators.py

@@ -12,9 +12,9 @@ import math
 
 import gettext
 import FlatCAMTranslation as fcTranslate
+import builtins
 
 fcTranslate.apply_language('strings')
-import builtins
 if '_' not in builtins.__dict__:
     _ = gettext.gettext
 

+ 27 - 26
flatcamTools/ToolSilk.py

@@ -108,6 +108,11 @@ class ToolSilk(FlatCAMTool):
         # object to hold a flattened geometry
         self.flat_geometry = []
 
+        self.sm_obj = None
+        self.sm_obj_name = None
+        self.silk_obj = None
+        self.silk_obj_name = None
+
         try:
             self.intersect_btn.clicked.disconnect(self.on_intersection_click)
         except:
@@ -194,7 +199,6 @@ class ToolSilk(FlatCAMTool):
 
                             new_geo = self.subtract_polygon(geo_silk, solder_poly)
                             if not new_geo.is_empty:
-                                print(new_geo.wkt)
                                 # if the resulting geometry is not empty add it to the new_apertures solid_geometry
                                 try:
                                     for g in new_geo:
@@ -204,40 +208,37 @@ class ToolSilk(FlatCAMTool):
                         # else:
                         #     new_solid_geometry.append(geo_silk)
         if new_solid_geometry:
-            try:
-                while not self.new_apertures[apid]['solid_geometry']:
-                    self.new_apertures[apid]['solid_geometry'] = new_solid_geometry
-                    time.sleep(0.5)
-            except:
-                pass
-
-        try:
             while True:
-                # removal from list is done in a multithreaded way therefore not always the removal can be done
-                # so we keep trying until it's done
-                if apid in self.promises:
-                    self.promises.remove(apid)
-                else:
+                if self.new_apertures[apid]['solid_geometry']:
                     break
+                self.new_apertures[apid]['solid_geometry'] = new_solid_geometry
                 time.sleep(0.5)
-        except:
-            log.debug("Promise fulfilled: %s" % str(apid))
-            pass
+
+        while True:
+            # removal from list is done in a multithreaded way therefore not always the removal can be done
+            # so we keep trying until it's done
+            if apid not in self.promises:
+                break
+            self.promises.remove(apid)
+            time.sleep(0.5)
+
+        log.debug("Promise fulfilled: %s" % str(apid))
 
     def subtract_polygon(self, geometry, polygon):
         """
-        Subtract polygon from the given object. This only operates on the paths in the original geometry, i.e. it converts polygons into paths.
+        Subtract polygon from the given object. This only operates on the paths in the original geometry, i.e.
+        it converts polygons into paths.
 
-        :param points: The vertices of the polygon.
+        :param geometry: The geometry from which to substract.
+        :param polygon: The substractor geometry
         :return: none
         """
 
         # pathonly should be always True, otherwise polygons are not subtracted
         flat_geometry = self.flatten(geometry=geometry, pathonly=True)
-        log.debug("%d paths" % len(flat_geometry))
 
-        toolgeo=cascaded_union(polygon)
-        diffs=[]
+        toolgeo = cascaded_union(polygon)
+        diffs = []
         for target in flat_geometry:
             if type(target) == LineString or type(target) == LinearRing:
                 diffs.append(target.difference(toolgeo))
@@ -265,7 +266,7 @@ class ToolSilk(FlatCAMTool):
         if reset:
             self.flat_geometry = []
 
-        ## If iterable, expand recursively.
+        # If iterable, expand recursively. 
         try:
             for geo in geometry:
                 if geo is not None:
@@ -273,7 +274,7 @@ class ToolSilk(FlatCAMTool):
                                  reset=False,
                                  pathonly=pathonly)
 
-        ## Not iterable, do the actual indexing and add.
+        # Not iterable, do the actual indexing and add.
         except TypeError:
             if pathonly and type(geometry) == Polygon:
                 self.flat_geometry.append(geometry.exterior)
@@ -283,6 +284,7 @@ class ToolSilk(FlatCAMTool):
             else:
                 self.flat_geometry.append(geometry)
 
+        log.debug("%d paths" % len(self.flat_geometry))
         return self.flat_geometry
 
     def periodic_check(self, check_period, reset=False):
@@ -290,6 +292,7 @@ class ToolSilk(FlatCAMTool):
         This function starts an QTimer and it will periodically check if intersections are done
 
         :param check_period: time at which to check periodically
+        :param reset: will reset the timer
         :return:
         """
 
@@ -368,5 +371,3 @@ class ToolSilk(FlatCAMTool):
     def reset_fields(self):
         self.silk_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
         self.sm_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
-
-