def applyTransforms(self): """ Use the objects translation/rotation/scaling values to generate a new transformation Matrix if changes have happened. """ # generate new transformation matrix if needed if self.oldscaling != self.scaling or self.drotation != Vector() or self.oldpos != Vector(*self.pos): self.transform = Transform() self.linkTransform = Transform() drotationTransform = Transform() drotationTransform.applyRotation(self.drotation) self.transform.applyScaling(self.scaling) self.linkTransform.applyScaling(self.scaling) self.transform = self.transform*self.oldrotTransform*drotationTransform self.oldrotTransform = self.oldrotTransform*drotationTransform self.transform.applyTranslation(Vector(*self.pos)) self.linkTransform.applyTranslation(Vector(*self.pos)) if self.oldscaling != self.scaling: self.oldscaling = self.scaling.copy() self.drotation = Vector() if self.oldpos != Vector(*self.pos): self.oldpos = Vector(*self.pos) # send new transform to display service transform_update = { "TRANSFORM_UPDATE": True, "objectid": id(self), "transform": self.transform } return transform_update else: return None
def __init__(self, position=(-1, 0, -10), ID='', **argd): """x.__init__(...) initializes x; see x.__class__.__doc__ for signature""" super(Particle3D, self).__init__(position=position, ID=ID) self.pos = position self.initSize = Vector(*argd.get("size", (0, 0, 0))) self.selected = False self.bgcolour = argd.get("bgcolour", (230, 230, 230)) self.fgcolour = argd.get("fgcolour", (0, 0, 0)) self.sidecolour = argd.get("sidecolour", (200, 200, 244)) self.bgcolourselected = argd.get("bgcolourselected", (0, 0, 0)) self.fgcolourselected = argd.get("fgcolourselected", (244, 244, 244)) self.sidecolourselected = argd.get("sidecolourselected", (0, 0, 100)) self.margin = argd.get("margin", 8) self.fontsize = argd.get("fontsize", 50) self.pixelscaling = argd.get("pixelscaling", 100) self.thickness = argd.get("thickness", 0.3) # For picture texture self.image = argd.get("image", None) # For remote picture self.imageIO = None name = argd.get("name", "NoName") self.set_label(name) # For rotation and scaling self.drotation = Vector() self.scaling = Vector(*argd.get("scaling", (1, 1, 1))) # For detection of changes self.oldpos = self.initialpos = Vector() self.oldscaling = Vector() # For transformation matrix multiplication # Store all transformations self.transform = Transform() # Specially store link transformations because link doesn't do rotation and scaling self.linkTransform = Transform() # Store all previous transformations to be multiplied with the current one self.oldrotTransform = Transform() # For redraw detection self.needRedraw = True # For drag handling self.oldpoint = None
def __init__(self, position = (-1,0,-10), ID='', **argd): super(Particle3D, self).__init__(position=position, ID = ID) self.pos = position self.initSize = Vector(*argd.get("size", (0,0,0))) self.backgroundColourWhenUnselected = self.backgroundColour = argd.get("bgcolour", (230,230,230)) self.foregroundColourWhenUnselected = self.foregroundColour = argd.get("fgcolour", (0,0,0)) self.sideColourWhenUnselected = self.sideColour = argd.get("sidecolour", (200,200,244)) self.backgroundColourWhenSelected = argd.get("bgcolourselected", (0,0,0)) self.foregroundColourWhenSelected = argd.get("fgcolourselected", (244,244,244)) self.sideColourWhenSelected = argd.get("sidecolourselected", (200,200,244)) self.margin = argd.get("margin", 8) self.fontsize = argd.get("fontsize", 50) self.pixelscaling = argd.get("pixelscaling", 100) self.thickness = argd.get("thickness", 0.3) # For picture texture self.pic = argd.get("image", None) name = argd.get("name","NoName") self.set_label(name) # For rotation and scaling self.drotation = Vector() self.scaling = Vector( *argd.get("scaling", (1,1,1) ) ) # For detection of changes self.oldpos = self.initialpos = Vector() self.oldscaling = Vector() # For transformation matrix multiplication self.transform = Transform() self.linkTransform = Transform() self.oldrotTransform = Transform() # For redraw detection self.needRedraw = True # For drag handling self.oldpoint = None