graphics/LD_Objects.py
branchpython3
changeset 3759 f713566d5d01
parent 3752 9f6f46dbe3ae
equal deleted inserted replaced
3758:bc71b19b45ff 3759:f713566d5d01
    21 # You should have received a copy of the GNU General Public License
    21 # You should have received a copy of the GNU General Public License
    22 # along with this program; if not, write to the Free Software
    22 # along with this program; if not, write to the Free Software
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    24 
    24 
    25 
    25 
       
    26 from functools import cmp_to_key
       
    27 from operator import eq
    26 import wx
    28 import wx
    27 
    29 
    28 from graphics.GraphicCommons import *
    30 from graphics.GraphicCommons import *
    29 from graphics.DebugDataConsumer import DebugDataConsumer
    31 from graphics.DebugDataConsumer import DebugDataConsumer
    30 from plcopen.structures import *
    32 from plcopen.structures import *
   155         self.Pos.y = min(min_pos, self.Pos.y)
   157         self.Pos.y = min(min_pos, self.Pos.y)
   156         if min_pos == self.Pos.y:
   158         if min_pos == self.Pos.y:
   157             for connect in self.Connectors:
   159             for connect in self.Connectors:
   158                 connect_pos = connect.GetRelPosition()
   160                 connect_pos = connect.GetRelPosition()
   159                 connect.SetPosition(wx.Point(connect_pos.x, connect_pos.y - miny))
   161                 connect.SetPosition(wx.Point(connect_pos.x, connect_pos.y - miny))
   160         self.Connectors.sort(lambda x, y: cmp(x.Pos.y, y.Pos.y))
   162         self.Connectors.sort(key=cmp_to_key(lambda x, y: eq(x.Pos.y, y.Pos.y)))
   161         maxy = 0
   163         maxy = 0
   162         for connect in self.Connectors:
   164         for connect in self.Connectors:
   163             connect_pos = connect.GetRelPosition()
   165             connect_pos = connect.GetRelPosition()
   164             maxy = max(maxy, connect_pos.y)
   166             maxy = max(maxy, connect_pos.y)
   165         self.Size[1] = max(maxy + self.Extensions[1], self.Size[1])
   167         self.Size[1] = max(maxy + self.Extensions[1], self.Size[1])