浏览代码

Fix for remaining issues in ticket https://trac.osgeo.org/grass/ticket/291 for text overlays: added text show checkbox and disabled right click non-functional functions.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@35123 15284696-431f-4ddb-bdfa-cd5b030d7da7
Michael Barton 16 年之前
父节点
当前提交
4048c20e64
共有 2 个文件被更改,包括 33 次插入33 次删除
  1. 18 6
      gui/wxpython/gui_modules/gdialogs.py
  2. 15 27
      gui/wxpython/gui_modules/mapdisp.py

+ 18 - 6
gui/wxpython/gui_modules/gdialogs.py

@@ -466,37 +466,48 @@ class TextLayerDialog(wx.Dialog):
         sizer = wx.BoxSizer(wx.VERTICAL)
         sizer = wx.BoxSizer(wx.VERTICAL)
         box = wx.GridBagSizer(vgap=5, hgap=5)
         box = wx.GridBagSizer(vgap=5, hgap=5)
 
 
+        # show/hide
+        self.chkbox = wx.CheckBox(parent=self, id=wx.ID_ANY, \
+            label='Show text object')
+        if self.parent.Map.GetOverlay(self.ovlId) is None:
+            self.chkbox.SetValue(True)
+        else:
+            self.chkbox.SetValue(self.parent.MapWindow.overlays[self.ovlId]['layer'].IsActive())
+        box.Add(item=self.chkbox, span=(1,2),
+                flag=wx.ALIGN_LEFT|wx.ALL, border=5,
+                pos=(0, 0))
+
         # text entry
         # text entry
         label = wx.StaticText(parent=self, id=wx.ID_ANY, label=_("Enter text:"))
         label = wx.StaticText(parent=self, id=wx.ID_ANY, label=_("Enter text:"))
         box.Add(item=label,
         box.Add(item=label,
                 flag=wx.ALIGN_CENTER_VERTICAL,
                 flag=wx.ALIGN_CENTER_VERTICAL,
-                pos=(0, 0))
+                pos=(1, 0))
 
 
         self.textentry = wx.TextCtrl(parent=self, id=wx.ID_ANY, value="", size=(300,-1))
         self.textentry = wx.TextCtrl(parent=self, id=wx.ID_ANY, value="", size=(300,-1))
         self.textentry.SetFont(self.currFont)
         self.textentry.SetFont(self.currFont)
         self.textentry.SetForegroundColour(self.currClr)
         self.textentry.SetForegroundColour(self.currClr)
         self.textentry.SetValue(self.currText)
         self.textentry.SetValue(self.currText)
         box.Add(item=self.textentry,
         box.Add(item=self.textentry,
-                pos=(0, 1))
+                pos=(1, 1))
 
 
         # rotation
         # rotation
         label = wx.StaticText(parent=self, id=wx.ID_ANY, label=_("Rotation:"))
         label = wx.StaticText(parent=self, id=wx.ID_ANY, label=_("Rotation:"))
         box.Add(item=label,
         box.Add(item=label,
                 flag=wx.ALIGN_CENTER_VERTICAL,
                 flag=wx.ALIGN_CENTER_VERTICAL,
-                pos=(1, 0))
+                pos=(2, 0))
         self.rotation = wx.SpinCtrl(parent=self, id=wx.ID_ANY, value="", pos=(30, 50),
         self.rotation = wx.SpinCtrl(parent=self, id=wx.ID_ANY, value="", pos=(30, 50),
                                     size=(75,-1), style=wx.SP_ARROW_KEYS)
                                     size=(75,-1), style=wx.SP_ARROW_KEYS)
         self.rotation.SetRange(-360, 360)
         self.rotation.SetRange(-360, 360)
         self.rotation.SetValue(int(self.currRot))
         self.rotation.SetValue(int(self.currRot))
         box.Add(item=self.rotation,
         box.Add(item=self.rotation,
                 flag=wx.ALIGN_RIGHT,
                 flag=wx.ALIGN_RIGHT,
-                pos=(1, 1))
+                pos=(2, 1))
 
 
         # font
         # font
         fontbtn = wx.Button(parent=self, id=wx.ID_ANY, label=_("Set font"))
         fontbtn = wx.Button(parent=self, id=wx.ID_ANY, label=_("Set font"))
         box.Add(item=fontbtn,
         box.Add(item=fontbtn,
                 flag=wx.ALIGN_RIGHT,
                 flag=wx.ALIGN_RIGHT,
-                pos=(2, 1))
+                pos=(3, 1))
 
 
         sizer.Add(item=box, proportion=1,
         sizer.Add(item=box, proportion=1,
                   flag=wx.ALL, border=10)
                   flag=wx.ALL, border=10)
@@ -574,7 +585,8 @@ class TextLayerDialog(wx.Dialog):
                  'font' : self.currFont,
                  'font' : self.currFont,
                  'color' : self.currClr,
                  'color' : self.currClr,
                  'rotation' : self.currRot,
                  'rotation' : self.currRot,
-                 'coords' : self.currCoords }
+                 'coords' : self.currCoords,
+                 'active' : self.chkbox.IsChecked() }
 
 
 class LoadMapLayersDialog(wx.Dialog):
 class LoadMapLayersDialog(wx.Dialog):
     """Load selected map layers (raster, vector) into layer tree"""
     """Load selected map layers (raster, vector) into layer tree"""

