コード例 #1
0
ファイル: central_widget.py プロジェクト: R4GIS/DotDotGoose
    def __init__(self, parent=None):
        QtWidgets.QDialog.__init__(self)
        self.setupUi(self)
        self.canvas = Canvas()

        self.point_widget = PointWidget(self.canvas, self)
        self.findChild(QtWidgets.QGroupBox, 'groupBoxPointWidget').layout().addWidget(self.point_widget)

        self.graphicsView.setScene(self.canvas)
        self.graphicsView.load_image.connect(self.canvas.load_image)
        self.graphicsView.region_selected.connect(self.canvas.select_points)
        self.graphicsView.delete_selection.connect(self.canvas.delete_selected_points)
        self.graphicsView.relabel_selection.connect(self.canvas.relabel_selected_points)
        self.graphicsView.toggle_points.connect(self.point_widget.checkBoxDisplayPoints.toggle)

        self.graphicsView.add_point.connect(self.canvas.add_point)
        self.canvas.image_loaded.connect(self.graphicsView.image_loaded)

        # Image data fields
        self.canvas.image_loaded.connect(self.display_coordinates)
        self.canvas.image_loaded.connect(self.get_custom_field_data)
        self.canvas.fields_updated.connect(self.display_custom_fields)
        self.lineEditX.textEdited.connect(self.update_coordinates)
        self.lineEditY.textEdited.connect(self.update_coordinates)

        self.pushButtonAddField.clicked.connect(self.add_field_dialog)
        self.pushButtonDeleteField.clicked.connect(self.delete_field_dialog)
コード例 #2
0
    def __init__(self, parent=None):
        QtWidgets.QDialog.__init__(self)
        self.setupUi(self)
        self.canvas = Canvas()

        self.point_widget = PointWidget(self.canvas, self)
        self.findChild(QtWidgets.QFrame,
                       'framePointWidget').layout().addWidget(
                           self.point_widget)
        self.point_widget.hide_custom_fields.connect(self.hide_custom_fields)

        self.up_arrow = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_Up), self)
        self.up_arrow.setContext(QtCore.Qt.WidgetWithChildrenShortcut)
        self.up_arrow.activated.connect(self.point_widget.previous)

        self.down_arrow = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key_Down), self)
        self.down_arrow.setContext(QtCore.Qt.WidgetWithChildrenShortcut)
        self.down_arrow.activated.connect(self.point_widget.next)

        self.graphicsView.setScene(self.canvas)
        self.graphicsView.drop_complete.connect(self.canvas.load)
        self.graphicsView.region_selected.connect(self.canvas.select_points)
        self.graphicsView.delete_selection.connect(
            self.canvas.delete_selected_points)
        self.graphicsView.relabel_selection.connect(
            self.canvas.relabel_selected_points)
        self.graphicsView.toggle_points.connect(
            self.point_widget.checkBoxDisplayPoints.toggle)
        self.graphicsView.toggle_grid.connect(
            self.point_widget.checkBoxDisplayGrid.toggle)
        self.graphicsView.switch_class.connect(
            self.point_widget.set_active_class)

        self.graphicsView.add_point.connect(self.canvas.add_point)
        self.canvas.image_loaded.connect(self.graphicsView.image_loaded)
        self.canvas.directory_set.connect(self.display_working_directory)

        # Image data fields
        self.canvas.image_loaded.connect(self.display_coordinates)
        self.canvas.image_loaded.connect(self.get_custom_field_data)
        self.canvas.fields_updated.connect(self.display_custom_fields)
        self.lineEditX.textEdited.connect(self.update_coordinates)
        self.lineEditY.textEdited.connect(self.update_coordinates)

        self.pushButtonAddField.clicked.connect(self.add_field_dialog)
        self.pushButtonDeleteField.clicked.connect(self.delete_field_dialog)
        self.pushButtonFolder.clicked.connect(self.select_folder)
        self.pushButtonZoomOut.clicked.connect(self.graphicsView.zoom_out)
        self.pushButtonZoomIn.clicked.connect(self.graphicsView.zoom_in)
