06-22-2015 09:31 AM
Hi,
I would like to report 2 strange behaviors with Graphs that occur when I draw a bitmap image to a graph and then a rectangle.
1/ I would like to change the size of the rectangle by deleting all and then redraw all. I set the attribute ATTR_REFRESH_GRAPH to 0, then I delete all with the attribute VAL_DELAYED_DRAW, I draw all and then call RefreshGraph ().
The problem is that even with the attribute ATTR_REFRESH_GRAPH at 0 the graph is blinking when I change the size of the rectangle and redraw all.
2/ When I draw the bitmap with PlotBitmap and do a RefreshGraph before setting the image with SetCtrlBitmap I get a General Protection Error.
You will find attached a small projetc that illustrates these behaviors.
Thank you
Solved! Go to Solution.
06-22-2015 10:10 AM
Hi
I think the attached 7z file is corrupted.
Here is a new one.
By the way I made the same tests in CVI 2015 Beta and got nearly the same behaviors.
The only difference is that the programm stops without giving the reason, you don't get the message General protection error.
Best regards
06-25-2015 04:37 PM - edited 06-25-2015 04:38 PM
Looks like you found a new bug in the graph control. The bug happens when you change the opacity of a bitmap plot without having assigned it a bitmap.
The usual scenario is for a bitmap to be assigned to the plot at the moment that the plot is created, by passing the bitmap file to the PlotBitmap function. But it's also possible to create the plot without a bitmap, and to set it later from a handle, which is what you are doing, quite correctly. The bug happens when you change the opacity of this bitmap plot without having assigned it the bitmap handle, via the SetCtrlBitmap function.
I've created a bug report for this (534492). Until it's fixed, you should avoid this situation by setting the opacity in tandem with the bitmap handle. Something like this:
GetCtrlVal (panelHandle, PANEL_TEST_ERROR, &ErrorOn);
if (ErrorOn==0)
{
SetCtrlBitmap (panelHandle, PANEL_GRAPH, ImgPlotHandle, PG_RwyImgID);
SetPlotAttribute (panelHandle, PANEL_GRAPH, ImgPlotHandle, ATTR_PLOT_OPACITY, 125);
}
As for the flashing problem, that's because of a limitation of the ATTR_REFRESH_GRAPH attribute. This attribute only disables updates for the plotting functions. It does not disable updates for the SetCtrlBitmap function. That's where the flashing is coming from. The only way I can think of to work around this limitation is to always plot from file, and avoid using SetCtrlBitmap altogether. Something like this:
DeleteGraphPlot (panelHandle, PANEL_GRAPH, -1, VAL_DELAYED_DRAW);
SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_REFRESH_GRAPH, 0);
GetCtrlVal (panelHandle, PANEL_TEST_ERROR, &ErrorOn);
if (ErrorOn==0)
{
ImgPlotHandle = PlotBitmap (panelHandle, PANEL_GRAPH,
0.0, 0.0,
0.0, 0.0, DirAndFile);
SetPlotAttribute (panelHandle, PANEL_GRAPH, ImgPlotHandle, ATTR_PLOT_OPACITY, 125);
}
GetCtrlVal (panelHandle, PANEL_RECT_LENGTH, &RectLength);
PlotRectangle (panelHandle, PANEL_GRAPH, 10.0, 20.0, RectLength-10,
40.0, VAL_RED, VAL_RED);
SetCtrlAttribute (panelHandle, PANEL_GRAPH, ATTR_REFRESH_GRAPH, 1);
Note a couple of other changes I made: I got rid of the RefreshGraph call because it's not necessary. Instead, I simply turn ATTR_REFRESH_GRAPH back on when I'm done plotting (turning it on results in an implicit refresh). It's more intuitive to use the attribute this way, so that you don't have to keep turning it off without ever turning it back on. Also, I moved it below the DeleteGraphPlot, since this attribute does not affect what happens during deletion, which is determined solely by the last parameter you pass to the delete function.
06-26-2015 02:25 AM
Thank you very munch
08-23-2016 02:46 AM - edited 08-23-2016 02:46 AM
Hi Bertrand_ENAC,
The issue described by CAR #534492 has been addressed by the LabWindows/CVI 2015 SP1. Information about other bug fixes in this release can be found at: http://www.ni.com/product-documentation/53302/en/
The update is available for download via NI Update Service.
Best regards,
- Johannes