示例#1
0
    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")
示例#2
0
    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")
示例#3
0
    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()
示例#4
0
    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())
示例#5
0
    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()
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
    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)
示例#9
0
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))
示例#10
0
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))
示例#11
0
 def onTrash(self):
     self.keyView.setModel(KeyFrameList())
示例#12
0
    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)