コード例 #3
0
ファイル: central_widget.py プロジェクト: persts/DotDotGoose
    def __init__(self, parent=None):
        QtWidgets.QDialog.__init__(self)
        self.setupUi(self)
        self.canvas = Canvas()

        self.point_widget = PointWidget(self.canvas, self)
        self.findChild(QtWidgets.QFrame,
                       'framePointWidget').layout().addWidget(
                           self.point_widget)
        self.point_widget.hide_custom_fields.connect(self.hide_custom_fields)
        self.point_widget.saving.connect(self.display_quick_save)

        # Set up keyboard shortcuts
        self.save_shortcut = QtGui.QShortcut(
            QtGui.QKeySequence(self.tr("Ctrl+S")),
            self)  # quick save using Ctrl+S
        self.save_shortcut.setContext(
            QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
        self.save_shortcut.activated.connect(self.point_widget.quick_save)

        self.up_arrow = QtGui.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key.Key_Up), self)
        self.up_arrow.setContext(
            QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
        self.up_arrow.activated.connect(self.point_widget.previous)

        self.down_arrow = QtGui.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.Key.Key_Down), self)
        self.down_arrow.setContext(
            QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
        self.down_arrow.activated.connect(self.point_widget.next)

        # same as arrows but conventient for right handed people
        self.up_arrow = QtGui.QShortcut(QtGui.QKeySequence(self.tr("W")), self)
        self.up_arrow.setContext(
            QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
        self.up_arrow.activated.connect(self.point_widget.previous)

        self.down_arrow = QtGui.QShortcut(QtGui.QKeySequence(self.tr("S")),
                                          self)
        self.down_arrow.setContext(
            QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
        self.down_arrow.activated.connect(self.point_widget.next)

        # Make signal slot connections
        self.graphicsView.setScene(self.canvas)
        self.graphicsView.drop_complete.connect(self.canvas.load)
        self.graphicsView.region_selected.connect(self.canvas.select_points)
        self.graphicsView.delete_selection.connect(
            self.canvas.delete_selected_points)
        self.graphicsView.relabel_selection.connect(
            self.canvas.relabel_selected_points)
        self.graphicsView.toggle_points.connect(
            self.point_widget.checkBoxDisplayPoints.toggle)
        self.graphicsView.toggle_grid.connect(
            self.point_widget.checkBoxDisplayGrid.toggle)
        self.graphicsView.switch_class.connect(
            self.point_widget.set_active_class)
        self.graphicsView.add_point.connect(self.canvas.add_point)
        self.canvas.image_loaded.connect(self.graphicsView.image_loaded)
        self.canvas.directory_set.connect(self.display_working_directory)

        # Image data fields
        self.canvas.image_loaded.connect(self.display_coordinates)
        self.canvas.image_loaded.connect(self.get_custom_field_data)
        self.canvas.fields_updated.connect(self.display_custom_fields)
        self.lineEditX.textEdited.connect(self.update_coordinates)
        self.lineEditY.textEdited.connect(self.update_coordinates)

        # Buttons
        self.pushButtonAddField.clicked.connect(self.add_field_dialog)
        self.pushButtonDeleteField.clicked.connect(self.delete_field_dialog)
        self.pushButtonFolder.clicked.connect(self.select_folder)
        self.pushButtonZoomOut.clicked.connect(self.graphicsView.zoom_out)
        self.pushButtonZoomIn.clicked.connect(self.graphicsView.zoom_in)

        # Fix icons since no QRC file integration
        self.pushButtonFolder.setIcon(QtGui.QIcon('icons:folder.svg'))
        self.pushButtonZoomIn.setIcon(QtGui.QIcon('icons:zoom_in.svg'))
        self.pushButtonZoomOut.setIcon(QtGui.QIcon('icons:zoom_out.svg'))
        self.pushButtonDeleteField.setIcon(QtGui.QIcon('icons:delete.svg'))
        self.pushButtonAddField.setIcon(QtGui.QIcon('icons:add.svg'))

        self.quick_save_frame = QtWidgets.QFrame(self.graphicsView)
        self.quick_save_frame.setStyleSheet(
            "QFrame { background: #4caf50;color: #FFF;font-weight: bold}")
        self.quick_save_frame.setLayout(QtWidgets.QHBoxLayout())
        self.quick_save_frame.layout().addWidget(QtWidgets.QLabel('Saving...'))
        self.quick_save_frame.setGeometry(3, 3, 100, 35)
        self.quick_save_frame.hide()
コード例 #4
0
ファイル: central_widget.py プロジェクト: pangeorg/DotDotIC
    def __init__(self, parent=None):
        from functools import partial
        _translate = QtCore.QCoreApplication.translate
        QtWidgets.QDialog.__init__(self)
        self.setupUi(self)
        self.canvas = Canvas()

        self.point_widget = PointWidget(self.canvas, self)
        self.findChild(QtWidgets.QFrame,
                       'framePointWidget').layout().addWidget(
                           self.point_widget)
        self.point_widget.hide_custom_fields.connect(self.hide_custom_fields)
        self.point_widget.saving.connect(self.display_quick_save)
        self.point_widget.class_selection_changed.connect(
            self.display_attributes)
        self.point_widget.lineEditSurveyId.textEdited.connect(
            self.set_survey_id)

        self.save_shortcut = QtWidgets.QShortcut(
            QtGui.QKeySequence(self.tr("Ctrl+S")),
            self)  # quick save using Ctrl+S
        self.save_shortcut.setContext(QtCore.Qt.WidgetWithChildrenShortcut)
        self.save_shortcut.activated.connect(self.point_widget.quick_save)

        self.graphicsView.setScene(self.canvas)
        self.graphicsView.drop_complete.connect(self.canvas.load)
        self.graphicsView.region_selected.connect(self.canvas.select)
        self.graphicsView.delete_selection.connect(
            self.canvas.delete_selection)
        self.graphicsView.clear_selection.connect(self.canvas.clear_selection)
        self.graphicsView.relabel_selection.connect(
            self.canvas.relabel_selection)
        self.graphicsView.measure_area.connect(self.canvas.measure_area)
        self.graphicsView.toggle_points.connect(
            self.point_widget.checkBoxDisplayPoints.toggle)
        self.graphicsView.toggle_grid.connect(
            self.point_widget.checkBoxDisplayGrid.toggle)
        self.graphicsView.scale_selected.connect(self.set_scale)
        self.graphicsView.select_class.connect(
            self.point_widget.select_tree_item_from_name)
        self.graphicsView.add_class.connect(
            lambda: self.point_widget.add_class(askname=False))
        self.graphicsView.search.connect(self.search)
        self.canvas.edit_style_selected.connect(
            self.graphicsView._set_edit_style)

        self.graphicsView.add_point.connect(self.canvas.add_point)
        self.graphicsView.display_pointer_coordinates.connect(
            self.display_pointer_coordinates)
        self.graphicsView.find_point.connect(self.find_point)
        self.canvas.image_loaded.connect(self.graphicsView.image_loaded)
        self.canvas.directory_set.connect(self.display_working_directory)
        self.canvas.rect_size_changed.connect(
            self.update_component_size_from_canvas)

        # Image data fields
        self.canvas.image_loaded.connect(self.display_coordinates)
        self.canvas.image_loaded.connect(self.display_attributes)
        self.canvas.fields_updated.connect(self.display_attributes)

        self.dataLineEditsNames = [
            "lineEdit_ecu", "lineEdit_pcb", "comboBox_pos", "lineEditX",
            "lineEditY"
        ]
        pcbAttr = ["ECU Name", "PCB Name", "Side", "Length", "Width"]

        self.attribute_widget_names = [
            "comboBox_manufacturer", "lineEdit_partnumber", "comboBox_family",
            "lineEdit_description", "lineEdit_specifications",
            "comboBox_package", "lineEdit_pincount", "lineEdit_marking",
            "lineEdit_diameter", "lineEdit_length", "lineEdit_width",
            "lineEdit_height", "break", "comboBox_placement",
            "comboBox_metrik", "lineEdit_Researchprice",
            "lineEdit_Researchvol", "lineEdit_ResearchSource",
            "lineEdit_stdRef"
        ]

        self.attribute_names = [
            "Manufacturer", "Mfr. Partnumber", "Component Family",
            "Description", "Specifications", "Package", "Pin Count", "Marking",
            "Diameter", "Length", "Width", "Height", "Costing", "Placement",
            "Metrik", "Research Price [$]", "Research Volume [k]",
            "Research Source", "Std. Comp. Reference"
        ]

        value_types = {
            "Diameter": "float",
            "Length": "float",
            "Width": "float",
            "Height": "float",
            "Research Price [$]": "float",
            "Research Volume [k]": "float"
        }

        for i, k in enumerate(self.dataLineEditsNames):
            box = self.groupBoxImageData
            layout = self.gridLayout_2
            if "line" in k:
                widget = LineEdit(box, available_actions=["Copy", "Paste"])
                widget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
                widget.setAcceptDrops(False)
                widget.setObjectName(k)
                widget.setDisabled(True)
                widget.returnPressed.connect(self.cycle_edits)
                if "X" in k or "Y" in k:
                    widget.textEdited.connect(self.update_pcb_info)
                else:
                    widget.returnPressed.connect(self.update_ecu_name)
            else:
                widget = QtWidgets.QComboBox()
                widget.addItems(["Top", "Bottom"])
                widget.setDisabled(True)
                widget.setCurrentIndex(0)
                widget.activated.connect(self.update_ecu_name)
            layout.addWidget(widget, i, 1, 1, 1)

            label = QtWidgets.QLabel(box)
            sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Preferred)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(
                label.sizePolicy().hasHeightForWidth())
            label.setSizePolicy(sizePolicy)
            label.setText(_translate("CentralWidget", pcbAttr[i]))
            layout.addWidget(label, i, 0, 1, 1)
            setattr(self, k, widget)

        self.attribute_widgets = {}
        for i, k in enumerate(self.attribute_widget_names):
            box = self.groupBoxCustomFields
            layout = self.gridLayout
            if "line" in k:
                value_type = value_types.get(self.attribute_names[i], "string")
                widget = LineEdit(box, value_type=value_type)
                widget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
                widget.setAcceptDrops(False)
                widget.setObjectName(k)
                widget.setDisabled(True)
                widget.textEdited.connect(
                    partial(self.update_attributes, name=k))
                widget.returnPressed.connect(self.cycle_edits)
                widget.copy_all_signal.connect(self.copy_all_attributes)
                widget.paste_all_signal.connect(self.paste_all_attributes)
                widget.setFrame(False)
            elif "combo" in k:
                widget = QtWidgets.QComboBox(box)
                widget.setDisabled(True)
                widget.setObjectName(k)
                widget.setLineEdit(LineEdit())
                widget.currentTextChanged.connect(
                    partial(self.update_attributes, name=k))
                widget.currentIndexChanged.connect(
                    partial(self.update_attributes, name=k))
                widget.lineEdit().textEdited.connect(
                    partial(self.update_attributes, name=k))
                widget.lineEdit().returnPressed.connect(self.cycle_edits)
                widget.lineEdit().copy_all_signal.connect(
                    self.copy_all_attributes)
                widget.lineEdit().paste_all_signal.connect(
                    self.paste_all_attributes)
                widget.setFrame(False)
            elif k == "break":
                widget = QtWidgets.QFrame(box)
                widget.setFrameShape(QtWidgets.QFrame.HLine)
                # layout.addWidget(line, i, 1, 1, 1)
                # continue

            layout.addWidget(widget, i, 1, 1, 1)

            label = QtWidgets.QLabel(box)
            sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Preferred)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(
                label.sizePolicy().hasHeightForWidth())
            label.setSizePolicy(sizePolicy)
            if k != "break":
                label.setText(
                    _translate("CentralWidget", self.attribute_names[i]))
            else:
                label.setText("<b>" + self.attribute_names[i] + "</b>")
            layout.addWidget(label, i, 0, 1, 1)

            self.attribute_widgets[self.attribute_names[i]] = widget
            setattr(self, k, widget)
            setattr(
                self,
                k.replace("lineEdit", "label").replace("comboBox", "label"),
                label)

        self.info_widgets = self.dataLineEditsNames.copy()
        self.info_widgets.extend(self.attribute_widget_names)
        self.set_tool_tips()

        package_completer = QtWidgets.QCompleter(completion.packages)
        package_completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
        self.comboBox_package.lineEdit().setCompleter(package_completer)
        self.comboBox_package.addItems(completion.packages)
        self.comboBox_package.setCurrentText("")
        package_completer.setCompletionMode(
            QtWidgets.QCompleter.PopupCompletion)

        manufacturer_completer = QtWidgets.QCompleter(completion.manufacturers)
        manufacturer_completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
        self.comboBox_manufacturer.lineEdit().setCompleter(
            manufacturer_completer)
        self.comboBox_manufacturer.addItems(completion.manufacturers)
        self.comboBox_manufacturer.setCurrentText("")
        manufacturer_completer.setCompletionMode(
            QtWidgets.QCompleter.PopupCompletion)

        metrik_completer = QtWidgets.QCompleter(completion.metriks)
        metrik_completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
        self.comboBox_metrik.lineEdit().setCompleter(metrik_completer)
        self.comboBox_metrik.addItems(completion.metriks)
        self.comboBox_metrik.setCurrentText("")
        metrik_completer.setCompletionMode(
            QtWidgets.QCompleter.PopupCompletion)

        placement_list = list(sorted(completion.placement))
        placement_completer = QtWidgets.QCompleter(sorted(placement_list))
        placement_completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
        self.comboBox_placement.lineEdit().setCompleter(placement_completer)
        self.comboBox_placement.addItems(placement_list)
        self.comboBox_placement.setCurrentText("")
        placement_completer.setCompletionMode(
            QtWidgets.QCompleter.PopupCompletion)

        # self.pushButtonFolder.clicked.connect(self.select_folder)
        self.pushButtonZoomOut.clicked.connect(self.graphicsView.zoom_out)
        self.pushButtonZoomIn.clicked.connect(self.graphicsView.zoom_in)

        self.quick_save_frame = QtWidgets.QFrame(self.graphicsView)
        self.quick_save_frame.setStyleSheet(
            "QFrame { background: #4caf50;color: #FFF;font-weight: bold}")
        self.quick_save_frame.setLayout(QtWidgets.QHBoxLayout())
        self.quick_save_frame.layout().addWidget(QtWidgets.QLabel('Saving...'))
        self.quick_save_frame.setGeometry(3, 3, 100, 35)
        self.quick_save_frame.hide()

        # add toolbar
        self.toolBar = QtWidgets.QToolBar()
        self.toolLayout.addWidget(self.toolBar)
        self.toolButtons = []