[GRASS-SVN] r45904 - grass-addons/gui/wxpython/wx.psmap/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Apr 11 12:53:40 EDT 2011


Author: annakrat
Date: 2011-04-11 09:53:40 -0700 (Mon, 11 Apr 2011)
New Revision: 45904

Modified:
   grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap.py
   grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap_dialogs.py
Log:
wx.psmap: map frame resizing improved, minor changes in vector dialog

Modified: grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap.py
===================================================================
--- grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap.py	2011-04-11 10:43:23 UTC (rev 45903)
+++ grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap.py	2011-04-11 16:53:40 UTC (rev 45904)
@@ -1176,13 +1176,22 @@
 
                 if foundResize and foundResize[0] == self.idResizeBoxTmp:
                     self.mouse['use'] = 'resize'
+                    
+                    # when resizing, proportions match region
+                    if self.instruction[self.dragId].type == 'map':
+                        self.constraint = False
+                        self.mapBounds = self.pdcObj.GetIdBounds(self.dragId)
+                        if self.instruction[self.dragId]['scaleType'] in (0, 1, 2):
+                            self.constraint = True
+                            self.mapBounds = self.pdcObj.GetIdBounds(self.dragId)
+                    
                 elif found:
                     self.dragId = found[0]  
                     self.RedrawSelectBox(self.dragId)
                     if self.instruction[self.dragId].type != 'map':
                         self.pdcTmp.RemoveId(self.idResizeBoxTmp)
                         self.Refresh()
-
+                        
                 else:
                     self.dragId = -1
                     self.pdcTmp.RemoveId(self.idBoxTmp)
@@ -1224,17 +1233,29 @@
                 
             # resize object
             if self.mouse['use'] == 'resize':
-                bounds = self.pdcObj.GetIdBounds(self.dragId)
                 type = self.instruction[self.dragId].type
-                self.mouse['end'] = event.GetPosition()
-                diffX = self.mouse['end'][0] - self.begin[0]
-                diffY = self.mouse['end'][1] - self.begin[1]
-                bounds.Inflate(diffX, diffY)
+                pos = event.GetPosition()
+                x, y = self.mapBounds.GetX(), self.mapBounds.GetY()
+                width, height = self.mapBounds.GetWidth(), self.mapBounds.GetHeight()
+                diffX = pos[0] - self.mouse['begin'][0]
+                diffY = pos[1] - self.mouse['begin'][1]
+                # match given region
+                if self.constraint:
+                    if width > height:
+                        newWidth = width + diffX
+                        newHeight = height + diffX * (float(height) / width)
+                    else:
+                        newWidth = width + diffY * (float(width) / height)
+                        newHeight = height + diffY
+                else:
+                    newWidth = width + diffX
+                    newHeight = height + diffY
+                    
                 
+                bounds = wx.Rect(x, y, newWidth, newHeight)    
                 self.Draw(pen = self.pen[type], brush = self.brush[type], pdc = self.pdcObj, drawid = self.dragId,
                             pdctype = 'rectText', bb = bounds)
                 self.RedrawSelectBox(self.dragId)
-                self.begin = event.GetPosition()
                 
         elif event.LeftUp():
             # zoom in, zoom out

Modified: grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap_dialogs.py
===================================================================
--- grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap_dialogs.py	2011-04-11 10:43:23 UTC (rev 45903)
+++ grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap_dialogs.py	2011-04-11 16:53:40 UTC (rev 45904)
@@ -2533,19 +2533,19 @@
         self.btnUp = wx.Button(self, id = wx.ID_ANY, label = _("Up"))
         self.btnDown = wx.Button(self, id = wx.ID_ANY, label = _("Down"))
         self.btnDel = wx.Button(self, id = wx.ID_ANY, label = _("Delete"))
-        self.btnProp = wx.Button(self, id = wx.ID_ANY, label = _("Properties"))
+        self.btnProp = wx.Button(self, id = wx.ID_ANY, label = _("Properties..."))
         
         self.updateListBox(selected = 0)
         
         
-        gridBagSizer.Add(text, pos = (0,0), span = (1,2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
+        gridBagSizer.Add(text, pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
         gridBagSizer.Add(self.listbox, pos = (1,0), span = (4, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
-        gridBagSizer.Add(self.btnUp, pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
-        gridBagSizer.Add(self.btnDown, pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
-        gridBagSizer.Add(self.btnDel, pos = (3,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
-        gridBagSizer.Add(self.btnProp, pos = (4,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
+        gridBagSizer.Add(self.btnUp, pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
+        gridBagSizer.Add(self.btnDown, pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
+        gridBagSizer.Add(self.btnDel, pos = (3,1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
+        gridBagSizer.Add(self.btnProp, pos = (4,1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
         
-        sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
+        sizer.Add(gridBagSizer, proportion = 0, flag = wx.ALL, border = 5)
         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
         
         self.Bind(wx.EVT_BUTTON, self.OnAddVector, self.AddVector)
@@ -3820,6 +3820,7 @@
         else: 
             w = ''
         panel.widthCtrl = wx.TextCtrl(panel, id = wx.ID_ANY, value = str(w), validator = TCValidator("DIGIT_ONLY"))
+        panel.widthCtrl.SetToolTipString(_("Leave the edit field empty, to use default values."))
         
         if legendType == 'raster':
 ##            panel.defaultSize = wx.CheckBox(panel, id = wx.ID_ANY, label = _("Use default size"))



More information about the grass-commit mailing list