Ejemplo n.º 1
0
    def test_layout(self):
        self.c.edit()
        self.checkState(sm.EDITABLE)

        new_layout = Table(self.c.layout.meta)
        new_layout.name = ["partchild1", "partchild2", "partchild3"]
        new_layout.mri = ["part1", "part2", "part3"]
        new_layout.x = [10, 11, 12]
        new_layout.y = [20, 21, 22]
        new_layout.visible = [True, True, True]
        self.b.layout = new_layout
        self.assertEqual(self.c.parts['partchild1'].x, 10)
        self.assertEqual(self.c.parts['partchild1'].y, 20)
        self.assertEqual(self.c.parts['partchild1'].visible, True)
        self.assertEqual(self.c.parts['partchild2'].x, 11)
        self.assertEqual(self.c.parts['partchild2'].y, 21)
        self.assertEqual(self.c.parts['partchild2'].visible, True)
        self.assertEqual(self.c.parts['partchild3'].x, 12)
        self.assertEqual(self.c.parts['partchild3'].y, 22)
        self.assertEqual(self.c.parts['partchild3'].visible, True)

        new_layout.visible = [True, False, True]
        self.b.layout = new_layout
        self.assertEqual(self.c.parts['partchild1'].visible, True)
        self.assertEqual(self.c.parts['partchild2'].visible, False)
        self.assertEqual(self.c.parts['partchild3'].visible, True)
Ejemplo n.º 2
0
    def test_layout(self):
        b = self.p.block_view("mainBlock")

        new_layout = Table(self.c.layout.meta)
        new_layout.name = ["partchild1", "partchild2", "partchild3"]
        new_layout.mri = ["part1", "part2", "part3"]
        new_layout.x = [10, 11, 12]
        new_layout.y = [20, 21, 22]
        new_layout.visible = [True, True, True]
        b.layout.put_value(new_layout)
        assert self.c.parts['partchild1'].x == 10
        assert self.c.parts['partchild1'].y == 20
        assert self.c.parts['partchild1'].visible == True
        assert self.c.parts['partchild2'].x == 11
        assert self.c.parts['partchild2'].y == 21
        assert self.c.parts['partchild2'].visible == True
        assert self.c.parts['partchild3'].x == 12
        assert self.c.parts['partchild3'].y == 22
        assert self.c.parts['partchild3'].visible == True

        new_layout.visible = [True, False, True]
        b.layout.put_value(new_layout)
        assert self.c.parts['partchild1'].visible == True
        assert self.c.parts['partchild2'].visible == False
        assert self.c.parts['partchild3'].visible == True
    def test_set_and_load_layout(self):
        self.c.edit()
        self.checkState(self.sm.EDITABLE, child=False)

        new_layout = Table(self.c.layout.meta)
        new_layout.name = ["part2"]
        new_layout.mri = ["P45-MRI"]
        new_layout.x = [10]
        new_layout.y = [20]
        new_layout.visible = [True]
        self.b.layout = new_layout
        self.assertEqual(self.c.parts["part2"].x, 10)
        self.assertEqual(self.c.parts["part2"].y, 20)
        self.assertEqual(self.c.parts["part2"].visible, True)

        # save the layout, modify and restore it
        params = {"layoutName": "testSaveLayout"}
        params = ManagerController.save.MethodMeta.prepare_input_map(**params)
        self.c.save(params)

        self.c.edit()
        new_layout.x = [30]
        self.b.layout = new_layout
        self.assertEqual(self.c.parts["part2"].x, 30)
        self.b.layoutName = "testSaveLayout"
        self.assertEqual(self.c.parts["part2"].x, 10)
Ejemplo n.º 4
0
    def test_layout(self):
        self.c.edit()
        self.checkState(sm.EDITABLE)

        new_layout = Table(self.c.layout.meta)
        new_layout.name = ["partchild1", "partchild2", "partchild3"]
        new_layout.mri = ["part1", "part2", "part3"]
        new_layout.x = [10, 11, 12]
        new_layout.y = [20, 21, 22]
        new_layout.visible = [True, True, True]
        self.b.layout = new_layout
        self.assertEqual(self.c.parts['partchild1'].x, 10)
        self.assertEqual(self.c.parts['partchild1'].y, 20)
        self.assertEqual(self.c.parts['partchild1'].visible, True)
        self.assertEqual(self.c.parts['partchild2'].x, 11)
        self.assertEqual(self.c.parts['partchild2'].y, 21)
        self.assertEqual(self.c.parts['partchild2'].visible, True)
        self.assertEqual(self.c.parts['partchild3'].x, 12)
        self.assertEqual(self.c.parts['partchild3'].y, 22)
        self.assertEqual(self.c.parts['partchild3'].visible, True)

        new_layout.visible = [True, False, True]
        self.b.layout= new_layout
        self.assertEqual(self.c.parts['partchild1'].visible, True)
        self.assertEqual(self.c.parts['partchild2'].visible, False)
        self.assertEqual(self.c.parts['partchild3'].visible, True)
