Skip to content

Commit

Permalink
v0.42; make pyinstaller the default
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenhouser committed Dec 27, 2019
1 parent 3a83496 commit 3273809
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 44 deletions.
6 changes: 6 additions & 0 deletions Change_Log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,9 @@ Version 0.40:
Version 0.41:
- Fixed more minor issues reading certain SVG files.

Version 0.42:
- Minor update to DXF reading to include color by layer
- Fix for Inkscape Executable location button. Auto generated text made bu the button did not work for some version of Python
- Fixed trace boundary when X and Y scaling is used
- Limited minimum speed entries to prevent unexpected laser movements.
- Fixed trace boundary space so that it scales with units change.
8 changes: 4 additions & 4 deletions build_macOS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ VERBOSE=false
MAKE_DISK=false
KEEP_VENV=false
SETUP_ENVIRONMENT=false
PYINSTALLER=false
PYINSTALLER=true
while getopts "hvdesp" OPTION; do
case "$OPTION" in
h) echo "Options:"
echo "\t-h Print help (this)"
echo "\t-v Verbose output"
echo "\t-e Keep Python virtual environment (don't delete)"
echo "\t-p Use PyInstaller to build instead of py2app"
echo "\t-p Use py2app to build instead of PyInstaller"
echo "\t-s Setup dev environment"
echo "\t-d Make disk image (.dmg)"
exit 0
Expand All @@ -27,7 +27,7 @@ while getopts "hvdesp" OPTION; do
;;
e) KEEP_VENV=true
;;
p) PYINSTALLER=true
p) PYINSTALLER=false
;;
s) SETUP_ENVIRONMENT=true
;;
Expand Down Expand Up @@ -162,7 +162,7 @@ then
fi

rm ${VOLNAME}.dmg
hdiutil create -fs HFS+ -volname ${VOLNAME} -srcfolder ./dist ./K40-Whisperer-${VERSION}.dmg
hdiutil create -fs HFS+ -volname ${VOLNAME} -srcfolder ./dist ./${VOLNAME}.dmg
fi

echo "Done."
2 changes: 1 addition & 1 deletion dxf.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def add_coords(self,line,offset,scale,rotate,color=None,layer=None):
# Now test for Hidden layer IE Color < 0
if ( slcolor != None) and (slcolor < 0):
return
if color == None:
if (color == None) or (color == 256): # 256 is ColorByLayer
# default to layer color
color = slcolor
if ( color != None) and (color < 0):
Expand Down
119 changes: 82 additions & 37 deletions k40_whisperer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
version = '0.41'
version = '0.42'
title_text = "K40 Whisperer V"+version

import sys
Expand Down Expand Up @@ -456,6 +456,9 @@ def createWidgets(self):
self.Veng_time.set("0")
self.Vcut_time.set("0")
self.Gcde_time.set("0")

self.min_vector_speed = 1.1 #in/min
self.min_raster_speed = 12 #in/min

