How to use the gaphas.aspect.InMotion 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 / source / rafcon / gui / mygaphas / tools.py View on Github external
def movable_items(self):
        """Filter selection

        Filter items of selection that cannot be moved (i.e. are not instances of `Item`) and return the rest.
        """
        view = self.view

        if self._move_name_v:
            yield InMotion(self._item, view)
        else:
            selected_items = set(view.selected_items)
            for item in selected_items:
                if not isinstance(item, Item):
                    continue
                yield InMotion(item, view)
github gaphor / gaphor / gaphor / ui / diagramtools.py View on Github external
item = super()._create_item(pos, **kw)

            adapter = Group(parent, item)
            if parent and item and adapter:
                adapter.group()

                parent.request_update(matrix=False)
        finally:
            self._parent = None
            view.dropzone_item = None
            view.get_window().set_cursor(None)
        return item


@InMotion.register(ElementPresentation)
class DropZoneInMotion(GuidedItemInMotion):
    def move(self, pos):
        """
        Move the item. x and y are in view coordinates.
        """
        super().move(pos)
        item = self.item
        view = self.view
        x, y = pos

        current_parent = view.canvas.get_parent(item)
        over_item = view.get_item_at_point((x, y), selected=False)

        if not over_item:
            view.dropzone_item = None
            view.get_window().set_cursor(None)
github DLR-RM / RAFCON / source / rafcon / gui / mygaphas / guide.py View on Github external
def move(self, pos):
        if not self.item.moving:
            return
        super(GuidedStateInMotion, self).move(pos)
        parent_item = self.item.parent
        if parent_item:
            constraint = parent_item.keep_rect_constraints[self.item]
            self.view.canvas.solver.request_resolve_constraint(constraint)

    def stop_move(self):
        super(GuidedStateInMotion, self).stop_move()
        self.item.moving = False


@InMotion.when_type(NameView)
class GuidedNameInMotion(GuidedItemInMotion):
    def move(self, pos):
        super(GuidedNameInMotion, self).move(pos)
        parent_item = self.item.parent
        if parent_item:
            constraint = parent_item.keep_rect_constraints[self.item]
            self.view.canvas.solver.request_resolve_constraint(constraint)


@HandleInMotion.when_type(StateView)
class GuidedStateHandleInMotion(GuidedStateMixin, GuidedItemHandleInMotion):
    
    def glue(self, pos, distance=None):
        distance = distance if distance else self.GLUE_DISTANCE
        super(GuidedStateHandleInMotion, self).glue(pos, distance)
github DLR-RM / RAFCON / source / rafcon / gui / mygaphas / tools.py View on Github external
def movable_items(self):
        """Filter selection

        Filter items of selection that cannot be moved (i.e. are not instances of `Item`) and return the rest.
        """
        view = self.view

        if self._move_name_v:
            yield InMotion(self._item, view)
        else:
            selected_items = set(view.selected_items)
            for item in selected_items:
                if not isinstance(item, Item):
                    continue
                yield InMotion(item, view)
github DLR-RM / RAFCON / source / rafcon / gui / mygaphas / tools.py View on Github external
def movable_items(self):
        """Filter selection

        Filter items of selection that cannot be moved (i.e. are not instances of `Item`) and return the rest.
        """
        view = self.view

        if self._move_name_v:
            yield InMotion(self._item, view)
        else:
            selected_items = set(view.selected_items)
            for item in selected_items:
                if not isinstance(item, Item):
                    continue
                yield InMotion(item, view)
github gaphor / gaphor / gaphor / ui / groupingtools.py View on Github external
item = super(GroupPlacementTool, self)._create_item(pos, **kw)

            adapter = component.queryMultiAdapter((parent, item), IGroup)
            if parent and item and adapter:
                adapter.group()

                canvas = view.canvas
                parent.request_update(matrix=False)
        finally:
            self._parent = None
            view.dropzone_item = None
            view.window.set_cursor(None)
        return item


@InMotion.when_type(ElementItem)
class DropZoneInMotion(GuidedItemInMotion):


    def move(self, pos):
        """
        Move the item. x and y are in view coordinates.
        """
        super(DropZoneInMotion, self).move(pos)
        item = self.item
        view = self.view
        x, y = pos

        current_parent = view.canvas.get_parent(item)
        over_item = view.get_item_at_point((x, y), selected=False)

        if not over_item:
github gaphor / gaphor / gaphor / ui / diagramtools.py View on Github external
item = super(GroupPlacementTool, self)._create_item(pos, **kw)

            adapter = component.queryMultiAdapter((parent, item), IGroup)
            if parent and item and adapter:
                adapter.group()

                canvas = view.canvas
                parent.request_update(matrix=False)
        finally:
            self._parent = None
            view.dropzone_item = None
            view.window.set_cursor(None)
        return item


@InMotion.when_type(ElementItem)
class DropZoneInMotion(GuidedItemInMotion):


    def move(self, pos):
        """
        Move the item. x and y are in view coordinates.
        """
        super(DropZoneInMotion, self).move(pos)
        item = self.item
        view = self.view
        x, y = pos

        current_parent = view.canvas.get_parent(item)
        over_item = view.get_item_at_point((x, y), selected=False)

        if not over_item:
github DLR-RM / RAFCON / source / rafcon / mvc / controllers / graphical_editor_gaphas.py View on Github external
def on_drag_data_received(self, widget, context, x, y, data, info, time):
        """Receives state_id from LibraryTree and moves the state to the position of the mouse

        :param widget:
        :param context:
        :param x: Integer: x-position of mouse
        :param y: Integer: y-position of mouse
        :param data: SelectionData: contains state_id
        :param info:
        :param time:
        """
        item = self.canvas.get_view_for_model(self.model.selection.get_selected_state().states[data.get_text()])
        pos_start = item.model.meta['gui']['editor_gaphas']['rel_pos']
        motion = InMotion(item, self.view.editor)
        motion.start_move(self.view.editor.get_matrix_i2v(item).transform_point(pos_start[0], pos_start[1]))
        motion.move((x,y))
github DLR-RM / RAFCON / source / rafcon / gui / controllers / graphical_editor_gaphas.py View on Github external
:param widget:
        :param context:
        :param x: Integer: x-position of mouse
        :param y: Integer: y-position of mouse
        :param data: SelectionData: contains state_id
        :param info:
        :param time:
        """
        state_id_insert = data.get_text()
        parent_m = self.model.selection.get_selected_state()
        if not isinstance(parent_m, ContainerStateModel):
            return
        state_v = self.canvas.get_view_for_model(parent_m.states[state_id_insert])
        pos_start = state_v.model.get_meta_data_editor()['rel_pos']
        motion = InMotion(state_v, self.view.editor)
        motion.start_move(self.view.editor.get_matrix_i2v(state_v).transform_point(pos_start[0], pos_start[1]))
        motion.move((x, y))
        motion.stop_move()
        state_v.model.set_meta_data_editor('rel_pos', motion.item.position)
        self.canvas.wait_for_update(trigger_update=True)
        self._meta_data_changed(None, state_v.model, 'append_to_last_change', True)
github DLR-RM / RAFCON / source / rafcon / gui / mygaphas / tools.py View on Github external
def movable_items(self):
        """Filter selection

        Filter items of selection that cannot be moved (i.e. are not instances of `Item`) and return the rest.
        """
        view = self.view

        if self._move_name_v:
            yield InMotion(self._item, view)
        else:
            selected_items = set(view.selected_items)
            for item in selected_items:
                if not isinstance(item, Item):
                    continue
                yield InMotion(item, view)