LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting onto multiple graphs using PlotIntensity in a while loop

Can anyone help me?
I'm a student trying to do some image processing work. I'm trying to use PlotIntensity to plot several different results in seperate graphs on the same panel. I'm attempting to do this in a while loop and changing the Control ID of the graph with each iteration but it doesn't seem to work. Sounds simple huh but think its easier said than done.
0 Kudos
Message 1 of 5
(3,380 Views)

Hi  Leanne,

Would it be possible for you to post a copy of your code for me to look at?

Thanks

Emma Rogulska

NIUK & Ireland

0 Kudos
Message 2 of 5
(3,361 Views)
Dear Emma,
             here's the code that I used. I know the rest of it works fine because I can plot each result on the same graph the problem is plotting each result on a seperate graph.  The crux of the problem is what kind of variable is the Control Id for a graph? It doesn't appear to be a string or int.  I'd greatly appreciate any help.
                                    Leanne

           
            GetCtrlVal(panelHandle, PANEL_START, &start);
            GetCtrlVal(panelHandle, PANEL_END, &end);
            ww=start;
            ref=1;
       
            step = (end-start)/5;
             
            while(ww<=end)
            {
                sprintf(dd, "%d", ref);
                strcpy (str,"PANELCHILD_");
                strcat (str, dd);
                  
                StrToInt (str, &graph);
               
                DisplayPanel(childHandle);
                PlotIntensity(PANELCHILD,graph,Dec,column_num,row_num,
                    VAL_DOUBLE,colors,VAL_WHITE,colour_num,col,pix);
                   
                ww=ww+step;
                ref=ref+1;
             }
0 Kudos
Message 3 of 5
(3,320 Views)

ControlID is always an integer: it identifies the control on the panel pointed to by Panel Handle.

When you use the control name (e.g. PANEL_GRAPH) you are actually using a macro defined in the .h file associated to your user interface file, i.e. you are using an integer value.

In your problem, you need to address multiple controls in a loop: my personal solution is to create an array of integers to hold control IDs and then use the array values inside the loop, this way (look at the red parts; I'm supposing PANELCHILE is your panel the grapgh lie on and childHandle is its handle):

int   ctrl[10];

// Create the array of control IDs
ctrl[0] = PANELCHILD_GRAPH;
ctrl[1] = PANELCHILD_GRAPH_2;
...
ctrl[9] = PANELCHILD_GRAPH_10;

while(ww<=end) {
    DisplayPanel (childHandle);
    PlotIntensity(childHandle, ctrl[ref], Dec, column_num, row_num,
            VAL_DOUBLE, colors, VAL_WHITE, colour_num, col, pix);

    ww=ww+step;
    ref=ref+1;
}

Last tip: the online help for built-in functions shows you also the type of variable the function expects for this parameter; right-clicking on ControlID parameter in PlotIntensity function panel will show you the following:

Control Name: ControlID
Data type: int

Message Edited by Roberto Bozzolo on 05-31-2006 12:04 PM



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 5
(3,314 Views)
Thanks Roberto, that was a huge help.
                         Leanne
0 Kudos
Message 5 of 5
(3,306 Views)