Ejemplo n.º 1
0
        public ICollection <IAdornerSet> GetAdornerSets(SceneElement sceneElement)
        {
            List <IAdornerSet> list          = new List <IAdornerSet>();
            Base3DElement      base3Delement = sceneElement as Base3DElement;

            foreach (AdornerElementSet adornerElementSet in (IEnumerable <AdornerElementSet>) this.GetAdornerElementSetsContainingElement(base3Delement != null ? (SceneElement)base3Delement.Viewport : sceneElement))
            {
                AdornerLayer.ElementInfo elementInfo = this.GetElementInfo(adornerElementSet);
                if (elementInfo != null)
                {
                    if (base3Delement != null && elementInfo.AdornerSet3DContainer != null)
                    {
                        foreach (AdornerSet3D adornerSet3D in elementInfo.AdornerSet3DContainer.AdornerSets)
                        {
                            if (adornerSet3D.Element == base3Delement)
                            {
                                list.Add((IAdornerSet)adornerSet3D);
                            }
                        }
                    }
                    foreach (AdornerSet adornerSet in elementInfo.AdornerSets)
                    {
                        list.Add((IAdornerSet)adornerSet);
                    }
                }
            }
            return((ICollection <IAdornerSet>)list);
        }
Ejemplo n.º 2
0
        private void AddAdornerSet3D(AdornerSet3D adornerSet3D)
        {
            Base3DElement element = adornerSet3D.Element;

            if (element == null)
            {
                throw new InvalidOperationException(ExceptionStringTable.AdornedBase3DElementMayNotBeNull);
            }
            Viewport3DElement viewport = element.Viewport;

            if (viewport == null)
            {
                throw new InvalidOperationException(ExceptionStringTable.AdornedViewport3DElementMayNotBeNull);
            }
            AdornerLayer.ElementInfo createElementInfo = this.GetOrCreateElementInfo(this.CreateOrGetAdornerElementSetForElement((SceneElement)viewport));
            if (createElementInfo.AdornerSet3DContainer == null)
            {
                createElementInfo.AdornerSet3DContainer = new AdornerSet3DContainer(viewport);
                this.adornerSet3DContainers.Add(createElementInfo.AdornerSet3DContainer);
            }
            createElementInfo.Update((SceneElement)viewport, this, AdornerLayer.ElementInfoUpdateSource.Explicit);
            createElementInfo.AddAdornerSet(adornerSet3D);
            if (createElementInfo.AdornerSet3DContainer.Parent == this)
            {
                return;
            }
            this.children.Add((Visual)createElementInfo.AdornerSet3DContainer);
        }
Ejemplo n.º 3
0
        protected override void UpdateModelFromMouse(Base3DElement selected3DElement, Vector mousePositionDelta)
        {
            Vector3D normal = this.CalculateTransformationForSpotLightAdorner().Transform(new Vector3D(0.0, 0.0, 1.0));

            normal.Normalize();
            Plane3D          plane3D            = new Plane3D(normal, this.centerOfCone);
            Viewport3DVisual adorningViewport3D = this.ActiveView.AdornerLayer.GetAdornerSet3DContainer(this.ActiveAdorner.Element.Viewport).ShadowAdorningViewport3D;
            Ray3D            ray = CameraRayHelpers.RayFromViewportPoint(adorningViewport3D.Viewport.Size, adorningViewport3D.Camera, this.LastMousePosition + mousePositionDelta);
            double           t;

            if (!plane3D.IntersectWithRay(ray, out t))
            {
                return;
            }
            double    num1      = Math.Atan((ray.Evaluate(t) - this.centerOfCone).Length / 1.0) / Math.PI * 180.0;
            SpotLight spotLight = (SpotLight)this.Selected3DElement.ViewObject.PlatformSpecificObject;

            if (this.ActiveAdorner.TypeOfConeAngle == SpotLightAdornerBehavior3D.TypeOfConeAngle.InnerConeAngle)
            {
                double num2 = spotLight.OuterConeAngle - spotLight.InnerConeAngle;
                this.Selected3DElement.SetValue(SpotLightElement.InnerConeAngleProperty, (object)num1);
                this.Selected3DElement.SetValue(SpotLightElement.OuterConeAngleProperty, (object)(num1 + num2));
            }
            else
            {
                this.Selected3DElement.SetValue(SpotLightElement.OuterConeAngleProperty, (object)num1);
            }
            this.ActiveAdorner.PositionAndOrientGeometry();
        }
