Beispiel #1
0
    def __init__(self, view: View, parent: QtWidgets.QWidget = None):
        super().__init__(parent)

        self.view = view
        self.drag_start_pos = QtCore.QPoint(0, 0)
        self.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                           QtWidgets.QSizePolicy.Minimum)
        self.setElideMode(QtCore.Qt.ElideLeft)
        self.setUsesScrollButtons(True)
        self.setExpanding(False)
        self.setTabsClosable(True)

        self.setAcceptDrops(True)
        self.setMouseTracking(True)

        self.action_close_all = qAction(
            "view-close",
            "Close All Tabs",
            "Closes all tabs open in this view.",
            self.actionCloseAll,
        )
        self.action_close_others = qAction(
            "view-right-close",
            "Close Other Tabs",
            "Close all tabs but this one.",
            self.actionCloseOthers,
        )
Beispiel #2
0
    def __init__(
        self,
        orientation: QtCore.Qt.Orientation = QtCore.Qt.Horizontal,
        parent: QtWidgets.QWidget = None,
    ):
        super().__init__(orientation, parent)
        self.active_view: Optional["View"] = None
        self.views: List[View] = []

        self.action_split_horz = qAction(
            "view-split-left-right",
            "Split &Vertical",
            "Split the viewspace vertically.",
            self.splitActiveHorizontal,
        )
        self.action_split_vert = qAction(
            "view-split-top-bottom",
            "Split &Horizontal",
            "Split the viewspace horizontally.",
            self.splitActiveVertical,
        )
        self.action_close_view = qAction("view-close", "Close View",
                                         "Closes the current view.",
                                         self.closeActiveView)
        # self.action_close_others = QtWidgets.QAction(
        #     QtGui.QIcon.fromTheme("view-right-close"), "Close Other Views"
        # )
        # self.action_close_view.triggered.connect(self.closeOtherViews)

        self.addWidget(self.createView())
Beispiel #3
0
    def __init__(
        self,
        label: str,
        vmin: int,
        vmax: int,
        color: QtGui.QColor,
        color_pickable: bool = False,
        parent: "OverlayRows" = None,
    ):
        super().__init__(parent)

        self.label_name = QtWidgets.QLabel(label)
        self.colorrange = RangeSlider()
        self.colorrange.setRange(0, 99)
        self.colorrange.setValues(vmin, vmax)
        self.colorrange.valueChanged.connect(self.itemChanged)
        self.colorrange.value2Changed.connect(self.itemChanged)

        self.action_color = qAction(
            "color-picker",
            "Color",
            "Select the color for this element.",
            self.selectColor,
        )
        self.action_close = qAction(
            "window-close", "Remove", "Remove this element.", self.close
        )
        self.action_hide = qAction(
            "visibility", "Hide", "Toggle visibility of this element.", self.hideChanged
        )
        self.action_hide.setCheckable(True)

        self.button_hide = qToolButton(action=self.action_hide)
        self.button_color = qToolButton(action=self.action_color)
        self.button_color.setEnabled(color_pickable)

        self.effect_color = QtWidgets.QGraphicsColorizeEffect()
        self.effect_color.setColor(color)
        self.button_color.setGraphicsEffect(self.effect_color)

        self.button_close = qToolButton(action=self.action_close)

        layout = QtWidgets.QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.label_name, 2)
        layout.addWidget(self.colorrange, 1)
        layout.addWidget(self.button_hide, 0)
        layout.addWidget(self.button_color, 0)
        layout.addWidget(self.button_close, 0, QtCore.Qt.AlignRight)
        self.setLayout(layout)
Beispiel #4
0
    def __init__(
        self,
        image: ScaledImageItem,
        data: np.ndarray,
        pen: QtGui.QPen = None,
        font: QtGui.QFont = None,
        parent: QtWidgets.QGraphicsItem = None,
    ):
        super().__init__(image, parent)

        if pen is None:
            pen = QtGui.QPen(QtCore.Qt.white, 2.0, QtCore.Qt.DotLine)
            pen.setCosmetic(True)
            pen.setCapStyle(QtCore.Qt.RoundCap)

        if font is None:
            font = QtGui.QFont()

        self.image_data = data
        self.sliced: Optional[np.ndarray] = None

        self.pen = pen
        self.font = font

        self.line = QtCore.QLineF()
        self.poly = QtGui.QPolygonF()

        self.action_copy_to_clipboard = qAction(
            "insert-text",
            "Copy To Clipboard",
            "Copy slice values to the clipboard.",
            self.actionCopyToClipboard,
        )
