예제 #1
0
 def test_setReportDelta(self):
     """tests setReportDelta
     """
     global mySum
     mySum = 0.
     ### define callback method ###
     def foo(val):
         global mySum
         mySum = mySum + val
         self.assertEqual(val, 1.0)
     tw = ThumbWheel(width=100, height=26, reportDelta=1)
     tw.callbacks.AddCallback(foo)
     tw.master.update()
     pause()
     for i in xrange(10):
         tw.computeNewValue(1.) # emulate mouse rotation
     self.assertEqual(tw.value,10.0)
     #check that the get method returns deltaValue when setReportDelta is True
     self.assertEqual(tw.get(), 1.0)
     #mySum will be 1.0 because the value is deltaVal and never changes
     #so the callback is only called once
     self.assertEqual(mySum, 1.0)
     tw.master.update()
     pause()
     tw.master.destroy()
예제 #2
0
 def test_setOneTurn(self):
     """tests setOneturn
     """
     tw = ThumbWheel(width=100, height=26)
     tw.configure(oneTurn=23.0)
     tw.master.update()
     self.assertEqual(tw.oneTurn,23.0)
     tw.master.update()
     pause()
     tw.master.destroy()
예제 #3
0
 def test_tw_lockincrement(self):
     """tests lockincrement
     """
     tw = ThumbWheel(size = 100)
     tw.opPanel.displayPanel(1)
     tw.master.update()
     pause()
     self.assertEqual(tw.opPanel.incr_entry.cget('state'),'disabled')
     tw.lockIncrementCB(1)
     self.assertEqual(tw.opPanel.incr_entry.cget('state'),'normal')    
     tw.opPanel.Dismiss_cb()
     tw.master.destroy()
예제 #4
0
 def test_tw_lockOneTurnCB(self):
     """tests lockoneturn
     """
     tw = ThumbWheel(size = 100)
     tw.opPanel.displayPanel(1)
     tw.lockOneTurnCB(1)
     tw.master.update()
     pause()
     self.assertEqual(tw.opPanel.sens_entry.cget('state'),'disabled')
     tw.lockOneTurnCB(0)
     self.assertEqual(tw.opPanel.sens_entry.cget('state'),'normal')
     tw.opPanel.Dismiss_cb()
     tw.master.destroy()
예제 #5
0
 def test_setContinuous(self):
     """tests setContinuous
     """
     tw = ThumbWheel(width=100, height=26)
     tw.configure(continuous=1)
     tw.master.update()
     pause()
     self.assertEqual(tw.continuous,(1 or True))
     tw.configure(continuous=0)
     self.assertEqual(tw.continuous,(0 or False))
     tw.master.update()
     pause()
     tw.master.destroy()
예제 #6
0
    def __init__(self, tasks, root=None):

        # create panel if needed
        if root is None:
            root = Tkinter.Toplevel()
            root.title("Execution profile")
            self.ownsMaster = True
        else:
            assert isinstance(root, Tkinter.Toplevel) or\
                   isinstance(root, Tkinter.Frame)
            self.ownsMaster = False
        self.root = root

        self.pixelsPersecond = 100
        self.yoff = 20
        self.scale = 1.0

        self.scrolledCanvas = Pmw.ScrolledCanvas(root,
                                                 canvas_width=600,
                                                 canvas_bg='white',
                                                 vscrollmode='static',
                                                 hscrollmode='static',
                                                 horizscrollbar_width=10,
                                                 vertscrollbar_width=10)
        self.canvas = self.scrolledCanvas.component('canvas')
        self.scrollregion = [0, 0, 4000, 4000]
        self.canvas.configure(scrollregion=tuple(self.scrollregion))

        self.scrolledCanvas.pack(expand=True, fill='both')

        f = self.bframe = Tkinter.Frame(root)

        self.scaleTimeTW = ThumbWheel(f,
                                      showLabel=0,
                                      width=70,
                                      height=16,
                                      type=float,
                                      value=0,
                                      callback=self.setTimeScaleFactor_cb,
                                      continuous=True,
                                      oneTurn=10,
                                      wheelPad=2,
                                      reportDelta=True)
        self.scaleTimeTW.pack(side='right', anchor='e')

        f.pack(side='bottom', expand=0, fill='x')

        self.relativeData = []
        self.setTasks(tasks)
예제 #7
0
 def test_setOrient_vertical_to_horizontal(self):
     """tests setOrient horizontal
     """
     tw = ThumbWheel(width=100, height=50,orient = 'vertical')
     tw.setOrient('horizontal')
     tw.set(100)
     tw.master.update()
     pause()
     tw.lasty =100
     myevent = Dummyevent(y = 100,x =100)
     tw.mouseDown(myevent)
     tw.mouseMove(myevent)
     self.assertEqual(tw.orient,'horizontal')
     tw.master.update()
     pause()
     tw.master.destroy()
예제 #8
0
    def test_setMax(self):
        global wasCalled
        # test that we do not call the callback when we set the maximum value
        def foo(val):
            global wasCalled
#           print "I should not be called"
            wasCalled=1
        tw = ThumbWheel(width=100, height=26)
        tw.callbacks.AddCallback(foo)
        tw.master.update()
        pause()
        wasCalled=0
        # set the value without calling callback
        tw.setValue(4)
        # change maximum without affecting value ==> nocallback
        tw.configure(max=6)
        if wasCalled:
            raise RuntimeError
        # change maximum with affecting value ==> callback
        tw.configure(max=2)
        if wasCalled==0:
            raise RuntimeError
        tw.master.update()
        pause()
        tw.master.destroy()
예제 #9
0
    def test_setMin(self):
        global wasCalled
        # test that we do not call the callback when we set the minimum value
        def foo(val):
            global wasCalled
#           print "I should not be called"
            wasCalled=1

        from mglutil.gui.BasicWidgets.Tk.thumbwheel import ThumbWheel
    
        tw = ThumbWheel(width=100, height=26)
        tw.callbacks.AddCallback(foo)
        wasCalled=0
        # set the value without calling callback
        tw.setValue(4)
        # change minimum without affecting value ==> nocallback
        tw.configure(min=2)
        tw.master.update()
        pause()
        if wasCalled:
            raise RuntimeError
        # change minimum with affecting value ==> callback
        tw.configure(min=6)
        if wasCalled==0:
            raise RuntimeError
        tw.master.update()
        pause()
        tw.master.destroy()
예제 #10
0
    def test_callback_3(self):
        global wasCalled1
        global wasCalled2
        
        def foo1(val):
            global wasCalled1
            wasCalled1=True

        def foo2(val):
            global wasCalled2
            wasCalled2=True
            
        root = Tkinter.Tk()
        tw = ThumbWheel(width=100, height=26, master=root, callback=[foo1, foo2])
        self.assertEqual(tw.callbacks.callbacks, [foo1,foo2], "Expecting to have foo added to the callbackmanager callbacks list")
        # setValue(val) should NOT call callback
        wasCalled1 = False
        wasCalled2 = False
        tw.setValue(5.0)
        if wasCalled1 and wasCalled2:
            raise RuntimeError

        # set(val) should call callback
        tw.set(6.0)
        if not wasCalled1 and not wasCalled2:
            raise RuntimeError

        wasCalled1 = False
        wasCalled2 = False
        tw.set(7.0, update=0)
        if wasCalled1 and wasCalled2:
            raise RuntimeError
        tw.master.update()
        pause()
        tw.master.destroy()
예제 #11
0
 def test_callback_1(self):
     global wasCalled
     def foo(val):
         global wasCalled
         wasCalled=True
     root = Tkinter.Tk()
     tw = ThumbWheel(width=100, height=26,master = root)
     tw.callbacks.AddCallback(foo)
     # setValue(val) should NOT call callback
     wasCalled = 0
     tw.setValue(5.0)
     #tw.master.update()
     if wasCalled:
         raise RuntimeError
     # set(val) should call callback
     tw.set(6.0)
     if not wasCalled:
         raise RuntimeError
     wasCalled = False
     tw.set(7.0, update=0)
     if wasCalled:
         raise RuntimeError
     tw.master.update()
     pause()
     tw.master.destroy()
예제 #12
0
 def test_callback_2(self):
     global wasCalled
     def foo(val):
         global wasCalled
         wasCalled=True
     root = Tkinter.Tk()
     tw = ThumbWheel(width=100, height=26, master=root, callback=foo)
     self.assertEqual(tw.callbacks.callbacks, [foo,], "Expecting to have foo added to the callbackmanager callbacks list")
     #tw.callbacks.AddCallback(foo)
     # setValue(val) should NOT call callback
     wasCalled = 0
     tw.setValue(5.0)
     #tw.master.update()
     if wasCalled:
         raise RuntimeError
     # set(val) should call callback
     tw.set(6.0)
     if not wasCalled:
         raise RuntimeError
     wasCalled = False
     tw.set(7.0, update=0)
     if wasCalled:
         raise RuntimeError
     tw.master.update()
     pause()
     tw.master.destroy()
예제 #13
0
 def test_setType(self):
     # test setting of type
     tw = ThumbWheel(width=100, height=26, type='float')
     tw.set(100.0)
     # we can mix configure(type=float) and configure(type='float')
     tw.configure(type=float)
     self.assertEqual(tw.type,float)
     self.assertEqual(type(tw.get()),type(1.0))
     tw.configure(type='int')
     tw.master.update()
     pause()
     self.assertEqual(tw.type,int)
     self.assertEqual(type(tw.get()),type(1))
     tw.master.update()
     pause()
     tw.master.destroy()
    def createEntries(self, master):
        self.f = Tkinter.Frame(master)
	self.f.grid(column=1, rowspan=6)

        self.entryX = NormVectEntry(master=self.f, label='Vector X', width=18)
        self.entryX.grid(row=0,column=0)
        self.entryX.callbacks.AddCallback(self.entryX_cb)

        self.thumbx = ThumbWheel(master=self.f, width=self.widthX,
                                 height=self.heightX, labcfg=self.labcfgX,
                                 wheelPad=self.wheelPadX)
        self.thumbx.callbacks.AddCallback(self.thumbx_cb)
        self.thumbx.grid(row=1, column=0)

        self.entryY = NormVectEntry(master=self.f, label='Vector Y', width=18)
        self.entryY.grid(row=2,column=0)
        self.entryY.callbacks.AddCallback(self.entryY_cb)


        self.thumby = ThumbWheel(master=self.f, width=self.widthY,
                                 height=self.heightY, labcfg=self.labcfgY,
                                 wheelPad=self.wheelPadY)
        self.thumby.callbacks.AddCallback(self.thumby_cb)
        self.thumby.grid(row=3, column=0)

        self.entryZ = NormVectEntry(master=self.f, label='Vector Z', width=18)
        self.entryZ.grid(row=4,column=0)
        self.entryZ.callbacks.AddCallback(self.entryZ_cb)


        self.thumbz = ThumbWheel(master=self.f, width=self.widthZ,
                                 height=self.heightZ, labcfg=self.labcfgZ,
                                 wheelPad=self.wheelPadZ)
        self.thumbz.callbacks.AddCallback(self.thumbz_cb)
        self.thumbz.grid(row=5, column=0)

        self.f.pack(side='top', expand=1)

        self.setVector([1.0,0,0],'x')
        self.setVector([0.0,1,0],'y')
        self.setVector([0.0,0,1],'z')
예제 #15
0
 def test_setIncrement(self):
     #THIS IS A BUG
     #it is not working correctly
     tw = ThumbWheel(width=100, height=26)
     tw.set(5.0)
     tw.master.update()
     pause()
     tw.configure(increment=10)
     tw.set(24.0)
     self.assertEqual(tw.increment,10.0)
     #24 is shown instead of 25
     self.assertEqual(tw.get(),24.0)
     tw.master.update()
     pause()
     tw.master.destroy()
예제 #16
0
 def test_setShowLabel(self):
     """tests setShowLAbel
     """
     tw = ThumbWheel(width=100, height=26)
     tw.configure(showLabel=0)
     self.assertEqual(tw.showLabel,0)
     tw.configure(showLabel=1)
     tw.master.update()
     pause()
     self.assertEqual(tw.showLabel,1)
     tw.configure(showLabel=2)
     self.assertEqual(tw.showLabel,2)
     tw.master.update()
     pause()
     tw.master.destroy()
예제 #17
0
 def test_setValue(self):
     # test setting of a value
     root = Tkinter.Tk()
     tw = ThumbWheel(width=100, height=26, value=1.0,master = root)
     tw.set(10)
     tw.master.update()
     #tw.master.update()
     pause()
     self.assertEqual(tw.value,10.0)
     tw.configure(type=float)
     tw.set(20.0)
     tw.master.update()
     #tw.master.update()
     pause()
     self.assertEqual(tw.value,20.0)
     tw.master.destroy()
예제 #18
0
    def __init__(self, tasks, root=None):

        # create panel if needed
        if root is None:
            root = Tkinter.Toplevel()
            root.title("Execution profile")
            self.ownsMaster = True
        else:
            assert isinstance(root, Tkinter.Toplevel) or\
                   isinstance(root, Tkinter.Frame)
            self.ownsMaster = False
        self.root = root

        self.pixelsPersecond = 100
        self.yoff = 20
        self.scale = 1.0
        
        self.scrolledCanvas = Pmw.ScrolledCanvas(
            root, canvas_width=600, canvas_bg='white',
            vscrollmode='static', hscrollmode='static',
            horizscrollbar_width=10, vertscrollbar_width=10)
        self.canvas = self.scrolledCanvas.component('canvas')
        self.scrollregion=[0 , 0, 4000, 4000]
        self.canvas.configure(scrollregion=tuple(self.scrollregion))

        self.scrolledCanvas.pack(expand=True, fill='both')

        f = self.bframe = Tkinter.Frame(root)
        
        self.scaleTimeTW = ThumbWheel(
            f, showLabel=0, width=70, height=16, type=float, value=0,
            callback=self.setTimeScaleFactor_cb, continuous=True, oneTurn=10,
            wheelPad=2, reportDelta=True)
        self.scaleTimeTW.pack(side='right', anchor='e')

        f.pack(side='bottom', expand=0, fill='x')
        
        self.relativeData = []
        self.setTasks(tasks)
예제 #19
0
    def createEntries(self, master):
        self.f = Tkinter.Frame(master)
        self.f.grid(column=1, rowspan=6)

        self.entryX = NormVectEntry(master=self.f, label='Vector X', width=18)
        self.entryX.grid(row=0, column=0)
        self.entryX.callbacks.AddCallback(self.entryX_cb)

        self.thumbx = ThumbWheel(master=self.f,
                                 width=self.widthX,
                                 height=self.heightX,
                                 labcfg=self.labcfgX,
                                 wheelPad=self.wheelPadX)
        self.thumbx.callbacks.AddCallback(self.thumbx_cb)
        self.thumbx.grid(row=1, column=0)

        self.entryY = NormVectEntry(master=self.f, label='Vector Y', width=18)
        self.entryY.grid(row=2, column=0)
        self.entryY.callbacks.AddCallback(self.entryY_cb)

        self.thumby = ThumbWheel(master=self.f,
                                 width=self.widthY,
                                 height=self.heightY,
                                 labcfg=self.labcfgY,
                                 wheelPad=self.wheelPadY)
        self.thumby.callbacks.AddCallback(self.thumby_cb)
        self.thumby.grid(row=3, column=0)

        self.entryZ = NormVectEntry(master=self.f, label='Vector Z', width=18)
        self.entryZ.grid(row=4, column=0)
        self.entryZ.callbacks.AddCallback(self.entryZ_cb)

        self.thumbz = ThumbWheel(master=self.f,
                                 width=self.widthZ,
                                 height=self.heightZ,
                                 labcfg=self.labcfgZ,
                                 wheelPad=self.wheelPadZ)
        self.thumbz.callbacks.AddCallback(self.thumbz_cb)
        self.thumbz.grid(row=5, column=0)

        self.f.pack(side='top', expand=1)

        self.setVector([1.0, 0, 0], 'x')
        self.setVector([0.0, 1, 0], 'y')
        self.setVector([0.0, 0, 1], 'z')
