Пример #1
0
def test():
   import vcs_legacy,cdms2 as cdms,os,sys               # import vcs_legacy and cu

   f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','clt.nc'))
   s=f.getslab('clt')                   # get slab clt
   x=vcs_legacy.init()                         # construct vcs_legacy canvas

   x.plot(s,'default','isofill','quick', bg=1) # plot slab the old way, but in background
   x.gif('test')			# generate gif file
   x.postscript('test')		        # generate postscript file
   x.cgm('test')		        # generate cgm file

   x.setcolormap("ASD")		# change the colormap
   x.clear()				# clear all segments

   t1=x.createtemplate('test1','ASD1_of_2') # create template 'test' from AMIPDUD
   t2=x.createtemplate('test2','ASD2_of_2') # create template 'test' from AMIPDUD
   isof=x.createisofill('test')		# create isofill graphics method from default
   isol=x.createisoline('test')		# create isoline graphics method from default

   ######################################################################
   # draw isofill plot on top, then an isoline plot on the bottom       #
   ######################################################################
   x.plot(s,t1,isof, bg=1)		# generate isofill plot in background
   x.plot(s,t2, isol, bg=1)		# generate isoline plot in background
   x.gif('test2.gif')			# generate gif file
   x.postscript('test2.ps')		# generate postscript file
   x.cgm('test2.cgm')			# generate cgm file

   x.clear()				# clear all segments

   ######################################################################
   # draw isofill plot, then overlay an isoline plot                    #
   ######################################################################
   x.plot(s, isof, bg=1)		# generate isofill plot
   x.plot(s, isol, 'default', bg=1)	# generate isoline plot
   x.gif('test3.gif')			# generate gif file


   x.clear()                            # clear all segments
   x.setcolormap("default")		# change colormap to default
   x.plot(s,bg=1)			# plot boxfill
   x.postscript('test4.ps')		# create a postscript file
   x.pstogif('test4.ps')		# generate a gif file from the postscript file
   x.gs('test.png')                     # generate ghostscript png output file
   x.gs('test.tif', device = 'tiff24nc', orientation = 'l', resolution = '172.x172.')# generate ghostscript tiff output file

   print '***************************************************************************************'
   print '******                                                                           ******'
   print '******   H A R D C O P Y   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
   print '******                                                                           ******'
   print '***************************************************************************************'
Пример #2
0
def test():
    import vcs_legacy, cdms2 as cdms, os, sys  # import vcs_legacy and cu

    f = cdms.open(
        os.path.join(cdms.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'clt.nc'))
    s = f.getslab('clt')  # get slab clt
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    x.plot(s, 'default', 'isofill', 'quick',
           bg=1)  # plot slab the old way, but in background
    x.gif('test')  # generate gif file
    x.postscript('test')  # generate postscript file
    x.cgm('test')  # generate cgm file

    x.setcolormap("ASD")  # change the colormap
    x.clear()  # clear all segments

    t1 = x.createtemplate('test1',
                          'ASD1_of_2')  # create template 'test' from AMIPDUD
    t2 = x.createtemplate('test2',
                          'ASD2_of_2')  # create template 'test' from AMIPDUD
    isof = x.createisofill(
        'test')  # create isofill graphics method from default
    isol = x.createisoline(
        'test')  # create isoline graphics method from default

    ######################################################################
    # draw isofill plot on top, then an isoline plot on the bottom       #
    ######################################################################
    x.plot(s, t1, isof, bg=1)  # generate isofill plot in background
    x.plot(s, t2, isol, bg=1)  # generate isoline plot in background
    x.gif('test2.gif')  # generate gif file
    x.postscript('test2.ps')  # generate postscript file
    x.cgm('test2.cgm')  # generate cgm file

    x.clear()  # clear all segments

    ######################################################################
    # draw isofill plot, then overlay an isoline plot                    #
    ######################################################################
    x.plot(s, isof, bg=1)  # generate isofill plot
    x.plot(s, isol, 'default', bg=1)  # generate isoline plot
    x.gif('test3.gif')  # generate gif file

    x.clear()  # clear all segments
    x.setcolormap("default")  # change colormap to default
    x.plot(s, bg=1)  # plot boxfill
    x.postscript('test4.ps')  # create a postscript file
    x.pstogif('test4.ps')  # generate a gif file from the postscript file
    x.gs('test.png')  # generate ghostscript png output file
    x.gs('test.tif',
         device='tiff24nc',
         orientation='l',
         resolution='172.x172.')  # generate ghostscript tiff output file

    print '***************************************************************************************'
    print '******                                                                           ******'
    print '******   H A R D C O P Y   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
    print '******                                                                           ******'
    print '***************************************************************************************'
Пример #3
0
def test():
   import vcs_legacy,cdms2 as cdms,time,os,sys,support          # import vcs_legacy and cu

   bg= support.bg
   
   f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','clt.nc')) # open clt file
   s=f('clt')                           # get slab clt
   x=vcs_legacy.init()                         # construct vcs_legacy canvas
   

   a=x.createoutline('test')           # create 'test' outline
   if not vcs_legacy.isgraphicsmethod(a):            # test object 'a' for graphics method
      raise Exception, "Error did not retrieve the gm"
   else:
      if not vcs_legacy.isoutline(a):		# check for outline
         raise Exception, "Error gm is not right type"

   x.plot(s,'default','outline','test',bg=bg)# plot slab the old way
   support.check_plot(x)
   if bg==0:
      x.geometry(450,337,100,0)            # change the geometry and location
      x.flush()
      support.check_plot(x)
   
   s=f('u')	                        # get u slab
   x.clear()                            # clear the VCS Canvas
   x.plot(s,'default','outline','test',bg=bg)# plot the surface data
   support.check_plot(x)
   
   
   a.script('test','w')			# save 'test' outline as a Python script
   
   a.xticlabels('lon30','lon30')        # change the x-axis
   support.check_plot(x)
   a.xticlabels('','')                  # remove the x-axis
   support.check_plot(x)
   a.xticlabels('*')                    # put the x-axis
   support.check_plot(x)
   a.datawc(-45.0, 45.0, -90.0, 90.0)   # change the region
   support.check_plot(x)
   a.datawc(1e20,1e20,1e20,1e20)        # put the region back
   support.check_plot(x)
   

   cont = False
   for anarg in sys.argv:
      if anarg in ['--extended', '--full','-E','-F']:
         cont = True
         break
   if cont is False:
     print '\n************* PARTIAL TEST *****************'
     print 'FOR COMPLETE TEST OF THIS MODULE USE '
     print '   -F (--full) or -E (--extended) option'
     print '************* PARTIAL TEST *****************\n'
     sys.exit()

   a.outline=([0])			# set the outline value
   support.check_plot(x)
   a.line=0        			# same as 'solid', change the line style
   support.check_plot(x)
   a.line=1        			# same as 'dash', change the line style
   support.check_plot(x)
   a.line=2        			# same as 'dot', change the line style
   support.check_plot(x)
   a.line=3        			# same as 'dash-dot', change the line style
   support.check_plot(x)
   a.line=4        			# same as 'long-dash', change the line style
   support.check_plot(x)
   a.linecolor=(77)			# change the line color
   support.check_plot(x)
   a.linecolor=16			# change the line color
   support.check_plot(x)
   a.linecolor=44  			# same as a.linecolor=(44)
   support.check_plot(x)
   a.linecolor=None			# use the default line color, black
   support.check_plot(x)
   a.line=None				# use default line style, solid black line
   support.check_plot(x)

   a.outline=([1])			# set the outline value
   support.check_plot(x)
   a.outline=([0,1])			# set the outline value
   support.check_plot(x)
   a.outline=([0])			# set the outline value
   support.check_plot(x)
   
   x.clear()                            # clear the VCS Canvas
   x.outline(s,a,'default',bg=bg)             # plot outline using 'default' template
   support.check_plot(x)
   
   objs =x.listelements('template')                   # get the list of templates
   t=x.createtemplate('test')           # create template 'test' from 'default' template
   if not vcs_legacy.istemplate(t):                  # test whether 't' is a template or not
      raise Exception,"Error template not created"
   else:
      a2 =x.listelements('template')                   # get the list of templates
      if objs==a2:
         raise Exception,"Error template not created or added to list"
   
   x.clear()				# clear the VCS Canvas
   x.plot(t,a,s,bg=bg)			# plot outline template 't', outline 'a', and array 's'
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.outline(a,s,t,bg=bg)			# plot using outline 'a', array 's', and template 't'
   support.check_plot(x)
   
   #########################################################################
   # Create line object 'l' from the default line                          #
   #########################################################################
   #########################################################################
   objs = x.listelements('line')                      	# show the list of line secondary objects
   l=x.createline('test')
   if not vcs_legacy.issecondaryobject(l):           # check to see if it is a secondary object
      raise Exception,"Error did not get line"
   else:
      if not vcs_legacy.isline(l):                  	# check to see if it is a line
         raise Exception, "Error object created is not line"
   
   #########################################################################
   # Use the create line object 'l' from above and modify the line object  #
   #########################################################################
   a.line=l				# use the line object
   support.check_plot(x)
   l.color = 44                         # change the line color
   support.check_plot(x)
   l.type ='dash'                       # change the line type
   support.check_plot(x)
   
   
   a = x.listelements('outline')                      # show list of gm
   r=x.createoutline('test2','quick')     # create xyvsy 'test2'
   a2 = x.listelements('outline')                      # show list of gm
   if a2==a:
      raise "error gm not created or not added to list"
   x.removeobject(r)                    # remove xyvsy 'test2'
   a3 = x.listelements('outline')                      # show list of gm
   if a3!=a:
      raise "error gm not removed"
   
   
   #################################################################################
   # to see how x.update and x.mode work, see testoutline.py                       #
   #################################################################################
   #x.update()                             
   #x.mode=1
   #x.mode=0
   print '*************************************************************************************'
   print '******                                                                         ******'
   print '******   O U T F I L L   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
   print '******                                                                         ******'
   print '*************************************************************************************'
Пример #4
0
def test():
    import vcs_legacy, cdms2 as cdms, time, os, sys, support  # import vcs_legacy and cdms

    bg = support.bg

    f = cdms.open(
        os.path.join(cdms.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'clt.nc'))
    s1 = f.getslab('clt')  # get slab clt
    s2 = f.getslab('clt', 4, 4, -45, 45, -90, 90)
    s3 = f.getslab('clt', 6, 6, 0, 90, 0, 180)
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    p1 = x.plot(s1, bg=bg)  # plot slab the old way
    support.check_plot(x)
    x.plot(s2, bg=bg)  # plot slab the old way
    support.check_plot(x)

    p2 = x.getplot('dpy_plot_2')  # get display plot s2

    if not vcs_legacy.queries.isplot(p1):  # check for display plot object
        raise exception, "Error, p1 not a display!"

    if not '--extended' in sys.argv:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()

    p2.name = 'p2_name'  # change display plot's (p2) name
    p2.off = 1  # undisplay display plot (p2)
    support.check_plot(x)
    p2.off = 0  # redisplay display plot (p2)
    support.check_plot(x)

    p1.priority = 1  # bring display plot (p1) to the front
    support.check_plot(x)

    p2.off = 1  # undisplay display plot (p2)
    p1.template = 'default_dud'  # change display plot (p1) template
    support.check_plot(x)

    x.mode = 0  # turn atomatic update off
    p1.template = 'default'  # change display plot (p1) template
    p1.g_type = 'isoline'  # change display plot (p1) graphics type
    support.check_plot(x)
    x.update()  # view changes now
    support.check_plot(x)

    x.mode = 1  # turn atomatic update mode back on
    p1.g_type = 'isofill'  # change display plot (p1) graphics type
    support.check_plot(x)
    p1.g_name = 'quick'  # change display plot (p1) graphics name
    support.check_plot(x)

    p1.array = ['plot_2']  # change display plot (p1) array object
    support.check_plot(x)
    p1.array = ['plot_1']  # change display plot (p1) array object
    support.check_plot(x)
    p1.array = [s3]  # change display plot (p1) array object
    support.check_plot(x)

    #########################################################################
    #								           #
    # Produce an overlay plot.                                              #
    #								           #
    #########################################################################
    x.mode = 0  # turn atomatic update mode back on
    p1.array = ['plot_1']  # change display plot (p1) array object
    p2.off = 0  # redisplay display plot (p2)
    p2.priority = 2  # bring display plot (p2) to the front
    p2.array = [s1]  # change display plot (p2) array object
    p2.g_type = 'isoline'  # change display plot (p2) graphics type
    p2.g_name = 'default'  # change display plot (p1) graphics name
    x.update()  # view changes now
    support.check_plot(x)

    x.mode = 1  # turn atomatic update mode back on
    x.removeobject(p1)  # remove the display plot (p1)
    support.check_plot(x)

    print '*************************************************************************************'
    print '******                                                                         ******'
    print '******   D I S P L A Y   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
    print '******                                                                         ******'
    print '*************************************************************************************'
Пример #5
0
def test():
    import vcs_legacy, cdms2 as cdms, time, os, sys, support  # import vcs_legacy and cdms

    bg = support.bg

    f = cdms.open(os.path.join(cdms.__path__[0], "..", "..", "..", "..", "sample_data", "clt.nc"))
    s1 = f.getslab("clt")  # get slab clt
    s2 = f.getslab("clt", 4, 4, -45, 45, -90, 90)
    s3 = f.getslab("clt", 6, 6, 0, 90, 0, 180)
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    p1 = x.plot(s1, bg=bg)  # plot slab the old way
    support.check_plot(x)
    x.plot(s2, bg=bg)  # plot slab the old way
    support.check_plot(x)

    p2 = x.getplot("dpy_plot_2")  # get display plot s2

    if not vcs_legacy.queries.isplot(p1):  # check for display plot object
        raise exception, "Error, p1 not a display!"

    if not "--extended" in sys.argv:
        print "\n************* PARTIAL TEST *****************"
        print "FOR COMPLETE TEST OF THIS MODULE USE "
        print "   -F (--full) or -E (--extended) option"
        print "************* PARTIAL TEST *****************\n"
        sys.exit()

    p2.name = "p2_name"  # change display plot's (p2) name
    p2.off = 1  # undisplay display plot (p2)
    support.check_plot(x)
    p2.off = 0  # redisplay display plot (p2)
    support.check_plot(x)

    p1.priority = 1  # bring display plot (p1) to the front
    support.check_plot(x)

    p2.off = 1  # undisplay display plot (p2)
    p1.template = "default_dud"  # change display plot (p1) template
    support.check_plot(x)

    x.mode = 0  # turn atomatic update off
    p1.template = "default"  # change display plot (p1) template
    p1.g_type = "isoline"  # change display plot (p1) graphics type
    support.check_plot(x)
    x.update()  # view changes now
    support.check_plot(x)

    x.mode = 1  # turn atomatic update mode back on
    p1.g_type = "isofill"  # change display plot (p1) graphics type
    support.check_plot(x)
    p1.g_name = "quick"  # change display plot (p1) graphics name
    support.check_plot(x)

    p1.array = ["plot_2"]  # change display plot (p1) array object
    support.check_plot(x)
    p1.array = ["plot_1"]  # change display plot (p1) array object
    support.check_plot(x)
    p1.array = [s3]  # change display plot (p1) array object
    support.check_plot(x)

    #########################################################################
    # 								           #
    # Produce an overlay plot.                                              #
    # 								           #
    #########################################################################
    x.mode = 0  # turn atomatic update mode back on
    p1.array = ["plot_1"]  # change display plot (p1) array object
    p2.off = 0  # redisplay display plot (p2)
    p2.priority = 2  # bring display plot (p2) to the front
    p2.array = [s1]  # change display plot (p2) array object
    p2.g_type = "isoline"  # change display plot (p2) graphics type
    p2.g_name = "default"  # change display plot (p1) graphics name
    x.update()  # view changes now
    support.check_plot(x)

    x.mode = 1  # turn atomatic update mode back on
    x.removeobject(p1)  # remove the display plot (p1)
    support.check_plot(x)

    print "*************************************************************************************"
    print "******                                                                         ******"
    print "******   D I S P L A Y   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******"
    print "******                                                                         ******"
    print "*************************************************************************************"
Пример #6
0
import vcs_legacy, support
if support.dogui:
    x = vcs_legacy.init()
    x.graphicsmethodgui(gm_type='boxfill', gm_name='ASD')
else:
    print 'You need to run this one by hand (turn support.dogui to 1 first)'
Пример #7
0
def test():
   import vcs_legacy,cdms2,time,os,sys,support          # import vcs_legacy and cdms

   # In the initial.attribute file the page orientation is set to
   # portrait. The test is to convert from portrait to landscape.
   # See your initial.attribute file and set "Page(portrait)".
   # This should be located at the top of the initial.attribute
   # file.
   x=vcs_legacy.init()
   x.pause_time = 2
   
   # Check for the canvas orientation, which should be by default 'landscape'
   if x.islandscape() == 1:              # will return 1 if true or 0 if false
      print 'landscape page mode'
   if x.isportrait() == 1:		      # will return 1 if true or 0 if false
      print 'portrait page mode'
   print 'The page orientation is ( %s ). ' % x.orientation()  # will return 'landscape' or 'portrait'
   
   # Change the page orientation to portrait and print the test cases
   print '\nChange the page orientation to portrait and test'
   x.portrait()			# Change page orientation to portrait
   if x.islandscape() == 1:
      print 'landscape page mode'
   if x.isportrait() == 1:
      print 'portrait page mode'
   print 'The page orientation is ( %s ). ' % x.orientation()  # will return 'landscape' or 'portrait'
   
   # Change the page orientation to landscape and print the test cases
   print '\nChange the page orientation to landscape and test'
   x.landscape()
   if x.islandscape() == 1:              # will return 1 if true or 0 if false
      print 'landscape page mode'
   if x.isportrait() == 1:		      # will return 1 if true or 0 if false
      print 'portrait page mode'
   print 'The page orientation is ( %s ). ' % x.orientation()  # will return 'landscape' or 'portrait'
   

   #
   # prints in location mode
   # I feel this is correct!
   #
   f=cdms2.open(os.path.join(cdms2.__path__[0],'..','..','..','..','sample_data','clt.nc'))
   s=f('clt')
   x=vcs_legacy.init()
   t=x.createtemplate('new')
   to=x.createtextorientation('test')
   to.height = 30
   t.mean.y=0.5
   t.mean.x=0.5
   t.mean.textorientation = to 
   t.mean.list()
   x.plot(s,t,bg=support.bg)
   support.check_plot(x)
   x.flush()
   support.check_plot(x)
   
   #
   x.portrait()           # This will clear the screen
   support.check_plot(x)
   x.plot(s,t,bg=support.bg)
   support.check_plot(x)

   #
   x.landscape()           # This will clear the screen
   support.check_plot(x)
   x.plot(s,t,bg=support.bg)
   support.check_plot(x)
   
   print '*************************************************************************************'
   print '******                                                                         ******'
   print '******   P A G E  O R I E N T A T I O N   T E S T   C O M P L E T E D          ******'
   print '******   S U C E S S F U L L Y    ! ! !                                        ******'
   print '******                                                                         ******'
   print '*************************************************************************************'
Пример #8
0
    def __init__(self,
                 canvas=None,
                 gui_parent=None,
                 dialog_parent=None,
                 master=None,
                 name='default',
                 Parent=None):
        self.gui_parent = gui_parent
        if canvas is None:
            self.canvas = vcs_legacy.init()
        else:
            self.canvas = canvas

        self.line = self.canvas.getline(name)
        if self.line is None:
            if not name in self.canvas.listelements('line'):
                raise 'Error ' + t_name + ' is not a valid line name'
            else:
                raise 'Weird unkwnown error but no line object returned....'
        self.parent = Parent
        self.parent_Name = self.parent.parent_Name
        ## Saves original values
        self.orig = []
        self.save_vals()

        L_color = gui_support.gui_color.L_color

        if self.gui_parent is None:
            self.gui_parent = Tkinter.Toplevel()
            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
            self.gui_parent.withdraw()
        title = 'Line Editor - table: ' + self.line.name
        self.dialog = Pmw.Dialog(
            master,
            title=title,
            buttons=(),
        )
        self.dialog.withdraw()

        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent = self.dialog.interior()
        parent.configure(bg=L_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                                      hull_relief='raised',
                                      hull_borderwidth=2,
                                      balloon=gui_support.balloon)
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File',
                                'Open/Save VCS Line Objects',
                                tearoff=1)
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Open line object file',
            label='Open LineObject File',
            command=self.evt_open_file,
        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save Line',
            label='Save (i.e Apply changes)',
            command=self.setline,
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Copy Line',
            label='Copy Line',
            command=self.evt_save_line_as,
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save to file',
            label='Save To File',
            command=self.evt_save_to_file,
        )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            statusHelp='Close Line Editor',
            label="Exit Line Editor",
            command=self.dialog.destroy,
        )

        ##         self.ftype=Tkinter.Frame(parent)
        ##         self.ftype.pack(side='top')
        self.tprop = Pmw.Group(
            parent,
            tag_text='Line',
            tag_bg=L_color,
            tagindent=10,
            hull_bg=L_color,
            hull_highlightbackground=L_color,
            hull_highlightcolor=L_color,
            ring_bg=L_color,
        )
        self.tprop.pack(expand='yes', fill='both')
        self.tproperties = self.tprop.interior()
        self.tproperties.configure(bg=L_color)
        lines = self.canvas.listelements('line')
        lines.sort()

        labels = []
        self.Line = Pmw.OptionMenu(
            self.tproperties,
            items=lines,
            labelpos='w',
            label_text='Name:',
            command=self.loadline,
            initialitem=self.line.name,
            label_bg=L_color,
            hull_bg=L_color,
            menu_bg=L_color,
            menu_activebackground=L_color,
            menubutton_bg=L_color,
            menubutton_activebackground=L_color,
        )
        self.Line.pack()
        labels.append(self.Line)
        items = ["solid", "dash", "dot", "dash-dot", "long-dash"]
        self.type = Pmw.OptionMenu(
            self.tproperties,
            items=items,
            labelpos='w',
            label_text='Type:',
            label_bg=L_color,
            hull_bg=L_color,
            menu_bg=L_color,
            menu_activebackground=L_color,
            menubutton_bg=L_color,
            menubutton_activebackground=L_color,
            command=self.setline,
        )
        self.type.pack()
        labels.append(self.type)
        f = Tkinter.Frame(self.tproperties, bg=L_color)
        l = Tkinter.Label(
            f,
            text='Width:',
            bg=L_color,
        )
        l.pack(side='left')
        self.width = Tkinter.Scale(
            f,
            bigincrement=10,
            from_=1,
            to=300,
            orient='horizontal',
            tickinterval=50,
            length=200,
            bg=L_color,
            activebackground=L_color,
            highlightbackground=L_color,
            command=self.setline,
        )
        self.width.pack()
        labels.append(l)
        f.pack()

        f = Tkinter.Frame(self.tproperties, bg=L_color)

        l = Tkinter.Label(
            f,
            text='Color:',
            bg=L_color,
        )

        l.pack(side='left')

        self.Color = Tkinter.Scale(
            f,
            bigincrement=50,
            from_=0,
            to=255,
            orient='horizontal',
            tickinterval=50,
            length=200,
            bg=L_color,
            activebackground=L_color,
            highlightbackground=L_color,
            command=self.setline,
        )

        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)

        self.fbuttons = Tkinter.Frame(parent)
        self.fbuttons.pack()
        ##         b0=Tkinter.Button(self.fbuttons,
        ##                           text='Preview',
        ##                           command=self.setfont)
        ##         b0.pack(side='left')
        b1 = Tkinter.Button(self.fbuttons, text='Cancel', command=self.cancel)
        b1.pack(side='left')
        b2 = Tkinter.Button(self.fbuttons, text='Apply', command=self.exit)
        b2.pack(side='left')
        b3 = Tkinter.Button(self.fbuttons, text='Revert', command=self.reset)
        b3.pack(side='left')

        self.setgui()
        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi(geom[1])
            d2 = string.atoi(geom[2])
            self.dialog.activate(geometry="+%d+%d" % (d1, d2))
        else:
            self.dialog.activate(geometry='centerscreenalways')

        return
Пример #9
0
def test():
    import vcs_legacy, time, support, sys, os  # import vcs_legacy and cu
    bg = support.bg

    x = vcs_legacy.init()  # construct vcs_legacy canvas

    x.plot('default', 'continents', 'ASD', bg=bg)  # plot slab the old way
    support.check_plot(x)
    if bg == 0:
        x.geometry(450, 337, 100, 0)  # change the geometry and location
        x.flush()
        support.check_plot(x)

    obj = x.listelements('continents')  # show list of continents
    a = x.createcontinents('quick')  # get 'quick' continents
    if not vcs_legacy.isgraphicsmethod(
            a):  # test object 'a' for graphics method
        raise Exception, "Error not a gm"
    else:
        if not vcs_legacy.iscontinents(a):  # test object 'a' if continents
            raise Exception, "Error wrong type of gm"
    x.clear()
    x.plot(a, bg=bg)
    support.check_plot(x)

    a.script('test', 'w')  # save 'quick' continents as a Python script

    a.xticlabels('', '')  # remove the x-axis
    support.check_plot(x)
    a.xticlabels('lon30', 'lon30')  # change the x-axis
    support.check_plot(x)
    a.xticlabels('*')  # put the x-axis
    support.check_plot(x)
    a.datawc(-45.0, 45.0, -90.0, 90.0)  # change the region
    support.check_plot(x)
    a.datawc(1e20, 1e20, 1e20, 1e20)  # put the region back
    support.check_plot(x)

    if not '--extended' in sys.argv:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()

    a.line = 1  # same as 'dash', change the line style
    support.check_plot(x)
    a.line = 2  # same as 'dot', change the line style
    support.check_plot(x)
    a.line = 3  # same as 'dash-dot', change the line style
    support.check_plot(x)
    a.line = 0  # same as 'solid', change the line style
    support.check_plot(x)
    a.line = 4  # same as 'long-dash', change the line style
    support.check_plot(x)
    a.linecolor = (77)  # change the line color
    support.check_plot(x)
    a.linecolor = 16  # change the line color
    support.check_plot(x)
    a.linecolor = 44  # same as a.linecolor=(44)
    support.check_plot(x)
    a.linecolor = None  # use the default line color, black
    support.check_plot(x)
    a.line = None  # use default line style, solid black line
    support.check_plot(x)

    x.clear()  # clear the VCS Canvas
    x.continents(a, 'default',
                 bg=bg)  # plot continents using 'default' template
    support.check_plot(x)

    objs = x.listelements('template')  # get the list of templates
    t = x.createtemplate(
        'test')  # create template 'test' from 'default' template
    if not vcs_legacy.istemplate(t):  # test whether 't' is a template or not
        raise Exception, "Error template not created"
    else:
        a2 = x.listelements('template')  # get the list of templates
        if objs == a2:
            raise Exception, "Error template not created or added to list"

    x.clear()  # clear the VCS Canvas
    x.plot(t, a,
           bg=bg)  # plot continents using template 't', and continents 'a'
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.continents(a, t, bg=bg)  # plot continents
    support.check_plot(x)

    #########################################################################
    # Create line object 'l' from the default line                          #
    #########################################################################
    objs = x.listelements('line')  # show the list of line secondary objects
    l = x.getline('red')  # get line 'red'
    if not vcs_legacy.issecondaryobject(
            l):  # check to see if it is a secondary object
        raise Exception, "Error did not get line"
    else:
        if not vcs_legacy.isline(l):  # check to see if it is a line
            raise Exception, "Error object created is not line"

    #########################################################################
    # Use the create line object 'l' from above and modify the line object  #
    #########################################################################
    a.line = l  # use the line object
    support.check_plot(x)
    l.color = 44  # change the line color
    support.check_plot(x)
    l.type = 'dash'  # change the line type
    support.check_plot(x)

    a = x.listelements('continents')  # show list of xyvsy
    r = x.createcontinents('test2', 'quick')  # create xyvsy 'test2'
    a2 = x.listelements('continents')  # show list of xyvsy
    if a2 == a:
        raise "error gm not created or not added to list"


