Esempio n. 1
0
    def _do_init(self, view_context: ImageProcessorPluginViewContext,
                 z_index: int) -> None:
        self._view_context = view_context

        self.new_component(
            define_line_plugin_cs.factory(
                model=self.presenter.define_line_plugin_model,
                view_context=view_context,
                tool_id=ToolID.SURFACE,
                color=(0.1, 0.8, 0.1),
                z_index=z_index,
            ), )

        tool_ref = view_context.get_tool_item(ToolID.SURFACE)
        self._tool_button_interior = Gtk.Grid(hexpand=True, vexpand=True)
        tool_ref.button_interior.add(self._tool_button_interior)

        tool_button_lbl = Gtk.Label(
            label='Surface line',
            vexpand=True,
            valign=Gtk.Align.CENTER,
        )
        self._tool_button_interior.add(tool_button_lbl)

        self._tool_button_interior.show_all()
Esempio n. 2
0
    def _do_init(self, view_context: ImageProcessorPluginViewContext, z_index: int) -> None:
        self._view_context = view_context

        self.new_component(
            define_region_plugin_cs.factory(
                model=self.presenter.define_region_plugin_model,
                view_context=view_context,
                tool_id=ToolID.DROP_REGION,
                color=(1.0, 0.1, 0.05),
                label='Drop region',
                z_index=z_index,
            ),
        )

        tool_ref = view_context.get_tool_item(ToolID.DROP_REGION)
        self._tool_button_interior = Gtk.Grid(hexpand=True, vexpand=True)
        tool_ref.button_interior.add(self._tool_button_interior)

        tool_button_lbl = Gtk.Label(
            label='Drop region',
            vexpand=True,
            valign=Gtk.Align.CENTER,
        )
        self._tool_button_interior.add(tool_button_lbl)

        self._tool_button_interior.show_all()
Esempio n. 3
0
    def _do_init(
        self,
        view_context: ImageProcessorPluginViewContext,
        tool_id: Any,
        color: Tuple[float, float, float],
        z_index: int,
    ) -> None:
        self._view_context = view_context
        self._tool_ref = view_context.get_tool_item(tool_id)

        view_context.render.connect(
            'cursor-up-event',
            lambda render, pos: self.presenter.cursor_up(pos),
        )

        view_context.render.connect(
            'cursor-down-event',
            lambda render, pos: self.presenter.cursor_down(pos),
        )

        view_context.render.connect(
            'cursor-motion-event',
            lambda render, pos: self.presenter.cursor_move(pos),
        )

        view_context.render.connect('key-press-event',
                                    self._hdl_render_key_press_event)

        self.bn_tool_button_is_active = self._tool_ref.bn_is_active

        self._render = view_context.render

        self._defined_ro = Line(
            stroke_color=color,
            stroke_width=2,
            draw_control_points=False,
            z_index=z_index,
        )
        self._render.add_render_object(self._defined_ro)

        self._dragging_ro = Line(
            stroke_color=color,
            stroke_width=1,
            draw_control_points=True,
            z_index=z_index,
        )
        self._render.add_render_object(self._dragging_ro)

        self.bn_dragging = GObjectPropertyBindable(
            g_obj=self._dragging_ro,
            prop_name='line',
        )

        self.bn_defined = GObjectPropertyBindable(
            g_obj=self._defined_ro,
            prop_name='line',
        )

        self.presenter.view_ready()
