def __init__(self):
        super(Scene, self).__init__()
        Observable.__init__(self)

        self.logger = logging.getLogger("Scene")

        self.blocks = []
        self.edges = []

        self.graphics_scene = ESGraphicsScene(self)

        self.history = SceneHistoryController(self)
Ejemplo n.º 2
0
    def __init__(self, scene, start_socket, end_socket=None, edge_type=EdgeType.BEZIER):
        super(Edge, self).__init__()
        Observable.__init__(self)  # explicit call to second parent class

        self.logger = logging.getLogger("Edge")

        self.scene = scene

        # init sockets
        self.start_socket = start_socket
        self.end_socket = end_socket

        self.graphics_edge, self.__edge_type = (None,) * 2
        self.edge_type = edge_type

        # add edge to the scene
        self.scene.add_edge(self)
    def __init__(self,
                 block,
                 index=0,
                 position=Position.BOTTOM_LEFT,
                 socket_type=SocketType.INPUT,
                 edge_limit=-1):
        super(Socket, self).__init__()
        Observable.__init__(self)  # explicit call to second parent class

        self.logger = logging.getLogger("Socket")

        self.block = block
        self.index = index
        self.position = position
        self.socket_type = socket_type
        self.edge_limit = edge_limit

        self.edges = []
        self._init_graphics()
    def __init__(self,
                 scene,
                 title="Start",
                 socket_types=[],
                 pos=[],
                 parent=None,
                 icon=None,
                 output_edges=1,
                 bg_color=None):
        super(Block, self).__init__()
        Observable.__init__(self)  # explicit call to second parent class

        self.logger = logging.getLogger("Block")

        self.scene = scene
        self.parent = parent  # any container
        self.graphics_block = None
        self.bg_color = bg_color

        self.icon = icon
        self.title = title  # is also the pattern name

        self.inputs = []
        self.outputs = []

        self.socket_spacing = 22

        self._init_ui(socket_types, pos, output_edges)

        # add observers
        self.editing_observers = Observable()
        self.settings_observers = Observable()

        # add editing/settings listeners
        self.content.editing_icon.clicked.connect(
            lambda: self.editing_observers.notify_all(event=self))
        self.content.settings_icon.clicked.connect(
            lambda: self.settings_observers.notify_all(event=self))

        # add block to the scene
        self.scene.add_block(self)
    def __init__(self, block, parent=None, bg_color=None):
        super(ESGraphicsBlock, self).__init__(parent=parent)
        Observable.__init__(self)

        self.block = block
        self.logger = logging.getLogger("GraphicsBlock")

        # properties
        block_size_settings = config_helper.get_block_size_settings()
        self.width = block_size_settings["width"]
        self.height = block_size_settings["height"]
        self.rounded_edge_size = block_size_settings["rounded_edge_size"]
        self.title_height = block_size_settings["title_height"]

        self._padding = 5.0
        self.is_moved = False

        # pen
        block_colors = config_helper.get_colors()
        self._default_pen = QPen(QColor("#{}".format(block_colors['pen']['default'])))
        self._default_pen.setWidthF(2.0)
        self._selected_pen = QPen(QColor("#{}".format(block_colors['pen']['selected'])))
        self._selected_pen.setWidthF(block_size_settings["selected_pen_width"])

        self._title_brush = QBrush(QColor("#{}".format(block_colors['brush']['block_title'])))
        self._bg_brush = QBrush(QColor("#{}".format(
            block_colors['brush']['block_bg'] if bg_color is None else bg_color)))

        # set title
        self.__title = ""
        self._init_title()

        # init sockets
        self._init_sockets()

        # init content
        self._init_content()

        # init ui
        self._init_ui()