A visual element that contains a set of points. The size of the points is defined in screen space.
Inheritance: ScreenSpaceVisual3D
Esempio n. 1
0
        void OnCompositionTargetRendering(object sender, EventArgs e)
        {
            if (ShowLinesVisual3D && lines==null)
            {
                lines = new LinesVisual3D { Color = Colors.Blue };
                view1.Children.Add(lines);
            }
            if (!ShowLinesVisual3D && lines!=null)
            {
                lines.IsRendering = false;
                view1.Children.Remove(lines);
                lines = null;
            }
            if (ShowPointsVisual3D && points == null)
            {
                points = new PointsVisual3D { Color = Colors.Red, Size=6 };
                view1.Children.Add(points);
            }
            if (!ShowPointsVisual3D && points != null)
            {
                points.IsRendering = false;
                view1.Children.Remove(points);
                points = null;
            }
            if (ShowScreenSpaceLines3D && screenSpaceLines == null)
            {
                screenSpaceLines = new ScreenSpaceLines3D { Color = Colors.Green };
                view1.Children.Add(screenSpaceLines);
            }
            if (!ShowScreenSpaceLines3D && screenSpaceLines != null)
            {
                view1.Children.Remove(screenSpaceLines);
                screenSpaceLines = null;
            }
            if (ShowWireLines && wireLines == null)
            {
                wireLines = new WireLines { Color = Colors.Pink };
                view1.Children.Add(wireLines);
            }
            if (!ShowWireLines && wireLines != null)
            {
                view1.Children.Remove(wireLines);
                wireLines = null;
            }

            if (Points==null || Points.Count != N || isAnimating)
            {
                Points = GeneratePoints(N, watch.ElapsedMilliseconds*0.001);
                RaisePropertyChanged("Points");
            }

            if (lines != null)
                lines.Points = Points;
            if (points != null)
                points.Points = Points;
            if (screenSpaceLines != null)
                screenSpaceLines.Points = Points;
            if (wireLines != null)
                wireLines.Lines = Points;
        }
Esempio n. 2
0
        public dyn3DPreview()
        {
            InPortData.Add(new PortData("IN", "Incoming geometry objects.", typeof(object)));
            OutPortData.Add(new PortData("OUT", "Watch contents, passed through", typeof(object)));

            NodeUI.RegisterAllPorts();

            //get rid of right click delete
            //this.MainContextMenu.Items.Clear();

            MenuItem mi = new MenuItem();
            mi.Header = "Zoom to Fit";
            mi.Click +=new RoutedEventHandler(mi_Click);

            NodeUI.MainContextMenu.Items.Add(mi);

            //take out the left and right margins
            //and make this so it's not so wide
            NodeUI.inputGrid.Margin = new Thickness(10, 10, 10, 10);

            isScreenShot = true;

            if (isScreenShot)
            {
                NodeUI.topControl.Width = 800;
                NodeUI.topControl.Height = 500;
            }
            else
            {
                NodeUI.topControl.Width = 400;
                NodeUI.topControl.Height = 300;
            }

            //this.elementShine.Visibility = System.Windows.Visibility.Hidden;
            //this.elementRectangle.Visibility = System.Windows.Visibility.Hidden;

            //add a 3D viewport to the input grid
            //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation
            view = new HelixViewport3D();
            view.DataContext = this;
            view.CameraRotationMode = CameraRotationMode.Turntable;
            view.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            view.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            //RenderOptions.SetEdgeMode(view,EdgeMode.Aliased);
            RenderOptions.SetEdgeMode(view, EdgeMode.Unspecified);
            view.ShowViewCube = false;

            //view.IsHitTestVisible = true;
            view.ShowFrameRate = true;

            view.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(view_MouseRightButtonUp);
            view.PreviewMouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(view_PreviewMouseRightButtonDown);

            fixedPoints = new PointsVisual3D { Color = Colors.Red, Size = 8 };
            view.Children.Add(fixedPoints);

            points = new PointsVisual3D { Color = Colors.Black, Size = 4 };
            view.Children.Add(points);

            // a list of 10 colors to be used for
            // mapping analysis results
            colors.Add(Colors.Black); //01
            colors.Add(Colors.LightBlue); //02
            colors.Add(Colors.Blue); //03
            colors.Add(Colors.Purple); //04
            colors.Add(Colors.LightGreen); //05
            colors.Add(Colors.GreenYellow); //06
            colors.Add(Colors.Yellow); //07
            colors.Add(Colors.Orange); //08
            colors.Add(Colors.OrangeRed); //09
            colors.Add(Colors.Red); //10
            colors.Add(Colors.Black);//11 for naked lines and curves

            FixedPoints = new Point3DCollection();
            Points = new List<Point3DCollection>();
            for (int i = 0; i < colors.Count(); i++)
            {
                Points.Add(new Point3DCollection());
            }

            linesList = new List<LinesVisual3D>();
            for (int i = 0; i < colors.Count(); i++)
            {
                LinesVisual3D lines = new LinesVisual3D { Color = colors[i], Thickness = 1 };

                linesList.Add(lines);
                view.Children.Add(lines);
            }

            System.Windows.Shapes.Rectangle backgroundRect = new System.Windows.Shapes.Rectangle();
            backgroundRect.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            backgroundRect.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            backgroundRect.RadiusX = 10;
            backgroundRect.RadiusY = 10;
            backgroundRect.IsHitTestVisible = false;
            BrushConverter bc = new BrushConverter();
            Brush strokeBrush = (Brush)bc.ConvertFrom("#313131");
            backgroundRect.Stroke = strokeBrush;
            backgroundRect.StrokeThickness = 1;
            SolidColorBrush backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(250,250,216));
            backgroundRect.Fill = backgroundBrush;
            NodeUI.inputGrid.Children.Add(backgroundRect);
            NodeUI.inputGrid.Children.Add(view);

            CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
        }
