Esempio n. 1
0
        protected static void OnCameraChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            ViewportImage viewportImage = ((ViewportImage)obj);

            viewportImage.RequestRender();
            viewportImage.view = Matrix.LookAtRH(viewportImage.CameraPosition, viewportImage.CameraTarget, viewportImage.CameraUpVector);
        }
Esempio n. 2
0
 internal void RecursiveSetViewportImage(ViewportImage viewportImage)
 {
     if (viewportImage == null)
     {
         this.DisposeDisposables();
         this.viewportImage     = null;
         this.graphicsDevice    = null;
         this.layer2D           = null;
         Children.viewportImage = null;
     }
     else
     {
         this.graphicsDevice = viewportImage.GraphicsDevice;
         this.layer2D        = viewportImage.Layer2D;
         OnViewportImageChanged(viewportImage);
         BindToViewportImage();
         Children.viewportImage = viewportImage;
         this.RecreateDisposables();
     }
     foreach (Model3D model in this.Children)
     {
         model.RecursiveSetViewportImage(viewportImage);
     }
     // TODO Set target on all children, checking for maximum depth or
     // circular dependencies
 }
Esempio n. 3
0
 internal override void OnViewportImageChanged(ViewportImage newViewportImage)
 {
     base.OnViewportImageChanged(newViewportImage);
     UpdateLabels();
     this.OnDraw -= new OnDrawEventHandler(OnDrawUpdate);
     this.OnDraw += new OnDrawEventHandler(OnDrawUpdate);
 }
Esempio n. 4
0
 internal void RecursiveSetViewportImage(ViewportImage viewportImage)
 {
     if (viewportImage == null)
     {
         this.DisposeDisposables();
         this.viewportImage = null;
         this.graphicsDevice = null;
         this.layer2D = null;
         Children.viewportImage = null;
     }
     else
     {                
         this.graphicsDevice = viewportImage.GraphicsDevice;
         this.layer2D = viewportImage.Layer2D;
         OnViewportImageChanged(viewportImage);
         BindToViewportImage();
         Children.viewportImage = viewportImage;
         this.RecreateDisposables();
     }
     foreach (Model3D model in this.Children)
     {
         model.RecursiveSetViewportImage(viewportImage);
     }
     // TODO Set target on all children, checking for maximum depth or
     // circular dependencies
 }
Esempio n. 5
0
        public void Initialize()
        {
            Background        = null;
            viewport3DControl = new Viewport3DControl();
            viewport3DControl.SetValue(Grid.ZIndexProperty, 100);
            this.Children.Add(viewport3DControl);

            viewport3DImage = viewport3DControl.Viewport3DImage;
            if (viewport3DImage == null)
            {
                axes = new Axes3D();
                SetValue(ModelsProperty, new Model3DCollection(null));
                return;
            }
            viewport3DImage.ViewPort3D = this;

            SetValue(ModelsProperty, viewport3DImage.Models);
            // Set the owner of the Model3DCollection to be the D3DImageViewport
            // This ensures that the Model3D objects are rendered by the D3DImageViewport
            viewport3DImage.SetLayer2D(viewport3DImage.Canvas, GraphToWorld);

            viewport3DImage.Models.Changed += new Model3DCollection.ItemEventHandler(Models_Changed);

            trackball                       = new Trackball();
            trackball.EventSource           = viewport3DControl; //viewport3DImage.Canvas;
            trackball.OnTrackBallMoved     += new TrackballEventHandler(trackball_TrackBallMoved);
            trackball.OnTrackBallZoom      += new TrackballEventHandler(trackball_OnTrackBallZoom);
            trackball.OnTrackBallTranslate += new TrackballEventHandler(trackball_OnTrackBallTranslate);

            axes = new Axes3D();
            viewport3DImage.Models.Add(axes);

            viewport3DImage.CameraPosition = new Vector3(-3f, -3f, 2f);
            viewport3DImage.CameraTarget   = new Vector3(0f, 0f, 0f);
            //
            Binding bindingGraphMin = new Binding("GraphMin");

            bindingGraphMin.Source = this;
            bindingGraphMin.Mode   = BindingMode.TwoWay;
            BindingOperations.SetBinding(axes, Axes3D.GraphMinProperty, bindingGraphMin);
            Binding bindingGraphMax = new Binding("GraphMax");

            bindingGraphMax.Source = this;
            bindingGraphMax.Mode   = BindingMode.TwoWay;
            BindingOperations.SetBinding(axes, Axes3D.GraphMaxProperty, bindingGraphMax);
            Binding bindingGraphToWorld = new Binding("GraphToWorld");

            bindingGraphToWorld.Source = this;
            bindingGraphToWorld.Mode   = BindingMode.OneWay;
            BindingOperations.SetBinding(viewport3DImage, ViewportImage.ModelToWorldProperty, bindingGraphToWorld);
            ////
            GraphMax = new Point3D(1, 1, 1);
            GraphMin = new Point3D(-1, -1, -1);
            WorldMin = new Point3D(-1, -1, -1);
            WorldMax = new Point3D(1, 1, 1);
            axes.UpdateOpenSides(FindPhi());

            this.IsVisibleChanged += new DependencyPropertyChangedEventHandler(Viewport3D_IsVisibleChanged);
        }