+ 15 - 27
gui/wxpython/gui_modules/mapdisp.py

@@ -421,6 +421,7 @@ class BufferedWindow(MapWindow, wx.Window):
                 # self.ovlcoords[drawid] = coords
                 # self.ovlcoords[drawid] = coords
 
 
         elif pdctype == 'text': # draw text on top of map
         elif pdctype == 'text': # draw text on top of map
+            if not img['active']: return #only draw active text
             if img.has_key('rotation'):
             if img.has_key('rotation'):
                 rotation = float(img['rotation'])
                 rotation = float(img['rotation'])
             else:
             else:
@@ -1752,24 +1753,7 @@ class BufferedWindow(MapWindow, wx.Window):
         """
         """
         Debug.msg (5, "BufferedWindow.OnRightDown(): use=%s" % \
         Debug.msg (5, "BufferedWindow.OnRightDown(): use=%s" % \
                    self.mouse["use"])
                    self.mouse["use"])
-
-        x,y = event.GetPositionTuple()[:]
-        l = self.pdc.FindObjects(x=x, y=y, radius=self.hitradius)
-        if not l:
-            return
-
-        id = l[0]
-
-        if id != 99:
-            if self.pdc.GetIdGreyedOut(id) == True:
-                self.pdc.SetIdGreyedOut(id, False)
-            else:
-                self.pdc.SetIdGreyedOut(id, True)
-
-                r = self.pdc.GetIdBounds(id)
-                r.Inflate(4,4)
-                self.RefreshRect(r, False)
-
+                   
         digitToolbar = self.parent.toolbars['vdigit']
         digitToolbar = self.parent.toolbars['vdigit']
         if digitToolbar:
         if digitToolbar:
             digitClass = self.parent.digit
             digitClass = self.parent.digit
@@ -3890,6 +3874,7 @@ class MapFrame(wx.Frame):
                                       checktxt = _("Show/hide scale and North arrow"),
                                       checktxt = _("Show/hide scale and North arrow"),
                                       ctrltxt = _("scale object"))
                                       ctrltxt = _("scale object"))
 
 
+        self.dialogs['barscale'].CentreOnParent()
         self.dialogs['barscale'].Show()
         self.dialogs['barscale'].Show()
         self.MapWindow.mouse['use'] = 'pointer'
         self.MapWindow.mouse['use'] = 'pointer'
 
 
@@ -3918,6 +3903,7 @@ class MapFrame(wx.Frame):
                                       checktxt = _("Show/hide legend"),
                                       checktxt = _("Show/hide legend"),
                                       ctrltxt = _("legend object")) 
                                       ctrltxt = _("legend object")) 
 
 
+        self.dialogs['legend'].CentreOnParent()
         self.dialogs['legend'].Show()
         self.dialogs['legend'].Show()
         self.MapWindow.mouse['use'] = 'pointer'
         self.MapWindow.mouse['use'] = 'pointer'
 
 
@@ -3934,18 +3920,20 @@ class MapFrame(wx.Frame):
             else:
             else:
                 id = 101
                 id = 101
 
 
-        dlg = gdialogs.TextLayerDialog(parent=self, ovlId=id, title=_('Add text layer'),
-                                       size=(400, 200))
+        self.dialogs['text'] = gdialogs.TextLayerDialog(parent=self, ovlId=id, 
+                                                    title=_('Add text layer'),
+                                                    size=(400, 200))
 
 
-        dlg.CenterOnParent()
+        self.dialogs['text'].CenterOnParent()
 
 
         # If OK button pressed in decoration control dialog
         # If OK button pressed in decoration control dialog
-        if dlg.ShowModal() == wx.ID_OK:
-            text = dlg.GetValues()['text']
-            coords, w, h = self.MapWindow.TextBounds(dlg.GetValues())
+        if self.dialogs['text'].ShowModal() == wx.ID_OK:
+            text = self.dialogs['text'].GetValues()['text']
+            active = self.dialogs['text'].GetValues()['active']
+            coords, w, h = self.MapWindow.TextBounds(self.dialogs['text'].GetValues())
         
         
-            # delete object if it has no text
-            if text == '':
+            # delete object if it has no text or is not active
+            if text == '' or active == False:
                 try:
                 try:
                     self.MapWindow.pdc.ClearId(id)
                     self.MapWindow.pdc.ClearId(id)
                     self.MapWindow.pdc.RemoveId(id)
                     self.MapWindow.pdc.RemoveId(id)
@@ -3956,7 +3944,7 @@ class MapFrame(wx.Frame):
 
 
             self.MapWindow.pdc.ClearId(id)
             self.MapWindow.pdc.ClearId(id)
             self.MapWindow.pdc.SetId(id)
             self.MapWindow.pdc.SetId(id)
-            self.MapWindow.textdict[id] = dlg.GetValues()
+            self.MapWindow.textdict[id] = self.dialogs['text'].GetValues()
             
             
             self.MapWindow.Draw(self.MapWindow.pdcDec, img=self.MapWindow.textdict[id],
             self.MapWindow.Draw(self.MapWindow.pdcDec, img=self.MapWindow.textdict[id],
                                 drawid=id, pdctype='text', coords=coords)
                                 drawid=id, pdctype='text', coords=coords)