LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Don't get an EVENT_COMMIT from graph control

Hi,

I need to obtain the cursor coordinates from a graph control. My cursor snaps to the plot but never generates an EVENT_COMMIT, I see and EVENT_LEFT_CLICK and EVENT_VAL_CHANGED, but these give me the last coordinates not the current ones.

I get the same effect on the demo graphcursors.prj if I put a printf("event = %d", event); before or after the UpdateMarker switch statement.


int CVICALLBACK graphCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
int activeCursorNumber = 0;
int plotHandle;
int arrayIndex;
int index;
double x,y;
char tempString[10];

switch (event) {
case EVENT_COMMIT:

GetActiveGraphCursor (panel, control, &activeCursorNumber);

if(activeCursorNumber) {

GetGraphCursor (panel, control, activeCursorNumber, &x, &y);
GetGraphCursorIndex (panel, control, activeCursorNumber, &plotHandle, &arrayIndex);

/* get the handle for the graph */
for(index = 0; index < MAX_CHANNELS; index++) {
if(gDynamicPlotHandle[index] == plotHandle)
break;
}

SetCtrlVal (gPanelHandle[CURSOR_PANEL], CURSOR_STG_PLOT_1, scanInfo[index]->plotName);

SetCtrlVal (gPanelHandle[CURSOR_PANEL], CURSOR_NUM_TEMP_1, y);

convertSecsToTime(x, tempString);
SetCtrlVal (gPanelHandle[CURSOR_PANEL], CURSOR_STG_TIME_1, tempString);

}
break;
}
return 0;
}
0 Kudos
Message 1 of 5
(3,275 Views)
Hi,
it does not come from your sourcecode, but from your panel.
Double click on your graph to see the control settings and set the "Control Mode" to "Hot" instead of "Normal".
0 Kudos
Message 2 of 5
(3,273 Views)
Thanks for your reply, the graphs control mode is already set to VAL_HOT.
But I still can't get an EVENT_COMMIT.
I am genertaing 8 graphs onto 8 panels programatically here is the code I generate the graphs with:


/* create a graph control */
gDynamicGraphHandle[graphIndex] = NewCtrl (gDynamicPanelHandle[graphIndex], CTRL_GRAPH, tempString, 0, 0);
InstallCtrlCallback (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], graphCallback, NULL);

/* set control mode */
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_CTRL_MODE, VAL_HOT);

/* configure graph colours */
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_PLOT_BGCOLOR, VAL_BLACK);
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_GRID_COLOR, VAL_WHITE);

/* configure graph size */
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_WIDTH, 600);
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_HEIGHT, 300);

/* configure graph the Y axis */
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_YNAME, "Temperature (°C)");
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_YDIVISIONS, NUMBER_OF_DIVISIONS);
SetAxisScalingMode (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], VAL_LEFT_YAXIS, VAL_MANUAL, 0, 100);

/* configure graph the X axis */
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_XNAME, "Time (seconds)");
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_XDIVISIONS, NUMBER_OF_DIVISIONS);
SetAxisScalingMode (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], VAL_BOTTOM_XAXIS , VAL_MANUAL, 0, TIME_1_MINUTE * NUMBER_OF_DIVISIONS);

/* configure the pan and scan */
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_ENABLE_ZOOM_AND_PAN, TRUE);
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_CTRL_MODE, VAL_NORMAL);

SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_LEGEND_VISIBLE, TRUE);
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_LEGEND_SHOW_SAMPLES, TRUE);
0 Kudos
Message 3 of 5
(3,248 Views)
No, your control mode is set to VAL_NORMAL again with following line from your code:
SetCtrlAttribute (gDynamicPanelHandle[graphIndex], gDynamicGraphHandle[graphIndex], ATTR_CTRL_MODE, VAL_NORMAL);
!!!
0 Kudos
Message 4 of 5
(3,244 Views)
Doah

Sorry about that I didn't notice I had set it twice cheers for your help.

James
0 Kudos
Message 5 of 5
(3,242 Views)