Esempio n. 6
0
        //public Model3D(Device graphicsDevice)
        //{
        //    SetValue(ChildrenProperty, new Model3DCollection(this));
        //    Initialize();
        //}

        internal virtual void OnViewportImageChanged(ViewportImage newViewportImage)
        {
            RemoveBindToViewportImage();
            viewportImage       = newViewportImage;
            this.graphicsDevice = (viewportImage == null) ? null : viewportImage.GraphicsDevice;
            this.layer2D        = (viewportImage == null) ? null : viewportImage.Layer2D;
            BindToViewportImage();
            Children.viewportImage = (viewportImage == null) ? null : viewportImage;
            geometryChanged        = false;
        }
 public Model3DCollection(object owner)
     : base()
 {
     this.owner = owner;
     if (owner is ViewportImage)
     {
         viewportImage = (owner as ViewportImage);
     }
     else if (owner is Model3D)
     {
         viewportImage = (owner as Model3D).viewportImage;
     }
     else
     {
         viewportImage = null;
     }
 }
Esempio n. 8
0
        internal override void OnViewportImageChanged(ViewportImage newViewportImage)
        {
            ViewportImage oldViewportImage = viewportImage;

            if (oldViewportImage != null)
            {
                viewportImage.GraphicsDeviceService.DeviceReset     -= new EventHandler(GraphicsDeviceService_DeviceReset);
                viewportImage.GraphicsDeviceService.DeviceResetting -= new EventHandler(GraphicsDeviceService_DeviceResetting);
            }
            base.OnViewportImageChanged(newViewportImage);
            if (!viewportImage.GraphicsDeviceService.IsAntialiased)
            {
                LineThickness = 1.0;
            }
            viewportImage.GraphicsDeviceService.DeviceReset     += new EventHandler(GraphicsDeviceService_DeviceReset);
            viewportImage.GraphicsDeviceService.DeviceResetting += new EventHandler(GraphicsDeviceService_DeviceResetting);
            TryCreateEffects();
            UpdateGeometry();
        }
Esempio n. 9
0
 internal override void OnViewportImageChanged(ViewportImage newViewportImage)
 {
     // if the ViewportImage is owned by a Plot3D, we can add a ColourBar.
     if (viewportImage != null && viewportImage.ViewPort3D != null && colourBar != null)
     {
         viewportImage.ViewPort3D.Annotations.Remove(colourBar);
         colourBar.ColourMapChanged -= new RoutedEventHandler(colourBar_ColourMapChanged);
     }
     base.OnViewportImageChanged(newViewportImage);
     if (viewportImage.ViewPort3D != null)
     {
         if (colourBar == null)
         {
             colourBar     = new ColourBar(colourMap);
             colourBar.Min = bounds.Minimum.Z; colourBar.Max = bounds.Maximum.Z;
             colourBar.ColourMapChanged += new RoutedEventHandler(colourBar_ColourMapChanged);
         }
         viewportImage.ViewPort3D.Annotations.Add(colourBar);
     }
 }
Esempio n. 10
0
 internal override void OnViewportImageChanged(ViewportImage newViewportImage)
 {
     // if the ViewportImage is owned by a Plot3D, we can add a ColourBar.
     if (viewportImage != null && viewportImage.ViewPort3D != null && colourBar != null)
     {
         viewportImage.ViewPort3D.Annotations.Remove(colourBar);
         colourBar.ColourMapChanged -= new RoutedEventHandler(colourBar_ColourMapChanged);
     }
     base.OnViewportImageChanged(newViewportImage);
     if (viewportImage.ViewPort3D != null)
     {
         if (colourBar == null)
         {
             colourBar = new ColourBar(colourMap);
             colourBar.Min = bounds.Minimum.Z; colourBar.Max = bounds.Maximum.Z; 
             colourBar.ColourMapChanged += new RoutedEventHandler(colourBar_ColourMapChanged);
         }
         viewportImage.ViewPort3D.Annotations.Add(colourBar);
     }
 }
Esempio n. 11
0
 public SharpDXLayer2D(Canvas canvas, ViewportImage ViewportImage, MatrixTransform3D ModelToWorld)
 {
     this.canvas = canvas;
     this.ModelToWorld = ModelToWorld;
     this.ViewportImage = ViewportImage;
 }
 protected override void CreateDirectImage()
 {
     directImage = new ViewportImage();
 }
