浏览代码

wxGUI/gcp: removing remaining connection to lmgr and obsolate variables

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57233 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 11 年之前
父节点
当前提交
9f78d80e47
共有 4 个文件被更改,包括 56 次插入66 次删除
  1. 31 11
      gui/wxpython/gcp/manager.py
  2. 21 51
      gui/wxpython/gcp/mapdisplay.py
  3. 3 2
      gui/wxpython/gcp/toolbars.py
  4. 1 2
      gui/wxpython/lmgr/frame.py

+ 31 - 11
gui/wxpython/gcp/manager.py

@@ -299,9 +299,10 @@ class GCPWizard(object):
 
 
     def Cleanup(self):
     def Cleanup(self):
         """!Return to current location and mapset"""
         """!Return to current location and mapset"""
-        self.SwitchEnv('target')
-        self.parent.gcpmanagement = None
+        # here was also the cleaning of gcpmanagement from layer manager
+        # which is no longer needed
 
 
+        self.SwitchEnv('target')
         self.wizard.Destroy()
         self.wizard.Destroy()
 
 
 class LocationPage(TitledPage):
 class LocationPage(TitledPage):
@@ -795,20 +796,26 @@ class GCP(MapFrame, ColumnSorterMixin):
         
         
         #wx.Frame.__init__(self, parent, id, title, size = size, name = "GCPFrame")
         #wx.Frame.__init__(self, parent, id, title, size = size, name = "GCPFrame")
         MapFrame.__init__(self, parent = parent, giface = self._giface, title = title, size = size,
         MapFrame.__init__(self, parent = parent, giface = self._giface, title = title, size = size,
-                            Map = Map, toolbars = toolbars, lmgr = lmgr, name = 'GCPMapWindow')
+                            Map=Map, toolbars=toolbars, name='GCPMapWindow')
 
 
-        #
         # init variables
         # init variables
-        #
-        self.parent = parent # GMFrame
-        self.parent.gcpmanagement = self
-        
+        self.parent = parent
+
         #
         #
         # register data structures for drawing GCP's
         # register data structures for drawing GCP's
         #
         #
         self.pointsToDrawTgt = self.TgtMapWindow.RegisterGraphicsToDraw(graphicsType = "point", setStatusFunc = self.SetGCPSatus)
         self.pointsToDrawTgt = self.TgtMapWindow.RegisterGraphicsToDraw(graphicsType = "point", setStatusFunc = self.SetGCPSatus)
         self.pointsToDrawSrc = self.SrcMapWindow.RegisterGraphicsToDraw(graphicsType = "point", setStatusFunc = self.SetGCPSatus)
         self.pointsToDrawSrc = self.SrcMapWindow.RegisterGraphicsToDraw(graphicsType = "point", setStatusFunc = self.SetGCPSatus)
-        
+
+        # connect to the map windows signals
+        # used to add or edit GCP
+        self.SrcMapWindow.mouseLeftUpPointer.connect(
+            lambda x, y:
+            self._onMouseLeftUpPointer(self.SrcMapWindow, x, y))
+        self.TgtMapWindow.mouseLeftUpPointer.connect(
+            lambda x, y:
+            self._onMouseLeftUpPointer(self.TgtMapWindow, x, y))
+
         # window resized
         # window resized
         self.resize = False
         self.resize = False
 
 
@@ -949,7 +956,9 @@ class GCP(MapFrame, ColumnSorterMixin):
 
 
     def __del__(self):
     def __del__(self):
         """!Disable GCP manager mode"""
         """!Disable GCP manager mode"""
-        self.parent.gcpmanagement = None
+        # leaving the method here but was used only to delete gcpmanagement
+        # from layer manager which is now not needed
+        pass
         
         
     def CreateGCPList(self):
     def CreateGCPList(self):
         """!Create GCP List Control"""
         """!Create GCP List Control"""
@@ -1333,9 +1342,20 @@ class GCP(MapFrame, ColumnSorterMixin):
             targetMapWin.UpdateMap(render=False, renderVector=False)
             targetMapWin.UpdateMap(render=False, renderVector=False)
     
     
     def OnFocus(self, event):
     def OnFocus(self, event):
+        # TODO: it is here just to remove old or obsolate beavior of base class gcp/MapFrame?
         # self.grwiz.SwitchEnv('source')
         # self.grwiz.SwitchEnv('source')
         pass
         pass
