Example #1
0
 def __init__(self, view, item_factory, after_handler=None, handle_index=-1):
     """
     item_factory is a callable. It is used to create a CanvasItem
     that is displayed on the diagram.
     """
     _PlacementTool.__init__(self, view, factory=item_factory,
                                   handle_tool=ConnectHandleTool(),
                                   handle_index=handle_index)
     self.after_handler = after_handler
     self._tx = None
Example #2
0
 def __init__(self, view, item_factory, after_handler=None, handle_index=-1):
     """
     item_factory is a callable. It is used to create a CanvasItem
     that is displayed on the diagram.
     """
     _PlacementTool.__init__(self, view, factory=item_factory,
                                   handle_tool=ConnectHandleTool(),
                                   handle_index=handle_index)
     self.after_handler = after_handler
     self._tx = None
Example #3
0
 def __init__(self, view, item_factory, event_manager, handle_index=-1):
     """
     item_factory is a callable. It is used to create a CanvasItem
     that is displayed on the diagram.
     """
     _PlacementTool.__init__(
         self,
         view,
         factory=item_factory,
         handle_tool=ConnectHandleTool(),
         handle_index=handle_index,
     )
     self.event_manager = event_manager
     self._parent = None
Example #4
0
    def on_button_press(self, event):
        assert not self._tx
        self._tx = Transaction()
        view = self.view
        view.unselect_all()
        if _PlacementTool.on_button_press(self, event):
            try:
                opposite = self.new_item.opposite(
                    self.new_item.handles()[self._handle_index])
            except (KeyError, AttributeError):
                pass
            else:
                # Connect opposite handle first, using the HandleTool's
                # mechanisms

                # First make sure all matrices are updated:
                view.canvas.update_matrix(self.new_item)
                view.update_matrix(self.new_item)

                vpos = event.x, event.y

                item = self.handle_tool.glue(self.new_item, opposite, vpos)
                if item:
                    self.handle_tool.connect(self.new_item, opposite, vpos)
            return True
        return False
Example #5
0
    def on_button_press(self, event):
        assert not self._tx
        self._tx = Transaction()
        view = self.view
        view.unselect_all()
        if _PlacementTool.on_button_press(self, event):
            try:
                opposite = self.new_item.opposite(self.new_item.handles()[self._handle_index])
            except (KeyError, AttributeError):
                pass
            else:
                # Connect opposite handle first, using the HandleTool's
                # mechanisms

                # First make sure all matrices are updated:
                view.canvas.update_matrix(self.new_item)
                view.update_matrix(self.new_item)

                vpos = event.x, event.y

                item = self.handle_tool.glue(self.new_item, opposite, vpos)
                if item:
                    self.handle_tool.connect(self.new_item, opposite, vpos)
            return True
        return False
Example #6
0
 def on_button_release(self, event):
     try:
         if self.after_handler:
             self.after_handler(self.new_item)
         return _PlacementTool.on_button_release(self, event)
     finally:
         self._tx.commit()
         self._tx = None
Example #7
0
 def on_button_release(self, event):
     try:
         if self.after_handler:
             self.after_handler(self.new_item)
         return _PlacementTool.on_button_release(self, event)
     finally:
         self._tx.commit()
         self._tx = None
Example #8
0
    def add_pose(self):
        position = np.empty((3, 1), dtype=np.float64)

        for i in range(1, 4):
            entry = self.builder.get_object("NewPose2DEntry{}".format(i))
            text = entry.get_text()
            print(text)

            try:
                value = float(text)
            except:
                print("Error in entry {}".format(i))
                entry.set_text("")
                return

            position[i - 1] = value

        self.view.tool.grab(
            PlacementTool(self.view,
                          self._add_pose(self.view.canvas, position),
                          HandleTool(), 0))
Example #9
0
 def on_clicked(button):
     view.tool.grab(PlacementTool(factory(view, Line), HandleTool(), 1))
Example #10
0
 def on_clicked(button, view):
     #view.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.CROSSHAIR))
     view.tool.grab(PlacementTool(factory(view, DefaultBlockItem), HandleTool(), 2))
Example #11
0
 def on_button_release(self, event):
     if self.after_handler:
         self.after_handler(self.new_item)
     return _PlacementTool.on_button_release(self, event)
Example #12
0
 def on_clicked(button, view):
     # view.window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.CROSSHAIR))
     view.tool.grab(PlacementTool(view, factory(view, MyBox), HandleTool(), 2))
Example #13
0
 def add_landmark(self):
     self.view.tool.grab(
         PlacementTool(self.view, self._add_landmark(self.view.canvas),
                       HandleTool(), 0))