##########################################################################
### END INITILIZING VARIABLES ###
Expand Down Expand Up @@ -1258,11 +1261,8 @@ def Close_Current_Window_Click(self,event=None):
def Entry_Reng_feed_Check(self):
try:
value = float(self.Reng_feed.get())
if self.units.get() == 'mm':
vfactor = 25.4/60.0
else:
vfactor = 1.0
low_limit = 12*vfactor
vfactor=(25.4/60.0)/self.feed_factor()
low_limit = self.min_raster_speed*vfactor
if value < low_limit:
self.statusMessage.set(" Feed Rate should be greater than or equal to %f " %(low_limit))
return 2 # Value is invalid number
Expand All @@ -1276,8 +1276,10 @@ def Entry_Reng_feed_Callback(self, varName, index, mode):
def Entry_Veng_feed_Check(self):
try:
value = float(self.Veng_feed.get())
if value <= 0.0:
self.statusMessage.set(" Feed Rate should be greater than 0.0 ")
vfactor=(25.4/60.0)/self.feed_factor()
low_limit = self.min_vector_speed*vfactor
if value < low_limit:
self.statusMessage.set(" Feed Rate should be greater than or equal to %f " %(low_limit))
return 2 # Value is invalid number
except:
return 3 # Value not a number
Expand All @@ -1289,8 +1291,10 @@ def Entry_Veng_feed_Callback(self, varName, index, mode):
def Entry_Vcut_feed_Check(self):
try:
value = float(self.Vcut_feed.get())
if value <= 0.0:
self.statusMessage.set(" Feed Rate should be greater than 0.0 ")
vfactor=(25.4/60.0)/self.feed_factor()
low_limit = self.min_vector_speed*vfactor
if value < low_limit:
self.statusMessage.set(" Feed Rate should be greater than or equal to %f " %(low_limit))
return 2 # Value is invalid number
except:
return 3 # Value not a number
Expand Down Expand Up @@ -1555,8 +1559,10 @@ def Entry_Laser_R_Scale_Callback(self, varName, index, mode):
def Entry_Laser_Rapid_Feed_Check(self):
try:
value = float(self.rapid_feed.get())
if value < 0.0:
self.statusMessage.set(" Rapid feed should be greater than 0 (or 0 for default speed) ")
vfactor=(25.4/60.0)/self.feed_factor()
low_limit = 1.0*vfactor
if value !=0 and value < low_limit:
self.statusMessage.set(" Rapid feed should be greater than or equal to %f (or 0 for default speed) " %(low_limit))
return 2 # Value is invalid number
except:
return 3 # Value not a number
Expand Down Expand Up @@ -1636,6 +1642,11 @@ def Entry_Trace_Gap_Callback(self, varName, index, mode):
def Entry_Trace_Speed_Check(self):
try:
value = float(self.trace_speed.get())
vfactor=(25.4/60.0)/self.feed_factor()
low_limit = self.min_vector_speed*vfactor
if value < low_limit:
self.statusMessage.set(" Feed Rate should be greater than or equal to %f " %(low_limit))
return 2 # Value is invalid number
except:
return 3 # Value not a number
self.refreshTime()
Expand All @@ -1651,7 +1662,10 @@ def Inkscape_Path_Click(self, event):
("All Files","*")],\
initialdir=self.inkscape_path.get())
if newfontdir != "" and newfontdir != ():
self.inkscape_path.set(newfontdir.encode("utf-8"))
if type(newfontdir) is not str:
newfontdir = newfontdir.encode("utf-8")
self.inkscape_path.set(newfontdir)

try:
win_id.withdraw()
win_id.deiconify()
Expand Down Expand Up @@ -1686,15 +1700,16 @@ def Scale_Linear_Inputs(self, new_units=None):
self.units_scale = 25.4
else:
return
self.LaserXsize.set( self.Scale_Text_Value('%.2f',self.LaserXsize.get(),factor) )
self.LaserYsize.set( self.Scale_Text_Value('%.2f',self.LaserYsize.get(),factor) )
self.jog_step.set ( self.Scale_Text_Value('%.3f',self.jog_step.get() ,factor) )
self.gotoX.set ( self.Scale_Text_Value('%.3f',self.gotoX.get() ,factor) )
self.gotoY.set ( self.Scale_Text_Value('%.3f',self.gotoY.get() ,factor) )
self.Reng_feed.set ( self.Scale_Text_Value('%.1f',self.Reng_feed.get() ,vfactor) )
self.Veng_feed.set ( self.Scale_Text_Value('%.1f',self.Veng_feed.get() ,vfactor) )
self.Vcut_feed.set ( self.Scale_Text_Value('%.1f',self.Vcut_feed.get() ,vfactor) )
self.trace_speed.set ( self.Scale_Text_Value('%.1f',self.trace_speed.get() ,vfactor) )
self.LaserXsize.set ( self.Scale_Text_Value('%.2f',self.LaserXsize.get() ,factor ) )
self.LaserYsize.set ( self.Scale_Text_Value('%.2f',self.LaserYsize.get() ,factor ) )
self.jog_step.set ( self.Scale_Text_Value('%.3f',self.jog_step.get() ,factor ) )
self.gotoX.set ( self.Scale_Text_Value('%.3f',self.gotoX.get() ,factor ) )
self.gotoY.set ( self.Scale_Text_Value('%.3f',self.gotoY.get() ,factor ) )
self.Reng_feed.set ( self.Scale_Text_Value('%.1f',self.Reng_feed.get() ,vfactor) )
self.Veng_feed.set ( self.Scale_Text_Value('%.1f',self.Veng_feed.get() ,vfactor) )
self.Vcut_feed.set ( self.Scale_Text_Value('%.1f',self.Vcut_feed.get() ,vfactor) )
self.trace_speed.set( self.Scale_Text_Value('%.1f',self.trace_speed.get() ,vfactor) )
self.rapid_feed.set ( self.Scale_Text_Value('%.1f',self.rapid_feed.get() ,vfactor) )

