Esempio n. 1
0
        private SingletonShapes()
        {
            ShapeDto m_NewShapes = JsonConvert.DeserializeObject <ShapeDto>(File.ReadAllText(Path.Combine(Environment.CurrentDirectory, TestConstants.SHAPES_FILE_01_PATH)));

            m_Shapes.AddRange(m_NewShapes.Hexagons);
            m_Shapes.AddRange(m_NewShapes.Stars);
            m_Shapes.AddRange(m_NewShapes.Circles);
        }
Esempio n. 2
0
        protected override void AddLines()
        {
            var pen = new Pen(Color.Red, 3);

            pen.CustomEndCap = new AdjustableArrowCap(4, 4);
            Shapes.AddRange(СonnectLines(pen, new [] { BeginEllipse.GetDown(), InitializationIndex.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new [] { InitializationIndex.GetDown(), Cycle.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new [] { Cycle.GetDown(), CycleBodySum.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new [] { CycleBodySum.GetDown(), CycleBodyIndex.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new []
            {
                Cycle.GetRight(), new Point(Cycle.GetRight().X + 25, Cycle.GetRight().Y),
                new Point(Cycle.GetRight().X + 25, Result.GetUp().Y - 25),
                new Point(Result.GetUp().X, Result.GetUp().Y - 25),
                Result.GetUp()
            }));
            Shapes.AddRange(СonnectLines(pen, new []
            {
                CycleBodyIndex.GetDown(), new Point(CycleBodyIndex.GetDown().X, CycleBodyIndex.GetDown().Y + 25),
                new Point(Cycle.GetLeft().X - 25, CycleBodyIndex.GetDown().Y + 25),
                new Point(Cycle.GetLeft().X - 25, Cycle.GetLeft().Y),
                Cycle.GetLeft()
            }));
            Shapes.AddRange(СonnectLines(pen, new [] { Result.GetDown(), EndEllipse.GetUp() }));
        }
Esempio n. 3
0
 public override void Create()
 {
     foreach (Node n in Children)
     {
         Shapes.AddRange(n.Shapes.Select(a => a.Copy()));
     }
 }
Esempio n. 4
0
        public override void Create()
        {
            Matrix3D m = new RotateTransform3D(new AxisAngleRotation3D(Axis, Angle)).Value;

            foreach (Node n in Children)
            {
                Shapes.AddRange(n.Shapes.Select(a => a.Copy().ApplyTransform(m)));
            }
        }
Esempio n. 5
0
        public override void Create()
        {
            Matrix3D m = new TranslateTransform3D(Translation).Value;

            foreach (Node n in Children)
            {
                Shapes.AddRange(n.Shapes.Select(a => a.Copy().ApplyTransform(m)));
            }
        }
Esempio n. 6
0
        public virtual void DiscoverShapes()
        {
            var shapes = Slide.Descendants <DocumentFormat.OpenXml.Presentation.Shape>().Where(s => s.ElementName().ToUpper().StartsWith("DATA:"));

            Shapes.AddRange(shapes.Select(s => ShapeElement.Create(s.ElementName().Substring(5).Trim(), s, this)).Where(s => s != null));
            var graphicFrames = Slide.Descendants <DocumentFormat.OpenXml.Presentation.GraphicFrame>().Where(s => s.ElementName().ToUpper().StartsWith("DATA:"));

            foreach (var item in graphicFrames)
            {
                string name = item.ElementName().Substring(5).Trim();
                if (item.Graphic.GraphicData.FirstElement <Table>() != null)
                {
                    TableElement table = TableElement.Create(name, item, this);
                    if (table != null)
                    {
                        Shapes.Add(table);
                    }
                }
                else if (item.Graphic.GraphicData.FirstElement <ChartReference>() != null)
                {
                    ChartElement chart = ChartElement.Create(name, item, this);
                    if (chart != null)
                    {
                        Shapes.Add(chart);
                    }
                }
            }
            var paragraphs = Slide.Descendants <Paragraph>();

            foreach (var item in paragraphs)
            {
                if (!item.Ancestors <Table>().Any())
                {
                    if (textTagRegex.Match(item.InnerText).Success)
                    {
                        foreach (Match match in textTagRegex.Matches(item.InnerText))
                        {
                            McKinsey.PowerPointGenerator.Elements.TextElement text = McKinsey.PowerPointGenerator.Elements.TextElement.Create(match.Groups["tag"].Value, item, this);
                            if (text != null)
                            {
                                Shapes.Add(text);
                            }
                        }
                    }
                }
            }
            foreach (ShapeElementBase item in Shapes)
            {
                item.Slide = this;
            }
        }
Esempio n. 7
0
        public override void Create()
        {
            if (!Scene.NextStage("Create SplitByRayNode"))
            {
                Shapes.AddRange(Children.SelectMany(a => a.Shapes).Select(a => a.Copy())); // if not doing this stage, just copy over the none split convexes
                return;
            }
            else if (Scene.IsCurrentStage())
            {
                Scene.AddDebugLine(RayStart - RayDir * 10, RayStart + RayDir * 10);
            }

            Shapes.AddRange(Children.SelectMany(a => a.Shapes).Select(a => a.Copy().Split2d(RayStart, RayDir, SplitMode))); //do full copy then split
        }
Esempio n. 8
0
        /// <summary>
        /// Push power ups, remove out of bounds and add generated
        /// </summary>
        /// <param name="message"></param>
        public void Update(MessageDto message)
        {
            if (message.MessageType != MessageType.PowerUpsUpdate)
            {
                return;
            }

            Logging.Instance.Write("Observer: power ups got update", LoggingLevel.Pattern);

            ShiftShapes();

            if (message.Payload != null)
            {
                Shapes.AddRange(message.Payload as List <BaseShape>); //Append generated power ups
            }
        }
        public ViewerMainViewModel(IRegionManager regionManager) : base(regionManager)
        {
            Message      = "Viewer Module.";
            GoSqlCommand = new DelegateCommand(DoSqlTest);

            Equipments.Clear();

            List <string> equipments = new List <string>();

            for (int i = 0; i < 200; i++)
            {
                equipments.Add("Inlet");
                equipments.Add("Outlet");
                equipments.Add("Valve");
                equipments.Add("Pipe");
            }

            Equipments.AddRange(equipments);

            List <ShapeViewModelBase> shapes = new List <ShapeViewModelBase>();

            for (int i = 0; i < 30; i++)
            {
                shapes.Add(new InletViewModel()
                {
                    X      = (i % 8) * 40 + 5,
                    Y      = (int)(i / 8) * 40 + 5,
                    Width  = 64,
                    Height = 64,
                    Angle  = 0
                });
            }
            for (int i = 0; i < 5; i++)
            {
                shapes.Add(new PipeViewModel()
                {
                    X      = (i % 8) * 40 + 5,
                    Y      = (int)(i / 8) * 40 + 5 + 300,
                    Width  = 64,
                    Height = 64,
                    Angle  = 0
                });
            }

            Shapes.AddRange(shapes);
        }
Esempio n. 10
0
        protected override void AddLines()
        {
            var pen = new Pen(Color.Red, 3);

            pen.CustomEndCap = new AdjustableArrowCap(4, 4);
            Shapes.AddRange(СonnectLines(pen, new [] { BeginEllipse.GetDown(), InitializationIndex.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new [] { InitializationIndex.GetDown(), ShapeSum.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new [] { ShapeSum.GetDown(), ShapeIndex.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new [] { ShapeIndex.GetDown(), ShapeСondition.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new [] { ShapeСondition.GetDown(), Result.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new []
            {
                ShapeСondition.GetRight(), new Point(ShapeСondition.GetRight().X + 25, ShapeСondition.GetRight().Y),
                new Point(ShapeСondition.GetRight().X + 25, ShapeSum.GetRight().Y),
                ShapeSum.GetRight()
            }));
            Shapes.AddRange(СonnectLines(pen, new [] { Result.GetDown(), EndEllipse.GetUp() }));
        }
Esempio n. 11
0
        public override void Plot(bool animate = true)
        {
            if (Visibility != Visibility.Visible)
            {
                return;
            }
            var rr = PointRadius < 2.5 ? 2.5 : PointRadius;

            foreach (var segment in Values.Points.AsSegments())
            {
                var s = new List <FrameworkElement>();
                if (LineChart.LineType == LineChartLineType.Bezier)
                {
                    s.AddRange(_addSerieAsBezier(segment.Select(x => new Point(
                                                                    ToDrawMargin(x.X, AxisTags.X), ToDrawMargin(x.Y, AxisTags.Y)))
                                                 .ToArray(), animate));
                }

                if (LineChart.LineType == LineChartLineType.Polyline)
                {
                    s.AddRange(_addSeriesAsPolyline(segment.Select(x => new Point(
                                                                       ToDrawMargin(x.X, AxisTags.X), ToDrawMargin(x.Y, AxisTags.Y)))
                                                    .ToArray(), animate));
                }

                var hoverableAreas = new List <HoverableShape>();
                var f = Chart.GetFormatter(Chart.Invert ? Chart.AxisX : Chart.AxisY);

                foreach (var point in segment)
                {
                    var plotPoint = new Point(ToDrawMargin(point.X, AxisTags.X), ToDrawMargin(point.Y, AxisTags.Y));
                    var e         = new Ellipse
                    {
                        Width  = PointRadius * 2,
                        Height = PointRadius * 2,
                        Fill   = Stroke,
                        Stroke = new SolidColorBrush {
                            Color = Chart.PointHoverColor
                        },
                        StrokeThickness = 1,
                        ClipToBounds    = true
                    };
                    var r = new Rectangle
                    {
                        Fill            = Brushes.Transparent,
                        Width           = rr * 2,
                        Height          = rr * 2,
                        StrokeThickness = 0
                    };

                    if (DataLabels)
                    {
                        var tb = BuildATextBlock(0);
                        var t  = f(Chart.Invert ? point.X : point.Y);
                        var ft = new FormattedText(
                            t,
                            CultureInfo.CurrentUICulture,
                            FlowDirection.LeftToRight,
                            new Typeface(FontFamily, FontStyle, FontWeight, FontStretch), FontSize, Brushes.Black);
                        tb.Text = t;
                        Chart.DrawMargin.Children.Add(tb);
                        Chart.Shapes.Add(tb);
                        var l = plotPoint.X - ft.Width * .5;
                        l = l < 0
                            ? 0
                            : (l + ft.Width > Chart.DrawMargin.Width
                                ? Chart.DrawMargin.Width - ft.Width
                                : l);
                        var tp = plotPoint.Y - ft.Height - 5;
                        tp = tp < 0 ? 0 : tp;
                        Canvas.SetLeft(tb, l);
                        Canvas.SetTop(tb, tp);
                        s.Add(tb);
                    }

                    r.MouseEnter += Chart.DataMouseEnter;
                    r.MouseLeave += Chart.DataMouseLeave;
                    r.MouseDown  += Chart.DataMouseDown;

                    Canvas.SetLeft(r, plotPoint.X - r.Width / 2);
                    Canvas.SetTop(r, plotPoint.Y - r.Height / 2);
                    Panel.SetZIndex(r, int.MaxValue);
                    Canvas.SetLeft(e, plotPoint.X - e.Width * .5);
                    Canvas.SetTop(e, plotPoint.Y - e.Height * .5);

                    Chart.DrawMargin.Children.Add(r);
                    Chart.DrawMargin.Children.Add(e);

                    s.Add(e);
                    s.Add(r);
                    hoverableAreas.Add(new HoverableShape
                    {
                        Series = this,
                        Shape  = r,
                        Value  = point,
                        Target = e
                    });
                }

                Shapes.AddRange(s);
                Chart.HoverableShapes.AddRange(hoverableAreas);
            }
        }
Esempio n. 12
0
        public override void Plot(bool animate = true)
        {
            //TODO Improve
            //we are runing 3 foreach that could maybe be 1
            var serie = this;

            var xCount = 0;
            var points = new List <Point>();

            foreach (var d in serie.PrimaryValues)
            {
                xCount++;
                points.Add(new Point(xCount - 1, d));
            }

            var s = new List <Shape>();

            if (_chart.LineType == LineChartLineType.Bezier)
            {
                s.AddRange(_addSerieAsBezier(points.Select(ToPlotArea).ToArray(), Color,
                                             serie.StrokeThickness, animate));
            }

            if (_chart.LineType == LineChartLineType.Polyline)
            {
                s.AddRange(_addSeriesAsPolyline(points.Select(ToPlotArea).ToArray(), Color,
                                                serie.StrokeThickness, animate));
            }

            var hoverableAreas = new List <HoverableShape>();

            if (_chart.Hoverable)
            {
                foreach (var point in points)
                {
                    var plotPoint = ToPlotArea(point);
                    var e         = new Ellipse
                    {
                        Width  = serie.PointRadius * 2,
                        Height = serie.PointRadius * 2,
                        Fill   = new SolidColorBrush {
                            Color = Color
                        },
                        Stroke = new SolidColorBrush {
                            Color = Chart.PointHoverColor
                        },
                        StrokeThickness = 2,
                        ClipToBounds    = true
                    };
                    var r = new Rectangle
                    {
                        Fill            = Brushes.Transparent,
                        Width           = 40,
                        Height          = 40,
                        StrokeThickness = 0
                    };

                    r.MouseEnter += Chart.OnDataMouseEnter;
                    r.MouseLeave += Chart.OnDataMouseLeave;

                    Canvas.SetLeft(r, ToPlotArea(point.X, AxisTags.X) - r.Width / 2);
                    Canvas.SetTop(r, ToPlotArea(point.Y, AxisTags.Y) - r.Height / 2);
                    Panel.SetZIndex(r, int.MaxValue);
                    Canvas.SetLeft(e, plotPoint.X - e.Width * .5);
                    Canvas.SetTop(e, plotPoint.Y - e.Height * .5);

                    Chart.Canvas.Children.Add(r);
                    Chart.Canvas.Children.Add(e);

                    s.Add(e);
                    hoverableAreas.Add(new HoverableShape
                    {
                        Serie  = this,
                        Shape  = r,
                        Value  = point,
                        Target = e
                    });
                }
            }
            Shapes.AddRange(s);
            Chart.HoverableShapes.AddRange(hoverableAreas);
        }
Esempio n. 13
0
        public override void Plot(bool animate = true)
        {
            var points = new List <Point>();
            var count  = Math.Min(PrimaryValues.Count, SecondaryValues.Count);

            for (int index = 0; index < count; index++)
            {
                var value = new Point(SecondaryValues[index], PrimaryValues[index]);
                var point = ToPlotArea(value);
                points.Add(point);

                var e = new Ellipse
                {
                    Width  = PointRadius * 2,
                    Height = PointRadius * 2,
                    Fill   = Stroke,
                    Stroke = new SolidColorBrush {
                        Color = Chart.PointHoverColor
                    },
                    StrokeThickness = 2
                };

                Panel.SetZIndex(e, int.MaxValue - 2);
                Canvas.SetLeft(e, point.X - e.Width * .5);
                Canvas.SetTop(e, point.Y - e.Height * .5);
                Chart.Canvas.Children.Add(e);

                if (Chart.Hoverable)
                {
                    var r = new Rectangle
                    {
                        Fill            = Brushes.Transparent,
                        Width           = 40,
                        Height          = 40,
                        StrokeThickness = 0
                    };

                    r.MouseEnter += Chart.DataMouseEnter;
                    r.MouseLeave += Chart.DataMouseLeave;

                    Canvas.SetLeft(r, point.X - r.Width / 2);
                    Canvas.SetTop(r, point.Y - r.Height / 2);
                    Panel.SetZIndex(r, int.MaxValue);

                    Chart.Canvas.Children.Add(r);

                    Chart.HoverableShapes.Add(new HoverableShape
                    {
                        Series = this,
                        Shape  = r,
                        Target = e,
                        Value  = value
                    });
                }
                Shapes.Add(e);
            }

            var c = Chart as ILine;

            if (c == null)
            {
                return;
            }

            if (c.LineType == LineChartLineType.Bezier)
            {
                Shapes.AddRange(_addSerieAsBezier(points.ToArray(), Stroke, StrokeThickness, animate));
            }
            if (c.LineType == LineChartLineType.Polyline)
            {
                Shapes.AddRange(_addSeriesAsPolyline(points.ToArray(), Stroke, StrokeThickness, animate));
            }
        }
Esempio n. 14
0
        public override void Plot(bool animate = true)
        {
            if (Visibility != Visibility.Visible)
            {
                return;
            }

            var rr = PointRadius < 2.5 ? 2.5 : PointRadius;

            foreach (var segment in Values.Points.AsSegments())
            {
                var s = new List <FrameworkElement>();
                if (LineChart.LineType == LineChartLineType.Bezier)
                {
                    s.AddRange(_addSerieAsBezier(segment.Select(x => new Point(
                                                                    ToDrawMargin(x.X, AxisTags.X), ToDrawMargin(x.Y, AxisTags.Y)))
                                                 .ToArray(), animate));
                }

                if (LineChart.LineType == LineChartLineType.Polyline)
                {
                    s.AddRange(_addSeriesAsPolyline(segment.Select(x => new Point(
                                                                       ToDrawMargin(x.X, AxisTags.X), ToDrawMargin(x.Y, AxisTags.Y)))
                                                    .ToArray(), animate));
                }

                var f = Chart.GetFormatter(Chart.Invert ? Chart.AxisX : Chart.AxisY);

                for (int index = 0; index < segment.Count - 1; index++)
                {
                    var chrtP1 = segment[index];
                    var chrtP2 = segment[index + 1];

                    var p1 = new Point(ToDrawMargin(chrtP1.X, AxisTags.X), ToDrawMargin(chrtP1.Y, AxisTags.Y));
                    var p2 = new Point(ToDrawMargin(chrtP2.X, AxisTags.X), ToDrawMargin(chrtP2.Y, AxisTags.Y));

                    //if (LineChart.LineType == LineChartLineType.Polyline)
                    //    AddLine(p1, p2, animate);

                    if (DataLabels)
                    {
                        AddDataLabel(p1, chrtP1, f);
                    }
                    var mark = AddPointMarkup(p1);
                    AddHoverAndClickShape(rr, p1, chrtP1, mark);
                }

                if (segment.Count > 0)
                {
                    var lastP  = segment[segment.Count - 1];
                    var lastPp = new Point(ToDrawMargin(lastP.X, AxisTags.X), ToDrawMargin(lastP.Y, AxisTags.Y));

                    if (DataLabels)
                    {
                        AddDataLabel(lastPp, lastP, f);
                    }
                    var lastmark = AddPointMarkup(lastPp);
                    AddHoverAndClickShape(rr, lastPp, lastP, lastmark);
                }

                Shapes.AddRange(s);
            }
        }
Esempio n. 15
0
        public StarIcon(Entity entity) : base(entity.GetDataBlob <PositionDB>())
        {
            StarInfoDB starInfo = entity.GetDataBlob <StarInfoDB>();

            _tempK = starInfo.Temperature + 273.15;
            var massVol = entity.GetDataBlob <MassVolumeDB>();

            _bodyRadiusAU = massVol.Radius;

            double calcTemp = GMath.Clamp(_tempK, 1000, 40000);

            calcTemp = calcTemp / 100;

            //Red
            if (calcTemp <= 660)
            {
                _color.r = 255;
            }
            else
            {
                _color.r = (byte)(329.698727446 * Math.Pow(calcTemp - 60, -0.1332047592));
            }

            //Green
            if (calcTemp <= 66)
            {
                _color.g = (byte)(99.4708025861 * Math.Log(calcTemp) - 161.1195681661);
            }
            else
            {
                _color.g = (byte)(288.1221695283 * Math.Pow(calcTemp - 60, -0.0755148492));
            }

            //Blue
            if (calcTemp >= 66)
            {
                _color.b = 255;
            }
            else if (calcTemp <= 19)
            {
                _color.b = 0;
            }
            else
            {
                _color.b = (byte)(138.5177312231 * Math.Log(calcTemp - 10) - 305.0447927307);
            }
            _color.a = 255;


            byte          spikes      = (byte)(starInfo.SpectralType + 4);
            float         spikeheight = 100;
            float         spikeDepth  = 50;
            double        arc         = (2 * Math.PI) / spikes;
            double        startAngle  = 1.5708 - arc / 2;
            List <PointD> shapePoints = new List <PointD>();

            for (int i = 0; i < spikes; i++)
            {
                var    a1 = arc * i;
                double x1 = (0 * Math.Cos(a1) - spikeheight * Math.Sin(a1));
                double y1 = (0 * Math.Sin(a1) + spikeheight * Math.Cos(a1));
                var    p1 = new PointD()
                {
                    X = x1, Y = y1
                };

                var    a2 = a1 + arc * 0.5;
                double x2 = (0 * Math.Cos(a2) - spikeDepth * Math.Sin(a2));
                double y2 = (0 * Math.Sin(a2) + spikeDepth * Math.Cos(a2));
                var    p2 = new PointD()
                {
                    X = x2, Y = y2
                };

                shapePoints.Add(p1);
                shapePoints.Add(p2);

                /*
                 * this was an attempt at making slightly nicer looking stars using an elipsed curve instead of just straight lines. couldnt get it working though
                 * the idea was make an arc, then rotate it.
                 * List<SDL.SDL_Point> points = new List<SDL.SDL_Point>();
                 * points.AddRange(CreatePrimitiveShapes.CreateArc(32, 0, 32 - spikeDepth, 32 + spikeDepth, startAngle, arc, 32)); //32 segments is probilby way overkill maybe adjust this by the camera zoom level?
                 * //rotate it at i * arc;
                 * var a = arc * i;
                 * for (int i2 = 0; i2 < points.Count; i2++)
                 * {
                 *  int x = (int)(points[i2].x * Math.Cos(a) - points[i2].y * Math.Sin(a));
                 *  int y = (int)(points[i2].x * Math.Sin(a) + points[i2].y * Math.Cos(a));
                 *  points[i2] = new SDL.SDL_Point() { x = x, y = y };
                 * }
                 * shapePoints.AddRange(points);
                 * startAngle += arc;
                 */
            }
            shapePoints.Add(shapePoints[0]); //ensure the last point is the same as the first, so it joins up.
            List <Shape> shapes = new List <Shape>();

            shapes.Add(new Shape()
            {
                Color = _color, Points = shapePoints.ToArray()
            });
            Shapes.AddRange(shapes);
        }
Esempio n. 16
0
        public override void Plot(bool animate = true)
        {
            var s = new List <Shape>();

            if (LineChart.LineType == LineChartLineType.Bezier)
            {
                s.AddRange(_addSerieAsBezier(ChartPoints.Select(x => new Point(
                                                                    ToPlotArea(x.X, AxisTags.X) + Chart.XOffset, ToPlotArea(x.Y, AxisTags.Y))).ToArray(), animate));
            }

            if (LineChart.LineType == LineChartLineType.Polyline)
            {
                s.AddRange(_addSeriesAsPolyline(ChartPoints.Select(x => new Point(
                                                                       ToPlotArea(x.X, AxisTags.X) + Chart.XOffset, ToPlotArea(x.Y, AxisTags.Y))).ToArray(), animate));
            }

            var hoverableAreas = new List <HoverableShape>();

            if (Chart.Hoverable)
            {
                foreach (var point in ChartPoints)
                {
                    var plotPoint = ToPlotArea(point);
                    plotPoint.X += Chart.XOffset;
                    var e = new Ellipse
                    {
                        Width  = PointRadius * 2,
                        Height = PointRadius * 2,
                        Fill   = Stroke,
                        Stroke = new SolidColorBrush {
                            Color = Chart.PointHoverColor
                        },
                        StrokeThickness = 2,
                        ClipToBounds    = true
                    };
                    var r = new Rectangle
                    {
                        Fill            = Brushes.Transparent,
                        Width           = 40,
                        Height          = 40,
                        StrokeThickness = 0
                    };

                    r.MouseEnter += Chart.DataMouseEnter;
                    r.MouseLeave += Chart.DataMouseLeave;

                    Canvas.SetLeft(r, ToPlotArea(point.X, AxisTags.X) - r.Width / 2);
                    Canvas.SetTop(r, ToPlotArea(point.Y, AxisTags.Y) - r.Height / 2);
                    Panel.SetZIndex(r, int.MaxValue);
                    Canvas.SetLeft(e, plotPoint.X - e.Width * .5);
                    Canvas.SetTop(e, plotPoint.Y - e.Height * .5);

                    Chart.Canvas.Children.Add(r);
                    Chart.Canvas.Children.Add(e);

                    s.Add(e);
                    hoverableAreas.Add(new HoverableShape
                    {
                        Series = this,
                        Shape  = r,
                        Value  = point,
                        Target = e
                    });
                }
            }
            Shapes.AddRange(s);
            Chart.HoverableShapes.AddRange(hoverableAreas);
        }
Esempio n. 17
0
        public override void Create()
        {
            /*foreach (Node n in Children)
             * {
             *  Shapes.AddRange(n.Shapes.Select(a => a.Copy()));
             * }
             * return;*/

            if (Is3d)
            {
            }
            else
            {
                Shapes.AddRange(Children[0].Shapes.Select(a => a.Copy()));

                Shapes[0].Convexes[0].Faces[0].Split(Shapes[0].Convexes[0].Edges[1], 0.3, Shapes[0].Convexes[0].Edges[3], 0.25);
                Shapes[0].Convexes[0].Faces[0].IntegrityCheck();
                Shapes[0].Convexes[0].Faces[1].IntegrityCheck();
                double   closestdist, closestu, closestv;
                Point3D  raystart           = new Point3D(0, 0, 0);
                Vector3D raydir             = new Vector3D(5, 1, 0);
                MathUtils.RayLineResult res = MathUtils.ClosestPointRayLine(out closestdist, out closestu, out closestv, raystart, raydir, Shapes[0].Convexes[0].Edges[1].Vertices[0].Pos, Shapes[0].Convexes[0].Edges[1].Vertices[1].Pos);
                Scene.AddDebugLine(raystart - raydir * 10, raystart + raydir * 10);
                Scene.AddDebugCross(raystart + raydir * closestu, 0.5);
                Scene.AddDebugCross(Shapes[0].Convexes[0].Edges[1].Vertices[0].Pos + Shapes[0].Convexes[0].Edges[1].Offset * closestv, 0.5);

                //this'll be the clever algorithm. it takes advantage of the fact that we always maintain:
                //- for any given node, none of it's child convexes overlap
                //therefore:
                //- no node should test it's own convexes against each other


/*
 *
 *              //this is the simplest algorithm - we assume every convex could potentially overlap every other convex
 *              //and keep iterating until no more splits occur. it works, but involves a lot of unnecessary overlap tests
 *              Convexes = new List<Convex>();
 *              foreach (Node n in Children)
 *                  Convexes.AddRange(n.Convexes.Select(a => a.Copy()));
 *
 *              //draw all initial convexes if this is the current stage
 *              if (!CSGScene.NextStage("Begin union"))
 *              {
 *                  foreach (Convex c in Convexes)
 *                      c.DebugDraw();
 *                  return;
 *              }
 *
 *              //now do the iterative splitting
 *              //loop until no splits done
 *              bool done_split = true;
 *              while (done_split)
 *              {
 *                  //spin over every convex
 *                  done_split = false;
 *                  for (int i = 0; i < Convexes.Count; i++)
 *                  {
 *                      //go over every other convex
 *                      for (int j = i + 1; j < Convexes.Count; j++)
 *                      {
 *                          //get the 2 convexes to compare
 *                          Convex acvx = Convexes[i];
 *                          Convex bcvx = Convexes[j];
 *
 *                          //do a clip test
 *                          List<Convex> otherconvexsplit = new List<Convex>();
 *                          Convex overlap = null;
 *                          if (Convex.CalculateClippedConvexes2d(acvx, bcvx, otherconvexsplit, ref overlap))
 *                          {
 *                              //got a split, so remove the convex that was split (cvx a), and re-add the sections
 *                              //that didn't overlap
 *                              Convexes.RemoveAt(i);
 *                              Convexes.AddRange(otherconvexsplit);
 *                              done_split = true;
 *
 *                              //if last stage, draw the convex we were splitting and then bail
 *                              if (!CSGScene.NextStage("Done a split"))
 *                              {
 *                                  return;
 *                              }
 *                              break;
 *                          }
 *                      }
 *
 *                      //break out (so we iterate round again) if a split happened
 *                      if (done_split)
 *                          break;
 *                  }
 *              }*/
            }
        }