comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » cursor testcase
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
cursor testcase [message #30921] Tue, 28 May 2002 21:02 Go to next message
Ted Cary is currently offline  Ted Cary
Messages: 53
Registered: October 2001
Member
Hello all,

Probably no one read my rambling list of cursor problems from a week or so
ago. The glitches are not serious but they bother me, so I wrote a testcase
appended to the end of this post. To summarize:

On Macs (IDL 5.4), object graphics window cursors inexplicably change to the
current direct graphics cursor when the user mouses through a window with
the mouse button held down. This is if MOTION_EVENTS are being generated.

On Windows PCs (IDL 5.5), setting direct graphics cursors causes a new
direct graphics window to pop up if none is open already. Maybe there is a
reason or a workaround?

The two glitches together are especially annoying if you are trying to write
cross-platform applications, although it is possible the problem is related
to the different IDL versions (?).

Suggestions? (besides writing platform-specific code)

Thank you,

Ted Cary

;+
; NAME:
;
; Scribble
;
; PURPOSE:
;
; This is a barebones object graphics drawing program that
; demonstrates an object graphics cursor problem.
;
; 1) On Mac (IDL 5.4) platforms, holding down the left button while
; moving the mouse in object graphics windows causes the
; cursor to cycle between the object graphics cursor and the
; direct graphics cursor. This can be solved by setting the
; direct graphics cursor to the same image as the object graphics
; cursor, but...
; 2) On Windows (IDL 5.5) platforms, setting the direct graphics
cursor
; causes a direct graphics window to appear if one is not
; already open.
;
; These two bugs together make it necessary to write platform-
; specific code to change cursors in object graphics.
;
; AUTHOR:
;
; Ted Cary
;
; CATEGORY:
;
; Bug demonstration, proof that I'm not imagining things.
;
; CALLING SEQUENCE:
;
; Scribble
;
; PROCEDURE:
;
; Draw in the object graphics window by moving the mouse.
; Stop moving and double-click to clear the window.
;
; On a Mac (IDL 5.4), if you hold the button down while drawing, the
cursor
; changes from the pencil to the direct graphics standard. This is a
bug--
; you should never see the direct graphics cursor in the object window
; unless they are both set to the same image.
;
; On a Windows Machine (IDL 5.5), if no direct graphics windows are
open
; when the program is run, then a window appears for half a second
; before being destroyed. This is because calls to the DEVICE
procedure to
; change the cursor will open new direct graphics windows. Possibly
there
; is some reason for this (?), but it appears to be another glitch.
It
; does not occur on the Macintosh (IDL 5.4).
;
;

PRO Scribble_Cleanup, wTLB


Widget_Control, wTLB, Get_UValue=info, /No_Copy

; Destroy all objects in info structure.

FOR i=0, N_Tags(info) - 1 DO BEGIN
IF Obj_Valid(info.(i)) THEN BEGIN
Obj_Destroy, info.(i)
ENDIF
ENDFOR
END;-------------------------------------------------

PRO Scribble_Event, ev


Widget_Control, ev.top, Get_UValue=info, /No_Copy
CASE ev.type OF

; Clear ROI on double click.

0 : IF ev.clicks EQ 2 THEN BEGIN
info.oModel->Remove, info.oROI
Obj_Destroy, info.oROI
info.oROI = Obj_New('IDLgrROI', Style=1, Color=[255, 0, 0])
info.oModel->Add, info.oROI
info.oWindow->Draw, info.oView
ENDIF

; Append data to ROI while cursor is moving.

2 : BEGIN
info.oROI->AppendData, [ev.x, ev.y]
info.oWindow->Draw, info.oView
ENDCASE

ELSE :
ENDCASE

Widget_Control, ev.top, Set_UValue=info, /No_Copy
END;-------------------------------------------------

PRO Scribble


; Setup and realize widgets.

wTLB = Widget_Base(Title='Scribble')
wDraw = Widget_Draw( $
wTLB, $
/Button_Events, $
Graphics_Level=2, $
/Motion_Events, $
Renderer=1, $
Retain=0, $
XSize=400, $
YSize=400 $
)
Widget_Control, wTLB, /Realize

; Setup and draw the graphics tree.

Widget_Control, wDraw, Get_Value=oWindow
oView = Obj_New( $
'IDLgrView', $
ViewPlane_Rect = [0, 0, 400, 400] $
)
oModel = Obj_New('IDLgrModel')
oROI = Obj_New('IDLgrROI', Style=1, Color=[255,0,0])
oModel->Add, oROI
oView->Add, oModel
oWindow->Draw, oView

; Store object references in info structure.

