예제 #1
0
 public void AddPoint(LinePoint data)
 {
     m_points.Add(data);
     SetVerticesDirty();
 }
예제 #2
0
        /// <summary>
        ///     Gets the line selected at the locaiton given.
        /// </summary>
        private SelectedLine GetSelected(Vector2 rawLocation, float tolerance, out LinePoint loc)
        {
            Matrix3x2 viewMatrix = View.ViewMatrix;

            bool         checkNext = false;
            SelectedLine last      = null;
            LinePoint    lastHit   = null;

            // Check each line for each edge part for each tile
            foreach (TileBase tile in Tiles)
            {
                foreach (EdgePartShape partShape in tile.PartShapes)
                {
                    Matrix3x2 transform =
                        partShape.GetLineTransform()
                        * tile.Transform
                        * viewMatrix;

                    foreach (ILine line in partShape.Lines)
                    {
                        LinePoint hit = line.HitTest(rawLocation, tolerance, transform);
                        if (hit != null)
                        {
                            if (checkNext)
                            {
                                if (hit.Distance > 0)
                                {
                                    loc = hit;
                                    return(new SelectedLine(tile, partShape, line, transform));
                                }

                                loc = lastHit;
                                return(last);
                            }

                            // If the hit was just at/past the end of the line, check to see if it was in the next line
                            if (hit.Distance >= 1)
                            {
                                lastHit   = hit;
                                last      = new SelectedLine(tile, partShape, line, transform);
                                checkNext = true;
                                continue;
                            }

                            loc = hit;
                            return(new SelectedLine(tile, partShape, line, transform));
                        }

                        if (checkNext)
                        {
                            loc = lastHit;
                            return(last);
                        }
                    }
                }
            }

            if (checkNext)
            {
                loc = lastHit;
                return(last);
            }

            loc = null;
            return(null);
        }
예제 #3
0
 public void SetPointInfo(int index, LinePoint data)
 {
     m_points[index] = data;
     SetVerticesDirty();
 }
