# HG changeset patch
# User laurent
# Date 1318424927 -7200
# Node ID a7c706b9492e0f3f70890bea7e5fb625cd058852
# Parent 8c525217ef1fac0c18b1dca2ca6d15f4e8b25ccd
Adding hand tool icon in Toolbar for moving the view
diff -r 8c525217ef1f -r a7c706b9492e Images/icons.svg
--- a/Images/icons.svg Tue Oct 11 12:08:55 2011 +0200
+++ b/Images/icons.svg Wed Oct 12 15:08:47 2011 +0200
@@ -662,9 +662,9 @@
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
- inkscape:zoom="8"
- inkscape:cx="264.59165"
- inkscape:cy="46.838908"
+ inkscape:zoom="11.313708"
+ inkscape:cx="477.40877"
+ inkscape:cy="-82.224917"
inkscape:document-units="px"
inkscape:current-layer="layer1"
width="16px"
@@ -674,16 +674,18 @@
gridtolerance="10"
showguides="true"
inkscape:guide-bbox="true"
- inkscape:window-width="1623"
- inkscape:window-height="998"
- inkscape:window-x="52"
- inkscape:window-y="47"
- inkscape:window-maximized="0">
+ inkscape:window-width="1920"
+ inkscape:window-height="1056"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1">
+ enabled="true"
+ empspacing="5"
+ snapvisiblegridlinesonly="true" />
@@ -2867,5 +2869,29 @@
d="M 11,7 11,11 8,9 11.516466,17 15,9 12,11 12,7 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none" />
+
+ %%move%%
+
diff -r 8c525217ef1f -r a7c706b9492e Images/move.png
Binary file Images/move.png has changed
diff -r 8c525217ef1f -r a7c706b9492e PLCOpenEditor.py
--- a/PLCOpenEditor.py Tue Oct 11 12:08:55 2011 +0200
+++ b/PLCOpenEditor.py Wed Oct 12 15:08:47 2011 +0200
@@ -154,8 +154,8 @@
ID_PLCOPENEDITORTOOLBARBRANCH, ID_PLCOPENEDITORTOOLBARINITIALSTEP,
ID_PLCOPENEDITORTOOLBARSTEP, ID_PLCOPENEDITORTOOLBARTRANSITION,
ID_PLCOPENEDITORTOOLBARACTIONBLOCK, ID_PLCOPENEDITORTOOLBARDIVERGENCE,
- ID_PLCOPENEDITORTOOLBARJUMP,
-] = [wx.NewId() for _init_coll_DefaultToolBar_Items in range(17)]
+ ID_PLCOPENEDITORTOOLBARJUMP, ID_PLCOPENEDITORTOOLBARMOTION,
+] = [wx.NewId() for _init_coll_DefaultToolBar_Items in range(18)]
# Define behaviour of each Toolbar item according to current POU body type
# Informations meaning are in this order:
@@ -167,6 +167,9 @@
# - Item tooltip text
ToolBarItems = {
"FBD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITORTOOLBARMOTION, "OnMotionTool",
+ "move.png", _("Move the view")),
+ (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool",
"add_comment.png", _("Create a new comment")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
@@ -178,7 +181,10 @@
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool",
"add_connection.png", _("Create a new connection"))],
- "LD" : [(True, FREEDRAWING_MODE,
+ "LD" : [((True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITORTOOLBARMOTION, "OnMotionTool",
+ "move.png", _("Move the view")),
+ True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool",
"add_comment.png", _("Create a new comment")),
(True, FREEDRAWING_MODE,
@@ -205,7 +211,10 @@
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool",
"add_connection.png", _("Create a new connection"))],
- "SFC" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
+ "SFC" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
+ ID_PLCOPENEDITORTOOLBARMOTION, "OnMotionTool",
+ "move.png", _("Move the view")),
+ (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool",
"add_comment.png", _("Create a new comment")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
@@ -595,8 +604,8 @@
wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, _("Select an object"))
self.ToolBar.Realize()
- self.Bind(wx.EVT_TOOL, self.OnSelectionTool,
- id=ID_PLCOPENEDITORTOOLBARSELECTION)
+ self.Bind(wx.EVT_TOOL, self.OnSelectionTool,
+ id=ID_PLCOPENEDITORTOOLBARSELECTION)
self.VariablePanelIndexer = VariablePanelIndexer(self.BottomNoteBook, self)
self.BottomNoteBook.AddPage(self.VariablePanelIndexer, _("Variables"))
@@ -2083,43 +2092,42 @@
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_SELECTION)
- event.Skip()
+
+ def OnMotionTool(self, event):
+ selected = self.TabsOpened.GetSelection()
+ if selected != -1:
+ self.TabsOpened.GetPage(selected).SetMode(MODE_MOTION)
def OnCommentTool(self, event):
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCOMMENT)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_COMMENT)
- event.Skip()
def OnVariableTool(self, event):
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARVARIABLE)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_VARIABLE)
- event.Skip()
def OnBlockTool(self, event):
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARBLOCK)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_BLOCK)
- event.Skip()
def OnConnectionTool(self, event):
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCONNECTION)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_CONNECTION)
- event.Skip()
-
+
def OnPowerRailTool(self, event):
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARPOWERRAIL)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_POWERRAIL)
- event.Skip()
-
+
def OnRungTool(self, event):
selected = self.TabsOpened.GetSelection()
if selected != -1:
@@ -2142,20 +2150,17 @@
self.TabsOpened.GetPage(selected).SetMode(MODE_CONTACT)
else:
self.TabsOpened.GetPage(selected).AddLadderContact()
- event.Skip()
def OnBranchTool(self, event):
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).AddLadderBranch()
- event.Skip()
def OnInitialStepTool(self, event):
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARINITIALSTEP)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_INITIALSTEP)
- event.Skip()
def OnStepTool(self, event):
if self.GetDrawingMode() == FREEDRAWING_MODE:
@@ -2166,8 +2171,7 @@
self.TabsOpened.GetPage(selected).SetMode(MODE_STEP)
else:
self.TabsOpened.GetPage(selected).AddStep()
- event.Skip()
-
+
def OnActionBlockTool(self, event):
if self.GetDrawingMode() == FREEDRAWING_MODE:
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARACTIONBLOCK)
@@ -2177,15 +2181,13 @@
self.TabsOpened.GetPage(selected).SetMode(MODE_ACTION)
else:
self.TabsOpened.GetPage(selected).AddStepAction()
- event.Skip()
-
+
def OnTransitionTool(self, event):
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARTRANSITION)
selected = self.TabsOpened.GetSelection()
if selected != -1:
self.TabsOpened.GetPage(selected).SetMode(MODE_TRANSITION)
- event.Skip()
-
+
def OnDivergenceTool(self, event):
if self.GetDrawingMode() == FREEDRAWING_MODE:
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARDIVERGENCE)
@@ -2195,7 +2197,6 @@
self.TabsOpened.GetPage(selected).SetMode(MODE_DIVERGENCE)
else:
self.TabsOpened.GetPage(selected).AddDivergence()
- event.Skip()
def OnJumpTool(self, event):
if self.GetDrawingMode() == FREEDRAWING_MODE:
@@ -2206,8 +2207,7 @@
self.TabsOpened.GetPage(selected).SetMode(MODE_JUMP)
else:
self.TabsOpened.GetPage(selected).AddJump()
- event.Skip()
-
+
#-------------------------------------------------------------------------------
# Add Project Elements Functions
diff -r 8c525217ef1f -r a7c706b9492e Viewer.py
--- a/Viewer.py Tue Oct 11 12:08:55 2011 +0200
+++ b/Viewer.py Wed Oct 12 15:08:47 2011 +0200
@@ -533,10 +533,11 @@
self.RefreshHighlightsTimer.Stop()
def SetCurrentCursor(self, cursor):
- global CURSORS
- if self.CurrentCursor != cursor:
- self.CurrentCursor = cursor
- self.SetCursor(CURSORS[cursor])
+ if self.Mode != MODE_MOTION:
+ global CURSORS
+ if self.CurrentCursor != cursor:
+ self.CurrentCursor = cursor
+ self.SetCursor(CURSORS[cursor])
def GetScrolledRect(self, rect):
rect.x, rect.y = self.CalcScrolledPosition(int(rect.x * self.ViewScale[0]),
@@ -729,7 +730,9 @@
# Changes Viewer mode
def SetMode(self, mode):
- if self.Mode != mode or mode == MODE_SELECTION:
+ if self.Mode != mode or mode == MODE_SELECTION:
+ if self.Mode == MODE_MOTION:
+ wx.CallAfter(self.SetCursor, wx.NullCursor)
self.Mode = mode
self.SavedMode = False
else:
@@ -738,7 +741,10 @@
if self.Mode != MODE_SELECTION and self.SelectedElement:
self.SelectedElement.SetSelected(False)
self.SelectedElement = None
-
+ if self.Mode == MODE_MOTION:
+ wx.CallAfter(self.SetCursor, wx.StockCursor(wx.CURSOR_HAND))
+ self.SavedMode = True
+
# Return current drawing mode
def GetDrawingMode(self):
return self.ParentWindow.GetDrawingMode()
@@ -1393,6 +1399,9 @@
MODE_STEP, MODE_TRANSITION, MODE_DIVERGENCE, MODE_JUMP, MODE_ACTION]:
self.rubberBand.Reset()
self.rubberBand.OnLeftDown(event, self.GetLogicalDC(), self.Scaling)
+ elif self.Mode == MODE_MOTION:
+ self.StartMousePos = event.GetPosition()
+ self.StartScreenPos = self.GetScrollPos(wx.HORIZONTAL), self.GetScrollPos(wx.VERTICAL)
event.Skip()
def OnViewerLeftUp(self, event):
@@ -1469,6 +1478,9 @@
else:
self.SelectedElement.OnLeftUp(event, dc, self.Scaling)
wx.CallAfter(self.SetCurrentCursor, 0)
+ elif self.Mode == MODE_MOTION:
+ self.StartMousePos = None
+ self.StartScreenPos = None
if self.Mode != MODE_SELECTION and not self.SavedMode:
wx.CallAfter(self.ParentWindow.ResetCurrentMode)
event.Skip()
@@ -1541,7 +1553,7 @@
refresh = False
dc = self.GetLogicalDC()
pos = GetScaledEventPosition(event, dc, self.Scaling)
- if event.MiddleIsDown():
+ if event.MiddleIsDown() or self.Mode == MODE_MOTION:
if self.StartMousePos is not None and self.StartScreenPos is not None:
new_pos = event.GetPosition()
xmax = self.GetScrollRange(wx.HORIZONTAL) - self.GetScrollThumb(wx.HORIZONTAL)
@@ -1608,7 +1620,8 @@
event.Skip()
def OnLeaveViewer(self, event):
- self.StartMousePos = None
+ if self.StartScreenPos is None:
+ self.StartMousePos = None
if self.SelectedElement is not None and self.SelectedElement.GetDragging():
event.Skip()
elif self.HighlightedElement is not None:
diff -r 8c525217ef1f -r a7c706b9492e graphics/GraphicCommons.py
--- a/graphics/GraphicCommons.py Tue Oct 11 12:08:55 2011 +0200
+++ b/graphics/GraphicCommons.py Wed Oct 12 15:08:47 2011 +0200
@@ -83,7 +83,7 @@
# Contants for defining which mode is selected for each view
[MODE_SELECTION, MODE_BLOCK, MODE_VARIABLE, MODE_CONNECTION, MODE_COMMENT,
MODE_COIL, MODE_CONTACT, MODE_POWERRAIL, MODE_INITIALSTEP, MODE_STEP,
- MODE_TRANSITION, MODE_DIVERGENCE, MODE_JUMP, MODE_ACTION] = range(14)
+ MODE_TRANSITION, MODE_DIVERGENCE, MODE_JUMP, MODE_ACTION, MODE_MOTION] = range(15)
# Contants for defining alignment types for graphic group
[ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_TOP, ALIGN_MIDDLE, ALIGN_BOTTOM] = range(6)