Ejemplo n.º 4
0
 protected virtual bool Finish()
 {
   this.selected3DElement = (Base3DElement) null;
   this.CommitEditTransaction();
   if (this.popSelfOnButtonUp)
     this.PopSelf();
   return true;
 }
Ejemplo n.º 5
0
        protected override void UpdateModelFromMouse(Base3DElement selected3DElement, Vector mousePositionDelta)
        {
            Camera   camera    = (Camera)selected3DElement.Viewport.Camera.ViewObject.PlatformSpecificObject;
            Matrix3D matrix3D1 = Helper3D.CameraRotationMatrix(camera);
            Matrix3D matrix3D2 = camera.Transform.Value;

            if (matrix3D2.HasInverse)
            {
                matrix3D2.Invert();
                matrix3D1 *= matrix3D2;
            }
            Vector3D      vector1       = new Vector3D(matrix3D1.M11, matrix3D1.M21, matrix3D1.M31);
            Vector3D      vector2_1     = new Vector3D(matrix3D1.M12, matrix3D1.M22, matrix3D1.M32);
            Vector3D      vector2_2     = new Vector3D(matrix3D1.M13, matrix3D1.M23, matrix3D1.M33);
            Base3DElement base3Delement = selected3DElement.Parent as Base3DElement;
            Matrix3D      matrix3D3     = Matrix3D.Identity;

            if (base3Delement != null)
            {
                matrix3D3 = base3Delement.GetComputedTransformFromRoot3DElementToElement();
                matrix3D3.Invert();
            }
            if (this.mouseMovementMode == ObjectRotateTranslateBehavior.MovementMode.Rotate)
            {
                mousePositionDelta /= 2.0;
                Vector3D axisOfRotation = Vector3D.CrossProduct(new Vector3D(-mousePositionDelta.X, mousePositionDelta.Y, 0.0), vector2_2);
                double   length         = axisOfRotation.Length;
                if (length <= 0.0)
                {
                    return;
                }
                Vector3D vector3D = Helper3D.EulerAnglesFromQuaternion(new Quaternion(axisOfRotation, length) * Helper3D.QuaternionFromEulerAngles(selected3DElement.CanonicalRotationAngles));
                vector3D = new Vector3D(RoundingHelper.RoundAngle(vector3D.X), RoundingHelper.RoundAngle(vector3D.Y), RoundingHelper.RoundAngle(vector3D.Z));
                selected3DElement.CanonicalRotationAngles = vector3D;
            }
            else
            {
                Vector3D vector3D1         = new Vector3D(selected3DElement.CanonicalTranslationX, selected3DElement.CanonicalTranslationY, selected3DElement.CanonicalTranslationZ);
                Point    lastMousePosition = this.LastMousePosition;
                Point    endPoint          = lastMousePosition + mousePositionDelta;
                Vector3D vector3D2;
                if (this.mouseMovementMode == ObjectRotateTranslateBehavior.MovementMode.TranslateXY)
                {
                    Plane3D  plane     = new Plane3D(Vector3D.CrossProduct(vector1, vector2_1), this.hitPoint);
                    Vector3D vector    = Helper3D.VectorBetweenPointsOnPlane((Viewport3D)selected3DElement.Viewport.ViewObject.PlatformSpecificObject, plane, lastMousePosition, endPoint);
                    Vector3D vector3D3 = matrix3D3.Transform(vector);
                    vector3D2 = vector3D1 + vector3D3;
                }
                else
                {
                    double scale = this.Scale;
                    vector3D2 = vector3D1 + scale * -mousePositionDelta.Y * vector2_2;
                }
                selected3DElement.CanonicalTranslationX = RoundingHelper.RoundLength(vector3D2.X);
                selected3DElement.CanonicalTranslationY = RoundingHelper.RoundLength(vector3D2.Y);
                selected3DElement.CanonicalTranslationZ = RoundingHelper.RoundLength(vector3D2.Z);
            }
        }
Ejemplo n.º 6
0
 public RotateAdornerSet3D(ToolBehaviorContext toolContext, Base3DElement adornedElement)
     : base(toolContext, adornedElement)
 {
     this.DoScaleToScreen           = true;
     this.DoRemoveObjectScale       = true;
     this.DoCenterOnSpecifiedCenter = true;
     this.Placement = AdornerSet3D.Location.OrthographicLayer;
     this.CreateAdorners();
 }
