Results 1 to 8 of 8

Thread: Update a WwDrawingArea

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    10

    Update a WwDrawing widget

    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 :

    Code:
    ; 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.

  2. #2
    Senior Member
    Join Date
    Aug 2006
    Posts
    137
    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

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    10
    Thanks for your help.

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

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    10
    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 :

    Code:
    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

  5. #5
    Senior Member
    Join Date
    Aug 2006
    Posts
    137
    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.

  6. #6
    Junior Member
    Join Date
    Feb 2010
    Posts
    10
    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.

  7. #7
    Senior Member
    Join Date
    Aug 2006
    Posts
    137
    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.
    Code:
    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

  8. #8
    Junior Member
    Join Date
    Feb 2010
    Posts
    10
    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 !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •