[GRASS-SVN] r48226 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Sep 9 18:48:15 EDT 2011


Author: cmbarton
Date: 2011-09-09 15:48:15 -0700 (Fri, 09 Sep 2011)
New Revision: 48226

Modified:
   grass/trunk/gui/wxpython/gui_modules/psmap.py
   grass/trunk/gui/wxpython/gui_modules/psmap_dialogs.py
Log:
Makes text and map info background and borders visible in pdf preview and output. Gets rid of "exit with 1" errors.

Modified: grass/trunk/gui/wxpython/gui_modules/psmap.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/psmap.py	2011-09-09 22:29:54 UTC (rev 48225)
+++ grass/trunk/gui/wxpython/gui_modules/psmap.py	2011-09-09 22:48:15 UTC (rev 48226)
@@ -1325,7 +1325,7 @@
                     
                     self.RecalculatePosition(ids = [self.dragId])
                     if self.instruction[self.dragId].type in self.openDialogs:
-                        self.openDialogs[self.instruction[self.dragId].type].updateDialog()
+                        self.openDialogs[self.instruction[self.dragId].type].update()
 
         # double click launches dialogs
         elif event.LeftDClick():
@@ -1536,7 +1536,7 @@
             rot = float(textDict['rotate']) 
         else:
             rot = 0
-        
+
         fontsize = textDict['fontsize'] * self.currScale
         if textDict['background'] != 'none':
             background = textDict['background'] 
@@ -1562,7 +1562,7 @@
             pdc.SetBackgroundMode(wx.TRANSPARENT)
         
         fn = self.parent.makePSFont(textDict)
-        
+
         pdc.SetFont(fn)
         pdc.SetTextForeground(convertRGB(textDict['color']))        
         pdc.DrawRotatedText(textDict['text'], coords[0], coords[1], rot)
@@ -1689,7 +1689,6 @@
         self._buffer = wx.EmptyBitmap(width, height)
         # re-render image on idle
         self.resize = True
-
         
     def ScaleRect(self, rect, scale):
         """! Scale rectangle"""

Modified: grass/trunk/gui/wxpython/gui_modules/psmap_dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/psmap_dialogs.py	2011-09-09 22:29:54 UTC (rev 48225)
+++ grass/trunk/gui/wxpython/gui_modules/psmap_dialogs.py	2011-09-09 22:48:15 UTC (rev 48226)
@@ -840,8 +840,7 @@
         self.type = 'mapinfo'
         # default values
         self.defaultInstruction = dict(unit = 'inch', where = (0, 0),
-                                       font = 'Helvetica', fontsize = 10, color = 'black', background = 'none', 
-                                       #font = 'Sans', fontsize = 10, color = '0:0:0', background = 'none', 
+                                       font = 'Helvetica', fontsize = 10, color = '0:0:0', background = 'none', 
                                        border = 'none', rect = None)
         # current values
         self.instruction = dict(self.defaultInstruction)
@@ -2838,7 +2837,6 @@
 
             vector.SetInstruction({'list': deepcopy(self.vectorList)})
             
-
             # save new vectors
             for item in self.vectorList:
                 id = item[2]
@@ -2856,6 +2854,7 @@
                 
         if 'map' in self.parent.parent.openDialogs:
             self.parent.parent.openDialogs['map'].updateDialog()
+
         return True
     
 class RasterDialog(PsmapDialog):
@@ -4145,10 +4144,7 @@
         
         fontSizer.Add(item = flexSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 1)
         border.Add(item = fontSizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)    
-            
 
-
-
     #   some enable/disable methods  
         
     def OnIsLegend(self, event):
