Esempio n. 1
0
        public static double UnitsPerPixel(Viewport3D viewport, Base3DElement targetModel)
        {
            Matrix3D      matrix3D1     = Matrix3D.Identity;
            Base3DElement base3Delement = targetModel.Parent as Base3DElement;

            if (base3Delement != null)
            {
                matrix3D1 = base3Delement.GetComputedTransformFromViewport3DToElement();
            }
            Point3D  point3D     = matrix3D1.Transform(new Point3D(0.0, 0.0, 0.0));
            double   num         = (matrix3D1.Transform(new Point3D(0.1, 0.1, 0.1)) - point3D).Length / 0.1;
            Matrix3D matrix3D2   = targetModel.Transform.Value * matrix3D1;
            Point3D  targetPoint = new Point3D(matrix3D2.OffsetX, matrix3D2.OffsetY, matrix3D2.OffsetZ);

            return(Helper3D.UnitsPerPixel(viewport, targetPoint) / num);
        }
Esempio n. 2
0
        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;
            }
        }