64 else: |
64 else: |
65 parent.Append(helpString=help, id=id, kind=kind, item=text) |
65 parent.Append(helpString=help, id=id, kind=kind, item=text) |
66 |
66 |
67 if wx.Platform == '__WXMSW__': |
67 if wx.Platform == '__WXMSW__': |
68 faces = { 'times': 'Times New Roman', |
68 faces = { 'times': 'Times New Roman', |
69 'mono' : 'Courier New', |
69 'mono': 'Courier New', |
70 'helv' : 'Arial', |
70 'helv': 'Arial', |
71 'other': 'Comic Sans MS', |
71 'other': 'Comic Sans MS', |
72 'size' : 10, |
72 'size': 10, |
73 } |
73 } |
74 else: |
74 else: |
75 faces = { 'times': 'Times', |
75 faces = { 'times': 'Times', |
76 'mono' : 'Courier', |
76 'mono': 'Courier', |
77 'helv' : 'Helvetica', |
77 'helv': 'Helvetica', |
78 'other': 'new century schoolbook', |
78 'other': 'new century schoolbook', |
79 'size' : 12, |
79 'size': 12, |
80 } |
80 } |
81 |
81 |
82 if wx.Platform == '__WXMSW__': |
82 if wx.Platform == '__WXMSW__': |
83 MAX_ZOOMIN = 4 |
83 MAX_ZOOMIN = 4 |
84 else: |
84 else: |
1357 |
1357 |
1358 # Load instance from given informations |
1358 # Load instance from given informations |
1359 def loadInstance(self, instance, remaining_instances, selection): |
1359 def loadInstance(self, instance, remaining_instances, selection): |
1360 self.current_id = max(self.current_id, instance.id) |
1360 self.current_id = max(self.current_id, instance.id) |
1361 creation_function = ElementCreationFunctions.get(instance.type, None) |
1361 creation_function = ElementCreationFunctions.get(instance.type, None) |
1362 connectors = {"inputs" : [], "outputs" : []} |
1362 connectors = {"inputs": [], "outputs": []} |
1363 specific_values = instance.specific_values |
1363 specific_values = instance.specific_values |
1364 if creation_function is not None: |
1364 if creation_function is not None: |
1365 element = creation_function(self, instance.id, specific_values) |
1365 element = creation_function(self, instance.id, specific_values) |
1366 if isinstance(element, SFC_Step): |
1366 if isinstance(element, SFC_Step): |
1367 if len(instance.inputs) > 0: |
1367 if len(instance.inputs) > 0: |
2003 self.DrawingWire = False |
2003 self.DrawingWire = False |
2004 if self.SelectedElement is not None: |
2004 if self.SelectedElement is not None: |
2005 if element is None or element.TestHandle(event) == (0, 0): |
2005 if element is None or element.TestHandle(event) == (0, 0): |
2006 connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection()) |
2006 connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection()) |
2007 if connector is not None: |
2007 if connector is not None: |
2008 event.Dragging = lambda : True |
2008 event.Dragging = lambda: True |
2009 self.SelectedElement.OnMotion(event, dc, self.Scaling) |
2009 self.SelectedElement.OnMotion(event, dc, self.Scaling) |
2010 if self.SelectedElement.EndConnected is not None: |
2010 if self.SelectedElement.EndConnected is not None: |
2011 self.SelectedElement.ResetPoints() |
2011 self.SelectedElement.ResetPoints() |
2012 self.SelectedElement.GeneratePoints() |
2012 self.SelectedElement.GeneratePoints() |
2013 self.SelectedElement.RefreshModel() |
2013 self.SelectedElement.RefreshModel() |
2795 |
2795 |
2796 def EditBlockContent(self, block): |
2796 def EditBlockContent(self, block): |
2797 dialog = FBDBlockDialog(self.ParentWindow, self.Controler, self.TagName) |
2797 dialog = FBDBlockDialog(self.ParentWindow, self.Controler, self.TagName) |
2798 dialog.SetPreviewFont(self.GetFont()) |
2798 dialog.SetPreviewFont(self.GetFont()) |
2799 dialog.SetMinElementSize(block.GetSize()) |
2799 dialog.SetMinElementSize(block.GetSize()) |
2800 old_values = {"name" : block.GetName(), |
2800 old_values = { |
2801 "type" : block.GetType(), |
2801 "name": block.GetName(), |
2802 "extension" : block.GetExtension(), |
2802 "type": block.GetType(), |
2803 "inputs" : block.GetInputTypes(), |
2803 "extension": block.GetExtension(), |
2804 "executionControl" : block.GetExecutionControl(), |
2804 "inputs": block.GetInputTypes(), |
2805 "executionOrder" : block.GetExecutionOrder()} |
2805 "executionControl": block.GetExecutionControl(), |
|
2806 "executionOrder": block.GetExecutionOrder() |
|
2807 } |
2806 dialog.SetValues(old_values) |
2808 dialog.SetValues(old_values) |
2807 if dialog.ShowModal() == wx.ID_OK: |
2809 if dialog.ShowModal() == wx.ID_OK: |
2808 new_values = dialog.GetValues() |
2810 new_values = dialog.GetValues() |
2809 rect = block.GetRedrawRect(1, 1) |
2811 rect = block.GetRedrawRect(1, 1) |
2810 if "name" in new_values: |
2812 if "name" in new_values: |
2829 |
2831 |
2830 def EditVariableContent(self, variable): |
2832 def EditVariableContent(self, variable): |
2831 dialog = FBDVariableDialog(self.ParentWindow, self.Controler, self.TagName) |
2833 dialog = FBDVariableDialog(self.ParentWindow, self.Controler, self.TagName) |
2832 dialog.SetPreviewFont(self.GetFont()) |
2834 dialog.SetPreviewFont(self.GetFont()) |
2833 dialog.SetMinElementSize(variable.GetSize()) |
2835 dialog.SetMinElementSize(variable.GetSize()) |
2834 old_values = {"expression" : variable.GetName(), "class" : variable.GetType(), |
2836 old_values = { |
2835 "executionOrder" : variable.GetExecutionOrder()} |
2837 "expression": variable.GetName(), |
|
2838 "class": variable.GetType(), |
|
2839 "executionOrder": variable.GetExecutionOrder() |
|
2840 } |
2836 dialog.SetValues(old_values) |
2841 dialog.SetValues(old_values) |
2837 if dialog.ShowModal() == wx.ID_OK: |
2842 if dialog.ShowModal() == wx.ID_OK: |
2838 new_values = dialog.GetValues() |
2843 new_values = dialog.GetValues() |
2839 rect = variable.GetRedrawRect(1, 1) |
2844 rect = variable.GetRedrawRect(1, 1) |
2840 variable.SetName(new_values["expression"]) |
2845 variable.SetName(new_values["expression"]) |
2858 |
2863 |
2859 def EditConnectionContent(self, connection): |
2864 def EditConnectionContent(self, connection): |
2860 dialog = ConnectionDialog(self.ParentWindow, self.Controler, self.TagName, True) |
2865 dialog = ConnectionDialog(self.ParentWindow, self.Controler, self.TagName, True) |
2861 dialog.SetPreviewFont(self.GetFont()) |
2866 dialog.SetPreviewFont(self.GetFont()) |
2862 dialog.SetMinElementSize(connection.GetSize()) |
2867 dialog.SetMinElementSize(connection.GetSize()) |
2863 values = {"name" : connection.GetName(), "type" : connection.GetType()} |
2868 values = {"name": connection.GetName(), "type": connection.GetType()} |
2864 dialog.SetValues(values) |
2869 dialog.SetValues(values) |
2865 result = dialog.ShowModal() |
2870 result = dialog.ShowModal() |
2866 dialog.Destroy() |
2871 dialog.Destroy() |
2867 if result in [wx.ID_OK, wx.ID_YESTOALL]: |
2872 if result in [wx.ID_OK, wx.ID_YESTOALL]: |
2868 old_type = connection.GetType() |
2873 old_type = connection.GetType() |
2890 |
2895 |
2891 def EditContactContent(self, contact): |
2896 def EditContactContent(self, contact): |
2892 dialog = LDElementDialog(self.ParentWindow, self.Controler, self.TagName, "contact") |
2897 dialog = LDElementDialog(self.ParentWindow, self.Controler, self.TagName, "contact") |
2893 dialog.SetPreviewFont(self.GetFont()) |
2898 dialog.SetPreviewFont(self.GetFont()) |
2894 dialog.SetMinElementSize(contact.GetSize()) |
2899 dialog.SetMinElementSize(contact.GetSize()) |
2895 dialog.SetValues({"variable" : contact.GetName(), |
2900 dialog.SetValues({"variable": contact.GetName(), |
2896 "modifier" : contact.GetType()}) |
2901 "modifier": contact.GetType()}) |
2897 if dialog.ShowModal() == wx.ID_OK: |
2902 if dialog.ShowModal() == wx.ID_OK: |
2898 values = dialog.GetValues() |
2903 values = dialog.GetValues() |
2899 rect = contact.GetRedrawRect(1, 1) |
2904 rect = contact.GetRedrawRect(1, 1) |
2900 contact.SetName(values["variable"]) |
2905 contact.SetName(values["variable"]) |
2901 contact.SetType(values["modifier"]) |
2906 contact.SetType(values["modifier"]) |
2910 |
2915 |
2911 def EditCoilContent(self, coil): |
2916 def EditCoilContent(self, coil): |
2912 dialog = LDElementDialog(self.ParentWindow, self.Controler, self.TagName, "coil") |
2917 dialog = LDElementDialog(self.ParentWindow, self.Controler, self.TagName, "coil") |
2913 dialog.SetPreviewFont(self.GetFont()) |
2918 dialog.SetPreviewFont(self.GetFont()) |
2914 dialog.SetMinElementSize(coil.GetSize()) |
2919 dialog.SetMinElementSize(coil.GetSize()) |
2915 dialog.SetValues({"variable" : coil.GetName(), |
2920 dialog.SetValues({"variable": coil.GetName(), |
2916 "modifier" : coil.GetType()}) |
2921 "modifier": coil.GetType()}) |
2917 if dialog.ShowModal() == wx.ID_OK: |
2922 if dialog.ShowModal() == wx.ID_OK: |
2918 values = dialog.GetValues() |
2923 values = dialog.GetValues() |
2919 rect = coil.GetRedrawRect(1, 1) |
2924 rect = coil.GetRedrawRect(1, 1) |
2920 coil.SetName(values["variable"]) |
2925 coil.SetName(values["variable"]) |
2921 coil.SetType(values["modifier"]) |
2926 coil.SetType(values["modifier"]) |
2958 dialog = SFCStepDialog(self.ParentWindow, self.Controler, self.TagName, step.GetInitial()) |
2963 dialog = SFCStepDialog(self.ParentWindow, self.Controler, self.TagName, step.GetInitial()) |
2959 dialog.SetPreviewFont(self.GetFont()) |
2964 dialog.SetPreviewFont(self.GetFont()) |
2960 dialog.SetMinElementSize(step.GetSize()) |
2965 dialog.SetMinElementSize(step.GetSize()) |
2961 connectors = step.GetConnectors() |
2966 connectors = step.GetConnectors() |
2962 dialog.SetValues({ |
2967 dialog.SetValues({ |
2963 "name" : step.GetName(), |
2968 "name": step.GetName(), |
2964 "input": len(connectors["inputs"]) > 0, |
2969 "input": len(connectors["inputs"]) > 0, |
2965 "output": len(connectors["outputs"]) > 0, |
2970 "output": len(connectors["outputs"]) > 0, |
2966 "action": step.GetActionConnector() != None}) |
2971 "action": step.GetActionConnector() != None}) |
2967 if dialog.ShowModal() == wx.ID_OK: |
2972 if dialog.ShowModal() == wx.ID_OK: |
2968 values = dialog.GetValues() |
2973 values = dialog.GetValues() |