72 wxID_PLCOPENEDITORTABSOPENED, wxID_PLCOPENEDITORTOOLBAR, |
73 wxID_PLCOPENEDITORTABSOPENED, wxID_PLCOPENEDITORTOOLBAR, |
73 wxID_PLCOPENEDITORDEFAULTTOOLBAR, wxID_PLCOPENEDITORSFCTOOLBAR, |
74 wxID_PLCOPENEDITORDEFAULTTOOLBAR, wxID_PLCOPENEDITORSFCTOOLBAR, |
74 wxID_PLCOPENEDITORFBDTOOLBAR, wxID_PLCOPENEDITORLDTOOLBAR, |
75 wxID_PLCOPENEDITORFBDTOOLBAR, wxID_PLCOPENEDITORLDTOOLBAR, |
75 ] = [wx.NewId() for _init_ctrls in range(10)] |
76 ] = [wx.NewId() for _init_ctrls in range(10)] |
76 |
77 |
77 [wxID_PLCOPENEDITORTOOLBARITEMS0, |
|
78 ] = [wx.NewId() for _init_coll_DefaultToolBar_Items in range(1)] |
|
79 |
|
80 SFC_ITEMS = [wxID_PLCOPENEDITORSFCTOOLBARITEMS1, |
|
81 wxID_PLCOPENEDITORSFCTOOLBARITEMS2, wxID_PLCOPENEDITORSFCTOOLBARITEMS3, |
|
82 wxID_PLCOPENEDITORSFCTOOLBARITEMS4, wxID_PLCOPENEDITORSFCTOOLBARITEMS5, |
|
83 wxID_PLCOPENEDITORSFCTOOLBARITEMS6, |
|
84 ] = [wx.NewId() for _init_coll_SFCToolBar_Items in range(6)] |
|
85 |
|
86 FBD_ITEMS = [wxID_PLCOPENEDITORFBDTOOLBARITEMS1, |
|
87 wxID_PLCOPENEDITORFBDTOOLBARITEMS2, wxID_PLCOPENEDITORFBDTOOLBARITEMS3, |
|
88 wxID_PLCOPENEDITORFBDTOOLBARITEMS4, wxID_PLCOPENEDITORFBDTOOLBARITEMS5, |
|
89 ] = [wx.NewId() for _init_coll_FBDToolBar_Items in range(5)] |
|
90 |
|
91 LD_ITEMS = [wxID_PLCOPENEDITORLDTOOLBARITEMS1, |
|
92 wxID_PLCOPENEDITORLDTOOLBARITEMS2, wxID_PLCOPENEDITORLDTOOLBARITEMS3, |
|
93 wxID_PLCOPENEDITORLDTOOLBARITEMS4, |
|
94 ] = [wx.NewId() for _init_coll_LDToolBar_Items in range(4)] |
|
95 |
|
96 [wxID_PLCOPENEDITORFILEMENUITEMS0, wxID_PLCOPENEDITORFILEMENUITEMS1, |
78 [wxID_PLCOPENEDITORFILEMENUITEMS0, wxID_PLCOPENEDITORFILEMENUITEMS1, |
97 wxID_PLCOPENEDITORFILEMENUITEMS2, wxID_PLCOPENEDITORFILEMENUITEMS3, |
79 wxID_PLCOPENEDITORFILEMENUITEMS2, wxID_PLCOPENEDITORFILEMENUITEMS3, |
98 wxID_PLCOPENEDITORFILEMENUITEMS5, wxID_PLCOPENEDITORFILEMENUITEMS6, |
80 wxID_PLCOPENEDITORFILEMENUITEMS5, wxID_PLCOPENEDITORFILEMENUITEMS6, |
99 wxID_PLCOPENEDITORFILEMENUITEMS7, wxID_PLCOPENEDITORFILEMENUITEMS9, |
81 wxID_PLCOPENEDITORFILEMENUITEMS7, wxID_PLCOPENEDITORFILEMENUITEMS9, |
100 wxID_PLCOPENEDITORFILEMENUITEMS11, |
82 wxID_PLCOPENEDITORFILEMENUITEMS11, |
122 wxID_PLCOPENEDITORSFCMENUITEMS2, wxID_PLCOPENEDITORSFCMENUITEMS3, |
104 wxID_PLCOPENEDITORSFCMENUITEMS2, wxID_PLCOPENEDITORSFCMENUITEMS3, |
123 ] = [wx.NewId() for _init_coll_SFCMenu_Items in range(4)] |
105 ] = [wx.NewId() for _init_coll_SFCMenu_Items in range(4)] |
124 |
106 |
125 [wxID_PLCOPENEDITORCONFIGMENUITEMS0, wxID_PLCOPENEDITORCONFIGMENUITEMS1, |
107 [wxID_PLCOPENEDITORCONFIGMENUITEMS0, wxID_PLCOPENEDITORCONFIGMENUITEMS1, |
126 ] = [wx.NewId() for _init_coll_ConfigMenu_Items in range(2)] |
108 ] = [wx.NewId() for _init_coll_ConfigMenu_Items in range(2)] |
|
109 |
|
110 |
|
111 #------------------------------------------------------------------------------- |
|
112 # ToolBars definitions |
|
113 #------------------------------------------------------------------------------- |
|
114 |
|
115 |
|
116 [wxID_PLCOPENEDITORTOOLBARSELECTION, wxID_PLCOPENEDITORTOOLBARCOMMENT, |
|
117 wxID_PLCOPENEDITORTOOLBARVARIABLE, wxID_PLCOPENEDITORTOOLBARBLOCK, |
|
118 wxID_PLCOPENEDITORTOOLBARCONNECTION, wxID_PLCOPENEDITORTOOLBARWIRE, |
|
119 wxID_PLCOPENEDITORTOOLBARPOWERRAIL, wxID_PLCOPENEDITORTOOLBARRUNG, |
|
120 wxID_PLCOPENEDITORTOOLBARCOIL, wxID_PLCOPENEDITORTOOLBARCONTACT, |
|
121 wxID_PLCOPENEDITORTOOLBARBRANCH, wxID_PLCOPENEDITORTOOLBARINITIALSTEP, |
|
122 wxID_PLCOPENEDITORTOOLBARSTEP, wxID_PLCOPENEDITORTOOLBARTRANSITION, |
|
123 wxID_PLCOPENEDITORTOOLBARACTIONBLOCK, wxID_PLCOPENEDITORTOOLBARDIVERGENCE, |
|
124 wxID_PLCOPENEDITORTOOLBARJUMP, |
|
125 ] = [wx.NewId() for _init_coll_DefaultToolBar_Items in range(17)] |
|
126 |
|
127 ToolBarItems = { |
|
128 "FBD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", "Images/comment.png", "Create a new comment"), |
|
129 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", "Images/variable.png", "Create a new variable"), |
|
130 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", "Images/block.png", "Create a new block"), |
|
131 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", "Images/connection.png", "Create a new connection"), |
|
132 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARWIRE, "OnWireTool", "Images/wire.png", "Create a new wire")], |
|
133 "LD" : [(True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", "Images/comment.png", "Create a new comment"), |
|
134 (True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool", "Images/powerrail.png", "Create a new power rail"), |
|
135 (False, DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARRUNG, "OnRungTool", "Images/rung.png", "Create a new rung"), |
|
136 (True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCOIL, "OnCoilTool", "Images/coil.png", "Create a new coil"), |
|
137 (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool", "Images/contact.png", "Create a new contact"), |
|
138 (False, DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARBRANCH, "OnBranchTool", "Images/branch.png", "Create a new branch"), |
|
139 (True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", "Images/variable.png", "Create a new variable"), |
|
140 (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", "Images/block.png", "Create a new block"), |
|
141 (True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", "Images/connection.png", "Create a new connection"), |
|
142 (True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARWIRE, "OnWireTool", "Images/wire.png", "Create a new wire")], |
|
143 "SFC" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", "Images/comment.png", "Create a new comment"), |
|
144 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARINITIALSTEP, "OnInitialStepTool", "Images/initial_step.png", "Create a new initial step"), |
|
145 (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARSTEP, "OnStepTool", "Images/step.png", "Create a new step"), |
|
146 (True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARTRANSITION, "OnTransitionTool", "Images/transition.png", "Create a new transition"), |
|
147 (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARACTIONBLOCK, "OnActionBlockTool", "Images/action.png", "Create a new action block"), |
|
148 (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARDIVERGENCE, "OnDivergenceTool", "Images/divergence.png", "Create a new divergence"), |
|
149 (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARJUMP, "OnJumpTool", "Images/jump.png", "Create a new jump"), |
|
150 (True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", "Images/variable.png", "Create a new variable"), |
|
151 (True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", "Images/block.png", "Create a new block"), |
|
152 (True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", "Images/connection.png", "Create a new connection"), |
|
153 (True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool", "Images/powerrail.png", "Create a new power rail"), |
|
154 (True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool", "Images/contact.png", "Create a new contact"), |
|
155 (True, FREEDRAWING_MODE, wxID_PLCOPENEDITORTOOLBARWIRE, "OnWireTool", "Images/wire.png", "Create a new wire")], |
|
156 "ST" : [], |
|
157 "IL" : [] |
|
158 } |
127 |
159 |
128 class PLCOpenEditor(wx.Frame): |
160 class PLCOpenEditor(wx.Frame): |
129 _custom_classes = {'wx.SashWindow' : ['Viewer']} |
161 _custom_classes = {'wx.SashWindow' : ['Viewer']} |
130 |
162 |
131 def _init_coll_EditMenu_Items(self, parent): |
163 def _init_coll_EditMenu_Items(self, parent): |
349 self.OnPouSelectedChanged, id=wxID_PLCOPENEDITORTABSOPENED) |
383 self.OnPouSelectedChanged, id=wxID_PLCOPENEDITORTABSOPENED) |
350 |
384 |
351 self.ToolBar = wxToolBar(id=wxID_PLCOPENEDITORTOOLBAR, name='ToolBar', |
385 self.ToolBar = wxToolBar(id=wxID_PLCOPENEDITORTOOLBAR, name='ToolBar', |
352 parent=self.EditorPanel, pos=wx.Point(0, 0), size=wx.Size(0, 40), |
386 parent=self.EditorPanel, pos=wx.Point(0, 0), size=wx.Size(0, 40), |
353 style=wxTB_HORIZONTAL | wxNO_BORDER) |
387 style=wxTB_HORIZONTAL | wxNO_BORDER) |
354 self.ToolBar.AddRadioTool(wxID_PLCOPENEDITORTOOLBARITEMS0, |
388 self.ToolBar.AddRadioTool(wxID_PLCOPENEDITORTOOLBARSELECTION, |
355 wxBitmap(os.path.join(CWD, 'Images/select.png')), wxNullBitmap, "Select an object") |
389 wxBitmap(os.path.join(CWD, 'Images/select.png')), wxNullBitmap, "Select an object") |
356 self.Bind(wx.EVT_TOOL, self.OnSelectionTool, |
390 self.Bind(wx.EVT_TOOL, self.OnSelectionTool, |
357 id=wxID_PLCOPENEDITORTOOLBARITEMS0) |
391 id=wxID_PLCOPENEDITORTOOLBARSELECTION) |
358 |
392 |
359 self.ProjectTree = wx.TreeCtrl(id=wxID_PLCOPENEDITORPROJECTTREE, |
393 self.ProjectTree = wx.TreeCtrl(id=wxID_PLCOPENEDITORPROJECTTREE, |
360 name='treeCtrl1', parent=self.splitterWindow1, pos=wx.Point(0, 0), |
394 name='treeCtrl1', parent=self.splitterWindow1, pos=wx.Point(0, 0), |
361 size=wx.Size(-1, -1), |
395 size=wx.Size(-1, -1), |
362 style=wx.TR_HAS_BUTTONS|wx.TR_EDIT_LABELS|wx.TR_SINGLE|wx.SUNKEN_BORDER) |
396 style=wx.TR_HAS_BUTTONS|wx.TR_EDIT_LABELS|wx.TR_SINGLE|wx.SUNKEN_BORDER) |
363 self.Bind(wx.EVT_RIGHT_UP, self.OnProjectTreeRightUp) |
397 self.ProjectTree.Bind(wx.EVT_RIGHT_UP, self.OnProjectTreeRightUp) |
364 self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnProjectTreeBeginDrag, |
398 self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnProjectTreeBeginDrag, |
365 id=wxID_PLCOPENEDITORPROJECTTREE) |
399 id=wxID_PLCOPENEDITORPROJECTTREE) |
366 self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnProjectTreeItemBeginEdit, |
400 self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnProjectTreeItemBeginEdit, |
367 id=wxID_PLCOPENEDITORPROJECTTREE) |
401 id=wxID_PLCOPENEDITORPROJECTTREE) |
368 self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnProjectTreeItemEndEdit, |
402 self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnProjectTreeItemEndEdit, |
567 selected = self.TabsOpened.GetSelection() |
624 selected = self.TabsOpened.GetSelection() |
568 if selected != -1: |
625 if selected != -1: |
569 self.TabsOpened.GetPage(selected).SetMode(MODE_SELECTION) |
626 self.TabsOpened.GetPage(selected).SetMode(MODE_SELECTION) |
570 event.Skip() |
627 event.Skip() |
571 |
628 |
572 def OnSFCCommentTool(self, event): |
629 def OnCommentTool(self, event): |
573 self.ResetToolToggle(wxID_PLCOPENEDITORSFCTOOLBARITEMS1) |
630 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARCOMMENT) |
574 selected = self.TabsOpened.GetSelection() |
631 selected = self.TabsOpened.GetSelection() |
575 if selected != -1: |
632 if selected != -1: |
576 self.TabsOpened.GetPage(selected).SetMode(MODE_COMMENT) |
633 self.TabsOpened.GetPage(selected).SetMode(MODE_COMMENT) |
577 event.Skip() |
634 event.Skip() |
578 |
635 |
579 def OnSFCInitialStepTool(self, event): |
636 def OnVariableTool(self, event): |
580 self.ResetToolToggle(wxID_PLCOPENEDITORSFCTOOLBARITEMS2) |
637 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARVARIABLE) |
581 selected = self.TabsOpened.GetSelection() |
|
582 if selected != -1: |
|
583 self.TabsOpened.GetPage(selected).SetMode(MODE_INITIAL_STEP) |
|
584 event.Skip() |
|
585 |
|
586 def OnSFCStepTool(self, event): |
|
587 selected = self.TabsOpened.GetSelection() |
|
588 if selected != -1: |
|
589 self.TabsOpened.GetPage(selected).AddStep() |
|
590 event.Skip() |
|
591 |
|
592 def OnSFCActionBlockTool(self, event): |
|
593 selected = self.TabsOpened.GetSelection() |
|
594 if selected != -1: |
|
595 self.TabsOpened.GetPage(selected).AddStepAction() |
|
596 event.Skip() |
|
597 |
|
598 def OnSFCDivergenceTool(self, event): |
|
599 selected = self.TabsOpened.GetSelection() |
|
600 if selected != -1: |
|
601 self.TabsOpened.GetPage(selected).AddDivergence() |
|
602 event.Skip() |
|
603 |
|
604 def OnSFCJumpTool(self, event): |
|
605 selected = self.TabsOpened.GetSelection() |
|
606 if selected != -1: |
|
607 self.TabsOpened.GetPage(selected).AddJump() |
|
608 event.Skip() |
|
609 |
|
610 def OnFBDCommentTool(self, event): |
|
611 self.ResetToolToggle(wxID_PLCOPENEDITORFBDTOOLBARITEMS1) |
|
612 selected = self.TabsOpened.GetSelection() |
|
613 if selected != -1: |
|
614 self.TabsOpened.GetPage(selected).SetMode(MODE_COMMENT) |
|
615 event.Skip() |
|
616 |
|
617 def OnFBDVariableTool(self, event): |
|
618 self.ResetToolToggle(wxID_PLCOPENEDITORFBDTOOLBARITEMS2) |
|
619 selected = self.TabsOpened.GetSelection() |
638 selected = self.TabsOpened.GetSelection() |
620 if selected != -1: |
639 if selected != -1: |
621 self.TabsOpened.GetPage(selected).SetMode(MODE_VARIABLE) |
640 self.TabsOpened.GetPage(selected).SetMode(MODE_VARIABLE) |
622 event.Skip() |
641 event.Skip() |
623 |
642 |
624 def OnFBDBlockTool(self, event): |
643 def OnBlockTool(self, event): |
625 self.ResetToolToggle(wxID_PLCOPENEDITORFBDTOOLBARITEMS3) |
644 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARBLOCK) |
626 selected = self.TabsOpened.GetSelection() |
645 selected = self.TabsOpened.GetSelection() |
627 if selected != -1: |
646 if selected != -1: |
628 self.TabsOpened.GetPage(selected).SetMode(MODE_BLOCK) |
647 self.TabsOpened.GetPage(selected).SetMode(MODE_BLOCK) |
629 event.Skip() |
648 event.Skip() |
630 |
649 |
631 def OnFBDConnectionTool(self, event): |
650 def OnConnectionTool(self, event): |
632 self.ResetToolToggle(wxID_PLCOPENEDITORFBDTOOLBARITEMS4) |
651 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARCONNECTION) |
633 selected = self.TabsOpened.GetSelection() |
652 selected = self.TabsOpened.GetSelection() |
634 if selected != -1: |
653 if selected != -1: |
635 self.TabsOpened.GetPage(selected).SetMode(MODE_CONNECTION) |
654 self.TabsOpened.GetPage(selected).SetMode(MODE_CONNECTION) |
636 event.Skip() |
655 event.Skip() |
637 |
656 |
638 def OnFBDWireTool(self, event): |
657 def OnWireTool(self, event): |
639 self.ResetToolToggle(wxID_PLCOPENEDITORFBDTOOLBARITEMS5) |
658 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARWIRE) |
640 selected = self.TabsOpened.GetSelection() |
659 selected = self.TabsOpened.GetSelection() |
641 if selected != -1: |
660 if selected != -1: |
642 self.TabsOpened.GetPage(selected).SetMode(MODE_WIRE) |
661 self.TabsOpened.GetPage(selected).SetMode(MODE_WIRE) |
643 event.Skip() |
662 event.Skip() |
644 |
663 |
645 def OnLDCoilTool(self, event): |
664 def OnPowerRailTool(self, event): |
|
665 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARPOWERRAIL) |
|
666 selected = self.TabsOpened.GetSelection() |
|
667 if selected != -1: |
|
668 self.TabsOpened.GetPage(selected).SetMode(MODE_POWERRAIL) |
|
669 event.Skip() |
|
670 |
|
671 def OnRungTool(self, event): |
646 selected = self.TabsOpened.GetSelection() |
672 selected = self.TabsOpened.GetSelection() |
647 if selected != -1: |
673 if selected != -1: |
648 self.TabsOpened.GetPage(selected).AddRung() |
674 self.TabsOpened.GetPage(selected).AddRung() |
649 event.Skip() |
675 event.Skip() |
650 |
676 |
651 def OnLDContactTool(self, event): |
677 def OnCoilTool(self, event): |
|
678 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARCOIL) |
652 selected = self.TabsOpened.GetSelection() |
679 selected = self.TabsOpened.GetSelection() |
653 if selected != -1: |
680 if selected != -1: |
654 self.TabsOpened.GetPage(selected).AddContact() |
681 self.TabsOpened.GetPage(selected).SetMode(MODE_COIL) |
655 event.Skip() |
682 event.Skip() |
656 |
683 |
657 def OnLDBlockTool(self, event): |
684 def OnContactTool(self, event): |
|
685 if self.DrawingMode == FREEDRAWING_MODE: |
|
686 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARCONTACT) |
658 selected = self.TabsOpened.GetSelection() |
687 selected = self.TabsOpened.GetSelection() |
659 if selected != -1: |
688 if selected != -1: |
660 self.TabsOpened.GetPage(selected).AddBlock() |
689 if self.DrawingMode == FREEDRAWING_MODE: |
661 event.Skip() |
690 self.TabsOpened.GetPage(selected).SetMode(MODE_CONTACT) |
662 |
691 else: |
663 def OnLDBranchTool(self, event): |
692 self.TabsOpened.GetPage(selected).AddContact() |
|
693 event.Skip() |
|
694 |
|
695 def OnBranchTool(self, event): |
664 selected = self.TabsOpened.GetSelection() |
696 selected = self.TabsOpened.GetSelection() |
665 if selected != -1: |
697 if selected != -1: |
666 self.TabsOpened.GetPage(selected).AddBranch() |
698 self.TabsOpened.GetPage(selected).AddBranch() |
|
699 event.Skip() |
|
700 |
|
701 def OnInitialStepTool(self, event): |
|
702 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARINITIALSTEP) |
|
703 selected = self.TabsOpened.GetSelection() |
|
704 if selected != -1: |
|
705 self.TabsOpened.GetPage(selected).SetMode(MODE_INITIALSTEP) |
|
706 event.Skip() |
|
707 |
|
708 def OnStepTool(self, event): |
|
709 if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
710 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARSTEP) |
|
711 selected = self.TabsOpened.GetSelection() |
|
712 if selected != -1: |
|
713 if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
714 self.TabsOpened.GetPage(selected).SetMode(MODE_STEP) |
|
715 else: |
|
716 self.TabsOpened.GetPage(selected).AddStep() |
|
717 event.Skip() |
|
718 |
|
719 def OnActionBlockTool(self, event): |
|
720 if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
721 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARACTIONBLOCK) |
|
722 selected = self.TabsOpened.GetSelection() |
|
723 if selected != -1: |
|
724 if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
725 self.TabsOpened.GetPage(selected).SetMode(MODE_ACTION) |
|
726 else: |
|
727 self.TabsOpened.GetPage(selected).AddStepAction() |
|
728 event.Skip() |
|
729 |
|
730 def OnTransitionTool(self, event): |
|
731 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARTRANSITION) |
|
732 selected = self.TabsOpened.GetSelection() |
|
733 if selected != -1: |
|
734 self.TabsOpened.GetPage(selected).SetMode(MODE_TRANSITION) |
|
735 event.Skip() |
|
736 |
|
737 def OnDivergenceTool(self, event): |
|
738 if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
739 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARDIVERGENCE) |
|
740 selected = self.TabsOpened.GetSelection() |
|
741 if selected != -1: |
|
742 if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
743 self.TabsOpened.GetPage(selected).SetMode(MODE_DIVERGENCE) |
|
744 else: |
|
745 self.TabsOpened.GetPage(selected).AddDivergence() |
|
746 event.Skip() |
|
747 |
|
748 def OnJumpTool(self, event): |
|
749 if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
750 self.ResetToolToggle(wxID_PLCOPENEDITORTOOLBARJUMP) |
|
751 selected = self.TabsOpened.GetSelection() |
|
752 if selected != -1: |
|
753 if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
754 self.TabsOpened.GetPage(selected).SetMode(MODE_JUMP) |
|
755 else: |
|
756 self.TabsOpened.GetPage(selected).AddJump() |
667 event.Skip() |
757 event.Skip() |
668 |
758 |
669 def OnPouSelectedChanged(self, event): |
759 def OnPouSelectedChanged(self, event): |
670 selected = event.GetSelection() |
760 selected = event.GetSelection() |
671 if selected >= 0: |
761 if selected >= 0: |
1015 item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
1094 item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
1016 self.GenerateTreeBranch(item, values) |
1095 self.GenerateTreeBranch(item, values) |
1017 item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
1096 item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
1018 while item.IsOk(): |
1097 while item.IsOk(): |
1019 to_delete.append(item) |
1098 to_delete.append(item) |
1020 item, root_cookie = self.ProjectTree.GetNextChild(item, root_cookie) |
1099 item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
1021 for item in to_delete: |
1100 for item in to_delete: |
1022 self.ProjectTree.Delete(item) |
1101 self.ProjectTree.Delete(item) |
1023 |
1102 |
1024 def ResetToolBar(self): |
1103 def ResetToolBar(self): |
1025 for item in self.CurrentToolBar: |
1104 for item in self.CurrentToolBar: |
|
1105 self.Unbind(wx.EVT_MENU, id=item) |
1026 self.ToolBar.DeleteTool(item) |
1106 self.ToolBar.DeleteTool(item) |
1027 |
1107 |
1028 def RefreshToolBar(self): |
1108 def RefreshToolBar(self): |
1029 language = self.Controler.GetCurrentElementEditingBodyType() |
1109 language = self.Controler.GetCurrentElementEditingBodyType() |
1030 if language == "SFC": |
1110 if language and language != self.CurrentLanguage: |
1031 if self.CurrentToolBar != SFC_ITEMS: |
1111 self.ResetToolBar() |
1032 self.ResetToolBar() |
1112 self.CurrentLanguage = language |
1033 self.CurrentToolBar = SFC_ITEMS |
1113 self.CurrentToolBar = [] |
1034 self.ToolBar.AddRadioTool(wxID_PLCOPENEDITORSFCTOOLBARITEMS1, |
1114 for radio, modes, id, method, picture, help in ToolBarItems[language]: |
1035 wxBitmap(os.path.join(CWD, 'Images/comment.png')), wxNullBitmap, "Create a new comment") |
1115 if modes & self.DrawingMode: |
1036 self.ToolBar.AddRadioTool(wxID_PLCOPENEDITORSFCTOOLBARITEMS2, |
1116 if radio or self.DrawingMode == FREEDRAWING_MODE: |
1037 wxBitmap(os.path.join(CWD, 'Images/initial_step.png')), wxNullBitmap, "Create a new initial step") |
1117 self.ToolBar.AddRadioTool(id, wxBitmap(os.path.join(CWD, picture)), wxNullBitmap, help) |
1038 self.ToolBar.AddSimpleTool(wxID_PLCOPENEDITORSFCTOOLBARITEMS3, |
1118 else: |
1039 wxBitmap(os.path.join(CWD, 'Images/step.png')), "Create a new step") |
1119 self.ToolBar.AddSimpleTool(id, wxBitmap(os.path.join(CWD, picture)), help) |
1040 self.ToolBar.AddSimpleTool(wxID_PLCOPENEDITORSFCTOOLBARITEMS4, |
1120 self.Bind(wx.EVT_TOOL, getattr(self, method), id=id) |
1041 wxBitmap(os.path.join(CWD, 'Images/action.png')), "Add action block to step") |
1121 self.CurrentToolBar.append(id) |
1042 self.ToolBar.AddSimpleTool(wxID_PLCOPENEDITORSFCTOOLBARITEMS5, |
|
1043 wxBitmap(os.path.join(CWD, 'Images/divergence.png')), "Create a new divergence") |
|
1044 self.ToolBar.AddSimpleTool(wxID_PLCOPENEDITORSFCTOOLBARITEMS6, |
|
1045 wxBitmap(os.path.join(CWD, 'Images/jump.png')), "Create a new jump") |
|
1046 self.Bind(wx.EVT_TOOL, self.OnSFCCommentTool, |
|
1047 id=wxID_PLCOPENEDITORSFCTOOLBARITEMS1) |
|
1048 self.Bind(wx.EVT_TOOL, self.OnSFCInitialStepTool, |
|
1049 id=wxID_PLCOPENEDITORSFCTOOLBARITEMS2) |
|
1050 self.Bind(wx.EVT_TOOL, self.OnSFCStepTool, |
|
1051 id=wxID_PLCOPENEDITORSFCTOOLBARITEMS3) |
|
1052 self.Bind(wx.EVT_TOOL, self.OnSFCActionBlockTool, |
|
1053 id=wxID_PLCOPENEDITORSFCTOOLBARITEMS4) |
|
1054 self.Bind(wx.EVT_TOOL, self.OnSFCDivergenceTool, |
|
1055 id=wxID_PLCOPENEDITORSFCTOOLBARITEMS5) |
|
1056 self.Bind(wx.EVT_TOOL, self.OnSFCJumpTool, |
|
1057 id=wxID_PLCOPENEDITORSFCTOOLBARITEMS6) |
|
1058 elif language == "FBD": |
|
1059 if self.CurrentToolBar != FBD_ITEMS: |
|
1060 self.ResetToolBar() |
|
1061 self.CurrentToolBar = FBD_ITEMS |
|
1062 self.ToolBar.AddRadioTool(wxID_PLCOPENEDITORFBDTOOLBARITEMS1, |
|
1063 wxBitmap(os.path.join(CWD, 'Images/comment.png')), wxNullBitmap, "Create a new comment") |
|
1064 self.ToolBar.AddRadioTool(wxID_PLCOPENEDITORFBDTOOLBARITEMS2, |
|
1065 wxBitmap(os.path.join(CWD, 'Images/variable.png')), wxNullBitmap, "Create a new variable") |
|
1066 self.ToolBar.AddRadioTool(wxID_PLCOPENEDITORFBDTOOLBARITEMS3, |
|
1067 wxBitmap(os.path.join(CWD, 'Images/block.png')), wxNullBitmap, "Create a new block") |
|
1068 self.ToolBar.AddRadioTool(wxID_PLCOPENEDITORFBDTOOLBARITEMS4, |
|
1069 wxBitmap(os.path.join(CWD, 'Images/connection.png')), wxNullBitmap, "Create a new connection") |
|
1070 self.ToolBar.AddRadioTool(wxID_PLCOPENEDITORFBDTOOLBARITEMS5, |
|
1071 wxBitmap(os.path.join(CWD, 'Images/wire.png')), wxNullBitmap, "Create a new wire") |
|
1072 self.Bind(wx.EVT_TOOL, self.OnFBDCommentTool, |
|
1073 id=wxID_PLCOPENEDITORFBDTOOLBARITEMS1) |
|
1074 self.Bind(wx.EVT_TOOL, self.OnFBDVariableTool, |
|
1075 id=wxID_PLCOPENEDITORFBDTOOLBARITEMS2) |
|
1076 self.Bind(wx.EVT_TOOL, self.OnFBDBlockTool, |
|
1077 id=wxID_PLCOPENEDITORFBDTOOLBARITEMS3) |
|
1078 self.Bind(wx.EVT_TOOL, self.OnFBDConnectionTool, |
|
1079 id=wxID_PLCOPENEDITORFBDTOOLBARITEMS4) |
|
1080 self.Bind(wx.EVT_TOOL, self.OnFBDWireTool, |
|
1081 id=wxID_PLCOPENEDITORFBDTOOLBARITEMS5) |
|
1082 elif language == "LD": |
|
1083 if self.CurrentToolBar != LD_ITEMS: |
|
1084 self.ResetToolBar() |
|
1085 self.CurrentToolBar = LD_ITEMS |
|
1086 self.ToolBar.AddSimpleTool(wxID_PLCOPENEDITORLDTOOLBARITEMS1, |
|
1087 wxBitmap(os.path.join(CWD, 'Images/coil.png')), "Create a new rung") |
|
1088 self.ToolBar.AddSimpleTool(wxID_PLCOPENEDITORLDTOOLBARITEMS2, |
|
1089 wxBitmap(os.path.join(CWD, 'Images/contact.png')), "Create a new contact") |
|
1090 self.ToolBar.AddSimpleTool(wxID_PLCOPENEDITORLDTOOLBARITEMS3, |
|
1091 wxBitmap(os.path.join(CWD, 'Images/block.png')), "Create a new block") |
|
1092 self.ToolBar.AddSimpleTool(wxID_PLCOPENEDITORLDTOOLBARITEMS4, |
|
1093 wxBitmap(os.path.join(CWD, 'Images/branch.png')), "Create a new branch") |
|
1094 self.Bind(wx.EVT_TOOL, self.OnLDCoilTool, |
|
1095 id=wxID_PLCOPENEDITORLDTOOLBARITEMS1) |
|
1096 self.Bind(wx.EVT_TOOL, self.OnLDContactTool, |
|
1097 id=wxID_PLCOPENEDITORLDTOOLBARITEMS2) |
|
1098 self.Bind(wx.EVT_TOOL, self.OnLDBlockTool, |
|
1099 id=wxID_PLCOPENEDITORLDTOOLBARITEMS3) |
|
1100 self.Bind(wx.EVT_TOOL, self.OnLDBranchTool, |
|
1101 id=wxID_PLCOPENEDITORLDTOOLBARITEMS4) |
|
1102 else: |
|
1103 if len(self.CurrentToolBar) > 0: |
|
1104 self.ResetToolBar() |
|
1105 self.CurrentToolBar = [] |
|
1106 self.ResetCurrentMode() |
1122 self.ResetCurrentMode() |
1107 |
1123 |
1108 def RefreshTabsOpenedTitles(self): |
1124 def RefreshTabsOpenedTitles(self): |
1109 pous = self.Controler.GetElementsOpenedNames() |
1125 pous = self.Controler.GetElementsOpenedNames() |
1110 for i, pou in enumerate(pous): |
1126 for i, pou in enumerate(pous): |