I'm looking to make an interactive plot using mglGraphZB, where I want to
convert the co-ordinates of the x-y pixel in the drawn graph to the co-
ordinates in the plot (which i then use to adjust the axes). Is there a way to
do this at this time? Currently I am doing this (badly) with my own distance
computations
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Also you can use mglGraphAB::ObjID and array mglGraphAB::OI. First one set
some unique ID for plot (by ObjID). Second one give this ID for screen point
(OI is the array with sizes width*height -- the same as returned by GetBits()
).
For example, at plotting stage:
for(int i=0;i<N;i++)
{
gr->ObjID=i+1; // zero is used by default so, lets avoid it
gr->Plot( a[i] );
}
gr->ObjID=0; // in opposite case all later graphics will have last ObjID
Now you can check the which curve is lied under mouse (supposing x,y lie
inside the picture):
int id = gr->OI[x+gr->GetWidth()*y];
if(id) printf("Curve %d",id-1);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm looking to make an interactive plot using mglGraphZB, where I want to
convert the co-ordinates of the x-y pixel in the drawn graph to the co-
ordinates in the plot (which i then use to adjust the axes). Is there a way to
do this at this time? Currently I am doing this (badly) with my own distance
computations
Yes, you can use CalcXYZ() function. Also you can look on CalcScr() function
for inverse procedure.
Also you can use mglGraphAB::ObjID and array mglGraphAB::OI. First one set
some unique ID for plot (by ObjID). Second one give this ID for screen point
(OI is the array with sizes width*height -- the same as returned by GetBits()
).
For example, at plotting stage:
Now you can check the which curve is lied under mouse (supposing x,y lie
inside the picture):