444 self.Scroll(xpos, ymax) |
444 self.Scroll(xpos, ymax) |
445 elif event.ControlDown(): |
445 elif event.ControlDown(): |
446 self.Scroll(xpos, min(ypos + 1, ymax)) |
446 self.Scroll(xpos, min(ypos + 1, ymax)) |
447 else: |
447 else: |
448 event.Skip() |
448 event.Skip() |
|
449 |
|
450 #------------------------------------------------------------------------------- |
|
451 # Model adding functions from Drop Target |
|
452 #------------------------------------------------------------------------------- |
|
453 |
|
454 def AddVariableBlock(self, x, y, scaling, var_class, var_name, var_type): |
|
455 if var_type == "BOOL": |
|
456 id = self.GetNewId() |
|
457 if var_class == INPUT: |
|
458 contact = LD_Contact(self, CONTACT_NORMAL, var_name, id) |
|
459 width, height = contact.GetMinSize() |
|
460 if scaling is not None: |
|
461 x = round(float(x) / float(scaling[0])) * scaling[0] |
|
462 y = round(float(y) / float(scaling[1])) * scaling[1] |
|
463 width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0] |
|
464 height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1] |
|
465 contact.SetPosition(x, y) |
|
466 contact.SetSize(width, height) |
|
467 self.AddBlock(contact) |
|
468 self.Controler.AddEditedElementContact(self.GetTagName(), id) |
|
469 self.RefreshContactModel(contact) |
|
470 else: |
|
471 coil = LD_Coil(self, COIL_NORMAL, var_name, id) |
|
472 width, height = coil.GetMinSize() |
|
473 if scaling is not None: |
|
474 x = round(float(x) / float(scaling[0])) * scaling[0] |
|
475 y = round(float(y) / float(scaling[1])) * scaling[1] |
|
476 width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0] |
|
477 height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1] |
|
478 coil.SetPosition(x, y) |
|
479 coil.SetSize(width, height) |
|
480 self.AddBlock(coil) |
|
481 self.Controler.AddEditedElementCoil(self.GetTagName(), id) |
|
482 self.RefreshCoilModel(coil) |
|
483 self.RefreshBuffer() |
|
484 self.RefreshScrollBars() |
|
485 self.RefreshVisibleElements() |
|
486 self.Refresh(False) |
|
487 else: |
|
488 Viewer.AddVariableBlock(self, x, y, scaling, var_class, var_name, var_type) |
449 |
489 |
450 #------------------------------------------------------------------------------- |
490 #------------------------------------------------------------------------------- |
451 # Adding element functions |
491 # Adding element functions |
452 #------------------------------------------------------------------------------- |
492 #------------------------------------------------------------------------------- |
453 |
493 |