瀏覽代碼

wxGUI/vdigit: vdigit related code moved from mapdisp_window to
mapdisp_vdigit
(merge https://trac.osgeo.org/grass/changeset/45384 from devbr6)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@45385 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 14 年之前
父節點
當前提交
8c1586bcb9

+ 28 - 27
gui/wxpython/gui_modules/dbm_dialogs.py

@@ -1,4 +1,4 @@
-"""
+"""!
 @package dbm_dialogs.py
 
 @brief DBM-related dialogs
@@ -7,7 +7,7 @@ List of classes:
  - DisplayAttributesDialog
  - ModifyTableRecord
 
-(C) 2007-2010 by the GRASS Development Team
+(C) 2007-2011 by the GRASS Development Team
 
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
@@ -31,27 +31,26 @@ from preferences import globalSettings as UserSettings
 from dbm_base    import VectorDBInfo
 
 class DisplayAttributesDialog(wx.Dialog):
-    """
-    Standard dialog used to add/update/display attributes linked
-    to the vector map.
-
-    Attribute data can be selected based on layer and category number
-    or coordinates.
-
-    @param parent
-    @param map vector map
-    @param query query coordinates and distance (used for v.edit)
-    @param cats {layer: cats}
-    @param line feature id (requested for cats)
-    @param style
-    @param pos
-    @param action (add, update, display)
-    """
     def __init__(self, parent, map,
                  query=None, cats=None, line=None,
                  style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
                  pos=wx.DefaultPosition,
                  action="add"):
+        """!Standard dialog used to add/update/display attributes linked
+        to the vector map.
+        
+        Attribute data can be selected based on layer and category number
+        or coordinates.
+        
+        @param parent
+        @param map vector map
+        @param query query coordinates and distance (used for v.edit)
+        @param cats {layer: cats}
+        @param line feature id (requested for cats)
+        @param style
+        @param pos
+        @param action (add, update, display)
+        """
         self.parent = parent # mapdisplay.BufferedWindow
         self.map    = map
         self.action = action
@@ -268,14 +267,15 @@ class DisplayAttributesDialog(wx.Dialog):
                         self.FindWindowById(id).SetValue(str(value))
 
     def OnCancel(self, event):
-        """!Cancel button pressed"""
+        """!Cancel button pressed
+        """
         self.parent.parent.dialogs['attributes'] = None
-        if self.parent.parent.digit:
-            self.parent.parent.digit.GetDisplay().SetSelected([])
+        if self.parent.digit:
+            self.parent.digit.GetDisplay().SetSelected([])
             self.parent.UpdateMap(render = False)
         else:
             self.parent.parent.OnRender(None)
-
+        
         self.Close()
 
     def OnSubmit(self, event):
@@ -502,15 +502,16 @@ class DisplayAttributesDialog(wx.Dialog):
                 break
         
 class ModifyTableRecord(wx.Dialog):
-    """!Dialog for inserting/updating table record"""
     def __init__(self, parent, id, title, data, keyEditable=(-1, True),
                 style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
-        """
+        """!Dialog for inserting/updating table record
+
         Notes:
-         'Data' is a list: [(column, value)]
-         'KeyEditable' (id, editable?) indicates if textarea for key column
-          is editable(True) or not.
+        'Data' is a list: [(column, value)]
+        'KeyEditable' (id, editable?) indicates if textarea for key column
+        is editable(True) or not.
         """
+        # parent -> VDigitWindow
         wx.Dialog.__init__(self, parent, id, title, style=style)
         
         self.CenterOnParent()

+ 29 - 13
gui/wxpython/gui_modules/mapdisp.py

@@ -245,6 +245,8 @@ class MapFrame(wx.Frame):
         # default is 2D display mode
         self.MapWindow = self.MapWindow2D
         self.MapWindow.SetCursor(self.cursors["default"])
+        # used by vector digitizer
+        self.MapWindowVDigit = None
         # used by Nviz (3D display mode)
         self.MapWindow3D = None 
 
@@ -275,11 +277,6 @@ class MapFrame(wx.Frame):
         self.printopt = disp_print.PrintOptions(self, self.MapWindow)
         
         #
-        # Initialization of digitization tool
-        #
-        self.digit = None
-
-        #
         # Init zoom history
         #
         self.MapWindow.ZoomHistory(self.Map.region['n'],
@@ -311,7 +308,7 @@ class MapFrame(wx.Frame):
         # default toolbar
         if name == "map":
             self.toolbars['map'] = toolbars.MapToolbar(self, self.Map)
-
+            
             self._mgr.AddPane(self.toolbars['map'],
                               wx.aui.AuiPaneInfo().
                               Name("maptoolbar").Caption(_("Map toolbar")).
@@ -324,6 +321,7 @@ class MapFrame(wx.Frame):
         # vector digitizer
         elif name == "vdigit":
             from vdigit import haveVDigit
+            
             if not haveVDigit:
                 from vdigit import errorMsg
                 msg = _("Unable to start wxGUI vector digitizer.\nDo you want to start "
@@ -347,10 +345,28 @@ class MapFrame(wx.Frame):
                 log = self._layerManager.goutput
             else:
                 log = None
+            
+            if not self.MapWindowVDigit:
+                from mapdisp_vdigit import VDigitWindow
+                self.MapWindowVDigit = VDigitWindow(self, id = wx.ID_ANY,
+                                                    Map = self.Map, tree = self.tree,
+                                                    lmgr = self._layerManager)
+                self.MapWindowVDigit.Show()
+            
+            self.MapWindow = self.MapWindowVDigit
+            
+            self._mgr.DetachPane(self.MapWindow2D)
+            self.MapWindow2D.Hide()
+            
             self.toolbars['vdigit'] = toolbars.VDigitToolbar(parent = self, mapcontent = self.Map,
                                                              layerTree = self.tree,
                                                              log = log)
+            self.MapWindowVDigit.SetToolbar(self.toolbars['vdigit'])
             
+            self._mgr.AddPane(self.MapWindowVDigit, wx.aui.AuiPaneInfo().CentrePane().
+                              Dockable(False).BestSize((-1,-1)).
+                              CloseButton(False).DestroyOnClose(True).
+                              Layer(0))
             self._mgr.AddPane(self.toolbars['vdigit'],
                               wx.aui.AuiPaneInfo().
                               Name("vdigittoolbar").Caption(_("Vector digitizer toolbar")).
@@ -359,12 +375,12 @@ class MapFrame(wx.Frame):
                               BottomDockable(False).TopDockable(True).
                               CloseButton(False).Layer(2).
                               BestSize((self.toolbars['vdigit'].GetSize())))
-            
+                        
             # change mouse to draw digitized line
             self.MapWindow.mouse['box'] = "point"
-            self.MapWindow.zoomtype = 0
-            self.MapWindow.pen     = wx.Pen(colour = 'red',   width = 2, style = wx.SOLID)
-            self.MapWindow.polypen = wx.Pen(colour = 'green', width = 2, style = wx.SOLID)
+            self.MapWindow.zoomtype     = 0
+            self.MapWindow.pen          = wx.Pen(colour = 'red',   width = 2, style = wx.SOLID)
+            self.MapWindow.polypen      = wx.Pen(colour = 'green', width = 2, style = wx.SOLID)
         # georectifier
         elif name == "georect":
             self.toolbars['georect'] = toolbars.GRToolbar(self, self.Map)
@@ -397,7 +413,7 @@ class MapFrame(wx.Frame):
             
             # update status bar
             self.statusbarWin['toggle'].Enable(False)
-
+            
             # erase map window
             self.MapWindow.EraseMap()
             
@@ -541,8 +557,8 @@ class MapFrame(wx.Frame):
             self.MapWindow.ClearLines()
         
         # deselect features in vdigit
-        if self.toolbars['vdigit'] and self.digit:
-            self.digit.GetDisplay().SetSelected([])
+        if self.toolbars['vdigit']:
+            self.MapWindow.display.SetSelected([])
             self.MapWindow.UpdateMap(render = True, renderVector = True)
         else:
             self.MapWindow.UpdateMap(render = True)

文件差異過大導致無法顯示
+ 1064 - 0
gui/wxpython/gui_modules/mapdisp_vdigit.py


文件差異過大導致無法顯示
+ 221 - 1346
gui/wxpython/gui_modules/mapdisp_window.py


+ 17 - 16
gui/wxpython/gui_modules/toolbars.py

@@ -633,7 +633,8 @@ class VDigitToolbar(AbstractToolbar):
         self.layerTree     = layerTree  # reference to layer tree associated to map display
         self.log           = log        # log area
         AbstractToolbar.__init__(self, parent)
-        
+        self.digit         = self.parent.MapWindow.digit
+
         # currently selected map layer for editing (reference to MapLayer instance)
         self.mapLayer = None
         # list of vector layers from Layer Manager (only in the current mapset)
@@ -790,8 +791,8 @@ class VDigitToolbar(AbstractToolbar):
         # clear tmp canvas
         if self.action['id'] != id:
             self.parent.MapWindow.ClearLines(pdc = self.parent.MapWindow.pdcTmp)
-            if self.parent.digit and \
-                    len(self.parent.digit.GetDisplay().GetSelected()) > 0:
+            if self.parent.MapWindow.digit and \
+                    len(self.parent.MapWindow.digit.GetDisplay().GetSelected()) > 0:
                 # cancel action
                 self.parent.MapWindow.OnMiddleDown(None)
         
@@ -979,7 +980,7 @@ class VDigitToolbar(AbstractToolbar):
         
     def OnUndo(self, event):
         """!Undo previous changes"""
-        self.parent.digit.Undo()
+        self.digit.Undo()
         
         event.Skip()
 
@@ -997,11 +998,11 @@ class VDigitToolbar(AbstractToolbar):
         
     def OnSettings(self, event):
         """!Show settings dialog"""
-        if self.parent.digit is None:
+        if self.digit is None:
             try:
-                self.parent.digit = VDigit(mapwindow = self.parent.MapWindow)
+                self.digit = self.parent.MapWindow.digit = VDigit(mapwindow = self.parent.MapWindow)
             except SystemExit:
-                self.parent.digit = None
+                self.digit = self.parent.MapWindow.digit = None
         
         if not self.settingsDialog:
             self.settingsDialog = VDigitSettingsDialog(parent = self.parent, title = _("Digitization settings"),
@@ -1187,7 +1188,7 @@ class VDigitToolbar(AbstractToolbar):
 
     def OnZBulk(self, event):
         """!Z bulk-labeling selected lines/boundaries"""
-        if not self.parent.digit.IsVector3D():
+        if not self.digit.IsVector3D():
             gcmd.GError(parent = self.parent,
                         message = _("Vector map is not 3D. Operation canceled."))
             return
@@ -1297,12 +1298,12 @@ class VDigitToolbar(AbstractToolbar):
                                                 0)
         
         self.parent.MapWindow.pdcVector = wx.PseudoDC()
-        self.parent.digit = VDigit(mapwindow = self.parent.MapWindow)
+        self.digit = self.parent.MapWindow.digit = VDigit(mapwindow = self.parent.MapWindow)
         
         self.mapLayer = mapLayer
         
         # open vector map
-        if self.parent.digit.OpenMap(mapLayer.GetName()) is None:
+        if self.digit.OpenMap(mapLayer.GetName()) is None:
             self.mapLayer = None
             self.StopEditing()
             return False
@@ -1326,7 +1327,7 @@ class VDigitToolbar(AbstractToolbar):
         opacity = mapLayer.GetOpacity(float = True)
         if opacity < 1.0:
             alpha = int(opacity * 255)
-            self.parent.digit.driver.UpdateSettings(alpha)
+            self.digit.UpdateSettings(alpha)
         
         return True
 
@@ -1342,7 +1343,7 @@ class VDigitToolbar(AbstractToolbar):
         if self.mapLayer:
             Debug.msg (4, "VDigitToolbar.StopEditing(): layer=%s" % self.mapLayer.GetName())
             if UserSettings.Get(group = 'vdigit', key = 'saveOnExit', subkey = 'enabled') is False:
-                if self.parent.digit.GetUndoLevel() > -1:
+                if self.digit.GetUndoLevel() > -1:
                     dlg = wx.MessageDialog(parent = self.parent,
                                            message = _("Do you want to save changes "
                                                      "in vector map <%s>?") % self.mapLayer.GetName(),
@@ -1350,7 +1351,7 @@ class VDigitToolbar(AbstractToolbar):
                                            style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
                     if dlg.ShowModal() == wx.ID_NO:
                         # revert changes
-                        self.parent.digit.Undo(0)
+                        self.digit.Undo(0)
                     dlg.Destroy()
             
             self.parent.statusbar.SetStatusText(_("Please wait, "
@@ -1361,7 +1362,7 @@ class VDigitToolbar(AbstractToolbar):
             if lmgr:
                 lmgr.toolbar.Enable('vdigit', enable = True)
                 lmgr.notebook.SetSelection(1)
-            self.parent.digit.CloseMap()
+            self.digit.CloseMap()
             if lmgr:
                 lmgr.GetLogWindow().GetProgressBar().SetValue(0)
                 lmgr.GetLogWindow().WriteCmdLog(_("Editing of vector map <%s> successfully finished") % \
@@ -1381,8 +1382,8 @@ class VDigitToolbar(AbstractToolbar):
                 self.parent.dialogs[dialog].Close()
                 self.parent.dialogs[dialog] = None
         
-        self.parent.digit.__del__() # FIXME: destructor is not called here (del)
-        self.parent.digit = None
+        self.digit.__del__() # FIXME: destructor is not called here (del)
+        self.digit = self.parent.MapWindow.digit = None
         
         self.mapLayer = None
         

+ 1 - 1
gui/wxpython/gui_modules/wxvdigit.py

@@ -1075,7 +1075,7 @@ class IVDigit:
         area = Vect_get_centroid_area(self.poMapInfo, centroid)
         perimeter = -1
         if area > 0:
-            if not Vect_area_alive(self,poMapInfo, area):
+            if not Vect_area_alive(self.poMapInfo, area):
                 return -1
             
             Vect_get_area_points(self.poMapInfo, area, self.poPoints)