Преглед изворни кода

- fixed the above mentioned glitch in the OpenGL(3D) graphic engine when an Gerber object has been set with a color

Marius Stanciu пре 6 година
родитељ
комит
5b62b3c5f6
2 измењених фајлова са 28 додато и 4 уклоњено
  1. 1 0
      README.md
  2. 27 4
      flatcamGUI/VisPyVisuals.py

+ 1 - 0
README.md

@@ -15,6 +15,7 @@ CAD program, and create G-Code for Isolation routing.
 - fixed issue in Gerber UI where a label was not hidden when in Basic mode
 - fixed issue in Gerber UI where a label was not hidden when in Basic mode
 - added the color parameters of the objects to the serializable attributes
 - added the color parameters of the objects to the serializable attributes
 - fixed Gerber object color set for Legacy(2D) graphic engine; glitch on the OpenGL(3D) graphic engine
 - fixed Gerber object color set for Legacy(2D) graphic engine; glitch on the OpenGL(3D) graphic engine
+- fixed the above mentioned glitch in the OpenGL(3D) graphic engine when an Gerber object has been set with a color
 
 
 21.12.2019
 21.12.2019
 
 

+ 27 - 4
flatcamGUI/VisPyVisuals.py

@@ -329,27 +329,40 @@ class ShapeCollectionVisual(CompoundVisual):
         # Merge shapes buffers
         # Merge shapes buffers
 
 
         if indexes is None:
         if indexes is None:
-            for data in self.data.values():
+            for k, data in list(self.data.items()):
                 if data['visible'] and 'line_pts' in data:
                 if data['visible'] and 'line_pts' in data:
                     if new_mesh_color and new_mesh_color != '':
                     if new_mesh_color and new_mesh_color != '':
                         dim_mesh_tris = (len(data['mesh_tris']) // 3)
                         dim_mesh_tris = (len(data['mesh_tris']) // 3)
                         if dim_mesh_tris != 0:
                         if dim_mesh_tris != 0:
                             try:
                             try:
                                 mesh_colors[data['layer']] += [Color(new_mesh_color).rgba] * dim_mesh_tris
                                 mesh_colors[data['layer']] += [Color(new_mesh_color).rgba] * dim_mesh_tris
+                                self.data[k]['face_color'] = new_mesh_color
+
+                                new_temp = list()
+                                for i in range(len(data['mesh_colors'])):
+                                    new_temp.append(Color(new_mesh_color).rgba)
+                                data['mesh_colors'] = new_temp
                             except Exception as e:
                             except Exception as e:
                                 print("VisPyVisuals.ShapeCollectionVisual.update_color(). "
                                 print("VisPyVisuals.ShapeCollectionVisual.update_color(). "
                                       "Create mesh colors --> Data error. %s" % str(e))
                                       "Create mesh colors --> Data error. %s" % str(e))
+
                     if new_line_color and new_line_color != '':
                     if new_line_color and new_line_color != '':
                         dim_line_pts = (len(data['line_pts']))
                         dim_line_pts = (len(data['line_pts']))
                         if dim_line_pts != 0:
                         if dim_line_pts != 0:
                             try:
                             try:
                                 line_pts[data['layer']] += data['line_pts']
                                 line_pts[data['layer']] += data['line_pts']
                                 line_colors[data['layer']] += [Color(new_line_color).rgba] * dim_line_pts
                                 line_colors[data['layer']] += [Color(new_line_color).rgba] * dim_line_pts
+                                self.data[k]['color'] = new_line_color
+
+                                new_temp = list()
+                                for i in range(len(data['line_colors'])):
+                                    new_temp.append(Color(new_line_color).rgba)
+                                data['line_colors'] = new_temp
                             except Exception as e:
                             except Exception as e:
                                 print("VisPyVisuals.ShapeCollectionVisual.update_color(). "
                                 print("VisPyVisuals.ShapeCollectionVisual.update_color(). "
                                       "Create line colors --> Data error. %s" % str(e))
                                       "Create line colors --> Data error. %s" % str(e))
         else:
         else:
-            for k, data in self.data.items():
+            for k, data in list(self.data.items()):
                 if data['visible'] and 'line_pts' in data:
                 if data['visible'] and 'line_pts' in data:
                     dim_mesh_tris = (len(data['mesh_tris']) // 3)
                     dim_mesh_tris = (len(data['mesh_tris']) // 3)
                     dim_line_pts = (len(data['line_pts']))
                     dim_line_pts = (len(data['line_pts']))
@@ -360,6 +373,11 @@ class ShapeCollectionVisual(CompoundVisual):
                                 try:
                                 try:
                                     mesh_colors[data['layer']] += [Color(new_mesh_color).rgba] * dim_mesh_tris
                                     mesh_colors[data['layer']] += [Color(new_mesh_color).rgba] * dim_mesh_tris
                                     self.data[k]['face_color'] = new_mesh_color
                                     self.data[k]['face_color'] = new_mesh_color
+
+                                    new_temp = list()
+                                    for i in range(len(data['mesh_colors'])):
+                                        new_temp.append(Color(new_mesh_color).rgba)
+                                    data['mesh_colors'] = new_temp
                                 except Exception as e:
                                 except Exception as e:
                                     print("VisPyVisuals.ShapeCollectionVisual.update_color(). "
                                     print("VisPyVisuals.ShapeCollectionVisual.update_color(). "
                                           "Create mesh colors --> Data error. %s" % str(e))
                                           "Create mesh colors --> Data error. %s" % str(e))
@@ -369,6 +387,11 @@ class ShapeCollectionVisual(CompoundVisual):
                                     line_pts[data['layer']] += data['line_pts']
                                     line_pts[data['layer']] += data['line_pts']
                                     line_colors[data['layer']] += [Color(new_line_color).rgba] * dim_line_pts
                                     line_colors[data['layer']] += [Color(new_line_color).rgba] * dim_line_pts
                                     self.data[k]['color'] = new_line_color
                                     self.data[k]['color'] = new_line_color
+
+                                    new_temp = list()
+                                    for i in range(len(data['line_colors'])):
+                                        new_temp.append(Color(new_line_color).rgba)
+                                    data['line_colors'] = new_temp
                                 except Exception as e:
                                 except Exception as e:
                                     print("VisPyVisuals.ShapeCollectionVisual.update_color(). "
                                     print("VisPyVisuals.ShapeCollectionVisual.update_color(). "
                                           "Create line colors --> Data error. %s" % str(e))
                                           "Create line colors --> Data error. %s" % str(e))
@@ -481,8 +504,8 @@ class ShapeCollectionVisual(CompoundVisual):
         # Only one thread can update data
         # Only one thread can update data
         self.results_lock.acquire(True)
         self.results_lock.acquire(True)
 
 
-        for i in list(self.data.copy().keys()) if not indexes else indexes:
-            if i in list(self.results.copy().keys()):
+        for i in list(self.data.keys()) if not indexes else indexes:
+            if i in list(self.results.keys()):
                 try:
                 try:
                     self.results[i].wait()                                  # Wait for process results
                     self.results[i].wait()                                  # Wait for process results
                     if i in self.data:
                     if i in self.data: