diff -r 6f72513bc074 -r e7327ea490b4 LDViewer.py --- a/LDViewer.py Wed Mar 30 16:31:18 2011 +0200 +++ b/LDViewer.py Wed Mar 30 17:52:07 2011 +0200 @@ -448,6 +448,46 @@ event.Skip() #------------------------------------------------------------------------------- +# Model adding functions from Drop Target +#------------------------------------------------------------------------------- + + def AddVariableBlock(self, x, y, scaling, var_class, var_name, var_type): + if var_type == "BOOL": + id = self.GetNewId() + if var_class == INPUT: + contact = LD_Contact(self, CONTACT_NORMAL, var_name, id) + width, height = contact.GetMinSize() + if scaling is not None: + x = round(float(x) / float(scaling[0])) * scaling[0] + y = round(float(y) / float(scaling[1])) * scaling[1] + width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0] + height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1] + contact.SetPosition(x, y) + contact.SetSize(width, height) + self.AddBlock(contact) + self.Controler.AddEditedElementContact(self.GetTagName(), id) + self.RefreshContactModel(contact) + else: + coil = LD_Coil(self, COIL_NORMAL, var_name, id) + width, height = coil.GetMinSize() + if scaling is not None: + x = round(float(x) / float(scaling[0])) * scaling[0] + y = round(float(y) / float(scaling[1])) * scaling[1] + width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0] + height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1] + coil.SetPosition(x, y) + coil.SetSize(width, height) + self.AddBlock(coil) + self.Controler.AddEditedElementCoil(self.GetTagName(), id) + self.RefreshCoilModel(coil) + self.RefreshBuffer() + self.RefreshScrollBars() + self.RefreshVisibleElements() + self.Refresh(False) + else: + Viewer.AddVariableBlock(self, x, y, scaling, var_class, var_name, var_type) + +#------------------------------------------------------------------------------- # Adding element functions #-------------------------------------------------------------------------------