def __init__(self,parent):
    self.parent = parent
    self.parent.png_file = ''
    self.parent.zmin = ''
    self.parent.zmax = ''
    self.parent.units = 1
    #
    # make path
    #
    def make_path(event):
       if (self.parent.png_file == ''):
          print "png_path: oops -- must make .png first"
          return
       self.parent.path_file = self.parent.tmp+self.parent.rootname+'.path'
       path_png = self.parent.tmp+self.parent.rootname+'.path.png'
       selection = self.path_type.GetValue()
       if (selection == "2D"):
          diameter = self.diameter_2D.GetValue()
          number = self.number_2D.GetValue()
          overlap = self.overlap_2D.GetValue()
          error = self.error_2D.GetValue()
          intensity = self.intensity_2D.GetValue()
          command = 'png_path '+'\"'+self.parent.png_file+'\"'+' '+'\"'+self.parent.path_file+'\"'+' '+error+' '+diameter+' '+number+' '+overlap+' '+intensity
       elif (selection == "3D plane"):
          diameter = self.diameter_plane.GetValue()
          number = self.number_plane.GetValue()
          overlap = self.overlap_plane.GetValue()
          error = self.error_plane.GetValue()
          intensity = self.intensity_plane.GetValue()
          z = self.z_plane.GetValue()
          command = 'png_path '+'\"'+self.parent.png_file+'\"'+' '+'\"'+self.parent.path_file+'\"'+' '+error+' '+diameter+' '+number+' '+overlap+' '+intensity+' '+intensity+' '+z
       elif (selection == "3D rough"):
          diameter = self.diameter_rough.GetValue()
          number = self.number_rough.GetValue()
          overlap = self.overlap_rough.GetValue()
          error = self.error_rough.GetValue()
          itop = self.itop_rough.GetValue()
          ibot = self.ibot_rough.GetValue()
          ztop = self.ztop_rough.GetValue()
          zbot = self.zbot_rough.GetValue()
          zstep = self.zstep_rough.GetValue()
          command = 'png_path '+'\"'+self.parent.png_file+'\"'+' '+'\"'+self.parent.path_file+'\"'+' '+error+' '+diameter+' '+number+' '+overlap+' '+itop+' '+ibot+' '+ztop+' '+zbot+' '+zstep
       elif (selection == "3D finish"):
          diameter = self.diameter_finish.GetValue()
          overlap = self.overlap_finish.GetValue()
          error = self.error_finish.GetValue()
          itop = self.itop_finish.GetValue()
          ibot = self.ibot_finish.GetValue()
          ztop = self.ztop_finish.GetValue()
          zbot = self.zbot_finish.GetValue()
          clearance_length = self.clearance_length_finish.GetValue()
          clearance_diameter = self.clearance_diameter_finish.GetValue()
          number = '0'
          zstep = '0'
          if self.xz_finish.GetValue():
             xz = "1"
          else:
             xz = "0"
          if self.yz_finish.GetValue():
             yz = "1"
          else:
             yz = "0"
          xy = "0"
          if self.flat_end_finish.GetValue():
             tool_type = 'f'
          elif self.ball_end_finish.GetValue():
             tool_type = 'b'
          command = 'png_path '+'\"'+self.parent.png_file+'\"'+' '+'\"'+self.parent.path_file+'\"'+' '+error+' '+diameter+' '+number+' '+overlap+' '+itop+' '+ibot+' '+ztop+' '+zbot+' '+zstep+' '+xz+' '+yz+' '+xy+' '+tool_type+' '+clearance_length+' '+clearance_diameter
       print command
       ret = os.system(command)
       if (ret == 0):
          self.path_viewer.draw(self.parent.path_file)
          #self.parent.Layout()
          #self.parent.Fit()
    #
    # panel
    #
    wx.Panel.__init__(self,parent)
    self.sizer = wx.GridBagSizer(10,10)
    self.SetSizer(self.sizer)
    #
    # label
    #
    label = wx.StaticText(self,label='to: path')
    bold_font = wx.Font(10,wx.DEFAULT,wx.NORMAL,wx.BOLD)
    label.SetFont(bold_font)
    self.sizer.Add(label,(0,0),flag=wx.ALIGN_CENTER_HORIZONTAL)
    #
    # image
    #
    self.path_viewer = path_panel(self)
    self.sizer.Add(self.path_viewer,(1,0),flag=wx.ALIGN_CENTER_HORIZONTAL)
    #
    # controls
    #
    make_panel = wx.Panel(self)
    make_sizer = wx.GridBagSizer(10,10)
    make_panel.SetSizer(make_sizer)
    make_button = wx.Button(make_panel,label='make .path')
    make_button.Bind(wx.EVT_BUTTON,make_path)
    make_sizer.Add(make_button,(0,0),flag=wx.ALIGN_CENTER_HORIZONTAL)
    make_sizer.Add(wx.StaticText(make_panel,label='type:'),(0,1),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.path_types = ["2D","3D plane","3D rough","3D finish"]
    self.path_type = wx.ComboBox(make_panel,size=(100,-1),value="2D",choices=self.path_types,style=wx.CB_READONLY)
    self.parent.path_type = "2D"
    self.path_type.Bind(wx.EVT_COMBOBOX,self.path_type_handler)
    make_sizer.Add(self.path_type,(0,2),flag=wx.ALIGN_LEFT)
    self.sizer.Add(make_panel,(2,0),flag=(wx.ALIGN_CENTER_HORIZONTAL))
    #
    # 2D panel
    #
    panel_2D = wx.Panel(self)
    sizer_2D = wx.GridBagSizer(10,10)
    panel_2D.SetSizer(sizer_2D)
    #
    sizer_2D.Add(wx.StaticText(panel_2D,label='diameter (mm)'),(0,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.diameter_2D = wx.TextCtrl(panel_2D,-1,'0.25')
    sizer_2D.Add(self.diameter_2D,(0,1),flag=(wx.ALIGN_LEFT))
    self.number_2D = wx.TextCtrl(panel_2D,-1,'1')
    sizer_2D.Add(self.number_2D,(0,2),flag=(wx.ALIGN_RIGHT))
    sizer_2D.Add(wx.StaticText(panel_2D,label='offsets (-1 to fill)'),(0,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    sizer_2D.Add(wx.StaticText(panel_2D,label='overlap (0-1)'),(1,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.overlap_2D = wx.TextCtrl(panel_2D,-1,'0.5')
    sizer_2D.Add(self.overlap_2D,(1,1),flag=(wx.ALIGN_RIGHT))
    self.error_2D = wx.TextCtrl(panel_2D,-1,'1.1')
    sizer_2D.Add(self.error_2D,(1,2),flag=(wx.ALIGN_RIGHT))
    sizer_2D.Add(wx.StaticText(panel_2D,label='error (pixels)'),(1,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    sizer_2D.Add(wx.StaticText(panel_2D,label='intensity (0-1)'),(2,1),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.intensity_2D = wx.TextCtrl(panel_2D,-1,'0.5')
    sizer_2D.Add(self.intensity_2D,(2,2),flag=(wx.ALIGN_RIGHT))
    #
    self.sizer.Add(panel_2D,(3,0),flag=(wx.ALIGN_CENTER_HORIZONTAL))
    self.type_panel = panel_2D
    self.type_panels = [panel_2D]
    #
    # 3D plane panel
    #
    panel_3D_plane = wx.Panel(self)
    sizer_3D_plane = wx.GridBagSizer(10,10)
    panel_3D_plane.SetSizer(sizer_3D_plane)
    #
    sizer_3D_plane.Add(wx.StaticText(panel_3D_plane,label='  diameter (mm)'),(0,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.diameter_plane = wx.TextCtrl(panel_3D_plane,-1,'0.25')
    sizer_3D_plane.Add(self.diameter_plane,(0,1),flag=(wx.ALIGN_LEFT))
    self.number_plane = wx.TextCtrl(panel_3D_plane,-1,'1')
    sizer_3D_plane.Add(self.number_plane,(0,2),flag=(wx.ALIGN_RIGHT))
    sizer_3D_plane.Add(wx.StaticText(panel_3D_plane,label='offsets (-1 to fill)'),(0,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    sizer_3D_plane.Add(wx.StaticText(panel_3D_plane,label='overlap (0-1)'),(1,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.overlap_plane = wx.TextCtrl(panel_3D_plane,-1,'0.5')
    sizer_3D_plane.Add(self.overlap_plane,(1,1),flag=(wx.ALIGN_LEFT))
    self.error_plane = wx.TextCtrl(panel_3D_plane,-1,'1.1')
    sizer_3D_plane.Add(self.error_plane,(1,2),flag=(wx.ALIGN_RIGHT))
    sizer_3D_plane.Add(wx.StaticText(panel_3D_plane,label='error (pixels)'),(1,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    sizer_3D_plane.Add(wx.StaticText(panel_3D_plane,label='intensity (0-1) '),(2,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.intensity_plane = wx.TextCtrl(panel_3D_plane,-1,'0.5')
    sizer_3D_plane.Add(self.intensity_plane,(2,1),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    self.z_plane = wx.TextCtrl(panel_3D_plane,-1,'0')
    sizer_3D_plane.Add(self.z_plane,(2,2),flag=(wx.ALIGN_RIGHT))
    sizer_3D_plane.Add(wx.StaticText(panel_3D_plane,label='z (mm)'),(2,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    panel_3D_plane.Hide()
    self.type_panels.append(panel_3D_plane)
    #
    # 3D rough panel
    #
    panel_3D_rough = wx.Panel(self)
    sizer_3D_rough = wx.GridBagSizer(10,10)
    panel_3D_rough.SetSizer(sizer_3D_rough)
    #
    sizer_3D_rough.Add(wx.StaticText(panel_3D_rough,label='diameter (mm)'),(0,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.diameter_rough = wx.TextCtrl(panel_3D_rough,-1,'0.25')
    sizer_3D_rough.Add(self.diameter_rough,(0,1),flag=(wx.ALIGN_LEFT))
    self.number_rough = wx.TextCtrl(panel_3D_rough,-1,'-1')
    sizer_3D_rough.Add(self.number_rough,(0,2),flag=(wx.ALIGN_RIGHT))
    sizer_3D_rough.Add(wx.StaticText(panel_3D_rough,label='offsets (-1 to fill)'),(0,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    sizer_3D_rough.Add(wx.StaticText(panel_3D_rough,label='overlap (0-1)'),(1,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.overlap_rough = wx.TextCtrl(panel_3D_rough,-1,'0.5')
    sizer_3D_rough.Add(self.overlap_rough,(1,1),flag=(wx.ALIGN_LEFT))
    self.error_rough = wx.TextCtrl(panel_3D_rough,-1,'1.1')
    sizer_3D_rough.Add(self.error_rough,(1,2),flag=(wx.ALIGN_RIGHT))
    sizer_3D_rough.Add(wx.StaticText(panel_3D_rough,label='error (pixels)'),(1,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    sizer_3D_rough.Add(wx.StaticText(panel_3D_rough,label='top intensity (0-1)'),(2,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.itop_rough = wx.TextCtrl(panel_3D_rough,-1,'1')
    sizer_3D_rough.Add(self.itop_rough,(2,1),flag=(wx.ALIGN_LEFT))
    self.ztop_rough = wx.TextCtrl(panel_3D_rough,-1,'0')
    sizer_3D_rough.Add(self.ztop_rough,(2,2),flag=(wx.ALIGN_RIGHT))
    sizer_3D_rough.Add(wx.StaticText(panel_3D_rough,label='top z (mm)'),(2,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    sizer_3D_rough.Add(wx.StaticText(panel_3D_rough,label='bot intensity (0-1)'),(3,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.ibot_rough = wx.TextCtrl(panel_3D_rough,-1,'0')
    sizer_3D_rough.Add(self.ibot_rough,(3,1),flag=(wx.ALIGN_LEFT))
    self.zbot_rough = wx.TextCtrl(panel_3D_rough,-1,'')
    sizer_3D_rough.Add(self.zbot_rough,(3,2),flag=(wx.ALIGN_RIGHT))
    sizer_3D_rough.Add(wx.StaticText(panel_3D_rough,label='bot z (mm)'),(3,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    sizer_3D_rough.Add(wx.StaticText(panel_3D_rough,label='cut depth (mm)'),(4,1),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    self.zstep_rough = wx.TextCtrl(panel_3D_rough,-1,'1')
    sizer_3D_rough.Add(self.zstep_rough,(4,2),flag=(wx.ALIGN_RIGHT))
    #
    panel_3D_rough.Hide()
    self.type_panels.append(panel_3D_rough)
    #
    # 3D finish panel
    #
    panel_3D_finish = wx.Panel(self)
    sizer_3D_finish = wx.GridBagSizer(10,10)
    panel_3D_finish.SetSizer(sizer_3D_finish)
    #
    sizer_3D_finish.Add(wx.StaticText(panel_3D_finish,label='tool diameter (mm)'),(0,1),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.diameter_finish = wx.TextCtrl(panel_3D_finish,-1,'0.25')
    sizer_3D_finish.Add(self.diameter_finish,(0,2),flag=(wx.ALIGN_LEFT))
    #
    sizer_3D_finish.Add(wx.StaticText(panel_3D_finish,label='overlap (0-1)'),(1,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.overlap_finish = wx.TextCtrl(panel_3D_finish,-1,'0.5')
    sizer_3D_finish.Add(self.overlap_finish,(1,1),flag=(wx.ALIGN_LEFT))
    self.error_finish = wx.TextCtrl(panel_3D_finish,-1,'1.1')
    sizer_3D_finish.Add(self.error_finish,(1,2),flag=(wx.ALIGN_RIGHT))
    sizer_3D_finish.Add(wx.StaticText(panel_3D_finish,label='error (pixels)'),(1,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    sizer_3D_finish.Add(wx.StaticText(panel_3D_finish,label='top intensity (0-1)'),(2,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.itop_finish = wx.TextCtrl(panel_3D_finish,-1,'1')
    sizer_3D_finish.Add(self.itop_finish,(2,1),flag=(wx.ALIGN_LEFT))
    self.ztop_finish = wx.TextCtrl(panel_3D_finish,-1,'0')
    sizer_3D_finish.Add(self.ztop_finish,(2,2),flag=(wx.ALIGN_RIGHT))
    sizer_3D_finish.Add(wx.StaticText(panel_3D_finish,label='top z (mm)'),(2,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    sizer_3D_finish.Add(wx.StaticText(panel_3D_finish,label='bot intensity (0-1)'),(3,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.ibot_finish = wx.TextCtrl(panel_3D_finish,-1,'0')
    sizer_3D_finish.Add(self.ibot_finish,(3,1),flag=(wx.ALIGN_LEFT))
    self.zbot_finish = wx.TextCtrl(panel_3D_finish,-1,'')
    sizer_3D_finish.Add(self.zbot_finish,(3,2),flag=(wx.ALIGN_RIGHT))
    sizer_3D_finish.Add(wx.StaticText(panel_3D_finish,label='bot z (mm)'),(3,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    sizer_3D_finish.Add(wx.StaticText(panel_3D_finish,label='clearance length (mm)'),(4,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.clearance_length_finish = wx.TextCtrl(panel_3D_finish,-1,'0')
    sizer_3D_finish.Add(self.clearance_length_finish,(4,1),flag=(wx.ALIGN_LEFT))
    self.clearance_diameter_finish = wx.TextCtrl(panel_3D_finish,-1,'0')
    sizer_3D_finish.Add(self.clearance_diameter_finish,(4,2),flag=(wx.ALIGN_RIGHT))
    sizer_3D_finish.Add(wx.StaticText(panel_3D_finish,label='clearance diameter (mm)'),(4,3),flag=(wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL))
    #
    panel_3D_finish_4 = wx.Panel(panel_3D_finish)
    sizer_3D_finish_4 = wx.GridBagSizer(10,10)
    panel_3D_finish_4.SetSizer(sizer_3D_finish_4)
    sizer_3D_finish_4.Add(wx.StaticText(panel_3D_finish_4,label='direction:'),(0,0),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.xz_finish = wx.CheckBox(panel_3D_finish_4,-1,'xz',(10,10))
    self.xz_finish.SetValue(True)
    sizer_3D_finish_4.Add(self.xz_finish,(0,1),flag=wx.ALIGN_CENTER_HORIZONTAL)
    self.yz_finish = wx.CheckBox(panel_3D_finish_4,-1,'yz',(10,10))
    self.yz_finish.SetValue(True)
    sizer_3D_finish_4.Add(self.yz_finish,(0,2),flag=wx.ALIGN_CENTER_HORIZONTAL)
    sizer_3D_finish_4.Add(wx.StaticText(panel_3D_finish_4,label='type:'),(0,3),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.flat_end_finish = wx.RadioButton(panel_3D_finish_4,-1,'flat end',(10,10),style=wx.RB_GROUP)
    sizer_3D_finish_4.Add(self.flat_end_finish,(0,4),flag=wx.ALIGN_CENTER_HORIZONTAL)
    self.ball_end_finish = wx.RadioButton(panel_3D_finish_4,-1,'ball end',(10,10))
    #self.ball_end_finish.Enable(False)
    sizer_3D_finish_4.Add(self.ball_end_finish,(0,5),flag=wx.ALIGN_CENTER_HORIZONTAL)
    sizer_3D_finish.Add(panel_3D_finish_4,(5,0),span=(1,4),flag=(wx.ALIGN_CENTER_HORIZONTAL))
    #
    panel_3D_finish.Hide()
    self.type_panels.append(panel_3D_finish)
    #
    # fit
    #
    self.Fit()
Example #2
0
 def __init__(self,parent):
    self.parent = parent
    self.parent.stl_file = ''
    #
    # get stl info
    #
    def stl_info(name):
       #
       # construct command
       #
       temp_name = self.parent.tmp+'stl_info'
       command = 'stl_info '+'\"'+name+'\"'+' > '+'\"'+temp_name+'\"'
       os.system(command)
       output_file = open(temp_name,'r')
       output = output_file.read()
       output_file.close()
       print output
       if (string.find(output,'must be binary') != -1):
          sys.exit(-1)
       command = 'rm '+'\"'+temp_name+'\"'
       os.system(command)
       #
       # read limits
       #
       start = 6+string.find(output,'xmax:')
       space = string.find(output,' ',start)
       end = string.find(output,'ymin',space)-4
       self.parent.xmin = float(output[start:space])
       self.parent.xmax = float(output[1+space:end])
       start = 6+string.find(output,'ymax:')
       space = string.find(output,' ',start)
       end = string.find(output,'zmin',space)-4
       self.parent.ymin = float(output[start:space])
       self.parent.ymax = float(output[1+space:end])
       start = 6+string.find(output,'zmax:')
       space = string.find(output,' ',start)
       self.parent.zmin = float(output[start:space])
       self.parent.zmax = float(output[space+1:-1])
       #
       # move origin to top corner
       #
       #
       self.parent.xmax = self.parent.xmax - self.parent.xmin
       self.parent.xmin = 0
       self.parent.ymax = self.parent.ymax - self.parent.ymin
       self.parent.ymin = 0
       self.parent.zmin = self.parent.zmin - self.parent.zmax
       self.parent.zmax = 0
       #
       return output
    #
    # load file
    #
    def load_file(event):
       #
       # get file name
       #
       if (self.parent.basename == ""):
          return
       pos = string.find(self.parent.basename,".stl")
       if (pos == -1):
          pos = string.find(self.parent.basename,".STL")
          if (pos == -1):
             print 'stl_panel: oops -- must be .stl'
             sys.exit()
       self.parent.rootname = self.parent.basename[:pos]
       self.parent.stl_file = self.parent.filename
       #
       # get file info
       #
       info = stl_info(self.parent.filename)
       self.info.SetLabel(info)
       temp_name = self.parent.tmp+'stl.path'
       #
       # draw
       #
       if (self.path_viewer.view_type != "none"):
          units = 1.0
          resolution = 100
          command = 'stl_path '+'\"'+self.parent.stl_file+'\"'+' '+'\"'+temp_name+'\"'+' '+str(units)+' '+str(resolution)
          print command
          ret = os.system(command)
          if (ret == 0):
             self.path_viewer.draw(temp_name)
       #
       # fit
       #
       self.parent.Layout()
       self.parent.Fit()
    #
    # select file
    #
    def select_file(event):
       dialog = wx.FileDialog(self, "Choose a file", os.getcwd(), "", "*.stl;*.STL", wx.OPEN)
       if (dialog.ShowModal() == wx.ID_OK):
          self.parent.filename = dialog.GetPath()
          self.parent.basename = os.path.basename(self.parent.filename)
          load_file(0)
    #
    # panel
    #
    wx.Panel.__init__(self,parent)
    self.sizer = wx.GridBagSizer(10,10)
    self.SetSizer(self.sizer)
    #
    # label 
    #
    label = wx.StaticText(self,label='from: gif')
    bold_font = wx.Font(10,wx.DEFAULT,wx.NORMAL,wx.BOLD)
    label.SetFont(bold_font)
    self.sizer.Add(label,(0,0),flag=wx.ALIGN_CENTER_HORIZONTAL)
    #
    # image
    #
    self.path_viewer = path_panel(self)
    self.sizer.Add(self.path_viewer,(1,0),flag=wx.ALIGN_CENTER_HORIZONTAL)
    self.path_viewer.view_type = "segments"
    #
    # controls
    #
    load = wx.Button(self,label='load .stl')
    load.Bind(wx.EVT_BUTTON,select_file)
    self.sizer.Add(load,(2,0),flag=wx.ALIGN_CENTER_HORIZONTAL)
    #
    self.info = wx.StaticText(self,label="")
    self.sizer.Add(self.info,(3,0),flag=wx.ALIGN_CENTER_HORIZONTAL)
    #
    # file
    #
    load_file(0)
    #
    # fit
    #
    self.Fit()
Example #3
0
 def __init__(self,parent):
    self.parent = parent
    self.parent.zmin = 0
    self.parent.zmax = 0
    self.parent.units = 1
    #
    # make path
    #
    def make_path(event):
       if (self.parent.rootname == ''):
          return
       tmp_svg_file = self.parent.tmp+self.parent.rootname+'.svg'
       svg_file = open(tmp_svg_file,'w')
       svg_file.write(self.parent.svg_panel.text.GetValue())
       svg_file.close()
       self.parent.path_file = self.parent.tmp+self.parent.rootname+'.path'
       path_png = self.parent.tmp+self.parent.rootname+'.path.png'
       if (self.path_type.GetValue() == '3D'):
          scale = self.scale_3D.GetValue()
          points = self.points_3D.GetValue()
          resolution = self.resolution_3D.GetValue()
          zmin = self.zmin.GetValue()
          zmax = self.zmax.GetValue()
          command = 'svg_path '+'\"'+tmp_svg_file+'\"'+' '+'\"'+self.parent.path_file+'\"'+' '+scale+' '+points+' '+resolution+' '+zmin+' '+zmax
          print command
          os.system(command)
          temp_name = self.parent.tmp+'path_info'
          command = 'path_info '+'\"'+self.parent.path_file+'\"'+' > '+'\"'+temp_name+'\"'
          os.system(command)
          output_file = open(temp_name,'r')
          output = output_file.read()
          output_file.close()
          command = 'rm '+'\"'+temp_name+'\"'
          os.system(command)
          self.info_3D.SetLabel(output)
       elif (self.path_type.GetValue() == '2D'):
          scale = self.scale_2D.GetValue()
          points = self.points_2D.GetValue()
          resolution = self.resolution_2D.GetValue()
          command = 'svg_path '+'\"'+tmp_svg_file+'\"'+' '+'\"'+self.parent.path_file+'\"'+' '+scale+' '+points+' '+resolution
          print command
          os.system(command)
          temp_name = self.parent.tmp+'path_info'
          command = 'path_info '+'\"'+self.parent.path_file+'\"'+' > '+'\"'+temp_name+'\"'
          os.system(command)
          output_file = open(temp_name,'r')
          output = output_file.read()
          output_file.close()
          command = 'rm '+'\"'+temp_name+'\"'
          os.system(command)
          self.info_2D.SetLabel(output)
       self.path_viewer.draw(self.parent.path_file)
       self.parent.Layout()
       self.parent.Fit()
    #
    # panel
    #
    wx.Panel.__init__(self,parent)
    self.sizer = wx.GridBagSizer(10,10)
    self.SetSizer(self.sizer)
    #
    # label
    #
    label = wx.StaticText(self,label='to: path')
    bold_font = wx.Font(10,wx.DEFAULT,wx.NORMAL,wx.BOLD)
    label.SetFont(bold_font)
    self.sizer.Add(label,(0,0),flag=wx.ALIGN_CENTER_HORIZONTAL)
    #
    # image
    #
    self.path_viewer = path_panel(self)
    self.sizer.Add(self.path_viewer,(1,0),flag=wx.ALIGN_CENTER_HORIZONTAL)
    #
    # controls
    #
    make_panel = wx.Panel(self)
    make_sizer = wx.GridBagSizer(10,10)
    make_panel.SetSizer(make_sizer)
    make_button = wx.Button(make_panel,label='make .path')
    make_button.Bind(wx.EVT_BUTTON,make_path)
    make_sizer.Add(make_button,(0,0),flag=wx.ALIGN_CENTER_HORIZONTAL)
    make_sizer.Add(wx.StaticText(make_panel,label='type:'),(0,1),flag=(wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL))
    self.path_types = ["2D","3D"]
    self.path_type = wx.ComboBox(make_panel,size=(100,-1),value="2D",choices=self.path_types,style=wx.CB_READONLY)
    self.path_type.Bind(wx.EVT_COMBOBOX,self.path_type_handler)
    make_sizer.Add(self.path_type,(0,2),flag=wx.ALIGN_LEFT)
    self.sizer.Add(make_panel,(2,0),flag=(wx.ALIGN_CENTER_HORIZONTAL))
    #
    # 2D panel
    #
    panel_2D = wx.Panel(self)
    sizer_2D = wx.GridBagSizer(10,10)
    panel_2D.SetSizer(sizer_2D)
    #
    sizer_2D.Add(wx.StaticText(panel_2D,label='scale factor'),(0,1),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT))
    self.scale_2D = wx.TextCtrl(panel_2D,-1,'1.0')
    sizer_2D.Add(self.scale_2D,(0,2),flag=wx.ALIGN_LEFT)
    #
    sizer_2D.Add(wx.StaticText(panel_2D,label='curve points'),(1,0),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT))
    self.points_2D = wx.TextCtrl(panel_2D,-1,'10')
    sizer_2D.Add(self.points_2D,(1,1),flag=wx.ALIGN_LEFT)
    self.resolution_2D = wx.TextCtrl(panel_2D,-1,'10000')
    sizer_2D.Add(self.resolution_2D,(1,2),flag=wx.ALIGN_RIGHT)
    sizer_2D.Add(wx.StaticText(panel_2D,label='path resolution'),(1,3),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT))
    #
    self.info_2D = wx.StaticText(panel_2D,label="")
    sizer_2D.Add(self.info_2D,(2,0),span=(1,4),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL))
    #
    self.sizer.Add(panel_2D,(3,0),flag=(wx.ALIGN_CENTER_HORIZONTAL))
    self.type_panel = panel_2D
    self.type_panels = [panel_2D]
    #
    # 3D panel
    #
    panel_3D = wx.Panel(self)
    sizer_3D = wx.GridBagSizer(10,10)
    panel_3D.SetSizer(sizer_3D)
    #
    sizer_3D.Add(wx.StaticText(panel_3D,label='scale factor'),(0,1),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT))
    self.scale_3D = wx.TextCtrl(panel_3D,-1,'1.0')
    sizer_3D.Add(self.scale_3D,(0,2),flag=wx.ALIGN_LEFT)
    #
    sizer_3D.Add(wx.StaticText(panel_3D,label='curve points'),(1,0),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT))
    self.points_3D = wx.TextCtrl(panel_3D,-1,'10')
    sizer_3D.Add(self.points_3D,(1,1),flag=wx.ALIGN_LEFT)
    self.resolution_3D = wx.TextCtrl(panel_3D,-1,'10000')
    sizer_3D.Add(self.resolution_3D,(1,2),flag=wx.ALIGN_RIGHT)
    sizer_3D.Add(wx.StaticText(panel_3D,label='path resolution'),(1,3),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT))
    #
    sizer_3D.Add(wx.StaticText(panel_3D,label='min intensity z (mm)'),(2,0),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT))
    self.zmin = wx.TextCtrl(panel_3D,-1,'0')
    sizer_3D.Add(self.zmin,(2,1),flag=wx.ALIGN_LEFT)
    self.zmax = wx.TextCtrl(panel_3D,-1,'0')
    sizer_3D.Add(self.zmax,(2,2),flag=wx.ALIGN_RIGHT)
    sizer_3D.Add(wx.StaticText(panel_3D,label='max intensity z (mm)'),(2,3),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT))
    #
    self.info_3D = wx.StaticText(panel_3D,label="")
    sizer_3D.Add(self.info_3D,(3,0),span=(1,4),flag=(wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL))
    #
    panel_3D.Hide()
    self.type_panels.append(panel_3D)
    #
    # fit
    #
    self.Fit()
Example #4
0
    def __init__(self, parent):
        self.parent = parent
        self.parent.png_file = ""
        self.parent.zmin = ""
        self.parent.zmax = ""
        self.parent.units = 1
        #
        # make path
        #
        def make_path(event):
            if self.parent.png_file == "":
                print "png_path: oops -- must make .png first"
                return
            self.parent.path_file = self.parent.tmp + self.parent.rootname + ".path"
            path_png = self.parent.tmp + self.parent.rootname + ".path.png"
            selection = self.path_type.GetValue()
            if selection == "2D":
                diameter = self.diameter_2D.GetValue()
                number = self.number_2D.GetValue()
                overlap = self.overlap_2D.GetValue()
                error = self.error_2D.GetValue()
                intensity = self.intensity_2D.GetValue()
                command = (
                    "png_path "
                    + '"'
                    + self.parent.png_file
                    + '"'
                    + " "
                    + '"'
                    + self.parent.path_file
                    + '"'
                    + " "
                    + error
                    + " "
                    + diameter
                    + " "
                    + number
                    + " "
                    + overlap
                    + " "
                    + intensity
                )
            elif selection == "3D plane":
                diameter = self.diameter_plane.GetValue()
                number = self.number_plane.GetValue()
                overlap = self.overlap_plane.GetValue()
                error = self.error_plane.GetValue()
                intensity = self.intensity_plane.GetValue()
                z = self.z_plane.GetValue()
                command = (
                    "png_path "
                    + '"'
                    + self.parent.png_file
                    + '"'
                    + " "
                    + '"'
                    + self.parent.path_file
                    + '"'
                    + " "
                    + error
                    + " "
                    + diameter
                    + " "
                    + number
                    + " "
                    + overlap
                    + " "
                    + intensity
                    + " "
                    + intensity
                    + " "
                    + z
                )
            elif selection == "3D rough":
                diameter = self.diameter_rough.GetValue()
                number = self.number_rough.GetValue()
                overlap = self.overlap_rough.GetValue()
                error = self.error_rough.GetValue()
                itop = self.itop_rough.GetValue()
                ibot = self.ibot_rough.GetValue()
                ztop = self.ztop_rough.GetValue()
                zbot = self.zbot_rough.GetValue()
                zstep = self.zstep_rough.GetValue()
                command = (
                    "png_path "
                    + '"'
                    + self.parent.png_file
                    + '"'
                    + " "
                    + '"'
                    + self.parent.path_file
                    + '"'
                    + " "
                    + error
                    + " "
                    + diameter
                    + " "
                    + number
                    + " "
                    + overlap
                    + " "
                    + itop
                    + " "
                    + ibot
                    + " "
                    + ztop
                    + " "
                    + zbot
                    + " "
                    + zstep
                )
            elif selection == "3D finish":
                diameter = self.diameter_finish.GetValue()
                overlap = self.overlap_finish.GetValue()
                error = self.error_finish.GetValue()
                itop = self.itop_finish.GetValue()
                ibot = self.ibot_finish.GetValue()
                ztop = self.ztop_finish.GetValue()
                zbot = self.zbot_finish.GetValue()
                clearance_length = self.clearance_length_finish.GetValue()
                clearance_diameter = self.clearance_diameter_finish.GetValue()
                number = "0"
                zstep = "0"
                if self.xz_finish.GetValue():
                    xz = "1"
                else:
                    xz = "0"
                if self.yz_finish.GetValue():
                    yz = "1"
                else:
                    yz = "0"
                xy = "0"
                if self.flat_end_finish.GetValue():
                    tool_type = "f"
                elif self.ball_end_finish.GetValue():
                    tool_type = "b"
                command = (
                    "png_path "
                    + '"'
                    + self.parent.png_file
                    + '"'
                    + " "
                    + '"'
                    + self.parent.path_file
                    + '"'
                    + " "
                    + error
                    + " "
                    + diameter
                    + " "
                    + number
                    + " "
                    + overlap
                    + " "
                    + itop
                    + " "
                    + ibot
                    + " "
                    + ztop
                    + " "
                    + zbot
                    + " "
                    + zstep
                    + " "
                    + xz
                    + " "
                    + yz
                    + " "
                    + xy
                    + " "
                    + tool_type
                    + " "
                    + clearance_length
                    + " "
                    + clearance_diameter
                )
            print command
            ret = os.system(command)
            if ret == 0:
                self.path_viewer.draw(self.parent.path_file)
                # self.parent.Layout()
                # self.parent.Fit()

        #
        # panel
        #
        wx.Panel.__init__(self, parent)
        self.sizer = wx.GridBagSizer(10, 10)
        self.SetSizer(self.sizer)
        #
        # label
        #
        label = wx.StaticText(self, label="to: path")
        bold_font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)
        label.SetFont(bold_font)
        self.sizer.Add(label, (0, 0), flag=wx.ALIGN_CENTER_HORIZONTAL)
        #
        # image
        #
        self.path_viewer = path_panel(self)
        self.sizer.Add(self.path_viewer, (1, 0), flag=wx.ALIGN_CENTER_HORIZONTAL)
        #
        # controls
        #
        make_panel = wx.Panel(self)
        make_sizer = wx.GridBagSizer(10, 10)
        make_panel.SetSizer(make_sizer)
        make_button = wx.Button(make_panel, label="make .path")
        make_button.Bind(wx.EVT_BUTTON, make_path)
        make_sizer.Add(make_button, (0, 0), flag=wx.ALIGN_CENTER_HORIZONTAL)
        make_sizer.Add(
            wx.StaticText(make_panel, label="type:"), (0, 1), flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        )
        self.path_types = ["2D", "3D plane", "3D rough", "3D finish"]
        self.path_type = wx.ComboBox(
            make_panel, size=(100, -1), value="2D", choices=self.path_types, style=wx.CB_READONLY
        )
        self.parent.path_type = "2D"
        self.path_type.Bind(wx.EVT_COMBOBOX, self.path_type_handler)
        make_sizer.Add(self.path_type, (0, 2), flag=wx.ALIGN_LEFT)
        self.sizer.Add(make_panel, (2, 0), flag=(wx.ALIGN_CENTER_HORIZONTAL))
        #
        # 2D panel
        #
        panel_2D = wx.Panel(self)
        sizer_2D = wx.GridBagSizer(10, 10)
        panel_2D.SetSizer(sizer_2D)
        #
        sizer_2D.Add(
            wx.StaticText(panel_2D, label="diameter (mm)"), (0, 0), flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        )
        self.diameter_2D = wx.TextCtrl(panel_2D, -1, "0.25")
        sizer_2D.Add(self.diameter_2D, (0, 1), flag=(wx.ALIGN_LEFT))
        self.number_2D = wx.TextCtrl(panel_2D, -1, "1")
        sizer_2D.Add(self.number_2D, (0, 2), flag=(wx.ALIGN_RIGHT))
        sizer_2D.Add(
            wx.StaticText(panel_2D, label="offsets (-1 to fill)"),
            (0, 3),
            flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL),
        )
        #
        sizer_2D.Add(
            wx.StaticText(panel_2D, label="overlap (0-1)"), (1, 0), flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        )
        self.overlap_2D = wx.TextCtrl(panel_2D, -1, "0.5")
        sizer_2D.Add(self.overlap_2D, (1, 1), flag=(wx.ALIGN_RIGHT))
        self.error_2D = wx.TextCtrl(panel_2D, -1, "1.1")
        sizer_2D.Add(self.error_2D, (1, 2), flag=(wx.ALIGN_RIGHT))
        sizer_2D.Add(
            wx.StaticText(panel_2D, label="error (pixels)"), (1, 3), flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
        )
        #
        sizer_2D.Add(
            wx.StaticText(panel_2D, label="intensity (0-1)"), (2, 1), flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        )
        self.intensity_2D = wx.TextCtrl(panel_2D, -1, "0.5")
        sizer_2D.Add(self.intensity_2D, (2, 2), flag=(wx.ALIGN_RIGHT))
        #
        self.sizer.Add(panel_2D, (3, 0), flag=(wx.ALIGN_CENTER_HORIZONTAL))
        self.type_panel = panel_2D
        self.type_panels = [panel_2D]
        #
        # 3D plane panel
        #
        panel_3D_plane = wx.Panel(self)
        sizer_3D_plane = wx.GridBagSizer(10, 10)
        panel_3D_plane.SetSizer(sizer_3D_plane)
        #
        sizer_3D_plane.Add(
            wx.StaticText(panel_3D_plane, label="  diameter (mm)"),
            (0, 0),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.diameter_plane = wx.TextCtrl(panel_3D_plane, -1, "0.25")
        sizer_3D_plane.Add(self.diameter_plane, (0, 1), flag=(wx.ALIGN_LEFT))
        self.number_plane = wx.TextCtrl(panel_3D_plane, -1, "1")
        sizer_3D_plane.Add(self.number_plane, (0, 2), flag=(wx.ALIGN_RIGHT))
        sizer_3D_plane.Add(
            wx.StaticText(panel_3D_plane, label="offsets (-1 to fill)"),
            (0, 3),
            flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL),
        )
        #
        sizer_3D_plane.Add(
            wx.StaticText(panel_3D_plane, label="overlap (0-1)"),
            (1, 0),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.overlap_plane = wx.TextCtrl(panel_3D_plane, -1, "0.5")
        sizer_3D_plane.Add(self.overlap_plane, (1, 1), flag=(wx.ALIGN_LEFT))
        self.error_plane = wx.TextCtrl(panel_3D_plane, -1, "1.1")
        sizer_3D_plane.Add(self.error_plane, (1, 2), flag=(wx.ALIGN_RIGHT))
        sizer_3D_plane.Add(
            wx.StaticText(panel_3D_plane, label="error (pixels)"),
            (1, 3),
            flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL),
        )
        #
        sizer_3D_plane.Add(
            wx.StaticText(panel_3D_plane, label="intensity (0-1) "),
            (2, 0),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.intensity_plane = wx.TextCtrl(panel_3D_plane, -1, "0.5")
        sizer_3D_plane.Add(self.intensity_plane, (2, 1), flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL))
        self.z_plane = wx.TextCtrl(panel_3D_plane, -1, "0")
        sizer_3D_plane.Add(self.z_plane, (2, 2), flag=(wx.ALIGN_RIGHT))
        sizer_3D_plane.Add(
            wx.StaticText(panel_3D_plane, label="z (mm)"), (2, 3), flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
        )
        #
        panel_3D_plane.Hide()
        self.type_panels.append(panel_3D_plane)
        #
        # 3D rough panel
        #
        panel_3D_rough = wx.Panel(self)
        sizer_3D_rough = wx.GridBagSizer(10, 10)
        panel_3D_rough.SetSizer(sizer_3D_rough)
        #
        sizer_3D_rough.Add(
            wx.StaticText(panel_3D_rough, label="diameter (mm)"),
            (0, 0),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.diameter_rough = wx.TextCtrl(panel_3D_rough, -1, "0.25")
        sizer_3D_rough.Add(self.diameter_rough, (0, 1), flag=(wx.ALIGN_LEFT))
        self.number_rough = wx.TextCtrl(panel_3D_rough, -1, "-1")
        sizer_3D_rough.Add(self.number_rough, (0, 2), flag=(wx.ALIGN_RIGHT))
        sizer_3D_rough.Add(
            wx.StaticText(panel_3D_rough, label="offsets (-1 to fill)"),
            (0, 3),
            flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL),
        )
        #
        sizer_3D_rough.Add(
            wx.StaticText(panel_3D_rough, label="overlap (0-1)"),
            (1, 0),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.overlap_rough = wx.TextCtrl(panel_3D_rough, -1, "0.5")
        sizer_3D_rough.Add(self.overlap_rough, (1, 1), flag=(wx.ALIGN_LEFT))
        self.error_rough = wx.TextCtrl(panel_3D_rough, -1, "1.1")
        sizer_3D_rough.Add(self.error_rough, (1, 2), flag=(wx.ALIGN_RIGHT))
        sizer_3D_rough.Add(
            wx.StaticText(panel_3D_rough, label="error (pixels)"),
            (1, 3),
            flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL),
        )
        #
        sizer_3D_rough.Add(
            wx.StaticText(panel_3D_rough, label="top intensity (0-1)"),
            (2, 0),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.itop_rough = wx.TextCtrl(panel_3D_rough, -1, "1")
        sizer_3D_rough.Add(self.itop_rough, (2, 1), flag=(wx.ALIGN_LEFT))
        self.ztop_rough = wx.TextCtrl(panel_3D_rough, -1, "0")
        sizer_3D_rough.Add(self.ztop_rough, (2, 2), flag=(wx.ALIGN_RIGHT))
        sizer_3D_rough.Add(
            wx.StaticText(panel_3D_rough, label="top z (mm)"), (2, 3), flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
        )
        #
        sizer_3D_rough.Add(
            wx.StaticText(panel_3D_rough, label="bot intensity (0-1)"),
            (3, 0),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.ibot_rough = wx.TextCtrl(panel_3D_rough, -1, "0")
        sizer_3D_rough.Add(self.ibot_rough, (3, 1), flag=(wx.ALIGN_LEFT))
        self.zbot_rough = wx.TextCtrl(panel_3D_rough, -1, "")
        sizer_3D_rough.Add(self.zbot_rough, (3, 2), flag=(wx.ALIGN_RIGHT))
        sizer_3D_rough.Add(
            wx.StaticText(panel_3D_rough, label="bot z (mm)"), (3, 3), flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
        )
        #
        sizer_3D_rough.Add(
            wx.StaticText(panel_3D_rough, label="cut depth (mm)"),
            (4, 1),
            flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.zstep_rough = wx.TextCtrl(panel_3D_rough, -1, "1")
        sizer_3D_rough.Add(self.zstep_rough, (4, 2), flag=(wx.ALIGN_RIGHT))
        #
        panel_3D_rough.Hide()
        self.type_panels.append(panel_3D_rough)
        #
        # 3D finish panel
        #
        panel_3D_finish = wx.Panel(self)
        sizer_3D_finish = wx.GridBagSizer(10, 10)
        panel_3D_finish.SetSizer(sizer_3D_finish)
        #
        sizer_3D_finish.Add(
            wx.StaticText(panel_3D_finish, label="tool diameter (mm)"),
            (0, 1),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.diameter_finish = wx.TextCtrl(panel_3D_finish, -1, "0.25")
        sizer_3D_finish.Add(self.diameter_finish, (0, 2), flag=(wx.ALIGN_LEFT))
        #
        sizer_3D_finish.Add(
            wx.StaticText(panel_3D_finish, label="overlap (0-1)"),
            (1, 0),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.overlap_finish = wx.TextCtrl(panel_3D_finish, -1, "0.5")
        sizer_3D_finish.Add(self.overlap_finish, (1, 1), flag=(wx.ALIGN_LEFT))
        self.error_finish = wx.TextCtrl(panel_3D_finish, -1, "1.1")
        sizer_3D_finish.Add(self.error_finish, (1, 2), flag=(wx.ALIGN_RIGHT))
        sizer_3D_finish.Add(
            wx.StaticText(panel_3D_finish, label="error (pixels)"),
            (1, 3),
            flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL),
        )
        #
        sizer_3D_finish.Add(
            wx.StaticText(panel_3D_finish, label="top intensity (0-1)"),
            (2, 0),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.itop_finish = wx.TextCtrl(panel_3D_finish, -1, "1")
        sizer_3D_finish.Add(self.itop_finish, (2, 1), flag=(wx.ALIGN_LEFT))
        self.ztop_finish = wx.TextCtrl(panel_3D_finish, -1, "0")
        sizer_3D_finish.Add(self.ztop_finish, (2, 2), flag=(wx.ALIGN_RIGHT))
        sizer_3D_finish.Add(
            wx.StaticText(panel_3D_finish, label="top z (mm)"), (2, 3), flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
        )
        #
        sizer_3D_finish.Add(
            wx.StaticText(panel_3D_finish, label="bot intensity (0-1)"),
            (3, 0),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.ibot_finish = wx.TextCtrl(panel_3D_finish, -1, "0")
        sizer_3D_finish.Add(self.ibot_finish, (3, 1), flag=(wx.ALIGN_LEFT))
        self.zbot_finish = wx.TextCtrl(panel_3D_finish, -1, "")
        sizer_3D_finish.Add(self.zbot_finish, (3, 2), flag=(wx.ALIGN_RIGHT))
        sizer_3D_finish.Add(
            wx.StaticText(panel_3D_finish, label="bot z (mm)"), (3, 3), flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
        )
        #
        sizer_3D_finish.Add(
            wx.StaticText(panel_3D_finish, label="clearance length (mm)"),
            (4, 0),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.clearance_length_finish = wx.TextCtrl(panel_3D_finish, -1, "0")
        sizer_3D_finish.Add(self.clearance_length_finish, (4, 1), flag=(wx.ALIGN_LEFT))
        self.clearance_diameter_finish = wx.TextCtrl(panel_3D_finish, -1, "0")
        sizer_3D_finish.Add(self.clearance_diameter_finish, (4, 2), flag=(wx.ALIGN_RIGHT))
        sizer_3D_finish.Add(
            wx.StaticText(panel_3D_finish, label="clearance diameter (mm)"),
            (4, 3),
            flag=(wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL),
        )
        #
        panel_3D_finish_4 = wx.Panel(panel_3D_finish)
        sizer_3D_finish_4 = wx.GridBagSizer(10, 10)
        panel_3D_finish_4.SetSizer(sizer_3D_finish_4)
        sizer_3D_finish_4.Add(
            wx.StaticText(panel_3D_finish_4, label="direction:"),
            (0, 0),
            flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL),
        )
        self.xz_finish = wx.CheckBox(panel_3D_finish_4, -1, "xz", (10, 10))
        self.xz_finish.SetValue(True)
        sizer_3D_finish_4.Add(self.xz_finish, (0, 1), flag=wx.ALIGN_CENTER_HORIZONTAL)
        self.yz_finish = wx.CheckBox(panel_3D_finish_4, -1, "yz", (10, 10))
        self.yz_finish.SetValue(True)
        sizer_3D_finish_4.Add(self.yz_finish, (0, 2), flag=wx.ALIGN_CENTER_HORIZONTAL)
        sizer_3D_finish_4.Add(
            wx.StaticText(panel_3D_finish_4, label="type:"), (0, 3), flag=(wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        )
        self.flat_end_finish = wx.RadioButton(panel_3D_finish_4, -1, "flat end", (10, 10), style=wx.RB_GROUP)
        sizer_3D_finish_4.Add(self.flat_end_finish, (0, 4), flag=wx.ALIGN_CENTER_HORIZONTAL)
        self.ball_end_finish = wx.RadioButton(panel_3D_finish_4, -1, "ball end", (10, 10))
        # self.ball_end_finish.Enable(False)
        sizer_3D_finish_4.Add(self.ball_end_finish, (0, 5), flag=wx.ALIGN_CENTER_HORIZONTAL)
        sizer_3D_finish.Add(panel_3D_finish_4, (5, 0), span=(1, 4), flag=(wx.ALIGN_CENTER_HORIZONTAL))
        #
        panel_3D_finish.Hide()
        self.type_panels.append(panel_3D_finish)
        #
        # fit
        #
        self.Fit()