LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetAxisScalingMode is updated only after graph is refreshed

Solved!
Go to solution

Hi Luis,

 

Thanks for the information!! Now I can relax and wait patiently...Smiley Happy

0 Kudos
Message 11 of 18
(1,957 Views)

Okay, I've now looked into this.

 

1. It's still the case that the failure to update the graph axis range until those plots are refreshed is intentional. When you call GetAxisRange, you should get the maximum and minimum that you see in the graph at the time that you call the function.

 

2. The fact that setting the z-plane position causes the axis range to update was surprising to me, but after having looked at it, it too makes sense. It's a limitation of this attribute that it must refresh the graph before it can change the z-plane position (of course, from the point of view of your workaround, you might consider it to be more of a feature than a limitation Smiley Happy). As it is, it's pretty much equivalent to calling the RefreshGraph function. In any case, the plot attribute documentation did not list this as a side effect. That was an ovesight which we'll correct.

 

I checked, and the z-plane position was the only plot attribute that had this side-effect.

 

Luis

Message 12 of 18
(1,916 Views)

Thanks Luis for investigating this issue further!

 

If this is the intended (and soon properly documented) characteristics it is fine with me. Please advise me then how to achieve the following goal:

 

Let's assume a graph with seven plots in a certain z-plane order.

 

Now I'd like to modify one plot, say no. 3, e.g. subtract some offset (hence the y axis may change) or do some other scale correction.

 

Then I'd like to replot this plot #3 and because I need to end up in the same z-plane order as before, I need to rearrange z-order.

 

All this should be done without refreshing the graph several times, i.e. flicker free.

 

My idea was to set refresh to FALSE, do all the replotting and reordering, and then set refresh to TRUE, so the graph is updated exactly once without all the intermediate hassle.

 

As I understand, at present this is impossible because setting the z-plane order refreshes the graph immediately?!

 

Could it be added as a feature in the near future?

0 Kudos
Message 13 of 18
(1,897 Views)

In the example you give, it sounds as if you only need to change the z-plane of your plot. Is that right? If so, you could all the replotting you need while refresh is FALSE, then change the z-plane of the one plot as the last thing that you do. Yes, that will cause a refresh of the graph, but if it's the last thing you do, then that should be okay, since you're done deleting and redrawing plots.

 

Of course, if you have to change the z-plane of various plots, or if you must add additonal plots after changing the z-plane, then you would still have a flicker problem. In that case, I'd hide the graph (turn ATTR_VISIBLE to FALSE) instead of using the ATTR_REFRESH_GRAPH attribute. As long as you don't process UI events between the time when you hide the graph and the time when you re-show it, the graph should never visually be removed from the panel. But it will prevent any flickering caused by multiple plotting and z-plane changing to occur.

 

Luis

Message 14 of 18
(1,886 Views)

Wow,

 

THIS is a nice trick! I've just tried it and may now enjoy a clean update, thanks a lot! Smiley Very Happy

0 Kudos
Message 15 of 18
(1,880 Views)

Hi Luis,

 

I am happy with the flicker-free update of my graph using the visibility attribute as you have suggested above.

 

However, investigating the issue of refreshing the graph further I found out the following behavior which seems to contradict your statement that changing the z-plane position is pretty much equivalent to calling RefreshGraph, cited below:


1. It's still the case that the failure to update the graph axis range until those plots are refreshed is intentional. When you call GetAxisRange, you should get the maximum and minimum that you see in the graph at the time that you call the function.

 

2. The fact that setting the z-plane position causes the axis range to update was surprising to me, but after having looked at it, it too makes sense. It's a limitation of this attribute that it must refresh the graph before it can change the z-plane position (of course, from the point of view of your workaround, you might consider it to be more of a feature than a limitation :smileyhappy:). As it is, it's pretty much equivalent to calling the RefreshGraph function. In any case, the plot attribute documentation did not list this as a side effect. That was an ovesight which we'll correct.


 

OK, here is what I do:

 

version I:

 

1) hide the graph

2) plot data

3) refresh graph

4) obtain ymin, ymax using GetAxisScalingMode

5) plot vertical lines using PlotLine

6) show the graph

 

This does NOT work, i.e. ymin and ymax reflect the scale before plotting the graph (no. 2), although the graph is refreshed...

So what does refresh do... - does it not work if the graph is not visible??

 

version II:

 

1) hide the graph

2) plot data

3a) plot line

3b) set Z plane of line to 0

4) obtain ymin, ymax using GetAxisScalingMode

5) plot vertical lines using PlotLine

6) show the graph

 

This does not work either (well, actually the z-plane is not changed)

 

version III:

 

1) hide the graph

2) plot data

3a) plot line

3b) set Z plane of line to 1

4) obtain ymin, ymax using GetAxisScalingMode

5) plot vertical lines using PlotLine

6) show the graph

 

This works fine (and is more effective than refreshing the graph)

 

I am curious about your explanation Smiley Wink

0 Kudos
Message 16 of 18
(1,844 Views)

Ok, let's take those one at a time.

 

Version I:

 

RefreshGraph is really only intended to show plots that you had plotted while ATTR_REFRESH_GRAPH was disabled. Since you were not using that attribute in this scenario, calling this function really doesn't help much. By the way, even if you had plots such as those, because the graph is hidden, this function still wouldn't do much of anything, other than flag those plots to be refreshed once you do make the graph visible).

Also, normally the auto-scaling is only applied once the plots are drawn, this means that the axis ranges are also not changing until the time when you make the graph visible again.

 

If you're looking for some way to update the axis ranges before the plots are completely drawn, you still have the option to toggle the z-plane position of a given plot which has the side-effect of applying the auto-scaling. This also works when the graph is hidden.

 

Version II

 

When you set the z-plane of your line to 0, nothing should happen. Since the line plot was plotted last, its z-plane position was already 0 (i.e. on top). Therefore, setting it to 0 is a no-op.

 

Version III

 

For the same reason that setting it to 0 was a no-op, setting it to 1 does change their z-plane position. And yes, changing the z-plane position does have the side-effect of applying auto-scaling, regardless of whether the graph is visible or not.

 

Luis

 

0 Kudos
Message 17 of 18
(1,794 Views)

Thanks Luis!!

 

Your explanation is fine with me but I suggest that the help is updated. Right now, the help for RefreshGraph says:

 

Immediately redraws the plot area.

This action removes from the screen any plots that you delete using DeleteGraphPlot in delayed draw mode. It also displays any plots that you plot while ATTR_REFRESH_GRAPH is FALSE.

 

So you might consider updating the help file according to your statement that the plot area is only redrawn if it is not hidden. Right now, from reading the help I would expect a different behavior, i.e. that the plot is drawn but not visible because the graph is hidden.

 

Wolfgang

0 Kudos
Message 18 of 18
(1,779 Views)