예제 #20
0
 def __init__(self,master=None,callback=None,continuous=1):
            
     self.master=master
     self.callback = None
     self.callbacks = CallbackManager()
     self.canvas=canvas = Canvas(self.master,width=345,height=320,bg='white') 
     self.toolbar = Frame(master)             # Create Toolbar
     self.toolbar.pack(side='top', expand=1, fill='both') 
     self.menuFrame1 = Tkinter.Frame(self.toolbar, relief='raised', borderwidth=3)
     self.menuFrame1.pack(side='top', expand=1, fill='x')
     self.filebutton = Tkinter.Menubutton(self.menuFrame1, text='File')
     self.filebutton.pack(side='left')
     self.filemenu = Tkinter.Menu(self.filebutton, {})
     self.filemenu.add_command(label='Read', command=self.read_cb)
     self.filemenu.add_command(label='Write', command=self.write_cb)
     self.filebutton['menu'] = self.filemenu
     self.editbutton = Tkinter.Menubutton(self.menuFrame1, text='Edit')
     self.editbutton.pack(side='left', anchor='w')
     self.editmenu = Tkinter.Menu(self.editbutton, {})
     self.editmenu.add_command(label='Reset to first in history', command=self.resetAll_cb)
     self.editmenu.add_command(label='Step back in history loop', command=self.stepBack_cb)
     self.editmenu.add_command(label='Default Curve', command=self.defaultcurve_cb)
     self.editmenu.add_command(label='Invert Curve',command=self.invertGraph)
     self.histvar=IntVar()
     self.histvar.set(1)
     self.editmenu.add_checkbutton(label='Histogram',var=self.histvar,command=self.drawHistogram)
     self.editbutton['menu'] = self.editmenu
     self.optionType = IntVar()
     self.updatebutton = Tkinter.Menubutton(self.menuFrame1, text='Update')
     self.updatebutton.pack(side='left', anchor='w')
     self.updatemenu = Tkinter.Menu(self.updatebutton,{} )
     for v,s in {0:'Continuous',1:'MouseButtonUp',2:'Update'}.items():
         self.updatemenu.add_radiobutton(label=s,
                             var=self.optionType,
                             value = v,command=self.calloption)
     if continuous==1:
         self.optionType.set(0)
     self.updatebutton['menu'] = self.updatemenu
     #Curve Type
     self.CurveType = IntVar()
     self.CurveType.set(0) 
     self.Smooth=1
     self.curvebutton = Tkinter.Menubutton(self.menuFrame1, text='Curve')
     self.curvebutton.pack(side='left', anchor='w')
     self.curvemenu = Tkinter.Menu(self.curvebutton,{} )
     for v,s in {0:'Smooth',1:'Freehand'}.items():
         self.curvemenu.add_radiobutton(label=s,
                             var=self.CurveType,
                             value = v,command=self.curveoption)
     
         
     self.curvebutton['menu'] = self.curvemenu
     f1 = Tkinter.Frame(self.master)
     f1.pack(side='bottom', fill='both', expand=1)
     self.d1scalewheellab=Label(f1,text="Sensitivity")
     self.d1scalewheellab.pack(side="left")
     self.d1scalewheel=ThumbWheel(width=100, height=26,wheelPad=4,master=f1,labcfg={'fg':'black', 'side':'left', 'text':'Test:'},wheelLabcfg1={'font':(ensureFontCase('times'),14,'bold')},wheelLabcfg2={'font':(ensureFontCase('times'),14,'bold')},canvascfg={'bg':'blue'},min = 0.0,max = 1.0,precision =4,showlabel =0,value =0.013,continuous =0,oneTurn =0.01,size = 200)
     self.d1scalewheel.pack(side="left")
     #tooltip
     self.balloon = Pmw.Balloon(f1)
     self.balloon.bind(self.d1scalewheel,"cutoff value for differences in Z xoordinates,small values generate more contours")
     self.Updatebutton=Button(f1,text='  Update  ',command=self.Update)
     self.Updatebutton.pack(side=LEFT)
     
     self.Quitbutton=Button(f1,text=' Dismiss ',command=self.dismiss_cb)
     self.Quitbutton.pack(side=RIGHT)
     self.canvas.bind("<Button-1>", self.OnCanvasClicked)
     self.canvas.bind("<B1-Motion>", self.OnCanvasMouseDrag)
     self.canvas.bind("<ButtonRelease-1>", self.OnCanvasMouseUp)
     self.canvas.config(closeenough=2.0)
     self.canvas.pack(side=BOTTOM, fill=BOTH,expand=1)
     self.startpoint=(px,py)=(50,275)
     self.endpoint=(px1,py1)=(305,20)
     self.newpoints=[(px,py),(px1,py1)]
     self.canvas.create_rectangle([(px-1,py),(px1+1,py1)],fill='white',outline="black",width=1)
     self.canvas.create_text(46,281,text=0,anchor=N)
               
     #Drawing Graph Sheet
     for i in range(1,6):
         x=50+i*50
         canvas.create_line(x,280,x,275,width=1)
         canvas.create_text(x,281,text='%d' %(50*i),anchor=N)
     for i in range(1,5):
         x=50+i*50
         canvas.create_line(x,275,x,20,width=1,fill="gray80")
     for i in range(1,6):
         y=275-i*50
         canvas.create_line(45,y,50,y,width=1)
         canvas.create_text(44,y,text='%d' %(50*i),anchor=E)
     for i in range(1,5):
         y=275-i*50
         canvas.create_line(50,y,305,y,width=1,fill="gray80")
     (x,y)=self.newpoints[0]
     (x1,y1)=self.newpoints[-1]
     self.curline=canvas.create_line(self.newpoints,fill='black',width=1)
     
     #GRAY SCALE
     grays=[]
     for i in range(0,100,1):
         grays.append("gray"+"%d" %i)
     #grays.reverse()
     #bottom one
     x1=48
     x2=51
     self.canvas.create_rectangle([(50,315),(307,300)],fill='white',outline="black",width=0.5)
     for a in grays:
         if x1>306:
             
            x1=x2=306
         self.canvas.create_rectangle([(x1+2.5,314),(x2+2.5,301)],fill=a,outline=a,width=1)
         x1=x1+2.5
         x2=x2+2.5
     #left one
     y1=274
     y2=271
     self.canvas.create_rectangle([(20,275),(5,20)],fill='black',outline="black",width=0.5)
     for a in grays:
         if y1>275:
             y1=y2=275
         self.canvas.create_rectangle([(19,y1-2.5),(6,y2-2.5)],fill=a,outline=a,width=1)    
         y1=y1-2.5
         y2=y2-2.5
           
     self.oldpoints=[]
     self.canvas.configure(cursor='cross')
     self.curovals=[]
     self.default_points=[(50,275),(88, 238), (101, 150), (154, 78), (75, 271),(305,20)]
     # now set the constructor options correctly using the configure method
     apply( self.configure, (),{'callback':callback,'continuous':continuous})
     self.continuous=continuous
     self.mousebuttonup=0
     self.update=0
     self.range_points=[]
     self.history=[]
     self.bars=[]
     self.default_ramp=[]
     self.histvalues=[]
예제 #21
0
    def __init__(self, master=None, viewerGui=None):

        if master is None:
            self.master = Tkinter.Toplevel()
            self.master.withdraw()
            self.master.title('Selection Settings')
            self.master.protocol('WM_DELETE_WINDOW', self.master.withdraw)
        else:
            self.master = master

        self.mainFrame = Tkinter.Frame(self.master,
                                       relief='ridge',
                                       borderwidth=3)

        # CONTOUR WIDTH
        if DejaVu.enableSelectionContour is True:
            lLabel = Tkinter.Label(self.mainFrame, text='Contour width:')
            lLabel.grid(row=0, column=0, sticky='w')
            self.contourSizeSlider = Slider.Slider(self.mainFrame,
                                                   minval=0,
                                                   maxval=10,
                                                   immediate=1,
                                                   incr=1,
                                                   labelformat='%d',
                                                   cursortype='int')
            self.contourSizeSlider.frame.grid(row=0, column=1, columnspan=3)

            def setContourWidthSliderValue_cb(val):
                DejaVu.selectionContourSize = val
                viewerGui.viewer.Redraw()

            self.contourSizeSlider.AddCallback(setContourWidthSliderValue_cb)
        else:
            lLabel = Tkinter.Label(self.mainFrame,
                                   text='Contour selection is disabled')
            lLabel.grid(row=0, column=0, columnspan=3, sticky='w')

        # BACKGROUND COLOR
        lLabel = Tkinter.Label(self.mainFrame, text='Contour color:')
        lLabel.grid(row=1, column=0, sticky='w')
        lFunc = CallBackFunction(viewerGui.colorChooser.showColorChooser,
                                 'selection contour')
        self.contourColorButton = Tkinter.Button(
            self.mainFrame,
            #text='Contour color',
            width=7,
            background=TkColor(DejaVu.selectionContourColor),
            command=lFunc)
        self.contourColorButton.grid(row=1, column=1, columnspan=3)

        # PATTERN SIZE
        lLabel = Tkinter.Label(self.mainFrame, text='Pattern size:')
        lLabel.grid(row=2, column=0, sticky='w')

        def setPatternSizeSliderValue_cb(val):
            DejaVu.selectionPatternSize = val
            viewerGui.viewer.Redraw()

        self.patternSizeThumbwheel = ThumbWheel(
            self.mainFrame,
            width=70,
            height=16,
            type=int,
            value=DejaVu.selectionPatternSize,
            callback=setPatternSizeSliderValue_cb,
            continuous=True,
            oneTurn=10,
            wheelPad=2,
            min=0,
            max=50)
        self.patternSizeThumbwheel.grid(row=2, column=1, columnspan=3)

        self.mainFrame.pack(side='top')

        self.updateWidgets()
