From e658b61e533fa5c848032e9c25793ea875e527ec Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 26 Aug 2020 03:38:47 +0300 Subject: [PATCH] - 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 --- CHANGELOG.md | 2 ++ appObjects/FlatCAMGeometry.py | 37 +++++++++++++++++++++++++---------- appTools/ToolCutOut.py | 4 ++++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf323fc8..3c4879fb 100644 --- a/CHANGELOG.md +++ b/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 - 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 diff --git a/appObjects/FlatCAMGeometry.py b/appObjects/FlatCAMGeometry.py index e4fb71ca..a2693af0 100644 --- a/appObjects/FlatCAMGeometry.py +++ b/appObjects/FlatCAMGeometry.py @@ -717,6 +717,7 @@ class GeometryObject(FlatCAMObj, Geometry): 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.plot_cb.stateChanged.connect(self.on_plot_cb_click) # 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, because CNCJob require the 'kind' parameter. Perhaps the FlatCAMObj.plot() 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: """ @@ -2773,20 +2774,30 @@ class GeometryObject(FlatCAMObj, Geometry): if plot_tool is None: for tooluid_key in self.tools: 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: 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: # plot solid geometry that may be an direct attribute of the geometry object # for SingleGeo 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']) @@ -2820,6 +2831,7 @@ class GeometryObject(FlatCAMObj, Geometry): check_row = 0 self.shapes.clear(update=True) + for tooluid_key in self.tools: solid_geometry = self.tools[tooluid_key]['solid_geometry'] @@ -2829,8 +2841,13 @@ class GeometryObject(FlatCAMObj, Geometry): if tooluid_item == int(tooluid_key): check_row = row break + 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() # make sure that the general plot is disabled if one of the row plot's are disabled and diff --git a/appTools/ToolCutOut.py b/appTools/ToolCutOut.py index 50864fc2..49a989f0 100644 --- a/appTools/ToolCutOut.py +++ b/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']['multidepth'] = self.ui.mpass_cb.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" 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']['multidepth'] = self.ui.mpass_cb.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" 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']['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']['override_color'] = "#29a3a3fa" else: self.man_cutout_obj.tools[9999]['solid_geometry'].append(gaps_solid_geo)