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

- Geometry object - now plotting color for an individual tool can be specified
- in CutOut Tool - when using 'thin gaps' option then the cut parts are colored differently than the rest of the geometry in the Geometry object

Marius Stanciu 5 лет назад
Родитель
Сommit
e658b61e53
3 измененных файлов с 33 добавлено и 10 удалено
  1. 2 0
      CHANGELOG.md
  2. 27 10
      appObjects/FlatCAMGeometry.py
  3. 4 0
      appTools/ToolCutOut.py

+ 2 - 0
CHANGELOG.md

@@ -11,6 +11,8 @@ CHANGELOG for FlatCAM beta
 
 
 - fix for issue nr 2 in case of Drilling Tool. Need to check Isolation Tool, Paint Tool, NCC Tool
 - fix for issue nr 2 in case of Drilling Tool. Need to check Isolation Tool, Paint Tool, NCC Tool
 - Drilling Tool - UI changes
 - Drilling Tool - UI changes
+- Geometry object - now plotting color for an individual tool can be specified
+- in CutOut Tool - when using  'thin gaps' option then the cut parts are colored differently than the rest of the geometry in the Geometry object
 
 
 25.08.2020
 25.08.2020
 
 

+ 27 - 10
appObjects/FlatCAMGeometry.py

@@ -717,6 +717,7 @@ class GeometryObject(FlatCAMObj, Geometry):
 
 
         for row in range(self.ui.geo_tools_table.rowCount()):
         for row in range(self.ui.geo_tools_table.rowCount()):
             self.ui.geo_tools_table.cellWidget(row, 6).clicked.connect(self.on_plot_cb_click_table)
             self.ui.geo_tools_table.cellWidget(row, 6).clicked.connect(self.on_plot_cb_click_table)
+
         self.ui.plot_cb.stateChanged.connect(self.on_plot_cb_click)
         self.ui.plot_cb.stateChanged.connect(self.on_plot_cb_click)
 
 
         # common parameters update
         # common parameters update
@@ -2736,7 +2737,7 @@ class GeometryObject(FlatCAMObj, Geometry):
         :param kind:        added so there is no error when a project is loaded and it has both geometry and CNCJob,
         :param kind:        added so there is no error when a project is loaded and it has both geometry and CNCJob,
                             because CNCJob require the 'kind' parameter. Perhaps the FlatCAMObj.plot()
                             because CNCJob require the 'kind' parameter. Perhaps the FlatCAMObj.plot()
                             has to be rewritten
                             has to be rewritten
-        :param plot_tool:   plot a specif tool for multigeo objects
+        :param plot_tool:   plot a specific tool for multigeo objects
         :return:
         :return:
         """
         """
 
 
@@ -2773,20 +2774,30 @@ class GeometryObject(FlatCAMObj, Geometry):
                 if plot_tool is None:
                 if plot_tool is None:
                     for tooluid_key in self.tools:
                     for tooluid_key in self.tools:
                         solid_geometry = self.tools[tooluid_key]['solid_geometry']
                         solid_geometry = self.tools[tooluid_key]['solid_geometry']
-                        self.plot_element(solid_geometry, visible=visible,
-                                          color=random_color() if self.options['multicolored']
-                                          else self.app.defaults["geometry_plot_line"])
+                        if 'override_color' in self.tools[tooluid_key]['data']:
+                            color = self.tools[tooluid_key]['data']['override_color']
+                        else:
+                            color = random_color() if self.options['multicolored'] else \
+                                self.app.defaults["geometry_plot_line"]
+
+                        self.plot_element(solid_geometry, visible=visible, color=color)
                 else:
                 else:
                     solid_geometry = self.tools[plot_tool]['solid_geometry']
                     solid_geometry = self.tools[plot_tool]['solid_geometry']
-                    self.plot_element(solid_geometry, visible=visible,
-                                      color=random_color() if self.options['multicolored']
-                                      else self.app.defaults["geometry_plot_line"])
+                    if 'override_color' in self.tools[plot_tool]['data']:
+                        color = self.tools[plot_tool]['data']['override_color']
+                    else:
+                        color = random_color() if self.options['multicolored'] else \
+                            self.app.defaults["geometry_plot_line"]
+
+                    self.plot_element(solid_geometry, visible=visible, color=color)
             else:
             else:
                 # plot solid geometry that may be an direct attribute of the geometry object
                 # plot solid geometry that may be an direct attribute of the geometry object
                 # for SingleGeo
                 # for SingleGeo
                 if self.solid_geometry:
                 if self.solid_geometry:
-                    self.plot_element(self.solid_geometry, visible=visible,
-                                      color=self.app.defaults["geometry_plot_line"])
+                    solid_geometry = self.solid_geometry
+                    color = self.app.defaults["geometry_plot_line"]
+
+                    self.plot_element(solid_geometry, visible=visible, color=color)
 
 
             # self.plot_element(self.solid_geometry, visible=self.options['plot'])
             # self.plot_element(self.solid_geometry, visible=self.options['plot'])
 
 
