Пример #1
0
    def testAddingAndRemoving( self ):
        lsm = LayerStackModel()
        self.assertEqual(len(lsm), 0)

        lsm.append(self.l1)
        self.assertEqual(len(lsm), 1)
        self.assertEqual(lsm[0].name, self.l1.name )

        lsm.append(self.l2)
        self.assertEqual(len(lsm), 2)
        self.assertEqual(lsm[0].name, self.l2.name )
        self.assertEqual(lsm[1].name, self.l1.name )

        lsm.insert(1, self.l3)
        self.assertEqual(len(lsm), 3)
        self.assertEqual(lsm[0].name, self.l2.name )
        self.assertEqual(lsm[1].name, self.l3.name )
        self.assertEqual(lsm[2].name, self.l1.name )

        lsm.selectRow( 0 )
        lsm.deleteSelected()
        self.assertEqual(len(lsm), 2)
        self.assertEqual(lsm[0].name, self.l3.name )
        self.assertEqual(lsm[1].name, self.l1.name )

        lsm.clear()
        self.assertEqual(len(lsm), 0)
Пример #2
0
    def testAddingAndRemoving(self):
        lsm = LayerStackModel()
        self.assertEqual(len(lsm), 0)

        lsm.append(self.l1)
        self.assertEqual(len(lsm), 1)
        self.assertEqual(lsm[0].name, self.l1.name)

        lsm.append(self.l2)
        self.assertEqual(len(lsm), 2)
        self.assertEqual(lsm[0].name, self.l2.name)
        self.assertEqual(lsm[1].name, self.l1.name)

        lsm.insert(1, self.l3)
        self.assertEqual(len(lsm), 3)
        self.assertEqual(lsm[0].name, self.l2.name)
        self.assertEqual(lsm[1].name, self.l3.name)
        self.assertEqual(lsm[2].name, self.l1.name)

        lsm.selectRow(0)
        lsm.deleteSelected()
        self.assertEqual(len(lsm), 2)
        self.assertEqual(lsm[0].name, self.l3.name)
        self.assertEqual(lsm[1].name, self.l1.name)

        lsm.clear()
        self.assertEqual(len(lsm), 0)
Пример #3
0
    def testAddingAndRemovingLayers( self ):
        lsm = LayerStackModel()
        sims = StackedImageSources( lsm )
        ims_view = sims.viewImageSources()
        self.assertEqual(len(lsm), 0)
        self.assertEqual(len(sims), 0)
        self.assertEqual(len(ims_view), 0)

        lsm.append(self.layer1)
        lsm.append(self.layer2)
        sims.register(self.layer1, self.ims1)
        sims.register(self.layer2, self.ims2)
        self.assertEqual(sims.isRegistered(self.layer1), True)
        self.assertEqual(sims.isRegistered(self.layer2), True)
        self.assertEqual(len(lsm), 2)
        self.assertEqual(len(sims), 2)
        self.assertEqual(len(ims_view), 2)
        self.assertEqual(ims_view[0], self.ims2)
        self.assertEqual(ims_view[1], self.ims1)

        lsm.append(self.layer3)
        self.assertEqual(len(lsm), 3)
        self.assertEqual(len(sims), 2)
        self.assertEqual(len(ims_view), 2)
        self.assertEqual(ims_view[0], self.ims2)
        self.assertEqual(ims_view[1], self.ims1)
        self.assertEqual(sims.isRegistered(self.layer1), True)
        self.assertEqual(sims.isRegistered(self.layer2), True)

        lsm.selectRow(1) # layer2
        lsm.deleteSelected()
        self.assertEqual(len(lsm), 2)
        self.assertEqual(len(sims), 1)
        self.assertEqual(len(ims_view), 1)
        self.assertEqual(ims_view[0], self.ims1)
        self.assertEqual(sims.isRegistered(self.layer1), True)
        self.assertEqual(sims.isRegistered(self.layer2), False)

        lsm.selectRow(0) # layer3
        lsm.deleteSelected()
        self.assertEqual(len(lsm), 1)
        self.assertEqual(len(sims), 1)
        self.assertEqual(len(ims_view), 1)
        self.assertEqual(ims_view[0], self.ims1)
        self.assertEqual(sims.isRegistered(self.layer1), True)
        self.assertEqual(sims.isRegistered(self.layer2), False)

        sims.deregister(self.layer1)
        self.assertEqual(len(lsm), 1)
        self.assertEqual(len(sims), 0)
        self.assertEqual(len(ims_view), 0)
        self.assertEqual(sims.isRegistered(self.layer1), False)
        self.assertEqual(sims.isRegistered(self.layer2), False)