Ejemplo n.º 7
0
        protected override void UpdateModelFromMouse(Base3DElement selected3DElement, Vector mousePositionDelta)
        {
            double   num      = this.mouseMovementAxis * mousePositionDelta;
            Vector3D vector3D = new Vector3D(selected3DElement.CanonicalTranslationX, selected3DElement.CanonicalTranslationY, selected3DElement.CanonicalTranslationZ) + this.Scale * num * this.translationAxis;

            selected3DElement.CanonicalTranslationX = RoundingHelper.RoundLength(vector3D.X);
            selected3DElement.CanonicalTranslationY = RoundingHelper.RoundLength(vector3D.Y);
            selected3DElement.CanonicalTranslationZ = RoundingHelper.RoundLength(vector3D.Z);
        }
Ejemplo n.º 8
0
 public void InvalidateRender(Base3DElement optionalBase3DElement)
 {
     foreach (AdornerSet3D adornerSet3D in this.adornerSets)
     {
         if (optionalBase3DElement == null || adornerSet3D.Element == optionalBase3DElement)
         {
             adornerSet3D.InvalidateRender();
         }
     }
 }
Ejemplo n.º 9
0
 protected static Vector Vector3DInViewport3D(Base3DElement target, Vector3D vector)
 {
   Viewport3D viewport = (Viewport3D) target.Viewport.ViewObject.PlatformSpecificObject;
   Matrix3D viewport3DtoElement = target.GetComputedTransformFromViewport3DToElement();
   Point point = AdornedToolBehavior3D.Point3DInViewport3D(viewport, viewport3DtoElement, new Point3D(0.0, 0.0, 0.0));
   Vector vector1 = AdornedToolBehavior3D.Point3DInViewport3D(viewport, viewport3DtoElement, (Point3D) vector) - point;
   if (vector1.Length < 0.0 / 1.0)
     return new Vector(0.0, 1.0);
   return vector1;
 }
Ejemplo n.º 10
0
        public override void Draw(DrawingContext drawingContext, Matrix matrix)
        {
            Base3DElement element = this.Element as Base3DElement;

            if (element == null)
            {
                return;
            }
            HighlightAdorner3D.DrawCube(drawingContext, matrix, element, SceneInsertionPointAdorner3D.DefaultPen);
        }
Ejemplo n.º 11
0
        public bool IsProxied(SceneElement element)
        {
            Base3DElement base3Delement = element as Base3DElement;

            if (base3Delement != null)
            {
                return(this.ContainersWithProxiedLights.Contains(base3Delement.Viewport));
            }
            return(false);
        }
Ejemplo n.º 12
0
 public void Update(Base3DElement optionalBase3DElement)
 {
     this.MatchCameras();
     foreach (AdornerSet3D adornerSet3D in this.adornerSets)
     {
         if (adornerSet3D.Element.IsAttached && adornerSet3D.Element.ViewObject != null && (adornerSet3D.Element.Viewport != null && adornerSet3D.Element.Viewport.ViewObject != null) && (optionalBase3DElement == null || adornerSet3D.Element == optionalBase3DElement))
         {
             adornerSet3D.Update();
         }
     }
 }
Ejemplo n.º 13
0
 public void InvalidateRender(Base3DElement optionalBase3DElement)
 {
     foreach (AdornerSet adornerSet in this.adornerSets)
     {
         adornerSet.InvalidateRender();
     }
     if (this.adornerSet3DContainer == null)
     {
         return;
     }
     this.adornerSet3DContainer.InvalidateRender(optionalBase3DElement);
 }
Ejemplo n.º 14
0
        protected BaseFrameworkElement GetHitElement(Point point, IList <BaseFrameworkElement> ignoredElements)
        {
            SceneElement         elementAtPoint   = this.ActiveView.GetElementAtPoint(point, new HitTestModifier(this.GetUnlockedAncestorInEditingContainer), (InvisibleObjectHitTestModifier)null, (ICollection <BaseFrameworkElement>)ignoredElements);
            BaseFrameworkElement frameworkElement = elementAtPoint as BaseFrameworkElement;
            Base3DElement        base3Delement    = elementAtPoint as Base3DElement;

            if (base3Delement != null)
            {
                frameworkElement = (BaseFrameworkElement)base3Delement.Viewport;
            }
            return(frameworkElement);
        }
