private void RemoveAdornerSet3D(AdornerSet3D adornerSet3D) { Viewport3DElement adornedViewport = adornerSet3D.AdornerSet3DContainer.AdornedViewport; if (adornedViewport == null) { throw new InvalidOperationException(ExceptionStringTable.AdornedViewport3DElementMayNotBeNull); } IList <AdornerElementSet> containingElement = this.GetAdornerElementSetsContainingElement((SceneElement)adornedViewport); if (containingElement.Count <= 0) { return; } foreach (AdornerElementSet adornerElementSet in (IEnumerable <AdornerElementSet>)containingElement) { AdornerLayer.ElementInfo elementInfo = this.GetElementInfo(adornerElementSet); if (elementInfo.AdornerSet3DContainer != null && elementInfo.AdornerSet3DContainer.AdornerSets.Contains(adornerSet3D) && (elementInfo != null && elementInfo.RemoveAdornerSet(adornerSet3D))) { AdornerSet3DContainer adornerSet3Dcontainer = elementInfo.AdornerSet3DContainer; if (adornerSet3Dcontainer.AdornerSetCount == 0) { elementInfo.AdornerSet3DContainer = (AdornerSet3DContainer)null; this.children.Remove((Visual)adornerSet3Dcontainer); this.adornerSet3DContainers.Remove(adornerSet3Dcontainer); } if (elementInfo.IsEmpty) { this.elementMap.Remove(adornerElementSet); } } } }
internal Adorner3D GetHitAdorner3D(AdornerSet3DContainer layer, Point point) { this.hitTestParameters3D = new PointHitTestParameters(point); this.hitObject = (RectangleHitTestResult)null; VisualTreeHelper.HitTest((Visual)layer, new HitTestFilterCallback(this.FilterPotentialHit), new HitTestResultCallback(this.ProcessHitTestResult3D), (HitTestParameters)this.hitTestParameters3D); if (this.hitObject != null) { ModelVisual3D modelVisual3D1 = (ModelVisual3D)null; foreach (DependencyObject dependencyObject in this.hitObject.HitPath) { ModelVisual3D modelVisual3D2 = dependencyObject as ModelVisual3D; if (modelVisual3D2 != null) { modelVisual3D1 = modelVisual3D2; break; } } Adorner3D associatedAdorner = layer.GetAssociatedAdorner(modelVisual3D1); if (associatedAdorner != null) { return(associatedAdorner); } } return((Adorner3D)null); }
protected void RecomputeTransform() { AdornerSet3DContainer adornerSet3Dcontainer = this.adornerSet3DContainer; Viewport3D viewport = (Viewport3D)this.Element.Viewport.ViewObject.PlatformSpecificObject; Matrix3D viewport3DtoElement = this.Element.GetComputedTransformFromViewport3DToElement(); Point3D point = new Point3D(); if (this.DoCenterOnSpecifiedCenter) { point = (CanonicalTransform3D)this.Element.Transform.Center; } Matrix3D source = viewport3DtoElement; source.TranslatePrepend((Vector3D)point); if (this.DoRemoveObjectScale) { Matrix3D rotation = new Matrix3D(); Vector3D scale = new Vector3D(); Matrix3DOperations.DecomposeIntoRotationAndScale(source, out rotation, out scale); rotation.OffsetX = source.OffsetX; rotation.OffsetY = source.OffsetY; rotation.OffsetZ = source.OffsetZ; source = rotation; } if (this.adornmentLayer == AdornerSet3D.Location.OrthographicLayer && adornerSet3Dcontainer.ShadowAdorningViewport3D.Camera is ProjectionCamera) { OrthographicCamera ortho = (OrthographicCamera)adornerSet3Dcontainer.OrthographicAdorningViewport3D.Camera; Point3D point3D = AdornedToolBehavior3D.ProjectionPoint3DTranslatedToMatchingOrthographicPosition(viewport, viewport3DtoElement, ortho, point); source.OffsetX = point3D.X; source.OffsetY = point3D.Y; source.OffsetZ = point3D.Z; } Point3D targetPoint = new Point3D(source.OffsetX, source.OffsetY, source.OffsetZ); if (this.DoScaleToScreen) { double num1 = this.adornmentLayer != AdornerSet3D.Location.OrthographicLayer || !(adornerSet3Dcontainer.ShadowAdorningViewport3D.Camera is ProjectionCamera) ? Helper3D.UnitsPerPixel(viewport, targetPoint) * AdornerSet3D.PixelsPerInch : 6.0 / (this.AdornerSet3DContainer.AdornedViewport.GetComputedTightBounds().Width / 96.0); Matrix rotation; Vector scale; Matrix3DOperations.DecomposeIntoRotationAndScale(ElementUtilities.GetComputedTransform((Visual)viewport, (Visual)(this.View.ViewModel.DefaultView.ViewRoot.PlatformSpecificObject as FrameworkElement)), out rotation, out scale); double x = scale.X; double zoom = this.View.Zoom; double num2 = num1 / zoom * x; double offsetX = -targetPoint.X * num2 + targetPoint.X; double offsetY = -targetPoint.Y * num2 + targetPoint.Y; double offsetZ = -targetPoint.Z * num2 + targetPoint.Z; Matrix3D matrix3D = new Matrix3D(num2, 0.0, 0.0, 0.0, 0.0, num2, 0.0, 0.0, 0.0, 0.0, num2, 0.0, offsetX, offsetY, offsetZ, 1.0); ((MatrixTransform3D)this.adornerSetVisual.Transform).Matrix = source * matrix3D; } else { ((MatrixTransform3D)this.adornerSetVisual.Transform).Matrix = source; } }