def Scale_Text_Value(self,format_txt,Text_Value,factor):
try:
Expand Down Expand Up @@ -2806,7 +2821,8 @@ def slow_jog(self,dxmils,dymils):
self.stop[0]=False
Rapid_data=[]
Rapid_inst = egv(target=lambda s:Rapid_data.append(s))
Rapid_inst.make_egv_rapid(dxmils,dymils,Feed=float(self.rapid_feed.get()),board_name=self.board_name.get())
Rapid_feed = float(self.rapid_feed.get())*self.feed_factor()
Rapid_inst.make_egv_rapid(dxmils,dymils,Feed=Rapid_feed,board_name=self.board_name.get())
self.send_egv_data(Rapid_data, 1, None)
self.stop[0]=True

Expand Down Expand Up @@ -3053,9 +3069,6 @@ def make_trace_path(self):
Veng_coords = self.mirror_rotate_vector_coords(Veng_coords)
Gcode_coords= self.mirror_rotate_vector_coords(Gcode_coords)

Vcut_coords,startx,starty = self.scale_vector_coords(Vcut_coords,startx,starty)
Veng_coords,startx,starty = self.scale_vector_coords(Veng_coords,startx,starty)
Gcode_coords,startx,starty= self.scale_vector_coords(Gcode_coords,startx,starty)
#######################################
if self.RengData.ecoords==[]:
if self.stop[0] == True:
Expand Down Expand Up @@ -3086,6 +3099,8 @@ def make_trace_path(self):
trace_coords = my_hull.convexHullecoords(all_coords)
gap = float(self.trace_gap.get())/self.units_scale
trace_coords = self.offset_eccords(trace_coords,gap)

trace_coords,startx,starty = self.scale_vector_coords(trace_coords,startx,starty)
return trace_coords


Expand Down Expand Up @@ -3187,7 +3202,7 @@ def point_inside_polygon(self,x,y,poly):
return inside

def optimize_paths(self,ecoords,inside_check=True):
order_out = self.Sort_Paths(ecoords)
order_out = self.Sort_Paths(ecoords)
lastx=-999
lasty=-999
Acc=0.004
Expand Down Expand Up @@ -3337,6 +3352,14 @@ def scale_vector_coords(self,coords,startx,starty):
scaled_starty = starty

return coords_scale,scaled_startx,scaled_starty


def feed_factor(self):
if self.units.get()=='in':
feed_factor = 25.4/60.0
else:
feed_factor = 1.0
return feed_factor

def send_data(self,operation_type=None, output_filename=None):
num_passes=0
Expand All @@ -3345,11 +3368,8 @@ def send_data(self,operation_type=None, output_filename=None):
self.statusbar.configure( bg = 'red' )
return
try:
if self.units.get()=='in':
feed_factor = 25.4/60.0
else:
feed_factor = 1.0

feed_factor=self.feed_factor()

if self.inputCSYS.get() and self.RengData.image == None:
xmin,xmax,ymin,ymax = 0.0,0.0,0.0,0.0
else:
Expand Down Expand Up @@ -3384,6 +3404,30 @@ def send_data(self,operation_type=None, output_filename=None):
self.master.update()
if not self.VcutData.sorted and self.inside_first.get():
self.VcutData.set_ecoords(self.optimize_paths(self.VcutData.ecoords),data_sorted=True)