Ejemplo n.º 15
0
            public void Update(AdornerElementSet adornerElementSet, AdornerLayer adornerLayer, AdornerLayer.ElementInfoUpdateSource source)
            {
                SceneElement primaryElement = adornerElementSet.PrimaryElement;
                bool         flag           = false;

                if (!adornerLayer.SceneView.IsInArtboard(primaryElement))
                {
                    return;
                }
                Size size2 = primaryElement.Visual != null?adornerLayer.SceneView.GetRenderSize(primaryElement.Visual) : Size.Empty;

                Transform transform             = (Transform) new MatrixTransform(adornerElementSet.CalculatePrimaryElementTransformMatrixToAdornerLayer());
                Matrix    matrix                = transform == null ? Matrix.Identity : transform.Value;
                Point     renderTransformOrigin = adornerElementSet.RenderTransformOrigin;

                if (!AdornerLayer.ElementInfo.AreClose(renderTransformOrigin, this.sharedCenter) || !AdornerLayer.ElementInfo.AreClose(this.lastRenderSize, size2) || (this.primaryElementMatrix != matrix || adornerElementSet.IsPrimaryTransformNonAffine))
                {
                    flag = true;
                    this.sharedCenter         = renderTransformOrigin;
                    this.lastRenderSize       = size2;
                    this.primaryElementMatrix = matrix;
                }
                ISceneInsertionPoint sceneInsertionPoint = adornerElementSet.PrimaryElement.ViewModel.ActiveSceneInsertionPoint;

                if (flag || source == AdornerLayer.ElementInfoUpdateSource.LayoutUpdated && adornerElementSet.NeedsUpdate)
                {
                    adornerElementSet.Update();
                    this.matrix = adornerElementSet.GetTransformMatrixToAdornerLayer();
                    foreach (AdornerSet adornerSet in this.adornerSets)
                    {
                        this.UpdateMatrix(adornerSet, adornerLayer);
                    }
                    if (this.adornerSet3DContainer != null)
                    {
                        this.adornerSet3DContainer.SetMatrix(this.matrix);
                    }
                    if (sceneInsertionPoint != null && primaryElement.ParentElement is GridElement && (primaryElement.ParentElement == sceneInsertionPoint.SceneElement && primaryElement.ViewModel.IsInGridDesignMode))
                    {
                        adornerLayer.InvalidateAdornerVisuals(primaryElement.ParentElement);
                    }
                }
                if (!(primaryElement is Base3DElement) || sceneInsertionPoint == null)
                {
                    return;
                }
                Base3DElement base3Delement = sceneInsertionPoint.SceneElement as Base3DElement;

                if (base3Delement == null)
                {
                    return;
                }
                adornerLayer.InvalidateAdornerVisuals((SceneElement)base3Delement);
            }
Ejemplo n.º 16
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);
        }
Ejemplo n.º 17
0
        public override void Draw(DrawingContext drawingContext, Matrix matrix)
        {
            object platformSpecificObject = this.AdornerSet.Element.ViewTargetElement.PlatformSpecificObject;

            foreach (SceneElement sceneElement in this.Element.ViewModel.ElementSelectionSet.Selection)
            {
                Base3DElement element = sceneElement as Base3DElement;
                if (element != null && element.IsViewObjectValid)
                {
                    Viewport3DElement viewport = element.Viewport;
                    if (viewport != null && viewport.ViewObject.PlatformSpecificObject == platformSpecificObject)
                    {
                        HighlightAdorner3D.DrawCube(drawingContext, matrix, element, HighlightAdorner3D.DefaultPen);
                    }
                }
            }
        }
Ejemplo n.º 18
0
 internal AdornerSet3D(ToolBehaviorContext toolContext, Base3DElement adornedElement, AdornerSetOrder order)
 {
     if (toolContext == null)
     {
         throw new ArgumentNullException("toolContext");
     }
     if (adornedElement == null)
     {
         throw new ArgumentNullException("adornedElement");
     }
     this.toolContext       = toolContext;
     this.adornedElementSet = toolContext.View.Artboard.AdornerLayer.CreateOrGetAdornerElementSetForElement((SceneElement)adornedElement);
     this.order             = order;
     this.adornerSetVisual  = new ModelVisual3D();
     this.adornerSetVisual.SetValue(FrameworkElement.NameProperty, (object)"adornerSet3DVisual");
     this.adornerSetVisual.Transform = (Transform3D) new MatrixTransform3D();
 }
