[GRASS-SVN] r41918 - grass-addons/gui/wxpython/data_catalog

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Apr 18 06:47:38 EDT 2010


Author: rashadkm
Date: 2010-04-18 06:47:38 -0400 (Sun, 18 Apr 2010)
New Revision: 41918

Modified:
   grass-addons/gui/wxpython/data_catalog/LayerTree.py
   grass-addons/gui/wxpython/data_catalog/catalog.py
   grass-addons/gui/wxpython/data_catalog/wxgui.py
Log:
fix projection when changing location & mapset

Modified: grass-addons/gui/wxpython/data_catalog/LayerTree.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/LayerTree.py	2010-04-18 10:46:32 UTC (rev 41917)
+++ grass-addons/gui/wxpython/data_catalog/LayerTree.py	2010-04-18 10:47:38 UTC (rev 41918)
@@ -66,7 +66,7 @@
 	    glocs = glob.glob(os.path.join(self.gisdbase,location, mapset,"*"))
 	    for gloc in glocs:
 		    if not os.path.isfile(gloc) and os.path.isdir(gloc):
-			    if(os.path.basename(gloc)=='cats'):
+			    if(os.path.basename(gloc)=='cellhd'):
 				    for rast in glob.glob(os.path.join(self.gisdbase,location, mapset,gloc, "*")):
 					    self.AppendItem(node_raster, os.path.basename(rast))
 			    elif(os.path.basename(gloc)=='vector'):
@@ -317,6 +317,7 @@
       Thread.__init__(self)
       self.cmd =  cmd
    def run(self):
-      os.system(self.cmd)		
+      os.system(self.cmd)	
 
 
+

Modified: grass-addons/gui/wxpython/data_catalog/catalog.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/catalog.py	2010-04-18 10:46:32 UTC (rev 41917)
+++ grass-addons/gui/wxpython/data_catalog/catalog.py	2010-04-18 10:47:38 UTC (rev 41918)
@@ -99,6 +99,7 @@
 from   icons.icon import Icons
 import wx_utils as wx_utils
 from preferences import globalSettings as UserSettings
+import render
 
 
 class DataCatalog(wx.Frame):
@@ -644,11 +645,11 @@
 
     def OnChangeLocation(self, event):
         """Change current location"""
-        print "asdf"
+        pass
                     
     def OnChangeMapset(self, event):
         """Change current mapset"""
-        print "asdf"
+        pass
         
     def OnNewVector(self, event):
         """!Create new vector map layer"""
@@ -1667,18 +1668,40 @@
         self.gisrc['LOCATION_NAME'] = str(self.cmbLocation.GetValue())
         self.gisrc['MAPSET'] = str(self.cmbMapset.GetValue())
         self.update_grassrc(self.gisrc)
-        #gcmd.RunCommand("g.gisenv", set = "MAPSET=%s" % str(self.cmbMapset.GetValue()))
 
+        #self.pg_panel.Map.__init__()	
+        #self.pg_panel.Map.region = self.pg_panel.Map.GetRegion()
 
+        self.page = self.notebook.GetPage(self.notebook.GetSelection())
+        self.page.Map.__init__()	
+        self.page.Map.region = self.page.Map.GetRegion()
+
+
+        
+    def OnRunScript():
+        print "for grass7"
+
+    def OnQuit():
+        print "for grass7"
+
     def OnLocationChange(self,event):
         """
         Populate mapset combobox with selected location.
         """
+        count = self.current.maptree.GetCount()
+        firstitem = self.current.maptree.GetFirstVisibleItem()
+        for i in range(1, count):
+            nextitem = self.current.maptree.GetNext(firstitem);
+            self.current.maptree.Delete(nextitem)
+        if firstitem:
+            self.current.maptree.Delete(firstitem)
 
+
         self.cmbMapset.Clear()
         self.cmbMapset.SetValue("Select Mapset")
         self.ltree.DeleteAllItems()
 
+
         maplists = self.GetMapsets(self.cmbLocation.GetValue())
         for mapsets in maplists:
 	        self.cmbMapset.Append(str(mapsets))
@@ -1762,7 +1785,7 @@
 
     def read_gisrc(self):
 	    """
-	    Read variables from $HOME/.grassrc7 file
+	    Read variables gisrc file
 	    """
 
 	    rc = {}
@@ -1781,32 +1804,39 @@
 	    return rc
 
     def update_grassrc(self,gisrc):
-	    """
-	    Update $HOME/.grassrc7 and gisrc files
-	    """
+        """
+        Update $HOME/.grassrc(6/7) and gisrc files
+        """
+        rc = os.getenv("GISRC")
+        version = os.getenv("GRASS_VERSION")
+        if version == "7.0.svn":
+            grassrc = os.path.join(os.getenv('HOME'), ".grassrc7.%s" % os.uname()[1])
+            if not os.access(grassrc, os.R_OK):
+                grassrc = os.path.join(os.getenv('HOME'), ".grassrc7")
 
-	    rc = os.getenv("GISRC")
-	    grassrc = os.path.join(os.getenv('HOME'), ".grassrc7.%s" % os.uname()[1])
-	    if not os.access(grassrc, os.R_OK):
-		    grassrc = os.path.join(os.getenv('HOME'), ".grassrc7")
-	    if rc and os.path.isfile(rc):
-		    try:
-			    f = open(rc, 'w')
-			    for key, val in gisrc.iteritems():
-			        f.write("%s: %s\n" % (key, val))
-		    finally:
-			    f.close()
+        else:
+            grassrc = os.path.join(os.getenv('HOME'), ".grassrc6.%s" % os.uname()[1])
+            if not os.access(grassrc, os.R_OK):
+                grassrc = os.path.join(os.getenv('HOME'), ".grassrc6")
 
