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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Sep 18 12:18:45 EDT 2011


Author: sudeepsingh
Date: 2011-09-18 09:18:45 -0700 (Sun, 18 Sep 2011)
New Revision: 48349

Modified:
   grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
Log:
Comments added

Modified: grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py	2011-09-18 16:08:54 UTC (rev 48348)
+++ grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py	2011-09-18 16:18:45 UTC (rev 48349)
@@ -36,6 +36,8 @@
 
 
 class newLayerData():
+    """!Data structure to hold relevant details about a fetched layer
+    """
     name = None
     title = None
     abstract = None
@@ -45,12 +47,22 @@
 
 
 class LayerData():
+    """!LayerData class to manage LayerTree (Widget used to display fetched layers).
+    Includes functionality to add new layers in the LayerTree
+    """
     name = None
     title = None
     abstract = None
     srs = None
     
     def printLayerData(self,layerDataDict):
+     """
+     @description:Function to print dictionary structure holding information of
+                  layers with keys as integers and values as objects of type LayerData() 
+     @todo:None
+     @param1:reference variable
+     @param2:Dictionary holding values of type LayerData() object with keys as integers from 0 to len(layerDataDict)
+     """
         for key, value in layerDataDict.iteritems():
             print key
             print value.name
@@ -64,6 +76,15 @@
             print '--------------------------------------------'
             
     def appendLayerTree(self, layerDataDict, LayerTree, layerTreeRoot):
+     """
+     @description:Adds layers to LayerTree widget. 
+     @todo:None
+     @param self: reference variable
+     @param layerDataDict:{},  Dictionary holding values of type LayerData() object with keys as integers from 0 to len(layerDataDict)
+     @param LayerTree: TreeCtrl, widget used to display fetched layers. 
+     @param layerTreeRoot: TreeItemId,  returned by LayerTree.AddRoot("Layers") (in the init function), used to refer root of the LayerTree.
+     @return: None  
+     """
         for key, value in layerDataDict.iteritems():
             name = value.name
             title = value.title
@@ -72,6 +93,13 @@
             LayerTree.AppendItem(layerTreeRoot, string)
     
     def setKeyToEPSGCodes(self, layerDataDict):
+     """
+     @description: Builds a dictionary to map keys of layers to EPSG codes
+     @todo:None
+     @param self: reference variable
+     @param layerDataDict:{},  Dictionary holding values of type LayerData() object with keys as integers from 0 to len(layerDataDict)
+     @return: Dictionary with key as an integer in the string form str(int), and value a string (EPSG code for the key).  
+     """
         keytoepsgcodes = {}
         for key, value in layerDataDict.iteritems():
             srss = value.srs
@@ -87,8 +115,19 @@
     pass
 
 class ManageLayerTree():
+    """
+    Contains functionalities to Manage TreeCtrl widget (LayerTree) , used to display layers. 
+    """
     
     def getAllChild(self,LayerTree, parentId):
+     """
+     @description:Returns all the children nodes of a parent node in the TreeCtrl (LayerTree). 
+     @todo:None
+     @param self: reference variable
+     @param LayerTree: TreeCtrl, widget used to display fetched layers. 
+     @param parentId: TreeItemId, reference to the parent Node in TreeCtrl.
+     @return: a list of TreeItemId, the children nodes of parentId(TreeItemId)  
+     """
         children = []
         currentchild,obj = LayerTree.GetFirstChild(parentId)
         while(1):
@@ -100,6 +139,14 @@
         return children
     
     def layerTreeItemDFS(self,parent,LayerTree,nodeId):
+    """
+     @description: performs a DFS(Depth first search) selection on the LayerTree(TreeCtrl), starting from the nodeId(TreeItemId) 
+     @todo:None
+     @param self: reference variable
+     @param LayerTree: TreeCtrl, widget used to display fetched layers. 
+     @param nodeId: TreeItemId, reference to the parent Node in TreeCtrl.
+     @return: None
+     """
         if(not nodeId.IsOk()):
             return
         
@@ -217,7 +264,14 @@
         # end wxGlade
     
 
-    def OnGetCapabilities(self, event): # wxGlade: wmsFrame.<event_handler>            
+    def OnGetCapabilities(self, event): # wxGlade: wmsFrame.<event_handler>
+     """
+     @description: called on press of getCapabilities button. Performs fetching of the getCapabilties document for the selected URL. 
+     @todo:None
+     @param self: reference variable
+     @param event: event associated. 
+     @return: None
+     """            
         if(self.selectedURL == "No server selected"):
             message = 'No Server selected'
             self.ShowMessage(message, 'Warning')
@@ -292,6 +346,13 @@
         
     
     def OnGetMaps(self, event): # wxGlade: wmsFrame.<event_handler>
+        """
+     @description: called on press of getMaps button. Performs fetching of the Maps for the selected layers of a WMS Service. 
+     @todo:None
+     @param self: reference variable
+     @param event: event associated. 
+     @return: None
+     """ 
         if(self.selectedURL == "No server selected"):
             message = 'No server selected'
             grass.warning(message)
@@ -385,6 +446,13 @@
         event.Skip()
         
     def OnEPSGList(self,event):
+        """
+     @description: called on selection of an epsg code from the epsg list(ComboBox) displayed. Sets self.selectedEPSG variable.
+     @todo:None
+     @param self: reference variable
+     @param event: event associated. 
+     @return: None
+     """ 
         info = self.epsgList.GetValue()
         if(not info.isdigit()):
             message = 'Please select an EPSG Code'