Beispiel #5
0
 def __init__(self, parent: QtWidgets.QWidget = None):
     super().__init__(parent)
     self.action_edit_names = qAction(
         "document-edit",
         "Edit Names",
         "Edit image names.",
         self.actionNameEditDialog,
     )
Beispiel #6
0
    def __init__(self, widget: LaserWidget):
        super().__init__(widget, graphics_label="Preview")

        self.graphics = LaserGraphicsView(self.viewspace.options, parent=self)
        self.graphics.cursorValueChanged.connect(
            self.widget.updateCursorStatus)
        self.graphics.setMouseTracking(True)

        self.action_toggle_filter = qAction(
            "visibility",
            "Filter Visible",
            "Toggle visibility of the filtering.",
            self.toggleFilter,
        )
        self.action_toggle_filter.setCheckable(True)
        self.button_hide_filter = qToolButton(action=self.action_toggle_filter)
        self.button_hide_filter.setToolButtonStyle(
            QtCore.Qt.ToolButtonTextBesideIcon)

        self.combo_element = QtWidgets.QComboBox()
        self.combo_element.activated.connect(self.completeChanged)
        self.combo_element.activated.connect(self.refresh)

        self.combo_filter = QtWidgets.QComboBox()
        self.combo_filter.addItems(FilteringTool.methods.keys())
        self.combo_filter.setCurrentText("Rolling Median")
        self.combo_filter.activated.connect(self.filterChanged)
        self.combo_filter.activated.connect(self.completeChanged)
        self.combo_filter.activated.connect(self.refresh)

        nparams = np.amax(
            [len(f["params"]) for f in FilteringTool.methods.values()])
        self.label_fparams = [QtWidgets.QLabel() for _ in range(nparams)]
        self.lineedit_fparams = [ValidColorLineEdit() for _ in range(nparams)]
        for le in self.lineedit_fparams:
            le.textEdited.connect(self.completeChanged)
            le.editingFinished.connect(self.refresh)
            le.setValidator(
                ConditionalLimitValidator(0.0, 0.0, 4, condition=None))

        layout_graphics = QtWidgets.QVBoxLayout()
        layout_graphics.addWidget(self.graphics)
        layout_graphics.addWidget(self.combo_element, 0, QtCore.Qt.AlignRight)
        self.box_graphics.setLayout(layout_graphics)

        layout_controls = QtWidgets.QFormLayout()
        layout_controls.addWidget(self.combo_filter)
        for i in range(len(self.label_fparams)):
            layout_controls.addRow(self.label_fparams[i],
                                   self.lineedit_fparams[i])
        layout_controls.addWidget(self.button_hide_filter)

        self.box_controls.setLayout(layout_controls)

        self.initialise()
Beispiel #7
0
    def __init__(
        self,
        laser: Laser,
        item: QtWidgets.QListWidgetItem,
        close_button: bool,
        parent: "MergeLaserList",
    ):
        super().__init__(parent)

        self.laser = laser
        self.image: Optional[ScaledImageItem] = None
        self.item = item

        self.action_close = qAction(
            "window-close", "Remove", "Remove laser.", self.close
        )

        self.label_name = QtWidgets.QLabel(laser.info["Name"])
        self.label_offset = QtWidgets.QLabel("(0.0, 0.0)")
        self.combo_element = QtWidgets.QComboBox()
        self.combo_element.addItems(laser.elements)

        self.combo_element.currentTextChanged.connect(
            lambda _: self.elementChanged.emit(self.item)
        )

        self.button_close = qToolButton(action=self.action_close)
        self.button_close.setEnabled(close_button)

        self.slider_alpha = QtWidgets.QSlider()
        self.slider_alpha.setMinimumWidth(200)
        self.slider_alpha.setOrientation(QtCore.Qt.Horizontal)
        self.slider_alpha.setRange(0, 100)
        self.slider_alpha.setValue(100)
        self.slider_alpha.valueChanged.connect(
            lambda _: self.alphaChanged.emit(self.item)
        )

        layout = QtWidgets.QHBoxLayout()
        layout.addWidget(self.label_name, 2)
        layout.addWidget(self.label_offset, 0, QtCore.Qt.AlignRight)
        layout.addWidget(self.slider_alpha, 0, QtCore.Qt.AlignRight)
        layout.addWidget(self.combo_element, 0, QtCore.Qt.AlignRight)
        layout.addWidget(self.button_close, 0, QtCore.Qt.AlignRight)

        self.setLayout(layout)
