PDA

View Full Version : Update a WwDrawingArea



buzzkaido
04-07-2010, 08:46 AM
Hi !

I'm working on a widget based-application and I use a WwDrawing widget to display some results (using the callback parameter).

But I need to force update of the WwDraw widget several times (every step of the process).

I try to used :



; Creation :
drawId = WwDrawing(layout, widx, ?DrawCB?, $
[256, 256], [512, 512], /Noscroll, $
Area = areaId, /Right, /Left, /Top, /Bottom)

; Update : doesn't work
WwSetValue(drawId , /update)

; Update : doesn't work
WwSetValue(areaId, /update)


But it doesn't seems to work : the "DrawCB" function is not called

Could someone help me on that ?

Thanks.

rwagner
04-07-2010, 12:50 PM
Wwsetvalue with respect to wwdrawing is used to update the size of the drawing area. The callback function is called when the drawing area is resized or if backing store is not used to redraw when the area is covered by another window.

If you want to force an update, why not call the callback function directly?

-Ryan

buzzkaido
04-07-2010, 02:40 PM
Thanks for your help.

I didn't try to call the DrawCB directly... I'll try it !

buzzkaido
04-09-2010, 01:06 AM
Hum... it's working... but the problem is it doesn't draw in the right widget.

Probably because of a "Graphics Context" problem :

- the 'DrawCB' function is used as a draw callback for widget A
- when I call 'DrawCB' function directly from widget B, the 'DrawCB' draws on widget B !

In fact, I think the best way to do that is to send an "WM_PAINT" event to the widget, corresponding to a PV-Wave event with "ExposureMask" set.

But I didn't find a way to send such an event.

I tried using : TmExecuteMethod, widgetId, 'TM_DISPLAY'

But I gives me an error at runtime.

Is there any way to "invalidate" the content of a WwDrawing ?

Thanks.


Here is my 'DrawCB' test function :


PRO DrawCB, wid, data

test_image = bytarr(512, 512)
for x=1,511 do begin
for y=1,511 do begin
test_image(x,y) = y/2
endfor
endfor

tv, test_image

end

rwagner
04-09-2010, 09:39 AM
Take a look at the documentation for WSET. When you create a WWDRAWING area you supply a window_id. Wset tells PV-WAVE which wwdrawing area to update using this window_id. So in the callback for A, call WWSET, window_id_for_a and do similarly for B.

buzzkaido
04-09-2010, 10:20 AM
Thanks.

I tried :

status = wwset(widx)

But it doesn't work...

From the documentation :

WSet Procedure
Used to select the current, or ?active? window to be used by the graphics
and imaging routines.

Seems like "WSet" is used only for raised a window, not update it.

rwagner
04-09-2010, 12:04 PM
Ok, look at this and see if it clears it up for you. You weren't passing in the window_ids, you were using the widget_id.



PRO DrawCB1, wid, data
COMMON c1, img, count, window_id1, window_id2
PRINT, 'Draw1'
WSET,data
TV, img
END

PRO DrawCB2, wid, data
COMMON c1, img, count, window_id1, window_id2
PRINT, 'Draw2'
WSET,data
TV, img
END

PRO ButtonCB, wid, data
COMMON c1, img, count, window_id1, window_id2
PRINT, 'Button'
img = RANDOMN(count, 512,512)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;
; EXAMPLE OF CALLING CALLBACKS DIRECTLY. NOTE THAT THE
; WINDOW_ID IS PASSED IN AS THE SECOND PARAM.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;
IF count MOD 2 EQ 0 THEN BEGIN
drawCB1,0, window_id1
ENDIF ELSE BEGIN
drawcb2,0, window_id2
ENDELSE
count = count + 1
END

PRO draw2
top=WwInit('ww_ex24', 'Examples', layout)
COMMON c1, img, count, window_id1, window_id2
count = 0
img = BYTARR(512,512)
OPENR,1, !Data_Dir + 'head.img'
READU,1,img
CLOSE, 1
draw = WwDrawing(layout, 1, 'DrawCB1', [256,256], [512,512], area=area)
draw2 = WwDrawing(layout, 2, 'DrawCB2', [256,256], [512,512], area=area2)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;
;NOTE: In these two calls (above) 1 and 2 are the window ids.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;
window_id1 = 1
window_id2 = 2
bbox = wwbuttonbox(layout, ['test'], 'buttoncb', /Horizontal)
status = WwSetValue(top, /Display)
WwLoop
END

buzzkaido
04-20-2010, 08:39 AM
Ok, look at this and see if it clears it up for you. You weren't passing in the window_ids, you were using the widget_id.

Exact, I didn't read carefully the first time.

Thanks a lot !