void OnDragPlaneChanged(object sender, EventArgs e)
        {
            List <NVector3DD> intersections3D = m_SurfaceSeries.Get3DIntersections(new NPointD(m_DragPlane.PointA.X, m_DragPlane.PointA.Z), new NPointD(m_DragPlane.PointB.X, m_DragPlane.PointB.Z));
            List <NVector2DD> intersections2D = m_SurfaceSeries.Get2DIntersections(new NPointD(m_DragPlane.PointA.X, m_DragPlane.PointA.Z), new NPointD(m_DragPlane.PointB.X, m_DragPlane.PointB.Z));

            m_CrossSection3DSeries.ClearDataPoints();

            for (int i = 0; i < intersections3D.Count; i++)
            {
                NVector3DD intersection3D = intersections3D[i];

                m_CrossSection3DSeries.Values.Add(intersection3D.Z + 1);
                m_CrossSection3DSeries.XValues.Add(intersection3D.X);
                m_CrossSection3DSeries.ZValues.Add(intersection3D.Y);
            }

            m_CrossSection2DSeries.ClearDataPoints();

            for (int i = 0; i < intersections2D.Count; i++)
            {
                NVector2DD intersection2D = intersections2D[i];

                m_CrossSection2DSeries.Values.Add(intersection2D.Y);
                m_CrossSection2DSeries.XValues.Add(intersection2D.X);
            }

            nChartControl1.Refresh();
        }
        void OnDataPointDragToolDataPointChanged(object sender, EventArgs e)
        {
            // copy the point values to the line series
            m_BeginEndLineSeries.Values.Clear();
            m_BeginEndLineSeries.XValues.Clear();

            for (int i = 0; i < m_BeginEndPointSeries.Values.Count; i++)
            {
                m_BeginEndLineSeries.Values.Add(m_BeginEndPointSeries.Values[i]);
                m_BeginEndLineSeries.XValues.Add(m_BeginEndPointSeries.XValues[i]);
            }

            List <NVector2DD> intersections = m_HeatMap.Get2DIntersections(new NPointD((double)m_BeginEndPointSeries.XValues[0], (double)m_BeginEndPointSeries.Values[0]),
                                                                           new NPointD((double)m_BeginEndPointSeries.XValues[1], (double)m_BeginEndPointSeries.Values[1]));

            int count = intersections.Count;

            m_CrossLineSeries.Values.Clear();
            m_CrossLineSeries.XValues.Clear();

            for (int i = 0; i < count; i++)
            {
                NVector2DD intersection = intersections[i];

                m_CrossLineSeries.Values.Add(intersection.Y);
                m_CrossLineSeries.XValues.Add(intersection.X);
            }

            nChartControl1.Refresh();
        }
