【问题标题】:Make edges not clickable in Roassal visualization from within a Glamour browser在 Glamour 浏览器中使边缘在 Roassal 可视化中不可点击
【发布时间】:2026-01-24 07:40:01
【问题描述】:

我在 Pharo 2.0 的 Glamour 浏览器中使用 Roassal 绘制了一个动态调用图。

默认情况下不仅节点可以点击,边也可以点击。

由于我没有要显示边缘的更多信息,我希望它们不可点击。如何删除“可点击性”?

这就是我在 Glamour 浏览器中绘制调用图的方式:

methodsUnderTestAsCallGraphIn: constructor
    constructor roassal
        painting: [ :view :testFailure | 
                    view shape rectangle
                        size: 30;
                        fillColor: ThreeColorLinearNormalizer new.
                    view nodes: (tests methodsUnderTest: testFailure).
                    view shape arrowedLine.
                    view edges: (tests methodsUnderTest: testFailure) from: #yourself toAll: #outgoingCalls.
                    view treeLayout ];
        title: 'Callgraph of methods under test'

我认为 GLMRoassalPresentation>>renderOn: 负责添加“可点击性”:

[...]

    self shouldPopulateSelection ifTrue: [   
        aView raw allElementsDo: [:each | 
            each on: ROMouseClick do: [:event | self selection: each model ]] ].

[...]

我想为节点保留此行为,但不为边缘保留此行为。

【问题讨论】:

    标签: smalltalk pharo moose-technology roassal


    【解决方案1】:

    有一个独立的例子来阐明你想要的行为会有所帮助,所以我重新定义了你的问题。

    有了两个注释掉的行,我想这是你不想要的行为。取消注释这两行是否提供了您想要的行为?

    browser := GLMTabulator new.
    browser column: #myRoassal ; column: #mySelection.
    browser transmit 
        to: #myRoassal ;
        andShow: 
        [   : aGLMPresentation |
            aGLMPresentation roassal
                painting:
                [   : view : numbers |  |edges|
                    view shape rectangle ; withText ; size: 30.
                    view nodes: numbers.
                    view interaction noPopup.
                    view edges: numbers from:  [ :x | x / 2] to: [ :x | x ].
    "               view edges do: [ :edge | edge model:#doNotSelectMe ]."
                    view treeLayout.
                ].
        ].
    browser transmit 
        to: #mySelection ;
        from: #myRoassal ;
    "   when: [ :selection | selection ~= #doNotSelectMe ] ;"
        andShow: 
        [   : aGLMPresentation |
            aGLMPresentation text
                display: [ : selectedItem | selectedItem asString ]
        ].
    browser openOn: (1 to: 10).
    

    【讨论】:

      【解决方案2】:

      很遗憾,目前这是不可能的,因为点击是在 GLMRoassalPresentation 中硬编码的。但是,您是对的,我们应该找到解决方案,所以我打开了一个问题: http://code.google.com/p/moose-technology/issues/detail?id=981

      【讨论】:

        【解决方案3】:

        我不确定您所说的“可点击性”是什么意思。您没有定义交互,因此默认交互是一个简单的弹出窗口。如果要删除弹出窗口,则只需插入“查看交互 noPopup”。在新的 Roassal 画架上试试这个:

        view shape rectangle size: 40.
        view nodes: #(1 2).
        
        view interaction noPopup.
        view edgesFrom: 1 to: 2.
        

        【讨论】:

        • 我认为 GLMRoassalPresentation>>renderOn: 负责添加“可点击性”。我更新了我的问题。见上文。