Bug 539537 - [ELK] Wrong ELK layout result with show/hide ports operation
Summary: [ELK] Wrong ELK layout result with show/hide ports operation
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 6.0.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2018-09-26 21:52 EDT by li yufang CLA
Modified: 2019-11-13 11:46 EST (History)
4 users (show)

See Also:


Attachments
screenshots for steps (36.85 KB, application/octet-stream)
2018-09-26 21:52 EDT, li yufang CLA
no flags Details
539537.sample.zip (4.28 KB, application/x-zip-compressed)
2019-11-13 11:44 EST, Laurent Redor CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description li yufang CLA 2018-09-26 21:52:19 EDT
Created attachment 276012 [details]
screenshots for steps

Hi,
I am using layered algorithm to layout my diagram in Sirius editor.
When I do the following operations, I found the layout result is wrong:
Steps
1). Execute layered algorithm on my diagram in Sirius editor, it works well.
2). Hide ports.
3). Relayout on this diagram after doing 2), it works well, too.
4). Show these hidden ports.
5). Execute layered layout on this diagram again.
The result in step 5) is messed-up, it looks like these ports which are shown after hidden are not placed in their places. But, when I close this diagram, and then reopen it, the diagram is shown well as the step 1) shows.

More details:
https://www.eclipse.org/forums/index.php/m/1795385/#msg_1795385
Comment 1 Pierre-Charles David CLA 2018-09-28 12:31:55 EDT
When you say "Execute layered algorithm on my diagram in Sirius editor", are you using the tools provided by the ELK project itself, i.e. https://www.eclipse.org/elk/documentation/tooldevelopers/usingeclipselayout/layoutviewsupport.html, or did you configure your layout and parameters right in the Sirius configuration file (the .odesign) using the new feature added in Sirius 6.0 (https://blog.obeo.fr/a-picture-is-worth-a-thousand-words)?

In the first case, it is more or less expected that results will be inconsistent: ELK does not know about Sirius and works at a lower level (GEF/GMF) to move/resize the diagram elements. It is not aware of any of the Sirius-specific constraints that must be kept true for the system to continue working. It may look like it "works" at first glance because the elements move on the diagram, but the result is not guaranteed to make sense to Sirius.

In the second case (ELK layout configured directly in the VSM, as described in
https://blog.obeo.fr/a-picture-is-worth-a-thousand-words), then it may indeed be a bug in Sirius, but note that this feature is clearly marked as experimental at the moment. We released it so that users can try it and give us feedback, so thanks for yours, but it can not be considered as "critical". If you are in this case, even if you can not give acces to the full project, can you give us more information about the layout configuration you used (i.e. which values you set for the "ELK Layered" algorithm)?
Comment 2 Pierre Guilet CLA 2018-10-16 10:55:22 EDT
Layout was configured from VSM and arrange all button has been used.
Comment 3 Pierre Guilet CLA 2018-10-22 04:41:09 EDT
Configuration used is 

 private void configLayered(LayoutConfigurator layoutConfigurator, LayoutMapping layoutMapping) {
        layoutConfigurator.configure(ElkNode.class)
                .setProperty(LayeredOptions.PORT_LABELS_PLACEMENT, PortLabelPlacement.INSIDE)
                .setProperty(LayeredOptions.PORT_CONSTRAINTS, PortConstraints.UNDEFINED)
                .setProperty(LayeredOptions.NODE_SIZE_OPTIONS,
                        EnumSet.of(SizeOptions.MINIMUM_SIZE_ACCOUNTS_FOR_PADDING))
                .setProperty(LayeredOptions.NODE_SIZE_CONSTRAINTS, EnumSet.allOf(SizeConstraint.class))
                .setProperty(LayeredOptions.NODE_LABELS_PLACEMENT, NodeLabelPlacement.insideTopCenter())
                .setProperty(LayeredOptions.MERGE_EDGES, true).setProperty(LayeredOptions.MERGE_HIERARCHY_EDGES, true)
                .setProperty(LayeredOptions.HIERARCHY_HANDLING, HierarchyHandling.INCLUDE_CHILDREN)
                .setProperty(LayeredOptions.CROSSING_MINIMIZATION_GREEDY_SWITCH_TYPE, GreedySwitchType.OFF)
                .setProperty(LayeredOptions.CONTENT_ALIGNMENT, ContentAlignment.topLeft())
                .setProperty(LayeredOptions.EDGE_LABEL_SIDE_SELECTION, EdgeLabelSideSelection.ALWAYS_DOWN)
                .setProperty(LayeredOptions.SPACING_NODE_NODE, 10.0).setProperty(LayeredOptions.SPACING_PORT_PORT, 30.0)
                .setProperty(LayeredOptions.SPACING_EDGE_EDGE, 20.0).setProperty(LayeredOptions.THOROUGHNESS, 1)
                .setProperty(LayeredOptions.SPACING_LABEL_LABEL, 20.0)
                .setProperty(LayeredOptions.SPACING_EDGE_LABEL, 5.0)
                .setProperty(LayeredOptions.INSIDE_SELF_LOOPS_ACTIVATE, true);
        layoutConfigurator.configure(ElkEdge.class).setProperty(LayeredOptions.INSIDE_SELF_LOOPS_YO, true);

called from ELKLayoutNodeProvider

with 

    public Command layoutEditParts(final List selectedObjects, final IAdaptable layoutHint) {
           .........
        ElkDiagramLayoutConnector connector = injector.getInstance(ElkDiagramLayoutConnector.class);
        LayoutMapping layoutMapping = connector.buildLayoutGraph(null, container.getParent());

       configLayered();
      ......

    }
Comment 4 Laurent Redor CLA 2019-11-13 11:44:58 EST
Created attachment 280629 [details]
539537.sample.zip

In order to make a first succinct analysis, I created a use case to reproduce.

Steps to reproduce:
* Import project 539537.sample (from 539537.sample.zip)
* Open diagram "new Diagram539537"
* Launch an arrange all (button of tabbar)
* Expected: The ports are on the left side (Port2 above and Port1 below)
* Select the ports
* Hide them (through the contextual menu "Show/Hide>Hide element")
* Launch an arrange all (button of tabbar)
* Expected: The size of containers is reduced.
* Reveal the ports (with the wizard "Show/Hide" in the tabbar)
* Expected: The port are reaveled bug with scrollbars (Port1 cannot be seen).
* Launch an arrange all (button of tabbar)
* KO: The size of containers is increased, but the Port1 is not on the left side (as it should be).
* Save
* Close the diagram
* Open the diagram
* Expected: The Port1 is well located and the scrollbars are disappeared.
Comment 5 Laurent Redor CLA 2019-11-13 11:46:46 EST
Analysis: The GMF coordinates of Port1 are OK. It seems that a draw2d refresh is missing to allow to redraw the figure of Port1 after having resize its container.