# HG changeset patch # User Laurent Bessard # Date 1371199928 -7200 # Node ID 441f31474b50e2959ce2cd11da476f2496fbb982 # Parent 4b7ef7ea318f6062a737df2783891c8058cefb62 Fixed move of LD_PowerRail and SFC_Divergence connectors using Right button diff -r 4b7ef7ea318f -r 441f31474b50 graphics/GraphicCommons.py --- a/graphics/GraphicCommons.py Fri Jun 14 10:49:14 2013 +0200 +++ b/graphics/GraphicCommons.py Fri Jun 14 10:52:08 2013 +0200 @@ -504,7 +504,7 @@ # If the cursor is dragging and the element have been clicked if event.Dragging() and self.oldPos: # Calculate the movement of cursor - pos = event.GetLogicalPosition(dc) + pos = GetScaledEventPosition(event, dc, scaling) movex = pos.x - self.oldPos.x movey = pos.y - self.oldPos.y # If movement is greater than MIN_MOVE then a dragging is initiated diff -r 4b7ef7ea318f -r 441f31474b50 graphics/LD_Objects.py --- a/graphics/LD_Objects.py Fri Jun 14 10:49:14 2013 +0200 +++ b/graphics/LD_Objects.py Fri Jun 14 10:52:08 2013 +0200 @@ -120,8 +120,10 @@ self.RefreshBoundingBox() # Returns the block minimum size - def GetMinSize(self): - return LD_POWERRAIL_WIDTH, self.Extensions[0] + self.Extensions[1] + def GetMinSize(self, default=False): + height = (LD_LINE_SIZE * (len(self.Connectors) - 1) + if default else 0) + return LD_POWERRAIL_WIDTH, height + self.Extensions[0] + self.Extensions[1] # Add a connector or a blank to this power rail at the last place def AddConnector(self): @@ -279,7 +281,7 @@ # Method called when a RightUp event have been generated def OnRightUp(self, event, dc, scaling): handle_type, handle = self.Handle - if handle_type == HANDLE_CONNECTOR: + if handle_type == HANDLE_CONNECTOR and self.Dragging and self.oldPos: wires = handle.GetWires() if len(wires) == 1: if handle == wires[0][0].StartConnected: diff -r 4b7ef7ea318f -r 441f31474b50 graphics/SFC_Objects.py --- a/graphics/SFC_Objects.py Fri Jun 14 10:49:14 2013 +0200 +++ b/graphics/SFC_Objects.py Fri Jun 14 10:52:08 2013 +0200 @@ -1360,11 +1360,25 @@ # Method called when a LeftDown event have been generated def OnLeftDown(self, event, dc, scaling): - connector = None - if event.ControlDown(): - pos = GetScaledEventPosition(event, dc, scaling) - # Test if a connector have been handled - connector = self.TestConnector(pos, exclude=False) + self.RealConnectors = {"Inputs":[],"Outputs":[]} + for input in self.Inputs: + position = input.GetRelPosition() + self.RealConnectors["Inputs"].append(float(position.x)/float(self.Size[0])) + for output in self.Outputs: + position = output.GetRelPosition() + self.RealConnectors["Outputs"].append(float(position.x)/float(self.Size[0])) + Graphic_Element.OnLeftDown(self, event, dc, scaling) + + # Method called when a LeftUp event have been generated + def OnLeftUp(self, event, dc, scaling): + Graphic_Element.OnLeftUp(self, event, dc, scaling) + self.RealConnectors = None + + # Method called when a RightDown event have been generated + def OnRightDown(self, event, dc, scaling): + pos = GetScaledEventPosition(event, dc, scaling) + # Test if a connector have been handled + connector = self.TestConnector(pos, exclude=False) if connector: self.Handle = (HANDLE_CONNECTOR, connector) wx.CallAfter(self.Parent.SetCurrentCursor, 1) @@ -1372,17 +1386,11 @@ # Initializes the last position self.oldPos = GetScaledEventPosition(event, dc, scaling) else: - self.RealConnectors = {"Inputs":[],"Outputs":[]} - for input in self.Inputs: - position = input.GetRelPosition() - self.RealConnectors["Inputs"].append(float(position.x)/float(self.Size[0])) - for output in self.Outputs: - position = output.GetRelPosition() - self.RealConnectors["Outputs"].append(float(position.x)/float(self.Size[0])) - Graphic_Element.OnLeftDown(self, event, dc, scaling) - - # Method called when a LeftUp event have been generated - def OnLeftUp(self, event, dc, scaling): + Graphic_Element.OnRightDown(self, event, dc, scaling) + + # Method called when a RightUp event have been generated + def OnRightUp(self, event, dc, scaling): + pos = GetScaledEventPosition(event, dc, scaling) handle_type, handle = self.Handle if handle_type == HANDLE_CONNECTOR and self.Dragging and self.oldPos: wires = handle.GetWires() @@ -1394,21 +1402,17 @@ block.RefreshInputModel() else: block.RefreshOutputModel() - Graphic_Element.OnLeftUp(self, event, dc, scaling) - self.RealConnectors = None - - # Method called when a RightUp event have been generated - def OnRightUp(self, event, dc, scaling): - pos = GetScaledEventPosition(event, dc, scaling) - # Popup the menu with special items for a block and a connector if one is handled - connector = self.TestConnector(pos, exclude=False) - if connector: - self.Handle = (HANDLE_CONNECTOR, connector) - self.Parent.PopupDivergenceMenu(True) - else: - # Popup the divergence menu without delete branch - self.Parent.PopupDivergenceMenu(False) - + Graphic_Element.OnRightUp(self, event, dc, scaling) + else: + # Popup the menu with special items for a block and a connector if one is handled + connector = self.TestConnector(pos, exclude=False) + if connector: + self.Handle = (HANDLE_CONNECTOR, connector) + self.Parent.PopupDivergenceMenu(True) + else: + # Popup the divergence menu without delete branch + self.Parent.PopupDivergenceMenu(False) + # Refreshes the divergence state according to move defined and handle selected def ProcessDragging(self, movex, movey, event, scaling): handle_type, handle = self.Handle