-	    if grassrc and os.path.isfile(grassrc):
-		    try:
-			    g = open(grassrc, 'w')
-			    for key, val in gisrc.iteritems():
-			        g.write("%s: %s\n" % (key, val))
-		    finally:
-			        g.close()
+        if rc and os.path.isfile(rc):
+            try:
+	            f = open(rc, 'w')
+	            for key, val in gisrc.iteritems():
+	                f.write("%s: %s\n" % (key, val))
+            finally:
+	            f.close()
 
+        if grassrc and os.path.isfile(grassrc):
+            try:
+	            g = open(grassrc, 'w')
+	            for key, val in gisrc.iteritems():
+	                g.write("%s: %s\n" % (key, val))
+            finally:
+	                g.close()
 
 
+
 #End of DataCatalog class
 
 

Modified: grass-addons/gui/wxpython/data_catalog/wxgui.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/wxgui.py	2010-04-18 10:46:32 UTC (rev 41917)
+++ grass-addons/gui/wxpython/data_catalog/wxgui.py	2010-04-18 10:47:38 UTC (rev 41918)
@@ -347,12 +347,14 @@
         old_pgnum = event.GetOldSelection()
         new_pgnum = event.GetSelection()
         
-        self.curr_page   = self.gm_cb.GetCurrentPage()
-        self.curr_pagenum = self.gm_cb.GetSelection()
+        self.curr_page   = self.notebook.GetCurrentPage()
+        self.curr_pagenum = self.notebook.GetSelection()
         
         try:
             self.curr_page.maptree.mapdisplay.SetFocus()
             self.curr_page.maptree.mapdisplay.Raise()
+            print self.curr_page.ltree + "ddd"
+
         except:
             pass
         
@@ -360,7 +362,10 @@
 
     def OnPageChanged(self, event):
         """!Page in notebook changed"""
-        page = event.GetSelection()
+        pageno = event.GetSelection()
+        self.page = self.notebook.GetPage(pageno)
+        self.page.Map.__init__()	
+        self.page.Map.region = self.page.Map.GetRegion()
         if page == self.goutput.pageid:
             # remove '(...)'
             self.notebook.SetPageText(page, _("Command output"))
@@ -400,8 +405,8 @@
                     return
                 dlg.Destroy()
         
-        self.gm_cb.GetPage(event.GetSelection()).maptree.Map.Clean()
-        self.gm_cb.GetPage(event.GetSelection()).maptree.Close(True)
+        self.notebook.GetPage(event.GetSelection()).maptree.Map.Clean()
+        self.notebook.GetPage(event.GetSelection()).maptree.Close(True)
         
         self.curr_page = None
         
@@ -647,7 +652,7 @@
         mapdisplay = []
         for display in gxwXml.displays:
             mapdisplay.append(self.NewDisplay(show=False))
-            maptree = self.gm_cb.GetPage(displayId).maptree
+            maptree = self.notebook.GetPage(displayId).maptree
             
             # set windows properties
             mapdisplay[-1].SetProperties(render=display['render'],
@@ -687,7 +692,7 @@
         #
         for layer in gxwXml.layers:
             display = layer['display']
-            maptree = self.gm_cb.GetPage(display).maptree
+            maptree = self.notebook.GetPage(display).maptree
             
             newItem = maptree.AddLayer(ltype=layer['type'],
                                        lname=layer['name'],
@@ -772,7 +777,7 @@
 
         maptree = None
         for layer in workspace.ProcessGrcFile(filename).read(self):
-            maptree = self.gm_cb.GetPage(layer['display']).maptree
+            maptree = self.notebook.GetPage(layer['display']).maptree
             newItem = maptree.AddLayer(ltype=layer['type'],
                                        lname=layer['name'],
                                        lchecked=layer['checked'],
@@ -872,8 +877,8 @@
         self.SetTitle(self.baseTitle)
 
         displays = []
-        for page in range(0, self.gm_cb.GetPageCount()):
-            displays.append(self.gm_cb.GetPage(page).maptree.mapdisplay)
+        for page in range(0, self.notebook.GetPageCount()):
+            displays.append(self.notebook.GetPage(page).maptree.mapdisplay)
         
         for display in displays:
             display.OnCloseWindow(event)
@@ -1128,18 +1133,21 @@
         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()
+        self.pg_panel = wx.Panel(self.notebook, id=wx.ID_ANY, style= wx.EXPAND)
+        self.notebook.AddPage(self.pg_panel, text="Display "+ str(self.disp_idx + 1), select = True)
+        self.curr_page = self.notebook.GetCurrentPage()
 
         # create layer tree (tree control for managing GIS layers)  and put on new notebook page
         self.curr_page.maptree = wxgui_utils.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,
+                                                       idx=self.disp_idx, lmgr=self, notebook=self.notebook,
                                                        auimgr=self._auimgr, showMapDisplay=show)
+        #self.pg_panel.Map.__init__()	
+        #self.pg_panel.Map.region = self.pg_panel.Map.GetRegion()
 
+
         # layout for controls
         cb_boxsizer = wx.BoxSizer(wx.VERTICAL)
         cb_boxsizer.Add(self.curr_page.maptree, proportion=1, flag=wx.EXPAND, border=1)



More information about the grass-commit mailing list