[GRASS-SVN] r35121 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 30 17:12:18 EST 2008


Author: cmbarton
Date: 2008-12-30 17:12:18 -0500 (Tue, 30 Dec 2008)
New Revision: 35121

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
Log:
Fix for remaining issues in ticket #291 for text overlays: added text show checkbox and disabled right click non-functional functions.

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py	2008-12-30 18:32:44 UTC (rev 35120)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py	2008-12-30 22:12:18 UTC (rev 35121)
@@ -466,37 +466,48 @@
         sizer = wx.BoxSizer(wx.VERTICAL)
         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
         label = wx.StaticText(parent=self, id=wx.ID_ANY, label=_("Enter text:"))
         box.Add(item=label,
                 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.SetFont(self.currFont)
         self.textentry.SetForegroundColour(self.currClr)
         self.textentry.SetValue(self.currText)
         box.Add(item=self.textentry,
-                pos=(0, 1))
+                pos=(1, 1))
 
         # rotation
         label = wx.StaticText(parent=self, id=wx.ID_ANY, label=_("Rotation:"))
         box.Add(item=label,
                 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),
                                     size=(75,-1), style=wx.SP_ARROW_KEYS)
         self.rotation.SetRange(-360, 360)
         self.rotation.SetValue(int(self.currRot))
         box.Add(item=self.rotation,
                 flag=wx.ALIGN_RIGHT,
-                pos=(1, 1))
+                pos=(2, 1))
 
         # font
         fontbtn = wx.Button(parent=self, id=wx.ID_ANY, label=_("Set font"))
         box.Add(item=fontbtn,
                 flag=wx.ALIGN_RIGHT,
-                pos=(2, 1))
+                pos=(3, 1))
 
         sizer.Add(item=box, proportion=1,
                   flag=wx.ALL, border=10)
@@ -574,7 +585,8 @@
                  'font' : self.currFont,
                  'color' : self.currClr,
                  'rotation' : self.currRot,
-                 'coords' : self.currCoords }
+                 'coords' : self.currCoords,
+                 'active' : self.chkbox.IsChecked() }
 
 class LoadMapLayersDialog(wx.Dialog):
     """Load selected map layers (raster, vector) into layer tree"""

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-12-30 18:32:44 UTC (rev 35120)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-12-30 22:12:18 UTC (rev 35121)
@@ -421,6 +421,7 @@
                 # self.ovlcoords[drawid] = coords
 
         elif pdctype == 'text': # draw text on top of map
+            if not img['active']: return #only draw active text
             if img.has_key('rotation'):
                 rotation = float(img['rotation'])
             else:
@@ -1752,24 +1753,7 @@
         """
         Debug.msg (5, "BufferedWindow.OnRightDown(): use=%s" % \
                    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']
         if digitToolbar:
             digitClass = self.parent.digit
@@ -3895,6 +3879,7 @@
                                       checktxt = _("Show/hide scale and North arrow"),
                                       ctrltxt = _("scale object"))
 
+        self.dialogs['barscale'].CentreOnParent()
         self.dialogs['barscale'].Show()
         self.MapWindow.mouse['use'] = 'pointer'
 
@@ -3923,6 +3908,7 @@
                                       checktxt = _("Show/hide legend"),
                                       ctrltxt = _("legend object")) 
 
+        self.dialogs['legend'].CentreOnParent()
         self.dialogs['legend'].Show()
         self.MapWindow.mouse['use'] = 'pointer'
 
@@ -3939,18 +3925,20 @@
             else:
                 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 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:
                     self.MapWindow.pdc.ClearId(id)
                     self.MapWindow.pdc.RemoveId(id)
@@ -3961,7 +3949,7 @@
 
             self.MapWindow.pdc.ClearId(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],
                                 drawid=id, pdctype='text', coords=coords)



More information about the grass-commit mailing list