##    x.removeobject(r)                    # remove xyvsy 'test2'
##    a3 = x.listelements('continents')                      # show list of xyvsy
##    if a3!=a:
##       raise "error gm not removed"

    a = x.getcontinents('quick')  # get 'quick' boxfill graphics method
    x.clear()
    x.plot(a, bg=bg)
    support.check_plot(x)
    if support.dogui:
        x.graphicsmethodgui(
            'continents',
            'quick')  # display the continents graphics method GUI

    #################################################################################
    # to see how x.update and x.mode work, see testoutline.py                       #
    #################################################################################
    #x.update()
    #x.mode=1
    #x.mode=0

    print '*******************************************************************************************'
    print '******                                                                               ******'
    print '******   C O N T I N E N T S   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
    print '******                                                                               ******'
    print '*******************************************************************************************'
Пример #10
0
def test():
   import vcs_legacy,cdms2 as cdms,time,os,sys,support		# import vcs_legacy and cdms
   bg=support.bg

   f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','clt.nc'))
   s=f('clt')			        # get slab clt
   x=vcs_legacy.init()				# construct vcs_legacy canvas
   
   x.plot(s,'default','boxfill','quick',bg=bg)# plot slab the old way
   #support.check_plot(x)
   if bg==0:
      x.geometry(450,337)                  # change the geometry
      x.flush()
      #support.check_plot(x)
   
   a=x.getboxfill('quick') 		# get 'quick' boxfill graphics method
   if not vcs_legacy.isgraphicsmethod(a):            # test object 'a' for graphics method
      raise Exception, "Error did not retrieve the gm"
   else:
      if not vcs_legacy.isboxfill(a):		# check for boxfill
         raise Exception, "Error gm is not right type"

   # Change boxfill's legend
   a.legend={0:'Great',20:'Outstanding',40:'Wonderful',60:'Happy',80:'Exciting!',100:'Best'}
   support.check_plot(x)
   a.legend={0:'100',20:'80',40:'60',60:'40',80:'20',100:'0'}
   support.check_plot(x)
   a.legend={0:'Blue',20:'Green',40:'Yellow',60:'Red',80:'Burgundy',100:'Magenta'}
   support.check_plot(x)
   a.legend=(90)
   support.check_plot(x)
   a.legend=[10,90]
   support.check_plot(x)
   a.legend=(1.5,45.8,89.7)
   support.check_plot(x)
   a.legend=None
   support.check_plot(x)

   if not '--extended' in sys.argv:
     print '\n************* PARTIAL TEST *****************'
     print 'FOR COMPLETE TEST OF THIS MODULE USE '
     print '   -F (--full) or -E (--extended) option'
     print '************* PARTIAL TEST *****************\n'
     sys.exit()

   a.color_1=50				# change color_1 index attribute
   support.check_plot(x)
   
   a.xticlabels('lon30','lon30')	# change xlabels attribute
   support.check_plot(x)
   a.xticlabels('','')			# change remove xlables from plot
   support.check_plot(x)
   a.datawc(-45.0, 45.0, -90.0, 90.0) 	# change region
   support.check_plot(x)
   a.datawc(1e20,1e20,1e20,1e20)	# change region back
   support.check_plot(x)
   a.xticlabels('*')			# change attribute labels back
   support.check_plot(x)
   
   x.mode=0				# turn atomatic update off
   a.color_1=100			# change color_1 attribute
   a.color_2=200			# change color_2 index value
   a.xticlabels('lon30','lon30')	# change attribute
   a.yticlabels('','')			# change y-labels off attribute
   a.datawc(-45.0, 45.0, -90.0, 90.0) 	# change region
   support.check_plot(x)
   x.update()				# view changes now
   support.check_plot(x)
   
   # Test log10 boxfill plot
   x.clear()				# clear the VCS Canvas
   a.boxfill_type = 'log10'             # Change the Boxfill type to log10
   a.datawc(1e20,1e20,1e20,1e20) 	# change region
   a.level_1=1e20			# change level_1
   a.level_2=1e20			# change level_2
   a.color_1=16				# change color_1 attribute
   a.color_2=239			# change color_2 index value
   x.boxfill(s,a,bg=bg)		        # plot using default template
   support.check_plot(x)


   # Test custom boxfill plot
   x.clear()				# clear the VCS Canvas
   a.boxfill_type = 'custom'            # Change the Boxfill type to custom 
   a.levels=(0,20,35,40,75,100)         # Set the custom ranges
   a.fillareacolors=(16,25,38,55,100,166) # Set the color indices
   x.boxfill(s,a,bg=bg)		        # plot using default template
   support.check_plot(x)

   # Test legend with fillareacolors boxfill plot
   x.clear()				# clear the VCS Canvas
   a.boxfill_type = 'linear'            # Change the Boxfill type back to linear 
   a.fillareacolors=(254,)           # Set the color indices
   a.level_1=0				# change level_1
   a.level_2=0				# change level_2
   x.boxfill(s,a,bg=bg)		        # plot using default template
   support.check_plot(x)
   
   a.script('test','w')			# save 'quick' boxfill as a Python script
   
   x.mode=1				# turn atomatic update mode back on
   a.color_1=16				# change color_1 attribute
   support.check_plot(x)
   a.color_2=239			# change color_2 index value
   support.check_plot(x)
   a.level_1=20				# change level_1
   support.check_plot(x)
   a.level_2=80				# change level_2
   support.check_plot(x)
   a.datawc(1e20,1e20,1e20,1e20)	# change region back
   support.check_plot(x)
   a.yticlabels('*')                    # change y-labels attribute
   support.check_plot(x)
   
   x.scriptobject(a,'test', 'a')	# append 'quick' to the existing file 
   a.script('test.scr','w')		# save 'quick' as a VCS script file
   
   objs =x.listelements('template')                   # get the list of templates
   t=x.createtemplate('test')           # create template 'test' from 'default' template
   if not vcs_legacy.istemplate(t):                  # test whether 't' is a template or not
      raise Exception,"Error template not created"
   else:
      a2 =x.listelements('template')                   # get the list of templates
      if objs==a2:
         raise Exception,"Error template not created or added to list"
   
   x.clear()				# clear the VCS Canvas
   x.boxfill(s,a,'default',bg=bg)		# plot using default template
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.boxfill(a,'default',s,bg=bg)		# plot using default template, but, reverse the order
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.boxfill(s,a,t,bg=bg)			# plot using template 'test'
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.boxfill(a,s,t,bg=bg)			# plot using template 'test', but reverse the objects
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.boxfill(t,a,s,bg=bg)			# plot using template 'test', but reverse the objects
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   
   x.plot(t,a,s,bg=bg)			# plot using the new way
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.plot(a,t,s,bg=bg)			# plot using the new way
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.plot(s,t,a,bg=bg)			# plot using the new way
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.plot('default',a,s,bg=bg)		# plot using the new way
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.plot('default',s,bg=bg)			# plot using the new way
   support.check_plot(x)
   
   a = x.listelements('boxfill')                      # show list of xyvsy
   r=x.createboxfill('test2','quick')     # create xyvsy 'test2'
   a2 = x.listelements('boxfill')                      # show list of xyvsy
   if a2==a:
      raise "error gm not created or not added to list"
   x.removeobject(r)                    # remove xyvsy 'test2'
   a3 = x.listelements('boxfill')                      # show list of xyvsy
   if a3!=a:
      raise "error gm not removed"

   a=x.getboxfill('quick')              # get 'quick' boxfill graphics method
   x.clear()
   x.plot(s,a,bg=bg)
   support.check_plot(x)
   if support.dogui:
      x.graphicsmethodgui('boxfill','quick')	# display the boxfill graphics method GUI
      raw_input("Press enter when done with gui testing")
   print '*************************************************************************************'
   print '******                                                                         ******'
   print '******   B O X F I L L   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
   print '******                                                                         ******'
   print '*************************************************************************************'
Пример #11
0
    def __init__(self, canvas=None, gui_parent=None, dialog_parent=None, master=None, name='default',Parent=None):
        self.gui_parent=gui_parent
        if canvas is None:
            self.canvas=vcs_legacy.init()
        else:
            self.canvas=canvas

        self.line=self.canvas.getline(name)
        if self.line is None:
            if not name in self.canvas.listelements('line'):
                raise 'Error '+t_name+' is not a valid line name'
            else:
                raise 'Weird unkwnown error but no line object returned....'
        self.parent=Parent
        self.parent_Name=self.parent.parent_Name
        ## Saves original values
        self.orig=[]
        self.save_vals()
        
        L_color = gui_support.gui_color.L_color
        
        if self.gui_parent is None:
            self.gui_parent=Tkinter.Toplevel()
            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
            self.gui_parent.withdraw()
        title='Line Editor - table: '+self.line.name
        self.dialog = Pmw.Dialog(master,
                                 title=title,
                                 buttons=(),
                                )
        self.dialog.withdraw()
       
        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent=self.dialog.interior()
        parent.configure(bg=L_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                hull_relief = 'raised',
                hull_borderwidth = 2,
                balloon = gui_support.balloon
                )
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File', 'Open/Save VCS Line Objects', tearoff = 1)
        self.cmain_menu.addmenuitem('File', 'command', 'Open line object file',
                         label = 'Open LineObject File',
                         command = self.evt_open_file,
                        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
        self.cmain_menu.addmenuitem('File', 'command', 'Save Line',
                                    label = 'Save (i.e Apply changes)',
                                    command = self.setline,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Copy Line',
                                    label = 'Copy Line',
                                    command = self.evt_save_line_as,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Save to file',
                                    label = 'Save To File',
                                    command = self.evt_save_to_file,
                                    )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem('File', 'command',
                                    statusHelp='Close Line Editor',
                                    label = "Exit Line Editor",
                                    command = self.dialog.destroy,
                                    )
        
##         self.ftype=Tkinter.Frame(parent)
##         self.ftype.pack(side='top')
        self.tprop=Pmw.Group(parent,
                             tag_text='Line',
                             tag_bg=L_color,
                             tagindent=10,
                             hull_bg=L_color,
                             hull_highlightbackground=L_color,
                             hull_highlightcolor=L_color,
                            ring_bg=L_color,
                             )
        self.tprop.pack(expand='yes',fill='both')
        self.tproperties=self.tprop.interior()
        self.tproperties.configure(bg=L_color)
        lines=self.canvas.listelements('line')
        lines.sort()

        labels=[]
        self.Line=Pmw.OptionMenu(self.tproperties,
                                  items=lines,
                                  labelpos='w',
                                  label_text='Name:',
                                  command=self.loadline,
                                  initialitem=self.line.name,
                                  label_bg=L_color,
                                  hull_bg=L_color,
                                  menu_bg=L_color,
                                  menu_activebackground=L_color,
                                  menubutton_bg=L_color,
                                  menubutton_activebackground=L_color,
                                 )
        self.Line.pack()
        labels.append(self.Line)
        items=["solid", "dash", "dot", "dash-dot", "long-dash"]
        self.type=Pmw.OptionMenu(self.tproperties,
                                 items=items,
                                 labelpos='w',
                                 label_text='Type:',
                                 label_bg=L_color,
                                 hull_bg=L_color,
                                 menu_bg=L_color,
                                 menu_activebackground=L_color,
                                 menubutton_bg=L_color,
                                 menubutton_activebackground=L_color,
                                 command=self.setline,
                                 )
        self.type.pack()
        labels.append(self.type)
        f=Tkinter.Frame(self.tproperties,bg=L_color)
        l=Tkinter.Label(f,
                        text='Width:',
                        bg=L_color,
                        )
        l.pack(side='left')
        self.width=Tkinter.Scale(f,
                                 bigincrement=10,
                                 from_=1,
                                 to=300,
                                 orient='horizontal',
                                 tickinterval=50,
                                 length=200,
                                 bg=L_color,
                                 activebackground=L_color,
                                 highlightbackground=L_color,
                                 command=self.setline,
                                 )
        self.width.pack()
        labels.append(l)
        f.pack()

        f=Tkinter.Frame(self.tproperties,bg=L_color)
        
        l=Tkinter.Label(f,
                        text='Color:',
                        bg=L_color,
                        )
        
        l.pack(side='left')
        
        self.Color=Tkinter.Scale(f,
                                 bigincrement=50,
                                 from_=0,
                                 to=255,
                                 orient='horizontal',
                                 tickinterval=50,
                                 length=200,
                                 bg=L_color,
                                 activebackground=L_color,
                                 highlightbackground=L_color,
                                 command=self.setline,
                                 )
        
        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)
        
        self.fbuttons=Tkinter.Frame(parent)
        self.fbuttons.pack()
##         b0=Tkinter.Button(self.fbuttons,
##                           text='Preview',
##                           command=self.setfont)
##         b0.pack(side='left')
        b1=Tkinter.Button(self.fbuttons,
                          text='Cancel',
                          command=self.cancel)
        b1.pack(side='left')
        b2=Tkinter.Button(self.fbuttons,
                          text='Apply',
                          command=self.exit)
        b2.pack(side='left')
        b3=Tkinter.Button(self.fbuttons,
                          text='Revert',
                          command=self.reset)
        b3.pack(side='left')
        
        self.setgui()
        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi( geom[1] )
            d2 = string.atoi( geom[2] )
            self.dialog.activate( geometry="+%d+%d" % (d1, d2) )
        else:
            self.dialog.activate(geometry = 'centerscreenalways')

        return
Пример #12
0
    def __init__(self,
                 canvas=None,
                 gui_parent=None,
                 dialog_parent=None,
                 master=None,
                 t_name='default',
                 o_name='default',
                 Parent=None):
        self.gui_parent = gui_parent
        if canvas is None:
            ##             import Canvas
            ##             self.canvas = Canvas.Canvas()
            self.canvas = vcs_legacy.init()
        else:
            self.canvas = canvas

        self.text = self.canvas.gettext(t_name, o_name)
        if self.text is None:
            if not t_name in self.canvas.listelements('texttable'):
                raise 'Error ' + t_name + ' is not a valid texttable name'
            elif not o_name in self.canvas.listelements('textorientation'):
                raise 'Error ' + o_name + ' is not a valid textorientation name'
            else:
                raise 'Weird unkwnown error but no text object returned....'
        self.parent = Parent
        try:
            self.parent_Name = self.parent.parent_Name
        except:
            pass
        ## Saves original values
        self.orig = []
        self.save_vals()

        Tt_color = gui_support.gui_color.Tt_color
        To_color = gui_support.gui_color.To_color

        #################################################################################################
        # At the moment, this will never happen. When we need to pop this editor up on its own, then we
        # will revist this case.
        #        if self.gui_parent is None:
        #            self.gui_parent=Tkinter.Toplevel()
        #            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
        #            self.gui_parent.withdraw()
        #################################################################################################

        title = 'Text Editor - table: ' + self.text.Tt_name + ', orientation: ' + self.text.To_name
        self.dialog = Pmw.Dialog(
            master,
            title=title,
            buttons=(),
        )
        self.dialog.withdraw()

        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent = self.dialog.interior()
        parent.configure(bg=Tt_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                                      hull_relief='raised',
                                      hull_borderwidth=2,
                                      balloon=gui_support.balloon)
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File',
                                'Open/Save VCS Text Objects',
                                tearoff=1)
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Open textobject file',
            label='Open TextObject File',
            command=gui_control.Command(self.evt_open_file, master),
        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
        ##         self.cmain_menu.addmenuitem('File', 'command', 'Select Table',
        ##                                     label = 'Select Table',
        ##                                     command = self.evt_loadtable,
        ##                                     )
        ##         self.cmain_menu.addmenuitem('File', 'command', 'Select Orientation',
        ##                                     label = 'Select Orientation',
        ##                                     command = self.evt_loadorientation,
        ##                                     )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save TextObject',
            label='Save (i.e Apply changes)',
            command=self.setfont,
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Copy Table',
            label='Copy Table',
            command=gui_control.Command(self.evt_save_table_as, self.dialog),
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Copy Orientation',
            label='Copy Orientation',
            command=gui_control.Command(self.evt_save_orientation_as,
                                        self.dialog),
        )
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            'Save to file',
            label='Save To File',
            command=gui_control.Command(self.evt_save_to_file, master),
        )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem(
            'File',
            'command',
            statusHelp='Close TextObject Editor',
            label="Exit TextObject Editor",
            command=self.dialog.destroy,
        )

        ##         self.ftype=Tkinter.Frame(parent)
        ##         self.ftype.pack(side='top')
        self.tprop = Pmw.Group(
            parent,
            tag_text='Table',
            tag_bg=Tt_color,
            tagindent=10,
            hull_bg=Tt_color,
            hull_highlightbackground=Tt_color,
            hull_highlightcolor=Tt_color,
            ring_bg=Tt_color,
        )
        self.tprop.pack(expand='yes', fill='both')
        self.tproperties = self.tprop.interior()
        self.tproperties.configure(bg=Tt_color)
        tables = self.canvas.listelements('texttable')
        tables.sort()

        labels = []
        self.table = Pmw.OptionMenu(
            self.tproperties,
            items=tables,
            labelpos='w',
            label_text='Name:',
            command=self.loadtable,
            initialitem=self.text.Tt_name,
            label_bg=Tt_color,
            hull_bg=Tt_color,
            menu_bg=Tt_color,
            menu_activebackground=Tt_color,
            menubutton_bg=Tt_color,
            menubutton_activebackground=Tt_color,
        )
        self.table.pack()
        labels.append(self.table)

        fonts = self.canvas.listelements("font")
        self.font = Pmw.OptionMenu(
            self.tproperties,
            items=fonts,
            labelpos='w',
            label_text='Font:',
            label_bg=Tt_color,
            hull_bg=Tt_color,
            menu_bg=Tt_color,
            menu_activebackground=Tt_color,
            menubutton_bg=Tt_color,
            menubutton_activebackground=Tt_color,
            command=self.setfont,
        )
        self.font.pack()
        labels.append(self.font)

        f = Tkinter.Frame(self.tproperties, bg=Tt_color)
        l = Tkinter.Label(
            f,
            text='Spacing:',
            bg=Tt_color,
        )
        l.pack(side='left')
        self.spacing = Tkinter.Scale(
            f,
            bigincrement=10,
            from_=-50,
            to=50,
            orient='horizontal',
            tickinterval=25,
            length=200,
            bg=Tt_color,
            activebackground=Tt_color,
            highlightbackground=Tt_color,
            command=self.setfont,
        )
        self.spacing.pack()
        labels.append(l)
        f.pack()
        f = Tkinter.Frame(self.tproperties, bg=Tt_color)
        l = Tkinter.Label(
            f,
            text='Width:',
            bg=Tt_color,
        )
        l.pack(side='left')
        self.expansion = Tkinter.Scale(
            f,
            bigincrement=10,
            from_=50,
            to=150,
            orient='horizontal',
            tickinterval=25,
            length=200,
            bg=Tt_color,
            activebackground=Tt_color,
            highlightbackground=Tt_color,
            command=self.setfont,
        )
        self.expansion.pack()
        labels.append(l)
        f.pack()

        f = Tkinter.Frame(self.tproperties, bg=Tt_color)

        l = Tkinter.Label(
            f,
            text='Color:',
            bg=Tt_color,
        )

        l.pack(side='left')

        self.Color = Tkinter.Scale(
            f,
            bigincrement=50,
            from_=0,
            to=255,
            orient='horizontal',
            tickinterval=50,
            length=200,
            bg=Tt_color,
            activebackground=Tt_color,
            highlightbackground=Tt_color,
            command=self.setfont,
        )

        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)
        labels = []
        self.oprop = Pmw.Group(parent,
                               tag_text='Orientation',
                               tagindent=10,
                               tag_bg=To_color,
                               ring_bg=To_color,
                               hull_bg=To_color)
        self.oprop.pack(expand='yes', fill='both')
        self.oproperties = self.oprop.interior()
        self.oproperties.configure(bg=To_color)

        orientations = self.canvas.listelements('textorientation')
        orientations.sort()
        self.orientation = Pmw.OptionMenu(
            self.oproperties,
            items=orientations,
            labelpos='w',
            label_text='Name:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.loadorientation,
            initialitem=self.text.To_name,
        )
        self.orientation.pack()
        labels.append(self.orientation)

        self.height = Pmw.EntryField(
            self.oproperties,
            label_text='Size:',
            labelpos='w',
            label_justify='left',
            label_bg=To_color,
            hull_bg=To_color,
            validate={
                'min': 0,
                'validator': 'real'
            },
            command=self.setfont,
        )
        self.height.pack()
        labels.append(self.height)

        f = Tkinter.Frame(self.oproperties, bg=To_color)
        l = Tkinter.Label(
            f,
            text='Angle:',
            bg=To_color,
        )
        l.pack(side='left')
        labels.append(l)
        self.angle = Tkinter.Scale(
            f,
            bigincrement=30,
            from_=-180,
            to=180,
            orient='horizontal',
            tickinterval=90,
            length=200,
            bg=To_color,
            activebackground=To_color,
            highlightbackground=To_color,
            command=self.setfont,
        )
        self.angle.pack()
        f.pack()

        paths = ["right", "left", "up", "down"]
        self.path = Pmw.OptionMenu(
            self.oproperties,
            items=paths,
            labelpos='w',
            label_text='Path:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.setfont,
        )
        self.path.pack()
        labels.append(self.path)

        haligns = ["left", "center", "right"]
        self.halign = Pmw.OptionMenu(
            self.oproperties,
            items=haligns,
            labelpos='w',
            label_text='Halign:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.setfont,
        )
        self.halign.pack()
        labels.append(self.halign)

        valigns = ["top", "cap", "half", "base", "bottom"]
        self.valign = Pmw.OptionMenu(
            self.oproperties,
            items=valigns,
            labelpos='w',
            label_text='Valign:',
            label_bg=To_color,
            hull_bg=To_color,
            menu_bg=To_color,
            menu_activebackground=To_color,
            menubutton_bg=To_color,
            menubutton_activebackground=To_color,
            command=self.setfont,
        )
        self.valign.pack()
        labels.append(self.valign)

        Pmw.alignlabels(labels)

        self.fbuttons = Tkinter.Frame(parent)
        self.fbuttons.pack()
        ##         b0=Tkinter.Button(self.fbuttons,
        ##                           text='Preview',
        ##                           command=self.setfont)
        ##         b0.pack(side='left')
        b1 = Tkinter.Button(self.fbuttons, text='Cancel', command=self.cancel)
        b1.pack(side='left')
        b2 = Tkinter.Button(self.fbuttons, text='Apply', command=self.exit)
        b2.pack(side='left')
        b3 = Tkinter.Button(self.fbuttons, text='Revert', command=self.reset)
        b3.pack(side='left')

        self.setgui()

        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi(geom[1])
            d2 = string.atoi(geom[2])
            self.dialog.activate(geometry="+%d+%d" % (d1, d2))
        else:
            self.dialog.activate(geometry='centerscreenalways')

        return
