def load_from_file(self, fname): '''Load the chimera architecture from a formatted file''' try: M, N, adj = load_chimera_file(fname) except IOError: print('Failed to load given ffile...') return self.build_tile_grid(M, N, adj)
def load_chimera(self, fname): '''Load and set the chimera structure''' try: M, N, adj = load_chimera_file(fname) except IOError: return self.M = M self.N = N self.adj = {linear_to_tuple(k, M, N):\ [linear_to_tuple(a, M, N) for a in adj[k]] for k in adj} # forget old grid layout for tile in self.canvas.tiles: self.canvas.tiles[tile].setParent(None) self.canvas.tiles = {} while self.layout.count(): item = self.layout.takeAt(0) item.widget().deleteLater() # resize canvas width = N * TILE_SIZE height = M * TILE_SIZE self.canvas.w = width self.canvas.h = height self.canvas.scaling = 1. self.canvas.setGeometry(0, 0, width, height) # set up tiles and default nodes for m in range(M): for n in range(N): tile = TileWidget(m, n, parent=self.canvas) tile.set_nodes(self.adj) self.layout.addWidget(tile, m, n) self.canvas.tiles[(m, n)] = tile tile.show() self.canvas.update()
def load_chimera(self, fname): '''Load and set the chimera structure''' try: M, N, adj = load_chimera_file(fname) except IOError: return self.M = M self.N = N self.adj = {linear_to_tuple(k, M, N):\ [linear_to_tuple(a, M, N) for a in adj[k]] for k in adj} # forget old grid layout for tile in self.canvas.tiles: self.canvas.tiles[tile].setParent(None) self.canvas.tiles = {} while self.layout.count(): item = self.layout.takeAt(0) item.widget().deleteLater() # resize canvas width = N*TILE_SIZE height = M*TILE_SIZE self.canvas.w = width self.canvas.h = height self.canvas.scaling = 1. self.canvas.setGeometry(0, 0, width, height) # set up tiles and default nodes for m in range(M): for n in range(N): tile = TileWidget(m, n, parent=self.canvas) tile.set_nodes(self.adj) self.layout.addWidget(tile, m, n) self.canvas.tiles[(m, n)] = tile tile.show() self.canvas.update()
def updateChimera(self, filename): '''Process a chimera specification file and update the widget''' try: M, N, adj = load_chimera_file(filename) except IOError: print('Failed to load given file...') return # forget old grid layout for tile in self.tiles: self.tiles[tile].setParent(None) self.tiles = {} while self.layout.count(): item = self.layout.takeAt(0) item.widget().deleteLater() # resize canvas width = N*settings.CHIMERA_TILE_SIZE height = M*settings.CHIMERA_TILE_SIZE self.canvas.setGeometry(0, 0, width, height) # convert adjacency dict to tuple format adj = {linear_to_tuple(k, M, N):\ [linear_to_tuple(a, M, N) for a in adj[k]] for k in adj} self.M = M self.N = N self.adj = adj for m in xrange(M): for n in xrange(N): tile = ChimeraTile(self, m, n, adj=adj) self.tiles[(m, n)] = tile self.layout.addWidget(tile, m, n) tile.show() self.canvas.update()
def updateChimera(self, filename): '''Process a chimera specification file and update the widget''' try: M, N, adj = load_chimera_file(filename) except IOError: print('Failed to load given file...') return # forget old grid layout for tile in self.tiles: self.tiles[tile].setParent(None) self.tiles = {} while self.layout.count(): item = self.layout.takeAt(0) item.widget().deleteLater() # resize canvas width = N * settings.CHIMERA_TILE_SIZE height = M * settings.CHIMERA_TILE_SIZE self.canvas.setGeometry(0, 0, width, height) # convert adjacency dict to tuple format adj = {linear_to_tuple(k, M, N):\ [linear_to_tuple(a, M, N) for a in adj[k]] for k in adj} self.M = M self.N = N self.adj = adj for m in xrange(M): for n in xrange(N): tile = ChimeraTile(self, m, n, adj=adj) self.tiles[(m, n)] = tile self.layout.addWidget(tile, m, n) tile.show() self.canvas.update()