Search  English (United States) Русский (Россия)
Thursday, July 29, 2010 ..:: Форумы ::.. Register  Login
 RSWB Forum
Minimize
 
  RSWB Forums  DotNet Code  Desktop Applica...  Drawing Function Points 2D Chart (VB.NET Sub)
Previous Previous
 
Next Disabled
New Post 1/8/2009 6:53 AM
  Oleg
3 posts
www.olegyakupov.com
No Ranking


Drawing Function Points 2D Chart (VB.NET Sub) 
Modified By SuperUser Account  on 7/20/2009 2:19:11 PM)

Imports System.Drawing

Imports System.Drawing.Drawing2D

 

Public gfx As Graphics

Public bmp As Bitmap

 

Private Sub DrawChart(ByVal Az As Double(), ByVal delT As Double())

        Dim sizePnt As Integer = 2

        Dim pointPen As New Pen(Color.Black, sizePnt)

        Dim gridLine As New Pen(Color.LightGray, 1)

        Dim maxDataPoints As Integer = Az.Length

        Dim chartHeight As Integer = Me.bmp.Height

        Dim chartWidth As Integer = Me.bmp.Width

        Dim minYpos As Integer = chartHeight

        Dim maxYpos As Integer = 10

        ' Adjustable Values

        Dim vrtRatio As Double = chartHeight / 4.0

        Dim hrzRatio As Double = chartWidth / 360.0

        ' Drawing Border Lines

        Dim borderLine As New Pen(Color.DarkGray, 2)

        'Left Border

        Me.gfx.DrawLine(borderLine, New Point(0, chartHeight), New Point(0, 0))

        ' Bottom Border

        Me.gfx.DrawLine(borderLine, New Point(0, chartHeight), New Point(chartWidth, chartHeight))

        ' Right Border

        Me.gfx.DrawLine(borderLine, New Point(chartWidth, chartHeight), New Point(chartWidth, 0))

        ' Top Border

        Me.gfx.DrawLine(borderLine, New Point(0, 0), New Point(chartWidth, 0))

        ' Drawing X-Axis (Azimuth -180 - +180))

        Me.gfx.DrawLine(borderLine, New Point(0, chartHeight / 2), New Point(chartWidth, chartHeight / 2))

        Dim xPos As Single = 0

        Dim snglAz As Single = -180.0

        Dim shiftX As Single = chartWidth / 8

        While (snglAz <= 180.0)

            Me.gfx.DrawString(snglAz.ToString(), New Font("Arial", 5), New SolidBrush(Color.Gray), New Point(xPos, chartHeight / 2 + 1))

            Me.gfx.DrawLine(gridLine, New Point(xPos, 0), New Point(xPos, chartHeight))

            snglAz += 45.0

            xPos += shiftX

        End While

        ' Drawing Y-Axis (Time -2.00 - +2.00)

        Me.gfx.DrawLine(borderLine, New Point(chartWidth / 2, chartHeight), New Point(chartWidth / 2, 0))

        Dim yPos As Single = 0

        Dim snglDelT As Single = 2.0

        Dim shiftY As Single = chartHeight / 8

        While (snglDelT >= -2.0)

            If (snglDelT <> 0) Then

                Me.gfx.DrawString(snglDelT.ToString("F"), New Font("Arial", 5), New SolidBrush(Color.Gray), New Point(chartWidth / 2 + 2, yPos))

                Me.gfx.DrawLine(gridLine, New Point(0, yPos), New Point(chartWidth, yPos))

            End If

            snglDelT -= 0.5

            yPos += shiftY

        End While

        ' Drawing the Points

        For i As Integer = 0 To maxDataPoints - 1

            xPos = Convert.ToSingle(Az(i) * hrzRatio)

            yPos = Convert.ToSingle(Math.Abs(delT(i) - 2.0) * vrtRatio)

            Me.gfx.DrawRectangle(pointPen, xPos, yPos, sizePnt, sizePnt)

        Next

    End Sub

Олег Якупов.

www.OlegYakupov.com

 

 
Previous Previous
 
Next Disabled
  RSWB Forums  DotNet Code  Desktop Applica...  Drawing Function Points 2D Chart (VB.NET Sub)
Copyright 2008 - 2009 by Oleg Yakupov   Terms Of Use  Privacy Statement