public override IHitTestObject HitTest(HitTestPointData htd) { IHitTestObject result; var pt = htd.GetHittedPointInWorldCoord(_transformation); foreach (GraphicsPath gp in _cachedSymbolPositions.Keys) { if (gp.IsVisible((PointF)pt)) { result = new HitTestObject(gp, _cachedSymbolPositions[gp]) { DoubleClick = PlotItemEditorMethod }; return(result); } } result = base.HitTest(htd); if (null != result) { result.DoubleClick = TextGraphicsEditorMethod; } return(result); }
public override IHitTestObject HitTest(HitTestPointData htd) { if (_axisStyle.Title != null) { var titleResult = _axisStyle.Title.HitTest(htd); if (null != titleResult) { titleResult.Remove = EhTitleRemove; return(titleResult); } } var pt = htd.GetHittedPointInWorldCoord(); HitTestObjectBase result = null; GraphicsPath gp = GetSelectionPath(); if (gp.IsVisible((PointF)pt)) { result = new MyHitTestObject(this); } if (result != null) { result.DoubleClick = EhHitDoubleClick; } return(result); }
/// <summary> /// Determines whether the grip is hit by the current mouse position. /// </summary> /// <param name="mousePosition">The mouse position (hit ray).</param> /// <returns></returns> public bool IsGripHit(HitTestPointData mousePosition) { var vec = new VectorD3D(_gripRadius, _gripRadius, _gripRadius); var rect = new RectangleD3D(_gripCenter - vec, 2 * vec); return(mousePosition.IsHit(rect, out var z)); }
public void MoveGrip(HitTestPointData newPosition) { foreach (var ele in GripList) { ele.MoveGrip(newPosition); } }
public override IHitTestObject HitTest(HitTestPointData htd) { HitTestObjectBase result = null; GraphicsPath gp = GetPath(); if (_fillBrush.IsVisible && gp.IsVisible((PointF)htd.GetHittedPointInWorldCoord(_transformation))) { result = new GraphicBaseHitTestObject(this); } else if (_linePen.IsVisible && gp.IsOutlineVisible((PointF)htd.GetHittedPointInWorldCoord(_transformation), _linePen)) { result = new GraphicBaseHitTestObject(this); } else { gp.Transform(htd.GetTransformation(_transformation)); // Transform to page coord if (gp.IsOutlineVisible((PointF)htd.HittedPointInPageCoord, new Pen(Color.Black, 6))) { result = new GraphicBaseHitTestObject(this); } } if (result != null) { result.DoubleClick = EhHitDoubleClick; } return(result); }
/// <summary> /// Returns the index of a scatter point that is closest to the location <c>hitpoint</c> /// </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>The information about the point that is nearest to the location, or null if it can not be determined.</returns> public XYZScatterPointInformation GetNearestPlotPoint(IPlotArea layer, HitTestPointData hitpoint) { Processed3DPlotData pdata; if (null != (pdata = _cachedPlotDataUsedForPainting)) { PlotRangeList rangeList = pdata.RangeList; var ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates; double mindistance = double.MaxValue; int minindex = -1; var hitTransformation = hitpoint.HitTransformation; var lineStart = hitTransformation.Transform(ptArray[0]).PointD2DWithoutZ; for (int i = 1; i < ptArray.Length; i++) { var lineEnd = hitTransformation.Transform(ptArray[i]).PointD2DWithoutZ; double distance = Math2D.SquareDistanceLineToPoint(PointD2D.Empty, lineStart, lineEnd); if (distance < mindistance) { mindistance = distance; minindex = Math2D.Distance(lineStart, PointD2D.Empty) < Math2D.Distance(lineEnd, PointD2D.Empty) ? i - 1 : i; } lineStart = lineEnd; } // ok, minindex is the point we are looking for // so we have a look in the rangeList, what row it belongs to int rowindex = rangeList.GetRowIndexForPlotIndex(minindex); return(new XYZScatterPointInformation(ptArray[minindex], rowindex, minindex)); } return(null); }
/// <summary> /// Activates this grip, providing the initial position of the mouse. /// </summary> /// <param name="initialPosition">Initial position of the mouse.</param> /// <param name="isActivatedUponCreation">If true the activation is called right after creation of this handle. If false, /// thie activation is due to a regular mouse click in this grip.</param> public void Activate(HitTestPointData initialPosition, bool isActivatedUponCreation) { foreach (var ele in GripList) { ele.Activate(initialPosition, isActivatedUponCreation); } }
public override IHitTestObject HitTest(HitTestPointData parentHitData) { var result = base.HitTest(parentHitData); if (null != result) { result.DoubleClick = EhHitDoubleClick; } return(result); }
public override IHitTestObject HitTest(HitTestPointData htd) { IHitTestObject result = base.HitTest(htd); if (result != null) { result.DoubleClick = EhHitDoubleClick; } return(result); }
/// <summary> /// Activates this grip, providing the initial position of the mouse. /// </summary> /// <param name="initialPosition">Initial position of the mouse.</param> /// <param name="isActivatedUponCreation">If true the activation is called right after creation of this handle. If false, /// thie activation is due to a regular mouse click in this grip.</param> public void Activate(HitTestPointData initialPosition, bool isActivatedUponCreation) { if (null == initialPosition) throw new ArgumentNullException(nameof(initialPosition)); _wasActivatedUponCreation = isActivatedUponCreation; _initialMousePosition = initialPosition; _initialObjectPosition = ((GraphicBase)_parent.HittedObject).Position; _hasMoved = false; }
/// <summary> /// Calculates a difference vector for moving a handle or an object. /// </summary> /// <param name="initialMousePosition">The initial mouse position at begin of the move operation.</param> /// <param name="currentMousePosition">The current mouse position.</param> /// <param name="initialObjectHitPositionLocalCoordinates">The initial position in local coordinates where the object or the handle was hit.</param> /// <returns>A difference vector (in world coordinates) that can be used to move the object or handle around.</returns> /// <exception cref="System.ArgumentOutOfRangeException"></exception> public static VectorD3D GetMoveVectorInWorldCoordinates(HitTestPointData initialMousePosition, HitTestPointData currentMousePosition, PointD3D initialObjectHitPositionLocalCoordinates) { var m = initialMousePosition.HitTransformation; // initial ray position var n = currentMousePosition.HitTransformation; // current ray position double x = initialObjectHitPositionLocalCoordinates.X; double y = initialObjectHitPositionLocalCoordinates.Y; double z = initialObjectHitPositionLocalCoordinates.Z; // For the mathematics behind the following, see internal document "3D_MoveObjectByMovingRay" double denom = m.M33 * n.M12 * n.M21 - m.M33 * n.M11 * n.M22 - m.M23 * n.M12 * n.M31 + m.M13 * n.M22 * n.M31 + m.M23 * n.M11 * n.M32 - m.M13 * n.M21 * n.M32; if (0 == denom) { throw new ArgumentOutOfRangeException(); } double dx = m.M23 * (-(m.M42 * n.M31) + n.M32 * (m.M41 - n.M41 + m.M11 * x - n.M11 * x + m.M21 * y - n.M21 * y + m.M31 * z) + n.M31 * (n.M42 - m.M12 * x + n.M12 * x - m.M22 * y + n.M22 * y - m.M32 * z)) + m.M33 * (m.M42 * n.M21 - n.M22 * (m.M41 - n.M41 + m.M11 * x - n.M11 * x + m.M21 * y) - (m.M31 * n.M22 - n.M22 * n.M31 + n.M21 * n.M32) * z + n.M21 * (-n.M42 + m.M12 * x - n.M12 * x + m.M22 * y + m.M32 * z)); double dy = m.M13 * (m.M42 * n.M31 - n.M32 * (m.M41 - n.M41 + m.M11 * x - n.M11 * x + m.M21 * y - n.M21 * y + m.M31 * z) + n.M31 * (-n.M42 + m.M12 * x - n.M12 * x + m.M22 * y - n.M22 * y + m.M32 * z)) + m.M33 * (-(m.M42 * n.M11) + n.M12 * (m.M41 - n.M41) + n.M12 * (m.M11 * x + m.M21 * y - n.M21 * y + m.M31 * z - n.M31 * z) + n.M11 * (n.M42 - m.M12 * x - m.M22 * y + n.M22 * y - m.M32 * z + n.M32 * z)); double dz = m.M13 * (-(m.M42 * n.M21) + n.M22 * (m.M41 - n.M41 + m.M11 * x - n.M11 * x + m.M21 * y) + (m.M31 * n.M22 - n.M22 * n.M31 + n.M21 * n.M32) * z + n.M21 * (n.M42 - m.M12 * x + n.M12 * x - m.M22 * y - m.M32 * z)) + m.M23 * (m.M42 * n.M11 + n.M12 * (-m.M41 + n.M41) - n.M12 * (m.M11 * x + m.M21 * y - n.M21 * y + m.M31 * z - n.M31 * z) + n.M11 * (-n.M42 + m.M12 * x + m.M22 * y - n.M22 * y + m.M32 * z - n.M32 * z)); var diff = new VectorD3D(dx / denom, dy / denom, dz / denom); return(diff); }
public bool IsGripHit(HitTestPointData point) { foreach (var ele in GripList) { if (ele.IsGripHit(point)) { return(true); } } return(false); }
/// <summary> /// Activates this grip, providing the initial position of the mouse. /// </summary> /// <param name="initialPosition">Initial position of the mouse.</param> /// <param name="isActivatedUponCreation">If true the activation is called right after creation of this handle. If false, /// thie activation is due to a regular mouse click in this grip.</param> public void Activate(HitTestPointData initialPosition, bool isActivatedUponCreation) { if (null == initialPosition) { throw new ArgumentNullException(nameof(initialPosition)); } _wasActivatedUponCreation = isActivatedUponCreation; _initialMousePosition = initialPosition; _initialObjectPosition = ((GraphicBase)_parent.HittedObject).Position; _hasMoved = false; }
internal IHitTestObject HitTest(HitTestPointData parentCoord, DoubleClickHandler AxisScaleEditorMethod, DoubleClickHandler AxisStyleEditorMethod, DoubleClickHandler AxisLabelMajorStyleEditorMethod, DoubleClickHandler AxisLabelMinorStyleEditorMethod) { foreach (var axisStyle in _axisStyles) { var hit = axisStyle.HitTest(parentCoord, AxisScaleEditorMethod, AxisStyleEditorMethod, AxisLabelMajorStyleEditorMethod, AxisLabelMinorStyleEditorMethod); if (null != hit) { return(hit); } } return(null); }
public IHitTestObject HitTest(HitTestPointData hitData, bool testTickLines) { if (!testTickLines) { var mainAxisPoints = _cachedMainLinePointsUsedForHitTesting; if (null != mainAxisPoints) { if (hitData.IsHit(mainAxisPoints, _axisPen.Thickness1, _axisPen.Thickness2)) { return(new HitTestObject( new PolylineObjectOutline(_axisPen.Thickness1, _axisPen.Thickness2, mainAxisPoints, hitData.WorldTransformation), this, hitData.WorldTransformation)); } } } else // Test Tick lines { // test major ticks for hit if (null != _cachedMajorTickLinesUsedForHitTesting) { foreach (var line in _cachedMajorTickLinesUsedForHitTesting) { if (hitData.IsHit(line, _majorTickPen.Thickness1, _majorTickPen.Thickness2)) { return(new HitTestObject( new MultipleSingleLinesObjectOutline(_majorTickPen.Thickness1, _majorTickPen.Thickness2, _cachedMajorTickLinesUsedForHitTesting, hitData.WorldTransformation), this, hitData.WorldTransformation)); } } } // test minor ticks for hit if (null != _cachedMinorTickLinesUsedForHitTesting) { foreach (var line in _cachedMinorTickLinesUsedForHitTesting) { if (hitData.IsHit(line, _minorTickPen.Thickness1, _majorTickPen.Thickness2)) { return(new HitTestObject( new MultipleSingleLinesObjectOutline(_minorTickPen.Thickness1, _minorTickPen.Thickness2, _cachedMinorTickLinesUsedForHitTesting, hitData.WorldTransformation), this, hitData.WorldTransformation)); } } } } return(null); }
/// <summary> /// Tests a mouse click, whether or not it hits the object. /// </summary> /// <param name="parentHitData">Data containing the position of the click and the transformations.</param> /// <returns>Null if the object is not hitted. Otherwise data to further process the hitted object.</returns> public virtual IHitTestObject HitTest(HitTestPointData parentHitData) { var localHitData = parentHitData.NewFromAdditionalTransformation(_transformation); if (localHitData.IsHit(Bounds, out var z)) { var result = GetNewHitTestObject(parentHitData.WorldTransformation); result.DoubleClick = null; return(result); } else { return(null); } }
/// <summary> /// Moves the grip to the new position. /// </summary> /// <param name="newPosition">The new position (of the mouse).</param> public virtual void MoveGrip(HitTestPointData newPosition) { if (_moveAction != null) { _moveAction(newPosition); } else { var diffWC = MovementGripHandle.GetMoveVectorInWorldCoordinates(_initialMousePosition, newPosition, _gripCenter); // in World coordinates var diffLC = _parent.Transformation.InverseTransform(diffWC); // now in local (layer) coordinates var diffOC = GraphObject._transformation.InverseTransform(diffLC); // now in object coordinates GraphObject.SetBoundsFrom(_fixPointRelativePosition, _fixPointAbsolutePosition, _movePointRelativePosition, diffOC, _initialObjectSize, Main.EventFiring.Suppressed); _hasMoved = true; } }
public void MoveGrip(HitTestPointData newPosition) { var objectToMove = ((GraphicBase)_parent.HittedObject); VectorD3D diff = GetMoveVectorInWorldCoordinates(_initialMousePosition, newPosition, _initialObjectPosition); if (!diff.IsEmpty) { _hasMoved = true; } diff = _parent.Transformation.InverseTransform(diff); // Transform from world to local coordinates objectToMove.SilentSetPosition(_initialObjectPosition + diff); }
public override IHitTestObject HitTest(HitTestPointData parentHitData) { // HitTestPointData layerHitTestData = pageC.NewFromTranslationRotationScaleShear(Position.X, Position.Y, -Rotation, ScaleX, ScaleY, ShearX); var localHitData = parentHitData.NewFromAdditionalTransformation(_transformation); if (localHitData.IsHit(Bounds, out var z)) { var result = GetNewHitTestObject(parentHitData.WorldTransformation); result.DoubleClick = TextGraphicsEditorMethod; return(result); } else { return(null); } }
public bool GetHittedElement(HitTestPointData point, out IGripManipulationHandle gripHandle, out IHitTestObject hitObject) { for (int i = GripList.Count - 1; i >= 0; i--) { if (GripList[i].IsGripHit(point)) { gripHandle = GripList[i]; hitObject = HittedList[i]; return(true); } } gripHandle = null; hitObject = null; return(false); }
/// <summary> /// Tests if a grip from the <see cref="DisplayedGrips"/> is hitted. /// </summary> /// <param name="pt">Mouse location.</param> /// <returns>The grip which was hitted, or null if no grip was hitted.</returns> public IGripManipulationHandle GripHitTest(HitTestPointData pt) { if (null == DisplayedGrips || DisplayedGrips.Length == 0) { return(null); } for (int i = 0; i < DisplayedGrips.Length; i++) { if (DisplayedGrips[i].IsGripHit(pt)) { return(DisplayedGrips[i]); } } return(null); }
public override IHitTestObject HitTest(HitTestPointData parentHitData) { IHitTestObject result = null; var localHitData = parentHitData.NewFromAdditionalTransformation(_transformation); if (localHitData.IsHit(new LineD3D(Bounds.Location, Bounds.LocationPlusSize), _linePen.Thickness1, _linePen.Thickness2)) { result = GetNewHitTestObject(parentHitData.WorldTransformation); } if (result != null) { result.DoubleClick = EhHitDoubleClick; } return(result); }
public IHitTestObject HitTest(HitTestPointData hitData) { var labelOutlines = _cachedLabelOutlines; if (null == labelOutlines) { return(null); } foreach (var outline in labelOutlines) { if (outline.IsHittedBy(hitData)) { return(new HitTestObject(new MultipleRectangularObjectOutlines(labelOutlines, hitData.WorldTransformation), this, hitData.WorldTransformation)); } } return(null); }
public override void OnMouseDown(PointD3D position, MouseButtonEventArgs e) { base.OnMouseDown(position, e); if (e.ChangedButton == MouseButton.Left) { var hitData = new HitTestPointData(_grac.Doc.Camera.GetHitRayMatrix(position)); // first, if we have a mousedown without shift key and the // position has changed with respect to the last mousedown // we have to deselect all objects var keyboardModifiers = System.Windows.Input.Keyboard.Modifiers; bool bControlKey = keyboardModifiers.HasFlag(ModifierKeys.Control); bool bShiftKey = keyboardModifiers.HasFlag(ModifierKeys.Shift); ActiveGrip = GripHitTest(hitData); if ((ActiveGrip is SuperGrip) && (bShiftKey || bControlKey)) { var superGrip = ActiveGrip as SuperGrip; if (superGrip.GetHittedElement(hitData, out var gripHandle, out var hitTestObj)) { _selectedObjects.Remove(hitTestObj); superGrip.Remove(gripHandle); return; } } else if (ActiveGrip != null) { ActiveGrip.Activate(hitData, false); return; } _grac.FindGraphObjectAtPixelPosition(hitData, false, out var clickedObject, out var clickedLayerNumber); if (!bShiftKey && !bControlKey) // if shift or control are pressed, we add the object to the selection list and start moving mode { ClearSelections(); } if (null != clickedObject) { AddSelectedObject(hitData, clickedObject); } } }
/// <summary> /// Looks for a graph object at pixel position <paramref name="pixelPos"/> and returns true if one is found. /// </summary> /// <param name="pixelPos">The pixel coordinates (graph panel coordinates)</param> /// <param name="plotItemsOnly">If true, only the plot items where hit tested.</param> /// <param name="foundObject">Found object if there is one found, else null</param> /// <param name="foundInLayerNumber">The layer the found object belongs to, otherwise 0</param> /// <returns>True if a object was found at the pixel coordinates <paramref name="pixelPos"/>, else false.</returns> public bool FindGraphObjectAtPixelPosition(PointF pixelPos, bool plotItemsOnly, out IHitTestObject foundObject, out int foundInLayerNumber) { var mousePT = PixelToPrintableAreaCoordinates(pixelPos); var hitData = new HitTestPointData(mousePT, this.ZoomFactor); for (int nLayer = 0; nLayer < Layers.Count; nLayer++) { XYPlotLayer layer = Layers[nLayer]; foundObject = layer.HitTest(hitData, plotItemsOnly); if (null != foundObject) { foundInLayerNumber = nLayer; return(true); } } foundObject = null; foundInLayerNumber = 0; return(false); }
/// <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> /// Handles the mouse move event. /// </summary> /// <param name="position">Mouse position.</param> /// <param name="e">MouseEventArgs as provided by the view.</param> /// <returns>The next mouse state handler that should handle mouse events.</returns> public override void OnMouseMove(PointD3D position, MouseEventArgs e) { base.OnMouseMove(position, e); if (null != ActiveGrip) { var graphCoord = new HitTestPointData(_grac.Doc.Camera.GetHitRayMatrix(position)); ActiveGrip.MoveGrip(graphCoord); _wereObjectsMoved = true; _grac?.View?.RenderOverlay(); } /* * else if (e.LeftButton == MouseButtonState.Pressed) * { * var diffPos = position - _positionLastMouseDownInMouseCoordinates; * * var oldRect = _rectangleSelectionArea_GraphCoordinates; * * if (null != _rectangleSelectionArea_GraphCoordinates || * Math.Abs(diffPos.X) >= System.Windows.SystemParameters.MinimumHorizontalDragDistance || * Math.Abs(diffPos.Y) >= System.Windows.SystemParameters.MinimumHorizontalDragDistance) * { * if (null == _rectangleSelectionArea_GraphCoordinates) * { * _grac.CaptureMouse(); * } * * var pt1 = _grac.ConvertMouseToRootLayerCoordinates(_positionLastMouseDownInMouseCoordinates); * var rect = new RectangleD2D(pt1, PointD2D.Empty); * rect.ExpandToInclude(_grac.ConvertMouseToRootLayerCoordinates(position)); * _rectangleSelectionArea_GraphCoordinates = rect; * } * if (null != _rectangleSelectionArea_GraphCoordinates) * _grac.RenderOverlay(); * } */ }
private void AddSelectedObject(HitTestPointData hitPoint, IHitTestObject clickedObject) { _selectedObjects.Add(clickedObject); DisplayedGripLevel = 1; DisplayedGrips = GetGripsFromSelectedObjects(); if (_selectedObjects.Count == 1) // single object selected { ActiveGrip = GripHitTest(hitPoint); if (ActiveGrip != null) { ActiveGrip.Activate(hitPoint, true); } } else // multiple objects selected { ActiveGrip = DisplayedGrips[0]; // this is our SuperGrip DisplayedGrips[0].Activate(hitPoint, true); } _grac.View?.RenderOverlay(); }
public IHitTestObject HitTest(HitTestPointData parentCoord, DoubleClickHandler AxisScaleEditorMethod, DoubleClickHandler AxisStyleEditorMethod, DoubleClickHandler AxisLabelMajorStyleEditorMethod, DoubleClickHandler AxisLabelMinorStyleEditorMethod) { IHitTestObject hit; if (null != (hit = _axisTitle?.HitTest(parentCoord))) { return(hit); } if (IsAxisLineEnabled && null != (hit = _axisLineStyle.HitTest(parentCoord, false))) { hit.DoubleClick = AxisScaleEditorMethod; return(hit); } // hit testing the axes - secondly now with the ticks // in this case the TitleAndFormat editor for the axis should be shown if (IsAxisLineEnabled && null != (hit = _axisLineStyle.HitTest(parentCoord, true))) { hit.DoubleClick = AxisStyleEditorMethod; return(hit); } if (null != (hit = _majorLabelStyle?.HitTest(parentCoord))) { hit.DoubleClick = AxisLabelMajorStyleEditorMethod; return(hit); } if (null != (hit = _minorLabelStyle?.HitTest(parentCoord))) { hit.DoubleClick = AxisLabelMinorStyleEditorMethod; return(hit); } return(null); }
public override IHitTestObject HitTest(HitTestPointData htd) { var myHitTestData = htd.NewFromAdditionalTransformation(_transformation); IHitTestObject result = null; foreach (var axstyle in _axisStyles) { if (null != axstyle.Title && null != (result = axstyle.Title.HitTest(myHitTestData))) { result.Remove = EhAxisTitleRemove; result.Transform(_transformation); return(result); } } result = base.HitTest(htd); if (result != null) { result.DoubleClick = EhDoubleClick; } return(result); }
/// <summary> /// Calculates a difference vector for moving a handle or an object. /// </summary> /// <param name="initialMousePosition">The initial mouse position at begin of the move operation.</param> /// <param name="currentMousePosition">The current mouse position.</param> /// <param name="initialObjectHitPositionLocalCoordinates">The initial position in local coordinates where the object or the handle was hit.</param> /// <returns>A difference vector (in world coordinates) that can be used to move the object or handle around.</returns> /// <exception cref="System.ArgumentOutOfRangeException"></exception> public static VectorD3D GetMoveVectorInWorldCoordinates(HitTestPointData initialMousePosition, HitTestPointData currentMousePosition, PointD3D initialObjectHitPositionLocalCoordinates) { var m = initialMousePosition.HitTransformation; // initial ray position var n = currentMousePosition.HitTransformation; // current ray position double x = initialObjectHitPositionLocalCoordinates.X; double y = initialObjectHitPositionLocalCoordinates.Y; double z = initialObjectHitPositionLocalCoordinates.Z; // For the mathematics behind the following, see internal document "3D_MoveObjectByMovingRay" double denom = m.M33 * n.M12 * n.M21 - m.M33 * n.M11 * n.M22 - m.M23 * n.M12 * n.M31 + m.M13 * n.M22 * n.M31 + m.M23 * n.M11 * n.M32 - m.M13 * n.M21 * n.M32; if (0 == denom) throw new ArgumentOutOfRangeException(); double dx = m.M23 * (-(m.M42 * n.M31) + n.M32 * (m.M41 - n.M41 + m.M11 * x - n.M11 * x + m.M21 * y - n.M21 * y + m.M31 * z) + n.M31 * (n.M42 - m.M12 * x + n.M12 * x - m.M22 * y + n.M22 * y - m.M32 * z)) + m.M33 * (m.M42 * n.M21 - n.M22 * (m.M41 - n.M41 + m.M11 * x - n.M11 * x + m.M21 * y) - (m.M31 * n.M22 - n.M22 * n.M31 + n.M21 * n.M32) * z + n.M21 * (-n.M42 + m.M12 * x - n.M12 * x + m.M22 * y + m.M32 * z)); double dy = m.M13 * (m.M42 * n.M31 - n.M32 * (m.M41 - n.M41 + m.M11 * x - n.M11 * x + m.M21 * y - n.M21 * y + m.M31 * z) + n.M31 * (-n.M42 + m.M12 * x - n.M12 * x + m.M22 * y - n.M22 * y + m.M32 * z)) + m.M33 * (-(m.M42 * n.M11) + n.M12 * (m.M41 - n.M41) + n.M12 * (m.M11 * x + m.M21 * y - n.M21 * y + m.M31 * z - n.M31 * z) + n.M11 * (n.M42 - m.M12 * x - m.M22 * y + n.M22 * y - m.M32 * z + n.M32 * z)); double dz = m.M13 * (-(m.M42 * n.M21) + n.M22 * (m.M41 - n.M41 + m.M11 * x - n.M11 * x + m.M21 * y) + (m.M31 * n.M22 - n.M22 * n.M31 + n.M21 * n.M32) * z + n.M21 * (n.M42 - m.M12 * x + n.M12 * x - m.M22 * y - m.M32 * z)) + m.M23 * (m.M42 * n.M11 + n.M12 * (-m.M41 + n.M41) - n.M12 * (m.M11 * x + m.M21 * y - n.M21 * y + m.M31 * z - n.M31 * z) + n.M11 * (-n.M42 + m.M12 * x + m.M22 * y - n.M22 * y + m.M32 * z - n.M32 * z)); var diff = new VectorD3D(dx / denom, dy / denom, dz / denom); return diff; }
/// <summary> /// Test wether the mouse hits a plot item. The default implementation here returns null. /// If you want to have a reaction on mouse click on a curve, implement this function. /// </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 virtual IHitTestObject HitTest(IPlotArea layer, HitTestPointData hitpoint) { return null; }
public void MoveGrip(HitTestPointData newPosition) { var objectToMove = ((GraphicBase)_parent.HittedObject); VectorD3D diff = GetMoveVectorInWorldCoordinates(_initialMousePosition, newPosition, _initialObjectPosition); if (!diff.IsEmpty) _hasMoved = true; diff = _parent.Transformation.InverseTransform(diff); // Transform from world to local coordinates objectToMove.SilentSetPosition(_initialObjectPosition + diff); }
public override IHitTestObject HitTest(HitTestPointData htd) { IHitTestObject result; var pt = htd.GetHittedPointInWorldCoord(_transformation); foreach (GraphicsPath gp in this._cachedSymbolPositions.Keys) { if (gp.IsVisible((PointF)pt)) { result = new HitTestObject(gp, _cachedSymbolPositions[gp]); result.DoubleClick = PlotItemEditorMethod; return result; } } result = base.HitTest(htd); if (null != result) result.DoubleClick = TextGraphicsEditorMethod; return result; }
public IHitTestObject HitTest(HitTestPointData parentCoord, DoubleClickHandler AxisScaleEditorMethod, DoubleClickHandler AxisStyleEditorMethod, DoubleClickHandler AxisLabelMajorStyleEditorMethod, DoubleClickHandler AxisLabelMinorStyleEditorMethod) { IHitTestObject hit; if (null != (hit = _axisTitle?.HitTest(parentCoord))) return hit; if (this.IsAxisLineEnabled && null != (hit = _axisLineStyle.HitTest(parentCoord, false))) { hit.DoubleClick = AxisScaleEditorMethod; return hit; } // hit testing the axes - secondly now with the ticks // in this case the TitleAndFormat editor for the axis should be shown if (this.IsAxisLineEnabled && null != (hit = _axisLineStyle.HitTest(parentCoord, true))) { hit.DoubleClick = AxisStyleEditorMethod; return hit; } if (null != (hit = _majorLabelStyle?.HitTest(parentCoord))) { hit.DoubleClick = AxisLabelMajorStyleEditorMethod; return hit; } if (null != (hit = _minorLabelStyle?.HitTest(parentCoord))) { hit.DoubleClick = AxisLabelMinorStyleEditorMethod; return hit; } return null; }
public override IHitTestObject HitTest(HitTestPointData htd) { IHitTestObject result = base.HitTest(htd); if (result != null) result.DoubleClick = EhHitDoubleClick; return result; }
/// <summary> /// Returns the index of a scatter point that is closest to the location <c>hitpoint</c> /// </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>The information about the point that is nearest to the location, or null if it can not be determined.</returns> public XYZScatterPointInformation GetNearestPlotPoint(IPlotArea layer, HitTestPointData hitpoint) { Processed3DPlotData pdata; if (null != (pdata = _cachedPlotDataUsedForPainting)) { PlotRangeList rangeList = pdata.RangeList; var ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates; double mindistance = double.MaxValue; int minindex = -1; var hitTransformation = hitpoint.HitTransformation; var lineStart = hitTransformation.Transform(ptArray[0]).PointD2DWithoutZ; for (int i = 1; i < ptArray.Length; i++) { var lineEnd = hitTransformation.Transform(ptArray[i]).PointD2DWithoutZ; double distance = Math2D.SquareDistanceLineToPoint(PointD2D.Empty, lineStart, lineEnd); if (distance < mindistance) { mindistance = distance; minindex = Math2D.Distance(lineStart, PointD2D.Empty) < Math2D.Distance(lineEnd, PointD2D.Empty) ? i - 1 : i; } lineStart = lineEnd; } // ok, minindex is the point we are looking for // so we have a look in the rangeList, what row it belongs to int rowindex = rangeList.GetRowIndexForPlotIndex(minindex); return new XYZScatterPointInformation(ptArray[minindex], rowindex, minindex); } return null; }
public IHitTestObject HitTest(HitTestPointData hitData, bool testTickLines) { if (!testTickLines) { var mainAxisPoints = _cachedMainLinePointsUsedForHitTesting; if (null != mainAxisPoints) { if (hitData.IsHit(mainAxisPoints, _axisPen.Thickness1, _axisPen.Thickness2)) return new HitTestObject( new PolylineObjectOutline(_axisPen.Thickness1, _axisPen.Thickness2, mainAxisPoints, hitData.WorldTransformation), this, hitData.WorldTransformation); } } else // Test Tick lines { // test major ticks for hit if (null != _cachedMajorTickLinesUsedForHitTesting) { foreach (var line in _cachedMajorTickLinesUsedForHitTesting) { if (hitData.IsHit(line, _majorTickPen.Thickness1, _majorTickPen.Thickness2)) return new HitTestObject( new MultipleSingleLinesObjectOutline(_majorTickPen.Thickness1, _majorTickPen.Thickness2, _cachedMajorTickLinesUsedForHitTesting, hitData.WorldTransformation), this, hitData.WorldTransformation); } } // test minor ticks for hit if (null != _cachedMinorTickLinesUsedForHitTesting) { foreach (var line in _cachedMinorTickLinesUsedForHitTesting) { if (hitData.IsHit(line, _minorTickPen.Thickness1, _majorTickPen.Thickness2)) return new HitTestObject( new MultipleSingleLinesObjectOutline(_minorTickPen.Thickness1, _minorTickPen.Thickness2, _cachedMinorTickLinesUsedForHitTesting, hitData.WorldTransformation), this, hitData.WorldTransformation); } } } return null; }
public IHitTestObject HitTest(HitTestPointData hitData) { var labelOutlines = _cachedLabelOutlines; if (null == labelOutlines) return null; foreach (var outline in labelOutlines) { if (outline.IsHittedBy(hitData)) return new HitTestObject(new MultipleRectangularObjectOutlines(labelOutlines, hitData.WorldTransformation), this, hitData.WorldTransformation); } return null; }
/// <summary> /// Activates this grip, providing the initial position of the mouse. /// </summary> /// <param name="initialPosition">Initial position of the mouse.</param> /// <param name="isActivatedUponCreation">If true the activation is called right after creation of this handle. If false, /// thie activation is due to a regular mouse click in this grip.</param> public void Activate(HitTestPointData initialPosition, bool isActivatedUponCreation) { _initialMousePosition = initialPosition; _hasMoved = false; }
public override IHitTestObject HitTest(HitTestPointData htd) { HitTestObjectBase result = null; GraphicsPath gp = GetPath(); if (gp.IsOutlineVisible((PointF)htd.GetHittedPointInWorldCoord(_transformation), _linePen)) { result = new LineShapeHitTestObject(this); } else { gp.Transform(htd.GetTransformation(_transformation)); // Transform to page coord if (gp.IsOutlineVisible((PointF)htd.HittedPointInPageCoord, new Pen(Color.Black, 6))) { result = new LineShapeHitTestObject(this); } } if (result != null) result.DoubleClick = EhHitDoubleClick; return result; }
/// <summary> /// Determines whether the grip is hit by the current mouse position. /// </summary> /// <param name="mousePosition">The mouse position (hit ray).</param> /// <returns></returns> public bool IsGripHit(HitTestPointData mousePosition) { var vec = new VectorD3D(_gripRadius, _gripRadius, _gripRadius); var rect = new RectangleD3D(_gripCenter - vec, 2 * vec); double z; return mousePosition.IsHit(rect, out z); }
public override IHitTestObject HitTest(HitTestPointData parentHitData) { // HitTestPointData layerHitTestData = pageC.NewFromTranslationRotationScaleShear(Position.X, Position.Y, -Rotation, ScaleX, ScaleY, ShearX); var localHitData = parentHitData.NewFromAdditionalTransformation(this._transformation); double z; if (localHitData.IsHit(Bounds, out z)) { var result = GetNewHitTestObject(parentHitData.WorldTransformation); result.DoubleClick = TextGraphicsEditorMethod; return result; } else { return null; } }
public override IHitTestObject HitTest(HitTestPointData parentHitData) { IHitTestObject result = null; var localHitData = parentHitData.NewFromAdditionalTransformation(_transformation); if (localHitData.IsHit(new LineD3D(Bounds.Location, Bounds.LocationPlusSize), _linePen.Thickness1, _linePen.Thickness2)) { result = GetNewHitTestObject(parentHitData.WorldTransformation); } if (result != null) result.DoubleClick = EhHitDoubleClick; return result; }
public bool IsGripHit(HitTestPointData point) { return _gripPath.IsHittedBy(point); }
public override IHitTestObject HitTest(HitTestPointData htd) { var myHitTestData = htd.NewFromAdditionalTransformation(_transformation); IHitTestObject result = null; foreach (var axstyle in _axisStyles) { if (null != axstyle.Title && null != (result = axstyle.Title.HitTest(myHitTestData))) { result.Remove = this.EhAxisTitleRemove; result.Transform(_transformation); return result; } } result = base.HitTest(htd); if (result != null) result.DoubleClick = EhDoubleClick; return result; }
public override IHitTestObject HitTest(HitTestPointData htd) { if (_axisStyle.Title != null) { var titleResult = _axisStyle.Title.HitTest(htd); if (null != titleResult) { titleResult.Remove = EhTitleRemove; return titleResult; } } var pt = htd.GetHittedPointInWorldCoord(); HitTestObjectBase result = null; GraphicsPath gp = GetSelectionPath(); if (gp.IsVisible((PointF)pt)) { result = new MyHitTestObject(this); } if (result != null) result.DoubleClick = EhHitDoubleClick; return result; }
public override IHitTestObject HitTest(HitTestPointData parentHitData) { var result = base.HitTest(parentHitData); if (null != result) { result.DoubleClick = EhHitDoubleClick; } return result; }
/// <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); }