[GRASS-SVN] r47056 - grass-addons/grass7/gui/wxpython/wx.wms

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jul 8 00:08:04 EDT 2011


Author: sudeepsingh
Date: 2011-07-07 21:08:04 -0700 (Thu, 07 Jul 2011)
New Revision: 47056

Added:
   grass-addons/grass7/gui/wxpython/wx.wms/WMSMapDisplay.py
Modified:
   grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
   grass-addons/grass7/gui/wxpython/wx.wms/wxgui.py
Log:
functionality added for displaying Map fetched in a New Window

Added: grass-addons/grass7/gui/wxpython/wx.wms/WMSMapDisplay.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/WMSMapDisplay.py	                        (rev 0)
+++ grass-addons/grass7/gui/wxpython/wx.wms/WMSMapDisplay.py	2011-07-08 04:08:04 UTC (rev 47056)
@@ -0,0 +1,24 @@
+import wx
+import  cStringIO
+
+class ImagePanel(wx.Panel):
+   def __init__(self, parent, id):
+    wx.Panel.__init__(self, parent, id)
+    try:
+        imageFile = 'map.png'
+        data = open(imageFile, "rb").read()
+        stream = cStringIO.StringIO(data) 
+        bmp = wx.BitmapFromImage( wx.ImageFromStream( stream )) 
+        wx.StaticBitmap(self, -1, bmp, (5, 5))          
+        png = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap() 
+        wx.StaticBitmap(self, -1, png, (10 + png.GetWidth(), 5), (png.GetWidth(), png.GetHeight()))
+    except IOError:
+        print "Image file %s not found" % imageFile
+        raise SystemExit
+
+def NewImageFrame(): 
+    NewWindowapp = wx.PySimpleApp()
+    NewWindowframe = wx.Frame(None, -1, "Map Display", size = (400, 300))
+    ImagePanel(NewWindowframe,-1)
+    NewWindowframe.Show(1)
+    NewWindowapp.MainLoop()

Modified: grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py	2011-07-08 00:24:57 UTC (rev 47055)
+++ grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py	2011-07-08 04:08:04 UTC (rev 47056)
@@ -1,16 +1,15 @@
 #!/usr/bin/python
- 
 
+
 from urllib2 import Request, urlopen, URLError, HTTPError
 import wx
 from parse import parsexml
-import cStringIO
-from image import NewImageFrame
+from WMSMapDisplay import NewImageFrame
 
-class WMSGUI(wx.Frame):
+class Example(wx.Frame):
   
     def __init__(self, parent, title):
