def __init__(self, main_menu, parent, tear_it): self.parent = parent PT_name = 'Visus' if ((sys.platform == 'darwin') and (gui_control.do_aqua == 1)): PT_name = 'Visus ' main_menu.addmenu(PT_name, 'Visus', tearoff=tear_it) # # Create the cascade "Cartesian Views" menu and its items #main_menu.addcascademenu(PT_name, 'CartesianViews', # 'Create Cartesian Views', # label = 'Cartesian Views', # traverseSpec = 'z', tearoff = tear_it # ) main_menu.addmenuitem( PT_name, 'command', 'Create a window showing a cartesian view of the data', label='Cartesian view', command=gui_control.Command(self.createScene, VisusCartesianSlice.CartesianSlice)) main_menu.addmenuitem( PT_name, 'command', 'Create a window showing a color mapped sphere potentially with an iso-surface', label='Spherical view', command=gui_control.Command(self.createScene, VisusColorMapSphere.ColorMapSphere)) main_menu.addmenuitem(PT_name, 'command', 'Create a window showing four labeled slices', label='Four Slices', command=gui_control.Command( self.createScene, VisusFourSliceScene.FourSliceScene)) main_menu.addmenuitem( PT_name, 'command', 'Create a window showing a spherical view with slices on the side', label='Movie Scene', command=gui_control.Command(self.createScene, VisusMovieScene.MovieScene)) main_menu.addmenuitem(PT_name, 'command', 'Load and animate the demo scene', label='Demo animation', command=gui_control.Command(self.demoScene))
def setgui(self,*crap): Proj_color=gui_support.gui_color.Proj_color projs=self.canvas.listelements('projection') projs.sort() a=self.projection.name self.projections.setitems(projs) self.projections.setvalue(a) self.parent.projection.setitems(projs) self.parent.projection.invoke(a) self.parent.button.configure(command=gui_control.Command(ProjGUI,canvas=self.canvas,gui_parent=self.gui_parent,dialog_parent=self.dialog_parent,master=self.master,name=a,Parent=self.parent)) self.projtype.configure(menubutton_state='normal') self.projtype.setvalue(self.projtypes[self.projection._type+3]) self.fproperties.destroy() inter=self.fprop.interior() inter.configure(bg=Proj_color) self.fproperties=Tkinter.Frame(inter,bg=Proj_color,relief='sunken') self.fproperties.pack(expand='yes',fill='both') self.fields=[] p=[] balloons={ 'smajor':'Semi-major axis of ellipsoid.\nIf zero, Clarke 1866 in meters is assumed.', 'sminor':'Eccentricity squared of the ellipsoid if less than zero\nIf zero, a spherical form is assumed\nIf greater than zero, the semi-minor axis of ellipsoid.', 'sphere':'Radius of reference sphere.\nIf zero, 6370997 meters is used.', 'standardparallel':'Latitude of the standard parallel', 'standardparallel1':'Latitude of the first standard parallel', 'standardparallel2':'Latitude of the second standard parallel', 'centralmeridian':' Longitude of the central meridian', 'originlatitude':'Latitude of the projection origin', 'falseeasting':'False easting in the same units as the semi-major axis', 'falsenorthing':'False northing in the same units as the semi-major axis', 'truescale':'Latitude of true scale', 'LongPol':'Longitude down below pole of map', 'factor':'Scale factor at central meridian (Transverse Mercator)\nor\nCenter of projection (Hotine Oblique Mercator)', 'centerlongitude':'Longitude of center of projection', 'centerlatitude':'Latitude of center of projection', 'height':'Height of perspective point', 'longitude1':'Longitude of first point on center line', 'longitude2':'Longitude of second point on center line', 'latitude1':'Latitude of first point on center line', 'latitude2':'Latitude of second point on center line', 'azimuthalangle':'Azimuth angle east of north of center line', 'azimuthallongitude':' Longitude of point on central meridian where azimuth occurs', 'orbitinclination':'Inclination of orbit at ascending node\ncounter-clockwise from equator', 'orbitlongitude':' Longitude of ascending orbit at equator', 'satelliterevolutionperiod':'Period of satellite revolution in minutes', 'landsatcompensationratio':'Landsat ratio to compensate for confusion at northern end of orbit\n(use 0.5201613)', 'pathflag':'End of path flag for Landsat\n0 = start of path, 1 = end of path', 'satellite':'Landsat Satellite Number', 'path':'Landsat Path Number\nUse WRS-1 for Landsat 1, 2 and 3\nUse WRS-2 for Landsat 4, 5 and 6.', 'shapem':'Oblated Equal Area oval shape parameter m', 'shapen':'Oblated Equal Area oval shape parameter n', 'angle':'Oblated Equal Area oval rotation angle', 'subtype':'Subtype of the projection (0 or 1)', } if self.projection._type in [3,4]: p.append('smajor') p.append('sminor') p.append('standardparallel1') p.append('standardparallel2') p.append('centralmeridian') p.append('originlatitude') p.append('falseeasting') p.append('falsenorthing') elif self.projection._type==5: p.append('smajor') p.append('sminor') p.append('centralmeridian') p.append('truescale') p.append('falseeasting') p.append('falsenorthing') elif self.projection._type==6: p.append('smajor') p.append('sminor') p.append('centerlongitude') p.append('truescale') p.append('falseeasting') p.append('falsenorthing') elif self.projection._type==7: p.append('smajor') p.append('sminor') p.append('centralmeridian') p.append('originlatitude') p.append('falseeasting') p.append('falsenorthing') elif self.projection._type==8: p.append('subtype') p.append('smajor') p.append('sminor') p.append('centralmeridian') p.append('originlatitude') p.append('falseeasting') p.append('falsenorthing') if self.projection.subtype==0: p.append('standardparallel') else: p.append('standardparallel1') p.append('standardparallel2') elif self.projection._type==9: p.append('smajor') p.append('sminor') p.append('factor') p.append('centralmeridian') p.append('originlatitude') p.append('falseeasting') p.append('falsenorthing') elif self.projection._type in [10,11,12,13,14]: p.append('sphere') p.append('centerlongitude') p.append('centerlatitude') p.append('falseeasting') p.append('falsenorthing') elif self.projection._type==15: p.append('sphere') p.append('height') p.append('centerlongitude') p.append('centerlatitude') p.append('falseeasting') p.append('falsenorthing') elif self.projection._type in [16,18,21,25,27,28,29]: p.append('sphere') p.append('centralmeridian') p.append('falseeasting') p.append('falsenorthing') elif self.projection._type==17: p.append('sphere') p.append('centralmeridian') p.append('truescale') p.append('falseeasting') p.append('falsenorthing') elif self.projection._type==19: p.append('sphere') p.append('centralmeridian') p.append('originlatitude') p.append('falseeasting') p.append('falsenorthing') elif self.projection._type==20: p.append('subtype') p.append('smajor') p.append('sminor') p.append('factor') p.append('originlatitude') p.append('falseeasting') p.append('falsenorthing') if self.projection.subtype==0: p.append('longitude1') p.append('latitude1') p.append('longitude2') p.append('latitude2') else: p.append('azimuthalangle') p.append('azimuthallongitude') elif self.projection._type==22: p.append('subtype') p.append('smajor') p.append('sminor') p.append('falseeasting') p.append('falsenorthing') if self.projection.subtype==0: p.append('orbitinclination') p.append('orbitlongitude') p.append('satelliterevolutionperiod') p.append('landsatcompensationratio') p.append('pathflag') else: p.append('satellite') p.append('path') elif self.projection._type==23: p.append('smajor') p.append('sminor') p.append('falseeasting') p.append('falsenorthing') elif self.projection._type in [24,26]: p.append('sphere') elif self.projection._type==30: p.append('sphere') p.append('shapem') p.append('shapen') p.append('centerlongitude') p.append('centerlatitude') p.append('falseeasting') p.append('falsenorthing') self.properties_names=p for p in self.properties_names: f=Tkinter.Frame(self.fproperties) f.pack(expand='yes',fill='both') a=Pmw.EntryField(self.fproperties, label_width=20,labelpos='w', label_justify='left', label_text=p, label_bg=Proj_color, hull_bg=Proj_color, entry_relief='sunken', entry_background='white', command=self.setprojection, value=getattr(self.projection,p), ## balloon=gui_support.balloon, ) a.pack(expand=1,fill='both') b=gui_support.balloon.bind( a, balloons[p] ) self.fields.append(a) if self.projection.name in ['default','robinson','polar','mollweide','linear']: self.projtype.configure(menubutton_state='disabled') for a in self.fields: a.configure(entry_state='disabled') self.setprojection() return
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.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