@@ -396,6 +464,13 @@
         self.selectedEPSG = info
         
     def OnServerList(self, event): # wxGlade: wmsFrame.<event_handler>
+        """
+     @description: called on selection of a URL from ServerList(ComboBox) displayed. Sets self.selectedURL variable.
+     @todo:None
+     @param self: reference variable
+     @param event: event associated. 
+     @return: None
+     """ 
         info = self.ServerList.GetValue()
         if(len(info) == 0):
             return
@@ -423,6 +498,13 @@
             
 
     def OnLayerTreeSelChanged(self, event): # wxGlade: wmsFrame.<event_handler>"
+         """
+     @description: called on selection of a layer from self.LayerTree. Sets self.selectedURL variable.
+     @todo:None
+     @param self: reference variable
+     @param event: event associated. 
+     @return: None
+     """
         self.epsgList.Clear()
         self.epsgList.Append('')
         self.selectedLayerList = []
@@ -443,53 +525,64 @@
         self.layerName = self.layersString[1:]
         #print self.layerDataDict1
         self.selectedEPSG = None
-        
-        '''
-        for sellayer in self.LayerTree.GetSelections():
-            layerNameString = self.LayerTree.GetItemText(sellayer)
-            layerNameStringList = layerNameString.split(':')
-            if(len(layerNameStringList)==0):
-                message = 'Unable to select layers'
-                self.ShowMessage(message, 'Warning')
-                grass.warning(message)
-                StatusBar_fields = [message]
-                self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
-                return
-            layerName = layerNameStringList[0].split('-')[1]
-            key = layerNameStringList[0].split('-')[0]
-            self.selectedLayerList += [layerName]
-            self.layerName += ","+layerName
-            keys += [key]
-            lEPSG = self.keyToEPSGCodes[key]
-            self.epsgList.Append('<'+layerName+'>')
-            self.epsgList.AppendItems(lEPSG)
-            
-          
-        self.layerName = self.layerName[1:]
-        self.selectedEPSG = None
-        '''
         event.Skip()
         
     def OnAddServer(self, event): # wxGlade: wmsFrame.<event_handler>
+        """
+     @description: called on ManageServers button press. Calls AddSerevrFrame function to display GUI to Manage Servers.
+     @todo:None
+     @param self: reference variable
+     @param event: event associated. 
+     @return: None
+     """
         self.AddServerisClosed = False
         self.addServer.Disable()
         AddServerFrame(self)
         return 
     
     def onAddServerFrameClose(self, msg):
+        """
+     @description: called when the AddServer Frame is closed. Re-enables the addServer Button
+     @todo:None
+     @param self: reference variable
+     @param event: event associated. 
+     @return: None
+     """
         self.AddServerisClosed = True
         self.addServer.Enable()
         
     def onUpdateServerListmessage(self, msg):
+    """
+     @description: called when the updateserverlist message is received from AddServerFrame. Updates the local server list (self.ServerList) 
+     @todo:None
+     @param self: reference variable
+     @param event: event associated. 
+     @return: None
+     """
         self.servers = msg.data
         #self.printDict(self.servers)
         self.__update_Url_List(self.ServerList)
         
     def onUpdateMapListmessage(self, msg): 
+           """
+     @description: called when the update.map_servernameTouid message is received from AddServerFrame. Updates the local dictionary
+      self.map_servernameTouid . This dictionary translates servername to itd Uid. 
+     @todo:None
+     @param self: reference variable
+     @param event: event associated. 
+     @return: None
+     """
         self.map_servernameTouid = msg.data
         #self.printDict(self.map_servernameTouid)
         
     def OnQuit(self, event):
+        """
+     @description: called when the close button is pressed. Closes the AddServerFrame if it's not closed. 
+     @todo:None
+     @param self: reference variable
+     @param event: event associated. 
+     @return: None
+     """
         msg = ""
 
         if(not self.AddServerisClosed):
@@ -498,9 +591,24 @@
         return
     
     def ShowMessage(self, message, type = 'Warning'):
+        """
+     @description: Display's the message as a pop-up. 
+     @todo:None
+     @param self: reference variable
+     @param message: String, message to be displayed. 
+     @param type: String, the type of message
+     @return: None
+     """
         wx.MessageBox(message, type)
     
     def __update_Url_List(self, ComboBox):
+        """
+     @description: Internal function to update ServerList(ComboBox).  
+     @todo:None
+     @param self: reference variable
+     @param ComboBox: ComboBox to be updated. 
+     @return: None
+     """
         ComboBox.Clear()
         ComboBox.Append("")
         for key, value in self.servers.items():
@@ -508,6 +616,13 @@
         return
         
     def __populate_Url_List(self, ComboBox):
+        """
+     @description: Internal function to populate ServerList(ComboBox). Used to populate ServerList for the first time in the init function. 
+     @todo:None
+     @param self: reference variable
+     @param ComboBox: ComboBox to be updated.
+     @return: None
+     """
         self.servers, self.map_servernameTouid = getAllRows(self.soup)
         ComboBox.Append("")
         for key, value in self.servers.items():
@@ -516,6 +631,12 @@
         return
     
     def getBBOXParameters(self):
+        """
+     @description: to parse bounding box parameters in Grass_Region parameter.
+     @todo:None
+     @param self: reference variable
+     @return: a string containing comma separated bounding box parameters.
+     """
         n=parseGrass_Region(None, 'north')
         s=parseGrass_Region(None, 'south')
         e=parseGrass_Region(None, 'east')



More information about the grass-commit mailing list