1041 self.Controler.AddCurrentElementEditingDivergence(id, values["type"]) |
1041 self.Controler.AddCurrentElementEditingDivergence(id, values["type"]) |
1042 self.RefreshDivergenceModel(divergence) |
1042 self.RefreshDivergenceModel(divergence) |
1043 self.Refresh() |
1043 self.Refresh() |
1044 dialog.Destroy() |
1044 dialog.Destroy() |
1045 |
1045 |
1046 #------------------------------------------------------------------------------- |
|
1047 # Model update functions |
|
1048 #------------------------------------------------------------------------------- |
|
1049 |
|
1050 def RefreshBlockModel(self, block): |
|
1051 blockid = block.GetId() |
|
1052 infos = {} |
|
1053 infos["type"] = block.GetType() |
|
1054 infos["name"] = block.GetName() |
|
1055 infos["x"], infos["y"] = block.GetPosition() |
|
1056 infos["width"], infos["height"] = block.GetSize() |
|
1057 infos["connectors"] = block.GetConnectors() |
|
1058 self.Controler.SetCurrentElementEditingBlockInfos(blockid, infos) |
|
1059 |
|
1060 def RefreshVariableModel(self, variable): |
|
1061 variableid = variable.GetId() |
|
1062 infos = {} |
|
1063 infos["name"] = variable.GetName() |
|
1064 infos["x"], infos["y"] = variable.GetPosition() |
|
1065 infos["width"], infos["height"] = variable.GetSize() |
|
1066 infos["connectors"] = variable.GetConnectors() |
|
1067 self.Controler.SetCurrentElementEditingVariableInfos(variableid, infos) |
|
1068 |
|
1069 def RefreshConnectionModel(self, connection): |
|
1070 connectionid = connection.GetId() |
|
1071 infos = {} |
|
1072 infos["name"] = connection.GetName() |
|
1073 infos["x"], infos["y"] = connection.GetPosition() |
|
1074 infos["width"], infos["height"] = connection.GetSize() |
|
1075 infos["connector"] = connection.GetConnector() |
|
1076 self.Controler.SetCurrentElementEditingConnectionInfos(connectionid, infos) |
|
1077 |
|
1078 def RefreshCommentModel(self, comment): |
|
1079 commentid = comment.GetId() |
|
1080 infos = {} |
|
1081 infos["content"] = comment.GetContent() |
|
1082 infos["x"], infos["y"] = comment.GetPosition() |
|
1083 infos["width"], infos["height"] = comment.GetSize() |
|
1084 self.Controler.SetCurrentElementEditingCommentInfos(commentid, infos) |
|
1085 |
|
1086 def RefreshPowerRailModel(self, powerrail): |
|
1087 powerrailid = powerrail.GetId() |
|
1088 infos = {} |
|
1089 infos["x"], infos["y"] = powerrail.GetPosition() |
|
1090 infos["width"], infos["height"] = powerrail.GetSize() |
|
1091 infos["connectors"] = powerrail.GetConnectors() |
|
1092 self.Controler.SetCurrentElementEditingPowerRailInfos(powerrailid, infos) |
|
1093 |
|
1094 def RefreshContactModel(self, contact): |
|
1095 contactid = contact.GetId() |
|
1096 infos = {} |
|
1097 infos["name"] = contact.GetName() |
|
1098 infos["type"] = contact.GetType() |
|
1099 infos["x"], infos["y"] = contact.GetPosition() |
|
1100 infos["width"], infos["height"] = contact.GetSize() |
|
1101 infos["connectors"] = contact.GetConnectors() |
|
1102 self.Controler.SetCurrentElementEditingContactInfos(contactid, infos) |
|
1103 |
|
1104 def RefreshCoilModel(self, coil): |
|
1105 coilid = coil.GetId() |
|
1106 infos = {} |
|
1107 infos["name"] = coil.GetName() |
|
1108 infos["type"] = coil.GetType() |
|
1109 infos["x"], infos["y"] = coil.GetPosition() |
|
1110 infos["width"], infos["height"] = coil.GetSize() |
|
1111 infos["connectors"] = coil.GetConnectors() |
|
1112 self.Controler.SetCurrentElementEditingCoilInfos(coilid, infos) |
|
1113 |
|
1114 def RefreshStepModel(self, step): |
|
1115 stepid = step.GetId() |
|
1116 infos = {} |
|
1117 infos["name"] = step.GetName() |
|
1118 infos["initial"] = step.GetInitial() |
|
1119 infos["x"], infos["y"] = step.GetPosition() |
|
1120 infos["width"], infos["height"] = step.GetSize() |
|
1121 infos["connectors"] = step.GetConnectors() |
|
1122 self.Controler.SetCurrentElementEditingStepInfos(stepid, infos) |
|
1123 |
|
1124 def RefreshTransitionModel(self, transition): |
|
1125 transitionid = transition.GetId() |
|
1126 infos = {} |
|
1127 infos["type"] = transition.GetType() |
|
1128 infos["condition"] = transition.GetCondition() |
|
1129 infos["x"], infos["y"] = transition.GetPosition() |
|
1130 infos["width"], infos["height"] = transition.GetSize() |
|
1131 infos["connectors"] = transition.GetConnectors() |
|
1132 self.Controler.SetCurrentElementEditingTransitionInfos(transitionid, infos) |
|
1133 |
|
1134 def RefreshDivergenceModel(self, divergence): |
|
1135 divergenceid = divergence.GetId() |
|
1136 infos = {} |
|
1137 infos["x"], infos["y"] = divergence.GetPosition() |
|
1138 infos["width"], infos["height"] = divergence.GetSize() |
|
1139 infos["connectors"] = divergence.GetConnectors() |
|
1140 self.Controler.SetCurrentElementEditingDivergenceInfos(divergenceid, infos) |
|
1141 |
|
1142 def RefreshJumpModel(self, jump): |
|
1143 jumpid = jump.GetId() |
|
1144 infos = {} |
|
1145 infos["target"] = jump.GetTarget() |
|
1146 infos["x"], infos["y"] = jump.GetPosition() |
|
1147 infos["width"], infos["height"] = jump.GetSize() |
|
1148 infos["connector"] = jump.GetConnector() |
|
1149 self.Controler.SetCurrentElementEditingJumpInfos(jumpid, infos) |
|
1150 |
|
1151 def RefreshActionBlockModel(self, actionblock): |
|
1152 actionblockid = actionblock.GetId() |
|
1153 infos = {} |
|
1154 infos["actions"] = actionblock.GetActions() |
|
1155 infos["x"], infos["y"] = actionblock.GetPosition() |
|
1156 infos["width"], infos["height"] = actionblock.GetSize() |
|
1157 infos["connector"] = actionblock.GetConnector() |
|
1158 self.Controler.SetCurrentElementEditingActionBlockInfos(actionblockid, infos) |
|
1159 |
|
1160 |
|
1161 #------------------------------------------------------------------------------- |
|
1162 # Model delete functions |
|
1163 #------------------------------------------------------------------------------- |
|
1164 |
|
1165 |
|
1166 def DeleteBlock(self, block): |
|
1167 elements = [] |
|
1168 for output in block.GetConnectors()["outputs"]: |
|
1169 for element in output.GetConnectedBlocks(): |
|
1170 if element not in elements: |
|
1171 elements.append(element) |
|
1172 block.Clean() |
|
1173 self.Blocks.remove(block) |
|
1174 self.Elements.remove(block) |
|
1175 self.Controler.RemoveCurrentElementEditingInstance(block.GetId()) |
|
1176 for element in elements: |
|
1177 element.RefreshModel() |
|
1178 |
|
1179 def DeleteVariable(self, variable): |
|
1180 connectors = variable.GetConnectors() |
|
1181 if connectors["output"]: |
|
1182 elements = connectors["output"].GetConnectedBlocks() |
|
1183 else: |
|
1184 elements = [] |
|
1185 variable.Clean() |
|
1186 self.Blocks.remove(variable) |
|
1187 self.Elements.remove(variable) |
|
1188 self.Controler.RemoveCurrentElementEditingInstance(variable.GetId()) |
|
1189 for element in elements: |
|
1190 element.RefreshModel() |
|
1191 |
|
1192 def DeleteConnection(self, connection): |
|
1193 if connection.GetType() == CONTINUATION: |
|
1194 elements = connection.GetConnector().GetConnectedBlocks() |
|
1195 else: |
|
1196 elements = [] |
|
1197 connection.Clean() |
|
1198 self.Blocks.remove(connection) |
|
1199 self.Elements.remove(connection) |
|
1200 self.Controler.RemoveCurrentElementEditingInstance(connection.GetId()) |
|
1201 for element in elements: |
|
1202 element.RefreshModel() |
|
1203 |
|
1204 def DeleteComment(self, comment): |
|
1205 self.Elements.remove(comment) |
|
1206 self.Controler.RemoveCurrentElementEditingInstance(comment.GetId()) |
|
1207 |
|
1208 def DeleteWire(self, wire): |
|
1209 connected = wire.GetConnected() |
|
1210 wire.Clean() |
|
1211 self.Wires.remove(wire) |
|
1212 self.Elements.remove(wire) |
|
1213 for connector in connected: |
|
1214 connector.RefreshParentBlock() |
|
1215 |
|
1216 def DeleteContact(self, contact): |
|
1217 connectors = contact.GetConnectors() |
|
1218 elements = connectors["output"].GetConnectedBlocks() |
|
1219 contact.Clean() |
|
1220 self.Blocks.remove(contact) |
|
1221 self.Elements.remove(contact) |
|
1222 self.Controler.RemoveCurrentElementEditingInstance(contact.GetId()) |
|
1223 for element in elements: |
|
1224 element.RefreshModel() |
|
1225 |
|
1226 def DeleteCoil(self, coil): |
|
1227 connectors = coil.GetConnectors() |
|
1228 elements = connectors["output"].GetConnectedBlocks() |
|
1229 coil.Clean() |
|
1230 self.Blocks.remove(coil) |
|
1231 self.Elements.remove(coil) |
|
1232 self.Controler.RemoveCurrentElementEditingInstance(coil.GetId()) |
|
1233 for element in elements: |
|
1234 element.RefreshModel() |
|
1235 |
|
1236 def DeletePowerRail(self, powerrail): |
|
1237 elements = [] |
|
1238 if powerrail.GetType() == LEFTRAIL: |
|
1239 for connector in powerrail.GetConnectors(): |
|
1240 for element in connector.GetConnectedBlocks(): |
|
1241 if element not in elements: |
|
1242 elements.append(element) |
|
1243 powerrrail.Clean() |
|
1244 self.Blocks.remove(powerrrail) |
|
1245 self.Elements.remove(powerrrail) |
|
1246 self.Controler.RemoveCurrentElementEditingInstance(powerrrail.GetId()) |
|
1247 for element in elements: |
|
1248 element.RefreshModel() |
|
1249 |
1046 |
1250 #------------------------------------------------------------------------------- |
1047 #------------------------------------------------------------------------------- |
1251 # Edit element content functions |
1048 # Edit element content functions |
1252 #------------------------------------------------------------------------------- |
1049 #------------------------------------------------------------------------------- |
1253 |
1050 |
1254 def EditBlockContent(self, block): |
1051 def EditBlockContent(self, block): |
1255 dialog = BlockPropertiesDialog(self.Parent) |
1052 dialog = BlockPropertiesDialog(self.Parent) |
1256 dialog.SetBlockList(self.Controler.GetBlockTypes()) |
1053 dialog.SetBlockList(self.Controler.GetBlockTypes()) |
1257 dialog.SetMinBlockSize(block.GetSize()) |
1054 dialog.SetMinBlockSize(block.GetSize()) |
1258 values = {"name" : block.GetName(), "type" : block.GetType()} |
1055 values = {"name" : block.GetName(), "type" : block.GetType(), "inputs" : block.GetInputTypes()} |
1259 values["extension"] = block.GetExtension() |
1056 values["extension"] = block.GetExtension() |
1260 dialog.SetValues(values) |
1057 dialog.SetValues(values) |
1261 if dialog.ShowModal() == wxID_OK: |
1058 if dialog.ShowModal() == wxID_OK: |
1262 values = dialog.GetValues() |
1059 values = dialog.GetValues() |
1263 if "name" in values: |
1060 if "name" in values: |
1293 self.Controler.RemoveCurrentElementEditingInstance(id) |
1090 self.Controler.RemoveCurrentElementEditingInstance(id) |
1294 self.Controler.AddCurrentElementEditingVariable(id, values["type"]) |
1091 self.Controler.AddCurrentElementEditingVariable(id, values["type"]) |
1295 self.RefreshVariableModel(variable) |
1092 self.RefreshVariableModel(variable) |
1296 self.Refresh() |
1093 self.Refresh() |
1297 dialog.Destroy() |
1094 dialog.Destroy() |
|
1095 |
|
1096 def EditConnectionContent(self, connection): |
|
1097 dialog = ConnectionPropertiesDialog(self.Parent) |
|
1098 dialog.SetMinConnectionSize(connection.GetSize()) |
|
1099 values = {"name" : connection.GetName(), "type" : connection.GetType()} |
|
1100 dialog.SetValues(values) |
|
1101 if dialog.ShowModal() == wxID_OK: |
|
1102 old_type = connection.GetType() |
|
1103 values = dialog.GetValues() |
|
1104 connection.SetName(values["name"]) |
|
1105 connection.SetType(values["type"]) |
|
1106 connection.SetSize(values["width"], values["height"]) |
|
1107 if old_type != values["type"]: |
|
1108 id = connection.GetId() |
|
1109 self.Controler.RemoveCurrentElementEditingInstance(id) |
|
1110 self.Controler.AddCurrentElementEditingConnection(id, values["type"]) |
|
1111 self.RefreshConnectionModel(connection) |
|
1112 self.Refresh() |
|
1113 dialog.Destroy() |
|
1114 |
|
1115 def EditContactContent(self, contact): |
|
1116 dialog = LDElementDialog(self.Parent, "contact") |
|
1117 varlist = [] |
|
1118 vars = self.Controler.GetCurrentElementEditingInterfaceVars() |
|
1119 if vars: |
|
1120 for var in vars: |
|
1121 if var["Class"] != "Output" and var["Type"] == "BOOL": |
|
1122 varlist.append(var["Name"]) |
|
1123 dialog.SetVariables(varlist) |
|
1124 values = {"name" : contact.GetName(), "type" : contact.GetType()} |
|
1125 dialog.SetValues(values) |
|
1126 dialog.SetElementSize(contact.GetSize()) |
|
1127 if dialog.ShowModal() == wxID_OK: |
|
1128 values = dialog.GetValues() |
|
1129 contact.SetName(values["name"]) |
|
1130 contact.SetType(values["type"]) |
|
1131 contact.SetSize(values["width"], values["height"]) |
|
1132 self.RefreshContactModel(contact) |
|
1133 self.Refresh() |
|
1134 dialog.Destroy() |
|
1135 |
|
1136 def EditCoilContent(self, coil): |
|
1137 dialog = LDElementDialog(self.Parent, "coil") |
|
1138 varlist = [] |
|
1139 vars = self.Controler.GetCurrentElementEditingInterfaceVars() |
|
1140 if vars: |
|
1141 for var in vars: |
|
1142 if var["Class"] != "Input" and var["Type"] == "BOOL": |
|
1143 varlist.append(var["Name"]) |
|
1144 returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType() |
|
1145 if returntype == "BOOL": |
|
1146 varlist.append(self.Controler.GetCurrentElementEditingName()) |
|
1147 dialog.SetVariables(varlist) |
|
1148 values = {"name" : coil.GetName(), "type" : coil.GetType()} |
|
1149 dialog.SetValues(values) |
|
1150 dialog.SetElementSize(contact.GetSize()) |
|
1151 if dialog.ShowModal() == wxID_OK: |
|
1152 values = dialog.GetValues() |
|
1153 coil.SetName(values["name"]) |
|
1154 coil.SetType(values["type"]) |
|
1155 coil.SetSize(values["width"], values["height"]) |
|
1156 self.RefreshContactModel(coil) |
|
1157 self.Refresh() |
|
1158 dialog.Destroy() |
|
1159 |
|
1160 def EditPowerRailContent(self, powerrail): |
|
1161 dialog = LDPowerRailDialog(self.Parent, powerrail.GetType(), len(powerrail.GetConnectors())) |
|
1162 dialog.SetMinSize(powerrail.GetSize()) |
|
1163 if dialog.ShowModal() == wxID_OK: |
|
1164 old_type = powerrail.GetType() |
|
1165 values = dialog.GetValues() |
|
1166 powerrail.SetType(values["type"]) |
|
1167 powerrail.SetSize(values["width"], values["height"]) |
|
1168 if old_type != values["type"]: |
|
1169 id = powerrail.GetId() |
|
1170 self.Controler.RemoveCurrentElementEditingInstance(id) |
|
1171 self.Controler.AddCurrentElementEditingPowerRail(id, values["type"]) |
|
1172 self.RefreshPowerRailModel(powerrail) |
|
1173 self.Refresh() |
|
1174 dialog.Destroy() |
|
1175 |
|
1176 |
|
1177 def AddNewTransition(self, bbox): |
|
1178 dialog = TransitionContentDialog(self.Parent) |
|
1179 dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions()) |
|
1180 if dialog.ShowModal() == wxID_OK: |
|
1181 id = self.GetNewId() |
|
1182 values = dialog.GetValues() |
|
1183 transition = SFC_Transition(self, values["type"], values["value"], id) |
|
1184 transition.SetPosition(bbox.x, bbox.y) |
|
1185 min_width, min_height = transition.GetMinSize() |
|
1186 transition.SetSize(max(bbox.width, min_width), max(bbox.height, min_height)) |
|
1187 self.Blocks.append(transition) |
|
1188 self.Elements.append(transition) |
|
1189 self.Controler.AddCurrentElementEditingTransition(id) |
|
1190 self.RefreshTransitionModel(transition) |
|
1191 self.Refresh() |
|
1192 dialog.Destroy() |
|
1193 |
|
1194 def AddNewDivergence(self, bbox): |
|
1195 dialog = DivergenceCreateDialog(self.Parent) |
|
1196 dialog.SetMinSize((bbox.width, bbox.height)) |
|
1197 if dialog.ShowModal() == wxID_OK: |
|
1198 id = self.GetNewId() |
|
1199 values = dialog.GetValues() |
|
1200 divergence = SFC_Divergence(self, values["type"], values["number"], id) |
|
1201 divergence.SetPosition(bbox.x, bbox.y) |
|
1202 min_width, min_height = divergence.GetMinSize() |
|
1203 divergence.SetSize(max(bbox.width, min_width), max(bbox.height, min_height)) |
|
1204 self.Blocks.append(divergence) |
|
1205 self.Elements.append(divergence) |
|
1206 self.Controler.AddCurrentElementEditingDivergence(id, values["type"]) |
|
1207 self.RefreshDivergenceModel(divergence) |
|
1208 self.Refresh() |
|
1209 dialog.Destroy() |
|
1210 |
|
1211 #------------------------------------------------------------------------------- |
|
1212 # Model update functions |
|
1213 #------------------------------------------------------------------------------- |
|
1214 |
|
1215 def RefreshBlockModel(self, block): |
|
1216 blockid = block.GetId() |
|
1217 infos = {} |
|
1218 infos["type"] = block.GetType() |
|
1219 infos["name"] = block.GetName() |
|
1220 infos["x"], infos["y"] = block.GetPosition() |
|
1221 infos["width"], infos["height"] = block.GetSize() |
|
1222 infos["connectors"] = block.GetConnectors() |
|
1223 self.Controler.SetCurrentElementEditingBlockInfos(blockid, infos) |
|
1224 |
|
1225 def RefreshVariableModel(self, variable): |
|
1226 variableid = variable.GetId() |
|
1227 infos = {} |
|
1228 infos["name"] = variable.GetName() |
|
1229 infos["x"], infos["y"] = variable.GetPosition() |
|
1230 infos["width"], infos["height"] = variable.GetSize() |
|
1231 infos["connectors"] = variable.GetConnectors() |
|
1232 self.Controler.SetCurrentElementEditingVariableInfos(variableid, infos) |
|
1233 |
|
1234 def RefreshConnectionModel(self, connection): |
|
1235 connectionid = connection.GetId() |
|
1236 infos = {} |
|
1237 infos["name"] = connection.GetName() |
|
1238 infos["x"], infos["y"] = connection.GetPosition() |
|
1239 infos["width"], infos["height"] = connection.GetSize() |
|
1240 infos["connector"] = connection.GetConnector() |
|
1241 self.Controler.SetCurrentElementEditingConnectionInfos(connectionid, infos) |
|
1242 |
|
1243 def RefreshCommentModel(self, comment): |
|
1244 commentid = comment.GetId() |
|
1245 infos = {} |
|
1246 infos["content"] = comment.GetContent() |
|
1247 infos["x"], infos["y"] = comment.GetPosition() |
|
1248 infos["width"], infos["height"] = comment.GetSize() |
|
1249 self.Controler.SetCurrentElementEditingCommentInfos(commentid, infos) |
|
1250 |
|
1251 def RefreshPowerRailModel(self, powerrail): |
|
1252 powerrailid = powerrail.GetId() |
|
1253 infos = {} |
|
1254 infos["x"], infos["y"] = powerrail.GetPosition() |
|
1255 infos["width"], infos["height"] = powerrail.GetSize() |
|
1256 infos["connectors"] = powerrail.GetConnectors() |
|
1257 self.Controler.SetCurrentElementEditingPowerRailInfos(powerrailid, infos) |
|
1258 |
|
1259 def RefreshContactModel(self, contact): |
|
1260 contactid = contact.GetId() |
|
1261 infos = {} |
|
1262 infos["name"] = contact.GetName() |
|
1263 infos["type"] = contact.GetType() |
|
1264 infos["x"], infos["y"] = contact.GetPosition() |
|
1265 infos["width"], infos["height"] = contact.GetSize() |
|
1266 infos["connectors"] = contact.GetConnectors() |
|
1267 self.Controler.SetCurrentElementEditingContactInfos(contactid, infos) |
|
1268 |
|
1269 def RefreshCoilModel(self, coil): |
|
1270 coilid = coil.GetId() |
|
1271 infos = {} |
|
1272 infos["name"] = coil.GetName() |
|
1273 infos["type"] = coil.GetType() |
|
1274 infos["x"], infos["y"] = coil.GetPosition() |
|
1275 infos["width"], infos["height"] = coil.GetSize() |
|
1276 infos["connectors"] = coil.GetConnectors() |
|
1277 self.Controler.SetCurrentElementEditingCoilInfos(coilid, infos) |
|
1278 |
|
1279 def RefreshStepModel(self, step): |
|
1280 stepid = step.GetId() |
|
1281 infos = {} |
|
1282 infos["name"] = step.GetName() |
|
1283 infos["initial"] = step.GetInitial() |
|
1284 infos["x"], infos["y"] = step.GetPosition() |
|
1285 infos["width"], infos["height"] = step.GetSize() |
|
1286 infos["connectors"] = step.GetConnectors() |
|
1287 self.Controler.SetCurrentElementEditingStepInfos(stepid, infos) |
|
1288 |
|
1289 def RefreshTransitionModel(self, transition): |
|
1290 transitionid = transition.GetId() |
|
1291 infos = {} |
|
1292 infos["type"] = transition.GetType() |
|
1293 infos["condition"] = transition.GetCondition() |
|
1294 infos["x"], infos["y"] = transition.GetPosition() |
|
1295 infos["width"], infos["height"] = transition.GetSize() |
|
1296 infos["connectors"] = transition.GetConnectors() |
|
1297 self.Controler.SetCurrentElementEditingTransitionInfos(transitionid, infos) |
|
1298 |
|
1299 def RefreshDivergenceModel(self, divergence): |
|
1300 divergenceid = divergence.GetId() |
|
1301 infos = {} |
|
1302 infos["x"], infos["y"] = divergence.GetPosition() |
|
1303 infos["width"], infos["height"] = divergence.GetSize() |
|
1304 infos["connectors"] = divergence.GetConnectors() |
|
1305 self.Controler.SetCurrentElementEditingDivergenceInfos(divergenceid, infos) |
|
1306 |
|
1307 def RefreshJumpModel(self, jump): |
|
1308 jumpid = jump.GetId() |
|
1309 infos = {} |
|
1310 infos["target"] = jump.GetTarget() |
|
1311 infos["x"], infos["y"] = jump.GetPosition() |
|
1312 infos["width"], infos["height"] = jump.GetSize() |
|
1313 infos["connector"] = jump.GetConnector() |
|
1314 self.Controler.SetCurrentElementEditingJumpInfos(jumpid, infos) |
|
1315 |
|
1316 def RefreshActionBlockModel(self, actionblock): |
|
1317 actionblockid = actionblock.GetId() |
|
1318 infos = {} |
|
1319 infos["actions"] = actionblock.GetActions() |
|
1320 infos["x"], infos["y"] = actionblock.GetPosition() |
|
1321 infos["width"], infos["height"] = actionblock.GetSize() |
|
1322 infos["connector"] = actionblock.GetConnector() |
|
1323 self.Controler.SetCurrentElementEditingActionBlockInfos(actionblockid, infos) |
|
1324 |
|
1325 |
|
1326 #------------------------------------------------------------------------------- |
|
1327 # Model delete functions |
|
1328 #------------------------------------------------------------------------------- |
|
1329 |
|
1330 |
|
1331 def DeleteBlock(self, block): |
|
1332 elements = [] |
|
1333 for output in block.GetConnectors()["outputs"]: |
|
1334 for element in output.GetConnectedBlocks(): |
|
1335 if element not in elements: |
|
1336 elements.append(element) |
|
1337 block.Clean() |
|
1338 self.Blocks.remove(block) |
|
1339 self.Elements.remove(block) |
|
1340 self.Controler.RemoveCurrentElementEditingInstance(block.GetId()) |
|
1341 for element in elements: |
|
1342 element.RefreshModel() |
|
1343 |
|
1344 def DeleteVariable(self, variable): |
|
1345 connectors = variable.GetConnectors() |
|
1346 if connectors["output"]: |
|
1347 elements = connectors["output"].GetConnectedBlocks() |
|
1348 else: |
|
1349 elements = [] |
|
1350 variable.Clean() |
|
1351 self.Blocks.remove(variable) |
|
1352 self.Elements.remove(variable) |
|
1353 self.Controler.RemoveCurrentElementEditingInstance(variable.GetId()) |
|
1354 for element in elements: |
|
1355 element.RefreshModel() |
|
1356 |
|
1357 def DeleteConnection(self, connection): |
|
1358 if connection.GetType() == CONTINUATION: |
|
1359 elements = connection.GetConnector().GetConnectedBlocks() |
|
1360 else: |
|
1361 elements = [] |
|
1362 connection.Clean() |
|
1363 self.Blocks.remove(connection) |
|
1364 self.Elements.remove(connection) |
|
1365 self.Controler.RemoveCurrentElementEditingInstance(connection.GetId()) |
|
1366 for element in elements: |
|
1367 element.RefreshModel() |
|
1368 |
|
1369 def DeleteComment(self, comment): |
|
1370 self.Elements.remove(comment) |
|
1371 self.Controler.RemoveCurrentElementEditingInstance(comment.GetId()) |
|
1372 |
|
1373 def DeleteWire(self, wire): |
|
1374 if wire in self.Wires: |
|
1375 connected = wire.GetConnected() |
|
1376 wire.Clean() |
|
1377 self.Wires.remove(wire) |
|
1378 self.Elements.remove(wire) |
|
1379 for connector in connected: |
|
1380 connector.RefreshParentBlock() |
|
1381 |
|
1382 def DeleteContact(self, contact): |
|
1383 connectors = contact.GetConnectors() |
|
1384 elements = connectors["output"].GetConnectedBlocks() |
|
1385 contact.Clean() |
|
1386 self.Blocks.remove(contact) |
|
1387 self.Elements.remove(contact) |
|
1388 self.Controler.RemoveCurrentElementEditingInstance(contact.GetId()) |
|
1389 for element in elements: |
|
1390 element.RefreshModel() |
|
1391 |
|
1392 def DeleteCoil(self, coil): |
|
1393 connectors = coil.GetConnectors() |
|
1394 elements = connectors["output"].GetConnectedBlocks() |
|
1395 coil.Clean() |
|
1396 self.Blocks.remove(coil) |
|
1397 self.Elements.remove(coil) |
|
1398 self.Controler.RemoveCurrentElementEditingInstance(coil.GetId()) |
|
1399 for element in elements: |
|
1400 element.RefreshModel() |
|
1401 |
|
1402 def DeletePowerRail(self, powerrail): |
|
1403 elements = [] |
|
1404 if powerrail.GetType() == LEFTRAIL: |
|
1405 for connector in powerrail.GetConnectors(): |
|
1406 for element in connector.GetConnectedBlocks(): |
|
1407 if element not in elements: |
|
1408 elements.append(element) |
|
1409 powerrrail.Clean() |
|
1410 self.Blocks.remove(powerrrail) |
|
1411 self.Elements.remove(powerrrail) |
|
1412 self.Controler.RemoveCurrentElementEditingInstance(powerrrail.GetId()) |
|
1413 for element in elements: |
|
1414 element.RefreshModel() |
|
1415 |
|
1416 def DeleteStep(self, step): |
|
1417 elements = [] |
|
1418 connectors = step.GetConnectors() |
|
1419 if connectors["output"]: |
|
1420 for element in connectors["output"].GetConnectedBlocks(): |
|
1421 if element not in elements: |
|
1422 elements.append(element) |
|
1423 if connectors["action"]: |
|
1424 for element in connectors["action"].GetConnectedBlocks(): |
|
1425 if element not in elements: |
|
1426 elements.append(element) |
|
1427 step.Clean() |
|
1428 self.Blocks.remove(step) |
|
1429 self.Elements.remove(step) |
|
1430 self.Controler.RemoveCurrentElementEditingInstance(step.GetId()) |
|
1431 for element in elements: |
|
1432 element.RefreshModel() |
|
1433 |
|
1434 def DeleteTransition(self, transition): |
|
1435 elements = [] |
|
1436 connectors = transition.GetConnectors() |
|
1437 if connectors["output"]: |
|
1438 for element in connectors["output"].GetConnectedBlocks(): |
|
1439 if element not in elements: |
|
1440 elements.append(element) |
|
1441 transition.Clean() |
|
1442 self.Blocks.remove(transition) |
|
1443 self.Elements.remove(transition) |
|
1444 self.Controler.RemoveCurrentElementEditingInstance(transition.GetId()) |
|
1445 for element in elements: |
|
1446 element.RefreshModel() |
|
1447 |
|
1448 def DeleteDivergence(self, divergence): |
|
1449 elements = [] |
|
1450 connectors = divergence.GetConnectors() |
|
1451 for output in connectors["outputs"]: |
|
1452 for element in output.GetConnectedBlocks(): |
|
1453 if element not in elements: |
|
1454 elements.append(element) |
|
1455 divergence.Clean() |
|
1456 self.Blocks.remove(divergence) |
|
1457 self.Elements.remove(divergence) |
|
1458 self.Controler.RemoveCurrentElementEditingInstance(divergence.GetId()) |
|
1459 for element in elements: |
|
1460 element.RefreshModel() |
|
1461 |
|
1462 def DeleteJump(self, jump): |
|
1463 jump.Clean() |
|
1464 self.Blocks.remove(jump) |
|
1465 self.Elements.remove(jump) |
|
1466 self.Controler.RemoveCurrentElementEditingInstance(jump.GetId()) |
|
1467 |
|
1468 def DeleteActionBlock(self, actionblock): |
|
1469 actionblock.Clean() |
|
1470 self.Blocks.remove(actionblock) |
|
1471 self.Elements.remove(actionblock) |
|
1472 self.Controler.RemoveCurrentElementEditingInstance(actionblock.GetId()) |
1298 |
1473 |
1299 |
1474 |
1300 #------------------------------------------------------------------------------- |
1475 #------------------------------------------------------------------------------- |
1301 # Editing functions |
1476 # Editing functions |
1302 #------------------------------------------------------------------------------- |
1477 #------------------------------------------------------------------------------- |