示例#1
0
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
        super(NoEditorWidget, self).setupUi(self)

        self.new_project_button.clicked.connect(
            ActionManager.action(Id("NewProject")).trigger)
        self.open_project_btn.clicked.connect(
            ActionManager.action(Id("OpenProject")).trigger)
        self.open_image_btn.clicked.connect(
            ActionManager.action(Id("OpenProjectAs")).trigger)
示例#2
0
    def _create_context_menu(self) -> QMenu:
        menu = QMenu(self.parentWidget())

        self.cancel_select_action = create_action(menu, "取消选择")
        self.reverse_select_action = create_action(menu, "选择反向")
        self.as_mark_item_action = ActionManager.action(Id("AsOutline"))

        self.cancel_select_action.triggered.connect(self.cancel_selection_signal)
        self.as_mark_item_action.triggered.connect(self.as_mark_item_signal)
        self.reverse_select_action.triggered.connect(self.reverse_select_signal)
        self.reverse_select_action.setEnabled(False)

        add_actions(menu, (self.cancel_select_action, self.reverse_select_action, None,
                           self.as_mark_item_action, None))

        mark_menu = menu.addMenu("标注")
        self.origin_outline_action = ActionManager.action(Id("OriginOutline"))
        self.convex_outline_action = ActionManager.action(Id("ConvexOutline"))
        self.polygon_outline_action = ActionManager.action(Id("PolygonOutline"))
        outline_actions = (self.origin_outline_action, self.convex_outline_action, self.polygon_outline_action)
        add_actions(mark_menu, outline_actions)

        correction_menu = menu.addMenu("轮廓微调")
        correction_actions = (ActionManager.action(Id("AddOutlineCorrection")),
                              ActionManager.action(Id("RemoveOutlineCorrection")))
        add_actions(correction_menu, correction_actions)

        menu.aboutToShow.connect(self._update_context_menu)
        return menu
示例#3
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        super(MainWindow, self)._init_ui(self)
        self.setWindowIcon(QIcon(":/app-icon.png"))

        self._action_manager = ActionManager.instance(self)
        self._undo_group = QUndoGroup(self)
        self.cmp_browser_dock = None
        self._preferences_dialog = None
        self._undo_widget.set_group(self._undo_group)

        # undo redo action 要重新create
        self.undo_action = self._undo_group.createUndoAction(self)
        self.redo_action = self._undo_group.createRedoAction(self)
        self.undo_action.setText("撤销")
        self.undo_action.setShortcut("Ctrl+Z")
        self.redo_action.setText("重做")
        self.redo_action.setShortcut("Ctrl+Shift+Z")

        self.edit_menu.insertAction(self.edit_menu.actions()[0], self.undo_action)
        self.edit_menu.insertAction(self.undo_action, self.redo_action)
        self.edit_menu.insertSeparator(self.edit_menu.actions()[2])
        self.__register_actions()

        self._has_editor = False

        self._property_dock = PropertyBrowserDock(parent=self)
        self._property_dock.setAllowedAreas(Qt.RightDockWidgetArea | Qt.LeftDockWidgetArea)
        self.addDockWidget(Qt.LeftDockWidgetArea, self._property_dock)
        self.project_dock_widget.current_item_changed_signal.connect(self._property_dock.set_browser)

        self._main_toolbar = MainToolBar(self)
        self.addToolBar(self._main_toolbar)
        self._tools_toolbar = ToolsToolBar(self)

        self._selection_toolbar = self._tools_toolbar.selection_toolbar()
        self._eraser_toolbar = self._tools_toolbar.eraser_toolbar()
        self.toolbar_gadget = ToolbarState.NONE_SELECTED

        self.window_state_data = WindowStateData()
        self._connect_notify()
        self._load_initial_file()
        self._restore_data()
        self.update_actions()

        self._show_no_editor_widget()
示例#4
0
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtWidgets
from Manager.ActionManager import ActionManager
from Manager.Id import Id
from UILayer.MainWindowPk.NoEditorWidget.NoEditorWidgetUi import Ui_NoEditorWidget


