# Created by Leo from: C:\Python23\Tom\leo\pyterra.leo # << globalDEMV declarations >> import os import wx import dislin import string import binascii import Image import image_view import StringIO import struct from pyTerra import TerraImage import wx.lib.colourselect as csel import pyTerra import wx.lib.masked as mnum # startup numbers (declares global variables) not sure if it is necessary lat_num = 39.99583333333333 start_lat = 39.99583333333333 long_num = -139.99583333333334 start_long = -139.99583333333334 Latitude_Minimum = -10 Latitude_Maximum = 40 Longitude_Minimum = -140 Longitude_Maximum = -100 x_scale = 0.00833333333333 y_scale = 0.00833333333333 demdirectory = 'EMPTY' RSpin = 10 USpin = 25 DSpin = 400 height_num = 1.0 width_num = 1.0 wx.InitAllImageHandlers() # initialize wx.Python image handlers # -- end -- << globalDEMV declarations >> # << globalDEMV methods >> (1 of 8) def imgtyp(file_nm):# returns wx. image type fl_fld = os.path.splitext(file_nm) ext = fl_fld[1] ext = string.lower(ext[1:])# get extension if ext == 'bmp': image = wx.BITMAP_TYPE_BMP elif ext == 'gif': image = wx.BITMAP_TYPE_GIF elif ext == 'png': image = wx.BITMAP_TYPE_PNG elif ext == 'jpg': image = wx.BITMAP_TYPE_JPEG return image # << globalDEMV methods >> (2 of 8) def get_init_data(parent):# get data from the .hdr file global tom,long_num,start_long,lat_num,start_lat,x_scale,y_scale,Latitude_Minimum,Latitude_Maximum ,Longitude_Minimum,Longitude_Maximum dir = '' dlg = wx.FileDialog(parent, "Location of DEM file", ".", "", "*.dem", wx.OPEN) if dlg.ShowModal() == wx.ID_OK: dir = dlg.GetPath() dlg.Destroy() tom = open(dir,'rb') head_file_name = os.path.join(os.path.split(dir)[0],os.path.splitext(os.path.split(dir)[1])[0] + '.hdr') temp_file = open(head_file_name,'r') temp_file.readline() temp_file.readline() N_ROWS = int(string.split(temp_file.readline())[1]) N_COLS = int(string.split(temp_file.readline())[1]) temp_file.readline() temp_file.readline() temp_file.readline() temp_file.readline() temp_file.readline() temp_file.readline() long_num = float(string.split(temp_file.readline())[1]) start_long = long_num lat_num = float(string.split(temp_file.readline())[1]) start_lat = lat_num x_scale = float(string.split(temp_file.readline())[1]) y_scale = float(string.split(temp_file.readline())[1]) Latitude_Minimum = lat_num - (N_ROWS * y_scale) Latitude_Maximum = lat_num + y_scale Longitude_Minimum = long_num - x_scale Longitude_Maximum = long_num + (N_COLS * x_scale) temp_file.close() return dir # << globalDEMV methods >> (3 of 8) class Global_tile(wx.ScrolledWindow):# the display window for giff from DEM package # << class Global_tile methods >> (1 of 4) def __init__(self, parent, main_parent,id = -1, size = wx.DefaultSize): # object, parent objet (one side of split window) for wx.Python, parent object wx.ScrolledWindow.__init__(self, parent, id, wx.Point(0, 0), size, wx.SUNKEN_BORDER) self.parent = main_parent # make the parent object pointer passable to other procedures in the class # scrolled window properties self.imgscale = 8 self.lines = [] self.maxWidth = 1500 self.maxHeight = 1500 self.SetBackgroundColour(wx.NamedColor("WHITE")) self.SetCursor(wx.StockCursor(wx.CURSOR_CROSS)) temp_dir = os.path.join(os.path.split(demdirectory)[0],os.path.splitext(os.path.split(demdirectory)[1])[0] + '.gif') bmp = wx.Bitmap(temp_dir,wx.BITMAP_TYPE_GIF) self.bmp = bmp self.SetScrollbars(1, 1,600, 750) # some class variables self.coords = (0,0,1,1)# the box coordinates (probably redundant) self.x, self.y = 0,0 # the mouse position self.recstartx, self.recstarty = 0,0 # the rectangle start position # class events wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvent) # for when the mouse is used over the scrolled window wx.EVT_PAINT(self,self.OnPaint)# for when the window is move or resized # << class Global_tile methods >> (2 of 4) def OnMouseEvent(self,event):# the whole point of this class if event.LeftDown():# mouse down global lat_num, long_num, y_scale, x_scale,start_lat,start_long# make sure I have access to my global variables self.x, self.y = self.ConvertEventCoords(event)# get the mouse position self.recstartx, self.recstarty = self.x, self.y # set the start of the rectangle mouse position lat_num = start_lat - ((self.recstarty * self.imgscale) * y_scale)# calculate the latitude long_num = start_long + ((self.recstartx * self.imgscale) * x_scale)# calculate the longitude self.parent.Longitude.SetValue(str(long_num))# set the value of the Longitude text box self.parent.Latitude.SetValue(str(lat_num))# set the value of the Latitude text box self.CaptureMouse()# Capture all mouse events in class elif event.Dragging():# dragging the mouse dc = wx.ClientDC(self) # make a device context, client because it is not in the OnPaint method self.PrepareDC(dc)# link with class dc.BeginDrawing()# draw to the DC dc.DrawBitmapPoint(self.bmp, wx.Point(0, 0), 0)# draw the GIF from the DEM Package self.x, self.y = self.ConvertEventCoords(event)# get the mouse position dc.SetBrush(wx.TRANSPARENT_BRUSH)# make sure the square is not filled dc.SetPen(wx.Pen(wx.NamedColour('RED'), 1))# set the box outline to red 1pixel self.coords = (self.recstartx, self.recstarty) + ((self.x - self.recstartx), (self.y - self.recstarty)) # put the box in a tuple for the drawing function dc.DrawRectanglePointSize(wx.Point(self.coords[0],self.coords[1]),(self.coords[2],self.coords[3])) #apply(dc.DrawRectanglePointSize, self.coords)# draw the box dc.EndDrawing()# move the drawing to the window elif event.LeftUp():# let go of mouse button global height_num,width_num# make sure I have access to my global variables height_num = ((self.y - self.recstarty)* 8) * y_scale# calculate the height width_num = ((self.x - self.recstartx) * 8) * x_scale# calculate the width self.parent.Width.SetValue(str(width_num))# set the value of the Width text box self.parent.Height.SetValue(str(height_num))# set the value of the Height text box self.ReleaseMouse()# Release Mouse events # << class Global_tile methods >> (3 of 4) def OnPaint(self, event):# when the window is moved or uncovered dc = wx.PaintDC(self) # make a device context, paint because it is in the OnPaint method self.PrepareDC(dc)# link with class dc.BeginDrawing()# draw to the DC dc.DrawBitmapPoint(self.bmp,wx.Point( 0, 0), 0)# draw the GIF from the DEM Package dc.SetBrush(wx.TRANSPARENT_BRUSH)# make sure the square is not filled dc.SetPen(wx.Pen(wx.NamedColour('RED'), 1))# set the box outline to red 1pixel dc.DrawRectanglePointSize(wx.Point(self.coords[0],self.coords[1]),(self.coords[2],self.coords[3])) #apply(dc.DrawRectanglePointSize, self.coords)# draw the box dc.EndDrawing()# move the drawing to the window # << class Global_tile methods >> (4 of 4) def ConvertEventCoords(self, event):# gets x, y inside scrolled window xView, yView = self.GetViewStart() # Get the position at which the visible portion of the window starts. xDelta, yDelta = self.GetScrollPixelsPerUnit() # Get the number of pixels per scroll line made by SetScrollbars. return (event.GetX() + (xView * xDelta), event.GetY() + (yView * yDelta)) # -- end -- << class Global_tile methods >> # << globalDEMV methods >> (4 of 8) class ColorWindow (wx.Frame): # << class ColorWindow methods >> (1 of 3) def __init__(self,parent,colorlist): wx.Frame.__init__(self, None, -1, "Color Settings",wx.DefaultPosition,wx.Size(100,100),style = wx.DEFAULT_FRAME_STYLE) self.colorlist = colorlist self.parent = parent self.colorbuttonlist = [] self.colorbuttonsizerlist = [] for i in range(len(colorlist)): self.colorbuttonlist.append(csel.ColourSelect(self, -1, '', colorlist[i], (20,20))) wx.SafeYield for i in range(0,len(colorlist),16): self.colorbuttonsizerlist.append(wx.BoxSizer(wx.HORIZONTAL)) wx.SafeYield for j in range(16): try: self.colorbuttonsizerlist[-1].Add(self.colorbuttonlist[i+j], 1, wx.EXPAND) except: self.colorbuttonsizerlist[-1].Add(wx.Size(20,20), 1, wx.EXPAND) # self.ok = wx.Button(self, -1, 'OK', wx.DefaultPosition) wx.EVT_BUTTON(self, self.ok.GetId(), self.OnOK) #self.bind(wx.EVT_BUTTON,self.OnOK,self.ok) self.cancel = wx.Button(self, -1, 'Cancel', wx.DefaultPosition) wx.EVT_BUTTON(self, self.cancel.GetId(), self.OnCancel) #self.bind(wx.EVT_BUTTON,self.OnCancel,self.cancel) mainsizer = wx.BoxSizer(wx.VERTICAL) for i in self.colorbuttonsizerlist: mainsizer.Add(i, 1, wx.EXPAND) buttonsizer = wx.BoxSizer(wx.HORIZONTAL) buttonsizer.Add(self.ok, 1, wx.EXPAND) buttonsizer.Add(self.cancel, 1, wx.EXPAND) mainsizer.Add(buttonsizer, 1, wx.EXPAND) self.SetSizer(mainsizer) self.SetAutoLayout(1) mainsizer.Fit(self) # << class ColorWindow methods >> (2 of 3) def OnOK(self,event): colorlist = [] rx,gx,bx = [],[],[] for i in self.colorbuttonlist: clol = i.GetColour() rx.append(clol.Red()/255.0) gx.append(clol.Green()/255.0) bx.append(clol.Blue()/255.0) colorlist.append(rx) colorlist.append(gx) colorlist.append(bx) self.parent.dislinpal = None self.parent.colorlist = colorlist # << class ColorWindow methods >> (3 of 3) def OnCancel(self,event): self.Destroy() # -- end -- << class ColorWindow methods >> # << globalDEMV methods >> (5 of 8) class DislinLight (wx.Panel): # << class DislinLight methods >> (1 of 2) def __init__(self,parent,id = -1): wx.Panel.__init__(self, parent, id,wx.DefaultPosition,wx.DefaultSize) self.parent = parent self.ison = wx.CheckBox(self, -1, ' On ', wx.DefaultPosition, wx.DefaultSize, wx.NO_BORDER) sampleList = [ 'ABS', 'USER','ANGLE'] self.lightpostyp = wx.ComboBox(self, -1, 'ABS', wx.DefaultPosition, wx.DefaultSize, sampleList, wx.CB_DROPDOWN ) self.lightposX = mnum.MaskedNumCtrl( self, integerWidth=5, fractionWidth=2 ) self.lightposY = mnum.MaskedNumCtrl( self, integerWidth=5, fractionWidth=2 ) self.lightposZ = mnum.MaskedNumCtrl( self, integerWidth=5, fractionWidth=2 ) optionlist = ['AMBIENT', 'DIFFUSE', 'SPECULAR', 'CONSTANT','LINEAR','QUADRATIC'] self.lightopttyp = wx.ComboBox(self, -1, 'AMBIENT', wx.DefaultPosition, wx.DefaultSize, optionlist, wx.CB_DROPDOWN) self.lightoptparim = mnum.MaskedNumCtrl( self, integerWidth=5, fractionWidth=2 ) self.mainsizer = wx.BoxSizer(wx.VERTICAL) midsizer = wx.BoxSizer(wx.HORIZONTAL) lightoptsizer = wx.BoxSizer(wx.VERTICAL) lightpossizer = wx.BoxSizer(wx.VERTICAL) lightpossizer.Add(self.lightpostyp, 0, wx.EXPAND) lightpossizer.Add(self.lightposX, 0, wx.EXPAND) lightpossizer.Add(self.lightposY, 0, wx.EXPAND) lightpossizer.Add(self.lightposZ, 0, wx.EXPAND) midsizer.Add(lightpossizer, 1, wx.EXPAND) lightoptsizer.Add(self.lightopttyp, 0, wx.EXPAND) lightoptsizer.Add(self.lightoptparim, 0, wx.EXPAND) midsizer.Add(lightoptsizer, 1, wx.EXPAND) self.mainsizer.Add(midsizer, 1, wx.EXPAND) self.mainsizer.Add(self.ison, 0, wx.EXPAND) self.SetSizer(self.mainsizer) self.SetAutoLayout(1) self.mainsizer.Fit(self) # << class DislinLight methods >> (2 of 2) def OnSize(self,event): self.mainsizer.Fit(self) # -- end -- << class DislinLight methods >> # << globalDEMV methods >> (6 of 8) class LightWindow (wx.Frame): # << class LightWindow methods >> (1 of 3) def __init__(self,parent,thelights = None): wx.Frame.__init__(self, None, -1, "Light Settings",wx.DefaultPosition,wx.DefaultSize,style = wx.DEFAULT_FRAME_STYLE) if thelights: self.thelights = thelights else: self.thelights = {1:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],2:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],3:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],4:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],5:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],6:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],7:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],8:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']]} self.parent = parent self.lightlist = {} for i in self.thelights.keys(): self.lightlist[i] = DislinLight(self) wx.SafeYield sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer2 = wx.BoxSizer(wx.HORIZONTAL) for i in range(1,5): sizer1.Add(self.lightlist[i], 1, wx.EXPAND) for i in range(5,9): sizer2.Add(self.lightlist[i], 1, wx.EXPAND) self.ok = wx.Button(self, -1, 'OK', wx.DefaultPosition) wx.EVT_BUTTON(self, self.ok.GetId(), self.OnOK) #self.bind(wx.EVT_BUTTON,self.OnOK,self.ok) self.cancel = wx.Button(self, -1, 'Cancel', wx.DefaultPosition) wx.EVT_BUTTON(self, self.cancel.GetId(), self.OnCancel) #self.bind(wx.EVT_BUTTON,self.OnCancel,self.cancel) mainsizer = wx.BoxSizer(wx.VERTICAL) mainsizer.Add(sizer1, 1, wx.EXPAND) mainsizer.Add(sizer2, 1, wx.EXPAND) buttonsizer = wx.BoxSizer(wx.HORIZONTAL) buttonsizer.Add(self.ok, 1, wx.EXPAND) buttonsizer.Add(self.cancel, 1, wx.EXPAND) mainsizer.Add(buttonsizer, 1, wx.EXPAND) self.SetSizer(mainsizer) self.SetAutoLayout(1) mainsizer.Fit(self) # << class LightWindow methods >> (2 of 3) def OnOK(self,event): lightlist = [] lightdict = {} count = 0 for i in self.lightlist.keys(): if self.lightlist[i].ison.GetValue(): lightlist.append('ON') else: lightlist.append('OFF') count += 1 lightlist.append([long(self.lightlist[i].lightposX.GetValue()),long(self.lightlist[i].lightposY.GetValue()),long(self.lightlist[i].lightposZ.GetValue()),self.lightlist[i].lightpostyp.GetValue()]) lightlist.append([long(self.lightlist[i].lightoptparim.GetValue()),self.lightlist[i].lightopttyp.GetValue()]) lightdict[i] = lightlist lightlist = [] self.parent.lightflag = True if count == 8: self.parent.lightflag = False self.parent.thelights = lightdict # << class LightWindow methods >> (3 of 3) def OnCancel(self,event): self.parent.lightflag = False self.Destroy() # -- end -- << class LightWindow methods >> # << globalDEMV methods >> (7 of 8) class ViewerFrame(wx.Frame): # << class ViewerFrame methods >> (1 of 27) def __init__(self, parent, id, title): # First, call the base class' __init__ method to create the frame wx.Frame.__init__(self, parent, id, title,wx.DefaultPosition,wx.DefaultSize) global demdirectory,tom,long_num,start_long,lat_num,start_lat,x_scale,y_scale,Latitude_Minimum,Latitude_Maximum ,Longitude_Minimum,Longitude_Maximum self.colorlist = [] self.dislinpal = None self.lightflag = False self.thelights = {1:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],2:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],3:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],4:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],5:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],6:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],7:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']],8:['ON',[0.0,0.0,0.0,'ABS'],[0,'AMBIENT'],[0.2,'AMBIENT']]} self.Imagetest = Image.new.__init__('RGB',(853,603)) # make sure I have access to my global variables demdirectory = get_init_data(self) # get .DEM file location as well as set up data from .HDR file self.displaychoice = 'shade'# start with shade plot self.globdir = os.path.join(os.getcwd(),'glob.png') # set the file name used for transferring the data from dislin in the current working directory self.mainmenu = wx.MenuBar() # Create menu bar. menu=wx.Menu()# Make a menu (will be the Open menu) exitID=wx.NewId() # Make a new ID for a menu entry. menu.Append(exitID, '&Open', 'Open Picture') # Name the ID by adding it to the menu. wx.EVT_MENU(self, exitID, self.Picture_Open)# the menu event submenu = wx.Menu() exitID=wx.NewId()# submenu.Append(exitID, 'Small', 'Small Pallette') wx.EVT_MENU(self, exitID, self.OnPalletteSmall) exitID=wx.NewId()# submenu.Append(exitID, 'VGA', 'VGA Pallette') wx.EVT_MENU(self, exitID, self.OnPalletteVGA) exitID=wx.NewId()# submenu.Append(exitID, 'Rainbow', 'Rainbow Pallette') wx.EVT_MENU(self, exitID, self.OnPalletteRainbow) exitID=wx.NewId()# submenu.Append(exitID, 'Spec', 'More violet rainbow Pallette') wx.EVT_MENU(self, exitID, self.OnPalletteSpec) exitID=wx.NewId()# submenu.Append(exitID, 'Grey', 'Grey Pallette') wx.EVT_MENU(self, exitID, self.OnPalletteGrey) exitID=wx.NewId()# submenu.Append(exitID, 'Rev Rainbow', 'Reverse Rainbow Pallette') wx.EVT_MENU(self, exitID, self.OnPalletteRevRainbowl) exitID=wx.NewId()# submenu.Append(exitID,'Rev Spec', 'Reverse Spec Pallette') wx.EVT_MENU(self, exitID, self.OnPalletteRevSpec) exitID=wx.NewId()# submenu.Append(exitID, 'Rev Grey', 'Reverse Grey Pallette') wx.EVT_MENU(self, exitID, self.OnPalletteRevGrey) exitID=wx.NewId()# submenu.Append(exitID, 'Temp', 'Tempiture Pallette') wx.EVT_MENU(self, exitID, self.OnPalletteTemp) exitID=wx.NewId()# submenu.Append(exitID, 'Custom', 'Custom Pallette') wx.EVT_MENU(self, exitID, self.OnPallette)# the menu event exitID=wx.NewId()# Make a new ID for a menu entry. menu.AppendMenu(exitID, 'Pallette', submenu)# Name the ID by adding it to the menu. exitID=wx.NewId()# Make a new ID for a menu entry. menu.Append(exitID, 'E&xit', 'Exit program')# Name the ID by adding it to the menu. wx.EVT_MENU(self, exitID, self.Picture_Exit)# the menu event self.mainmenu.Append (menu, '&File') # Add the File menu to the menu bar. self.SetMenuBar (self.mainmenu) # Attach the menu bar to the window. # make the main splitter window one side holds the dislin picture one for the DEM GIF self.notebook = wx.Notebook(self, -1, style = wx.NB_TOP) #self.Splitter = wx.SplitterWindow(self, -1) # make sizers self.Picture_button_sizer = wx.BoxSizer(wx.HORIZONTAL) self.Picture_sizer = wx.BoxSizer(wx.VERTICAL) self.sub_Picture_button_sizer = wx.BoxSizer(wx.VERTICAL) self.sub_Picture_button_text_sizer = wx.BoxSizer(wx.VERTICAL) self.sub_Picture_button_sizer2 = wx.BoxSizer(wx.VERTICAL) self.sub_Picture_button_text_sizer2 = wx.BoxSizer(wx.VERTICAL) self.ThreeD_button_sizer = wx.BoxSizer(wx.HORIZONTAL) self.ThreeD_sizer = wx.BoxSizer(wx.VERTICAL) self.choices_sizer = wx.BoxSizer(wx.VERTICAL) self.choices_text_sizer = wx.BoxSizer(wx.VERTICAL) self.camera_sizer = wx.BoxSizer(wx.VERTICAL) self.camera_text_sizer = wx.BoxSizer(wx.VERTICAL) self.terra_sizer = wx.BoxSizer(wx.VERTICAL) self.terra_size_sizer = wx.BoxSizer(wx.HORIZONTAL) # right splitter window # panel for text and labels and scrolled window self.Picture_view = wx.Panel(self.notebook, -1, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) # The DEM gif scrolled window self.PictureWindow = Global_tile(self.Picture_view, self) # long and lat boxes with labels self.Longitude_ID = wx.NewId() self.Latitude_ID = wx.NewId() self.lattext = wx.StaticText(self.Picture_view, -1, " Latitude") self.longtext = wx.StaticText(self.Picture_view, -1, " Longitude") self.Latitude = wx.TextCtrl(self.Picture_view, self.Latitude_ID, "0", size=(125, -1)) self.Latitude.SetInsertionPoint(0) self.Latitude.SetValue(str(lat_num)) wx.EVT_TEXT(self, self.Latitude_ID, self.EvtLatitudeText) self.Longitude = wx.TextCtrl(self.Picture_view, self.Longitude_ID, "0", size=(125, -1)) self.Longitude.SetInsertionPoint(0) self.Longitude.SetValue(str(long_num)) wx.EVT_TEXT(self, self.Longitude_ID, self.EvtLongitudeText) #Height and Width boxes with lables self.widthtext = wx.StaticText(self.Picture_view, -1, " Width") self.heighttext = wx.StaticText(self.Picture_view, -1, " Height") self.Width_ID = wx.NewId() self.Height_ID = wx.NewId() self.Width = wx.TextCtrl(self.Picture_view, self.Width_ID, "0", size=(125, -1)) self.Width.SetInsertionPoint(0) self.Width.SetValue(str(width_num)) wx.EVT_TEXT(self, self.Width_ID, self.EvtText) self.Height = wx.TextCtrl(self.Picture_view, self.Height_ID, "0", size=(125, -1)) self.Height.SetInsertionPoint(0) self.Height.SetValue(str(height_num)) wx.EVT_TEXT(self, self.Height_ID, self.EvtHeightText) # right splitter window # panel for text and lables and scrolled window self.ThreeD_viewID = wx.NewId() self.ThreeD_view = wx.Panel(self.notebook, self.ThreeD_viewID, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) # The Dislin PNG scrolled window #self.ThreeDWindowID = wx.NewId() self.terra_view = wx.Panel(self.notebook, wx.NewId(), wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) # The Dislin PNG scrolled window #self.ThreeDWindowID = wx.NewId() self.terratype = wx.RadioButton( self.terra_view, -1, "Photo ", style =wx.RB_GROUP)#wx.RB_SINGLE ) self.terratype.SetValue(1) self.terratypeT = wx.RadioButton( self.terra_view, -1, "Topo " ) self.terratypeT.SetValue(0) self.Scale1m = wx.RadioButton( self.terra_view, -1, " Scale1m ", style = wx.RB_GROUP ) self.Scale1m.SetValue(0) self.Scale2m = wx.RadioButton( self.terra_view, -1, "Scale2m ") self.Scale2m.SetValue(0) self.Scale4m = wx.RadioButton( self.terra_view, -1, "Scale4m " ) self.Scale4m.SetValue(0) self.Scale8m = wx.RadioButton( self.terra_view, -1, "Scale8m " ) self.Scale8m.SetValue(0) self.Scale16m = wx.RadioButton( self.terra_view, -1, "Scale16m " ) self.Scale16m.SetValue(0) self.Scale32m = wx.RadioButton( self.terra_view, -1, "Scale32m " ) self.Scale32m.SetValue(0) self.Scale64m = wx.RadioButton( self.terra_view, -1, "Scale64m " ) self.Scale64m.SetValue(1) self.Scale128m = wx.RadioButton( self.terra_view, -1, "Scale128m " ) self.Scale128m.SetValue(0) self.Scale256m = wx.RadioButton( self.terra_view, -1, "Scale256m " ) self.Scale256m.SetValue(0) #self.glob_thing = wx.ScrolledWindow(self.ThreeD_view, self.ThreeDWindowID, wx.DefaultPosition, wx.DefaultSize, wx.SUNKEN_BORDER) self.terra_thing = image_view.ImageView(self.terra_view, -1, tools = [image_view.PanTool, image_view.ZoomTool, image_view.SharpTool , image_view.ColorTool , image_view.BrightTool , image_view.ContTool , image_view.RestoreTool, image_view.SaveTool]) # refresh button self.ThreeD_terra_thing_Button_ID = wx.NewId() self.ThreeD_terra_thing_Button = wx.Button(self.terra_view, self.ThreeD_terra_thing_Button_ID, 'Refresh', wx.DefaultPosition) wx.EVT_BUTTON(self, self.ThreeD_terra_thing_Button_ID, self.ThreeD_Refresh_Button_Press) #self.ThreeD_Refresh_Button = wx.Button(self.ThreeD_view, -1, 'Refresh', wx.DefaultPosition) #wx.EVT_BUTTON(self, self.ThreeD_Refresh_Button_ID, self.ThreeD_Refresh_Button_Press) #self.glob_thing = wx.ScrolledWindow(self.ThreeD_view, self.ThreeDWindowID, wx.DefaultPosition, wx.DefaultSize, wx.SUNKEN_BORDER) self.glob_thing = image_view.ImageView(self.ThreeD_view, -1, tools = [image_view.PanTool, image_view.ZoomTool, image_view.SharpTool , image_view.ColorTool , image_view.BrightTool , image_view.ContTool , image_view.RestoreTool, image_view.SaveTool]) # refresh button self.ThreeD_Refresh_Button_ID = wx.NewId() self.ThreeD_Refresh_Button = wx.Button(self.ThreeD_view, self.ThreeD_Refresh_Button_ID, 'Refresh', wx.DefaultPosition) wx.EVT_BUTTON(self, self.ThreeD_Refresh_Button_ID, self.ThreeD_Refresh_Button_Press) # A choice dialog for the display type self.lightbutton = wx.Button(self.ThreeD_view, -1, 'Lighting', wx.DefaultPosition) wx.EVT_BUTTON(self, self.lightbutton.GetId(), self.Lighting_Button_Press) self.displaytext = wx.StaticText(self.ThreeD_view, -1, " Display") TypeList = ['shade', 'contour', 'grid'] self.choice = wx.Choice(self.ThreeD_view, 40, (80, 50), choices = TypeList) self.choice.SetStringSelection('shade') wx.EVT_CHOICE(self, 40 , self.EvtChoice) # spin controls and lables for the contour lines, z debth, rotation angle, up angle and distance self.conttext = wx.StaticText(self.ThreeD_view, -1, " Cont. lines") self.ztext = wx.StaticText(self.ThreeD_view, -1, " Z depth") self.Cont_linesID = wx.NewId() self.Cont_lines = wx.SpinCtrl(self.ThreeD_view, self.Cont_linesID, "", wx.Point(30, 50), wx.Size(80, -1)) self.Cont_lines.SetRange(1,25) self.Cont_lines.SetValue(10) self.Z_depthID = wx.NewId() self.Z_depth = wx.SpinCtrl(self.ThreeD_view, self.Z_depthID, "", wx.Point(30, 50), wx.Size(80, -1)) self.Z_depth.SetRange(1,150) self.Z_depth.SetValue(10) self.ratext = wx.StaticText(self.ThreeD_view, -1, " R Angle") self.uatext = wx.StaticText(self.ThreeD_view, -1, " Up Angle") self.disttext = wx.StaticText(self.ThreeD_view, -1, " Distance") self.RAngle_ID = wx.NewId() self.RAngle = wx.SpinCtrl(self.ThreeD_view, self.RAngle_ID, "", wx.Point(30, 50), wx.Size(80, -1)) self.RAngle.SetRange(0,359) self.RAngle.SetValue(RSpin) wx.EVT_SPINCTRL(self, self.RAngle_ID, self.OnRSpin) self.UAngle_ID = wx.NewId() self.UAngle = wx.SpinCtrl(self.ThreeD_view, self.UAngle_ID, "", wx.Point(30, 50), wx.Size(80, -1)) self.UAngle.SetRange(0,359) self.UAngle.SetValue(USpin) wx.EVT_SPINCTRL(self, self.UAngle_ID, self.OnUSpin) self.DAngle_ID = wx.NewId() self.DAngle = wx.SpinCtrl(self.ThreeD_view, self.DAngle_ID, "", wx.Point(30, 50), wx.Size(80, -1)) self.DAngle.SetRange(0,5000) self.DAngle.SetValue(DSpin) wx.EVT_SPINCTRL(self, self.DAngle_ID, self.OnDSpin) # set up splitter window #self.Splitter.SetMinimumPaneSize(20) #self.Splitter.SplitVertically(self.ThreeD_view, self.Picture_view) #self.Splitter.SetSashPosition(300) # set up initial bitmaps for scrolled windows temp_dir = os.path.join(os.path.split(demdirectory)[0],os.path.splitext(os.path.split(demdirectory)[1])[0] + '.gif') self.view_bitmap = wx.Bitmap(temp_dir,wx.BITMAP_TYPE_GIF) self.bitmapID = wx.NewId() self.bitmap2ID = wx.NewId() #self.glob_thing = wx.StaticBitmap(self.ThreeDWindow, self.bitmap2ID,self.view_bitmap, wx.Point(0,0), wx.Size(853, 603)) self.notebook.AddPage(self.Picture_view, "Locator") self.notebook.AddPage(self.ThreeD_view, "DEMV") self.notebook.AddPage(self.terra_view, "Terra") # add everything to sizers self.sub_Picture_button_text_sizer.Add(self.lattext, 1, wx.EXPAND) self.sub_Picture_button_text_sizer.Add(self.longtext, 1, wx.EXPAND) self.sub_Picture_button_sizer.Add(self.Latitude, 1, wx.EXPAND) self.sub_Picture_button_sizer.Add(self.Longitude, 1, wx.EXPAND) self.sub_Picture_button_text_sizer2.Add(self.heighttext, 1, wx.EXPAND) self.sub_Picture_button_text_sizer2.Add(self.widthtext, 1, wx.EXPAND) self.sub_Picture_button_sizer2.Add(self.Height, 1, wx.EXPAND) self.sub_Picture_button_sizer2.Add(self.Width, 1, wx.EXPAND) self.Picture_button_sizer.Add(self.sub_Picture_button_text_sizer, 1, wx.EXPAND) self.Picture_button_sizer.Add(self.sub_Picture_button_sizer, 1, wx.EXPAND) self.Picture_button_sizer.Add(self.sub_Picture_button_text_sizer2, 1, wx.EXPAND) self.Picture_button_sizer.Add(self.sub_Picture_button_sizer2, 1, wx.EXPAND) self.Picture_sizer.Add(self.Picture_button_sizer, 1, wx.EXPAND) self.Picture_sizer.Add(self.PictureWindow, 10, wx.EXPAND) self.Picture_view.SetSizer(self.Picture_sizer) self.Picture_view.SetAutoLayout(1) self.Picture_sizer.Fit(self.Picture_view) self.camera_text_sizer.Add(self.ratext, 1, wx.EXPAND) self.camera_text_sizer.Add(self.uatext, 1, wx.EXPAND) self.camera_text_sizer.Add(self.disttext, 1, wx.EXPAND) self.camera_sizer.Add(self.RAngle, 1, wx.EXPAND) self.camera_sizer.Add(self.UAngle, 1, wx.EXPAND) self.camera_sizer.Add(self.DAngle, 1, wx.EXPAND) self.ThreeD_button_sizer.Add(self.ThreeD_Refresh_Button, 1, wx.EXPAND) self.ThreeD_button_sizer.Add(self.lightbutton, 1, wx.EXPAND) self.ThreeD_button_sizer.Add(self.camera_text_sizer, 1, wx.EXPAND) self.ThreeD_button_sizer.Add(self.camera_sizer, 1, wx.EXPAND) self.choices_sizer.Add(self.choice, 1, wx.EXPAND) self.choices_sizer.Add(self.Cont_lines, 1, wx.EXPAND) self.choices_sizer.Add(self.Z_depth, 1, wx.EXPAND) self.choices_text_sizer.Add(self.displaytext, 1, wx.EXPAND) self.choices_text_sizer.Add(self.conttext, 1, wx.EXPAND) self.choices_text_sizer.Add(self.ztext, 1, wx.EXPAND) self.ThreeD_button_sizer.Add(self.choices_text_sizer, 1, wx.EXPAND) self.ThreeD_button_sizer.Add(self.choices_sizer, 1, wx.EXPAND) self.ThreeD_sizer.Add(self.ThreeD_button_sizer, 1, wx.EXPAND) self.ThreeD_sizer.Add(self.glob_thing, 10, wx.EXPAND) self.ThreeD_view.SetSizer(self.ThreeD_sizer) self.ThreeD_view.SetAutoLayout(1) self.ThreeD_sizer.Fit(self.ThreeD_view) self.terratyp_sizer = wx.BoxSizer(wx.HORIZONTAL) self.terrascale_sizer = wx.BoxSizer(wx.HORIZONTAL) self.terrascaleb_sizer = wx.BoxSizer(wx.HORIZONTAL) self.terrascale_all_sizer = wx.BoxSizer(wx.VERTICAL) self.terra_size_sizer.Add(self.ThreeD_terra_thing_Button, 1, wx.EXPAND) self.terratyp_sizer.Add(self.terratype, 1, wx.EXPAND) self.terratyp_sizer.Add(self.terratypeT, 1, wx.EXPAND) self.terra_size_sizer.Add(self.terratyp_sizer, 5, wx.EXPAND) self.terrascale_sizer.Add(self.Scale1m, 1, wx.EXPAND) self.terrascale_sizer.Add(self.Scale2m , 1, wx.EXPAND) self.terrascale_sizer.Add(self.Scale4m , 1, wx.EXPAND) self.terrascale_sizer.Add(self.Scale8m , 1, wx.EXPAND) self.terrascale_sizer.Add(self.Scale16m , 1, wx.EXPAND) self.terrascale_all_sizer.Add(self.terrascale_sizer , 1, wx.EXPAND) self.terrascaleb_sizer.Add(self.Scale32m , 1, wx.EXPAND) self.terrascaleb_sizer.Add(self.Scale64m , 1, wx.EXPAND) self.terrascaleb_sizer.Add(self.Scale128m , 1, wx.EXPAND) self.terrascaleb_sizer.Add(self.Scale256m , 1, wx.EXPAND) self.terrascale_all_sizer.Add(self.terrascaleb_sizer , 1, wx.EXPAND) self.terra_size_sizer.Add(self.terrascale_all_sizer , 10, wx.EXPAND) self.terra_sizer.Add(self.terra_size_sizer, 1, wx.EXPAND) self.terra_sizer.Add(self.terra_thing, 10, wx.EXPAND) self.terra_view.SetSizer(self.terra_sizer) self.terra_view.SetAutoLayout(1) self.terra_sizer.Fit(self.terra_view) #make sure that the right controls are displayed self.UAngle.Show(0) self.DAngle.Show(0) self.RAngle.Show(0) self.ratext.Show(0) self.uatext.Show(0) self.disttext.Show(0) self.conttext.Show(0) self.ztext.Show(0) self.Cont_lines.Show(0) self.Z_depth.Show(0) # << class ViewerFrame methods >> (2 of 27) def OnCloseWindow(self, event): # close the DEM file tom.close() # tell the window to kill itself self.Destroy() # << class ViewerFrame methods >> (3 of 27) def Picture_Open(self, event): # run the get_init_data function and reset bitmaps and text boxes in DEM gif scrolled window global demdirectory demdirectory = get_init_data(self) temp_dir = os.path.join(os.path.split(demdirectory)[0],os.path.splitext(os.path.split(demdirectory)[1])[0] + '.gif') bitmap = wx.Bitmap(temp_dir,wx.BITMAP_TYPE_GIF) self.PictureWindow.bmp = bitmap self.PictureWindow.Refresh() self.Longitude.SetValue(str(long_num)) self.Latitude.SetValue(str(lat_num)) self.Height.SetValue(str(height_num)) self.Width.SetValue(str(width_num)) # << class ViewerFrame methods >> (4 of 27) def Lighting_Button_Press(self, event): self.LW = LightWindow(self) self.LW.Show() wx.SafeYield # << class ViewerFrame methods >> (5 of 27) def OnPalletteVGA(self, event): self.dislinpal = 'VGA' # << class ViewerFrame methods >> (6 of 27) def OnPalletteRainbow(self, event): self.dislinpal = 'RAIN' # << class ViewerFrame methods >> (7 of 27) def OnPalletteSpec(self, event): self.dislinpal = 'SPEC' # << class ViewerFrame methods >> (8 of 27) def OnPalletteGrey(self, event): self.dislinpal = 'GREY' # << class ViewerFrame methods >> (9 of 27) def OnPalletteRevRainbowl(self, event): self.dislinpal = 'RRAIN' # << class ViewerFrame methods >> (10 of 27) def OnPalletteRevSpec(self, event): self.dislinpal = 'RSPEC' # << class ViewerFrame methods >> (11 of 27) def OnPalletteRevGrey(self, event): self.dislinpal = 'RGREY' # << class ViewerFrame methods >> (12 of 27) def OnPalletteTemp(self, event): self.dislinpal = 'TEMP' # << class ViewerFrame methods >> (13 of 27) def OnPalletteSmall(self, event): self.dislinpal = 'SMALL' # << class ViewerFrame methods >> (14 of 27) def OnPallette(self, event): dislin.disini() r,g,b = 0.0,0.0,0.0 colorlist = [] for i in range(255): col = dislin.getind(i) colorlist.append((int(col[0]*255),int(col[1]*255),int(col[2]*255))) dislin.disfin() wx.SafeYield self.colorwin = ColorWindow(self,colorlist) self.colorwin.Show() # << class ViewerFrame methods >> (15 of 27) def EvtChoice(self, event):# if the display choice is changed self.displaychoice = event.GetString() if self.displaychoice == 'shade': self.UAngle.Show(0)# makeing sure only appropriate controls are displayed self.DAngle.Show(0) self.RAngle.Show(0) self.ratext.Show(0) self.uatext.Show(0) self.disttext.Show(0) self.conttext.Show(0) self.ztext.Show(0) self.Cont_lines.Show(0) self.Z_depth.Show(0) elif self.displaychoice == 'contour': self.UAngle.Show(0) self.DAngle.Show(0) self.RAngle.Show(0) self.ratext.Show(0) self.uatext.Show(0) self.disttext.Show(0) self.conttext.Show(1) self.ztext.Show(0) self.Cont_lines.Show(1) self.Z_depth.Show(0) elif self.displaychoice == 'grid': self.UAngle.Show(1) self.DAngle.Show(1) self.RAngle.Show(1) self.ratext.Show(1) self.uatext.Show(1) self.disttext.Show(1) self.conttext.Show(0) self.ztext.Show(1) self.Cont_lines.Show(0) self.Z_depth.Show(1) # << class ViewerFrame methods >> (16 of 27) def OnRSpin(self, event):# rotation angle has changed RSpin = self.RAngle.GetValue() # << class ViewerFrame methods >> (17 of 27) def OnUSpin(self, event):# up angle has changed USpin = self.UAngle.GetValue() # << class ViewerFrame methods >> (18 of 27) def OnDSpin(self, event):# distance has changed DSpin = self.DAngle.GetValue() # << class ViewerFrame methods >> (19 of 27) def EvtLatitudeText(self, event):# Latitude has changed try: # while you type in a new number some of the characters # don?t make since so we just pass till it makes since my_lat_num = float(event.GetString()) my_height_num = float(self.Height.GetValue()) if my_lat_num > Latitude_Minimum and my_lat_num < Latitude_Maximum:# is it in scale temp = int((-(my_lat_num - start_lat)/ y_scale)/ 8)# convert from lat to bitmap cooranants if temp != self.PictureWindow.recstarty:# is it the same spot on the bitmap # the same drawing procedure used in the Global_tile class self.PictureWindow.recstarty = temp self.PictureWindow.y = int(((my_height_num / y_scale) / 8) + self.PictureWindow.recstarty) self.PictureWindow.coords = (self.PictureWindow.recstartx, self.PictureWindow.recstarty) + ((self.PictureWindow.x - self.PictureWindow.recstartx), (self.PictureWindow.y - self.PictureWindow.recstarty)) dc = wx.ClientDC(self.PictureWindow) self.PictureWindow.PrepareDC(dc) dc.BeginDrawing() dc.DrawBitmapPoint(self.PictureWindow.bmp,wx.Point( 0, 0), 0) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.SetPen(wx.Pen(wx.NamedColour('RED'), 1)) dc.DrawRectanglePointSize(wx.Point(self.PictureWindow.coords[0],self.PictureWindow.coords[1]),(self.PictureWindow.coords[2],self.PictureWindow.coords[3])) #apply(dc.DrawRectanglePointSize, self.PictureWindow.coords) dc.EndDrawing() except ValueError: pass # << class ViewerFrame methods >> (20 of 27) def EvtLongitudeText(self, event):# Longitude has changed try:# while you type in a new number some of the characters # don?t make since so we just pass till it makes since my_long_num = float(event.GetString()) my_width_num = float(self.Width.GetValue()) if my_long_num > Longitude_Minimum and my_long_num < Longitude_Maximum:# is it in scale temp = int(((my_long_num - start_long) / x_scale)/ 8)# convert from long to bitmap cooranants if temp != self.PictureWindow.recstartx:# is it the same spot on the bitmap self.PictureWindow.recstartx = temp self.PictureWindow.x = int(((my_width_num / x_scale) / 8) + self.PictureWindow.recstartx) self.PictureWindow.coords = (self.PictureWindow.recstartx, self.PictureWindow.recstarty) + ((self.PictureWindow.x - self.PictureWindow.recstartx), (self.PictureWindow.y - self.PictureWindow.recstarty)) dc = wx.ClientDC(self.PictureWindow) self.PictureWindow.PrepareDC(dc) dc.BeginDrawing() dc.DrawBitmapPoint(self.PictureWindow.bmp,wx.Point( 0, 0), 0) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.SetPen(wx.Pen(wx.NamedColour('RED'), 1)) dc.DrawRectanglePointSize(wx.Point(self.PictureWindow.coords[0],self.PictureWindow.coords[1]),(self.PictureWindow.coords[2],self.PictureWindow.coords[3])) #apply(dc.DrawRectanglePointSize, self.PictureWindow.coords) dc.EndDrawing() except ValueError: pass # << class ViewerFrame methods >> (21 of 27) def EvtText(self, event): try:# while you type in a new number some of the characters # don?t make since so we just pass till it makes since my_width_num = float(event.GetString()) temp = int(((my_width_num / x_scale) / 8) + self.PictureWindow.recstartx) if temp != self.PictureWindow.x: self.PictureWindow.x = temp self.PictureWindow.coords = (self.PictureWindow.recstartx, self.PictureWindow.recstarty) + ((self.PictureWindow.x - self.PictureWindow.recstartx), (self.PictureWindow.y - self.PictureWindow.recstarty)) dc = wx.ClientDC(self.PictureWindow) self.PictureWindow.PrepareDC(dc) dc.BeginDrawing() dc.DrawBitmapPoint(self.PictureWindow.bmp, wx.Point(0, 0), 0) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.SetPen(wx.Pen(wx.NamedColour('RED'), 1)) dc.DrawRectanglePointSize(wx.Point(self.PictureWindow.coords[0],self.PictureWindow.coords[1]),(self.PictureWindow.coords[2],self.PictureWindow.coords[3])) #apply(dc.DrawRectanglePointSize, self.PictureWindow.coords) dc.EndDrawing() except ValueError: pass # << class ViewerFrame methods >> (22 of 27) def EvtHeightText(self, event): try:# while you type in a new number some of the characters # don?t make since so we just pass till it makes since my_height_num = float(event.GetString()) temp = int(((my_height_num / y_scale) / 8) + self.PictureWindow.recstarty) if temp != self.PictureWindow.y: self.PictureWindow.y = temp self.PictureWindow.coords = (self.PictureWindow.recstartx, self.PictureWindow.recstarty) + ((self.PictureWindow.x - self.PictureWindow.recstartx), (self.PictureWindow.y - self.PictureWindow.recstarty)) dc = wx.ClientDC(self.PictureWindow) self.PictureWindow.PrepareDC(dc) dc.BeginDrawing() dc.DrawBitmapPoint(self.PictureWindow.bmp, wx.Point(0, 0), 0) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.SetPen(wx.Pen(wx.NamedColour('RED'), 1)) dc.DrawRectanglePointSize(wx.Point(self.PictureWindow.coords[0],self.PictureWindow.coords[1]),(self.PictureWindow.coords[2],self.PictureWindow.coords[3])) #apply(dc.DrawRectanglePointSize, self.PictureWindow.coords) dc.EndDrawing() except ValueError: pass # << class ViewerFrame methods >> (23 of 27) def Picture_Exit(self, event): # close the DEM file tom.close() # tell the window to kill itself self.Destroy() # << class ViewerFrame methods >> (24 of 27) def ThreeD_Refresh_Button_Press(self, event): # where Everything is happening #hi_num = 0# there?s a master list of elevation for each tile of the DEM data #lo_num = 4328# so I could use some kind of look up table but this way is just as easy new_line = [] data_char = '' data_line_num = (self.PictureWindow.coords[2] * 16) # width of box 8 to 1 data to gif ratio 16 bit variable in a string for x in range((self.PictureWindow.coords[1] * 8),(self.PictureWindow.coords[1] + self.PictureWindow.coords[3]) * 8): # iterate over height data_start = (x * 9600) + (self.PictureWindow.coords[0] * 16) # find start position of rectangle in file (the number 9600 bytes per line # should probably be in a variable) tom.seek(data_start)# move to proper position in file data_char = tom.read(data_line_num)# read proper number of bytes for i in range(0, len(data_char) - 1, 2):# iterate over the characters by 2s # its a 16 bit signed integer which means that there has got to be # a more elegant way of doing this but I was lazy data_num = struct.unpack('>h',data_char[i:i+2])[0] #data_num = (ord(data_char[i]) << 8) | ord(data_char[i+1]) #if data_num == 55537:#sea level # data_num = 0 #if data_num >= 32767: # data_num = -(data_num ^ 65535) if data_num == -9999:#sea level data_num = 0 new_line.append(data_num) img_size = ((self.PictureWindow.coords[2] * 8) , (self.PictureWindow.coords[3] * 8) ) # Image size for dislin # this could be an error spot on some systems if self.displaychoice == 'shade':# call the shade routine self.dis_img(new_line, img_size[1], img_size[0], min(new_line),max(new_line)) elif self.displaychoice == 'grid':# call the grid routine self.dis_img2(new_line,img_size[1],img_size[0],min(new_line),max(new_line)) elif self.displaychoice == 'contour':# call the contour routine self.dis_img3(new_line,img_size[1],img_size[0], min(new_line),max(new_line)) self.glob_thing.set_image(self.Imagetest) if self.Scale1m.GetValue(): thescale = "Scale1m" elif self.Scale2m.GetValue(): thescale = "Scale2m" elif self.Scale4m.GetValue(): thescale = "Scale4m" elif self.Scale8m.GetValue(): thescale = "Scale8m" elif self.Scale16m.GetValue(): thescale = "Scale16m" elif self.Scale32m.GetValue(): thescale = "Scale32m" elif self.Scale64m.GetValue(): thescale = "Scale64m" elif self.Scale128m.GetValue(): thescale = "Scale128m" elif self.Scale256m.GetValue(): thescale = "Scale256m" if self.terratype.GetValue(): thetype = 'Photo' elif self.terratypeT.GetValue(): thetype = 'Topo' strng = str(self.Longitude.GetValue()) lngg = float(strng) strng = str(self.Latitude.GetValue()) latt = float(strng) strng = str(self.Height.GetValue()) lng2 = lngg + float(strng) strng = str(self.Width.GetValue()) lat2 = latt - float(strng) thezone = TerraImage.zonefromLng(lngg) #filename = StringIO.StringIO()#'c:\\python23\\tom2\\terrtest2.jpg' upperLeft = TerraImage.point(latt,lngg) lowerRight = TerraImage.point(lat2,lng2) #upperLeft = TerraImage.point(34.8,-112.1) #lowerRight = TerraImage.point(34.4,-111.7) uL = pyTerra.ConvertLonLatPtToUtmPt(upperLeft) lR = pyTerra.ConvertLonLatPtToUtmPt(lowerRight) upperLeft = TerraImage.utm(uL.X, uL.Y, uL.Zone) lowerRight = TerraImage.utm(lR.X, lR.Y, lR.Zone) ti = TerraImage.TerraImage(upperLeft,lowerRight,thescale,thetype,thezone) ti._get_extent() flenm = ti._get_tile_dataImg(format='JPEG') #flenm = Image.open(filename) self.terra_thing.set_image(flenm) del ti # << class ViewerFrame methods >> (25 of 27) def dis_img(self, zmat, n, m, zl, zh):# shade routine char = '' temp_Width = 1 temp_Height = 1 temp_lat = 1 temp_long = 1 newmat = [] max_bytes = 0 for i in range(m-1,-1,-1):# transform the rectangle for j in range(n): newmat.append(zmat[(j*m)+i]) newmat.reverse() # get the lat, long, height and width for lables try: temp_Width = float(self.Width.GetValue()) temp_Height = float(self.Height.GetValue()) except ValueError: temp_Width = 1 temp_Height = 1 try: temp_lat = float(self.Latitude.GetValue()) temp_long = float(self.Longitude.GetValue()) except ValueError: temp_lat = lat_num temp_long = long_num if zl == zh: zl = 0 zh = 10 dislin.metafl('VIRT')# level 0,sets the file type dislin.setpag('da4l')# page size and orientation dislin.setfil(self.globdir)# file name dislin.disini()# level 1, change to level 1 dislin.pagera()# plots a border around the page dislin.hwfont()# sets default font if self.dislinpal: dislin.setvlt(self.dislinpal) elif self.colorlist != []: dislin.myvlt(self.colorlist[0],self.colorlist[1],self.colorlist[2],255) dislin.name ('Latitude', 'Y') dislin.name ('Longitude', 'X') dislin.name ('Meters', 'Z') if (m * (1400 / n))< 2000: dislin.ax3len(m * (1400 / n), 1400, 1400) else: dislin.ax3len(2000, n * (2000 / m), 1400) #dislin.shdmod('poly', 'contur') dislin.shdmod('smooth', 'surface') #dislin.shdmod('cell', 'contur') dislin.autres(m, n) # level 3 dislin.graf3(temp_long, temp_long + temp_Width, temp_long, temp_Width/5, temp_lat - temp_Height, temp_lat , temp_lat - temp_Height, temp_Height / 5, zl, zh, zl, (zh-zl)/10) dislin.crvmat(newmat, m, n, 100, 100) dislin.title() char_buff = dislin.rbfpng(max_bytes) max_bytes = int(char_buff[1]) char_buff = dislin.rbfpng(max_bytes) char = char_buff[0] self.Imagetest = Image.open(StringIO.StringIO(char)) dislin.disfin() # << class ViewerFrame methods >> (26 of 27) def dis_img2(self, zmat, n, m, zl, zh): char = '' max_bytes = 0 newmat = [] for i in range(m): for j in range(n): newmat.append(zmat[(j*m)+i]) newmat.reverse() zmat = newmat try: temp_Width = float(self.Width.GetValue()) temp_Height = float(self.Height.GetValue()) except ValueError: temp_Width = 1 temp_Height = 1 try: temp_lat = float(self.Latitude.GetValue()) temp_long = float(self.Longitude.GetValue()) except ValueError: temp_lat = lat_num temp_long = long_num if zl == zh: zl = 0 zh = 10 xray = range (m) yray = range (n) for i in range(n): yray[i] = temp_lat - ((temp_Height / n) * i) for i in range(m): xray[i] = temp_long + ((temp_Width / m) * i) RSpin = self.RAngle.GetValue() USpin = self.UAngle.GetValue() DSpin = self.DAngle.GetValue() z_debth = self.Z_depth.GetValue() dislin.metafl ('VIRT') dislin.setpag ('da4l') dislin.setfil (self.globdir) dislin.disini () dislin.pagera () dislin.hwfont () if self.dislinpal: dislin.setvlt(self.dislinpal) elif self.colorlist != []: dislin.myvlt(self.colorlist[0],self.colorlist[1],self.colorlist[2],255) if self.lightflag: dislin.light('ON') for i in self.thelights.keys(): dislin.litmod(i,self.thelights[i][0]) dislin.litpos(i, self.thelights[i][1][0], self.thelights[i][1][1], self.thelights[i][1][2], self.thelights[i][1][3]) dislin.litopt(i, self.thelights[i][2][0], self.thelights[i][2][1]) dislin.name ('Latitude', 'Y') dislin.name ('Longitude', 'X') dislin.axis3d(m, n, z_debth) dislin.view3d(RSpin, USpin, DSpin, 'ANGLE') dislin.shdmod('smooth', 'surface') dislin.color('BLUE') dislin.graf3d(temp_long, temp_long + temp_Width, temp_long, temp_Width/5, temp_lat - temp_Height, temp_lat , temp_lat - temp_Height, temp_Height / 5, zl, zh, zl, (zh-zl)/10) #dislin.graf3d(temp_lat ,temp_lat + temp_Width , temp_lat , temp_Width/5, temp_long, temp_long + temp_Height, temp_long,temp_Height/5, zl, zh, zl, (zh-zl)/5)--temp_long, temp_long + temp_Height, temp_long, temp_Height/5, temp_lat - temp_Width, temp_lat , temp_lat - temp_Width, temp_Width/5, dislin.surshd(xray, m, yray,n, zmat) dislin.title() char_buff = dislin.rbfpng(max_bytes) max_bytes = int(char_buff[1]) char_buff = dislin.rbfpng(max_bytes) char = char_buff[0] self.Imagetest = Image.open(StringIO.StringIO(char)) dislin.disfin() # << class ViewerFrame methods >> (27 of 27) def dis_img3(self, zmat, n, m, zl, zh): char = '' max_bytes = 0 newmat = [] for i in range(m): for j in range(n): newmat.append(zmat[(j*m)+i]) try: temp_Width = float(self.Width.GetValue()) temp_Height = float(self.Height.GetValue()) temp_lat = float(self.Latitude.GetValue()) temp_long = float(self.Longitude.GetValue()) except ValueError: temp_lat = lat_num temp_long = long_num temp_Width = 1 temp_Height = 1 if zl == zh: zl = 0 zh = 10 xray = range (m) yray = range (n) c_lines = self.Cont_lines.GetValue() for i in range(n): yray[i] = temp_lat - ((temp_Height / n) * i) for i in range(m): xray[i] = temp_long + ((temp_Width / m) * i) dislin.metafl('VIRT') dislin.setpag('da4l') dislin.setfil(self.globdir) dislin.disini() dislin.pagera() dislin.hwfont() if self.dislinpal: dislin.setvlt(self.dislinpal) elif self.colorlist != []: dislin.myvlt(self.colorlist[0],self.colorlist[1],self.colorlist[2],255) dislin.complx() dislin.name ('Latitude', 'Y') dislin.name ('Longitude', 'X') if (m * (1400 / n))< 2000: dislin.axslen(m * (1400 / n), 1400) else: dislin.axslen(2000,n * (2000 / m)) dislin.graf(temp_long, temp_long + temp_Width, temp_long, temp_Width/5, temp_lat - temp_Height, temp_lat , temp_lat - temp_Height, temp_Height/5) #dislin.graf(temp_lat,temp_lat + temp_Width, temp_lat , temp_Width/5,temp_long, temp_long + temp_Height, temp_long,temp_Height/5) dislin.height (25) for i in range (c_lines -1 ): zlev = (i * ((zh-zl) / c_lines)) + zl dislin.labels ('FLOAT', 'CONTUR') dislin.setclr ((i+1) * int(255/c_lines)) dislin.contur (xray, m, yray, n, newmat, zlev) char_buff = dislin.rbfpng(max_bytes) max_bytes = int(char_buff[1]) char_buff = dislin.rbfpng(max_bytes) char = char_buff[0] self.Imagetest = Image.open(StringIO.StringIO(char)) dislin.disfin() # -- end -- << class ViewerFrame methods >> # << globalDEMV methods >> (8 of 8) class MyApp(wx.App): # << class MyApp methods >> def OnInit(self): # Create an instance of our customized Frame class frame = ViewerFrame(None, -1, "Digital Elevation Model Viewer") frame.Show(True)# Tell wx.Windows that this is our main window self.SetTopWindow(frame) # Return a success flag return True # -- end -- << class MyApp methods >> # -- end -- << globalDEMV methods >> app = MyApp(0) # Create an instance of the application class app.MainLoop() # Tell it to start processing events