Пример #1
0
 def translate(self, coordinate):
     """Translates all 2d cartesian coordinates in a layout given
     the (x,y) offset"""
     for obj in self.objs:
         obj.offset = vector(snap_to_grid(obj.offset - coordinate))
     for inst in self.insts:
         inst.offset = vector(snap_to_grid(inst.offset - coordinate))
Пример #2
0
 def __init__(self, layerNumber, offset, width, height):
     """Initializes a rectangular shape for specified layer"""
     geometry.__init__(self)
     self.name = "rect"
     self.layerNumber = layerNumber
     self.offset = snap_to_grid(offset)
     self.size = snap_to_grid([width, height])
     self.width = self.size[0]
     self.height = self.size[1]
Пример #3
0
 def translate(self, coordinate):
     """Translates all 2d cartesian coordinates in a layout given
     the (x,y) offset"""
     for obj in self.objs:
         obj.offset = snap_to_grid(
             [obj.offset[0] - coordinate.x, obj.offset[1] - coordinate.y])
     for inst in self.insts:
         inst.offset = snap_to_grid(
             [inst.offset[0] - coordinate.x, inst.offset[1] - coordinate.y])
Пример #4
0
    def on_mouse_move(self, event, position):
        if self.scroll_point:
            change = utils.make_vector(position, self.scroll_point)
            self.canvas.set_viewport(
                utils.vector_add(self.canvas.get_viewport(), change))
            return

        if self.drag_items:
            change = utils.make_vector(self.drag_mouse_origin, position)
            for i, item in enumerate(self.drag_items):
                new_position = utils.vector_add(self.drag_items_origin[i], change)
                new_position = utils.snap_to_grid(new_position, self.grid_size)
                item.set_position(new_position)
            self.canvas.redraw()
            return

        item = self.get_item_at_position(position)
        if item:
            self.canvas.set_cursor(get_cursor(item.action))
            if self.selection:
                self.mouseover_items = item.get_group()
                self.set_highlight()
        elif self.mouseover_items:
            self.canvas.set_cursor(None)
            self.mouseover_items = []
            self.set_highlight()
        else:
            self.canvas.set_cursor(None)
Пример #5
0
 def draw(self, cr):
     NetEditCanvasConfig.draw(self, cr)
     if self.mouse_position:
         position = utils.snap_to_grid(self.get_position(self.mouse_position), self.grid_size)
         placement = citems.AbsPlacement(position)
         box = citems.ElementBox(None, "", placement, self.element.default_size, self.element.default_radius)
         box.draw(cr)
Пример #6
0
    def on_mouse_left_up(self, event, position):
        item = self.get_item_at_position(position)
        if item:
            t = self.is_transition_box(item)
            p = self.is_place_box(item)
        else:
            t = False
            p = False

        if self.from_element is None:
            if t:
                for i in self.items:
                    i.inactive = not self.is_place_box(i)
            if p:
                for i in self.items:
                    i.inactive = not self.is_transition_box(i)
            if t or p:
                self.from_element = item
                self.mouse_position = position
                self.points = []
                self.canvas.redraw()
        elif item:
            if not item.inactive:
                edge = self.net.add_edge(self.from_element.owner, item.owner,
                                         self.points)
                self.from_element = None
                self.points = None
                self.neteditor.set_tool("selection", set_button=True)
                self.canvas.config.select_item(edge.line)
        else:
            position = utils.snap_to_grid(position, self.grid_size)
            self.points.append(position)
Пример #7
0
    def on_mouse_move(self, event, position):
        if self.scroll_point:
            change = utils.make_vector(position, self.scroll_point)
            self.canvas.set_viewport(
                utils.vector_add(self.canvas.get_viewport(), change))
            return

        if self.mass_selection_origin:
            self.mass_selection_cursor = position
            self.mouseover_items = self.get_items_in_mass_selection()
            self.set_highlight()
            return

        if self.drag_items:
            change = utils.make_vector(self.drag_mouse_origin, position)
            for i, item in enumerate(self.drag_items):
                new_position = utils.vector_add(self.drag_items_origin[i],
                                                change)
                new_position = utils.snap_to_grid(new_position, self.grid_size)
                item.set_position(new_position)
            self.canvas.redraw()
            return

        item = self.get_item_at_position(position)
        if item:
            self.canvas.set_cursor(get_cursor(item.action))
            if self.selection:
                self.mouseover_items = item.get_group()
                self.set_highlight()
        elif self.mouseover_items:
            self.canvas.set_cursor(None)
            self.mouseover_items = []
            self.set_highlight()
        else:
            self.canvas.set_cursor(None)
Пример #8
0
    def on_mouse_left_up(self, event, position):
        item = self.get_item_at_position(position)
        if item:
            t = self.is_transition_box(item)
            p = self.is_place_box(item)
        else:
            t = False
            p = False

        if self.from_element is None:
            if t:
                for i in self.items:
                    i.inactive = not self.is_place_box(i)
            if p:
                for i in self.items:
                    i.inactive = not self.is_transition_box(i)
            if t or p:
                self.from_element = item
                self.mouse_position = position
                self.points = []
                self.canvas.redraw()
        elif item:
            if not item.inactive:
                edge = self.net.add_edge(self.from_element.owner, item.owner, self.points)
                self.from_element = None
                self.points = None
                self.neteditor.set_tool("selection", set_button=True)
                self.canvas.config.select_item(edge.line)
        else:
            position = utils.snap_to_grid(position, self.grid_size)
            self.points.append(position)