Esempio n. 3
0
        private void DrawCurve(Curve c)
        {
            List<XYZ> points;

            points = c.Tessellate() as List<XYZ>;
            XYZ pt1;
            XYZ pt2;
            Point3D ptVis1;
            Point3D ptVis2;
            int lastPointColor = Points.Count() - 1;//master Point list for color assignment
            for (int i = 0; i < points.Count - 1; i++)
            {
                pt1 = points[i] as XYZ;
                pt2 = points[i + 1] as XYZ;
                ptVis1 = new Point3D(pt1.X, pt1.Y, pt1.Z);
                ptVis2 = new Point3D(pt2.X, pt2.Y, pt2.Z);
                Points[lastPointColor].Add(ptVis1);
                Points[lastPointColor].Add(ptVis2);
            }
        }
        private void SetDraw(object sender, RoutedEventArgs e)
        {
            if (checkDraw.IsChecked.GetValueOrDefault())
            {

                tmpArrete = new LinesVisual3D();
                tmpArrete.Color = colorLines;
                tmpArrete.Thickness = 0.01;

                tmpPoints = new PointsVisual3D();
                tmpPoints.Color = colorPoints;
                tmpPoints.Size = 0.05;

                bufArrete = new Point3DCollection();
                bufPoint = new Point3DCollection();

                listePoints.Add(tmpPoints);
                listeLignes.Add(tmpArrete);

                ViewPort.Children.Add(listeLignes.Last());
                ViewPort.Children.Add(listePoints.Last());
                nbTraits.Content = "Nombre de traits : " + listeLignes.Count;

                timer.Tick += new EventHandler(drawPoints);
                timer.Start();
            }

            

        }
Esempio n. 5
0
        private void InitializeScene()
        {
            limitationsCuboid = new RoomVisual3D();
            limitationsCuboid.Initialize(20.0);
            limitationsCuboid.IsDampingActive = Damping;

            bezierCube = new BezierCubeVisual3D();
            bezierCube.Initialize(cubeSize);
            bezierCube.CollisionChecker = limitationsCuboid;
            bezierCube.IsDampingActive = Damping;

            spherePoints = new PointsVisual3D();
            spherePoints.Points = bezierCube.GetSpherePoints();
            spherePoints.Size = 3;

            if (DeformedSolidEnabled)
                HelixViewport.Children.Add(spherePoints);

            if (ControlPointsEnabled)
            {
                HelixViewport.Children.Add(bezierCube.points);
                HelixViewport.Children.Add(bezierCube.lines);
            }

            steeringFrame = new FrameVisual3D();
            steeringFrame.Initialize(cubeSize);
            if (SteeringFrameEnabled)
            {
                HelixViewport.Children.Add(steeringFrame.points);
                HelixViewport.Children.Add(steeringFrame.lines);
                HelixViewport.Children.Add(steeringFrame.GetJointsPoints(bezierCube.GetCornerPoints()));
            }
            manipulator = new CombinedManipulator();
            manipulator.Diameter = 3;
            manipulator.Offset = new Vector3D(0, 0, 5);
            HelixViewport.Children.Add(manipulator);

            //geometry = new MeshGeometryVisual3D();
            //var builder = new MeshBuilder(false, false);
            //builder.AddTriangles(bezierCube.GetSpherePoints());
            //geometry.MeshGeometry = builder.ToMesh(true);
            //HelixViewport.Children.Add(geometry);

            surfaces = new BezierSurface[6];
            for (int i = 0; i < 6; i++)
            {
                surfaces[i] = new BezierSurface()
                {
                    Fill = Brushes.Red,
                    MeshSizeU = 20,
                    MeshSizeV = 20
                };
                surfaces[i].UpdateSurface(bezierCube.GetFaceControlPoints(i));
                surfaces[i].UpdateModel();
                if (BezierCubeEnabled)
                    HelixViewport.Children.Add(surfaces[i]);
            }
            //limitationsCuboid.UpdateViewport(HelixViewport);
        }
