Browse Source

wxGUI/wxpsmap: use '/usr/local/src/psmap_trunk/dist.i686-pc-linux-gnu' shortcut in eps file path if possible

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@50897 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 13 năm trước cách đây
mục cha
commit
4da1248083
2 tập tin đã thay đổi với 12 bổ sung7 xóa
  1. 11 6
      gui/wxpython/psmap/instructions.py
  2. 1 1
      gui/wxpython/psmap/utils.py

+ 11 - 6
gui/wxpython/psmap/instructions.py

@@ -889,9 +889,10 @@ class Image(InstructionObject):
         
     def __str__(self):
         self.ChangeRefPoint(toCenter = True)
+        epsfile = self.instruction['epsfile'].replace(os.getenv('GISBASE'), "$GISBASE")
         
         instr = "eps %s %s\n" % (self.instruction['east'], self.instruction['north'])
-        instr += string.Template("    epsfile $epsfile\n").substitute(self.instruction)
+        instr += "    epsfile %s\n" % epsfile
         if self.instruction["rotate"]:
             instr += string.Template("    rotate $rotate\n").substitute(self.instruction)
         if self.instruction["scale"]:
@@ -916,7 +917,8 @@ class Image(InstructionObject):
                         instr['east'], instr['north'] = float(e), float(n)
                 
                 elif sub == 'epsfile':
-                    instr['epsfile'] = line.split(None, 1)[1]
+                    epsfile = line.split(None, 1)[1]
+                    instr['epsfile'] = epsfile.replace("$GISBASE", os.getenv("GISBASE"))
                 elif sub == 'rotate':
                     instr['rotate'] = float(line.split(None, 1)[1])
                 elif sub == 'scale':
@@ -999,10 +1001,11 @@ class NorthArrow(Image):
         
     def __str__(self):
         self.ChangeRefPoint(toCenter = True)
-        
+        epsfile = self.instruction['epsfile'].replace(os.getenv('GISBASE'), "$GISBASE")
+
         instr = "eps %s %s\n" % (self.instruction['east'], self.instruction['north'])
         instr += "# north arrow\n"
-        instr += string.Template("    epsfile $epsfile\n").substitute(self.instruction)
+        instr += "    epsfile %s\n" % epsfile
         if self.instruction["rotate"]:
             instr += string.Template("    rotate $rotate\n").substitute(self.instruction)
         if self.instruction["scale"]:
@@ -1663,7 +1666,8 @@ class VProperties(InstructionObject):
                     
         if self.subType == 'areas':
             if dic['pat'] is not None:
-                vInstruction += string.Template("    pat $pat\n").substitute(dic)
+                patternFile = dic['pat'].replace(os.getenv("GISBASE"), "$GISBASE")
+                vInstruction += "    pat %s\n" % patternFile
                 vInstruction += string.Template("    pwidth $pwidth\n").substitute(dic)
                 vInstruction += string.Template("    scale $scale\n").substitute(dic)
                 
@@ -1775,7 +1779,8 @@ class VProperties(InstructionObject):
                 if line.startswith('fcolor'):
                     instr['fcolor'] = line.split()[1]    
                 elif line.startswith('pat'):
-                    instr['pat'] = line.split()[1]
+                    patternFile = line.split()[1]
+                    instr['pat'] = patternFile.replace("$GISBASE", os.getenv("GISBASE"))
                 elif line.startswith('pwidth'):
                     instr['pwidth'] = float(line.split()[1])
                 elif line.startswith('scale'):

+ 1 - 1
gui/wxpython/psmap/utils.py

@@ -15,7 +15,7 @@ This program is free software under the GNU General Public License
 
 @author Anna Kratochvilova <kratochanna gmail.com>
 """
-
+import os
 import wx
 from math import ceil, floor, sin, cos, pi