Pārlūkot izejas kodu

wxGUI/modeler: fix export to image

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@41868 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 15 gadi atpakaļ
vecāks
revīzija
31d8f91363
1 mainītis faili ar 25 papildinājumiem un 2 dzēšanām
  1. 25 2
      gui/wxpython/gui_modules/gmodeler.py

+ 25 - 2
gui/wxpython/gui_modules/gmodeler.py

@@ -361,8 +361,31 @@ class ModelFrame(wx.Frame):
                      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))