LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I zoom/pan on two graphs at the same time?

I have two separate graphs both with zooming enabled. I want to be able to have my mouse cursor on one of them, but when I do the zoom thing (ctrl + right click) I want BOTH of the graphs to zoom in. Is this possible? I'm using CVI 5.5
0 Kudos
Message 1 of 3
(3,506 Views)
I understand that's not so elegant, but you could try a workaround like this one:
1. DO NOT enable zooming on the graph
2. Instead, write your own routine to zoom both graphs.

Here you'll find some sample code to zoom the x-axis of a graph; it's easily expandable for panning, for the y-axis and for the other graph:

int CVICALLBACK zoom (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int mod, left, right;
double min, max;

switch (event) {
case EVENT_LEFT_CLICK:
case EVENT_RIGHT_CLICK:
GetGlobalMouseState (NULL, NULL, NULL, &left, &right, &mod);
if (mod & VAL_MENUKEY_MODIFIER) {
GetAxisScalingMode (panel, control, VAL_XAXIS, 0, &min, &max);
if (right) {
min *= 1.1;

max /= 1.1;
}
else {
min /= 1.1;
max *= 1.1;
}
SetAxisScalingMode (panel, control, VAL_XAXIS, VAL_MANUAL, min, max);
// Place code here to zoom other graph
}
break;
}
return 0;
}

I tried this solution and it behaves differently from the original zooming: it doesn't respond if you maintain the mouse button pressed and on my machine some clicks are missed... but it works.

Hope this helps
Roberto


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?
Message 2 of 3
(3,506 Views)
Dear Roberto,

Thank you so much for your quick response. I tried out the code you provided and it worked like a charm!

--Marianne
0 Kudos
Message 3 of 3
(3,506 Views)