Beispiel #8
0
    def __init__(
        self,
        text: str,
        font: QtGui.QFont = None,
        color: QtGui.QColor = None,
        parent: QtWidgets.QGraphicsItem = None,
    ):
        super().__init__(parent)

        if font is None:
            font = QtGui.QFont()
        if color is None:
            color = QtCore.Qt.white

        self._text = text
        self.font = font
        self.color = color

        self.action_edit_label = qAction(
            "edit-rename",
            "Rename",
            "Rename the current element.",
            self.editLabel,
        )
Beispiel #9
0
    def __init__(self, config: Config, parent: QtWidgets.QWidget = None):
        super().__init__(parent)
        self.setWindowTitle("Configuration")
        self.config = copy.copy(config)

        self.action_copy = qAction(
            "edit-paste",
            "Copy to Clipboard",
            "Copy the current configuration to the system clipboard.",
            self.copyToClipboard,
        )
        self.button_copy = qToolButton(action=self.action_copy)

        # Line edits
        self.lineedit_spotsize = QtWidgets.QLineEdit()
        self.lineedit_spotsize.setText(str(self.config.spotsize))
        self.lineedit_spotsize.setValidator(DecimalValidator(0, 1e9, 4))
        self.lineedit_spotsize.setToolTip("Diameter of the laser spot.")
        self.lineedit_spotsize.textChanged.connect(self.completeChanged)

        if isinstance(self.config, SpotConfig):
            self.lineedit_spotsize_y = QtWidgets.QLineEdit()
            self.lineedit_spotsize_y.setText(str(self.config.spotsize_y))
            self.lineedit_spotsize_y.setValidator(DecimalValidator(0, 1e9, 4))
            self.lineedit_spotsize_y.textChanged.connect(self.completeChanged)

        self.lineedit_speed = QtWidgets.QLineEdit()
        self.lineedit_speed.setText(str(self.config.speed))
        self.lineedit_speed.setValidator(DecimalValidator(0, 1e9, 4))
        self.lineedit_speed.setToolTip("Scanning speed of the laser.")
        self.lineedit_speed.textChanged.connect(self.completeChanged)

        self.lineedit_scantime = QtWidgets.QLineEdit()
        self.lineedit_scantime.setText(str(self.config.scantime))
        self.lineedit_scantime.setValidator(DecimalValidator(0, 1e9, 4))
        self.lineedit_scantime.setToolTip(
            "Total dwell time for one aquistion (pixel).")
        self.lineedit_scantime.textChanged.connect(self.completeChanged)

        if isinstance(self.config, SRRConfig):
            self.lineedit_warmup = QtWidgets.QLineEdit()
            self.lineedit_warmup.setText(str(self.config.warmup))
            self.lineedit_warmup.setValidator(DecimalValidator(0, 1e3, 1))
            self.lineedit_warmup.setToolTip(
                "Laser warmup time; delay before aquisition.")
            self.lineedit_warmup.textChanged.connect(self.completeChanged)
            self.spinbox_offsets = QtWidgets.QSpinBox()
            self.spinbox_offsets.setRange(2, 10)
            self.spinbox_offsets.setValue(self.config._subpixel_size)
            self.spinbox_offsets.setToolTip(
                "Number of subpixels per pixel. "
                "Offseting each layer by 50% will have a subpixel width of 2.")

        self.check_all = QtWidgets.QCheckBox("Apply config to all images.")

        # Form layout for line edits
        layout_form = QtWidgets.QFormLayout()
        layout_form.addRow("Spotsize (μm):", self.lineedit_spotsize)
        if isinstance(config, SpotConfig):
            layout_form.addRow("Spotsize Y (μm):", self.lineedit_spotsize_y)
        else:
            layout_form.addRow("Speed (μm/s):", self.lineedit_speed)
            layout_form.addRow("Scantime (s):", self.lineedit_scantime)
        if isinstance(config, SRRConfig):
            layout_form.addRow("Warmup (s):", self.lineedit_warmup)
            layout_form.addRow("Subpixel width:", self.spinbox_offsets)

        layout_horz = QtWidgets.QHBoxLayout()
        layout_horz.addLayout(layout_form, 1)
        layout_horz.addWidget(self.button_copy, 0, QtCore.Qt.AlignTop)

        self.layout_main.addLayout(layout_horz)
        self.layout_main.addWidget(self.check_all)
