04-18-2013 07:32 AM
Oups, I have noticed that sometimes, the graph appears to be hidden after SetPlotAttribute function executes. So the behaviour is not always strictly the same...sometimes it's PlotY and sometimes it's SetPlotAttribute...
04-18-2013 09:36 AM
Maybe I have an idea, not very simple but it can be a solution...
I'm going to try using SetPlotAttribute with ATTR_PLOT_YDATA attribute...So, after getting a plot handle during first function call, I will have the possibility to replace plot Y data only for this plot handle (without changing any other attribute). I will need to declare some static variable inside UpdateGraph () function.
Does anybody have any other idea ?
04-18-2013 10:14 AM
My solution works and legend does not "blink" any more but...it's not a good idea. In terms of performance, it's lame ! So, if anybody has another suggestion, I would really appreciate it ! ^^
04-19-2013 03:23 AM
OK ! I kept my solution which made legend not blink. But there was something stupid in what I did : the number of points for each channels ! I plotted 1 second of data (2000 points) and needed to see only 40 ms, so I displayed only the 80 first points for each channel...but for each channel, 2000 points were "loaded" into the graph !
Instead of doing this stupid thing, I decided to plot directly 40 ms of data (80 points instead of 2000)...Now that's OK...
04-19-2013 03:42 AM
Congratulations! Learning by doing is a time-consuming but sustainable method 😉
04-19-2013 04:05 AM
Yes indeed ! ^^ Thank you everybody for your help !
04-22-2013 09:53 AM
Hi Julien,
I realize you've already resolved your problem, but I was curious about the fact that you saw the graph disappear when you plotted. I wouldn't expect that to happen. I tested the following snippet:
SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_VISIBLE, 0);
PlotY (panel, PANEL_GRAPH, data, 100, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_VISIBLE, 1);
... and for me, the graph never disappears, even if I single-step through the code, in the debugger. In other words, PlotY did not trigger a redraw event.
If you happen to have a code snippet for which the redraw does happen, would you mind posting here, so that I could check it?
Thanks,
Luis
04-22-2013 10:05 AM
Hi Luis,
My code was as follow...(this function was called in another thread, but I guess that it does not change anything)
/*========================================================================================*/
/* Update graph function */
/*========================================================================================*/
void UpdateGraph (float64 *acqData, CHNLCONFIG *chnlConfig)
{
int plotIndex;
int plotHdl;
const int chnlColor[NB_CHANNELS] = {VAL_RED, VAL_GREEN, VAL_BLUE, VAL_DK_RED, VAL_DK_GREEN, VAL_DK_BLUE};
const char *chnlName[NB_CHANNELS] = {"U1", "U2", "U3", "I1", "I2", "I3"};
const int chnlAxis[NB_CHANNELS] = {VAL_LEFT_YAXIS, VAL_LEFT_YAXIS, VAL_LEFT_YAXIS, VAL_RIGHT_YAXIS, VAL_RIGHT_YAXIS, VAL_RIGHT_YAXIS};
// Make graph invisible
SetCtrlAttribute (mesPanelHdl, TABMES_UIGRAPH, ATTR_VISIBLE, 0);
// Delete graph
DeleteGraphPlot (mesPanelHdl, TABMES_UIGRAPH, -1, VAL_DELAYED_DRAW);
// For each plot...
for (plotIndex = 0 ; plotIndex < NB_CHANNELS ; plotIndex++)
{
// If channel activated...
if (chnlConfig[plotIndex].selected)
{
// Plot curve
plotHdl = PlotY (mesPanelHdl, TABMES_UIGRAPH, acqData + plotIndex * RATE, RATE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, chnlColor[plotIndex]);
// Set curve name
SetPlotAttribute (mesPanelHdl, TABMES_UIGRAPH, plotHdl, ATTR_PLOT_LG_TEXT, chnlName[plotIndex]);
// Set curve axis
SetPlotAttribute (mesPanelHdl, TABMES_UIGRAPH, plotHdl, ATTR_PLOT_YAXIS, chnlAxis[plotIndex]);
}
}
// Make graph visible
SetCtrlAttribute (mesPanelHdl, TABMES_UIGRAPH, ATTR_VISIBLE, 1);
04-29-2013 07:34 AM
Thanks, Julien.
I have a couple more questions:
1. Does this graph have any cursors in VAL_SNAP_TO_POINT mode?
2. Is chnlAxis[plotIndex] = VAL_RIGHT_YAXIS for any of your plots?
Thanks,
Luis
04-29-2013 07:39 AM
Hi Luis,
1. Does this graph have any cursors in VAL_SNAP_TO_POINT mode? => NO
2. Is chnlAxis[plotIndex] = VAL_RIGHT_YAXIS for any of your plots? => NO (there are 6 plots : VAL_LEFT_YAXIS for plots 1 to 3, and VAL_RIGHT_YAXIS for plots 4 to 6)
Any idea ? 🙂