Ejemplo n.º 19
0
        public static List <FrameworkElement> ConvertToFrameworkElementList(ICollection <SceneElement> collection)
        {
            List <FrameworkElement> list = new List <FrameworkElement>();

            foreach (SceneElement sceneElement in (IEnumerable <SceneElement>)collection)
            {
                Base3DElement base3Delement = sceneElement as Base3DElement;
                if (base3Delement != null)
                {
                    list.Add(base3Delement.Viewport.ViewTargetElement.PlatformSpecificObject as FrameworkElement);
                }
                else
                {
                    list.Add(sceneElement.ViewTargetElement.PlatformSpecificObject as FrameworkElement);
                }
            }
            return(list);
        }
Ejemplo n.º 20
0
 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;
 }
Ejemplo n.º 21
0
        protected override void UpdateModelFromMouse(Base3DElement selected3DElement, Vector mousePositionDelta)
        {
            this.lastUnsnappedAngle += this.ActiveView.Zoom * this.mouseMovementAxis * mousePositionDelta;
            double angleInDegrees1 = this.lastUnsnappedAngle;

            if (this.ShiftKeyDepressed)
            {
                angleInDegrees1 = RotateBehavior3D.shiftSnapAngle * Math.Round(angleInDegrees1 / RotateBehavior3D.shiftSnapAngle);
            }
            double angleInDegrees2 = !this.previousAngle.HasValue ? angleInDegrees1 : angleInDegrees1 - this.previousAngle.Value;

            this.previousAngle = new double?(angleInDegrees1);
            Vector3D unitEulerAngles = RotateBehavior3D.GetUnitEulerAngles(Helper3D.EulerAnglesFromQuaternion(this.previousQuaternion * new Quaternion(this.rotationAxis, angleInDegrees2)) - selected3DElement.CanonicalRotationAngles);

            this.previousQuaternion = this.initialQuaternion * new Quaternion(this.rotationAxis, angleInDegrees1);
            Vector3D vector3D = selected3DElement.CanonicalRotationAngles + unitEulerAngles;

            vector3D = new Vector3D(RoundingHelper.RoundAngle(vector3D.X), RoundingHelper.RoundAngle(vector3D.Y), RoundingHelper.RoundAngle(vector3D.Z));
            selected3DElement.CanonicalRotationAngles = vector3D;
        }
