private static void MyLinesInPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { OcTreeManager otm = d as OcTreeManager; if (otm != null) { List <Utils.LineWHistory> lines = e.NewValue as List <Utils.LineWHistory>; if (lines != null) { if (!otm.root.TreeBuilt) { otm.root.BuildTree(otm.MinVolumeSize, lines); } else { otm.root.UpdateTree(lines); } //// DEBUG //otm.root.BuildTree(otm.MinVolumeSize, lines); // DEBUG var test = otm.root.ToString(); otm.UpdateGeometry(); } } }
private static void MyShowTreePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { OcTreeManager otm = d as OcTreeManager; if (otm != null) { if (otm.ShowTree) { otm.cell.Visibility = Visibility.Visible; otm.colPointMarker.Visibility = Visibility.Visible; } else { otm.cell.Visibility = Visibility.Collapsed; otm.colPointMarker.Visibility = Visibility.Collapsed; } } }
public int OnMouseMove(Point _currentHit, Viewport3DXext _vp, out Point3D snapPoint, bool _testEnd, bool _testMid, bool _testInters, int _pixelTolerance = 20) { int foundIndex = -1; snapPoint = new Point3D(0, 0, 0); if (_currentHit == null || _vp == null) { return(foundIndex); } // test points priority: END > INTERSECTION > MIDPOINT if (_testEnd) { foundIndex = OcTreeManager.SnapTestPoints(_currentHit, _vp, out snapPoint, _pixelTolerance, this.PointsVisible_End); if (foundIndex != -1) { this.snapMarker.Geometry = OcTreeManager.EndPoint; } } if (_testInters && foundIndex == -1) { foundIndex = OcTreeManager.SnapTestPoints(_currentHit, _vp, out snapPoint, _pixelTolerance, this.PointsCollision); if (foundIndex != -1) { this.snapMarker.Geometry = OcTreeManager.IntPoint; } } if (_testMid && foundIndex == -1) { foundIndex = OcTreeManager.SnapTestPoints(_currentHit, _vp, out snapPoint, _pixelTolerance, this.PointsVisible_Mid); if (foundIndex != -1) { this.snapMarker.Geometry = OcTreeManager.MidPoint; } } // process display if (foundIndex != -1) { // snap found Vector3D offset = snapPoint - new Point3D(0, 0, 0); double scale = Vector3.Distance(snapPoint.ToVector3(), _vp.Camera.Position.ToVector3()); float factOrthoCam = ((_vp.Camera as HelixToolkit.SharpDX.OrthographicCamera) != null) ? SNAP_ORTHOFACT : 1.0f; scale *= factOrthoCam; Matrix3D M = Matrix3D.Identity; M.Scale(new Vector3D(scale, scale, scale)); M.Translate(offset); this.snapMarker.Transform = new MatrixTransform3D(M); this.snapMarker.Visibility = Visibility.Visible; } else { this.snapMarker.Transform = new MatrixTransform3D(Matrix3D.Identity); this.snapMarker.Visibility = Visibility.Hidden; } return(foundIndex); }