Beispiel #1
0
    def _diagram_canvas_default(self):
        """ Trait initialiser """

        canvas = Canvas()

        for tool in self.tools:
            canvas.tools.append(tool(canvas))

        return canvas
Beispiel #2
0
    def clear_canvas(self):
        """ Removes all components from the canvas """

        logger.debug("Clearing the diagram canvas!")
        old_canvas = self.diagram_canvas

        #        logger.debug("Canvas components: %s" % canvas.components)
        #        for component in canvas.components:
        #            canvas.remove(component)
        #        logger.debug("Canvas components: %s" % canvas.components)
        #        for component in canvas.components:
        #            canvas.remove(component)
        #        logger.debug("Canvas components: %s" % canvas.components)
        #        canvas.request_redraw()

        new_canvas = Canvas()
        new_canvas.copy_traits(old_canvas, ["bgcolor", "draw_axes"])
        self.diagram_canvas = new_canvas

        self.viewport.component = new_canvas
        self.viewport.request_redraw()

        return
Beispiel #3
0

if __name__ == "__main__":
    from pylon.dss.common.api import Circuit, Bus
    from pylon.dss.delivery.api import Line, Transformer, Fault, Capacitor
    from pylon.dss.conversion.api import \
        Generator, Load, VoltageSource, CurrentSource
    from pylon.dss.control.api import CapacitorControl, RegulatorControl

    logger = logging.getLogger()
    logger.addHandler(logging.StreamHandler(sys.stdout))
    logger.setLevel(logging.DEBUG)

    diagram = CanvasMapping(domain_model=Circuit(buses=[Bus(), Bus()],
                                                 generators=[Generator()]),
                            diagram_canvas=Canvas(bgcolor="lightslategrey",
                                                  draw_axes=True),
                            tools=[ContextMenuTool])

    node_mappings = [
        #        NodeMapping(containment_trait="buses", diagram_node=DiagramNode),
        NodeMapping(containment_trait="buses",
                    element=Bus,
                    dot_node=GodotNode(shape="rectangle",
                                       fixed_size=True,
                                       width=1.5,
                                       height=0.5,
                                       fill_color="white",
                                       color="orange",
                                       style=["filled"]),
                    tools=[MoveTool, ElementTool],
                    label=LabelMapping()),
Beispiel #4
0
    def _canvas_default(self):
        """ Trait initialiser """

        canvas = Canvas(draw_axes=True, bgcolor="honeydew")
        return canvas