Attribute VB_Name = "modPlot" Option Explicit 'converts vb type 24bit rgb (BlueGreenRed) to QBColor Public Function RgbToQbColor(PlotColor As Long) Dim PlotColorIndex As Integer 'QBColors 0-15 Select Case PlotColor Case &H0&: PlotColorIndex = 0 'Black Case &H800000: PlotColorIndex = 1 'Blue Case &H8000&: PlotColorIndex = 2 'Green Case &H808000: PlotColorIndex = 3 'Cyan Case &H80&: PlotColorIndex = 4 'Red Case &H800080: PlotColorIndex = 5 'Magenta Case &H8080&: PlotColorIndex = 6 'Brown Case &HC0C0C0: PlotColorIndex = 7 'White Case &H808080: PlotColorIndex = 8 'Grey Case &HFF0000: PlotColorIndex = 9 'Light Blue Case &HFF00&: PlotColorIndex = 10 'Light Green Case &HFFFF00: PlotColorIndex = 11 'Light Cyan Case &HFF&: PlotColorIndex = 12 'Light Red Case &HFF00FF: PlotColorIndex = 13 'Light Magenta Case &HFFFF&: PlotColorIndex = 14 'Yellow Case &HFFFFFF: PlotColorIndex = 15 'Bright White Case Else PlotColorIndex = &H0 'unknown color End Select PlotColorIndex = PlotColorIndex + 1 If (PlotColorIndex >= 16) Then PlotColorIndex = 0 RgbToQbColor = QBColor(PlotColorIndex) End Function Public Sub Plot_Spectrum(picMCAPlot As VB.PictureBox, SPECTRUM As Spec, isLinear As Boolean, isLines As Boolean) Dim X As Integer Dim Y As Integer Dim MCAMax As Long Dim MCAPeak As Long Dim TString As String Dim Buffer(64) Dim MCSScale As Long Dim MCAScale As Long Dim PlotXMin As Long Dim PlotXMax As Long Dim LogScaleValue As Long MCAMax = 0 MCAPeak = 0 For X = 0 To SPECTRUM.Channels - 1 If SPECTRUM.DATA(X) > MCAMax Then MCAMax = SPECTRUM.DATA(X) MCAPeak = X End If Next X If isLinear Then MCAScale = Fix(MCAMax + 10 + (10# * Log(MCAMax + 1))) Else LogScaleValue = Fix(Log(MCAMax + 1) / Log(10) + 1) MCAScale = 10 ^ LogScaleValue End If PlotXMin = 0 PlotXMax = SPECTRUM.Channels - 1 If isLinear Then picMCAPlot.Scale (PlotXMin, MCAScale)-(PlotXMax + 1, 0) picMCAPlot.Line (PlotXMin, 0)-(PlotXMax + 1, MCAScale), picMCAPlot.BackColor, BF Else picMCAPlot.Scale (PlotXMin, Log(MCAScale))-(PlotXMax + 1, 0) picMCAPlot.Line (PlotXMin, 0)-(PlotXMax + 1, Log(MCAScale)), picMCAPlot.BackColor, BF End If If isLinear Then picMCAPlot.Line (PlotXMin, 0)-(PlotXMax + 1, MCAScale), picMCAPlot.BackColor, BF For X = 1 To 9 picMCAPlot.Line (PlotXMin, MCAScale * X / 10)-(PlotXMax + 1, MCAScale * X / 10), vbWhite Next X Else picMCAPlot.Line (PlotXMin, 0)-(PlotXMax + 1, Log(MCAScale)), picMCAPlot.BackColor, BF For Y = 1 To LogScaleValue For X = 1 To 9 picMCAPlot.Line (PlotXMin, Log(MCAScale * X / (10 ^ Y)))-(PlotXMax + 1, Log(MCAScale * X / (10 ^ Y))), colorLightGray Next X Next Y End If If isLines Then For X = PlotXMin To PlotXMax - 1 If isLinear Then picMCAPlot.Line (X, SPECTRUM.DATA(X))-(X + 1, SPECTRUM.DATA(X + 1)), PlotColor Else picMCAPlot.Line (X, Log(1# + SPECTRUM.DATA(X)))-(X + 1, Log(1# + SPECTRUM.DATA(X + 1))), PlotColor End If Next X Else For X = PlotXMin To PlotXMax If isLinear Then picMCAPlot.Line (X, 0)-(X + 0.5, SPECTRUM.DATA(X)), PlotColor, BF Else picMCAPlot.Line (X, 0)-(X + 0.5, Log(1# + SPECTRUM.DATA(X))), PlotColor, BF End If Next X End If End Sub Public Sub Plot_Scope(picScope As VB.PictureBox, Scope() As Byte, PlotColor As Long) Dim X As Integer picScope.Scale (0, 255)-(2047, 0) picScope.Line (0, 0)-(2047, 255), picScope.BackColor, BF For X = 0 To 2046 picScope.Line (X, Scope(X))-(X + 1, Scope(X + 1)), PlotColor Next X End Sub Public Sub WriteTextFile(strFilename As String, strData As String, Optional OverWrite As Boolean = False) Dim intFile As Integer intFile = FreeFile If (OverWrite) Then Open strFilename For Output As #intFile Else Open strFilename For Append As #intFile End If Print #intFile, strData Close #intFile End Sub