Пример #4
0
    def testAddingAndRemovingLayers(self):
        lsm = LayerStackModel()
        sims = StackedImageSources(lsm)
        ims_view = sims.viewImageSources()
        self.assertEqual(len(lsm), 0)
        self.assertEqual(len(sims), 0)
        self.assertEqual(len(ims_view), 0)

        lsm.append(self.layer1)
        lsm.append(self.layer2)
        sims.register(self.layer1, self.ims1)
        sims.register(self.layer2, self.ims2)
        self.assertEqual(sims.isRegistered(self.layer1), True)
        self.assertEqual(sims.isRegistered(self.layer2), True)
        self.assertEqual(len(lsm), 2)
        self.assertEqual(len(sims), 2)
        self.assertEqual(len(ims_view), 2)
        self.assertEqual(ims_view[0], self.ims2)
        self.assertEqual(ims_view[1], self.ims1)

        lsm.append(self.layer3)
        self.assertEqual(len(lsm), 3)
        self.assertEqual(len(sims), 2)
        self.assertEqual(len(ims_view), 2)
        self.assertEqual(ims_view[0], self.ims2)
        self.assertEqual(ims_view[1], self.ims1)
        self.assertEqual(sims.isRegistered(self.layer1), True)
        self.assertEqual(sims.isRegistered(self.layer2), True)

        lsm.selectRow(1)  # layer2
        lsm.deleteSelected()
        self.assertEqual(len(lsm), 2)
        self.assertEqual(len(sims), 1)
        self.assertEqual(len(ims_view), 1)
        self.assertEqual(ims_view[0], self.ims1)
        self.assertEqual(sims.isRegistered(self.layer1), True)
        self.assertEqual(sims.isRegistered(self.layer2), False)

        lsm.selectRow(0)  # layer3
        lsm.deleteSelected()
        self.assertEqual(len(lsm), 1)
        self.assertEqual(len(sims), 1)
        self.assertEqual(len(ims_view), 1)
        self.assertEqual(ims_view[0], self.ims1)
        self.assertEqual(sims.isRegistered(self.layer1), True)
        self.assertEqual(sims.isRegistered(self.layer2), False)

        sims.deregister(self.layer1)
        self.assertEqual(len(lsm), 1)
        self.assertEqual(len(sims), 0)
        self.assertEqual(len(ims_view), 0)
        self.assertEqual(sims.isRegistered(self.layer1), False)
        self.assertEqual(sims.isRegistered(self.layer2), False)