Esempio n. 13
0
        public void Initialize()
        {
            Background = null;
            viewport3DControl = new Viewport3DControl();
            viewport3DControl.SetValue(Grid.ZIndexProperty, 100);
            this.Children.Add(viewport3DControl);

            viewport3DImage = viewport3DControl.Viewport3DImage;
            if (viewport3DImage == null)
            {
                axes = new Axes3D();
                SetValue(ModelsProperty, new Model3DCollection(null));
                return;
            }
            viewport3DImage.ViewPort3D = this;

            SetValue(ModelsProperty, viewport3DImage.Models);
            // Set the owner of the Model3DCollection to be the D3DImageViewport
            // This ensures that the Model3D objects are rendered by the D3DImageViewport
            viewport3DImage.SetLayer2D(viewport3DImage.Canvas, GraphToWorld);

            viewport3DImage.Models.Changed += new Model3DCollection.ItemEventHandler(Models_Changed);

            trackball = new Trackball();
            trackball.EventSource = viewport3DControl; //viewport3DImage.Canvas;
            trackball.OnTrackBallMoved += new TrackballEventHandler(trackball_TrackBallMoved);
            trackball.OnTrackBallZoom += new TrackballEventHandler(trackball_OnTrackBallZoom);
            trackball.OnTrackBallTranslate += new TrackballEventHandler(trackball_OnTrackBallTranslate);

            axes = new Axes3D();
            viewport3DImage.Models.Add(axes);

            viewport3DImage.CameraPosition = new Vector3(-3f, -3f, 2f);
            viewport3DImage.CameraTarget = new Vector3(0f, 0f, 0f);
            //
            Binding bindingGraphMin = new Binding("GraphMin");
            bindingGraphMin.Source = this;
            bindingGraphMin.Mode = BindingMode.TwoWay;
            BindingOperations.SetBinding(axes, Axes3D.GraphMinProperty, bindingGraphMin);
            Binding bindingGraphMax = new Binding("GraphMax");
            bindingGraphMax.Source = this;
            bindingGraphMax.Mode = BindingMode.TwoWay;
            BindingOperations.SetBinding(axes, Axes3D.GraphMaxProperty, bindingGraphMax);
            Binding bindingGraphToWorld = new Binding("GraphToWorld");
            bindingGraphToWorld.Source = this;
            bindingGraphToWorld.Mode = BindingMode.OneWay;
            BindingOperations.SetBinding(viewport3DImage, ViewportImage.ModelToWorldProperty, bindingGraphToWorld);
            ////
            GraphMax = new Point3D(1, 1, 1);
            GraphMin = new Point3D(-1, -1, -1);
            WorldMin = new Point3D(-1, -1, -1);
            WorldMax = new Point3D(1, 1, 1);
            axes.UpdateOpenSides(FindPhi());

            this.IsVisibleChanged += new DependencyPropertyChangedEventHandler(Viewport3D_IsVisibleChanged);
        }
Esempio n. 14
0
 public SlimDXLayer2D(Canvas canvas, ViewportImage ViewportImage, MatrixTransform3D ModelToWorld)
 {
     this.canvas        = canvas;
     this.ModelToWorld  = ModelToWorld;
     this.ViewportImage = ViewportImage;
 }
Esempio n. 15
0
 internal override void OnViewportImageChanged(ViewportImage newViewportImage)
 {
     ViewportImage oldViewportImage = viewportImage;
     if (oldViewportImage != null)
     {
         viewportImage.GraphicsDeviceService.DeviceReset -= new EventHandler(GraphicsDeviceService_DeviceReset);
         viewportImage.GraphicsDeviceService.DeviceResetting -= new EventHandler(GraphicsDeviceService_DeviceResetting);
     }
     base.OnViewportImageChanged(newViewportImage);
     if (!viewportImage.GraphicsDeviceService.IsAntialiased) LineThickness = 1.0;
     viewportImage.GraphicsDeviceService.DeviceReset += new EventHandler(GraphicsDeviceService_DeviceReset);
     viewportImage.GraphicsDeviceService.DeviceResetting += new EventHandler(GraphicsDeviceService_DeviceResetting);
     TryCreateEffects();
     UpdateGeometry();
 }
Esempio n. 16
0
        //public Model3D(Device graphicsDevice)
        //{
        //    SetValue(ChildrenProperty, new Model3DCollection(this));
        //    Initialize();
        //}

        internal virtual void OnViewportImageChanged(ViewportImage newViewportImage)
        {
            RemoveBindToViewportImage();
            viewportImage = newViewportImage;
            this.graphicsDevice = (viewportImage == null) ? null : viewportImage.GraphicsDevice;
            this.layer2D = (viewportImage == null) ? null : viewportImage.Layer2D;
            BindToViewportImage();
            Children.viewportImage = (viewportImage == null) ? null : viewportImage;
            geometryChanged = false;
        }
Esempio n. 17
0
 protected override void CreateDirectImage()
 {
     directImage = new ViewportImage();
 }
Esempio n. 18
0
        internal override void OnViewportImageChanged(ViewportImage newViewportImage)
        {
 	        base.OnViewportImageChanged(newViewportImage);
            UpdateLabels();
            this.OnDraw -= new OnDrawEventHandler(OnDrawUpdate);
            this.OnDraw += new OnDrawEventHandler(OnDrawUpdate);
        }