Beispiel #10
0
    def __init__(
        self,
        calibrations: Dict[str, Calibration],
        current_element: str,
        parent: QtWidgets.QWidget = None,
    ):
        super().__init__(parent)
        self.setWindowTitle("Calibration")
        self.setSizePolicy(QtWidgets.QSizePolicy.Minimum,
                           QtWidgets.QSizePolicy.Minimum)
        self.calibrations = copy.deepcopy(calibrations)

        self.action_copy = qAction(
            "edit-paste",
            "Copy to Clipboard",
            "Copy the current calibration to the system clipboard.",
            self.copyToClipboard,
        )
        self.action_copy_all = qAction(
            "edit-paste",
            "Copy All to Clipboard",
            "Copy the all calibrations to the system clipboard.",
            self.copyAllToClipboard,
        )
        self.button_copy = qToolButton(action=self.action_copy)
        self.button_copy.addAction(self.action_copy_all)

        # LIne edits
        self.lineedit_gradient = QtWidgets.QLineEdit()
        self.lineedit_gradient.setValidator(
            DecimalValidatorNoZero(-1e10, 1e10, 4))
        self.lineedit_gradient.setPlaceholderText("1.0000")
        self.lineedit_intercept = QtWidgets.QLineEdit()
        self.lineedit_intercept.setValidator(DecimalValidator(-1e10, 1e10, 4))
        self.lineedit_intercept.setPlaceholderText("0.0000")
        self.lineedit_unit = QtWidgets.QLineEdit()
        self.lineedit_unit.setPlaceholderText("")

        # Element combo
        self.combo_element = QtWidgets.QComboBox()
        self.combo_element.addItems(list(self.calibrations.keys()))
        self.combo_element.setCurrentText(current_element)
        self.previous_index = self.combo_element.currentIndex()
        self.combo_element.currentIndexChanged.connect(self.comboChanged)

        # Check all
        self.check_all = QtWidgets.QCheckBox(
            "Apply calibration to all images.")

        # Button to plot
        self.button_plot = QtWidgets.QPushButton("Plot")
        self.button_plot.setEnabled(
            self.calibrations[current_element].points.size > 0)
        self.button_plot.pressed.connect(self.showCurve)

        self.points = CalibrationPointsWidget(self)
        self.points.levelsChanged.connect(self.updatePlotEnabled)
        self.points.weightingChanged.connect(self.updateLineEdits)
        self.points.model.dataChanged.connect(self.updateLineEdits)
        self.points.model.dataChanged.connect(self.updatePlotEnabled)

        layout_elements = QtWidgets.QHBoxLayout()
        layout_elements.addWidget(self.button_plot, 0, QtCore.Qt.AlignLeft)
        layout_elements.addWidget(self.combo_element, 0, QtCore.Qt.AlignRight)

        # Form layout for line edits
        layout_form = QtWidgets.QFormLayout()
        layout_form.addRow("Gradient:", self.lineedit_gradient)
        layout_form.addRow("Intercept:", self.lineedit_intercept)
        layout_form.addRow("Unit:", self.lineedit_unit)

        layout_horz = QtWidgets.QHBoxLayout()
        layout_horz.addLayout(layout_form, 1)
        layout_horz.addWidget(self.button_copy, 0, QtCore.Qt.AlignTop)

        self.layout_main.addLayout(layout_horz)
        self.layout_main.addWidget(self.points)
        self.layout_main.addWidget(self.check_all)
        self.layout_main.addLayout(layout_elements)

        self.updateLineEdits()
        self.updatePoints()
