예제 #1
0
 def __init__(self,nb, app):
     self.nb = nb
     self.app = app
     self.frame = ttk.Frame(self.nb)
     self.levelCut = 30
     #self.frame2 = ttk.Frame(self.nb)
     self.nb.add(self.frame, text='   Material   ')
     r = 0
     tk.Button(self.frame, text = 'Upload saved material', command=self.app.uploadMaterial, width = 25).grid(column=0, row=r, pady=10)
     r += 1
     tk.Button(self.frame, text = 'Save current material', command=self.app.saveMaterial, width = 25).grid(column=0, row=r, pady=10)
     r += 1
     tk.Label(self.frame, text="Material (name)").grid(column=0, row=r, pady=(20,2) )
     r += 1
     tk.Entry(self.frame, textvariable=self.app.mName , width='50').grid(column=0, columnspan=2 , row=r , padx=1,pady=(1,10), sticky=W)
     r += 1
     tk.Label(self.frame, text="High speed for this material (mm/sec)").grid(column=0, row=r, pady=(20,2), sticky=W)
     #tk.Entry(self.frame, textvariable=self.app.mSpeedHigh , width='6').grid(column=1, row=r , padx=1,pady=(20,1), sticky=W)
     EntryFloat(self.frame, self.app.mSpeedHigh , 1 , 50, self.levelCut , width='6' ).grid(column=1, row=r , padx=1,pady=(20,1), sticky=W)
 
     r += 1
     tk.Label(self.frame, text="      Heating at high speed (%)").grid(column=0, row=r, pady=(10,2), sticky=W)
     #tk.Entry(self.frame, textvariable=self.app.mHeatSpHigh , width='6').grid(column=1, row=r , padx=1,pady=(10,1), sticky=W)
     EntryFloat(self.frame, self.app.mHeatSpHigh , 1 , 100, self.levelCut , width='6' ).grid(column=1, row=r , padx=1,pady=(10,1), sticky=W)
 
     r += 1
     tk.Label(self.frame, text="      Radiance at high speed (mm)").grid(column=0, row=r, pady=(10,2), sticky=W)
     #tk.Entry(self.frame, textvariable=self.app.mRadSpHigh , width='6').grid(column=1, row=r , padx=1,pady=(10,1), sticky=W)
     EntryFloat(self.frame, self.app.mRadSpHigh , 0.1 , 3, self.levelCut , width='6' ).grid(column=1, row=r , padx=1,pady=(10,1), sticky=W)
 
     r += 1
     tk.Label(self.frame, text="Low speed (mm/sec)").grid(column=0, row=r, pady=(20,2), sticky=W)
     #tk.Entry(self.frame, textvariable=self.app.mSpeedLow , width='6').grid(column=1, row=r , padx=1,pady=(20,1), sticky=W)
     EntryFloat(self.frame, self.app.mSpeedLow , 1 , 50, self.levelCut , width='6' ).grid(column=1, row=r , padx=1,pady=(20,1), sticky=W)
 
     r += 1
     tk.Label(self.frame, text="      Heating at low speed (%)").grid(column=0, row=r, pady=(10,2), sticky=W)
     #tk.Entry(self.frame, textvariable=self.app.mHeatSpLow , width='6').grid(column=1, row=r , padx=1,pady=(10,1), sticky=W)
     EntryFloat(self.frame, self.app.mHeatSpLow , 1 , 100, self.levelCut , width='6' ).grid(column=1, row=r , padx=1,pady=(10,1), sticky=W)
 
     r += 1
     tk.Label(self.frame, text="Half speed (= high/2) ").grid(column=0, row=r, pady=(20,2), sticky=W)
     tk.Entry(self.frame, textvariable=self.app.mSpeedHalf , width='6', state='disabled').grid(column=1, row=r , padx=1,pady=(20,1), sticky=W)
     
     r += 1
     tk.Label(self.frame, text="      Radiance at high speed / 2 (mm)").grid(column=0, row=r, pady=(20,2), sticky=W)
     #tk.Entry(self.frame, textvariable=self.app.mRadSpHalf , width='6').grid(column=1, row=r , padx=1,pady=(20,1), sticky=W)
     EntryFloat(self.frame, self.app.mRadSpHalf , 0.1 , 3, self.levelCut , width='6' ).grid(column=1, row=r , padx=1,pady=(20,1), sticky=W)
 
     r += 1
     tk.Label(self.frame, text="Usual cutting speed (mm/sec)").grid(column=0, row=r, pady=(20,1), sticky=W)
     EntryFloat(self.frame, self.app.vCut, 0.1, 10, self.levelCut , width='6').grid(column=1, row=r , padx=1,pady=(20,1), sticky=W)