class NoEditorWidget(QtWidgets.QWidget, Ui_NoEditorWidget):
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
        super(NoEditorWidget, self).setupUi(self)

        self.new_project_button.clicked.connect(
            ActionManager.action(Id("NewProject")).trigger)
        self.open_project_btn.clicked.connect(
            ActionManager.action(Id("OpenProject")).trigger)
        self.open_image_btn.clicked.connect(
            ActionManager.action(Id("OpenProjectAs")).trigger)


if __name__ == '__main__':
    import sys

    ActionManager.instance()
    app = QtWidgets.QApplication(sys.argv)
    no_editor_widget = NoEditorWidget()
    no_editor_widget.showMaximized()
    app.exec_()
示例#5
0
 def __register(self):
     ActionManager.register_action(self._replace, Id("ReplaceSelection"))
     ActionManager.register_action(self._add, Id("AddSelection"))
     ActionManager.register_action(self._subtract, Id("SubtractSelection"))
     ActionManager.register_action(self._intersect,
                                   Id("IntersectSelection"))
示例#6
0
 def __register(self):
     ActionManager.register_action(self._eraser_tool, Id("橡皮擦"))
     ActionManager.register_action(self._rectangle_tool, Id("矩形选择框"))
     ActionManager.register_action(self._eraser_tool, Id("多边形选择框"))
     ActionManager.register_action(self._eraser_tool, Id("魔法棒"))
示例#7
0
    def __init__(self, parent=None):
        super(ToolsToolBar, self).__init__(parent)

        self.setObjectName("ToolsTooBar")
        self.setWindowTitle("Tools Toolbar")
        self.setToolButtonStyle(Qt.ToolButtonFollowStyle)
        parent.addToolBar(self)

        self._browser_result_tool = QAction()
        self._eraser_tool = QAction()
        self._rectangle_tool = ActionManager.action(Id("Rectangle"))
        self._polygon_tool = ActionManager.action(Id("Polygon"))
        self._magic_tool = QAction()

        self._browser_result_tool.setIcon(QIcon(":/plugin.png"))
        self._browser_result_tool.setCheckable(True)
        self._browser_result_tool.setToolTip("预览结果")
        self._browser_result_tool.setData(ToolsToolBar.BrowserImageTool)

        self._eraser_tool.setIcon(QIcon(":/stock-tool-eraser.png"))
        self._eraser_tool.setCheckable(True)
        self._eraser_tool.setToolTip("橡皮擦")
        self._eraser_tool.setData(ToolsToolBar.EraserTool)

        self._rectangle_tool.setIcon(QIcon(":/stock-tool-rect-select.png"))
        self._rectangle_tool.setCheckable(True)
        self._rectangle_tool.setChecked(True)
        self._rectangle_tool.setToolTip("矩形选择框")
        self._rectangle_tool.setData(ToolsToolBar.RectangleTool)

        self._polygon_tool.setIcon(QIcon(":/tool-edit-polygons.png"))
        self._polygon_tool.setCheckable(True)
        self._polygon_tool.setToolTip("多边形选择框")
        self._polygon_tool.setData(ToolsToolBar.PolygonTool)

        self._magic_tool.setIcon(QIcon(":/stock-tool-fuzzy-select-22.png"))
        self._magic_tool.setCheckable(True)
        self._magic_tool.setToolTip("魔法棒")
        self._magic_tool.setData(ToolsToolBar.MagicTool)

        self._tools_group = QActionGroup(self)
        self._tools_group.addAction(self._eraser_tool)
        self._tools_group.addAction(self._rectangle_tool)
        self._tools_group.addAction(self._polygon_tool)
        self._tools_group.addAction(self._magic_tool)
        self._tools_group.addAction(self._browser_result_tool)

        self.addAction(self._browser_result_tool)
        self.addAction(self._eraser_tool)
        self.addAction(self._rectangle_tool)
        self.addAction(self._polygon_tool)
        self.addAction(self._magic_tool)

        self._tools_group.triggered.connect(self.checked_action_changed)
        self._tools_group.triggered.connect(self.tools_changed)
        self.__register()

        self._selection_option_toolbar = SelectionOptionToolBar(self)
        self._eraser_option_toolbar = EraserOptionToolBar(self)
        self.parent().addToolBar(self._selection_option_toolbar)
        self.parent().addToolBar(self._eraser_option_toolbar)
        self._eraser_option_toolbar.setHidden(True)

        self._selection_option_toolbar.selection_option_changed.connect(
            self.selection_option_changed)
        self._eraser_option_toolbar.eraser_size_changed.connect(
            self.eraser_size_changed)
