LDViewer.py
changeset 391 07447ee3538e
parent 383 25ffba02b6a8
child 426 afe2488a4635
equal deleted inserted replaced
390:020420ad8914 391:07447ee3538e
   208                         connected = self.FindElementById(link["refLocalId"])
   208                         connected = self.FindElementById(link["refLocalId"])
   209                         rung = self.FindRung(connected)
   209                         rung = self.FindRung(connected)
   210                         if rung not in rungs:
   210                         if rung not in rungs:
   211                             rungs.append(rung)
   211                             rungs.append(rung)
   212                 if len(rungs) > 1:
   212                 if len(rungs) > 1:
   213                     raise "ValueError", "Ladder element with id %d is on more than one rung."%instance["id"]
   213                     raise ValueError, _("Ladder element with id %d is on more than one rung.")%instance["id"]
   214                 element = self.FindElementById(instance["id"])
   214                 element = self.FindElementById(instance["id"])
   215                 self.Rungs[rungs[0]].SelectElement(element)
   215                 self.Rungs[rungs[0]].SelectElement(element)
   216                 for connector in element.GetConnectors():
   216                 for connector in element.GetConnectors():
   217                     for wire, num in connector.GetWires():
   217                     for wire, num in connector.GetWires():
   218                         self.Rungs[rungs[0]].SelectElement(wire)
   218                         self.Rungs[rungs[0]].SelectElement(wire)
   223                     connected = self.FindElementById(link["refLocalId"])
   223                     connected = self.FindElementById(link["refLocalId"])
   224                     rung = self.FindRung(connected)
   224                     rung = self.FindRung(connected)
   225                     if rung not in rungs:
   225                     if rung not in rungs:
   226                         rungs.append(rung)
   226                         rungs.append(rung)
   227                 if len(rungs) > 1:
   227                 if len(rungs) > 1:
   228                     raise "ValueError", "Ladder element with id %d is on more than one rung."%instance["id"]
   228                     raise ValueError, _("Ladder element with id %d is on more than one rung.")%instance["id"]
   229                 element = self.FindElementById(instance["id"])
   229                 element = self.FindElementById(instance["id"])
   230                 self.Rungs[rungs[0]].SelectElement(element)
   230                 self.Rungs[rungs[0]].SelectElement(element)
   231                 for wire, num in element.GetConnectors()["input"].GetWires():
   231                 for wire, num in element.GetConnectors()["input"].GetWires():
   232                     self.Rungs[rungs[0]].SelectElement(wire)
   232                     self.Rungs[rungs[0]].SelectElement(wire)
   233                 self.RefreshPosition(element)
   233                 self.RefreshPosition(element)
   473                 starty = bbox.y + bbox.height
   473                 starty = bbox.y + bbox.height
   474             starty += LD_OFFSET[1]
   474             starty += LD_OFFSET[1]
   475             rung = Graphic_Group(self)
   475             rung = Graphic_Group(self)
   476             # Create comment
   476             # Create comment
   477             id = self.GetNewId()
   477             id = self.GetNewId()
   478             comment = Comment(self, "Commentaire", id)
   478             comment = Comment(self, _("Comment"), id)
   479             comment.SetPosition(startx, starty)
   479             comment.SetPosition(startx, starty)
   480             comment.SetSize(LD_COMMENT_DEFAULTSIZE[0], LD_COMMENT_DEFAULTSIZE[1])
   480             comment.SetSize(LD_COMMENT_DEFAULTSIZE[0], LD_COMMENT_DEFAULTSIZE[1])
   481             self.AddComment(comment)
   481             self.AddComment(comment)
   482             self.RungComments.append(comment)
   482             self.RungComments.append(comment)
   483             self.Controler.AddEditedElementComment(self.TagName, id)
   483             self.Controler.AddEditedElementComment(self.TagName, id)
   623                 self.RefreshRungs(new_bbox.height - old_bbox.height, rungindex + 1)
   623                 self.RefreshRungs(new_bbox.height - old_bbox.height, rungindex + 1)
   624                 self.RefreshBuffer()
   624                 self.RefreshBuffer()
   625                 self.RefreshScrollBars()
   625                 self.RefreshScrollBars()
   626                 self.Refresh(False)
   626                 self.Refresh(False)
   627         else:
   627         else:
   628             message = wx.MessageDialog(self, "You must select the wire where a contact should be added!", "Error", wx.OK|wx.ICON_ERROR)
   628             message = wx.MessageDialog(self, _("You must select the wire where a contact should be added!"), _("Error"), wx.OK|wx.ICON_ERROR)
   629             message.ShowModal()
   629             message.ShowModal()
   630             message.Destroy()
   630             message.Destroy()
   631 
   631 
   632     def AddLadderBranch(self):
   632     def AddLadderBranch(self):
   633         blocks = []
   633         blocks = []
   845                 self.RefreshRungs(new_bbox.height - old_bbox.height, rungindex + 1)
   845                 self.RefreshRungs(new_bbox.height - old_bbox.height, rungindex + 1)
   846                 self.RefreshBuffer()
   846                 self.RefreshBuffer()
   847                 self.RefreshScrollBars()
   847                 self.RefreshScrollBars()
   848                 self.Refresh(False)
   848                 self.Refresh(False)
   849             else:
   849             else:
   850                 message = wx.MessageDialog(self, "The group of block must be coherent!", "Error", wx.OK|wx.ICON_ERROR)
   850                 message = wx.MessageDialog(self, _("The group of block must be coherent!"), _("Error"), wx.OK|wx.ICON_ERROR)
   851                 message.ShowModal()
   851                 message.ShowModal()
   852                 message.Destroy()
   852                 message.Destroy()
   853         else:
   853         else:
   854             message = wx.MessageDialog(self, "You must select the block or group of blocks around which a branch should be added!", "Error", wx.OK|wx.ICON_ERROR)
   854             message = wx.MessageDialog(self, _("You must select the block or group of blocks around which a branch should be added!"), _("Error"), wx.OK|wx.ICON_ERROR)
   855             message.ShowModal()
   855             message.ShowModal()
   856             message.Destroy()
   856             message.Destroy()
   857 
   857 
   858     def AddLadderBlock(self):
   858     def AddLadderBlock(self):
   859         message = wx.MessageDialog(self, "This option isn't available yet!", "Warning", wx.OK|wx.ICON_EXCLAMATION)
   859         message = wx.MessageDialog(self, _("This option isn't available yet!"), _("Warning"), wx.OK|wx.ICON_EXCLAMATION)
   860         message.ShowModal()
   860         message.ShowModal()
   861         message.Destroy()
   861         message.Destroy()
   862 
   862 
   863 #-------------------------------------------------------------------------------
   863 #-------------------------------------------------------------------------------
   864 #                          Delete element functions
   864 #                          Delete element functions