Пример #13
0
def test():

   import vcs_legacy,support,sys
   bg=support.bg
   
   x=vcs_legacy.init()
   
   # For plotting of each test case, set the pause time to 1.
   x.pause_time=1
   
   ############################ First Test ###############################
   
   # Set the global viewport values only.
   #
   # Remember, must set global x.viewport (vp) and/or x.world coordinate (wc)
   # values before calling { [x.createline, x.createmarker, x.createfillarea,
   # x.createtext], [x.getline, x.getmarker, x.getfillarea, x.gettext],
   # [x.drawline, x.drawmarker, x.drawfillarea, x.drawtext] }.
   #
   # If the global viewport (vp) and world coordinate (wc) values are set 
   # and the, functions, listed above, do not specify them, then the global
   # settings will override the default settings.
   #
   # If the functions listed above have vp and wc set as an argument, then 
   # these vp and wc values will be used instead of the global vp and wc
   # values.
   #
   # Draw text on the screen.
   tex=x.createtext('nTtex','std','nToex','7left')
   tex.height = 25
   tex.x=[0.1, 0.1]
   tex.y=[0.97, 0.93]
   tex.string=['Example of drawing VCS low-level primitives.', 'Also, an example of using the viewport to clip graphics.']
   x.plot(tex,bg=bg)
   support.check_plot(x)
   #
   # At this point, let the world coordinate values remain at the default
   # settings [0, 1, 0, 1], but change the viewport.
   x.viewport=[0.3,0.7,0.3,0.7]
   support.check_plot(x)
   
   # Create the line, marker, fill area, and text objects
   ln=x.createline('new')
   mk=x.createmarker('new')
   fa=x.createfillarea('new')
   t=x.createtext('newTt','std','newTo','7left')
   
   # Draw a box around the entire VCS Canvas viewport. It will use the
   # global viewport set above and use the default world coordinate values:
   # Remember the default values for vp and wc are:
   #            viewport         = [0.0, 1.0, 0.0, 1.0]
   #            worldcoordinate  = [0.0, 1.0, 0.0, 1.0]
   ln.x=[0, 1, 1, 0, 0]		# x line positions
   ln.y=[0, 0, 1, 1, 0]		# y line positions
   ln.width=4  			# test width
   ln.color = 242 			# test color
   ln.type = 4			# test line type
   x.plot(ln,bg=bg)			# plot lines
   support.check_plot(x)
   
   # Draw text on the screen. Use global vp and default wc.
   t.x = [0.2, 0.7]		# x text positions
   t.y = [0.7, 0.7]		# y text positions
   t.string=['PCMDI', 'CDAT']	# text strings
   t.color=243			# text color
   t.height = 90			# text size
   x.plot(t,bg=bg)			# plot text
   support.check_plot(x)
   
   # Draw fill area on screen. Use global vp and default wc.
   fa.x=[[0.0,0.5,0.5,0.0],[0.5,1.0,0.75]]  # x fill area positions
   fa.y=[[0.0,0.0,0.5,0.5],[0.5,0.5,0.0]]   # x fill area positions
   
   # fa.color=[241,243] cannot do this! How important is this?
   
   fa.color=241				# fill area color
   fa.style='solid'			# fill area style
   fa.index=3				# fill area index
   x.plot(fa,bg=bg)				# plot fill area
   support.check_plot(x)
  
   
   # Draw marker on screen. Use global vp and default wc.
   mk.x=[[0.5,0.2],[0.3,0.7,1.0]]	# x marker positions
   mk.y=[[0.5,0.2],[0.3,0.7,0.5]]	# y marker positions
   mk.color=242			# marker color
   mk.size=50			# marker size
   mk.type='dot'			# marker type
   x.plot(mk,bg=bg)			# plot marker
   support.check_plot(x)
   
   ############################ First Test completed ######################

 
   if not '--extended' in sys.argv:
     print '\n************* PARTIAL TEST *****************'
     print 'FOR COMPLETE TEST OF THIS MODULE USE '
     print '   -F (--full) or -E (--extended) option'
     print '************* PARTIAL TEST *****************\n'
     sys.exit()

   
   ############################ Second Test ###############################
   # Reset the global viewport values.
   x.viewport=[0.2,0.8,0.2,0.8]
   support.check_plot(x)
   
   # Redraw a box around the drawing area, but use 'x.line' instead of 'x.plot'.
   ln = x.getline('new')
   x.line(ln,bg=bg)
   support.check_plot(x)
   
   # Redraw markers, but use 'x.marker', instead of 'x.plot'.
   mk = x.getmarker('new')
   x.marker(mk,bg=bg)
   support.check_plot(x)
   
   # Redraw fill area, but use 'x.fillarea', instead of 'x.plot'.
   fa = x.getfillarea('new')
   x.fillarea(fa,bg=bg)
   support.check_plot(x)
   
   # Redraw text, but use 'x.text', instead of 'x.plot'.
   t= x.gettext('newTt', 'newTo')
   x.text(t,bg=bg)
   support.check_plot(x)

   ############################ Second Test completed ######################
   
   ############################ Third Test ###############################
   # Change the drawing area's world coordinate from [0,1,0,1] to [0,2,0,2]
   # via primitive's graphics method, then redraw. The graphics will be drawn
   # in the lower left corner. This is because the line x and y values are 
   # between (0 and 1) and the wc values are now between (0 and 2).
   
   ln.worldcoordinate=[0,2, 0,2]	# set wc
   support.check_plot(x)
   x.plot(ln,bg=bg)
   support.check_plot(x)
   
   # Note how the most right marker is not clipped
   mk.worldcoordinate=[0,2, 0,2]	# set wc
   support.check_plot(x)
   x.plot(mk,bg=bg)
   
   fa.worldcoordinate=[0,2, 0,2]
   support.check_plot(x)
   fa.color = 240			# change color to white
   support.check_plot(x)
   x.plot(fa,bg=bg)
   support.check_plot(x)
   
   t.worldcoordinate=[0,2, 0,2]	# set wc
   x.plot(t,bg=bg)
   support.check_plot(x)

   ############################ Third Test completed ######################
   
   
   ############################ Fourth Test ###############################
   #
   # Clear the VCS Canvas and redraw graphics using Python list of lists.
   #
   # Remember, the viewport and world coordinates for the graphics primitives
   # are:
   #       viewport         = [0.2, 0.8, 0.2, 0.8]
   #       worldcoordinate  = [0, 2, 0, 2]
   x.clear()
   
   # Draw multiple line segments
   ln.x=[[0.0,2.0,2.0,0.0,0.0], [0.5,1.5]]	# x line positions
   ln.y=[[0.0,0.0,2.0,2.0,0.0], [1.0,1.0]] # y line positions
   ln.type='solid'
   x.plot(ln,bg=bg)
   support.check_plot(x)
   
   # Draw multiple marker segments
   mk.x=[[0.8,1.3],[0.5,1.0,1.5]]  # x marker positions
   mk.y=[[1.5,1.5],[0.5,0.5,0.5]]  # y marker positions
   x.plot(mk,bg=bg)
   support.check_plot(x)
   
   # Draw multiple fill area segments
   fa.x=[[0.2,0.5,0.5,0.2],[1.2,1.8,1.8,1.2]]  # x fill area positions
   fa.y=[[0.2,0.2,0.5,0.5],[1.2,1.2,1.8,1.8]]   # x fill area positions
   fa.color=241
   x.plot(fa,bg=bg)
   support.check_plot(x)
   
   # Draw multiple text segments
   t.x = [0.5, 1.17]                # x text positions
   t.y = [0.8, 0.8]                # y text positions
   t.string=['Text 1', 'Text 2']   # text strings
   t.color=244                     # text color
   t.height = 90                   # text size
   x.plot(t,bg=bg)                       # plot text
   support.check_plot(x)

   
   
   ############################ Fourth Test completed ######################
   
   ############################ Fifth Test ###############################
   # Change the viewport only to a different shape and replot.
   # 1st change
   ln.viewport=[0.0,0.2,0.0,0.8]
   support.check_plot(x)
   x.plot(ln,bg=bg)
   support.check_plot(x)

   mk.viewport=[0.0,0.2,0.0,0.8]
   support.check_plot(x)
   x.plot(mk,bg=bg)
   support.check_plot(x)
   fa.viewport=[0.0,0.2,0.0,0.8]
   support.check_plot(x)
   x.plot(fa,bg=bg)
   support.check_plot(x)
   t.viewport=[0.0,0.2,0.0,0.8]
   support.check_plot(x)
   x.plot(t,bg=bg)
   support.check_plot(x)
   
   # 2nd change
   ln.viewport=[0.0,0.8,0.0,0.2]
   support.check_plot(x)
   x.plot(ln,bg=bg)
   support.check_plot(x)
   mk.viewport=[0.0,0.8,0.0,0.2]
   support.check_plot(x)
   x.plot(mk,bg=bg)
   support.check_plot(x)
   fa.viewport=[0.0,0.8,0.0,0.2]
   support.check_plot(x)
   x.plot(fa,bg=bg)
   support.check_plot(x)
   t.viewport=[0.0,0.8,0.0,0.2]
   support.check_plot(x)
   x.plot(t,bg=bg)
   support.check_plot(x)
   
   ############################ Fifth Test completed ######################
   
   ############################ Sixth Test ###############################
   # Clear the VCS Canvas and redraw the graphics, but this time use the
   # draw functions. That is, user drawline, drawmarker, drawfillarea, and
   # drawtext.
   x.clear()
   ln=x.drawline('new',
                 ltype= 1,
                 width= 10,
                 color=244,
                 worldcoordinate=[0.0,2.0,0.0,2.0],
                 x=[[0.0,2.0,2.0,0.0,0.0], [0.5,1.5]],
                 y=[[0.0,0.0,2.0,2.0,0.0], [1.0,1.0]],
                 bg=bg
                )
   support.check_plot(x)

   mk=x.drawmarker('new',
                   mtype= 'square_fill',
                   size= 40,
                   color=243,
                   viewport=[0.0,1.0,0.0,1.0],
                   worldcoordinate=[0.0,2.0,0.0,2.0],
                   x=[[0.0,1.0], [1.0]],
                   y=[[0.0,1.0], [2.0]],
                   bg=bg
                  )
   support.check_plot(x)

   fa=x.drawfillarea('new',
                   style='hatch',
                   index=2,
                   color=246,
                   viewport=[0.0,1.0,0.0,1.0],
                   worldcoordinate=[0.0,2.0,0.0,2.0],
		   x=[[0.5,1.0,1.0,0.5],[0.5,1.0,0.75]],
		   y=[[0.0,0.0,0.5,0.5],[1.0,1.0,0.5]],
                     bg=bg
                  )
   support.check_plot(x)

   t=x.drawtext(Tt_name='newTt',To_name='newTo',
                   font = 4,
                   color = 242,
                   height = 70,
                   angle=45,
                   string=[ 'Quad 1', 'Quad 2', 'Quad 3', 'Quad 4' ],
                   viewport=[0.0,1.0,0.0,1.0],
                   worldcoordinate=[0.0,2.0,0.0,2.0],
                   x=[[1.5,1.5], [0.5,0.5]],
                   y=[[0.5,1.5], [1.5, 0.5]],
                bg=bg
                  )
   support.check_plot(x)

   
   ############################ Sixth Test completed ######################
   
   ############################ Seventh Test ###############################
   # Clear the VCS Canvas and test the priority of each primitive.
   #
   x.clear()
   # Set the global viewport and worldcoordinate values.
   x.viewport=[0.3,0.7,0.3,0.7]
   x.worldcoordinate=[0,1,0,1]
   
   ln2=x.createline('new2')
   ln3=x.createline('new3')
   mk2=x.createmarker('new2')
   mk3=x.createmarker('new3')
   fa2=x.createfillarea('new2')
   fa3=x.createfillarea('new3')
   t2=x.createtext('new12','std','new22','7left')
   
   # Draw a box around the VCS Canvas drawing area.
   ln.x=[0, 1, 1, 0, 0]
   ln.y=[0, 0, 1, 1, 0]
   ln.viewport=[0.3,0.7,0.3,0.7]
   ln.worldcoordinate=[0,1,0,1]
   ln.width=4
   ln.color = 241
   ln.type = 0
   ln.priority=10		# Set the priority high so it will always be seen
   x.plot(ln,bg=bg)
   support.check_plot(x)
   
   ln2.x=[0,0.5]
   ln2.y=[0.5,0.5]
   ln2.priority=2		# Set the priority higher than the next line
   ln2.width=10
   ln2.color=243
   x.plot(ln2,bg=bg)
   support.check_plot(x)
   
   ln3.x=[0,1]
   ln3.y=[0.5,0.5]
   ln3.priority=1
   ln3.width=10
   ln3.color=244
   x.plot(ln3,bg=bg)
   support.check_plot(x)
   
   mk2.x=[0.5]
   mk2.y=[0.7]
   mk2.color=242
   mk2.size=50
   mk2.priority=2
   x.plot(mk2,bg=bg)
   support.check_plot(x)
   
   mk3.x=[0.55]
   mk3.y=[0.7]
   mk3.color=246
   mk3.size=40
   mk3.type='square_fill'
   mk3.priority=1
   x.plot(mk3,bg=bg)
   support.check_plot(x)
   
   fa2.x=[0.3,0.7,0.7,0.3]
   fa2.y=[0.0,0.0,0.4,0.4]
   fa2.color=247
   fa2.style='solid'
   fa2.index=3
   fa2.priority = 2
   x.plot(fa2,bg=bg)
   support.check_plot(x)
   
   fa3.x=[0.5,0.9,0.7]
   fa3.y=[0.4,0.4,0.0]
   fa3.style='solid'
   fa3.color=248
   fa3.index=15
   fa3.priority = 1
   x.plot(fa3,bg=bg)
   support.check_plot(x)
   
   t2.x = [0.2, 0.6]
   t2.y = [0.4, 0.4]
   t2.string=['PCMDI', 'CDAT']
   t2.color=241
   t2.font=2
   t2.height = 120
   t2.priority = 1
   x.plot(t2,bg=bg)
   support.check_plot(x)
   
   ############################ Seventh Test completed ######################
   
   ############################ Eighth Test ###############################
   # Clear the VCS Canvas and test the Python list for the primitive attributes.
   #
   x.clear()
   ln.x=[[0,1], [1,1], [1,0],[0,0]]
   ln.y=[[0,0], [0,1], [1,1],[1,0]]
   ln.width=[1,10,20,30]
   ln.color = [242, 243, 244, 245]
   ln.type = [1,2,3,0]
   ln.viewport=[0.2,0.8,0.2,0.8]
   ln.worldcoordinate=[0.0, 1.0, 0.0, 1.0]
   x.plot(ln,bg=bg)
   support.check_plot(x)
   
   mk.x=[[0.5,0.2],[0.3,0.7],[1.0]]
   mk.y=[[0.5,0.2],[0.3,0.7],[0.5]]
   mk.color=[242,243,244]
   mk.size=[30,50,70]
   mk.type=['dot', 'star', 'square_fill']
   mk.viewport=[0.2,0.8,0.2,0.8]
   mk.worldcoordinate=[0.0, 1.0, 0.0, 1.0]
   x.plot(mk,bg=bg)
   support.check_plot(x)
   
   fa.x=[[0.0,0.5,0.5,0.0],[0.5,1.0,0.75], [0.3,0.7,0.5]]
   fa.y=[[0.0,0.0,0.5,0.5],[0.5,0.5,0.0], [0.52,0.52,0.95]]
   fa.color=[241,242,243]
   fa.style=['hatch','solid']
   fa.index=[ 1, 2, 3]
   fa.viewport=[0.2,0.8,0.2,0.8]
   fa.worldcoordinate=[0.0, 1.0, 0.0, 1.0]
   x.plot(fa,bg=bg)
   support.check_plot(x)
   
   ############################ Eighth Test completed ######################
   
   print '*****************************************************************************************'
   print '******                                                                             ******'
   print '******   L O W - L E V E L   P R I M I T I V E S ( I . E . ,  L I N E S ,          ******'
   print '******           M A R K E R S ,   F I L L A R E A S ,   A N D   T E X T )         ******'
   print '******                                                                             ******'
   print '******               C O M P L E T E D   S U C E S S F U L L Y   ! ! !             ******'
   print '******                                                                             ******'
   print '*****************************************************************************************'
Пример #14
0
def test():
   import vcs_legacy,cdms2 as cdms,time,os,sys,support 		# import vcs_legacy and cdms
   bg=support.bg

   f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','clt.nc')) # open clt file
   s=f('clt')                   	# get slab clt
   x=vcs_legacy.init()                         # construct vcs_legacy canvas

   tt=x.createtext()
   

   a = x.listelements('template')                   # show the list of templates
   t=x.createtemplate('test','ASD')    # create template 'test' from ASD

   t.ylabel1.texttable=tt
   t.ylabel1.textorientation=tt
   
   a2 = x.listelements('template')                   # show the list of templates
   if a2==a:
      raise Excpetion,"Error, template not added to list"
   if not vcs_legacy.istemplate(t):
      raise Exception,"Error obj created is not a template!"
   
   t.script('test','w')			# save test template as a Python script

   g=x.createisofill('test')           	# create isofill 'test' from 'default' isofill

   x.plot(g,s,t,bg=bg)			# make isofill plot
   support.check_plot(x)
   
   #############################################################################
   # Show the many different ways to show the template members (attributes)    #
   # and their values.                                                         #
   #############################################################################
##    t.list()				# list the templates members
##    t.list('text')			# list only text members, same as t.list('Pt')
##    t.list('format')			# list only format members, same as t.list('Pf')
##    t.list('xtickmarks')			# list only xtickmarks members, same as t.list('Pxt')
##    t.list('ytickmarks')			# list only ytickmarks members, same as t.list('Pyt')
##    t.list('xlabels')			# list only xlabels members, same as t.list('Pxl')
##    t.list('ylabels')			# list only ylabels members, same as t.list('Pyl')
##    t.list('boxeslines')			# list only boxeslines members, same as t.list('Pbl')
##    t.list('legend')			# list only legend member, same as t.list('Pls')
##    t.list('data')			# list only data member, same as t.list('Pds')
##    t.list('file')			# list only file member and its values
##    t.file.list()			# list only file member and its values
##    t.list('mean')			# list only mean member and its values
##    t.mean.list()			# list only mean member and its values

   #############################################################################
   # The screen x and y positions on the screen are normalized between 0 and 1 #
   # for both the x and y axis.                                                #
   #############################################################################
   t.mean.priority = 0			# remove the "Mean" text from the plot
   support.check_plot(x)
   t.mean.priority = 1			# re-display the "Mean" text on the plot
   support.check_plot(x)
   t.mean.x=0.5				# move the "Mean" text to x-axis center
   support.check_plot(x)
   t.mean.y=0.5				# move the "Mean" text to y-axis center
   support.check_plot(x)
   


   if not '--extended' in sys.argv:
     print '\n************* PARTIAL TEST *****************'
     print 'FOR COMPLETE TEST OF THIS MODULE USE '
     print '   -F (--full) or -E (--extended) option'
     print '************* PARTIAL TEST *****************\n'
     sys.exit()


 
   #############################################################################
   # Position the data in front of the "Mean" text, then move the "Mean" text  #
   # in front of the data.                                                     #
   #############################################################################
   t.data.priority = 2
   support.check_plot(x)
   t.data.priority=3
   support.check_plot(x)
#  The above does not work. I will fix this later when time permits.
# seems to work now 2007-07-16
   t.data.priority=1 # back to normal
   support.check_plot(x)

   #############################################################################
   # Change the font representation for the "Mean" text.                       #
   # You can set the text by using text objects or text names.                 #
   #############################################################################
   tt = x.createtexttable('test')
   to = x.createtextorientation('test')
   t.mean.texttable = tt		# set texttable by using texttable object
   support.check_plot(x)
   t.mean.textorientation = 'test'	# set textorientation by using textorientation name
   support.check_plot(x)
   t.mean.list()                        # show the mean member and their new values
   tt.font=2				# change the font 
   support.check_plot(x)
   to.height=40				# change the height
   support.check_plot(x)

   #############################################################################
   # Change the legend space.                                                  #
   #############################################################################
   t.legend.list()		       	# list the legend members
   x.mode=0				# turn the automatic update off
   t.legend.x1=0.85
   support.check_plot(x)
   t.legend.y1=0.90
   support.check_plot(x)
   t.legend.x2=0.95
   support.check_plot(x)
   t.legend.y2=0.16
   support.check_plot(x)
   x.update()
   support.check_plot(x)
#  The above does not work. I will fix this later when time permits.

   print '***************************************************************************************'
   print '******                                                                           ******'
   print '******   T E M P L A T E   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
   print '******                                                                           ******'
   print '***************************************************************************************'
Пример #15
0
    def __init__(self, canvas=None, gui_parent=None, dialog_parent=None, master=None, t_name='default',o_name='default',Parent=None):
        self.gui_parent=gui_parent
        if canvas is None:
##             import Canvas
##             self.canvas = Canvas.Canvas()
            self.canvas=vcs_legacy.init()
        else:
            self.canvas=canvas

        self.text=self.canvas.gettext(t_name,o_name)
        if self.text is None:
            if not t_name in self.canvas.listelements('texttable'):
                raise 'Error '+t_name+' is not a valid texttable name'
            elif not o_name in self.canvas.listelements('textorientation'):
                raise 'Error '+o_name+' is not a valid textorientation name'
            else:
                raise 'Weird unkwnown error but no text object returned....'
        self.parent=Parent
        try:
            self.parent_Name=self.parent.parent_Name
        except:
            pass
        ## Saves original values
        self.orig=[]
        self.save_vals()
        
        Tt_color = gui_support.gui_color.Tt_color
        To_color = gui_support.gui_color.To_color
        