Пример #5
0
    def testMovingLayers( self ):
        lsm = LayerStackModel()
        lsm.append(self.l1)
        lsm.append(self.l2)
        lsm.append(self.l3)
        lsm.selectRow(1)
        self.assertEqual(len(lsm),3)
        self.assertEqual(lsm[0].name, self.l3.name )
        self.assertEqual(lsm[1].name, self.l2.name )
        self.assertEqual(lsm[2].name, self.l1.name )
        self.assertEqual(lsm.selectedRow(), 1)

        lsm.moveSelectedDown()
        self.assertEqual(lsm.selectedRow(), 2)
        self.assertEqual(len(lsm),3)
        self.assertEqual(lsm[0].name, self.l3.name )
        self.assertEqual(lsm[1].name, self.l1.name )
        self.assertEqual(lsm[2].name, self.l2.name )

        lsm.selectRow(1)
        lsm.moveSelectedUp()
        self.assertEqual(lsm.selectedRow(), 0)
        self.assertEqual(len(lsm),3)
        self.assertEqual(lsm[0].name, self.l1.name )
        self.assertEqual(lsm[1].name, self.l3.name )
        self.assertEqual(lsm[2].name, self.l2.name )


        # moving topmost layer up => nothing should happen
        lsm.selectRow(0)
        self.assertEqual(lsm.selectedRow(), 0)
        self.assertEqual(lsm[0].name, self.l1.name )
        self.assertEqual(lsm[1].name, self.l3.name )
        self.assertEqual(lsm[2].name, self.l2.name )
        lsm.moveSelectedUp()
        self.assertEqual(lsm.selectedRow(), 0)
        self.assertEqual(lsm[0].name, self.l1.name )
        self.assertEqual(lsm[1].name, self.l3.name )
        self.assertEqual(lsm[2].name, self.l2.name )

        # moving bottommost layer down => nothing should happen
        lsm.selectRow(2)
        self.assertEqual(lsm.selectedRow(), 2)
        self.assertEqual(lsm[0].name, self.l1.name )
        self.assertEqual(lsm[1].name, self.l3.name )
        self.assertEqual(lsm[2].name, self.l2.name )
        lsm.moveSelectedDown()
        self.assertEqual(lsm.selectedRow(), 2)
        self.assertEqual(lsm[0].name, self.l1.name )
        self.assertEqual(lsm[1].name, self.l3.name )
        self.assertEqual(lsm[2].name, self.l2.name )
Пример #6
0
    def testMovingLayers(self):
        lsm = LayerStackModel()
        lsm.append(self.l1)
        lsm.append(self.l2)
        lsm.append(self.l3)
        lsm.selectRow(1)
        self.assertEqual(len(lsm), 3)
        self.assertEqual(lsm[0].name, self.l3.name)
        self.assertEqual(lsm[1].name, self.l2.name)
        self.assertEqual(lsm[2].name, self.l1.name)
        self.assertEqual(lsm.selectedRow(), 1)

        lsm.moveSelectedDown()
        self.assertEqual(lsm.selectedRow(), 2)
        self.assertEqual(len(lsm), 3)
        self.assertEqual(lsm[0].name, self.l3.name)
        self.assertEqual(lsm[1].name, self.l1.name)
        self.assertEqual(lsm[2].name, self.l2.name)

        lsm.selectRow(1)
        lsm.moveSelectedUp()
        self.assertEqual(lsm.selectedRow(), 0)
        self.assertEqual(len(lsm), 3)
        self.assertEqual(lsm[0].name, self.l1.name)
        self.assertEqual(lsm[1].name, self.l3.name)
        self.assertEqual(lsm[2].name, self.l2.name)

        # moving topmost layer up => nothing should happen
        lsm.selectRow(0)
        self.assertEqual(lsm.selectedRow(), 0)
        self.assertEqual(lsm[0].name, self.l1.name)
        self.assertEqual(lsm[1].name, self.l3.name)
        self.assertEqual(lsm[2].name, self.l2.name)
        lsm.moveSelectedUp()
        self.assertEqual(lsm.selectedRow(), 0)
        self.assertEqual(lsm[0].name, self.l1.name)
        self.assertEqual(lsm[1].name, self.l3.name)
        self.assertEqual(lsm[2].name, self.l2.name)

        # moving bottommost layer down => nothing should happen
        lsm.selectRow(2)
        self.assertEqual(lsm.selectedRow(), 2)
        self.assertEqual(lsm[0].name, self.l1.name)
        self.assertEqual(lsm[1].name, self.l3.name)
        self.assertEqual(lsm[2].name, self.l2.name)
        lsm.moveSelectedDown()
        self.assertEqual(lsm.selectedRow(), 2)
        self.assertEqual(lsm[0].name, self.l1.name)
        self.assertEqual(lsm[1].name, self.l3.name)
        self.assertEqual(lsm[2].name, self.l2.name)