-        
+
+    def _onMouseLeftUpPointer(self, mapWindow, x, y):
+        if mapWindow == self.SrcMapWindow:
+            coordtype = 'source'
+        else:
+            coordtype = 'target'
+
+        coord = (x, y)
+        self.SetGCPData(coordtype, coord, self, confirm=True)
+        mapWindow.UpdateMap(render=False, renderVector=False)
+
     def OnRMS(self, event):
     def OnRMS(self, event):
         """
         """
         RMS button handler
         RMS button handler

+ 21 - 51
gui/wxpython/gcp/mapdisplay.py

@@ -42,17 +42,16 @@ class MapFrame(SingleMapFrame):
     """!Main frame for map display window. Drawing takes place in
     """!Main frame for map display window. Drawing takes place in
     child double buffered drawing window.
     child double buffered drawing window.
     """
     """
-    def __init__(self, parent, giface, title=_("GRASS GIS Manage Ground Control Points"),
-                 toolbars=["gcpdisp"], tree=None, notebook=None, lmgr=None,
-                 page=None, Map=None, auimgr=None, name = 'GCPMapWindow', **kwargs):
+    def __init__(self, parent, giface,
+                 title=_("GRASS GIS Manage Ground Control Points"),
+                 toolbars=["gcpdisp"], Map=None, auimgr=None,
+                 name='GCPMapWindow', **kwargs):
         """!Main map display window with toolbars, statusbar and
         """!Main map display window with toolbars, statusbar and
         DrawWindow
         DrawWindow
 
 
+        @param giface GRASS interface instance
+        @param title window title
         @param toolbars array of activated toolbars, e.g. ['map', 'digit']
         @param toolbars array of activated toolbars, e.g. ['map', 'digit']
-        @param tree reference to layer tree
-        @param notebook control book ID in Layer Manager
-        @param lmgr Layer Manager
-        @param page notebook page with layer tree
         @param Map instance of render.Map
         @param Map instance of render.Map
         @param auimgs AUI manager
         @param auimgs AUI manager
         @param kwargs wx.Frame attribures
         @param kwargs wx.Frame attribures
@@ -60,12 +59,9 @@ class MapFrame(SingleMapFrame):
         
         
         SingleMapFrame.__init__(self, parent = parent, giface = giface, title = title,
         SingleMapFrame.__init__(self, parent = parent, giface = giface, title = title,
                               Map = Map, auimgr = auimgr, name = name, **kwargs)
                               Map = Map, auimgr = auimgr, name = name, **kwargs)
-        
-        self._layerManager = lmgr   # Layer Manager object
-        self.tree       = tree      # Layer Manager layer tree object
-        self.page       = page      # Notebook page holding the layer tree
-        self.layerbook  = notebook  # Layer Manager layer tree notebook
+
         self._giface = giface
         self._giface = giface
+
         #
         #
         # Add toolbars
         # Add toolbars
         #
         #
@@ -115,11 +111,11 @@ class MapFrame(SingleMapFrame):
         #
         #
         self.grwiz.SwitchEnv('source')
         self.grwiz.SwitchEnv('source')
         self.SrcMapWindow = BufferedWindow(parent=self, giface=self._giface, id=wx.ID_ANY,
         self.SrcMapWindow = BufferedWindow(parent=self, giface=self._giface, id=wx.ID_ANY,
-                                          Map=self.SrcMap, frame = self, tree=self.tree, lmgr=self._layerManager)
+                                           Map=self.SrcMap, frame=self)
 
 
         self.grwiz.SwitchEnv('target')
         self.grwiz.SwitchEnv('target')
         self.TgtMapWindow = BufferedWindow(parent=self, giface=self._giface, id=wx.ID_ANY,
         self.TgtMapWindow = BufferedWindow(parent=self, giface=self._giface, id=wx.ID_ANY,
-                                          Map=self.TgtMap, frame = self, tree=self.tree, lmgr=self._layerManager)
+                                          Map=self.TgtMap, frame=self)
         self.MapWindow = self.SrcMapWindow
         self.MapWindow = self.SrcMapWindow
         self.Map = self.SrcMap
         self.Map = self.SrcMap
         self._setUpMapWindow(self.SrcMapWindow)
         self._setUpMapWindow(self.SrcMapWindow)
@@ -133,13 +129,6 @@ class MapFrame(SingleMapFrame):
         self.TgtMapWindow.mouseEntered.connect(
         self.TgtMapWindow.mouseEntered.connect(
             lambda:
             lambda:
             self._setActiveMapWindow(self.TgtMapWindow))
             self._setActiveMapWindow(self.TgtMapWindow))
