/// <summary>
        /// Gets the data point from the specified point
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        protected int GetDataPointIndexFromPoint(NPoint point)
        {
            NPointSeries pointSeries = m_DragPlane.PointSeries;
            NChart       chart       = pointSeries.Chart;
            NModel3DToViewTransformation model3DToViewTransformation = new NModel3DToViewTransformation(GetView().Context, chart.Projection);

            float xHotSpotArea = 10;
            float yHotSpotArea = 10;

            int dataPointIndex = -1;

            for (int i = 0; i < pointSeries.Values.Count; i++)
            {
                double x = (double)pointSeries.XValues[i];
                double y = (double)pointSeries.Values[i];
                double z = (double)pointSeries.ZValues[i];

                NVector3DF vecModelPoint;
                vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, x);
                vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, y);
                vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, z);

                NPointF viewPoint = NPointF.Empty;
                model3DToViewTransformation.Transform(vecModelPoint, ref viewPoint);

                if (Math.Abs(viewPoint.X - point.X) < xHotSpotArea &&
                    Math.Abs(viewPoint.Y - point.Y) < yHotSpotArea)
                {
                    dataPointIndex = i;
                    break;
                }
            }

            return(dataPointIndex);
        }
Esempio n. 2
0
            public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)
            {
                if (m_Parent.m_bUpdateWatermark == false)
                {
                    return;
                }

                // intercepts the on chart after paint event and converts
                // point or XYZ coordniates to chart viewport coordinates
                // used to position the custom watermark
                NChartControl chartControl = m_Parent.nChartControl1;
                NWatermark    watermark    = chartControl.Watermarks[0];
                NChart        chart        = m_Parent.nChartControl1.Charts[0];

                NPointF    viewPoint     = new NPointF();
                NVector3DF vecModelPoint = new NVector3DF();

                NModel3DToViewTransformation model3DToViewTransformation = new NModel3DToViewTransformation(chartControl.View.Context, chart.Projection);

                switch (m_Parent.WatermarkPositionComboBox.SelectedIndex)
                {
                case 0:
                    vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, (double)m_Parent.XPositionNumericUpDown.Value);
                    vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, (double)m_Parent.YPositionNumericUpDown.Value);
                    vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, (double)m_Parent.ZPositionNumericUpDown.Value);
                    break;

                case 1:
                    NVector3DF vecPoint = new NVector3DF();
                    int        nIndex   = (int)m_Parent.DataPointNumericUpDown.Value;

                    vecPoint.X = (float)(double)(m_Parent.m_Point.XValues[nIndex]);
                    vecPoint.Y = (float)(double)(m_Parent.m_Point.Values[nIndex]);
                    vecPoint.Z = (float)(double)(m_Parent.m_Point.ZValues[nIndex]);

                    vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, vecPoint.X);
                    vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, vecPoint.Y);
                    vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, vecPoint.Z);
                    break;
                }

                model3DToViewTransformation.Transform(vecModelPoint, ref viewPoint);

                // convert the view point to parent pixel coordinates
                watermark.TransformViewPointToParent(ref viewPoint);

                watermark.Location = new NPointL(
                    new NLength(viewPoint.X, NGraphicsUnit.Pixel),
                    new NLength(viewPoint.Y, NGraphicsUnit.Pixel));

                m_Parent.nChartControl1.RecalcLayout();
            }
Esempio n. 3
0
            /// <summary>
            /// Return true if dragging can start
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            /// <returns></returns>
            public override bool CanBeginDrag(object sender, Nevron.Chart.Windows.NMouseEventArgs e)
            {
                if (!base.CanBeginDrag(sender, e))
                {
                    return(false);
                }

                NPoint       point       = new NPoint(e.X, e.Y);
                NPointSeries pointSeries = m_DragPlane.PointSeries;
                NChart       chart       = pointSeries.Chart;
                NModel3DToViewTransformation model3DToViewTransformation = new NModel3DToViewTransformation(GetView().Context, chart.Projection);

                float xHotSpotArea = 10;
                float yHotSpotArea = 10;

                int dataPointIndex = -1;

                for (int i = 0; i < pointSeries.Values.Count; i++)
                {
                    double x = (double)pointSeries.XValues[i];
                    double y = (double)pointSeries.Values[i];
                    double z = (double)pointSeries.ZValues[i];

                    NVector3DF vecModelPoint;
                    vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, x);
                    vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, y);
                    vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, z);

                    NPointF viewPoint = NPointF.Empty;
                    model3DToViewTransformation.Transform(vecModelPoint, ref viewPoint);

                    if (Math.Abs(viewPoint.X - point.X) < xHotSpotArea &&
                        Math.Abs(viewPoint.Y - point.Y) < yHotSpotArea)
                    {
                        dataPointIndex = i;
                        break;
                    }
                }

                if (dataPointIndex == -1)
                {
                    return(false);
                }

                m_DataPointIndex   = dataPointIndex;
                m_OriginalPosition = m_DragPlane.GetVectorFromPoint(m_DataPointIndex);

                return(true);
            }