예제 #1
0
        /// <summary>
        /// Gets the ordinate on the specified axis that is represented by the locating value
        /// </summary>
        /// <param name="locator">The ordinate that is to be displayed</param>
        /// <param name="axis">The axis on which the ordinate is required</param>
        /// <returns>The value of the ordinate that the point is to be drawn at</returns>
        int GetPointOrdinate(float locator, axisParameters axis, bool horizontal)
        {
            float locatorToRepresent = locator + (horizontal ? -1 : 1) * axis.baseOffset;
            int   position           = (int)(axis.startLocation + (axis.scaleFactor * locatorToRepresent));

            return(position);
        }
예제 #2
0
 private void MyEvents_AxesModifiedByUser(axisParameters horizontalAxis, axisParameters verticalAxis, NormalisationType normalisation)
 {
     GraphPanel.SetNormalisationType(normalisation);
     GraphPanel.SetHorizontalAxis(horizontalAxis);
     GraphPanel.SetVerticalAxis(verticalAxis);
     Invalidate();
 }
예제 #3
0
        /// <summary>
        /// Draws a the line represented by the list of points using the specified graphics
        /// </summary>
        /// <param name="horizontalAxis">The horizontal axis parameters</param>
        /// <param name="verticalAxis">The vertical axis parameters</param>
        /// <param name="g">The graphics to use to draw the line</param>
        /// <param name="upToLap">The last lap to display</param>
        public void DrawLine(axisParameters horizontalAxis, axisParameters verticalAxis, Graphics g, int upToLap)
        {
            //If the line is to be shown
            if (show)
            {
                Point startPoint = new Point();
                Point endPoint   = new Point();
                Color lineColour = Data.Drivers[driverIndex].LineColour;
                Pen   pen        = new Pen(lineColour, 1);

                //Lap number is 0-based
                endPoint.X = GetPointOrdinate(points[0].lap, horizontalAxis, true);
                endPoint.Y = GetPointOrdinate(points[0].time, verticalAxis, false);

                //Cycle through the points
                for (int pointIndex = 1; pointIndex < points.Count; pointIndex++)
                {
                    //Set the new start point to the old end point
                    startPoint = endPoint;

                    //Update the end point
                    endPoint.X = GetPointOrdinate(points[pointIndex].lap, horizontalAxis, true);
                    endPoint.Y = GetPointOrdinate(points[pointIndex].time, verticalAxis, false);

                    //If the point is within range and is to be shown
                    if ((startPoint.X >= horizontalAxis.startLocation) && (points[pointIndex].draw) && (points[pointIndex].lap <= upToLap))
                    {
                        g.DrawLine(pen, startPoint, endPoint);
                    }
                }
                pen.Dispose();
            }
        }
예제 #4
0
 /// <summary>
 /// Sets the axes to the specified values
 /// </summary>
 void SetupAxes(axisParameters horizontalAxis, axisParameters verticalAxis, NormalisationType normalisation)
 {
     this.horizontalAxis    = horizontalAxis;
     this.verticalAxis      = verticalAxis;
     graphNormalisationType = normalisation;
     Invalidate();
 }
예제 #5
0
 protected void MyEvents_AxesModified(axisParameters XAxis, axisParameters YAxis, NormalisationType normalisation, bool UserModified)
 {
     if (UserModified)
     {
         SetupAxes(XAxis, YAxis, normalisation);
     }
 }
예제 #6
0
 /// <summary>
 /// Fires the AxesChangedByComputer event. This represents any scaling or setting which does not involve the axes panel.
 /// </summary>
 /// <param name="horizontalAxis">The new horizontal axis</param>
 /// <param name="verticalAxis">The new vertical axis</param>
 /// <param name="normalisation">The new graph normalisation type</param>
 public static void OnAxesComputerGenerated(axisParameters horizontalAxis, axisParameters verticalAxis, NormalisationType normalisation)
 {
     if (AxesChangedByComputer != null)
     {
         AxesChangedByComputer(horizontalAxis, verticalAxis, normalisation);
     }
 }
예제 #7
0
        /// <summary>
        /// Populates the text boxes on the panel with data from the given axes
        /// </summary>
        void PopulateAxesBoxes(axisParameters horizontalAxis, axisParameters verticalAxis, NormalisationType normalisationType)
        {
            axisParameterDataBoxes[0, 0].Text = Convert.ToString(horizontalAxis.baseOffset);
            axisParameterDataBoxes[0, 1].Text = Convert.ToString(horizontalAxis.scaleFactor);
            axisParameterDataBoxes[0, 2].Text = Convert.ToString(horizontalAxis.startLocation);
            axisParameterDataBoxes[0, 3].Text = Convert.ToString(horizontalAxis.axisLabelSpacing);

            axisParameterDataBoxes[1, 0].Text = Convert.ToString(verticalAxis.baseOffset);
            axisParameterDataBoxes[1, 1].Text = Convert.ToString(verticalAxis.scaleFactor);
            axisParameterDataBoxes[1, 2].Text = Convert.ToString(verticalAxis.startLocation);
            axisParameterDataBoxes[1, 3].Text = Convert.ToString(verticalAxis.axisLabelSpacing);

            NormalisationTypeSelected.SelectedIndex = (int)normalisationType;
        }
예제 #8
0
        /// <summary>
        /// Converts a panel coordinate location into a lapDataPoint
        /// </summary>
        /// <param name="point">The point to be converted</param>
        /// <param name="HorizontalAxis">The horizontal axis used for conversion</param>
        /// <param name="VerticalAxis">The vertical axis used for conversion</param>
        /// <returns>The lapDataPoint closest to the specified point</returns>
        public static lapDataPoint GetPositionOfPoint(Point point, axisParameters HorizontalAxis, axisParameters VerticalAxis)
        {
            lapDataPoint pointOnAxes;

            pointOnAxes.driver = -1;
            pointOnAxes.draw   = true;

            int x = point.X;
            int y = point.Y;

            pointOnAxes.lap  = (int)((x - HorizontalAxis.startLocation) / HorizontalAxis.scaleFactor) - HorizontalAxis.baseOffset + 1;
            pointOnAxes.time = ((y - VerticalAxis.startLocation) / VerticalAxis.scaleFactor) + VerticalAxis.baseOffset;

            return(pointOnAxes);
        }
예제 #9
0
 private void AxisModified(object sender, axisParameters e)
 {
     MyEvents.OnAxesComputerGenerated(GraphPanel.HorizontalAxis, GraphPanel.VerticalAxis, GraphPanel.NormalisationType);
     Invalidate();
 }
예제 #10
0
 void MyEvents_AxesModified(axisParameters XAxis, axisParameters YAxis, NormalisationType normalisation)
 {
     localHorizontalAxis = XAxis;
     localVerticalAxis = YAxis;
     PopulateAxesBoxes(XAxis, YAxis, normalisation);
 }