changeset 56 | 7187e1c00975 |
parent 45 | 42637f721b5b |
child 58 | 39cd981ff242 |
55:e24d2f917c7e | 56:7187e1c00975 |
---|---|
311 else: |
311 else: |
312 scaling = (8, 8) |
312 scaling = (8, 8) |
313 if keycode == WXK_DELETE and self.SelectedElement: |
313 if keycode == WXK_DELETE and self.SelectedElement: |
314 self.SelectedElement.Delete() |
314 self.SelectedElement.Delete() |
315 self.SelectedElement = None |
315 self.SelectedElement = None |
316 self.RefreshBuffer() |
|
317 self.RefreshScrollBars() |
|
318 self.Refresh() |
|
316 elif keycode == WXK_LEFT: |
319 elif keycode == WXK_LEFT: |
317 if event.ControlDown() and event.ShiftDown(): |
320 if event.ControlDown() and event.ShiftDown(): |
318 self.Scroll(0, ypos) |
321 self.Scroll(0, ypos) |
319 elif event.ControlDown(): |
322 elif event.ControlDown(): |
320 self.Scroll(max(0, xpos - 1), ypos) |
323 self.Scroll(max(0, xpos - 1), ypos) |
321 elif self.SelectedElement: |
324 elif self.SelectedElement: |
322 self.SelectedElement.Move(-scaling[0], 0) |
325 self.SelectedElement.Move(-scaling[0], 0) |
326 self.RefreshBuffer() |
|
327 self.RefreshScrollBars() |
|
328 self.Refresh() |
|
323 elif keycode == WXK_RIGHT: |
329 elif keycode == WXK_RIGHT: |
324 if event.ControlDown() and event.ShiftDown(): |
330 if event.ControlDown() and event.ShiftDown(): |
325 self.Scroll(xmax, ypos) |
331 self.Scroll(xmax, ypos) |
326 elif event.ControlDown(): |
332 elif event.ControlDown(): |
327 self.Scroll(min(xpos + 1, xmax), ypos) |
333 self.Scroll(min(xpos + 1, xmax), ypos) |
328 elif self.SelectedElement: |
334 elif self.SelectedElement: |
329 self.SelectedElement.Move(scaling[0], 0) |
335 self.SelectedElement.Move(scaling[0], 0) |
336 self.RefreshBuffer() |
|
337 self.RefreshScrollBars() |
|
338 self.Refresh() |
|
330 elif keycode == WXK_UP: |
339 elif keycode == WXK_UP: |
331 if event.ControlDown() and event.ShiftDown(): |
340 if event.ControlDown() and event.ShiftDown(): |
332 self.Scroll(xpos, 0) |
341 self.Scroll(xpos, 0) |
333 elif event.ControlDown(): |
342 elif event.ControlDown(): |
334 self.Scroll(xpos, max(0, ypos - 1)) |
343 self.Scroll(xpos, max(0, ypos - 1)) |
335 elif self.SelectedElement: |
344 elif self.SelectedElement: |
336 self.SelectedElement.Move(0, -scaling[1]) |
345 self.SelectedElement.Move(0, -scaling[1]) |
346 self.RefreshBuffer() |
|
347 self.RefreshScrollBars() |
|
348 self.Refresh() |
|
337 elif keycode == WXK_DOWN: |
349 elif keycode == WXK_DOWN: |
338 if event.ControlDown() and event.ShiftDown(): |
350 if event.ControlDown() and event.ShiftDown(): |
339 self.Scroll(xpos, ymax) |
351 self.Scroll(xpos, ymax) |
340 elif event.ControlDown(): |
352 elif event.ControlDown(): |
341 self.Scroll(xpos, min(ypos + 1, ymax)) |
353 self.Scroll(xpos, min(ypos + 1, ymax)) |
342 elif self.SelectedElement: |
354 elif self.SelectedElement: |
343 self.SelectedElement.Move(0, scaling[1]) |
355 self.SelectedElement.Move(0, scaling[1]) |
344 self.Refresh() |
356 self.RefreshBuffer() |
357 self.RefreshScrollBars() |
|
358 self.Refresh() |
|
345 |
359 |
346 #------------------------------------------------------------------------------- |
360 #------------------------------------------------------------------------------- |
347 # Adding element functions |
361 # Adding element functions |
348 #------------------------------------------------------------------------------- |
362 #------------------------------------------------------------------------------- |
349 |
363 |
362 step.SetSize(max(min_width, width), max(min_height, height)) |
376 step.SetSize(max(min_width, width), max(min_height, height)) |
363 self.AddBlock(step) |
377 self.AddBlock(step) |
364 self.Controler.AddCurrentElementEditingStep(id) |
378 self.Controler.AddCurrentElementEditingStep(id) |
365 self.RefreshStepModel(step) |
379 self.RefreshStepModel(step) |
366 self.Parent.RefreshProjectTree() |
380 self.Parent.RefreshProjectTree() |
381 self.RefreshBuffer() |
|
382 self.RefreshScrollBars() |
|
367 self.Refresh() |
383 self.Refresh() |
368 dialog.Destroy() |
384 dialog.Destroy() |
369 |
385 |
370 def AddStep(self): |
386 def AddStep(self): |
371 if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step): |
387 if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step): |
415 else: |
431 else: |
416 self.SelectedElement.SetSelected(False) |
432 self.SelectedElement.SetSelected(False) |
417 self.SelectedElement = step |
433 self.SelectedElement = step |
418 self.SelectedElement.SetSelected(True) |
434 self.SelectedElement.SetSelected(True) |
419 self.Parent.RefreshProjectTree() |
435 self.Parent.RefreshProjectTree() |
436 self.RefreshBuffer() |
|
437 self.RefreshScrollBars() |
|
420 self.Refresh() |
438 self.Refresh() |
421 dialog.Destroy() |
439 dialog.Destroy() |
422 |
440 |
423 def AddStepAction(self): |
441 def AddStepAction(self): |
424 if isinstance(self.SelectedElement, SFC_Step): |
442 if isinstance(self.SelectedElement, SFC_Step): |
442 wire.SetPoints([wxPoint(pos.x + SFC_WIRE_MIN_SIZE, pos.y), wxPoint(pos.x, pos.y)]) |
460 wire.SetPoints([wxPoint(pos.x + SFC_WIRE_MIN_SIZE, pos.y), wxPoint(pos.x, pos.y)]) |
443 actionblock.SetActions(actions) |
461 actionblock.SetActions(actions) |
444 self.AddBlock(actionblock) |
462 self.AddBlock(actionblock) |
445 self.Controler.AddCurrentElementEditingActionBlock(id) |
463 self.Controler.AddCurrentElementEditingActionBlock(id) |
446 self.RefreshActionBlockModel(actionblock) |
464 self.RefreshActionBlockModel(actionblock) |
465 self.RefreshBuffer() |
|
466 self.RefreshScrollBars() |
|
447 self.Refresh() |
467 self.Refresh() |
448 dialog.Destroy() |
468 dialog.Destroy() |
449 |
469 |
450 def AddDivergence(self): |
470 def AddDivergence(self): |
451 if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, Graphic_Group) or isinstance(self.SelectedElement, SFC_Step): |
471 if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, Graphic_Group) or isinstance(self.SelectedElement, SFC_Step): |
636 else: |
656 else: |
637 transition = self.CreateTransition(divergence_connectors["outputs"][0]) |
657 transition = self.CreateTransition(divergence_connectors["outputs"][0]) |
638 transition_connectors = transition.GetConnectors() |
658 transition_connectors = transition.GetConnectors() |
639 previous = transition_connectors["output"] |
659 previous = transition_connectors["output"] |
640 self.CreateStep("Step", previous) |
660 self.CreateStep("Step", previous) |
661 self.RefreshBuffer() |
|
662 self.RefreshScrollBars() |
|
641 self.Refresh() |
663 self.Refresh() |
642 dialog.Destroy() |
664 dialog.Destroy() |
643 |
665 |
644 def AddDivergenceBranch(self, divergence): |
666 def AddDivergenceBranch(self, divergence): |
645 if isinstance(divergence, SFC_Divergence): |
667 if isinstance(divergence, SFC_Divergence): |
652 transition_connectors = transition.GetConnectors() |
674 transition_connectors = transition.GetConnectors() |
653 previous = transition_connectors["output"] |
675 previous = transition_connectors["output"] |
654 else: |
676 else: |
655 previous = divergence_connectors["outputs"][-1] |
677 previous = divergence_connectors["outputs"][-1] |
656 step = self.CreateStep("Step", previous) |
678 step = self.CreateStep("Step", previous) |
679 self.RefreshBuffer() |
|
680 self.RefreshScrollBars() |
|
657 self.Refresh() |
681 self.Refresh() |
658 |
682 |
659 def AddJump(self): |
683 def AddJump(self): |
660 if isinstance(self.SelectedElement, SFC_Step) and not self.SelectedElement.Output: |
684 if isinstance(self.SelectedElement, SFC_Step) and not self.SelectedElement.Output: |
661 choices = [] |
685 choices = [] |
679 jump_connector = jump.GetConnector() |
703 jump_connector = jump.GetConnector() |
680 wire = self.ConnectConnectors(jump_connector, transition_connectors["output"]) |
704 wire = self.ConnectConnectors(jump_connector, transition_connectors["output"]) |
681 transition.RefreshOutputPosition() |
705 transition.RefreshOutputPosition() |
682 wire.SetPoints([wxPoint(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wxPoint(pos.x, pos.y)]) |
706 wire.SetPoints([wxPoint(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wxPoint(pos.x, pos.y)]) |
683 self.RefreshJumpModel(jump) |
707 self.RefreshJumpModel(jump) |
708 self.RefreshBuffer() |
|
709 self.RefreshScrollBars() |
|
684 self.Refresh() |
710 self.Refresh() |
685 dialog.Destroy() |
711 dialog.Destroy() |
686 |
|
687 def AddComment(self, bbox): |
|
688 dialog = wxTextEntryDialog(self.Parent, "Add a new comment", "Please enter comment text", "", wxOK|wxCANCEL|wxTE_MULTILINE) |
|
689 if dialog.ShowModal() == wxID_OK: |
|
690 value = dialog.GetValue() |
|
691 id = self.GetNewId() |
|
692 comment = Comment(self, value, id) |
|
693 comment.SetPosition(bbox.x, bbox.y) |
|
694 min_width, min_height = comment.GetMinSize() |
|
695 comment.SetSize(max(min_width,bbox.width),max(min_height,bbox.height)) |
|
696 self.AddComment(comment) |
|
697 self.Controler.AddCurrentElementEditingComment(id) |
|
698 self.RefreshCommentModel(comment) |
|
699 self.Refresh() |
|
700 dialog.Destroy() |
|
701 |
712 |
702 def EditStepContent(self, step): |
713 def EditStepContent(self, step): |
703 dialog = StepNameDialog(self.Parent, "Edit step name", "Please enter step name", step.GetName(), wxOK|wxCANCEL) |
714 dialog = StepNameDialog(self.Parent, "Edit step name", "Please enter step name", step.GetName(), wxOK|wxCANCEL) |
704 dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
715 dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
705 dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars()) |
716 dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars()) |
709 step.SetName(value) |
720 step.SetName(value) |
710 min_size = step.GetMinSize() |
721 min_size = step.GetMinSize() |
711 size = step.GetSize() |
722 size = step.GetSize() |
712 step.UpdateSize(max(min_size[0], size[0]), max(min_size[1], size[1])) |
723 step.UpdateSize(max(min_size[0], size[0]), max(min_size[1], size[1])) |
713 step.RefreshModel() |
724 step.RefreshModel() |
725 self.RefreshBuffer() |
|
726 self.RefreshScrollBars() |
|
714 self.Refresh() |
727 self.Refresh() |
715 dialog.Destroy() |
728 dialog.Destroy() |
716 |
729 |
717 def EditTransitionContent(self, transition): |
730 def EditTransitionContent(self, transition): |
718 dialog = TransitionContentDialog(self.Parent) |
731 dialog = TransitionContentDialog(self.Parent) |
721 if dialog.ShowModal() == wxID_OK: |
734 if dialog.ShowModal() == wxID_OK: |
722 values = dialog.GetValues() |
735 values = dialog.GetValues() |
723 transition.SetType(values["type"]) |
736 transition.SetType(values["type"]) |
724 transition.SetCondition(values["value"]) |
737 transition.SetCondition(values["value"]) |
725 transition.RefreshModel() |
738 transition.RefreshModel() |
739 self.RefreshBuffer() |
|
740 self.RefreshScrollBars() |
|
726 self.Refresh() |
741 self.Refresh() |
727 dialog.Destroy() |
742 dialog.Destroy() |
728 |
743 |
729 def EditJumpContent(self, jump): |
744 def EditJumpContent(self, jump): |
730 choices = [] |
745 choices = [] |
735 dialog.SetSelection(choices.index(jump.GetTarget())) |
750 dialog.SetSelection(choices.index(jump.GetTarget())) |
736 if dialog.ShowModal() == wxID_OK: |
751 if dialog.ShowModal() == wxID_OK: |
737 value = dialog.GetStringSelection() |
752 value = dialog.GetStringSelection() |
738 jump.SetTarget(value) |
753 jump.SetTarget(value) |
739 jump.RefreshModel() |
754 jump.RefreshModel() |
755 self.RefreshBuffer() |
|
756 self.RefreshScrollBars() |
|
740 self.Refresh() |
757 self.Refresh() |
741 dialog.Destroy() |
758 dialog.Destroy() |
742 |
759 |
743 def EditActionBlockContent(self, actionblock): |
760 def EditActionBlockContent(self, actionblock): |
744 dialog = ActionBlockDialog(self.Parent) |
761 dialog = ActionBlockDialog(self.Parent) |
748 dialog.SetValues(actionblock.GetActions()) |
765 dialog.SetValues(actionblock.GetActions()) |
749 if dialog.ShowModal() == wxID_OK: |
766 if dialog.ShowModal() == wxID_OK: |
750 actions = dialog.GetValues() |
767 actions = dialog.GetValues() |
751 actionblock.SetActions(actions) |
768 actionblock.SetActions(actions) |
752 actionblock.RefreshModel() |
769 actionblock.RefreshModel() |
770 self.RefreshBuffer() |
|
771 self.RefreshScrollBars() |
|
753 self.Refresh() |
772 self.Refresh() |
754 dialog.Destroy() |
773 dialog.Destroy() |
755 |
774 |
756 |
775 |
757 #------------------------------------------------------------------------------- |
776 #------------------------------------------------------------------------------- |