Esempio n. 6
0
        public override void SetupCustomUIElements(Controls.dynNodeView nodeUI)
        {
            MenuItem mi = new MenuItem();
            mi.Header = "Zoom to Fit";
            mi.Click += new RoutedEventHandler(mi_Click);

            nodeUI.MainContextMenu.Items.Add(mi);

            //take out the left and right margins and make this so it's not so wide
            //NodeUI.inputGrid.Margin = new Thickness(10, 10, 10, 10);

            //add a 3D viewport to the input grid
            //http://helixtoolkit.codeplex.com/wikipage?title=HelixViewport3D&referringTitle=Documentation
            _watchView = new WatchView();
            _watchView.watch_view.DataContext = this;

            RenderOptions.SetEdgeMode(_watchView, EdgeMode.Unspecified);

            Points = new Point3DCollection();
            Lines = new Point3DCollection();

            _points = new PointsVisual3D { Color = Colors.Red, Size = 6 };
            _lines = new LinesVisual3D { Color = Colors.Blue, Thickness = 1 };

            _points.Points = Points;
            _lines.Points = Lines;

            _watchView.watch_view.Children.Add(_lines);
            _watchView.watch_view.Children.Add(_points);

            _watchView.watch_view.Children.Add(new DefaultLights());

            _watchView.Width = 400;
            _watchView.Height = 300;

            System.Windows.Shapes.Rectangle backgroundRect = new System.Windows.Shapes.Rectangle();
            backgroundRect.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            backgroundRect.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            //backgroundRect.RadiusX = 10;
            //backgroundRect.RadiusY = 10;
            backgroundRect.IsHitTestVisible = false;
            BrushConverter bc = new BrushConverter();
            Brush strokeBrush = (Brush)bc.ConvertFrom("#313131");
            backgroundRect.Stroke = strokeBrush;
            backgroundRect.StrokeThickness = 1;
            SolidColorBrush backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(250, 250, 216));
            backgroundRect.Fill = backgroundBrush;

            //nodeUI.inputGrid.Children.Add(backgroundRect);
            //nodeUI.inputGrid.Children.Add(_watchView);

            nodeUI.grid.Children.Add(backgroundRect);
            nodeUI.grid.Children.Add(_watchView);
            backgroundRect.SetValue(Grid.RowProperty,2);
            backgroundRect.SetValue(Grid.ColumnSpanProperty,3);
            _watchView.SetValue(Grid.RowProperty, 2);
            _watchView.SetValue(Grid.ColumnSpanProperty, 3);
            _watchView.Margin = new Thickness(5,0,5,5);
            backgroundRect.Margin = new Thickness(5, 0, 5, 5);
            CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
        }
