/// <summary> /// Test wether the mouse hits a plot item. /// </summary> /// <param name="layer">The layer in which this plot item is drawn into.</param> /// <param name="hitpoint">The point where the mouse is pressed.</param> /// <returns>Null if no hit, or a <see cref="IHitTestObject" /> if there was a hit.</returns> public override IHitTestObject HitTest(IPlotArea layer, HitTestPointData hitpoint) { Processed3DPlotData pdata = _cachedPlotDataUsedForPainting; if (null == pdata) { return(null); } var rangeList = pdata.RangeList; var ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates; if (ptArray.Length < 2) { return(null); } var hitTransformation = hitpoint.HitTransformation; int hitindex = -1; var lineStart = hitTransformation.Transform(ptArray[0]).PointD2DWithoutZ; for (int i = 1; i < ptArray.Length; i++) { var lineEnd = hitTransformation.Transform(ptArray[i]).PointD2DWithoutZ; if (Math2D.IsPointIntoDistance(PointD2D.Empty, 1, lineStart, lineEnd)) { hitindex = i; break; } lineStart = lineEnd; } if (hitindex < 0) { return(null); } var outline = new PolylineObjectOutline(5, 5, ptArray, hitpoint.WorldTransformation); return(new HitTestObject(outline, this, hitpoint.WorldTransformation)); }
/// <summary> /// Test wether the mouse hits a plot item. /// </summary> /// <param name="layer">The layer in which this plot item is drawn into.</param> /// <param name="hitpoint">The point where the mouse is pressed.</param> /// <returns>Null if no hit, or a <see cref="IHitTestObject" /> if there was a hit.</returns> public override IHitTestObject HitTest(IPlotArea layer, HitTestPointData hitpoint) { Processed3DPlotData pdata = _cachedPlotDataUsedForPainting; if (null == pdata) return null; var rangeList = pdata.RangeList; var ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates; if (ptArray.Length < 2) return null; var hitTransformation = hitpoint.HitTransformation; int hitindex = -1; var lineStart = hitTransformation.Transform(ptArray[0]).PointD2DWithoutZ; for (int i = 1; i < ptArray.Length; i++) { var lineEnd = hitTransformation.Transform(ptArray[i]).PointD2DWithoutZ; if (Math2D.IsPointIntoDistance(PointD2D.Empty, 1, lineStart, lineEnd)) { hitindex = i; break; } lineStart = lineEnd; } if (hitindex < 0) return null; var outline = new PolylineObjectOutline(5, 5, ptArray, hitpoint.WorldTransformation); return new HitTestObject(outline, this, hitpoint.WorldTransformation); }