示例#8
0
    def __init__(self, parent=None):
        QToolBar.__init__(self, parent)

        self._new_button = QToolButton(self)
        self._open_button = QToolButton(self)
        self._export_action = ActionManager.action(Id("Export"))
        self._save_action = ActionManager.action(Id("SaveProject"))
        self._undo_action = ActionManager.action(Id("Undo"))
        self._redo_action = ActionManager.action(Id("Redo"))

        new_menu = QMenu(self)
        new_menu.addAction(ActionManager.action(Id("NewProject")))
        # new_menu.addAction(ActionManager.action(Id("NewMarkItem")))
        self._new_button.setMenu(new_menu)
        # 设置弹出模式 按下工具按钮时,菜单会立即显示。 在此模式下,不会触发按钮自己的操作。
        self._new_button.setPopupMode(QToolButton.InstantPopup)

        open_menu = QMenu(self)
        open_menu.addAction(ActionManager.action(Id("OpenProject")))
        open_menu.addAction(ActionManager.action(Id("OpenOriginalImage")))
        # open_menu.addAction(ActionManager.action(Id("OpenMarkFile")))
        self._open_button.setMenu(open_menu)
        self._open_button.setPopupMode(QToolButton.InstantPopup)

        self.setObjectName("ManTooBar")
        self.setWindowTitle("Main Toolbar")
        self.setToolButtonStyle(Qt.ToolButtonFollowStyle)

        new_icon = QIcon(":/document-new.png")
        open_icon = QIcon(":/document-open.png")
        save_icon = QIcon(":/document-save.png")
        export_icon = QIcon(":/daochu.png")
        undo_icon = QIcon(":/edit-undo.png")
        redo_icon = QIcon(":/edit-redo.png")

        # new_icon.addFile(":/document-new.png")
        # open_icon.addFile(":/document-open.png")
        # save_icon.addFile(":/document-save.png")
        # undo_icon.addFile(":/edit-undo.png")
        # redo_icon.addFile(":/edit-redo.png")

        self._new_button.setIcon(new_icon)
        self._new_button.setToolTip("新建")
        self._open_button.setIcon(open_icon)
        self._open_button.setToolTip("打开")
        self._export_action.setIcon(export_icon)
        self._export_action.setToolTip("导出结果")
        self._save_action.setIcon(save_icon)
        self._save_action.setToolTip("保存")
        self._undo_action.setIcon(undo_icon)
        self._undo_action.setToolTip("撤销")
        self._redo_action.setIcon(redo_icon)
        self._redo_action.setToolTip("重做")

        # 优先级
        self._redo_action.setPriority(QAction.LowPriority)

        self.addWidget(self._new_button)
        self.addWidget(self._open_button)
        self.addAction(self._export_action)
        self.addAction(self._save_action)
        self.addSeparator()
        self.addAction(self._undo_action)
        self.addAction(self._redo_action)

        self.orientationChanged.connect(
            self.orientation_changed)  # toolbar方向改变

        self._restranslateUi()