Esempio n. 4
0
    def _do_init(
        self,
        view_context: ImageProcessorPluginViewContext,
        tool_id: Any,
        color: Tuple[float, float, float],
        label: str,
        z_index: int,
    ) -> None:
        self._view_context = view_context
        self._tool_ref = view_context.get_tool_item(tool_id)

        view_context.render.connect(
            'cursor-up-event',
            lambda render, pos: self.presenter.cursor_up(pos),
        )

        view_context.render.connect(
            'cursor-down-event',
            lambda render, pos: self.presenter.cursor_down(pos),
        )

        view_context.render.connect(
            'cursor-motion-event',
            lambda render, pos: self.presenter.cursor_move(pos),
        )

        self.bn_tool_button_is_active = self._tool_ref.bn_is_active

        self._render = view_context.render

        self._defined_ro = RectangleWithLabel(
            border_color=color,
            border_width=2,
            label=label,
            z_index=z_index,
        )
        self._render.add_render_object(self._defined_ro)

        self._dragging_ro = Rectangle(
            border_color=color,
            border_width=1,
            z_index=z_index,
        )
        self._render.add_render_object(self._dragging_ro)

        self.bn_dragging = GObjectPropertyBindable(
            g_obj=self._dragging_ro,
            prop_name='extents',
        )

        self.bn_defined = GObjectPropertyBindable(
            g_obj=self._defined_ro,
            prop_name='extents',
        )

        self.presenter.view_ready()
Esempio n. 5
0
    def _do_init(
        self,
        view_context: ImageProcessorPluginViewContext,
        tool_id: Any,
        color: Tuple[float, float, float],
        label: str,
        z_index: int,
    ) -> None:
        self._view_context = view_context
        self._tool_ref = view_context.get_tool_item(tool_id)

        view_context.canvas.connect(
            'cursor-up',
            lambda canvas, pos: self.presenter.cursor_up(pos),
        )

        view_context.canvas.connect(
            'cursor-down',
            lambda canvas, pos: self.presenter.cursor_down(pos),
        )

        view_context.canvas.connect(
            'cursor-motion',
            lambda canvas, pos: self.presenter.cursor_move(pos),
        )

        self.bn_tool_button_is_active = self._tool_ref.bn_is_active

        self._canvas = view_context.canvas

        self._defined_rect = RectangleArtist(
            stroke_color=color,
            stroke_width=1,
            scale_strokes=True,
        )
        self._canvas.add_artist(self._defined_rect, z_index=z_index)

        self._dragging_rect = RectangleArtist(
            stroke_color=color,
            stroke_width=1,
            scale_strokes=True,
        )
        self._canvas.add_artist(self._dragging_rect, z_index=z_index)

        self.bn_defined = GObjectPropertyBindable(
            g_obj=self._defined_rect,
            prop_name='extents',
        )

        self.bn_dragging = GObjectPropertyBindable(
            g_obj=self._dragging_rect,
            prop_name='extents',
        )

        self.presenter.view_ready()
Esempio n. 6
0
    def _do_init(
        self,
        view_context: ImageProcessorPluginViewContext,
        tool_id: Any,
        color: Tuple[float, float, float],
        z_index: int,
    ) -> None:
        self._view_context = view_context
        self._tool_ref = view_context.get_tool_item(tool_id)

        view_context.canvas.connect(
            'cursor-up',
            lambda canvas, pos: self.presenter.cursor_up(pos),
        )

        view_context.canvas.connect(
            'cursor-down',
            lambda canvas, pos: self.presenter.cursor_down(pos),
        )

        view_context.canvas.connect(
            'cursor-motion',
            lambda canvas, pos: self.presenter.cursor_move(pos),
        )

        view_context.canvas.connect(
            'key-press-event',
            self._hdl_canvas_key_press_event,
        )

        self.bn_tool_button_is_active = self._tool_ref.bn_is_active

        self._canvas = view_context.canvas

        self._defined_artist = LineArtist(
            stroke_color=color,
            stroke_width=1,
            scale_strokes=True,
        )
        self._canvas.add_artist(self._defined_artist, z_index=z_index)

        self._dragging_artist = LineArtist(
            stroke_color=color,
            stroke_width=1,
            scale_strokes=True,
        )
        self._canvas.add_artist(self._dragging_artist, z_index=z_index)

        self._control_point_artist = CircleArtist(
            fill_color=color,
            scale_radius=True,
        )
        self._canvas.add_artist(self._control_point_artist, z_index=z_index)

        self.bn_defined = GObjectPropertyBindable(
            g_obj=self._defined_artist,
            prop_name='line',
        )

        self.bn_dragging = GObjectPropertyBindable(
            g_obj=self._dragging_artist,
            prop_name='line',
        )

        self.presenter.view_ready()