Re: Tracking Cursor in Object Graphics Draw Widgets [message #42265 is a reply to message #42264] |
Fri, 21 January 2005 09:28  |
Antonio Santiago
Messages: 201 Registered: February 2004
|
Senior Member |
|
|
Hi,
I dont know if I understand so well your question.
I am supossing you are refering to have 2 widget draw with a pair of
"photos" and select some points on one implies select the same points in
the other.
(I hope i am right with my suposition because this message is a bit
sticky :) )
Some time ago I create a little "EventAction" class that can add signals
(events) and actions to the objects.
Supossing you have a new object graphics class that show an image and
select some points you can use "EventAction" to emit the signal
"point_select" and configure a method of your class to receive the event.
Then you can connect one object with the other using signals (events).
For example, i have a class that shows a "photo" and permits me to
select a region. It inherits from my "EventAction" class and:
FUNCTION SelectMap::Init, parent, _EXTRA=extra
;;Initilize superclass
result = self->EventAction::Init()
IF NOT KEYWORD_SET(parent) THEN RETURN, 0
;;Create widget and object hieriarchy.
wBase = WIDGET_BASE(parent)
wDraw = WIDGET_DRAW(wBase, GRAPHICS_LEVEL=2, /EXPOSE_EVENTS, $
/BUTTON_EVENTS, /MOTION_EVENTS, _EXTRA=extra, $
UVALUE={class_name: 'SelectMap', object: self, $
handler: 'EventHandler'})
self.parent_id = parent
self.base_id = wBase
self.widget_id = wDraw
;;Register the 'event' of the class
self->AddEvent, 'POINT_SELECT'
self->AddEvent, 'POINT_UNSELECT'
self->AddEvent, 'LINE_SELECTION'
self->AddEvent, 'SQUARE_SELECTION'
self->AddEvent, 'MOTION'
self->Initialize
RETURN, 1
END
I initialize some signals (events) in the class.
Later in the method that handles the events i emit the corresponding
events. For example when I select a point:
self->EmitEvent, 'POINT_SELECT', $
EVENT_STRUCT={x: values[0], y: values[1]}
Then all method object, function or procedures that are connected with
that signal are executed.
You can use the same mechanism to "connect" your classes without
coupling them. One class dont known anything of the others that are
listening it.
Well, this is a link to my home page:
" http://asantiago.gentelibre.org/index.php/archives/2004/11/1 8/a-signal-mechanism-for-objects-in-idl/".
It has an example how to use. It is not very object oriented but at work
i use it between object and helps me very often.
Bye.
Antonio
> Object Graphics Gurus,
>
> Suppose I have two object graphics draw widgets in a program.
> And suppose I wanted to move the cursor in one window and
> have it mirrored in the other. Anybody know how to do that
> in object graphics?
>
> Cheers,
>
> David
>
|
|
|