Ejemplo n.º 5
0
 def move_child_block(self):
     new_layout = Table(self.c.layout.meta)
     new_layout.name = ["part2"]
     new_layout.mri = ["anything"]
     new_layout.x = [10]
     new_layout.y = [20]
     new_layout.visible = [True]
     self.c.set_layout(new_layout)
Ejemplo n.º 6
0
 def move_child_block(self):
     self.assertEqual(self.b.layout.x, [0])
     new_layout = Table(self.c.layout.meta)
     new_layout.name = ["part2"]
     new_layout.mri = ["P45-MRI"]
     new_layout.x = [10]
     new_layout.y = [20]
     new_layout.visible = [True]
     self.b.layout = new_layout
     self.assertEqual(self.b.layout.x, [10])
Ejemplo n.º 7
0
    def test_set_and_load_layout(self):
        new_layout = Table(self.c.layout.meta)
        new_layout.name = ["part2"]
        new_layout.mri = ["anything"]
        new_layout.x = [10]
        new_layout.y = [20]
        new_layout.visible = [False]
        self.c.set_layout(new_layout)
        assert self.c.parts['part2'].x == 10
        assert self.c.parts['part2'].y == 20
        assert self.c.parts['part2'].visible == False
        assert self.c.modified.value == True
        assert self.c.modified.alarm.message == "layout changed"

        # save the layout, modify and restore it
        call_with_params(self.c.save, design='testSaveLayout')
        assert self.c.modified.value == False
        self.check_expected_save(10.0, 20.0, "false")
        self.c.parts['part2'].x = 30
        self.c.set_design('testSaveLayout')
        assert self.c.parts['part2'].x == 10
Ejemplo n.º 8
0
 def set_layout(self, value):
     """Set the layout table value. Called on attribute put"""
     # If it isn't a table, make it one
     if not isinstance(value, Table):
         value = Table(self.layout.meta, value)
     # Can't do this with changes_squashed as it will call update_modified
     # from another thread and deadlock
     part_info = self.run_hook(
         self.Layout, self.create_part_contexts(only_visible=False),
         self.port_info, value)
     with self.changes_squashed:
         layout_table = Table(self.layout.meta)
         layout_parts = LayoutInfo.filter_parts(part_info)
         for name, layout_infos in layout_parts.items():
             assert len(layout_infos) == 1, \
                 "%s returned more than 1 layout infos" % name
             layout_parts[name] = layout_infos[0]
         layout_table.name = list(layout_parts)
         layout_table.mri = [i.mri for i in layout_parts.values()]
         layout_table.x = [i.x for i in layout_parts.values()]
         layout_table.y = [i.y for i in layout_parts.values()]
         layout_table.visible = [i.visible for i in layout_parts.values()]
         try:
             np.testing.assert_equal(
                 layout_table.visible, self.layout.value.visible)
         except AssertionError:
             visibility_changed = True
         else:
             visibility_changed = False
         self.layout.set_value(layout_table)
         if self.saved_visibility is None:
             # First write of table, set layout and exports saves
             self.saved_visibility = layout_table.visible
             self.saved_exports = self.exports.value.to_dict()
         if visibility_changed:
             self.update_modified()
             self.update_exportable()
             # Part visibility changed, might have attributes or methods
             # that we need to hide or show
             self._update_block_endpoints()
Ejemplo n.º 9
0
    def test_set_and_load_layout(self):
        self.c.edit()
        self.checkState(self.sm.EDITABLE, child=False)

        new_layout = Table(self.c.layout.meta)
        new_layout.name = ["part2"]
        new_layout.mri = ["P45-MRI"]
        new_layout.x = [10]
        new_layout.y = [20]
        new_layout.visible = [True]
        self.b.layout = new_layout
        self.assertEqual(self.c.parts['part2'].x, 10)
        self.assertEqual(self.c.parts['part2'].y, 20)
        self.assertEqual(self.c.parts['part2'].visible, True)

        # save the layout, modify and restore it
        params = {'layoutName': 'testSaveLayout'}
        params = ManagerController.save.MethodMeta.prepare_input_map(**params)
        self.c.save(params)
        self.check_expected_save(10.0, 20.0, "true")

        self.c.parts['part2'].x = 30
        self.b.layoutName = 'testSaveLayout'
        self.assertEqual(self.c.parts['part2'].x, 10)