Ejemplo n.º 22
0
        public static void DrawCube(DrawingContext drawingContext, Matrix matrix, Base3DElement element, Pen pen)
        {
            Viewport3DElement viewport1 = element.Viewport;

            if (viewport1 == null)
            {
                return;
            }
            Viewport3D viewport2                      = viewport1.ViewObject.PlatformSpecificObject as Viewport3D;
            Rect3D     localSpaceBounds               = element.LocalSpaceBounds;
            Matrix3D   viewport3DtoElement            = element.GetComputedTransformFromViewport3DToElement();
            Matrix3D   matrix3D                       = Helper3D.CameraRotationTranslationMatrix(viewport2.Camera);
            Matrix3D   cameraToObject                 = viewport3DtoElement * matrix3D;
            KeyValuePair <Point, bool> keyValuePair1  = HighlightAdorner3D.Calculate2DPoint(viewport2, cameraToObject, viewport3DtoElement, matrix, localSpaceBounds.Location);
            KeyValuePair <Point, bool> keyValuePair2  = HighlightAdorner3D.Calculate2DPoint(viewport2, cameraToObject, viewport3DtoElement, matrix, localSpaceBounds.Location + new Vector3D(localSpaceBounds.SizeX, 0.0, 0.0));
            KeyValuePair <Point, bool> keyValuePair3  = HighlightAdorner3D.Calculate2DPoint(viewport2, cameraToObject, viewport3DtoElement, matrix, localSpaceBounds.Location + new Vector3D(localSpaceBounds.SizeX, localSpaceBounds.SizeY, 0.0));
            KeyValuePair <Point, bool> keyValuePair4  = HighlightAdorner3D.Calculate2DPoint(viewport2, cameraToObject, viewport3DtoElement, matrix, localSpaceBounds.Location + new Vector3D(0.0, localSpaceBounds.SizeY, 0.0));
            KeyValuePair <Point, bool> keyValuePair5  = HighlightAdorner3D.Calculate2DPoint(viewport2, cameraToObject, viewport3DtoElement, matrix, localSpaceBounds.Location + new Vector3D(0.0, 0.0, localSpaceBounds.SizeZ));
            KeyValuePair <Point, bool> keyValuePair6  = HighlightAdorner3D.Calculate2DPoint(viewport2, cameraToObject, viewport3DtoElement, matrix, localSpaceBounds.Location + new Vector3D(localSpaceBounds.SizeX, 0.0, localSpaceBounds.SizeZ));
            KeyValuePair <Point, bool> keyValuePair7  = HighlightAdorner3D.Calculate2DPoint(viewport2, cameraToObject, viewport3DtoElement, matrix, localSpaceBounds.Location + new Vector3D(localSpaceBounds.SizeX, localSpaceBounds.SizeY, localSpaceBounds.SizeZ));
            KeyValuePair <Point, bool> keyValuePair8  = HighlightAdorner3D.Calculate2DPoint(viewport2, cameraToObject, viewport3DtoElement, matrix, localSpaceBounds.Location + new Vector3D(0.0, localSpaceBounds.SizeY, localSpaceBounds.SizeZ));
            StreamGeometry             streamGeometry = new StreamGeometry();
            StreamGeometryContext      context        = streamGeometry.Open();

            HighlightAdorner3D.DrawLine(context, keyValuePair1, keyValuePair2);
            HighlightAdorner3D.DrawLine(context, keyValuePair2, keyValuePair3);
            HighlightAdorner3D.DrawLine(context, keyValuePair3, keyValuePair4);
            HighlightAdorner3D.DrawLine(context, keyValuePair4, keyValuePair1);
            HighlightAdorner3D.DrawLine(context, keyValuePair5, keyValuePair6);
            HighlightAdorner3D.DrawLine(context, keyValuePair6, keyValuePair7);
            HighlightAdorner3D.DrawLine(context, keyValuePair7, keyValuePair8);
            HighlightAdorner3D.DrawLine(context, keyValuePair8, keyValuePair5);
            HighlightAdorner3D.DrawLine(context, keyValuePair6, keyValuePair2);
            HighlightAdorner3D.DrawLine(context, keyValuePair7, keyValuePair3);
            HighlightAdorner3D.DrawLine(context, keyValuePair5, keyValuePair1);
            HighlightAdorner3D.DrawLine(context, keyValuePair8, keyValuePair4);
            context.Close();
            streamGeometry.Freeze();
            drawingContext.DrawGeometry((Brush)null, pen, (System.Windows.Media.Geometry)streamGeometry);
        }
Ejemplo n.º 23
0
        public void InvalidateAdornerVisuals(SceneElement sceneElement)
        {
            if (sceneElement == null)
            {
                throw new ArgumentNullException("sceneElement");
            }
            if (!sceneElement.IsAttached)
            {
                return;
            }
            Base3DElement optionalBase3DElement = sceneElement as Base3DElement;

            foreach (AdornerElementSet adornerElementSet in (IEnumerable <AdornerElementSet>) this.GetAdornerElementSetsContainingElement(sceneElement))
            {
                AdornerLayer.ElementInfo elementInfo = this.GetElementInfo(adornerElementSet);
                if (elementInfo != null)
                {
                    elementInfo.InvalidateRender(optionalBase3DElement);
                }
                adornerElementSet.Invalidate();
            }
            if (optionalBase3DElement == null)
            {
                return;
            }
            Viewport3DElement viewport = optionalBase3DElement.Viewport;

            if (viewport == null)
            {
                return;
            }
            foreach (AdornerElementSet adornerElementSet in (IEnumerable <AdornerElementSet>) this.GetAdornerElementSetsContainingElement((SceneElement)viewport))
            {
                AdornerLayer.ElementInfo elementInfo = this.GetElementInfo(adornerElementSet);
                if (elementInfo != null)
                {
                    elementInfo.InvalidateRender(optionalBase3DElement);
                }
            }
        }
