LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

[graph] deleted plots are drawn till resize of graph

Solved!
Go to solution

I work on CVI2012SP1 and I´m having some trouble with the graph control.

 

As the stripchart control does make to much trouble for me I went with the graph control to display a moving chart. This works much more painless than with the stripchart, but now I got another problem with drawing the plots.

 

I´m deleting all plots and then adding new ones. Then I call RefreshGraph() and the new plot is drawn, but also is the old plot (see the screenshot)!? If I resize the graph only the current plot is drawn.

 

Why is this so? Is this a bug? How can I work around it?

0 Kudos
Message 1 of 11
(5,415 Views)

What should we learn from your (nice) graphs - it would be more useful if you could provide a short piece of code showing the problem, allowing us to reproduce it.

0 Kudos
Message 2 of 11
(5,412 Views)
Solution
Accepted by topic author ISITEC_RIEPER

Sorry, I don´t have a short piece of code for the problem. The problem is that all old plots, which where deleted by the DeleteGraphPlot function, are still drawn when I select "VAL_DELAYED_DRAW".

 

But I found a solution, I just have to select "VAL_IMMEDIATE_DRAW" for DeleteGraphPlot and it works as expected.

0 Kudos
Message 3 of 11
(5,403 Views)

Good for you that it is working Smiley Wink

 

...but your description does not fit to the expected behavior: calling RefreshGraph() should remove any plots from screen that were deleted using DeleteGraphPlot in delayed draw mode.

0 Kudos
Message 4 of 11
(5,400 Views)
...but your description does not fit to the expected behavior: calling RefreshGraph() should remove any plots from screen that were deleted using DeleteGraphPlot in delayed draw mode.

 

Yeah, I also think so.

 

To test you could create a graph, initialize a buffer with the y-values of a sinus function and do the following all 10 seconds or so:

  • delete all plots of the graph
  • shift the buffer by one element
  • put the buffer into the graph
  • refresh the graph

This is what I´m doing and there the old and deleted plots are still drawn (when VAL_DELAYED_DRAW is selected) till the graph is resized.

 

0 Kudos
Message 5 of 11
(5,381 Views)

I would assume that this is because you modify your data before refreshing the graph - all that RefreshGraph knows is the plot handle (and from this it has to derive the plotted data), so if you use the same plot handle for different data sets it can not work...

0 Kudos
Message 6 of 11
(5,378 Views)

I don´t know if I understood you right.

 

This is a stripped down example of the code I use:

	// Graph nicht zeichnen
	SetCtrlAttribute(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],ATTR_REFRESH_GRAPH,0);
	// alte Plots entfernen
	DeleteGraphPlot(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],-1,VAL_IMMEDIATE_DRAW);
	// aktive Y- Achse setzen
	SetCtrlAttribute(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],ATTR_ACTIVE_YAXIS,VAL_RIGHT_YAXIS);
	// Plots eintragen
	for(int sensor = 0; sensor < 8; sensor++)
	{
		int colorTrace;
		int colorMinMax;
		// Farben festlegen
		if(panel->showTrace[sensor])
		{
			colorTrace = g_GraphTraceColors[sensor];
			
			if(panel->showMinMax[sensor])
			{
				colorMinMax = g_GraphTraceColors[sensor];
			}
			else
			{
				colorMinMax = VAL_TRANSPARENT;
			}
		}
		else
		{
			colorTrace = VAL_TRANSPARENT;
			colorMinMax = VAL_TRANSPARENT;
		}
		// Value Plot zeichnen
		panel->plotHandle[sensor * 3] = PlotXY(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],g_sGraphXBuffer,valueBuffer[sensor],numPointsChart,VAL_INTEGER,VAL_DOUBLE,g_GraphLineThickness,VAL_NO_POINT,VAL_SOLID,1,colorTrace);
		// Min Plot zeichnen
		panel->plotHandle[sensor * 3 + 1] = PlotXY(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],g_sGraphXBuffer,minBuffer[sensor],numPointsChart,VAL_INTEGER,VAL_DOUBLE,g_GraphLineThickness,VAL_NO_POINT,VAL_SOLID,1,colorMinMax);
		// Max Plot zeichnen
		panel->plotHandle[sensor * 3 + 2] = PlotXY(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],g_sGraphXBuffer,maxBuffer[sensor],numPointsChart,VAL_INTEGER,VAL_DOUBLE,g_GraphLineThickness,VAL_NO_POINT,VAL_SOLID,1,colorMinMax);
	}
	// Graph zeichnen
	SetCtrlAttribute(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],ATTR_REFRESH_GRAPH,1);
	RefreshGraph(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART]);

 As said, if I replace the "VAL_IMMEDIATE_DRAW" with "VAL_DELAYED_DRAW" the old plots are drawn until I resize teh graph.

 

As I see it, I´m not reusing the plot handles, but getting new ones for every change (of the data) I make.

0 Kudos
Message 7 of 11
(5,349 Views)

The problem does not occure if I make the graph invisible, delete the old plots, add the new plots and then make it visible again. This also solves my flickering problem.

0 Kudos
Message 8 of 11
(5,342 Views)

Well, the documentation does not elaborate when the plot handles are 'freed', when calling DeleteGraphPlot or when the graph is refreshed (I would have assumed the latter). But then in my understanding it should not depend on the visibility of the graph. And if the plot handles are 'freed' right after calling DeleteGraphPlot then it should not depend on the refresh mode... maybe someone from NI will join in and help...

0 Kudos
Message 9 of 11
(5,330 Views)

So I tried to make a simple version for this problem and what can I say, I can´t reproduce the problem in the simple version.

 

When I got time I need to try to reproduce the problem with my project.

0 Kudos
Message 10 of 11
(5,313 Views)