예제 #4
0
        private void ChartToCreate(String item)
        {
            List <String[]> originalData = ChartData();

            String[] dataPicker = new String[originalData.Count];

            for (int i = 0; i < originalData.Count; i++)
            {
                dataPicker[i] = originalData[i][1];
            }
            _customChart.ChartView.Chart.Series.RemoveAllSeries();

            var imageButton = ((((this.Children[0] as ContentPage).Content as ScrollView).Content as StackLayout).Children[1] as Grid).Children[2] as Button;

            switch (item)
            {
            case "AREA":
                Area area = new Area();
                area.FillSampleValues(3);
                _customChart.ChartView.Chart.Series.Add(area);
                _customChart.ImageSource = dataPicker[0];
                imageButton.Image        = dataPicker[0];

                break;

                    #if !TEE_STD
            case "ARROW":
                Arrow arrow = new Arrow();
                arrow.FillSampleValues(10);
                _customChart.ChartView.Chart.Series.Add(arrow);
                _customChart.ImageSource = dataPicker[1];
                imageButton.Image        = dataPicker[1];
                break;
#endif

            case "BAR":
                Bar bar = new Bar();
                bar.FillSampleValues(4);
                _customChart.ChartView.Chart.Series.Add(bar);
                _customChart.ImageSource = dataPicker[2];
                imageButton.Image        = dataPicker[2];
                break;

                    #if !TEE_STD
            case "BARJOIN":
                BarJoin barjoin = new BarJoin();
                barjoin.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(barjoin);
                _customChart.ImageSource = dataPicker[3];
                imageButton.Image        = dataPicker[3];
                break;

            case "BEZIER":
                Bezier bezier = new Bezier();
                bezier.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(bezier);
                _customChart.ImageSource = dataPicker[4];
                imageButton.Image        = dataPicker[4];
                break;

            case "BOX":
                Box box = new Box();
                box.FillSampleValues(3);
                _customChart.ChartView.Chart.Series.Add(box);
                _customChart.ImageSource = dataPicker[5];
                imageButton.Image        = dataPicker[5];
                break;
#endif
            case "BUBBLES":
                Bubble bubble = new Bubble();
                bubble.FillSampleValues(7);
                _customChart.ChartView.Chart.Series.Add(bubble);
                _customChart.ImageSource = dataPicker[6];
                imageButton.Image        = dataPicker[6];
                break;

                    #if !TEE_STD
            case "CANDLE":
                Candle candle = new Candle();
                candle.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(candle);
                _customChart.ImageSource = dataPicker[7];
                imageButton.Image        = dataPicker[7];
                break;

            case "CONTOUR":
                Contour countour = new Contour();
                countour.FillSampleValues(1);
                _customChart.ChartView.Chart.Series.Add(countour);
                _customChart.ImageSource = dataPicker[8];
                imageButton.Image        = dataPicker[8];
                break;

            case "DARVAS":
                Darvas darvas = new Darvas();
                darvas.FillSampleValues(3);
                _customChart.ChartView.Chart.Series.Add(darvas);
                _customChart.ImageSource = dataPicker[9];
                imageButton.Image        = dataPicker[9];
                break;
#endif
            case "DONUT":
                Donut donut = new Donut();
                donut.FillSampleValues(1);
                _customChart.ChartView.Chart.Series.Add(donut);
                _customChart.ImageSource = dataPicker[10];
                imageButton.Image        = dataPicker[10];
                break;

                    #if !TEE_STD
            case "ERROR":
                Error error = new Error();
                error.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(error);
                _customChart.ImageSource = dataPicker[11];
                imageButton.Image        = dataPicker[11];
                break;

            case "ERRORBAR":
                ErrorBar errorbar = new ErrorBar();
                errorbar.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(errorbar);
                _customChart.ImageSource = dataPicker[12];
                imageButton.Image        = dataPicker[12];
                break;

            case "ERRORPOINT":
                ErrorPoint errorPoint = new ErrorPoint();
                errorPoint.FillSampleValues(7);
                _customChart.ChartView.Chart.Series.Add(errorPoint);
                _customChart.ImageSource = dataPicker[13];
                imageButton.Image        = dataPicker[13];
                break;
#endif
            case "FASTLINE":
                FastLine fastLine = new FastLine();
                fastLine.FillSampleValues(2);
                _customChart.ChartView.Chart.Series.Add(fastLine);
                _customChart.ImageSource = dataPicker[14];
                imageButton.Image        = dataPicker[14];
                break;

                    #if !TEE_STD
            case "HIGHLOW":
                HighLow highLow = new HighLow();
                highLow.FillSampleValues(4);
                _customChart.ChartView.Chart.Series.Add(highLow);
                _customChart.ImageSource = dataPicker[15];
                imageButton.Image        = dataPicker[15];
                break;

            case "HISTOGRAM":
                Histogram histogram = new Histogram();
                histogram.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(histogram);
                _customChart.ImageSource = dataPicker[16];
                imageButton.Image        = dataPicker[16];
                break;
#endif
            case "HORIZAREA":
                HorizArea horizArea = new HorizArea();
                horizArea.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(horizArea);
                _customChart.ImageSource = dataPicker[17];
                imageButton.Image        = dataPicker[17];
                break;

            case "HORIZBAR":
                HorizBar horizBar = new HorizBar();
                horizBar.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(horizBar);
                _customChart.ImageSource = dataPicker[18];
                imageButton.Image        = dataPicker[18];
                break;

            case "HORIZLINE":
                HorizLine horizLine = new HorizLine();
                horizLine.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(horizLine);
                _customChart.ImageSource = dataPicker[19];
                imageButton.Image        = dataPicker[19];
                break;

                    #if !TEE_STD
            case "ISOSURFACE":
                IsoSurface isoSurface = new IsoSurface();
                isoSurface.FillSampleValues(10);
                _customChart.ChartView.Chart.Series.Add(isoSurface);
                _customChart.ImageSource = dataPicker[20];
                imageButton.Image        = dataPicker[20];
                break;
#endif
            case "LINE":
                Line line = new Line();
                line.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(line);
                _customChart.ImageSource = dataPicker[21];
                imageButton.Image        = dataPicker[21];
                break;

#if !TEE_STD
            case "LINEPOINT":
                LinePoint linePoint = new LinePoint();
                linePoint.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(linePoint);
                _customChart.ImageSource = dataPicker[22];
                imageButton.Image        = dataPicker[22];
                break;
#endif
            case "PIE":
                Pie pie = new Pie();
                pie.FillSampleValues(4);
                _customChart.ChartView.Chart.Series.Add(pie);
                _customChart.ImageSource = dataPicker[23];
                imageButton.Image        = dataPicker[23];
                break;

#if !TEE_STD
            case "SURFACE":
                Surface surface = new Surface();
                surface.FillSampleValues(10);
                //surface.
                _customChart.ChartView.Chart.Series.Add(surface);
                _customChart.ImageSource = dataPicker[24];
                imageButton.Image        = dataPicker[24];
                break;

            case "TOWER":
                Tower tower = new Tower();
                tower.FillSampleValues(8);
                _customChart.ChartView.Chart.Series.Add(tower);
                _customChart.ImageSource = dataPicker[25];
                imageButton.Image        = dataPicker[25];
                break;

            case "VOLUME":
                Volume volume = new Volume();
                volume.FillSampleValues(9);
                _customChart.ChartView.Chart.Series.Add(volume);
                _customChart.ImageSource = dataPicker[26];
                imageButton.Image        = dataPicker[26];
                break;
#endif
            }

            _customChart.ChartView.Chart.Axes.Left.Automatic   = true;
            _customChart.ChartView.Chart.Axes.Bottom.Automatic = true;
        }