예제 #22
0
class GraphApp:
    
      
    # Initialization
    def __init__(self,master=None,callback=None,continuous=1):
               
        self.master=master
        self.callback = None
        self.callbacks = CallbackManager()
        self.canvas=canvas = Canvas(self.master,width=345,height=320,bg='white') 
        self.toolbar = Frame(master)             # Create Toolbar
        self.toolbar.pack(side='top', expand=1, fill='both') 
        self.menuFrame1 = Tkinter.Frame(self.toolbar, relief='raised', borderwidth=3)
        self.menuFrame1.pack(side='top', expand=1, fill='x')
        self.filebutton = Tkinter.Menubutton(self.menuFrame1, text='File')
        self.filebutton.pack(side='left')
        self.filemenu = Tkinter.Menu(self.filebutton, {})
        self.filemenu.add_command(label='Read', command=self.read_cb)
        self.filemenu.add_command(label='Write', command=self.write_cb)
        self.filebutton['menu'] = self.filemenu
        self.editbutton = Tkinter.Menubutton(self.menuFrame1, text='Edit')
        self.editbutton.pack(side='left', anchor='w')
        self.editmenu = Tkinter.Menu(self.editbutton, {})
        self.editmenu.add_command(label='Reset to first in history', command=self.resetAll_cb)
        self.editmenu.add_command(label='Step back in history loop', command=self.stepBack_cb)
        self.editmenu.add_command(label='Default Curve', command=self.defaultcurve_cb)
        self.editmenu.add_command(label='Invert Curve',command=self.invertGraph)
        self.histvar=IntVar()
        self.histvar.set(1)
        self.editmenu.add_checkbutton(label='Histogram',var=self.histvar,command=self.drawHistogram)
        self.editbutton['menu'] = self.editmenu
        self.optionType = IntVar()
        self.updatebutton = Tkinter.Menubutton(self.menuFrame1, text='Update')
        self.updatebutton.pack(side='left', anchor='w')
        self.updatemenu = Tkinter.Menu(self.updatebutton,{} )
        for v,s in {0:'Continuous',1:'MouseButtonUp',2:'Update'}.items():
            self.updatemenu.add_radiobutton(label=s,
                                var=self.optionType,
                                value = v,command=self.calloption)
        if continuous==1:
            self.optionType.set(0)
        self.updatebutton['menu'] = self.updatemenu
        #Curve Type
        self.CurveType = IntVar()
        self.CurveType.set(0) 
        self.Smooth=1
        self.curvebutton = Tkinter.Menubutton(self.menuFrame1, text='Curve')
        self.curvebutton.pack(side='left', anchor='w')
        self.curvemenu = Tkinter.Menu(self.curvebutton,{} )
        for v,s in {0:'Smooth',1:'Freehand'}.items():
            self.curvemenu.add_radiobutton(label=s,
                                var=self.CurveType,
                                value = v,command=self.curveoption)
        
            
        self.curvebutton['menu'] = self.curvemenu
        f1 = Tkinter.Frame(self.master)
        f1.pack(side='bottom', fill='both', expand=1)
        self.d1scalewheellab=Label(f1,text="Sensitivity")
        self.d1scalewheellab.pack(side="left")
        self.d1scalewheel=ThumbWheel(width=100, height=26,wheelPad=4,master=f1,labcfg={'fg':'black', 'side':'left', 'text':'Test:'},wheelLabcfg1={'font':(ensureFontCase('times'),14,'bold')},wheelLabcfg2={'font':(ensureFontCase('times'),14,'bold')},canvascfg={'bg':'blue'},min = 0.0,max = 1.0,precision =4,showlabel =0,value =0.013,continuous =0,oneTurn =0.01,size = 200)
        self.d1scalewheel.pack(side="left")
        #tooltip
        self.balloon = Pmw.Balloon(f1)
        self.balloon.bind(self.d1scalewheel,"cutoff value for differences in Z xoordinates,small values generate more contours")
        self.Updatebutton=Button(f1,text='  Update  ',command=self.Update)
        self.Updatebutton.pack(side=LEFT)
        
        self.Quitbutton=Button(f1,text=' Dismiss ',command=self.dismiss_cb)
        self.Quitbutton.pack(side=RIGHT)
        self.canvas.bind("<Button-1>", self.OnCanvasClicked)
        self.canvas.bind("<B1-Motion>", self.OnCanvasMouseDrag)
        self.canvas.bind("<ButtonRelease-1>", self.OnCanvasMouseUp)
        self.canvas.config(closeenough=2.0)
        self.canvas.pack(side=BOTTOM, fill=BOTH,expand=1)
        self.startpoint=(px,py)=(50,275)
        self.endpoint=(px1,py1)=(305,20)
        self.newpoints=[(px,py),(px1,py1)]
        self.canvas.create_rectangle([(px-1,py),(px1+1,py1)],fill='white',outline="black",width=1)
        self.canvas.create_text(46,281,text=0,anchor=N)
                  
        #Drawing Graph Sheet
        for i in range(1,6):
            x=50+i*50
            canvas.create_line(x,280,x,275,width=1)
            canvas.create_text(x,281,text='%d' %(50*i),anchor=N)
        for i in range(1,5):
            x=50+i*50
            canvas.create_line(x,275,x,20,width=1,fill="gray80")
        for i in range(1,6):
            y=275-i*50
            canvas.create_line(45,y,50,y,width=1)
            canvas.create_text(44,y,text='%d' %(50*i),anchor=E)
        for i in range(1,5):
            y=275-i*50
            canvas.create_line(50,y,305,y,width=1,fill="gray80")
        (x,y)=self.newpoints[0]
        (x1,y1)=self.newpoints[-1]
        self.curline=canvas.create_line(self.newpoints,fill='black',width=1)
        
        #GRAY SCALE
        grays=[]
        for i in range(0,100,1):
            grays.append("gray"+"%d" %i)
        #grays.reverse()
        #bottom one
        x1=48
        x2=51
        self.canvas.create_rectangle([(50,315),(307,300)],fill='white',outline="black",width=0.5)
        for a in grays:
            if x1>306:
                
               x1=x2=306
            self.canvas.create_rectangle([(x1+2.5,314),(x2+2.5,301)],fill=a,outline=a,width=1)
            x1=x1+2.5
            x2=x2+2.5
        #left one
        y1=274
        y2=271
        self.canvas.create_rectangle([(20,275),(5,20)],fill='black',outline="black",width=0.5)
        for a in grays:
            if y1>275:
                y1=y2=275
            self.canvas.create_rectangle([(19,y1-2.5),(6,y2-2.5)],fill=a,outline=a,width=1)    
            y1=y1-2.5
            y2=y2-2.5
              
        self.oldpoints=[]
        self.canvas.configure(cursor='cross')
        self.curovals=[]
        self.default_points=[(50,275),(88, 238), (101, 150), (154, 78), (75, 271),(305,20)]
        # now set the constructor options correctly using the configure method
        apply( self.configure, (),{'callback':callback,'continuous':continuous})
        self.continuous=continuous
        self.mousebuttonup=0
        self.update=0
        self.range_points=[]
        self.history=[]
        self.bars=[]
        self.default_ramp=[]
        self.histvalues=[]
        
    def calloption(self):
        tag=self.optionType.get()
        self.continuous=0
        self.mousebuttonup=0
        self.update=0
        if tag==0:
            self.continuous=1
        elif tag==1:
            self.mousebuttonup=1
        elif tag==2:    
            self.update=1
        
    def curveoption(self):
        tag=self.CurveType.get()
        self.Smooth=0
        self.Freehand=0
        if tag==0:
            self.Smooth=1
            self.canvas.delete(self.curline)
            self.curline=self.canvas.create_line(self.getControlPoints(),smooth=1)
        elif tag==1:
            self.Freehand=1
            self.canvas.delete(self.curline)
            self.curline=self.canvas.create_line(self.getControlPoints())
            
    def OnCanvasClicked(self,event):
        """Appends last drag point to controlpoint list if not appended by mouseleave func.
        when clicked on any controlpoint removes control point and draws line with remaining 
        control points.""" 
        self.CLICK_NODRAG=1 
        if self.history!=[]:
            if self.history[-1][1]!=self.d1scalewheel.get():
                self.history[-1]=(self.history[-1][0],self.d1scalewheel.get())
        if hasattr(self,"curx"): 
            if (self.curx,self.cury) :#not in [self.startpoint,self.endpoint]:
                (self.ox,self.oy)=(self.curx,self.cury)
                if (self.ox,self.oy) not in self.oldpoints:
                    self.oldpoints.append((self.ox,self.oy))
                    if hasattr(self,"curoval"):
                        self.curovals.append(self.curoval)
        self.OrgX=event.x
        self.OrgY=event.y
        CtlPoints=[]
        xcoords=[]
        ycoords=[]
        #Limiting points not to cross
        self.limit_xcoord=[]
        for i in range(0,10):
            xcoords.append(self.OrgX-i)
            ycoords.append(self.OrgY-i)
            xcoords.append(self.OrgX+i)
            ycoords.append(self.OrgY+i)
            
        if xcoords!=[] and ycoords!=[]:
            for x in xcoords:
                for y in ycoords:
                    CtlPoints.append((x,y))
            self.range_points=self.oldpoints
            self.range_points.sort()
            for c in CtlPoints:
             if  c in self.range_points:
                    index_c=self.range_points.index(c)
                    if index_c<len(self.range_points)-1:
                        self.limit_xcoord.append(self.range_points[index_c+1])
                        
                        if index_c>0:
                            self.limit_xcoord.append(self.range_points[index_c-1])
                            return
                        else:
                            self.limit_xcoord.append(self.startpoint)
                            return
                    elif index_c==len(self.range_points)-1:
                        self.limit_xcoord.append(self.range_points[index_c-1])
                        self.limit_xcoord.append(self.endpoint)
                        return 
        self.newd1ramp= self.caluculate_ramp()
        
    
    def OnCanvasMouseUp(self,event):
             
        CtlPoints=[]
        xcoords=[]
        ycoords=[]
        if hasattr(self,"curx"): 
            (self.ox,self.oy)=(self.curx,self.cury)
            if (self.ox,self.oy) not in self.oldpoints :#not in [self.startpoint,self.endpoint] :
                self.oldpoints.append((self.ox,self.oy))     
                if hasattr(self,"curoval"):
                    if self.curoval not in self.curovals:
                        self.curovals.append(self.curoval)
        
        if self.CLICK_NODRAG==1:
         #finding out points around the selected point
         for i in range(0,10):
            xcoords.append(self.OrgX-i)
            ycoords.append(self.OrgY-i)
            xcoords.append(self.OrgX+i)
            ycoords.append(self.OrgY+i)
            
         if xcoords!=[] and ycoords!=[]:
            for x in xcoords:
                for y in ycoords:
                    CtlPoints.append((x,y))
            
            for c in CtlPoints:
             if  c in self.oldpoints:
                ind=self.oldpoints.index(c)
                op=self.oldpoints[ind]
                if ind>0:
                    prev_oldpoint=self.oldpoints[ind-1]
                else:
                    prev_oldpoint=self.endpoint
                del self.oldpoints[ind]
                
                for co in self.curovals:
                    ov_point1=self.canvas.coords(co)
                    if len(ov_point1)!=0:
                        ov_point=(int(ov_point1[0]+2),int(ov_point1[1]+2))
                                    
                        if ov_point==c  and ov_point not in [self.startpoint,self.endpoint]:
                            self.canvas.delete(co)
                            self.curovals.remove(co) 
                            if hasattr(self,"curx"): 
                             if ov_point==(self.curx,self.cury):
                                (self.curx,self.cury)=prev_oldpoint
                                                            
                            self.draw()
        if  self.mousebuttonup:
            self.newd1ramp=self.caluculate_ramp()
            self.callbacks.CallCallbacks(self.newd1ramp)
        
        self.history.append((deepCopySeq(self.oldpoints),self.d1scalewheel.get()))
        
    
        
    
    def OnCanvasMouseDrag(self,event):
        self.CLICK_NODRAG=0
        CtlPoints=[]
        xcoords=[]
        ycoords=[]
        #making active clickrange to be ten points around clicked point  
        for i in range(0,10):
            xcoords.append(self.OrgX-i)
            ycoords.append(self.OrgY-i)
            xcoords.append(self.OrgX+i)
            ycoords.append(self.OrgY+i)
            
        if xcoords!=[] and ycoords!=[]:
            for x in xcoords:
                for y in ycoords:
                    CtlPoints.append((x,y))
            
            for c in CtlPoints:
             if  c in self.oldpoints:
                ind=self.oldpoints.index(c)
                op=self.oldpoints[ind]
                del self.oldpoints[ind]
                
                for co in self.curovals:
                    ov_point1=self.canvas.coords(co)
                    if len(ov_point1)!=0:
                        ov_point=(int(round(ov_point1[0],3))+2,int(round(ov_point1[1],3))+2)
                                    
                        if ov_point==c :
                            self.canvas.delete(co)
                            self.curovals.remove(co)
                            
        self.curx=dx=event.x
        self.cury=dy=event.y
        self.draw() 
        
    def draw(self):
        """Draws line,ovals with current controlpoints. """
        new1points=[]
        curve_points=[]
        self.smoothened_points=[]
        if self.CLICK_NODRAG==0:
            dx=self.curx
            dy=self.cury
        else:
            (dx,dy)=(self.curx,self.cury)=(self.endpoint)
        ###Limiting  xcoords of the current point not to cross adjacent points
        if hasattr(self,"limit_xcoord"):
         if self.limit_xcoord!=[]:
            self.limit_xcoord.sort()
            if  (self.curx,self.cury) not in [self.startpoint,self.endpoint]:
                if (self.curx,self.cury)< self.limit_xcoord[0]:
                    if self.curx<=self.limit_xcoord[0][0] and self.cury<self.limit_xcoord[0][1]:
                        dx=self.curx=self.limit_xcoord[0][0]+1
                    if  self.curx<=self.limit_xcoord[0][0] and self.cury>self.limit_xcoord[0][1]:
                        dx=self.curx=self.limit_xcoord[0][0]
                if  (self.curx,self.cury)> self.limit_xcoord[1]:
                    if self.curx>=self.limit_xcoord[1][0] and self.cury>self.limit_xcoord[1][1]:
                        dx=self.curx=self.limit_xcoord[1][0]-1
                    if self.curx>=self.limit_xcoord[1][0] and self.cury<self.limit_xcoord[1][1]:
                        dx=self.curx=self.limit_xcoord[1][0]
        #Limit graph with in the axis
        if self.curx not in range(50,305):
                if self.curx<50:
                    self.curx=dx=50
                else:
                    self.curx=dx=305
                    
        if self.cury not in range(20,275):
                if self.cury<20:
                    self.cury=dy=20
                else:
                    self.cury=dy=275
        #adding start,end points  
        new1points.append(self.startpoint)
        new1points.append(self.endpoint)
        #adding current point to list
        if (dx,dy) not in new1points and (dx,dy) not in [self.startpoint,self.endpoint]:
            new1points.append((dx,dy))
        #adding oldpoints to list
        if hasattr(self,"ox"):
          for op in self.oldpoints:
                if op not in new1points:
                    new1points.append(op)
        new1points.sort()
        #removing oval point that is on drag
        if hasattr(self,"curoval"):
            if self.curoval not in self.curovals:
               self.canvas.delete(self.curoval)
        self.canvas.delete(self.curline)
        #if points that start with 50 or 51  or 305,304 other than start ,end
        #points exists remove start or end points
        #remove ovals
        #finding oval for start point and endpoint
        for i in new1points:
            if i[0]==51 or i[0]==50:
                if i!=self.startpoint:
                    if self.startpoint in new1points:
                        new1points.remove(self.startpoint)
                        ###removing start point oval 
                        x = 50
                        y = 275
                        st_oval_1= self.canvas.find_enclosed(x-3,y-3,x+3,y+3)
                         
                        if st_oval_1:
                            for so in st_oval_1:
                                if so!=[]:
                                    st_oval=so
                                    st_oval_coords=self.canvas.coords(st_oval)
                                    if (int(st_oval_coords[0]+2),int(st_oval_coords[1]+2))==self.startpoint: 
                                        self.canvas.delete(st_oval)
                                        if st_oval in self.curovals:
                                            self.curovals.remove(st_oval)
                        
                        
        for i in new1points:   
            if i[0]==304 or i[0]==305: 
                if i!=self.endpoint :
                    if self.endpoint in new1points:
                        new1points.remove(self.endpoint)
                        ###removing end point oval
                        x = 305
                        y = 20
                        end_oval_1= self.canvas.find_enclosed(x-3,y-3,x+3,y+3)
                        if end_oval_1:
                            for eo in end_oval_1:
                                if eo!=[]:
                                    end_oval=eo
                                    end_oval_coords=self.canvas.coords(end_oval)
                                    if (int(end_oval_coords[0]+2),int(end_oval_coords[1]+2))==self.endpoint: 
                                        self.canvas.delete(end_oval)
                                        if end_oval in self.curovals:
                                            self.curovals.remove(end_oval)
        new1points.sort()
          
        for (x,y) in new1points:
            curve_points.append(x)
            curve_points.append(y)
        self.smoothened_points= self.smooth(curve_points)
        #drawing line
        if len(self.smoothened_points)>2: 
            if self.Smooth:
                self.curline=self.canvas.create_line(self.smoothened_points)
            else:
                self.curline=self.canvas.create_line(curve_points)
        else:
            
            if curve_points[0]==50 or 51:
                 if self.Smooth:
                    self.curline=self.canvas.create_line(curve_points,smooth=1)
                 else:
                    self.curline=self.canvas.create_line(curve_points)   
            else:    
                self.curline=self.canvas.create_line(self.startpoint,self.endpoint)
        
        ##Adding oval when start or end point in new1points
        coval_coords=[]
        for i in self.curovals:
            coval_coords.append(self.canvas.coords(i))
        if self.endpoint in new1points:
            co=self.canvas.create_oval(self.endpoint[0]-2,self.endpoint[-1]-2,self.endpoint[0]+2,self.endpoint[-1]+2,width=1,outline='black',fill='black')
            endco_coords =self.canvas.coords(co)
            if endco_coords not in  coval_coords:
                self.curovals.append(co)
        if self.startpoint in new1points:
            co=self.canvas.create_oval(self.startpoint[0]-2,self.startpoint[-1]-2,self.startpoint[0]+2,self.startpoint[-1]+2,width=1,outline='black',fill='black')          
            startco_coords=self.canvas.coords(co)
            if startco_coords not in  coval_coords:
                self.curovals.append(co)
        #drawing ovals
        if (self.curx,self.cury)!=self.endpoint:
            self.curoval=self.canvas.create_oval(self.curx-2,self.cury-2,self.curx+2,self.cury+2,width=1,outline='black',fill='black') 
            
        if (self.curx,self.cury)==self.endpoint and self.endpoint in new1points:
            self.curoval=self.canvas.create_oval(self.curx-2,self.cury-2,self.curx+2,self.cury+2,width=1,outline='black',fill='black')
        self.newd1ramp= self.caluculate_ramp()
        if self.continuous:
                self.callbacks.CallCallbacks(self.newd1ramp)
            
  
        
    ########  convert coordinates to ramp##################  
    def caluculate_ramp(self):
        """ 
        """
        dramp=[] 
        mypoints=[]
        mynewpoints=[]
        self.oldpoints.sort()
        calcpoints=[]
        #if self.continuous :
        if hasattr(self,"curx"):
                if (self.curx,self.cury) not in self.oldpoints and (self.curx,self.cury) not in [self.startpoint,self.endpoint]:
                    calcpoints.append((self.curx,self.cury))
        if len(self.oldpoints)!=0:
            for o in self.oldpoints:
                if o not in calcpoints:
                    calcpoints.append(o)
        if self.startpoint not in calcpoints:
                calcpoints.append(self.startpoint)
        if self.endpoint not in calcpoints:
                calcpoints.append(self.endpoint)
        
        calcpoints.sort()    
        length=len(calcpoints)
        for l in range(length):
            if l+1<=length-1:
                mypoints=[calcpoints[l],calcpoints[l+1]]
                if calcpoints[l] not in mynewpoints:
                    mynewpoints.append( calcpoints[l])   
                
                (x1,y1)=calcpoints[l]
                (x2,y2)=calcpoints[l+1]
                if x1>x2:
                    dcx=x1-x2
                    px=x1-1
                else:
                    dcx=x2-x1
                    px=x1+1
                if y1>y2:
                    dcy=y1-y2
                    if dcx>=1:
                        py=y1-float(dcy)/float(dcx)
                    else:
                        py=y1
                else:   
                    dcy=y2-y1
                    if dcx>=1:
                        py=y1+float(dcy)/float(dcx)
                    else:
                        py=y2
                mynewpoints.append( (px,int(round(py))))
                for dc in range(dcx-1):
                    
                    if x1>x2:
                        px=px-1
                    else:
                        px=px+1
                    if y1>y2:
                        if dcx>=1:
                            py=py-float(dcy)/float(dcx)
                        else:
                            py=y1
                    else:
                        if dcx>=1:
                            py=py+float(dcy)/float(dcx)
                        else:
                            py=y2
                    mynewpoints.append( (px,int(round(py))))
        ramp=[]
        for r in mynewpoints:
            #scale
            ra=float(275-r[1])
            if ra>=256:
                ra=255.0
            ramp.append(ra)
            dramp=Numeric.array(ramp,'f')
        if len(dramp)!=0:
            return   dramp     
        else:
            dramp=Numeric.arange(0,256,1,'f')
            return   dramp
        
    def get(self):
        if hasattr(self,"newd1ramp"):
           return self.newd1ramp
        else:    
            return self.caluculate_ramp()
        
    def configure(self, **kw):
        if 'type' in kw.keys(): # make sure type is set first
            self.setType(kw['type'])
            del kw['type']
            
        for key,value in kw.items():
            if key=='callback': 
                self.setCallbacks(value)
            
   
    def setCallbacks(self, cb):
        """Set widget callback. Must be callable function. Callback is called
every time the widget value is set/modified"""

        assert cb is None or callable(cb) or type(cb) is types.ListType,\
               "Illegal callback: must be either None or callable. Got %s"%cb
        if cb is None: return
        elif type(cb) is types.ListType:
            for func in cb:
                assert callable(func), "Illegal callback must be callable. Got %s"%func
                self.callbacks.AddCallback(func)
        else:
            self.callbacks.AddCallback(cb)
        self.callback = cb
        

    def invertGraph(self):
        """This function is for inverting graph by reverse computing controlpoints"""
        if self.history!=[]:
            if self.history[-1][1]!=self.d1scalewheel.get():
                self.history[-1]=(self.history[-1][0],self.d1scalewheel.get())
        invert_points=[]
        #self.oldpoints=[]
        points=self.getControlPoints()
        if len(points)<2:
            points=[self.startpoint,self.endpoint]
        for p in points:
            if p[1] in range(20,276):
                y=275 -(p[1]-20)
                invert_points.append((p[0],y))
        self.reset()
        ###################################################
        #Some times start and end points are not deleted 
        #So for deleting them canvas.find_enclosed points at
        #startpoint and endpoint are caluculated(returns alist of
        #canvas objects present there) and if the coords of
        #any canvas objects matches with start or end point that gets deleted
        #####################################################             
        x = 50
        y = 275
        st_oval_1= self.canvas.find_enclosed(x-3,y-3,x+3,y+3)
        if st_oval_1:
            for so in st_oval_1:
                if so!=[]:
                    st_oval=so
                    st_oval_coords=self.canvas.coords(st_oval)
                    if (int(st_oval_coords[0]+2),int(st_oval_coords[1]+2))==self.startpoint: 
                        self.canvas.delete(st_oval)
                        if st_oval in self.curovals:
                            self.curovals.remove(st_oval)
        x = 305
        y = 20
        end_oval_1= self.canvas.find_enclosed(x-3,y-3,x+3,y+3)
        if end_oval_1:
            for eo in end_oval_1:
                if eo!=[]:
                    end_oval=eo
                    end_oval_coords=self.canvas.coords(end_oval)
                    if (int(end_oval_coords[0]+2),int(end_oval_coords[1]+2))==self.endpoint: 
                        self.canvas.delete(end_oval)
                        if end_oval in self.curovals:
                            self.curovals.remove(end_oval)
        self.canvas.delete(self.curline)
        if self.Smooth:
              self.curline=self.canvas.create_line(invert_points,smooth=1)  
        else:
                self.curline=self.canvas.create_line(invert_points)
        self.oldpoints=invert_points
        for p in invert_points:
            self.curoval=self.canvas.create_oval(p[0]-2,p[1]-2,p[0]+2,p[1]+2,width=1,outline='black',fill='black')
            self.curovals.append(self.curoval)
        (self.curx,self.cury) =invert_points[-2]    
        if self.continuous or self.mousebuttonup:
            self.newd1ramp=self.caluculate_ramp()
            self.callbacks.CallCallbacks([self.newd1ramp])
        self.history.append((deepCopySeq(self.oldpoints),self.d1scalewheel.get()))
         

    def defaultcurve_cb(self):
        """draws curve with default points"""
        if self.history!=[]:
            if self.history[-1][1]!=self.d1scalewheel.get():
                self.history[-1]=(self.history[-1][0],self.d1scalewheel.get())
        points=[]
        self.default_points=[]
        self.oldpoints=[]
        self.d1scalewheel.set(0.013)
        self.default_points=[(50,275),(88, 238), (101, 150), (154, 78), (75, 271),(305,20)]
        self.reset()
        self.canvas.delete(self.curline)
        self.default_points.sort()
        if self.Smooth:
            self.curline=self.canvas.create_line(self.default_points,smooth=1) 
        else:
                self.curline=self.canvas.create_line(self.default_points)
        self.oldpoints=self.default_points
        for p in self.default_points:
            self.curoval=self.canvas.create_oval(p[0]-2,p[1]-2,p[0]+2,p[1]+2,width=1,outline='black',fill='black')
            self.curovals.append(self.curoval)
        (self.curx,self.cury) =self.default_points[-2]    
        if self.continuous or self.mousebuttonup:
            self.newd1ramp=self.caluculate_ramp()
            self.callbacks.CallCallbacks(self.newd1ramp)
        self.history.append((deepCopySeq(self.oldpoints),self.d1scalewheel.get()))
        self.default_ramp= self.newd1ramp
        
    def read_cb(self):
        fileTypes = [("Graph",'*_Graph.py'), ("any file",'*.*')]
        fileBrowserTitle = "Read Graph"
        fileName  = self.fileOpenAsk(types=fileTypes,
                                     title=fileBrowserTitle)
        if not fileName:
            return
        self.read(fileName)

    def read( self,fileName):
        if self.history!=[]:
            if self.history[-1][1]!=self.d1scalewheel.get():
                self.history[-1]=(self.history[-1][0],self.d1scalewheel.get())
        fptr=open(fileName,"r")
        data=fptr.readlines()
        cpoints=data[0][:-1]
        sensitivity=data[1]
        self.d1scalewheel.set(eval(sensitivity))
        if len(cpoints)==0:
            return
        else:
            points=cpoints
        self.oldpoints=[]        
        self.reset()
        if hasattr(self,"curline"):
            self.canvas.delete(self.curline)
            for c in self.curovals:
                self.canvas.delete(c)
                self.curovals.remove(c)
            if hasattr(self,"curoval"):
                self.canvas.delete(self.curoval)
            self.curovals=[]
            if self.Smooth:
                self.curline=self.canvas.create_line(eval(points),smooth=1)
            else:
                self.curline=self.canvas.create_line(eval(points))
            self.readpoints=self.oldpoints=eval(points)[1:-1]
            for p in eval(points)[1:-1]:
                self.curoval=self.canvas.create_oval(p[0]-2,p[1]-2,p[0]+2,p[1]+2,width=1,outline='black',fill='black')
                self.curovals.append(self.curoval)
            (self.curx,self.cury) =eval(points)[-2]
            self.history.append((deepCopySeq(self.oldpoints),self.d1scalewheel.get()))

    def fileOpenAsk(self, idir=None, ifile=None, types=None,
                    title='Open'):
        if types==None: types = [ ('All files', '*') ]
        file = tkFileDialog.askopenfilename( filetypes=types,
                                             initialdir=idir,
                                             initialfile=ifile,
                                             title=title)
        if file=='': file = None
        return file 
    
    def write_cb(self):
        fileTypes = [("Graph",'*_Graph.py'), ("any file",'*.*')]
        fileBrowserTitle = "Write Graph"
        fileName  = self.fileSaveAsk(types=fileTypes,
                                     title=fileBrowserTitle)
        if not fileName:
            return
        self.write(fileName)
    
    def write(self,fileName):
        fptr=open(fileName,"w")
        points= self.getControlPoints()        
        points.sort()
        fptr.write(str(points))
        fptr.write("\n")
        fptr.write(str(self.d1scalewheel.get()))
        fptr.close()
        
    def fileSaveAsk(self, idir=None, ifile=None, types = None,
                title='Save'):
        if types==None: types = [ ('All files', '*') ]
        file = tkFileDialog.asksaveasfilename( filetypes=types,
                                               initialdir=idir,
                                               initialfile=ifile,
                                               title=title)
        if file=='': file = None
        return file
        
    def reset(self):
        """This function deletes current line removes current ovals"""  
        self.canvas.delete(self.curline)
        self.oldpoints=[]
        for c in self.curovals:
            self.canvas.delete(c)
        if hasattr(self,"curoval"):
            self.canvas.delete(self.curoval)
        self.curovals=[]
        if hasattr(self,"curoval"):
            delattr(self,"curoval")
        if hasattr(self,"curx"):
            delattr(self,"curx")
        

    def resetAll_cb(self):
        """Resetting curve as slant line 0 to 255"""
        self.reset()    
        self.curline=self.canvas.create_line([self.startpoint,self.endpoint],width=1,fill='black')
        for p in [self.startpoint,self.endpoint]:
            self.curoval=self.canvas.create_oval(p[0]-2,p[1]-2,p[0]+2,p[1]+2,width=1,outline='black',fill='black') 
            self.curovals.append(self.curoval)
        self.oldpoints=[self.startpoint,self.endpoint]
        (self.curx,self.cury)=self.endpoint
        self.d1scalewheel.set(0.013)
        
        if self.continuous or self.mousebuttonup:
            self.newd1ramp=Numeric.arange(0,256,1,'f')
            self.callbacks.CallCallbacks(self.newd1ramp)
        #self.histvar.set(0)
        self.history=[]
        
        
    def stepBack_cb(self):
        """when stepBack button clicked previous step is displayed.History of
        all the steps done is remembered and when stepback clicked from history
        list previous step is shown and that step is removed from history list """
        
        if self.history!=[]:
            if len(self.history)==1:
                self.resetAll_cb()
            
            else:
                del self.history[-1]
                pns = self.history[-1][0]
                #deleting 
                self.oldpoints=pns
                self.canvas.delete(self.curline)
                for c in self.curovals:
                    self.canvas.delete(c)
                if hasattr(self,"curoval"):
                    self.canvas.delete(self.curoval)
                self.curovals=[]
                ###################################################
                #Some times start and end points are not deleted 
                #So for deleting them canvas.find_enclosed points at
                #startpoint and endpoint are caluculated(returns alist of
                #canvas objects present there) and if the coords of
                #any canvas objects matches with start or end point that gets deleted
                #####################################################             
                x = 50
                y = 275
                st_oval_1= self.canvas.find_enclosed(x-3,y-3,x+3,y+3)
                if st_oval_1:
                            for so in st_oval_1:
                                if so!=[]:
                                    st_oval=so
                                    st_oval_coords=self.canvas.coords(st_oval)
                                    if (int(st_oval_coords[0]+2),int(st_oval_coords[1]+2))==self.startpoint: 
                                        self.canvas.delete(st_oval)
                                        if st_oval in self.curovals:
                                            self.curovals.remove(st_oval)
                x = 305
                y = 20
                end_oval_1= self.canvas.find_enclosed(x-3,y-3,x+3,y+3)
                if end_oval_1:
                            for eo in end_oval_1:
                                if eo!=[]:
                                    end_oval=eo
                                    end_oval_coords=self.canvas.coords(end_oval)
                                    if (int(end_oval_coords[0]+2),int(end_oval_coords[1]+2))==self.endpoint: 
                                        self.canvas.delete(end_oval)
                                        if end_oval in self.curovals:
                                            self.curovals.remove(end_oval)
                
                
                
                pns.sort()
                #if no start or end points 
                if pns[0][0]>51 :
                    pns.insert(0,self.startpoint)
                l=len(pns) 
                if pns[-1][0]<304:
                    pns.insert(l,self.endpoint)
                
                #if start or endpoints and points with (50or 51) or (305or305)
                if self.startpoint in pns:
                    for p in pns:
                        if p!=self.startpoint:
                            if p[0]== 50 or p[0]==51:
                               pns.remove(self.startpoint)
                if self.endpoint in pns:
                    for p in pns:
                        if p!=self.endpoint:
                            if p[0]==305 or p[0]==304:
                                pns.remove(self.endpoint)
                      
                print pns
                if self.Smooth:
                    self.curline=self.canvas.create_line(pns,width=1,fill='black',smooth=1)
                else:
                    self.curline=self.canvas.create_line(pns,width=1,fill='black')
                
                for p in pns:
                    self.curoval=self.canvas.create_oval(p[0]-2,p[1]-2,p[0]+2,p[1]+2,width=1,outline='black',fill='black')
                    self.curovals.append(self.curoval)
                self.d1scalewheel.set(self.history[-1][1])
                
                 
                if self.continuous or self.mousebuttonup:
                    self.newd1ramp=Numeric.arange(0,256,1,'f')
                    self.callbacks.CallCallbacks(self.newd1ramp)
                (self.curx,self.cury)=self.endpoint    
    def getControlPoints(self):
        """fuction to get current control points of the curve"""
        if not self.oldpoints==[self.startpoint,self.endpoint]:
          for i in range(len(self.oldpoints)):
            if self.startpoint  in self.oldpoints:
                self.oldpoints.remove(self.startpoint)
            if self.endpoint in self.oldpoints:
                self.oldpoints.remove(self.endpoint)
        self.controlpoints=[]
        
        if hasattr(self,"curoval"):
           c=self.canvas.coords(self.curoval)
           if len(c)!=0:
                if (int(c[0]+2),int(c[1]+2)) not in self.oldpoints and (int(c[0]+2),int(c[1]+2)) not in [self.startpoint,self.endpoint]:
                    self.controlpoints.append((int(c[0]+2),int(c[1]+2))) 
        for op in self.oldpoints:
                self.controlpoints.append(op)
        self.controlpoints.sort()
        if len(self.controlpoints)>0:
            if self.controlpoints[0][0]==50 or self.controlpoints[0][0]==51 :
                pass
            else:
                self.controlpoints.append(self.startpoint)
            self.controlpoints.sort()
            if self.controlpoints[-1][0]==305 or self.controlpoints[-1][0]==304:
                pass
            else:
                self.controlpoints.append(self.endpoint)
            self.controlpoints.sort() 
        return  self.controlpoints   
                
    def setControlPoints(self,points):
        """function to set curve control points"""
        assert isinstance(points, types.ListType),"Illegal type for points"
        
        for (x,y) in points:
            assert  x in range(50,306),"coordinates are out of range,x should be in [50,305]"
            assert  y in range(20,276),"coordinates are out of range,y should be in [20,275]"
                
        self.oldpoints=[]
        self.controlpoints=[]
        self.reset()
        self.oldpoints=self.controlpoints=points
        self.controlpoints.sort()
        if self.controlpoints[0]!=self.startpoint:
            self.controlpoints.append(self.startpoint)
        if  self.controlpoints[-1]!=self.endpoint:
            self.controlpoints.append(self.endpoint)
        self.canvas.delete(self.curline)   
        self.controlpoints.sort()
        if self.Smooth:
            self.curline=self.canvas.create_line( self.controlpoints,smooth=1)
        else:
            self.curline=self.canvas.create_line( self.controlpoints)
        for p in self.controlpoints[1:-1]:
            self.curoval=self.canvas.create_oval(p[0]-2,p[1]-2,p[0]+2,p[1]+2,width=1,outline='black',fill='black')
            self.curovals.append(self.curoval)
        (self.curx,self.cury)=   self.controlpoints[-2] 
        self.history.append((deepCopySeq(self.oldpoints),self.d1scalewheel.get()))
        if self.continuous or self.mousebuttonup:
            self.newd1ramp=self.caluculate_ramp()
            self.callbacks.CallCallbacks(self.newd1ramp)
             
    def setSensitivity(self,val):
        self.d1scalewheel.set(val)
        
    def Update(self):
        if self.update==1:
            dramp=self.caluculate_ramp()
            self.newd1ramp=dramp
            self.callbacks.CallCallbacks(dramp)
                
    def dismiss_cb(self):
       
       try:
            if self.master.winfo_ismapped():
                self.master.withdraw()
       except:
            if self.master.master.winfo_ismapped():
                self.master.master.withdraw()

        
    #draw Histogram

    def removeHistogram(self):
        """removes Histograms"""
        for b in self.bars:
            self.canvas.delete(b)
        self.bars=[]
    
    def drawHistogram(self):
       """This function draws histogram from list of pixel counts ,one for
            each value in the source image"""        
       self.removeHistogram()
       if self.histvar.get():
           h=self.histvalues 
           if h==[]:
            return
           list_pixels_count=h
           c=[]
           maxc=max(list_pixels_count)
           if maxc==0:
            return
           if list_pixels_count.index(maxc):
                
                list_pixels_count.remove(maxc)
                list_pixels_count.insert(255,0)
           
           for i in list_pixels_count[:256]:
                max_list=max(list_pixels_count)
                if max_list==0:
                    return
                val=i*200/max_list
                c.append(val)
           
           for i in range(0,len(c)):
                x1=50+i
                x2=50+i
                y1=275-c[i]
                y2=275
                r=self.canvas.create_line([(x1,y1),(x2,y2)],fill="gray70",width=1)
                
                self.bars.append(r)
           #displaying line and ovals ontop
           self.canvas.tkraise(self.curline)
           for i in self.curovals:
                self.canvas.tkraise(i)
           if hasattr(self,"curoval"):
                self.canvas.tkraise(self.curoval)
           self.canvas.update()
           ##Update Histograms on Graphtool
           #if self.update!=1:
           #      prev_option=self.optionType.get()
           #      self.optionType.set(2)
           #      self.update=1
           #      self.Update()
           #      self.optionType.set(prev_option)
           #      self.update=0
           #      return
           
               
    ################SMOOTHING  CODE############################
    def addcurve(self,out, xy, steps):
        
        add = out.append
        for i in range(1, steps+1):
            t = float(i) / steps; t2 = t*t; t3 = t2*t
            u = 1.0 - t; u2 = u*u; u3 = u2*u
            add(xy[0]*u3 + 3*(xy[2]*t*u2 + xy[4]*t2*u) + xy[6]*t3)
            add(xy[1]*u3 + 3*(xy[3]*t*u2 + xy[5]*t2*u) + xy[7]*t3)

    def smooth(self,xy, steps=12):
        
        if not xy:
            return xy
        closed = xy[0] == xy[-2] and xy[1] == xy[-1]
        out = []
        if closed:
            # connect end segment to first segment
            control = (
            0.500*xy[-4] + 0.500*xy[0],
            0.500*xy[-3] + 0.500*xy[1],
            0.167*xy[-4] + 0.833*xy[0],
            0.167*xy[-3] + 0.833*xy[1],
            0.833*xy[0]  + 0.167*xy[2],
            0.833*xy[1]  + 0.167*xy[3],
            0.500*xy[0]  + 0.500*xy[2],
            0.500*xy[1]  + 0.500*xy[3],
            )
            out = [control[0], control[1]]
            self.addcurve(out, control, steps)
        else:
            out = [xy[0], xy[1]]
        for i in range(0, len(xy)-4, 2):
            if i == 0 and not closed:
                control = (xy[i],xy[i+1],0.333*xy[i] + 0.667*xy[i+2],0.333*xy[i+1] + 0.667*xy[i+3],)
            else:
                control = (
                0.500*xy[i] + 0.500*xy[i+2],
                0.500*xy[i+1] + 0.500*xy[i+3],
                0.167*xy[i] + 0.833*xy[i+2],
                0.167*xy[i+1] + 0.833*xy[i+3],
                )
            if i == len(xy)-6 and not closed:
                control = control + (
                0.667*xy[i+2] + 0.333*xy[i+4],
                0.667*xy[i+3] + 0.333*xy[i+5],
                xy[i+4],
                xy[i+5],
                )
            else:
                control = control + (
                0.833*xy[i+2] + 0.167*xy[i+4],
                0.833*xy[i+3] + 0.167*xy[i+5],
                0.500*xy[i+2] + 0.500*xy[i+4],
                0.500*xy[i+3] + 0.500*xy[i+5],
                )
            if ((xy[i] == xy[i+2] and xy[i+1] == xy[i+3]) or
                (xy[i+2] == xy[i+4] and xy[i+3] == xy[i+5])):
                out.append(control[6])
                out.append(control[7])
            else:
                self.addcurve(out, control, steps)
        return out 
