Commit 2f836c09 authored by Radoslav Mráz's avatar Radoslav Mráz
Browse files

added a `bool` `auto_register` property to `Action` that indicates whether the appropriate parts

of MAPHIS should automatically register them (e.g. whether `LabelEditor` should register a `Tool` on its own)
parent ccc734a0
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -257,6 +257,7 @@ class MAPHIS(QMainWindow):
                tool_obj: Tool = tool_cls(self.state)
                tool_obj.set_tool_id(len(self.tools))
                self.tools.append(tool_obj)
                if tool_obj.auto_register:
                    self.label_editor.register_tool(tool_obj)
            # for tool in plugin.tools:
            #     self.label_editor.register_tool(tool)
+4 −0
Original line number Diff line number Diff line
@@ -69,6 +69,10 @@ class Action:
    def initialize(self) -> typing.Tuple[bool, str]:
        return True, ''

    @property
    def auto_register(self) -> bool:
        return True


class RegionComputation(Action):
    FOLDER = 'regions'
+2 −1
Original line number Diff line number Diff line
@@ -268,6 +268,7 @@ class LabelEditor(QObject):

    def register_tools(self, tools: typing.List[Tool]):
        for tool in tools:
            if tool.auto_register:
                self.register_tool(tool)

    def register_tool(self, tool: Tool):