示例#9
0
    def __register_actions(self):
        ActionManager.register_menu(self.file_menu, Id("File"))
        ActionManager.register_menu(self.edit_menu, Id("Edit"))
        ActionManager.register_menu(self.project_menu, Id("Project"))
        ActionManager.register_menu(self.graph_menu, Id("Graph"))
        ActionManager.register_menu(self.mark_menu, Id("Mark"))
        ActionManager.register_menu(self.cmp_menu, Id("Comp"))
        ActionManager.register_menu(self.help_menu, Id("Help"))
        ActionManager.register_menu(self.view_menu, Id("View"))
        ActionManager.register_menu(self.outline_correction_menu, Id("OutlineCorrection"))

        ActionManager.register_action(self.new_project_action, Id("NewProject"))
        ActionManager.register_action(self.open_project_action, Id("OpenProject"))
        ActionManager.register_action(self.open_original_image_action, Id("OpenOriginalImage"))
        ActionManager.register_action(self.open_project_as_action, Id("OpenProjectAs"))
        ActionManager.register_action(self.save_project_action, Id("SaveProject"))
        ActionManager.register_action(self.save_project_as_action, Id("SaveProjectAs"))
        ActionManager.register_action(self.save_all_action, Id("SaveAll"))
        ActionManager.register_action(self.close_project_action, Id("CloseProject"))
        ActionManager.register_action(self.close_action, Id("Close"))
        ActionManager.register_action(self.close_all_action, Id("CloseALl"))
        ActionManager.register_action(self.import_action, Id("Import"))
        ActionManager.register_action(self.export_action, Id("Export"))
        ActionManager.register_action(self.project_info_action, Id("ProjectInfo"))
        ActionManager.register_action(self.quit_action, Id("Quit"))
        ActionManager.register_action(self.undo_action, Id("Undo"))
        ActionManager.register_action(self.redo_action, Id("Redo"))
        ActionManager.register_action(self.reference_action, Id("Reference"))
        ActionManager.register_action(self.quick_find_action, Id("QuickFind"))
        ActionManager.register_action(self.quick_replace_action, Id("QuickReplace"))
        ActionManager.register_action(self.quick_find_in_file_action, Id("QuickFindInFile"))
        ActionManager.register_action(self.quick_replace_in_file_action, Id("QuickReplaceInFile"))
        ActionManager.register_action(self.new_mark_action, Id("NewMark"))
        ActionManager.register_action(self.new_mark_from_action, Id("NewMarkFrom"))
        ActionManager.register_action(self.size_action, Id("Size"))
        ActionManager.register_action(self.bmp_action, Id("Bmp"))
        ActionManager.register_action(self.gray_action, Id("Gray"))
        ActionManager.register_action(self.rgb_action, Id("RGB"))
        ActionManager.register_action(self.bright_action, Id("Bright"))
        ActionManager.register_action(self.rotate_180_action, Id("Rotate180"))
        ActionManager.register_action(self.rotate_clockwise90_action, Id("RotateClockwise90"))
        ActionManager.register_action(self.rotate_counterclockwise90_action, Id("RotateCounterClockwise90"))
        ActionManager.register_action(self.rotate_any_action, Id("RotateAny"))
        ActionManager.register_action(self.rectangle_action, Id("Rectangle"))
        ActionManager.register_action(self.polygon_action, Id("Polygon"))
        ActionManager.register_action(self.origin_outline_action, Id("OriginOutline"))
        ActionManager.register_action(self.convex_outline_action, Id("ConvexOutline"))
        ActionManager.register_action(self.polygon_outline_action, Id("PolygonOutline"))
        ActionManager.register_action(self.woodland_outline_action, Id("AiOutline"))
        ActionManager.register_action(self.as_outline_action, Id("AsOutline"))

        ActionManager.register_action(self.add_outline_correction, Id("AddOutlineCorrection"))
        ActionManager.register_action(self.remove_outline_correction, Id("RemoveOutlineCorrection"))

        ActionManager.register_action(self.erosion_area_action, Id("ErosionArea"))
        ActionManager.register_action(self.girth_area_action, Id("GirthArea"))
        ActionManager.register_action(self.cmp_history_action, Id("CmpHistory"))
        ActionManager.register_action(self.help_about_action, Id("HelpAbout"))
        ActionManager.register_action(self.help_help_action, Id("HelpHelp"))

        ActionManager.register_action(self.delete_mark_item_action, Id("DeleteMarkItem"))

        ActionManager.register_action(self.project_dock_action, Id("ProjectDock"))
        ActionManager.register_action(self.property_dock_action, Id("PropertyDock"))
        ActionManager.register_action(self.history_dock_action, Id("HistoryDock"))