Пример #1
0
    def activated_details(self, item: QListWidgetItem):
        """
        Handles context switch when another working day was selected in the left list.

        :param item:
        :return:
        """
        self.ui.tabWidget_Details.setEnabled(True)
        self.time_capture_service.selected_day = item.text()
        self.__clean_and_load_entries__(item.text())
        self.__clean_and_load_bookings__(item.text())
        self.ui.label_sumHours.setText("Sum: {} hrs".format(self.__sum_booked_hours__()))
Пример #2
0
 def __path_dlg(self, item: QListWidgetItem) -> None:
     """View path data."""
     name = item.text().split(":", maxsplit=1)[0]
     try:
         paths = self.__paths[name]
     except KeyError:
         return
     points_text = ", ".join(f"Point{i}" for i in range(len(paths)))
     if QMessageBox.question(
         self,
         "Path data",
         f"This path data including {points_text}.",
         (QMessageBox.Save | QMessageBox.Close),
         QMessageBox.Close
     ) != QMessageBox.Save:
         return
     file_name = self.output_to(
         "path data",
         ["Comma-Separated Values (*.csv)", "Text file (*.txt)"]
     )
     if not file_name:
         return
     with open(file_name, 'w+', encoding='utf-8', newline='') as stream:
         w = writer(stream)
         for path in paths:
             for point in path:
                 w.writerow(point)
             w.writerow(())
     logger.info(f"Output path data: {file_name}")
Пример #3
0
 def get_index(item: QListWidgetItem, new_values: typing.List[str]) -> int:
     if item is None:
         return -1
     text = item.text()
     try:
         return new_values.index(text)
     except ValueError:
         return -1
Пример #4
0
 def __show_mapping_dialog(self, item: QListWidgetItem):
     ''' Shows the edit mapping dialog '''
     if self.filterMapping.isEnabled():
         text = item.text()
         channel_name = text.split(' ')[1]
         mapped_signal = self.__channel_to_signal.get(channel_name, None)
         EditMappingDialog(self, self.__filters_by_channel.keys(),
                           channel_name, self.__signal_model, mapped_signal,
                           self.__map_signal_to_channel).exec()
Пример #5
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(),
            self.ground_engine,
            link_is_node,
            self.graph_show_label.isChecked(),
            self.prefer.monochrome_option
        ))
        self.selection_window.addItem(item_preview)

        # Set attributes
        self.edges_text.setText(str(list(g.edges)))
        self.nl_label.setText(str(len(g.nodes)))
        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)))

        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()
Пример #6
0
    def open_scene(item: QListWidgetItem) -> None:
        scene_text = item.text()

        # Use scene indexes to cover for duplicate names
        scene_index = int(scene_text.split(SCENE_LABEL_DELIMITER)[0])

        # Update scene on image and get data
        img.set_scene(scene_index)
        data = _get_full_image_data(img=img, in_memory=in_memory)

        # Get metadata and add to image
        meta = _get_meta(data, img)

        # Optionally clear layers
        if _widget_is_checked(CLEAR_LAYERS_ON_SELECT):
            viewer.layers.clear()

        # Optionally remove channel axis
        if not _widget_is_checked(UNPACK_CHANNELS_TO_LAYERS):
            meta["name"] = scene_text
            meta.pop("channel_axis", None)

        viewer.add_image(data, **meta)