예제 #23
0
    def __init__(self, master=None, viewerGui=None):

        if master is None:
            self.master = Tkinter.Toplevel()
            self.master.withdraw()
            self.master.title('Selection Settings')
            self.master.protocol('WM_DELETE_WINDOW', self.master.withdraw )
        else:
            self.master = master

        self.mainFrame = Tkinter.Frame(self.master, relief='ridge', borderwidth=3)

        # CONTOUR WIDTH
        if DejaVu.enableSelectionContour is True:
            lLabel =Tkinter.Label(self.mainFrame, text='Contour width:')
            lLabel.grid(row=0, column=0, sticky='w')
            self.contourSizeSlider = Slider.Slider(
                                        self.mainFrame,
                                        minval=0,
                                        maxval = 10,
                                        immediate=1,
                                        incr=1,
                                        labelformat = '%d',
                                        cursortype='int'
                                        )
            self.contourSizeSlider.frame.grid(row=0, column=1, columnspan=3)
            def setContourWidthSliderValue_cb(val):
                DejaVu.selectionContourSize = val
                viewerGui.viewer.Redraw()
            self.contourSizeSlider.AddCallback(setContourWidthSliderValue_cb)
        else:
            lLabel =Tkinter.Label(self.mainFrame, text='Contour selection is disabled')
            lLabel.grid(row=0, column=0, columnspan=3, sticky='w')

        # BACKGROUND COLOR
        lLabel =Tkinter.Label(self.mainFrame, text='Contour color:')
        lLabel.grid(row=1, column=0, sticky='w')
        lFunc = CallBackFunction(viewerGui.colorChooser.showColorChooser,'selection contour')
        self.contourColorButton = Tkinter.Button(self.mainFrame,
                                 #text='Contour color',
                                 width=7,
                                 background=TkColor(DejaVu.selectionContourColor),
                                 command=lFunc)
        self.contourColorButton.grid(row=1, column=1, columnspan=3)

        # PATTERN SIZE
        lLabel =Tkinter.Label(self.mainFrame, text='Pattern size:')
        lLabel.grid(row=2, column=0, sticky='w')
        
        def setPatternSizeSliderValue_cb(val):
            DejaVu.selectionPatternSize = val
            viewerGui.viewer.Redraw()

        self.patternSizeThumbwheel = ThumbWheel(
                             self.mainFrame, width=70, height=16, type=int,
                             value=DejaVu.selectionPatternSize,
                             callback=setPatternSizeSliderValue_cb,
                             continuous=True, oneTurn=10,
                             wheelPad=2, min=0, max=50)
        self.patternSizeThumbwheel.grid(row=2, column=1, columnspan=3)

        self.mainFrame.pack(side='top')

        self.updateWidgets()
예제 #24
0
파일: moveTk.py 프로젝트: lisarosalina/App
 def __init__(self, master=None, width=200, height=40, nblines=40):
     ThumbWheel.__init__(self, master, width, height, nblines)
     self.showLabelInWidget = 1
예제 #25
0
 def test_setPrecision(self):
     
     tw = ThumbWheel(width=100, height=26)
     tw.configure(type='float')
     tw.configure(precision=5)
     # increase precision to 5 - this is only visual. value is not changed
     self.assertEqual(tw.precision,5)
     tw.set(4.123456789)
     tw.master.update()
     pause()
     # make sure that value did not change
     self.assertEqual(tw.value,4.123456789)
     # test that out-of-range values are set to 1 - 10
     tw.configure(precision=0)
     self.assertEqual(tw.precision,1)
     tw.configure(precision=11)
     self.assertEqual(tw.precision,10)
     tw.master.update()
     pause()
     tw.master.destroy()