예제 #5
0
        private void DrawCurve()
        {
            HHDevice device = comboBoxEdit2.SelectedItem as HHDevice;

            HHDeviceProperty devProp = comboBoxEdit1.SelectedItem as HHDeviceProperty;
            DateTime         timeSel = DateTime.Now;

            if (comboBoxEdit3.SelectedIndex >= 0)
            {
                timeSel = (DateTime)comboBoxEdit3.SelectedItem;
            }



            HHDeviceProperty devBindProp = device.GetProperty(devProp);


            List <DevCurve> curves = devBindProp.Curves;

            UltraChart.CurveGroup grp = chart.GroupList[0];
            grp.ClearChartObject();

            LineArea area = new LineArea(chart, "道岔曲线", true);

            area.IsShowFoldFlag   = false;
            area.IsFold           = false;
            area.YAxes.Mode       = YAxesMode.Manual;
            area.YAxes.YAxesMin   = curves[0].ADMin;
            area.YAxes.YAxesMax   = curves[0].ADMax;
            area.YAxes.Precision  = 3;
            area.YAxes.UnitString = "";
            grp.AddChartObject(area);
            grp.XAxes.SetOrgTime(ChartGraph.DateTime2ChartTime(timeSel), 0);
            chart.AutoSetXScale();


            List <StationCurve> listCurve = DataStorage.DatabaseModule.GetInstance().QueryCurveHistory(curves[0].Group.Type, curves[0].Index, timeSel);


            string[][] curveNames = new string[][] {
                new string[] { "曲线" },
                new string[] { "曲线1", "曲线2" },
                new string[] { "A相", "B相", "C相" },
            };

            for (int i = 0; i < curves.Count; i++)
            {
                LineCurve line = new LineCurve(chart, curveNames[curves.Count - 1][i], 0);
                line.LineColor = ColorList[i % ColorList.Length];
                area.AddLine(line);
                if (listCurve != null && listCurve.Count > 0 && listCurve[i] != null)
                {
                    for (int j = 0; j < listCurve[i].Points.Length; j++)
                    {
                        DateTime  time  = timeSel.AddMilliseconds(curves[i].TimeInterval * j); //40毫秒
                        LinePoint point = new LinePoint();
                        point.Value = listCurve[i].Points[j];
                        point.Time  = ChartGraph.DateTime2ChartTime(time);
                        line.AddPoint(point);
                    }
                }
            }
            chart.AutoSetXScale();
            chart.Draw();
        }
