Skip to content

Commit

Permalink
Eliminate plugin progress bar...
Browse files Browse the repository at this point in the history
...and uses Cura progress bar for both CuraEngine and the plugins.
  • Loading branch information
Dim3nsioneer committed Feb 25, 2015
1 parent 73241e2 commit f69011b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
11 changes: 9 additions & 2 deletions Cura/gui/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,15 @@ def onPluginUpdate(self,msg): #receives commands from the plugin thread
elif cmd[0] == "ClosePluginProgressWindow":
self.dialogframe.Destroy()
self.dialogframe=None
else:
print "Unknown Plugin update received: " + cmd[0]
else: #assume first token to be the name and second token the percentage
if len(cmd)>=2:
number = int(cmd[1])
else:
number = 100
# direct output to Cura progress bar
self.scene.printButton.setProgressBar(float(number)/100.)
self.scene.printButton.setBottomText('%s' % (cmd[0]))
self.scene.QueueRefresh()

def onTimer(self, e):
#Check if there is something in the clipboard
Expand Down
3 changes: 2 additions & 1 deletion Cura/gui/sceneView.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ def _updateEngineProgress(self, progressValue):
self.printButton.setProgressBar(progressValue)
else:
self.printButton.setProgressBar(None)
self.QueueRefresh()
self._engineResultView.setResult(result)
if finished:
self.printButton.setProgressBar(None)
Expand All @@ -648,7 +649,7 @@ def _updateEngineProgress(self, progressValue):
text += '\n%s' % (cost)
self.printButton.setBottomText(text)
else:
self.printButton.setBottomText('')
self.printButton.setBottomText('CuraEngine')
self.QueueRefresh()

def loadScene(self, fileList, pms_transforms=None):
Expand Down
3 changes: 2 additions & 1 deletion Cura/gui/util/openglGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ def draw(self):
glTranslatef(0, 0.6*bs, 0)
glTranslatef(0, 6, 0)
#glTranslatef(0.6*bs*scale, 0, 0)

if progress is not None:
glTranslatef(0, bs/4+4, 0) #shifts text to the bottom if progress bar is active
for line in self._altTooltip.split('\n'):
glPushMatrix()
glColor4ub(60,60,60,255)
Expand Down
26 changes: 9 additions & 17 deletions plugins/TweakAtZ.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Name: Tweak At Z 4.0.1
#Name: Tweak At Z 4.0.2
#Info: Change printing parameters at a given height
#Help: TweakAtZ
#Depend: GCode
Expand Down Expand Up @@ -43,8 +43,8 @@
## extruder three code removed, tweaking print speed, save call of Publisher class,
## uses previous value from other plugins also on UltiGCode
##V4.0.1: Bugfix for doubled G1 commands

version = '4.0.1'
##V4.0.2: uses Cura progress bar instead of its own
version = '4.0.2'

import re
import wx
Expand Down Expand Up @@ -128,18 +128,14 @@ def getValue(line, key, default = None):
except:
targetL_i = -100000

if Publisher is not None:
if targetL_i > -100000:
wx.CallAfter(Publisher().sendMessage, "pluginupdate",
"OpenPluginProgressWindow;TweakAtZ;Tweak At Z plugin is executed at layer " + str(targetL_i))
else:
wx.CallAfter(Publisher().sendMessage, "pluginupdate",
"OpenPluginProgressWindow;TweakAtZ;Tweak At Z plugin is executed at height " + str(targetZ) + "mm")
with open(filename, "w") as file:
for line in lines:
if int(i*100/l) > lastpercentage and Publisher is not None: #progressbar
lastpercentage = int(i*100/l)
wx.CallAfter(Publisher().sendMessage, "pluginupdate", "Progress;" + str(lastpercentage))
if targetL_i > -100000:
wx.CallAfter(Publisher().sendMessage, "pluginupdate", ("TweakAtZ Layer %d" % targetL_i) + ";" + str(lastpercentage))
else:
wx.CallAfter(Publisher().sendMessage, "pluginupdate", ("TweakAtZ %1.2f" % targetZ) + "mm;" + str(lastpercentage))
if ';Layer count:' in line:
TWinstances += 1
file.write(';TweakAtZ instances: %d\n' % TWinstances)
Expand Down Expand Up @@ -202,8 +198,8 @@ def getValue(line, key, default = None):
if 'G1' in line and x != None and y != None and f != None and e != None and newZ==z:
file.write("G1 F%d X%1.3f Y%1.3f E%1.5f\n" % (int(f/100.0*float(printspeed)),getValue(line,'X'),
getValue(line,'Y'),getValue(line,'E')))
else: #G1 command but not a print movement
file.write(line)
else: #G1 command but not a print movement
file.write(line)
# no tweaking on retraction hops which have no x and y coordinate:
if (newZ != z) and (x is not None) and (y is not None):
z = newZ
Expand Down Expand Up @@ -266,7 +262,3 @@ def getValue(line, key, default = None):
else:
file.write("M606 ;recalls saved settings\n")
i+=1
if Publisher is not None:
wx.CallAfter(Publisher().sendMessage, "pluginupdate", "Progress;100")
time.sleep(1)
wx.CallAfter(Publisher().sendMessage, "pluginupdate", "ClosePluginProgressWindow")

0 comments on commit f69011b

Please sign in to comment.