-        super(WMSGUI, self).__init__(parent, title=title, 
+        super(Example, self).__init__(parent, title=title, 
             size=(390, 350))
             
         self.InitUI()
@@ -69,7 +68,7 @@
 
         self.hbox5 = wx.BoxSizer(wx.HORIZONTAL)
         
-        self.btn1 = wx.Button(self.panel, label='GetMaps', size=(150, 30))
+        self.btn1 = wx.Button(self.panel, label='Get Map', size=(150, 30))
         self.hbox5.Add(self.btn1)
         self.btn2 = wx.Button(self.panel, label='GetCapabilities', size=(150, 30))
         self.hbox5.Add(self.btn2, flag=wx.LEFT|wx.BOTTOM, border=5)
@@ -81,6 +80,7 @@
         self.panel.SetSizer(self.vbox)
         
         self.tc.SetValue('http://www.gisnet.lv/cgi-bin/topo?request=GetCapabilities&service=wms')
+        #service=WMS&request=GetMap http://www.gisnet.lv/cgi-bin/topo?service=WMS&request=GetMap&version=1.1.1&format=image/png&width=800&height=600&srs=EPSG:4326&layers=Atlants&bbox=-180,0,0,90
 
     def OnServerManagment(self, event):
         url = self.tc.GetValue()
@@ -93,18 +93,16 @@
 	    outfile.write(image)
 	    outfile.close()
 	    
+	    
 	    NewImageFrame()
-        
 	    
+	    
 	except HTTPError, e:
 	    print 'The server couldn\'t fulfill the request.'
 	    print 'Error code: ', e.code
 	except URLError, e:
 	    print 'We failed to reach a server.'
 	    print 'Reason: ', e.reason
-	except IOError:
-       	    print "Image file %s not found" % imageFile
-            raise SystemExit
 	else:
 	    print 'Successful'
 
@@ -130,22 +128,10 @@
 	    print 'Reason: ', e.reason
 	else:
 	    print 'Successful'
-'''
-class MyAppsudeep(wx.App):
-    def OnInit(self):
-        frame = MyToolBar(None, -1, 'toolbar.py')
-        frame.Show(True)
-        return True
-'''
-def func():
+
+def DisplayWMSMenu():
 	app = wx.App()
    	WMSGUI(None, title='WMS')
      	app.MainLoop()
 	
-	'''
-
-if __name__ == '__main__':
-  
-    app = wx.App()
-    WMSGUI(None, title='WMS')
-    app.MainLoop() '''
+	

Modified: grass-addons/grass7/gui/wxpython/wx.wms/wxgui.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/wxgui.py	2011-07-08 00:24:57 UTC (rev 47055)
+++ grass-addons/grass7/gui/wxpython/wx.wms/wxgui.py	2011-07-08 04:08:04 UTC (rev 47056)
@@ -81,7 +81,7 @@
 from gui_modules import gmodeler
 from gui_modules import vclean
 from gui_modules import nviz_tools
-from gui_modules.wmsmenu import func as func1 #sudeep
+from gui_modules.wmsmenu import DisplayWMSMenu #sudeep
 from gui_modules.debug    import Debug
 from gui_modules.ghelp    import MenuTreeWindow, AboutWindow, InstallExtensionWindow
 from gui_modules.toolbars import LMWorkspaceToolbar, LMDataToolbar, LMToolsToolbar, LMMiscToolbar
@@ -1183,54 +1183,8 @@
 
     def NewDisplay1(self, show = True):
         Debug.msg(1, "GMFrame.NewDisplay(): idx=%d" % self.disp_idx)
-    	func1()
+    	DisplayWMSMenu()
     	
-    	
-        """!Create new layer tree, which will
-        create an associated map display frame
-
-        @param show show map display window if True
-
-        @return reference to mapdisplay intance
-        """
-  	'''      Debug.msg(1, "GMFrame.NewDisplay(): idx=%d" % self.disp_idx)
-        
-        # make a new page in the bookcontrol for the layer tree (on page 0 of the notebook)
-        self.pg_panel = wx.Panel(self.gm_cb, id = wx.ID_ANY, style = wx.EXPAND)
-        self.gm_cb.AddPage(self.pg_panel, text = "Display "+ str(self.disp_idx + 1), select = True)
-        self.curr_page = self.gm_cb.GetCurrentPage()
-        
-        # create layer tree (tree control for managing GIS layers)  and put on new notebook page
-        self.curr_page.maptree = layertree.LayerTree(self.curr_page, id = wx.ID_ANY, pos = wx.DefaultPosition,
-                                                     size = wx.DefaultSize, style = wx.TR_HAS_BUTTONS |
-                                                     wx.TR_LINES_AT_ROOT| wx.TR_HIDE_ROOT |
-                                                     wx.TR_DEFAULT_STYLE| wx.NO_BORDER | wx.FULL_REPAINT_ON_RESIZE,
-                                                     idx = self.disp_idx, lmgr = self, notebook = self.gm_cb,
-                                                     auimgr = self._auimgr, showMapDisplay = show)
-        
-        # layout for controls
-        cb_boxsizer = wx.BoxSizer(wx.VERTICAL)
-        cb_boxsizer.Add(self.curr_page.maptree, proportion = 1, flag = wx.EXPAND, border = 1)
-        self.curr_page.SetSizer(cb_boxsizer)
-        cb_boxsizer.Fit(self.curr_page.maptree)
-        self.curr_page.Layout()
-        self.curr_page.maptree.Layout()
-        
-        # use default window layout
-        if UserSettings.Get(group = 'general', key = 'defWindowPos', subkey = 'enabled'):
-            dim = UserSettings.Get(group = 'general', key = 'defWindowPos', subkey = 'dim')
-            idx = 4 + self.disp_idx * 4
-            try:
-                x, y = map(int, dim.split(',')[idx:idx + 2])
-                w, h = map(int, dim.split(',')[idx + 2:idx + 4])
-                self.curr_page.maptree.mapdisplay.SetPosition((x, y))
-                self.curr_page.maptree.mapdisplay.SetSize((w, h))
-            except:
-                pass
-        
-        self.disp_idx += 1
-        
-        return self.curr_page.maptree.mapdisplay'''
     def OnNewDisplay(self, event = None):
         """!Create new layer tree and map display instance"""
         self.NewDisplay()



More information about the grass-commit mailing list