Ejemplo n.º 24
0
        protected override void UpdateModelFromMouse(Base3DElement selected3DElement, Vector mousePositionDelta)
        {
            double           num = this.mouseMovementAxis * mousePositionDelta;
            ScaleTransform3D scaleTransform3D = selected3DElement.CanonicalScaleTransform3D;
            Vector3D         vector3D         = new Vector3D(scaleTransform3D.ScaleX, scaleTransform3D.ScaleY, scaleTransform3D.ScaleZ) + num * this.scaleAxis * 1.0 / 96.0;

            if (vector3D.X < 0.0)
            {
                vector3D.X = 0.0;
            }
            if (vector3D.Y < 0.0)
            {
                vector3D.Y = 0.0;
            }
            if (vector3D.Z < 0.0)
            {
                vector3D.Z = 0.0;
            }
            selected3DElement.CanonicalScaleX = RoundingHelper.RoundScale(vector3D.X);
            selected3DElement.CanonicalScaleY = RoundingHelper.RoundScale(vector3D.Y);
            selected3DElement.CanonicalScaleZ = RoundingHelper.RoundScale(vector3D.Z);
        }
Ejemplo n.º 25
0
 private void SelectionManager_LateActiveSceneUpdatePhase(object sender, SceneUpdatePhaseEventArgs args)
 {
     if (args.IsDirtyViewState(SceneViewModel.ViewStateBits.ActiveEditingContainer) || args.IsDirtyViewState(SceneViewModel.ViewStateBits.IsEditable))
     {
         this.UpdateFromEditingContainerChange(false);
     }
     this.triggerSubscription.Update(args.ViewModel, args.DocumentChanges, args.DocumentChangeStamp);
     foreach (SubSubscription subSubscription in this.delayedUpdates)
     {
         subSubscription.ProcessChanges(args.DocumentChangeStamp);
     }
     this.delayedUpdates.Clear();
     if (args.IsDirtyViewState(SceneViewModel.ViewStateBits.ActiveTrigger | SceneViewModel.ViewStateBits.RecordMode) && this.ActiveSceneViewModel != null)
     {
         this.UpdateActiveTrigger();
         if (this.SelectedItem == null || this.SelectedItem is NoneTriggerModel)
         {
             if (this.locked3DElements.Count != 0)
             {
                 using (SceneEditTransaction editTransaction = this.ActiveSceneViewModel.CreateEditTransaction("Unlock3DElements", true))
                 {
                     SceneElementSelectionSet elementSelectionSet = this.ActiveSceneViewModel.ElementSelectionSet;
                     if (elementSelectionSet != null && this.selectionChangesSinceLock <= 2)
                     {
                         foreach (Base3DElement base3Delement in this.locked3DElements)
                         {
                             if (base3Delement.IsAttached)
                             {
                                 elementSelectionSet.ExtendSelection((SceneElement)base3Delement);
                             }
                         }
                     }
                     editTransaction.Commit();
                 }
                 this.locked3DElements.Clear();
             }
         }
         else if (this.locked3DElements.Count == 0)
         {
             this.selectionChangesSinceLock = 0;
             SceneElementSelectionSet elementSelectionSet = this.ActiveSceneViewModel.ElementSelectionSet;
             if (elementSelectionSet != null)
             {
                 using (SceneEditTransaction editTransaction = this.ActiveSceneViewModel.CreateEditTransaction("Lock3DElements", true))
                 {
                     foreach (SceneElement sceneElement in elementSelectionSet.Selection)
                     {
                         Base3DElement base3Delement = sceneElement as Base3DElement;
                         if (base3Delement != null)
                         {
                             this.locked3DElements.Add(base3Delement);
                             elementSelectionSet.RemoveSelection((SceneElement)base3Delement);
                         }
                     }
                     editTransaction.Commit();
                 }
             }
         }
     }
     if (!args.IsDirtyViewState(SceneViewModel.ViewStateBits.ElementSelection))
     {
         return;
     }
     ++this.selectionChangesSinceLock;
 }
Ejemplo n.º 26
0
 public SpotLightProxyAdornerSet3D(ToolBehaviorContext toolContext, Base3DElement adornedElement)
     : base(toolContext, adornedElement)
 {
     this.CreateAdorners();
 }
Ejemplo n.º 27
0
 protected abstract void UpdateModelFromMouse(Base3DElement selected3DElement, Vector mousePositionDelta);
