Beispiel #1
0
 def __init__(self, net, id, position):
     NetElement.__init__(self, net, id, position)
     p = (position[0], position[1] - 20)
     self.guard = citems.Text(self, "guard",
                              self.box.get_relative_placement(p))
     p = (position[0] + self.default_size[0] / 2 + 5, position[1] + 40)
     self.root = citems.Text(self, "root",
                             self.box.get_relative_placement(p))
     self.root.format = "root({0})"
Beispiel #2
0
    def __init__(self, net, id, position, size):
        RectItem.__init__(self, net, id, position, size)
        self.area = citems.Area(self, "area", self.point1, self.point2)

        position = utils.vector_add(self.point1.get_position(), (0, -15))
        self.init = citems.Text(self, "init",
                                self.point1.get_relative_placement(position))
Beispiel #3
0
    def __init__(self, net, id, position):
        NetElement.__init__(self, net, id, position)

        p = (position[0] + self.box.radius * 0.85,
             position[1] + self.box.radius * 0.85)
        self.place_type = citems.Text(self, "type",
                                      self.box.get_relative_placement(p))

        p = (position[0] + self.box.radius * 0.85,
             position[1] - self.box.radius * 1.5)
        self.init = citems.Text(self, "init",
                                self.box.get_relative_placement(p))

        p = self.box.get_relative_placement((-self.box.radius - 5, -5),
                                            absolute=False)
        self.interface = citems.PlaceInterface(self, "interface", p)

        self.trace_tokens = False
        self.trace_tokens_functions = []
Beispiel #4
0
    def get_packet_items(self):
        def get_size(self, cr):
            if not self.texts:
                return
            tx = max(utils.text_size(cr, t)[0] for t in self.texts)
            tx += 20
            ty = 13 * len(self.texts) + 4
            return (tx, ty)

        result = []
        color = (0.8, 0.3, 0.1, 0.85)
        color_active = (1, 1, 1)
        color_inactive = (0.8, 0.8, 0.8)
        for edge in self.perspective.runinstance.net.edges_out():
            packets = self.perspective.get_packets_info(edge.id)
            packet_box = self.packet_boxes.get(edge.id)
            if packet_box is None:
                position = utils.vector_add(edge.inscription.get_position(),
                                            (0, 15))
                placement = citems.AbsPlacement(position)
                packet_box = citems.Box(None,
                                        "packetbox",
                                        placement)
                packet_box.size_fn = get_size
                packet_box.background = color
                packet_box.radius = 5

                self.packet_boxes[edge.id] = packet_box
            result.append(packet_box)
            packet_box.texts = [ p[3] for p in packets ]
            for i, (process_id, origin_id, top, text) in enumerate(packets):
                position = utils.vector_add(packet_box.get_position(),
                                            (10, 13 * i))
                t = citems.Text(
                    None,
                    "packet",
                    packet_box.get_relative_placement(position),
                    text)
                if top:
                    t.color = color_active
                    t.packet_data = (process_id, origin_id)
                else:
                    t.color = color_inactive
                    t.packet_data = None
                t.padding_y = 4
                t.z_level = 15
                t.action = None
                result.append(t)
        return result
Beispiel #5
0
 def __init__(self, net, id, from_item, to_item, points):
     NetItem.__init__(self, net, id)
     self.from_item = from_item
     self.to_item = to_item
     self.points = [
         citems.Point(self, "point", citems.AbsPlacement(p)) for p in points
     ]
     self.line = citems.ArrowLine(self, "line", self.get_all_points)
     self.inscription = citems.Text(self, "inscription",
                                    self.line.get_relative_placement(None),
                                    "")
     self.label_simrun = citems.SimRunLabel(
         self, "simrunbox",
         self.inscription.get_relative_placement((0, 18), absolute=False))
     self.label_simrun.text_fn = self.get_simrun_label_text
Beispiel #6
0
 def get_error_items(self):
     result = []
     messages = self.net.project.get_error_messages(self)
     if not messages:
         return result
     items = self.get_canvas_items_dict(None)
     for name in messages:
         item = items.get(name)
         if item is None:
             # Key was not found, take first item
             # For transition/place it is expected that "box" is returned
             item = self.get_canvas_items()[0]
         position = utils.vector_add(item.get_position(), item.size)
         position = utils.vector_add(position, (0, 0))
         placement = item.get_relative_placement(position)
         error_item = citems.Text(None, "error", placement)
         error_item.delegate_selection = item
         error_item.background_color = (255, 0, 0)
         error_item.border_color = (0, 0, 0)
         error_item.align_y = 0
         error_item.z_level = 20
         error_item.text = messages[name][0]
         result.append(error_item)
     return result