What does canon do?
lib/python/qt5_graphics.py:392: result, seq = self.load_preview(filename, canon, unitcode, initcode)
The whole function
def load(self,filename = None):
s = self.stat
s.poll()
if not filename and s.file:
filename = s.file
elif not filename and not s.file:
return
lines = open(filename).readlines()
progress = Progress(2, len(lines))
# monkey patch function to call ours
progress.emit_percent = self.emit_percent
code = []
i = 0
for i, l in enumerate(lines):
l = l.expandtabs().replace("\r", "")
code.extend(["%6d: " % (i+1), "lineno", l, ""])
if i % 1000 == 0:
del code[:]
progress.update(i)
if code:
pass
progress.nextphase(len(lines))
td = tempfile.mkdtemp()
self._current_file = filename
try:
random = int(self.inifile.find("EMCIO", "RANDOM_TOOLCHANGER") or 0)
arcdivision = int(self.inifile.find("DISPLAY", "ARCDIVISION") or 64)
text = ''
canon = StatCanon(self.colors,
self.get_geometry(),
self.foam_option,
self.lathe_option,
s, text, random, i,
progress, arcdivision)
# monkey patched function to call ours
canon.output_notify_message = self.output_notify_message
parameter = self.inifile.find("RS274NGC", "PARAMETER_FILE")
temp_parameter = os.path.join(td, os.path.basename(parameter or "linuxcnc.var"))
if parameter:
shutil.copy(parameter, temp_parameter)
canon.parameter_file = temp_parameter
unitcode = "G%d" % (20 + (s.linear_units == 1))
initcode = self.inifile.find("RS274NGC", "RS274NGC_STARTUP_CODE") or ""
result, seq = self.load_preview(filename, canon, unitcode, initcode)
if result > gcode.MIN_ERROR:
self.report_gcode_error(result, seq, filename)
self.logger.set_depth(self.from_internal_linear_unit(self.get_foam_z()),
self.from_internal_linear_unit(self.get_foam_w()))
self.calculate_gcode_properties(canon)
except Exception as e:
print (e)
self.gcode_properties = None
finally:
shutil.rmtree(td)
if canon:
canon.progress = DummyProgress()
try:
progress.done()
except UnboundLocalError:
pass
self._redraw()
class StatCanon(glcanon.GLCanon, interpret.StatMixin):
def __init__(self, colors, geometry, is_foam, lathe_view_option, stat, random, text, linecount, progress, arcdivision):
glcanon.GLCanon.__init__(self, colors, geometry, is_foam)
interpret.StatMixin.__init__(self, stat, random)
self.lathe_view_option = lathe_view_option
self.text = text
self.linecount = linecount
self.progress = progress
self.aborted = False
self.arcdivision = arcdivision
def is_lathe(self): return self.lathe_view_option
def change_tool(self, pocket):
glcanon.GLCanon.change_tool(self,pocket)
interpret.StatMixin.change_tool(self,pocket)
# not sure if this is used - copied from AXIS code
def do_cancel(self, event):
self.aborted = True
# not sure if this is used - copied from AXIS code
def check_abort(self):
#root_window.update()
if self.aborted: raise KeyboardInterrupt
def next_line(self, st):
glcanon.GLCanon.next_line(self, st)
self.progress.update(self.lineno)
if self.notify:
self.output_notify_message(self.notify_message)
self.notify = 0
# this is class patched
# output the text from the magic comment eg: (PREVIEW,notify,The text)
def output_notify_message(self, message):
pass
Just trying to understand what's doing what and why.
JT
Please Log in or Create an account to join the conversation.
This is line 322 'lib/python/gremlin.py':
canon = StatCanon(self.colors, self.get_geometry(),self.lathe_option, s, random)
and this is line 80:
class StatCanon(rs274.glcanon.GLCanon, rs274.interpret.StatMixin):
def __init__(self, colors, geometry, lathe_view_option, stat, random):
rs274.glcanon.GLCanon.__init__(self, colors, geometry)
rs274.interpret.StatMixin.__init__(self, stat, random)
self.progress = DummyProgress()
self.lathe_view_option = lathe_view_option
def is_lathe(self): return self.lathe_view_option
def change_tool(self, pocket):
rs274.glcanon.GLCanon.change_tool(self,pocket)
rs274.interpret.StatMixin.change_tool(self,pocket)
Please Log in or Create an account to join the conversation.
JT
Please Log in or Create an account to join the conversation.
- MennilTossFlykune
- Offline
- Junior Member
- Posts: 35
- Thank you received: 25
Please Log in or Create an account to join the conversation.
- tommylight
- Offline
- Moderator
- Posts: 19300
- Thank you received: 6462
Please Log in or Create an account to join the conversation.
Yes, I know canon = StatCanon(...) but what does StatCanon do?
Well, I'm certainly not the python expert but if we follow the trail then it seems to initialize these two classes which can be found in /lib/python/rs274/glcanon.py and /lib/python/rs274/interpret.py
rs274.glcanon.GLCanon.__init__(self, colors, geometry)
rs274.interpret.StatMixin.__init__(self, stat, random)
Please Log in or Create an account to join the conversation.
It looks to me that all the graphics previews are a copy of what Axis has with some variations.
JT
Please Log in or Create an account to join the conversation.
Yes, with the exeption of 'Probe Basic'.It looks to me that all the graphics previews are a copy of what Axis has with some variations.
forum.linuxcnc.org/qtpyvcp/52562-preview...-program-path#300022
Please Log in or Create an account to join the conversation.
- tommylight
- Offline
- Moderator
- Posts: 19300
- Thank you received: 6462
Me not helping ...
Please Log in or Create an account to join the conversation.
JT
Please Log in or Create an account to join the conversation.