Function Graphics overlaid objects on image() [message #90364] |
Thu, 26 February 2015 05:26  |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
Hi,
I'm working with function graphics and I'm overlaying objects (lines, polygons) on images. I would like these objects to be linked to the underlying image (pinned if you wish), unless the user explicitly moves these objects with the mouse.
I would like to avoid having to handle events from the object on my own (pick up event, process, send to all overlaid objects). I have the feeling that there might be an easy solution...
I have so far tested three conditions (the test code is below):
Data coordinates: in this case the overlays are anchored to the image (if the image is made smaller or moved, the objects are rescaled along). However, it is not possible to move the polylines. The only ways is by clicking on the end-points and changing the line length and angle. However, after this clicking on the image results in a rotation in space of the image... very inconvenient
Norm or relative coordinates: in this case the objects are unfortunately not anchored to the underlying image.
Is there a trivial solution to this problem that I haven't picked up?
Thanks,
Helder
pro testFGObjects
;data coordinates
w1 = window(dimensions=[500,500], window_title='Data coordinates')
i1 = image(dist(500), current=w1)
scale = [i1.xrange[1]-i1.xrange[0],i1.yrange[1]-i1.yrange[0]]
l1 = polyline([0.25,0.75]*scale[0],[0.25,0.75]*scale[1], /data, target=i1)
;norm coordinates
w2 = window(dimensions=[500,500], window_title='Norm coordinates')
i2 = image(dist(500), current=w2)
l2 = polyline([0.25,0.75],[0.25,0.75], /norm, target=i2)
;relative coordinates
w3 = window(dimensions=[500,500], window_title='Relative coordinates')
i3 = image(dist(500), current=w3)
l3 = polyline([0.25,0.75],[0.25,0.75], /relative, target=i3)
;test widget interaction:
;data coordinates: it is not possible to move the line, only to change
; its size by moving the edges. After this the image
; becomes 3d. The line rescales/moves with the underlying image
;norm coordinates: line responds to movements with the mouse. But the line
; does not move when rescaling/moving the undlying image
;relative coordinates: same as norm coordinates
end
|
|
|