## DEBUG_PLOT=False
## test_ecoords=self.VcutData.ecoords
## if DEBUG_PLOT:
## import matplotlib.pyplot as plt
## plt.ion()
## plt.clf()
## X=[]
## Y=[]
## LOOP_OLD = test_ecoords[0][2]
## for i in range(len(test_ecoords)):
## LOOP = test_ecoords[i][2]
## if LOOP != LOOP_OLD:
## plt.plot(X,Y)
## plt.pause(.5)
## X=[]
## Y=[]
## LOOP_OLD=LOOP
## X.append(test_ecoords[i][0])
## Y.append(test_ecoords[i][1])
## plt.plot(X,Y)


self.statusMessage.set("Generating EGV data...")
self.master.update()

Expand Down Expand Up @@ -3806,16 +3850,17 @@ def menu_Calc_Raster_Time(self,event=None):

def menu_Help_About(self):

about = "K40 Whisperer by Scorch.\n"
about = "K40 Whisperer Version %s\n\n" %(version)
about = about + "By Scorch.\n"
about = about + "\163\143\157\162\143\150\100\163\143\157\162"
about = about + "\143\150\167\157\162\153\163\056\143\157\155\n"
about = about + "https://www.scorchworks.com/\n\n"
try:
version = "%d.%d.%d" %(sys.version_info.major,sys.version_info.minor,sys.version_info.micro)
python_version = "%d.%d.%d" %(sys.version_info.major,sys.version_info.minor,sys.version_info.micro)
except:
version = ""
about = about + "Python "+version+" (%d bit)" %(struct.calcsize("P") * 8)
message_box("About k40_whisperer",about)
python_version = ""
about = about + "Python "+python_version+" (%d bit)" %(struct.calcsize("P") * 8)
message_box("About k40 Whisperer",about)

def menu_Help_Web(self):
webbrowser.open_new(r"https://www.scorchworks.com/K40whisperer/k40whisperer.html")
Expand Down
2 changes: 1 addition & 1 deletion py2app_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from setuptools import setup

app_name = 'K40 Whisperer'
app_version = "0.41"
app_version = "0.42"
app_copyright = u'Copyright © 2017-2019, Scorch Works, GNU General Public License'
main_script = 'k40_whisperer.py'
url = 'https://github.com/stephenhouser/k40-whisperer'
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
lxml
pyusb
pillow
pyinstaller
4 changes: 4 additions & 0 deletions svg_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def __init__(self):
self.inkscape_exe_list.append("/usr/bin/inkscape")
self.inkscape_exe_list.append("/usr/local/bin/inkscape")
self.inkscape_exe_list.append("/Applications/Inkscape.app/Contents/Resources/bin/inkscape")
self.inkscape_exe_list.append("/Applications/Inkscape.app/Contents/MacOS/Inkscape")
self.inkscape_exe = None
self.lines =[]
self.Cut_Type = {}
Expand Down Expand Up @@ -503,11 +504,13 @@ def process_clone(self, node):
self.groupmat.append(simpletransform.composeTransform(self.groupmat[-1], mat))
# get referenced node
refid = node.get(inkex.addNS('href','xlink'))
#print(refid,node.get('id'),node.get('layer'))
refnode = self.getElementById(refid[1:])
if refnode is not None:
if refnode.tag == inkex.addNS('g','svg') or refnode.tag == inkex.addNS('switch','svg'):
self.process_group(refnode)
elif refnode.tag == inkex.addNS('use', 'svg'):
#print(refnode,'1')
self.process_clone(refnode)
else:
self.process_shape(refnode, self.groupmat[-1])
Expand Down Expand Up @@ -556,6 +559,7 @@ def process_group(self, group):
if node.tag == inkex.addNS('g','svg') or node.tag == inkex.addNS('switch','svg'):
self.process_group(node)
elif node.tag == inkex.addNS('use', 'svg'):
#print(node.get('id'),'2',node.get('href'))
self.process_clone(node)

elif node.tag == inkex.addNS('style', 'svg'):
Expand Down

0 comments on commit 3273809

Please sign in to comment.