Beispiel #11
0
    def __init__(self, parent: QtWidgets.QWidget):
        super().__init__("Points", parent)

        self.action_add_level = qAction(
            "list-add",
            "Add Level",
            "Adds a level to the calibraiton.",
            self.addCalibrationLevel,
        )
        self.action_remove_level = qAction(
            "list-remove",
            "Remove Level",
            "Removes a level to the calibraiton.",
            self.removeCalibrationLevel,
        )

        self.button_add = qToolButton(action=self.action_add_level)
        self.button_remove = qToolButton(action=self.action_remove_level)

        self.combo_weighting = QtWidgets.QComboBox()
        self.combo_weighting.addItems(Calibration.KNOWN_WEIGHTING)
        self.combo_weighting.addItem("Custom")
        self.combo_weighting.currentTextChanged.connect(self.weightingChanged)

        label_weighting = QtWidgets.QLabel("Weighting:")

        self.model = CalibrationPointsTableModel(
            Calibration(),
            axes=(1, 0),
            counts_editable=True,
            parent=self,
        )

        self.levelsChanged.connect(self.updateButtonRemoveEnabled)
        self.model.modelReset.connect(self.updateButtonRemoveEnabled)
        self.combo_weighting.currentTextChanged.connect(self.updateWeighting)

        self.table = BasicTableView()
        self.table.setItemDelegate(DoubleSignificantFiguresDelegate(4))
        self.table.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.AdjustToContents)
        self.table.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.table.setMaximumWidth(800)
        self.table.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.table.setModel(self.model)
        self.table.horizontalHeader().setSectionResizeMode(
            QtWidgets.QHeaderView.ResizeToContents)

        layout_buttons = QtWidgets.QHBoxLayout()
        layout_buttons.addWidget(self.button_remove, 0, QtCore.Qt.AlignLeft)
        layout_buttons.addWidget(self.button_add, 0, QtCore.Qt.AlignLeft)
        layout_buttons.addStretch(1)

        layout_weighting = QtWidgets.QHBoxLayout()
        layout_weighting.addStretch(1)
        layout_weighting.addWidget(label_weighting, 0, QtCore.Qt.AlignRight)
        layout_weighting.addWidget(self.combo_weighting, 0,
                                   QtCore.Qt.AlignRight)

        layout = QtWidgets.QVBoxLayout()
        layout.addLayout(layout_buttons)
        layout.addWidget(self.table)
        layout.addLayout(layout_weighting)
        self.area.setLayout(layout)
