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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 14 17:44:36 EDT 2010


Author: martinl
Date: 2010-04-14 17:44:35 -0400 (Wed, 14 Apr 2010)
New Revision: 41868

Modified:
   grass/trunk/gui/wxpython/gui_modules/gmodeler.py
Log:
wxGUI/modeler: fix export to image


Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2010-04-14 20:57:48 UTC (rev 41867)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2010-04-14 21:44:35 UTC (rev 41868)
@@ -361,8 +361,31 @@
                      msgType = 'info')
     
     def OnExportImage(self, event):
-        """!Export model to image (default image)"""
-        size = self.canvas.GetSize()
+        """!Export model to image (default image)
+        """
+        xminImg = 0
+        xmaxImg = 0
+        yminImg = 0
+        ymaxImg = 0
+        for shape in self.canvas.GetDiagram().GetShapeList():
+            w, h = shape.GetBoundingBoxMax()
+            x    = shape.GetX()
+            y    = shape.GetY()
+            xmin = x - w / 2
+            xmax = x + w / 2
+            ymin = y - h / 2
+            ymax = y + h / 2
+            if xmin < xminImg:
+                xminImg = xmin
+            if xmax > xmaxImg:
+                xmaxImg = xmax
+            if ymin < yminImg:
+                xminImg = xmin
+            if ymax < ymaxImg:
+                xminImg = xmin
+            
+        size = wx.Size(int(xmaxImg - xminImg),
+                       int(ymaxImg - ymaxImg))
         bitmap = wx.EmptyBitmap(width = size.width, height = size.height)
         
         filetype, ltype = GetImageHandlers(wx.ImageFromBitmap(bitmap))



More information about the grass-commit mailing list