How to use the gaphas.item.SE function in gaphas

To help you get started, we’ve selected a few gaphas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DLR-RM / RAFCON / tests / user_input / test_user_input_gaphas.py View on Github external
def south_east_coordinates_of_model(gaphas_view):
    from gaphas.item import Element, NW, NE, SE, SW
    i2v = gaphas_view.view.get_matrix_i2v(gaphas_view)
    x, y = i2v.transform_point(gaphas_view.handles()[SE].pos.x.value,
                               gaphas_view.handles()[SE].pos.y.value)
    return x, y
github gaphor / gaphor / gaphor / diagram / interactions / lifeline.py View on Github external
def setup_canvas(self):
        assert self.canvas

        super().setup_canvas()

        top = self.lifetime.top
        bottom = self.lifetime.bottom

        # create constraints to:
        # - keep bottom handle below top handle
        # - keep top and bottom handle in the middle of the head
        c1 = CenterConstraint(
            self._handles[SW].pos.x, self._handles[SE].pos.x, bottom.pos.x
        )

        c2 = EqualsConstraint(top.pos.x, bottom.pos.x, delta=0.0)

        c3 = EqualsConstraint(self._handles[SW].pos.y, top.pos.y, delta=0.0)
        self.lifetime._c_min_length = LessThanConstraint(
            top.pos.y, bottom.pos.y, delta=LifetimeItem.MIN_LENGTH
        )
        self.__constraints = (c1, c2, c3, self.lifetime._c_min_length)

        list(map(self.canvas.solver.add_constraint, self.__constraints))
github gaphor / gaphor / gaphor / diagram / diagramtoolbox.py View on Github external
item_factory=None,
            ),
            ToolDef(
                "toolbox-line",
                gettext("Line"),
                "gaphor-line-symbolic",
                "l",
                PlacementTool.new_item_factory(diagram.general.Line),
            ),
            ToolDef(
                "toolbox-box",
                gettext("Box"),
                "gaphor-box-symbolic",
                "b",
                PlacementTool.new_item_factory(diagram.general.Box),
                SE,
            ),
            ToolDef(
                "toolbox-ellipse",
                gettext("Ellipse"),
                "gaphor-ellipse-symbolic",
                "e",
                PlacementTool.new_item_factory(diagram.general.Ellipse),
                SE,
            ),
            ToolDef(
                "toolbox-comment",
                gettext("Comment"),
                "gaphor-comment-symbolic",
                "k",
                PlacementTool.new_item_factory(
                    diagram.general.CommentItem, UML.Comment
github gaphor / gaphor / gaphor / diagram / diagramtoolbox.py View on Github external
item_factory=PlacementTool.new_item_factory(
                    diagram.actions.ActionItem,
                    UML.Action,
                    config_func=namespace_config,
                ),
                handle_index=SE,
            ),
            ToolDef(
                "toolbox-initial-node",
                gettext("Initial node"),
                "gaphor-initial-node-symbolic",
                "j",
                item_factory=PlacementTool.new_item_factory(
                    diagram.actions.InitialNodeItem, UML.InitialNode
                ),
                handle_index=SE,
            ),
            ToolDef(
                "toolbox-activity-final-node",
                gettext("Activity final node"),
                "gaphor-activity-final-node-symbolic",
                "f",
                item_factory=PlacementTool.new_item_factory(
                    diagram.actions.ActivityFinalNodeItem, UML.ActivityFinalNode
                ),
                handle_index=SE,
            ),
            ToolDef(
                "toolbox-flow-final-node",
                gettext("Flow final node"),
                "gaphor-flow-final-node-symbolic",
                "w",
github gaphor / gaphor / gaphor / diagram / classes / interface.py View on Github external
draw_mode = self.DRAW_COMPARTMENT
            name_style = self.UNFOLDED_STYLE
        else:
            if self._folded == self.FOLDED_PROVIDED:
                icon_size = self.style.icon_size_provided
            else: # required interface or assembly icon mode
                icon_size = self.style.icon_size_required

            self.style.icon_size =  icon_size
            self.min_width, self.min_height = icon_size
            self.width, self.height = icon_size

            # update only h_se handle - rest of handles should be updated by
            # constraints
            h_nw = self._handles[NW]
            h_se = self._handles[SE]
            h_se.pos.x = h_nw.pos.x + self.min_width
            h_se.pos.y = h_nw.pos.y + self.min_height

            movable = False
            draw_mode = self.DRAW_ICON
            name_style = self.FOLDED_STYLE

        # call super method to avoid recursion (set_drawing_style calls
        # _set_folded method)
        super(InterfaceItem, self).set_drawing_style(draw_mode)
        self._name.style.update(name_style)

        for h in self._handles:
            h.movable = movable

        self.request_update()
github DLR-RM / RAFCON / source / rafcon / mvc / mygaphas / items / state.py View on Github external
def corner_handles(self):
        return [self.handles()[NW], self.handles()[NE], self.handles()[SW], self.handles()[SE]]
github DLR-RM / RAFCON / source / awesome_tool / mvc / views / gap / scope.py View on Github external
input_handle = Handle(left_center, connectable=True, movable=False)
        self._handles.append(input_handle)
        self._input_handle = input_handle
        input_port = PointPort(input_handle.pos)
        self._input_port = input_port
        self._ports.append(input_port)
        
        output_handle = Handle(right_center, connectable=True, movable=False)
        self._handles.append(output_handle)
        self._output_handle = output_handle
        output_port = PointPort(output_handle.pos)
        self._output_port = output_port
        self._ports.append(output_port)

        self.constraint(line=(input_handle.pos, (self._handles[NW].pos, self._handles[SW].pos)), align=0.5)
        self.constraint(line=(output_handle.pos, (self._handles[NE].pos, self._handles[SE].pos)), align=0.5)
github gaphor / gaphor / gaphor / diagram / classes / interface.py View on Github external
if folded == Folded.NONE:
            movable = True
        else:
            if self._folded == Folded.PROVIDED:
                icon_size = self.RADIUS_PROVIDED * 2
            else:  # required interface or assembly icon mode
                icon_size = self.RADIUS_REQUIRED * 2

            self.min_width, self.min_height = icon_size, icon_size
            self.width, self.height = icon_size, icon_size

            # update only h_se handle - rest of handles should be updated by
            # constraints
            h_nw = self._handles[NW]
            h_se = self._handles[SE]
            h_se.pos.x = h_nw.pos.x + self.min_width
            h_se.pos.y = h_nw.pos.y + self.min_height

            movable = False

        for h in self._handles:
            h.movable = movable

        self.update_shapes()
github DLR-RM / RAFCON / source / rafcon / gui / mygaphas / items / state.py View on Github external
def add_rect_constraint_for_port(self, port):
        constraint = PortRectConstraint((self.handles()[NW].pos, self.handles()[SE].pos), port.pos, port)
        solver = self.canvas.solver
        solver.add_constraint(constraint)
        self.port_constraints[port] = constraint