Beispiel #12
0
    def __init__(self, laser: Laser, options: GraphicsOptions, view: LaserView = None):
        super().__init__(view)
        self.laser = laser
        self.is_srr = isinstance(laser, SRRLaser)

        self.graphics = LaserGraphicsView(options, parent=self)
        self.graphics.setMouseTracking(True)

        self.graphics.cursorValueChanged.connect(self.updateCursorStatus)
        self.graphics.label.labelChanged.connect(self.renameCurrentElement)
        self.graphics.colorbar.editRequested.connect(self.actionRequestColorbarEdit)

        self.combo_layers = QtWidgets.QComboBox()
        self.combo_layers.addItem("*")
        self.combo_layers.addItems([str(i) for i in range(0, self.laser.layers)])
        self.combo_layers.currentIndexChanged.connect(self.refresh)
        if not self.is_srr:
            self.combo_layers.setEnabled(False)
            self.combo_layers.setVisible(False)

        self.combo_element = LaserComboBox()
        self.combo_element.namesSelected.connect(self.updateNames)
        self.combo_element.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents)
        self.combo_element.currentIndexChanged.connect(self.refresh)
        self.populateElements()

        self.action_calibration = qAction(
            "go-top",
            "Ca&libration",
            "Edit the documents calibration.",
            self.actionCalibration,
        )
        self.action_config = qAction(
            "document-edit", "&Config", "Edit the document's config.", self.actionConfig
        )
        self.action_copy_image = qAction(
            "insert-image",
            "Copy &Image",
            "Copy image to clipboard.",
            self.actionCopyImage,
        )
        self.action_duplicate = qAction(
            "edit-copy",
            "Duplicate image",
            "Open a copy of the image.",
            self.actionDuplicate,
        )
        self.action_export = qAction(
            "document-save-as", "E&xport", "Export documents.", self.actionExport
        )
        self.action_export.setShortcut("Ctrl+X")
        # Add the export action so we can use it via shortcut
        self.addAction(self.action_export)
        self.action_information = qAction(
            "documentinfo",
            "In&formation",
            "View and edit image information.",
            self.actionInformation,
        )
        self.action_save = qAction(
            "document-save", "&Save", "Save document to numpy archive.", self.actionSave
        )
        self.action_save.setShortcut("Ctrl+S")
        # Add the save action so we can use it via shortcut
        self.addAction(self.action_save)
        self.action_statistics = qAction(
            "dialog-information",
            "Statistics",
            "Open the statisitics dialog.",
            self.actionStatistics,
        )
        self.action_select_statistics = qAction(
            "dialog-information",
            "Selection Statistics",
            "Open the statisitics dialog for the current selection.",
            self.actionStatisticsSelection,
        )
        self.action_colocalisation = qAction(
            "dialog-information",
            "Colocalisation",
            "Open the colocalisation dialog.",
            self.actionColocal,
        )
        self.action_select_colocalisation = qAction(
            "dialog-information",
            "Selection Colocalisation",
            "Open the colocalisation dialog for the current selection.",
            self.actionColocalSelection,
        )

        # Toolbar actions
        self.action_select_none = qAction(
            "transform-move",
            "Clear Selection",
            "Clear any selections.",
            self.graphics.endSelection,
        )
        self.action_widget_none = qAction(
            "transform-move",
            "Clear Widgets",
            "Closes any open widgets.",
            self.graphics.endWidget,
        )
        self.action_select_rect = qAction(
            "draw-rectangle",
            "Rectangle Selector",
            "Start the rectangle selector tool, use 'Shift' "
            "to add to selection and 'Control' to subtract.",
            self.graphics.startRectangleSelection,
        )
        self.action_select_lasso = qAction(
            "draw-freehand",
            "Lasso Selector",
            "Start the lasso selector tool, use 'Shift' "
            "to add to selection and 'Control' to subtract.",
            self.graphics.startLassoSelection,
        )
        self.action_select_dialog = qAction(
            "dialog-information",
            "Selection Dialog",
            "Start the selection dialog.",
            self.actionSelectDialog,
        )
        self.action_select_copy_text = qAction(
            "insert-table",
            "Copy Selection as Text",
            "Copy the current selection to the clipboard as a column of text values.",
            self.actionCopySelectionText,
        )
        self.action_select_crop = qAction(
            "transform-crop",
            "Crop to Selection",
            "Crop the image to the current selection.",
            self.actionCropSelection,
        )

        self.selection_button = qToolButton("select", "Selection")
        self.selection_button.addAction(self.action_select_none)
        self.selection_button.addAction(self.action_select_rect)
        self.selection_button.addAction(self.action_select_lasso)
        self.selection_button.addAction(self.action_select_dialog)

        self.action_ruler = qAction(
            "tool-measure",
            "Measure",
            "Use a ruler to measure distance.",
            self.graphics.startRulerWidget,
        )
        self.action_slice = qAction(
            "tool-measure",
            "1D Slice",
            "Select and display a 1-dimensional slice of the image.",
            self.graphics.startSliceWidget,
        )
        self.widgets_button = qToolButton("tool-measure", "Widgets")
        self.widgets_button.addAction(self.action_widget_none)
        self.widgets_button.addAction(self.action_ruler)
        self.widgets_button.addAction(self.action_slice)

        self.action_zoom_in = qAction(
            "zoom-in",
            "Zoom to Area",
            "Start zoom area selection.",
            self.graphics.zoomStart,
        )
        self.action_zoom_out = qAction(
            "zoom-original",
            "Reset Zoom",
            "Reset zoom to full image extent.",
            self.graphics.zoomReset,
        )
        self.view_button = qToolButton("zoom", "Zoom")
        self.view_button.addAction(self.action_zoom_in)
        self.view_button.addAction(self.action_zoom_out)

        self.graphics.viewport().installEventFilter(DragDropRedirectFilter(self))
        # Filters for setting active view
        self.graphics.viewport().installEventFilter(self)
        self.combo_element.installEventFilter(self)
        self.selection_button.installEventFilter(self)
        self.widgets_button.installEventFilter(self)
        self.view_button.installEventFilter(self)

        layout_bar = QtWidgets.QHBoxLayout()
        layout_bar.addWidget(self.selection_button, 0, QtCore.Qt.AlignLeft)
        layout_bar.addWidget(self.widgets_button, 0, QtCore.Qt.AlignLeft)
        layout_bar.addWidget(self.view_button, 0, QtCore.Qt.AlignLeft)
        layout_bar.addStretch(1)
        layout_bar.addWidget(self.combo_layers, 0, QtCore.Qt.AlignRight)
        layout_bar.addWidget(self.combo_element, 0, QtCore.Qt.AlignRight)

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(self.graphics, 1)
        layout.addLayout(layout_bar)
        self.setLayout(layout)
