def __init__(self): super(MainWindow, self).__init__() self.resize(500, 40) self.setWindowTitle("Key Frame View") self.keyPanel = KeyFramePanel(None) dataModel = DataModel(dataContainer=DemoData(50), prefetchSize=0) transModel = TransformModel() transModel.setModel(dataModel) transModel.setValueScale(0, 200) dataModel.setPos(2) self.keyPanel.connect_to_transform(transModel) k = KeyFrameList() k.addItem(KeyFrame(0.)) k.addItem(KeyFrame(1.)) self.keyPanel.setModel(k) self.setCentralWidget(self.keyPanel) self.setStyleSheet("background-color:black;color:white")
def __init__(self): super(MainWindow,self).__init__() self.resize(500, 40) self.setWindowTitle("Key Frame View") self.keyPanel = KeyFramePanel(None) dataModel = DataModel(dataContainer = DemoData(50),prefetchSize = 0) transModel = TransformModel() transModel.setModel(dataModel) transModel.setValueScale(0,200) dataModel.setPos(2) self.keyPanel.connect_to_transform(transModel) k = KeyFrameList() k.addItem(KeyFrame(0.)) k.addItem(KeyFrame(1.)) self.keyPanel.setModel(k) self.setCentralWidget(self.keyPanel) self.setStyleSheet("background-color:black;color:white")
def dataModelChanged(self): logger.debug("data Model changed") dataModel = self.glWidget.dataModel dataModel._dataSourceChanged.connect(self.dataSourceChanged) dataModel._dataPosChanged.connect(self.sliderTime.setValue) self.sliderTime.valueChanged.connect(self.transform.setPos) kvList = KeyFrameList() kvList.addItem(KeyFrame(0.)) kvList.addItem(KeyFrame(1.)) self.keyPanel.connect_to_transform(self.transform) self.keyPanel.setModel(kvList) self.dataSourceChanged()
def __init__(self): super(KeyListView, self).__init__() self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setCacheMode(QGraphicsView.CacheBackground) self.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate) self.setRenderHint(QPainter.Antialiasing) self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.setResizeAnchor(QGraphicsView.AnchorViewCenter) self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.scene = KeyFrameScene(self) self.setMinimumHeight(30) self.setMaximumHeight(30) self.scene.setItemIndexMethod(QGraphicsScene.NoIndex) self.scene.setSceneRect(0, -KeyFrameScene.HEIGHT // 2, KeyFrameScene.WIDTH, KeyFrameScene.HEIGHT) self.setScene(self.scene) # self.scale(1,.1) # self.setMinimumSize(300,20) self.setWindowTitle("KeyFrameView") self.zoom = 1. self.relativeAspect = 1. self.isListening = True self.connect_to_transform(None) self.setModel(KeyFrameList())
def setModel(self, keyList=KeyFrameList()): logger.debug("setModel: %s", keyList) self.keyList = keyList self.resetScene() # for it in self.scene.items(): # it.updateTransformData() self.keyList._modelChanged.connect(self.modelChanged)
def load_from_JSON(self, fName): with open(fName, "r") as f: try: k = KeyFrameList._from_JSON(f.read()) self.setModel(k) except Exception as e: print(e) print("not a valid keyframe json file: %s" % fName)
def load_from_JSON(self,fName): with open(fName,"r") as f: try: k = KeyFrameList._from_JSON(f.read()) self.setModel(k) except Exception as e: print(e) print("not a valid keyframe json file: %s"%fName)
def test_keyframes(): k = KeyFrameList() k.addItem(KeyFrame(0, TransformData())) k.addItem(KeyFrame(1, TransformData(zoom=.0, quatRot=Quaternion(.71, .71, 0, 0), bounds=[0]*6))) print("interpolating.....") for t in np.linspace(0,1.,10): print(k.getTransform(t))
def test_json(): k = KeyFrameList() k.addItem(KeyFrame(0, TransformData())) k.addItem(KeyFrame(1, TransformData(zoom=.0, quatRot=Quaternion(.71, .71, 0, 0), bounds=[0]*6))) s = k._to_JSON() print(s) k2 = KeyFrameList._from_JSON(s) print(k2.getTransform(.1))
def onTrash(self): self.keyView.setModel(KeyFrameList())
def setModel(self, keyList=None): if not keyList: keyList = KeyFrameList() logger.debug("keyPanel.setModel: keyList = %s\n" % keyList) self.keyView.setModel(keyList)
[email protected] """ from __future__ import print_function, unicode_literals, absolute_import, division import numpy as np from spimagine.models.keyframe_model import KeyFrameList, KeyFrame, TransformData from spimagine import Quaternion import matplotlib.pyplot as plt if __name__ == '__main__': elast = 2 k = KeyFrameList() k.addItem(KeyFrame(0, TransformData(zoom = 1.),interp_elasticity=elast)) k.addItem(KeyFrame(.5, TransformData(zoom=.2, quatRot=Quaternion(.71, .71, 0, 0), bounds=[0] * 6),interp_elasticity=elast)) k.addItem(KeyFrame(1, TransformData(zoom=1., quatRot=Quaternion(.71, .71, 0, 0), bounds=[0] * 6),interp_elasticity=elast)) ts = np.linspace(0,1,100) trans = tuple(k.getTransform(t) for t in ts) zooms = np.array([tran.zoom for tran in trans]) plt.figure(num=1) plt.clf() plt.plot(ts, zooms)