Provides a control that manipulates the camera by mouse and keyboard gestures.
Inheritance: System.Windows.Controls.Grid
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.thisControl = ((HelixToolkit.Wpf.StereoView3D)(target));
                return;

            case 2:
                this.LeftView = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 3:
                this.LeftCameraControl = ((HelixToolkit.Wpf.CameraController)(target));
                return;

            case 4:
                this.RightView = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 5:
                this.RightCameraControl = ((HelixToolkit.Wpf.CameraController)(target));
                return;
            }
            this._contentLoaded = true;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PanHandler"/> class.
 /// </summary>
 /// <param name="controller">
 /// The controller.
 /// </param>
 public PanHandler(CameraController controller)
     : base(controller)
 {
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RotateHandler"/> class.
 /// </summary>
 /// <param name="controller">
 /// The controller.
 /// </param>
 /// <param name="changeLookAt">
 /// The change look at.
 /// </param>
 public RotateHandler(CameraController controller, bool changeLookAt = false)
     : base(controller)
 {
     this.changeLookAt = changeLookAt;
 }
Exemplo n.º 4
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call
        ///     <see
        ///         cref="M:System.Windows.FrameworkElement.ApplyTemplate" />
        /// .
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (this.adornerLayer == null)
            {
                this.adornerLayer = this.Template.FindName(PartAdornerLayer, this) as AdornerDecorator;
                if (this.adornerLayer != null)
                {
                    this.adornerLayer.Child = this.viewport;
                }
            }

            if (this.adornerLayer == null)
            {
                throw new HelixToolkitException("{0} is missing from the template.", PartAdornerLayer);
            }

            if (this.cameraController == null)
            {
                this.cameraController = this.Template.FindName(PartCameraController, this) as CameraController;
                if (this.cameraController != null)
                {
                    this.cameraController.Viewport = this.Viewport;
                    this.cameraController.LookAtChanged += (s, e) => this.OnLookAtChanged();
                    this.cameraController.ZoomedByRectangle += (s, e) => this.OnZoomedByRectangle();
                }
            }

            if (this.cameraController == null)
            {
                throw new HelixToolkitException("{0} is missing from the template.", PartCameraController);
            }

            if (this.coordinateView == null)
            {
                this.coordinateView = this.Template.FindName(PartCoordinateView, this) as Viewport3D;

                this.coordinateSystemLights = new Model3DGroup();

                // coordinateSystemLights.Children.Add(new DirectionalLight(Colors.White, new Vector3D(1, 1, 1)));
                // coordinateSystemLights.Children.Add(new AmbientLight(Colors.DarkGray));
                this.coordinateSystemLights.Children.Add(new AmbientLight(Colors.LightGray));

                if (this.coordinateView != null)
                {
                    this.coordinateView.Camera = new PerspectiveCamera();
                    this.coordinateView.Children.Add(new ModelVisual3D { Content = this.coordinateSystemLights });
                }
            }

            if (this.coordinateView == null)
            {
                throw new HelixToolkitException("{0} is missing from the template.", PartCoordinateView);
            }

            if (this.viewCubeViewport == null)
            {
                this.viewCubeViewport = this.Template.FindName(PartViewCubeViewport, this) as Viewport3D;

                this.viewCubeLights = new Model3DGroup();
                this.viewCubeLights.Children.Add(new AmbientLight(Colors.White));
                if (this.viewCubeViewport != null)
                {
                    this.viewCubeViewport.Camera = new PerspectiveCamera();
                    this.viewCubeViewport.Children.Add(new ModelVisual3D { Content = this.viewCubeLights });
                    this.viewCubeViewport.MouseEnter += this.ViewCubeViewportMouseEnter;
                    this.viewCubeViewport.MouseLeave += this.ViewCubeViewportMouseLeave;
                }

                this.viewCube = this.Template.FindName(PartViewCube, this) as ViewCubeVisual3D;
                if (this.viewCube != null)
                {
                    this.viewCube.Viewport = this.Viewport;
                }
            }

            // update the coordinateview camera
            this.OnCameraChanged();

            // add the default headlight
            this.OnHeadlightChanged();
            base.OnApplyTemplate();
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MouseGestureHandler"/> class.
 /// </summary>
 /// <param name="controller">
 /// The controller.
 /// </param>
 protected MouseGestureHandler(CameraController controller)
 {
     this.Controller = controller;
     this.ManipulationWatch = new Stopwatch();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZoomHandler"/> class.
 /// </summary>
 /// <param name="controller">
 /// The controller.
 /// </param>
 /// <param name="changeFieldOfView">
 /// if set to <c>true</c> [change field of view].
 /// </param>
 public ZoomHandler(CameraController controller, bool changeFieldOfView = false)
     : base(controller)
 {
     this.changeFieldOfView = changeFieldOfView;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZoomRectangleHandler"/> class.
 /// </summary>
 /// <param name="controller">
 /// The controller.
 /// </param>
 public ZoomRectangleHandler(CameraController controller)
     : base(controller)
 {
 }