Esempio n. 7
0
        private void OnCompositionTargetRendering(object sender, EventArgs e)
        {
            if (this.ShowLinesVisual3D && this.linesVisual == null)
            {
                this.linesVisual = new LinesVisual3D { Color = Colors.Blue };
                View1.Children.Add(this.linesVisual);
            }

            if (!this.ShowLinesVisual3D && this.linesVisual != null)
            {
                this.linesVisual.IsRendering = false;
                View1.Children.Remove(this.linesVisual);
                this.linesVisual = null;
            }

            if (this.ShowPointsVisual3D && this.pointsVisual == null)
            {
                this.pointsVisual = new PointsVisual3D { Color = Colors.Red, Size = 6 };
                View1.Children.Add(this.pointsVisual);
            }

            if (!this.ShowPointsVisual3D && this.pointsVisual != null)
            {
                this.pointsVisual.IsRendering = false;
                View1.Children.Remove(this.pointsVisual);
                this.pointsVisual = null;
            }

            if (this.ShowScreenSpaceLines3D && this.screenSpaceLines == null)
            {
                this.screenSpaceLines = new ScreenSpaceLines3D { Color = Colors.Green };
                View1.Children.Add(this.screenSpaceLines);
            }

            if (!this.ShowScreenSpaceLines3D && this.screenSpaceLines != null)
            {
                View1.Children.Remove(this.screenSpaceLines);
                this.screenSpaceLines = null;
            }

            if (this.ShowWireLines && this.wireLines == null)
            {
                this.wireLines = new WireLines { Color = Colors.Pink };
                View1.Children.Add(this.wireLines);
            }

            if (!this.ShowWireLines && this.wireLines != null)
            {
                View1.Children.Remove(this.wireLines);
                this.wireLines = null;
            }

            if (this.Points == null || this.Points.Count != this.NumberOfPoints)
            {
                this.Points = new Point3DCollection(GeneratePoints(this.NumberOfPoints, this.watch.ElapsedMilliseconds * 0.001));
            }

            if (this.linesVisual != null)
            {
                this.linesVisual.Points = this.Points;
            }

            if (this.pointsVisual != null)
            {
                this.pointsVisual.Points = this.Points;
            }

            if (this.screenSpaceLines != null)
            {
                this.screenSpaceLines.Points = this.Points;
            }

            if (this.wireLines != null)
            {
                this.wireLines.Lines = this.Points;
            }
        }
Esempio n. 8
0
		public static void GetPreviewModel(Vector2 min, Vector2 max, int pointsX, int pointsY, LinesVisual3D border, PointsVisual3D pointv)
		{
			Vector2 min_temp = new Vector2(Math.Min(min.X, max.X), Math.Min(min.Y, max.Y));
			Vector2 max_temp = new Vector2(Math.Max(min.X, max.X), Math.Max(min.Y, max.Y));

			min = min_temp;
			max = max_temp;

			double gridX = (max.X - min.X) / (pointsX - 1);
			double gridY = (max.Y - min.Y) / (pointsY - 1);

			Point3DCollection points = new Point3DCollection();

			for (int x = 0; x < pointsX; x++)
			{
				for (int y = 0; y < pointsY; y++)
				{
					points.Add(new Point3D(min.X + x * gridX, min.Y + y * gridY, 0));
				}
			}

			pointv.Points.Clear();
			pointv.Points = points;

			Point3DCollection b = new Point3DCollection();
			b.Add(new Point3D(min.X, min.Y, 0));
			b.Add(new Point3D(min.X, max.Y, 0));
			b.Add(new Point3D(min.X, max.Y, 0));
			b.Add(new Point3D(max.X, max.Y, 0));
			b.Add(new Point3D(max.X, max.Y, 0));
			b.Add(new Point3D(max.X, min.Y, 0));
			b.Add(new Point3D(max.X, min.Y, 0));
			b.Add(new Point3D(min.X, min.Y, 0));

			border.Points.Clear();
			border.Points = b;
		}
Esempio n. 9
0
		public static void GetPreviewModel(Vector2 min, Vector2 max, double gridSize, LinesVisual3D border, PointsVisual3D pointv)
		{
			Vector2 min_temp = new Vector2(Math.Min(min.X, max.X), Math.Min(min.Y, max.Y));
			Vector2 max_temp = new Vector2(Math.Max(min.X, max.X), Math.Max(min.Y, max.Y));

			min = min_temp;
			max = max_temp;

			if ((max.X - min.X) == 0 || (max.Y - min.Y) == 0)
			{
				pointv.Points.Clear();
				border.Points.Clear();
				return;
			}

			int pointsX = (int)Math.Ceiling((max.X - min.X) / gridSize) + 1;
			int pointsY = (int)Math.Ceiling((max.Y - min.Y) / gridSize) + 1;

			GetPreviewModel(min, max, pointsX, pointsY, border, pointv);
		}
Esempio n. 10
0
		public void GetPreviewModel(LinesVisual3D border, PointsVisual3D pointv)
		{
			GetPreviewModel(Min, Max, SizeX, SizeY, border, pointv);
		}