예제 #1
0
 def __efd_path(self) -> None:
     """Elliptical Fourier Descriptors."""
     path = self.current_path()
     n, ok = QInputDialog.getInt(self, "Elliptical Fourier Descriptors",
                                 "The number of points:", len(path), 3)
     if not ok:
         return
     dlg = QProgressDialog("Path transform.", "Cancel", 0, 1, self)
     dlg.setWindowTitle("Elliptical Fourier Descriptors")
     dlg.show()
     self.set_path(efd_fitting(path, n))
     dlg.setValue(1)
     dlg.deleteLater()
예제 #2
0
    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}")
            engine = engine_picker(g, engine_str, self.graph_link_as_node.isChecked())
            item.setIcon(graph2icon(
                g,
                self.collection_list.iconSize().width(),
                engine,
                self.graph_link_as_node.isChecked(),
                self.graph_show_label.isChecked(),
                self.prefer.monochrome_option
            ))
            self.collections_layouts.append(engine)
            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())
예제 #3
0
 def __check_update(self) -> None:
     """Check for update."""
     dlg = QProgressDialog("Checking update ...", "Cancel", 0, 3, self)
     dlg.setWindowTitle("Check for update")
     dlg.resize(400, dlg.height())
     dlg.setModal(True)
     dlg.show()
     url = check_update(dlg)
     dlg.deleteLater()
     if url:
         if QMessageBox.question(
                 self, "Pyslvs has update",
                 "Do you want to get it from Github?") == QMessageBox.Yes:
             self.__open_url(url)
     else:
         QMessageBox.information(
             self, "Pyslvs is up to date",
             "You are using the latest version of Pyslvs.")
예제 #4
0
    def load_data(self, file_name: str, data: Dict[str, Any]) -> None:
        """Load file method."""
        self.main_clear()
        ver = data.get('pyslvs_ver', "")
        if ver:
            logger.info(f"Load data from Pyslvs {ver}")
        del ver
        dlg = QProgressDialog("Loading project", "Cancel", 0, 8, self.parent())
        dlg.setLabelText("Reading file ...")
        dlg.show()

        # Mechanism data
        dlg.setValue(1)
        dlg.setLabelText("Loading mechanism ...")
        if dlg.wasCanceled():
            dlg.deleteLater()
            return self.main_clear()
        self.__set_group("Add mechanism")
        links_data: Dict[str, str] = data.get('links', {})
        self.add_empty_links(links_data)
        mechanism_data: str = data.get('mechanism', "")
        self.parse_expression(mechanism_data)
        self.__end_group()

        # Input data
        dlg.setValue(2)
        dlg.setLabelText("Loading inputs data ...")
        if dlg.wasCanceled():
            dlg.deleteLater()
            return self.main_clear()
        self.__set_group("Add inputs data")
        input_data: List[Dict[str, int]] = data.get('input', [])
        i_attr = []
        for b, d in input_data:
            QCoreApplication.processEvents()
            i_attr.append((b, d))
        self.load_inputs(i_attr)
        self.__end_group()

        # Storage data
        dlg.setValue(3)
        dlg.setLabelText("Loading storage ...")
        if dlg.wasCanceled():
            dlg.deleteLater()
            return self.main_clear()
        self.__set_group("Add storage")
        storage_data: Dict[str, str] = data.get('storage', {})
        self.load_storage(storage_data)
        self.__end_group()

        # Path data
        dlg.setValue(4)
        dlg.setLabelText("Loading paths ...")
        if dlg.wasCanceled():
            dlg.deleteLater()
            return self.main_clear()
        self.__set_group("Add paths")
        path_data: Dict[str, Sequence[Tuple[float,
                                            float]]] = data.get('path', {})
        self.load_paths(path_data)
        self.__end_group()

        # Collection data
        dlg.setValue(5)
        dlg.setLabelText("Loading graph collections ...")
        if dlg.wasCanceled():
            dlg.deleteLater()
            return self.main_clear()
        self.__set_group("Add graph collections")
        collection_data: List[Tuple[Tuple[int, int],
                                    ...]] = data.get('collection', [])
        self.load_collections(collection_data)
        self.__end_group()

        # Configuration data
        dlg.setValue(6)
        dlg.setLabelText("Loading synthesis configurations ...")
        if dlg.wasCanceled():
            dlg.deleteLater()
            return self.main_clear()
        self.__set_group("Add synthesis configurations")
        config_data: Dict[str, Dict[str, Any]] = data.get('triangle', {})
        self.load_config(config_data)
        self.__end_group()

        # Algorithm data
        dlg.setValue(7)
        dlg.setLabelText("Loading synthesis results ...")
        if dlg.wasCanceled():
            dlg.deleteLater()
            return self.main_clear()
        self.__set_group("Add synthesis results")
        algorithm_data: List[Dict[str, Any]] = data.get('algorithm', [])
        self.load_algorithm(algorithm_data)
        self.__end_group()

        # Workbook loaded
        dlg.setValue(8)
        dlg.deleteLater()

        # File type option align (ignore previous one)
        self.prefer.file_type_option = data.get('file_type', 0)

        # Show overview dialog
        dlg = OverviewDialog(self.parent(),
                             QFileInfo(file_name).baseName(), storage_data,
                             i_attr, path_data, collection_data, config_data,
                             algorithm_data)
        dlg.show()
        dlg.exec_()
        dlg.deleteLater()