def test_separate_props(self): '''Test modifying the properties of node and alias that are separate, i.e. not shared. As in, if the position of an alias is changed, that of the node should remain the same, and vice versa. ''' alias_pos = Vec2(100, 100) alias_size = Vec2(50, 50) nodei = api.add_node(self.neti, id='Hookie') aliasi = api.add_alias(self.neti, nodei, position=alias_pos, size=alias_size) new_pos = Vec2(33, 33) new_size = Vec2(66, 66) new_lockNode = True api.update_node(self.neti, nodei, position=Vec2(33, 33), size=Vec2(66, 66), lock_node=True) node = api.get_node_by_index(self.neti, nodei) alias = api.get_node_by_index(self.neti, aliasi) # alias remains the same self.assertEqual(alias_pos, alias.position) self.assertEqual(alias_size, alias.size) self.assertEqual(False, alias.lock_node) # node is updated self.assertEqual(new_pos, node.position) self.assertEqual(new_size, node.size) self.assertEqual(new_lockNode, node.lock_node)
def unhighlight(self, evt): """ Callback for the color picker control; sets the color of every node/reaction selected. """ # start group action context for undo purposes with api.group_action(): # color selected nodes #for index in api.selected_node_indices(): try: for index in self.index_list: api.update_node(api.cur_net_index(), index, fill_color=self.default_color) except: wx.MessageBox("There is no highlighted nodes", "Message", wx.OK | wx.ICON_INFORMATION)
def color_callback(self, evt): """ Get whatever cells are currently selected """ cells = self.tab2.grid_moi.GetSelectedCells() if not cells: if self.tab2.grid_moi.GetSelectionBlockTopLeft(): top_left = self.tab2.grid_moi.GetSelectionBlockTopLeft()[0] bottom_right = self.tab2.grid_moi.GetSelectionBlockBottomRight( )[0] self.printSelectedCells(top_left, bottom_right) #else: # print (self.currentlySelectedCell) else: print("no cells are selected") """ Callback for the color picker control; sets the color of every node/reaction selected. """ wxcolor = evt.GetColour() color = Color.from_rgb(wxcolor.GetRGB()) # start group action context for undo purposes with api.group_action(): # color selected nodes #for index in api.selected_node_indices(): if len(self.index_list) == 0: wx.MessageBox("Please select a row and pick a color again", "Message", wx.OK | wx.ICON_INFORMATION) try: for index in self.index_list: #api.update_node(api.cur_net_index(), index, fill_color=color, forder_color=color) api.update_node(api.cur_net_index(), index, fill_color=color) except: wx.MessageBox("Please select a row and pick a color again", "Message", wx.OK | wx.ICON_INFORMATION)
def test_update_failure(self): api.add_node(self.neti, id='Zulu') # empty ID with self.assertRaises(ValueError): api.update_node(self.neti, 0, id='') # nodes don't exist with self.assertRaises(NetIndexError): api.update_node(-1, 0, size=Vec2(50, 60)) with self.assertRaises(NodeIndexError): api.update_node(0, 2, size=Vec2(50, 60)) # out of bounds with self.assertRaises(ValueError): api.update_node(self.neti, 0, position=Vec2(-1, 0)) with self.assertRaises(ValueError): api.update_node(self.neti, 0, position=Vec2(0, -1)) csize = api.canvas_size() # in bounds api.update_node(self.neti, 0, position=csize - Vec2(100, 100)) # out of bounds with self.assertRaises(ValueError): api.update_node(self.neti, 0, position=csize - Vec2(1, 1))
def test_update_basic(self): api.add_node(self.neti, id="Eric") api.update_node(self.neti, 0, 'James') nodes = api.get_nodes(self.neti) self.assertEqual(len(nodes), 1) self.assertEqual(nodes[0].id, 'James')