예제 #26
0
    def makeInterface(self):
        """ create interface for ssh """
        self.resetFrame()
        
        colors = { 'center_x' : '#ff3333',
                   'center_y' : 'green',
                   'center_z' : '#00aaff',
                   'size_x' : '#ff3333',
                   'size_y' : 'green',
                   'size_z' : '#0099ff',
                   }

        frame_set = {  'ring_bd' : 1, 'ring_highlightbackground' :'black', 'ring_borderwidth' : 2, 
                    'ring_highlightcolor' : 'black', 'ring_highlightthickness' : 1, 'ring_relief' : 'flat', 
                    'groupchildsite_bg':'white', 'groupchildsite_relief':'sunken','ring_bg':'white',
                        'tag_bd' : '1', 'tag_highlightbackground' :'black', 'tag_borderwidth':2, 
                        'tag_highlightcolor' : 'black', 'tag_highlightthickness': 1}

        frame_set = { 'ring_bd' : 1, 'ring_highlightbackground' :'black', 'ring_borderwidth' : 2, 
                    'ring_highlightcolor' : 'black', 'ring_highlightthickness' : 1, 'ring_relief' : 'flat'}

        frame_set = {}
        bset = { 'bg' : '#95bed5', 'width' : 22, 'height': 22, 'relief' : 'raised'}
        bset = { 'bg' : '#2e363b', 'width' : 22, 'height': 22, 'relief' : 'raised'}
        bset = { 'bg' : '#a6abae', 'width' : 22, 'height': 22, 'relief' : 'raised'}
        bset = { 'bg' : '#969b9d'  } # 'width' : 22, 'height': 22, 'relief' : 'raised'}
        bset = {}
        bset.update(self.BORDER)

        # left frame
        lframe = tk.Frame(self.frame)
        # button tollbar 
        tk.Frame(lframe, height=7).pack(expand=0, fill='x', padx=0, pady=0, side='top', anchor='n')
        # minispacer

        bframe = tk.Frame(lframe)
        b = tk.Button(bframe, text='Load...', command = self.openConfig, image= self._ICON_open, compound='left',
            height=14,**bset)
        b.pack(expand=1,fill='x', anchor='w', side='left',padx=1)

        b.pack(expand=1,fill='x', anchor='w', side='left',padx=1)
        bframe.pack(expand=0, fill='x', padx=0, pady=0, side='top', anchor='n')
        ########################## center wheels
        self._thumbw_array = []
        c_group = Pmw.Group(lframe, tag_text='Center', tag_font=self.FONTbold, **frame_set)
        for lab in ['center_x', 'center_y', 'center_z']:
            cb = CallbackFunction(self.setWheelBox, lab)
            tw = ThumbWheel(
                c_group.interior(), labCfg={'text':lab, 'side':'left','fg':colors[lab],
                'bg':'black', 'width':9 }, showLabel=1,
                width=90, height=14, type=float, value=0.0,
                callback=cb, continuous=True,
                oneTurn=5, wheelPad=0)
            tw.pack(side='top', pady=2,anchor='n')
            self._thumbw_array.append(tw)
        c_group.pack(side='top', anchor='n', expand=0,fill='x',ipadx=2,ipady=3, padx=1)

        ########################## size wheels
        s_group = Pmw.Group(lframe, tag_text='Size', tag_font=self.FONTbold, **frame_set)
                     
        for lab in ['size_x', 'size_y', 'size_z']:
            cb = CallbackFunction(self.setWheelBox, lab)
            tw = ThumbWheel(
                s_group.interior(), labCfg={'text':lab, 'side':'left','fg':colors[lab],
                'bg':'black', 'width':9 }, showLabel=1,
                width=90, height=14, type=float, value=0.0, min=0.0001,
                callback=cb, continuous=True,
                oneTurn=5, wheelPad=0)
            tw.pack(side='top', pady=2,anchor='n')
            self._thumbw_array.append(tw)
        s_group.pack(side='top', anchor='n', expand=0,fill='x',ipadx=2,ipady=3, padx=1,pady=2)

        ########################## search settings
        self.searchparmgroup = Pmw.Group(lframe, tag_text='Search parameters', tag_font=self.FONTbold, **frame_set)
        # autodock search parms
        self.buildSearchADPanel(target = self.searchparmgroup )
        # vina search parms
        self.buildSearchVinaPanel(target = self.searchparmgroup )

        self.searchparmgroup.pack(side='top', anchor='n', expand=0,fill='x',ipadx=2,ipady=3, padx=1,pady=5)

        ########################## Receptors
        self._receptors_group = Pmw.Group(lframe, tag_text='Receptor list', tag_font=self.FONTbold,collapsedsize=3, **frame_set)
        # important
        self.receptorListbox = Pmw.ScrolledListBox(self._receptors_group.interior(), listbox_highlightbackground = 'black',
            # selectioncommand=self.loadreceptor, 
            listbox_selectbackground='yellow')
        self.receptorListbox.pack(expand=1, fill='both',padx=3, pady=0)
        self.receptorListbox.component('listbox').bind('<ButtonRelease-1>', self.loadreceptor)
        self.receptorListbox.component('listbox').bind('<Button-3>', self._delreceptor)

        tb = tk.Frame(self._receptors_group.interior())
        # single-multi load buttons
        self.recLoaderMode_single = tk.Radiobutton(tb, text='Single', image = self._ICON_single, indicatoron=False, 
            variable=self.recLoaderMultiMode, value = False, compound='left', height=16, **bset)
        self.recLoaderMode_single.pack(anchor='n', side='left',pady=1,expand=1,fill='x',padx=1)
        self.recLoaderMode_multi = tk.Radiobutton(tb, text='Multi', image = self._ICON_multi, indicatoron=False,
            variable=self.recLoaderMultiMode, value = True, compound='left', height=16, **bset)
        self.recLoaderMode_multi.pack(anchor='n', side='left',pady=1,expand=1,fill='x',padx=1)
        

        tb.pack(expand=0, fill='x',anchor='s',side='bottom',padx=3)

        self._receptors_group.pack(side='bottom', anchor='n', expand=1, fill='both',ipadx=4,ipady=4, padx=1,pady=0)

        lframe.pack(side = 'left', anchor='n', expand='n', fill='y', padx=0, pady=0)

        ###### 3D Viewer
        rframe = tk.Frame(self.frame)
        spacer = tk.Frame(rframe, width=5) #, bg='red')
        spacer.pack(expand=0,fill='y',side='left',anchor='w')
        spacer.pack_propagate(0)
        vgroup = Pmw.Group(rframe, tag_text = '3D viewer', tag_font=self.FONTbold,groupchildsite_bg='black',  **frame_set)

        # TOOLBAR
        vtoolbar = tk.Frame(vgroup.interior())
        vtoolbar.pack(side='left', anchor='w', expand=0, fill='y')
        cb = CallbackFunction(self.centerView, None)
        tk.Button(vtoolbar, text='Center\nall', image = self._ICON_center_all, width=22, height=22, 
            command=cb, **bset).pack(anchor='n', side='top')
        cb = CallbackFunction(self.centerView, 'mol')
        tk.Button(vtoolbar, text='Center\nmol', image = self._ICON_center_mol, width=22, height=22,
            command=cb, **bset ).pack(anchor='n', side='top')
        cb = CallbackFunction(self.centerView, 'box')
        tk.Button(vtoolbar, text='Center\nbox', image = self._ICON_center_box, width=22, height=22,
            command=cb, **bset ).pack(anchor='n', side='top',pady=1)
        # 3d Viewer settings XXX TODO
        #tk.Button(vtoolbar, text='Settings', image = self._ICON_sys, width=22, height=22, **bset).pack(anchor='n', side='top')
        vgroup.pack(side='right', anchor='e', expand=1, fill='both', padx=0, pady=0)

        # 3D viewer  
        self.make3Dboxviewer(vgroup.interior())

        rframe.pack(side = 'right', anchor='n', expand=1, fill='both',padx=0, pady=0)
        
        if self.app.dockengine == 'vina':
            self.setSearchParmsVina()
        elif self.app.dockengine == 'autodock':
            self.setSearchParmsAD()
        self.frame.pack(expand=1, fill='both',anchor='n', side='top')
예제 #27
0
    def makeInterface(self):
        """ create interface for ssh """
        self.resetFrame()

        colors = {
            "center_x": "#ff3333",
            "center_y": "green",
            "center_z": "#00aaff",
            "size_x": "#ff3333",
            "size_y": "green",
            "size_z": "#0099ff",
        }

        frame_set = {
            "ring_bd": 1,
            "ring_highlightbackground": "black",
            "ring_borderwidth": 2,
            "ring_highlightcolor": "black",
            "ring_highlightthickness": 1,
            "ring_relief": "flat",
            "groupchildsite_bg": "white",
            "groupchildsite_relief": "sunken",
            "ring_bg": "white",
            "tag_bd": "1",
            "tag_highlightbackground": "black",
            "tag_borderwidth": 2,
            "tag_highlightcolor": "black",
            "tag_highlightthickness": 1,
        }

        frame_set = {
            "ring_bd": 1,
            "ring_highlightbackground": "black",
            "ring_borderwidth": 2,
            "ring_highlightcolor": "black",
            "ring_highlightthickness": 1,
            "ring_relief": "flat",
        }

        frame_set = {}
        bset = {"bg": "#95bed5", "width": 22, "height": 22, "relief": "raised"}
        bset = {"bg": "#2e363b", "width": 22, "height": 22, "relief": "raised"}
        bset = {"bg": "#a6abae", "width": 22, "height": 22, "relief": "raised"}
        bset = {"bg": "#969b9d"}  # 'width' : 22, 'height': 22, 'relief' : 'raised'}
        bset = {}
        bset.update(self.BORDER)

        # left frame
        lframe = tk.Frame(self.frame)
        # button tollbar
        tk.Frame(lframe, height=7).pack(expand=0, fill="x", padx=0, pady=0, side="top", anchor="n")
        # minispacer

        bframe = tk.Frame(lframe)
        b = tk.Button(
            bframe, text="Load...", command=self.openConfig, image=self._ICON_open, compound="left", height=14, **bset
        )
        b.pack(expand=1, fill="x", anchor="w", side="left", padx=1)

        b.pack(expand=1, fill="x", anchor="w", side="left", padx=1)
        bframe.pack(expand=0, fill="x", padx=0, pady=0, side="top", anchor="n")
        ########################## center wheels
        self._thumbw_array = []
        c_group = Pmw.Group(lframe, tag_text="Center", tag_font=self.FONTbold, **frame_set)
        for lab in ["center_x", "center_y", "center_z"]:
            cb = CallbackFunction(self.setWheelBox, lab)
            tw = ThumbWheel(
                c_group.interior(),
                labCfg={"text": lab, "side": "left", "fg": colors[lab], "bg": "black", "width": 9},
                showLabel=1,
                width=90,
                height=14,
                type=float,
                value=0.0,
                callback=cb,
                continuous=True,
                oneTurn=5,
                wheelPad=0,
            )
            tw.pack(side="top", pady=2, anchor="n")
            self._thumbw_array.append(tw)
        c_group.pack(side="top", anchor="n", expand=0, fill="x", ipadx=2, ipady=3, padx=1)

        ########################## size wheels
        s_group = Pmw.Group(lframe, tag_text="Size", tag_font=self.FONTbold, **frame_set)

        for lab in ["size_x", "size_y", "size_z"]:
            cb = CallbackFunction(self.setWheelBox, lab)
            tw = ThumbWheel(
                s_group.interior(),
                labCfg={"text": lab, "side": "left", "fg": colors[lab], "bg": "black", "width": 9},
                showLabel=1,
                width=90,
                height=14,
                type=float,
                value=0.0,
                min=0.0001,
                callback=cb,
                continuous=True,
                oneTurn=5,
                wheelPad=0,
            )
            tw.pack(side="top", pady=2, anchor="n")
            self._thumbw_array.append(tw)
        s_group.pack(side="top", anchor="n", expand=0, fill="x", ipadx=2, ipady=3, padx=1, pady=2)

        ########################## search settings
        self.searchparmgroup = Pmw.Group(lframe, tag_text="Search parameters", tag_font=self.FONTbold, **frame_set)
        # autodock search parms
        self.buildSearchADPanel(target=self.searchparmgroup)
        # vina search parms
        self.buildSearchVinaPanel(target=self.searchparmgroup)

        self.searchparmgroup.pack(side="top", anchor="n", expand=0, fill="x", ipadx=2, ipady=3, padx=1, pady=5)

        ########################## Receptors
        self._receptors_group = Pmw.Group(
            lframe, tag_text="Receptor list", tag_font=self.FONTbold, collapsedsize=3, **frame_set
        )
        # important
        self.receptorListbox = Pmw.ScrolledListBox(
            self._receptors_group.interior(),
            listbox_highlightbackground="black",
            # selectioncommand=self.loadreceptor,
            listbox_selectbackground="yellow",
        )
        self.receptorListbox.pack(expand=1, fill="both", padx=3, pady=0)
        self.receptorListbox.component("listbox").bind("<ButtonRelease-1>", self.loadreceptor)
        self.receptorListbox.component("listbox").bind("<Button-3>", self._delreceptor)

        tb = tk.Frame(self._receptors_group.interior())
        # single-multi load buttons
        self.recLoaderMode_single = tk.Radiobutton(
            tb,
            text="Single",
            image=self._ICON_single,
            indicatoron=False,
            variable=self.recLoaderMultiMode,
            value=False,
            compound="left",
            height=16,
            **bset
        )
        self.recLoaderMode_single.pack(anchor="n", side="left", pady=1, expand=1, fill="x", padx=1)
        self.recLoaderMode_multi = tk.Radiobutton(
            tb,
            text="Multi",
            image=self._ICON_multi,
            indicatoron=False,
            variable=self.recLoaderMultiMode,
            value=True,
            compound="left",
            height=16,
            **bset
        )
        self.recLoaderMode_multi.pack(anchor="n", side="left", pady=1, expand=1, fill="x", padx=1)

        tb.pack(expand=0, fill="x", anchor="s", side="bottom", padx=3)

        self._receptors_group.pack(side="bottom", anchor="n", expand=1, fill="both", ipadx=4, ipady=4, padx=1, pady=0)

        lframe.pack(side="left", anchor="n", expand="n", fill="y", padx=0, pady=0)

        ###### 3D Viewer
        rframe = tk.Frame(self.frame)
        spacer = tk.Frame(rframe, width=5)  # , bg='red')
        spacer.pack(expand=0, fill="y", side="left", anchor="w")
        spacer.pack_propagate(0)
        vgroup = Pmw.Group(rframe, tag_text="3D viewer", tag_font=self.FONTbold, groupchildsite_bg="black", **frame_set)

        # TOOLBAR
        vtoolbar = tk.Frame(vgroup.interior())
        vtoolbar.pack(side="left", anchor="w", expand=0, fill="y")
        cb = CallbackFunction(self.centerView, None)
        tk.Button(
            vtoolbar, text="Center\nall", image=self._ICON_center_all, width=22, height=22, command=cb, **bset
        ).pack(anchor="n", side="top")
        cb = CallbackFunction(self.centerView, "mol")
        tk.Button(
            vtoolbar, text="Center\nmol", image=self._ICON_center_mol, width=22, height=22, command=cb, **bset
        ).pack(anchor="n", side="top")
        cb = CallbackFunction(self.centerView, "box")
        tk.Button(
            vtoolbar, text="Center\nbox", image=self._ICON_center_box, width=22, height=22, command=cb, **bset
        ).pack(anchor="n", side="top", pady=1)
        # 3d Viewer settings XXX TODO
        # tk.Button(vtoolbar, text='Settings', image = self._ICON_sys, width=22, height=22, **bset).pack(anchor='n', side='top')
        vgroup.pack(side="right", anchor="e", expand=1, fill="both", padx=0, pady=0)

        # 3D viewer
        self.make3Dboxviewer(vgroup.interior())

        rframe.pack(side="right", anchor="n", expand=1, fill="both", padx=0, pady=0)

        if self.app.dockengine == "vina":
            self.setSearchParmsVina()
        elif self.app.dockengine == "autodock":
            self.setSearchParmsAD()
        self.frame.pack(expand=1, fill="both", anchor="n", side="top")
예제 #28
0
class Gantt:
    """
    Plot a simple Gant diagram for a list of tasks.
The task are specified as a list of (name, start, end) 3-tuples
"""

    def __init__(self, tasks, root=None):

        # create panel if needed
        if root is None:
            root = Tkinter.Toplevel()
            root.title("Execution profile")
            self.ownsMaster = True
        else:
            assert isinstance(root, Tkinter.Toplevel) or\
                   isinstance(root, Tkinter.Frame)
            self.ownsMaster = False
        self.root = root

        self.pixelsPersecond = 100
        self.yoff = 20
        self.scale = 1.0
        
        self.scrolledCanvas = Pmw.ScrolledCanvas(
            root, canvas_width=600, canvas_bg='white',
            vscrollmode='static', hscrollmode='static',
            horizscrollbar_width=10, vertscrollbar_width=10)
        self.canvas = self.scrolledCanvas.component('canvas')
        self.scrollregion=[0 , 0, 4000, 4000]
        self.canvas.configure(scrollregion=tuple(self.scrollregion))

        self.scrolledCanvas.pack(expand=True, fill='both')

        f = self.bframe = Tkinter.Frame(root)
        
        self.scaleTimeTW = ThumbWheel(
            f, showLabel=0, width=70, height=16, type=float, value=0,
            callback=self.setTimeScaleFactor_cb, continuous=True, oneTurn=10,
            wheelPad=2, reportDelta=True)
        self.scaleTimeTW.pack(side='right', anchor='e')

        f.pack(side='bottom', expand=0, fill='x')
        
        self.relativeData = []
        self.setTasks(tasks)
        

    def setTasks(self, tasks):
        self.relativeData = []

        if len(tasks)==0:
            return
        assert len(tasks)
        assert len(tasks[0])==3
        off = tasks[0][1]

        for node,t0,t1 in tasks:
            # name, start, length
            self.relativeData.append( (node.name, t0-off, t1-t0) )
        self.redraw()
        

    def setTimeScaleFactor_cb(self, value, event=None):
        self.scale = self.scale * (1.1)**value
        self.redraw()
        

    def redraw(self):
        pixelPerUnit = 30000 # use that many pixels to draw mini time

        cury = 20
        canvas = self.canvas
        canvas.delete("names")
        canvas.delete("lines")

        for name, start, length in self.relativeData:
            scale = self.scale
            x0 = 10 + scale*start*pixelPerUnit
            x1 = 10 + scale*(start+length)*pixelPerUnit
            canvas.create_text(x0, cury, text=name, anchor='sw',
                               tags=('names'), fill='magenta')
            canvas.create_line(x0, cury, x1, cury, width=3,
                               fill='black', tags=('lines',name))
            canvas.create_text(x0, cury+20, text='%.4f'%length, anchor='sw',
                               tags=('names'), fill='orange')
            cury += self.yoff
예제 #29
0
class ColorMapLegend(Insert2d):
    """Class for displaying a colormap legend.
    arguments for the constructor or Set method are:
       ramp: Numeric array of shape Nx3 or Nx4 (default is RBGRamp())
       height: height of colormap legend
       width:  width of colormap legend
       interp: 1 or 0 to turn color interpolation on and off resp.
       mini:   minimum values (i.e which corresponds to the first color)
       maxi:   maximum values (i.e which corresponds to the last color)
    
    If interp is set to 1 QUAD_STRIPS are used and colors are interpolated,
    else one QUAD is drawn for each entry in the colormap.
    If the color provide alpha values, a chechered background is drawn.
    """

    keywords = Insert2d.keywords + [
        'ramp',
        'height',
        'width',
        'interp',       # 1: for color interpolation, or 0
        'mini',         # 
        'maxi',         #
        'labelValues',  # floating point numbers to be written below cml
        'glfFont',
        'fontScale',
        'numOfLabels',
        'unitsString',
        'interp',
        'visibleFrame',
        'invertLabelsColor',
        ]    

    glfVectorFontList = [
        'arial1.glf',
        'courier1.glf',
        'crystal1.glf',
        'techno0.glf',
        'techno1.glf',
        'times_new1.glf',
        'aksent1.glf',
        'alpine1.glf',
        'broadway1.glf',
        'chicago1.glf',
        'compact1.glf',
        'cricket1.glf',
        'garamond1.glf',
        'gothic1.glf',
        'penta1.glf',
        'present_script1.glf'
    ]


    def __init__(self, colormapgui, name='color map legend', check=1, **kw):

        # GLF FONTS Initialisations
        glf.glfInit()
        glf.glfEnable(glf.GLF_CONSOLE_MESSAGES)
        lGlfModulePath = os.path.split(glf.__file__)[-2]
        lPathToFonts = lGlfModulePath+os.sep+'fonts'+os.sep
        self.glfVectorFontLoadIdDict = {}
        for font in self.glfVectorFontList:
            self.glfVectorFontLoadIdDict[font] = glf.glfLoadFont(lPathToFonts+font)   
        self.fontScale = 8
        self.glfFontID = 0

        # other initialisations
        self.colormapguiRef = ref(colormapgui) 
        self.resizeSpotRadius = 5 
        self.resizeSpot = None
        self.verticalLegend = True

        self.mini = None
        self.maxi = None
        
        kw['ramp'] = RGBRamp()
        kw['height'] = 1.
        kw['width'] = len(kw['ramp'])
        kw['interp'] = 1
