Google Summer of Code 2016 - Xcos Automatic Layout II
Table of contents:
Contents
Overview
The idea of Xcos Automatic Layout to provide options to automatically update the layout of an Xcos schema including its links and blocks, so that the diagrams could be kept well-presented. Based on the optimal route for a link, I will improve the positions of blocks including Split Blocks and Normal Blocks. I will also try to implement the preview functionality.
Schedule
Week01 - Check the previous feature (05.23-05.29): Review my previous work based on the latest master branch. Check whether everything works well and try to improve Optimal Link Style if possible.
Week02-05 - Automatic Position of Split Block (05.30-06.26): Implement this feature. Test it and make a commit.
Week04-09 - Automatic Position of Basic Block (06.27-07.24): Implement this feature. Test it and make a commit. This feature might be more difficult and possibly require more time.
Week10-12 - Auto-layout Preview (07.25-08.14): Implement this feature. Test it and make a commit.
Week13 - Final (08.15 - 08.21): Beautify codes, make final commits and write documentation.
Tasks
- Block Automatic Position - Split Blocks (BAP - SBAP)
When there is only one single split block in the whole part of links.
When there are at least 2 split blocks in the whole part of links.
- Block Automatic Position - Normal Blocks (BAP - NBAP)
The blocks which has only 1 IN/OUT port. (Start/End blocks)
The blocks which are not Start/End blocks.
Some blocks which are connected.
- Automatic Layout Preview
When creating a link.
When moving a block.
Implementation
Block Auto-Position - Split Block
Option to set a new position for the SplitBlock. Select the SplitBlocks and press 'P' to find a new position for the SplitBlocks and their links.
Automatically move the SplitBlocks to a new position.
If there is only 1 SplitBlock in the whole part of links, move it to the intersection of the 2 optimal routes.
If there are 2 or more SplitBlocks, all the SplitBlocks in that whole part of links will be moved no matter how many SplitBlocks are selected.
Also, rework their links if it brings a better alignment. Based on the original optimal routes and the position of SplitBlocks, find the optimal routes for each part of links.
Add menus in the menubar and contextmenu (only enabled when one SplitBlock is selected).
Block Auto-Position - Normal Block
Option to set a new position for the Normal Block (BasicBlock excluding SplitBlock and TextBlock). Select the Normal Blocks and press 'N' to find a new position for the Normal Blocks.
- Select the blocks which has only 1 IN/OUT port. (Start/End blocks)
- Choose multiple start/end blocks.
- Choose several single start/end blocks.
- Select the blocks which are not Start/End blocks.
- If there are blocks on left which are closed, move the block and its right blocks.
- If there are blocks on right which are closed, move this block and its right blocks.
- If there are blocks above which are closed, move the block downwards.
- If there are blocks below which are closed, move this block downwards.
- Select some blocks which are connected.
- Hierarchical Flat connection:
- make them horizontally aligned if there are more ports in horizontal direction.
- make them vertically aligned if there are more ports in vertical direction.
- Tree connection:
- calculate the depth and the width of the tree.
- choose the root (the first OUT block) as start block.
- arrange the positions of the blocks in each level.
- Reversed Tree connection: (debugging)
- calculate the depth and the width of the tree.
- choose the last IN block as start block.
- arrange the positions of the blocks in each level.
- Cycled connection: (unfinished)
- deal with it as a hierarchical flat connection or tree connection.
- Choose the block on the first left as the start block.
- Hierarchical Flat connection:
Result
Block Auto-Position - Split Block
Here are 2 testings for Split Blocks.
Example 1.1
Diagram-A in original version:
Diagram-A after using SBAP:
Example 1.2
Diagram-B in original version:
Diagram-B after using SBAP:
Block Auto-Position - Normal Block
Here are 3 testings for Split Blocks.
Example 2.1
Diagram-C in original version:
Diagram-C after using NBAP for the start/end blocks:
Example 2.2
Diagram-D in original version:
Diagram-D after using NBAP for keeping a distance away:
Example 2.3
Diagram-E in original version:
Diagram-E after using NBAP for connected blocks:
Future Work
Block Auto-Position - Normal Block
Besides the auto-position for blocks in a Cycled connection, what we want to implement is:
- when we select all blocks in a diagram, all the blocks will be in a better position for good-looking.
Relative files which need to be modified:
org.scilab.modules.xcos.utils.NormalBlockAutoPositionUtils
Dynamic Auto Layout Preview
For now, the Scilab/Xcos only supports straight/vertical/horizontal link style preview when creating a link. What we want to implement is:
- there is an optimal link style preview when creating a link.
- the existing link will be previewed with a dashed line when moving a block.
Relative files which need to be modified:
org.scilab.modules.xcos.preferences.XcosOptions
org.scilab.modules.xcos.utils.XcosRouteUtils
Relative Links
Code Review in Scilab
Block Auto-Position - Split Block
Block Auto-Position - Normal Block
Personal Repository in GitHub
Email: <zhuchenf@gmail.com>