diff --git a/HeeksCNC installer.iss b/HeeksCNC installer.iss index af646e2e..030ba5d2 100644 --- a/HeeksCNC installer.iss +++ b/HeeksCNC installer.iss @@ -7,7 +7,7 @@ ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) AppId={{FE583F3D-8863-438B-AD81-790FD54A7113} AppName=HeeksCNC -AppVerName=HeeksCNC 0.27.0 +AppVerName=HeeksCNC 0.28.0 AppPublisher=Heeks Software AppPublisherURL=http://heeks.net/ AppSupportURL=http://code.google.com/p/heekscnc/ @@ -15,7 +15,7 @@ AppUpdatesURL=http://code.google.com/p/heekscnc/ DefaultDirName={pf}\HeeksCNC DefaultGroupName=HeeksCNC DisableProgramGroupPage=yes -OutputBaseFilename=HeeksCNC 0.27.0 +OutputBaseFilename=HeeksCNC 0.28.0 Compression=lzma SolidCompression=yes @@ -40,22 +40,22 @@ Source: "C:\Dev\HeeksCADSVN\wxmsw28u_gl_vc_custom.dll"; DestDir: "{app}"; Flags: Source: "C:\Dev\HeeksCADSVN\wxmsw28u_core_vc_custom.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "C:\Dev\HeeksCADSVN\wxmsw28u_aui_vc_custom.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "C:\Dev\HeeksCADSVN\wxbase28u_vc_custom.dll"; DestDir: "{app}"; Flags: ignoreversion -Source: "C:\Dev\HeeksCNCSVN\post for installer.bat"; DestDir: "{app}\HeeksCNC"; DestName: "post.bat"; Flags: ignoreversion -Source: "C:\Dev\HeeksCNCSVN\nc_read for installer.bat"; DestDir: "{app}\HeeksCNC"; DestName: "nc_read.bat"; Flags: ignoreversion -Source: "C:\Dev\HeeksCNCSVN\backplot.py"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion -Source: "C:\Dev\HeeksCNCSVN\area_funcs.py"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion +Source: "C:\Dev\HeeksCNCSVN\post for installer.bat"; DestDir: "{app}\HeeksCNC"; DestName: "post.bat"; Flags: ignoreversion; Permissions: users-modify +Source: "C:\Dev\HeeksCNCSVN\nc_read for installer.bat"; DestDir: "{app}\HeeksCNC"; DestName: "nc_read.bat"; Flags: ignoreversion; Permissions: users-modify +Source: "C:\Dev\HeeksCNCSVN\backplot.py"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion; Permissions: users-modify +Source: "C:\Dev\HeeksCNCSVN\area_funcs.py"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion; Permissions: users-modify Source: "C:\Dev\libarea\Release\area.pyd"; DestDir: "{app}\HeeksCNC\Boolean"; Flags: ignoreversion Source: "C:\Dev\HeeksCNCSVN\subdir.manifest"; DestDir: "{app}\HeeksCNC\Boolean"; DestName: "Microsoft.VC90.CRT.manifest"; Flags: ignoreversion -Source: "C:\Dev\HeeksCNCSVN\kurve_funcs.py"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion -Source: "C:\Dev\HeeksCNCSVN\area_funcs.py"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion +Source: "C:\Dev\HeeksCNCSVN\kurve_funcs.py"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion; Permissions: users-modify +Source: "C:\Dev\HeeksCNCSVN\area_funcs.py"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion; Permissions: users-modify Source: "C:\Dev\libarea\ClipperRelease\area.pyd"; DestDir: "{app}\HeeksCNC\Clipper"; Flags: ignoreversion Source: "C:\Dev\HeeksCNCSVN\subdir.manifest"; DestDir: "{app}\HeeksCNC\Clipper"; DestName: "Microsoft.VC90.CRT.manifest"; Flags: ignoreversion -Source: "C:\Dev\HeeksCNCSVN\ocl_funcs.py"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion +Source: "C:\Dev\HeeksCNCSVN\ocl_funcs.py"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion; Permissions: users-modify Source: "C:\Dev\HeeksCNCSVN\ocl.pyd"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion -Source: "C:\Dev\HeeksCNCSVN\*.speeds"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion -Source: "C:\Dev\HeeksCNCSVN\*.tooltable"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion -Source: "C:\Dev\HeeksCNCSVN\nc\*.py"; DestDir: "{app}\HeeksCNC\nc"; Flags: ignoreversion -Source: "C:\Dev\HeeksCNCSVN\nc\*.txt"; DestDir: "{app}\HeeksCNC\nc"; Flags: ignoreversion +Source: "C:\Dev\HeeksCNCSVN\*.speeds"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion; Permissions: users-modify +Source: "C:\Dev\HeeksCNCSVN\*.tooltable"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion; Permissions: users-modify +Source: "C:\Dev\HeeksCNCSVN\nc\*.py"; DestDir: "{app}\HeeksCNC\nc"; Flags: ignoreversion; Permissions: users-modify +Source: "C:\Dev\HeeksCNCSVN\nc\*.txt"; DestDir: "{app}\HeeksCNC\nc"; Flags: ignoreversion; Permissions: users-modify Source: "C:\Dev\HeeksCNCSVN\src\Unicode Release\HeeksCNC.dll"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion Source: "C:\Dev\HeeksCNCSVN\bitmaps\*.png"; DestDir: "{app}\HeeksCNC\bitmaps"; Flags: ignoreversion Source: "C:\Dev\HeeksCNCSVN\bitmaps\pocket\*.png"; DestDir: "{app}\HeeksCNC\bitmaps\pocket"; Flags: ignoreversion @@ -69,7 +69,7 @@ Source: "C:\python26\python.exe"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversio Source: "C:\Dev\voxelcut\voxelcut.bat"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion Source: "C:\Dev\voxelcut\area.pyd"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion Source: "C:\Dev\voxelcut\voxelcut.pyd"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion -Source: "C:\Dev\voxelcut\*.py"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion +Source: "C:\Dev\voxelcut\*.py"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion; Permissions: users-modify Source: "C:\Dev\voxelcut\bitmaps\*.png"; DestDir: "{app}\HeeksCNC\bitmaps"; Flags: ignoreversion Source: "C:\Program Files (x86)\VoxelCut\wx.*.pyd"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion Source: "C:\Program Files (x86)\VoxelCut\wx*.dll"; DestDir: "{app}\HeeksCNC"; Flags: ignoreversion diff --git a/area_funcs.py b/area_funcs.py index 53128abc..66298460 100644 --- a/area_funcs.py +++ b/area_funcs.py @@ -358,7 +358,7 @@ def zigzag(a, stepover, zig_unidirectional): reorder_zigs() -def pocket(a,tool_radius, extra_offset, rapid_safety_space, start_depth, final_depth, stepover, stepdown, z_finish_depth, z_thru_depth, user_depths, clearance_height, from_center, keep_tool_down_if_poss, use_zig_zag, zig_angle, zig_unidirectional = False,start_point=None, cut_mode = 'conventional'): +def pocket(a,tool_radius, extra_offset, stepover, depth_params, from_center, keep_tool_down_if_poss, use_zig_zag, zig_angle, zig_unidirectional = False,start_point=None, cut_mode = 'conventional'): global tool_radius_for_pocket global area_for_feed_possible @@ -375,9 +375,6 @@ def pocket(a,tool_radius, extra_offset, rapid_safety_space, start_depth, final_d area_for_feed_possible = area.Area(a) area_for_feed_possible.Offset(extra_offset - 0.01) - if rapid_safety_space > clearance_height: - rapid_safety_space = clearance_height - use_internal_function = (area.holes_linked() == False) # use internal function, if area module is the Clipper library if use_internal_function: @@ -419,16 +416,16 @@ def pocket(a,tool_radius, extra_offset, rapid_safety_space, start_depth, final_d a_offset.Offset(current_offset) curve_list = get_curve_list(arealist, cut_mode == 'climb') - depths = kurve_funcs.get_depths(start_depth, final_depth, stepdown, z_finish_depth, z_thru_depth, user_depths) + depths = depth_params.get_depths() - current_start_depth = start_depth + current_start_depth = depth_params.start_depth if start_point==None: for depth in depths: - cut_curvelist1(curve_list, rapid_safety_space, current_start_depth, depth, clearance_height, keep_tool_down_if_poss) + cut_curvelist1(curve_list, depth_params.rapid_safety_space, current_start_depth, depth, depth_params.clearance_height, keep_tool_down_if_poss) current_start_depth = depth else: for depth in depths: - cut_curvelist2(curve_list, rapid_safety_space, current_start_depth, depth, clearance_height, keep_tool_down_if_poss, start_point) + cut_curvelist2(curve_list, depth_params.rapid_safety_space, current_start_depth, depth, depth_params.clearance_height, keep_tool_down_if_poss, start_point) current_start_depth = depth diff --git a/bitmaps/bitmaps.svg b/bitmaps/bitmaps.svg index 6d29c8bc..6d06fe07 100644 --- a/bitmaps/bitmaps.svg +++ b/bitmaps/bitmaps.svg @@ -28,12 +28,12 @@ objecttolerance="10" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="35.311145" + inkscape:zoom="1.7220218" inkscape:cx="401.14537" - inkscape:cy="670.86404" + inkscape:cy="844.52024" inkscape:document-units="px" inkscape:current-layer="layer1" - showgrid="false" + showgrid="true" inkscape:window-width="1495" inkscape:window-height="968" inkscape:window-x="295" @@ -11050,6 +11050,58 @@ offset="1" id="stop3694-9" /> + + + + + + + + + + + @@ -12871,5 +12923,26 @@ style="fill:none;stroke:#00ff00;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + + + + diff --git a/bitmaps/depthop/clearance height.png b/bitmaps/depthop/clearance height.png index 97ef9602..0c78cebe 100644 Binary files a/bitmaps/depthop/clearance height.png and b/bitmaps/depthop/clearance height.png differ diff --git a/bitmaps/depthop/depthop.svg b/bitmaps/depthop/depthop.svg index c262ec71..45aef263 100644 --- a/bitmaps/depthop/depthop.svg +++ b/bitmaps/depthop/depthop.svg @@ -7,6 +7,7 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="744.09448819" @@ -16,7 +17,5235 @@ inkscape:version="0.48.2 r9819" sodipodi:docname="depthop.svg"> + id="defs4"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + inkscape:window-width="1920" + inkscape:window-height="1018" + inkscape:window-x="-8" + inkscape:window-y="-8" + inkscape:window-maximized="1"> - - - - - - - Z - - - - X - - - - - - - - - - - - - - - - + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Dev\HeeksCNCSVN\bitmaps\drilling\clearance height.png" + id="g4236" + style="display:inline" + transform="translate(620,1040.0128)"> + + + + + + + + + + - - Z - - - - X - - - - - - - - - - - - - - + sodipodi:nodetypes="cccccccccccccccccccc" /> - + id="g3720" + transform="translate(-310,-405)"> + transform="translate(0,-215)" + id="g4088-5-8-7" + style="display:inline"> Z + id="rect4084-4-2-8" />Z X - - - - - - - - - - - - - + + + + + + + + + + + + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Dev\HeeksCNCSVN\bitmaps\drilling\stand off.png" + id="g4570" + style="display:inline" + transform="translate(620,1040)"> + + + + + - + transform="matrix(0.40650676,0,0,0.40650676,2.3685106,478.03946)" + style="display:inline" + id="g22931-7-5"> - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Z + + + + X + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Z + + + + X + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Z Z + id="g4088-6-5-5-4" + transform="matrix(-0.00329066,0.99999459,-0.99999459,-0.00329066,843.4768,1104.922)"> + + + + X + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Z + + + + X + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Z + + + + X + + + + + + + + + + - X - - + + + + + + + + + + + + + + + + + + + + + id="path4076-1-1-0-1" + d="m 340,812.36218 0,-35" + style="fill:none;stroke:#0000ff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + id="path4078-5-5-7-1" + d="m 335,787.36218 5,-15 5,15 z" + style="fill:#0000ff;stroke:#0000ff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + + Z - + id="path4076-8-4-1-2-0" + d="m 340,812.36218 0,-35" + style="fill:#ff0000;stroke:#ff0000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + id="path4078-2-7-8-14-9" + d="m 335,787.36218 5,-15 5,15 z" + style="fill:#ff0000;stroke:#ff0000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + + X + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id="path4076" + d="m 340,812.36218 0,-35" + style="fill:none;stroke:#0000ff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + id="path4078" + d="m 335,787.36218 5,-15 5,15 z" + style="fill:#0000ff;stroke:#0000ff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + + Z + id="path4076-8" + d="m 340,812.36218 0,-35" + style="fill:#ff0000;stroke:#ff0000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + id="path4078-2" + d="m 335,787.36218 5,-15 5,15 z" + style="fill:#ff0000;stroke:#ff0000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + X + + + + + + + + + + + + + + + + + + + + + + + + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Dev\HeeksCNCSVN\bitmaps\pocket\final depth.png" + id="g5895"> + transform="translate(0,210)" /> + id="g4088-5" + transform="translate(0,210)"> Z Z X + id="tspan4125-1" + x="383.32968" + y="1026.6075">X + + + style="fill:url(#linearGradient6876-5-5-8-8-3-5);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.20000000000000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 393.63839,319.31458 0.71662,-0.0496 c 2.13758,-4.76651 9.54782,-11.84509 9.73942,-16.2815 0.002,-0.20591 -0.12212,-0.49053 -0.14065,-0.36321 -0.62196,4.27344 -9.65791,12.38152 -10.31539,16.69429 z" + id="path6707-9-5-9-1-5-0" + sodipodi:nodetypes="cccsc" + inkscape:connector-curvature="0" /> + + + + + + + + - - + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="C:\Dev\HeeksCNCSVN\bitmaps\pocket\rapid down height.png" + id="g5988"> + + + + + + + + + Z + + + + X + + + + + + + + + + + + + + + + + + sodipodi:nodetypes="cccsc" + id="path8920" + d="m 393.63839,319.31458 0.71662,-0.0496 c 2.13758,-4.76651 9.54782,-11.84509 9.73942,-16.2815 0.002,-0.20591 -0.12212,-0.49053 -0.14065,-0.36321 -0.62196,4.27344 -9.65791,12.38152 -10.31539,16.69429 z" + style="fill:url(#linearGradient8940);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.20000000000000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> - - Z - + sodipodi:nodetypes="csssssc" + id="path8922" + d="m 394.36865,319.28724 c 1.73265,-0.29038 3.24943,-0.29129 3.26957,-0.31047 1.49107,-1.42036 2.12768,-1.1428 1.91218,0.27999 -0.001,0.008 0.607,0.26802 0.66407,0.19834 2.31598,-2.82805 5.70784,-6.29982 3.30829,-12.78865 -0.24483,-0.66205 -0.0369,-1.12109 -0.26566,-0.67108 -2.09113,4.11427 -7.99296,10.41706 -8.88845,13.29187 z" + style="fill:url(#linearGradient8942);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.20000000000000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccsc" + id="path8924" + d="m 397.59613,318.97397 -0.008,0.008 c 0.7424,-0.0968 1.4003,0.25994 1.98156,0.2719 0,0 0.008,2.3e-4 0.008,2.3e-4 0.13662,-1.3559 -0.34251,-1.7629 -1.98131,-0.27979 z" + style="fill:url(#linearGradient8944);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.20000000000000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + + + + + + + - X - - - - - - - - - - - - - - - - - + style="stroke-width:0.2;stroke-miterlimit:4;stroke-dasharray:none;display:inline" + inkscape:export-ydpi="40.651165" + inkscape:export-xdpi="40.651165" + inkscape:export-filename="C:\Users\Dan\HeeksCNC\icons\endmill.png" + id="g6878-2-8-2-0-3" + transform="matrix(1.9538327,-0.01260281,0.01260281,1.9538327,-336.98906,528.06444)"> + style="fill:url(#linearGradient6876-5-5-8-8-8);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 393.63839,319.31458 0.71662,-0.0496 c 2.13758,-4.76651 9.54782,-11.84509 9.73942,-16.2815 0.002,-0.20591 -0.12212,-0.49053 -0.14065,-0.36321 -0.62196,4.27344 -9.65791,12.38152 -10.31539,16.69429 z" + id="path6707-9-5-9-1-2" + sodipodi:nodetypes="cccsc" + inkscape:connector-curvature="0" /> + + + + + + + - - Z - - X - - - - - - - - - - - - - diff --git a/bitmaps/depthop/drill clearance height.png b/bitmaps/depthop/drill clearance height.png new file mode 100644 index 00000000..91917be2 Binary files /dev/null and b/bitmaps/depthop/drill clearance height.png differ diff --git a/bitmaps/depthop/drill final depth.png b/bitmaps/depthop/drill final depth.png new file mode 100644 index 00000000..9fd0b60c Binary files /dev/null and b/bitmaps/depthop/drill final depth.png differ diff --git a/bitmaps/depthop/drill rapid down height.png b/bitmaps/depthop/drill rapid down height.png new file mode 100644 index 00000000..2cba5d8f Binary files /dev/null and b/bitmaps/depthop/drill rapid down height.png differ diff --git a/bitmaps/depthop/drill start depth.png b/bitmaps/depthop/drill start depth.png new file mode 100644 index 00000000..33fb0c8a Binary files /dev/null and b/bitmaps/depthop/drill start depth.png differ diff --git a/bitmaps/depthop/drill step down.png b/bitmaps/depthop/drill step down.png new file mode 100644 index 00000000..3ea9eb96 Binary files /dev/null and b/bitmaps/depthop/drill step down.png differ diff --git a/bitmaps/depthop/drill z finish depth.png b/bitmaps/depthop/drill z finish depth.png new file mode 100644 index 00000000..6e1ab643 Binary files /dev/null and b/bitmaps/depthop/drill z finish depth.png differ diff --git a/bitmaps/depthop/drill z thru depth.png b/bitmaps/depthop/drill z thru depth.png new file mode 100644 index 00000000..61f85520 Binary files /dev/null and b/bitmaps/depthop/drill z thru depth.png differ diff --git a/bitmaps/depthop/final depth.png b/bitmaps/depthop/final depth.png index dfc2b4a5..17d7acdc 100644 Binary files a/bitmaps/depthop/final depth.png and b/bitmaps/depthop/final depth.png differ diff --git a/bitmaps/depthop/rapid down height.png b/bitmaps/depthop/rapid down height.png index 6d430468..ab06d7c9 100644 Binary files a/bitmaps/depthop/rapid down height.png and b/bitmaps/depthop/rapid down height.png differ diff --git a/bitmaps/depthop/start depth.png b/bitmaps/depthop/start depth.png index 197cd2f1..27027772 100644 Binary files a/bitmaps/depthop/start depth.png and b/bitmaps/depthop/start depth.png differ diff --git a/bitmaps/depthop/step down.png b/bitmaps/depthop/step down.png index c6015553..ed76065a 100644 Binary files a/bitmaps/depthop/step down.png and b/bitmaps/depthop/step down.png differ diff --git a/bitmaps/depthop/z finish depth.png b/bitmaps/depthop/z finish depth.png index 0dbe8c15..7e48cbd3 100644 Binary files a/bitmaps/depthop/z finish depth.png and b/bitmaps/depthop/z finish depth.png differ diff --git a/bitmaps/depthop/z thru depth.png b/bitmaps/depthop/z thru depth.png index 25149c28..4b46d3dd 100644 Binary files a/bitmaps/depthop/z thru depth.png and b/bitmaps/depthop/z thru depth.png differ diff --git a/bitmaps/pocket/clearance height.png b/bitmaps/pocket/clearance height.png deleted file mode 100644 index 97ef9602..00000000 Binary files a/bitmaps/pocket/clearance height.png and /dev/null differ diff --git a/bitmaps/pocket/final depth.png b/bitmaps/pocket/final depth.png deleted file mode 100644 index dfc2b4a5..00000000 Binary files a/bitmaps/pocket/final depth.png and /dev/null differ diff --git a/bitmaps/pocket/rapid down height.png b/bitmaps/pocket/rapid down height.png deleted file mode 100644 index 6d430468..00000000 Binary files a/bitmaps/pocket/rapid down height.png and /dev/null differ diff --git a/bitmaps/pocket/start depth.png b/bitmaps/pocket/start depth.png deleted file mode 100644 index 197cd2f1..00000000 Binary files a/bitmaps/pocket/start depth.png and /dev/null differ diff --git a/bitmaps/pocket/step down.png b/bitmaps/pocket/step down.png deleted file mode 100644 index c6015553..00000000 Binary files a/bitmaps/pocket/step down.png and /dev/null differ diff --git a/bitmaps/pocket/z finish depth.png b/bitmaps/pocket/z finish depth.png deleted file mode 100644 index 0dbe8c15..00000000 Binary files a/bitmaps/pocket/z finish depth.png and /dev/null differ diff --git a/bitmaps/pocket/z thru depth.png b/bitmaps/pocket/z thru depth.png deleted file mode 100644 index 25149c28..00000000 Binary files a/bitmaps/pocket/z thru depth.png and /dev/null differ diff --git a/depth_params.py b/depth_params.py new file mode 100644 index 00000000..1debdae1 --- /dev/null +++ b/depth_params.py @@ -0,0 +1,29 @@ +class depth_params: + def __init__(self, clearance_height, rapid_safety_space, start_depth, step_down, z_finish_depth, z_thru_depth, final_depth, user_depths): + self.clearance_height = clearance_height + self.rapid_safety_space = rapid_safety_space + self.start_depth = start_depth + self.step_down = step_down + self.z_finish_depth = z_finish_depth + self.z_thru_depth = z_thru_depth + self.final_depth = final_depth + self.user_depths = user_depths + + def get_depths(self): + if self.user_depths != None: + depths = self.user_depths + else: + depth = self.final_depth - self.z_thru_depth + depths = [depth] + depth += self.z_finish_depth + if depth + 0.0000001 < self.start_depth: + if self.z_finish_depth > 0.0000001: depths.insert(0, depth) + depth += self.z_thru_depth + layer_count = int((self.start_depth - depth) / self.step_down - 0.0000001) + 1 + if layer_count > 0: + layer_depth = (self.start_depth - depth)/layer_count + for i in range(1, layer_count): + depth += layer_depth + depths.insert(0, depth) + + return depths diff --git a/kurve_funcs.py b/kurve_funcs.py index 409aa48e..ce574dc8 100644 --- a/kurve_funcs.py +++ b/kurve_funcs.py @@ -140,7 +140,7 @@ def add_roll_on(curve, roll_on_curve, direction, roll_radius, offset_extra, roll off_v = area.Point(v.y, -v.x) else: off_v = area.Point(-v.y, v.x) - rollstart = first_span.p + off_v * roll_radius - v * roll_radius + rollstart = first_span.p + off_v * roll_radius else: rollstart = roll_on @@ -173,7 +173,7 @@ def add_roll_off(curve, roll_off_curve, direction, roll_radius, offset_extra, ro else: off_v = area.Point(-v.y, v.x) - rollend = last_span.v.p + off_v * roll_radius + v * roll_radius; + rollend = last_span.v.p + off_v * roll_radius; else: rollend = roll_off @@ -221,28 +221,9 @@ def add_CRC_end_line(curve,roll_on_curve,roll_off_curve,radius,direction,crc_end crc_end_point.x = crc_end.x crc_end_point.y = crc_end.y -def get_depths(start_depth, final_depth, stepdown, z_finish_depth, z_thru_depth, user_depths): - if user_depths != None: - depths = user_depths - else: - depth = final_depth - z_thru_depth - depths = [depth] - depth += z_finish_depth - if depth + 0.0000001 < start_depth: - if z_finish_depth > 0.0000001: depths.insert(0, depth) - depth += z_thru_depth - layer_count = int((start_depth - depth) / stepdown - 0.0000001) + 1 - if layer_count > 0: - layer_depth = (start_depth - depth)/layer_count - for i in range(1, layer_count): - depth += layer_depth - depths.insert(0, depth) - - return depths - # profile command, # direction should be 'left' or 'right' or 'on' -def profile(curve, direction = "on", radius = 1.0, offset_extra = 0.0, roll_radius = 2.0, roll_on = None, roll_off = None, rapid_safety_space = None, clearance = None, start_depth = None, stepdown = None, z_finish_depth = None, z_thru_depth = None, user_depths = None, final_depth = None, extend_at_start = 0.0, extend_at_end = 0.0, lead_in_line_len=0.0,lead_out_line_len= 0.0): +def profile(curve, direction = "on", radius = 1.0, offset_extra = 0.0, roll_radius = 2.0, roll_on = None, roll_off = None, depth_params = None, extend_at_start = 0.0, extend_at_end = 0.0, lead_in_line_len=0.0,lead_out_line_len= 0.0): global tags offset_curve = area.Curve(curve) @@ -288,21 +269,24 @@ def profile(curve, direction = "on", radius = 1.0, offset_extra = 0.0, roll_radi raise "sketch has no spans!" # do multiple depths - depths = get_depths(start_depth, final_depth, stepdown, z_finish_depth, z_thru_depth, user_depths) + depths = depth_params.get_depths() - current_start_depth = start_depth + current_start_depth = depth_params.start_depth # tags if len(tags) > 0: # make a copy to restore to after each level copy_of_offset_curve = area.Curve(offset_curve) - prev_depth = start_depth + prev_depth = depth_params.start_depth + + endpoint = None + for depth in depths: mat_depth = prev_depth if len(tags) > 0: - split_for_tags(offset_curve, radius, start_depth, depth, final_depth) + split_for_tags(offset_curve, radius, start_depth, depth, depth_params.final_depth) # make the roll on and roll off kurves roll_on_curve = area.Curve() @@ -314,21 +298,22 @@ def profile(curve, direction = "on", radius = 1.0, offset_extra = 0.0, roll_radi add_CRC_start_line(offset_curve,roll_on_curve,roll_off_curve,radius,direction,crc_start_point,lead_in_line_len) # get the tag depth at the start - start_z = get_tag_z_for_span(0, offset_curve, radius, start_depth, depth, final_depth) + start_z = get_tag_z_for_span(0, offset_curve, radius, depth_params.start_depth, depth, depth_params.final_depth) if start_z > mat_depth: mat_depth = start_z # rapid across to the start s = roll_on_curve.FirstVertex().p # start point - if use_CRC(): - rapid(crc_start_point.x,crc_start_point.y) - else: - rapid(s.x, s.y) - - # rapid down to just above the material - rapid(z = mat_depth + rapid_safety_space) + if (endpoint == None) or (endpoint != s): + if use_CRC(): + rapid(crc_start_point.x,crc_start_point.y) + else: + rapid(s.x, s.y) + # rapid down to just above the material + rapid(z = mat_depth + depth_params.rapid_safety_space) + # feed down to depth mat_depth = depth if start_z > mat_depth: mat_depth = start_z @@ -338,7 +323,6 @@ def profile(curve, direction = "on", radius = 1.0, offset_extra = 0.0, roll_radi start_CRC(direction == "left", radius) # move to the startpoint feed(s.x, s.y) - # cut the roll on arc cut_curve(roll_on_curve) @@ -349,7 +333,7 @@ def profile(curve, direction = "on", radius = 1.0, offset_extra = 0.0, roll_radi for span in offset_curve.GetSpans(): # height for tags current_perim += span.Length() - ez = get_tag_z_for_span(current_perim, offset_curve, radius, start_depth, depth, final_depth) + ez = get_tag_z_for_span(current_perim, offset_curve, radius, depth_params.start_depth, depth, depth_params.final_depth) if span.v.type == 0:#line feed(span.v.p.x, span.v.p.y, ez) @@ -363,12 +347,14 @@ def profile(curve, direction = "on", radius = 1.0, offset_extra = 0.0, roll_radi # cut the roll off arc cut_curve(roll_off_curve) + endpoint = roll_off_curve.LastVertex().p + #add CRC end_line if use_CRC(): crc_end_point = area.Point() add_CRC_end_line(offset_curve,roll_on_curve,roll_off_curve,radius,direction,crc_end_point,lead_out_line_len) if direction == "on": - rapid(z = clearance) + rapid(z = depth_params.clearance_height) else: feed(crc_end_point.x, crc_end_point.y) @@ -378,9 +364,10 @@ def profile(curve, direction = "on", radius = 1.0, offset_extra = 0.0, roll_radi offset_curve = area.Curve(copy_of_offset_curve) if use_CRC(): end_CRC() - # rapid up to the clearance height - rapid(z = clearance) + if endpoint != s: + # rapid up to the clearance height + rapid(z = depth_params.clearance_height) del offset_curve diff --git a/nc/anilam_crusader_m.py b/nc/anilam_crusader_m.py index b8be53f5..50e3be4a 100644 --- a/nc/anilam_crusader_m.py +++ b/nc/anilam_crusader_m.py @@ -104,7 +104,7 @@ def workplane(self, id): def write_blocknum(self): pass - def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None,retract_mode=None, spindle_mode=None, clearance_height = None): + def drill(self, x=None, y=None, dwell=None, depth_params = None, retract_mode=None, spindle_mode=None): self.write('(Canned drill cycle ops are not yet supported here on this Anilam Crusader M postprocessor)') nc.creator = Creator() diff --git a/nc/emc2.py b/nc/emc2.py index 1c520055..e3335175 100755 --- a/nc/emc2.py +++ b/nc/emc2.py @@ -325,7 +325,7 @@ def end_CRC(self): # retract_mode : 0 - rapid retract, 1 - feed retract # spindle_mode ; if true, stop spindle at bottom, otherwise keep runnung - def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None, retract_mode=None, spindle_mode=None, clearance_height = None): + def drill(self, x=None, y=None, dwell=None, depth_params = None, retract_mode=None, spindle_mode=None): if standoff == None: # This is a bad thing. All the drilling cycles need a retraction (and starting) height. diff --git a/nc/heiden.py b/nc/heiden.py index 1d7c81cc..543a89f5 100644 --- a/nc/heiden.py +++ b/nc/heiden.py @@ -737,7 +737,7 @@ def profile(self): # revert it. I must set the mode so that I can be sure the values I'm passing in make # sense to the end-machine. # - def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None, retract_mode=None, spindle_mode=None, clearance_height = None): + def drill(self, x=None, y=None, dwell=None, depth_params = None, retract_mode=None, spindle_mode=None): if (standoff == None): # This is a bad thing. All the drilling cycles need a retraction (and starting) height. return diff --git a/nc/iso.py b/nc/iso.py index 711c70c4..0762b11e 100644 --- a/nc/iso.py +++ b/nc/iso.py @@ -764,25 +764,22 @@ def profile(self): # revert it. I must set the mode so that I can be sure the values I'm passing in make # sense to the end-machine. # - def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None, retract_mode=None, spindle_mode=None, clearance_height = None): - if (standoff == None): - # This is a bad thing. All the drilling cycles need a retraction (and starting) height. + def drill(self, x=None, y=None, dwell=None, depth_params = None, retract_mode=None, spindle_mode=None): + if (depth_params.clearance_height == None): return - - if (z == None): - return # We need a Z value as well. This input parameter represents the top of the hole drillExpanded = self.drillExpanded - if (peck_depth != 0) and (dwell != 0): + if (depth_params.step_down != 0) and (dwell != 0): # pecking and dwell together if self.dwell_allowed_in_G83 != True: drillExpanded = True if drillExpanded: # for machines which don't understand G81, G82 etc. + peck_depth = depth_params.step_down if peck_depth == None: - peck_depth = depth - current_z = z + peck_depth = depth_params.final_depth + current_z = depth_params.start_depth self.rapid(x, y) first = True @@ -790,20 +787,20 @@ def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, p while True: next_z = current_z - peck_depth - if next_z < (z - depth + 0.001): - next_z = z - depth + if next_z < (depth_params.final_depth + 0.001): + next_z = depth_params.final_depth last_cut = True if next_z >= current_z: break; if first: - self.rapid(z = z + standoff) + self.rapid(z = depth_params.start_depth + depth_params.rapid_safety_space) else: self.rapid(z = current_z) self.feed(z = next_z) if dwell != 0 and last_cut: self.dwell(dwell) - if last_cut:self.rapid(z = clearance_height) - else: self.rapid(z = z + standoff) + if last_cut:self.rapid(z = depth_params.clearance_height) + else: self.rapid(z = depth_params.start_depth + depth_params.rapid_safety_space) current_z = next_z first = False @@ -813,14 +810,14 @@ def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, p self.write_preps() self.write_blocknum() - if (peck_depth != 0): + if (depth_params.step_down != 0): # We're pecking. Let's find a tree. if self.drill_modal: - if self.PECK_DRILL() + self.PECK_DEPTH(peck_depth) != self.prev_drill: - self.write(self.SPACE() + self.PECK_DRILL() + self.SPACE() + self.PECK_DEPTH(peck_depth)) - self.prev_drill = self.PECK_DRILL() + self.PECK_DEPTH(peck_depth) + if self.PECK_DRILL() + self.PECK_DEPTH(depth_params.step_down) != self.prev_drill: + self.write(self.SPACE() + self.PECK_DRILL() + self.SPACE() + self.PECK_DEPTH(depth_params.step_down)) + self.prev_drill = self.PECK_DRILL() + self.PECK_DEPTH(depth_params.step_down) else: - self.write(self.PECK_DRILL() + self.PECK_DEPTH(peck_depth)) + self.write(self.PECK_DRILL() + self.PECK_DEPTH(depth_params.step_down)) if (self.dwell != 0) and self.dwell_allowed_in_G83: self.write(self.SPACE() + self.TIME() + (self.FORMAT_TIME().string(dwell))) @@ -847,7 +844,7 @@ def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, p self.write(self.SPACE() + self.DRILL_WITH_DWELL(dwell)) # Set the retraction point to the 'standoff' distance above the starting z height. - retract_height = z + standoff + retract_height = depth_params.start_depth + depth_params.rapid_safety_space if (x != None): dx = x - self.x self.write(self.SPACE() + self.X() + (self.fmt.string(x + self.shift_x))) @@ -858,15 +855,15 @@ def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, p self.write(self.SPACE() + self.Y() + (self.fmt.string(y + self.shift_y))) self.y = y - dz = (z + standoff) - self.z # In the end, we will be standoff distance above the z value passed in. + dz = (depth_params.start_depth + depth_params.rapid_safety_space) - self.z # In the end, we will be standoff distance above the z value passed in. if self.drill_modal: - if z != self.prev_z: - self.write(self.SPACE() + self.Z() + (self.fmt.string(z - depth))) - self.prev_z=z + if depth_params.start_depth != self.prev_z: + self.write(self.SPACE() + self.Z() + (self.fmt.string(depth_params.final_depth))) + self.prev_z=depth_params.start_depth else: - self.write(self.SPACE() + self.Z() + (self.fmt.string(z - depth))) # This is the 'z' value for the bottom of the hole. - self.z = (z + standoff) # We want to remember where z is at the end (at the top of the hole) + self.write(self.SPACE() + self.Z() + (self.fmt.string(depth_params.final_depth))) # This is the 'z' value for the bottom of the hole. + self.z = (depth_params.start_depth + depth_params.rapid_safety_space) # We want to remember where z is at the end (at the top of the hole) if self.drill_modal: if self.prev_retract != self.RETRACT(retract_height) : @@ -882,68 +879,6 @@ def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, p self.write_spindle() self.write_misc() self.write('\n') - - # G33.1 tapping with EMC for now - # unsynchronized (chuck) taps NIY (tap_mode = 1) - - def tap(self, x=None, y=None, z=None, zretract=None, depth=None, standoff=None, dwell_bottom=None, pitch=None, stoppos=None, spin_in=None, spin_out=None, tap_mode=None, direction=None): - # mystery parameters: - # zretract=None, dwell_bottom=None,pitch=None, stoppos=None, spin_in=None, spin_out=None): - # I dont see how to map these to EMC Gcode - - if (standoff == None): - # This is a bad thing. All the drilling cycles need a retraction (and starting) height. - return - if (z == None): - return # We need a Z value as well. This input parameter represents the top of the hole - if (pitch == None): - return # We need a pitch value. - if (direction == None): - return # We need a direction value. - - if (tap_mode != 0): - raise "only rigid tapping currently supported" - - self.in_canned_cycle = True - self.write_preps() - self.write_blocknum() - self.write_spindle() - self.write('\n') - - # rapid to starting point; z first, then x,y iff given - - # Set the retraction point to the 'standoff' distance above the starting z height. - retract_height = z + standoff - - # unsure if this is needed: - if self.z != retract_height: - self.rapid(z = retract_height) - - # then continue to x,y if given - if (x != None) or (y != None): - self.write_blocknum() - self.write(self.RAPID() ) - - if (x != None): - self.write(self.X() + self.fmt.string(x + self.shift_x)) - self.x = x - - if (y != None): - self.write(self.Y() + self.fmt.string(y + self.shift_y)) - self.y = y - self.write('\n') - - self.write_blocknum() - self.write( self.TAP() ) - self.write( self.TAP_DEPTH(self.ffmt,pitch) + self.SPACE() ) - self.write(self.Z() + self.fmt.string(z - depth))# This is the 'z' value for the bottom of the tap. - self.write_misc() - self.write('\n') - - self.z = retract_height # this cycle returns to the start position, so remember that as z value - - def bore(self, x=None, y=None, z=None, zretract=None, depth=None, standoff=None, dwell_bottom=None, feed_in=None, feed_out=None, stoppos=None, shift_back=None, shift_right=None, backbore=False, stop=False): - pass def end_canned_cycle(self): if self.in_canned_cycle == False: diff --git a/nc/nc.py b/nc/nc.py index 83e20939..163f5e55 100644 --- a/nc/nc.py +++ b/nc/nc.py @@ -256,7 +256,7 @@ def profile(self): """Profile routine""" pass - def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None, retract_mode=None, spindle_mode=None, clearance_height = None): + def drill(self, x=None, y=None, dwell=None, depth_params = None, retract_mode=None, spindle_mode=None): """Drilling routines""" pass @@ -587,8 +587,8 @@ def pocket(): def profile(): creator.profile() -def drill(x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None, retract_mode=None, spindle_mode=None, clearance_height = None): - creator.drill(x, y, z, depth, standoff, dwell, peck_depth, retract_mode, spindle_mode, clearance_height) +def drill(x=None, y=None, dwell=None, depth_params = None, retract_mode=None, spindle_mode=None): + creator.drill(x, y, dwell, depth_params, retract_mode, spindle_mode) def tap(x=None, y=None, z=None, zretract=None, depth=None, standoff=None, dwell_bottom=None, pitch=None, stoppos=None, spin_in=None, spin_out=None, tap_mode=None, direction=None): diff --git a/nc/recreator.py b/nc/recreator.py index 1bc8906b..d31fd0ba 100644 --- a/nc/recreator.py +++ b/nc/recreator.py @@ -234,9 +234,9 @@ def circular_pocket(self, x=None, y=None, ToolDiameter=None, HoleDiameter=None, self.cut_path() self.circular_pocket(x, y, ToolDiameter, HoleDiameter, ClearanceHeight, StartHeight, MaterialTop, FeedRate, SpindleRPM, HoleDepth, DepthOfCut, StepOver) - def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None,retract_mode=None, spindle_mode=None, clearance_height = None): + def drill(self, x=None, y=None, dwell=None, depth_params = None, retract_mode=None, spindle_mode=None): self.cut_path() - self.original.drill(x, y, z, depth, standoff, dwell, peck_depth, retract_mode, spindle_mode, clearance_height) + self.original.drill(x, y, dwell, depth_params, spindle_mode, clearance_height) # argument list adapted for compatibility with Tapping module # wild guess - I'm unsure about the purpose of this file and wether this works -haberlerm diff --git a/nc/rez2.py b/nc/rez2.py index 094fc23a..b6392b14 100644 --- a/nc/rez2.py +++ b/nc/rez2.py @@ -492,7 +492,7 @@ def circular_pocket(self, x=None, y=None, ToolDiameter=None, HoleDiameter=None, # revert it. I must set the mode so that I can be sure the values I'm passing in make # sense to the end-machine. # - def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None,retract_mode=None, spindle_mode=None, clearance_height = None): + def drill(self, x=None, y=None, dwell=None, depth_params = None, retract_mode=None, spindle_mode=None): if (standoff == None): # This is a bad thing. All the drilling cycles need a retraction (and starting) height. return diff --git a/nc/transform.py b/nc/transform.py index dbdc4157..4a871d46 100644 --- a/nc/transform.py +++ b/nc/transform.py @@ -308,8 +308,8 @@ def profile(self): def circular_pocket(self, x=None, y=None, ToolDiameter=None, HoleDiameter=None, ClearanceHeight=None, StartHeight=None, MaterialTop=None, FeedRate=None, SpindleRPM=None, HoleDepth=None, DepthOfCut=None, StepOver=None ): self.circular_pocket(x, y, ToolDiameter, HoleDiameter, ClearanceHeight, StartHeight, MaterialTop, FeedRate, SpindleRPM, HoleDepth, DepthOfCut, StepOver) - def drill(self, x=None, y=None, z=None, depth=None, standoff=None, dwell=None, peck_depth=None,retract_mode=None, spindle_mode=None, clearance_height = None): - self.commands.append(Drill(x, y, z, depth, standoff, dwell, peck_depth, retract_mode, spindle_mode, clearance_height)) + def drill(self, x=None, y=None, dwell=None, depth_params = None, retract_mode=None, spindle_mode=None): + self.commands.append(Drill(x, y, dwell, depth_params, spindle_mode, clearance_height)) # argument list adapted for compatibility with Tapping module # wild guess - I'm unsure about the purpose of this file and wether this works -haberlerm diff --git a/nc_read.bat b/nc_read.bat index 0c9f2032..03b0f9ba 100644 --- a/nc_read.bat +++ b/nc_read.bat @@ -1,3 +1 @@ %HOMEDRIVE%\python26\python.exe backplot.py %1 %2 - -pause \ No newline at end of file diff --git a/ocl_funcs.py b/ocl_funcs.py index 7b2fae2c..e7aca66f 100644 --- a/ocl_funcs.py +++ b/ocl_funcs.py @@ -1,6 +1,7 @@ import ocl import math from nc.nc import * +import tempfile def STLSurfFromFile(filepath): s = ocl.STLSurf() diff --git a/post.bat b/post.bat index 1b89b3a4..1db85763 100644 --- a/post.bat +++ b/post.bat @@ -1,3 +1 @@ %HOMEDRIVE%\python26\python.exe %1 - -pause \ No newline at end of file diff --git a/src/CTool.cpp b/src/CTool.cpp index fa65ab87..590ebbcb 100644 --- a/src/CTool.cpp +++ b/src/CTool.cpp @@ -1344,7 +1344,7 @@ Python CTool::OpenCamLibDefinition(const unsigned int indent /* = 0 */ )const return(python); } -static bool OnEdit(HeeksObj* object, std::list *others) +static bool OnEdit(HeeksObj* object) { CToolDlg dlg(heeksCAD->GetMainFrame(), (CTool*)object); if(dlg.ShowModal() == wxID_OK) @@ -1356,7 +1356,7 @@ static bool OnEdit(HeeksObj* object, std::list *others) return false; } -void CTool::GetOnEdit(bool(**callback)(HeeksObj*, std::list *)) +void CTool::GetOnEdit(bool(**callback)(HeeksObj*)) { #if 1 *callback = OnEdit; diff --git a/src/CTool.h b/src/CTool.h index 3997e118..fedb630e 100644 --- a/src/CTool.h +++ b/src/CTool.h @@ -135,7 +135,7 @@ class CTool: public HeeksObj { Python OpenCamLibDefinition(const unsigned int indent = 0)const; Python VoxelcutDefinition()const; - void GetOnEdit(bool(**callback)(HeeksObj*, std::list *)); + void GetOnEdit(bool(**callback)(HeeksObj*)); void OnChangeViewUnits(const double units); private: diff --git a/src/DepthOp.cpp b/src/DepthOp.cpp index bb6d6289..98194d2e 100644 --- a/src/DepthOp.cpp +++ b/src/DepthOp.cpp @@ -214,95 +214,23 @@ void CDepthOp::ReadDefaultValues() config.Read(_T("RapidDown"), &m_depth_op_params.m_rapid_safety_space, 2.0); } -void CDepthOp::SetDepthsFromSketchesAndTool(const std::list *sketches) -{ - std::list objects; - - if (sketches != NULL) - { - for (std::list::const_iterator l_itSketch = sketches->begin(); l_itSketch != sketches->end(); l_itSketch++) - { - HeeksObj *pSketch = heeksCAD->GetIDObject( SketchType, *l_itSketch ); - if (pSketch != NULL) - { - objects.push_back(pSketch); - } - } - } - - SetDepthsFromSketchesAndTool( objects ); -} - -void CDepthOp::SetDepthsFromSketchesAndTool(const std::list sketches) -{ - for (std::list::const_iterator l_itSketch = sketches.begin(); l_itSketch != sketches.end(); l_itSketch++) - { - double default_depth = 1.0; // mm - HeeksObj *pSketch = *l_itSketch; - if (pSketch != NULL) - { - CBox bounding_box; - pSketch->GetBox( bounding_box ); - - if (l_itSketch == sketches.begin()) - { - // This is the first cab off the rank. - - m_depth_op_params.m_start_depth = bounding_box.MaxZ(); - m_depth_op_params.m_final_depth = m_depth_op_params.m_start_depth - default_depth; - } // End if - then - else - { - // We've seen some before. If this one is higher up then use - // that instead. - - if (m_depth_op_params.m_start_depth < bounding_box.MaxZ()) - { - m_depth_op_params.m_start_depth = bounding_box.MaxZ(); - } // End if - then - - if (m_depth_op_params.m_final_depth > bounding_box.MinZ()) - { - m_depth_op_params.m_final_depth = bounding_box.MinZ() - default_depth; - } // End if - then - } // End if - else - } // End if - then - } // End for - - // If we've chosen a chamfering bit, calculate the depth required to give a 1 mm wide - // chamfer. It's as good as any width to start with. If it's not a chamfering bit - // then we can't even guess as to what the operator wants. - - const double default_chamfer_width = 1.0; // mm - if (m_tool_number > 0) - { - CTool *pTool = CTool::Find( m_tool_number ); - if (pTool != NULL) - { - if ((pTool->m_params.m_type == CToolParams::eChamfer) && - (pTool->m_params.m_cutting_edge_angle > 0)) - { - m_depth_op_params.m_final_depth = m_depth_op_params.m_start_depth - (default_chamfer_width * tan( degrees_to_radians( 90.0 - pTool->m_params.m_cutting_edge_angle ) )); - } // End if - then - } // End if - then - } // End if - then -} - Python CDepthOp::AppendTextToProgram() { Python python; python << CSpeedOp::AppendTextToProgram(); - python << _T("clearance = float(") << m_depth_op_params.m_clearance_height / theApp.m_program->m_units << _T(")\n"); - python << _T("rapid_safety_space = float(") << m_depth_op_params.m_rapid_safety_space / theApp.m_program->m_units << _T(")\n"); - python << _T("start_depth = float(") << m_depth_op_params.m_start_depth / theApp.m_program->m_units << _T(")\n"); - python << _T("step_down = float(") << m_depth_op_params.m_step_down / theApp.m_program->m_units << _T(")\n"); - python << _T("z_finish_depth = float(") << m_depth_op_params.m_z_finish_depth / theApp.m_program->m_units << _T(")\n"); - python << _T("z_thru_depth = float(") << m_depth_op_params.m_z_thru_depth / theApp.m_program->m_units << _T(")\n"); - if(m_depth_op_params.m_user_depths.Len() == 0) python << _T("user_depths = None\n"); - else python << _T("user_depths = [") << m_depth_op_params.m_user_depths << _T("]\n"); - python << _T("final_depth = float(") << m_depth_op_params.m_final_depth / theApp.m_program->m_units << _T(")\n"); + python << _T("depth_params = depth_params("); + python << _T("float(") << m_depth_op_params.m_clearance_height / theApp.m_program->m_units << _T(")"); + python << _T(", float(") << m_depth_op_params.m_rapid_safety_space / theApp.m_program->m_units << _T(")"); + python << _T(", float(") << m_depth_op_params.m_start_depth / theApp.m_program->m_units << _T(")"); + python << _T(", float(") << m_depth_op_params.m_step_down / theApp.m_program->m_units << _T(")"); + python << _T(", float(") << m_depth_op_params.m_z_finish_depth / theApp.m_program->m_units << _T(")"); + python << _T(", float(") << m_depth_op_params.m_z_thru_depth / theApp.m_program->m_units << _T(")"); + python << _T(", float(") << m_depth_op_params.m_final_depth / theApp.m_program->m_units << _T(")"); + if(m_depth_op_params.m_user_depths.Len() == 0) python << _T(", None"); + else python << _T(", [") << m_depth_op_params.m_user_depths << _T("]"); + python << _T(")\n"); CTool *pTool = CTool::Find( m_tool_number ); if (pTool != NULL) diff --git a/src/DepthOp.h b/src/DepthOp.h index c17fd718..38c3deec 100644 --- a/src/DepthOp.h +++ b/src/DepthOp.h @@ -18,13 +18,13 @@ class CDepthOp; class CDepthOpParams{ public: double m_clearance_height; + double m_rapid_safety_space; double m_start_depth; double m_step_down; double m_z_finish_depth; double m_z_thru_depth; double m_final_depth; wxString m_user_depths; - double m_rapid_safety_space; CDepthOpParams(); bool operator== ( const CDepthOpParams & rhs ) const; @@ -42,18 +42,10 @@ class CDepthOp : public CSpeedOp public: CDepthOpParams m_depth_op_params; - CDepthOp(const std::list *sketches = NULL, const int tool_number = -1, const int operation_type = UnknownType ) - : CSpeedOp(tool_number, operation_type) - { - ReadDefaultValues(); - SetDepthsFromSketchesAndTool(sketches); - } - - CDepthOp(const std::list sketches, const int tool_number = -1, const int operation_type = UnknownType ) + CDepthOp(const int tool_number = -1, const int operation_type = UnknownType ) : CSpeedOp(tool_number, operation_type) { ReadDefaultValues(); - SetDepthsFromSketchesAndTool(sketches); } CDepthOp & operator= ( const CDepthOp & rhs ); @@ -72,9 +64,6 @@ class CDepthOp : public CSpeedOp void GetTools(std::list* t_list, const wxPoint* p); void glCommands(bool select, bool marked, bool no_color); - void SetDepthsFromSketchesAndTool(const std::list *sketches); - void SetDepthsFromSketchesAndTool(const std::list sketches); - bool operator== ( const CDepthOp & rhs ) const; bool operator!= ( const CDepthOp & rhs ) const { return(! (*this == rhs)); } bool IsDifferent(HeeksObj *other) { return(*this != (*((CDepthOp *) other))); } diff --git a/src/DepthOpDlg.cpp b/src/DepthOpDlg.cpp index b0836ac9..6ab007fd 100644 --- a/src/DepthOpDlg.cpp +++ b/src/DepthOpDlg.cpp @@ -12,8 +12,8 @@ BEGIN_EVENT_TABLE(DepthOpDlg, SpeedOpDlg) END_EVENT_TABLE() -DepthOpDlg::DepthOpDlg(wxWindow *parent, CDepthOp* object, const wxString& title, bool top_level) -:SpeedOpDlg(parent, object, false, title, false) +DepthOpDlg::DepthOpDlg(wxWindow *parent, CDepthOp* object, bool drill_pictures, const wxString& title, bool top_level) +:m_drill_pictures(drill_pictures), SpeedOpDlg(parent, object, false, title, false) { leftControls.push_back(MakeLabelAndControl( _("clearance height"), m_lgthClearanceHeight = new CLengthCtrl(this))); leftControls.push_back(MakeLabelAndControl( _("rapid safety space"), m_lgthRapidDownToHeight = new CLengthCtrl(this))); @@ -58,13 +58,13 @@ void DepthOpDlg::SetFromDataRaw(HeeksObj* object) void DepthOpDlg::SetPictureByWindow(wxWindow* w) { - if(w == m_lgthClearanceHeight)DepthOpDlg::SetPicture(_T("clearance height")); - else if(w == m_lgthRapidDownToHeight)DepthOpDlg::SetPicture(_T("rapid down height")); - else if(w == m_lgthStartDepth)DepthOpDlg::SetPicture(_T("start depth")); - else if(w == m_lgthFinalDepth)DepthOpDlg::SetPicture(_T("final depth")); - else if(w == m_lgthStepDown)DepthOpDlg::SetPicture(_T("step down")); - else if(w == m_lgthZFinishDepth)DepthOpDlg::SetPicture(_T("z finish depth")); - else if(w == m_lgthZThruDepth)DepthOpDlg::SetPicture(_T("z thru depth")); + if(w == m_lgthClearanceHeight)DepthOpDlg::SetPicture(m_drill_pictures ? _T("drill clearance height") : _T("clearance height")); + else if(w == m_lgthRapidDownToHeight)DepthOpDlg::SetPicture(m_drill_pictures ? _T("drill rapid down height") : _T("rapid down height")); + else if(w == m_lgthStartDepth)DepthOpDlg::SetPicture(m_drill_pictures ? _T("drill start depth") : _T("start depth")); + else if(w == m_lgthFinalDepth)DepthOpDlg::SetPicture(m_drill_pictures ? _T("drill final depth") : _T("final depth")); + else if(w == m_lgthStepDown)DepthOpDlg::SetPicture(m_drill_pictures ? _T("drill step down") : _T("step down")); + else if(w == m_lgthZFinishDepth)DepthOpDlg::SetPicture(m_drill_pictures ? _T("drill z finish depth") : _T("z finish depth")); + else if(w == m_lgthZThruDepth)DepthOpDlg::SetPicture(m_drill_pictures ? _T("drill z thru depth") : _T("z thru depth")); else SpeedOpDlg::SetPictureByWindow(w); } diff --git a/src/DepthOpDlg.h b/src/DepthOpDlg.h index f40cef32..57f24873 100644 --- a/src/DepthOpDlg.h +++ b/src/DepthOpDlg.h @@ -20,8 +20,10 @@ class DepthOpDlg : public SpeedOpDlg CLengthCtrl *m_lgthFinalDepth; CLengthCtrl *m_lgthRapidDownToHeight; + bool m_drill_pictures; + public: - DepthOpDlg(wxWindow *parent, CDepthOp* object, const wxString& title = wxString(_T("")), bool top_level = true); + DepthOpDlg(wxWindow *parent, CDepthOp* object, bool drill_pictures = false, const wxString& title = wxString(_T("Depth Operation")), bool top_level = true); // HeeksObjDlg virtual functions void GetDataRaw(HeeksObj* object); diff --git a/src/Drilling.cpp b/src/Drilling.cpp index aa0ea136..a8110e7b 100755 --- a/src/Drilling.cpp +++ b/src/Drilling.cpp @@ -36,55 +36,18 @@ void CDrillingParams::set_initial_values( const double depth, const int tool_num { CNCConfig config; - config.Read(_T("m_standoff"), &m_standoff, (25.4 / 4)); // Quarter of an inch config.Read(_T("m_dwell"), &m_dwell, 1); - config.Read(_T("m_depth"), &m_depth, 25.4); // One inch - config.Read(_T("m_peck_depth"), &m_peck_depth, (25.4 / 10)); // One tenth of an inch config.Read(_T("m_retract_mode"), &m_retract_mode, 0); config.Read(_T("m_spindle_mode"), &m_spindle_mode, 0); - config.Read(_T("m_clearance_height"), &m_clearance_height, 25.4); // One inch - - if (depth > 0) - { - // We've found the depth we want used. Assign it now. - m_depth = depth; - } // End if - then - - // The following is taken from the 'rule of thumb' document that Stanley Dornfeld put - // together for drilling feeds and speeds. It includes a statement something like; - // "We most always peck every one half drill diameter in depth after the first peck of - // three diameters". From this, we will take his advice and set a default peck depth - // that is half the drill's diameter. - // - // NOTE: If the peck depth is zero (or less) then the operator may have manually chosen - // to not peck. In this case, don't add a positive peck depth - which would force - // a pecking cycle rather than another drilling cycle. - if ((tool_number > 0) && (m_peck_depth > 0.0)) - { - CTool *pTool = CTool::Find( tool_number ); - if (pTool != NULL) - { - m_peck_depth = pTool->m_params.m_diameter / 2.0; - } - } - } void CDrillingParams::write_values_to_config() { - // We always want to store the parameters in mm and convert them back later on. - CNCConfig config; - // These values are in mm. - config.Write(_T("m_standoff"), m_standoff); config.Write(_T("m_dwell"), m_dwell); - config.Write(_T("m_depth"), m_depth); - config.Write(_T("m_peck_depth"), m_peck_depth); config.Write(_T("m_retract_mode"), m_retract_mode); config.Write(_T("m_spindle_mode"), m_spindle_mode); - config.Write(_T("m_clearance_height"), m_clearance_height); - } @@ -100,43 +63,15 @@ static void on_set_retract_mode(int value, HeeksObj* object, bool from_undo_redo ((CDrilling*)object)->m_params.write_values_to_config(); } -static void on_set_standoff(double value, HeeksObj* object) -{ - ((CDrilling*)object)->m_params.m_standoff = value; - ((CDrilling*)object)->m_params.write_values_to_config(); -} - static void on_set_dwell(double value, HeeksObj* object) { ((CDrilling*)object)->m_params.m_dwell = value; ((CDrilling*)object)->m_params.write_values_to_config(); } -static void on_set_depth(double value, HeeksObj* object) -{ - ((CDrilling*)object)->m_params.m_depth = value; - ((CDrilling*)object)->m_params.write_values_to_config(); -} - -static void on_set_peck_depth(double value, HeeksObj* object) -{ - ((CDrilling*)object)->m_params.m_peck_depth = value; - ((CDrilling*)object)->m_params.write_values_to_config(); -} - -static void on_set_clearance_height(double value, HeeksObj* object) -{ - ((CDrilling*)object)->m_params.m_clearance_height = value; - ((CDrilling*)object)->m_params.write_values_to_config(); -} - void CDrillingParams::GetProperties(CDrilling* parent, std::list *list) { - list->push_back(new PropertyLength(_("standoff"), m_standoff, parent, on_set_standoff)); - list->push_back(new PropertyLength(_("clearance height"), m_clearance_height, parent, on_set_clearance_height)); list->push_back(new PropertyDouble(_("dwell"), m_dwell, parent, on_set_dwell)); - list->push_back(new PropertyLength(_("depth"), m_depth, parent, on_set_depth)); - list->push_back(new PropertyLength(_("peck_depth"), m_peck_depth, parent, on_set_peck_depth)); { // Begin choice scope std::list< wxString > choices; @@ -163,26 +98,16 @@ void CDrillingParams::WriteXMLAttributes(TiXmlNode *root) element = heeksCAD->NewXMLElement( "params" ); heeksCAD->LinkXMLEndChild( root, element ); - element->SetDoubleAttribute( "standoff", m_standoff); element->SetDoubleAttribute( "dwell", m_dwell); - element->SetDoubleAttribute( "depth", m_depth); - element->SetDoubleAttribute( "peck_depth", m_peck_depth); - element->SetAttribute( "retract_mode", m_retract_mode); element->SetAttribute( "spindle_mode", m_spindle_mode); - element->SetAttribute( "clearance_height", m_clearance_height); } void CDrillingParams::ReadParametersFromXMLElement(TiXmlElement* pElem) { - if (pElem->Attribute("standoff")) pElem->Attribute("standoff", &m_standoff); - m_clearance_height = m_standoff; // Default if the clearance_height parameter is not found. if (pElem->Attribute("dwell")) pElem->Attribute("dwell", &m_dwell); - if (pElem->Attribute("depth")) pElem->Attribute("depth", &m_depth); - if (pElem->Attribute("peck_depth")) pElem->Attribute("peck_depth", &m_peck_depth); if (pElem->Attribute("retract_mode")) pElem->Attribute("retract_mode", &m_retract_mode); if (pElem->Attribute("spindle_mode")) pElem->Attribute("spindle_mode", &m_spindle_mode); - if (pElem->Attribute("clearance_height")) pElem->Attribute("clearance_height", &m_clearance_height); } const wxBitmap &CDrilling::GetIcon() @@ -202,7 +127,7 @@ Python CDrilling::AppendTextToProgram() { Python python; - python << CSpeedOp::AppendTextToProgram(); // Set any private fixtures and change tools (if necessary) + python << CDepthOp::AppendTextToProgram(); // Set any private fixtures and change tools (if necessary) for (std::list::iterator It = m_points.begin(); It != m_points.end(); It++) { @@ -214,14 +139,10 @@ Python CDrilling::AppendTextToProgram() python << _T("drill(") << _T("x=") << p[0]/theApp.m_program->m_units << _T(", ") << _T("y=") << p[1]/theApp.m_program->m_units << _T(", ") - << _T("z=") << p[2]/theApp.m_program->m_units << _T(", ") - << _T("depth=") << m_params.m_depth/theApp.m_program->m_units << _T(", ") - << _T("standoff=") << m_params.m_standoff/theApp.m_program->m_units << _T(", ") << _T("dwell=") << m_params.m_dwell << _T(", ") - << _T("peck_depth=") << m_params.m_peck_depth/theApp.m_program->m_units << _T(", ") + << _T("depth_params = depth_params, ") << _T("retract_mode=") << m_params.m_retract_mode << _T(", ") - << _T("spindle_mode=") << m_params.m_spindle_mode << _T(", ") - << _T("clearance_height=") << m_params.m_clearance_height + << _T("spindle_mode=") << m_params.m_spindle_mode << _T(")\n"); theApp.m_location = make_point(p); // Remember where we are. } // End for @@ -286,7 +207,7 @@ std::list< CNCPoint > CDrilling::DrillBitVertices( const CNCPoint & origin, cons double depthPerItteration; countersinkDepth = -1 * radius * tan(31.0); // For a typical (118 degree bevel on the drill bit tip) - unsigned int l_iNumItterations = numPoints * (length / flutePitch); + unsigned int l_iNumItterations = numPoints * fabs(length / flutePitch); depthPerItteration = (length - countersinkDepth) / l_iNumItterations; // Now generate the spirals. @@ -343,7 +264,7 @@ std::list< CNCPoint > CDrilling::DrillBitVertices( const CNCPoint & origin, cons */ void CDrilling::glCommands(bool select, bool marked, bool no_color) { - CSpeedOp::glCommands(select, marked, no_color); + CDepthOp::glCommands(select, marked, no_color); if(marked && !no_color) { @@ -369,13 +290,11 @@ void CDrilling::glCommands(bool select, bool marked, bool no_color) start[0] = point.X(); start[1] = point.Y(); - start[2] = point.Z(); + start[2] = m_depth_op_params.m_start_depth; end[0] = point.X(); end[1] = point.Y(); - end[2] = point.Z(); - - end[2] -= m_params.m_depth; + end[2] = m_depth_op_params.m_final_depth; glBegin(GL_LINE_STRIP); glVertex3dv( start ); @@ -384,7 +303,7 @@ void CDrilling::glCommands(bool select, bool marked, bool no_color) std::list< CNCPoint > pointsAroundCircle = DrillBitVertices( point, l_dHoleDiameter / 2, - m_params.m_depth); + m_depth_op_params.m_final_depth); glBegin(GL_LINE_STRIP); CNCPoint previous = *(pointsAroundCircle.begin()); @@ -404,7 +323,7 @@ void CDrilling::glCommands(bool select, bool marked, bool no_color) void CDrilling::GetProperties(std::list *list) { m_params.GetProperties(this, list); - CSpeedOp::GetProperties(list); + CDepthOp::GetProperties(list); } HeeksObj *CDrilling::MakeACopy(void)const @@ -423,13 +342,13 @@ void CDrilling::CopyFrom(const HeeksObj* object) CDrilling::CDrilling( const std::list &points, const int tool_number, const double depth ) - : CSpeedOp(tool_number, DrillingType), m_points(points) + : CDepthOp(tool_number, DrillingType), m_points(points) { m_params.set_initial_values(depth, tool_number); } -CDrilling::CDrilling( const CDrilling & rhs ) : CSpeedOp( rhs ) +CDrilling::CDrilling( const CDrilling & rhs ) : CDepthOp( rhs ) { m_points = rhs.m_points; m_params = rhs.m_params; @@ -439,7 +358,7 @@ CDrilling & CDrilling::operator= ( const CDrilling & rhs ) { if (this != &rhs) { - CSpeedOp::operator=(rhs); + CDepthOp::operator=(rhs); m_points.clear(); m_points = rhs.m_points; m_params = rhs.m_params; @@ -470,10 +389,6 @@ void CDrilling::WriteXML(TiXmlNode *root) heeksCAD->LinkXMLEndChild( root, element ); m_params.WriteXMLAttributes(element); - //TiXmlElement * symbols; - //symbols = heeksCAD->NewXMLElement( "symbols" ); - //heeksCAD->LinkXMLEndChild( element, symbols ); - for (std::list::iterator It = m_points.begin(); It != m_points.end(); It++) { TiXmlElement * point = heeksCAD->NewXMLElement( "Point" ); @@ -532,18 +447,14 @@ HeeksObj* CDrilling::ReadFromXMLElement(TiXmlElement* element) void CDrilling::GetTools(std::list* t_list, const wxPoint* p) { - CSpeedOp::GetTools( t_list, p ); + CDepthOp::GetTools( t_list, p ); } bool CDrillingParams::operator==( const CDrillingParams & rhs) const { - if (m_standoff != rhs.m_standoff) return(false); if (m_dwell != rhs.m_dwell) return(false); - if (m_depth != rhs.m_depth) return(false); - if (m_peck_depth != rhs.m_peck_depth) return(false); if (m_retract_mode != rhs.m_retract_mode) return(false); if (m_spindle_mode != rhs.m_spindle_mode) return(false); - if (m_clearance_height != rhs.m_clearance_height) return(false); return(true); } @@ -553,76 +464,15 @@ bool CDrilling::operator==( const CDrilling & rhs ) const { if (m_params != rhs.m_params) return(false); - return(CSpeedOp::operator==(rhs)); + return(CDepthOp::operator==(rhs)); } -static bool OnEdit(HeeksObj* object, std::list *others) +static bool OnEdit(HeeksObj* object) { - int type = 3; // 3 for drilling, 2, for speedop, 1 for op, 0 for other - - if(others) - { - for(std::list::iterator It = others->begin(); It != others->end(); It++) - { - HeeksObj* obj = *It; - switch(obj->GetType()) - { - case DrillingType: - break; - case ProfileType: - case PocketType: - if(type > 2)type = 2; - break; - case ScriptOpType: - if(type>1)type = 1; - break; - default: - type = 0; - break; - } - } - } - - int res = 0; - - HeeksObjDlg* dlg = NULL; - - switch(type) - { - case 3: - dlg = new DrillingDlg(heeksCAD->GetMainFrame(), (CDrilling*)object); - break; - case 2: - dlg = new SpeedOpDlg(heeksCAD->GetMainFrame(), (CDrilling*)object, false); - break; - case 1: - //dlg = new OpDlg(heeksCAD->GetMainFrame(), (CDrilling*)object); - break; - default: - break; - } - - if(dlg) - { - if(dlg->ShowModal() == wxID_OK) - { - dlg->GetData(object); - object->WriteDefaultValues(); - if(others) - { - for(std::list::iterator It = others->begin(); It != others->end(); It++) - { - HeeksObj* obj = *It; - dlg->GetData(obj); - } - } - return true; - } - } - return false; + return DrillingDlg::Do((CDrilling*)object); } -void CDrilling::GetOnEdit(bool(**callback)(HeeksObj*, std::list *)) +void CDrilling::GetOnEdit(bool(**callback)(HeeksObj*)) { *callback = OnEdit; } diff --git a/src/Drilling.h b/src/Drilling.h index 4de57842..e3c3fb44 100755 --- a/src/Drilling.h +++ b/src/Drilling.h @@ -9,7 +9,7 @@ * details. */ -#include "SpeedOp.h" +#include "DepthOp.h" #include "HeeksCNCTypes.h" #include #include @@ -20,13 +20,9 @@ class CDrilling; class CDrillingParams{ public: - double m_standoff; // This is the height above the staring Z position that forms the Z retract height (R word) double m_dwell; // If dwell_bottom is non-zero then we're using the G82 drill cycle rather than G83 peck drill cycle. This is the 'P' word - double m_depth; // Incremental length down from 'z' value at which the bottom of the hole can be found - double m_peck_depth; // This is the 'Q' word in the G83 cycle. How deep to peck each time. int m_retract_mode; // boring - 0 - rapid retract, 1 - feed retract int m_spindle_mode; // boring - if true, stop spindle at bottom - double m_clearance_height; // The tool moves to this height between drill locations and then rapidly moves down to the m_standoff height. void set_initial_values( const double depth, const int tool_number ); void write_values_to_config(); @@ -38,7 +34,7 @@ class CDrillingParams{ bool operator!= ( const CDrillingParams & rhs ) const { return(! (*this == rhs)); } }; -class CDrilling: public CSpeedOp { +class CDrilling: public CDepthOp { public: /** The following two methods are just to draw pretty lines on the screen to represent drilling @@ -52,7 +48,7 @@ class CDrilling: public CSpeedOp { CDrillingParams m_params; // Constructors. - CDrilling():CSpeedOp(0){} + CDrilling():CDepthOp(0){} CDrilling( const std::list &points, const int tool_number, const double depth ); @@ -73,7 +69,7 @@ class CDrilling: public CSpeedOp { bool CanAddTo(HeeksObj* owner); bool CanAdd(HeeksObj* object); void GetTools(std::list* t_list, const wxPoint* p); - void GetOnEdit(bool(**callback)(HeeksObj*, std::list *)); + void GetOnEdit(bool(**callback)(HeeksObj*)); // This is the method that gets called when the operator hits the 'Python' button. It generates a Python // program whose job is to generate RS-274 GCode. diff --git a/src/DrillingDlg.cpp b/src/DrillingDlg.cpp index f2ba6ffc..f9975d33 100644 --- a/src/DrillingDlg.cpp +++ b/src/DrillingDlg.cpp @@ -12,27 +12,27 @@ enum { ID_FEED_RETRACT = 100, + ID_POINTS_PICK, ID_STOP_SPINDLE, }; -BEGIN_EVENT_TABLE(DrillingDlg, SpeedOpDlg) +BEGIN_EVENT_TABLE(DrillingDlg, DepthOpDlg) EVT_CHECKBOX(ID_FEED_RETRACT, HeeksObjDlg::OnComboOrCheck) + EVT_BUTTON(ID_POINTS_PICK, DrillingDlg::OnPointsPick) EVT_CHECKBOX(ID_STOP_SPINDLE, HeeksObjDlg::OnComboOrCheck) END_EVENT_TABLE() DrillingDlg::DrillingDlg(wxWindow *parent, CDrilling* object, const wxString& title, bool top_level) -: SpeedOpDlg(parent, object, true, title, false) +: DepthOpDlg(parent, object, true, title, false) { std::list save_leftControls = leftControls; leftControls.clear(); // add all the controls to the left side - leftControls.push_back(MakeLabelAndControl(_("points"), m_idsPoints = new CObjectIdsCtrl(this))); - leftControls.push_back(MakeLabelAndControl(_("stand off"), m_lgthStandOff = new CLengthCtrl(this))); + leftControls.push_back(MakeLabelAndControl(_("points"), m_idsPoints = new CObjectIdsCtrl(this), m_btnPointsPick = new wxButton(this, ID_POINTS_PICK, _("Pick")))); leftControls.push_back(MakeLabelAndControl(_("dwell"), m_dblDwell = new CDoubleCtrl(this))); leftControls.push_back( HControl( m_chkFeedRetract = new wxCheckBox( this, ID_FEED_RETRACT, _("feed retract") ), wxALL )); leftControls.push_back( HControl( m_chkStopSpindleAtBottom = new wxCheckBox( this, ID_STOP_SPINDLE, _("stop spindle at bottom") ), wxALL )); - leftControls.push_back(MakeLabelAndControl(_("clearance height"), m_lgthClearanceHeight = new CLengthCtrl(this))); for(std::list::iterator It = save_leftControls.begin(); It != save_leftControls.end(); It++) { @@ -50,31 +50,27 @@ void DrillingDlg::GetDataRaw(HeeksObj* object) { ((CDrilling*)object)->m_points.clear(); m_idsPoints->GetIDList(((CDrilling*)object)->m_points); - ((CDrilling*)object)->m_params.m_standoff = m_lgthStandOff->GetValue(); + ((CDrilling*)object)->m_params.m_dwell = m_dblDwell->GetValue(); ((CDrilling*)object)->m_params.m_retract_mode = m_chkFeedRetract->GetValue(); ((CDrilling*)object)->m_params.m_spindle_mode = m_chkStopSpindleAtBottom->GetValue(); - ((CDrilling*)object)->m_params.m_clearance_height = m_lgthClearanceHeight->GetValue(); - SpeedOpDlg::GetDataRaw(object); + DepthOpDlg::GetDataRaw(object); } void DrillingDlg::SetFromDataRaw(HeeksObj* object) { m_idsPoints->SetFromIDList(((CDrilling*)object)->m_points); - m_lgthStandOff->SetValue(((CDrilling*)object)->m_params.m_standoff); m_dblDwell->SetValue(((CDrilling*)object)->m_params.m_dwell); m_chkFeedRetract->SetValue(((CDrilling*)object)->m_params.m_retract_mode != 0); m_chkStopSpindleAtBottom->SetValue(((CDrilling*)object)->m_params.m_spindle_mode != 0); - m_lgthClearanceHeight->SetValue(((CDrilling*)object)->m_params.m_clearance_height); - SpeedOpDlg::SetFromDataRaw(object); + DepthOpDlg::SetFromDataRaw(object); } void DrillingDlg::SetPictureByWindow(wxWindow* w) { - if(w == m_lgthStandOff)SetPicture(_T("stand off")); - else if(w == m_dblDwell)SetPicture(_T("dwell")); + if(w == m_dblDwell)SetPicture(_T("dwell")); else if(w == m_chkFeedRetract) { if(m_chkFeedRetract->GetValue())SetPicture(_T("feed retract")); @@ -85,8 +81,7 @@ void DrillingDlg::SetPictureByWindow(wxWindow* w) if(m_chkStopSpindleAtBottom->GetValue())SetPicture(_T("stop spindle at bottom")); else SetPicture(_T("dont stop spindle")); } - else if(w == m_lgthClearanceHeight)SetPicture(_T("clearance height")); - else SpeedOpDlg::SetPictureByWindow(w); + else DepthOpDlg::SetPictureByWindow(w); } @@ -94,3 +89,48 @@ void DrillingDlg::SetPicture(const wxString& name) { HeeksObjDlg::SetPicture(name, _T("drilling")); } + +void DrillingDlg::OnPointsPick( wxCommandEvent& event ) +{ + EndModal(ID_POINTS_PICK); +} + +bool DrillingDlg::Do(CDrilling* object) +{ + DrillingDlg dlg(heeksCAD->GetMainFrame(), object); + + while(1) + { + int result = dlg.ShowModal(); + + if(result == wxID_OK) + { + dlg.GetData(object); + return true; + } + else if(result == ID_POINTS_PICK) + { + heeksCAD->ClearMarkedList(); + heeksCAD->PickObjects(_("Pick points to drill"), MARKING_FILTER_POINT, false); + + std::list ids; + const std::list &list = heeksCAD->GetMarkedList(); + if(list.size() > 0) + { + for(std::list::const_iterator It = list.begin(); It != list.end(); It++) + { + HeeksObj* object = *It; + ids.push_back(object->GetID()); + } + } + + dlg.m_idsPoints->SetFromIDList(ids); + + dlg.Fit(); + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/DrillingDlg.h b/src/DrillingDlg.h index acda20b5..ad132223 100644 --- a/src/DrillingDlg.h +++ b/src/DrillingDlg.h @@ -8,26 +8,28 @@ class CLengthCtrl; class CDoubleCtrl; class CObjectIdsCtrl; -#include "SpeedOpDlg.h" +#include "DepthOpDlg.h" -class DrillingDlg : public SpeedOpDlg +class DrillingDlg : public DepthOpDlg { CObjectIdsCtrl *m_idsPoints; - CLengthCtrl *m_lgthStandOff; CDoubleCtrl *m_dblDwell; wxCheckBox *m_chkFeedRetract; wxCheckBox *m_chkStopSpindleAtBottom; - CLengthCtrl *m_lgthClearanceHeight; + wxButton *m_btnPointsPick; public: DrillingDlg(wxWindow *parent, CDrilling* object, const wxString& title = wxString(_T("Drilling Operation")), bool top_level = true); - // SpeedOpDlg's virtual functions + static bool Do(CDrilling* object); + + // HeeksObjDlg's virtual functions void GetDataRaw(HeeksObj* object); void SetFromDataRaw(HeeksObj* object); void SetPictureByWindow(wxWindow* w); void SetPicture(const wxString& name); + void OnPointsPick( wxCommandEvent& event ); DECLARE_EVENT_TABLE() }; diff --git a/src/Excellon.cpp b/src/Excellon.cpp index 5809ddd0..a5def05e 100644 --- a/src/Excellon.cpp +++ b/src/Excellon.cpp @@ -179,9 +179,9 @@ bool Excellon::Read( const char *p_szFileName, const bool force_mirror /* = fals CDrilling *new_object = new CDrilling( m_holes[ *l_itToolNumber ], *l_itToolNumber, depth ); new_object->m_speed_op_params.m_spindle_speed = m_spindle_speed; new_object->m_speed_op_params.m_vertical_feed_rate = m_feed_rate; - new_object->m_params.m_peck_depth = 0.0; // Don't peck for a Printed Circuit Board. + new_object->m_depth_op_params.m_step_down = 0.0; // Don't peck for a Printed Circuit Board. new_object->m_params.m_dwell = 0.0; // Don't wait around to clear stringers either. - new_object->m_params.m_standoff = 2.0; // Printed Circuit Boards a quite flat + new_object->m_depth_op_params.m_rapid_safety_space = 2.0; // Printed Circuit Boards a quite flat theApp.m_program->Operations()->Add(new_object,NULL); } // End for diff --git a/src/HeeksCNC VC2008.vcproj b/src/HeeksCNC VC2008.vcproj index c9a64047..00f1cdd3 100644 --- a/src/HeeksCNC VC2008.vcproj +++ b/src/HeeksCNC VC2008.vcproj @@ -926,6 +926,62 @@ RelativePath=".\Tags.h" > + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/HeeksCNC.cpp b/src/HeeksCNC.cpp index 0526962c..b3e9ffb9 100644 --- a/src/HeeksCNC.cpp +++ b/src/HeeksCNC.cpp @@ -125,13 +125,29 @@ static void OnOutputCanvas( wxCommandEvent& event ) } } +static void OnPrintCanvas( wxCommandEvent& event ) +{ + wxAuiManager* aui_manager = heeksCAD->GetAuiManager(); + wxAuiPaneInfo& pane_info = aui_manager->GetPane(theApp.m_print_canvas); + if(pane_info.IsOk()){ + pane_info.Show(event.IsChecked()); + aui_manager->Update(); + } +} + static void OnUpdateOutputCanvas( wxUpdateUIEvent& event ) { wxAuiManager* aui_manager = heeksCAD->GetAuiManager(); event.Check(aui_manager->GetPane(theApp.m_output_canvas).IsShown()); } -static bool GetSketches(std::list& sketches, std::list &tools ) +static void OnUpdatePrintCanvas( wxUpdateUIEvent& event ) +{ + wxAuiManager* aui_manager = heeksCAD->GetAuiManager(); + event.Check(aui_manager->GetPane(theApp.m_print_canvas).IsShown()); +} + +static void GetSketches(std::list& sketches, std::list &tools ) { // check for at least one sketch selected @@ -149,14 +165,6 @@ static bool GetSketches(std::list& sketches, std::list &tools ) tools.push_back( object->m_id ); } // End if - then } - - if(sketches.size() == 0) - { - wxMessageBox(_("You must select some sketches, first!")); - return false; - } - - return true; } static void NewProfileOpMenuCallback(wxCommandEvent &event) @@ -182,18 +190,17 @@ static void NewPocketOpMenuCallback(wxCommandEvent &event) { std::list tools; std::list sketches; - if(GetSketches(sketches, tools)) + GetSketches(sketches, tools); + + CPocket *new_object = new CPocket(sketches, (tools.size()>0)?(*tools.begin()):-1 ); + if(new_object->Edit()) { - CPocket *new_object = new CPocket(sketches, (tools.size()>0)?(*tools.begin()):-1 ); - if(new_object->Edit()) - { - heeksCAD->StartHistory(); - heeksCAD->AddUndoably(new_object, theApp.m_program->Operations()); - heeksCAD->EndHistory(); - } - else - delete new_object; + heeksCAD->StartHistory(); + heeksCAD->AddUndoably(new_object, theApp.m_program->Operations()); + heeksCAD->EndHistory(); } + else + delete new_object; } static void AddNewObjectUndoablyAndMarkIt(HeeksObj* new_object, HeeksObj* parent) @@ -530,7 +537,9 @@ static void AddToolBars() heeksCAD->AddFlyoutButton(_("Run Python Script"), ToolImage(_T("runpython")), _("Run Python Script"), RunScriptMenuCallback); heeksCAD->AddFlyoutButton(_("OpenNC"), ToolImage(_T("opennc")), _("Open NC File"), OpenNcFileMenuCallback); heeksCAD->AddFlyoutButton(_("SaveNC"), ToolImage(_T("savenc")), _("Save NC File"), SaveNcFileMenuCallback); +#ifndef WIN32 heeksCAD->AddFlyoutButton(_("Send to Machine"), ToolImage(_T("tomachine")), _("Send to Machine"), SendToMachineMenuCallback); +#endif heeksCAD->AddFlyoutButton(_("Cancel"), ToolImage(_T("cancel")), _("Cancel Python Script"), CancelMenuCallback); #ifdef WIN32 heeksCAD->AddFlyoutButton(_("Simulate"), ToolImage(_T("simulate")), _("Simulate"), SimulateCallback); @@ -590,6 +599,109 @@ static void UnitsChangedHandler( const double units ) } } +class SketchBox{ +public: + CBox m_box; + gp_Vec m_latest_shift; + + SketchBox(const CBox &box); + + SketchBox(const SketchBox &s) + { + m_box = s.m_box; + m_latest_shift = s.m_latest_shift; + } + + void UpdateBoxAndSetShift(const CBox &new_box) + { + // use Centre + double old_centre[3], new_centre[3]; + m_box.Centre(old_centre); + new_box.Centre(new_centre); + m_latest_shift = gp_Vec(new_centre[0] - old_centre[0], new_centre[1] - old_centre[1], 0.0); + m_box = new_box; + } +}; +SketchBox::SketchBox(const CBox &box) + { + m_box = box; + m_latest_shift = gp_Vec(0, 0, 0); + } + +class HeeksCADObserver: public Observer +{ +public: + std::map m_box_map; + + void OnChanged(const std::list* added, const std::list* removed, const std::list* modified) + { + if(added) + { + for(std::list::const_iterator It = added->begin(); It != added->end(); It++) + { + HeeksObj* object = *It; + if(object->GetType() == SketchType) + { + CBox box; + object->GetBox(box); + m_box_map.insert(std::make_pair(object->GetID(), SketchBox(box))); + } + } + } + + if(modified) + { + for(std::list::const_iterator It = modified->begin(); It != modified->end(); It++) + { + HeeksObj* object = *It; + if(object->GetType() == SketchType) + { + CBox new_box; + object->GetBox(new_box); + std::map::iterator FindIt = m_box_map.find(object->GetID()); + if(FindIt != m_box_map.end()) + { + SketchBox &sketch_box = FindIt->second; + sketch_box.UpdateBoxAndSetShift(new_box); + } + } + } + + // check all the profile operations, so we can move the tags + for(HeeksObj* object = theApp.m_program->Operations()->GetFirstChild(); object; object = theApp.m_program->Operations()->GetNextChild()) + { + if(object->GetType() == ProfileType) + { + if(((CProfile*)object)->m_sketches.size() > 0) + { + int sketch = ((CProfile*)object)->m_sketches.front(); + std::map::iterator FindIt = m_box_map.find(object->GetID()); + if(FindIt != m_box_map.end()) + { + SketchBox &sketch_box = FindIt->second; + for(HeeksObj* tag = ((CProfile*)object)->Tags()->GetFirstChild(); tag; tag = ((CProfile*)object)->Tags()->GetNextChild()) + { + ((CTag*)tag)->m_pos[0] += sketch_box.m_latest_shift.X(); + ((CTag*)tag)->m_pos[1] += sketch_box.m_latest_shift.Y(); + } + } + } + } + } + + for(std::map::iterator It = m_box_map.begin(); It != m_box_map.end(); It++) + { + SketchBox &sketch_box = It->second; + sketch_box.m_latest_shift = gp_Vec(0, 0, 0); + } + } + } + + void Clear() + { + m_box_map.clear(); + } +}heekscad_observer; void CHeeksCNCApp::OnStartUp(CHeeksCADInterface* h, const wxString& dll_path) { @@ -599,6 +711,9 @@ void CHeeksCNCApp::OnStartUp(CHeeksCADInterface* h, const wxString& dll_path) wxInitialize(); #endif + // to do, use os_id + wxOperatingSystemId os_id = wxGetOsVersion(); + CNCConfig config; // About box, stuff @@ -655,7 +770,9 @@ void CHeeksCNCApp::OnStartUp(CHeeksCADInterface* h, const wxString& dll_path) #endif heeksCAD->AddMenuItem(menuMachining, _("Open NC File"), ToolImage(_T("opennc")), OpenNcFileMenuCallback); heeksCAD->AddMenuItem(menuMachining, _("Save NC File"), ToolImage(_T("savenc")), SaveNcFileMenuCallback); +#ifndef WIN32 heeksCAD->AddMenuItem(menuMachining, _("Send to Machine"), ToolImage(_T("tomachine")), SendToMachineMenuCallback); +#endif frame->GetMenuBar()->Append(menuMachining, _("Machining")); // add the program canvas @@ -666,11 +783,17 @@ void CHeeksCNCApp::OnStartUp(CHeeksCADInterface* h, const wxString& dll_path) m_output_canvas = new COutputCanvas(frame); aui_manager->AddPane(m_output_canvas, wxAuiPaneInfo().Name(_T("Output")).Caption(_T("Output")).Bottom().BestSize(wxSize(600, 200))); + // add the print canvas + m_print_canvas = new CPrintCanvas(frame); + aui_manager->AddPane(m_print_canvas, wxAuiPaneInfo().Name(_T("Print")).Caption(_T("Print")).Bottom().BestSize(wxSize(600, 200))); + bool program_visible; bool output_visible; + bool print_visible; config.Read(_T("ProgramVisible"), &program_visible); config.Read(_T("OutputVisible"), &output_visible); + config.Read(_T("PrintVisible"), &print_visible); // read other settings CNCCode::ReadColorsFromConfig(); @@ -682,14 +805,17 @@ void CHeeksCNCApp::OnStartUp(CHeeksCADInterface* h, const wxString& dll_path) config.Read(_T("UseDOSNotUnix"), &m_use_DOS_not_Unix, false); aui_manager->GetPane(m_program_canvas).Show(program_visible); aui_manager->GetPane(m_output_canvas).Show(output_visible); + aui_manager->GetPane(m_print_canvas).Show(print_visible); // add tick boxes for them all on the view menu wxMenu* window_menu = heeksCAD->GetWindowMenu(); heeksCAD->AddMenuItem(window_menu, _T("Program"), wxBitmap(), OnProgramCanvas, OnUpdateProgramCanvas, NULL, true); heeksCAD->AddMenuItem(window_menu, _T("Output"), wxBitmap(), OnOutputCanvas, OnUpdateOutputCanvas, NULL, true); + heeksCAD->AddMenuItem(window_menu, _T("Print"), wxBitmap(), OnPrintCanvas, OnUpdatePrintCanvas, NULL, true); heeksCAD->AddMenuItem(window_menu, _T("Machining"), wxBitmap(), OnMachiningBar, OnUpdateMachiningBar, NULL, true); heeksCAD->RegisterHideableWindow(m_program_canvas); heeksCAD->RegisterHideableWindow(m_output_canvas); + heeksCAD->RegisterHideableWindow(m_print_canvas); heeksCAD->RegisterHideableWindow(m_machiningBar); // add object reading functions @@ -742,6 +868,8 @@ void CHeeksCNCApp::OnStartUp(CHeeksCADInterface* h, const wxString& dll_path) } } + heeksCAD->RegisterObserver(&heekscad_observer); + heeksCAD->RegisterUnitsChangeHandler( UnitsChangedHandler ); heeksCAD->RegisterHeeksTypesConverter( HeeksCNCType ); } @@ -819,6 +947,7 @@ void CHeeksCNCApp::OnNewOrOpen(bool open, int res) heeksCAD->GetMainObject()->Add(m_program, NULL); theApp.m_program_canvas->Clear(); theApp.m_output_canvas->Clear(); + theApp.m_print_canvas->Clear(); std::list directories; wxString directory_separator; @@ -916,6 +1045,7 @@ void CHeeksCNCApp::OnFrameDelete() CNCConfig config; config.Write(_T("ProgramVisible"), aui_manager->GetPane(m_program_canvas).IsShown()); config.Write(_T("OutputVisible"), aui_manager->GetPane(m_output_canvas).IsShown()); + config.Write(_T("PrintVisible"), aui_manager->GetPane(m_print_canvas).IsShown()); config.Write(_T("MachiningBarVisible"), aui_manager->GetPane(m_machiningBar).IsShown()); CNCCode::WriteColorsToConfig(); diff --git a/src/HeeksCNC.h b/src/HeeksCNC.h index 876e1c48..3bc06d49 100644 --- a/src/HeeksCNC.h +++ b/src/HeeksCNC.h @@ -18,6 +18,7 @@ class Property; class CProgram; class CProgramCanvas; class COutputCanvas; +class CPrintCanvas; class Tool; class CSurface; @@ -27,6 +28,7 @@ class CHeeksCNCApp{ CProgram* m_program; CProgramCanvas* m_program_canvas; COutputCanvas* m_output_canvas; + CPrintCanvas* m_print_canvas; bool m_run_program_on_new_line; wxToolBarBase* m_machiningBar; wxMenu *m_menuMachining; diff --git a/src/MachineState.cpp b/src/MachineState.cpp deleted file mode 100644 index 80f29edf..00000000 --- a/src/MachineState.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// MachineState.cpp -/* - * Copyright (c) 2009, Dan Heeks - * This program is released under the BSD license. See the file COPYING for - * details. - */ - -#include -#include "MachineState.h" -#include "CTool.h" -#include "CNCPoint.h" -#include "Program.h" - -#ifdef HEEKSCNC -#define PROGRAM theApp.m_program -#else -#define PROGRAM heeksCNC->GetProgram() -#endif - -CMachineState::CMachineState() -{ - m_location = CNCPoint(0.0, 0.0, 0.0); - m_tool_number = 0; // No tool assigned. - m_attached_to_surface = NULL; -} - -CMachineState::~CMachineState() { } - -CMachineState::CMachineState(const CMachineState & rhs) -{ - *this = rhs; // Call the assignment operator -} - -CMachineState & CMachineState::operator= ( const CMachineState & rhs ) -{ - if (this != &rhs) - { - m_location = rhs.Location(); - m_tool_number = rhs.Tool(); - m_attached_to_surface = rhs.m_attached_to_surface; - } - - return(*this); -} - -bool CMachineState::operator== ( const CMachineState & rhs ) const -{ - if (m_tool_number != rhs.m_tool_number) return(false); - if(m_attached_to_surface != rhs.m_attached_to_surface) return false; - - // Don't include the location in the state check. Moving around the machine is nothing to reset ourselves - // over. - - // Don't worry about m_fixture_has_been_set - - return(true); -} - -/** - The machine's tool has changed. Issue the appropriate GCode if necessary. - */ -Python CMachineState::Tool( const int new_tool ) -{ - Python python; - - if (m_tool_number != new_tool) - { - m_tool_number = new_tool; - - // Select the right tool. - CTool *pTool = (CTool *) CTool::Find(new_tool); - if (pTool != NULL) - { - python << _T("comment(") << PythonString(_T("tool change to ") + pTool->GetMeaningfulName(PROGRAM->m_units)) << _T(")\n"); - python << _T("tool_change( id=") << new_tool << _T(")\n"); - if(m_attached_to_surface) - { - python << _T("nc.nc.creator.set_ocl_cutter(") << pTool->OCLDefinition(m_attached_to_surface) << _T(")\n"); - } - } // End if - then - } - - return(python); -} - diff --git a/src/MachineState.h b/src/MachineState.h deleted file mode 100644 index e6cb16fd..00000000 --- a/src/MachineState.h +++ /dev/null @@ -1,65 +0,0 @@ -// MachineState.h -/* - * Copyright (c) 2009, Dan Heeks - * This program is released under the BSD license. See the file COPYING for - * details. - */ - -#pragma once - -#include "PythonStuff.h" -#include "CNCPoint.h" - -#include - -class Python; -class CNCPoint; -class CSurface; - -/** - The CMachineState class stores information about the machine for use - in the GCode generation routines. An object of this class will be passed - both into and back out of each gcode generation routine so that - subsequent routines can know whether tool changes or fixture changes - are either necessary or have occured. - - Location values returned also allow subsequent gcode generation routines - to sort their objects so that starting points can be selected based on - previous operation's ending points. - - This class also keeps track of which objects have had their gcode generated - for which fixtures. We need to know this so that we don't double-up while - we are handling the various private and public fixture settings. - */ -class CMachineState -{ -private: - /** - This class remembers an individual machine operation along with - the fixture used for gcode generation. It's really just a placeholder - for a tuple of three values so we can keep track of what we've already - processed. - */ -public: - CSurface* m_attached_to_surface; - - CMachineState(); - ~CMachineState(); - - CMachineState(const CMachineState & rhs); - CMachineState & operator= ( const CMachineState & rhs ); - - int Tool() const { return(m_tool_number); } - Python Tool( const int new_tool ); - - CNCPoint Location() const { return(m_location); } - void Location( const CNCPoint rhs ) { m_location = rhs; } - - bool operator== ( const CMachineState & rhs ) const; - bool operator!= ( const CMachineState & rhs ) const { return(! (*this == rhs)); } - -private: - int m_tool_number; - CNCPoint m_location; - -}; // End CMachineState class definition diff --git a/src/OutputCanvas.cpp b/src/OutputCanvas.cpp index fc7c0079..9e922c8b 100644 --- a/src/OutputCanvas.cpp +++ b/src/OutputCanvas.cpp @@ -100,3 +100,43 @@ void COutputCanvas::Clear() m_textCtrl->Clear(); } + +BEGIN_EVENT_TABLE(CPrintCanvas, wxScrolledWindow) + EVT_SIZE(CPrintCanvas::OnSize) +END_EVENT_TABLE() + + +CPrintCanvas::CPrintCanvas(wxWindow* parent) + : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, + wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE) +{ + m_textCtrl = new wxTextCtrl( this, 100, _T(""), wxPoint(180,170), wxSize(200,70), wxTE_MULTILINE | wxTE_DONTWRAP | wxTE_RICH | wxTE_RICH2); + + // Ensure the wxTextCtrl object can accept the maximum + // text length allowable for this operating system. + // (64kb on Win32) (32kb without this call on Win32) + m_textCtrl->SetMaxLength( 0 ); + Resize(); +} + + +void CPrintCanvas::OnSize(wxSizeEvent& event) +{ + Resize(); + + event.Skip(); +} + + + +void CPrintCanvas::Resize() +{ + wxSize size = GetClientSize(); + m_textCtrl->SetSize(0, 0, size.x, size.y); +} + +void CPrintCanvas::Clear() +{ + m_textCtrl->Clear(); +} + diff --git a/src/OutputCanvas.h b/src/OutputCanvas.h index b07882bf..ba74f859 100644 --- a/src/OutputCanvas.h +++ b/src/OutputCanvas.h @@ -39,3 +39,24 @@ class COutputCanvas: public wxScrolledWindow DECLARE_EVENT_TABLE() }; + +class CPrintCanvas: public wxScrolledWindow +{ +private: + void Resize(); + +public: + wxTextCtrl *m_textCtrl; + + CPrintCanvas(wxWindow* parent); + virtual ~CPrintCanvas(){} + + void Clear(); + + void OnSize(wxSizeEvent& event); + void OnLengthExceeded(wxCommandEvent& event); + + DECLARE_NO_COPY_CLASS(CPrintCanvas) + DECLARE_EVENT_TABLE() +}; + diff --git a/src/Pattern.cpp b/src/Pattern.cpp index 95269fd1..4e5cfca9 100644 --- a/src/Pattern.cpp +++ b/src/Pattern.cpp @@ -142,19 +142,18 @@ void CPattern::GetMatrices(std::list &matrices) } } -static bool OnEdit(HeeksObj* object, std::list *others) +static bool OnEdit(HeeksObj* object) { PatternDlg dlg(heeksCAD->GetMainFrame(), (CPattern*)object); if(dlg.ShowModal() == wxID_OK) { dlg.GetData((CPattern*)object); - ((CPattern*)object)->WriteDefaultValues(); return true; } return false; } -void CPattern::GetOnEdit(bool(**callback)(HeeksObj*, std::list *)) +void CPattern::GetOnEdit(bool(**callback)(HeeksObj*)) { *callback = OnEdit; } diff --git a/src/Pattern.h b/src/Pattern.h index 006d2b12..b2ff2536 100644 --- a/src/Pattern.h +++ b/src/Pattern.h @@ -32,7 +32,7 @@ class CPattern: public IdNamedObj { void CopyFrom(const HeeksObj* object); bool CanAddTo(HeeksObj* owner); const wxBitmap &GetIcon(); - void GetOnEdit(bool(**callback)(HeeksObj*, std::list *)); + void GetOnEdit(bool(**callback)(HeeksObj*)); static HeeksObj* ReadFromXMLElement(TiXmlElement* pElem); diff --git a/src/Pocket.cpp b/src/Pocket.cpp index bac14048..8adae999 100644 --- a/src/Pocket.cpp +++ b/src/Pocket.cpp @@ -331,9 +331,8 @@ void CPocket::WritePocketPython(Python &python) // Pocket the area python << _T("area_funcs.pocket(a, tool_diameter/2, "); python << m_pocket_params.m_material_allowance / theApp.m_program->m_units; - python << _T(", rapid_safety_space, start_depth, final_depth, "); - python << m_pocket_params.m_step_over / theApp.m_program->m_units; - python << _T(", step_down, z_finish_depth, z_thru_depth, user_depths, clearance, "); + python << _T(", ") << m_pocket_params.m_step_over / theApp.m_program->m_units; + python << _T(", depth_params, "); python << m_pocket_params.m_starting_place; python << (m_pocket_params.m_keep_tool_down_if_poss ? _T(", True") : _T(", False")); python << (m_pocket_params.m_use_zig_zag ? _T(", True") : _T(", False")); @@ -344,7 +343,7 @@ void CPocket::WritePocketPython(Python &python) python << _T(")\n"); // rapid back up to clearance plane - python << _T("rapid(z = clearance)\n"); + python << _T("rapid(z = depth_params.clearance_height)\n"); } Python CPocket::AppendTextToProgram() @@ -614,14 +613,14 @@ HeeksObj* CPocket::ReadFromXMLElement(TiXmlElement* element) } CPocket::CPocket(const std::list &sketches, const int tool_number ) - : CDepthOp(&sketches, tool_number ), m_sketches(sketches) + : CDepthOp(tool_number ), m_sketches(sketches) { ReadDefaultValues(); m_pocket_params.set_initial_values(tool_number); } CPocket::CPocket(const std::list &sketches, const int tool_number ) - : CDepthOp(sketches, tool_number ) + : CDepthOp( tool_number ) { ReadDefaultValues(); m_pocket_params.set_initial_values(tool_number); @@ -694,19 +693,12 @@ bool CPocket::operator==(const CPocket & rhs) const return(CDepthOp::operator==(rhs)); } -static bool OnEdit(HeeksObj* object, std::list *others) +static bool OnEdit(HeeksObj* object) { - PocketDlg dlg(heeksCAD->GetMainFrame(), (CPocket*)object); - if(dlg.ShowModal() == wxID_OK) - { - dlg.GetData((CPocket*)object); - ((CPocket*)object)->WriteDefaultValues(); - return true; - } - return false; + return PocketDlg::Do((CPocket*)object); } -void CPocket::GetOnEdit(bool(**callback)(HeeksObj*, std::list *)) +void CPocket::GetOnEdit(bool(**callback)(HeeksObj*)) { *callback = OnEdit; } diff --git a/src/Pocket.h b/src/Pocket.h index cd2b6041..45a24e11 100644 --- a/src/Pocket.h +++ b/src/Pocket.h @@ -74,7 +74,7 @@ class CPocket: public CDepthOp{ void WriteXML(TiXmlNode *root); bool CanAddTo(HeeksObj* owner); void GetTools(std::list* t_list, const wxPoint* p); - void GetOnEdit(bool(**callback)(HeeksObj*, std::list *)); + void GetOnEdit(bool(**callback)(HeeksObj*)); bool Add(HeeksObj* object, HeeksObj* prev_object); void WriteDefaultValues(); void ReadDefaultValues(); diff --git a/src/PocketDlg.cpp b/src/PocketDlg.cpp index 8ebec42b..737dbec6 100644 --- a/src/PocketDlg.cpp +++ b/src/PocketDlg.cpp @@ -10,6 +10,7 @@ enum { ID_SKETCH = 100, + ID_SKETCH_PICK, ID_STARTING_PLACE, ID_CUT_MODE, ID_KEEP_TOOL_DOWN, @@ -19,6 +20,7 @@ enum BEGIN_EVENT_TABLE(PocketDlg, DepthOpDlg) EVT_COMBOBOX(ID_SKETCH,HeeksObjDlg::OnComboOrCheck) + EVT_BUTTON(ID_SKETCH_PICK,PocketDlg::OnSketchPick) EVT_COMBOBOX(ID_STARTING_PLACE,HeeksObjDlg::OnComboOrCheck) EVT_COMBOBOX(ID_CUT_MODE,HeeksObjDlg::OnComboOrCheck) EVT_CHECKBOX(ID_KEEP_TOOL_DOWN, HeeksObjDlg::OnComboOrCheck) @@ -27,13 +29,13 @@ BEGIN_EVENT_TABLE(PocketDlg, DepthOpDlg) END_EVENT_TABLE() PocketDlg::PocketDlg(wxWindow *parent, CPocket* object, const wxString& title, bool top_level) - : DepthOpDlg(parent, object, title, false) + : DepthOpDlg(parent, object, false, title, false) { std::list save_leftControls = leftControls; leftControls.clear(); // add all the controls to the left side - leftControls.push_back(MakeLabelAndControl(_("sketches"), m_cmbSketch = new HTypeObjectDropDown(this, ID_SKETCH, SketchType, heeksCAD->GetMainObject()))); + leftControls.push_back(MakeLabelAndControl(_("sketches"), m_cmbSketch = new HTypeObjectDropDown(this, ID_SKETCH, SketchType, heeksCAD->GetMainObject()), m_btnSketchPick = new wxButton(this, ID_SKETCH_PICK, _("Pick")))); leftControls.push_back(MakeLabelAndControl(_("step over"), m_lgthStepOver = new CLengthCtrl(this))); leftControls.push_back(MakeLabelAndControl(_("material allowance"), m_lgthMaterialAllowance = new CLengthCtrl(this))); @@ -65,6 +67,7 @@ void PocketDlg::GetDataRaw(HeeksObj* object) ((CPocket*)object)->m_sketches.clear(); int sketch = m_cmbSketch->GetSelectedId(); if(sketch != 0)((CPocket*)object)->m_sketches.push_back(sketch); + ((CPocket*)object)->m_pocket_params.m_material_allowance = m_lgthMaterialAllowance->GetValue(); ((CPocket*)object)->m_pocket_params.m_starting_place = m_cmbStartingPlace->GetValue() ? 1:0; ((CPocket*)object)->m_pocket_params.m_cut_mode = (m_cmbCutMode->GetValue().CmpNoCase(_("climb")) == 0) ? CPocketParams::eClimb : CPocketParams::eConventional; @@ -146,3 +149,42 @@ void PocketDlg::EnableZigZagControls() m_dblZigAngle->Enable(enable); m_chkZigUnidirectional->Enable(enable); } + +void PocketDlg::OnSketchPick( wxCommandEvent& event ) +{ + EndModal(ID_SKETCH_PICK); +} + +bool PocketDlg::Do(CPocket* object) +{ + PocketDlg dlg(heeksCAD->GetMainFrame(), object); + + while(1) + { + int result = dlg.ShowModal(); + + if(result == wxID_OK) + { + dlg.GetData(object); + return true; + } + else if(result == ID_SKETCH_PICK) + { + heeksCAD->ClearMarkedList(); + heeksCAD->PickObjects(_("Pick a sketch"), MARKING_FILTER_SKETCH, true); + + dlg.m_cmbSketch->Recreate(); + dlg.Fit(); + + const std::list &list = heeksCAD->GetMarkedList(); + if(list.size() > 0) + { + dlg.m_cmbSketch->SelectById(list.front()->GetID()); + } + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/PocketDlg.h b/src/PocketDlg.h index 3de93e30..435b9526 100644 --- a/src/PocketDlg.h +++ b/src/PocketDlg.h @@ -22,12 +22,15 @@ class PocketDlg : public DepthOpDlg wxCheckBox *m_chkUseZigZag; CDoubleCtrl *m_dblZigAngle; wxCheckBox *m_chkZigUnidirectional; + wxButton *m_btnSketchPick; void EnableZigZagControls(); public: PocketDlg(wxWindow *parent, CPocket* object, const wxString& title = wxString(_T("Pocket Operation")), bool top_level = true); + static bool Do(CPocket* object); + // HeeksObjDlg virtual functions void GetDataRaw(HeeksObj* object); void SetFromDataRaw(HeeksObj* object); @@ -35,6 +38,7 @@ class PocketDlg : public DepthOpDlg void SetPicture(const wxString& name); void OnCheckUseZigZag(wxCommandEvent& event); + void OnSketchPick( wxCommandEvent& event ); DECLARE_EVENT_TABLE() }; diff --git a/src/Profile.cpp b/src/Profile.cpp index 8d42d754..b70474ff 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -362,8 +362,7 @@ CProfile::CProfile( const CProfile & rhs ) : CDepthOp(rhs) } CProfile::CProfile(const std::list &sketches, const int tool_number ) - : CDepthOp(&sketches, tool_number, ProfileType), - m_tags(NULL), m_sketches(sketches) + : CDepthOp(tool_number, ProfileType), m_tags(NULL), m_sketches(sketches) { ReadDefaultValues(); } // End constructor @@ -731,7 +730,7 @@ Python CProfile::AppendTextForOneSketch(HeeksObj* object, CProfileParams::eCutMo python << _T("lead_out_line_len= ") << m_profile_params.m_lead_out_line_len / theApp.m_program->m_units<< _T("\n"); // profile the kurve - python << wxString::Format(_T("kurve_funcs.profile(curve, '%s', tool_diameter/2, offset_extra, roll_radius, roll_on, roll_off, rapid_safety_space, clearance, start_depth, step_down, z_finish_depth, z_thru_depth, user_depths, final_depth,extend_at_start,extend_at_end,lead_in_line_len,lead_out_line_len )\n"), side_string.c_str()); + python << wxString::Format(_T("kurve_funcs.profile(curve, '%s', tool_diameter/2, offset_extra, roll_radius, roll_on, roll_off, depth_params, extend_at_start,extend_at_end,lead_in_line_len,lead_out_line_len )\n"), side_string.c_str()); } python << _T("absolute()\n"); return(python); @@ -841,7 +840,7 @@ Python CProfile::AppendTextToProgram(bool finishing_pass) python << m_speed_op_params.m_vertical_feed_rate / theApp.m_program->m_units << _T(")\n"); python << _T("flush_nc()\n"); python << _T("offset_extra = 0.0\n"); - python << _T("step_down = ") << m_profile_params.m_finishing_step_down << _T("\n"); + python << _T("depth_params.step_down = ") << m_profile_params.m_finishing_step_down << _T("\n"); } else { @@ -1266,19 +1265,12 @@ bool CProfile::operator==( const CProfile & rhs ) const return(CDepthOp::operator==(rhs)); } -static bool OnEdit(HeeksObj* object, std::list *others) +static bool OnEdit(HeeksObj* object) { - ProfileDlg dlg(heeksCAD->GetMainFrame(), (CProfile*)object); - if(dlg.ShowModal() == wxID_OK) - { - dlg.GetData((CProfile*)object); - ((CProfile*)object)->WriteDefaultValues(); - return true; - } - return false; + return ProfileDlg::Do((CProfile*)object); } -void CProfile::GetOnEdit(bool(**callback)(HeeksObj*, std::list *)) +void CProfile::GetOnEdit(bool(**callback)(HeeksObj*)) { *callback = OnEdit; } diff --git a/src/Profile.h b/src/Profile.h index cfd8c5f2..73201daf 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -102,7 +102,7 @@ class CProfile: public CDepthOp{ void Remove(HeeksObj* object); bool CanAdd(HeeksObj* object); bool CanAddTo(HeeksObj* owner); - void GetOnEdit(bool(**callback)(HeeksObj*, std::list *)); + void GetOnEdit(bool(**callback)(HeeksObj*)); void WriteDefaultValues(); void ReadDefaultValues(); diff --git a/src/ProfileDlg.cpp b/src/ProfileDlg.cpp index 872bfb21..c78e2a9e 100644 --- a/src/ProfileDlg.cpp +++ b/src/ProfileDlg.cpp @@ -12,6 +12,7 @@ enum { ID_SKETCH = 100, + ID_SKETCH_PICK, ID_TOOL_ON_SIDE, ID_CUT_MODE, ID_DO_FINISHING_PASS, @@ -21,6 +22,7 @@ enum BEGIN_EVENT_TABLE(ProfileDlg, DepthOpDlg) EVT_COMBOBOX(ID_SKETCH,HeeksObjDlg::OnComboOrCheck) + EVT_BUTTON(ID_SKETCH_PICK,ProfileDlg::OnSketchPick) EVT_COMBOBOX(ID_TOOL_ON_SIDE,HeeksObjDlg::OnComboOrCheck) EVT_COMBOBOX(ID_CUT_MODE,HeeksObjDlg::OnComboOrCheck) EVT_CHECKBOX(ID_DO_FINISHING_PASS, ProfileDlg::OnCheckFinishingPass) @@ -29,13 +31,13 @@ BEGIN_EVENT_TABLE(ProfileDlg, DepthOpDlg) END_EVENT_TABLE() ProfileDlg::ProfileDlg(wxWindow *parent, CProfile* object, const wxString& title, bool top_level) -: DepthOpDlg(parent, object, title, false) +: DepthOpDlg(parent, object, false, title, false) { std::list save_leftControls = leftControls; leftControls.clear(); // add all the controls to the left side - leftControls.push_back(MakeLabelAndControl(_("sketches"), m_cmbSketch = new HTypeObjectDropDown(this, ID_SKETCH, SketchType, heeksCAD->GetMainObject()))); + leftControls.push_back(MakeLabelAndControl(_("sketches"), m_cmbSketch = new HTypeObjectDropDown(this, ID_SKETCH, SketchType, heeksCAD->GetMainObject()), m_btnSketchPick = new wxButton(this, ID_SKETCH_PICK, _("Pick")))); wxString tool_on_side_choices[] = {_("left"), _("right"), _("on")}; leftControls.push_back(MakeLabelAndControl( _("tool on side"), m_cmbToolOnSide = new wxComboBox(this, ID_TOOL_ON_SIDE, _T(""), wxDefaultPosition, wxDefaultSize, 3, tool_on_side_choices))); @@ -67,6 +69,22 @@ void ProfileDlg::GetDataRaw(HeeksObj* object) { ((CProfile*)object)->m_sketches.clear(); int sketch = m_cmbSketch->GetSelectedId(); + + switch (m_cmbToolOnSide->GetSelection()) + { + case 1: + ((CProfile*)object)->m_profile_params.m_tool_on_side = CProfileParams::eRightOrInside; + break; + + case 2: + ((CProfile*)object)->m_profile_params.m_tool_on_side = CProfileParams::eOn; + break; + + case 0: + ((CProfile*)object)->m_profile_params.m_tool_on_side = CProfileParams::eLeftOrOutside; + break; + } // End switch + if(sketch != 0)((CProfile*)object)->m_sketches.push_back(sketch); ((CProfile*)object)->m_profile_params.m_cut_mode = (m_cmbCutMode->GetValue().CmpNoCase(_("climb")) == 0) ? CProfileParams::eClimb : CProfileParams::eConventional; @@ -167,8 +185,8 @@ void ProfileDlg::SetPictureByWindow(wxWindow* w) } else if(w == m_cmbCutMode) { - if(m_cmbCutMode->GetValue() == _("climb"))SetPicture(_T("climb milling")); - else SetPicture(_T("conventional milling")); + if(m_cmbCutMode->GetValue() == _("climb"))HeeksObjDlg::SetPicture(_T("climb milling"),_T("pocket")); + else HeeksObjDlg::SetPicture(_T("conventional milling"),_T("pocket")); } else if(w == m_lgthRollRadius)SetPicture(_T("roll radius")); else if(w == m_lgthOffsetExtra)SetPicture(_T("offset extra")); @@ -183,10 +201,10 @@ void ProfileDlg::SetPictureByWindow(wxWindow* w) } else if(w == m_cmbFinishingCutMode) { - if(m_cmbFinishingCutMode->GetValue() == _("climb"))SetPicture(_T("climb milling")); - else SetPicture(_T("conventional milling")); + if(m_cmbFinishingCutMode->GetValue() == _("climb"))HeeksObjDlg::SetPicture(_T("climb milling"),_T("pocket")); + else HeeksObjDlg::SetPicture(_T("conventional milling"),_T("pocket")); } - else if(w == m_lgthFinishStepDown)SetPicture(_T("step down")); + else if(w == m_lgthFinishStepDown)HeeksObjDlg::SetPicture(_T("step down"),_T("depthop")); else DepthOpDlg::SetPictureByWindow(w); } @@ -235,3 +253,42 @@ void ProfileDlg::SetSketchOrderAndCombo() break; } } + +void ProfileDlg::OnSketchPick( wxCommandEvent& event ) +{ + EndModal(ID_SKETCH_PICK); +} + +bool ProfileDlg::Do(CProfile* object) +{ + ProfileDlg dlg(heeksCAD->GetMainFrame(), object); + + while(1) + { + int result = dlg.ShowModal(); + + if(result == wxID_OK) + { + dlg.GetData(object); + return true; + } + else if(result == ID_SKETCH_PICK) + { + heeksCAD->ClearMarkedList(); + heeksCAD->PickObjects(_("Pick a sketch"), MARKING_FILTER_SKETCH, true); + + dlg.m_cmbSketch->Recreate(); + dlg.Fit(); + + const std::list &list = heeksCAD->GetMarkedList(); + if(list.size() > 0) + { + dlg.m_cmbSketch->SelectById(list.front()->GetID()); + } + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/ProfileDlg.h b/src/ProfileDlg.h index d98e0914..02ee63ee 100644 --- a/src/ProfileDlg.h +++ b/src/ProfileDlg.h @@ -25,6 +25,7 @@ class ProfileDlg : public DepthOpDlg wxStaticText* m_staticFinishingFeedrate; wxStaticText* m_staticFinishingCutMode; wxStaticText* m_staticFinishStepDown; + wxButton *m_btnSketchPick; SketchOrderType m_order; @@ -33,6 +34,8 @@ class ProfileDlg : public DepthOpDlg public: ProfileDlg(wxWindow *parent, CProfile* object, const wxString& title = wxString(_T("Profile Operation")), bool top_level = true); + static bool Do(CProfile* object); + // HeeksObjDlg virtual functions void GetDataRaw(HeeksObj* object); void SetFromDataRaw(HeeksObj* object); @@ -41,6 +44,7 @@ class ProfileDlg : public DepthOpDlg void SetSketchOrderAndCombo(); void OnCheckFinishingPass( wxCommandEvent& event ); + void OnSketchPick( wxCommandEvent& event ); DECLARE_EVENT_TABLE() }; diff --git a/src/Program.cpp b/src/Program.cpp index 3691c968..4c9eaa11 100644 --- a/src/Program.cpp +++ b/src/Program.cpp @@ -182,6 +182,7 @@ CMachine & CMachine::operator= ( const CMachine & rhs ) { configuration_file_name = rhs.configuration_file_name; file_name = rhs.file_name; + suffix = rhs.suffix; description = rhs.description; m_max_spindle_speed = rhs.m_max_spindle_speed; m_safety_height_defined = rhs.m_safety_height_defined; @@ -603,6 +604,7 @@ Python CProgram::RewritePythonProgram() bool ocl_funcs_needed = false; bool nc_attach_needed = false; bool transform_module_needed = false; + bool depths_needed = false; typedef std::vector< COp * > OperationsMap_t; OperationsMap_t operations; @@ -627,16 +629,23 @@ Python CProgram::RewritePythonProgram() { case ProfileType: kurve_funcs_needed = true; + depths_needed = true; break; case PocketType: area_funcs_needed = true; + depths_needed = true; + break; + + case DrillingType: + depths_needed = true; break; case ScriptOpType: ocl_module_needed = true; nc_attach_needed = true; ocl_funcs_needed = true; + depths_needed = true; break; } } @@ -710,6 +719,11 @@ Python CProgram::RewritePythonProgram() //hackhack, make it work on unix with FHS python << _T("import sys\n"); + // redirect errors and print statements to files + wxStandardPaths standard_paths; + wxFileName errors_path( standard_paths.GetTempDir().c_str(), _T(ERRORS_TXT_FILE_NAME)); + wxFileName output_path( standard_paths.GetTempDir().c_str(), _T(OUTPUT_TXT_FILE_NAME)); + #ifdef CMAKE_UNIX #ifdef RUNINPLACE python << _T("sys.path.insert(0,'") << theApp.GetResFolder() << _T("/')\n"); @@ -770,6 +784,12 @@ Python CProgram::RewritePythonProgram() python << _T("\n"); } + if(depths_needed) + { + python << _T("from depth_params import depth_params as depth_params\n"); + python << _T("\n"); + } + // machine general stuff python << _T("from nc.nc import *\n"); @@ -906,71 +926,48 @@ void CProgram::GetMachines(std::vector &machines) wxString machines_file = CProgram::alternative_machines_file; #ifdef CMAKE_UNIX #ifdef RUNINPLACE - if(machines_file.Len() == 0)machines_file = theApp.GetResFolder() + _T("/nc/machines.txt"); + if(machines_file.Len() == 0)machines_file = theApp.GetResFolder() + _T("/nc/machines.xml"); #else - if(machines_file.Len() == 0)machines_file = _T("/usr/lib/heekscnc/nc/machines.txt"); + if(machines_file.Len() == 0)machines_file = _T("/usr/lib/heekscnc/nc/machines.xml"); #endif #else - if(machines_file.Len() == 0)machines_file = theApp.GetResFolder() + _T("/nc/machines.txt"); -#endif - ifstream ifs(Ttc(machines_file.c_str())); - if(!ifs) - { -#ifdef UNICODE - std::wostringstream l_ossMessage; -#else - std::ostringstream l_ossMessage; + if(machines_file.Len() == 0)machines_file = theApp.GetResFolder() + _T("/nc/machines.xml"); #endif - l_ossMessage << "Could not open '" << machines_file.c_str() << "' for reading"; - wxMessageBox( l_ossMessage.str().c_str() ); + TiXmlDocument doc(Ttc(machines_file.c_str())); + if (!doc.LoadFile()) + { + if(doc.Error()) + { + wxMessageBox(Ctt(doc.ErrorDesc())); + } return; } - char str[1024] = ""; + char oldlocale[1000]; + strcpy(oldlocale, setlocale(LC_NUMERIC, "C")); - while(!(ifs.eof())) - { - CMachine m; + TiXmlHandle hDoc(&doc); + TiXmlElement* element; + TiXmlNode* root = &doc; - ifs.getline(str, 1024); - - m.configuration_file_name = machines_file; - - std::vector tokens = Tokens( Ctt(str), _T(" \t\n\r") ); - - // The first token is the machine name (post processor name) - if (tokens.size() > 0) { - m.file_name = tokens[0]; - tokens.erase(tokens.begin()); - } // End if - then - - // If there are other tokens, check the last one to see if it could be a maximum - // spindle speed. - if (tokens.size() > 0) - { - // We may have a material rate value. - if (AllNumeric( *tokens.rbegin() )) - { - tokens.rbegin()->ToDouble(&(m.m_max_spindle_speed)); - tokens.resize(tokens.size() - 1); // Remove last token. - } // End if - then - } // End if - then - - // Everything else must be a description. - m.description.clear(); - for (std::vector::const_iterator l_itToken = tokens.begin(); l_itToken != tokens.end(); l_itToken++) - { - if (l_itToken != tokens.begin()) m.description << _T(" "); - m.description << *l_itToken; - } // End for - - if(m.file_name.Length() > 0) + for(element = root->FirstChildElement(); element; element = element->NextSiblingElement()) + { + //if(!stricmp(element->GetText(), "machine")) { + //TiXmlElement* element = TiXmlHandle(pElem).FirstChildElement("machine").Element(); + + //if(element) + //{ + CMachine m; + if(const char* pyfile_str = element->Attribute("pyfile"))m.file_name = wxString(Ctt(pyfile_str)); + if(const char* suffix_str = element->Attribute("suffix"))m.suffix = wxString(Ctt(suffix_str)); + if(const char* descrp_str = element->Attribute("description"))m.description = wxString(Ctt(descrp_str)); machines.push_back(m); } } + setlocale(LC_NUMERIC, oldlocale); } // static @@ -1016,7 +1013,7 @@ wxString CProgram::GetOutputFileName() const path.Remove(offset); // chop off the end. } // End if - then - path << _T(".tap"); + path << m_machine.suffix.c_str(); return(path); } // End if - then else @@ -1109,6 +1106,7 @@ bool CMachine::operator==( const CMachine & rhs ) const { if (configuration_file_name != rhs.configuration_file_name) return(false); if (file_name != rhs.file_name) return(false); + if (suffix != rhs.suffix) return(false); if (description != rhs.description) return(false); if (m_max_spindle_speed != rhs.m_max_spindle_speed) return(false); if (m_safety_height_defined != rhs.m_safety_height_defined) return(false); @@ -1140,7 +1138,7 @@ void CProgram::ReadDefaultValues() m_machine = CProgram::GetMachine(machine_file_name); config.Read(_T("OutputFileNameFollowsDataFileName"), &m_output_file_name_follows_data_file_name, true); wxStandardPaths standard_paths; - wxFileName default_path( standard_paths.GetTempDir().c_str(), _T("test.tap")); + wxFileName default_path( standard_paths.GetTempDir().c_str(), wxString(_T("test")) + m_machine.suffix); config.Read(_T("ProgramOutputFile"), &m_output_file, default_path.GetFullPath().c_str()); config.Read(_T("ProgramUnits"), &m_units, 1.0); config.Read(_("ProgramPathControlMode"), (int *) &m_path_control_mode, (int) ePathControlUndefined ); @@ -1148,19 +1146,18 @@ void CProgram::ReadDefaultValues() config.Read(_("ProgramNaiveCamTolerance"), &m_naive_cam_tolerance, 0.0001); } -static bool OnEdit(HeeksObj* object, std::list *others) +static bool OnEdit(HeeksObj* object) { ProgramDlg dlg(heeksCAD->GetMainFrame(), (CProgram*)object); if(dlg.ShowModal() == wxID_OK) { dlg.GetData((CProgram*)object); - ((CProgram*)object)->WriteDefaultValues(); return true; } return false; } -void CProgram::GetOnEdit(bool(**callback)(HeeksObj*, std::list *)) +void CProgram::GetOnEdit(bool(**callback)(HeeksObj*)) { *callback = OnEdit; } diff --git a/src/Program.h b/src/Program.h index 046a4861..bccdd26f 100644 --- a/src/Program.h +++ b/src/Program.h @@ -33,6 +33,7 @@ class CMachine wxString configuration_file_name; wxString file_name; + wxString suffix; wxString description; double m_max_spindle_speed; // in revolutions per minute (RPM) bool m_safety_height_defined; @@ -129,7 +130,7 @@ class CProgram:public ObjList bool CanBeDragged(){return false;} void WriteDefaultValues(); void ReadDefaultValues(); - void GetOnEdit(bool(**callback)(HeeksObj*, std::list *)); + void GetOnEdit(bool(**callback)(HeeksObj*)); Python RewritePythonProgram(); ProgramUserType GetUserType(); diff --git a/src/PythonStuff.cpp b/src/PythonStuff.cpp index b13520bd..8138d744 100644 --- a/src/PythonStuff.cpp +++ b/src/PythonStuff.cpp @@ -47,7 +47,7 @@ void CPyProcess::HandleInput(void) { s += wxString::From8BitData(buffer, m_in->LastRead()); } if (s.Length() > 0) { - wxLogMessage(_T("> %s"), s.c_str()); + theApp.m_print_canvas->m_textCtrl->AppendText(s); } } if (m_err) { @@ -72,9 +72,8 @@ void CPyProcess::Execute(const wxChar* cmd) m_pid = wxExecute(cmd, wxEXEC_ASYNC|wxEXEC_MAKE_GROUP_LEADER, this); if (!m_pid) { wxLogMessage(_T("could not execute '%s'"),cmd); - } else { - wxLogMessage(_T("starting '%s' (%d)"),cmd,m_pid); } + if (redirect) { m_timer.Start(100); //msec } @@ -122,11 +121,7 @@ void CPyProcess::OnTerminate(int pid, int status) m_timer.Stop(); HandleInput(); // anything left? } - if (status) { - wxLogMessage(_T("process %d exit(%d)"),pid, status); - } else { - wxLogDebug(_T("process %d exit(0)"),pid); - } + m_pid = 0; ThenDo(); } @@ -227,8 +222,19 @@ class CPyPostProcess : public CPyProcess void Do(void) { - wxBusyCursor wait; // show an hour glass until the end of this function wxStandardPaths standard_paths; + wxFileName errors_path( standard_paths.GetTempDir().c_str(), _T(ERRORS_TXT_FILE_NAME)); + wxFileName output_path( standard_paths.GetTempDir().c_str(), _T(OUTPUT_TXT_FILE_NAME)); + + // clear the error and output files + { + ofstream ofs(Ttc(errors_path.GetFullPath().c_str())); + } + { + ofstream ofs(Ttc(output_path.GetFullPath().c_str())); + } + wxBusyCursor wait; // show an hour glass until the end of this function + wxFileName path( standard_paths.GetTempDir().c_str(), _T("post.py")); #ifdef WIN32 @@ -241,6 +247,46 @@ class CPyPostProcess : public CPyProcess } void ThenDo(void) { + wxStandardPaths standard_paths; + wxFileName errors_path( standard_paths.GetTempDir().c_str(), _T(ERRORS_TXT_FILE_NAME)); + wxFileName output_path( standard_paths.GetTempDir().c_str(), _T(OUTPUT_TXT_FILE_NAME)); + + ifstream ifs(Ttc(errors_path.GetFullPath().c_str())); + if(!ifs) + { + #ifdef UNICODE + std::wostringstream l_ossMessage; + #else + std::ostringstream l_ossMessage; + #endif + + l_ossMessage << "Could not open '" << errors_path.GetFullPath().c_str() << "' for reading"; + wxMessageBox( l_ossMessage.str().c_str() ); + return; + } + + char str[1024] = ""; + + bool there_were_errors = false; + while(!(ifs.eof())) + { + ifs.getline(str, 1024); + if(strlen(str)>0) + { + there_were_errors = true; + theApp.m_output_canvas->m_textCtrl->AppendText(Ctt(str)); + theApp.m_output_canvas->m_textCtrl->AppendText(_T("\n")); + } + } + + if(there_were_errors) + { + wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, _T("Lucida Console"), wxFONTENCODING_SYSTEM); + theApp.m_output_canvas->m_textCtrl->SetFont(font); + wxMessageBox(_("There were errors!, see Output window")); + return; + } + if (m_include_backplot_processing) { (new CPyBackPlot(m_program, (HeeksObj*)m_program, m_filename))->Do(); @@ -266,6 +312,7 @@ bool HeeksPyPostProcess(const CProgram* program, const wxString &filepath, const { try{ theApp.m_output_canvas->m_textCtrl->Clear(); // clear the output window + theApp.m_print_canvas->m_textCtrl->Clear(); // clear the output window // write the python file wxStandardPaths standard_paths; @@ -288,7 +335,9 @@ bool HeeksPyPostProcess(const CProgram* program, const wxString &filepath, const #endif // call the python file - (new CPyPostProcess(program, filepath, include_backplot_processing))->Do(); + CPyPostProcess::redirect = true; + CPyPostProcess* p = new CPyPostProcess(program, filepath, include_backplot_processing); + p->Do(); return true; } @@ -373,7 +422,9 @@ static void on_set_to_machine_command(const wxChar *value, HeeksObj* object) // static void CSendToMachine::GetOptions(std::list *list) { +#ifndef WIN32 list->push_back(new PropertyString(_("send-to-machine command"), m_command, NULL, on_set_to_machine_command)); +#endif } // static diff --git a/src/PythonStuff.h b/src/PythonStuff.h index bbda5d7d..de6eca35 100644 --- a/src/PythonStuff.h +++ b/src/PythonStuff.h @@ -7,6 +7,9 @@ class Property; #include "PythonString.h" #include + +#define ERRORS_TXT_FILE_NAME "heeks errors.txt" +#define OUTPUT_TXT_FILE_NAME "heeks output.txt" class CPyProcess : public wxProcess { diff --git a/src/ScriptOp.cpp b/src/ScriptOp.cpp index 6decfe6b..695984a3 100644 --- a/src/ScriptOp.cpp +++ b/src/ScriptOp.cpp @@ -339,14 +339,11 @@ void CScriptOp::GetProperties(std::list *list) ObjectCanvas* CScriptOp::GetDialog(wxWindow* parent) { - static TextCanvas* object_canvas = NULL; - if(object_canvas == NULL)object_canvas = new TextCanvas(parent, &m_str); - else - { - object_canvas->m_str = &m_str; - object_canvas->SetWithObject(this); - } - return object_canvas; + if(TextCanvas::global_text_canvas)delete TextCanvas::global_text_canvas; + + TextCanvas::global_text_canvas = new TextCanvas(parent, &m_str); + + return TextCanvas::global_text_canvas; } HeeksObj *CScriptOp::MakeACopy(void)const diff --git a/src/SpeedOpDlg.cpp b/src/SpeedOpDlg.cpp index 55613cf6..16f5dc15 100644 --- a/src/SpeedOpDlg.cpp +++ b/src/SpeedOpDlg.cpp @@ -88,5 +88,7 @@ void SpeedOpDlg::SetPicture(const wxString& name) void SpeedOpDlg::SetPictureByWindow(wxWindow* w) { - SetPicture(_T("general")); + if(w == m_cmbPattern)HeeksObjDlg::SetPicture(_T("general"), _T("pattern")); + else if(w == m_cmbSurface)HeeksObjDlg::SetPicture(_T("general"), _T("surface")); + else SetPicture(_T("general")); } diff --git a/src/Surface.cpp b/src/Surface.cpp index ea56d233..3a64aec3 100644 --- a/src/Surface.cpp +++ b/src/Surface.cpp @@ -145,19 +145,18 @@ const wxBitmap &CSurface::GetIcon() return *icon; } -static bool OnEdit(HeeksObj* object, std::list *others) +static bool OnEdit(HeeksObj* object) { SurfaceDlg dlg(heeksCAD->GetMainFrame(), (CSurface*)object); if(dlg.ShowModal() == wxID_OK) { dlg.GetData((CSurface*)object); - ((CSurface*)object)->WriteDefaultValues(); return true; } return false; } -void CSurface::GetOnEdit(bool(**callback)(HeeksObj*, std::list *)) +void CSurface::GetOnEdit(bool(**callback)(HeeksObj*)) { *callback = OnEdit; } diff --git a/src/Surface.h b/src/Surface.h index ddbe2fad..a6f1153e 100644 --- a/src/Surface.h +++ b/src/Surface.h @@ -38,6 +38,6 @@ class CSurface: public IdNamedObj { const wxBitmap &GetIcon(); void WriteDefaultValues(); void ReadDefaultValues(); - void GetOnEdit(bool(**callback)(HeeksObj*, std::list *)); + void GetOnEdit(bool(**callback)(HeeksObj*)); }; // End CSurface class definition.