5656"""
5757
5858
59- class CanonShade (GLCanon , interpret .StatMixin ):
59+ class CanonInfo (GLCanon , interpret .StatMixin ):
6060 """
6161 Implementing GLcanon in a way to use shaders pipeline.
6262 Instantiating interpret stat mixin to be a self contained library without needing to reimplement it.
@@ -80,7 +80,13 @@ def __init__(
8080 self .shader_type = "CanonShader"
8181
8282 def draw_lines (self , lines , for_selection , j = 0 , geometry = None ):
83-
83+ """
84+ Returns the list of lines to draw in a format suitable for OpenGL.
85+ if line is
86+ Traverse: [(line number, (start position), (end position), (tlo x, tlo y, tlo z))]
87+ Feed: [(line number, (start position), (end position), feedrate, (tlo x, tlo y, tlo z))]
88+ ArcFeed: [(line number, (start position), (end position), feedrate, (tlo x, tlo y, tlo z))]
89+ """
8490 out_list = []
8591 if len (lines ) < 0 :
8692 print ("No lines to draw, returning empty list." )
@@ -96,7 +102,10 @@ def draw_lines(self, lines, for_selection, j=0, geometry=None):
96102 return (c_float * len (out_list ))(* out_list )
97103
98104 def draw_dwells (self , dwells , alpha , for_selection , j0 = 0 ):
99- # print(f"Drawing {len(dwells)} dwells with CanonShader")
105+ """
106+ Returns the list of dwells to draw in a format suitable for OpenGL.
107+ TODO: Does this actually draw anything? like would it be better to be a point or something?
108+ """
100109 out_list = []
101110 if len (dwells ) < 0 :
102111 print ("No dwells to draw, returning empty list." )
@@ -111,6 +120,10 @@ def draw_dwells(self, dwells, alpha, for_selection, j0=0):
111120 return (c_float * len (out_list ))(* out_list )
112121
113122 def highlight (self , lineno , geometry ):
123+ """
124+ Highlight a specific line in the G-code.
125+ TODO: This is not implemented in the shader yet.
126+ """
114127 out_list = []
115128 if lineno < 0 or lineno >= len (self .feed ):
116129 print (f"Invalid line number { lineno } , returning empty list." )
@@ -524,9 +537,7 @@ def __init__(
524537 self .rotationAxis = QtGui .QVector3D (1 , 1 , 0 )
525538 self .angularSpeed = 0
526539 self .lastTime = time .time ()
527- self .timer = QtCore .QTimer ()
528- self .timer .timeout .connect (self .update )
529- self .timer .start (16 ) # Approximately 60 FPS
540+
530541 self .setMinimumSize (800 , 600 )
531542
532543 self .last_mouse_position = QtCore .QPoint ()
@@ -539,7 +550,7 @@ def init_canon(self):
539550 inifile = linuxcnc .ini (status .ini_filename )
540551 parameter = inifile .find ("RS274NGC" , "PARAMETER_FILE" )
541552 self .parrr = os .path .dirname (self .status .ini_filename ) + "/" + parameter
542- self .canon = CanonShade (
553+ self .canon = CanonInfo (
543554 colors = self .colors ,
544555 geometry = "XYZ" ,
545556 is_foam = False ,
@@ -611,6 +622,7 @@ def mousePressEvent(self, e):
611622 elif e .button () == QtCore .Qt .RightButton :
612623 self .last_mouse_position = e .pos ()
613624 self .angularSpeed = 0.1
625+ self .update ()
614626
615627 def mouseReleaseEvent (self , e ):
616628 if e .button () == QtCore .Qt .LeftButton :
@@ -646,6 +658,8 @@ def mouseMoveEvent(self, e):
646658 self .rotation = QtGui .QQuaternion .fromAxisAndAngle (self .rotationAxis , self .angularSpeed ) * self .rotation
647659 self .last_mouse_position = e .pos ()
648660
661+ self .update ()
662+
649663 def wheelEvent (self , e : QtGui .QWheelEvent ):
650664 """
651665 Handle mouse scroll events to zoom in and out.
@@ -655,9 +669,6 @@ def wheelEvent(self, e: QtGui.QWheelEvent):
655669 self .current_scale = max (0.1 , min (self .current_scale , 10.0 ))
656670 self .update ()
657671
658- def timerEvent (self , arg__0 ):
659- update ()
660-
661672
662673if __name__ == "__main__" :
663674 colors = {
0 commit comments