04-20-2005 09:44 AM
04-20-2005 09:02 PM
private void OnPlotAreaMouseMove(object sender, MouseEventArgs e)
{
double xValue, yValue;
InverseMap(waveformGraph1.PlotAreaBounds, e.X, e.Y, xAxis1, yAxis1, out xValue, out yValue);
xyCursor1.XPosition = xValue;
xyCursor1.YPosition = yValue;
}
private void InverseMap(Rectangle plotAreaBounds, int x, int y, XAxis xAxis,
YAxis yAxis, out double xValue, out double yValue)
{
xValue = ((xAxis.Range.Maximum - xAxis.Range.Minimum) *
((x - plotAreaBounds.Left) / (double)(plotAreaBounds.Right - plotAreaBounds.Left))) + xAxis.Range.Minimum;
yValue = ((yAxis.Range.Maximum - yAxis.Range.Minimum) *
((plotAreaBounds.Bottom - y)/ (double)(plotAreaBounds.Bottom - plotAreaBounds.Top))) + yAxis.Range.Minimum;
}
04-21-2005 09:46 AM
04-21-2005 09:51 PM
private void OnPlotAreaMouseMove(object sender, MouseEventArgs e)
{
double xValue, yValue;
InverseMap(waveformGraph1.PlotAreaBounds, e.X, e.Y, xAxis1, yAxis1, out xValue, out yValue);
xyCursor1.XPosition = xValue;
xyCursor1.YPosition = yValue;
}
private Range GetScaledLogRange(Range range, double logBase)
{
Range scaledRange = range;
if(scaledRange.Minimum <= 0)
scaledRange = new Range(Math.Pow(logBase, -1), scaledRange.Maximum);
scaledRange = new Range(Math.Log(scaledRange.Minimum, logBase), Math.Log(scaledRange.Maximum, logBase));
return scaledRange;
}
private void InverseMap(Rectangle plotAreaBounds, int x, int y, XAxis xAxis, YAxis yAxis,
out double xValue, out double yValue)
{
if(xAxis.ScaleType == ScaleType.Logarithmic)
{
Range scaledRange = GetScaledLogRange(xAxis.Range, xAxis.LogBase);
xValue = Math.Pow(xAxis.LogBase, ((scaledRange.Maximum - scaledRange.Minimum) *
((x - plotAreaBounds.Left) / (double)(plotAreaBounds.Right - plotAreaBounds.Left))) + scaledRange.Minimum);
}
else
{
xValue = ((xAxis.Range.Maximum - xAxis.Range.Minimum) *
((x - plotAreaBounds.Left) / (double)(plotAreaBounds.Right - plotAreaBounds.Left))) + xAxis.Range.Minimum;
}
if(yAxis.ScaleType == ScaleType.Logarithmic)
{
Range scaledRange = GetScaledLogRange(yAxis.Range, yAxis.LogBase);
yValue = Math.Pow(yAxis.LogBase, ((scaledRange.Maximum - scaledRange.Minimum) *
((plotAreaBounds.Bottom - y)/ (double)(plotAreaBounds.Bottom - plotAreaBounds.Top))) + scaledRange.Minimum);
}
else
{
yValue = ((yAxis.Range.Maximum - yAxis.Range.Minimum) *
((plotAreaBounds.Bottom - y)/ (double)(plotAreaBounds.Bottom - plotAreaBounds.Top))) + yAxis.Range.Minimum;
}
}
04-22-2005 07:47 AM - edited 04-22-2005 07:47 AM
Message Edited by dprice on 04-22-2005 07:48 AM
04-22-2005 08:40 AM
04-22-2005 10:17 AM
04-22-2005 10:49 AM