Пример #9
0
 def __init__(self, name, mod, offset, mirror, rotate):
     """Initializes an instance to represent a module"""
     geometry.__init__(self)
     self.name = name
     self.mod = mod
     self.gds = mod.gds
     self.rotate = rotate
     self.offset = snap_to_grid(offset)
     self.mirror = mirror
Пример #10
0
 def __init__(self, text, layerNumber, offset, zoom=1):
     """Initializes a text label for specified layer"""
     geometry.__init__(self)
     self.name = "label"
     self.text = text
     self.layerNumber = layerNumber
     self.offset = snap_to_grid(offset)
     self.zoom = zoom
     self.size = 0
Пример #11
0
 def draw(self, cr):
     NetEditCanvasConfig.draw(self, cr)
     if self.from_element:
         p = self.points[:]
         position = utils.snap_to_grid(self.mouse_position, self.grid_size)
         p.append(position)
         p.insert(0, self.from_element.get_border_point(p[0]))
         cr.set_source_rgb(0, 0, 0)
         drawing.draw_polyline_nice_corners(cr, p, 0.5, 12, False, True)
Пример #12
0
 def draw(self, cr):
     NetEditCanvasConfig.draw(self, cr)
     if self.from_element:
         p = self.points[:]
         position = utils.snap_to_grid(self.mouse_position, self.grid_size)
         p.append(position)
         p.insert(0, self.from_element.get_border_point(p[0]))
         cr.set_source_rgb(0, 0, 0)
         drawing.draw_polyline_nice_corners(cr, p, 0.5, 12, False, True)
Пример #13
0
 def draw(self, cr):
     NetEditCanvasConfig.draw(self, cr)
     if self.mouse_position:
         position = utils.snap_to_grid(
             self.get_position(self.mouse_position), self.grid_size)
         placement = citems.AbsPlacement(position)
         box = citems.ElementBox(None, "", placement,
                                 self.element.default_size,
                                 self.element.default_radius)
         box.draw(cr)
Пример #14
0
 def on_mouse_move(self, event, position):
     if self.resize_item:
         change = utils.make_vector(self.initial_mouse, position)
         change = utils.snap_to_grid(change, self.grid_size)
         new_size = utils.vector_add(self.initial_size, change)
         new_size = utils.vector_at_least(new_size, 0, 0)
         self.resize_item.size = new_size
         self.canvas.redraw()
     else:
         NetEditCanvasConfig.on_mouse_move(self, event, position)
Пример #15
0
 def on_mouse_move(self, event, position):
     if self.resize_item:
         change = utils.make_vector(self.initial_mouse, position)
         change = utils.snap_to_grid(change, self.grid_size)
         new_size = utils.vector_add(self.initial_size, change)
         new_size = utils.vector_at_least(new_size, 0, 0)
         self.resize_item.size = new_size
         self.canvas.redraw()
     else:
         NetEditCanvasConfig.on_mouse_move(self, event, position)
Пример #16
0
    def __init__(self, layerNumber, coordinates, path_width):
        """Initializes a path for the specified layer"""
        geometry.__init__(self)
        self.name = "path"
        self.layerNumber = layerNumber
        self.coordinates = map(lambda x: [x[0], x[1]], coordinates)
        self.coordinates = snap_to_grid(self.coordinates)
        self.path_width = path_width

        # FIXME figure out the width/height. This type of path is not
        # supported right now. It might not work in gdsMill.
        assert (0)
Пример #17
0
 def gds_write_file(self, newLayout):
     """Writes the rectangular shape to GDS"""
     snapped_offset = snap_to_grid(self.offset)
     debug.info(
         3, "writing rectangle (" + str(self.layerNumber) + "):" +
         str(self.width) + "x" + str(self.height) + " @ " +
         str(snapped_offset))
     newLayout.addBox(layerNumber=self.layerNumber,
                      purposeNumber=0,
                      offsetInMicrons=snapped_offset,
                      width=self.width,
                      height=self.height,
                      center=False)
Пример #18
0
def create_rectilinear_route(my_list):
    """ Add intermediate nodes if it isn't rectilinear. Also skip
        repeated nodes. Also, convert to vector if the aren't."""
    pl = [snap_to_grid(x) for x in my_list]
    
    my_list = []
    for index in range(len(pl) - 1):
        if pl[index] != pl[index + 1]:
            my_list.append(vector(pl[index]))
        if (pl[index][0] != pl[index + 1][0]) and (pl[index][1] != pl[index + 1][1]):
            my_list.append(vector(pl[index][0], pl[index + 1][1]))
    my_list.append(vector(pl[-1]))
    return my_list
Пример #19
0
 def on_mouse_left_down(self, event, position):
     position = utils.snap_to_grid(position, self.grid_size)
     item = self.net.add_place(self.get_position(position))
     self.neteditor.set_tool("selection", set_button=True)
     self.canvas.config.select_item(item.box)
     self.neteditor.add_undo_action(UndoAddNetItemAction(self.net, item))
Пример #20
0
 def on_mouse_left_down(self, event, position):
     position = utils.snap_to_grid(position, self.grid_size)
     item = self.net.add_place(self.get_position(position))
     self.neteditor.set_tool("selection", set_button=True)
     self.canvas.config.select_item(item.box)
     self.neteditor.add_undo_action(UndoAddNetItemAction(self.net, item))