def on_grounded_button_clicked(self): current_item = self.collection_list.currentItem() self.collections_grounded.clear() self.grounded_list.clear() G = self.collections[self.collection_list.row(current_item)] item = QListWidgetItem("Released") try: icon = graph(G, self.grounded_list.iconSize().width(), self.ground_engine) except EngineError as e: self.engineErrorMsg(e) return item.setIcon(icon) self.collections_grounded.append(G) self.grounded_list.addItem(item) for node in G.nodes: G_ = Graph(G) G_.remove_node(node) error = False for H in self.collections_grounded: if is_isomorphic(G_, H): error = True if error: continue item = QListWidgetItem("link_{} constrainted".format(node)) icon = graph(G, self.grounded_list.iconSize().width(), self.ground_engine, except_node=node) item.setIcon(icon) self.collections_grounded.append(G_) self.grounded_list.addItem(item) self.grounded_merge.setEnabled(bool(self.grounded_list.count()))
def on_collection_list_currentItemChanged(self, item, p0): """Show the data of collection. Save the layout position to keep the graphs will be in same appearance. """ has_item = bool(item) self.delete_button.setEnabled(has_item) self.grounded_button.setEnabled(has_item) self.triangle_button.setEnabled(has_item) if not item: return self.selection_window.clear() item_ = QListWidgetItem(item.text()) row = self.collection_list.row(item) G = self.collections[row] self.ground_engine = self.collections_layouts[row] item_.setIcon( graph(G, self.selection_window.iconSize().width(), self.ground_engine)) self.selection_window.addItem(item_) self.Expression_edges.setText(str(list(G.edges))) self.NL.setText(str(len(G.nodes))) self.NJ.setText(str(len(G.edges))) self.DOF.setText( str(3 * (int(self.NL.text()) - 1) - 2 * int(self.NJ.text())))
def drawAtlas(self, i, G) -> bool: item = QListWidgetItem("No. {}".format(i+1)) try: item.setIcon(graph(G, self.Topologic_result.iconSize().width(), self.engine, self.graph_link_as_node.isChecked())) except EngineError as e: QMessageBox.warning(self, str(e), "Please install and make sure Graphviz is working.") return False else: item.setToolTip(str(G.edges)) self.Topologic_result.addItem(item) return True
def on_grounded_button_clicked(self): """Grounded combinations.""" current_item = self.collection_list.currentItem() self.collections_grounded.clear() self.grounded_list.clear() G = self.collections[self.collection_list.row(current_item)] item = QListWidgetItem("Released") try: icon = graph(G, self.grounded_list.iconSize().width(), self.ground_engine) except EngineError as e: self.engineErrorMsg(e) return item.setIcon(icon) self.collections_grounded.append(G) self.grounded_list.addItem(item) def isomorphic(G: Graph, l: List[Graph]) -> bool: for H in l: if is_isomorphic(G, H): return True return False for node in G.nodes: G_ = Graph(G) G_.remove_node(node) if isomorphic(G_, self.collections_grounded): continue item = QListWidgetItem("link_{}".format(node)) icon = graph(G, self.grounded_list.iconSize().width(), self.ground_engine, except_node=node) item.setIcon(icon) self.collections_grounded.append(G_) self.grounded_list.addItem(item) self.grounded_merge.setEnabled(bool(self.grounded_list.count()))
def on_reload_atlas_clicked(self, p0=None): """Reload atlas with the engine.""" if not self.collections: return self.collections_layouts.clear() self.collection_list.clear() self.selection_window.clear() self.Expression_edges.clear() self.NL.setText('0') self.NJ.setText('0') self.DOF.setText('0') self.grounded_list.clear() progdlg = QProgressDialog("Drawing atlas...", "Cancel", 0, len(self.collections), self) progdlg.setAttribute(Qt.WA_DeleteOnClose, True) progdlg.setWindowTitle("Type synthesis") progdlg.resize(400, progdlg.height()) progdlg.setModal(True) progdlg.show() engineSTR = self.graph_engine.currentText().split(" - ")[1] for i, G in enumerate(self.collections): QCoreApplication.processEvents() if progdlg.wasCanceled(): return item = QListWidgetItem("No. {}".format(i + 1)) try: engine = engine_picker(G, engineSTR) item.setIcon( graph(G, self.collection_list.iconSize().width(), engine)) except EngineError as e: progdlg.setValue(progdlg.maximum()) self.engineErrorMsg(e) break else: self.collections_layouts.append(engine) item.setToolTip( "{}\nUse the right-click menu to operate.".format(G.edges)) self.collection_list.addItem(item) progdlg.setValue(i + 1)