예제 #6
0
 Vector2 EvaluatePoint(LinePoint p0, LinePoint p1, float t)
 {
     //t = t * t;//보정...
     if(p0.isNextCurve && !p1.isPrvCurve)
     {
         return Curve.CalculateBezier(p0.point, p1.point, p0.nextCurvePoint, t);
     }
     if(!p0.isNextCurve && p1.isPrvCurve)
     {
         return Curve.CalculateBezier(p0.point, p1.point, p1.prvCurvePoint, t);
     }
     if(p0.isNextCurve && p1.isPrvCurve)
     {
         return Curve.CalculateBezier(p0.point, p1.point, p0.nextCurvePoint, p1.prvCurvePoint, t);
     }
     //직선의 경우.
     return Vector2.Lerp(p0.point, p1.point, t);
 }
 private void SetLinePointToGlobalPosition(LinePoint lp, Vector3 pos)
 {
     lp.point = pos - transform.position;
 }
예제 #8
0
                /// <summary>
                ///     Updates the location of the action.
                /// </summary>
                /// <param name="rawLocation">
                ///     The raw location that the action has been dragged to.
                ///     Should be transformed by the <see cref="IView.InverseViewMatrix" /> for the
                ///     <see cref="EscherTiler.Controllers.Controller.View" /> to get the location in 1the tiling itself.
                /// </param>
                public override void Update(Vector2 rawLocation)
                {
                    LinePoint hit = _line.Line.HitTest(rawLocation, float.PositiveInfinity, _line.LineTransform);
                    Debug.Assert(hit != null, "hit != null");

                    if (hit.Distance < 0)
                        _point = new LinePoint(Vector2.Transform(_line.Line.Start, _line.LineTransform), 0);
                    else if (hit.Distance > 1)
                        _point = new LinePoint(Vector2.Transform(_line.Line.End, _line.LineTransform), 1);
                    else _point = hit;

                    _tool.SetSplitLineLoc(_line, _point);
                }
예제 #9
0
 public PathSegment(LinePoint head, LinePoint tail) {
    Head = head;
    Tail = tail;
 }
예제 #10
0
            /// <summary>
            ///     Sets the location that the line will be split along, for drwaing the preview.
            /// </summary>
            /// <param name="line">The line.</param>
            /// <param name="point">The point.</param>
            private void SetSplitLineLoc(SelectedLine line, LinePoint point)
            {
                Vector2 tangent = Vector2.Normalize(line.Line.GetTangent(point.Distance, line.LineTransform)) * 3;

                Vector2 pos = Vector2.Transform(point.Position, Controller.View.InverseViewMatrix);

                _splitLineStart = pos + new Vector2(tangent.Y, -tangent.X);
                _splitLineEnd = pos + new Vector2(-tangent.Y, tangent.X);
            }
예제 #11
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="SplitLineAction" /> class.
 /// </summary>
 /// <param name="line">The line.</param>
 /// <param name="point">The point.</param>
 /// <param name="tool">The tool.</param>
 public SplitLineAction(SelectedLine line, LinePoint point, [NotNull] SplitLineTool tool)
 {
     Debug.Assert(line != null, "line != null");
     Debug.Assert(point != null, "point != null");
     Debug.Assert(tool != null, "tool != null");
     _line = line;
     _point = point;
     _tool = tool;
 }