#        kw['mini'] = None
#        kw['maxi'] = None
        kw['labelValues'] = []
        kw['numOfLabels'] = 5
        kw['unitsString'] = 'law'
        kw['invertLabelsColor'] = False
        kw['visibleFrame'] = True

        #kw['protected'] = True
        kw['immediateRendering'] = False
        kw['visible'] = False
        kw['transparent'] = True

        kw['size'] = [12, 120] # override the default value in Insert2d

        self.clickPosFromLegendBottomLeft = [0, 0]

        apply( Insert2d.__init__, (self, name, check), kw)

        # Insert2d initialisations 
        # (need to be done after the Insert2d.__init__ otherwise it overrides)
        self.needsRedoDpyListOnResize = True
        self.initialPosition = [1, 350] # override the default value in Insert2d
        self.coord2d = deepcopy(self.initialPosition) # 2d coordinates in pixels from top left
        self.animatable = False


    def Set(self, check=1, redo=1, updateOwnGui=True, **kw):
        """set data for this object: add faces (polygon or lines) to this object
check=1 : verify that all the keywords present can be handle by this func 
redo=1 : append self to viewer.objectsNeedingRedo
updateOwnGui=True : allow to update owngui at the end this func
"""
        #print "colorMapLegend.Set"
        redoFlags = apply( Insert2d.Set, (self, check, 0), kw)
        
        ramp=kw.get('ramp')
        if ramp is not None:
            assert len(ramp) > 0
            assert len(ramp[0])==3 or len(ramp[0])==4
            self.ramp = ramp
            redoFlags |= self._redoFlags['redoDisplayListFlag']

        height = kw.get('height')
        if height:
            assert height > 0.0
            self.height = height
            redoFlags |= self._redoFlags['redoDisplayListFlag']

        width = kw.get('width')
        if width:
            assert width > 0.0
            self.width = width
            redoFlags |= self._redoFlags['redoDisplayListFlag']

        mini = kw.get('mini')
        if mini is not None:
            #assert isinstance(mini, types.FloatType)
            self.mini = mini
            redoFlags |= self._redoFlags['redoDisplayListFlag']

        maxi = kw.get('maxi')
        if maxi is not None:
            #assert isinstance(maxi, types.FloatType)
            self.maxi = maxi
            redoFlags |= self._redoFlags['redoDisplayListFlag']

        labelValues = kw.get('labelValues')
        if labelValues is not None:
            # for v in labelValues:
            #    assert isinstance(v, types.FloatType)
            self.labelValues = labelValues
            redoFlags |= self._redoFlags['updateOwnGuiFlag']
            redoFlags |= self._redoFlags['redoDisplayListFlag']

        glfFont = kw.get('glfFont')
        if glfFont is not None:
            if glfFont in self.glfVectorFontLoadIdDict.keys():
                self.glfFontID = self.glfVectorFontLoadIdDict[glfFont]
                redoFlags |= self._redoFlags['updateOwnGuiFlag']
                redoFlags |= self._redoFlags['redoDisplayListFlag']

        fontScale = kw.get('fontScale')
        if fontScale is not None:
            assert isinstance(fontScale, types.IntType)
            self.fontScale = fontScale
            redoFlags |= self._redoFlags['updateOwnGuiFlag']
            redoFlags |= self._redoFlags['redoDisplayListFlag']

        numOfLabels = kw.get('numOfLabels')
        if numOfLabels is not None:
            assert isinstance(numOfLabels, types.IntType)
            self.numOfLabels = numOfLabels
            redoFlags |= self._redoFlags['updateOwnGuiFlag']
            redoFlags |= self._redoFlags['redoDisplayListFlag']

        unitsString = kw.get('unitsString')
        if unitsString is not None:
            self.unitsString = unitsString
            redoFlags |= self._redoFlags['updateOwnGuiFlag']
            redoFlags |= self._redoFlags['redoDisplayListFlag']

        interp = kw.get('interp')
        if interp is not None:
            assert interp in (0, 1)
            self.interp = interp
            redoFlags |= self._redoFlags['updateOwnGuiFlag']
            redoFlags |= self._redoFlags['redoDisplayListFlag']

        visibleFrame = kw.get('visibleFrame')
        if visibleFrame is not None:
            self.visibleFrame = visibleFrame
            redoFlags |= self._redoFlags['updateOwnGuiFlag']
            redoFlags |= self._redoFlags['redoDisplayListFlag']

        invertLabelsColor = kw.get('invertLabelsColor')
        if invertLabelsColor is not None:
            self.invertLabelsColor = invertLabelsColor
            redoFlags |= self._redoFlags['updateOwnGuiFlag']
            redoFlags |= self._redoFlags['redoDisplayListFlag']

        return self.redoNow(redo, updateOwnGui, redoFlags)


    def Draw(self):
        #print "colorMapLegend.Draw", self

        if self.viewer.tileRender:
            tile = self.getTile()
            #print "tile", tile
        else:
            tile = None

        fullWidth = self.viewer.currentCamera.width
        fullHeight = self.viewer.currentCamera.height

        if self.invertLabelsColor is False:
            backgroundColor = (
                           self.viewer.currentCamera.backgroundColor[0],
                           self.viewer.currentCamera.backgroundColor[1],
                           self.viewer.currentCamera.backgroundColor[2],
                           .5)
        else:
            backgroundColor = (
                           1-self.viewer.currentCamera.backgroundColor[0],
                           1-self.viewer.currentCamera.backgroundColor[1],
                           1-self.viewer.currentCamera.backgroundColor[2],
                           .5)

        from DejaVu.Legend import drawSelfOrientedLegend
        self.polygonContour , self.resizeSpot , self.verticalLegend = drawSelfOrientedLegend( 
                fullWidth=fullWidth,
                fullHeight=fullHeight,
                tile=tile,
                ramp=self.ramp,
                mini=self.mini,
                maxi=self.maxi,
                name=self.name,
                unit=self.unitsString,
                labelValues=self.labelValues,
                roomLeftToLegend=self.coord2d[0],
                roomBelowLegend=fullHeight-self.coord2d[1],
                legendShortSide=self.size[0],
                legendLongSide=self.size[1],
                significantDigits=3,
                backgroundColor=backgroundColor,
                interpolate=self.interp,
                frame=self.visibleFrame,
                selected=(self.viewer.currentObject == self),
                numOfLabels=self.numOfLabels,
                resizeSpotRadius=self.resizeSpotRadius,
                fontScale=self.fontScale,
                glfFontID=self.glfFontID,
        )

        return 1


    def pickDraw(self):
        """called by the picking process to operate the selection
"""
        #print "colorMapLegend.pickDraw", self
        # we draw just flat quad of the insert2d
        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glPushMatrix()       
        #GL.glLoadIdentity()
        GL.glLoadMatrixf(self.viewer.currentCamera.pickMatrix) 
        GL.glOrtho(0, float(self.viewer.currentCamera.width),
                   0, float(self.viewer.currentCamera.height), -1, 1)
        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glPushMatrix()
        GL.glLoadIdentity()
        GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
        #GL.glColor3f(1,0,0)

        if self.resizeSpot is not None:
            GL.glPushName(1)
            GL.glBegin(GL.GL_QUADS)
            GL.glVertex2f(float(self.resizeSpot[0]+self.resizeSpotRadius),
                          float(self.resizeSpot[1]-self.resizeSpotRadius))
            GL.glVertex2f(float(self.resizeSpot[0]+self.resizeSpotRadius),
                          float(self.resizeSpot[1]+self.resizeSpotRadius))
            GL.glVertex2f(float(self.resizeSpot[0]-self.resizeSpotRadius),
                          float(self.resizeSpot[1]+self.resizeSpotRadius))
            GL.glVertex2f(float(self.resizeSpot[0]-self.resizeSpotRadius),
                          float(self.resizeSpot[1]-self.resizeSpotRadius))
            GL.glEnd()
            GL.glPopName()

        GL.glPushName(0)
        GL.glBegin(GL.GL_QUADS)
        GL.glVertex2fv(self.polygonContour[0])
        GL.glVertex2fv(self.polygonContour[1])
        GL.glVertex2fv(self.polygonContour[2])
        GL.glVertex2fv(self.polygonContour[3])
        GL.glEnd()
        GL.glPopName()

        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glPopMatrix()
        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glPopMatrix()


    def setPosition(self, event, redo=1):
        """the trackball transmit the translation info
"""
        #print "colorMapLegend.setPosition", event.x, event.y
        self.coord2d[0] = event.x - self.clickPosFromLegendBottomLeft[0]
        self.coord2d[1] = event.y - self.clickPosFromLegendBottomLeft[1]

        if self.coord2d[0] < 0:
            self.coord2d[0] = 0
        if self.coord2d[1] < 0:
            self.coord2d[1] = 0

        if self.coord2d[0] > self.viewer.currentCamera.width:
            self.coord2d[0] = self.viewer.currentCamera.width
        if self.coord2d[1] > self.viewer.currentCamera.height:
            self.coord2d[1] = self.viewer.currentCamera.height

        self.viewer.objectsNeedingRedo[self] = None


    def setSize(self, event, redo=1):
        """override the Insert2d function
"""
        #print "colorMapLegend.setSize", self
        if self.verticalLegend is True:
            self.size[0] = event.x - self.coord2d[0]        
            self.size[1] = self.coord2d[1] - event.y

            if self.size[0] > self.viewer.currentCamera.width:
                self.size[0] = self.viewer.currentCamera.width
            if self.size[1] > self.viewer.currentCamera.height:
                self.size[1] = self.viewer.currentCamera.height
        else:
            self.size[1] = event.x - self.coord2d[0]        
            self.size[0] = self.coord2d[1] - event.y

            if self.size[1] > self.viewer.currentCamera.width:
                self.size[1] = self.viewer.currentCamera.width
            if self.size[0] > self.viewer.currentCamera.height:
                self.size[0] = self.viewer.currentCamera.height

        if self.size[0] < 1:
            self.size[0] = 1
        if self.size[1] < 1:
            self.size[1] = 1

        if self.needsRedoDpyListOnResize and self.viewer:
            self.viewer.objectsNeedingRedo[self] = None


    def ResetPosition(self):
        self.coord2d = deepcopy(self.initialPosition)
        if self.viewer:
            self.viewer.objectsNeedingRedo[self] = None


    def respondToDoubleClick(self, event):
        """
"""
        self.showOwnGui()

        if self.needsRedoDpyListOnResize and self.viewer:
            self.viewer.objectsNeedingRedo[self] = None


    def processHit_cb(self, pick):
        #print "colorMapLegend.processHit_cb", self
        #print "pick",pick
        #print "pick.event",dir(pick)
        #print "pick.type",pick.type
        #print "pick.event",dir(pick.event)
        #print "pick.event",pick.event
        #print "pick.event.type",pick.event.type
        #print "pick.event.state",pick.event.state
        #print "pick.event.time",pick.event.time
        #print "pick.hits",pick.hits

        if ( len(pick.hits) == 1) and  pick.hits.has_key(self):
            if self.viewer.currentObject != self:
                    # if the only hit is the legend, 
                    # it becomes the current object
                    self.viewer.SetCurrentObject(self)
                    self.isMoving = True
            elif pick.event.time - self.lastPickEventTime < 200: #double click
                self.viewer.SetCurrentObject(self.viewer.rootObject)
                self.respondToDoubleClick(pick.event)
            elif pick.hits[self][0][0] == 1:
                # the click in inside the resize button
                #print "resize"
                self.isMoving = False
            elif pick.hits[self][0][0] == 0:
                # the click in inside the legend but outside 
                # the resize button
                self.isMoving = True
                self.clickPosFromLegendBottomLeft = [pick.event.x - self.coord2d[0],
                                                     pick.event.y - self.coord2d[1]]
                #print "self.clickPosFromLegendBottomLeft", self.clickPosFromLegendBottomLeft

            if self.viewer:
                self.viewer.objectsNeedingRedo[self] = None

        elif self.viewer.currentObject == self:
            #print "the insert2d is selected, but picking is outside"
            self.isMoving = None
            self.viewer.SetCurrentObject(self.viewer.rootObject)
            if self.needsRedoDpyListOnResize and self.viewer:
                self.viewer.objectsNeedingRedo[self] = None

        self.lastPickEventTime = pick.event.time


    def createOwnGui(self):
        self.ownGui = Tkinter.Toplevel()
        self.ownGui.title(self.name)
        self.ownGui.protocol('WM_DELETE_WINDOW', self.ownGui.withdraw )

        frame1 = Tkinter.Frame(self.ownGui)
        frame1.pack(side='top')

        #unit
        self.unitsEnt = Pmw.EntryField(frame1, 
                                       label_text='Units  ',
                                       labelpos='w',
                                       value=self.unitsString,
                                       command=self.setWithOwnGui)
        self.unitsEnt.pack(side='top', fill='x')

        #glf vector font
        self.glfFont = Tkinter.StringVar()
        self.glfFont.set('chicago1.glf')
        self.glfFontCB = Pmw.ComboBox(frame1, label_text='Font    ',
                                   labelpos='w',
                                   entryfield_value=self.glfFont.get(),
                                   scrolledlist_items=self.glfVectorFontList,
                                   selectioncommand=self.setWithOwnGui)
        self.glfFontCB.pack(side='top', fill='x')

        #fontScale
        self.fontScaleThumb = ThumbWheel(frame1,
                                    labCfg={'text':'font scale            ', 'side':'left'},
                                    showLabel=1, 
                                    width=90,
                                    height=14,
                                    min=0, 
                                    max=200,
                                    type=int, 
                                    value=self.fontScale,
                                    callback=self.setWithOwnGui,
                                    continuous=True,
                                    oneTurn=10,
                                    wheelPad=0)
        self.fontScaleThumb.pack(side='top')

        #label
        lLabelValuesString = ''
        for lLabelValue in self.labelValues:
            lLabelValuesString += str(lLabelValue) + ' '
        self.labelValsEnt = Pmw.EntryField(
                                frame1, 
                                label_text='Numeric labels    ',
                                labelpos='w',
                                value=lLabelValuesString,
                                command=self.setWithOwnGui)
        self.labelValsEnt.component('entry').config(width=6)
        self.labelValsEnt.pack(side='top', fill='x')

        #numOfLabel
        self.numOfLabelsCtr = ThumbWheel(frame1,
                                    labCfg={'text':'Automatic labels', 'side':'left'},
                                    showLabel=1, 
                                    width=90,
                                    height=14,
                                    min=0, 
                                    max=200,
                                    type=int, 
                                    value=self.numOfLabels,
                                    callback=self.setWithOwnGui,
                                    continuous=True,
                                    oneTurn=20,
                                    wheelPad=0)
        self.numOfLabelsCtr.pack(side='top')

        # Interpolate
        self.interpVar = Tkinter.IntVar()
        self.interpVar.set(0)
        self.checkBoxFrame = Tkinter.Checkbutton(
                                frame1, 
                                text='Interpolate',
                                variable=self.interpVar, 
                                command=self.setWithOwnGui)
        self.checkBoxFrame.pack(side='top')

        # frame
        self.frameVar = Tkinter.IntVar()
        self.frameVar.set(1)
        self.checkBoxFrame = Tkinter.Checkbutton(
                                frame1, 
                                text='Frame',
                                variable=self.frameVar, 
                                command=self.setWithOwnGui)
        self.checkBoxFrame.pack(side='top')

        # invert labels color
        self.invertLabelsColorVar = Tkinter.IntVar()
        self.invertLabelsColorVar.set(0)
        self.checkBoxinvertLabelsColor = Tkinter.Checkbutton(
                                frame1, 
                                text='Invert labels color',
                                variable=self.invertLabelsColorVar, 
                                command=self.setWithOwnGui)
        #self.checkBoxFrame.pack(side='top')
        self.checkBoxinvertLabelsColor.pack(side='top')

        # colormapguiwidget:
        self.launchColormapWidget = Tkinter.Button(
                                        frame1, 
                                        text="Show colormap settings",
                                        command=self.colormapguiRef().showColormapSettings_cb 
                                        )
        self.launchColormapWidget.pack(side='top', fill='x')


    def setWithOwnGui(self, event=None):
        #print "setWithOwnGui"

        glfFont = self.glfFontCB.get()
        fontScale = int(self.fontScaleThumb.get())
        labelValues = map(float, string.split(self.labelValsEnt.get()))
        unitsString = self.unitsEnt.get()
        numOfLabels = int(self.numOfLabelsCtr.get())

        if self.interpVar.get() == 1:
            interp = True
        else:
            interp = False

        if self.frameVar.get() == 1:
            visibleFrame = True
        else:
            visibleFrame = False

        if self.invertLabelsColorVar.get() == 1:
            invertLabelsColor = True
        else:
            invertLabelsColor = False

        self.Set(
                glfFont=glfFont,
                fontScale=fontScale,
                labelValues=labelValues, 
                numOfLabels=numOfLabels,
                unitsString=unitsString,
                interp=interp,
                visibleFrame=visibleFrame,
                invertLabelsColor=invertLabelsColor,
                updateOwnGui=False)
        self.viewer.Redraw()


    def updateOwnGui(self):
        if self.ownGui is None:
            return
        self.ownGui.title(self.name)
        self.glfFontCB.selectitem(self.glfFont.get())
        self.fontScaleThumb.set(self.fontScale)
        lLabelValuesString = ''
        for lLabelValue in self.labelValues:
            lLabelValuesString += str(lLabelValue) + ' '
        self.labelValsEnt.setentry(lLabelValuesString)
        self.unitsEnt.setentry(self.unitsString)
        self.numOfLabelsCtr.set(self.numOfLabels)
        self.interpVar.set(self.interp)
        self.invertLabelsColorVar.set(self.visibleFrame)
        self.invertLabelsColorVar.set(self.invertLabelsColor)
