Skip to content

Commit

Permalink
More automated cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
iXce committed Aug 8, 2012
1 parent 77eb244 commit 6f446e3
Show file tree
Hide file tree
Showing 20 changed files with 448 additions and 440 deletions.
8 changes: 8 additions & 0 deletions README.cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ Some cleanup commands :

To add a space after each comma :
sed -e "s/\(\w\),\(\w\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\w\),\(\"\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\"\),\(\w\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\"\),\(\"\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\([)}\]]\),\(\w\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\([)}\]]\),\([\[{(]\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\w\),\([\[{(]\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py

To add spaces around each = :
sed -e "s/\(\w\)=\(\w\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\w\)=\(\"\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\w\)=\((\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\w\)=\((\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\w\)=\([\[{(]\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py

To add spaces around each == :
sed -e "s/\(\w\)==\(\w\)/\1 == \2/g" -i *.py printrun/*.py printrun/svg/*.py
Expand Down
2 changes: 1 addition & 1 deletion plater.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def load_stl(self, event, name):
self.Refresh()
#print time.time()-t

def load_stl_into_model(self, path, name, offset=[0, 0, 0], rotation = 0, scale=[1.0, 1.0, 1.0]):
def load_stl_into_model(self, path, name, offset = [0, 0, 0], rotation = 0, scale = [1.0, 1.0, 1.0]):
newname = os.path.split(name.lower())[1]
c = 1
while newname in self.models:
Expand Down
4 changes: 2 additions & 2 deletions printcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def _sendnext(self):
self.clear = True
return
if self.resendfrom < self.lineno and self.resendfrom > -1:
self._send(self.sentlines[self.resendfrom],self.resendfrom, False)
self._send(self.sentlines[self.resendfrom], self.resendfrom, False)
self.resendfrom += 1
return
self.resendfrom = -1
Expand Down Expand Up @@ -364,7 +364,7 @@ def _send(self, command, lineno = 0, calcchecksum = False):
p = printcore(port, baud)
p.loud = loud
time.sleep(2)
gcode = [i.replace("\n","") for i in open(filename)]
gcode = [i.replace("\n", "") for i in open(filename)]
p.startprint(gcode)

try:
Expand Down
4 changes: 2 additions & 2 deletions printrun/calibrateextruder.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def gettemp(p):
-t --temp Extrusion temperature in degrees Celsius (default: %d \xb0C, max %d \xb0C)
-p --port Serial port the printer is connected to (default: %s)
-h --help This cruft.
"""[1:-1].encode('utf-8')%(sys.argv[0],n, k,temp, tempmax, port if port else 'auto')
"""[1:-1].encode('utf-8')%(sys.argv[0], n, k, temp, tempmax, port if port else 'auto')
try:
opts, args = getopt.getopt(sys.argv[1:],"hl:s:t:p:",["help","length = ","steps = ","temp = ","port = "])
opts, args = getopt.getopt(sys.argv[1:],"hl:s:t:p:",["help", "length=", "steps=", "temp=", "port="])
except getopt.GetoptError, err:
print str(err)
print help
Expand Down
6 changes: 3 additions & 3 deletions printrun/gcview.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def glline(self):
]
def glcolor(self, upper_limit = None, lower_limit = 0, max_feedrate = 0):
if self.extrusion_ratio == 0:
return [255, 255, 255, 0,0, 0]
return [255, 255, 255, 0, 0, 0]
else:
blue_color = 0
green_color = 0
Expand Down Expand Up @@ -430,7 +430,7 @@ def transform(self, line):
else:
self.lastf = cur[4]

r = gcline(x = cur[0], y = cur[1], z = cur[2],e = cur[3], f = cur[4], prev_gcline = self.prev, orgline = orgline)
r = gcline(x = cur[0], y = cur[1], z = cur[2], e = cur[3], f = cur[4], prev_gcline = self.prev, orgline = orgline)
self.prev = r
return r
return None
Expand Down Expand Up @@ -927,7 +927,7 @@ def GetSelection(self):
self.modelindex = 0
self.GLPanel1 = TestGlPanel(self, size)

def addfile(self, gcode=[]):
def addfile(self, gcode = []):
self.models["GCODE"].gc.delete()
self.models["GCODE"].gc = gcview(gcode, batch = self.models["GCODE"].batch)
self.setlayerindex(None)
Expand Down
32 changes: 16 additions & 16 deletions printrun/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ def updateTemperatures(self, event):


def drawgrid(self, dc, gc):
#cold, medium, hot = wx.Colour(0, 167, 223),wx.Colour(239, 233, 119),wx.Colour(210, 50.100)
#col1 = wx.Colour(255, 0,0, 255)
#cold, medium, hot = wx.Colour(0, 167, 223), wx.Colour(239, 233, 119), wx.Colour(210, 50.100)
#col1 = wx.Colour(255, 0, 0, 255)
#col2 = wx.Colour(255, 255, 255, 128)

#b = gc.CreateLinearGradientBrush(0, 0, w, h, col1, col2)

gc.SetPen(wx.Pen(wx.Colour(255, 0,0, 0), 4))
gc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 4))
#gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(245, 245, 255, 252))))
#gc.SetBrush(b)
gc.DrawRectangle(0, 0, self.width, self.height)

#gc.SetBrush(wx.Brush(wx.Colour(245, 245, 255, 52)))

#gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0,0, 255))))
#gc.SetPen(wx.Pen(wx.Colour(255, 0,0, 0), 4))
#gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0, 0, 255))))
#gc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 4))

#gc.DrawLines(wx.Point(0, 0), wx.Point(50, 10))

Expand Down Expand Up @@ -121,20 +121,20 @@ def drawgrid(self, dc, gc):

if self.timer.IsRunning() == False:
font = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD)
gc.SetFont(font, wx.Colour(3, 4,4))
gc.SetFont(font, wx.Colour(3, 4, 4))
gc.DrawText("Graph offline", self.width/2 - (font.GetPointSize() * 3), self.height/2 - (font.GetPointSize() * 1))

#dc.DrawCircle(50, 50, 1)

#gc.SetPen(wx.Pen(wx.Colour(255, 0,0, 0), 1))
#gc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 1))
#gc.DrawLines([[20, 30], [10, 53]])
#dc.SetPen(wx.Pen(wx.Colour(255, 0,0, 0), 1))
#dc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 1))

def drawtemperature(self, dc, gc, temperature_list, text, text_xoffset, r, g, b, a):
if self.timer.IsRunning() == False:
dc.SetPen(wx.Pen(wx.Colour(128, 128, 128, 128), 1))
else:
dc.SetPen(wx.Pen(wx.Colour(r, g,b, a), 1))
dc.SetPen(wx.Pen(wx.Colour(r, g, b, a), 1))

x_add = float(self.width)/self.xsteps
x_pos = float(0.0)
Expand All @@ -155,32 +155,32 @@ def drawtemperature(self, dc, gc, temperature_list, text, text_xoffset, r, g, b,
if self.timer.IsRunning() == False:
gc.SetFont(font, wx.Colour(128, 128, 128))
else:
gc.SetFont(font, wx.Colour(r, g,b))
gc.SetFont(font, wx.Colour(r, g, b))

#gc.DrawText(text, self.width - (font.GetPointSize() * ((len(text) * text_xoffset + 1))), self.height - self._lastyvalue - (font.GetPointSize() / 2))
gc.DrawText(text, x_pos - x_add - (font.GetPointSize() * ((len(text) * text_xoffset + 1))), self.height - self._lastyvalue - (font.GetPointSize() / 2))
#gc.DrawText(text, self.width - (font.GetPixelSize().GetWidth() * ((len(text) * text_xoffset + 1) + 1)), self.height - self._lastyvalue - (font.GetPointSize() / 2))


def drawbedtemp(self, dc, gc):
self.drawtemperature(dc, gc, self.bedtemps, "Bed",2, 255, 0,0, 128)
self.drawtemperature(dc, gc, self.bedtemps, "Bed", 2, 255, 0, 0, 128)

def drawbedtargettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.bedtargettemps, "Bed Target",2, 255, 120, 0, 128)
self.drawtemperature(dc, gc, self.bedtargettemps, "Bed Target", 2, 255, 120, 0, 128)


def drawextruder0temp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder0temps, "Ex0",1, 0, 155, 255, 128)
self.drawtemperature(dc, gc, self.extruder0temps, "Ex0", 1, 0, 155, 255, 128)

def drawextruder0targettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder0targettemps, "Ex0 Target",2, 0, 5,255, 128)
self.drawtemperature(dc, gc, self.extruder0targettemps, "Ex0 Target", 2, 0, 5, 255, 128)


def drawextruder1temp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder1temps, "Ex1",3, 55, 55, 0, 128)
self.drawtemperature(dc, gc, self.extruder1temps, "Ex1", 3, 55, 55, 0, 128)

def drawextruder1targettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder1targettemps, "Ex1 Target",2, 55, 55, 0, 128)
self.drawtemperature(dc, gc, self.extruder1targettemps, "Ex1 Target", 2, 55, 55, 0, 128)


def SetBedTemperature(self, value):
Expand Down
Loading

0 comments on commit 6f446e3

Please sign in to comment.