Exemplo n.º 1
0
    def InitSizeAndObjs(self):
        # Only call this once enclosing frame has been set up, so that get correct world coord dimensions

        self.canvas_resizer = CanvasResizer(canvas=self)

        # Don't assert canvas size sanity anymore as wxpython3 (phoenix) doesn't set canvas size
        # as quickly as wxpython2.8 does, even though frame has been sized and shown
        # with frame.SetSize(WINDOW_SIZE) and frame.Show(True)
        # In wxpython3 (phoenix) canvas stays at (20,20) despite the frame increasing in size to (1024,768)
        # but good ole wxpython2.8 does indeed change canvas size immediately to (1024,768)
        #
        # assert not self.canvas_resizer.canvas_too_small(), "InitSizeAndObjs being called too early - please set up enclosing frame size first"

        self.umlworkspace = UmlWorkspace()
        self.layout = LayoutBasic(leftmargin=5,
                                  topmargin=5,
                                  verticalwhitespace=50,
                                  horizontalwhitespace=50,
                                  maxclassesperline=7)
        self.snapshot_mgr = GraphSnapshotMgr(graph=self.umlworkspace.graph,
                                             umlcanvas=self)
        self.coordmapper = CoordinateMapper(self.umlworkspace.graph,
                                            self.GetSize())
        self.layouter = GraphLayoutSpring(self.umlworkspace.graph, gui=self)
        self.overlap_remover = OverlapRemoval(self.umlworkspace.graph,
                                              margin=50,
                                              gui=self)
Exemplo n.º 2
0
    def testStress2_InitialBoot(self):
        """
        This is the slowest stress test because it runs the spring layout several times.
        """

        from layout.layout_spring import GraphLayoutSpring
        from layout.coordinate_mapper import CoordinateMapper

        self.g.LoadGraphFromStrings(
            GRAPH_INITIALBOOT)  # load the scenario ourselves

        layouter = GraphLayoutSpring(self.g)
        coordmapper = CoordinateMapper(self.g, (800, 800))

        def AllToLayoutCoords():
            coordmapper.AllToLayoutCoords()

        def AllToWorldCoords():
            coordmapper.AllToWorldCoords()

        for i in range(8):
            print(i, end=" ")

            AllToLayoutCoords()
            layouter.layout(keep_current_positions=False)
            AllToWorldCoords()

            were_all_overlaps_removed = self.overlap_remover.RemoveOverlaps()
            self.assertTrue(were_all_overlaps_removed)
Exemplo n.º 3
0
    def ReLayout(self, keep_current_positions=False, gui=None, optimise=True):
        self.AllToLayoutCoords()

        layouter = GraphLayoutSpring(self.graph, gui)    # should keep this around
        layouter.layout(keep_current_positions, optimise=optimise)
        
        self.AllToWorldCoords()
        self.stage2() # does overlap removal and stateofthenation
Exemplo n.º 4
0
    def InitSizeAndObjs(self):
        # Only call this once enclosing frame has been set up, so that get correct world coord dimensions

        self.canvas_resizer = CanvasResizer(canvas=self)
        assert not self.canvas_resizer.canvas_too_small(
        ), "InitSizeAndObjs being called too early - please set up enclosing frame size first"

        self.umlworkspace = UmlWorkspace()
        self.layout = LayoutBasic(leftmargin=5,
                                  topmargin=5,
                                  verticalwhitespace=50,
                                  horizontalwhitespace=50,
                                  maxclassesperline=7)
        self.snapshot_mgr = GraphSnapshotMgr(graph=self.umlworkspace.graph,
                                             umlcanvas=self)
        self.coordmapper = CoordinateMapper(self.umlworkspace.graph,
                                            self.GetSize())
        self.layouter = GraphLayoutSpring(self.umlworkspace.graph, gui=self)
        self.overlap_remover = OverlapRemoval(self.umlworkspace.graph,
                                              margin=50,
                                              gui=self)
Exemplo n.º 5
0
    def __init__(self):
        wx.Frame.__init__( self,
                          None, -1, "Andy's UML Layout Experimentation Sandbox",
                          size=(800,800),
                          style=wx.DEFAULT_FRAME_STYLE )
        sizer = wx.BoxSizer( wx.VERTICAL )
        # put stuff into sizer

        self.CreateStatusBar()

        canvas = GraphShapeCanvas(self) # ogl.ShapeCanvas( self )
        sizer.Add( canvas, 1, wx.GROW )

        canvas.SetBackgroundColour( "LIGHT BLUE" ) #

        diagram = ogl.Diagram()
        canvas.SetDiagram( diagram )
        diagram.SetCanvas( canvas )

        ## ==========================================
        
        g = Graph()
        
        a = GraphNode('A', 0, 0, 250, 250)
        a1 = GraphNode('A1', 0, 0)
        a2 = GraphNode('A2', 0, 0)
        g.AddEdge(a, a1)
        g.AddEdge(a, a2)

        b = GraphNode('B', 0, 0)
        b1 = GraphNode('B1', 0, 0)
        b2 = GraphNode('B2', 0, 0)
        g.AddEdge(b, b1)
        g.AddEdge(b, b2)

        b21 = GraphNode('B21', 0, 0)
        b22 = GraphNode('B22', 0, 0, 100, 200)
        g.AddEdge(b2, b21)
        g.AddEdge(b2, b22)

        c = GraphNode('c', 0, 0)
        c1 = GraphNode('c1', 0, 0)
        c2 = GraphNode('c2', 0, 0)
        c3 = GraphNode('c3', 0, 0)
        c4 = GraphNode('c4', 0, 0)
        c5 = GraphNode('c5', 0, 0, 60, 120)
        g.AddEdge(c, c1)
        g.AddEdge(c, c2)
        g.AddEdge(c, c3)
        g.AddEdge(c, c4)
        g.AddEdge(c, c5)
        g.AddEdge(a, c)
        
        g.AddEdge(b2, c)
        g.AddEdge(b2, c5)
        g.AddEdge(a, c5)

        layouter = GraphLayoutSpring(g)
        layouter.layout()
        
        #for node in g.nodes:
        #    print node.id, (node.layoutPosX, node.layoutPosY)
        
        ## ==========================================
        
        # apply sizer
        self.SetSizer(sizer)
        self.SetAutoLayout(1)
        self.Show(1)

        ## ==========================================

        renderer = GraphRendererOgl(g, canvas);
        renderer.draw();
        
        diagram.ShowAll( 1 )