private void OnTimerTick(object sender, ElapsedEventArgs e)
        {
            lock (_timer)
            {
                Random r = new Random();

                // First load, fill with some random values
                if (_xyzData.Count == 0)
                {
                    for (int i = 0; i < _pointCount; i++)
                    {
                        double x = DataManager.Instance.GetGaussianRandomNumber(50, 15);
                        double y = DataManager.Instance.GetGaussianRandomNumber(50, 15);
                        double z = DataManager.Instance.GetGaussianRandomNumber(50, 15);

                        _xyzData.Append(x, y, z);
                    }

                    return;
                }

                // Subsequent load, update point positions using a sort of brownian motion by using random
                // numbers between -0.5, +0.5
                using (_xyzData.SuspendUpdates())
                {
                    for (int i = 0; i < _xyzData.Count; i++)
                    {
                        double currentX = _xyzData.XValues[i];
                        double currentY = _xyzData.YValues[i];
                        double currentZ = _xyzData.ZValues[i];

                        currentX += r.NextDouble() - 0.5;
                        currentY += r.NextDouble() - 0.5;
                        currentZ += r.NextDouble() - 0.5;

                        _xyzData.Update(i, currentX, currentY, currentZ);
                    }
                }
            }
        }
コード例 #2
0
        private void SurfaceMouseUp(object sender, MouseButtonEventArgs e)
        {
            if (positionInfo.Count < 1)
            {
                return;
            }

            // using SciChart.Charting3D.RenderableSeries
            HitTestInfo3D hitVertex2 = backgroundSurfaceMesh.HitTest(e.GetPosition(sciChart));
            HitTestInfo3D hitVertex  = surfaceMeshRenderableSeries.HitTest(e.GetPosition(sciChart));
            var           xyzInfo2   = backgroundSurfaceMesh.ToSeriesInfo(hitVertex2);
            var           xyzInfo    = surfaceMeshRenderableSeries.ToSeriesInfo(hitVertex);



            if (IsHitPointValid(hitVertex) && !drawInfo.IsNullOrEmptyList())
            {
                if (movePoint && selectedIdx > -1)
                {
                    int idx = sciChart.Viewport3D.RootEntity.Children.Count; // sciChart.Viewport3D.RootEntity.Children.Count?

                    if (positionInfo[selectedIdx / 2].points[0].y > positionInfo[selectedIdx / 2].points[1].y)
                    {
                        marker.Update(selectedIdx, xyzInfo.HitVertex.X, positionInfo[selectedIdx / 2].points[0].y + 25, xyzInfo.HitVertex.Z);
                    }
                    else
                    {
                        marker.Update(selectedIdx, xyzInfo.HitVertex.X, positionInfo[selectedIdx / 2].points[1].y + 25, xyzInfo.HitVertex.Z);
                    }

                    Coords tt = positionInfo[selectedIdx / 2].points[selectedIdx % 2];
                    tt.x = xyzInfo.HitVertex.X;
                    tt.y = xyzInfo.HitVertex.Y;
                    tt.z = xyzInfo.HitVertex.Z;

                    positionInfo[selectedIdx / 2].points[selectedIdx % 2] = tt;
                    tt = ConvertCoordToVec(tt);

                    if (selectedIdx % 2 == 0)
                    {
                        drawInfo[selectedIdx / 2].firstPos.X = tt.x;
                        drawInfo[selectedIdx / 2].firstPos.Y = tt.y;
                        drawInfo[selectedIdx / 2].firstPos.Z = tt.z;
                    }
                    else
                    {
                        drawInfo[selectedIdx / 2].secondPos.X = tt.x;
                        drawInfo[selectedIdx / 2].secondPos.Y = tt.y;
                        drawInfo[selectedIdx / 2].secondPos.Z = tt.z;
                    }

                    drawInfo[selectedIdx / 2].Update();

                    movePoint   = false;
                    selectedIdx = -1;
                }
            }

            //if (drawInfo.Count > 0)
            //{
            //    MessageBox.Show(e.GetPosition(sciChart).X.ToString() + ", " + e.GetPosition(sciChart).Y.ToString());
            //    SciChart.Charting3D.Primitives.HeightMapIndex t = new SciChart.Charting3D.Primitives.HeightMapIndex();
            //    t.XIndex = 647;
            //    t.ZIndex = 375;
            //    hitVertex.EntityId = 7;
            //    hitVertex.IjIndices = t;
            //    hitVertex.IsHit = true;
            //    hitVertex.VertexId = 0;
            //
            //    //var tt = surfaceMeshRenderableSeries.HitTest(new Point(647, 375));
            //    var tt = surfaceMeshRenderableSeries.ToSeriesInfo(hitVertex);
            //}

            if (IsHitPointValid(hitVertex) && positionInfo[annotIdx].checkShape != CheckShape.None)
            {
                PositionInfo temp = positionInfo[annotIdx];

                temp.points.Add(new Coords(xyzInfo.HitVertex.X, xyzInfo.HitVertex.Y, xyzInfo.HitVertex.Z));

                // 마우스 따라가는 거 필요함

                if (temp.points.Count == 2 && temp.checkShape != CheckShape.Circle_3P)
                {
                    PositionEventArgs args = new PositionEventArgs();

                    switch (temp.checkShape)
                    {
                    case CheckShape.Line:
                        Coords[] LineCoords = { temp.points[0], temp.points[1] };
                        temp.length   = GetLength();
                        LineCoords[0] = ConvertCoordToVec(temp.points[0]);
                        LineCoords[1] = ConvertCoordToVec(temp.points[1]);
                        drawInfo.Add(new DrawGeometry(new Vector3(LineCoords[0].x, LineCoords[0].y, LineCoords[0].z), new Vector3(LineCoords[1].x, LineCoords[1].y, LineCoords[1].z), Color.FromArgb(128, 0, 0, 255), CheckShape.Line));
                        sciChart.Viewport3D.RootEntity.Children.Add(drawInfo[annotIdx]);
                        AddMarker(temp);
                        args.Data = temp;
                        OnMeasureData(args);
                        break;

                    case CheckShape.Rect:
                        Coords[] rectCoords = { temp.points[0], temp.points[1] };
                        temp.width    = GetWidth();
                        temp.height   = GetHeight();
                        rectCoords[0] = ConvertCoordToVec(temp.points[0]);
                        rectCoords[1] = ConvertCoordToVec(temp.points[1]);
                        drawInfo.Add(new DrawGeometry(new Vector3(rectCoords[0].x, rectCoords[0].y, rectCoords[0].z), new Vector3(rectCoords[1].x, rectCoords[1].y, rectCoords[1].z), Color.FromArgb(128, 255, 0, 0), CheckShape.Rect));
                        sciChart.Viewport3D.RootEntity.Children.Add(drawInfo[annotIdx]);
                        AddMarker(temp);
                        args.Data = temp;
                        OnMeasureData(args);
                        break;

                    case CheckShape.Circle_2P:
                        Coords[] circleCoords = { temp.points[0], temp.points[1] };
                        temp.radius     = GetRadius2P();
                        circleCoords[0] = ConvertCoordToVec(temp.points[0]);
                        circleCoords[1] = ConvertCoordToVec(temp.points[1]);
                        drawInfo.Add(new DrawGeometry(new Vector3(circleCoords[0].x, circleCoords[0].y, circleCoords[0].z), new Vector3(circleCoords[1].x, circleCoords[1].y, circleCoords[1].z), Color.FromArgb(255, 255, 0, 0), CheckShape.Circle_2P));
                        sciChart.Viewport3D.RootEntity.Children.Add(drawInfo[annotIdx]);
                        break;

                    default:
                        break;
                    }
                }
                else if (temp.points.Count == 3)
                {
                    double[] ret = GetRadiusCenter3P();

                    temp.centerPoints.x = (float)ret[0];
                    temp.centerPoints.y = xyzInfo.HitVertex.Y;
                    temp.centerPoints.z = (float)ret[1];
                    temp.radius         = ret[2];
                }

                positionInfo[annotIdx] = temp;
            }
        }