-        # used to add or edit GCP
-        self.SrcMapWindow.mouseLeftUpPointer.connect(
-            lambda x, y:
-            self._onMouseLeftUpPointer(self.SrcMapWindow, x, y))
-        self.TgtMapWindow.mouseLeftUpPointer.connect(
-            lambda x, y:
-            self._onMouseLeftUpPointer(self.TgtMapWindow, x, y))
 
 
         #
         #
         # initialize region values
         # initialize region values
@@ -289,19 +278,13 @@ class MapFrame(SingleMapFrame):
         Change choicebook page to match display.
         Change choicebook page to match display.
         Or set display for georectifying
         Or set display for georectifying
         """
         """
-        if self._layerManager and \
-                self._layerManager.gcpmanagement:
-            # in GCP Management, set focus to current MapWindow for mouse actions
-            self.OnPointer(event)
-            self.MapWindow.SetFocus()
-        else:
-            # change bookcontrol page to page associated with display
-            # GCP Manager: use bookcontrol?
-            if self.page:
-                pgnum = self.layerbook.GetPageIndex(self.page)
-                if pgnum > -1:
-                    self.layerbook.SetSelection(pgnum)
-        
+        # was in if layer manager but considering the state it was executed
+        # always, moreover, there is no layer manager dependent code
+
+        # in GCP Management, set focus to current MapWindow for mouse actions
+        self.OnPointer(event)
+        self.MapWindow.SetFocus()
+
         event.Skip()
         event.Skip()
 
 
     def OnDraw(self, event):
     def OnDraw(self, event):
@@ -627,19 +610,16 @@ class MapFrame(SingleMapFrame):
         
         
     def IsStandalone(self):
     def IsStandalone(self):
         """!Check if Map display is standalone"""
         """!Check if Map display is standalone"""
-        if self._layerManager:
-            return False
-        
+        # we do not know and we do not care, so always False
         return True
         return True
     
     
     def GetLayerManager(self):
     def GetLayerManager(self):
         """!Get reference to Layer Manager
         """!Get reference to Layer Manager
 
 
-        @return window reference
-        @return None (if standalone)
+        @return always None
         """
         """
-        return self._layerManager
-    
+        return None
+
     def GetSrcWindow(self):
     def GetSrcWindow(self):
         return self.SrcMapWindow
         return self.SrcMapWindow
         
         
@@ -660,13 +640,3 @@ class MapFrame(SingleMapFrame):
             self.UpdateActive(mapWindow)
             self.UpdateActive(mapWindow)
             # needed for wingrass
             # needed for wingrass
             self.SetFocus()
             self.SetFocus()
-
-    def _onMouseLeftUpPointer(self, mapWindow, x, y):
-        if mapWindow == self.SrcMapWindow:
-            coordtype = 'source'
-        else:
-            coordtype = 'target'
-
-        coord = (x, y)
-        self._layerManager.gcpmanagement.SetGCPData(coordtype, coord, self, confirm=True)
-        mapWindow.UpdateMap(render=False, renderVector=False)

+ 3 - 2
gui/wxpython/gcp/toolbars.py

@@ -23,8 +23,9 @@ import wx
 from core              import globalvar
 from core              import globalvar
 from core.utils import _
 from core.utils import _
 from gui_core.toolbars import BaseToolbar, BaseIcons
 from gui_core.toolbars import BaseToolbar, BaseIcons
-from icon              import MetaIcon
-    
+from icons.icon import MetaIcon
+
+
 class GCPManToolbar(BaseToolbar):
 class GCPManToolbar(BaseToolbar):
     """!Toolbar for managing ground control points
     """!Toolbar for managing ground control points
 
 

+ 1 - 2
gui/wxpython/lmgr/frame.py

@@ -94,8 +94,7 @@ class GMFrame(wx.Frame):
         self.currentPageNum  = None       # currently selected page number for layer tree notebook
         self.currentPageNum  = None       # currently selected page number for layer tree notebook
         self.workspaceFile = workspace    # workspace file
         self.workspaceFile = workspace    # workspace file
         self.workspaceChanged = False     # track changes in workspace
         self.workspaceChanged = False     # track changes in workspace
-        self.gcpmanagement = None         # reference to GCP class or None
-        
+
         wx.Frame.__init__(self, parent = parent, id = id, size = size,
         wx.Frame.__init__(self, parent = parent, id = id, size = size,
                           style = style, **kwargs)
                           style = style, **kwargs)
         self._setTitle()
         self._setTitle()