Keeping objects fixed in function graphics [message #86986] |
Thu, 19 December 2013 04:40  |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
Hi,
since I spent the last half an hour trying to figure this out, I thought I might as well share this.
The reason and idea behind this, was to draw in a window where I have an image some sort of markers that stay where they are. For example a grid or an aiming target or crosshair.
One should be able to pan and zoom the image below it, but not these objects on top.
Well, this is how I did it. Let me know if you know of a better/cleaner way, otherwise I'll stick to this.
What I did was basically turn off the event handlers for mouse movements and any other sort. Here is the code:
;#################################
FUNCTION AvoidMovingObj::MouseDown, oWin, x, y, iButton, KeyMods, nClicks
RETURN, 1
END
FUNCTION AvoidMovingObj::MouseMotion, oWin, x, y, KeyMods
RETURN, ~ISA(oWin.GetSelect(), 'ELLIPSE')
END
FUNCTION AvoidMovingObj::MouseUp, oWin, x, y, iButton
RETURN, ~ISA(oWin.GetSelect(), 'ELLIPSE')
END
FUNCTION AvoidMovingObj::MouseWheel, oWin, x, y, Delta, KeyMods
RETURN, ~ISA(oWin.GetSelect(), 'ELLIPSE')
END
PRO AvoidMovingObj__define
void = {AvoidMovingObj, inherits GraphicsEventAdapter}
END
PRO AvoidMovingObjTest
p = PLOT(/test)
e = ellipse(0.5,0.5, '-r2', FILL_BACKGROUND=0, /norm)
e.window.EVENT_HANDLER=Obj_New('AvoidMovingObj')
END
;#################################
There are two clear drawbacks in this way of working:
1) if there are ellipses that one would like to move, than I should make sure that the correct ellipse (or object) is not moved and the rest is moved. I think this is solvable, but I didn't spend time on it yet
2) this seems to be an intrinsic drawback of this method: when clicking on the "unmovable" object, the mouse cursor will stay as it is until another object has been clicked. Not terrible, but not elegant.
I hope I'm not the only one in need for this and if you have suggestion on how to improve this... very welcome!
Cheers,
Helder
|
|
|