Getting X Positions through the MouseMove Event
Posted: Tue Sep 12, 2006 12:34 pm
I am currently using VB6 to create a program to plot data using the DPlotLib. I am attempting to "zoom in" on a graph when the user clicks on a certain section of the graph, and therefore need to know the X value clicked on. I copied the code used in the BTEST2.vbp project, and I am getting interesting and unexpected results.
The problem appears to be related to the range of points I choose to display. Unlike BTEST2.vbp's X range of 1 to 4, my plots are from 350 to 900, with Y values as large as 26000. I am also using a DataFormat = DATA_XYXY, instead of BTEST2's DATA_XYYY. I am still using linear scaling.
When I am on the tick mark for 450, the mousemove displays 477, 500=>522, and by the time it gets to 750=>752 it is almost correct. I experimented and increased my range to 350-1050, and it results in 450=>485 ... 850=>853, even worse. With a range of 350-360 everything was fine.
So it appears the offset I am getting is some function of the data range I am displaying. The magic guts of the MouseMove event appears to be the following code:
The vll/hll/vur/hur values are in pixels. Is there anything special about those pixel values in relation to the picturebox I should account for? Am I missing something obvious?
In the meantime I am going to derive the equation for the offset I am seeing for the data ranges I plan on using, maybe that will shed some light on the situation.
thanks,
xander
The problem appears to be related to the range of points I choose to display. Unlike BTEST2.vbp's X range of 1 to 4, my plots are from 350 to 900, with Y values as large as 26000. I am also using a DataFormat = DATA_XYXY, instead of BTEST2's DATA_XYYY. I am still using linear scaling.
When I am on the tick mark for 450, the mousemove displays 477, 500=>522, and by the time it gets to 750=>752 it is almost correct. I experimented and increased my range to 350-1050, and it results in 450=>485 ... 850=>853, even worse. With a range of 350-360 everything was fine.
So it appears the offset I am getting is some function of the data range I am displaying. The magic guts of the MouseMove event appears to be the following code:
Code: Select all
worldx = DPM.xlo + (X - DPM.hll) * (DPM.xhi - DPM.xlo) / (DPM.hur - DPM.hll)
worldy = DPM.ylo + (Y - DPM.vll) * (DPM.yhi - DPM.ylo) / (DPM.vur - DPM.vll)
In the meantime I am going to derive the equation for the offset I am seeing for the data ranges I plan on using, maybe that will shed some light on the situation.
thanks,
xander