graphics/LD_Objects.py
changeset 64 dd6f693e46a1
parent 61 dc7142ae9438
child 71 0578bc212c20
--- a/graphics/LD_Objects.py	Tue Aug 07 17:37:38 2007 +0200
+++ b/graphics/LD_Objects.py	Tue Aug 07 17:38:48 2007 +0200
@@ -22,7 +22,6 @@
 #License along with this library; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-from wxPython.wx import *
 import wx
 
 from GraphicCommons import *
@@ -83,12 +82,12 @@
                 
     # Refresh the power rail bounding box
     def RefreshBoundingBox(self):
-        dc = wxClientDC(self.Parent)
-        self.BoundingBox = wxRect(self.Pos.x, self.Pos.y, self.Size[0], self.Size[1] + 1)
+        dc = wx.ClientDC(self.Parent)
+        self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y, self.Size[0], self.Size[1] + 1)
     
     # Refresh the power rail size
     def RefreshSize(self):
-        self.Size = wxSize(2, LD_LINE_SIZE * len(self.Connectors))
+        self.Size = wx.Size(2, LD_LINE_SIZE * len(self.Connectors))
         self.RefreshBoundingBox()
     
     # Returns the block minimum size
@@ -103,9 +102,9 @@
     def InsertConnector(self, idx, connector = True):
         if connector:
             if self.Type == LEFTRAIL:
-                connector = Connector(self, "", "BOOL", wxPoint(2, 0), EAST)
+                connector = Connector(self, "", "BOOL", wx.Point(2, 0), EAST)
             elif self.Type == RIGHTRAIL:
-                connector = Connector(self, "", "BOOL", wxPoint(0, 0), WEST)
+                connector = Connector(self, "", "BOOL", wx.Point(0, 0), WEST)
             self.Connectors.insert(idx, connector)
         else:
             self.Connectors.insert(idx, None)
@@ -115,7 +114,7 @@
     # Moves the divergence connector given
     def MoveConnector(self, connector, movey):
         position = connector.GetRelPosition()
-        connector.SetPosition(wxPoint(position.x, position.y + movey))
+        connector.SetPosition(wx.Point(position.x, position.y + movey))
         miny = self.Size[1]
         maxy = 0
         for connect in self.Connectors:
@@ -127,7 +126,7 @@
         if min_pos == self.Pos.y:
             for connect in self.Connectors:
                 connect_pos = connect.GetRelPosition()
-                connect.SetPosition(wxPoint(connect_pos.x, connect_pos.y - miny + self.Extensions[0]))
+                connect.SetPosition(wx.Point(connect_pos.x, connect_pos.y - miny + self.Extensions[0]))
         self.Size[1] = max(maxy - miny + self.Extensions[0] + self.Extensions[1], self.Size[1])
         connector.MoveConnected()
         self.RefreshBoundingBox()
@@ -156,9 +155,9 @@
         for connector in self.Connectors:
             if connector:
                 if self.Type == LEFTRAIL:
-                    connector.SetPosition(wxPoint(self.Size[0], position))
+                    connector.SetPosition(wx.Point(self.Size[0], position))
                 elif self.Type == RIGHTRAIL:
-                    connector.SetPosition(wxPoint(0, position))
+                    connector.SetPosition(wx.Point(0, position))
             position += LD_LINE_SIZE
         self.RefreshConnected()
     
@@ -217,7 +216,7 @@
         connector = self.TestConnector(pos, False)
         if connector:
             self.Handle = (HANDLE_CONNECTOR, connector)
-            self.Parent.SetCursor(wxStockCursor(wxCURSOR_HAND))
+            self.Parent.SetCursor(wx.StockCursor(wx.CURSOR_HAND))
             self.Selected = False
             # Initializes the last position
             self.oldPos = GetScaledEventPosition(event, dc, scaling)
@@ -284,8 +283,8 @@
     
     # Draws power rail
     def Draw(self, dc):