Ejemplo n.º 28
0
 public HighlightAdornerSet3D(ToolBehaviorContext toolContext, Base3DElement adornedElement)
     : base(toolContext, (SceneElement)adornedElement)
 {
 }
Ejemplo n.º 29
0
        private SceneElement GroupElements()
        {
            ReadOnlyCollection <SceneElement> selection = this.SceneViewModel.ElementSelectionSet.Selection;

            if (selection[0] is BaseFrameworkElement)
            {
                return((SceneElement)null);
            }
            if (!(selection[0] is Base3DElement))
            {
                return((SceneElement)null);
            }
            SceneElement primarySelection = this.SceneViewModel.ElementSelectionSet.PrimarySelection;

            this.SceneViewModel.ElementSelectionSet.Clear();
            List <SceneElement> list           = new List <SceneElement>((IEnumerable <SceneElement>)selection);
            Base3DElement       base3Delement1 = (Base3DElement)null;
            int num = int.MaxValue;
            Viewport3DElement viewport = ((Base3DElement)list[0]).Viewport;

            foreach (Base3DElement base3Delement2 in list)
            {
                if (base3Delement2.Viewport == viewport)
                {
                    int depthFromViewport3D = base3Delement2.DepthFromViewport3D;
                    if (depthFromViewport3D < num)
                    {
                        base3Delement1 = base3Delement2;
                        num            = depthFromViewport3D;
                    }
                }
            }
            SceneElement parentElement = base3Delement1.ParentElement;
            Matrix3D     matrix3D      = Matrix3D.Identity;

            if (parentElement is Base3DElement)
            {
                matrix3D = ((Base3DElement)parentElement).GetComputedTransformFromViewport3DToElement();
                matrix3D.Invert();
            }
            Base3DElement parent = (Base3DElement)null;

            if (list[0] is Model3DElement)
            {
                Model3DGroup      model3Dgroup      = new Model3DGroup();
                Model3DCollection model3Dcollection = new Model3DCollection();
                model3Dgroup.Children = model3Dcollection;
                parent = (Base3DElement)this.SceneViewModel.CreateSceneNode((object)model3Dgroup);
            }
            else if (list[0] is Visual3DElement)
            {
                parent = (Base3DElement)this.SceneViewModel.CreateSceneNode((object)new ModelVisual3D());
            }
            SceneNodeIDHelper sceneNodeIdHelper = new SceneNodeIDHelper(this.SceneViewModel, (SceneNode)this.SceneViewModel.ActiveSceneInsertionPoint.SceneElement.StoryboardContainer);
            string            validElementId    = sceneNodeIdHelper.GetValidElementID((SceneNode)parent, "group3D");

            sceneNodeIdHelper.SetLocalName((SceneNode)parent, validElementId);
            using (this.SceneViewModel.ForceBaseValue())
            {
                Matrix3D[] matrix3DArray = new Matrix3D[list.Count];
                for (int index = 0; index < list.Count; ++index)
                {
                    matrix3DArray[index] = ((Base3DElement)list[index]).GetComputedTransformFromViewport3DToElement();
                }
                foreach (Base3DElement base3Delement2 in list)
                {
                    if (base3Delement2 != primarySelection)
                    {
                        base3Delement2.Remove();
                    }
                }
                int insertAt = primarySelection.GetCollectionContainer().IndexOf((SceneNode)primarySelection);
                primarySelection.Remove();
                if (parentElement is Viewport3DElement)
                {
                    GroupCommandHelpers.InsertElement(parentElement, (SceneNode)parent, insertAt);
                }
                else
                {
                    GroupCommandHelpers.InsertElement(this.SceneViewModel, (Base3DElement)parentElement, (SceneNode)parent, new int?(insertAt));
                }
                for (int index = 0; index < list.Count; ++index)
                {
                    GroupCommandHelpers.InsertElement(this.SceneViewModel, parent, (SceneNode)list[index], new int?());
                    ((Base3DElement)list[index]).Transform = (Transform3D) new CanonicalTransform3D(matrix3DArray[index] * matrix3D);
                }
            }
            return((SceneElement)parent);
        }
Ejemplo n.º 30
0
 public DirectionalLightAdornerSet3D(ToolBehaviorContext toolContext, Base3DElement adornedElement)
     : base(toolContext, adornedElement)
 {
     this.CreateAdorners();
 }