예제 #2
0
    def __init__(self, nb, app):
        self.nb = nb
        self.app = app
        self.frame = ttk.Frame(self.nb)
        self.levelCut = 30
        #self.frame2 = ttk.Frame(self.nb)
        self.nb.add(self.frame, text='   Cut   ')
        self.lastGcodeFileName = ""
        r = 0
        self.cutBtn = tk.Button(self.frame,
                                text='Cut',
                                width=25,
                                command=self.cut,
                                state='disabled')
        self.cutBtn.grid(column=0, row=r, padx=1, pady=(20, 1))
        r += 1
        self.cancelBtn = tk.Button(self.frame,
                                   text='Cancel',
                                   command=self.app.tGrbl.resetGrbl,
                                   width=25,
                                   state='disabled')
        self.cancelBtn.grid(column=0,
                            columnspan=2,
                            row=r,
                            pady=(10, 1),
                            sticky=W)
        r += 1
        self.button2 = tk.Button(self.frame,
                                 text='Save Gcode',
                                 width=25,
                                 command=self.saveGcode)
        self.button2.grid(column=0, row=r, padx=1, pady=(20, 1))
        r += 1
        tk.Label(self.frame,
                 text="Usual cutting speed (mm/sec)").grid(column=0,
                                                           row=r,
                                                           pady=(20, 1),
                                                           sticky=W)
        EntryFloat(self.frame,
                   self.app.vCut,
                   0.1,
                   10,
                   self.levelCut,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(20, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Errors").grid(column=0,
                                                 row=r,
                                                 pady=(20, 1),
                                                 padx=(10, 1),
                                                 sticky=W)
        r += 1
        tk.Label(self.frame, textvariable=self.app.cutMsg,
                 height=10).grid(column=0,
                                 columnspan=2,
                                 row=r,
                                 pady=(1, 1),
                                 padx=(10, 1),
                                 sticky=NW)

        self.figRoot = Figure(figsize=(10, 3), dpi=100)
        self.axesRoot = self.figRoot.add_subplot(1, 1, 1)
        self.axesRoot.autoscale(enable=False)
        self.axesRoot.set_xlim(0, 1300)
        self.axesRoot.set_ybound(0, 400)
        self.axesRoot.set_title('Root')
        self.lineRoot1, = self.axesRoot.plot([], [])
        self.lineRoot2, = self.axesRoot.plot([], [])
        self.canvasRoot = FigureCanvasTkAgg(
            self.figRoot, master=self.frame)  # A tk.DrawingArea.
        self.canvasRoot.draw()
        self.canvasRoot.get_tk_widget().grid(column=2,
                                             row=0,
                                             rowspan=20,
                                             padx=10,
                                             pady=(10, 2))

        self.figTip = Figure(figsize=(10, 3), dpi=100)
        self.axesTip = self.figTip.add_subplot(1, 1, 1)
        self.axesTip.autoscale(enable=False)
        self.axesTip.set_xlim(0, 1300)
        self.axesTip.set_ybound(0, 400)
        self.axesTip.set_title('Tip')
        self.lineTip1, = self.axesTip.plot([], [])
        self.lineTip2, = self.axesTip.plot([], [])
        self.canvasTip = FigureCanvasTkAgg(
            self.figTip, master=self.frame)  # A tk.DrawingArea.
        self.canvasTip.draw()
        self.canvasTip.get_tk_widget().grid(column=2,
                                            row=20,
                                            rowspan=20,
                                            padx=10,
                                            pady=(10, 2))
예제 #3
0
    def __init__(self,nb, app , queueCmd):
        self.nb = nb
        self.app = app
        self.queueCmd = queueCmd
        self.frame = ttk.Frame(self.nb)
        self.levelGuillotine = 40
        #self.frame2 = ttk.Frame(self.nb)
        self.nb.add(self.frame, text='   Guillotine & Move   ')
        #self.t_frame= ttk.Frame(self.frame, highlightbackground="black" , highlightthickness=1)
        self.t_frame= ttk.Frame(self.frame, relief="groove",padding=10)
        self.l_frame= ttk.Frame(self.frame, relief="groove",padding=10)
        
        self.r_frame= ttk.Frame(self.frame, relief="groove",padding=10)
        self.m_frame= ttk.Frame(self.frame, relief="groove",padding=10)
        #self.t_frame.pack(side = TOP)
        self.l_frame.pack(side = LEFT , fill= Y)
        self.r_frame.pack(side = RIGHT , fill= Y)
        self.t_frame.pack(side = TOP)        
        self.m_frame.pack(side = TOP)
        r = 0
        tk.Label(self.l_frame, text="Guillotine",font=("Helvetica", 18)).grid(column=0, row=r, pady=(1,1))
        
        r += 1
        tk.Label(self.l_frame, text="Cutting speed (mm/sec)").grid(column=0, row=r, pady=(20,1), sticky=E)
        EntryFloat(self.l_frame, self.app.gCuttingSpeed , 0.1 , 10, self.levelGuillotine , width='6' ).grid(column=1, row=r , padx=1,pady=(20,1), sticky=W)
        
        r += 1
        tk.Label(self.l_frame, text="Apply calculated heating").grid(column=0, row=r, pady=(20,1), sticky=E)
        tk.Checkbutton(self.l_frame, variable=self.app.gApplyCalculatedHeating , text='' ,
            command=self.updateGuillotineHeating).grid(column=1, row=r , padx=1,pady=(20,1), sticky=W )
        r += 1
        tk.Label(self.l_frame, text="Heating (%)").grid(column=0, row=r, pady=(1,1), sticky=E)
        self.gHeatingBox = EntryFloat(self.l_frame, self.app.gHeating , 0.1 , 100, self.levelGuillotine , width='6' )
        self.gHeatingBox.grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.l_frame, text="Type of guillotine").grid(column=0, row=r, pady=(20,1), sticky=W)
        r += 1
        tk.Radiobutton(self.l_frame, text="Vertical", variable=self.app.gType, value="Vertical",
            command=self.changedGType).grid(column=0, row=r, pady=(1,1), sticky=W)
        self.gVDistBox = EntryFloat(self.l_frame, self.app.gVDist , -500 , 500, self.levelGuillotine , width='6' )
        self.gVDistBox.grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        
        r += 1
        tk.Radiobutton(self.l_frame, text="Horizontal", variable=self.app.gType, value="Horizontal",
            command=self.changedGType).grid(column=0, row=r, pady=(1,1), sticky=W)
        self.gHDistBox = EntryFloat(self.l_frame, self.app.gHDist , -500 , 500, self.levelGuillotine , width='6' , state='disabled' )
        self.gHDistBox.grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)

        r += 1
        tk.Radiobutton(self.l_frame, text="Inclined", variable=self.app.gType, value="Inclined",
            command=self.changedGType).grid(column=0, row=r, pady=(1,1), sticky=W)
        
        r += 1
        tk.Label(self.l_frame, text="Cutting while").grid(column=0, row=r, pady=(20,1), sticky=W)
        r += 1
        tk.Radiobutton(self.l_frame, text="Going forward AND back", variable=self.app.gCuttingWhile, value="Both").grid(column=0, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Radiobutton(self.l_frame, text="Only going forward", variable=self.app.gCuttingWhile, value="Forward").grid(column=0, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Radiobutton(self.l_frame, text="Only going back", variable=self.app.gCuttingWhile, value="Back").grid(column=0, row=r, pady=(1,1), sticky=W)
        
        r += 1
        self.goForwardBtn = tk.Button(self.l_frame, text = 'Go forward', command=self.goForward, width = 25 , state='disabled')
        self.goForwardBtn.grid(column=0, columnspan=2 , row=r , padx=(10,10),pady=(10,1), sticky=W)
        r += 1
        self.goBackBtn = tk.Button(self.l_frame, text = 'Go back', command=self.goBackward, width = 25, state='disabled' )
        self.goBackBtn.grid(column=0, columnspan=2, row=r , padx=(10,10),pady=(10,1), sticky=W)
        r += 1
        self.cancelBtn = tk.Button(self.l_frame, text = 'Cancel', command=self.app.tGrbl.resetGrbl, width = 25, state='disabled' )
        self.cancelBtn.grid(column=0, columnspan=2, row=r , padx=(10,10),pady=(10,1), sticky=W)
        
        r=0
        tk.Label(self.t_frame, text="Grbl status").grid(column=3, row=r, pady=(1,1))
        tk.Label(self.t_frame, text="Horiz. left").grid(column=4, row=r, pady=(1,1))
        tk.Label(self.t_frame, text="Vertical left").grid(column=5, row=r, pady=(1,1))
        tk.Label(self.t_frame, text="Horiz. right").grid(column=6, row=r, pady=(1,1))
        tk.Label(self.t_frame, text="Vertical right").grid(column=7, row=r, pady=(1,1))
        tk.Label(self.t_frame, text="Speed").grid(column=8, row=r, pady=(1,1))
        tk.Label(self.t_frame, text="Heating").grid(column=9, row=r, pady=(1,1))
        r += 1
        grblStatusBox = tk.Entry(self.t_frame, textvariable=self.app.grblStatus , width='20',state='disabled' )
        grblStatusBox.grid(column=3, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.t_frame, textvariable=self.app.grblXG , width='8',state='disabled' ).grid(column=4, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.t_frame, textvariable=self.app.grblYG , width='8',state='disabled' ).grid(column=5, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.t_frame, textvariable=self.app.grblXD , width='8',state='disabled' ).grid(column=6, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.t_frame, textvariable=self.app.grblYD , width='8',state='disabled' ).grid(column=7, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.t_frame, textvariable=self.app.grblF , width='8',state='disabled' ).grid(column=8, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.t_frame, textvariable=self.app.grblS , width='8',state='disabled' ).grid(column=9, row=r , padx=1,pady=(1,1), sticky=W)
        r += 1
        #self.msgText = ""
        self.msgBox = tkst.ScrolledText(self.t_frame,  width=80, height=4, wrap=tk.WORD)
        self.msgBox.grid(column=0, row=r , columnspan=9, padx=(1,1),pady=(10,10), sticky=W)
             
        r += 1
        self.connectBtn = tk.Button(self.t_frame, text = 'Connect to Grbl', command=self.connect, width = 25 )
        self.connectBtn.grid(column=3, row=r , columnspan=3, padx=(1,1),pady=(10,10), sticky=W)
        self.disconnectBtn = tk.Button(self.t_frame, text = 'Disconnect from Grbl', command=self.disconnect, width = 25 , state='disabled' )
        self.disconnectBtn.grid(column=6, row=r , columnspan=3, padx=(1,1),pady=(10,10), sticky=W)
            
        r = 0
        self.resetBtn = tk.Button(self.r_frame, text = 'Reset Grbl', command=self.app.tGrbl.resetGrbl,width = 25 , state='disabled' )
        self.resetBtn.grid(column=2, row=r , padx=(10,10),pady=(20,1), sticky=W)
        r += 1
        self.unlockBtn = tk.Button(self.r_frame, text = 'Unlock Grbl', command=self.app.tGrbl.unlockGrbl, width = 25, state='disabled' )
        self.unlockBtn.grid(column=2, row=r , padx=(10,10),pady=(20,1), sticky=W)
        r += 1
        self.homeBtn = tk.Button(self.r_frame, text = 'Home', command=self.app.tGrbl.homeGrbl, width = 25, state='disabled' )
        self.homeBtn.grid(column=2, row=r , padx=(10,10),pady=(20,1), sticky=W)
        r += 1
        self.setBtn = tk.Button(self.r_frame, text = 'Set position', command=self.app.tGrbl.setPosGrbl, width = 25, state='disabled' )
        self.setBtn.grid(column=2, row=r , padx=(10,10),pady=(40,1), sticky=W)
        r += 1
        self.gotoBtn = tk.Button(self.r_frame, text = 'Go to position', command=self.app.tGrbl.goToPosGrbl, width = 25, state='disabled' ) 
        self.gotoBtn.grid(column=2, row=r , padx=(10,10),pady=(20,1), sticky=W)
        r += 1
        self.startHeatingBtn = tk.Button(self.r_frame, text = 'Start heating', command=self.startHeat, width = 25, state='disabled' )
        self.startHeatingBtn.grid(column=2, row=r , padx=(10,10),pady=(40,1), sticky=W)
        r += 1
        self.stopHeatingBtn = tk.Button(self.r_frame, text = 'Stop heating', command=self.stopHeat, width = 25, state='disabled' )
        self.stopHeatingBtn.grid(column=2, row=r , padx=(10,10),pady=(20,1), sticky=W)

        r=0
        tk.Label(self.m_frame, text="Move",font=("Helvetica", 18)).grid(column=0, row=r, columnspan= 3, pady=(20,1))
        r += 1
        self.moveUpBtn = tk.Button(self.m_frame, text = 'Up', command=self.moveUp, width = 15, state='disabled' )
        self.moveUpBtn.grid(column=1, row=r , padx=(10,10),pady=(20,1))
        r += 1
        self.moveBackBtn = tk.Button(self.m_frame, text = 'Back', command=self.moveBack, width = 15, state='disabled' )
        self.moveBackBtn.grid(column=0, row=r , padx=(10,10),pady=(20,1))
        EntryFloat(self.m_frame, self.app.gMoveDist , 0.1 , 500, self.levelGuillotine , width='6' ).grid(column=1, row=r , padx=1,pady=(20,1))
        self.moveForwardBtn = tk.Button(self.m_frame, text = 'Forward', command=self.moveForward, width = 15, state='disabled' )
        self.moveForwardBtn.grid(column=2, row=r , padx=(10,10),pady=(20,1))
        r += 1
        self.moveDownBtn = tk.Button(self.m_frame, text = 'Down', command=self.moveDown, width = 15, state='disabled' )
        self.moveDownBtn.grid(column=1, row=r , padx=(10,10),pady=(20,1))
        r += 1
        tk.Radiobutton(self.m_frame, text="Left axis", variable=self.app.gMoveAxis, value="Left").grid(column=0, row=r, pady=(20,1))
        tk.Radiobutton(self.m_frame, text="Both axis", variable=self.app.gMoveAxis, value="Both").grid(column=1, row=r, pady=(20,1))
        tk.Radiobutton(self.m_frame, text="Right axis", variable=self.app.gMoveAxis, value="Right").grid(column=2, row=r, pady=(20,1))
예제 #4
0
class Guillotine:
    def __init__(self,nb, app , queueCmd):
        self.nb = nb
        self.app = app
        self.queueCmd = queueCmd
        self.frame = ttk.Frame(self.nb)
        self.levelGuillotine = 40
        #self.frame2 = ttk.Frame(self.nb)
        self.nb.add(self.frame, text='   Guillotine & Move   ')
        #self.t_frame= ttk.Frame(self.frame, highlightbackground="black" , highlightthickness=1)
        self.t_frame= ttk.Frame(self.frame, relief="groove",padding=10)
        self.l_frame= ttk.Frame(self.frame, relief="groove",padding=10)
        
        self.r_frame= ttk.Frame(self.frame, relief="groove",padding=10)
        self.m_frame= ttk.Frame(self.frame, relief="groove",padding=10)
        #self.t_frame.pack(side = TOP)
        self.l_frame.pack(side = LEFT , fill= Y)
        self.r_frame.pack(side = RIGHT , fill= Y)
        self.t_frame.pack(side = TOP)        
        self.m_frame.pack(side = TOP)
        r = 0
        tk.Label(self.l_frame, text="Guillotine",font=("Helvetica", 18)).grid(column=0, row=r, pady=(1,1))
        
        r += 1
        tk.Label(self.l_frame, text="Cutting speed (mm/sec)").grid(column=0, row=r, pady=(20,1), sticky=E)
        EntryFloat(self.l_frame, self.app.gCuttingSpeed , 0.1 , 10, self.levelGuillotine , width='6' ).grid(column=1, row=r , padx=1,pady=(20,1), sticky=W)
        
        r += 1
        tk.Label(self.l_frame, text="Apply calculated heating").grid(column=0, row=r, pady=(20,1), sticky=E)
        tk.Checkbutton(self.l_frame, variable=self.app.gApplyCalculatedHeating , text='' ,
            command=self.updateGuillotineHeating).grid(column=1, row=r , padx=1,pady=(20,1), sticky=W )
        r += 1
        tk.Label(self.l_frame, text="Heating (%)").grid(column=0, row=r, pady=(1,1), sticky=E)
        self.gHeatingBox = EntryFloat(self.l_frame, self.app.gHeating , 0.1 , 100, self.levelGuillotine , width='6' )
        self.gHeatingBox.grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.l_frame, text="Type of guillotine").grid(column=0, row=r, pady=(20,1), sticky=W)
        r += 1
        tk.Radiobutton(self.l_frame, text="Vertical", variable=self.app.gType, value="Vertical",
            command=self.changedGType).grid(column=0, row=r, pady=(1,1), sticky=W)
        self.gVDistBox = EntryFloat(self.l_frame, self.app.gVDist , -500 , 500, self.levelGuillotine , width='6' )
        self.gVDistBox.grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        
        r += 1
        tk.Radiobutton(self.l_frame, text="Horizontal", variable=self.app.gType, value="Horizontal",
            command=self.changedGType).grid(column=0, row=r, pady=(1,1), sticky=W)
        self.gHDistBox = EntryFloat(self.l_frame, self.app.gHDist , -500 , 500, self.levelGuillotine , width='6' , state='disabled' )
        self.gHDistBox.grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)

        r += 1
        tk.Radiobutton(self.l_frame, text="Inclined", variable=self.app.gType, value="Inclined",
            command=self.changedGType).grid(column=0, row=r, pady=(1,1), sticky=W)
        
        r += 1
        tk.Label(self.l_frame, text="Cutting while").grid(column=0, row=r, pady=(20,1), sticky=W)
        r += 1
        tk.Radiobutton(self.l_frame, text="Going forward AND back", variable=self.app.gCuttingWhile, value="Both").grid(column=0, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Radiobutton(self.l_frame, text="Only going forward", variable=self.app.gCuttingWhile, value="Forward").grid(column=0, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Radiobutton(self.l_frame, text="Only going back", variable=self.app.gCuttingWhile, value="Back").grid(column=0, row=r, pady=(1,1), sticky=W)
        
        r += 1
        self.goForwardBtn = tk.Button(self.l_frame, text = 'Go forward', command=self.goForward, width = 25 , state='disabled')
        self.goForwardBtn.grid(column=0, columnspan=2 , row=r , padx=(10,10),pady=(10,1), sticky=W)
        r += 1
        self.goBackBtn = tk.Button(self.l_frame, text = 'Go back', command=self.goBackward, width = 25, state='disabled' )
        self.goBackBtn.grid(column=0, columnspan=2, row=r , padx=(10,10),pady=(10,1), sticky=W)
        r += 1
        self.cancelBtn = tk.Button(self.l_frame, text = 'Cancel', command=self.app.tGrbl.resetGrbl, width = 25, state='disabled' )
        self.cancelBtn.grid(column=0, columnspan=2, row=r , padx=(10,10),pady=(10,1), sticky=W)
        
        r=0
        tk.Label(self.t_frame, text="Grbl status").grid(column=3, row=r, pady=(1,1))
        tk.Label(self.t_frame, text="Horiz. left").grid(column=4, row=r, pady=(1,1))
        tk.Label(self.t_frame, text="Vertical left").grid(column=5, row=r, pady=(1,1))
        tk.Label(self.t_frame, text="Horiz. right").grid(column=6, row=r, pady=(1,1))
        tk.Label(self.t_frame, text="Vertical right").grid(column=7, row=r, pady=(1,1))
        tk.Label(self.t_frame, text="Speed").grid(column=8, row=r, pady=(1,1))
        tk.Label(self.t_frame, text="Heating").grid(column=9, row=r, pady=(1,1))
        r += 1
        grblStatusBox = tk.Entry(self.t_frame, textvariable=self.app.grblStatus , width='20',state='disabled' )
        grblStatusBox.grid(column=3, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.t_frame, textvariable=self.app.grblXG , width='8',state='disabled' ).grid(column=4, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.t_frame, textvariable=self.app.grblYG , width='8',state='disabled' ).grid(column=5, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.t_frame, textvariable=self.app.grblXD , width='8',state='disabled' ).grid(column=6, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.t_frame, textvariable=self.app.grblYD , width='8',state='disabled' ).grid(column=7, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.t_frame, textvariable=self.app.grblF , width='8',state='disabled' ).grid(column=8, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.t_frame, textvariable=self.app.grblS , width='8',state='disabled' ).grid(column=9, row=r , padx=1,pady=(1,1), sticky=W)
        r += 1
        #self.msgText = ""
        self.msgBox = tkst.ScrolledText(self.t_frame,  width=80, height=4, wrap=tk.WORD)
        self.msgBox.grid(column=0, row=r , columnspan=9, padx=(1,1),pady=(10,10), sticky=W)
             
        r += 1
        self.connectBtn = tk.Button(self.t_frame, text = 'Connect to Grbl', command=self.connect, width = 25 )
        self.connectBtn.grid(column=3, row=r , columnspan=3, padx=(1,1),pady=(10,10), sticky=W)
        self.disconnectBtn = tk.Button(self.t_frame, text = 'Disconnect from Grbl', command=self.disconnect, width = 25 , state='disabled' )
        self.disconnectBtn.grid(column=6, row=r , columnspan=3, padx=(1,1),pady=(10,10), sticky=W)
            
        r = 0
        self.resetBtn = tk.Button(self.r_frame, text = 'Reset Grbl', command=self.app.tGrbl.resetGrbl,width = 25 , state='disabled' )
        self.resetBtn.grid(column=2, row=r , padx=(10,10),pady=(20,1), sticky=W)
        r += 1
        self.unlockBtn = tk.Button(self.r_frame, text = 'Unlock Grbl', command=self.app.tGrbl.unlockGrbl, width = 25, state='disabled' )
        self.unlockBtn.grid(column=2, row=r , padx=(10,10),pady=(20,1), sticky=W)
        r += 1
        self.homeBtn = tk.Button(self.r_frame, text = 'Home', command=self.app.tGrbl.homeGrbl, width = 25, state='disabled' )
        self.homeBtn.grid(column=2, row=r , padx=(10,10),pady=(20,1), sticky=W)
        r += 1
        self.setBtn = tk.Button(self.r_frame, text = 'Set position', command=self.app.tGrbl.setPosGrbl, width = 25, state='disabled' )
        self.setBtn.grid(column=2, row=r , padx=(10,10),pady=(40,1), sticky=W)
        r += 1
        self.gotoBtn = tk.Button(self.r_frame, text = 'Go to position', command=self.app.tGrbl.goToPosGrbl, width = 25, state='disabled' ) 
        self.gotoBtn.grid(column=2, row=r , padx=(10,10),pady=(20,1), sticky=W)
        r += 1
        self.startHeatingBtn = tk.Button(self.r_frame, text = 'Start heating', command=self.startHeat, width = 25, state='disabled' )
        self.startHeatingBtn.grid(column=2, row=r , padx=(10,10),pady=(40,1), sticky=W)
        r += 1
        self.stopHeatingBtn = tk.Button(self.r_frame, text = 'Stop heating', command=self.stopHeat, width = 25, state='disabled' )
        self.stopHeatingBtn.grid(column=2, row=r , padx=(10,10),pady=(20,1), sticky=W)

        r=0
        tk.Label(self.m_frame, text="Move",font=("Helvetica", 18)).grid(column=0, row=r, columnspan= 3, pady=(20,1))
        r += 1
        self.moveUpBtn = tk.Button(self.m_frame, text = 'Up', command=self.moveUp, width = 15, state='disabled' )
        self.moveUpBtn.grid(column=1, row=r , padx=(10,10),pady=(20,1))
        r += 1
        self.moveBackBtn = tk.Button(self.m_frame, text = 'Back', command=self.moveBack, width = 15, state='disabled' )
        self.moveBackBtn.grid(column=0, row=r , padx=(10,10),pady=(20,1))
        EntryFloat(self.m_frame, self.app.gMoveDist , 0.1 , 500, self.levelGuillotine , width='6' ).grid(column=1, row=r , padx=1,pady=(20,1))
        self.moveForwardBtn = tk.Button(self.m_frame, text = 'Forward', command=self.moveForward, width = 15, state='disabled' )
        self.moveForwardBtn.grid(column=2, row=r , padx=(10,10),pady=(20,1))
        r += 1
        self.moveDownBtn = tk.Button(self.m_frame, text = 'Down', command=self.moveDown, width = 15, state='disabled' )
        self.moveDownBtn.grid(column=1, row=r , padx=(10,10),pady=(20,1))
        r += 1
        tk.Radiobutton(self.m_frame, text="Left axis", variable=self.app.gMoveAxis, value="Left").grid(column=0, row=r, pady=(20,1))
        tk.Radiobutton(self.m_frame, text="Both axis", variable=self.app.gMoveAxis, value="Both").grid(column=1, row=r, pady=(20,1))
        tk.Radiobutton(self.m_frame, text="Right axis", variable=self.app.gMoveAxis, value="Right").grid(column=2, row=r, pady=(20,1))
        
    
    def changedGType(self):
        if self.app.gType.get() == "Vertical":
            self.gVDistBox['state'] = 'normal'
            self.gHDistBox['state'] = 'disabled'
        elif self.app.gType.get() == "Horizontal":
            self.gVDistBox['state'] = 'disabled'
            self.gHDistBox['state'] = 'normal'
        else:
            self.gVDistBox['state'] = 'normal'
            self.gHDistBox['state'] = 'normal'

    def updateGuillotineHeating(self):
        #if box is checked, calculate heating based on speed and materail and disable the heating box
        # else keep the value but limit it depending on table parameter and set heating box state on normal
        if self.app.gApplyCalculatedHeating.get():
            self.gHeatingBox['validate']='none' #disable focusout while updating
            self.app.gHeating.set(self.calculateHeating(self.app.gCuttingSpeed.get()) )
            self.gHeatingBox['validate']='focusout' #enable focusout after updating
            self.gHeatingBox['state']= 'disabled'
        else:
            self.gHeatingBox['state']= 'normal'    

    def calculateHeating(self, speed):
        x1 = self.app.mSpeedLow.get()
        x2 = self.app.mSpeedHigh.get()
        y1 = self.app.mHeatSpLow.get()
        y2 = self.app.mHeatSpHigh.get()
        heat = 0
        
        if (x2-x1) != 0:
            heat = y1 + (y2-y1)/(x2-x1)*(speed - x1) 
        #print(x1, x2, y1 ,y2 , heat)
        if heat < 1:
            heat =1
        if heat > self.app.tHeatingMax.get():
           heat = self.app.tHeatingMax.get()     
        return heat

    def calculateMove(self , factor):
        axis = self.app.gCodeLetters.get()
        if self.app.gType.get() == "Vertical":
            move = axis[1] + str(factor * self.app.gVDist.get()) + axis[3] + str(factor * self.app.gVDist.get()) 
        elif  self.app.gType.get() == "Horizontal":
            move = axis[0] + str(factor * self.app.gHDist.get()) + axis[2] + str(factor * self.app.gHDist.get()) 
        else:
            move = axis[1] + str(factor * self.app.gVDist.get()) + axis[0] + str(factor * self.app.gHDist.get()) + (
                axis[3] + str(factor * self.app.gVDist.get()) + axis[2] + str(factor * self.app.gHDist.get()) )
        return move
    
    def goForward(self):
        command = ["G21" , "G91", "G94"]  # mm incremental normal feed rate
        if self.app.gCuttingWhile.get() == "Forward" or self.app.gCuttingWhile.get() == "Both":
            command.append("M3")
            command.append("S" + str( int(self.app.gHeating.get()) ) )
            command.append( "G04P" + str(self.app.tPreHeat.get() ) ) 
            command.append("F" +str(60 * self.app.gCuttingSpeed.get() ))
            command.append( "G01")
        else:
            command.append( "G00")     
        command.append( self.calculateMove(1))
        if self.app.gCuttingWhile.get() == "Forward" or self.app.gCuttingWhile.get() == "Both":
            command.append( "G04P" + str(self.app.tPostHeat.get() ) ) 
            command.append("M5")
        print("\n".join(command))
        self.app.tGrbl.stream("\n".join(command))
        
    def goBackward(self):
        command = ["G21" , "G91", "G94"]  # mm incremental normal feed rate
        if self.app.gCuttingWhile.get() == "Back" or self.app.gCuttingWhile.get() == "Both":
            command.append("M3")
            command.append("S" + str( int(self.app.gHeating.get()) ) )
            command.append( "G04P" + str(self.app.tPreHeat.get() ) ) 
            command.append("F"+str(60 * self.app.gCuttingSpeed.get() ))
            command.append( "G01")
        else:
            command.append( "G00")     
        command.append( self.calculateMove(-1))
        if self.app.gCuttingWhile.get() == "Back" or self.app.gCuttingWhile.get() == "Both":
            command.append( "G04P" + str(self.app.tPostHeat.get() ) ) 
            command.append("M5")
        print("\n".join(command))
        self.app.tGrbl.stream("\n".join(command))

    def startHeat(self):
        command = ["S" + str( int(self.app.gHeating.get()) )  , "M3"] 
        self.app.tGrbl.stream("\n".join(command))

    def stopHeat(self):
        command = ["S0" ,"M5"] 
        self.app.tGrbl.stream("\n".join(command))
        
    def moveUp(self):
        self.move("Up")

    def moveDown(self):
        self.move("Down")

    def moveForward(self):
        self.move("Forward")

    def moveBack(self):
        self.move("Back")

    def move(self, dir):
        command = ["G21" , "G91" , "G94"]  # mm incremental normal feed rate
        axis = self.app.gCodeLetters.get()
        axisIdx = 0
        dirPos = 1
        if dir == "Up":
            axisIdx = 1
        elif dir == "Down":
            axisIdx = 1
            dirPos = -1
        elif dir == "Back":
            dirPos = -1
        if self.app.gMoveAxis.get() == "Left":
            command.append("G00 "+ axis[axisIdx]+ str(dirPos * self.app.gMoveDist.get() ) )
        elif self.app.gMoveAxis.get() == "Right":
            command.append("G00 "+ axis[axisIdx+2]+ str(dirPos * self.app.gMoveDist.get() ) )
        else:
            command.append("G00 "+ axis[axisIdx]+ str(dirPos * self.app.gMoveDist.get() ) +
                axis[axisIdx+2]+ str(dirPos * self.app.gMoveDist.get() ) )
        print("\n".join(command))
        self.app.tGrbl.stream("\n".join(command))
        

    def connect(self):
        self.queueCmd.put("Connect") 
    
    
    def disconnect(self):
        self.queueCmd.put("Disconnect")
        
    
    def updateBtnState(self):
        grblStatus= self.app.grblStatus.get()
        if grblStatus == "Not connected" or grblStatus == "Connection lost":
            state = 'disabled'
            oppositeState = 'normal'
        else:
            state = 'normal'
            oppositeState = 'disabled'
        self.goForwardBtn['state'] = state
        self.goBackBtn['state'] = state
        self.cancelBtn['state'] = state
        self.connectBtn['state'] = oppositeState
        self.disconnectBtn['state'] = state
        self.resetBtn['state'] = state
        self.unlockBtn['state'] = state
        self.homeBtn['state'] = state
        self.setBtn['state'] = state
        self.gotoBtn['state'] = state
        self.startHeatingBtn['state'] = state
        self.stopHeatingBtn['state'] = state
        self.moveUpBtn['state'] = state
        self.moveBackBtn['state'] = state
        self.moveForwardBtn['state'] = state
        self.moveDownBtn['state'] = state

        self.app.tCut.cutBtn['state'] = state
        self.app.tCut.cancelBtn['state'] = state
예제 #5
0
    def __init__(self, nb, app):
        self.nb = nb
        self.app = app
        self.frame = ttk.Frame(self.nb)
        self.levelCut = 30
        self.nb.add(self.frame, text='   Cut   ')
        self.lastGcodeFileName = ""
        #self.l_frame= ttk.Frame(self.frame, relief="groove",padding=10)
        #self.r_frame= ttk.Frame(self.frame, relief="groove",padding=10)

        self.l_frame = ttk.Frame(self.frame)
        self.r_frame = ttk.Frame(self.frame)
        self.l_frame.pack(side=LEFT, fill=Y)
        self.r_frame.pack(side=RIGHT, fill=Y)

        r = 0
        self.cutBtn = tk.Button(self.l_frame,
                                text='Cut',
                                width=25,
                                command=self.cut,
                                state='disabled')
        self.cutBtn.grid(column=0, row=r, padx=1, pady=(20, 1))
        r += 1
        self.cancelBtn = tk.Button(self.l_frame,
                                   text='Cancel',
                                   command=self.app.tGrbl.resetGrbl,
                                   width=25,
                                   state='disabled')
        self.cancelBtn.grid(column=0,
                            columnspan=2,
                            row=r,
                            pady=(10, 1),
                            sticky=W)
        r += 1
        self.button2 = tk.Button(self.l_frame,
                                 text='Save Gcode',
                                 width=25,
                                 command=self.saveGcode)
        self.button2.grid(column=0, row=r, padx=1, pady=(20, 1))
        r += 1
        tk.Label(self.l_frame,
                 text="Usual cutting speed (mm/sec)").grid(column=0,
                                                           row=r,
                                                           pady=(20, 1),
                                                           sticky=W)
        EntryFloat(self.l_frame,
                   self.app.vCut,
                   0.1,
                   10,
                   self.levelCut,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(20, 1),
                                   sticky=W)

        #r += 1
        #tk.Label(self.l_frame, text="Entry slope (degree)").grid(column=0, row=r, pady=(2,1), sticky=W)
        r += 1
        tk.Label(self.l_frame,
                 text="Entry slope (degree)         At root)").grid(column=0,
                                                                    row=r,
                                                                    pady=(10,
                                                                          1),
                                                                    sticky=E)
        EntryFloat(self.l_frame,
                   self.app.angleInRoot,
                   -70,
                   +70,
                   self.levelCut,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(10, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.l_frame, text="At tip)").grid(column=0,
                                                    row=r,
                                                    pady=(1, 1),
                                                    sticky=E)
        EntryFloat(self.l_frame,
                   self.app.angleInTip,
                   -70,
                   +70,
                   self.levelCut,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        #r += 1
        #tk.Label(self.l_frame, text="Exit slope (degree)").grid(column=0, row=r, pady=(5,1), sticky=W)
        r += 1
        tk.Label(self.l_frame,
                 text="Exit slope (degree)          At root)").grid(column=0,
                                                                    row=r,
                                                                    pady=(1,
                                                                          1),
                                                                    sticky=E)
        EntryFloat(self.l_frame,
                   self.app.angleOutRoot,
                   -70,
                   +70,
                   self.levelCut,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.l_frame, text="At tip)").grid(column=0,
                                                    row=r,
                                                    pady=(1, 1),
                                                    sticky=E)
        EntryFloat(self.l_frame,
                   self.app.angleOutTip,
                   -70,
                   +70,
                   self.levelCut,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.l_frame, text="Errors").grid(column=0,
                                                   row=r,
                                                   pady=(20, 1),
                                                   padx=(2, 1),
                                                   sticky=W)
        r += 1
        tk.Label(self.l_frame, textvariable=self.app.cutMsg,
                 height=10).grid(column=0,
                                 columnspan=2,
                                 row=r,
                                 pady=(1, 1),
                                 padx=(10, 1),
                                 sticky=NW)

        r += 1
        tk.Label(self.l_frame, text="   Display starts at ").grid(column=0,
                                                                  row=r,
                                                                  pady=(10, 1),
                                                                  sticky=E)
        r += 1
        tk.Label(self.l_frame, text="X (mm)").grid(column=0,
                                                   row=r,
                                                   pady=(1, 1),
                                                   sticky=E)
        EntryFloat(self.l_frame,
                   self.app.limMinX,
                   0,
                   1500,
                   self.levelCut,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.l_frame, text="Y (mm)").grid(column=0,
                                                   row=r,
                                                   pady=(1, 1),
                                                   sticky=E)
        EntryFloat(self.l_frame,
                   self.app.limMinY,
                   0,
                   500,
                   self.levelCut,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.l_frame, text="Zoom factor").grid(column=0,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=E)
        ttk.Combobox(self.l_frame,
                     textvariable=self.app.zoom,
                     values=["1X", "2X", "5X", "10X", "20X", "50", "100X"],
                     state="readonly",
                     width='4').grid(column=1,
                                     row=r,
                                     padx=1,
                                     pady=(1, 1),
                                     sticky=E)
        self.app.zoom.trace('w', self.calculateRedraw2)

        self.dotX = 10  # define the size and ratio of the figure
        self.dotY = 3
        self.figRoot = Figure(figsize=(self.dotX, self.dotY), dpi=100)
        self.axesRoot = self.figRoot.add_subplot(1, 1, 1)
        self.axesRoot.spines['top'].set_visible(False)  #avoid top frame
        self.axesRoot.spines['right'].set_visible(False)
        self.axesRoot.autoscale(enable=False)
        #self.axesRoot.set_xlim(0, 100)
        #self.axesRoot.set_ylim(0, 30)
        #self.axesRoot.set_title('Root')
        self.lineWireRoot1, = self.axesRoot.plot([], [], 'k:', color='black')
        self.lineProfileRoot2, = self.axesRoot.plot([], [], color='red')
        self.lineBlocRoot, = self.axesRoot.plot([], [], color='black')
        self.arrowRoot = None  #use to annotate the line with an arrow
        self.figRoot.legend(
            (self.lineProfileRoot2, self.lineWireRoot1, self.lineBlocRoot),
            ('Root profile', 'Wire', 'Bloc'), 'upper right')
        self.figRoot.set_tight_layout(True)
        self.canvasRoot = FigureCanvasTkAgg(
            self.figRoot, master=self.r_frame)  # A tk.DrawingArea.
        self.canvasRoot.draw()
        self.canvasRoot.get_tk_widget().grid(column=2,
                                             row=0,
                                             rowspan=22,
                                             padx=10,
                                             pady=(2, 2))

        self.figTip = Figure(figsize=(self.dotX, self.dotY), dpi=100)
        self.axesTip = self.figTip.add_subplot(1, 1, 1)
        self.axesTip.spines['top'].set_visible(False)  #avoid top frame
        self.axesTip.spines['right'].set_visible(False)
        self.axesTip.autoscale(enable=False)
        self.lineWireTip1, = self.axesTip.plot([], [], 'k:', color='black')
        self.lineProfileTip2, = self.axesTip.plot([], [], color='blue')
        self.lineBlocTip, = self.axesTip.plot([], [], color='black')
        self.arrowTip = None
        self.figTip.legend(
            (self.lineProfileTip2, self.lineWireTip1, self.lineBlocTip),
            ('Tip profile', 'Wire', 'Bloc'), 'upper right')
        self.figTip.set_tight_layout(True)
        self.canvasTip = FigureCanvasTkAgg(
            self.figTip, master=self.r_frame)  # A tk.DrawingArea.
        self.canvasTip.draw()
        self.canvasTip.get_tk_widget().grid(column=2,
                                            row=22,
                                            rowspan=22,
                                            padx=10,
                                            pady=(10, 2))
예제 #6
0
    def __init__(self,nb , app ):
        self.first = 0
        self.nb = nb
        self.app = app
        self.frame = ttk.Frame(self.nb)
        self.level = 20
        self.nb.add(self.frame, text='   Bloc (top view)   ')
        r = 0
        tk.Label(self.frame, text="Wingspan (mm)").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.blocLX , 10 , 1000, self.level , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
    
        r += 1
        tk.Label(self.frame, text="Bloc thickness (mm)").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.blocHZ , 1 , 500, self.level , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
    
        r += 1
        tk.Label(self.frame, text="Flèche (mm)").grid(column=0, row=r, pady=(10,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="    Leading edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.fLeading , -500 , 500, self.level , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
    
        r += 1
        tk.Label(self.frame, text="    Trailing edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        #EntryFloat(self.frame, self.app.fTrailing , -500 , 500, self.level+3 , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.frame, textvariable=self.app.fTrailing, width='6', state='disabled').grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)

        r += 1
        tk.Label(self.frame, text="Margins (mm)").grid(column=0, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="     Leading edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.mLeading , -20 , 50, self.level , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
    
        r += 1
        tk.Label(self.frame, text="     Root trailing edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.mTrailingRoot , -20 , 50, self.level , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
    
        r += 1
        tk.Label(self.frame, text="     Tip trailing edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.mTrailingTip , -20 , 50, self.level , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
    
        r += 1
        tk.Label(self.frame, text="Left / Right wing").grid(column=0, row=r, pady=(20,1), sticky=W)
        r += 1
        tk.Radiobutton(self.frame, text="Left", variable=self.app.leftRightWing, value="Left",
            command=self.validateAllLevelBloc).grid(column=0, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Radiobutton(self.frame, text="Right", variable=self.app.leftRightWing, value="Right",
            command=self.validateAllLevelBloc).grid(column=0, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="Distance between table and block (mm)").grid(column=0, columnspan=2, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Radiobutton(self.frame, text="On the left side", variable=self.app.blocPosition, value="Left",
            command=self.blocPositionChanged).grid(column=0, row=r, pady=(1,1), sticky=W)
        
        self.blocToTableLeftBox = EntryFloat(self.frame, self.app.blocToTableLeft , 0 , 1000, self.level , width='6' )
        self.blocToTableLeftBox.grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        r += 1
        tk.Radiobutton(self.frame, text="On the rigth side", variable=self.app.blocPosition, value="Right",
            command=self.blocPositionChanged).grid(column=0, row=r, pady=(1,1), sticky=W)
        self.blocToTableRightBox = EntryFloat(self.frame, self.app.blocToTableRight , 0 , 1000, self.level , width='6' , state='disabled')
        self.blocToTableRightBox.grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="Distance between table origin and ").grid(column=0, columnspan=2, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="   Root trailing edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.blocToTableTrailingRoot , 0 , 500, self.level , width='6').grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="   Tip trailing edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        tk.Entry(self.frame, textvariable=self.app.blocToTableTrailingTip , width='5' , state='disabled').grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        
        r += 1
        tk.Label(self.frame, text="   Root leading edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        tk.Entry(self.frame, textvariable=self.app.blocToTableLeadingRoot , width='5', state='disabled').grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="   Tip leading edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        tk.Entry(self.frame, textvariable=self.app.blocToTableLeadingTip , width='5', state='disabled').grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        
        self.blocTopFig = Figure(figsize=(8, 6), dpi=100)
        self.blocTopAxes = self.blocTopFig.add_subplot(1,1,1)
        self.blocTopAxes.set_xlim(0, 1600)
        self.blocTopAxes.set_ylim(0, 1200)
        self.blocTopAxes.set_title('Top view')
        self.blocTopAxes.spines['top'].set_visible(False)
        self.blocTopAxes.spines['right'].set_visible(False)
        self.blocTopAxes.autoscale(enable=False)
        #self.blocTopAxes.axis('equal')
        self.plotTable, = self.blocTopAxes.plot([], [] ) #draw table
        self.plotBloc, = self.blocTopAxes.plot([], [] ) #draw table
        self.plotLeading, = self.blocTopAxes.plot([], [] , 'k--') #draw leading edge
        self.plotTrailing, = self.blocTopAxes.plot([], [] , 'k--') #draw trailing edge
        self.blocTopCanvas = FigureCanvasTkAgg(self.blocTopFig, master=self.frame)  # A tk.DrawingArea.
        self.blocTopCanvas.draw()
        self.blocTopCanvas.get_tk_widget().grid(column=2, row=0, rowspan=20, padx=10 , pady=(20,2))
        self.updatePlotBloc()
예제 #7
0
class Bloc:
    def __init__(self,nb , app ):
        self.first = 0
        self.nb = nb
        self.app = app
        self.frame = ttk.Frame(self.nb)
        self.level = 20
        self.nb.add(self.frame, text='   Bloc (top view)   ')
        r = 0
        tk.Label(self.frame, text="Wingspan (mm)").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.blocLX , 10 , 1000, self.level , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
    
        r += 1
        tk.Label(self.frame, text="Bloc thickness (mm)").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.blocHZ , 1 , 500, self.level , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
    
        r += 1
        tk.Label(self.frame, text="Flèche (mm)").grid(column=0, row=r, pady=(10,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="    Leading edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.fLeading , -500 , 500, self.level , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
    
        r += 1
        tk.Label(self.frame, text="    Trailing edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        #EntryFloat(self.frame, self.app.fTrailing , -500 , 500, self.level+3 , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.frame, textvariable=self.app.fTrailing, width='6', state='disabled').grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)

        r += 1
        tk.Label(self.frame, text="Margins (mm)").grid(column=0, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="     Leading edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.mLeading , -20 , 50, self.level , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
    
        r += 1
        tk.Label(self.frame, text="     Root trailing edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.mTrailingRoot , -20 , 50, self.level , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
    
        r += 1
        tk.Label(self.frame, text="     Tip trailing edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.mTrailingTip , -20 , 50, self.level , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
    
        r += 1
        tk.Label(self.frame, text="Left / Right wing").grid(column=0, row=r, pady=(20,1), sticky=W)
        r += 1
        tk.Radiobutton(self.frame, text="Left", variable=self.app.leftRightWing, value="Left",
            command=self.validateAllLevelBloc).grid(column=0, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Radiobutton(self.frame, text="Right", variable=self.app.leftRightWing, value="Right",
            command=self.validateAllLevelBloc).grid(column=0, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="Distance between table and block (mm)").grid(column=0, columnspan=2, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Radiobutton(self.frame, text="On the left side", variable=self.app.blocPosition, value="Left",
            command=self.blocPositionChanged).grid(column=0, row=r, pady=(1,1), sticky=W)
        
        self.blocToTableLeftBox = EntryFloat(self.frame, self.app.blocToTableLeft , 0 , 1000, self.level , width='6' )
        self.blocToTableLeftBox.grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        r += 1
        tk.Radiobutton(self.frame, text="On the rigth side", variable=self.app.blocPosition, value="Right",
            command=self.blocPositionChanged).grid(column=0, row=r, pady=(1,1), sticky=W)
        self.blocToTableRightBox = EntryFloat(self.frame, self.app.blocToTableRight , 0 , 1000, self.level , width='6' , state='disabled')
        self.blocToTableRightBox.grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="Distance between table origin and ").grid(column=0, columnspan=2, row=r, pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="   Root trailing edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        EntryFloat(self.frame, self.app.blocToTableTrailingRoot , 0 , 500, self.level , width='6').grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="   Tip trailing edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        tk.Entry(self.frame, textvariable=self.app.blocToTableTrailingTip , width='5' , state='disabled').grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        
        r += 1
        tk.Label(self.frame, text="   Root leading edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        tk.Entry(self.frame, textvariable=self.app.blocToTableLeadingRoot , width='5', state='disabled').grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        r += 1
        tk.Label(self.frame, text="   Tip leading edge").grid(column=0, row=r, pady=(1,1), sticky=W)
        tk.Entry(self.frame, textvariable=self.app.blocToTableLeadingTip , width='5', state='disabled').grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        
        self.blocTopFig = Figure(figsize=(8, 6), dpi=100)
        self.blocTopAxes = self.blocTopFig.add_subplot(1,1,1)
        self.blocTopAxes.set_xlim(0, 1600)
        self.blocTopAxes.set_ylim(0, 1200)
        self.blocTopAxes.set_title('Top view')
        self.blocTopAxes.spines['top'].set_visible(False)
        self.blocTopAxes.spines['right'].set_visible(False)
        self.blocTopAxes.autoscale(enable=False)
        #self.blocTopAxes.axis('equal')
        self.plotTable, = self.blocTopAxes.plot([], [] ) #draw table
        self.plotBloc, = self.blocTopAxes.plot([], [] ) #draw table
        self.plotLeading, = self.blocTopAxes.plot([], [] , 'k--') #draw leading edge
        self.plotTrailing, = self.blocTopAxes.plot([], [] , 'k--') #draw trailing edge
        self.blocTopCanvas = FigureCanvasTkAgg(self.blocTopFig, master=self.frame)  # A tk.DrawingArea.
        self.blocTopCanvas.draw()
        self.blocTopCanvas.get_tk_widget().grid(column=2, row=0, rowspan=20, padx=10 , pady=(20,2))
        self.updatePlotBloc()
        
    def validateAllLevelBloc(self):
        self.app.validateAll(self.level)
    
    """
    def validate_blocToTableLeft(self):
        if self.first > 0:
            self.app.validateAll() 
        self.first = 1

        return True
    """

    def blocPositionChanged(self):
        if self.app.blocPosition.get() == 'Left':
            self.blocToTableLeftBox['state']='normal'
            self.blocToTableRightBox['state']='disabled'
        else:
            self.blocToTableLeftBox['state']='disabled'
            self.blocToTableRightBox['state']='normal'
        
    def updatePlotBloc(self):  #update plotting the bloc (1 canvas: Top)
        # draw table
        cMaxY = self.app.cMaxY.get()
        cMaxX = self.app.tableYY.get() - self.app.tableYG.get() - self.app.tableYD.get()
        self.plotTable.set_xdata([0, 0 , cMaxX, cMaxX, 0  ])
        self.plotTable.set_ydata([0 , cMaxY, cMaxY, 0 , 0 ])
        #draw bloc
        bGX = self.app.blocToTableLeft.get()
        bDX = self.app.blocToTableLeft.get() + self.app.blocLX.get()
        if self.app.leftRightWing.get() == "Right":        
            bGTY = self.app.blocToTableTrailingRoot.get()
            bGLY = self.app.blocToTableLeadingRoot.get()
            bDTY = self.app.blocToTableTrailingTip.get()
            bDLY = self.app.blocToTableLeadingTip.get()
        else:
            bGTY = self.app.blocToTableTrailingTip.get()
            bGLY = self.app.blocToTableLeadingTip.get()
            bDTY = self.app.blocToTableTrailingRoot.get()
            bDLY = self.app.blocToTableLeadingRoot.get()
        self.plotBloc.set_xdata( [bGX , bGX , bDX, bDX , bGX ] )
        self.plotBloc.set_ydata( [bGTY , bGLY, bDLY , bDTY , bGTY] )
        # draw trailing edge
        fTGX = self.app.blocToTableLeft.get()
        fTDX = fTGX + self.app.blocLX.get()
        fTGXp = 0
        fTDXp = self.app.tableYY.get() - self.app.tableYD.get() - self.app.tableYG.get()
        if self.app.leftRightWing.get() == "Right":        
            fTGY = self.app.blocToTableTrailingRoot.get() + self.app.mTrailingRoot.get()
            fTDY = self.app.blocToTableTrailingTip.get() + self.app.mTrailingTip.get() 
        else:
            fTGY = self.app.blocToTableTrailingTip.get() + self.app.mTrailingTip.get()
            fTDY = self.app.blocToTableTrailingRoot.get() + self.app.mTrailingRoot.get() 
        fTGYp , fTDYp = projection( fTGX , fTDX , fTGY , fTDY , fTGXp , fTDXp  )
        self.plotTrailing.set_xdata( [fTGXp , fTDXp ] )
        self.plotTrailing.set_ydata( [fTGYp , fTDYp] )
        #draw leading edge
        fLGX = fTGX
        fLDX = fTDX
        fLGXp = 0
        fLDXp = fTDXp
        if self.app.leftRightWing.get() == "Right":        
            fLGY = fTGY + self.app.cRoot.get()
            fLDY = fTDY + self.app.cTip.get()
        else:    
            fLGY = fTGY + self.app.cTip.get()
            fLDY = fTDY + self.app.cRoot.get()
        fLGYp , fLDYp = projection( fLGX , fLDX , fLGY , fLDY , fLGXp , fLDXp  )
        self.plotLeading.set_xdata( [fLGXp , fLDXp ] )
        self.plotLeading.set_ydata( [fLGYp , fLDYp] )
        self.blocTopCanvas.draw()
예제 #8
0
    def __init__(self, nb, app):
        self.first = 0
        self.nb = nb
        self.app = app
        self.frame = ttk.Frame(self.nb)
        self.level = 20
        self.nb.add(self.frame, text='   Heights & Margins (side view)   ')
        r = 0
        tk.Label(self.frame, text="Block height (mm)").grid(column=0,
                                                            row=r,
                                                            pady=(1, 1),
                                                            sticky=W)
        EntryFloat(self.frame, self.app.blocHZ, 1, 500, self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Block elevation (mm)").grid(column=0,
                                                               row=r,
                                                               pady=(1, 1),
                                                               sticky=W)
        EntryFloat(self.frame, self.app.hOffset, 0, 500, self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 3
        tk.Label(self.frame,
                 text="Vertical positioning of the profile (mm)").grid(
                     column=0, row=r, pady=(10, 1), sticky=W)
        EntryFloat(self.frame, self.app.hProfil, 0, 500, self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(10, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Profile alignment").grid(column=0,
                                                            row=r,
                                                            pady=(10, 1),
                                                            sticky=W)
        r += 1
        tk.Radiobutton(self.frame,
                       text="Align trailing edges",
                       variable=self.app.alignProfil,
                       value="Trailing",
                       command=self.validateAllLevelMargin).grid(column=0,
                                                                 row=r,
                                                                 pady=(1, 1),
                                                                 sticky=W)
        r += 1
        tk.Radiobutton(self.frame,
                       text="Align leading edges",
                       variable=self.app.alignProfil,
                       value="Leading",
                       command=self.validateAllLevelMargin).grid(column=0,
                                                                 row=r,
                                                                 pady=(1, 1),
                                                                 sticky=W)
        r += 1
        tk.Radiobutton(self.frame,
                       text="Align intrados",
                       variable=self.app.alignProfil,
                       value="Intrados",
                       command=self.validateAllLevelMargin).grid(column=0,
                                                                 row=r,
                                                                 pady=(1, 1),
                                                                 sticky=W)
        r += 1
        tk.Radiobutton(self.frame,
                       text="Align extrados",
                       variable=self.app.alignProfil,
                       value="Extrados",
                       command=self.validateAllLevelMargin).grid(column=0,
                                                                 row=r,
                                                                 pady=(1, 1),
                                                                 sticky=W)
        r = 0
        tk.Label(self.frame,
                 text=" - Heights relative to block-").grid(column=3,
                                                            row=r,
                                                            columnspan=5,
                                                            pady=(10, 1),
                                                            sticky=(W, E))
        r += 1
        tk.Label(self.frame, text="Trailing edge").grid(column=3,
                                                        row=r,
                                                        columnspan=3,
                                                        pady=(1, 1),
                                                        sticky=W)
        tk.Label(self.frame, text="Leading edge").grid(column=7,
                                                       row=r,
                                                       columnspan=3,
                                                       pady=(1, 1),
                                                       sticky=W)
        r += 1
        tk.Label(self.frame, text="Root").grid(column=2,
                                               row=r,
                                               pady=(1, 1),
                                               sticky=W)
        tk.Entry(self.frame,
                 textvariable=self.app.hTrailingRoot,
                 width='6',
                 state='disabled').grid(column=3,
                                        row=r,
                                        padx=1,
                                        pady=(1, 1),
                                        sticky=W)
        tk.Entry(self.frame,
                 textvariable=self.app.hLeadingRoot,
                 width='6',
                 state='disabled').grid(column=7,
                                        row=r,
                                        padx=1,
                                        pady=(1, 1),
                                        sticky=W)
        r += 1
        tk.Label(self.frame, text="Tip").grid(column=2,
                                              row=r,
                                              pady=(1, 1),
                                              sticky=W)
        tk.Entry(self.frame,
                 textvariable=self.app.hTrailingTip,
                 width='6',
                 state='disabled').grid(column=3,
                                        row=r,
                                        padx=1,
                                        pady=(1, 1),
                                        sticky=W)
        tk.Entry(self.frame,
                 textvariable=self.app.hLeadingTip,
                 width='6',
                 state='disabled').grid(column=7,
                                        row=r,
                                        padx=1,
                                        pady=(1, 1),
                                        sticky=W)
        r = 0
        tk.Label(self.frame,
                 text=" - Margins relative to block -").grid(column=13,
                                                             row=r,
                                                             columnspan=5,
                                                             pady=(10, 1),
                                                             sticky=(W, E))
        r += 1
        tk.Label(self.frame, text="Intrados").grid(column=13,
                                                   row=r,
                                                   columnspan=3,
                                                   pady=(1, 1),
                                                   sticky=W)
        tk.Label(self.frame, text="Extrados").grid(column=17,
                                                   row=r,
                                                   columnspan=3,
                                                   pady=(1, 1),
                                                   sticky=W)
        r += 1
        tk.Label(self.frame, text="Root").grid(column=12,
                                               row=r,
                                               pady=(1, 1),
                                               sticky=W)
        tk.Entry(self.frame,
                 textvariable=self.app.hMinRoot,
                 width='6',
                 state='disabled').grid(column=13,
                                        row=r,
                                        padx=1,
                                        pady=(1, 1),
                                        sticky=W)
        tk.Entry(self.frame,
                 textvariable=self.app.hMaxRoot,
                 width='6',
                 state='disabled').grid(column=17,
                                        row=r,
                                        padx=1,
                                        pady=(1, 1),
                                        sticky=W)
        r += 1
        tk.Label(self.frame, text="Tip").grid(column=12,
                                              row=r,
                                              pady=(1, 1),
                                              sticky=W)
        tk.Entry(self.frame,
                 textvariable=self.app.hMinTip,
                 width='6',
                 state='disabled').grid(column=13,
                                        row=r,
                                        padx=1,
                                        pady=(1, 1),
                                        sticky=W)
        tk.Entry(self.frame,
                 textvariable=self.app.hMaxTip,
                 width='6',
                 state='disabled').grid(column=17,
                                        row=r,
                                        padx=1,
                                        pady=(1, 1),
                                        sticky=W)
        r += 1
        tk.Label(self.frame, textvariable=self.app.warningMsg,
                 fg='red').grid(column=2, columnspan=15, row=r, pady=(1, 1))

        #lists to draw the bloc
        blocRootX = [
            self.app.blocToTableTrailingRoot.get(),
            self.app.blocToTableLeadingRoot.get(),
            self.app.blocToTableLeadingRoot.get(),
            self.app.blocToTableTrailingRoot.get(),
            self.app.blocToTableTrailingRoot.get()
        ]
        blocTipX = [
            self.app.blocToTableTrailingTip.get(),
            self.app.blocToTableLeadingTip.get(),
            self.app.blocToTableLeadingTip.get(),
            self.app.blocToTableTrailingTip.get(),
            self.app.blocToTableTrailingTip.get()
        ]
        hOffset = self.app.hOffset.get()
        blocHZ = self.app.blocHZ.get()
        blocRootY = [
            hOffset, hOffset, hOffset + blocHZ, hOffset + blocHZ, hOffset
        ]
        blocTipY = blocRootY

        self.figRoot = Figure(figsize=(10, 2), dpi=100)
        self.axesRoot = self.figRoot.add_subplot(1, 1, 1)
        self.axesRoot.set_xlim(0, 1300)
        self.axesRoot.set_ylim(0, 260)
        self.axesRoot.set_title('Root')
        self.axesRoot.autoscale(enable=False)
        self.axesRoot.spines['top'].set_visible(False)
        self.axesRoot.spines['right'].set_visible(False)

        self.plotBlocRoot, = self.axesRoot.plot(blocRootX,
                                                blocRootY,
                                                color='black')
        self.plotRoot, = self.axesRoot.plot(self.app.pRootX,
                                            self.app.pRootY,
                                            color='red')
        self.canvasRoot = FigureCanvasTkAgg(
            self.figRoot, master=self.frame)  # A tk.DrawingArea.
        self.canvasRoot.draw()
        self.canvasRoot.get_tk_widget().grid(column=2,
                                             rowspan=3,
                                             columnspan=20,
                                             row=5,
                                             pady=(20, 2))

        self.figTip = Figure(figsize=(10, 2), dpi=100)
        self.axesTip = self.figTip.add_subplot(1, 1, 1)
        self.axesTip.set_xlim(0, 1300)
        self.axesTip.set_ylim(0, 260)
        self.axesTip.set_title('Tip')
        self.axesTip.autoscale(enable=False)
        self.axesTip.spines['top'].set_visible(False)
        self.axesTip.spines['right'].set_visible(False)

        self.plotBlocTip, = self.axesTip.plot(blocTipX,
                                              blocTipY,
                                              color='black')
        self.plotTip, = self.axesTip.plot(self.app.pTipX,
                                          self.app.pTipY,
                                          color='blue')
        self.canvasTip = FigureCanvasTkAgg(
            self.figTip, master=self.frame)  # A tk.DrawingArea.
        self.canvasTip.draw()
        self.canvasTip.get_tk_widget().grid(column=2,
                                            rowspan=3,
                                            columnspan=20,
                                            row=9,
                                            pady=(20, 2))
예제 #9
0
    def __init__(self, nb, app):
        self.nb = nb
        self.app = app
        self.frame = ttk.Frame(self.nb)
        self.levelBloc = 20
        self.levelCut = 30
        self.nb.add(self.frame, text='   Table   ')
        #reg_tableYY =  self.frame.register(self.validate_tableYY)            #enregistre la fonction de validation

        r = 0
        tk.Button(self.frame,
                  text='Upload saved table',
                  command=self.app.uploadTable,
                  width=25).grid(column=0, row=r, pady=10)
        r += 1
        tk.Button(self.frame,
                  text='Save current table',
                  command=self.app.saveTable,
                  width=25).grid(column=0, row=r, pady=10)
        r += 1
        tk.Label(self.frame, text="Table (name)").grid(column=0,
                                                       row=r,
                                                       pady=(20, 2))
        r += 1
        tk.Entry(self.frame, textvariable=self.app.tName,
                 width='50').grid(column=0,
                                  columnspan=2,
                                  row=r,
                                  padx=1,
                                  pady=(1, 10),
                                  sticky=W)

        r += 1
        tk.Label(self.frame,
                 text="Distance between axes (mm)").grid(column=0,
                                                         row=r,
                                                         pady=(1, 1),
                                                         sticky=W)
        #tk.Entry(self.frame, textvariable=self.app.tableYY , width='5' , validate='focusout',
        #    validatecommand=(reg_tableYY) ).grid(column=1, row=r , padx=1,pady=(1,1))
        EntryFloat(self.frame,
                   self.app.tableYY,
                   10,
                   1600,
                   self.levelBloc,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.frame,
                 text="Distance between table and").grid(column=0,
                                                         row=r,
                                                         pady=(1, 1),
                                                         sticky=W)
        r += 1
        tk.Label(self.frame, text="     left axis (mm)").grid(column=0,
                                                              row=r,
                                                              pady=(1, 1),
                                                              sticky=W)
        #tk.Entry(self.frame, textvariable=self.app.tableYG , width='5').grid(column=1, row=r , padx=1,pady=(1,1))
        EntryFloat(self.frame,
                   self.app.tableYG,
                   1,
                   500,
                   self.levelBloc,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.frame, text="     right axis (mm)").grid(column=0,
                                                               row=r,
                                                               pady=(1, 1),
                                                               sticky=W)
        #tk.Entry(self.frame, textvariable=self.app.tableYD , width='5').grid(column=1, row=r , padx=1,pady=(1,1))
        EntryFloat(self.frame,
                   self.app.tableYD,
                   1,
                   500,
                   self.levelBloc,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.frame, text="Max course (mm)").grid(column=0,
                                                          row=r,
                                                          pady=(1, 1),
                                                          sticky=W)
        r += 1
        tk.Label(self.frame, text="       Horizontal").grid(column=0,
                                                            row=r,
                                                            pady=(1, 1),
                                                            sticky=W)
        #tk.Entry(self.frame, textvariable=self.app.cMaxY , width='5').grid(column=1, row=r , padx=1,pady=(1,1))
        EntryFloat(self.frame,
                   self.app.cMaxY,
                   1,
                   1300,
                   self.levelBloc,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.frame, text="       Vertical").grid(column=0,
                                                          row=r,
                                                          pady=(1, 1),
                                                          sticky=W)
        #tk.Entry(self.frame, textvariable=self.app.cMaxZ , width='5').grid(column=1, row=r , padx=1,pady=(1,1))
        EntryFloat(self.frame,
                   self.app.cMaxZ,
                   1,
                   1200,
                   self.levelBloc,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.frame, text="Max speed (mm/sec)").grid(column=0,
                                                             row=r,
                                                             pady=(1, 1),
                                                             sticky=W)
        r += 1
        tk.Label(self.frame, text="            Horizontal").grid(column=0,
                                                                 row=r,
                                                                 pady=(1, 1),
                                                                 sticky=W)
        #tk.Entry(self.frame, textvariable=self.app.vMaxY , width='5').grid(column=1, row=r , padx=1,pady=(1,1))
        EntryFloat(self.frame, self.app.vMaxY, 1, 50, self.levelCut,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.frame, text="            Vertical").grid(column=0,
                                                               row=r,
                                                               pady=(1, 1),
                                                               sticky=W)
        #reg_vMaxZ =  self.frame.register(self.validate_vMaxZ)
        #tk.Entry(self.frame, textvariable=self.app.vMaxZ , width='5' ).grid(column=1, row=r , padx=1,pady=(1,1))
        EntryFloat(self.frame,
                   self.app.vMaxZ,
                   1,
                   500,
                   self.levelCut,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.frame, text="Max heating").grid(column=0,
                                                      row=r,
                                                      pady=(1, 1),
                                                      sticky=W)
        #reg_vMaxZ =  self.frame.register(self.validate_vMaxZ)
        #tk.Entry(self.frame, textvariable=self.app.vMaxZ , width='5' ).grid(column=1, row=r , padx=1,pady=(1,1))
        EntryFloat(self.frame,
                   self.app.tHeatingMax,
                   1,
                   100,
                   self.levelCut,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 2
        tk.Label(self.frame, text=" Com Port").grid(column=0,
                                                    row=r,
                                                    pady=(20, 1),
                                                    sticky=W)
        self.comListBox = ttk.Combobox(self.frame,
                                       textvariable=self.app.tComPort,
                                       values=self.comGet(),
                                       state="readonly")
        self.comListBox.grid(column=1, row=r, padx=1, pady=(20, 1), sticky=E)
        tk.Button(self.frame,
                  text='Refresh Com list',
                  command=self.refreshComList).grid(column=2,
                                                    row=r,
                                                    pady=(20, 1),
                                                    padx=20)
        r += 1
        tk.Label(self.frame, text=" Baudrate").grid(column=0,
                                                    row=r,
                                                    pady=(10, 1),
                                                    sticky=W)
        ttk.Combobox(self.frame,
                     textvariable=self.app.tBaudrate,
                     values=["9600", "19200", "38400", "57600", "115200"],
                     state="readonly").grid(column=1,
                                            row=r,
                                            padx=1,
                                            pady=(10, 1),
                                            sticky=E)
        r += 1
        tk.Label(self.frame, text="Selected Com is").grid(column=0,
                                                          row=r,
                                                          pady=(10, 1),
                                                          sticky=E)
        tk.Entry(self.frame, textvariable=self.app.connected,
                 width='5').grid(column=1,
                                 row=r,
                                 padx=1,
                                 pady=(10, 1),
                                 sticky=W)

        r = 3
        tk.Label(self.frame,
                 text="Apply heating before move (sec)").grid(column=3,
                                                              row=r,
                                                              pady=(1, 1),
                                                              sticky=E)
        EntryFloat(self.frame,
                   self.app.tPreHeat,
                   0,
                   10,
                   self.levelCut,
                   width='6').grid(column=4,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.frame,
                 text="Keep heating after move (sec)").grid(column=3,
                                                            row=r,
                                                            pady=(1, 1),
                                                            sticky=E)
        EntryFloat(self.frame,
                   self.app.tPostHeat,
                   0,
                   10,
                   self.levelCut,
                   width='6').grid(column=4,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 2
        tk.Label(self.frame, text="Gcode").grid(column=3, row=r, pady=(1, 1))
        r += 1
        tk.Label(self.frame, text="   start with").grid(column=3,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=E)
        tk.Entry(self.frame, textvariable=self.app.gCodeStart1,
                 width='20').grid(column=4,
                                  row=r,
                                  padx=1,
                                  pady=(1, 1),
                                  sticky=W)
        r += 1
        tk.Entry(self.frame, textvariable=self.app.gCodeStart2,
                 width='20').grid(column=4,
                                  row=r,
                                  padx=1,
                                  pady=(1, 1),
                                  sticky=W)
        r += 1
        tk.Entry(self.frame, textvariable=self.app.gCodeStart3,
                 width='20').grid(column=4,
                                  row=r,
                                  padx=1,
                                  pady=(1, 1),
                                  sticky=W)
        r += 1
        tk.Entry(self.frame, textvariable=self.app.gCodeStart4,
                 width='20').grid(column=4,
                                  row=r,
                                  padx=1,
                                  pady=(1, 1),
                                  sticky=W)

        r += 1
        tk.Label(self.frame, text="   end with").grid(column=3,
                                                      row=r,
                                                      pady=(1, 1),
                                                      sticky=E)
        tk.Entry(self.frame, textvariable=self.app.gCodeEnd1,
                 width='20').grid(column=4,
                                  row=r,
                                  padx=1,
                                  pady=(1, 1),
                                  sticky=W)
        r += 1
        tk.Entry(self.frame, textvariable=self.app.gCodeEnd2,
                 width='20').grid(column=4,
                                  row=r,
                                  padx=1,
                                  pady=(1, 1),
                                  sticky=W)
        r += 1
        tk.Entry(self.frame, textvariable=self.app.gCodeEnd3,
                 width='20').grid(column=4,
                                  row=r,
                                  padx=1,
                                  pady=(1, 1),
                                  sticky=W)
        r += 1
        tk.Entry(self.frame, textvariable=self.app.gCodeEnd4,
                 width='20').grid(column=4,
                                  row=r,
                                  padx=1,
                                  pady=(1, 1),
                                  sticky=W)
        r += 2
        tk.Label(self.frame, text="Axis letters").grid(column=3,
                                                       row=r,
                                                       pady=(1, 1),
                                                       sticky=E)
        tk.Entry(self.frame, textvariable=self.app.gCodeLetters,
                 width='5').grid(column=4,
                                 row=r,
                                 padx=1,
                                 pady=(1, 1),
                                 sticky=W)
예제 #10
0
class Bloc:
    def __init__(self, nb, app):
        self.first = 0
        self.nb = nb
        self.app = app
        self.frame = ttk.Frame(self.nb)
        self.level = 20
        self.nb.add(self.frame, text='   Bloc (top view)   ')
        r = 0
        tk.Label(self.frame, text="Wingspan (mm)").grid(column=0,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=W)
        EntryFloat(self.frame,
                   self.app.blocLX,
                   10,
                   1000,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Bloc thickness (mm)").grid(column=0,
                                                              row=r,
                                                              pady=(1, 1),
                                                              sticky=W)
        EntryFloat(self.frame, self.app.blocHZ, 1, 500, self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Flèche (mm)").grid(column=0,
                                                      row=r,
                                                      pady=(10, 1),
                                                      sticky=W)
        r += 1
        tk.Label(self.frame, text="    Leading edge").grid(column=0,
                                                           row=r,
                                                           pady=(1, 1),
                                                           sticky=W)
        EntryFloat(self.frame,
                   self.app.fLeading,
                   -500,
                   500,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="    Trailing edge").grid(column=0,
                                                            row=r,
                                                            pady=(1, 1),
                                                            sticky=W)
        #EntryFloat(self.frame, self.app.fTrailing , -500 , 500, self.level+3 , width='6' ).grid(column=1, row=r , padx=1,pady=(1,1), sticky=W)
        tk.Entry(self.frame,
                 textvariable=self.app.fTrailing,
                 width='6',
                 state='disabled').grid(column=1,
                                        row=r,
                                        padx=1,
                                        pady=(1, 1),
                                        sticky=W)

        r += 1
        tk.Label(self.frame, text="Margins (mm)").grid(column=0,
                                                       row=r,
                                                       pady=(1, 1),
                                                       sticky=W)
        r += 1
        tk.Label(self.frame, text="     Leading edge").grid(column=0,
                                                            row=r,
                                                            pady=(1, 1),
                                                            sticky=W)
        EntryFloat(self.frame,
                   self.app.mLeading,
                   -20,
                   50,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="     Root trailing edge").grid(column=0,
                                                                  row=r,
                                                                  pady=(1, 1),
                                                                  sticky=W)
        EntryFloat(self.frame,
                   self.app.mTrailingRoot,
                   -20,
                   50,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="     Tip trailing edge").grid(column=0,
                                                                 row=r,
                                                                 pady=(1, 1),
                                                                 sticky=W)
        EntryFloat(self.frame,
                   self.app.mTrailingTip,
                   -20,
                   50,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Left / Right wing").grid(column=0,
                                                            row=r,
                                                            pady=(20, 1),
                                                            sticky=W)
        r += 1
        tk.Radiobutton(self.frame,
                       text="Left",
                       variable=self.app.leftRightWing,
                       value="Left",
                       command=self.validateAllLevelBloc).grid(column=0,
                                                               row=r,
                                                               pady=(1, 1),
                                                               sticky=W)
        r += 1
        tk.Radiobutton(self.frame,
                       text="Right",
                       variable=self.app.leftRightWing,
                       value="Right",
                       command=self.validateAllLevelBloc).grid(column=0,
                                                               row=r,
                                                               pady=(1, 1),
                                                               sticky=W)
        r += 1
        tk.Label(self.frame,
                 text="Distance between table and block (mm)").grid(
                     column=0, columnspan=2, row=r, pady=(1, 1), sticky=W)
        r += 1
        tk.Radiobutton(self.frame,
                       text="On the left side",
                       variable=self.app.blocPosition,
                       value="Left",
                       command=self.blocPositionChanged).grid(column=0,
                                                              row=r,
                                                              pady=(1, 1),
                                                              sticky=W)

        self.blocToTableLeftBox = EntryFloat(self.frame,
                                             self.app.blocToTableLeft,
                                             0,
                                             1000,
                                             self.level,
                                             width='6')
        self.blocToTableLeftBox.grid(column=1,
                                     row=r,
                                     padx=1,
                                     pady=(1, 1),
                                     sticky=W)
        r += 1
        tk.Radiobutton(self.frame,
                       text="On the rigth side",
                       variable=self.app.blocPosition,
                       value="Right",
                       command=self.blocPositionChanged).grid(column=0,
                                                              row=r,
                                                              pady=(1, 1),
                                                              sticky=W)
        self.blocToTableRightBox = EntryFloat(self.frame,
                                              self.app.blocToTableRight,
                                              0,
                                              1000,
                                              self.level,
                                              width='6',
                                              state='disabled')
        self.blocToTableRightBox.grid(column=1,
                                      row=r,
                                      padx=1,
                                      pady=(1, 1),
                                      sticky=W)
        r += 1
        tk.Label(self.frame,
                 text="Distance between table origin and ").grid(column=0,
                                                                 columnspan=2,
                                                                 row=r,
                                                                 pady=(1, 1),
                                                                 sticky=W)
        r += 1
        tk.Label(self.frame, text="   Root trailing edge").grid(column=0,
                                                                row=r,
                                                                pady=(1, 1),
                                                                sticky=W)
        EntryFloat(self.frame,
                   self.app.blocToTableTrailingRoot,
                   0,
                   500,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)
        r += 1
        tk.Label(self.frame, text="   Tip trailing edge").grid(column=0,
                                                               row=r,
                                                               pady=(1, 1),
                                                               sticky=W)
        tk.Entry(self.frame,
                 textvariable=self.app.blocToTableTrailingTip,
                 width='5',
                 state='disabled').grid(column=1,
                                        row=r,
                                        padx=1,
                                        pady=(1, 1),
                                        sticky=W)

        r += 1
        tk.Label(self.frame, text="   Root leading edge").grid(column=0,
                                                               row=r,
                                                               pady=(1, 1),
                                                               sticky=W)
        tk.Entry(self.frame,
                 textvariable=self.app.blocToTableLeadingRoot,
                 width='5',
                 state='disabled').grid(column=1,
                                        row=r,
                                        padx=1,
                                        pady=(1, 1),
                                        sticky=W)
        r += 1
        tk.Label(self.frame, text="   Tip leading edge").grid(column=0,
                                                              row=r,
                                                              pady=(1, 1),
                                                              sticky=W)
        tk.Entry(self.frame,
                 textvariable=self.app.blocToTableLeadingTip,
                 width='5',
                 state='disabled').grid(column=1,
                                        row=r,
                                        padx=1,
                                        pady=(1, 1),
                                        sticky=W)

        self.dotX = 10  # define the size and ratio of the figure
        self.dotY = 6
        self.blocTopFig = Figure(figsize=(self.dotX, self.dotY), dpi=100)
        self.blocTopAxes = self.blocTopFig.add_subplot(1, 1, 1)
        self.blocTopAxes.set_title('Top view')
        self.blocTopAxes.spines['top'].set_visible(False)
        self.blocTopAxes.spines['right'].set_visible(False)
        self.blocTopAxes.autoscale(enable=False)
        self.plotTable, = self.blocTopAxes.plot([], [],
                                                color='green')  #draw table
        self.plotBloc, = self.blocTopAxes.plot([], [],
                                               color='black')  #draw bloc
        self.plotLeading, = self.blocTopAxes.plot(
            [], [], 'k-.', color='black')  #draw leading edge
        self.plotTrailing, = self.blocTopAxes.plot(
            [], [], 'k--', color='black')  #draw trailing edge
        #arrow = self.blocTopAxes.arrow(10,30, 50, 50, head_width=10)

        self.blocTopFig.legend((self.plotTable, self.plotBloc,
                                self.plotLeading, self.plotTrailing),
                               ('Table', 'Bloc', 'Leading', 'Trailing'),
                               'upper right')
        self.blocTopFig.set_tight_layout(True)
        self.blocTopCanvas = FigureCanvasTkAgg(
            self.blocTopFig, master=self.frame)  # A tk.DrawingArea.
        self.blocTopCanvas.draw()
        self.blocTopCanvas.get_tk_widget().grid(column=2,
                                                row=0,
                                                rowspan=20,
                                                padx=10,
                                                pady=(20, 2))
        self.updatePlotBloc()

    def validateAllLevelBloc(self):
        self.app.validateAll(self.level)

    """
    def validate_blocToTableLeft(self):
        if self.first > 0:
            self.app.validateAll() 
        self.first = 1

        return True
    """

    def blocPositionChanged(self):
        if self.app.blocPosition.get() == 'Left':
            self.blocToTableLeftBox['state'] = 'normal'
            self.blocToTableRightBox['state'] = 'disabled'
        else:
            self.blocToTableLeftBox['state'] = 'disabled'
            self.blocToTableRightBox['state'] = 'normal'

    def updatePlotBloc(self):  #update plotting the bloc (1 canvas: Top)
        # draw table
        cMaxY = self.app.cMaxY.get()
        cMaxX = self.app.tableYY.get() - self.app.tableYG.get(
        ) - self.app.tableYD.get()
        # set the limits of X and Y depending on table size (keeping predifine ratio of the figure)
        maxX = cMaxX + 3
        maxY = cMaxY + 4
        limMinX = -3
        limMinY = -3
        zoom = 1
        if (maxY / maxX) < (self.dotY / self.dotX):
            limMaxX = limMinX + (maxX / zoom)
            limMaxY = limMinY + (maxX / zoom * self.dotY / self.dotX)
        else:
            limMaxY = limMinY + (maxY / zoom)
            limMaxX = limMinX + (maxY / zoom * self.dotX / self.dotY)
        self.blocTopAxes.set_xlim(limMinX, limMaxX)
        self.blocTopAxes.set_ylim(limMinY, limMaxY)

        self.plotTable.set_xdata([0, 0, cMaxX, cMaxX, 0])
        self.plotTable.set_ydata([0, cMaxY, cMaxY, 0, 0])
        #draw bloc
        bGX = self.app.blocToTableLeft.get()
        bDX = self.app.blocToTableLeft.get() + self.app.blocLX.get()
        if self.app.leftRightWing.get() == "Right":
            bGTY = self.app.blocToTableTrailingRoot.get()
            bGLY = self.app.blocToTableLeadingRoot.get()
            bDTY = self.app.blocToTableTrailingTip.get()
            bDLY = self.app.blocToTableLeadingTip.get()
        else:
            bGTY = self.app.blocToTableTrailingTip.get()
            bGLY = self.app.blocToTableLeadingTip.get()
            bDTY = self.app.blocToTableTrailingRoot.get()
            bDLY = self.app.blocToTableLeadingRoot.get()
        self.plotBloc.set_xdata([bGX, bGX, bDX, bDX, bGX])
        self.plotBloc.set_ydata([bGTY, bGLY, bDLY, bDTY, bGTY])
        # draw trailing edge
        fTGX = self.app.blocToTableLeft.get()
        fTDX = fTGX + self.app.blocLX.get()
        fTGXp = 0
        fTDXp = self.app.tableYY.get() - self.app.tableYD.get(
        ) - self.app.tableYG.get()
        if self.app.leftRightWing.get() == "Right":
            fTGY = self.app.blocToTableTrailingRoot.get(
            ) + self.app.mTrailingRoot.get()
            fTDY = self.app.blocToTableTrailingTip.get(
            ) + self.app.mTrailingTip.get()
        else:
            fTGY = self.app.blocToTableTrailingTip.get(
            ) + self.app.mTrailingTip.get()
            fTDY = self.app.blocToTableTrailingRoot.get(
            ) + self.app.mTrailingRoot.get()
        fTGYp, fTDYp = projection(fTGX, fTDX, fTGY, fTDY, fTGXp, fTDXp)
        self.plotTrailing.set_xdata([fTGXp, fTDXp])
        self.plotTrailing.set_ydata([fTGYp, fTDYp])
        #draw leading edge
        fLGX = fTGX
        fLDX = fTDX
        fLGXp = 0
        fLDXp = fTDXp
        if self.app.leftRightWing.get() == "Right":
            fLGY = fTGY + self.app.cRoot.get()
            fLDY = fTDY + self.app.cTip.get()
        else:
            fLGY = fTGY + self.app.cTip.get()
            fLDY = fTDY + self.app.cRoot.get()
        fLGYp, fLDYp = projection(fLGX, fLDX, fLGY, fLDY, fLGXp, fLDXp)
        self.plotLeading.set_xdata([fLGXp, fLDXp])
        self.plotLeading.set_ydata([fLGYp, fLDYp])
        self.blocTopCanvas.draw()
예제 #11
0
    def __init__(self, nb, app):
        self.nb = nb
        self.app = app
        self.frame = ttk.Frame(self.nb)
        self.level = 10
        self.nb.add(self.frame, text='   Transform   ')
        r = 0
        tk.Label(self.frame, text="Root").grid(column=0, row=r, pady=(1, 2))
        r += 1
        tk.Label(self.frame, text="Chord").grid(column=0,
                                                row=r,
                                                pady=(1, 1),
                                                sticky=E)
        EntryFloat(self.frame,
                   self.app.cRoot,
                   1,
                   self.app.cMaxY.get(),
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Thickness (%)").grid(column=0,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=E)
        EntryFloat(self.frame,
                   self.app.thicknessRoot,
                   1,
                   500,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Incidence (°)").grid(column=0,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=E)
        EntryFloat(self.frame,
                   self.app.incidenceRoot,
                   -180,
                   180,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Vertically invert").grid(column=0,
                                                            row=r,
                                                            pady=(1, 1),
                                                            sticky=E)
        tk.Checkbutton(self.frame,
                       variable=self.app.vInvertRoot,
                       text='',
                       command=self.validateAllLevelTransform).grid(column=1,
                                                                    row=r,
                                                                    padx=1,
                                                                    pady=(1,
                                                                          1),
                                                                    sticky=W)

        r += 1
        tk.Label(self.frame, text="Tip").grid(column=0, row=r, pady=(20, 2))
        r += 1
        tk.Label(self.frame, text="Chord").grid(column=0,
                                                row=r,
                                                pady=(1, 1),
                                                sticky=E)
        EntryFloat(self.frame,
                   self.app.cTip,
                   1,
                   self.app.cMaxY.get(),
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Thickness (%)").grid(column=0,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=E)
        EntryFloat(self.frame,
                   self.app.thicknessTip,
                   1,
                   500,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Incidence (°)").grid(column=0,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=E)
        EntryFloat(self.frame,
                   self.app.incidenceTip,
                   -180,
                   180,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Vertically invert").grid(column=0,
                                                            row=r,
                                                            pady=(1, 1),
                                                            sticky=E)
        tk.Checkbutton(self.frame,
                       variable=self.app.vInvertTip,
                       text='',
                       command=self.validateAllLevelTransform).grid(column=1,
                                                                    row=r,
                                                                    padx=1,
                                                                    pady=(1,
                                                                          1),
                                                                    sticky=W)

        r += 1
        tk.Label(self.frame, text="Apply on both profils").grid(column=0,
                                                                row=r,
                                                                pady=(20, 2))
        r += 1
        tk.Label(self.frame, text="Smooth profiles").grid(column=0,
                                                          row=r,
                                                          pady=(1, 1),
                                                          sticky=W)
        tk.Checkbutton(self.frame,
                       variable=self.app.smooth,
                       text='',
                       command=self.changeSmooth).grid(column=1,
                                                       row=r,
                                                       padx=1,
                                                       pady=(1, 1),
                                                       sticky=E)
        r += 1
        tk.Label(self.frame, text="  Number of points").grid(column=0,
                                                             row=r,
                                                             pady=(1, 1),
                                                             sticky=E)
        self.nbrPointsBox = EntryFloat(self.frame,
                                       self.app.nbrPoints,
                                       10,
                                       1000,
                                       self.level,
                                       width='6')
        self.nbrPointsBox.grid(column=1, row=r, padx=1, pady=(1, 1), sticky=W)
        r += 1
        tk.Label(self.frame, text="  Spreading factor").grid(column=0,
                                                             row=r,
                                                             pady=(1, 1),
                                                             sticky=E)
        self.repartitionBox = EntryFloat(self.frame,
                                         self.app.repartition,
                                         0.5,
                                         2,
                                         self.level,
                                         width='6')
        self.repartitionBox.grid(column=1,
                                 row=r,
                                 padx=1,
                                 pady=(1, 1),
                                 sticky=W)

        r += 1
        tk.Label(self.frame, text="Covering (mm)").grid(column=0,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=W)
        EntryFloat(self.frame, self.app.covering, -5, 5, self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Extend to keep chords").grid(column=0,
                                                                row=r,
                                                                pady=(1, 1),
                                                                sticky=E)
        tk.Checkbutton(self.frame,
                       variable=self.app.keepChord,
                       text='',
                       command=self.validateAllLevelTransform).grid(column=1,
                                                                    row=r,
                                                                    padx=1,
                                                                    pady=(1,
                                                                          1),
                                                                    sticky=W)
        r += 1
        tk.Label(self.frame, text="Reduce nbr of points").grid(column=0,
                                                               row=r,
                                                               pady=(1, 1),
                                                               sticky=E)
        tk.Checkbutton(self.frame,
                       variable=self.app.reducePoints,
                       text='',
                       command=self.validateAllLevelTransform).grid(column=1,
                                                                    row=r,
                                                                    padx=1,
                                                                    pady=(1,
                                                                          1))

        r = 22
        self.displayPoints = IntVar(value='1')
        tk.Checkbutton(self.frame,
                       variable=self.displayPoints,
                       text='Show points',
                       command=self.validateAllLevelTransform).grid(column=2,
                                                                    row=r,
                                                                    padx=1,
                                                                    pady=(1,
                                                                          1))

        r = 24
        tk.Label(self.frame, textvariable=self.app.warningMsg,
                 fg='red').grid(column=2, columnspan=5, row=r, pady=(1, 1))
        #tk.Label(self.frame, text="test", bg='red').grid(column=2, columnspan=5, row=r, pady=(1,1))

        self.app.tRootX = np.array(self.app.oRootX)
        self.app.tRootY = np.array(self.app.oRootY)
        self.app.tTipX = np.array(self.app.oTipX)
        self.app.tTipY = np.array(self.app.oTipY)
        self.plotProfil()
예제 #12
0
class Transform:
    def __init__(self, nb, app):
        self.nb = nb
        self.app = app
        self.frame = ttk.Frame(self.nb)
        self.level = 10
        self.nb.add(self.frame, text='   Transform   ')
        r = 0
        tk.Label(self.frame, text="Root").grid(column=0, row=r, pady=(1, 2))
        r += 1
        tk.Label(self.frame, text="Chord").grid(column=0,
                                                row=r,
                                                pady=(1, 1),
                                                sticky=E)
        EntryFloat(self.frame,
                   self.app.cRoot,
                   1,
                   self.app.cMaxY.get(),
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Thickness (%)").grid(column=0,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=E)
        EntryFloat(self.frame,
                   self.app.thicknessRoot,
                   1,
                   500,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Incidence (°)").grid(column=0,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=E)
        EntryFloat(self.frame,
                   self.app.incidenceRoot,
                   -180,
                   180,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Vertically invert").grid(column=0,
                                                            row=r,
                                                            pady=(1, 1),
                                                            sticky=E)
        tk.Checkbutton(self.frame,
                       variable=self.app.vInvertRoot,
                       text='',
                       command=self.validateAllLevelTransform).grid(column=1,
                                                                    row=r,
                                                                    padx=1,
                                                                    pady=(1,
                                                                          1),
                                                                    sticky=W)

        r += 1
        tk.Label(self.frame, text="Tip").grid(column=0, row=r, pady=(20, 2))
        r += 1
        tk.Label(self.frame, text="Chord").grid(column=0,
                                                row=r,
                                                pady=(1, 1),
                                                sticky=E)
        EntryFloat(self.frame,
                   self.app.cTip,
                   1,
                   self.app.cMaxY.get(),
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Thickness (%)").grid(column=0,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=E)
        EntryFloat(self.frame,
                   self.app.thicknessTip,
                   1,
                   500,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Incidence (°)").grid(column=0,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=E)
        EntryFloat(self.frame,
                   self.app.incidenceTip,
                   -180,
                   180,
                   self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Vertically invert").grid(column=0,
                                                            row=r,
                                                            pady=(1, 1),
                                                            sticky=E)
        tk.Checkbutton(self.frame,
                       variable=self.app.vInvertTip,
                       text='',
                       command=self.validateAllLevelTransform).grid(column=1,
                                                                    row=r,
                                                                    padx=1,
                                                                    pady=(1,
                                                                          1),
                                                                    sticky=W)

        r += 1
        tk.Label(self.frame, text="Apply on both profils").grid(column=0,
                                                                row=r,
                                                                pady=(20, 2))
        r += 1
        tk.Label(self.frame, text="Smooth profiles").grid(column=0,
                                                          row=r,
                                                          pady=(1, 1),
                                                          sticky=W)
        tk.Checkbutton(self.frame,
                       variable=self.app.smooth,
                       text='',
                       command=self.changeSmooth).grid(column=1,
                                                       row=r,
                                                       padx=1,
                                                       pady=(1, 1),
                                                       sticky=E)
        r += 1
        tk.Label(self.frame, text="  Number of points").grid(column=0,
                                                             row=r,
                                                             pady=(1, 1),
                                                             sticky=E)
        self.nbrPointsBox = EntryFloat(self.frame,
                                       self.app.nbrPoints,
                                       10,
                                       1000,
                                       self.level,
                                       width='6')
        self.nbrPointsBox.grid(column=1, row=r, padx=1, pady=(1, 1), sticky=W)
        r += 1
        tk.Label(self.frame, text="  Spreading factor").grid(column=0,
                                                             row=r,
                                                             pady=(1, 1),
                                                             sticky=E)
        self.repartitionBox = EntryFloat(self.frame,
                                         self.app.repartition,
                                         0.5,
                                         2,
                                         self.level,
                                         width='6')
        self.repartitionBox.grid(column=1,
                                 row=r,
                                 padx=1,
                                 pady=(1, 1),
                                 sticky=W)

        r += 1
        tk.Label(self.frame, text="Covering (mm)").grid(column=0,
                                                        row=r,
                                                        pady=(1, 1),
                                                        sticky=W)
        EntryFloat(self.frame, self.app.covering, -5, 5, self.level,
                   width='6').grid(column=1,
                                   row=r,
                                   padx=1,
                                   pady=(1, 1),
                                   sticky=W)

        r += 1
        tk.Label(self.frame, text="Extend to keep chords").grid(column=0,
                                                                row=r,
                                                                pady=(1, 1),
                                                                sticky=E)
        tk.Checkbutton(self.frame,
                       variable=self.app.keepChord,
                       text='',
                       command=self.validateAllLevelTransform).grid(column=1,
                                                                    row=r,
                                                                    padx=1,
                                                                    pady=(1,
                                                                          1),
                                                                    sticky=W)
        r += 1
        tk.Label(self.frame, text="Reduce nbr of points").grid(column=0,
                                                               row=r,
                                                               pady=(1, 1),
                                                               sticky=E)
        tk.Checkbutton(self.frame,
                       variable=self.app.reducePoints,
                       text='',
                       command=self.validateAllLevelTransform).grid(column=1,
                                                                    row=r,
                                                                    padx=1,
                                                                    pady=(1,
                                                                          1))

        r = 22
        self.displayPoints = IntVar(value='1')
        tk.Checkbutton(self.frame,
                       variable=self.displayPoints,
                       text='Show points',
                       command=self.validateAllLevelTransform).grid(column=2,
                                                                    row=r,
                                                                    padx=1,
                                                                    pady=(1,
                                                                          1))

        r = 24
        tk.Label(self.frame, textvariable=self.app.warningMsg,
                 fg='red').grid(column=2, columnspan=5, row=r, pady=(1, 1))
        #tk.Label(self.frame, text="test", bg='red').grid(column=2, columnspan=5, row=r, pady=(1,1))

        self.app.tRootX = np.array(self.app.oRootX)
        self.app.tRootY = np.array(self.app.oRootY)
        self.app.tTipX = np.array(self.app.oTipX)
        self.app.tTipY = np.array(self.app.oTipY)
        self.plotProfil()

    def changeSmooth(self):
        if self.app.smooth.get() == 1:
            self.nbrPointsBox['state'] = 'normal'
            self.repartitionBox['state'] = 'normal'
        else:
            self.nbrPointsBox['state'] = 'disabled'
            self.repartitionBox['state'] = 'disabled'
        self.validateAllLevelTransform()

    def validateAllLevelTransform(self):
        self.app.validateAll(self.level)

    def validateTransform(self):
        #at the end, tRoot and tTip are generated, and draw but do not take care of bloc and margin

        #convert List to numpy array
        self.app.tRootX = np.array(self.app.oRootX)
        self.app.tRootY = np.array(self.app.oRootY)
        self.app.tRootS = self.app.oRootS.copy()
        self.app.tTipX = np.array(self.app.oTipX)
        self.app.tTipY = np.array(self.app.oTipY)
        self.app.tTipS = self.app.oTipS.copy()

        #apply thickness
        if self.app.thicknessRoot.get() != 100.0:
            self.app.tRootY = self.app.tRootY * self.app.thicknessRoot.get(
            ) / 100
        if self.app.thicknessTip.get() != 100.0:
            self.app.tTipY = self.app.tTipY * self.app.thicknessTip.get() / 100
        #apply incidence
        if self.app.incidenceRoot.get() != 0:
            line = LineString(self.merge(
                self.app.tRootX,
                self.app.tRootY))  #create a linestring with a list of turple
            rotated = affinity.rotate(
                line,
                -1 * self.app.incidenceRoot.get())  #rotate the linestring
            rotatedXY = rotated.xy  #extract the coordinate
            self.app.tRootX = np.array(rotatedXY[0])
            self.app.tRootY = np.array(rotatedXY[1])
        if self.app.incidenceTip.get() != 0:
            line = LineString(self.merge(
                self.app.tTipX,
                self.app.tTipY))  #create a linestring with a list of turple
            rotated = affinity.rotate(
                line, -1 * self.app.incidenceTip.get())  #rotate the linestring
            rotatedXY = rotated.xy  #extract the coordinate
            self.app.tTipX = np.array(rotatedXY[0])
            self.app.tTipY = np.array(rotatedXY[1])
        # appy vertical invert
        if self.app.vInvertRoot.get() == 1:
            self.app.tRootY = self.app.tRootY * -1.0
            self.app.tRootX = np.flip(self.app.tRootX)
            self.app.tRootY = np.flip(self.app.tRootY)
        if self.app.vInvertTip.get() == 1:
            self.app.tTipY = self.app.tTipY * -1.0
            self.app.tTipX = np.flip(self.app.tTipX)
            self.app.tTipY = np.flip(self.app.tTipY)

        # Normalise the 2 profiles based on chords and apply covering on Root and Tip
        # Here we don't yet take care of position of bloc and of margin
        self.app.tRootX, self.app.tRootY = self.app.normaliseArrayProfil(
            self.app.tRootX, self.app.tRootY, self.app.cRoot.get())
        self.app.tTipX, self.app.tTipY = self.app.normaliseArrayProfil(
            self.app.tTipX, self.app.tTipY, self.app.cTip.get())
        #print("root after normalise", self.app.tRootX, self.app.tRootY)

        # apply smoothing (if asked) based on number of points and spreading repartition
        if self.app.smooth.get() == 1:
            self.app.tRootX, self.app.tRootY = self.changeNbrPoints(
                self.app.tRootX, self.app.tRootY)
            self.app.tTipX, self.app.tTipY = self.changeNbrPoints(
                self.app.tTipX, self.app.tTipY)

        # take care of covering
        self.applyCovering()

        # insert synchro points if they do not yet exist
        if len(self.app.tRootS) == 0 or len(self.app.tTipS) == 0:
            self.app.tRootS = self.addSynchroPoints(self.app.tRootX,
                                                    self.app.tRootY)
            self.app.tTipS = self.addSynchroPoints(self.app.tTipX,
                                                   self.app.tTipY)

        #self.printProfile("before simplify", self.app.tRootX , self.app.tRootY , self.app.tRootS)
        # reduce the number of points but keep the synchronisation; the parameter is the max error (in mm)
        if self.app.reducePoints.get() == 1:
            #self.app.tRootX , self.app.tRootY , self.app.tTipX , self.app.tTipY = self.simplify(0.01)
            self.app.tRootX, self.app.tRootY, self.app.tRootS = self.simplifyOneProfile(
                self.app.tRootX, self.app.tRootY, self.app.tRootS, 0.01)
            self.app.tTipX, self.app.tTipY, self.app.tTipS = self.simplifyOneProfile(
                self.app.tTipX, self.app.tTipY, self.app.tTipS, 0.01)
            #self.printProfile("after simplify", self.app.tRootX , self.app.tRootY , self.app.tRootS)
        # insert mid first and last points of profile as defined before covering when extend to original coord is requested
        self.applyKeepChord()

        #self.printProfile("Root X Y S" , self.app.tRootX, self.app.tRootY , self.app.tRootS)

    def printProfile(self, text, x, y, s):
        print(text)
        print("len x y s", len(x), len(y), len(s))
        if len(x) > 0 and len(x) == len(y) and len(x) == len(s):
            i = 0
            imax = len(x)
            while i < imax:
                print("   ", x[i], y[i], s[i])
                i += 1

    def addSynchroPoints(self, x, y):
        #create a list with the synchronisation point (4 = synchro; 0 = no synchro, 10 = synchro and no radiance)
        #first and last points are synchronisation points
        # point with the greatest X is also a synchro
        s = []
        if len(x) > 0:
            s = [0] * len(x)  # create a list with 0 every where
            s[0] = 4  # add synchro for the first and last point
            s[-1] = 4
            # find the point with max X
            maxX = np.max(x)
            # find the index of this point
            idxMax = np.where(x == maxX)  #return an array with indexes
            if len(idxMax) > 0 and len(idxMax[0]) > 0:
                r = idxMax[0][0]
                s[r] = 4
            else:
                r = 0  # not sure if it can happens
        return s

    def applyCovering(self):
        if self.app.covering.get() != 0:
            #save a copy of txxxx before covering because we use it after synchro when Extend Chord is ON
            self.nRootX = np.copy(self.app.tRootX)
            self.nRootY = np.copy(self.app.tRootY)
            self.nTipX = np.copy(self.app.tTipX)
            self.nTipY = np.copy(self.app.tTipY)
            self.app.tRootX, self.app.tRootY = self.applyOffset(
                self.nRootX, self.nRootY, self.app.covering.get())
            self.app.tTipX, self.app.tTipY = self.applyOffset(
                self.nTipX, self.nTipY, self.app.covering.get())

    def applyOffset(self, xN, yN, d):
        line = LineString(self.merge(
            xN, yN))  #create a linestring with a list of turple
        offLine = line.parallel_offset(d,
                                       side='right',
                                       resolution=16,
                                       join_style=2,
                                       mitre_limit=5)
        if "Multi" in str(type(offLine)):
            offLineXY = offLine[0].xy  #extract the coordinate
        else:
            offLineXY = offLine.xy  #extract the coordinate
        # there is a bug in the Offset function. With side = right, sequence is revered and have to be reversed afterward
        return np.array(list(reversed(offLineXY[0]))), np.array(
            list(reversed(offLineXY[1])))

    def applyKeepChord(self):
        if (self.app.keepChord.get() == 1) and (self.app.covering.get() != 0):
            #insert first and last points before applying offset (reuse nxxxx saved before covering)
            self.app.tRootX = np.insert(self.app.tRootX, 0, self.nRootX[0])
            self.app.tRootX = np.append(self.app.tRootX, self.nRootX[-1])
            self.app.tRootY = np.insert(self.app.tRootY, 0, self.nRootY[0])
            self.app.tRootY = np.append(self.app.tRootY, self.nRootY[-1])
            self.app.tTipX = np.insert(self.app.tTipX, 0, self.nTipX[0])
            self.app.tTipX = np.append(self.app.tTipX, self.nTipX[-1])
            self.app.tTipY = np.insert(self.app.tTipY, 0, self.nTipY[0])
            self.app.tTipY = np.append(self.app.tTipY, self.nTipY[-1])
            self.app.tRootS.insert(
                0, 10)  #insert a first point as synchro  and No radiance
            self.app.tRootS[
                -1] = 10  # convert last point as synchro  and No radiance
            self.app.tRootS.append(4)  #add a last point as synchro
            self.app.tTipS.insert(
                0, 10)  #insert a first point as synchro  and No radiance
            self.app.tTipS[
                -1] = 10  # convert last point as synchro  and No radiance
            self.app.tTipS.append(4)  #add a last point as synchro

    def changeNbrPoints(self, x, y):
        xnew = []
        ynew = []
        if len(x) > 0:
            # find the point with max X
            maxX = np.max(x)
            # find the index of this point
            idxMax = np.where(x == maxX)  #return an array with indexes
            if len(idxMax) > 0 and len(idxMax[0]) > 0:
                r = idxMax[0][0]
            else:
                r = 0  # not sure if it can happens
            # split extrados / intrados in 2 lines
            #print("r=",r)
            #print("x,y", x, y)
            eX = x[0:r + 1]
            eY = y[0:r + 1]
            iX = x[r:]
            iY = y[r:]
            #print("extrados avant=", eX, eY)

            mytck, myu = interpolate.splprep([eX, eY], k=1, s=0)
            arrayRepartition = np.linspace(0, 1,
                                           int(self.app.nbrPoints.get() /
                                               2))**self.app.repartition.get()
            arrayRepartitionExt = (np.flip(arrayRepartition) * -1) + 1
            eXnew, eYnew = interpolate.splev(arrayRepartitionExt, mytck)
            #print("arrayRepartition ext",arrayRepartitionExt)
            #print("extrados après", eXnew, eYnew)

            #print("intrados avant=", iX, iY)
            mytck, myu = interpolate.splprep([iX, iY], k=1, s=0)
            arrayRepartition = np.linspace(0, 1,
                                           int(self.app.nbrPoints.get() /
                                               2))**self.app.repartition.get()
            #print("arrayRepartition int",arrayRepartition)
            #arrayRepartition = np.flip(arrayRepartition)
            iXnew, iYnew = interpolate.splev(arrayRepartition, mytck)
            #print("intrados après",self.printDistance(iXnew, iYnew))

            xnew = np.concatenate([eXnew, iXnew[1:]])
            ynew = np.concatenate([eYnew, iYnew[1:]])
            #print("xy new=" , xnew , ynew)
        return xnew, ynew

        # change points repartition for extrados and then for intrados
        # merge both
        # add the first and last point if extend is selected

    def printDistance(self, x, y):
        imax = len(x)
        i = 0
        result = []
        while i < imax - 1:
            d1 = x[i + 1] - x[i]
            d2 = y[i + 1] - y[i]
            result.append(math.sqrt(d1 * d1 + d2 * d2))
            i += 1
        return result

    def updatePlotRoot(self):
        self.axesRoot.clear()
        self.axesRoot.axis('equal')
        self.lineRoot, = self.axesRoot.plot(self.app.tRootX,
                                            self.app.tRootY,
                                            color='red')
        if self.displayPoints.get() == 1:
            self.lineRoot, = self.axesRoot.plot(self.app.tRootX,
                                                self.app.tRootY, 'ro')
        self.canvasRoot.draw()

    def updatePlotTip(self):
        self.axesTip.clear()
        self.axesTip.axis('equal')
        self.axesTip.plot(self.app.tTipX, self.app.tTipY, color='blue')
        if self.displayPoints.get() == 1:
            self.axesTip.plot(self.app.tTipX, self.app.tTipY, 'bo')
        self.canvasTip.draw()

    def plotProfil(self):
        self.figRoot = Figure(figsize=(10, 3), dpi=100)
        self.axesRoot = self.figRoot.add_subplot(1, 1, 1)
        self.axesRoot.axis('equal')
        self.axesRoot.set_title('Root')
        self.lineRoot, = self.axesRoot.plot(self.app.tRootX,
                                            self.app.tRootY,
                                            color='red')
        self.canvasRoot = FigureCanvasTkAgg(
            self.figRoot, master=self.frame)  # A tk.DrawingArea.
        self.canvasRoot.draw()
        self.canvasRoot.get_tk_widget().grid(column=2,
                                             rowspan=10,
                                             row=0,
                                             padx=(10, 2),
                                             pady=(2, 2))

        self.figTip = Figure(figsize=(10, 3), dpi=100)
        self.axesTip = self.figTip.add_subplot(1, 1, 1)
        self.axesTip.axis('equal')
        self.axesTip.set_title('Tip')
        self.lineTip, = self.axesTip.plot(self.app.tTipX,
                                          self.app.tTipY,
                                          color='blue')
        self.canvasTip = FigureCanvasTkAgg(
            self.figTip, master=self.frame)  # A tk.DrawingArea.
        self.canvasTip.draw()
        self.canvasTip.get_tk_widget().grid(column=2,
                                            rowspan=10,
                                            row=10,
                                            padx=(10, 2),
                                            pady=(20, 2))

    def merge(self, list1, list2):
        merged_list = tuple(zip(list1, list2))
        return merged_list

    def unmerge(self, liste1):
        result1 = []
        result2 = []
        for t in liste1:
            result1.append(t[0])
            result2.append(t[1])
        return result1, result2

    def distPoint2(self, x1, x2, x3, y1, y2, y3):
        # calculate distance between point 2 and line 1-3
        # returned value is the power of 2 of the distance (avoid a square root)
        a = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
        b = (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2)
        c = (x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1)
        return a - (a * a + b * b + c * c + 2 *
                    (a * c - a * b - b * c)) / 4 / c

    def lookNextPoint(self, x, y, idx, errorMax):
        #look from idx up to max, for the next point to keep in order to keep the error less than a value
        # return the last point where the error is lower
        # if it is possible to go up to the end of the polyline, return the index of the last point
        iMax = len(x)
        i = idx + 2
        while i < iMax:
            j = idx + 1
            while j < i:
                h = self.distPoint2(x[idx], x[j], x[i], y[idx], y[j], y[i])
                if h > errorMax:
                    #print("idex max" , j , i)
                    return i - 1
                #print("idx, j , i ,h" , idx , j , i , h)
                j += 1
            i += 1
        #print("fin de iterHauteur")
        return iMax

    def lookNextSynchro(self, s, idx):
        #look from idx + 1 up to max, for the next synchro point
        # if it is possible to go up to the end of the polyline, return the index of the last point
        iMax = len(s)
        i = idx + 1
        while i < iMax:
            if s[i] > 0:
                return i
            i += 1
        return iMax

    """
    def simplify(self, errorMax):
        # remove points when a direct connection does not lead to to big error nor on Root nor on Tip
        # Keep always first and last points
        # Return the new Root and Tip in numpy arry
        i = 0
        errorMax2 = errorMax * errorMax #power of 2 because distance between points are calculated in power of 2
        iMax = len(self.app.tRootX)
        #always keep the first point
        rX = [self.app.tRootX[0]]
        rY = [self.app.tRootY[0]]
        tX = [self.app.tTipX[0]]
        tY = [self.app.tTipY[0]]
        while i < iMax:
            nextPointR = self.lookNextPoint(self.app.tRootX ,self.app.tRootY , i, errorMax2)
            nextPointT = self.lookNextPoint(self.app.tTipX ,self.app.tTipY , i, errorMax2)
            if nextPointR < nextPointT:
                i = nextPointR
            else:
                i = nextPointT
            if i < iMax: #add the point if we did not reach the end
                rX.append(self.app.tRootX[i])
                rY.append(self.app.tRootY[i])
                tX.append(self.app.tTipX[i])
                tY.append(self.app.tTipY[i])
        #add the last point in all cases
        rX.append(self.app.tRootX[iMax-1]) 
        rY.append(self.app.tRootY[iMax-1])
        tX.append(self.app.tTipX[iMax-1])
        tY.append(self.app.tTipY[iMax-1])
        return np.array(rX) , np.array(rY) , np.array(tX) , np.array(tY)
    """

    def simplifyOneProfile(self, x, y, s, errorMax):
        # remove points when a direct connection does not lead to to big error nor on Root nor on Tip
        # Keep always first and last points and synchro points
        # Return the new Root and Tip in numpy arry and new s in list
        i = 0
        errorMax2 = errorMax * errorMax  #power of 2 because distance between points are calculated in power of 2
        iMax = len(x)
        rX = []
        rY = []
        rS = []
        if iMax > 0:
            #always keep the first point
            rX.append(x[0])
            rY.append(y[0])
            rS.append(s[0])
            while i < iMax:
                nextPoint = self.lookNextPoint(x, y, i, errorMax2)
                nextSynchro = self.lookNextSynchro(
                    s, i)  #search next Synchro point
                if nextPoint < nextSynchro:
                    i = nextPoint
                else:
                    i = nextSynchro
                if i < iMax:  #add the point if we did not reach the end
                    rX.append(x[i])
                    rY.append(y[i])
                    rS.append(s[i])
            #add the last point in all cases
            #rX.append(x[iMax-1])
            #rY.append(y[iMax-1])
            #rS.append(s[iMax-1])
            return np.array(rX), np.array(rY), rS