예제 #12
0
        /// <summary>
        ///     Gets the line selected at the locaiton given.
        /// </summary>
        private SelectedLine GetSelected(Vector2 rawLocation, float tolerance, out LinePoint loc)
        {
            Matrix3x2 viewMatrix = View.ViewMatrix;

            bool checkNext = false;
            SelectedLine last = null;
            LinePoint lastHit = null;

            // Check each line for each edge part for each tile
            foreach (TileBase tile in Tiles)
            {
                foreach (EdgePartShape partShape in tile.PartShapes)
                {
                    Matrix3x2 transform =
                        partShape.GetLineTransform()
                        * tile.Transform
                        * viewMatrix;

                    foreach (ILine line in partShape.Lines)
                    {
                        LinePoint hit = line.HitTest(rawLocation, tolerance, transform);
                        if (hit != null)
                        {
                            if (checkNext)
                            {
                                if (hit.Distance > 0)
                                {
                                    loc = hit;
                                    return new SelectedLine(tile, partShape, line, transform);
                                }

                                loc = lastHit;
                                return last;
                            }

                            // If the hit was just at/past the end of the line, check to see if it was in the next line
                            if (hit.Distance >= 1)
                            {
                                lastHit = hit;
                                last = new SelectedLine(tile, partShape, line, transform);
                                checkNext = true;
                                continue;
                            }

                            loc = hit;
                            return new SelectedLine(tile, partShape, line, transform);
                        }

                        if (checkNext)
                        {
                            loc = lastHit;
                            return last;
                        }
                    }
                }
            }

            if (checkNext)
            {
                loc = lastHit;
                return last;
            }

            loc = null;
            return null;
        }
예제 #13
0
 public void SetPointColor(LinePoint item, Color color)
 {
     Points.Find(x => x == item).color = color;
     SetAllDirty();
 }
예제 #14
0
 public void AddPoints(LinePoint item)
 {
     Points.Add(item);
     SetAllDirty();
 }
예제 #15
0
        public async Task <DashboardsDTO> All()
        {
            var rentsPerEmployee = await _context.Employee
                                   .Select(employee => new PieData
            {
                Id    = $"{employee.User.FirstName} {employee.User.MiddleName} {employee.User.LastName}",
                Value = employee.Rents.Where(rent => rent.From > (DateTime.Now - TimeSpan.FromDays(360))).Count()
            })
                                   .Where(x => x.Value > 0)
                                   .ToArrayAsync();

            var rentsPerEquipmentType = await _context.EquipmentType
                                        .Select(type => new PieData
            {
                Id    = type.Name,
                Value = _context.RentEquipment
                        .Where(req => req.Rent.From > (DateTime.Now - TimeSpan.FromDays(360)))
                        .Where(req => req.Equipment.EquipmentTypeId == type.Id)
                        .Count()
            })
                                        .Where(x => x.Value > 0)
                                        .ToArrayAsync();

            var shops = await _context.Shop.Include(x => x.Rents).ToListAsync();

            var rentsPerShop = shops
                               .Select(shop => new LineData
            {
                Id   = shop.Name,
                Data = shop.Rents.GroupBy(x => x.From.Month).Select(x => new LinePoint
                {
                    X = x.Key,
                    Y = x.Count()
                }).ToArray()
            })
                               .ToArray();

            var rentsPerShopMonthly = rentsPerShop.Select(line =>
            {
                var data = new LinePoint[12];
                for (int i = 0; i < 12; i++)
                {
                    data[i] = new LinePoint
                    {
                        X = i + 1
                    };
                }

                foreach (var point in line.Data)
                {
                    data[point.X - 1].Y = point.Y;
                }
                return(new LineData
                {
                    Id = line.Id,
                    Data = data
                });
            }).ToArray();

            return(new DashboardsDTO
            {
                RentsPerEmployee = rentsPerEmployee,
                RentsPerEquipmentType = rentsPerEquipmentType,
                RentsPerShop = rentsPerShopMonthly
            });
        }
예제 #16
0
 public void MoveTo(double x, double y) {
    pathHead = new LinePoint(new Point2D(x, y), lineStyleColor, lineStyleThickness, true);
 }
예제 #17
0
	private int ColorFunction(LinePoint point)
	{
		if (point == -1) return 16;

		return point.GetColor(2) * 4 + point.GetColor(16) / 4;
	}