Beispiel #13
0
 def __init__(self, viewspace: LaserViewSpace):
     super().__init__(viewspace)
     self.action_open = qAction(
         "document-open", "&Open", "Open new document(s).", self.actionOpen
     )
Beispiel #14
0
    def createActions(self) -> None:
        self.action_about = qAction("help-about", "&About", "About pew².",
                                    self.actionAbout)
        self.action_help = qAction("help-contents", "&Help",
                                   "Show the help contents.", self.actionHelp)
        self.action_colortable_range = qAction(
            "",
            "Set &Range",
            "Set the range of the colortable.",
            self.viewspace.colortableRangeDialog,
        )
        self.action_colortable_range.setShortcut("Ctrl+R")
        self.action_config = qAction(
            "document-edit",
            "Default Config",
            "Edit the default config.",
            self.viewspace.configDialog,
        )
        self.action_config.setShortcut("Ctrl+K")

        self.action_exit = qAction("application-exit", "Quit",
                                   "Exit the program.", self.close)
        self.action_exit.setShortcut("Ctrl+Shift+Q")

        self.action_export_all = qAction(
            "document-save-all",
            "E&xport All",
            "Export all open documents.",
            self.actionExportAll,
        )
        self.action_export_all.setShortcut("Ctrl+Shift+X")

        self.action_fontsize = qAction(
            "insert-text",
            "Fontsize",
            "Set the font size in points.",
            self.viewspace.fontsizeDialog,
        )
        self.action_group_colortable = qActionGroup(
            self,
            list(self.viewspace.options.colortables.keys()),
            self.actionGroupColortable,
            checked=self.viewspace.options.colortable,
            statuses=list(self.viewspace.options.colortables.values()),
        )
        self.action_smooth = qAction(
            "smooth",
            "&Smooth",
            "Smooth images with bilinear interpolation.",
            self.viewspace.toggleSmooth,
        )
        self.action_smooth.setCheckable(True)
        self.action_smooth.setChecked(self.viewspace.options.smoothing)
        self.action_wizard_import = qAction(
            "",
            "Import Wizard",
            "Start the line-wise import wizard. .",
            self.actionWizardImport,
        )
        self.action_wizard_spot = qAction(
            "",
            "Spotwise Wizard",
            "Start the import wizard for data collected spot-wise.",
            self.actionWizardSpot,
        )
        self.action_wizard_srr = qAction(
            "",
            "Kriss Kross Wizard",
            "Start the Super-Resolution-Reconstruction import wizard.",
            self.actionWizardSRR,
        )
        self.action_log = qAction("clock", "&Show Log",
                                  "Show the pew² event and error log.",
                                  self.actionLog)
        self.action_open = qAction("document-open", "&Open",
                                   "Open new document(s).", self.actionOpen)
        self.action_open.setShortcut("Ctrl+O")

        self.action_toggle_calibrate = qAction(
            "go-top",
            "Ca&librate",
            "Toggle calibration.",
            self.viewspace.toggleCalibrate,
        )
        self.action_toggle_calibrate.setShortcut("Ctrl+L")
        self.action_toggle_calibrate.setCheckable(True)
        self.action_toggle_calibrate.setChecked(
            self.viewspace.options.calibrate)
        self.action_toggle_colorbar = qAction(
            "", "Show Colorbar", "Toggle colorbars.",
            self.viewspace.setColorbarVisible)
        self.action_toggle_colorbar.setCheckable(True)
        self.action_toggle_colorbar.setChecked(
            self.viewspace.options.items["colorbar"])
        self.action_toggle_label = qAction("", "Show Labels",
                                           "Toggle element labels.",
                                           self.viewspace.setLabelVisible)
        self.action_toggle_label.setCheckable(True)
        self.action_toggle_label.setChecked(
            self.viewspace.options.items["label"])
        self.action_toggle_scalebar = qAction(
            "", "Show Scalebar", "Toggle scalebar.",
            self.viewspace.setScalebarVisible)
        self.action_toggle_scalebar.setCheckable(True)
        self.action_toggle_scalebar.setChecked(
            self.viewspace.options.items["scalebar"])
        self.action_tool_calculator = qAction(
            "document-properties",
            "Calculator",
            "Open the calculator.",
            self.actionToolCalculator,
        )
        self.action_tool_drift = qAction(
            "document-properties",
            "Drift Compensation",
            "Open the drift compensation tool.",
            self.actionToolDrift,
        )
        self.action_tool_filter = qAction(
            "document-properties",
            "Filtering",
            "Open the filtering tool.",
            self.actionToolFilter,
        )
        self.action_tool_merge = qAction(
            "align-vertical-top",
            "Merge Tool",
            "Open tool for merging multiple images.",
            self.actionToolMerge,
        )
        self.action_tool_standards = qAction(
            "document-properties",
            "Calibration Standards",
            "Open the standards calibration tool.",
            self.actionToolStandards,
        )
        self.action_tool_overlay = qAction(
            "document-properties",
            "Image Overlay",
            "Open the overlay tool.",
            self.actionToolOverlay,
        )

        self.action_transform_flip_horizontal = qAction(
            "object-flip-horizontal",
            "Flip Horizontal",
            "Flip the image about vertical axis.",
            self.actionTransformFlipHorz,
        )
        self.action_transform_flip_vertical = qAction(
            "object-flip-vertical",
            "Flip Vertical",
            "Flip the image about horizontal axis.",
            self.actionTransformFlipVert,
        )
        self.action_transform_rotate_left = qAction(
            "object-rotate-left",
            "Rotate Left",
            "Rotate the image 90° counter clockwise.",
            self.actionTransformRotateLeft,
        )
        self.action_transform_rotate_right = qAction(
            "object-rotate-right",
            "Rotate Right",
            "Rotate the image 90° clockwise.",
            self.actionTransformRotateRight,
        )

        self.action_refresh = qAction("view-refresh", "Refresh",
                                      "Redraw documents.",
                                      self.viewspace.refresh)
        self.action_refresh.setShortcut("F5")
