diff -r 45d70748e45a -r fc2d6cbb8b39 Viewer.py --- a/Viewer.py Tue Aug 12 18:15:35 2008 +0200 +++ b/Viewer.py Tue Aug 12 18:16:09 2008 +0200 @@ -316,6 +316,7 @@ self.DrawingWire = False self.current_id = 0 self.TagName = tagname + self.Errors = [] # Initialize Block, Wire and Comment numbers self.block_id = self.wire_id = self.comment_id = 0 @@ -533,6 +534,7 @@ if not wire.IsConnectedCompatible(): wire.MarkAsInvalid() + self.ShowErrors() self.Refresh(False) def GetMaxSize(self): @@ -823,6 +825,15 @@ wire.ConnectEndPoint(None, end_connector) self.AddWire(wire) + def IsOfType(self, type, reference): + return self.Controler.IsOfType(type, reference) + + def IsEndType(self, type): + return self.Controler.IsEndType(type) + + def GetBlockType(self, type, inputs = None): + return self.Controler.GetBlockType(type, inputs) + #------------------------------------------------------------------------------- # Search Element functions #------------------------------------------------------------------------------- @@ -1417,7 +1428,7 @@ return width, height def AddNewBlock(self, bbox): - dialog = BlockPropertiesDialog(self.ParentWindow) + dialog = BlockPropertiesDialog(self.ParentWindow, self.Controler) dialog.SetPreviewFont(self.GetFont()) dialog.SetBlockList(self.Controler.GetBlockTypes(self.TagName)) dialog.SetPouNames(self.Controler.GetProjectPouNames()) @@ -1442,7 +1453,7 @@ dialog.Destroy() def AddNewVariable(self, bbox): - dialog = VariablePropertiesDialog(self.ParentWindow) + dialog = VariablePropertiesDialog(self.ParentWindow, self.Controler) dialog.SetPreviewFont(self.GetFont()) dialog.SetMinVariableSize((bbox.width, bbox.height)) varlist = [] @@ -1470,7 +1481,7 @@ dialog.Destroy() def AddNewConnection(self, bbox): - dialog = ConnectionPropertiesDialog(self.ParentWindow) + dialog = ConnectionPropertiesDialog(self.ParentWindow, self.Controler) dialog.SetPreviewFont(self.GetFont()) dialog.SetMinConnectionSize((bbox.width, bbox.height)) if dialog.ShowModal() == wx.ID_OK: @@ -1508,7 +1519,7 @@ dialog.Destroy() def AddNewContact(self, bbox): - dialog = LDElementDialog(self.ParentWindow, "contact") + dialog = LDElementDialog(self.ParentWindow, self.Controler, "contact") dialog.SetPreviewFont(self.GetFont()) varlist = [] vars = self.Controler.GetEditedElementInterfaceVars(self.TagName) @@ -1534,7 +1545,7 @@ dialog.Destroy() def AddNewCoil(self, bbox): - dialog = LDElementDialog(self.ParentWindow, "coil") + dialog = LDElementDialog(self.ParentWindow, self.Controler, "coil") dialog.SetPreviewFont(self.GetFont()) varlist = [] vars = self.Controler.GetEditedElementInterfaceVars(self.TagName) @@ -1563,7 +1574,7 @@ dialog.Destroy() def AddNewPowerRail(self, bbox): - dialog = LDPowerRailDialog(self.ParentWindow) + dialog = LDPowerRailDialog(self.ParentWindow, self.Controler) dialog.SetPreviewFont(self.GetFont()) dialog.SetMinSize((bbox.width, bbox.height)) if dialog.ShowModal() == wx.ID_OK: @@ -1581,7 +1592,7 @@ dialog.Destroy() def AddNewStep(self, bbox, initial = False): - dialog = StepContentDialog(self.ParentWindow, initial) + dialog = StepContentDialog(self.ParentWindow, self.Controler, initial) dialog.SetPreviewFont(self.GetFont()) dialog.SetPouNames(self.Controler.GetProjectPouNames()) dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName)) @@ -1615,7 +1626,7 @@ dialog.Destroy() def AddNewTransition(self, bbox): - dialog = TransitionContentDialog(self.ParentWindow, self.GetDrawingMode() == FREEDRAWING_MODE) + dialog = TransitionContentDialog(self.ParentWindow, self.Controler, self.GetDrawingMode() == FREEDRAWING_MODE) dialog.SetPreviewFont(self.GetFont()) dialog.SetTransitions(self.Controler.GetEditedElementTransitions(self.TagName)) if dialog.ShowModal() == wx.ID_OK: @@ -1634,7 +1645,7 @@ dialog.Destroy() def AddNewDivergence(self, bbox): - dialog = DivergenceCreateDialog(self.ParentWindow) + dialog = DivergenceCreateDialog(self.ParentWindow, self.Controler) dialog.SetPreviewFont(self.GetFont()) dialog.SetMinSize((bbox.width, bbox.height)) if dialog.ShowModal() == wx.ID_OK: @@ -1698,7 +1709,7 @@ #------------------------------------------------------------------------------- def EditBlockContent(self, block): - dialog = BlockPropertiesDialog(self.ParentWindow) + dialog = BlockPropertiesDialog(self.ParentWindow, self.Controler) dialog.SetPreviewFont(self.GetFont()) dialog.SetBlockList(self.Controler.GetBlockTypes(self.TagName)) dialog.SetPouNames(self.Controler.GetProjectPouNames()) @@ -1731,7 +1742,7 @@ dialog.Destroy() def EditVariableContent(self, variable): - dialog = VariablePropertiesDialog(self.ParentWindow) + dialog = VariablePropertiesDialog(self.ParentWindow, self.Controler) dialog.SetPreviewFont(self.GetFont()) dialog.SetMinVariableSize(variable.GetSize()) varlist = [] @@ -1768,7 +1779,7 @@ dialog.Destroy() def EditConnectionContent(self, connection): - dialog = ConnectionPropertiesDialog(self.ParentWindow) + dialog = ConnectionPropertiesDialog(self.ParentWindow, self.Controler) dialog.SetPreviewFont(self.GetFont()) dialog.SetMinConnectionSize(connection.GetSize()) values = {"name" : connection.GetName(), "type" : connection.GetType()} @@ -1792,7 +1803,7 @@ dialog.Destroy() def EditContactContent(self, contact): - dialog = LDElementDialog(self.ParentWindow, "contact") + dialog = LDElementDialog(self.ParentWindow, self.Controler, "contact") dialog.SetPreviewFont(self.GetFont()) varlist = [] vars = self.Controler.GetEditedElementInterfaceVars(self.TagName) @@ -1818,7 +1829,7 @@ dialog.Destroy() def EditCoilContent(self, coil): - dialog = LDElementDialog(self.ParentWindow, "coil") + dialog = LDElementDialog(self.ParentWindow, self.Controler, "coil") dialog.SetPreviewFont(self.GetFont()) varlist = [] vars = self.Controler.GetEditedElementInterfaceVars(self.TagName) @@ -1847,7 +1858,7 @@ dialog.Destroy() def EditPowerRailContent(self, powerrail): - dialog = LDPowerRailDialog(self.ParentWindow, powerrail.GetType(), len(powerrail.GetConnectors())) + dialog = LDPowerRailDialog(self.ParentWindow, self.Controler, powerrail.GetType(), len(powerrail.GetConnectors())) dialog.SetPreviewFont(self.GetFont()) dialog.SetMinSize(powerrail.GetSize()) if dialog.ShowModal() == wx.ID_OK: @@ -1868,7 +1879,7 @@ dialog.Destroy() def EditStepContent(self, step): - dialog = StepContentDialog(self.ParentWindow, step.GetInitial()) + dialog = StepContentDialog(self.ParentWindow, self.Controler, step.GetInitial()) dialog.SetPreviewFont(self.GetFont()) dialog.SetPouNames(self.Controler.GetProjectPouNames()) dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName)) @@ -1904,7 +1915,7 @@ step.Refresh(rect) def EditTransitionContent(self, transition): - dialog = TransitionContentDialog(self.ParentWindow, self.GetDrawingMode() == FREEDRAWING_MODE) + dialog = TransitionContentDialog(self.ParentWindow, self.Controler, self.GetDrawingMode() == FREEDRAWING_MODE) dialog.SetPreviewFont(self.GetFont()) dialog.SetTransitions(self.Controler.GetEditedElementTransitions(self.TagName)) dialog.SetValues({"type":transition.GetType(),"value":transition.GetCondition(), "priority":transition.GetPriority()}) @@ -2328,8 +2339,26 @@ self.Controler.AddEditedElementActionBlock(self.TagName, id) self.RefreshActionBlockModel(block) return block - - + + +#------------------------------------------------------------------------------- +# Errors showing functions +#------------------------------------------------------------------------------- + + def ClearErrors(self): + self.Errors = [] + self.RefreshView() + + def AddShownError(self, infos, start, end): + self.Errors.append((infos, start, end)) + + def ShowErrors(self): + for infos, start, end in self.Errors: + if infos[0] in ["io_variable", "block", "coil", "contact", "transition", "step", "action_block"]: + block = self.FindElementById(infos[1]) + if block is not None: + block.AddError(infos[2:], start, end) + #------------------------------------------------------------------------------- # Drawing functions #-------------------------------------------------------------------------------