Exemplo n.º 1
0
    def test_repaint_after_visible_change(self):
        self.model = LayerStackModel()

        self.o1 = Layer([])
        self.o1.name = "Fancy Layer"
        self.o1.opacity = 0.5
        self.model.append(self.o1)

        self.o2 = Layer([])
        self.o2.name = "Some other Layer"
        self.o2.opacity = 0.25
        self.model.append(self.o2)

        self.view = LayerWidget(None, self.model)
        self.view.show()
        self.view.updateGeometry()

        self.w = QWidget()
        self.lh = QHBoxLayout(self.w)
        self.lh.addWidget(self.view)
        self.w.setGeometry(100, 100, 300, 300)
        self.w.show()
        self.w.raise_()

        # Run the test within the GUI event loop
        QTimer.singleShot(500, self.impl)
        self.app.exec_()

        # Were there errors?
        assert not TestLayerWidget.errors, "There were GUI errors/failures.  See above."
Exemplo n.º 2
0
 def setUp(self):
     self.l1 = Layer([])
     self.l1.name = "l1"
     self.l2 = Layer([])
     self.l2.name = "l2"
     self.l3 = Layer([])
     self.l3.name = "l3"
Exemplo n.º 3
0
 def setUp(self):
     self.l1 = Layer([])
     self.l1.name = 'l1'
     self.l2 = Layer([])
     self.l2.name = 'l2'
     self.l3 = Layer([])
     self.l3.name = 'l3'
Exemplo n.º 4
0
 def insertRows(self, row, count, parent=QModelIndex()):
     '''Insert empty rows in the stack. 
     
     DO NOT USE THIS METHOD TO INSERT NEW LAYERS!
     Always use the insert() or append() method.
     
     '''
     if parent.isValid():
         return False
     oldRowCount = self.rowCount()
     #for some reason, row can be negative!
     beginRow = max(0, row)
     endRow = min(beginRow + count - 1, len(self._layerStack))
     self.beginInsertRows(parent, beginRow, endRow)
     while (beginRow <= endRow):
         self._layerStack.insert(row, Layer(datasources=[]))
         beginRow += 1
     self.endInsertRows()
     assert self.rowCount(
     ) == oldRowCount + 1, "oldRowCount = %d, self.rowCount() = %d" % (
         oldRowCount, self.rowCount())
     return True
Exemplo n.º 5
0
 def addRandomLayer():
     o = Layer()
     o.name = "Layer %d" % (model.rowCount()+1)
     o.opacity = numpy.random.rand()
     o.visible = bool(numpy.random.randint(0,2))
     model.append(o)
Exemplo n.º 6
0
if __name__ == "__main__":
    #make the program quit on Ctrl+C
    import signal
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    import sys, numpy

    from PyQt4.QtGui import QApplication, QPushButton, QHBoxLayout, QVBoxLayout
    from volumina.pixelpipeline.datasources import ArraySource

    app = QApplication(sys.argv)

    model = LayerStackModel()

    o1 = Layer()
    o1.name = "Fancy Layer"
    o1.opacity = 0.5
    model.append(o1)

    o2 = Layer()
    o2.name = "Some other Layer"
    o2.opacity = 0.25
    model.append(o2)

    o3 = Layer()
    o3.name = "Invisible Layer"
    o3.opacity = 0.15
    o3.visible = False
    model.append(o3)
Exemplo n.º 7
0
 def addRandomLayer():
     o = Layer([ConstantSource()])
     o.name = "Layer %d" % (model.rowCount() + 1)
     o.opacity = numpy.random.rand()
     o.visible = bool(numpy.random.randint(0, 2))
     model.append(o)
Exemplo n.º 8
0
if __name__ == "__main__":
    # make the program quit on Ctrl+C
    import signal

    signal.signal(signal.SIGINT, signal.SIG_DFL)

    import sys, numpy

    from PyQt5.QtWidgets import QPushButton, QHBoxLayout, QVBoxLayout
    from volumina.pixelpipeline.datasources import ArraySource, ConstantSource

    app = QApplication(sys.argv)

    model = LayerStackModel()

    o1 = Layer([ConstantSource()])
    o1.name = "Fancy Layer"
    o1.opacity = 0.5
    model.append(o1)

    o2 = Layer([ConstantSource()])
    o2.name = "Some other Layer"
    o2.opacity = 0.25
    o2.numberOfChannels = 3
    model.append(o2)

    o3 = Layer([ConstantSource()])
    o3.name = "Invisible Layer"
    o3.opacity = 0.15
    o3.visible = False
    model.append(o3)