Beispiel #15
0
    def __init__(self, widget: LaserWidget):
        super().__init__(widget, orientation=QtCore.Qt.Vertical, apply_all=False)
        self.button_box.removeButton(
            self.button_box.button(QtWidgets.QDialogButtonBox.Apply)
        )

        self.graphics = MergeGraphicsView(self.viewspace.options, parent=self)
        self.graphics.setMouseTracking(True)

        self.list = MergeLaserList()
        self.list.rowElementChanged.connect(self.redrawRow)
        self.list.rowAlphaChanged.connect(self.updateRowAlpha)
        self.list.model().rowsMoved.connect(self.reassignZValues)

        self.button_add = QtWidgets.QPushButton("Add Laser")
        self.button_add.clicked.connect(self.addLaserDialog)

        box_align = QtWidgets.QGroupBox("Align Images")
        box_align.setLayout(QtWidgets.QVBoxLayout())

        self.action_align_auto = qAction(
            "view-refresh",
            "FFT Register",
            "Register all images to the topmost image.",
            self.alignImagesFFT,
        )
        self.action_align_horz = qAction(
            "align-vertical-top",
            "Left to Right",
            "Layout images in a horizontal line.",
            self.alignImagesLeftToRight,
        )
        self.action_align_vert = qAction(
            "align-horizontal-left",
            "Top to Bottom",
            "Layout images in a vertical line.",
            self.alignImagesTopToBottom,
        )

        self.button_align = qToolButton("align-horizontal-left", "Align Images")
        self.button_align.addAction(self.action_align_auto)
        self.button_align.addAction(self.action_align_horz)
        self.button_align.addAction(self.action_align_vert)

        layout_right = QtWidgets.QVBoxLayout()
        layout_right.addWidget(self.button_align)
        layout_right.addStretch(1)
        layout_right.addWidget(self.button_add)

        layout_graphics = QtWidgets.QVBoxLayout()
        layout_graphics.addWidget(self.graphics)

        layout_controls = QtWidgets.QHBoxLayout()
        layout_controls.addWidget(self.list, 1)
        # layout_controls.addWidget(self.button_add, 0)
        layout_controls.addLayout(layout_right)

        self.box_graphics.setLayout(layout_graphics)
        self.box_controls.setLayout(layout_controls)

        # Add the tool widgets laser, make unclosable
        self.list.addRow(self.widget.laser, close_button=False)

        self.refresh()