Exemple #1
0
        /// <inheritdoc />
        protected override ILayoutAlgorithm CreateConfiguredLayout(GraphControl graphControl)
        {
            var router = new ChannelEdgeRouter();

            var orthogonalPatternEdgeRouter = new OrthogonalPatternEdgeRouter();

            orthogonalPatternEdgeRouter.AffectedEdgesDpKey = ChannelEdgeRouter.AffectedEdgesDpKey;
            orthogonalPatternEdgeRouter.MinimumDistance    = MinimumDistanceItem;
            orthogonalPatternEdgeRouter.GridRouting        = ActivateGridRoutingItem;
            orthogonalPatternEdgeRouter.GridSpacing        = GridSpacingItem;

            orthogonalPatternEdgeRouter.BendCost         = BendCostItem;
            orthogonalPatternEdgeRouter.EdgeCrossingCost = EdgeCrossingCostItem;
            orthogonalPatternEdgeRouter.NodeCrossingCost = NodeCrossingCostItem;

            // disable edge overlap costs when Edge distribution will run afterwards anyway
            orthogonalPatternEdgeRouter.EdgeOverlapCost = 0;

            router.PathFinderStrategy = orthogonalPatternEdgeRouter;

            var segmentDistributionStage = new OrthogonalSegmentDistributionStage();

            segmentDistributionStage.AffectedEdgesDpKey = ChannelEdgeRouter.AffectedEdgesDpKey;
            segmentDistributionStage.PreferredDistance  = MinimumDistanceItem;
            segmentDistributionStage.GridRouting        = ActivateGridRoutingItem;
            segmentDistributionStage.GridSpacing        = GridSpacingItem;

            router.EdgeDistributionStrategy = segmentDistributionStage;

            return(router);
        }
        ///<inheritdoc/>
        protected override void ConfigureLayout()
        {
            OptionGroup                 layoutGroup = (OptionGroup)Handler.GetGroupByName(TOP_LEVEL).GetGroupByName(LAYOUT_OPTIONS);
            OptionGroup                 costGroup   = (OptionGroup)Handler.GetGroupByName(TOP_LEVEL).GetGroupByName(COST);
            ILayoutAlgorithm            pathFinder;
            OrthogonalPatternEdgeRouter orthogonalPatternEdgeRouter = new OrthogonalPatternEdgeRouter();

            orthogonalPatternEdgeRouter.AffectedEdgesDpKey = ChannelEdgeRouter.AffectedEdgesDpKey;
            orthogonalPatternEdgeRouter.MinimumDistance    = (double)layoutGroup[MINIMUM_DISTANCE].Value;
            orthogonalPatternEdgeRouter.GridRouting        = (bool)layoutGroup[ACTIVATE_GRID_ROUTING].Value;
            orthogonalPatternEdgeRouter.GridSpacing        = (double)layoutGroup[GRID_SPACING].Value;

            orthogonalPatternEdgeRouter.BendCost         = (double)costGroup[BEND_COST].Value;
            orthogonalPatternEdgeRouter.EdgeCrossingCost = (double)costGroup[EDGE_CROSSING_COST].Value;
            orthogonalPatternEdgeRouter.NodeCrossingCost = (double)costGroup[NODE_CROSSING_COST].Value;

            //disable edge overlap costs when Edge distribution will run afterwards anyway
            orthogonalPatternEdgeRouter.EdgeOverlapCost = 0.0;
            pathFinder = orthogonalPatternEdgeRouter;

            router.PathFinderStrategy = pathFinder;

            OrthogonalSegmentDistributionStage segmentDistributionStage = new OrthogonalSegmentDistributionStage();

            segmentDistributionStage.AffectedEdgesDpKey = ChannelEdgeRouter.AffectedEdgesDpKey;
            segmentDistributionStage.PreferredDistance  = (double)layoutGroup[MINIMUM_DISTANCE].Value;
            segmentDistributionStage.GridRouting        = (bool)layoutGroup[ACTIVATE_GRID_ROUTING].Value;
            segmentDistributionStage.GridSpacing        = (double)layoutGroup[GRID_SPACING].Value;

            router.EdgeDistributionStrategy = segmentDistributionStage;

            LayoutAlgorithm = router;
        }
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            createRouter();
            OptionGroup toplevelGroup = Handler.AddGroup(TOP_LEVEL);

            //the toplevel group will show neither in Table view nor in dialog view explicitely
            toplevelGroup.SetAttribute(TableEditorFactory.RENDERING_HINTS_ATTRIBUTE,
                                       (int)TableEditorFactory.RenderingHints.Invisible);
            toplevelGroup.SetAttribute(DefaultEditorFactory.RENDERING_HINTS_ATTRIBUTE,
                                       (int)DefaultEditorFactory.RenderingHints.Invisible);
            OptionGroup layoutGroup = toplevelGroup.AddGroup(LAYOUT_OPTIONS);
            OptionGroup costGroup   = toplevelGroup.AddGroup(COST);

            if (router.PathFinderStrategy is OrthogonalPatternEdgeRouter)
            {
                OrthogonalPatternEdgeRouter oper = (OrthogonalPatternEdgeRouter)router.PathFinderStrategy;
                layoutGroup.AddList(PATHFINDER, pathFinderList, ORTHOGONAL_PATTERN_PATH_FINDER);
                layoutGroup.AddList(SCOPE, scopes, SCOPE_ALL_EDGES);
                layoutGroup.AddDouble(MINIMUM_DISTANCE, oper.MinimumDistance);
                layoutGroup.AddBool(ACTIVATE_GRID_ROUTING, oper.GridRouting);
                layoutGroup.AddDouble(GRID_SPACING, oper.GridSpacing, 2.0, Double.MaxValue);

                ConstraintManager cm = new ConstraintManager(Handler);
                cm.SetEnabledOnValueEquals(layoutGroup[ACTIVATE_GRID_ROUTING], true, layoutGroup[GRID_SPACING]);

                costGroup.AddDouble(BEND_COST, oper.BendCost);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[BEND_COST]);
                costGroup.AddDouble(EDGE_CROSSING_COST, oper.EdgeCrossingCost);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[EDGE_CROSSING_COST]);
                costGroup.AddDouble(NODE_CROSSING_COST, oper.NodeCrossingCost);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[NODE_CROSSING_COST]);
            }
            else
            {
                layoutGroup.AddList(PATHFINDER, pathFinderList, ORTHOGONAL_PATTERN_PATH_FINDER);
                layoutGroup.AddList(SCOPE, scopes, SCOPE_ALL_EDGES);
                layoutGroup.AddDouble(MINIMUM_DISTANCE, 10);
                layoutGroup.AddBool(ACTIVATE_GRID_ROUTING, true);
                layoutGroup.AddDouble(GRID_SPACING, 20);

                ConstraintManager cm = new ConstraintManager(Handler);
                cm.SetEnabledOnValueEquals(layoutGroup[ACTIVATE_GRID_ROUTING], true, layoutGroup[GRID_SPACING]);

                costGroup.AddDouble(BEND_COST, 1);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[BEND_COST]);
                costGroup.AddDouble(EDGE_CROSSING_COST, 5);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[EDGE_CROSSING_COST]);
                costGroup.AddDouble(NODE_CROSSING_COST, 50);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[NODE_CROSSING_COST]);
            }
        }
        /// <summary>
        /// sets up the option handler for specifying the layout parameters.
        /// </summary>
        protected override void SetupHandler()
        {
            // use an instance of the layout as a defaults provider
            CompactOrthogonalLayout layout = new CompactOrthogonalLayout();
            var topLevelGroup = Handler.AddGroup(TOP_LEVEL);

            topLevelGroup.SetAttribute(TableEditorFactory.RENDERING_HINTS_ATTRIBUTE,
                                       (int)TableEditorFactory.RenderingHints.Invisible);
            topLevelGroup.SetAttribute(DefaultEditorFactory.RENDERING_HINTS_ATTRIBUTE,
                                       (int)DefaultEditorFactory.RenderingHints.Invisible);

            OrthogonalLayout cl = (OrthogonalLayout)layout.CoreLayout;

            topLevelGroup.AddList(ORTHOGONAL_LAYOUT_STYLE, new [] { NORMAL, NORMAL_TREE, FIXED_BOX_NODES, FIXED_MIXED }, str2styles[cl.LayoutStyle]);

            topLevelGroup.AddList(PLACEMENT_STRATEGY, new[] { STYLE_ROWS, STYLE_PACKED_COMPACT_RECTANGLE }, str2componentStyles[ComponentArrangementStyles.PackedCompactRectangle]);

            topLevelGroup.AddDouble(ASPECT_RATIO, layout.AspectRatio);
            topLevelGroup.AddInt(GRID, layout.GridSpacing, 1, int.MaxValue);

            OrthogonalPatternEdgeRouter oper = new OrthogonalPatternEdgeRouter();

            IOptionItem bendCostOptionItem         = topLevelGroup.AddDouble(BEND_COST, oper.BendCost);
            IOptionItem nodeCrossingCostOptionItem = topLevelGroup.AddDouble(NODE_CROSSING_COST, oper.NodeCrossingCost);
            IOptionItem edgeCrossingCostOptionItem = topLevelGroup.AddDouble(EDGE_CROSSING_COST, oper.EdgeCrossingCost);
            IOptionItem minimumDistanceOptionItem  = topLevelGroup.AddDouble(MINIMUM_DISTANCE, oper.MinimumDistance);

            IOptionItem pathFinderOptionItem = topLevelGroup.AddList(PATH_FINDER, PATH_FINDER_ENUM, ORTHOGONAL_SHORTESTPATH_PATH_FINDER);

            ConstraintManager cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(pathFinderOptionItem, ORTHOGONAL_PATTERN_PATH_FINDER, bendCostOptionItem);
            cm.SetEnabledOnValueEquals(pathFinderOptionItem, ORTHOGONAL_PATTERN_PATH_FINDER, nodeCrossingCostOptionItem);
            cm.SetEnabledOnValueEquals(pathFinderOptionItem, ORTHOGONAL_PATTERN_PATH_FINDER, edgeCrossingCostOptionItem);
            cm.SetEnabledOnValueEquals(pathFinderOptionItem, ORTHOGONAL_PATTERN_PATH_FINDER, minimumDistanceOptionItem);

            topLevelGroup.AddBool(ROUTE_ALL_EDGES, !layout.InterEdgeRouter.RouteInterEdgesOnly);
        }
