834 elif self.Mode == MODE_COIL: |
834 elif self.Mode == MODE_COIL: |
835 wx.CallAfter(self.AddNewCoil, bbox) |
835 wx.CallAfter(self.AddNewCoil, bbox) |
836 elif self.Mode == MODE_POWERRAIL: |
836 elif self.Mode == MODE_POWERRAIL: |
837 wx.CallAfter(self.AddNewPowerRail, bbox) |
837 wx.CallAfter(self.AddNewPowerRail, bbox) |
838 elif self.Mode == MODE_INITIALSTEP: |
838 elif self.Mode == MODE_INITIALSTEP: |
839 wx.CallAfter(self.AddNewInitialStep, bbox) |
839 wx.CallAfter(self.AddNewStep, bbox, True) |
840 elif self.Mode == MODE_STEP: |
840 elif self.Mode == MODE_STEP: |
841 wx.CallAfter(self.AddNewStep, bbox) |
841 wx.CallAfter(self.AddNewStep, bbox, False) |
842 elif self.Mode == MODE_TRANSITION: |
842 elif self.Mode == MODE_TRANSITION: |
843 wx.CallAfter(self.AddNewTransition, bbox) |
843 wx.CallAfter(self.AddNewTransition, bbox) |
844 elif self.Mode == MODE_DIVERGENCE: |
844 elif self.Mode == MODE_DIVERGENCE: |
845 wx.CallAfter(self.AddNewDivergence, bbox) |
845 wx.CallAfter(self.AddNewDivergence, bbox) |
846 elif self.Mode == MODE_JUMP: |
846 elif self.Mode == MODE_JUMP: |
901 if not connector or self.SelectedElement.EndConnected == None: |
901 if not connector or self.SelectedElement.EndConnected == None: |
902 self.SelectedElement.ResetPoints() |
902 self.SelectedElement.ResetPoints() |
903 self.SelectedElement.OnMotion(event, dc, self.Scaling) |
903 self.SelectedElement.OnMotion(event, dc, self.Scaling) |
904 self.SelectedElement.GeneratePoints() |
904 self.SelectedElement.GeneratePoints() |
905 self.Refresh() |
905 self.Refresh() |
|
906 event.Skip() |
|
907 |
|
908 def UpdateScrollPos(self, event): |
906 if (event.Dragging() and self.SelectedElement) or self.rubberBand.IsShown(): |
909 if (event.Dragging() and self.SelectedElement) or self.rubberBand.IsShown(): |
907 position = event.GetPosition() |
910 position = event.GetPosition() |
908 move_window = wx.Point() |
911 move_window = wx.Point() |
909 window_size = self.GetClientSize() |
912 window_size = self.GetClientSize() |
910 xstart, ystart = self.GetViewStart() |
913 xstart, ystart = self.GetViewStart() |
917 elif position.y > window_size[1] - SCROLL_ZONE: |
920 elif position.y > window_size[1] - SCROLL_ZONE: |
918 move_window.y = 1 |
921 move_window.y = 1 |
919 if move_window.x != 0 or move_window.y != 0: |
922 if move_window.x != 0 or move_window.y != 0: |
920 self.Scroll(xstart + move_window.x, ystart + move_window.y) |
923 self.Scroll(xstart + move_window.x, ystart + move_window.y) |
921 self.RefreshScrollBars() |
924 self.RefreshScrollBars() |
922 event.Skip() |
|
923 |
925 |
924 #------------------------------------------------------------------------------- |
926 #------------------------------------------------------------------------------- |
925 # Keyboard event functions |
927 # Keyboard event functions |
926 #------------------------------------------------------------------------------- |
928 #------------------------------------------------------------------------------- |
927 |
929 |
1143 self.RefreshBuffer() |
1145 self.RefreshBuffer() |
1144 self.RefreshScrollBars() |
1146 self.RefreshScrollBars() |
1145 self.Refresh() |
1147 self.Refresh() |
1146 dialog.Destroy() |
1148 dialog.Destroy() |
1147 |
1149 |
|
1150 def AddNewStep(self, bbox, initial = False): |
|
1151 dialog = StepContentDialog(self.Parent, initial) |
|
1152 dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
1153 dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars()) |
|
1154 dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)]) |
|
1155 dialog.SetMinStepSize((bbox.width, bbox.height)) |
|
1156 if dialog.ShowModal() == wx.ID_OK: |
|
1157 id = self.GetNewId() |
|
1158 values = dialog.GetValues() |
|
1159 step = SFC_Step(self, values["name"], initial, id) |
|
1160 if values["input"]: |
|
1161 step.AddInput() |
|
1162 else: |
|
1163 step.RemoveInput() |
|
1164 if values["output"]: |
|
1165 step.AddOutput() |
|
1166 else: |
|
1167 step.RemoveOutput() |
|
1168 if values["action"]: |
|
1169 step.AddAction() |
|
1170 else: |
|
1171 step.RemoveAction() |
|
1172 step.SetPosition(bbox.x, bbox.y) |
|
1173 min_width, min_height = step.GetMinSize() |
|
1174 step.SetSize(max(bbox.width, min_width), max(bbox.height, min_height)) |
|
1175 self.AddBlock(step) |
|
1176 self.Controler.AddCurrentElementEditingStep(id) |
|
1177 self.RefreshStepModel(step) |
|
1178 self.RefreshBuffer() |
|
1179 self.RefreshScrollBars() |
|
1180 self.Refresh() |
|
1181 dialog.Destroy() |
|
1182 |
1148 def AddNewTransition(self, bbox): |
1183 def AddNewTransition(self, bbox): |
1149 dialog = TransitionContentDialog(self.Parent, self.GetDrawingMode() == FREEDRAWING_MODE) |
1184 dialog = TransitionContentDialog(self.Parent, self.GetDrawingMode() == FREEDRAWING_MODE) |
1150 dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions()) |
1185 dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions()) |
1151 if dialog.ShowModal() == wx.ID_OK: |
1186 if dialog.ShowModal() == wx.ID_OK: |
1152 id = self.GetNewId() |
1187 id = self.GetNewId() |
1324 self.RefreshBuffer() |
1359 self.RefreshBuffer() |
1325 self.RefreshScrollBars() |
1360 self.RefreshScrollBars() |
1326 self.Refresh() |
1361 self.Refresh() |
1327 dialog.Destroy() |
1362 dialog.Destroy() |
1328 |
1363 |
1329 |
1364 def EditStepContent(self, step): |
|
1365 dialog = StepContentDialog(self.Parent, step.GetInitial()) |
|
1366 dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
1367 dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars()) |
|
1368 dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()]) |
|
1369 dialog.SetMinStepSize(step.GetSize()) |
|
1370 values = {"name" : step.GetName()} |
|
1371 connectors = step.GetConnectors() |
|
1372 values["input"] = connectors["input"] != None |
|
1373 values["output"] = connectors["output"] != None |
|
1374 values["action"] = connectors["action"] != None |
|
1375 dialog.SetValues(values) |
|
1376 if dialog.ShowModal() == wx.ID_OK: |
|
1377 values = dialog.GetValues() |
|
1378 step.SetName(values["name"]) |
|
1379 if values["input"]: |
|
1380 step.AddInput() |
|
1381 else: |
|
1382 step.RemoveInput() |
|
1383 if values["output"]: |
|
1384 step.AddOutput() |
|
1385 else: |
|
1386 step.RemoveOutput() |
|
1387 if values["action"]: |
|
1388 step.AddAction() |
|
1389 else: |
|
1390 step.RemoveAction() |
|
1391 step.UpdateSize(values["width"], values["height"]) |
|
1392 step.RefreshModel() |
|
1393 self.RefreshBuffer() |
|
1394 self.RefreshScrollBars() |
|
1395 self.Refresh() |
|
1396 |
1330 def EditTransitionContent(self, transition): |
1397 def EditTransitionContent(self, transition): |
1331 dialog = TransitionContentDialog(self.Parent, self.GetDrawingMode() == FREEDRAWING_MODE) |
1398 dialog = TransitionContentDialog(self.Parent, self.GetDrawingMode() == FREEDRAWING_MODE) |
1332 dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions()) |
1399 dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions()) |
1333 dialog.SetValues({"type":transition.GetType(),"value":transition.GetCondition()}) |
1400 dialog.SetValues({"type":transition.GetType(),"value":transition.GetCondition()}) |
1334 dialog.SetElementSize(transition.GetSize()) |
1401 dialog.SetElementSize(transition.GetSize()) |