LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing order of plots

Hello all,

say you have several plots on a graph:

PlotY(...)
PlotWaveform(...)
Rect=PlotRectangle(...)

Now Rect is on top, but I want to draw it below the others (I cannot change
the order fo the draw orders). I thought I could then do something like:
SetPlotAttribute (.., Rect, ATTR_PLOT_ZPLANE_POSITION, 10);
Or some high value for the zplane position.

But it fails with "The attribute value passed is not valid".
Do I need to set it to the precise number of plots already drawn ? I cannot
seem to find this value among GetPlotAttribute or GetCtrlAttribute.

Any idea ?
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 1 of 14
(6,485 Views)
Hello Gillaume, You should definitely be able to change the order of the plots with ATTR_PLOT_ZPLANE_POSITION. The problem is the value that you are passing it. Unfortunately, you can't just specify an arbitrarily large value. The value that you pass must be the nth plot in the z-plane ordering. So, for example, if you have 5 plots in the graph, and you want to move a plot all the way to the back, you must set the value to be 4 (the topmost plot is in the 0th position). Luis
0 Kudos
Message 2 of 14
(6,474 Views)
> The value that you pass must be the n th plot in the z-plane ordering.

Thanks Luis,
That's good to know... but how do you know how many plots are on your graph.
There must be an attribute somewhere but I can't find it.
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 3 of 14
(6,467 Views)

@Guillaume Dargaud wrote:
...how do you know how many plots are on your graph...


You could plot some fake element (say a single pixel outside plotting region or on (0, 0)): the plot handle retrieved is the last present in the graph...


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 14
(6,453 Views)
Roberto's suggestion works if you've never deleted any plot. It's true that the plot ids are numbered sequentially, but the ids are never reused. So if you've created 3 plots, their ids will be 1, 2, 3. If you then delete plot #2, and you create a new plot, its id will be 4, not 2. Roberto's method doesn't take these gaps into account.

There actually is an attribute to return the total number of plots in the graph, but for some reason it was never made public (I would love to tell you that that reason is, but for the life of me I can't remember). In any case, its perfectly safe to use, even though it's not public. Its attribute id is 20465. So, simply call GetCtrlAttribute with that attribute id, and it should work.

Luis
0 Kudos
Message 5 of 14
(6,495 Views)

Luis, I wonder how many of these hidden tips will fall out of your pockets if we shake you hard enough?!?! Smiley Wink Smiley Very Happy

Anyway, how many plots will return this attribute in your example? 2 or 3? In the first case, setting the zplane order of a plot to 2 (the last one) will not move it below all the others since it will remain on top of plot 3... I'll make a try later when coming back to the office.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 14
(6,474 Views)
Ok, both zplane position and number of plots (attribute 20465) take care of deleted plots while plot handle doesn't.
So the correct solution to move a plot in the background is:
 
- Plot your data (including deleting plots if necessary)
- GetCtrlAttribute (panelHandle, PANEL_GRAPH, 20465, &numPlots);
- SetPlotAttribute (panelHandle, PANEL_GRAPH, plotHandle, ATTR_PLOT_ZPLANE_POSITION, numPlots - 1);
 
Thanks to Luis to share this tip with us Smiley Happy


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 14
(6,466 Views)
Hello Roberto

> - GetCtrlAttribute (panelHandle, PANEL_GRAPH, 20465, &numPlots);

I had noticed the problem with deleted plots. Thanks for the tip on the
hidden attribute.
--
Guillaume Dargaud
http://www.gdargaud.net/
"Heaven sent and hell bent over the mountain tops we go !" - Lyrics
from Sweet Bird of Truth by The The.


0 Kudos
Message 8 of 14
(6,457 Views)

Hi all,

 

Your posts have helped me learn how to change the order of plots (albeit a long time after your original posts).

 

I have noticed in my case running LabWindows/cvi 8.5 that changing the order using the ATTR_PLOT_ZPLANE_POSITION only changes the visible order of the plots  and the order of the plot legends.  It does not change the order of the data arrays in the graph memory.

 

For example if I plot Array0 then Array1 using 2 PlotY calls, swap the plots and then read the plots back using 2 GetPlotAttribute calls with ATTR_PLOT_YDATA the data arrays will be returned in the original order of Array0 & Array1.

 

Is this what you would expect ?

 

Thanks

 

Aaron

0 Kudos
Message 9 of 14
(5,626 Views)

I have also noticed that the last plot added to a graph becomes the top visible plot 0 and all previous plots shift up by 1.  The plot legend visible order is also descending.

 

For example if I add a Temperature plot it will be visible plot 0 and the legend will look like this...

 

Temperature (visible plot 0)

 

If I then add a Pressure plot it will become visible plot 0, the Temperature will now become visible plot 1 and the legend will look like this...

 

Temperature (visible plot 1)

Pressure (visible plot 0)

 

If I swap the plots the legend will look like this...

 

Pressure (visible plot 1)

Temperature (visible plot 0)

 

The Temperature & Pressure data array / plot handle numbering will be unchanged though.

 

I guess this shows that the visible plot order / numbering is seperate from the data array / plot handle numbering.

0 Kudos
Message 10 of 14
(5,625 Views)