Exemple #5
0
        private PartitionLayout.IInterEdgeRouter ConfigureInterEdgeRouter()
        {
            OptionGroup topLevelGroup = Handler.GetGroupByName(TOP_LEVEL);

            PartitionLayout.IInterEdgeRouter interEdgeRouter;
            if (topLevelGroup[PATH_FINDER].Value.Equals(ORTHOGONAL_PATTERN_PATH_FINDER))
            {
                OrthogonalPatternEdgeRouter oper = new OrthogonalPatternEdgeRouter();
                oper.MinimumDistance  = (double)topLevelGroup[MINIMUM_DISTANCE].Value;
                oper.EdgeCrossingCost = (double)topLevelGroup[EDGE_CROSSING_COST].Value;
                oper.NodeCrossingCost = (double)topLevelGroup[NODE_CROSSING_COST].Value;
                oper.BendCost         = (double)topLevelGroup[BEND_COST].Value;
                var channelEdgeRouter = new ChannelEdgeRouter();
                channelEdgeRouter.PathFinderStrategy = oper;
                interEdgeRouter = PartitionLayout.CreateChannelInterEdgeRouter(channelEdgeRouter);
            }
            else
            {
                interEdgeRouter = PartitionLayout.CreateChannelInterEdgeRouter();
            }
            interEdgeRouter.RouteInterEdgesOnly = !(bool)(topLevelGroup.GetItemByName(ROUTE_ALL_EDGES).Value);
            return(interEdgeRouter);
        }