Exemplo n.º 1
0
 def __grounded(self) -> None:
     """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")
     icon = graph2icon(g,
                       self.grounded_list.iconSize().width(),
                       self.graph_link_as_node.isChecked(),
                       self.graph_show_label.isChecked(),
                       self.prefer.monochrome_option,
                       pos=self.ground_engine)
     item.setIcon(icon)
     self.collections_grounded.append(g)
     self.grounded_list.addItem(item)
     for node, graph_ in labeled_enumerate(g):
         item = QListWidgetItem(f"link_{node}")
         icon = graph2icon(g,
                           self.grounded_list.iconSize().width(),
                           self.graph_link_as_node.isChecked(),
                           self.graph_show_label.isChecked(),
                           self.prefer.monochrome_option,
                           except_node=node,
                           pos=self.ground_engine)
         item.setIcon(icon)
         self.collections_grounded.append(graph_)
         self.grounded_list.addItem(item)
Exemplo n.º 2
0
 def __draw_atlas(self, i: int, g: Graph) -> bool:
     """Draw atlas and return True if done."""
     item = QListWidgetItem(f"No. {i + 1}")
     item.setIcon(
         graph2icon(g,
                    self.structure_list.iconSize().width(),
                    self.graph_link_as_node.isChecked(),
                    self.graph_show_label.isChecked(),
                    self.prefer.monochrome_option,
                    engine=self.graph_engine.currentText()))
     item.setToolTip(
         f"Edge Set: {list(g.edges)}\n"
         f"Link assortment: {link_assortment(g)}\n"
         f"Contracted Link assortment: {contracted_link_assortment(g)}\n"
         f"Degree code: {g.degree_code()}")
     self.structure_list.addItem(item)
     return True
Exemplo n.º 3
0
    def __set_selection(self, item: QListWidgetItem) -> None:
        """Show the data of collection.

        Save the layout position to keep the graphs
        will be in same appearance.
        """
        for button in (
                self.delete_button,
                self.configure_button,
                self.duplicate_button,
        ):
            button.setEnabled(item is not None)
        self.selection_window.clear()
        if item is None:
            return
        # Preview item
        link_is_node = self.graph_link_as_node.isChecked()
        item_preview = QListWidgetItem(item.text())
        row = self.collection_list.row(item)
        g = self.collections[row]
        self.ground_engine = self.collections_layouts[row]
        item_preview.setIcon(
            graph2icon(g,
                       self.selection_window.iconSize().width(),
                       link_is_node,
                       self.graph_show_label.isChecked(),
                       self.prefer.monochrome_option,
                       pos=self.ground_engine))
        self.selection_window.addItem(item_preview)
        # Set attributes
        self.edges_text.setText(str(list(g.edges)))
        self.nl_label.setText(str(len(g.vertices)))
        self.nj_label.setText(str(len(g.edges)))
        self.dof_label.setText(str(g.dof()))
        self.is_degenerate_label.setText(str(g.is_degenerate()))
        self.link_assortment_label.setText(str(link_assortment(g)))
        self.contracted_link_assortment_label.setText(
            str(contracted_link_assortment(g)))
        # Buttons
        self.duplicate_button.setEnabled(link_is_node)
        self.configure_button.setEnabled(not link_is_node)
        self.merge_button.setEnabled(not link_is_node)
        self.__grounded()
 def __reload_atlas(self) -> None:
     """Reload atlas with the engine."""
     current_pos = self.collection_list.currentRow()
     self.collections_layouts.clear()
     self.collection_list.clear()
     self.__clear_selection()
     if not self.collections:
         return
     dlg = QProgressDialog(
         "Drawing atlas...",
         "Cancel",
         0,
         len(self.collections),
         self
     )
     dlg.setWindowTitle("Type synthesis")
     dlg.resize(400, dlg.height())
     dlg.setModal(True)
     dlg.show()
     engine_str = self.graph_engine.currentText()
     for i, g in enumerate(self.collections):
         QCoreApplication.processEvents()
         if dlg.wasCanceled():
             dlg.deleteLater()
             return
         item = QListWidgetItem(f"No. {i + 1}")
         pos = engine_picker(g, engine_str, self.graph_link_as_node.isChecked())
         item.setIcon(graph2icon(
             g,
             self.collection_list.iconSize().width(),
             self.graph_link_as_node.isChecked(),
             self.graph_show_label.isChecked(),
             self.prefer.monochrome_option,
             pos=pos
         ))
         self.collections_layouts.append(pos)
         item.setToolTip(f"{g.edges}")
         self.collection_list.addItem(item)
         dlg.setValue(i + 1)
     dlg.deleteLater()
     if current_pos > -1:
         self.collection_list.setCurrentRow(current_pos)
         self.__set_selection(self.collection_list.currentItem())