LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

canvas Refresh

I have a panel containing multiple canvas controls.  I am displaying images in each canvas.  If I open another panel on top of the panel containing the canvas controls and all the images are lost.  I can not refresh the images using updatecanvas.  I tried adjusting overlap policy and draw policy but the original images are lost.  I also tried using a graph but the same problem occurs.  Minimizing the panel causes the same problem.  Any suggestions?
0 Kudos
Message 1 of 9
(4,343 Views)
See if a call to processDrawEvents() works for you.
0 Kudos
Message 2 of 9
(4,334 Views)
My best guess is that you set the "Draw Policy" option to "Direct to Screen" (programmatic attribute is ATTR_DRAW_POLICY). This makes the drawing faster, but it also means that what you draw isn't retained when the canvas needs to redraw itself.

Luis
0 Kudos
Message 3 of 9
(4,318 Views)
I have tried a ProcessDrawEvents() and changed the draw policy and the problem still exists.  I am using CVI 7.0.
0 Kudos
Message 4 of 9
(4,299 Views)
The problem exists in the CVI example Grab and snap that uses an array and displays the image in a canvas.  I also looked at a canvas example that draws lines and shapes on a canvas.  It does not have this issue.  I believe the problem is with the array that is displayed in the canvas using the plot command.  I do not believe an image is stored in memory so it does not refresh when an overlap or the panel is minimized then restored. 
0 Kudos
Message 5 of 9
(4,287 Views)
Is samples\userint\canvasbmk.prj the example that you're referring to? In that example, the lines do disappear from the canvas when you minimize and then restore, but that is because the draw policy of the canvas is set to "Direct to Screen" (that's the fastest drawing mode). If you edit the canvas and change it to one of the other two policies, the lines shouldn't disappear any more. If they continue to disappear for you after you change the draw policy, that would be a bug, and I'll have to figure out how to reproduce the problem here.

Are you perhaps using a different example? I know of only two other shipping examples that use the canvas control (alphablend.prj and canvas.prj), but I don't think it's either of those.

Luis
0 Kudos
Message 6 of 9
(4,275 Views)
The example I was referring to was the Grab or Snap examples in CVI 7.0.  I will verify the Canvas settings Tomorrow.

Jon K.

0 Kudos
Message 7 of 9
(4,256 Views)

I changed the settings to mark for update and update immediately and the problem still occurs.  The example I am using is Imaq\snap\HLsnap.cws.  I tired ProcessDrawEvents() and CanvasUpdate without success.

 

0 Kudos
Message 8 of 9
(4,239 Views)
Okay, that makes more sense. I hadn't realized until now that you were using the imaq library to draw to your canvas. I had assumed that you were using the native CVI canvas functions from the UI library (CanvasDrawBitmap, etc...). The other functions you've mentioned, like CanvasUpdate, ProcessDrawEvents, and even the ATTR_DRAW_POLICY attribute only impact the native canvas controls functions from the UI library. The imaq functions are from a completely different library (which unfortunately I'm not really familiar with).

Since the imaq library doesn't have access to the internals of the CVI canvas control, it's not too surprising that it can't draw something into the canvas that would persist in the control. Looking at the imgPlot function, it looks as if it just treats the canvas as a region of the window, to which it renders a frame buffer once.

If I were you, I would assume that I would have to redraw the contents of the buffer every time the CVI window needs to redraw itself. To accomplish this, it should be sufficient to trap the low-level windows message WM_PAINT (you can do this with the InstallWinMsgCallback function from the Programmer's Toolbox). When you receive that message, you can post an internal event (using PostDeferredCall) to redraw the canvas. The reason you need to post an event is because you have to draw after CVI draws the blank canvas control first.

For more, and probably better recommendations, I also recommend that you re-post this question in the Machine Vision forum, since you're more likely to run into expert users of this library in that forum.

Luis


Message 9 of 9
(4,235 Views)