-        dc.SetPen(wxBLACK_PEN)
-        dc.SetBrush(wxBLACK_BRUSH)
+        dc.SetPen(wx.BLACK_PEN)
+        dc.SetBrush(wx.BLACK_BRUSH)
         # Draw a rectangle with the power rail size
         dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
         # Draw connectors
@@ -311,10 +310,10 @@
         self.Type = type
         self.Name = name
         self.Id = id
-        self.Size = wxSize(LD_ELEMENT_SIZE[0], LD_ELEMENT_SIZE[1])
+        self.Size = wx.Size(LD_ELEMENT_SIZE[0], LD_ELEMENT_SIZE[1])
         # Create an input and output connector
-        self.Input = Connector(self, "", "BOOL", wxPoint(0, self.Size[1] / 2 + 1), WEST)
-        self.Output = Connector(self, "", "BOOL", wxPoint(self.Size[0], self.Size[1] / 2 + 1), EAST)
+        self.Input = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2 + 1), WEST)
+        self.Output = Connector(self, "", "BOOL", wx.Point(self.Size[0], self.Size[1] / 2 + 1), EAST)
         self.RefreshNameSize()
         self.RefreshTypeSize()
     
@@ -340,7 +339,7 @@
     
     # Refresh the size of text for name
     def RefreshNameSize(self):
-        dc = wxClientDC(self.Parent)
+        dc = wx.ClientDC(self.Parent)
         if self.Name != "":
             self.NameSize = dc.GetTextExtent(self.Name)
         else:
@@ -348,7 +347,7 @@
     
     # Refresh the size of text for type
     def RefreshTypeSize(self):
-        dc = wxClientDC(self.Parent)
+        dc = wx.ClientDC(self.Parent)
         typetext = ""
         if self.Type == CONTACT_REVERSE:
             typetext = "/"
@@ -363,7 +362,7 @@
     
     # Refresh the contact bounding box
     def RefreshBoundingBox(self):
-        dc = wxClientDC(self.Parent)
+        dc = wx.ClientDC(self.Parent)
         # Calculate the size of the name outside the contact
         text_width, text_height = dc.GetTextExtent(self.Name)
         # Calculate the bounding box size
@@ -377,7 +376,7 @@
             bbx_width = self.Size[0]
             bbx_y = self.Pos.y
             bbx_height = self.Size[1]
-        self.BoundingBox = wxRect(bbx_x, bbx_y, bbx_width + 1, bbx_height + 1)
+        self.BoundingBox = wx.Rect(bbx_x, bbx_y, bbx_width + 1, bbx_height + 1)
     
     # Returns the block minimum size
     def GetMinSize(self):
@@ -423,8 +422,8 @@
 
     # Refresh the positions of the block connectors
     def RefreshConnectors(self):
-        self.Input.SetPosition(wxPoint(0, self.Size[1] / 2 + 1))
-        self.Output.SetPosition(wxPoint(self.Size[0], self.Size[1] / 2 + 1))
+        self.Input.SetPosition(wx.Point(0, self.Size[1] / 2 + 1))
+        self.Output.SetPosition(wx.Point(self.Size[0], self.Size[1] / 2 + 1))
         self.RefreshConnected()
 
     # Changes the contact name
@@ -459,8 +458,8 @@
     
     # Draws contact
     def Draw(self, dc):
-        dc.SetPen(wxBLACK_PEN)
-        dc.SetBrush(wxBLACK_BRUSH)
+        dc.SetPen(wx.BLACK_PEN)
+        dc.SetBrush(wx.BLACK_BRUSH)
         # Draw two rectangles for representing the contact
         dc.DrawRectangle(self.Pos.x, self.Pos.y, 2, self.Size[1] + 1)
         dc.DrawRectangle(self.Pos.x + self.Size[0] - 1, self.Pos.y, 2, self.Size[1] + 1)
@@ -500,10 +499,10 @@
         self.Type = type
         self.Name = name
         self.Id = id
-        self.Size = wxSize(LD_ELEMENT_SIZE[0], LD_ELEMENT_SIZE[1])
+        self.Size = wx.Size(LD_ELEMENT_SIZE[0], LD_ELEMENT_SIZE[1])
         # Create an input and output connector
-        self.Input = Connector(self, "", "BOOL", wxPoint(0, self.Size[1] / 2 + 1), WEST)
-        self.Output = Connector(self, "", "BOOL", wxPoint(self.Size[0], self.Size[1] / 2 + 1), EAST)
+        self.Input = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2 + 1), WEST)
+        self.Output = Connector(self, "", "BOOL", wx.Point(self.Size[0], self.Size[1] / 2 + 1), EAST)
         self.RefreshNameSize()
         self.RefreshTypeSize()
         
@@ -529,7 +528,7 @@
                 
     # Refresh the size of text for name
     def RefreshNameSize(self):
-        dc = wxClientDC(self.Parent)
+        dc = wx.ClientDC(self.Parent)
         if self.Name != "":
             self.NameSize = dc.GetTextExtent(self.Name)
         else:
@@ -537,7 +536,7 @@
     
     # Refresh the size of text for type
     def RefreshTypeSize(self):
-        dc = wxClientDC(self.Parent)
+        dc = wx.ClientDC(self.Parent)
         typetext = ""
         if self.Type == COIL_REVERSE:
             typetext = "/"
@@ -552,7 +551,7 @@
     
     # Refresh the coil bounding box
     def RefreshBoundingBox(self):
-        dc = wxClientDC(self.Parent)
+        dc = wx.ClientDC(self.Parent)
         # Calculate the size of the name outside the coil
         text_width, text_height = dc.GetTextExtent(self.Name)
         # Calculate the bounding box size
@@ -566,7 +565,7 @@
             bbx_width = self.Size[0]
             bbx_y = self.Pos.y
             bbx_height = self.Size[1]
-        self.BoundingBox = wxRect(bbx_x, bbx_y, bbx_width + 1, bbx_height + 1)
+        self.BoundingBox = wx.Rect(bbx_x, bbx_y, bbx_width + 1, bbx_height + 1)
         
     # Returns the block minimum size
     def GetMinSize(self):
@@ -612,8 +611,8 @@
     
     # Refresh the positions of the block connectors
     def RefreshConnectors(self):
-        self.Input.SetPosition(wxPoint(0, self.Size[1] / 2 + 1))
-        self.Output.SetPosition(wxPoint(self.Size[0], self.Size[1] / 2 + 1))
+        self.Input.SetPosition(wx.Point(0, self.Size[1] / 2 + 1))
+        self.Output.SetPosition(wx.Point(self.Size[0], self.Size[1] / 2 + 1))
         self.RefreshConnected()
     
     # Changes the coil name
@@ -648,12 +647,12 @@
     
     # Draws coil
     def Draw(self, dc):
-        dc.SetPen(wxPen(wxBLACK, 2, wxSOLID))
-        dc.SetBrush(wxTRANSPARENT_BRUSH)
+        dc.SetPen(wx.Pen(wx.BLACK, 2, wx.SOLID))
+        dc.SetBrush(wx.TRANSPARENT_BRUSH)
         # Draw a two circle arcs for representing the coil
         dc.DrawEllipticArc(self.Pos.x, self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1, self.Size[0], int(self.Size[1] * sqrt(2)) - 1, 135, 225)
         dc.DrawEllipticArc(self.Pos.x, self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1, self.Size[0], int(self.Size[1] * sqrt(2)) - 1, -45, 45)
-        dc.SetPen(wxBLACK_PEN)
+        dc.SetPen(wx.BLACK_PEN)
         dc.DrawPoint(self.Pos.x + 1, self.Pos.y + self.Size[1] / 2 + 1)
         # Draw coil name
         dc.DrawText(self.Name, self.Pos.x + (self.Size[0] - self.NameSize[0]) / 2,