moosetechnology / Moose

MOOSE - Platform for software and data analysis.
https://moosetechnology.github.io/moose-wiki
MIT License
136 stars 34 forks source link

adding Mondrian subview interactively operates on wrong node #790

Closed seandenigris closed 9 years ago

seandenigris commented 9 years ago

Originally reported on Google Code with ID 790

Executing the code snippet below in Mondrian Easel exhibits surprising behaviour.  Referring
to attached snapshot, clicking on a square incorrectly operates on an ellipse instead.
----8<----
view shape label.
view node: 'Ellipses' forIt:
[   
    view shape ellipse size: 30.
    view interaction
            whenClickingUpdateNode:
        [ :value |  view forNode: value do:
            [     view nodes: (1 to: 5).
                view gridLayout.
            ]
        ]
        withLayoutUpdate: true.
    view nodes: ( 1 to: 16 ).
    view gridLayout.
].

view shape label.
view node: 'Rectangles' forIt:
[   
    view shape rectangle size: 30.
    view interaction
            whenClickingUpdateNode:
        [ :value |  view forNode: value do:
            [     view nodes: (1 to: 5).
                view gridLayout.
            ]
        ]
        withLayoutUpdate: true.
    view nodes: ( 1 to: 16 ).
    view gridLayout.
].

Reported by benjamin.t.coman on 2012-04-09 07:36:37

seandenigris commented 9 years ago
Uploaded better image.

Reported by benjamin.t.coman on 2012-04-09 15:15:20


seandenigris commented 9 years ago
This is a bit presumptuous without knowing Mondrian better architecturally, but I can't
help thinking that some of the methods named 'forNode' would be more appropriately
named 'forNodeValue' - particularly for interaction such as 
registerForEvent:forNode:updateNode:updateLayout:.  Having tried tracing this down
further, the root cause is that the "node that is clicked" is not operated on directly.
 Instead the "value" of the clicked node searched from root.  Where the same value
occurs multiple times in a graph, a different node might be found for "that value"
to apply the operation to rather than the "node that was clicked".

Instead I expect to be able to apply operations to the actual node that I selected.

Here is another example...
----8<-----
view nodes: (1 to: 5) forEach:
[:each |
    view interaction strongHighlightWhenOver: [ :v | v ].       
    view shape rectangle withText; size: 20.       
    view nodes: (1 to: each).       
    view gridLayout
].
----8<-----
Executing this in Mondrian Easel (taking for example the third group) small squares
1 & 2 do not highlight when hovering over them, and hovering over small square 3 highlights
the large square rather than its small square. 

I can get what I consider the usually expected behaviour by modifying MOAnnouncer>>registerForEvent:forNodes:updateShape:updateLayout:
replacing...
           domainNodes := (aBlockOrSymbol moValue: ann element model).
           nodes := ann viewRenderer nodeForDomainValues: domainNodes.
by...
           nodes := OrderedCollection new add: ann element ; yourself.

I can see where you might want all graph nodes having the same value to highlight when
any one is selected, for which a method registerForEvent:forNodeValues: might be appropriate.

It is however not clear to me whether the 'node' in the forNodes is referring to a
node in the model or a node in the display. I am presuming the latter - particularly
in relation to interactions.

Reported by benjamin.t.coman on 2012-04-15 08:25:54

seandenigris commented 9 years ago
Most of the mechanisms to update nodes in Mondrian are a kind of hack. As soon as you
have two or more nodes with the same model, then the interaction will simply not work.

Regarding your suggestion for for the class MOAnnouncer, it does not have the same
effect. It turns some tests yellow.

I turn this issue WontFix because it simply cannot be fixed. 
Roassal provides a simpler model for building interactive visualization, especially
with node update.

Reported by alexandre.bergel on 2012-04-15 23:49:40