예제 #18
0
 public void LineTo(double x, double y) {
    var pathTail = new LinePoint(new Point2D(x, y), lineStyleColor, lineStyleThickness, false);
    pathSegments.Add(new PathSegment(pathHead, pathTail));
    pathHead = pathTail;
 }
예제 #19
0
 Vector2 GetDerivative(LinePoint p0, LinePoint p1, float t)
 {
     if(p0.isNextCurve || p1.isPrvCurve)
     {
         float oneMinusT = 1f - t;
         return
             3f * oneMinusT * oneMinusT * (p0.nextCurvePoint - p0.point) +
             6f * oneMinusT * t * (p1.prvCurvePoint - p0.nextCurvePoint) +
             3f * t * t * (p1.point - p1.prvCurvePoint);
     }
     return (p1.point - p0.point).normalized;
 }
예제 #20
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        private void button1_Click(object sender, EventArgs e) {
            mTemperatureLines.Clear();
            ResultsText.Clear();

            chrTemperatureDistr.Series.Clear();
            chrSahaBoltzmanPlot.Series.Clear();

            int measurementNum = 0;
            foreach (var measurement in MainWindow.mExperiments) {
                if (measurement.mSpectra.Count == 0) {
                    continue;
                }

                var line = new List<TemperaturePoint>();
                mTemperatureLines.Add(line);

                string name = "Measurement " + measurementNum;


                chrTemperatureDistr.Series.Add(name);
                chrTemperatureDistr.Series[name].ChartType = SeriesChartType.FastLine;

                ResultsText.Text += "Measurement " + measurementNum + Environment.NewLine;
                int spectrumNumber = 0;
                foreach (var spec in measurement.mSpectra) {
                    // get points in coordinates of [ E; ln(I/A*g) ]
                    var points = GetLogPoints(spec);

                    // plot points on Saha-Boltzman plane
                    var distributionName = "Distribution " + spectrumNumber;
                    LinePoint minPoint = points[0], maxPoint = points[0];
                    chrSahaBoltzmanPlot.Series.Add(distributionName);
                    StreamWriter of = new StreamWriter(distributionName + ".bdp");
                    foreach (var p in points) {
                        chrSahaBoltzmanPlot.Series[distributionName].Points.AddXY(Math.Round(p.mX,2), Math.Round(p.mY,2));
                        chrSahaBoltzmanPlot.Series[distributionName].ChartType = SeriesChartType.Point;
                        of.WriteLine("P\t" + p.mX + "\t" + p.mY);
                        if (p.mX > maxPoint.mX) {
                            maxPoint = p;
                        }
                        if (p.mX < minPoint.mX) {
                            minPoint = p;
                        }
                    }
                    of.Close();

                    // do linear approximation to get slope from points, for further temperature calculation
                    double a = 0.0f;
                    double b = 0.0f;
                    LinearApproximation(points, ref a, ref b);
                    double slope = ComputeSlope(a, b);

                    // plot approximation
                    var approxName = "Approximation " + spectrumNumber;
                    chrSahaBoltzmanPlot.Series.Add(approxName);
                    chrSahaBoltzmanPlot.Series[approxName].Points.AddXY(Math.Round(minPoint.mX, 2), Math.Round(a * minPoint.mX + b, 2));
                    chrSahaBoltzmanPlot.Series[approxName].Points.AddXY(Math.Round(maxPoint.mX,2), Math.Round(a * maxPoint.mX + b, 2));
                    chrSahaBoltzmanPlot.Series[approxName].ChartType = SeriesChartType.FastLine;

                    // calculate temperature using line slope
                    double temperature = ComputeTemperature(slope);

                    ResultsText.Text += "T: " + Math.Round(temperature, 2) + "; S: " + Math.Round(slope, 2) + Environment.NewLine;
                    line.Add(new TemperaturePoint(temperature, a, b, slope, spec.mIntegrationDelayMicroSec));

                    chrTemperatureDistr.Series[name].Points.AddXY(Math.Round(spec.mIntegrationDelayMicroSec, 1), temperature);

                    ++spectrumNumber;
                }

                ++measurementNum;
            }
        }