how to convert window coordinates to GraphWidget coordinates
I was developing a GUI that allows users to drag and drop nodes to GraphWidget. I set the (x,y) provided by the drag and drog event as the position of the node, and it can correctly draw the nodes I put one by one. Also, zoom-in and zoom-out work well. However, when I called "fit_to_window()", the whole graph disappeared.
I checked the differences of the coordinates in my case and the case that draws the graph at one time, as in your example, and I found that the latter always have coordinates (x,y) very samll like less than 10, but my step-by-step case always have coordinates like (220, 400).
I think, in my case, the (x,y) provided by the drag and drop event is something like window coordinates but GraphWidget uses another coordinate system, e.g., cairo_..., which I don't know.
I was wondering if I am right. Another question is how can we manually draw a line between the nodes by pointer, i.e., which function in the graph_tool finishes this job? Thanks a lot.