예제 #3
0
        void nChartControl1_MouseMove(object sender, MouseEventArgs e)
        {
            NViewToScale2DTransformation view2Scale = new NViewToScale2DTransformation(nChartControl1.Charts[0], (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY);

            NVector2DD pointScale = new NVector2DD();

            view2Scale.Transform(new NPointF(e.X, e.Y), ref pointScale);

            this.ValueTextBox.Text = m_HeatMap.GetValueFromPosition(new NPointD(pointScale.X, pointScale.Y)).ToString();
        }
        protected void nChartControl2_AsyncCustomCommand(object sender, EventArgs e)
        {
            NCallbackCustomCommandArgs args = e as NCallbackCustomCommandArgs;

            switch (args.Command.Name)
            {
            case "displayDataWindow":
                double dataWindowWidth = double.Parse(args.Command.Arguments["width"] as string);

                NCartesianChart   zoomChart = nChartControl2.Charts[0] as NCartesianChart;
                NSmoothLineSeries zoomLine  = zoomChart.Series[0] as NSmoothLineSeries;

                NCartesianChart previewChart = nChartControl1.Charts[0] as NCartesianChart;
                NAxis           previewXAxis = previewChart.Axis(StandardAxis.PrimaryX);

                NPointF    ptViewPoint   = new NPointF(float.Parse(args.Command.Arguments["x"] as string), 0);
                NVector2DD vecScalePoint = new NVector2DD();

                using (NChartRasterView view = new NChartRasterView(nChartControl1.Document, nChartControl1.Dimensions, NResolution.ScreenResolution))
                {
                    view.RecalcLayout();

                    NViewToScale2DTransformation viewToScale = new NViewToScale2DTransformation(
                        view.Context,
                        previewChart,
                        (int)StandardAxis.PrimaryX,
                        (int)StandardAxis.PrimaryY
                        );

                    if (viewToScale.Transform(ptViewPoint, ref vecScalePoint))
                    {
                        double rangeMin = vecScalePoint.X - dataWindowWidth / 2;
                        rangeMin = previewXAxis.Scale.ViewRange.GetValueInRange(rangeMin);

                        double rangeMax = rangeMin + dataWindowWidth;
                        rangeMax = previewXAxis.Scale.ViewRange.GetValueInRange(rangeMax);

                        rangeMin = rangeMax - dataWindowWidth;

                        // reinitialize data points
                        zoomLine.XValues.Clear();
                        zoomLine.Values.Clear();
                        for (int i = (int)rangeMin; i <= (int)rangeMax; i++)
                        {
                            zoomLine.XValues.Add(i);
                            zoomLine.Values.Add(waveData[i]);
                        }
                    }
                }
                break;
            }
        }
예제 #5
0
            /// <summary>
            /// Overriden to perform dragging
            /// </summary>
            /// <param name=`$:7` ></param>
            /// <param name=`$:8` ></param>
            public override void OnDoDrag(object sender, NMouseEventArgs e)
            {
                NChart chart = this.GetDocument().Charts[0];
                NViewToScale2DTransformation viewToScale = new NViewToScale2DTransformation(this.GetChartControlView().Context, chart, (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY);

                NVector2DD pointScale = new NVector2DD();

                if (viewToScale.Transform(new NPointF(e.X, e.Y), ref pointScale))
                {
                    // clamp y value to ruler range
                    double yValue = chart.Axis(StandardAxis.PrimaryX).Scale.RulerRange.GetValueInRange(pointScale.X);
                    m_ConstLine.Value = yValue;

                    chart.Refresh();
                    Repaint();
                }
            }
            void UpdateDataWindow(string webControlId, System.Web.HttpContext context, NStateObject state, NPointF ptViewPoint)
            {
                NChartSessionStateObject chartState = state as NChartSessionStateObject;
                NRootPanel      rootPanel           = chartState.Document.RootPanel;
                NCartesianChart chart         = rootPanel.Charts[0] as NCartesianChart;
                NVector2DD      vecScalePoint = new NVector2DD();
                NAxis           xAxis         = chart.Axis(StandardAxis.PrimaryX);
                NAxis           yAxis         = chart.Axis(StandardAxis.PrimaryY);

                using (NChartRasterView view = new NChartRasterView(chartState.Document, chartState.Size, NResolution.ScreenResolution))
                {
                    view.RecalcLayout();

                    NViewToScale2DTransformation viewToScale = new NViewToScale2DTransformation(
                        view.Context,
                        chart,
                        (int)StandardAxis.PrimaryX,
                        (int)StandardAxis.PrimaryY
                        );

                    if (viewToScale.Transform(ptViewPoint, ref vecScalePoint))
                    {
                        double rangeMin = vecScalePoint.X - DataWindowWidth / 2;
                        rangeMin = xAxis.Scale.ViewRange.GetValueInRange(rangeMin);

                        double rangeMax = rangeMin + DataWindowWidth;
                        rangeMax = xAxis.Scale.ViewRange.GetValueInRange(rangeMax);

                        rangeMin = rangeMax - DataWindowWidth;

                        NRangeSelection selection = chart.RangeSelections[0] as NRangeSelection;
                        selection.HorizontalAxisRange = new NRange1DD(rangeMin, rangeMax);
                        selection.VerticalAxisRange   = new NRange1DD(-waveDataWave1Factor, waveDataWave1Factor);
                    }
                }
            }
        void OnChartControl1MouseMove(object sender, MouseEventArgs e)
        {
            nChartControl1.RecalcLayout();
            NViewToScale2DTransformation viewScale = new NViewToScale2DTransformation(nChartControl1.Charts[0], (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY);

            NVector2DD value = new NVector2DD();

            viewScale.Transform(new Nevron.GraphicsCore.NPointF(e.X, e.Y), ref value);

            m_XCursor.Value = value.X;
            m_YCursor.Value = value.Y;

            m_Point.Values.Clear();
            m_Point.XValues.Clear();
            m_Point.FillStyles.Clear();

            List <double> xIntersections = m_Line.IntersectWithXValue(value.X);

            for (int i = 0; i < xIntersections.Count; i++)
            {
                m_Point.XValues.Add(value.X);
                m_Point.Values.Add(xIntersections[i]);
                m_Point.FillStyles[m_Point.Values.Count - 1] = new NColorFillStyle(Color.Red);
            }

            List <double> yIntersections = m_Line.IntersectWithYValue(value.Y);

            for (int i = 0; i < yIntersections.Count; i++)
            {
                m_Point.Values.Add(value.Y);
                m_Point.XValues.Add(yIntersections[i]);
                m_Point.FillStyles[m_Point.Values.Count - 1] = new NColorFillStyle(Color.Blue);
            }

            nChartControl1.Refresh();
        }
        void FillData(NMeshSurfaceSeries surface)
        {
            int m = 200;
            int n = 100;

            int lastM = m - 1;
            int lastN = n - 1;

            double centerX = 0;
            double centerZ = 0;
            double centerY = 0;

            double radius1 = 100.0;
            double radius2 = 10.0;

            double beginAlpha = 0;
            double endAlpha   = NMath.PI2;
            double alphaStep  = 2 * NMath.PI2 / m;

            double beginBeta = 0;
            double endBeta   = NMath.PI2;
            double betaStep  = NMath.PI2 / n;

            NVector2DD[] arrPrecomputedData = new NVector2DD[m];

            for (int i = 0; i < m; i++)
            {
                // calculate the current angle, its cos and sin
                double alpha = (i == lastM) ? (endAlpha) : (beginAlpha + i * alphaStep);

                arrPrecomputedData[i].X = Math.Cos(alpha);
                arrPrecomputedData[i].Y = Math.Sin(alpha);
            }

            int vertexIndex = 0;

            surface.Data.SetGridSize(m, n);

            Color beginColor = Color.Red;
            Color endColor   = Color.Blue;

            float offset = -100;

            for (int j = 0; j < n; j++)
            {
                // calculate the current beta angle
                double beta     = (j == lastN) ? (endBeta) : (beginBeta + j * betaStep);
                double fCosBeta = (float)Math.Cos(beta);
                double fSinBeta = (float)Math.Sin(beta);

                offset = -100;

                for (int i = 0; i < m; i++)
                {
                    double fCosAlpha = arrPrecomputedData[i].X;
                    double fSinAlpha = arrPrecomputedData[i].Y;

                    double fx = fCosBeta * radius2 + radius1;

                    double dx = fx * fCosAlpha;
                    double dz = fx * fSinAlpha;
                    double dy = -(fSinBeta * radius2);

                    double x = centerX + dx;
                    double y = centerY + dy + offset;
                    double z = centerZ + dz;

                    offset++;

                    surface.Data.SetValue(i, j, y, x, z);

                    double length = Math.Sqrt(dx * dx + dz * dz + dy * dy);
                    surface.Data.SetColor(i, j, InterpolateColors(beginColor, endColor, (float)i / (float)100));                    //(length - (radius1 - radius2)) / radius2));

                    vertexIndex++;
                }
            }
        }