-------------------------------------------------------------------------------
 情報処理T( サンプルプログラム )
-------------------------------------------------------------------------------

10.画像解析ソフトの作成(2)





Private Sub Command1_Click()
    Form4.Show
End Sub

Private Sub Command2_Click()
        End
End Sub


Private Sub Command3_Click()
        Form2.Show
        Beep
       
End Sub

Private Sub gazoa_Click(Index As Integer)
    Select Case Index
    Case 0
    Case 1
    Case 2
    Case 3
        Form3.Width = 3700
        Form3.Height = 6500
        Form3.Left = 6000
        Form3.Top = 1500
       
        Form4.Show
        Form3.Show
       
    Case 4
        Form3.Width = 3700
        Form3.Height = 6500
        Form3.Left = 6000
        Form3.Top = 1500
       
        Form4.Show
        Form3.Show
       
    Case 5
       
       
    End Select
End Sub

Private Sub Command4_Click()
        Picture1.Cls
        Form1.Picture1.Width = 6000
        Form1.Picture1.Height = 5800
        Form1.Picture1.Left = 100
        Form1.Picture1.Top = 200
        Picture1.ScaleWidth = 6000
        Picture1.ScaleHeight = 5800
        Picture1.ScaleLeft = -3000
        Picture1.ScaleTop = -2900
        Picture1.Line (-2950, -2850)-(2950, 2850), &HFFFF00, B
        Picture1.Line (0, -2850)-(0, 2850), &HFFFF00
        Picture1.Line (-2950, 0)-(2950, 0), &HFFFF00
        Picture1.Line (Sx, Sy)-(x, y), &HFFFF00
        Beep
        xL = 5000: yL = 2000
        Form1.Text10.Text = "手順3:基準となる長さをcm単位で数字だけ記入したあと、OKボタンをクリックして下さい"
        ht = InputBox("手順3:基準となる長さをcm単位で数字だけ記入したあと、OKボタンをクリックして下さい", "Data input", "0", xL, yL)
        Form1.Text7.Text = ht
        Form1.Text10.Text = "手順4:基準の長さに指定した2点をクリックして下さい"
        me1 = InputBox("下の手順4を実行後に手順5を実行する事。下の欄には、はなにも記入せず、OKボタンをクリックして下さい")
        Form1.Text10.Text = "手順5:キャリブレーションが終わったら、次に、解析のボタンをクリックして下さい"
End Sub

Private Sub Command5_Click()
        Picture1.Cls
            Text1.Text = "0"
            Text2.Text = "0"
            Text3.Text = "0"
            Text4.Text = "0"
            Text5.Text = "0"
            Text6.Text = "0"
            Text8.Text = "0"
End Sub


Private Sub Command6_Click()
Form5.Show

End Sub

Private Sub Form_Load()
    Form1.Show
    Picture1.Print "  "
    Picture1.Print "手順1: まず、写真を読み込んで下さい。"
    Picture1.Print "  "
    Picture1.Print "手順2: 次に、キャリブレーションのボタンをクリックして下さい"
    Picture1.Print "  "
    Picture1.Print "手順3: 標準となる長さをcm単位で数字だけ記入したあと、OKボタンをクリックして下さい  "
    Picture1.Print "  "
    Picture1.Print "手順4: 標準の長さにした2点をクリックして下さい。ここではなにも記入せず、OKボタンをクリックして下さい  "
    Picture1.Print "  "
    Picture1.Print "手順5: キャリブレーションが終わったら、次に、解析のボタンをクリックして下さい"
     
    End Sub



Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim D As Single
    Static n As Integer
    Static q1 As Integer
    Static L1 As Integer
    Static Sx As Single, Sy As Single
            Beep
            MousePointer = 2
            ht = Text7.Text
            'VA = Text1.Text
            'Fname = Text2.Text
           
            Text1.Text = Sx
            Text3.Text = -Sy
            Text2.Text = x
            Text4.Text = -y
                Picture1.CurrentX = x - 4
                Picture1.CurrentY = y - 4
                Picture1.Circle (x, y), 10, QBColor(15)
                n = n + 1
            If n = 2 Then
                Picture1.Line (Sx, Sy)-(x, y), QBColor(15)
                n = 0
            Else
                Beep
                Sx = x: Sy = y
                n = 1
            End If
           
            'XL = Abs(x - Sx)
            'YL = Abs(-y + Sy)
            xL = (x - Sx)
            yL = (-y + Sy)
           
       If yL = 0 Then
            yL = 0.0001
       Else
            yL = yL
       End If
           
            L = Sqr(xL ^ 2 + yL ^ 2)
            D = xL / yL
            q = Atn(D)
            q = q / 3.14159 * 180
            'Text7.Text = "XL=" & XL
            'Text8.Text = "YL=" & YL
            'q1 = q * 10: q = q1 / 10
            'L1 = L * 10: L = L1 / 10
            c = ht / L
           
            Text6.Text = q
            Text5.Text = L
            Text8.Text = c
            Form4.Text1.Text = q
            Form4.Text8.Text = c
            Form5.Text13.Text = c
           'MousePointer = 0
 
End Sub