#################################################################################################
# At the moment, this will never happen. When we need to pop this editor up on its own, then we
# will revist this case.
#        if self.gui_parent is None:
#            self.gui_parent=Tkinter.Toplevel()
#            #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
#            self.gui_parent.withdraw()
#################################################################################################

        title='Text Editor - table: '+self.text.Tt_name+', orientation: '+self.text.To_name
        self.dialog = Pmw.Dialog(master,
                                 title=title,
                                 buttons=(),
                                )
        self.dialog.withdraw()
       
        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent=self.dialog.interior()
        parent.configure(bg=Tt_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                hull_relief = 'raised',
                hull_borderwidth = 2,
                balloon = gui_support.balloon
                )
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File', 'Open/Save VCS Text Objects', tearoff = 1)
        self.cmain_menu.addmenuitem('File', 'command', 'Open textobject file',
                         label = 'Open TextObject File',
                         command = gui_control.Command( self.evt_open_file, master ),
                        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
##         self.cmain_menu.addmenuitem('File', 'command', 'Select Table',
##                                     label = 'Select Table',
##                                     command = self.evt_loadtable,
##                                     )
##         self.cmain_menu.addmenuitem('File', 'command', 'Select Orientation',
##                                     label = 'Select Orientation',
##                                     command = self.evt_loadorientation,
##                                     )
        self.cmain_menu.addmenuitem('File', 'command', 'Save TextObject',
                                    label = 'Save (i.e Apply changes)',
                                    command = self.setfont,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Copy Table',
                                    label = 'Copy Table',
                                    command = gui_control.Command( self.evt_save_table_as, self.dialog ),
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Copy Orientation',
                                    label = 'Copy Orientation',
                                    command = gui_control.Command( self.evt_save_orientation_as, self.dialog ),
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Save to file',
                                    label = 'Save To File',
                                    command = gui_control.Command( self.evt_save_to_file, master ),
                                    )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem('File', 'command',
                                    statusHelp='Close TextObject Editor',
                                    label = "Exit TextObject Editor",
                                    command = self.dialog.destroy,
                                    )
        
##         self.ftype=Tkinter.Frame(parent)
##         self.ftype.pack(side='top')
        self.tprop=Pmw.Group(parent,
                             tag_text='Table',
                             tag_bg=Tt_color,
                             tagindent=10,
                             hull_bg=Tt_color,
                             hull_highlightbackground=Tt_color,
                             hull_highlightcolor=Tt_color,
                            ring_bg=Tt_color,
                             )
        self.tprop.pack(expand='yes',fill='both')
        self.tproperties=self.tprop.interior()
        self.tproperties.configure(bg=Tt_color)
        tables=self.canvas.listelements('texttable')
        tables.sort()

        labels=[]
        self.table=Pmw.OptionMenu(self.tproperties,
                                  items=tables,
                                  labelpos='w',
                                  label_text='Name:',
                                  command=self.loadtable,
                                  initialitem=self.text.Tt_name,
                                  label_bg=Tt_color,
                                  hull_bg=Tt_color,
                                  menu_bg=Tt_color,
                                  menu_activebackground=Tt_color,
                                  menubutton_bg=Tt_color,
                                  menubutton_activebackground=Tt_color,
                                 )
        self.table.pack()
        labels.append(self.table)
        
        fonts=self.canvas.listelements("font")
        self.font=Pmw.OptionMenu(self.tproperties,
                                 items=fonts,
                                 labelpos='w',
                                 label_text='Font:',
                                 label_bg=Tt_color,
                                 hull_bg=Tt_color,
                                 menu_bg=Tt_color,
                                 menu_activebackground=Tt_color,
                                 menubutton_bg=Tt_color,
                                 menubutton_activebackground=Tt_color,
                                 command=self.setfont,
                                 )
        self.font.pack()
        labels.append(self.font)

        f=Tkinter.Frame(self.tproperties,bg=Tt_color)
        l=Tkinter.Label(f,
                        text='Spacing:',
                        bg=Tt_color,
                        )
        l.pack(side='left')
        self.spacing=Tkinter.Scale(f,
                                   bigincrement=10,
                                   from_=-50,
                                   to=50,
                                   orient='horizontal',
                                   tickinterval=25,
                                   length=200,
                                   bg=Tt_color,
                                   activebackground=Tt_color,
                                   highlightbackground=Tt_color,
                                   command=self.setfont,
                                  )
        self.spacing.pack()
        labels.append(l)
        f.pack()
        f=Tkinter.Frame(self.tproperties,bg=Tt_color)
        l=Tkinter.Label(f,
                        text='Width:',
                        bg=Tt_color,
                        )
        l.pack(side='left')
        self.expansion=Tkinter.Scale(f,
                                     bigincrement=10,
                                     from_=50,
                                     to=150,
                                     orient='horizontal',
                                     tickinterval=25,
                                     length=200,
                                     bg=Tt_color,
                                     activebackground=Tt_color,
                                     highlightbackground=Tt_color,
                                     command=self.setfont,
                                     )
        self.expansion.pack()
        labels.append(l)
        f.pack()

        f=Tkinter.Frame(self.tproperties,bg=Tt_color)
        
        l=Tkinter.Label(f,
                        text='Color:',
                        bg=Tt_color,
                        )
        
        l.pack(side='left')
        
        self.Color=Tkinter.Scale(f,
                                 bigincrement=50,
                                 from_=0,
                                 to=255,
                                 orient='horizontal',
                                 tickinterval=50,
                                 length=200,
                                 bg=Tt_color,
                                 activebackground=Tt_color,
                                 highlightbackground=Tt_color,
                                 command=self.setfont,
                                 )
        
        self.Color.pack()
        labels.append(l)
        f.pack()

        Pmw.alignlabels(labels)
        labels=[]
        self.oprop=Pmw.Group(parent,tag_text='Orientation',tagindent=10,tag_bg=To_color,ring_bg=To_color,hull_bg=To_color)
        self.oprop.pack(expand='yes',fill='both')
        self.oproperties=self.oprop.interior()
        self.oproperties.configure(bg=To_color)
        
        orientations=self.canvas.listelements('textorientation')
        orientations.sort()
        self.orientation=Pmw.OptionMenu(self.oproperties,
                                        items=orientations,
                                        labelpos='w',
                                        label_text='Name:',
                                        label_bg=To_color,
                                        hull_bg=To_color,
                                        menu_bg=To_color,
                                        menu_activebackground=To_color,
                                        menubutton_bg=To_color,
                                        menubutton_activebackground=To_color,
                                        command=self.loadorientation,
                                        initialitem=self.text.To_name,
                                 )
        self.orientation.pack()
        labels.append(self.orientation)
        
        self.height=Pmw.EntryField(self.oproperties,
                                   label_text='Size:',
                                   labelpos='w',
                                   label_justify='left',
                                   label_bg=To_color,
                                   hull_bg=To_color,
                                   validate={'min':0,'validator':'real'},
                                   command=self.setfont,
                                   )
        self.height.pack()
        labels.append(self.height)
        
        f=Tkinter.Frame(self.oproperties,bg=To_color)
        l=Tkinter.Label(f,
                        text='Angle:',
                        bg=To_color,
                        )
        l.pack(side='left')
        labels.append(l)
        self.angle=Tkinter.Scale(f,
                                 bigincrement=30,
                                 from_=-180,
                                 to=180,
                                 orient='horizontal',
                                 tickinterval=90,
                                 length=200,
                                 bg=To_color,
                                 activebackground=To_color,
                                 highlightbackground=To_color,
                                 command=self.setfont,
                                 )
        self.angle.pack()
        f.pack()

        paths=["right","left","up","down"]
        self.path=Pmw.OptionMenu(self.oproperties,
                                 items=paths,
                                 labelpos='w',
                                 label_text='Path:',
                                 label_bg=To_color,
                                 hull_bg=To_color,
                                 menu_bg=To_color,
                                 menu_activebackground=To_color,
                                 menubutton_bg=To_color,
                                 menubutton_activebackground=To_color,
                                 command=self.setfont,
                                 )
        self.path.pack()
        labels.append(self.path)
        
        haligns=["left","center","right"]
        self.halign=Pmw.OptionMenu(self.oproperties,
                                   items=haligns,
                                   labelpos='w',
                                   label_text='Halign:',
                                   label_bg=To_color,
                                   hull_bg=To_color,
                                   menu_bg=To_color,
                                   menu_activebackground=To_color,
                                   menubutton_bg=To_color,
                                   menubutton_activebackground=To_color,
                                   command=self.setfont,
                                   )
        self.halign.pack()
        labels.append(self.halign)
        
        valigns=["top","cap","half","base","bottom"]
        self.valign=Pmw.OptionMenu(self.oproperties,
                                   items=valigns,
                                   labelpos='w',
                                   label_text='Valign:',
                                   label_bg=To_color,
                                   hull_bg=To_color,
                                   menu_bg=To_color,
                                   menu_activebackground=To_color,
                                   menubutton_bg=To_color,
                                   menubutton_activebackground=To_color,
                                   command=self.setfont,
                                   )
        self.valign.pack()
        labels.append(self.valign)

        Pmw.alignlabels(labels)
        
        self.fbuttons=Tkinter.Frame(parent)
        self.fbuttons.pack()
##         b0=Tkinter.Button(self.fbuttons,
##                           text='Preview',
##                           command=self.setfont)
##         b0.pack(side='left')
        b1=Tkinter.Button(self.fbuttons,
                          text='Cancel',
                          command=self.cancel)
        b1.pack(side='left')
        b2=Tkinter.Button(self.fbuttons,
                          text='Apply',
                          command=self.exit)
        b2.pack(side='left')
        b3=Tkinter.Button(self.fbuttons,
                          text='Revert',
                          command=self.reset)
        b3.pack(side='left')
        
        self.setgui()

        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi( geom[1] )
            d2 = string.atoi( geom[2] )
            self.dialog.activate( geometry="+%d+%d" % (d1, d2) )
        else:
            self.dialog.activate(geometry = 'centerscreenalways')

        return
Пример #16
0
def test():
   import vcs_legacy,cdms2 as cdms,time,os,sys,support                      # import vcs_legacy and cdms

   bg = support.bg

   f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','clt.nc'))
   s=f('clt')                           # get slab clt
   x=vcs_legacy.init()                         # construct vcs_legacy canvas
   
   x.plot(s,'default','isofill','quick',bg=bg)# plot slab the old way
   support.check_plot(x)

   # Check the legend
   g=x.createisofill('vcs_legacymoduletest')
   x.clear()				# clear the VCS Canvas
   x.plot(s,g,bg=bg)				# plot slab the new way
   support.check_plot(x)
   g.legend = (10, 30, 70, 120)
   support.check_plot(x)
   g.legend={0:'test string1', 50:'test string2', 100:'test string3'}
   support.check_plot(x)
   g.legend = None
   support.check_plot(x)

   if bg==0:
      x.geometry(450,337,100,0)		# change the geometry and location
      x.flush()
      support.check_plot(x)
   
   # open and plot a missing data with isofill
   f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','tas_cru_1979.nc'))
   s=f('tas',longitude=(-180, 180),latitude=(-90,90))+273.15
   x.clear()				# clear the VCS Canvas
   x.plot(s,'default','isofill','quick',bg=bg)# plot missing value slabe the old way
   support.check_plot(x)
   
   a=x.getisofill('quick') 		# get 'quick' isofill graphics method
   if not vcs_legacy.isgraphicsmethod(a):            # test object 'a' for graphics method
      raise Exception, "Error did not retrieve the gm"
   else:
      if not vcs_legacy.isisofill(a):		# check for isofill
         raise Exception, "Error gm is not right type"
   
   a.script('test','w')			# save 'quick' isofill as a Python script
   
   x.setcolormap("AMIP")		# change the colormap from default to AMIP
   
   a.missing=241			# change the missing background color to black
   support.check_plot(x)
   


   if not '--extended' in sys.argv:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()


   
   a.xticlabels('lon30','lon30')	# change the x-axis
   support.check_plot(x)
   a.xticlabels('','')			# remove the x-axis
   support.check_plot(x)
   a.xticlabels('*')			# put the x-axis
   support.check_plot(x)
   a.datawc(-45.0, 45.0, -90.0, 90.0)	# change the region
   support.check_plot(x)
   a.datawc(1e20,1e20,1e20,1e20)	# put the region back
   support.check_plot(x)
   
   a.levels=([0,220],[230,240],[250,260])	# change the isofill levels
   support.check_plot(x)
   a.levels=([0,220,225,230,235,240],[230,240],[250,260])	# change the isofill levels
   support.check_plot(x)
   a.levels=([0,220,225,230,235,240],)	# change the isofill levels
   support.check_plot(x)
   a.levels=([0,220,225,230,235,240,245,250])	# change the isofill levels
   support.check_plot(x)
   a.levels=[0,220,225,230,235,240] 	# change the isofill levels
   support.check_plot(x)
   a.levels=(0.0,220.0,225.0,230.0,235.0,240.0,250.0)		# change the isofill levels
   support.check_plot(x)
   a.levels=([1e20],)			# change back to default settings
   support.check_plot(x)
   a.levels=(0,220,225,230,235,240,250,260,270)	# change the isofill levels
   support.check_plot(x)


   #########################################################################################
   # Below will produce an error. Later, if needed, I will add this functionality.	   #
   #a.levels=('0','20','25','30')			# this will produce an error	   #
   #########################################################################################
   
   a.ext_1='y'				# add the extended legend arrow to the left
   support.check_plot(x)
   a.ext_1='n'				# remove the extended legend arrow to the left
   support.check_plot(x)
   a.ext_2='y'				# add the extended legend arrow to the right
   support.check_plot(x)
   a.ext_2='n'				# remove the extended legend arrow to the right
   support.check_plot(x)
   a.exts('y','y')			# add the extended legend arrow to left and right
   support.check_plot(x)
   a.exts('n','n')			# remove the extended legend arrow to left and right
   support.check_plot(x)
   
   a.fillareastyle='pattern'		# change the fill style to pattern
   support.check_plot(x)
   a.fillareastyle='hatch'		# change the fill style to hatch
   support.check_plot(x)
   a.fillareaindices=([1,3,5,6,9,18])	# set the hatch index patterns
   support.check_plot(x)
   
   a.fillareacolors=([22,33,44,55,66,77]) 	# set the fill area color indices
   support.check_plot(x)
   a.fillareacolors=None			# use default color indices
   support.check_plot(x)
   a.fillareastyle='solid'			# change the fill style back to solid
   support.check_plot(x)
   
   x.clear()				# clear the VCS Canvas
   x.plot(s,a,'default',bg=bg)		# plot isofill using 'default' template
   support.check_plot(x)
   
   objs =x.listelements('template')                   # get the list of templates
   t=x.createtemplate('test')           # create template 'test' from 'default' template
   if not vcs_legacy.istemplate(t):                  # test whether 't' is a template or not
      raise Exception,"Error template not created"
   else:
      a2 =x.listelements('template')                   # get the list of templates
      if objs==a2:
         raise Exception,"Error template not created or added to list"
   
   objs = x.listelements('fillarea')                      	# show the list of fillarea secondary objects
   f=x.getfillarea('AuTo_1')                	# get fillarea 'red'
   if not vcs_legacy.issecondaryobject(f):           # check to see if it is a secondary object
      raise Exception,"Error did not get fillarea"
   else:
      if not vcs_legacy.isfillarea(f):                  	# check to see if it is a fillarea
         raise Exception, "Error object created is not fillarea"
   
   a.levels=(220,225,230,235,240,250,260,270,280,290,300,310)	# change the isofill levels
   x.clear()				# clear the VCS Canvas
   x.plot(a,t,s,bg=bg)			# plot array using isofill 'a' and template 't'
   support.check_plot(x)
   a.fillareaindices=(3,4,7,9,11)	# set the indices
   support.check_plot(x)
   a.fillareaindices=(f,f,f,f,f,f)	# set the indices using the fillarea object
   support.check_plot(x)
   a.fillareaindices=(f,2,4,7)		# reset the indices using the fillarea object
   support.check_plot(x)
   a.fillareaindices=(7,f,f,f,8)	# resett the indices using the fillare object
   support.check_plot(x)
   
   f.color=44				# change the fillarea object's color
   support.check_plot(x)
   f.style='hatch'			# change the fillarea object's fill style
   support.check_plot(x)
   
   x.scriptobject(a,'test')		# save 'quick' isofill as a Python script
   x.scriptobject(f,'test')		# save 'def37' fill area as a Python script
   
   a = x.listelements('isofill')                      # show list of gm
   r=x.createisofill('test2','quick')     # create xyvsy 'test2'
   a2 = x.listelements('isofill')                      # show list of gm
   if a2==a:
      raise "error gm not created or not added to list"
   x.removeobject(r)                    # remove xyvsy 'test2'
   a3 = x.listelements('isofill')                      # show list of gm
   if a3!=a:
      raise "error gm not removed"
   
   #################################################################################
   # to see how x.update and x.mode work, see testisofill.py			   #
   #################################################################################
   #x.update()				
   #x.mode=1
   #x.mode=0
   print '*************************************************************************************'
   print '******                                                                         ******'
   print '******   I S O F I L L   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
   print '******                                                                         ******'
   print '*************************************************************************************'
Пример #17
0
def test():
    import vcs_legacy, cdms2 as cdms, time, os, sys, support  # import vcs_legacy and cdms
    bg = support.bg

    f = cdms.open(
        os.path.join(cdms.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'clt.nc'))  # open clt file
    u = f('u')  # get slab u
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    x.plot(u, 'default', 'xyvsy', 'ASD7', bg=bg)  # plot slab the old way
    support.check_plot(x)
    if bg == 0:
        x.geometry(450, 337, 100, 0)  # change the geometry and location
        x.flush()
        support.check_plot(x)

    a = x.getxyvsy('ASD7')  # get 'ASD1' xyvsy
    if not vcs_legacy.isgraphicsmethod(
            a):  # test object 'a' for graphics method
        raise Exception, "Error did not retrieve the gm"
    else:
        if not vcs_legacy.isxyvsy(a):  # test object 'a' if xyvsy
            raise Exception, "Error gm is not right type"

    a.script('test', 'w')  # save 'ASD7' xyvsy as a Python script

    a.xticlabels('', '')  # remove the x-axis
    support.check_plot(x)
    a.xticlabels('*')  # put the x-axis
    support.check_plot(x)

    ############################################################################
    # Change the xyvsy line                                                    #
    ############################################################################
    a.line = 0  # same as 'solid'
    support.check_plot(x)
    a.line = 1  # same as 'dash'
    support.check_plot(x)
    a.line = 2  # same as 'dot'
    support.check_plot(x)
    a.line = 3  # same as 'dash-dot'
    support.check_plot(x)
    a.line = 4  # same as 'long-dash'
    support.check_plot(x)

    if not '--extended' in sys.argv:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()

    ############################################################################
    # Change the xyvsy line color                                              #
    ############################################################################
    a.linecolor = (77)
    support.check_plot(x)
    a.linecolor = 16
    support.check_plot(x)
    a.linecolor = 44  # same as a.color=(44)
    support.check_plot(x)
    a.linecolor = None
    support.check_plot(x)

    ############################################################################
    # Change the xyvsy marker                                                  #
    ############################################################################
    a.marker = 1  # Same as a.marker='dot'
    support.check_plot(x)
    a.marker = 2  # Same as a.marker='plus'
    support.check_plot(x)
    a.marker = 3  # Same as a.marker='star'
    support.check_plot(x)
    a.marker = 4  # Same as a.marker='circle'
    support.check_plot(x)
    a.marker = 5  # Same as a.marker='cross'
    support.check_plot(x)
    a.marker = 6  # Same as a.marker='diamond'
    support.check_plot(x)
    a.marker = 7  # Same as a.marker='triangle_up'
    support.check_plot(x)
    a.marker = 8  # Same as a.marker='triangle_down'
    support.check_plot(x)
    a.marker = 9  # Same as a.marker='triangle_left'
    support.check_plot(x)
    a.marker = 10  # Same as a.marker='triangle_right'
    support.check_plot(x)
    a.marker = 11  # Same as a.marker='square'
    support.check_plot(x)
    a.marker = 12  # Same as a.marker='diamond_fill'
    support.check_plot(x)
    a.marker = 13  # Same as a.marker='triangle_up_fill'
    support.check_plot(x)
    a.marker = 14  # Same as a.marker='triangle_down_fill'
    support.check_plot(x)
    a.marker = 15  # Same as a.marker='triangle_left_fill'
    support.check_plot(x)
    a.marker = 16  # Same as a.marker='triangle_right_fill'
    support.check_plot(x)
    a.marker = 17  # Same as a.marker='square_fill'
    support.check_plot(x)
    a.marker = None  # Draw no markers
    support.check_plot(x)

    ############################################################################
    # Change the xyvsy marker color                                            #
    ############################################################################
    a.marker = 'dot'
    support.check_plot(x)
    a.markercolor = 16
    support.check_plot(x)
    a.markercolor = 44  # same as a.markercolor=(44)
    support.check_plot(x)
    a.markercolor = None
    support.check_plot(x)

    ############################################################################
    # Change the xyvsy marker size                                             #
    ############################################################################
    a.markersize = 5
    support.check_plot(x)
    a.markersize = 55
    support.check_plot(x)
    a.markersize = 10
    support.check_plot(x)
    a.markersize = 100
    support.check_plot(x)
    a.markersize = 300
    support.check_plot(x)
    a.markersize = None
    support.check_plot(x)

    x.clear()  # clear the VCS Canvas
    x.xyvsy(u, a, 'default', bg=bg)  # plot xyvsy using 'default' template
    support.check_plot(x)

    objs = x.listelements('template')  # get the list of templates
    t = x.createtemplate(
        'test')  # create template 'test' from 'default' template
    if not vcs_legacy.istemplate(t):  # test whether 't' is a template or not
        raise Exception, "Error template not created"
    else:
        a2 = x.listelements('template')  # get the list of templates
        if objs == a2:
            raise Exception, "Error template not created or added to list"

    x.clear()  # clear the VCS Canvas
    x.plot(t, a, u,
           bg=bg)  # plot xyvsy template 't', outline 'a', and arrays 'u':'v'
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.xyvsy(a, u, t,
            bg=bg)  # plot using outline 'a', array 'u':'v', and template 't'
    support.check_plot(x)

    objs = x.listelements('line')  # show the list of line secondary objects
    l = x.getline('red')  # get line 'red'
    if not vcs_legacy.issecondaryobject(
            l):  # check to see if it is a secondary object
        raise Exception, "Error did not get line"
    else:
        if not vcs_legacy.isline(l):  # check to see if it is a line
            raise Exception, "Error object created is not line"

    ###########################################################################
    # Use the create line object 'm' from above and modify the line object    #
    ###########################################################################
    a.line = l  # use the line object
    l.color = 44  # change the line color
    support.check_plot(x)
    l.type = 'dot'  # change the line type
    support.check_plot(x)
    l.width = 4  # change the line size
    support.check_plot(x)

    objs = x.listelements(
        'marker')  # show the list of marker secondary objects
    m = x.getmarker('red')  # get marker 'red'
    if not vcs_legacy.issecondaryobject(
            m):  # check to see if it is a secondary object
        raise Exception, "Error did not get marker"
    else:
        if not vcs_legacy.ismarker(m):  # check to see if it is a line
            raise Exception, "Error object created is not marker"

    ###########################################################################
    # Use the create marker object 'm' from above and modify the line object  #
    ###########################################################################
    a.marker = m  # use the marker object
    support.check_plot(x)
    m.color = 44  # change the marker color
    support.check_plot(x)
    m.type = 'square'  # change the marker type
    support.check_plot(x)
    m.size = 20  # change the marker size
    support.check_plot(x)

    a = x.listelements('xyvsy')  # show list of xyvsy
    r = x.createxyvsy('test2', 'ASD1')  # create xyvsy 'test2'
    a2 = x.listelements('xyvsy')  # show list of xyvsy
    if a2 == a:
        raise "error gm not created or not added to list"
    x.removeobject(r)  # remove xyvsy 'test2'
    a3 = x.listelements('xyvsy')  # show list of xyvsy
    if a3 != a:
        raise "error gm not removed"

    #################################################################################
    # to see how x.update and x.mode work, see testoutline.py                       #
    #################################################################################
    #x.update()
    #x.mode=1
    #x.mode=0
    print '*************************************************************************************'
    print '******                                                                         ******'
    print '******   X y v s y   T E S T   C O M P L E T E D   S U C E S S F U L L Y       ******'
    print '******                                                                         ******'
    print '*************************************************************************************'
Пример #18
0
def test():
    import vcs_legacy, cdms2 as cdms, time, os, sys, support  # import vcs_legacy and cu
    bg = support.bg

    f = cdms.open(
        os.path.join(cdms.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'clt.nc'))  # open clt file
    u = f.getslab('u', ':', ':', -10., 0., 0, 10)  # get slab u
    v = f.getslab('v', ':', ':', -10., 0., 0, 10)  # get slab v
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    x.plot(u, v, 'default', 'vector', 'quick', bg=bg)  # plot slab the old way
    support.check_plot(x)
    if bg == 0:
        x.geometry(450, 337, 100, 0)  # change the geometry and location
        x.flush()
        support.check_plot(x)

    a = x.getvector('quick')  # get 'quick' vector
    if not vcs_legacy.isgraphicsmethod(
            a):  # test object 'a' for graphics method
        raise Exception, "Error did not retrieve the gm"
    else:
        if not vcs_legacy.isvector(a):  # test object 'a' if vector
            raise Exception, "Error gm is not right type"

    a.script('test', 'w')  # save 'quick' vector as a Python script

    a.xticlabels('', '')  # remove the x-axis
    support.check_plot(x)
    a.xticlabels('*')  # put the x-axis
    support.check_plot(x)

    ############################################################################
    # Change the vector scale                                                  #
    ############################################################################
    a.scale = 2.0
    support.check_plot(x)
    a.scale = 5.0
    support.check_plot(x)
    a.scale = 1.5
    support.check_plot(x)
    a.scale = 0.0
    support.check_plot(x)
    a.scale = -1.5
    support.check_plot(x)
    a.scale = -2.0
    support.check_plot(x)
    a.scale = -5.0
    support.check_plot(x)

    ############################################################################
    # Change the vector typeiiiiiii                                            #
    ############################################################################
    a.type = 0  # same as a.type = 'arrows'
    support.check_plot(x)
    a.type = 1  # same as a.type = 'barbs'
    support.check_plot(x)
    ##    a.type=2				# same as a.type = 'solidarrows'
    ##    support.check_plot(x)
    ##    raw_input("Done...")

    if not '--extended' in sys.argv:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()

    ############################################################################
    # Change the vector reference                                              #
    ############################################################################
    a.reference = 10.
    support.check_plot(x)
    a.reference = 100.
    support.check_plot(x)
    a.reference = 4.
    support.check_plot(x)
    a.reference = 5.
    support.check_plot(x)

    ############################################################################
    # Change the vector alignment                                              #
    ############################################################################
    a.alignment = 'head'  # same as a.alignment=0
    support.check_plot(x)
    a.alignment = 'center'  # same as a.alignment=1
    support.check_plot(x)
    a.alignment = 'tail'  # same as a.alignment=2
    support.check_plot(x)

    ############################################################################
    # Change the vector line                                                   #
    ############################################################################
    a.line = 0  # same as 'solid'
    support.check_plot(x)
    a.line = 1  # same as 'dash'
    support.check_plot(x)
    a.line = 2  # same as 'dot'
    support.check_plot(x)
    a.line = 3  # same as 'dash-dot'
    support.check_plot(x)
    a.line = 4  # same as 'long-dash'
    support.check_plot(x)
    a.line = None  # use default line
    support.check_plot(x)

    ############################################################################
    # Change the vector line color                                             #
    ############################################################################
    a.linecolor = (77)
    support.check_plot(x)
    a.linecolor = 16
    support.check_plot(x)
    a.linecolor = 44  # same as a.color=(44)
    support.check_plot(x)
    a.linecolor = None
    support.check_plot(x)

    x.clear()  # clear the VCS Canvas
    x.vector(u, v, a, 'default', bg=bg)  # plot vector using 'default' template
    support.check_plot(x)

    objs = x.listelements('template')  # get the list of templates
    t = x.createtemplate(
        'test')  # create template 'test' from 'default' template
    if not vcs_legacy.istemplate(t):  # test whether 't' is a template or not
        raise Exception, "Error template not created"
    else:
        a2 = x.listelements('template')  # get the list of templates
        if objs == a2:
            raise Exception, "Error template not created or added to list"

    x.clear()  # clear the VCS Canvas
    x.plot(t, a, u, v,
           bg=bg)  # plot vector template 't', outline 'a', and arrays 'u':'v'
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.vector(a, u, v, t,
             bg=bg)  # plot using outline 'a', array 'u':'v', and template 't'
    support.check_plot(x)

    l = x.getline('red')  # get line 'red'
    if not vcs_legacy.issecondaryobject(
            l):  # check to see if it is a secondary object
        raise Exception, "Error did not get line"
    else:
        if not vcs_legacy.isline(l):  # check to see if it is a line
            raise Exception, "Error object created is not line"

    ###########################################################################
    # Use the create line object 'm' from above and modify the line object    #
    ###########################################################################
    a.line = l  # use the line object
    support.check_plot(x)
    l.color = 44  # change the line color
    support.check_plot(x)
    l.type = 'dot'  # change the line type
    support.check_plot(x)
    l.width = 4  # change the line size
    support.check_plot(x)

    a = x.listelements('vector')  # show list of gm
    r = x.createvector('test2', 'quick')  # create xyvsy 'test2'
    a2 = x.listelements('vector')  # show list of gm
    if a2 == a:
        raise "error gm not created or not added to list"
    x.removeobject(r)  # remove xyvsy 'test2'
    a3 = x.listelements('vector')  # show list of gm
    if a3 != a:
        raise "error gm not removed"

    #################################################################################
    # to see how x.update and x.mode work, see testoutline.py                       #
    #################################################################################
    #x.update()
    #x.mode=1
    #x.mode=0
    print '*************************************************************************************'
    print '******                                                                         ******'
    print '******   V E C T O R   T E S T   C O M P L E T E D   S U C E S S F U L L Y     ******'
    print '******                                                                         ******'
    print '*************************************************************************************'
Пример #19
0
def test():
    import vcs_legacy, cdms2 as cdms, time, os, sys, support  # import vcs_legacy and cdms
    bg = support.bg

    f = cdms.open(
        os.path.join(cdms.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'clt.nc'))
    s = f('clt')  # get slab clt
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    x.plot(s, 'default', 'boxfill', 'quick', bg=bg)  # plot slab the old way
    #support.check_plot(x)
    if bg == 0:
        x.geometry(450, 337)  # change the geometry
        x.flush()
        #support.check_plot(x)

    a = x.getboxfill('quick')  # get 'quick' boxfill graphics method
    if not vcs_legacy.isgraphicsmethod(
            a):  # test object 'a' for graphics method
        raise Exception, "Error did not retrieve the gm"
    else:
        if not vcs_legacy.isboxfill(a):  # check for boxfill
            raise Exception, "Error gm is not right type"

    # Change boxfill's legend
    a.legend = {
        0: 'Great',
        20: 'Outstanding',
        40: 'Wonderful',
        60: 'Happy',
        80: 'Exciting!',
        100: 'Best'
    }
    support.check_plot(x)
    a.legend = {0: '100', 20: '80', 40: '60', 60: '40', 80: '20', 100: '0'}
    support.check_plot(x)
    a.legend = {
        0: 'Blue',
        20: 'Green',
        40: 'Yellow',
        60: 'Red',
        80: 'Burgundy',
        100: 'Magenta'
    }
    support.check_plot(x)
    a.legend = (90)
    support.check_plot(x)
    a.legend = [10, 90]
    support.check_plot(x)
    a.legend = (1.5, 45.8, 89.7)
    support.check_plot(x)
    a.legend = None
    support.check_plot(x)

    if not '--extended' in sys.argv:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()

    a.color_1 = 50  # change color_1 index attribute
    support.check_plot(x)

    a.xticlabels('lon30', 'lon30')  # change xlabels attribute
    support.check_plot(x)
    a.xticlabels('', '')  # change remove xlables from plot
    support.check_plot(x)
    a.datawc(-45.0, 45.0, -90.0, 90.0)  # change region
    support.check_plot(x)
    a.datawc(1e20, 1e20, 1e20, 1e20)  # change region back
    support.check_plot(x)
    a.xticlabels('*')  # change attribute labels back
    support.check_plot(x)

    x.mode = 0  # turn atomatic update off
    a.color_1 = 100  # change color_1 attribute
    a.color_2 = 200  # change color_2 index value
    a.xticlabels('lon30', 'lon30')  # change attribute
    a.yticlabels('', '')  # change y-labels off attribute
    a.datawc(-45.0, 45.0, -90.0, 90.0)  # change region
    support.check_plot(x)
    x.update()  # view changes now
    support.check_plot(x)

    # Test log10 boxfill plot
    x.clear()  # clear the VCS Canvas
    a.boxfill_type = 'log10'  # Change the Boxfill type to log10
    a.datawc(1e20, 1e20, 1e20, 1e20)  # change region
    a.level_1 = 1e20  # change level_1
    a.level_2 = 1e20  # change level_2
    a.color_1 = 16  # change color_1 attribute
    a.color_2 = 239  # change color_2 index value
    x.boxfill(s, a, bg=bg)  # plot using default template
    support.check_plot(x)

    # Test custom boxfill plot
    x.clear()  # clear the VCS Canvas
    a.boxfill_type = 'custom'  # Change the Boxfill type to custom
    a.levels = (0, 20, 35, 40, 75, 100)  # Set the custom ranges
    a.fillareacolors = (16, 25, 38, 55, 100, 166)  # Set the color indices
    x.boxfill(s, a, bg=bg)  # plot using default template
    support.check_plot(x)

    # Test legend with fillareacolors boxfill plot
    x.clear()  # clear the VCS Canvas
    a.boxfill_type = 'linear'  # Change the Boxfill type back to linear
    a.fillareacolors = (254, )  # Set the color indices
    a.level_1 = 0  # change level_1
    a.level_2 = 0  # change level_2
    x.boxfill(s, a, bg=bg)  # plot using default template
    support.check_plot(x)

    a.script('test', 'w')  # save 'quick' boxfill as a Python script

    x.mode = 1  # turn atomatic update mode back on
    a.color_1 = 16  # change color_1 attribute
    support.check_plot(x)
    a.color_2 = 239  # change color_2 index value
    support.check_plot(x)
    a.level_1 = 20  # change level_1
    support.check_plot(x)
    a.level_2 = 80  # change level_2
    support.check_plot(x)
    a.datawc(1e20, 1e20, 1e20, 1e20)  # change region back
    support.check_plot(x)
    a.yticlabels('*')  # change y-labels attribute
    support.check_plot(x)

    x.scriptobject(a, 'test', 'a')  # append 'quick' to the existing file
    a.script('test.scr', 'w')  # save 'quick' as a VCS script file

    objs = x.listelements('template')  # get the list of templates
    t = x.createtemplate(
        'test')  # create template 'test' from 'default' template
    if not vcs_legacy.istemplate(t):  # test whether 't' is a template or not
        raise Exception, "Error template not created"
    else:
        a2 = x.listelements('template')  # get the list of templates
        if objs == a2:
            raise Exception, "Error template not created or added to list"

    x.clear()  # clear the VCS Canvas
    x.boxfill(s, a, 'default', bg=bg)  # plot using default template
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.boxfill(a, 'default', s,
              bg=bg)  # plot using default template, but, reverse the order
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.boxfill(s, a, t, bg=bg)  # plot using template 'test'
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.boxfill(a, s, t,
              bg=bg)  # plot using template 'test', but reverse the objects
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.boxfill(t, a, s,
              bg=bg)  # plot using template 'test', but reverse the objects
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas

    x.plot(t, a, s, bg=bg)  # plot using the new way
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.plot(a, t, s, bg=bg)  # plot using the new way
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.plot(s, t, a, bg=bg)  # plot using the new way
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.plot('default', a, s, bg=bg)  # plot using the new way
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.plot('default', s, bg=bg)  # plot using the new way
    support.check_plot(x)

    a = x.listelements('boxfill')  # show list of xyvsy
    r = x.createboxfill('test2', 'quick')  # create xyvsy 'test2'
    a2 = x.listelements('boxfill')  # show list of xyvsy
    if a2 == a:
        raise "error gm not created or not added to list"
    x.removeobject(r)  # remove xyvsy 'test2'
    a3 = x.listelements('boxfill')  # show list of xyvsy
    if a3 != a:
        raise "error gm not removed"

    a = x.getboxfill('quick')  # get 'quick' boxfill graphics method
    x.clear()
    x.plot(s, a, bg=bg)
    support.check_plot(x)
    if support.dogui:
        x.graphicsmethodgui('boxfill',
                            'quick')  # display the boxfill graphics method GUI
        raw_input("Press enter when done with gui testing")
    print '*************************************************************************************'
    print '******                                                                         ******'
    print '******   B O X F I L L   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
    print '******                                                                         ******'
    print '*************************************************************************************'
Пример #20
0
def test():

    import vcs_legacy, support, sys
    bg = support.bg

    x = vcs_legacy.init()

    # For plotting of each test case, set the pause time to 1.
    x.pause_time = 1

    ############################ First Test ###############################

    # Set the global viewport values only.
    #
    # Remember, must set global x.viewport (vp) and/or x.world coordinate (wc)
    # values before calling { [x.createline, x.createmarker, x.createfillarea,
    # x.createtext], [x.getline, x.getmarker, x.getfillarea, x.gettext],
    # [x.drawline, x.drawmarker, x.drawfillarea, x.drawtext] }.
    #
    # If the global viewport (vp) and world coordinate (wc) values are set
    # and the, functions, listed above, do not specify them, then the global
    # settings will override the default settings.
    #
    # If the functions listed above have vp and wc set as an argument, then
    # these vp and wc values will be used instead of the global vp and wc
    # values.
    #
    # Draw text on the screen.
    tex = x.createtext('nTtex', 'std', 'nToex', '7left')
    tex.height = 25
    tex.x = [0.1, 0.1]
    tex.y = [0.97, 0.93]
    tex.string = [
        'Example of drawing VCS low-level primitives.',
        'Also, an example of using the viewport to clip graphics.'
    ]
    x.plot(tex, bg=bg)
    support.check_plot(x)
    #
    # At this point, let the world coordinate values remain at the default
    # settings [0, 1, 0, 1], but change the viewport.
    x.viewport = [0.3, 0.7, 0.3, 0.7]
    support.check_plot(x)

    # Create the line, marker, fill area, and text objects
    ln = x.createline('new')
    mk = x.createmarker('new')
    fa = x.createfillarea('new')
    t = x.createtext('newTt', 'std', 'newTo', '7left')

    # Draw a box around the entire VCS Canvas viewport. It will use the
    # global viewport set above and use the default world coordinate values:
    # Remember the default values for vp and wc are:
    #            viewport         = [0.0, 1.0, 0.0, 1.0]
    #            worldcoordinate  = [0.0, 1.0, 0.0, 1.0]
    ln.x = [0, 1, 1, 0, 0]  # x line positions
    ln.y = [0, 0, 1, 1, 0]  # y line positions
    ln.width = 4  # test width
    ln.color = 242  # test color
    ln.type = 4  # test line type
    x.plot(ln, bg=bg)  # plot lines
    support.check_plot(x)

    # Draw text on the screen. Use global vp and default wc.
    t.x = [0.2, 0.7]  # x text positions
    t.y = [0.7, 0.7]  # y text positions
    t.string = ['PCMDI', 'CDAT']  # text strings
    t.color = 243  # text color
    t.height = 90  # text size
    x.plot(t, bg=bg)  # plot text
    support.check_plot(x)

    # Draw fill area on screen. Use global vp and default wc.
    fa.x = [[0.0, 0.5, 0.5, 0.0], [0.5, 1.0, 0.75]]  # x fill area positions
    fa.y = [[0.0, 0.0, 0.5, 0.5], [0.5, 0.5, 0.0]]  # x fill area positions

    # fa.color=[241,243] cannot do this! How important is this?

    fa.color = 241  # fill area color
    fa.style = 'solid'  # fill area style
    fa.index = 3  # fill area index
    x.plot(fa, bg=bg)  # plot fill area
    support.check_plot(x)

    # Draw marker on screen. Use global vp and default wc.
    mk.x = [[0.5, 0.2], [0.3, 0.7, 1.0]]  # x marker positions
    mk.y = [[0.5, 0.2], [0.3, 0.7, 0.5]]  # y marker positions
    mk.color = 242  # marker color
    mk.size = 50  # marker size
    mk.type = 'dot'  # marker type
    x.plot(mk, bg=bg)  # plot marker
    support.check_plot(x)

    ############################ First Test completed ######################

    if not '--extended' in sys.argv:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()

    ############################ Second Test ###############################
    # Reset the global viewport values.
    x.viewport = [0.2, 0.8, 0.2, 0.8]
    support.check_plot(x)

    # Redraw a box around the drawing area, but use 'x.line' instead of 'x.plot'.
    ln = x.getline('new')
    x.line(ln, bg=bg)
    support.check_plot(x)

    # Redraw markers, but use 'x.marker', instead of 'x.plot'.
    mk = x.getmarker('new')
    x.marker(mk, bg=bg)
    support.check_plot(x)

    # Redraw fill area, but use 'x.fillarea', instead of 'x.plot'.
    fa = x.getfillarea('new')
    x.fillarea(fa, bg=bg)
    support.check_plot(x)

    # Redraw text, but use 'x.text', instead of 'x.plot'.
    t = x.gettext('newTt', 'newTo')
    x.text(t, bg=bg)
    support.check_plot(x)

    ############################ Second Test completed ######################

    ############################ Third Test ###############################
    # Change the drawing area's world coordinate from [0,1,0,1] to [0,2,0,2]
    # via primitive's graphics method, then redraw. The graphics will be drawn
    # in the lower left corner. This is because the line x and y values are
    # between (0 and 1) and the wc values are now between (0 and 2).

    ln.worldcoordinate = [0, 2, 0, 2]  # set wc
    support.check_plot(x)
    x.plot(ln, bg=bg)
    support.check_plot(x)

    # Note how the most right marker is not clipped
    mk.worldcoordinate = [0, 2, 0, 2]  # set wc
    support.check_plot(x)
    x.plot(mk, bg=bg)

    fa.worldcoordinate = [0, 2, 0, 2]
    support.check_plot(x)
    fa.color = 240  # change color to white
    support.check_plot(x)
    x.plot(fa, bg=bg)
    support.check_plot(x)

    t.worldcoordinate = [0, 2, 0, 2]  # set wc
    x.plot(t, bg=bg)
    support.check_plot(x)

    ############################ Third Test completed ######################

    ############################ Fourth Test ###############################
    #
    # Clear the VCS Canvas and redraw graphics using Python list of lists.
    #
    # Remember, the viewport and world coordinates for the graphics primitives
    # are:
    #       viewport         = [0.2, 0.8, 0.2, 0.8]
    #       worldcoordinate  = [0, 2, 0, 2]
    x.clear()

    # Draw multiple line segments
    ln.x = [[0.0, 2.0, 2.0, 0.0, 0.0], [0.5, 1.5]]  # x line positions
    ln.y = [[0.0, 0.0, 2.0, 2.0, 0.0], [1.0, 1.0]]  # y line positions
    ln.type = 'solid'
    x.plot(ln, bg=bg)
    support.check_plot(x)

    # Draw multiple marker segments
    mk.x = [[0.8, 1.3], [0.5, 1.0, 1.5]]  # x marker positions
    mk.y = [[1.5, 1.5], [0.5, 0.5, 0.5]]  # y marker positions
    x.plot(mk, bg=bg)
    support.check_plot(x)

    # Draw multiple fill area segments
    fa.x = [[0.2, 0.5, 0.5, 0.2], [1.2, 1.8, 1.8,
                                   1.2]]  # x fill area positions
    fa.y = [[0.2, 0.2, 0.5, 0.5], [1.2, 1.2, 1.8,
                                   1.8]]  # x fill area positions
    fa.color = 241
    x.plot(fa, bg=bg)
    support.check_plot(x)

    # Draw multiple text segments
    t.x = [0.5, 1.17]  # x text positions
    t.y = [0.8, 0.8]  # y text positions
    t.string = ['Text 1', 'Text 2']  # text strings
    t.color = 244  # text color
    t.height = 90  # text size
    x.plot(t, bg=bg)  # plot text
    support.check_plot(x)

    ############################ Fourth Test completed ######################

    ############################ Fifth Test ###############################
    # Change the viewport only to a different shape and replot.
    # 1st change
    ln.viewport = [0.0, 0.2, 0.0, 0.8]
    support.check_plot(x)
    x.plot(ln, bg=bg)
    support.check_plot(x)

    mk.viewport = [0.0, 0.2, 0.0, 0.8]
    support.check_plot(x)
    x.plot(mk, bg=bg)
    support.check_plot(x)
    fa.viewport = [0.0, 0.2, 0.0, 0.8]
    support.check_plot(x)
    x.plot(fa, bg=bg)
    support.check_plot(x)
    t.viewport = [0.0, 0.2, 0.0, 0.8]
    support.check_plot(x)
    x.plot(t, bg=bg)
    support.check_plot(x)

    # 2nd change
    ln.viewport = [0.0, 0.8, 0.0, 0.2]
    support.check_plot(x)
    x.plot(ln, bg=bg)
    support.check_plot(x)
    mk.viewport = [0.0, 0.8, 0.0, 0.2]
    support.check_plot(x)
    x.plot(mk, bg=bg)
    support.check_plot(x)
    fa.viewport = [0.0, 0.8, 0.0, 0.2]
    support.check_plot(x)
    x.plot(fa, bg=bg)
    support.check_plot(x)
    t.viewport = [0.0, 0.8, 0.0, 0.2]
    support.check_plot(x)
    x.plot(t, bg=bg)
    support.check_plot(x)

    ############################ Fifth Test completed ######################

    ############################ Sixth Test ###############################
    # Clear the VCS Canvas and redraw the graphics, but this time use the
    # draw functions. That is, user drawline, drawmarker, drawfillarea, and
    # drawtext.
    x.clear()
    ln = x.drawline('new',
                    ltype=1,
                    width=10,
                    color=244,
                    worldcoordinate=[0.0, 2.0, 0.0, 2.0],
                    x=[[0.0, 2.0, 2.0, 0.0, 0.0], [0.5, 1.5]],
                    y=[[0.0, 0.0, 2.0, 2.0, 0.0], [1.0, 1.0]],
                    bg=bg)
    support.check_plot(x)

    mk = x.drawmarker('new',
                      mtype='square_fill',
                      size=40,
                      color=243,
                      viewport=[0.0, 1.0, 0.0, 1.0],
                      worldcoordinate=[0.0, 2.0, 0.0, 2.0],
                      x=[[0.0, 1.0], [1.0]],
                      y=[[0.0, 1.0], [2.0]],
                      bg=bg)
    support.check_plot(x)

    fa = x.drawfillarea('new',
                        style='hatch',
                        index=2,
                        color=246,
                        viewport=[0.0, 1.0, 0.0, 1.0],
                        worldcoordinate=[0.0, 2.0, 0.0, 2.0],
                        x=[[0.5, 1.0, 1.0, 0.5], [0.5, 1.0, 0.75]],
                        y=[[0.0, 0.0, 0.5, 0.5], [1.0, 1.0, 0.5]],
                        bg=bg)
    support.check_plot(x)

    t = x.drawtext(Tt_name='newTt',
                   To_name='newTo',
                   font=4,
                   color=242,
                   height=70,
                   angle=45,
                   string=['Quad 1', 'Quad 2', 'Quad 3', 'Quad 4'],
                   viewport=[0.0, 1.0, 0.0, 1.0],
                   worldcoordinate=[0.0, 2.0, 0.0, 2.0],
                   x=[[1.5, 1.5], [0.5, 0.5]],
                   y=[[0.5, 1.5], [1.5, 0.5]],
                   bg=bg)
    support.check_plot(x)

    ############################ Sixth Test completed ######################

    ############################ Seventh Test ###############################
    # Clear the VCS Canvas and test the priority of each primitive.
    #
    x.clear()
    # Set the global viewport and worldcoordinate values.
    x.viewport = [0.3, 0.7, 0.3, 0.7]
    x.worldcoordinate = [0, 1, 0, 1]

    ln2 = x.createline('new2')
    ln3 = x.createline('new3')
    mk2 = x.createmarker('new2')
    mk3 = x.createmarker('new3')
    fa2 = x.createfillarea('new2')
    fa3 = x.createfillarea('new3')
    t2 = x.createtext('new12', 'std', 'new22', '7left')

    # Draw a box around the VCS Canvas drawing area.
    ln.x = [0, 1, 1, 0, 0]
    ln.y = [0, 0, 1, 1, 0]
    ln.viewport = [0.3, 0.7, 0.3, 0.7]
    ln.worldcoordinate = [0, 1, 0, 1]
    ln.width = 4
    ln.color = 241
    ln.type = 0
    ln.priority = 10  # Set the priority high so it will always be seen
    x.plot(ln, bg=bg)
    support.check_plot(x)

    ln2.x = [0, 0.5]
    ln2.y = [0.5, 0.5]
    ln2.priority = 2  # Set the priority higher than the next line
    ln2.width = 10
    ln2.color = 243
    x.plot(ln2, bg=bg)
    support.check_plot(x)

    ln3.x = [0, 1]
    ln3.y = [0.5, 0.5]
    ln3.priority = 1
    ln3.width = 10
    ln3.color = 244
    x.plot(ln3, bg=bg)
    support.check_plot(x)

    mk2.x = [0.5]
    mk2.y = [0.7]
    mk2.color = 242
    mk2.size = 50
    mk2.priority = 2
    x.plot(mk2, bg=bg)
    support.check_plot(x)

    mk3.x = [0.55]
    mk3.y = [0.7]
    mk3.color = 246
    mk3.size = 40
    mk3.type = 'square_fill'
    mk3.priority = 1
    x.plot(mk3, bg=bg)
    support.check_plot(x)

    fa2.x = [0.3, 0.7, 0.7, 0.3]
    fa2.y = [0.0, 0.0, 0.4, 0.4]
    fa2.color = 247
    fa2.style = 'solid'
    fa2.index = 3
    fa2.priority = 2
    x.plot(fa2, bg=bg)
    support.check_plot(x)

    fa3.x = [0.5, 0.9, 0.7]
    fa3.y = [0.4, 0.4, 0.0]
    fa3.style = 'solid'
    fa3.color = 248
    fa3.index = 15
    fa3.priority = 1
    x.plot(fa3, bg=bg)
    support.check_plot(x)

    t2.x = [0.2, 0.6]
    t2.y = [0.4, 0.4]
    t2.string = ['PCMDI', 'CDAT']
    t2.color = 241
    t2.font = 2
    t2.height = 120
    t2.priority = 1
    x.plot(t2, bg=bg)
    support.check_plot(x)

    ############################ Seventh Test completed ######################

    ############################ Eighth Test ###############################
    # Clear the VCS Canvas and test the Python list for the primitive attributes.
    #
    x.clear()
    ln.x = [[0, 1], [1, 1], [1, 0], [0, 0]]
    ln.y = [[0, 0], [0, 1], [1, 1], [1, 0]]
    ln.width = [1, 10, 20, 30]
    ln.color = [242, 243, 244, 245]
    ln.type = [1, 2, 3, 0]
    ln.viewport = [0.2, 0.8, 0.2, 0.8]
    ln.worldcoordinate = [0.0, 1.0, 0.0, 1.0]
    x.plot(ln, bg=bg)
    support.check_plot(x)

    mk.x = [[0.5, 0.2], [0.3, 0.7], [1.0]]
    mk.y = [[0.5, 0.2], [0.3, 0.7], [0.5]]
    mk.color = [242, 243, 244]
    mk.size = [30, 50, 70]
    mk.type = ['dot', 'star', 'square_fill']
    mk.viewport = [0.2, 0.8, 0.2, 0.8]
    mk.worldcoordinate = [0.0, 1.0, 0.0, 1.0]
    x.plot(mk, bg=bg)
    support.check_plot(x)

    fa.x = [[0.0, 0.5, 0.5, 0.0], [0.5, 1.0, 0.75], [0.3, 0.7, 0.5]]
    fa.y = [[0.0, 0.0, 0.5, 0.5], [0.5, 0.5, 0.0], [0.52, 0.52, 0.95]]
    fa.color = [241, 242, 243]
    fa.style = ['hatch', 'solid']
    fa.index = [1, 2, 3]
    fa.viewport = [0.2, 0.8, 0.2, 0.8]
    fa.worldcoordinate = [0.0, 1.0, 0.0, 1.0]
    x.plot(fa, bg=bg)
    support.check_plot(x)

    ############################ Eighth Test completed ######################

    print '*****************************************************************************************'
    print '******                                                                             ******'
    print '******   L O W - L E V E L   P R I M I T I V E S ( I . E . ,  L I N E S ,          ******'
    print '******           M A R K E R S ,   F I L L A R E A S ,   A N D   T E X T )         ******'
    print '******                                                                             ******'
    print '******               C O M P L E T E D   S U C E S S F U L L Y   ! ! !             ******'
    print '******                                                                             ******'
    print '*****************************************************************************************'
Пример #21
0
def test():
   import vcs_legacy,cdms2 as cdms,time,os,sys,support          # import vcs_legacy and cu
   bg=support.bg
   
   f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','clt.nc')) # open clt file
   u=f.getslab('u',':',':',-10.,0.,0,10)# get slab u
   v=f.getslab('v',':',':',-10.,0.,0,10)# get slab v
   x=vcs_legacy.init()                         # construct vcs_legacy canvas
   
   x.plot(u, v, 'default','vector','quick',bg=bg)	# plot slab the old way
   support.check_plot(x)
   if bg==0:
      x.geometry(450,337,100,0)		# change the geometry and location
      x.flush()
      support.check_plot(x)
   
   a=x.getvector('quick')		# get 'quick' vector
   if not vcs_legacy.isgraphicsmethod(a):            # test object 'a' for graphics method
      raise Exception, "Error did not retrieve the gm"
   else:
      if not vcs_legacy.isvector(a):                 # test object 'a' if vector
         raise Exception, "Error gm is not right type"
   
   a.script('test','w')                 # save 'quick' vector as a Python script
   
   
   a.xticlabels('','')                  # remove the x-axis
   support.check_plot(x)
   a.xticlabels('*')                    # put the x-axis
   support.check_plot(x)
   
   ############################################################################
   # Change the vector scale                                                  #
   ############################################################################
   a.scale=2.0
   support.check_plot(x)
   a.scale=5.0
   support.check_plot(x)
   a.scale=1.5
   support.check_plot(x)
   a.scale=0.0
   support.check_plot(x)
   a.scale=-1.5
   support.check_plot(x)
   a.scale=-2.0
   support.check_plot(x)
   a.scale=-5.0
   support.check_plot(x)
   
   ############################################################################
   # Change the vector typeiiiiiii                                            #
   ############################################################################
   a.type=0				# same as a.type = 'arrows'
   support.check_plot(x)
   a.type=1				# same as a.type = 'barbs'
   support.check_plot(x)
##    a.type=2				# same as a.type = 'solidarrows'
##    support.check_plot(x)
##    raw_input("Done...")


   if not '--extended' in sys.argv:
     print '\n************* PARTIAL TEST *****************'
     print 'FOR COMPLETE TEST OF THIS MODULE USE '
     print '   -F (--full) or -E (--extended) option'
     print '************* PARTIAL TEST *****************\n'
     sys.exit()


 



   ############################################################################
   # Change the vector reference                                              #
   ############################################################################
   a.reference=10.
   support.check_plot(x)
   a.reference=100.
   support.check_plot(x)
   a.reference=4.
   support.check_plot(x)
   a.reference=5.
   support.check_plot(x)
   
   ############################################################################
   # Change the vector alignment                                              #
   ############################################################################
   a.alignment='head'      		# same as a.alignment=0
   support.check_plot(x)
   a.alignment='center'    		# same as a.alignment=1
   support.check_plot(x)
   a.alignment='tail'      		# same as a.alignment=2
   support.check_plot(x)
   
   ############################################################################
   # Change the vector line                                                   #
   ############################################################################
   a.line=0        			# same as 'solid'
   support.check_plot(x)
   a.line=1       			# same as 'dash'
   support.check_plot(x)
   a.line=2        			# same as 'dot'
   support.check_plot(x)
   a.line=3        			# same as 'dash-dot'
   support.check_plot(x)
   a.line=4        			# same as 'long-dash'
   support.check_plot(x)
   a.line=None        			# use default line   
   support.check_plot(x)
   
   ############################################################################
   # Change the vector line color                                             #
   ############################################################################
   a.linecolor=(77)
   support.check_plot(x)
   a.linecolor=16
   support.check_plot(x)
   a.linecolor=44  # same as a.color=(44)
   support.check_plot(x)
   a.linecolor=None
   support.check_plot(x)
   
   x.clear()                            # clear the VCS Canvas
   x.vector(u, v, a,'default',bg=bg)		# plot vector using 'default' template
   support.check_plot(x)
   
   objs =x.listelements('template')                   # get the list of templates
   t=x.createtemplate('test')           # create template 'test' from 'default' template
   if not vcs_legacy.istemplate(t):                  # test whether 't' is a template or not
      raise Exception,"Error template not created"
   else:
      a2 =x.listelements('template')                   # get the list of templates
      if objs==a2:
         raise Exception,"Error template not created or added to list"
   
   x.clear()                            # clear the VCS Canvas
   x.plot(t,a,u,v,bg=bg)                      # plot vector template 't', outline 'a', and arrays 'u':'v'
   support.check_plot(x)
   x.clear()                            # clear the VCS Canvas
   x.vector(a,u,v,t,bg=bg)                    # plot using outline 'a', array 'u':'v', and template 't'
   support.check_plot(x)
   
   l=x.getline('red')                	# get line 'red'
   if not vcs_legacy.issecondaryobject(l):           # check to see if it is a secondary object
      raise Exception,"Error did not get line"
   else:
      if not vcs_legacy.isline(l):                  	# check to see if it is a line
         raise Exception, "Error object created is not line"
   
   ###########################################################################
   # Use the create line object 'm' from above and modify the line object    #
   ###########################################################################
   a.line=l                             # use the line object
   support.check_plot(x)
   l.color = 44                         # change the line color
   support.check_plot(x)
   l.type ='dot'                    # change the line type
   support.check_plot(x)
   l.width=4 				# change the line size
   support.check_plot(x)
   
   a = x.listelements('vector')                      # show list of gm
   r=x.createvector('test2','quick')     # create xyvsy 'test2'
   a2 = x.listelements('vector')                      # show list of gm
   if a2==a:
      raise "error gm not created or not added to list"
   x.removeobject(r)                    # remove xyvsy 'test2'
   a3 = x.listelements('vector')                      # show list of gm
   if a3!=a:
      raise "error gm not removed"
   
   #################################################################################
   # to see how x.update and x.mode work, see testoutline.py                       #
   #################################################################################
   #x.update()
   #x.mode=1
   #x.mode=0
   print '*************************************************************************************'
   print '******                                                                         ******'
   print '******   V E C T O R   T E S T   C O M P L E T E D   S U C E S S F U L L Y     ******'
   print '******                                                                         ******'
   print '*************************************************************************************'
Пример #22
0
def test():
    import vcs_legacy, cdms2, time, os, sys, support  # import vcs_legacy and cdms

    # In the initial.attribute file the page orientation is set to
    # portrait. The test is to convert from portrait to landscape.
    # See your initial.attribute file and set "Page(portrait)".
    # This should be located at the top of the initial.attribute
    # file.
    x = vcs_legacy.init()
    x.pause_time = 2

    # Check for the canvas orientation, which should be by default 'landscape'
    if x.islandscape() == 1:  # will return 1 if true or 0 if false
        print 'landscape page mode'
    if x.isportrait() == 1:  # will return 1 if true or 0 if false
        print 'portrait page mode'
    print 'The page orientation is ( %s ). ' % x.orientation(
    )  # will return 'landscape' or 'portrait'

    # Change the page orientation to portrait and print the test cases
    print '\nChange the page orientation to portrait and test'
    x.portrait()  # Change page orientation to portrait
    if x.islandscape() == 1:
        print 'landscape page mode'
    if x.isportrait() == 1:
        print 'portrait page mode'
    print 'The page orientation is ( %s ). ' % x.orientation(
    )  # will return 'landscape' or 'portrait'

    # Change the page orientation to landscape and print the test cases
    print '\nChange the page orientation to landscape and test'
    x.landscape()
    if x.islandscape() == 1:  # will return 1 if true or 0 if false
        print 'landscape page mode'
    if x.isportrait() == 1:  # will return 1 if true or 0 if false
        print 'portrait page mode'
    print 'The page orientation is ( %s ). ' % x.orientation(
    )  # will return 'landscape' or 'portrait'

    #
    # prints in location mode
    # I feel this is correct!
    #
    f = cdms2.open(
        os.path.join(cdms2.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'clt.nc'))
    s = f('clt')
    x = vcs_legacy.init()
    t = x.createtemplate('new')
    to = x.createtextorientation('test')
    to.height = 30
    t.mean.y = 0.5
    t.mean.x = 0.5
    t.mean.textorientation = to
    t.mean.list()
    x.plot(s, t, bg=support.bg)
    support.check_plot(x)
    x.flush()
    support.check_plot(x)

    #
    x.portrait()  # This will clear the screen
    support.check_plot(x)
    x.plot(s, t, bg=support.bg)
    support.check_plot(x)

    #
    x.landscape()  # This will clear the screen
    support.check_plot(x)
    x.plot(s, t, bg=support.bg)
    support.check_plot(x)

    print '*************************************************************************************'
    print '******                                                                         ******'
    print '******   P A G E  O R I E N T A T I O N   T E S T   C O M P L E T E D          ******'
    print '******   S U C E S S F U L L Y    ! ! !                                        ******'
    print '******                                                                         ******'
    print '*************************************************************************************'
Пример #23
0
def test():
    import vcs_legacy, cdms2 as cdms, time, os, sys, support  # import vcs_legacy and cdms

    bg = support.bg

    f = cdms.open(os.path.join(cdms.__path__[0], "..", "..", "..", "..", "sample_data", "clt.nc"))  # open clt file
    u = f("u")  # get slab u
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    x.plot(u, "default", "xyvsy", "ASD7", bg=bg)  # plot slab the old way
    support.check_plot(x)
    if bg == 0:
        x.geometry(450, 337, 100, 0)  # change the geometry and location
        x.flush()
        support.check_plot(x)

    a = x.getxyvsy("ASD7")  # get 'ASD1' xyvsy
    if not vcs_legacy.isgraphicsmethod(a):  # test object 'a' for graphics method
        raise Exception, "Error did not retrieve the gm"
    else:
        if not vcs_legacy.isxyvsy(a):  # test object 'a' if xyvsy
            raise Exception, "Error gm is not right type"

    a.script("test", "w")  # save 'ASD7' xyvsy as a Python script

    a.xticlabels("", "")  # remove the x-axis
    support.check_plot(x)
    a.xticlabels("*")  # put the x-axis
    support.check_plot(x)

    ############################################################################
    # Change the xyvsy line                                                    #
    ############################################################################
    a.line = 0  # same as 'solid'
    support.check_plot(x)
    a.line = 1  # same as 'dash'
    support.check_plot(x)
    a.line = 2  # same as 'dot'
    support.check_plot(x)
    a.line = 3  # same as 'dash-dot'
    support.check_plot(x)
    a.line = 4  # same as 'long-dash'
    support.check_plot(x)

    if not "--extended" in sys.argv:
        print "\n************* PARTIAL TEST *****************"
        print "FOR COMPLETE TEST OF THIS MODULE USE "
        print "   -F (--full) or -E (--extended) option"
        print "************* PARTIAL TEST *****************\n"
        sys.exit()

    ############################################################################
    # Change the xyvsy line color                                              #
    ############################################################################
    a.linecolor = 77
    support.check_plot(x)
    a.linecolor = 16
    support.check_plot(x)
    a.linecolor = 44  # same as a.color=(44)
    support.check_plot(x)
    a.linecolor = None
    support.check_plot(x)

    ############################################################################
    # Change the xyvsy marker                                                  #
    ############################################################################
    a.marker = 1  # Same as a.marker='dot'
    support.check_plot(x)
    a.marker = 2  # Same as a.marker='plus'
    support.check_plot(x)
    a.marker = 3  # Same as a.marker='star'
    support.check_plot(x)
    a.marker = 4  # Same as a.marker='circle'
    support.check_plot(x)
    a.marker = 5  # Same as a.marker='cross'
    support.check_plot(x)
    a.marker = 6  # Same as a.marker='diamond'
    support.check_plot(x)
    a.marker = 7  # Same as a.marker='triangle_up'
    support.check_plot(x)
    a.marker = 8  # Same as a.marker='triangle_down'
    support.check_plot(x)
    a.marker = 9  # Same as a.marker='triangle_left'
    support.check_plot(x)
    a.marker = 10  # Same as a.marker='triangle_right'
    support.check_plot(x)
    a.marker = 11  # Same as a.marker='square'
    support.check_plot(x)
    a.marker = 12  # Same as a.marker='diamond_fill'
    support.check_plot(x)
    a.marker = 13  # Same as a.marker='triangle_up_fill'
    support.check_plot(x)
    a.marker = 14  # Same as a.marker='triangle_down_fill'
    support.check_plot(x)
    a.marker = 15  # Same as a.marker='triangle_left_fill'
    support.check_plot(x)
    a.marker = 16  # Same as a.marker='triangle_right_fill'
    support.check_plot(x)
    a.marker = 17  # Same as a.marker='square_fill'
    support.check_plot(x)
    a.marker = None  # Draw no markers
    support.check_plot(x)

    ############################################################################
    # Change the xyvsy marker color                                            #
    ############################################################################
    a.marker = "dot"
    support.check_plot(x)
    a.markercolor = 16
    support.check_plot(x)
    a.markercolor = 44  # same as a.markercolor=(44)
    support.check_plot(x)
    a.markercolor = None
    support.check_plot(x)

    ############################################################################
    # Change the xyvsy marker size                                             #
    ############################################################################
    a.markersize = 5
    support.check_plot(x)
    a.markersize = 55
    support.check_plot(x)
    a.markersize = 10
    support.check_plot(x)
    a.markersize = 100
    support.check_plot(x)
    a.markersize = 300
    support.check_plot(x)
    a.markersize = None
    support.check_plot(x)

    x.clear()  # clear the VCS Canvas
    x.xyvsy(u, a, "default", bg=bg)  # plot xyvsy using 'default' template
    support.check_plot(x)

    objs = x.listelements("template")  # get the list of templates
    t = x.createtemplate("test")  # create template 'test' from 'default' template
    if not vcs_legacy.istemplate(t):  # test whether 't' is a template or not
        raise Exception, "Error template not created"
    else:
        a2 = x.listelements("template")  # get the list of templates
        if objs == a2:
            raise Exception, "Error template not created or added to list"

    x.clear()  # clear the VCS Canvas
    x.plot(t, a, u, bg=bg)  # plot xyvsy template 't', outline 'a', and arrays 'u':'v'
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.xyvsy(a, u, t, bg=bg)  # plot using outline 'a', array 'u':'v', and template 't'
    support.check_plot(x)

    objs = x.listelements("line")  # show the list of line secondary objects
    l = x.getline("red")  # get line 'red'
    if not vcs_legacy.issecondaryobject(l):  # check to see if it is a secondary object
        raise Exception, "Error did not get line"
    else:
        if not vcs_legacy.isline(l):  # check to see if it is a line
            raise Exception, "Error object created is not line"

    ###########################################################################
    # Use the create line object 'm' from above and modify the line object    #
    ###########################################################################
    a.line = l  # use the line object
    l.color = 44  # change the line color
    support.check_plot(x)
    l.type = "dot"  # change the line type
    support.check_plot(x)
    l.width = 4  # change the line size
    support.check_plot(x)

    objs = x.listelements("marker")  # show the list of marker secondary objects
    m = x.getmarker("red")  # get marker 'red'
    if not vcs_legacy.issecondaryobject(m):  # check to see if it is a secondary object
        raise Exception, "Error did not get marker"
    else:
        if not vcs_legacy.ismarker(m):  # check to see if it is a line
            raise Exception, "Error object created is not marker"

    ###########################################################################
    # Use the create marker object 'm' from above and modify the line object  #
    ###########################################################################
    a.marker = m  # use the marker object
    support.check_plot(x)
    m.color = 44  # change the marker color
    support.check_plot(x)
    m.type = "square"  # change the marker type
    support.check_plot(x)
    m.size = 20  # change the marker size
    support.check_plot(x)

    a = x.listelements("xyvsy")  # show list of xyvsy
    r = x.createxyvsy("test2", "ASD1")  # create xyvsy 'test2'
    a2 = x.listelements("xyvsy")  # show list of xyvsy
    if a2 == a:
        raise "error gm not created or not added to list"
    x.removeobject(r)  # remove xyvsy 'test2'
    a3 = x.listelements("xyvsy")  # show list of xyvsy
    if a3 != a:
        raise "error gm not removed"

    #################################################################################
    # to see how x.update and x.mode work, see testoutline.py                       #
    #################################################################################
    # x.update()
    # x.mode=1
    # x.mode=0
    print "*************************************************************************************"
    print "******                                                                         ******"
    print "******   X y v s y   T E S T   C O M P L E T E D   S U C E S S F U L L Y       ******"
    print "******                                                                         ******"
    print "*************************************************************************************"
Пример #24
0
def test():
   import vcs_legacy,cdms2,time,os,sys,support                # import vcs_legacy and cu
   bg=support.bg
   f=cdms2.open(os.path.join(cdms2.__path__[0],'..','..','..','..','sample_data','clt.nc'))
   u=f('u')                             # get slab u
   v=f('v')                             # get slab v
   x=vcs_legacy.init()                         # construct vcs_legacy canvas
   
   x.plot(u, v, 'default','scatter','quick',bg=bg)	# plot slab the old way
   support.check_plot(x)
   if bg==0:
      x.mode=1
      x.geometry(450,337,100,0)		# change the geometry and location
      x.flush()
      support.check_plot(x)

   
   a=x.getscatter('quick')		# get 'quick' scatter
   if not vcs_legacy.isgraphicsmethod(a):            # test object 'a' for graphics method
      raise Exception, "Error did not retrieve the gm"
   else:
      if not vcs_legacy.isscatter(a):                # test object 'a' if scatter
         raise Exception, "Error gm is not right type"
   
   a.script('test','w')                 # save 'quick' scatter as a Python script
   
   print 'yepp'
   a.xticlabels('','')                  # remove the x-axis
   support.check_plot(x)
   a.xticlabels('*')                    # put the x-axis
   support.check_plot(x)
   
   ############################################################################
   # Change the scatter marker type                                           #
   ############################################################################
   #a.marker=0
   a.marker=1				# same as a.marker='dot'
   support.check_plot(x)
   a.marker=2				# same as a.marker='plus'
   support.check_plot(x)
   a.marker=3				# same as a.marker='star'
   support.check_plot(x)
   a.marker=4				# same as a.marker='circle'
   support.check_plot(x)
   a.marker=5				# same as a.marker='cross'
   support.check_plot(x)
   a.marker=6				# same as a.marker='diamond'
   support.check_plot(x)
   a.marker=7				# same as a.marker='triangle_up'
   support.check_plot(x)
   a.marker=8				# same as a.marker='triangle_down'
   support.check_plot(x)
   a.marker=9				# same as a.marker='triangle_left'
   support.check_plot(x)
   a.marker=10				# same as a.marker='triangle_right'
   support.check_plot(x)
   a.marker=11				# same as a.marker='square'
   support.check_plot(x)
   a.marker=12				# same as a.marker='diamond_fill'
   support.check_plot(x)
   a.marker=13				# same as a.marker='triangle_up_fill'
   support.check_plot(x)
   a.marker=14				# same as a.marker='triangle_down_fill'
   support.check_plot(x)
   a.marker=15				# same as a.marker='triangle_left_fill'
   support.check_plot(x)
   a.marker=16				# same as a.marker='triangle_right_fill'
   support.check_plot(x)
   a.marker=17				# same as a.marker='square_fill'
   support.check_plot(x)
   
   ############################################################################
   # Change the scatter marker size                                           #
   ############################################################################
   a.markersize=5
   support.check_plot(x)
   a.markersize=55
   support.check_plot(x)
   a.markersize=100
   support.check_plot(x)
   a.markersize=300
   support.check_plot(x)
   a.markersize=15
   support.check_plot(x)
   
   ############################################################################
   # Change the scatter marker color                                          #
   ############################################################################
   a.markercolor=(77)
   support.check_plot(x)
   a.markercolor=16
   support.check_plot(x)
   a.markercolor=44			# same as a.markercolor=(44)
   support.check_plot(x)
   
   ############################################################################
   # Change the scatter settings to default                                   #
   ############################################################################
   a.markercolor=None
   support.check_plot(x)
   a.markersize=None
   support.check_plot(x)
   a.marker=None
   support.check_plot(x)
   
   a.marker=1                           # same as a.marker='dot'
   support.check_plot(x)
   
   x.clear()                            # clear the VCS Canvas
   x.scatter(u, v, a,'default',bg=bg)		# plot scatter using 'default' template
   support.check_plot(x)
   
   t=x.createtemplate('test')           # create template 'test' from 'default' template
   
   x.clear()                            # clear the VCS Canvas
   x.plot(t,a,u,v,bg=bg)                      # plot scatter template 't', outline 'a', and arrays 'u':'v'
   support.check_plot(x)
   x.clear()                            # clear the VCS Canvas
   x.scatter(a,u,v,t,bg=bg)                   # plot using outline 'a', array 'u':'v', and template 't'
   support.check_plot(x)
   
   m=x.getmarker('red')                	# get marker 'red'
   if vcs_legacy.issecondaryobject(m):           # check to see if it is a secondary object
      if not vcs_legacy.ismarker(m):                 # check to see if it is a fill area
         raise Exception, "Error: this is not a marker object."
   else:
      raise Exception, "Error: this is not a sceondary object."
   
   ###########################################################################
   # Use the create marker object 'm' from above and modify the line object  #
   ###########################################################################
   a.marker=m                           # use the marker object
   support.check_plot(x)
   m.color = 44                         # change the marker color
   support.check_plot(x)
   m.type ='square'                     # change the marker type
   support.check_plot(x)
   m.size=20				# change the marker size
   support.check_plot(x)
   
   e = x.listelements('scatter')         # show list of scatter
   r=x.createscatter('test2','quick')   # create scatter 'test2'
   e2 = x.listelements('scatter')         # show list of scatter
   if e2==e:
      raise Exception,"Error new scatter does not appear in list"
   e3=list(e)
   e3.append("test2")
   e3.sort()
   if e3!=e2:
      raise "Error new scatter created but not matching old list of scatter"
   x.removeobject(r)                    # remove scatter 'test2'
   e4 = x.listelements('scatter')         # show list of scatter
   if e4!=e:
      raise Exception,"Error method not removed"
   
   #################################################################################
   # to see how x.update and x.mode work, see testoutline.py                       #
   #################################################################################
   #x.update()
   #x.mode=1
   #x.mode=0
   print '*************************************************************************************'
   print '******                                                                         ******'
   print '******   S C A T T E R   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
   print '******                                                                         ******'
   print '*************************************************************************************'
Пример #25
0
def test():
   import vcs_legacy,cdms2 as cdms,time,os,sys,support          # import vcs_legacy and cdms

   bg=support.bg

   f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','clt.nc')) # open clt file
   u=f('u')  			        # get slab u
   x=vcs_legacy.init()                         # construct vcs_legacy canvas
   
   x.plot(u, 'default','yxvsx','ASD7',bg=bg)	# plot slab the old way
   support.check_plot(x)
   if support.dogui:
      x.geometry(450,337,100,0)		# change the geometry and location
      x.flush()
      support.check_plot(x)
   
   a=x.getyxvsx('ASD7')		    	# get 'ASD7' yxvsx
   if not vcs_legacy.isgraphicsmethod(a):            # test object 'a' for graphics method
      raise Exception, "Error not a gm"
   else:
      if not vcs_legacy.isyxvsx(a):                  # test object 'a' if yxvsx
         raise Exception,"Error wrong type of gm"
   
   a.script('test','w')                 # save 'ASD7' yxvsx as a Python script
   
   a.xticlabels('','')                  # remove the x-axis
   support.check_plot(x)
   a.xticlabels('*')                    # put the x-axis
   support.check_plot(x)
   
   ############################################################################
   # Change the yxvsx line                                                    #
   ############################################################################
   a.line=0        			# same as 'solid'
   support.check_plot(x)
   a.line=1        			# same as 'dash'
   support.check_plot(x)
   a.line=2        			# same as 'dot'
   support.check_plot(x)
   a.line=3        			# same as 'dash-dot'
   support.check_plot(x)
   a.line=4        			# same as 'long-dash'
   support.check_plot(x)

 
   if not '--extended' in sys.argv:
     print '\n************* PARTIAL TEST *****************'
     print 'FOR COMPLETE TEST OF THIS MODULE USE '
     print '   -F (--full) or -E (--extended) option'
     print '************* PARTIAL TEST *****************\n'
     sys.exit()


   
   ############################################################################
   # Change the yxvsx line color                                              #
   ############################################################################
   a.linecolor=(77)
   support.check_plot(x)
   a.linecolor=16
   support.check_plot(x)
   a.linecolor=44  			# same as a.color=(44)
   support.check_plot(x)
   a.linecolor=None
   support.check_plot(x)
   
   ############################################################################
   # Change the yxvsx marker                                                  #
   ############################################################################
   a.marker=1                        	# Same as a.marker='dot'
   support.check_plot(x)
   a.marker=2                       	# Same as a.marker='plus'
   support.check_plot(x)
   a.marker=3                       	# Same as a.marker='star'
   support.check_plot(x)
   a.marker=4                       	# Same as a.marker='circle'
   support.check_plot(x)
   a.marker=5                        	# Same as a.marker='cross'
   support.check_plot(x)
   a.marker=6                        	# Same as a.marker='diamond'
   support.check_plot(x)
   a.marker=7                        	# Same as a.marker='triangle_up'
   support.check_plot(x)
   a.marker=8                        	# Same as a.marker='triangle_down'
   support.check_plot(x)
   a.marker=9                        	# Same as a.marker='triangle_left'
   support.check_plot(x)
   a.marker=10                       	# Same as a.marker='triangle_right'
   support.check_plot(x)
   a.marker=11                       	# Same as a.marker='square'
   support.check_plot(x)
   a.marker=12                       	# Same as a.marker='diamond_fill'
   support.check_plot(x)
   a.marker=13                       	# Same as a.marker='triangle_up_fill'
   support.check_plot(x)
   a.marker=14                       	# Same as a.marker='triangle_down_fill'
   support.check_plot(x)
   a.marker=15                       	# Same as a.marker='triangle_left_fill'
   support.check_plot(x)
   a.marker=16                      	# Same as a.marker='triangle_right_fill'
   support.check_plot(x)
   a.marker=17                       	# Same as a.marker='square_fill'
   support.check_plot(x)
   a.marker=None                     	# Draw no markers
   support.check_plot(x)
   
   ############################################################################
   # Change the yxvsx marker color                                            #
   ############################################################################
   a.marker='dot'
   support.check_plot(x)
   a.markercolor=16
   support.check_plot(x)
   a.markercolor=44        		# same as a.markercolor=(44)
   support.check_plot(x)
   a.markercolor=None
   support.check_plot(x)
   
   ############################################################################
   # Change the yxvsx marker size                                             #
   ############################################################################
   a.markersize=5
   support.check_plot(x)
   a.markersize=55
   support.check_plot(x)
   a.markersize=10
   support.check_plot(x)
   a.markersize=100
   support.check_plot(x)
   a.markersize=300
   support.check_plot(x)
   a.markersize=None
   support.check_plot(x)
   
   x.clear()                            # clear the VCS Canvas
   x.yxvsx(u, a,'default',bg=bg)		# plot yxvsx using 'default' template
   support.check_plot(x)
   
   objs = x.listelements('template')                   # show the list of templates
   t=x.createtemplate('test')           # create template 'test' from 'default' template
   if not vcs_legacy.istemplate(t):                  # test whether 't' is a template or not
      raise Exception,"Error creating tmeplate"
   
   x.clear()                            # clear the VCS Canvas
   x.plot(t,a,u,bg=bg)                        # plot yxvsx template 't', outline 'a', and arrays 'u':'v'
   support.check_plot(x)
   x.clear()                            # clear the VCS Canvas
   x.yxvsx(a,u,t,bg=bg)                       # plot using outline 'a', array 'u':'v', and template 't'
   support.check_plot(x)
   
   objs = x.listelements('line')                      	# show the list of line secondary objects
   l=x.getline('red')                	# get line 'red'
   if not vcs_legacy.issecondaryobject(l):           # check to see if it is a secondary object
      raise Exception,"Error did not get line"
   else:
      if not vcs_legacy.isline(l):                  	# check to see if it is a line
         raise Exception, "Error object created is not line"
   
   ###########################################################################
   # Use the create line object 'm' from above and modify the line object    #
   ###########################################################################
   a.line=l                             # use the line object
   support.check_plot(x)
   l.color = 44                         # change the line color
   support.check_plot(x)
   l.type ='dot'                       # change the line type
   support.check_plot(x)
   l.width=4 				# change the line size
   support.check_plot(x)
   
   objs = x.listelements('marker')                     # show the list of marker secondary objects
   m=x.getmarker('red')                 # get marker 'red'
   if not vcs_legacy.issecondaryobject(m):           # check to see if it is a secondary object
      raise Exception,"Error did not get marker"
   else:
      if not vcs_legacy.ismarker(m):                  	# check to see if it is a line
         raise Exception, "Error object created is not marker"
   
   ###########################################################################
   # Use the create marker object 'm' from above and modify the line object  #
   ###########################################################################
   a.marker=m                           # use the marker object
   support.check_plot(x)
   m.color = 44                         # change the marker color
   support.check_plot(x)
   m.type ='square'                     # change the marker type
   support.check_plot(x)
   m.size=20                            # change the marker size
   support.check_plot(x)
   
   a = x.listelements('yxvsx')                      # show list of xyvsy
   r=x.createyxvsx('test2','ASD1')     # create xyvsy 'test2'
   a2 = x.listelements('yxvsx')                      # show list of xyvsy
   if a2==a:
      raise "error gm not created or not added to list"
   x.removeobject(r)                    # remove xyvsy 'test2'
   a3 = x.listelements('yxvsx')                      # show list of xyvsy
   if a3!=a:
      raise "error gm not removed"
   
   #################################################################################
   # to see how x.update and x.mode work, see testoutline.py                       #
   #################################################################################
   #x.update()
   #x.mode=1
   #x.mode=0
   print '*************************************************************************************'
   print '******                                                                         ******'
   print '******   Y x v s x   T E S T   C O M P L E T E D   S U C E S S F U L L Y       ******'
   print '******                                                                         ******'
   print '*************************************************************************************'
Пример #26
0
def test():
   import vcs_legacy,cdms2 as cdms,time,os,sys,support                 # import vcs_legacy and cu

   bg=support.bg
   
   f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','clt.nc'))
   s=f('clt')                           # get slab clt
   x=vcs_legacy.init()                         # construct vcs_legacy canvas

   x.plot(s,'default','isofill','quick',bg=bg)# plot slab the old way
   support.check_plot(x)
   if bg==0:
      x.geometry(450,337,0,0)              # change the geometry
      x.flush()
      support.check_plot(x)
   x.getcolormapname()			# get the active colormap name

   x.setcolormap("AMIP")		# change the colormap
   support.check_plot(x)


   cont = False
   for anarg in sys.argv:
      if anarg in ['--extended', '--full','-E','-F']:
         cont = True
         break
   if cont is False:
     print '\n************* PARTIAL TEST *****************'
     print 'FOR COMPLETE TEST OF THIS MODULE USE '
     print '   -F (--full) or -E (--extended) option'
     print '************* PARTIAL TEST *****************\n'
     sys.exit()


   ############################################################
   # Change the color map cell 31.			      #
   ############################################################
   colors = {}
   cols = [31,47,63,79,95,111,127,143,159,175,191]
   for c in cols:
      colors[c]=[int(float(c-16)/(191-16)*100.),]*3
   for c in cols:
      vals=colors[c]
      x.setcolorcell(c,vals[0],vals[1],vals[2])
      support.check_plot(x)
         
   for c in colors.keys():
      okvals=colors[c]
      vals = x.getcolorcell(c)
      if vals!=okvals:
         raise Exception,"Error setting color %i, should have been : %s, but is %s" % (c,str(okvals),str(vals))
   
   ##################################################################
   # Retrieve the color map RGB values for the given cell numbers.  #
   ##################################################################

   ##################################################################
   # Using colormap objects.                                        #  
   ##################################################################
   objs = x.listelements('colormap')                      	# show the list of line secondary objects
   c2=x.getcolormap()             	# get 'default' colormap object
   c=x.getcolormap('AMIP')             # get 'quick' colormap object
   if not vcs_legacy.issecondaryobject(c):           # check to see if it is a secondary object
      raise Exception,"Error did not get colormap as secondary obj"
   else:
      if not vcs_legacy.iscolormap(c):                  	# check to see if it is a line
         raise Exception, "Error object created is not colormap"

   a = x.listelements('colormap')                      # show list of xyvsy
   r=x.createcolormap('new')     # create colormap
   a2 = x.listelements('colormap')                      # show list of xyvsy
   if a2==a:
      raise "error cm not created or not added to list"
   x.removeobject(r)                    # remove xyvsy 'test2'
   a3 = x.listelements('colormap')                      # show list of xyvsy
   if a3!=a:
      raise Exception,"error cm not removed"
   c3=x.createcolormap('new')		# create a new colormap object from default
   x.setcolormap('new')			# change the colormap to 'new' colormap
   c3.index				# show just the colormap RGB values
   for c in colors.keys():
      vals=colors[c]
      c3.index[c]=vals                  # change color cell
      
   for c in colors.keys():
      okvals=colors[c]
      vals = x.getcolorcell(c)
      if vals!=okvals:
         raise Exception,"Error setting color %i, should have been : %s, but is %s" % (c,str(okvals),str(vals))
   
   c3.script('test.scr','w')		# save 'new' colormap as a VCS script
   c3.script('test','w')		# save 'new' colormap as a Python script
   if support.dogui is True:
      x.colormapgui()			# display the colormap GUI



   print '***************************************************************************************'
   print '******                                                                           ******'
   print '******   C O L O R M A P   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
   print '******                                                                           ******'
   print '***************************************************************************************'
Пример #27
0
def test():
   import vcs_legacy,time,support,sys,os                      # import vcs_legacy and cu
   bg=support.bg
   
   x=vcs_legacy.init()                         # construct vcs_legacy canvas
   
   x.plot('default','continents','ASD',bg=bg)# plot slab the old way
   support.check_plot(x)
   if bg==0:
      x.geometry(450,337,100,0)            # change the geometry and location
      x.flush()
      support.check_plot(x)
      
   
   
   obj = x.listelements('continents')                 # show list of continents
   a=x.createcontinents('quick')         	# get 'quick' continents
   if not vcs_legacy.isgraphicsmethod(a):            # test object 'a' for graphics method
      raise Exception, "Error not a gm"
   else:
      if not vcs_legacy.iscontinents(a):             # test object 'a' if continents
         raise Exception,"Error wrong type of gm"
   x.clear()
   x.plot(a,bg=bg)
   support.check_plot(x)
   
   a.script('test','w')                 # save 'quick' continents as a Python script
   
   a.xticlabels('','')                  # remove the x-axis
   support.check_plot(x)
   a.xticlabels('lon30','lon30')        # change the x-axis
   support.check_plot(x)
   a.xticlabels('*')                    # put the x-axis
   support.check_plot(x)
   a.datawc(-45.0, 45.0, -90.0, 90.0)   # change the region
   support.check_plot(x)
   a.datawc(1e20,1e20,1e20,1e20)        # put the region back
   support.check_plot(x)
   

   if not '--extended' in sys.argv:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()


  
   a.line=1                             # same as 'dash', change the line style
   support.check_plot(x)
   a.line=2                             # same as 'dot', change the line style
   support.check_plot(x)
   a.line=3                             # same as 'dash-dot', change the line style
   support.check_plot(x)
   a.line=0                             # same as 'solid', change the line style
   support.check_plot(x)
   a.line=4                             # same as 'long-dash', change the line style
   support.check_plot(x)
   a.linecolor=(77)                     # change the line color
   support.check_plot(x)
   a.linecolor=16                       # change the line color
   support.check_plot(x)
   a.linecolor=44                       # same as a.linecolor=(44)
   support.check_plot(x)
   a.linecolor=None                     # use the default line color, black
   support.check_plot(x)
   a.line=None                          # use default line style, solid black line
   support.check_plot(x)
   
   x.clear()                            # clear the VCS Canvas
   x.continents(a,'default',bg=bg)            # plot continents using 'default' template
   support.check_plot(x)
   
   objs =x.listelements('template')                   # get the list of templates
   t=x.createtemplate('test')           # create template 'test' from 'default' template
   if not vcs_legacy.istemplate(t):                  # test whether 't' is a template or not
      raise Exception,"Error template not created"
   else:
      a2 =x.listelements('template')                   # get the list of templates
      if objs==a2:
         raise Exception,"Error template not created or added to list"
   
   x.clear()                            # clear the VCS Canvas
   x.plot(t,a,bg=bg)                          # plot continents using template 't', and continents 'a'
   support.check_plot(x)
   x.clear()                            # clear the VCS Canvas
   x.continents(a,t,bg=bg)			# plot continents
   support.check_plot(x)
 
   #########################################################################
   # Create line object 'l' from the default line                          #
   #########################################################################
   objs = x.listelements('line')                      	# show the list of line secondary objects
   l=x.getline('red')                	# get line 'red'
   if not vcs_legacy.issecondaryobject(l):           # check to see if it is a secondary object
      raise Exception,"Error did not get line"
   else:
      if not vcs_legacy.isline(l):                  	# check to see if it is a line
         raise Exception, "Error object created is not line"
   
   #########################################################################
   # Use the create line object 'l' from above and modify the line object  #
   #########################################################################
   a.line=l                             # use the line object
   support.check_plot(x)
   l.color = 44                         # change the line color
   support.check_plot(x)
   l.type ='dash'                       # change the line type
   support.check_plot(x)
   
   a = x.listelements('continents')                      # show list of xyvsy
   r=x.createcontinents('test2','quick')     # create xyvsy 'test2'
   a2 = x.listelements('continents')                      # show list of xyvsy
   if a2==a:
      raise "error gm not created or not added to list"
##    x.removeobject(r)                    # remove xyvsy 'test2'
##    a3 = x.listelements('continents')                      # show list of xyvsy
##    if a3!=a:
##       raise "error gm not removed"

   a=x.getcontinents('quick')           # get 'quick' boxfill graphics method
   x.clear()
   x.plot(a,bg=bg)
   support.check_plot(x)
   if support.dogui:
      x.graphicsmethodgui('continents','quick')  # display the continents graphics method GUI

   #################################################################################
   # to see how x.update and x.mode work, see testoutline.py                       #
   #################################################################################
   #x.update()
   #x.mode=1
   #x.mode=0

   print '*******************************************************************************************'
   print '******                                                                               ******'
   print '******   C O N T I N E N T S   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
   print '******                                                                               ******'
   print '*******************************************************************************************'
Пример #28
0
def test():
    import vcs_legacy, cdms2 as cdms, time, os, sys, support  # import vcs_legacy and cdms

    bg = support.bg

    f = cdms.open(
        os.path.join(cdms.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'clt.nc'))
    s = f('clt')  # get slab clt
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    x.plot(s, 'default', 'isofill', 'quick', bg=bg)  # plot slab the old way
    support.check_plot(x)

    # Check the legend
    g = x.createisofill('vcs_legacymoduletest')
    x.clear()  # clear the VCS Canvas
    x.plot(s, g, bg=bg)  # plot slab the new way
    support.check_plot(x)
    g.legend = (10, 30, 70, 120)
    support.check_plot(x)
    g.legend = {0: 'test string1', 50: 'test string2', 100: 'test string3'}
    support.check_plot(x)
    g.legend = None
    support.check_plot(x)

    if bg == 0:
        x.geometry(450, 337, 100, 0)  # change the geometry and location
        x.flush()
        support.check_plot(x)

    # open and plot a missing data with isofill
    f = cdms.open(
        os.path.join(cdms.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'tas_cru_1979.nc'))
    s = f('tas', longitude=(-180, 180), latitude=(-90, 90)) + 273.15
    x.clear()  # clear the VCS Canvas
    x.plot(s, 'default', 'isofill', 'quick',
           bg=bg)  # plot missing value slabe the old way
    support.check_plot(x)

    a = x.getisofill('quick')  # get 'quick' isofill graphics method
    if not vcs_legacy.isgraphicsmethod(
            a):  # test object 'a' for graphics method
        raise Exception, "Error did not retrieve the gm"
    else:
        if not vcs_legacy.isisofill(a):  # check for isofill
            raise Exception, "Error gm is not right type"

    a.script('test', 'w')  # save 'quick' isofill as a Python script

    x.setcolormap("AMIP")  # change the colormap from default to AMIP

    a.missing = 241  # change the missing background color to black
    support.check_plot(x)

    if not '--extended' in sys.argv:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()

    a.xticlabels('lon30', 'lon30')  # change the x-axis
    support.check_plot(x)
    a.xticlabels('', '')  # remove the x-axis
    support.check_plot(x)
    a.xticlabels('*')  # put the x-axis
    support.check_plot(x)
    a.datawc(-45.0, 45.0, -90.0, 90.0)  # change the region
    support.check_plot(x)
    a.datawc(1e20, 1e20, 1e20, 1e20)  # put the region back
    support.check_plot(x)

    a.levels = ([0, 220], [230, 240], [250, 260])  # change the isofill levels
    support.check_plot(x)
    a.levels = ([0, 220, 225, 230, 235,
                 240], [230, 240], [250, 260])  # change the isofill levels
    support.check_plot(x)
    a.levels = ([0, 220, 225, 230, 235, 240], )  # change the isofill levels
    support.check_plot(x)
    a.levels = ([0, 220, 225, 230, 235, 240, 245,
                 250])  # change the isofill levels
    support.check_plot(x)
    a.levels = [0, 220, 225, 230, 235, 240]  # change the isofill levels
    support.check_plot(x)
    a.levels = (0.0, 220.0, 225.0, 230.0, 235.0, 240.0, 250.0
                )  # change the isofill levels
    support.check_plot(x)
    a.levels = ([1e20], )  # change back to default settings
    support.check_plot(x)
    a.levels = (0, 220, 225, 230, 235, 240, 250, 260, 270
                )  # change the isofill levels
    support.check_plot(x)

    #########################################################################################
    # Below will produce an error. Later, if needed, I will add this functionality.	   #
    #a.levels=('0','20','25','30')			# this will produce an error	   #
    #########################################################################################

    a.ext_1 = 'y'  # add the extended legend arrow to the left
    support.check_plot(x)
    a.ext_1 = 'n'  # remove the extended legend arrow to the left
    support.check_plot(x)
    a.ext_2 = 'y'  # add the extended legend arrow to the right
    support.check_plot(x)
    a.ext_2 = 'n'  # remove the extended legend arrow to the right
    support.check_plot(x)
    a.exts('y', 'y')  # add the extended legend arrow to left and right
    support.check_plot(x)
    a.exts('n', 'n')  # remove the extended legend arrow to left and right
    support.check_plot(x)

    a.fillareastyle = 'pattern'  # change the fill style to pattern
    support.check_plot(x)
    a.fillareastyle = 'hatch'  # change the fill style to hatch
    support.check_plot(x)
    a.fillareaindices = ([1, 3, 5, 6, 9, 18])  # set the hatch index patterns
    support.check_plot(x)

    a.fillareacolors = ([22, 33, 44, 55, 66,
                         77])  # set the fill area color indices
    support.check_plot(x)
    a.fillareacolors = None  # use default color indices
    support.check_plot(x)
    a.fillareastyle = 'solid'  # change the fill style back to solid
    support.check_plot(x)

    x.clear()  # clear the VCS Canvas
    x.plot(s, a, 'default', bg=bg)  # plot isofill using 'default' template
    support.check_plot(x)

    objs = x.listelements('template')  # get the list of templates
    t = x.createtemplate(
        'test')  # create template 'test' from 'default' template
    if not vcs_legacy.istemplate(t):  # test whether 't' is a template or not
        raise Exception, "Error template not created"
    else:
        a2 = x.listelements('template')  # get the list of templates
        if objs == a2:
            raise Exception, "Error template not created or added to list"

    objs = x.listelements(
        'fillarea')  # show the list of fillarea secondary objects
    f = x.getfillarea('AuTo_1')  # get fillarea 'red'
    if not vcs_legacy.issecondaryobject(
            f):  # check to see if it is a secondary object
        raise Exception, "Error did not get fillarea"
    else:
        if not vcs_legacy.isfillarea(f):  # check to see if it is a fillarea
            raise Exception, "Error object created is not fillarea"

    a.levels = (220, 225, 230, 235, 240, 250, 260, 270, 280, 290, 300, 310
                )  # change the isofill levels
    x.clear()  # clear the VCS Canvas
    x.plot(a, t, s, bg=bg)  # plot array using isofill 'a' and template 't'
    support.check_plot(x)
    a.fillareaindices = (3, 4, 7, 9, 11)  # set the indices
    support.check_plot(x)
    a.fillareaindices = (f, f, f, f, f, f
                         )  # set the indices using the fillarea object
    support.check_plot(x)
    a.fillareaindices = (f, 2, 4, 7
                         )  # reset the indices using the fillarea object
    support.check_plot(x)
    a.fillareaindices = (7, f, f, f, 8
                         )  # resett the indices using the fillare object
    support.check_plot(x)

    f.color = 44  # change the fillarea object's color
    support.check_plot(x)
    f.style = 'hatch'  # change the fillarea object's fill style
    support.check_plot(x)

    x.scriptobject(a, 'test')  # save 'quick' isofill as a Python script
    x.scriptobject(f, 'test')  # save 'def37' fill area as a Python script

    a = x.listelements('isofill')  # show list of gm
    r = x.createisofill('test2', 'quick')  # create xyvsy 'test2'
    a2 = x.listelements('isofill')  # show list of gm
    if a2 == a:
        raise "error gm not created or not added to list"
    x.removeobject(r)  # remove xyvsy 'test2'
    a3 = x.listelements('isofill')  # show list of gm
    if a3 != a:
        raise "error gm not removed"

    #################################################################################
    # to see how x.update and x.mode work, see testisofill.py			   #
    #################################################################################
    #x.update()
    #x.mode=1
    #x.mode=0
    print '*************************************************************************************'
    print '******                                                                         ******'
    print '******   I S O F I L L   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
    print '******                                                                         ******'
    print '*************************************************************************************'
Пример #29
0
def test():
    import vcs_legacy, cdms2, time, os, sys, support  # import vcs_legacy and cu
    bg = support.bg
    f = cdms2.open(
        os.path.join(cdms2.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'clt.nc'))
    u = f('u')  # get slab u
    v = f('v')  # get slab v
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    x.plot(u, v, 'default', 'scatter', 'quick', bg=bg)  # plot slab the old way
    support.check_plot(x)
    if bg == 0:
        x.mode = 1
        x.geometry(450, 337, 100, 0)  # change the geometry and location
        x.flush()
        support.check_plot(x)

    a = x.getscatter('quick')  # get 'quick' scatter
    if not vcs_legacy.isgraphicsmethod(
            a):  # test object 'a' for graphics method
        raise Exception, "Error did not retrieve the gm"
    else:
        if not vcs_legacy.isscatter(a):  # test object 'a' if scatter
            raise Exception, "Error gm is not right type"

    a.script('test', 'w')  # save 'quick' scatter as a Python script

    print 'yepp'
    a.xticlabels('', '')  # remove the x-axis
    support.check_plot(x)
    a.xticlabels('*')  # put the x-axis
    support.check_plot(x)

    ############################################################################
    # Change the scatter marker type                                           #
    ############################################################################
    #a.marker=0
    a.marker = 1  # same as a.marker='dot'
    support.check_plot(x)
    a.marker = 2  # same as a.marker='plus'
    support.check_plot(x)
    a.marker = 3  # same as a.marker='star'
    support.check_plot(x)
    a.marker = 4  # same as a.marker='circle'
    support.check_plot(x)
    a.marker = 5  # same as a.marker='cross'
    support.check_plot(x)
    a.marker = 6  # same as a.marker='diamond'
    support.check_plot(x)
    a.marker = 7  # same as a.marker='triangle_up'
    support.check_plot(x)
    a.marker = 8  # same as a.marker='triangle_down'
    support.check_plot(x)
    a.marker = 9  # same as a.marker='triangle_left'
    support.check_plot(x)
    a.marker = 10  # same as a.marker='triangle_right'
    support.check_plot(x)
    a.marker = 11  # same as a.marker='square'
    support.check_plot(x)
    a.marker = 12  # same as a.marker='diamond_fill'
    support.check_plot(x)
    a.marker = 13  # same as a.marker='triangle_up_fill'
    support.check_plot(x)
    a.marker = 14  # same as a.marker='triangle_down_fill'
    support.check_plot(x)
    a.marker = 15  # same as a.marker='triangle_left_fill'
    support.check_plot(x)
    a.marker = 16  # same as a.marker='triangle_right_fill'
    support.check_plot(x)
    a.marker = 17  # same as a.marker='square_fill'
    support.check_plot(x)

    ############################################################################
    # Change the scatter marker size                                           #
    ############################################################################
    a.markersize = 5
    support.check_plot(x)
    a.markersize = 55
    support.check_plot(x)
    a.markersize = 100
    support.check_plot(x)
    a.markersize = 300
    support.check_plot(x)
    a.markersize = 15
    support.check_plot(x)

    ############################################################################
    # Change the scatter marker color                                          #
    ############################################################################
    a.markercolor = (77)
    support.check_plot(x)
    a.markercolor = 16
    support.check_plot(x)
    a.markercolor = 44  # same as a.markercolor=(44)
    support.check_plot(x)

    ############################################################################
    # Change the scatter settings to default                                   #
    ############################################################################
    a.markercolor = None
    support.check_plot(x)
    a.markersize = None
    support.check_plot(x)
    a.marker = None
    support.check_plot(x)

    a.marker = 1  # same as a.marker='dot'
    support.check_plot(x)

    x.clear()  # clear the VCS Canvas
    x.scatter(u, v, a, 'default',
              bg=bg)  # plot scatter using 'default' template
    support.check_plot(x)

    t = x.createtemplate(
        'test')  # create template 'test' from 'default' template

    x.clear()  # clear the VCS Canvas
    x.plot(t, a, u, v,
           bg=bg)  # plot scatter template 't', outline 'a', and arrays 'u':'v'
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.scatter(a, u, v, t,
              bg=bg)  # plot using outline 'a', array 'u':'v', and template 't'
    support.check_plot(x)

    m = x.getmarker('red')  # get marker 'red'
    if vcs_legacy.issecondaryobject(
            m):  # check to see if it is a secondary object
        if not vcs_legacy.ismarker(m):  # check to see if it is a fill area
            raise Exception, "Error: this is not a marker object."
    else:
        raise Exception, "Error: this is not a sceondary object."

    ###########################################################################
    # Use the create marker object 'm' from above and modify the line object  #
    ###########################################################################
    a.marker = m  # use the marker object
    support.check_plot(x)
    m.color = 44  # change the marker color
    support.check_plot(x)
    m.type = 'square'  # change the marker type
    support.check_plot(x)
    m.size = 20  # change the marker size
    support.check_plot(x)

    e = x.listelements('scatter')  # show list of scatter
    r = x.createscatter('test2', 'quick')  # create scatter 'test2'
    e2 = x.listelements('scatter')  # show list of scatter
    if e2 == e:
        raise Exception, "Error new scatter does not appear in list"
    e3 = list(e)
    e3.append("test2")
    e3.sort()
    if e3 != e2:
        raise "Error new scatter created but not matching old list of scatter"
    x.removeobject(r)  # remove scatter 'test2'
    e4 = x.listelements('scatter')  # show list of scatter
    if e4 != e:
        raise Exception, "Error method not removed"

    #################################################################################
    # to see how x.update and x.mode work, see testoutline.py                       #
    #################################################################################
    #x.update()
    #x.mode=1
    #x.mode=0
    print '*************************************************************************************'
    print '******                                                                         ******'
    print '******   S C A T T E R   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
    print '******                                                                         ******'
    print '*************************************************************************************'
Пример #30
0
def test():
   import vcs_legacy,cdms2 as cdms,time,os,sys,support          # import vcs_legacy and cu
   bg=support.bg
   
   f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','clt.nc')) # open clt file
   s=f('clt')                   	# get slab clt
   x=vcs_legacy.init()                         # construct vcs_legacy canvas
   
   x.plot(s,'default','isoline','quick',bg=support.bg)# plot slab the old way
   support.check_plot(x)
   if bg == 0:
      x.geometry(450,337,0,0)		# change geometry and location
      support.check_plot(x)
      x.geometry(900,675,10,0)		# change geometry and location
      support.check_plot(x)
      x.flush()
      support.check_plot(x)

   
   a=x.getisoline('quick') 		# get 'quick' isoline graphics method
   if not vcs_legacy.isgraphicsmethod(a):            # test object 'a' for graphics method
      raise Exception, "Error did not retrieve the gm"
   else:
      if not vcs_legacy.isisoline(a):		# check for isoline
         raise Exception, "Error gm is not right type"
   
   a.script('test','w')                 # save 'quick' isoline as a Python script
   
   a.xticlabels('lon30','lon30')	# change the x-axis
   support.check_plot(x)
   a.xticlabels('','')                  # remove the x-axis
   support.check_plot(x)
   a.xticlabels('*')                    # put the x-axis back
   support.check_plot(x)
   a.datawc(-45.0, 45.0, -90.0, 90.0)   # change the region
   support.check_plot(x)
   a.datawc(1e20,1e20,1e20,1e20)        # put the region back
   support.check_plot(x)
	
 
   if not '--extended' in sys.argv:
     print '\n************* PARTIAL TEST *****************'
     print 'FOR COMPLETE TEST OF THIS MODULE USE '
     print '   -F (--full) or -E (--extended) option'
     print '************* PARTIAL TEST *****************\n'
     sys.exit()

  
   #########################################################################
   # Set the isoline level vales	     				   #
   #########################################################################
   a.level=([20,0.0],[30,0],[50,0],[60,0])	# change the isoline values
   support.check_plot(x)
   a.level=[[20,0.0],[30,0],[50,0]]	# change the isoline values
   support.check_plot(x)
   a.level=((20,0.0),(30,0),(50,0),(60,0),(70,0)) # change the isoline values
   support.check_plot(x)
   a.level=(25,35,45,55)		# change the isoline values
   support.check_plot(x)
   a.level=[(22,33,44,55,66)]		# change the isoline values
   support.check_plot(x)
   a.level=[(23,32,45,50,76),]		# change the isoline values
   support.check_plot(x)
   a.level=[0]      			# same as a.level=(0,)
   support.check_plot(x)
   a.level=[[0,1e20]] 			# same as a.level=((0,1e20),), use default settings
   support.check_plot(x)

   
   #########################################################################
   # Turn on and off the isoline level labels  				   #
   #########################################################################
   a.label='y'       			# same as a.label=1
   support.check_plot(x)
   a.label='n'       			# same as a.label=0
   support.check_plot(x)
   
   #########################################################################
   # Set the line style and line color        		 		   #
   #########################################################################
   a.level=((20,0.0),(30,0),(50,0),(60,0),(70,0)) # change the isoline values
   support.check_plot(x)
   a.line=[1,3,0,4]			# same as a.line=(1,3,0,4)
   support.check_plot(x)
   a.line=(['dash','long-dash','solid'])# same as a.line=([2,4,0])
   support.check_plot(x)
   a.line=[2,4,1,3,2,0]
   support.check_plot(x)
   a.linecolors=([22,33,44,55,66,77])	# change the line color
   support.check_plot(x)
   a.linecolors=(16,19,33,44)		# change the line color
   support.check_plot(x)
   a.linecolors=None			# use the default line color
   support.check_plot(x)
   a.line=None				# use the default line style, which is solid
   support.check_plot(x)
   
   #########################################################################
   # Set the text font and text color         		 		   #
   #########################################################################
   a.label='y'                          # same as a.label=1
   support.check_plot(x)
   a.text=(1,2,3,4,5,6,7,8,9)		# select fonts from 1 through 9
   support.check_plot(x)
   a.text=[9,8,7,6,5,4,3,2,1]
   support.check_plot(x)
   a.text=([1,3,5,6,9,2])
   support.check_plot(x)
   a.textcolors=([22,33,44,55,66,77])	# set the text color
   support.check_plot(x)
   a.textcolors=(16,19,33,44)
   support.check_plot(x)
   a.textcolors=None			# use default text color, black
   support.check_plot(x)
   a.text=None				# use default font, 1
   support.check_plot(x)
   
   #########################################################################
   # Create template 'test' from the default template			   #
   #########################################################################
   objs =x.listelements('template')                   # get the list of templates
   t=x.createtemplate('test')           # create template 'test' from 'default' template
   if not vcs_legacy.istemplate(t):                  # test whether 't' is a template or not
      raise Exception,"Error template not created"
   else:
      a2 =x.listelements('template')                   # get the list of templates
      if objs==a2:
         raise Exception,"Error template not created or added to list"
   
   #########################################################################
   # Create line object 'l' from the default line    			   #
   #########################################################################
   l=x.createline('test')
   objs = x.listelements('line')                      	# show the list of line secondary objects
   if not vcs_legacy.issecondaryobject(l):           # check to see if it is a secondary object
      raise Exception,"Error did not get line"
   else:
      if not vcs_legacy.isline(l):                  	# check to see if it is a line
         raise Exception, "Error object created is not line"
   
   x.clear()                            # clear the VCS Canvas
   x.isoline(s,a,t,bg=support.bg)			# plot the array using the template and isoline object
   support.check_plot(x)
   x.clear()                            # clear the VCS Canvas
   x.plot(t,a,s,bg=support.bg)			# plot again using the new way
   support.check_plot(x)
   
   #########################################################################
   # Use the create line object 'l' from above and modify the line object  #
   #########################################################################
   a.line=[1,3,0,4]        		# same as a.line=(1,3,0,4)
   support.check_plot(x)
   a.line=([2,4,0])        		# same as a.line=(['dash', 'long-dash', 'solid'])
   support.check_plot(x)
   a.line=(l,4,l,0)			# use the line object
   support.check_plot(x)
   a.line=(l,3,4,2,0)
   support.check_plot(x)
   l.color = 44				# change the line color
   support.check_plot(x)
   l.type ='dash'			# change the line type
   support.check_plot(x)
   
   #########################################################################
   # Create the three types of text objects                                #
   #########################################################################
   tc = x.createtextcombined('testc','std', 'testc','7left')
   if not vcs_legacy.istextcombined(tc):
      raise Exception,"Error not textcombined!"
   
   tt = x.createtexttable('testt', 'default')
   if not vcs_legacy.istexttable(tt):
      raise Exception,"Error not texttable"
   
   to = x.createtextorientation('testo')
   if not vcs_legacy.istextorientation(to):
      raise Exception,"Error not textorientation"
   
   #########################################################################
   # Use the text objects in the isoline plot                              #
   #########################################################################
   a.label='y'				# make sure that the labels are turn on
   support.check_plot(x)
   a.text=([1,3,5,6,9,2])		# set the font
   support.check_plot(x)
   a.text=([tc,tt,to,6,9,2])		# use the created text objects and fonts
   support.check_plot(x)
   
   #########################################################################
   # Change the text object values                                         #
   #########################################################################
   tc.font = 3				# changing isoline level 20
   support.check_plot(x)
   tc.height=15
   support.check_plot(x)
   tc.angle=180
   support.check_plot(x)
   tc.color=242
   support.check_plot(x)
   tt.font=2				# changing isoline level 30
   support.check_plot(x)
   tt.spacing=20
   support.check_plot(x)
   to.height=15				# changing isoline level 50
   support.check_plot(x)
   to.path='down'
   support.check_plot(x)
   
   a.text=None				# use default font, which is font 1
   support.check_plot(x)
   a.line=None				# use default line, which is solid
   support.check_plot(x)
   
   a = x.listelements('isoline')                      # show list of gm
   r=x.createisoline('test2','quick')     # create xyvsy 'test2'
   a2 = x.listelements('isoline')                      # show list of gm
   if a2==a:
      raise "error gm not created or not added to list"
   x.removeobject(r)                    # remove xyvsy 'test2'
   a3 = x.listelements('isoline')                      # show list of gm
   if a3!=a:
      raise "error gm not removed"
   
   #################################################################################
   # to see how x.update and x.mode work, see testisoline.py                       #
   #################################################################################
   #x.update()
   #x.mode=1
   #x.mode=0
   print '*************************************************************************************'
   print '******                                                                         ******'
   print '******   I S O L I N E   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
   print '******                                                                         ******'
   print '*************************************************************************************'
Пример #31
0
    def __init__(self, canvas=None, gui_parent=None, dialog_parent=None, master=None, name='default',Parent=None):
        self.gui_parent=gui_parent
        self.dialog_parent=dialog_parent
        self.master=master
        
#        print 'PASSED INSIDE:',gui_parent
        if canvas is None:
##             import Canvas
##             self.canvas = Canvas.Canvas()
            self.canvas=vcs_legacy.init()
        else:
            self.canvas=canvas
            
        self.projection=self.canvas.getprojection(name)
        if self.projection is None:
            raise 'Erro invalid projection name'
        
        self.parent=Parent
        ## Saves original values
        self.orig=[]
        self.save_vals()
        
        Proj_color = gui_support.gui_color.Proj_color

#################################################################################################
# At the moment, this will never happen. When we need to pop this editor up on its own, then we
# will revist this case.
##         if self.gui_parent is None:
##             self.gui_parent=Tkinter.Toplevel()
##             #self.gui_parent=Tkinter.Tk(":0.0") # Use the localhost:0.0 for the DISPLAY and screen
##             self.gui_parent.withdraw()
#################################################################################################

        title='Projection Editor - '+self.projection.name
        self.dialog = Pmw.Dialog(master,
                                 title=title,
                                 buttons=(),
                                )
        self.dialog.withdraw()

        if gui_support.root_exists():
            root = gui_support.root()
            self.top_parent = root
        else:
            root = gui_support.root()
            self.top_parent = None
        self.root = root
        parent=self.dialog.interior()
        parent.configure(bg=Proj_color)
        self.cmain_menu = Pmw.MenuBar(parent,
                hull_relief = 'raised',
                hull_borderwidth = 2,
                balloon = gui_support.balloon
                )
        self.cmain_menu.pack(side='top', fill='both')

        self.cmain_menu.addmenu('File', 'Open/Save VCS Projections', tearoff = 1)
        self.cmain_menu.addmenuitem('File', 'command', 'Open projection file',
                         label = 'Open Projection File',
                         command = self.evt_open_file,
                        )

        self.cmain_menu.addmenuitem('File', 'separator')

        #
        # Create the cascade "Save Colormap" menu and its items
##         self.cmain_menu.addmenuitem('File', 'command', 'Select projection',
##                                     label = 'Select',
##                                     command = self.evt_loadproj,
##                                     )
        self.cmain_menu.addmenuitem('File', 'command', 'Save projection',
                                    label = 'Save (i.e Apply changes)',
                                    command = self.setprojection,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Copy projection',
                                    label = 'Copy Projection',
                                    command = self.evt_save_as,
                                    )
        self.cmain_menu.addmenuitem('File', 'command', 'Save as file',
                                    label = 'Save To File',
                                    command = self.evt_save_to_file,
                                    )

        # Create the cascade "Exit" menu
        self.cmain_menu.addmenuitem('File', 'separator')
        self.cmain_menu.addmenuitem('File', 'command',
                                    statusHelp='Close Projection Editor',
                                    label = "Exit Projection Editor",
                                    command = self.dialog.destroy,
                                    )
        
##         self.ftype=Tkinter.Frame(parent)
##         self.ftype.pack(side='top')
        projs=self.canvas.listelements('projection')
        projs.sort()

        self.projections=Pmw.OptionMenu(parent,
                                  items=projs,
                                  labelpos='w',
                                  label_text='Name: ',
                                  command=self.loadproj,
                                  initialitem=self.projection.name,
                                  label_bg=Proj_color,
                                  hull_bg=Proj_color,
                                  menu_bg=Proj_color,
                                  menu_activebackground=Proj_color,
                                  menubutton_bg=Proj_color,
                                  menubutton_activebackground=Proj_color,
                                 )
        self.projections.pack()
        
        self.fprop=Pmw.Group(parent,tag_text='Properties',
                             tagindent=10,
                             tag_bg=Proj_color,
                             ring_bg=Proj_color,
                             hull_bg=Proj_color)
        self.fprop.pack(expand='yes',fill='both')
        inter=self.fprop.interior()
        inter.configure(bg=Proj_color)
        self.fproperties=Tkinter.Frame(inter,bg=Proj_color)
        self.fbuttons=Tkinter.Frame(parent,bg=Proj_color)
        self.fbuttons.pack()

        self.projtypes=["polar (non gctp)",
                        "mollweide (non gctp)",
                        "robinson (non gctp)",
                        "linear",
                        "utm",
                        "state plane",
                        "albers equal area",
                        "lambert",
                        "mercator",
                        "polar stereographic",
                        "polyconic",
                        "equid conic",
                        "transverse mercator",
                        "stereographic",
                        "lambert azimuthal",
                        "azimuthal",
                        "gnomonic",
                        "orthographic",
                        "gen. vert. near per",
                        "sinusoidal",
                        "equirectangular",
                        "miller cylindrical",
                        "van der grinten",
                        "hotin oblique",
                        "robinson",
                        "space oblique",
                        "alaska conformal",
                        "interrupted goode",
                        "mollweide",
                        "interrupted mollweide",
                        "hammer",
                        "wagner iv",
                        "wagner vii",
                        "oblated equal area",
                        ]
        
        self.projtype = Pmw.OptionMenu (inter,
                                        labelpos='w',
                                        label_text='Projection Type',
                                        label_bg=Proj_color,
                                        hull_bg=Proj_color,
                                        menu_bg=Proj_color,
                                        menu_activebackground=Proj_color,
                                        menubutton_bg=Proj_color,
                                        menubutton_activebackground=Proj_color,
                                        items=  self.projtypes,
                                        command=self.settype,
                                        )
        self.projtype.pack()
        b1=Tkinter.Button(self.fbuttons,
                          text='Cancel',
                          command=self.cancel)
        b1.pack(side='left')
        b2=Tkinter.Button(self.fbuttons,
                          text='Apply',
                          command=self.exit)
        b2.pack(side='left')
        b3=Tkinter.Button(self.fbuttons,
                          text='Revert',
                          command=self.reset)
        b3.pack(side='left')

        self.setgui()

        # Position dialog popup
        if dialog_parent is not None:
            parent_geom = dialog_parent.geometry()
            geom = string.split(parent_geom, '+')
            d1 = string.atoi( geom[1] )
            d2 = string.atoi( geom[2] )
            self.dialog.activate( geometry="+%d+%d" % (d1, d2) )
        else:
            self.dialog.activate(geometry = 'centerscreenalways')

        return
Пример #32
0
def test():
    import vcs_legacy, cdms2 as cdms, time, os, sys, support  # import vcs_legacy and cu
    bg = support.bg

    f = cdms.open(
        os.path.join(cdms.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'clt.nc'))  # open clt file
    s = f('clt')  # get slab clt
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    x.plot(s, 'default', 'isoline', 'quick',
           bg=support.bg)  # plot slab the old way
    support.check_plot(x)
    if bg == 0:
        x.geometry(450, 337, 0, 0)  # change geometry and location
        support.check_plot(x)
        x.geometry(900, 675, 10, 0)  # change geometry and location
        support.check_plot(x)
        x.flush()
        support.check_plot(x)

    a = x.getisoline('quick')  # get 'quick' isoline graphics method
    if not vcs_legacy.isgraphicsmethod(
            a):  # test object 'a' for graphics method
        raise Exception, "Error did not retrieve the gm"
    else:
        if not vcs_legacy.isisoline(a):  # check for isoline
            raise Exception, "Error gm is not right type"

    a.script('test', 'w')  # save 'quick' isoline as a Python script

    a.xticlabels('lon30', 'lon30')  # change the x-axis
    support.check_plot(x)
    a.xticlabels('', '')  # remove the x-axis
    support.check_plot(x)
    a.xticlabels('*')  # put the x-axis back
    support.check_plot(x)
    a.datawc(-45.0, 45.0, -90.0, 90.0)  # change the region
    support.check_plot(x)
    a.datawc(1e20, 1e20, 1e20, 1e20)  # put the region back
    support.check_plot(x)

    if not '--extended' in sys.argv:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()

    #########################################################################
    # Set the isoline level vales	     				   #
    #########################################################################
    a.level = ([20, 0.0], [30, 0], [50, 0], [60,
                                             0])  # change the isoline values
    support.check_plot(x)
    a.level = [[20, 0.0], [30, 0], [50, 0]]  # change the isoline values
    support.check_plot(x)
    a.level = ((20, 0.0), (30, 0), (50, 0), (60, 0), (70, 0)
               )  # change the isoline values
    support.check_plot(x)
    a.level = (25, 35, 45, 55)  # change the isoline values
    support.check_plot(x)
    a.level = [(22, 33, 44, 55, 66)]  # change the isoline values
    support.check_plot(x)
    a.level = [
        (23, 32, 45, 50, 76),
    ]  # change the isoline values
    support.check_plot(x)
    a.level = [0]  # same as a.level=(0,)
    support.check_plot(x)
    a.level = [[0, 1e20]]  # same as a.level=((0,1e20),), use default settings
    support.check_plot(x)

    #########################################################################
    # Turn on and off the isoline level labels  				   #
    #########################################################################
    a.label = 'y'  # same as a.label=1
    support.check_plot(x)
    a.label = 'n'  # same as a.label=0
    support.check_plot(x)

    #########################################################################
    # Set the line style and line color        		 		   #
    #########################################################################
    a.level = ((20, 0.0), (30, 0), (50, 0), (60, 0), (70, 0)
               )  # change the isoline values
    support.check_plot(x)
    a.line = [1, 3, 0, 4]  # same as a.line=(1,3,0,4)
    support.check_plot(x)
    a.line = (['dash', 'long-dash', 'solid'])  # same as a.line=([2,4,0])
    support.check_plot(x)
    a.line = [2, 4, 1, 3, 2, 0]
    support.check_plot(x)
    a.linecolors = ([22, 33, 44, 55, 66, 77])  # change the line color
    support.check_plot(x)
    a.linecolors = (16, 19, 33, 44)  # change the line color
    support.check_plot(x)
    a.linecolors = None  # use the default line color
    support.check_plot(x)
    a.line = None  # use the default line style, which is solid
    support.check_plot(x)

    #########################################################################
    # Set the text font and text color         		 		   #
    #########################################################################
    a.label = 'y'  # same as a.label=1
    support.check_plot(x)
    a.text = (1, 2, 3, 4, 5, 6, 7, 8, 9)  # select fonts from 1 through 9
    support.check_plot(x)
    a.text = [9, 8, 7, 6, 5, 4, 3, 2, 1]
    support.check_plot(x)
    a.text = ([1, 3, 5, 6, 9, 2])
    support.check_plot(x)
    a.textcolors = ([22, 33, 44, 55, 66, 77])  # set the text color
    support.check_plot(x)
    a.textcolors = (16, 19, 33, 44)
    support.check_plot(x)
    a.textcolors = None  # use default text color, black
    support.check_plot(x)
    a.text = None  # use default font, 1
    support.check_plot(x)

    #########################################################################
    # Create template 'test' from the default template			   #
    #########################################################################
    objs = x.listelements('template')  # get the list of templates
    t = x.createtemplate(
        'test')  # create template 'test' from 'default' template
    if not vcs_legacy.istemplate(t):  # test whether 't' is a template or not
        raise Exception, "Error template not created"
    else:
        a2 = x.listelements('template')  # get the list of templates
        if objs == a2:
            raise Exception, "Error template not created or added to list"

    #########################################################################
    # Create line object 'l' from the default line    			   #
    #########################################################################
    l = x.createline('test')
    objs = x.listelements('line')  # show the list of line secondary objects
    if not vcs_legacy.issecondaryobject(
            l):  # check to see if it is a secondary object
        raise Exception, "Error did not get line"
    else:
        if not vcs_legacy.isline(l):  # check to see if it is a line
            raise Exception, "Error object created is not line"

    x.clear()  # clear the VCS Canvas
    x.isoline(
        s, a, t,
        bg=support.bg)  # plot the array using the template and isoline object
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.plot(t, a, s, bg=support.bg)  # plot again using the new way
    support.check_plot(x)

    #########################################################################
    # Use the create line object 'l' from above and modify the line object  #
    #########################################################################
    a.line = [1, 3, 0, 4]  # same as a.line=(1,3,0,4)
    support.check_plot(x)
    a.line = ([2, 4, 0])  # same as a.line=(['dash', 'long-dash', 'solid'])
    support.check_plot(x)
    a.line = (l, 4, l, 0)  # use the line object
    support.check_plot(x)
    a.line = (l, 3, 4, 2, 0)
    support.check_plot(x)
    l.color = 44  # change the line color
    support.check_plot(x)
    l.type = 'dash'  # change the line type
    support.check_plot(x)

    #########################################################################
    # Create the three types of text objects                                #
    #########################################################################
    tc = x.createtextcombined('testc', 'std', 'testc', '7left')
    if not vcs_legacy.istextcombined(tc):
        raise Exception, "Error not textcombined!"

    tt = x.createtexttable('testt', 'default')
    if not vcs_legacy.istexttable(tt):
        raise Exception, "Error not texttable"

    to = x.createtextorientation('testo')
    if not vcs_legacy.istextorientation(to):
        raise Exception, "Error not textorientation"

    #########################################################################
    # Use the text objects in the isoline plot                              #
    #########################################################################
    a.label = 'y'  # make sure that the labels are turn on
    support.check_plot(x)
    a.text = ([1, 3, 5, 6, 9, 2])  # set the font
    support.check_plot(x)
    a.text = ([tc, tt, to, 6, 9, 2])  # use the created text objects and fonts
    support.check_plot(x)

    #########################################################################
    # Change the text object values                                         #
    #########################################################################
    tc.font = 3  # changing isoline level 20
    support.check_plot(x)
    tc.height = 15
    support.check_plot(x)
    tc.angle = 180
    support.check_plot(x)
    tc.color = 242
    support.check_plot(x)
    tt.font = 2  # changing isoline level 30
    support.check_plot(x)
    tt.spacing = 20
    support.check_plot(x)
    to.height = 15  # changing isoline level 50
    support.check_plot(x)
    to.path = 'down'
    support.check_plot(x)

    a.text = None  # use default font, which is font 1
    support.check_plot(x)
    a.line = None  # use default line, which is solid
    support.check_plot(x)

    a = x.listelements('isoline')  # show list of gm
    r = x.createisoline('test2', 'quick')  # create xyvsy 'test2'
    a2 = x.listelements('isoline')  # show list of gm
    if a2 == a:
        raise "error gm not created or not added to list"
    x.removeobject(r)  # remove xyvsy 'test2'
    a3 = x.listelements('isoline')  # show list of gm
    if a3 != a:
        raise "error gm not removed"

    #################################################################################
    # to see how x.update and x.mode work, see testisoline.py                       #
    #################################################################################
    #x.update()
    #x.mode=1
    #x.mode=0
    print '*************************************************************************************'
    print '******                                                                         ******'
    print '******   I S O L I N E   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
    print '******                                                                         ******'
    print '*************************************************************************************'
Пример #33
0
def test():
    import vcs_legacy, cdms2 as cdms, time, os, sys, support  # import vcs_legacy and cu

    bg = support.bg

    f = cdms.open(
        os.path.join(cdms.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'clt.nc'))
    s = f('clt')  # get slab clt
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    x.plot(s, 'default', 'isofill', 'quick', bg=bg)  # plot slab the old way
    support.check_plot(x)
    if bg == 0:
        x.geometry(450, 337, 0, 0)  # change the geometry
        x.flush()
        support.check_plot(x)
    x.getcolormapname()  # get the active colormap name

    x.setcolormap("AMIP")  # change the colormap
    support.check_plot(x)

    cont = False
    for anarg in sys.argv:
        if anarg in ['--extended', '--full', '-E', '-F']:
            cont = True
            break
    if cont is False:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()

    ############################################################
    # Change the color map cell 31.			      #
    ############################################################
    colors = {}
    cols = [31, 47, 63, 79, 95, 111, 127, 143, 159, 175, 191]
    for c in cols:
        colors[c] = [
            int(float(c - 16) / (191 - 16) * 100.),
        ] * 3
    for c in cols:
        vals = colors[c]
        x.setcolorcell(c, vals[0], vals[1], vals[2])
        support.check_plot(x)

    for c in colors.keys():
        okvals = colors[c]
        vals = x.getcolorcell(c)
        if vals != okvals:
            raise Exception, "Error setting color %i, should have been : %s, but is %s" % (
                c, str(okvals), str(vals))

    ##################################################################
    # Retrieve the color map RGB values for the given cell numbers.  #
    ##################################################################

    ##################################################################
    # Using colormap objects.                                        #
    ##################################################################
    objs = x.listelements(
        'colormap')  # show the list of line secondary objects
    c2 = x.getcolormap()  # get 'default' colormap object
    c = x.getcolormap('AMIP')  # get 'quick' colormap object
    if not vcs_legacy.issecondaryobject(
            c):  # check to see if it is a secondary object
        raise Exception, "Error did not get colormap as secondary obj"
    else:
        if not vcs_legacy.iscolormap(c):  # check to see if it is a line
            raise Exception, "Error object created is not colormap"

    a = x.listelements('colormap')  # show list of xyvsy
    r = x.createcolormap('new')  # create colormap
    a2 = x.listelements('colormap')  # show list of xyvsy
    if a2 == a:
        raise "error cm not created or not added to list"
    x.removeobject(r)  # remove xyvsy 'test2'
    a3 = x.listelements('colormap')  # show list of xyvsy
    if a3 != a:
        raise Exception, "error cm not removed"
    c3 = x.createcolormap('new')  # create a new colormap object from default
    x.setcolormap('new')  # change the colormap to 'new' colormap
    c3.index  # show just the colormap RGB values
    for c in colors.keys():
        vals = colors[c]
        c3.index[c] = vals  # change color cell

    for c in colors.keys():
        okvals = colors[c]
        vals = x.getcolorcell(c)
        if vals != okvals:
            raise Exception, "Error setting color %i, should have been : %s, but is %s" % (
                c, str(okvals), str(vals))

    c3.script('test.scr', 'w')  # save 'new' colormap as a VCS script
    c3.script('test', 'w')  # save 'new' colormap as a Python script
    if support.dogui is True:
        x.colormapgui()  # display the colormap GUI

    print '***************************************************************************************'
    print '******                                                                           ******'
    print '******   C O L O R M A P   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
    print '******                                                                           ******'
    print '***************************************************************************************'
Пример #34
0
def test():
    import vcs_legacy, cdms2 as cdms, time, os, sys, support  # import vcs_legacy and cu

    bg = support.bg

    f = cdms.open(
        os.path.join(cdms.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'clt.nc'))  # open clt file
    s = f('clt')  # get slab clt
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    a = x.createoutline('test')  # create 'test' outline
    if not vcs_legacy.isgraphicsmethod(
            a):  # test object 'a' for graphics method
        raise Exception, "Error did not retrieve the gm"
    else:
        if not vcs_legacy.isoutline(a):  # check for outline
            raise Exception, "Error gm is not right type"

    x.plot(s, 'default', 'outline', 'test', bg=bg)  # plot slab the old way
    support.check_plot(x)
    if bg == 0:
        x.geometry(450, 337, 100, 0)  # change the geometry and location
        x.flush()
        support.check_plot(x)

    s = f('u')  # get u slab
    x.clear()  # clear the VCS Canvas
    x.plot(s, 'default', 'outline', 'test', bg=bg)  # plot the surface data
    support.check_plot(x)

    a.script('test', 'w')  # save 'test' outline as a Python script

    a.xticlabels('lon30', 'lon30')  # change the x-axis
    support.check_plot(x)
    a.xticlabels('', '')  # remove the x-axis
    support.check_plot(x)
    a.xticlabels('*')  # put the x-axis
    support.check_plot(x)
    a.datawc(-45.0, 45.0, -90.0, 90.0)  # change the region
    support.check_plot(x)
    a.datawc(1e20, 1e20, 1e20, 1e20)  # put the region back
    support.check_plot(x)

    cont = False
    for anarg in sys.argv:
        if anarg in ['--extended', '--full', '-E', '-F']:
            cont = True
            break
    if cont is False:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()

    a.outline = ([0])  # set the outline value
    support.check_plot(x)
    a.line = 0  # same as 'solid', change the line style
    support.check_plot(x)
    a.line = 1  # same as 'dash', change the line style
    support.check_plot(x)
    a.line = 2  # same as 'dot', change the line style
    support.check_plot(x)
    a.line = 3  # same as 'dash-dot', change the line style
    support.check_plot(x)
    a.line = 4  # same as 'long-dash', change the line style
    support.check_plot(x)
    a.linecolor = (77)  # change the line color
    support.check_plot(x)
    a.linecolor = 16  # change the line color
    support.check_plot(x)
    a.linecolor = 44  # same as a.linecolor=(44)
    support.check_plot(x)
    a.linecolor = None  # use the default line color, black
    support.check_plot(x)
    a.line = None  # use default line style, solid black line
    support.check_plot(x)

    a.outline = ([1])  # set the outline value
    support.check_plot(x)
    a.outline = ([0, 1])  # set the outline value
    support.check_plot(x)
    a.outline = ([0])  # set the outline value
    support.check_plot(x)

    x.clear()  # clear the VCS Canvas
    x.outline(s, a, 'default', bg=bg)  # plot outline using 'default' template
    support.check_plot(x)

    objs = x.listelements('template')  # get the list of templates
    t = x.createtemplate(
        'test')  # create template 'test' from 'default' template
    if not vcs_legacy.istemplate(t):  # test whether 't' is a template or not
        raise Exception, "Error template not created"
    else:
        a2 = x.listelements('template')  # get the list of templates
        if objs == a2:
            raise Exception, "Error template not created or added to list"

    x.clear()  # clear the VCS Canvas
    x.plot(t, a, s,
           bg=bg)  # plot outline template 't', outline 'a', and array 's'
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.outline(a, s, t,
              bg=bg)  # plot using outline 'a', array 's', and template 't'
    support.check_plot(x)

    #########################################################################
    # Create line object 'l' from the default line                          #
    #########################################################################
    #########################################################################
    objs = x.listelements('line')  # show the list of line secondary objects
    l = x.createline('test')
    if not vcs_legacy.issecondaryobject(
            l):  # check to see if it is a secondary object
        raise Exception, "Error did not get line"
    else:
        if not vcs_legacy.isline(l):  # check to see if it is a line
            raise Exception, "Error object created is not line"

    #########################################################################
    # Use the create line object 'l' from above and modify the line object  #
    #########################################################################
    a.line = l  # use the line object
    support.check_plot(x)
    l.color = 44  # change the line color
    support.check_plot(x)
    l.type = 'dash'  # change the line type
    support.check_plot(x)

    a = x.listelements('outline')  # show list of gm
    r = x.createoutline('test2', 'quick')  # create xyvsy 'test2'
    a2 = x.listelements('outline')  # show list of gm
    if a2 == a:
        raise "error gm not created or not added to list"
    x.removeobject(r)  # remove xyvsy 'test2'
    a3 = x.listelements('outline')  # show list of gm
    if a3 != a:
        raise "error gm not removed"

    #################################################################################
    # to see how x.update and x.mode work, see testoutline.py                       #
    #################################################################################
    #x.update()
    #x.mode=1
    #x.mode=0
    print '*************************************************************************************'
    print '******                                                                         ******'
    print '******   O U T F I L L   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
    print '******                                                                         ******'
    print '*************************************************************************************'
Пример #35
0
import vcs_legacy,support
if support.dogui:
    x=vcs_legacy.init()
    x.graphicsmethodgui(gm_type='boxfill', gm_name='ASD')
else:
    print 'You need to run this one by hand (turn support.dogui to 1 first)'
Пример #36
0
def test():
   import vcs_legacy,cdms2 as cdms,time,os,sys,support          # import vcs_legacy and cdms

   bg=support.bg
   f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','clt.nc')) # open clt file
   s=f('clt')                           # get slab clt
   x=vcs_legacy.init()                         # construct vcs_legacy canvas
   

   x.plot(s,'default','outfill','ASD_map',bg=bg)# plot slab the old way
   support.check_plot(x)
   if bg==0:
      x.geometry(450,337,100,0)            # change the geometry and location
      support.check_plot(x)
      x.flush()
      support.check_plot(x)
   
   
   s=f('u')	                        # get u slab
   x.clear()                            # clear the VCS Canvas
   x.plot(s,'default','outfill','ASD_map',bg=bg)# plot the surface data
   support.check_plot(x)
   
   a=x.createoutfill('quick')		# create 'quick' outfill
   if not vcs_legacy.isgraphicsmethod(a):            # test object 'a' for graphics method
      raise Exception, "Error did not retrieve the gm"
   else:
      if not vcs_legacy.isoutfill(a):		# check for isofill
         raise Exception, "Error gm is not right type"
   
   a.script('test','w')			# save 'quick' outfill as a Python script
   
  
   a.xticlabels('lon30','lon30')        # change the x-axis
   support.check_plot(x)
   a.xticlabels('','')                  # remove the x-axis
   support.check_plot(x)
   a.xticlabels('*')                    # put the x-axis
   support.check_plot(x)
   a.datawc(-45.0, 45.0, -90.0, 90.0)   # change the region
   support.check_plot(x)
   a.datawc(1e20,1e20,1e20,1e20)        # put the region back
   support.check_plot(x)
   

   cont = False
   for anarg in sys.argv:
      if anarg in ['--extended', '--full','-E','-F']:
         cont = True
         break
   if cont is False:
     print '\n************* PARTIAL TEST *****************'
     print 'FOR COMPLETE TEST OF THIS MODULE USE '
     print '   -F (--full) or -E (--extended) option'
     print '************* PARTIAL TEST *****************\n'
     sys.exit()
   

   x.clear()                            # clear the VCS Canvas
   x.outfill(s,a,'default',bg=bg)             # plot outfill using 'default' template
   
   a.fillareastyle='hatch'		# change the fill style to hatch
   support.check_plot(x)
   a.fillareaindex=11			# change the hatch index pattern
   support.check_plot(x)
   a.fillareacolor=(77)			# change the hatch color
   support.check_plot(x)
   a.fillareacolor=16			# chnage the hatch color
   support.check_plot(x)
   a.fillareacolor=44			# same as a.fillareacolor=(44)
   support.check_plot(x)
   a.fillareacolor=None			# use the default hatch color (black)
   support.check_plot(x)
   a.outfill=([0])			# set the outfill value
   support.check_plot(x)
   a.outfill=([1])			# set the outfill value
   support.check_plot(x)
   a.outfill=([0,1])			# set the outfill value
   support.check_plot(x)
   a.outfill=([0])			# set the outfill value
   support.check_plot(x)
   
   support.check_plot(x)
   
   objs =x.listelements('template')                   # get the list of templates
   t=x.createtemplate('test')           # create template 'test' from 'default' template
   if not vcs_legacy.istemplate(t):                  # test whether 't' is a template or not
      raise Exception,"Error template not created"
   else:
      a2 =x.listelements('template')                   # get the list of templates
      if objs==a2:
         raise Exception,"Error template not created or added to list"
   
   x.clear()				# clear the VCS Canvas
   x.plot(a, t, s,bg=bg)			# plot outfill template 't', outfill 'a', and array 's'
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.outfill(a,s,t,bg=bg)			# plot using outfill 'a', array 's', and template 't'
   support.check_plot(x)
   
   objs = x.listelements('fillarea')                      	# show the list of fillarea secondary objects
   f=x.getfillarea('AuTo_1')                	# get fillarea 'red'
   if not vcs_legacy.issecondaryobject(f):           # check to see if it is a secondary object
      raise Exception,"Error did not get fillarea"
   else:
      if not vcs_legacy.isfillarea(f):                  	# check to see if it is a fillarea
         raise Exception, "Error object created is not fillarea"
   a.fillareastyle=f
   support.check_plot(x)
   f.color=44                           # change the fillarea object's color
   support.check_plot(x)
   f.style='hatch'                      # change the fillarea object's fill style
   support.check_plot(x)
   
   a = x.listelements('outfill')                      # show list of gm
   r=x.createoutfill('test2','quick')     # create xyvsy 'test2'
   a2 = x.listelements('outfill')                      # show list of gm
   if a2==a:
      raise "error gm not created or not added to list"
   x.removeobject(r)                    # remove xyvsy 'test2'
   a3 = x.listelements('outfill')                      # show list of gm
   if a3!=a:
      raise "error gm not removed"
   
   
   #################################################################################
   # to see how x.update and x.mode work, see testoutfill.py                       #
   #################################################################################
   #x.update()                             
   #x.mode=1
   #x.mode=0
   print '*************************************************************************************'
   print '******                                                                         ******'
   print '******   O U T F I L L   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
   print '******                                                                         ******'
   print '*************************************************************************************'
   return x, s
Пример #37
0
def test():
    import vcs_legacy, cdms2 as cdms, time, os, sys, support  # import vcs_legacy and cdms
    bg = support.bg

    f = cdms.open(
        os.path.join(cdms.__path__[0], '..', '..', '..', '..', 'sample_data',
                     'clt.nc'))  # open clt file
    s = f('clt')  # get slab clt
    x = vcs_legacy.init()  # construct vcs_legacy canvas

    tt = x.createtext()

    a = x.listelements('template')  # show the list of templates
    t = x.createtemplate('test', 'ASD')  # create template 'test' from ASD

    t.ylabel1.texttable = tt
    t.ylabel1.textorientation = tt

    a2 = x.listelements('template')  # show the list of templates
    if a2 == a:
        raise Excpetion, "Error, template not added to list"
    if not vcs_legacy.istemplate(t):
        raise Exception, "Error obj created is not a template!"

    t.script('test', 'w')  # save test template as a Python script

    g = x.createisofill('test')  # create isofill 'test' from 'default' isofill

    x.plot(g, s, t, bg=bg)  # make isofill plot
    support.check_plot(x)

    #############################################################################
    # Show the many different ways to show the template members (attributes)    #
    # and their values.                                                         #
    #############################################################################
    ##    t.list()				# list the templates members
    ##    t.list('text')			# list only text members, same as t.list('Pt')
    ##    t.list('format')			# list only format members, same as t.list('Pf')
    ##    t.list('xtickmarks')			# list only xtickmarks members, same as t.list('Pxt')
    ##    t.list('ytickmarks')			# list only ytickmarks members, same as t.list('Pyt')
    ##    t.list('xlabels')			# list only xlabels members, same as t.list('Pxl')
    ##    t.list('ylabels')			# list only ylabels members, same as t.list('Pyl')
    ##    t.list('boxeslines')			# list only boxeslines members, same as t.list('Pbl')
    ##    t.list('legend')			# list only legend member, same as t.list('Pls')
    ##    t.list('data')			# list only data member, same as t.list('Pds')
    ##    t.list('file')			# list only file member and its values
    ##    t.file.list()			# list only file member and its values
    ##    t.list('mean')			# list only mean member and its values
    ##    t.mean.list()			# list only mean member and its values

    #############################################################################
    # The screen x and y positions on the screen are normalized between 0 and 1 #
    # for both the x and y axis.                                                #
    #############################################################################
    t.mean.priority = 0  # remove the "Mean" text from the plot
    support.check_plot(x)
    t.mean.priority = 1  # re-display the "Mean" text on the plot
    support.check_plot(x)
    t.mean.x = 0.5  # move the "Mean" text to x-axis center
    support.check_plot(x)
    t.mean.y = 0.5  # move the "Mean" text to y-axis center
    support.check_plot(x)

    if not '--extended' in sys.argv:
        print '\n************* PARTIAL TEST *****************'
        print 'FOR COMPLETE TEST OF THIS MODULE USE '
        print '   -F (--full) or -E (--extended) option'
        print '************* PARTIAL TEST *****************\n'
        sys.exit()

    #############################################################################
    # Position the data in front of the "Mean" text, then move the "Mean" text  #
    # in front of the data.                                                     #
    #############################################################################
    t.data.priority = 2
    support.check_plot(x)
    t.data.priority = 3
    support.check_plot(x)
    #  The above does not work. I will fix this later when time permits.
    # seems to work now 2007-07-16
    t.data.priority = 1  # back to normal
    support.check_plot(x)

    #############################################################################
    # Change the font representation for the "Mean" text.                       #
    # You can set the text by using text objects or text names.                 #
    #############################################################################
    tt = x.createtexttable('test')
    to = x.createtextorientation('test')
    t.mean.texttable = tt  # set texttable by using texttable object
    support.check_plot(x)
    t.mean.textorientation = 'test'  # set textorientation by using textorientation name
    support.check_plot(x)
    t.mean.list()  # show the mean member and their new values
    tt.font = 2  # change the font
    support.check_plot(x)
    to.height = 40  # change the height
    support.check_plot(x)

    #############################################################################
    # Change the legend space.                                                  #
    #############################################################################
    t.legend.list()  # list the legend members
    x.mode = 0  # turn the automatic update off
    t.legend.x1 = 0.85
    support.check_plot(x)
    t.legend.y1 = 0.90
    support.check_plot(x)
    t.legend.x2 = 0.95
    support.check_plot(x)
    t.legend.y2 = 0.16
    support.check_plot(x)
    x.update()
    support.check_plot(x)
    #  The above does not work. I will fix this later when time permits.

    print '***************************************************************************************'
    print '******                                                                           ******'
    print '******   T E M P L A T E   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
    print '******                                                                           ******'
    print '***************************************************************************************'
Пример #38
0
def test():
   import vcs_legacy,cu                        # import vcs_legacy and cu

   f=cu.open('clt.nc')                  # open clt file
   s=f.getslab('clt')                   # get slab clt
   x=vcs_legacy.init()                         # construct vcs_legacy canvas

   x.show('template')                   # show the list of templates
   t=x.createtemplate('test','AMIP')    # create template 'test' from AMIP
   x.show('template')                   # show the list of templates

   t.script('test','w')			# save test template as a Python script

   g=x.createisofill('test')           	# create isofill 'test' from 'default' isofill

   x.plot(g,s,t)			# make isofill plot
#   x.isofill(g,s,t)			# make isofill plot

   
   #############################################################################
   # Show the many different ways to show the template members (attributes)    #
   # and their values.                                                         #
   #############################################################################
   t.list()				# list the templates members
   t.list('text')			# list only text members, same as t.list('Pt')
   t.list('format')			# list only format members, same as t.list('Pf')
   t.list('xtickmarks')			# list only xtickmarks members, same as t.list('Pxt')
   t.list('ytickmarks')			# list only ytickmarks members, same as t.list('Pyt')
   t.list('xlabels')			# list only xlabels members, same as t.list('Pxl')
   t.list('ylabels')			# list only ylabels members, same as t.list('Pyl')
   t.list('boxeslines')			# list only boxeslines members, same as t.list('Pbl')
   t.list('legend')			# list only legend member, same as t.list('Pls')
   t.list('data')			# list only data member, same as t.list('Pds')
   t.list('file')			# list only file member and its values
   t.file.list()			# list only file member and its values
   t.list('mean')			# list only mean member and its values
   t.mean.list()			# list only mean member and its values

   #############################################################################
   # The screen x and y positions on the screen are normalized between 0 and 1 #
   # for both the x and y axis.                                                #
   #############################################################################
   t.mean.priority = 0			# remove the "Mean" text from the plot
   t.mean.priority = 1			# re-display the "Mean" text on the plot
   t.mean.x=0.5				# move the "Mean" text to x-axis center
   t.mean.y=0.5				# move the "Mean" text to y-axis center
   
   #############################################################################
   # Position the data in front of the "Mean" text, then move the "Mean" text  #
   # in front of the data.                                                     #
   #############################################################################
   t.data.priority = 2
   t.data.priority=3
#  The above does not work. I will fix this later when time permits.

   #############################################################################
   # Change the font representation for the "Mean" text.                       #
   # You can set the text by using text objects or text names.                 #
   #############################################################################
   tt = x.createtexttable('test')
   to = x.createtextorientation('test')
   t.mean.texttable = tt		# set texttable by using texttable object
   t.mean.textorientation = 'test'	# set textorientation by using textorientation name
   t.mean.list()                        # show the mean member and their new values
   tt.font=2				# change the font 
   to.height=40				# change the height

   #############################################################################
   # Change the legend space.                                                  #
   #############################################################################
   t.legend.list()		       	# list the legend members
   x.mode=0				# turn the automatic update off
   t.legend.x1=0.85
   t.legend.y1=0.90
   t.legend.x2=0.95
   t.legend.y2=0.16
   x.update()
#  The above does not work. I will fix this later when time permits.

   print '***************************************************************************************'
   print '******                                                                           ******'
   print '******   T E M P L A T E   T E S T   C O M P L E T E D   S U C E S S F U L L Y   ******'
   print '******                                                                           ******'
   print '***************************************************************************************'