@@ -4233,9 +4229,8 @@
         
         self.rSizeGBSizer.Add(self.panelRaster.heightOrColumnsCtrl, pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
         self.panelRaster.Layout()
-        self.panelRaster.Fit()
+        self.panelRaster.Fit()   
         
-        
     def OnRange(self, event):
         if not self.range.GetValue():
             self.min.Disable()        
@@ -4349,13 +4344,7 @@
             # font 
             self.rLegendDict['font'] = self.panelRaster.font['fontCtrl'].GetStringSelection()
             self.rLegendDict['fontsize'] = self.panelRaster.font['fontSizeCtrl'].GetValue()
-##            font = self.panelRaster.font['fontCtrl'].GetSelectedFont()
-##            self.rLegendDict['font'] = font.GetFaceName()
-##            self.rLegendDict['fontsize'] = font.GetPointSize()
             color = self.panelRaster.font['colorCtrl'].GetColour()
-##            if color.GetAsString(wx.C2S_NAME) in PSMAP_COLORS:
-##                self.rLegendDict['color'] = color.GetAsString(wx.C2S_NAME) 
-##            else:
             self.rLegendDict['color'] = convertRGB(color)
 
             # position
@@ -4469,8 +4458,6 @@
                 # font 
                 self.vLegendDict['font'] = self.panelVector.font['fontCtrl'].GetStringSelection()
                 self.vLegendDict['fontsize'] = self.panelVector.font['fontSizeCtrl'].GetValue()
-##                self.vLegendDict['font'] = font.GetFaceName()
-##                self.vLegendDict['fontsize'] = font.GetPointSize()
                 dc = wx.PaintDC(self)
                 font = dc.GetFont()
                 dc.SetFont(wx.Font(pointSize = self.vLegendDict['fontsize'], family = font.GetFamily(),
@@ -4499,16 +4486,11 @@
                 #border
                 if self.borderCheck.GetValue():
                     color = self.borderColorCtrl.GetColour()
-##                    if color.GetAsString(wx.C2S_NAME) in PSMAP_COLORS:
-##                        self.vLegendDict['border'] = color.GetAsString(wx.C2S_NAME) 
-##                    else:
                     self.vLegendDict['border'] = convertRGB(color)
                     
                 else:
                     self.vLegendDict['border'] = 'none'
-                    
-                    
-             
+                                 
         if not self.id[1] in self.instruction:
             vectorLegend = VectorLegend(self.id[1])
             self.instruction.AddInstruction(vectorLegend)
@@ -4590,7 +4572,6 @@
         else:
             self.id = wx.NewId()
             self.mapinfo = Mapinfo(self.id)
-
             self.mapinfoDict = self.mapinfo.GetInstruction()
             page = self.instruction.FindInstructionByType('page').GetInstruction()
             self.mapinfoDict['where'] = page['Left'], page['Top']
@@ -4634,11 +4615,6 @@
         
         self.AddFont(parent = panel, dialogDict = self.mapinfoDict)#creates font color too, used below
         
-##        gridBagSizer.Add(panel.font['fontLabel'], pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
-##        gridBagSizer.Add(panel.font['fontCtrl'], pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
-##        gridBagSizer.Add(panel.font['colorLabel'], pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
-##        gridBagSizer.Add(panel.font['colorCtrl'], pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
-
         gridBagSizer.Add(panel.font['fontLabel'], pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
         gridBagSizer.Add(panel.font['fontCtrl'], pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
         gridBagSizer.Add(panel.font['fontSizeLabel'], pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
@@ -4668,7 +4644,6 @@
             self.colors['borderColor'].SetColour(convertRGB(self.mapinfoDict['border']))
         else:
             self.colors['borderCtrl'].SetValue(False)
-            self.colors['borderColor'].SetColour('white')
 
         if self.mapinfoDict['background'] == None:
             self.mapinfoDict['background'] == 'none'
@@ -4677,8 +4652,7 @@
             self.colors['backgroundColor'].SetColour(convertRGB(self.mapinfoDict['background']))
         else:
             self.colors['backgroundCtrl'].SetValue(False)
-            self.colors['backgroundColor'].SetColour('white')
-        
+                    
         flexSizer.Add(self.colors['borderCtrl'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
         flexSizer.Add(self.colors['borderColor'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
         flexSizer.Add(self.colors['backgroundCtrl'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
@@ -4689,7 +4663,6 @@
         
         panel.SetSizer(border)
         
-
         self.Bind(wx.EVT_CHECKBOX, self.OnIsBorder, self.colors['borderCtrl'])
         self.Bind(wx.EVT_CHECKBOX, self.OnIsBackground, self.colors['backgroundCtrl'])
         
@@ -4715,6 +4688,7 @@
         #units
         currUnit = self.panel.units['unitsCtrl'].GetStringSelection()
         self.mapinfoDict['unit'] = currUnit
+        
         # position
         if self.panel.position['xCtrl'].GetValue():
             x = self.panel.position['xCtrl'].GetValue() 
@@ -4729,33 +4703,23 @@
         x = self.unitConv.convert(value = float(self.panel.position['xCtrl'].GetValue()), fromUnit = currUnit, toUnit = 'inch')
         y = self.unitConv.convert(value = float(self.panel.position['yCtrl'].GetValue()), fromUnit = currUnit, toUnit = 'inch')
         self.mapinfoDict['where'] = (x, y)
+        
         # font
         self.mapinfoDict['font'] =  self.panel.font['fontCtrl'].GetStringSelection()
         self.mapinfoDict['fontsize'] = self.panel.font['fontSizeCtrl'].GetValue()
-##        font = self.panel.font['fontCtrl'].GetSelectedFont()
-##        self.mapinfoDict['font'] = font.GetFaceName()
-##        self.mapinfoDict['fontsize'] = font.GetPointSize()
+
         #colors
         color = self.panel.font['colorCtrl'].GetColour()
-##        if color.GetAsString(wx.C2S_NAME) in PSMAP_COLORS:
-##            self.mapinfoDict['color'] = color.GetAsString(wx.C2S_NAME) 
-##        else:
         self.mapinfoDict['color'] = convertRGB(color)
         
         if self.colors['backgroundCtrl'].GetValue():    
             background = self.colors['backgroundColor'].GetColour()
-##            if background.GetAsString(wx.C2S_NAME) in PSMAP_COLORS:
-##                self.mapinfoDict['background'] = background.GetAsString(wx.C2S_NAME) 
-##            else:
             self.mapinfoDict['background'] = convertRGB(background)
         else:
             self.mapinfoDict['background'] = 'none'
 
         if self.colors['borderCtrl'].GetValue():    
             border = self.colors['borderColor'].GetColour()
-##            if border.GetAsString(wx.C2S_NAME) in PSMAP_COLORS:
-##                self.mapinfoDict['border'] = border.GetAsString(wx.C2S_NAME) 
-##            else:
             self.mapinfoDict['border'] = convertRGB(border)
         else:
             self.mapinfoDict['border'] = 'none'
@@ -4763,15 +4727,17 @@
         # estimation of size
         self.mapinfoDict['rect'] = self.mapinfo.EstimateRect(self.mapinfoDict)
 
-        
         if self.id not in self.instruction:
             mapinfo = Mapinfo(self.id)
             self.instruction.AddInstruction(mapinfo)
+            
         self.instruction[self.id].SetInstruction(self.mapinfoDict)
 
         if self.id not in self.parent.objectId:
             self.parent.objectId.append(self.id)
             
+        self.updateDialog()
+
         return True
     
     def updateDialog(self):
@@ -4782,9 +4748,7 @@
         y = self.unitConv.convert(value = y, fromUnit = 'inch', toUnit = currUnit)
         self.panel.position['xCtrl'].SetValue("%5.3f" % x)
         self.panel.position['yCtrl'].SetValue("%5.3f" % y)
-           
-        
-    
+             
 class ScalebarDialog(PsmapDialog):
     """!Dialog for scale bar"""
     def __init__(self, parent, id, settings):
@@ -4800,8 +4764,6 @@
             page = self.instruction.FindInstructionByType('page').GetInstruction()
             self.scalebarDict['where'] = page['Left'], page['Top']
 
-
-            
         self.panel = self._scalebarPanel()
         
         self._layout(self.panel)
@@ -5106,7 +5068,6 @@
         sizer.Add(self.textCtrl, proportion = 1, flag = wx.ALIGN_CENTER_VERTICAL|wx.ALL, border = 5)
         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)        
         
-
         #font
         
         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
@@ -5145,19 +5106,21 @@
         self.effect['borderColor'] = wx.ColourPickerCtrl(panel, id = wx.ID_ANY)
         self.effect['borderWidth'] = wx.SpinCtrl(panel, id = wx.ID_ANY, size = self.spinCtrlSize, min = 1, max = 25, initial = 1)
         self.effect['borderWidthLabel'] = wx.StaticText(panel, id = wx.ID_ANY, label = _("Width (pts):"))
+
         #set values
-        if self.textDict['background'] != 'none':
+        if self.textDict['background'] == None:
+            self.textDict['background'] = 'none'
+        elif self.textDict['background'] != 'none':
             self.effect['backgroundCtrl'].SetValue(True) 
+            self.effect['backgroundColor'].SetColour(convertRGB(self.textDict['background']))
         else:
             self.effect['backgroundCtrl'].SetValue(False)
 
-        if self.textDict['background'] != 'none':
-            self.effect['backgroundColor'].SetColour(convertRGB(self.textDict['background']))    
-        else:
-            self.effect['backgroundColor'].SetColour('white')
-
-        if self.textDict['hcolor'] != 'none':
+        if self.textDict['hcolor'] == None:
+             self.textDict['hcolor'] = 'none'
+        elif self.textDict['hcolor'] != 'none':
             self.effect['highlightCtrl'].SetValue(True) 
+            self.effect['highlightColor'].SetColour(convertRGB(self.textDict['hcolor']))
         else:
             self.effect['highlightCtrl'].SetValue(False)
 
@@ -5167,16 +5130,15 @@
             self.effect['highlightColor'].SetColour(convertRGB('grey'))
 
         self.effect['highlightWidth'].SetValue(float(self.textDict['hwidth']))
-        if self.textDict['border'] != 'none':
+        
+        if self.textDict['border'] == None:
+            self.textDict['border'] = 'none'
+        elif self.textDict['border'] != 'none':
             self.effect['borderCtrl'].SetValue(True) 
+            self.effect['borderColor'].SetColour(convertRGB(self.textDict['border'])) 
         else:
             self.effect['borderCtrl'].SetValue(False)
 
-        if self.textDict['border'] != 'none':
-            self.effect['borderColor'].SetColour(convertRGB(self.textDict['border'])) 
-        else:
-            self.effect['borderColor'].SetColour('black')
-
         self.effect['borderWidth'].SetValue(float(self.textDict['width']))
         
         gridBagSizer.Add(self.effect['backgroundCtrl'], pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
@@ -5200,6 +5162,7 @@
         
         panel.SetSizer(border)
         panel.Fit()
+        
         return panel 
     
     def _positionPanel(self, notebook):
@@ -5243,11 +5206,9 @@
         self.gridBagSizerP.Add(panel.position['yCtrl'], pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
         self.gridBagSizerP.Add(panel.position['comment'], pos = (3,0), span = (1,2), flag = wx.ALIGN_BOTTOM, border = 0)
         
-        
         sizerP.Add(self.gridBagSizerP, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
         gridBagSizer.Add(sizerP, pos = (2,0),span = (1,1), flag = wx.ALIGN_CENTER_HORIZONTAL|wx.EXPAND, border = 0)
         
-        
         # second box - map coordinates
         box2   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = "")
         sizerM = wx.StaticBoxSizer(box2, wx.VERTICAL)
@@ -5263,7 +5224,6 @@
         self.eastingCtrl.SetValue(str(east))
         self.northingCtrl.SetValue(str(north))
         
-
         self.gridBagSizerM.Add(self.eastingLabel, pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
         self.gridBagSizerM.Add(self.northingLabel, pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
         self.gridBagSizerM.Add(self.eastingCtrl, pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
@@ -5308,8 +5268,7 @@
             self.radio[-1].SetValue(False)
             flexSizer.Add(self.radio[-1], proportion = 0, flag = wx.ALIGN_CENTER, border = 0)
         self.FindWindowByName(self.textDict['ref']).SetValue(True)
-
-        
+                
         sizerR.Add(flexSizer, proportion = 1, flag = wx.EXPAND, border = 0)
         gridBagSizer.Add(sizerR, pos = (3,1), flag = wx.ALIGN_LEFT|wx.EXPAND, border = 0)
         
@@ -5362,6 +5321,7 @@
                 widget.GetWindow().Enable()
             for widget in self.gridBagSizerP.GetChildren():
                 widget.GetWindow().Disable()
+                
     def OnBackground(self, event):
         if self.effect['backgroundCtrl'].GetValue():
             self.effect['backgroundColor'].Enable()
@@ -5402,14 +5362,9 @@
         #font
         self.textDict['font'] = self.textPanel.font['fontCtrl'].GetStringSelection()
         self.textDict['fontsize'] = self.textPanel.font['fontSizeCtrl'].GetValue()
-##        font = self.textPanel.font['fontCtrl'].GetSelectedFont()
-##        self.textDict['font'] = font.GetFaceName()
-##        self.textDict['fontsize'] = font.GetPointSize()
         color = self.textPanel.font['colorCtrl'].GetColour()
-##        if color.GetAsString(wx.C2S_NAME) in PSMAP_COLORS:
-##            self.textDict['color'] = color.GetAsString(wx.C2S_NAME) 
-##        else:
         self.textDict['color'] = convertRGB(color)
+
         #effects
         if self.effect['backgroundCtrl'].GetValue():
             background = self.effect['backgroundColor'].GetColour()
@@ -5436,6 +5391,7 @@
         #offset
         self.textDict['xoffset'] = self.xoffCtrl.GetValue()
         self.textDict['yoffset'] = self.yoffCtrl.GetValue()
+
         #position
         if self.paperPositionCtrl.GetValue():
             self.textDict['XY'] = True
@@ -5487,6 +5443,8 @@
         if self.id not in self.parent.objectId:
             self.parent.objectId.append(self.id)
 
+#        self.updateDialog()
+
         return True
     
     def updateDialog(self):
@@ -5502,7 +5460,6 @@
         e, n = self.textDict['east'], self.textDict['north']
         self.eastingCtrl.SetValue(str(self.textDict['east']))
         self.northingCtrl.SetValue(str(self.textDict['north']))
-
         
 def convertRGB(rgb):
     """!Converts wx.Colour(r,g,b,a) to string 'r:g:b' or named color,



More information about the grass-commit mailing list