Changeset 1884 for trunk/python


Ignore:
Timestamp:
08/20/10 18:46:03 (14 years ago)
Author:
Kana Sugimoto
Message:

New Development: Yes

JIRA Issue: Yes (CAS-1801)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: A new button 'note' added to casatoolbar

Test Programs: Need GUI testing

Put in Release Notes: Yes

Module(s): asap.plotter

Description:

A new button, 'note', added to casatoolbar.
You can graphically add an arbitrary text string on the plotter
when 'note' button is active.


Location:
trunk/python
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/casatoolbar.py

    r1826 r1884  
    11import os
    22import matplotlib
     3
    34######################################
    45##    Add CASA custom toolbar       ##
     
    144145        mymask.select_mask(once=True,showmask=False)
    145146
     147    def _mod_note(self,event):
     148        # Do not fire event when in zooming/panning mode
     149        if not self.figmgr.toolbar.mode == '':
     150            return
     151        if event.button ==1:
     152            self.notewin.load_textwindow(event)
     153        elif event.button == 3 and self._note_picked(event):
     154            self.notewin.show_modmenu(event)
     155        return
     156
     157    def _note_picked(self,event):
     158        # just briefly check if any texts are picked
     159        for textobj in self.canvas.figure.texts:
     160            if textobj.contains(event)[0]:
     161                return True
     162        for ax in self.canvas.figure.axes:
     163            for textobj in ax.texts:
     164                if textobj.contains(event)[0]:
     165                    return True
     166        #print "No text picked"
     167        return False
     168
    146169#####################################
    147170##    Backend dependent Classes    ##
     
    150173if matplotlib.get_backend() == 'TkAgg':
    151174    import Tkinter as Tk
     175    from notationwindow import NotationWindowTkAgg
    152176
    153177class CustomToolbarTkAgg(CustomToolbarCommon, Tk.Frame):
     
    164188        self.button=True
    165189        self._add_custom_toolbar()
     190        self.notewin=NotationWindowTkAgg(master=self.canvas)
    166191        CustomToolbarCommon.__init__(self,parent)
    167192
     
    174199                                   text='statistics',
    175200                                   command=self.stat_cal)
     201        self.bNote=self._NewButton(master=self,
     202                                   text=' note ',
     203                                   command=self.modify_note)
    176204        self.bQuit=self._NewButton(master=self,
    177205                                   text='Quit',
     
    198226        self.bStat.config(relief='raised')
    199227        self.bSpec.config(relief='sunken')
     228        self.bNote.config(relief='raised')
    200229        self.mode='spec'
    201230        self.__disconnect_event()
     
    209238        self.bSpec.config(relief='raised')
    210239        self.bStat.config(relief='sunken')
     240        self.bNote.config(relief='raised')
    211241        self.mode='stat'
    212242        self.__disconnect_event()
    213243        self._p.register('button_press',self._single_mask)
     244
     245    def modify_note(self):
     246        if not self.figmgr.toolbar.mode == '' or not self.button: return
     247        self.figmgr.toolbar.set_message('text: select a position/text')
     248        if self.mode == 'note': return
     249        self.bSpec.config(relief='raised')
     250        self.bStat.config(relief='raised')
     251        self.bNote.config(relief='sunken')
     252        self.mode='note'
     253        self.__disconnect_event()
     254        self._p.register('button_press',self._mod_note)
    214255
    215256    def quit(self):
Note: See TracChangeset for help on using the changeset viewer.