info = { $
oModel : oModel, $
oROI : oROI, $
oView : oView, $
oWindow : oWindow $
}
Widget_Control, wTLB, Set_UValue=info, /No_Copy

; Change object graphics window cursor to a fat pencil.

cursorPencil = [ $
7680, 8448, 8448, 9088, 7296, 4160, 2112, 2080, $
1056, 1040, 528, 528, 304, 240, 112, 48 $
]
ByteOrder, cursorPencil
oWindow->SetCurrentCursor, $
HotSpot = [6,0], $
Image=cursorPencil, $
Mask=cursorPencil

; Make sure the direct graphics cursor is set to "standard."

IF !Window GE 0 THEN BEGIN
Device, /Cursor_Standard
ENDIF ELSE BEGIN
Device, /Cursor_Standard

; If using Windows, delete the annoying window that pops up.

IF StrUpCase(!version.os_family) EQ 'WINDOWS' THEN BEGIN
Wait, 0.5
WDelete
ENDIF
ENDELSE

; XManage events and cleanup.

XManager, 'scribble', wTLB, Cleanup='scribble_cleanup', /No_Block
END;-------------------------------------------------
Re: cursor testcase [message #31001 is a reply to message #30921] Wed, 29 May 2002 11:11 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ted Cary (tedcary@yahoo.com) writes:

> Thanks for the workaround... and the typo find. Your trick works because
> the base doesn't have /COLUMN or /ROW set, right?

That's right. A base widget without COLUMN or ROW set is
a bulletin board base widget. It's children are stacked
on top of one another.

> I guess a more general
> version of the same technique would be to create a separate unmapped TLB
> with a draw widget.

I'm not sure that is any more general than this. You
can put any two draw widgets in any bulletin board
base. You could even write your own compound widget
that did this, if you wanted to. I guess *that* would
be pretty general. :-)

> Since I know you don't use Macs often, you probably could not see the cursor
> change problem.

No, I leave this up to Pavel. :-)

> The !Window thing wasn't a typo, technically--I rarely ask
> for the index of the current direct graphics window, so I had forgotten that
> it was a field in the !d structure. !Window worked, so I just left it.
> What is !Window, anyway? It seems to be the short integer version of the
> long !d.window, although a quick "? !Window" command does not show any help
> on it.

My Gosh! I think !Window is a throw-back all the way
to IDL 1.0. That was a LONG time ago! But you are right,
it does seem to work. One of those things they kept meaning
to throw out, I guess.

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: cursor testcase [message #31003 is a reply to message #30921] Wed, 29 May 2002 09:15 Go to previous message
Ted Cary is currently offline  Ted Cary
Messages: 53
Registered: October 2001
Member
>> There is a typo a little further on in your code, too.
> You have "!Window", and I think you mean "!D.Window".
>

Thanks for the workaround... and the typo find. Your trick works because
the base doesn't have /COLUMN or /ROW set, right? I guess a more general
version of the same technique would be to create a separate unmapped TLB
with a draw widget.

Since I know you don't use Macs often, you probably could not see the cursor
change problem. The !Window thing wasn't a typo, technically--I rarely ask
for the index of the current direct graphics window, so I had forgotten that
it was a field in the !d structure. !Window worked, so I just left it.
What is !Window, anyway? It seems to be the short integer version of the
long !d.window, although a quick "? !Window" command does not show any help
on it.

Thanks again,

TC
Re: cursor testcase [message #31017 is a reply to message #30921] Wed, 29 May 2002 05:27 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ted Cary (tedcary@yahoo.com) writes:

> On Windows PCs (IDL 5.5), setting direct graphics cursors causes a new
> direct graphics window to pop up if none is open already. Maybe there is a
> reason or a workaround?

I don't know the reason for it. I find it strange, too, that
changing the cursor in a pixmap window is not allowed.
There clearly has to be an open graphics window.

I created a workaround by putting the object graphics draw
widget in a bulletin board base along with a direct graphics
draw widget, with the object graphics draw widget in front.
This way, there is *always* a window open when you change
the direct graphics cursor:

; Setup and realize widgets.

wTLB = Widget_Base(Title='Scribble')
drawBase = Widget_Base(wTLB) ; Bulletin board base
wDraw = Widget_Draw( $
drawBase, $
/Button_Events, $
Graphics_Level=2, $
/Motion_Events, $
Renderer=1, $
Retain=0, $
XSize=400, $
YSize=400 $
)
fakeDraw = Widget_Draw(drawBase)
Widget_Control, wTLB, /Realize

There is a typo a little further on in your code, too.
You have "!Window", and I think you mean "!D.Window".

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Widgets
Next Topic: Image outline

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 14:52:39 PDT 2025

Total time taken to generate the page: 0.00566 seconds