@@ -2820,6 +2831,7 @@ class GeometryObject(FlatCAMObj, Geometry):
         check_row = 0
         check_row = 0
 
 
         self.shapes.clear(update=True)
         self.shapes.clear(update=True)
+
         for tooluid_key in self.tools:
         for tooluid_key in self.tools:
             solid_geometry = self.tools[tooluid_key]['solid_geometry']
             solid_geometry = self.tools[tooluid_key]['solid_geometry']
 
 
@@ -2829,8 +2841,13 @@ class GeometryObject(FlatCAMObj, Geometry):
                 if tooluid_item == int(tooluid_key):
                 if tooluid_item == int(tooluid_key):
                     check_row = row
                     check_row = row
                     break
                     break
+
             if self.ui.geo_tools_table.cellWidget(check_row, 6).isChecked():
             if self.ui.geo_tools_table.cellWidget(check_row, 6).isChecked():
-                self.plot_element(element=solid_geometry, visible=True)
+                if 'override' in self.tools[tooluid_key]['data']:
+                    self.plot_element(element=solid_geometry, visible=True,
+                                      color=self.tools[tooluid_key]['data']['override'])
+                else:
+                    self.plot_element(element=solid_geometry, visible=True)
         self.shapes.redraw()
         self.shapes.redraw()
 
 
         # make sure that the general plot is disabled if one of the row plot's are disabled and
         # make sure that the general plot is disabled if one of the row plot's are disabled and

+ 4 - 0
appTools/ToolCutOut.py

@@ -503,6 +503,8 @@ class CutOut(AppTool):
                 geo_obj.tools[9999]['data']['cutz'] = self.ui.thin_depth_entry.get_value()
                 geo_obj.tools[9999]['data']['cutz'] = self.ui.thin_depth_entry.get_value()
                 geo_obj.tools[9999]['data']['multidepth'] = self.ui.mpass_cb.get_value()
                 geo_obj.tools[9999]['data']['multidepth'] = self.ui.mpass_cb.get_value()
                 geo_obj.tools[9999]['data']['depthperpass'] = self.ui.maxdepth_entry.get_value()
                 geo_obj.tools[9999]['data']['depthperpass'] = self.ui.maxdepth_entry.get_value()
+                # plot this tool in a different color
+                geo_obj.tools[9999]['data']['override_color'] = "#29a3a3fa"
 
 
         outname = cutout_obj.options["name"] + "_cutout"
         outname = cutout_obj.options["name"] + "_cutout"
         ret = self.app.app_obj.new_object('geometry', outname, geo_init)
         ret = self.app.app_obj.new_object('geometry', outname, geo_init)
@@ -756,6 +758,7 @@ class CutOut(AppTool):
                 geo_obj.tools[9999]['data']['cutz'] = self.ui.thin_depth_entry.get_value()
                 geo_obj.tools[9999]['data']['cutz'] = self.ui.thin_depth_entry.get_value()
                 geo_obj.tools[9999]['data']['multidepth'] = self.ui.mpass_cb.get_value()
                 geo_obj.tools[9999]['data']['multidepth'] = self.ui.mpass_cb.get_value()
                 geo_obj.tools[9999]['data']['depthperpass'] = self.ui.maxdepth_entry.get_value()
                 geo_obj.tools[9999]['data']['depthperpass'] = self.ui.maxdepth_entry.get_value()
+                geo_obj.tools[9999]['data']['override_color'] = "#29a3a3fa"
 
 
         outname = cutout_obj.options["name"] + "_cutout"
         outname = cutout_obj.options["name"] + "_cutout"
         ret = self.app.app_obj.new_object('geometry', outname, geo_init)
         ret = self.app.app_obj.new_object('geometry', outname, geo_init)
@@ -879,6 +882,7 @@ class CutOut(AppTool):
                 self.man_cutout_obj.tools[9999]['data']['cutz'] = self.ui.thin_depth_entry.get_value()
                 self.man_cutout_obj.tools[9999]['data']['cutz'] = self.ui.thin_depth_entry.get_value()
                 self.man_cutout_obj.tools[9999]['data']['multidepth'] = self.ui.mpass_cb.get_value()
                 self.man_cutout_obj.tools[9999]['data']['multidepth'] = self.ui.mpass_cb.get_value()
                 self.man_cutout_obj.tools[9999]['data']['depthperpass'] = self.ui.maxdepth_entry.get_value()
                 self.man_cutout_obj.tools[9999]['data']['depthperpass'] = self.ui.maxdepth_entry.get_value()
+                self.man_cutout_obj.tools[9999]['data']['override_color'] = "#29a3a3fa"
             else:
             else:
                 self.man_cutout_obj.tools[9999]['solid_geometry'].append(gaps_solid_geo)
                 self.man_cutout_obj.tools[9999]['solid_geometry'].append(gaps_solid_geo)