예제 #30
0
    def createOwnGui(self):
        #print "GlfLabels.createOwnGui", self
        self.ownGui = Tkinter.Toplevel()
        self.ownGui.title(self.name)
        self.ownGui.protocol('WM_DELETE_WINDOW', self.ownGui.withdraw)

        frame1 = Tkinter.Frame(self.ownGui)
        frame1.pack(side='top')

        # label
        self.ownGui.labelEnt = Pmw.EntryField(frame1,
                                              label_text='label',
                                              labelpos='w',
                                              value=str(self.label),
                                              command=self.setWithOwnGui)
        self.ownGui.labelEnt.pack(side='top', fill='x')

        # fontName
        self.ownGui.guiFontNameComboBox = Pmw.ComboBox(
            frame1,
            label_text='font name',
            labelpos='w',
            entryfield_value=self.fontName,
            scrolledlist_items=self.glfVectorFontList,
            selectioncommand=self.setWithOwnGui)
        self.ownGui.guiFontNameComboBox.pack(side='top', fill='x')

        # wirefont
        self.ownGui.wireFontVar = Tkinter.IntVar()
        self.ownGui.wireFontVar.set(self.wireFont)
        self.ownGui.guiWireFont = Tkinter.Checkbutton(
            frame1,
            text='wire font',
            variable=self.ownGui.wireFontVar,
            command=self.setWithOwnGui)
        self.ownGui.guiWireFont.pack(side='top', fill='x')

        # fontSpacing
        self.ownGui.guiFontSpacing = ThumbWheel(
            frame1,
            labCfg={
                'text': 'font spacing',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            min=0,
            #max=100,
            type=float,
            value=self.fontSpacing,
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=1,
            wheelPad=2)
        self.ownGui.guiFontSpacing.pack(side='top', fill='x')

        # font global scale
        self.ownGui.guiGlobalScale = ThumbWheel(
            frame1,
            labCfg={
                'text': 'global scale',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            min=0,
            #max=100,
            type=float,
            value=1.,
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=5,
            wheelPad=2)
        self.ownGui.guiGlobalScale.pack(side='top', fill='x')

        # font scale X
        self.ownGui.guiFontScaleX = ThumbWheel(
            frame1,
            labCfg={
                'text': 'font scale X',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            min=0,
            #max=100,
            type=int,
            value=self.fontScales[0],
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=20,
            wheelPad=2)
        self.ownGui.guiFontScaleX.pack(side='top', fill='x')

        # font scale Y
        self.ownGui.guiFontScaleY = ThumbWheel(
            frame1,
            labCfg={
                'text': 'font scale Y',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            min=0,
            #max=100,
            type=int,
            value=self.fontScales[1],
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=20,
            wheelPad=2)
        self.ownGui.guiFontScaleY.pack(side='top', fill='x')

        self.ownGui.guiFramePolygonModeOptionMenu = Pmw.OptionMenu(
            frame1,
            label_text='frame PolygonMode',
            labelpos='w',
            initialitem=self.framePolygonModeDictRev[self.framePolygonMode],
            items=self.framePolygonModeDict.keys(),
            command=self.setWithOwnGui)
        self.ownGui.guiFramePolygonModeOptionMenu.pack(side='top', fill='x')

        # frame space X
        self.ownGui.guiFrameSpaceX = ThumbWheel(
            frame1,
            labCfg={
                'text': 'frame space X',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            min=0,
            #max=100,
            type=float,
            value=self.frameSpace[0],
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=5,
            wheelPad=2)
        self.ownGui.guiFrameSpaceX.pack(side='top', fill='x')

        # frame space Y
        self.ownGui.guiFrameSpaceY = ThumbWheel(
            frame1,
            labCfg={
                'text': 'frame space Y',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            min=0,
            #max=100,
            type=float,
            value=self.frameSpace[1],
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=5,
            wheelPad=2)
        self.ownGui.guiFrameSpaceY.pack(side='top', fill='x')

        # fontColor
        self.ownGui.guiColorChooser = ColorChooser(
            master=frame1,
            targetDict={
                'fontColor': (self.fontColor, 'RGB', self.setFontColor),
                'frameColor': (self.frameColor, 'RGB', self.setFrameColor)
            },
            targetKey='fontColor')
예제 #31
0
    def createOwnGui(self):
        self.ownGui = Tkinter.Toplevel()
        self.ownGui.title(self.name)
        self.ownGui.protocol('WM_DELETE_WINDOW', self.ownGui.withdraw )

        frame1 = Tkinter.Frame(self.ownGui)
        frame1.pack(side='top')

        #unit
        self.unitsEnt = Pmw.EntryField(frame1, 
                                       label_text='Units  ',
                                       labelpos='w',
                                       value=self.unitsString,
                                       command=self.setWithOwnGui)
        self.unitsEnt.pack(side='top', fill='x')

        #glf vector font
        self.glfFont = Tkinter.StringVar()
        self.glfFont.set('chicago1.glf')
        self.glfFontCB = Pmw.ComboBox(frame1, label_text='Font    ',
                                   labelpos='w',
                                   entryfield_value=self.glfFont.get(),
                                   scrolledlist_items=self.glfVectorFontList,
                                   selectioncommand=self.setWithOwnGui)
        self.glfFontCB.pack(side='top', fill='x')

        #fontScale
        self.fontScaleThumb = ThumbWheel(frame1,
                                    labCfg={'text':'font scale            ', 'side':'left'},
                                    showLabel=1, 
                                    width=90,
                                    height=14,
                                    min=0, 
                                    max=200,
                                    type=int, 
                                    value=self.fontScale,
                                    callback=self.setWithOwnGui,
                                    continuous=True,
                                    oneTurn=10,
                                    wheelPad=0)
        self.fontScaleThumb.pack(side='top')

        #label
        lLabelValuesString = ''
        for lLabelValue in self.labelValues:
            lLabelValuesString += str(lLabelValue) + ' '
        self.labelValsEnt = Pmw.EntryField(
                                frame1, 
                                label_text='Numeric labels    ',
                                labelpos='w',
                                value=lLabelValuesString,
                                command=self.setWithOwnGui)
        self.labelValsEnt.component('entry').config(width=6)
        self.labelValsEnt.pack(side='top', fill='x')

        #numOfLabel
        self.numOfLabelsCtr = ThumbWheel(frame1,
                                    labCfg={'text':'Automatic labels', 'side':'left'},
                                    showLabel=1, 
                                    width=90,
                                    height=14,
                                    min=0, 
                                    max=200,
                                    type=int, 
                                    value=self.numOfLabels,
                                    callback=self.setWithOwnGui,
                                    continuous=True,
                                    oneTurn=20,
                                    wheelPad=0)
        self.numOfLabelsCtr.pack(side='top')

        # Interpolate
        self.interpVar = Tkinter.IntVar()
        self.interpVar.set(0)
        self.checkBoxFrame = Tkinter.Checkbutton(
                                frame1, 
                                text='Interpolate',
                                variable=self.interpVar, 
                                command=self.setWithOwnGui)
        self.checkBoxFrame.pack(side='top')

        # frame
        self.frameVar = Tkinter.IntVar()
        self.frameVar.set(1)
        self.checkBoxFrame = Tkinter.Checkbutton(
                                frame1, 
                                text='Frame',
                                variable=self.frameVar, 
                                command=self.setWithOwnGui)
        self.checkBoxFrame.pack(side='top')

        # invert labels color
        self.invertLabelsColorVar = Tkinter.IntVar()
        self.invertLabelsColorVar.set(0)
        self.checkBoxinvertLabelsColor = Tkinter.Checkbutton(
                                frame1, 
                                text='Invert labels color',
                                variable=self.invertLabelsColorVar, 
                                command=self.setWithOwnGui)
        #self.checkBoxFrame.pack(side='top')
        self.checkBoxinvertLabelsColor.pack(side='top')

        # colormapguiwidget:
        self.launchColormapWidget = Tkinter.Button(
                                        frame1, 
                                        text="Show colormap settings",
                                        command=self.colormapguiRef().showColormapSettings_cb 
                                        )
        self.launchColormapWidget.pack(side='top', fill='x')
예제 #32
0
    def createSpinGui(self):
        #print "createSpinGui"
        
        self.spinGui = Tkinter.Toplevel()
        self.spinGui.title('Spin Settings')
        self.spinGui.protocol('WM_DELETE_WINDOW', self.spinGui.withdraw )

        mainFrame = Tkinter.Frame(self.spinGui, relief='ridge', borderwidth=3)

        lLabelSpinBold = Tkinter.Label(mainFrame,
                      text="Spinning only occurs in \"Object\" transform mode",
                      font=(ensureFontCase('helvetica'),10,'bold'))
        lLabelSpinBold.pack(side='top')

        lLabelSpin = Tkinter.Label(mainFrame,
                      font=(ensureFontCase('helvetica'),'9'),
                      justify='left',
                      text="""start: release the middle button while the mouse is still moving
stop: left click
"""
                     )
        lLabelSpin.pack(side='top')

        anglesFrame = Tkinter.Frame(mainFrame, relief='ridge', borderwidth=3)
        # off/spin/rock radio buttons
        radioFrame = Tkinter.Frame(anglesFrame)#, relief='ridge', borderwidth=3)

        radioOff = Tkinter.Radiobutton(
            radioFrame,
            text='Off',
            value=0,
            variable=self.spinVar,
            width=8,
            indicatoron=0,
            command=self.resetSpinValues,
            )
        radioOff.grid(row=0, column=0, sticky='we')
        radioSpin = Tkinter.Radiobutton(
            radioFrame,
            text='Spin',
            value=1,
            variable=self.spinVar,
            width=8,
            indicatoron=0,
            command=self.toggleCycle,
            )
        radioSpin.grid(row=0, column=1, sticky='we')
        radioBounce = Tkinter.Radiobutton(
            radioFrame,
            text='Bounce',
            value=2,
            variable=self.spinVar,
            width=8,
            indicatoron=0,
            command=self.toggleCycle,
            )
        radioBounce.grid(row=0, column=2, sticky='we')
        radioOscillate = Tkinter.Radiobutton(
            radioFrame,
            text='Oscillate',
            value=3,
            variable=self.spinVar,
            width=8,
            indicatoron=0,
            command=self.toggleCycle,
            )
        radioOscillate.grid(row=0, column=3, sticky='we')
        radioFrame.pack(side='top')

        self.spinGui.anglePerFrameThumbwheel = ThumbWheel(
                                    anglesFrame,
                                    labCfg={'text':'Angular speed (degrees per frame)', 'side':'left'},
                                    showLabel=1, 
                                    width=90,
                                    height=14,
                                    min=.01, 
                                    max=10.,
                                    type=float, 
                                    value=self.spinAnglePerFrame,
                                    callback=self.setWithSpinGui,
                                    continuous=True,
                                    oneTurn=5,
                                    wheelPad=0,
                                    )
        self.spinGui.anglePerFrameThumbwheel.pack(side='top', anchor='e')
        self.spinGui.rockAngleThumbwheel = ThumbWheel(
                                    anglesFrame,
                                    labCfg={'text':'Rock angle (degrees)', 'side':'left'},
                                    showLabel=1, 
                                    width=90,
                                    height=14,
                                    min=1, 
                                    max=360,
                                    type=int, 
                                    value=self.rockAngle,
                                    callback=self.setWithSpinGui,
                                    continuous=True,
                                    oneTurn=60,
                                    wheelPad=0,
                                    )
        self.spinGui.rockAngleThumbwheel.pack(side='top', anchor='e')
        def shiftRockCenter(val):
            lSpinRotMat = self.makeSpinRotationMat(self.spinAxis, -val)
            c = self.camera()
            c.viewer.rootObject.ConcatRotation(lSpinRotMat)
            c.Redraw()
            vi.afterRedraw()
            shiftRockCenterThumbwheel.set(0, update=0)
        shiftRockCenterThumbwheel = ThumbWheel(
                                    anglesFrame,
                                    labCfg={'text':'Shift rock center', 'side':'left'},
                                    showLabel=0, 
                                    width=90,
                                    height=14,
                                    min=-100, 
                                    max=100,
                                    type=int, 
                                    value=0,
                                    callback=shiftRockCenter,
                                    continuous=True,
                                    oneTurn=90,
                                    wheelPad=0,
                                    )
        shiftRockCenterThumbwheel.pack(side='top', anchor='e')
        anglesFrame.pack(side='top')

        self.spinGui.vectorGUI = vectorGUI(mainFrame,
                                           size=150,
                                           vector=self.spinAxis,
                                           callback=self.setWithSpinGui,
                                           )

        mainFrame.pack(side='top')
예제 #33
0
 def __init__(self, master=None, width=200, height=40,
              nblines=40):
     ThumbWheel.__init__(self, master, width, height, nblines)
     self.showLabelInWidget = 1
예제 #34
0
class XYZVectGUI(xyzGUI):
    def __init__(self,
                 master=None,
                 name='VectXYZ',
                 callback=None,
                 callbackX=None,
                 widthX=100,
                 heightX=26,
                 wheelPadX=4,
                 labcfgX={'text': None},
                 widthY=100,
                 heightY=26,
                 wheelPadY=4,
                 labcfgY={'text': None},
                 callbackY=None,
                 widthZ=100,
                 heightZ=26,
                 wheelPadZ=4,
                 callbackZ=None,
                 labcfgZ={'text': None},
                 **kw):

        xyzGUI.__init__(self, master, name, callback, callbackX, widthX,
                        heightX, wheelPadX, labcfgX, widthY, heightY,
                        wheelPadY, labcfgY, callbackY, widthZ, heightZ,
                        wheelPadZ, callbackZ, labcfgZ)

    def createEntries(self, master):
        self.f = Tkinter.Frame(master)
        self.f.grid(column=1, rowspan=6)

        self.entryX = NormVectEntry(master=self.f, label='Vector X', width=18)
        self.entryX.grid(row=0, column=0)
        self.entryX.callbacks.AddCallback(self.entryX_cb)

        self.thumbx = ThumbWheel(master=self.f,
                                 width=self.widthX,
                                 height=self.heightX,
                                 labcfg=self.labcfgX,
                                 wheelPad=self.wheelPadX)
        self.thumbx.callbacks.AddCallback(self.thumbx_cb)
        self.thumbx.grid(row=1, column=0)

        self.entryY = NormVectEntry(master=self.f, label='Vector Y', width=18)
        self.entryY.grid(row=2, column=0)
        self.entryY.callbacks.AddCallback(self.entryY_cb)

        self.thumby = ThumbWheel(master=self.f,
                                 width=self.widthY,
                                 height=self.heightY,
                                 labcfg=self.labcfgY,
                                 wheelPad=self.wheelPadY)
        self.thumby.callbacks.AddCallback(self.thumby_cb)
        self.thumby.grid(row=3, column=0)

        self.entryZ = NormVectEntry(master=self.f, label='Vector Z', width=18)
        self.entryZ.grid(row=4, column=0)
        self.entryZ.callbacks.AddCallback(self.entryZ_cb)

        self.thumbz = ThumbWheel(master=self.f,
                                 width=self.widthZ,
                                 height=self.heightZ,
                                 labcfg=self.labcfgZ,
                                 wheelPad=self.wheelPadZ)
        self.thumbz.callbacks.AddCallback(self.thumbz_cb)
        self.thumbz.grid(row=5, column=0)

        self.f.pack(side='top', expand=1)

        self.setVector([1.0, 0, 0], 'x')
        self.setVector([0.0, 1, 0], 'y')
        self.setVector([0.0, 0, 1], 'z')

    def set(self, x, y, z, v1, v2, v3):
        # called from outside
        self.thumbx.setValue(x)
        self.thumby.setValue(y)
        self.thumbz.setValue(z)
        self.entryX.set(v1)
        self.entryY.set(v2)
        self.entryZ.set(v3)

    def entryX_cb(self, events=None):
        self.callbacks.CallCallbacks(self.entryX.point)

    def entryY_cb(self, events=None):
        self.callbacks.CallCallbacks(self.entryY.point)

    def entryZ_cb(self, events=None):
        self.callbacks.CallCallbacks(self.entryZ.point)

#####################################################################
# the 'configure' methods:
#####################################################################

    def configure(self, **kw):
        for key, value in kw.items():
            # the 'set parameter' callbacks
            if key == 'labcfgX': self.setLabel(value, 'x')
            elif key == 'labcfgY': self.setLabel(value, 'y')
            elif key == 'labcfg': self.setLabel(value, 'z')

            elif key == 'continuousX': self.setContinuous(value, 'x')
            elif key == 'continuousY': self.setContinuous(value, 'y')
            elif key == 'continuousZ': self.setContinuous(value, 'z')

            elif key == 'precisionX': self.setPrecision(value, 'x')
            elif key == 'precisionY': self.setPrecision(value, 'y')
            elif key == 'precisionZ': self.setPrecision(value, 'z')

            elif key == 'typeX': self.setType(value, 'x')
            elif key == 'typeY': self.setType(value, 'y')
            elif key == 'typeZ': self.setType(value, 'z')

            elif key == 'minX': self.setMin(value, 'x')
            elif key == 'minY': self.setMin(value, 'y')
            elif key == 'minZ': self.setMin(value, 'z')

            elif key == 'maxX': self.setMax(value, 'x')
            elif key == 'maxY': self.setMax(value, 'y')
            elif key == 'maxZ': self.setMax(value, 'z')

            elif key == 'oneTurnX': self.setOneTurn(value, 'x')
            elif key == 'oneTurnY': self.setOneTurn(value, 'y')
            elif key == 'oneTurnZ': self.setOneTurn(value, 'z')

            elif key == 'showLabelX': self.setShowLabel(value, 'x')
            elif key == 'showLabelY': self.setShowLabel(value, 'y')
            elif key == 'showLabelZ': self.setShowLabel(value, 'z')

            elif key == 'incrementX': self.setIncrement(value, 'x')
            elif key == 'incrementY': self.setIncrement(value, 'y')
            elif key == 'incrementZ': self.setIncrement(value, 'z')

            elif key == 'vectX': self.setVector(value, 'x')
            elif key == 'vectY': self.setVector(value, 'y')
            elif key == 'vectZ':
                self.setVector(value, 'z')

                ####################################################

            elif key == 'lockTypeX':
                self.lockType(value, 'x')
            elif key == 'lockTypeY':
                self.lockType(value, 'y')
            elif key == 'lockTypeZ':
                self.lockType(value, 'z')

            elif key == 'lockMinX':
                self.lockMin(value, 'x')
            elif key == 'lockMinY':
                self.lockMin(value, 'y')
            elif key == 'lockMinZ':
                self.lockMin(value, 'z')

            elif key == 'lockBMinX':
                self.lockBMin(value, 'x')
            elif key == 'lockBMinY':
                self.lockBMin(value, 'y')
            elif key == 'lockBMinZ':
                self.lockBMin(value, 'z')

            elif key == 'lockMaxX':
                self.lockMax(value, 'x')
            elif key == 'lockMaxY':
                self.lockMax(value, 'y')
            elif key == 'lockMaxZ':
                self.lockMax(value, 'z')

            elif key == 'lockBMaxX':
                self.lockBMax(value, 'x')
            elif key == 'lockBMaxY':
                self.lockBMax(value, 'y')
            elif key == 'lockBMaxZ':
                self.lockBMax(value, 'z')

            elif key == 'lockIncrementX':
                self.lockIncrement(value, 'x')
            elif key == 'lockIncrementY':
                self.lockIncrement(value, 'y')
            elif key == 'lockIncrementZ':
                self.lockIncrement(value, 'z')

            elif key == 'lockBIncrementX':
                self.lockBIncrement(value, 'x')
            elif key == 'lockBIncrementY':
                self.lockBIncrement(value, 'y')
            elif key == 'lockBIncrementZ':
                self.lockBIncrement(value, 'z')

            elif key == 'lockPrecisionX':
                self.lockPrecision(value, 'x')
            elif key == 'lockPrecisionY':
                self.lockPrecision(value, 'y')
            elif key == 'lockPrecisionZ':
                self.lockPrecision(value, 'z')

            elif key == 'lockShowLabelX':
                self.lockShowLabel(value, 'x')
            elif key == 'lockShowLabelY':
                self.lockShowLabel(value, 'y')
            elif key == 'lockShowLabelZ':
                self.lockShowLabel(value, 'z')

            elif key == 'lockValueX':
                self.lockValue(value, 'x')
            elif key == 'lockValueY':
                self.lockValue(value, 'y')
            elif key == 'lockValueZ':
                self.lockValue(value, 'z')

            elif key == 'lockContinuousX':
                self.lockContinuous(value, 'x')
            elif key == 'lockContinuousY':
                self.lockContinuous(value, 'y')
            elif key == 'lockContinuousZ':
                self.lockContinuous(value, 'z')

            elif key == 'lockOneTurnX':
                self.lockOneTurn(value, 'x')
            elif key == 'lockOneTurnY':
                self.lockOneTurn(value, 'y')
            elif key == 'lockOneTurnZ':
                self.lockOneTurn(value, 'z')

    def setVector(self, value, mode):
        if mode == 'x':
            self.entryX.set(value)
        if mode == 'y':
            self.entryY.set(value)
        if mode == 'z':
            self.entryZ.set(value)
예제 #35
0
class Gantt:
    """
    Plot a simple Gant diagram for a list of tasks.
The task are specified as a list of (name, start, end) 3-tuples
"""
    def __init__(self, tasks, root=None):

        # create panel if needed
        if root is None:
            root = Tkinter.Toplevel()
            root.title("Execution profile")
            self.ownsMaster = True
        else:
            assert isinstance(root, Tkinter.Toplevel) or\
                   isinstance(root, Tkinter.Frame)
            self.ownsMaster = False
        self.root = root

        self.pixelsPersecond = 100
        self.yoff = 20
        self.scale = 1.0

        self.scrolledCanvas = Pmw.ScrolledCanvas(root,
                                                 canvas_width=600,
                                                 canvas_bg='white',
                                                 vscrollmode='static',
                                                 hscrollmode='static',
                                                 horizscrollbar_width=10,
                                                 vertscrollbar_width=10)
        self.canvas = self.scrolledCanvas.component('canvas')
        self.scrollregion = [0, 0, 4000, 4000]
        self.canvas.configure(scrollregion=tuple(self.scrollregion))

        self.scrolledCanvas.pack(expand=True, fill='both')

        f = self.bframe = Tkinter.Frame(root)

        self.scaleTimeTW = ThumbWheel(f,
                                      showLabel=0,
                                      width=70,
                                      height=16,
                                      type=float,
                                      value=0,
                                      callback=self.setTimeScaleFactor_cb,
                                      continuous=True,
                                      oneTurn=10,
                                      wheelPad=2,
                                      reportDelta=True)
        self.scaleTimeTW.pack(side='right', anchor='e')

        f.pack(side='bottom', expand=0, fill='x')

        self.relativeData = []
        self.setTasks(tasks)

    def setTasks(self, tasks):
        self.relativeData = []

        if len(tasks) == 0:
            return
        assert len(tasks)
        assert len(tasks[0]) == 3
        off = tasks[0][1]

        for node, t0, t1 in tasks:
            # name, start, length
            self.relativeData.append((node.name, t0 - off, t1 - t0))
        self.redraw()

    def setTimeScaleFactor_cb(self, value, event=None):
        self.scale = self.scale * (1.1)**value
        self.redraw()

    def redraw(self):
        pixelPerUnit = 30000  # use that many pixels to draw mini time

        cury = 20
        canvas = self.canvas
        canvas.delete("names")
        canvas.delete("lines")

        for name, start, length in self.relativeData:
            scale = self.scale
            x0 = 10 + scale * start * pixelPerUnit
            x1 = 10 + scale * (start + length) * pixelPerUnit
            canvas.create_text(x0,
                               cury,
                               text=name,
                               anchor='sw',
                               tags=('names'),
                               fill='magenta')
            canvas.create_line(x0,
                               cury,
                               x1,
                               cury,
                               width=3,
                               fill='black',
                               tags=('lines', name))
            canvas.create_text(x0,
                               cury + 20,
                               text='%.4f' % length,
                               anchor='sw',
                               tags=('names'),
                               fill='orange')
            cury += self.yoff
예제 #36
0
    def createOwnGui(self):
        #print "GlfLabels.createOwnGui", self
        self.ownGui = Tkinter.Toplevel()
        self.ownGui.title(self.name)
        self.ownGui.protocol('WM_DELETE_WINDOW', self.ownGui.withdraw)

        frame1 = Tkinter.Frame(self.ownGui)
        frame1.pack(side='top')

        # labels
        self.ownGui.labelsEnt = Pmw.EntryField(frame1,
                                               label_text='list of labels',
                                               labelpos='w',
                                               value=str(self.labels),
                                               command=self.setWithOwnGui)
        self.ownGui.labelsEnt.pack(side='top', fill='x')

        # billboard
        self.ownGui.billboardVar = Tkinter.IntVar()
        self.ownGui.billboardVar.set(self.billboard)
        self.ownGui.guiBillboard = Tkinter.Checkbutton(
            frame1,
            text='billboard',
            variable=self.ownGui.billboardVar,
            command=self.setWithOwnGui)
        self.ownGui.guiBillboard.pack(side='top', fill='x')

        # includeCameraRotationInBillboard
        self.ownGui.includeCameraRotationInBillboardVar = Tkinter.IntVar()
        self.ownGui.includeCameraRotationInBillboardVar.set(
            self.includeCameraRotationInBillboard)
        self.ownGui.guiIncludeCameraRotationInBillboard = Tkinter.Checkbutton(
            frame1,
            text='includeCameraRotationInBillboard',
            variable=self.ownGui.includeCameraRotationInBillboardVar,
            command=self.setWithOwnGui)
        self.ownGui.guiIncludeCameraRotationInBillboard.pack(side='top',
                                                             fill='x')

        #        # lighting
        #        self.ownGui.lightingVar = Tkinter.IntVar()
        #        self.ownGui.lightingVar.set(self.lighting)
        #        self.ownGui.guiLighting = Tkinter.Checkbutton(
        #                                frame1,
        #                                text='lighting',
        #                                variable=self.ownGui.lightingVar,
        #                                command=self.setWithOwnGui)
        #        self.ownGui.guiLighting.pack(side='top', fill='x')

        # font
        self.ownGui.guiFontComboBox = Pmw.ComboBox(
            frame1,
            label_text='font',
            labelpos='w',
            entryfield_value=self.font,
            scrolledlist_items=self.fontList,
            selectioncommand=self.setWithOwnGui)
        self.ownGui.guiFontComboBox.pack(side='top', fill='x')

        # font style
        self.ownGui.guiFontStyleComboBox = Pmw.ComboBox(
            frame1,
            label_text='font style',
            labelpos='w',
            entryfield_value=self.fontStyle,
            scrolledlist_items=self.fontStyleList,
            selectioncommand=self.setWithOwnGui)
        self.ownGui.guiFontStyleComboBox.pack(side='top', fill='x')

        # font spacing
        self.ownGui.guiSpacing = ThumbWheel(
            frame1,
            labCfg={
                'text': 'font spacing',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            min=0,
            #max=100,
            type=float,
            value=self.fontSpacing,
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=1,
            wheelPad=2)
        self.ownGui.guiSpacing.pack(side='top', fill='x')

        # font global scale
        self.ownGui.guiGlobalScale = ThumbWheel(
            frame1,
            labCfg={
                'text': 'global scale',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            min=0,
            #max=100,
            type=float,
            value=1.,
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=1,
            wheelPad=2)
        self.ownGui.guiGlobalScale.pack(side='top', fill='x')

        # font scale X
        self.ownGui.guiScaleX = ThumbWheel(
            frame1,
            labCfg={
                'text': 'scale X',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            min=0,
            #max=100,
            type=float,
            value=self.fontScales[0],
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=1,
            wheelPad=2)
        self.ownGui.guiScaleX.pack(side='top', fill='x')

        # font scale Y
        self.ownGui.guiScaleY = ThumbWheel(
            frame1,
            labCfg={
                'text': 'scale Y',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            min=0,
            #max=100,
            type=float,
            value=self.fontScales[1],
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=1,
            wheelPad=2)
        self.ownGui.guiScaleY.pack(side='top', fill='x')

        # font scale Z
        self.ownGui.guiScaleZ = ThumbWheel(
            frame1,
            labCfg={
                'text': 'scale Z',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            min=0,
            #max=100,
            type=float,
            value=self.fontScales[2],
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=1,
            wheelPad=2)
        self.ownGui.guiScaleZ.pack(side='top', fill='x')

        # font Translate X
        self.ownGui.guiTranslateX = ThumbWheel(
            frame1,
            labCfg={
                'text': 'translate X',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            #min=0,
            #max=100,
            type=float,
            value=self.fontTranslation[0],
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=1,
            wheelPad=2)
        self.ownGui.guiTranslateX.pack(side='top', fill='x')

        # font Translate Y
        self.ownGui.guiTranslateY = ThumbWheel(
            frame1,
            labCfg={
                'text': 'translate Y',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            #min=0,
            #max=100,
            type=float,
            value=self.fontTranslation[1],
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=1,
            wheelPad=2)
        self.ownGui.guiTranslateY.pack(side='top', fill='x')

        # font Translate Z
        self.ownGui.guiTranslateZ = ThumbWheel(
            frame1,
            labCfg={
                'text': 'translate Z',
                'side': 'left'
            },
            showLabel=1,
            width=80,
            height=16,
            #min=0,
            #max=100,
            type=float,
            value=self.fontTranslation[2],
            callback=self.setWithOwnGui,
            continuous=True,
            oneTurn=1,
            wheelPad=2)
        self.ownGui.guiTranslateZ.pack(side='top', fill='x')

        # font Rotate X
        self.ownGui.guiRotateX = ThumbWheel(frame1,
                                            labCfg={
                                                'text': 'Rotate X',
                                                'side': 'left'
                                            },
                                            showLabel=1,
                                            width=80,
                                            height=16,
                                            min=-180,
                                            max=180,
                                            type=float,
                                            value=self.fontRotateAngles[0],
                                            callback=self.setWithOwnGui,
                                            continuous=True,
                                            oneTurn=90,
                                            wheelPad=2)
        self.ownGui.guiRotateX.pack(side='top', fill='x')

        # font Rotate Y
        self.ownGui.guiRotateY = ThumbWheel(frame1,
                                            labCfg={
                                                'text': 'Rotate Y',
                                                'side': 'left'
                                            },
                                            showLabel=1,
                                            width=80,
                                            height=16,
                                            min=-180,
                                            max=180,
                                            type=float,
                                            value=self.fontRotateAngles[1],
                                            callback=self.setWithOwnGui,
                                            continuous=True,
                                            oneTurn=90,
                                            wheelPad=2)
        self.ownGui.guiRotateY.pack(side='top', fill='x')

        # font Rotate Z
        self.ownGui.guiRotateZ = ThumbWheel(frame1,
                                            labCfg={
                                                'text': 'Rotate Z',
                                                'side': 'left'
                                            },
                                            showLabel=1,
                                            width=80,
                                            height=16,
                                            min=-180,
                                            max=180,
                                            type=float,
                                            value=self.fontRotateAngles[2],
                                            callback=self.setWithOwnGui,
                                            continuous=True,
                                            oneTurn=90,
                                            wheelPad=2)
        self.ownGui.guiRotateZ.pack(side='top', fill='x')
class XYZVectGUI(xyzGUI):

    def __init__(self, master=None, name='VectXYZ', callback=None,
                 callbackX=None, widthX=100, heightX=26, wheelPadX=4,
                 labcfgX={'text':None}, widthY=100, heightY=26, wheelPadY=4,
                 labcfgY={'text':None}, callbackY=None, widthZ=100,
                 heightZ=26, wheelPadZ=4, callbackZ=None,
                 labcfgZ={'text':None}, **kw):

        xyzGUI.__init__(self, master, name, callback, callbackX, widthX,
                        heightX, wheelPadX, labcfgX, widthY, heightY,
                        wheelPadY, labcfgY, callbackY, widthZ, heightZ,
                        wheelPadZ, callbackZ, labcfgZ)

        
    def createEntries(self, master):
        self.f = Tkinter.Frame(master)
	self.f.grid(column=1, rowspan=6)

        self.entryX = NormVectEntry(master=self.f, label='Vector X', width=18)
        self.entryX.grid(row=0,column=0)
        self.entryX.callbacks.AddCallback(self.entryX_cb)

        self.thumbx = ThumbWheel(master=self.f, width=self.widthX,
                                 height=self.heightX, labcfg=self.labcfgX,
                                 wheelPad=self.wheelPadX)
        self.thumbx.callbacks.AddCallback(self.thumbx_cb)
        self.thumbx.grid(row=1, column=0)

        self.entryY = NormVectEntry(master=self.f, label='Vector Y', width=18)
        self.entryY.grid(row=2,column=0)
        self.entryY.callbacks.AddCallback(self.entryY_cb)


        self.thumby = ThumbWheel(master=self.f, width=self.widthY,
                                 height=self.heightY, labcfg=self.labcfgY,
                                 wheelPad=self.wheelPadY)
        self.thumby.callbacks.AddCallback(self.thumby_cb)
        self.thumby.grid(row=3, column=0)

        self.entryZ = NormVectEntry(master=self.f, label='Vector Z', width=18)
        self.entryZ.grid(row=4,column=0)
        self.entryZ.callbacks.AddCallback(self.entryZ_cb)


        self.thumbz = ThumbWheel(master=self.f, width=self.widthZ,
                                 height=self.heightZ, labcfg=self.labcfgZ,
                                 wheelPad=self.wheelPadZ)
        self.thumbz.callbacks.AddCallback(self.thumbz_cb)
        self.thumbz.grid(row=5, column=0)

        self.f.pack(side='top', expand=1)

        self.setVector([1.0,0,0],'x')
        self.setVector([0.0,1,0],'y')
        self.setVector([0.0,0,1],'z')

    def set(self, x, y, z, v1, v2, v3):
        # called from outside
        self.thumbx.setValue(x)
        self.thumby.setValue(y)
        self.thumbz.setValue(z)
        self.entryX.set(v1)
        self.entryY.set(v2)
        self.entryZ.set(v3)


    def entryX_cb(self, events=None):
        self.callbacks.CallCallbacks(self.entryX.point)
        

    def entryY_cb(self, events=None):
        self.callbacks.CallCallbacks(self.entryY.point)


    def entryZ_cb(self, events=None):
        self.callbacks.CallCallbacks(self.entryZ.point)


 #####################################################################
 # the 'configure' methods:
 #####################################################################

    def configure(self, **kw):
        for key,value in kw.items():
            # the 'set parameter' callbacks
            if key=='labcfgX': self.setLabel(value,'x')
            elif key=='labcfgY': self.setLabel(value,'y')
            elif key=='labcfg': self.setLabel(value,'z')

            elif key=='continuousX': self.setContinuous(value,'x')
            elif key=='continuousY': self.setContinuous(value,'y')
            elif key=='continuousZ': self.setContinuous(value,'z')

            elif key=='precisionX': self.setPrecision(value,'x')
            elif key=='precisionY': self.setPrecision(value,'y')
            elif key=='precisionZ': self.setPrecision(value,'z')

            elif key=='typeX': self.setType(value,'x')
            elif key=='typeY': self.setType(value,'y')
            elif key=='typeZ': self.setType(value,'z')

            elif key=='minX': self.setMin(value,'x')
            elif key=='minY': self.setMin(value,'y')
            elif key=='minZ': self.setMin(value,'z')

            elif key=='maxX': self.setMax(value,'x')
            elif key=='maxY': self.setMax(value,'y')
            elif key=='maxZ': self.setMax(value,'z')

            elif key=='oneTurnX': self.setOneTurn(value,'x')
            elif key=='oneTurnY': self.setOneTurn(value,'y')
            elif key=='oneTurnZ': self.setOneTurn(value,'z')

            elif key=='showLabelX': self.setShowLabel(value,'x')
            elif key=='showLabelY': self.setShowLabel(value,'y')
            elif key=='showLabelZ': self.setShowLabel(value,'z')

            elif key=='incrementX': self.setIncrement(value,'x')
            elif key=='incrementY': self.setIncrement(value,'y')
            elif key=='incrementZ': self.setIncrement(value,'z')

            elif key=='vectX' : self.setVector(value,'x')
            elif key=='vectY' : self.setVector(value,'y')
            elif key=='vectZ' : self.setVector(value,'z')

            ####################################################

            elif key=='lockTypeX': self.lockType(value,'x')
            elif key=='lockTypeY': self.lockType(value,'y')
            elif key=='lockTypeZ': self.lockType(value,'z')

            elif key=='lockMinX': self.lockMin(value,'x')
            elif key=='lockMinY': self.lockMin(value,'y')
            elif key=='lockMinZ': self.lockMin(value,'z')

            elif key=='lockBMinX': self.lockBMin(value,'x')
            elif key=='lockBMinY': self.lockBMin(value,'y')
            elif key=='lockBMinZ': self.lockBMin(value,'z')

            elif key=='lockMaxX': self.lockMax(value,'x')
            elif key=='lockMaxY': self.lockMax(value,'y')
            elif key=='lockMaxZ': self.lockMax(value,'z')

            elif key=='lockBMaxX': self.lockBMax(value,'x')
            elif key=='lockBMaxY': self.lockBMax(value,'y')
            elif key=='lockBMaxZ': self.lockBMax(value,'z')

            elif key=='lockIncrementX': self.lockIncrement(value,'x')
            elif key=='lockIncrementY': self.lockIncrement(value,'y')
            elif key=='lockIncrementZ': self.lockIncrement(value,'z')

            elif key=='lockBIncrementX': self.lockBIncrement(value,'x')
            elif key=='lockBIncrementY': self.lockBIncrement(value,'y')
            elif key=='lockBIncrementZ': self.lockBIncrement(value,'z')

            elif key=='lockPrecisionX': self.lockPrecision(value,'x')
            elif key=='lockPrecisionY': self.lockPrecision(value,'y')
            elif key=='lockPrecisionZ': self.lockPrecision(value,'z')

            elif key=='lockShowLabelX': self.lockShowLabel(value,'x')
            elif key=='lockShowLabelY': self.lockShowLabel(value,'y')
            elif key=='lockShowLabelZ': self.lockShowLabel(value,'z')

            elif key=='lockValueX': self.lockValue(value,'x')
            elif key=='lockValueY': self.lockValue(value,'y')
            elif key=='lockValueZ': self.lockValue(value,'z')

            elif key=='lockContinuousX': self.lockContinuous(value,'x')
            elif key=='lockContinuousY': self.lockContinuous(value,'y')
            elif key=='lockContinuousZ': self.lockContinuous(value,'z')

            elif key=='lockOneTurnX': self.lockOneTurn(value,'x')
            elif key=='lockOneTurnY': self.lockOneTurn(value,'y')
            elif key=='lockOneTurnZ': self.lockOneTurn(value,'z')


    def setVector(self, value, mode):
       if mode == 'x':
           self.entryX.set(value)
       if mode == 'y':
            self.entryY.set(value)
       if mode == 'z':
            self.entryZ.set(value)