protected override bool OnButtonDown(Point pointerPosition)
        {
            this.isActive = false;
            Viewport3DElement firstHitViewport3D = this.ActiveView.GetFirstHitViewport3D(pointerPosition);

            if (firstHitViewport3D == null || firstHitViewport3D.ViewObject.PlatformSpecificObject == null)
            {
                return(false);
            }
            this.cameraElement = firstHitViewport3D.Camera;
            if (this.cameraElement == null || !this.cameraElement.IsSelectable)
            {
                return(false);
            }
            this.scale = Helper3D.UnitsPerPixel((Viewport3D)firstHitViewport3D.ViewObject.PlatformSpecificObject, new Point3D(0.0, 0.0, 0.0));
            this.rootToViewport3DMatrix       = ElementUtilities.GetComputedTransform(firstHitViewport3D.Visual != null ? firstHitViewport3D.Visual.PlatformSpecificObject as Visual : (Visual)null, (Visual)this.ActiveSceneViewModel.DefaultView.ViewRootContainer);
            this.pointerInViewportCoordinates = pointerPosition * this.rootToViewport3DMatrix;
            this.SetMovementMode();
            this.cameraInitialUp       = (Vector3D)this.cameraElement.GetComputedValue(ProjectionCameraElement.UpDirectionProperty);
            this.cameraInitialPosition = (Point3D)this.cameraElement.GetComputedValue(ProjectionCameraElement.PositionProperty);
            this.cameraInitialLookAt   = this.cameraInitialPosition + (Vector3D)this.cameraElement.GetComputedValue(ProjectionCameraElement.LookDirectionProperty);
            this.totalAzimuthDelta     = 0.0;
            this.totalElevationDelta   = 0.0;
            this.lastPoint             = this.pointerInViewportCoordinates;
            this.EnsureEditTransaction();
            this.isActive = true;
            return(true);
        }
Beispiel #2
0
 public override Matrix GetComputedTransformToRoot(IViewObject element)
 {
     if (element == null)
     {
         return(Matrix.Identity);
     }
     return(ElementUtilities.GetComputedTransform((Visual)this.ViewRootContainer, element.PlatformSpecificObject as Visual));
 }
Beispiel #3
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;
            }
        }
 protected override sealed bool OnButtonDown(Point pointerPosition)
 {
   if (this.ActiveAdorner != null)
     this.selected3DElement = this.EditingElement as Base3DElement;
   if (this.selected3DElement == null)
     this.selected3DElement = this.ActiveSceneViewModel.ElementSelectionSet.PrimarySelection as Base3DElement;
   if (this.selected3DElement == null || this.selected3DElement.Viewport.Visual == null)
     return false;
   this.Scale = Helper3D.UnitsPerPixel((Viewport3D) this.Selected3DElement.Viewport.ViewObject.PlatformSpecificObject, this.Selected3DElement);
   this.rootToViewport3DMatrix = ElementUtilities.GetComputedTransform(this.selected3DElement.Viewport.Visual.PlatformSpecificObject as Visual, (Visual) this.ActiveSceneViewModel.DefaultView.ViewRootContainer);
   this.pointerInViewportCoordinates = pointerPosition * this.rootToViewport3DMatrix;
   this.shiftDown = this.IsShiftDown;
   this.controlDown = this.IsControlDown;
   this.altDown = this.IsAltDown;
   this.ButtonDownAction();
   this.lastMousePosition = this.pointerInViewportCoordinates;
   this.EnsureEditTransaction();
   return true;
 }
Beispiel #5
0
 public override Matrix GetComputedTransformFromRoot(IViewObject element)
 {
     return(ElementUtilities.GetComputedTransform(element.PlatformSpecificObject as Visual, (Visual)this.ViewRootContainer));
 }