Tulip-Dev / tulip

Large graphs analysis, drawing and visualization framework
http://tulip.labri.fr/
GNU Lesser General Public License v3.0
124 stars 24 forks source link

Wrong result of the python method `View.pickNodeEdge` #139

Open rgiot opened 5 years ago

rgiot commented 5 years ago

If I use the code of the issue #133 and apply to it this patch:

@@ -49,4 +49,9 @@ mouse = g.addNode()
 viewLayout[mouse] = mouse_world
 viewSize[mouse] = (0.75, 0.75, 1.0)

+g.delNode(n)
+
+found = gui.pickNodeEdge(mouse_view[0], mouse_view[1],True, False)
+print found
+

I obtain the following answer (False, <node 4294967295>, <edge 4294967295>) wheras I expect to obtain (False, <node 6>, <edge 4294967295>)

anlambert commented 5 years ago

This seems related to issue #137.

When the graph set to the view is empty and calling method setOverviewVisible before the resize one, a nasty side effect appears.

This code works as expected for instance:

from tulip import tlp
from tulipgui import tlpgui

WIDTH = 500
HEIGHT = 500

g = tlp.newGraph()
viewLayout = g.getLayoutProperty("viewLayout")
viewSize = g.getSizeProperty("viewSize")
viewColor = g.getColorProperty("viewColor")

gui = tlpgui.createNodeLinkDiagramView(g)

gui.resize(WIDTH, HEIGHT)
gui.setOverviewVisible(False)

# Ensure the camera is as I want
nodes = g.addNodes(4)
viewLayout[nodes[0]] = (-10,10,0)
viewLayout[nodes[1]] = (-10,-10,0)
viewLayout[nodes[2]] = (10,10,0)
viewLayout[nodes[3]] = (10,-10,0)
for i in range(4):
    viewColor[nodes[i]] = tlp.Color.Black

gui.centerView()

# Add node in the middle of screen using world coordinates
n = g.addNode()
viewLayout[n] = (0, 0, 0)
viewSize[n] = (1.0, 1.0, 1.0)
viewColor[n] = tlp.Color.Green

# Add node in the middle of screen using pixels coordinates (should hide the previous one)
mouse_view = (WIDTH/2, HEIGHT/2, 0)
mouse_world = gui.viewToWorld(mouse_view)

print("View", mouse_view, "Computed World", mouse_world, "Groundtruth world", (0,0,0))

mouse = g.addNode()

viewLayout[mouse] = mouse_world
viewSize[mouse] = (0.75, 0.75, 1.0)

g.delNode(n)

found = gui.pickNodeEdge(mouse_view[0], mouse_view[1],True, False)
print(found)