VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   AutoRedraw      =   -1  'True
   Caption         =   "ND-Plot"
   ClientHeight    =   11115
   ClientLeft      =   165
   ClientTop       =   450
   ClientWidth     =   13590
   LinkTopic       =   "Form1"
   ScaleHeight     =   741
   ScaleMode       =   3  'ﾋﾟｸｾﾙ
   ScaleWidth      =   906
   StartUpPosition =   3  'Windows の既定値
   Begin VB.CommandButton Movie 
      Caption         =   "Movie"
      Height          =   615
      Left            =   120
      TabIndex        =   6
      Top             =   1680
      Width           =   1455
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   600
      Top             =   4080
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton SaveBMP 
      Caption         =   "Save to BMP"
      Height          =   615
      Left            =   120
      TabIndex        =   5
      Top             =   2640
      Width           =   1455
   End
   Begin VB.PictureBox graph 
      AutoRedraw      =   -1  'True
      BackColor       =   &H00FFFFFF&
      Height          =   11895
      Left            =   1680
      ScaleHeight     =   789
      ScaleMode       =   3  'ﾋﾟｸｾﾙ
      ScaleWidth      =   789
      TabIndex        =   4
      Top             =   120
      Width           =   11895
   End
   Begin VB.TextBox Status 
      BeginProperty Font 
         Name            =   "ＭＳ ゴシック"
         Size            =   9
         Charset         =   128
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   7215
      Left            =   45
      MultiLine       =   -1  'True
      ScrollBars      =   2  '垂直
      TabIndex        =   3
      Top             =   4680
      Width           =   1575
   End
   Begin VB.CommandButton Next 
      Caption         =   "Next"
      Height          =   615
      Left            =   120
      TabIndex        =   2
      Top             =   960
      Width           =   1455
   End
   Begin VB.CommandButton Print 
      Caption         =   "Print"
      Height          =   615
      Left            =   120
      TabIndex        =   1
      Top             =   3360
      Width           =   1455
   End
   Begin VB.CommandButton Run 
      Caption         =   "Run"
      Height          =   615
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   1455
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'--------------------------------------------------------------------------
'
'     　　PCAMPOR.Cの計算結果の描画
'
'            < RPCAMPOR.BAS >
'
'       2002.11.16 作成 BY 岩附
'       2003.11.17 改良 BY 岩附
'       2004. 7. 1 改良 BY 岩附
'       2005. 7. 7 改良 BY 岩附
'       2006. 7. 6 改良 BY 岩附
'       2010. 7. 1 改良 BY 岩附
'       2010.11.21 改良 BY 岩附
'       2017. 9.26 改良 BY 岩附
'       2017.11.28 改良 BY 岩附
'
'--------------------------------------------------------------------------
'
Dim PSD(361) As Double, RC(361) As Double, XC(361) As Double, YC(361) As Double, ALP(361) As Double
Dim XR(361), YR(361)
Dim XP, YP, R, L As Double
Dim DR(361) As Double
Dim DTR As Double, RTD As Double, PAI As Double, PAI2 As Double
Dim THD(361) As Double, PSIC(361) As Double, PHI(361) As Double
Dim XB(361), YB(361) As Double
Dim YN As String

Private Sub Exe()
    PAI = 3.14159265358979
    PAI2 = PAI * 2#
    DTR = PAI / 180#
    RTD = 180# / PAI
'
    Open "pcampor.dat" For Input As #1
'
    Input #1, YN
    Input #1, PRG
    Input #1, XP, YP, R, L
        XP = XP * 1000#
        YP = YP * 1000#
        R = R * 1000#
        L = L * 1000#
    For i = 1 To 361
        Input #1, THD(i), PHI(i), XB(i), YB(i)
        XB(i) = XB(i) * 1000#
        YB(i) = YB(i) * 1000#
    Next i
    For i = 1 To 361
        Input #1, THD(i), RC(i), PSIC(i), XC(i), YC(i), ALP(i)
        XC(i) = XC(i) * 1000#
        YC(i) = YC(i) * 1000#
        RC(i) = RC(i) * 1000#
        XR(i) = L * Cos(PHI(i) * DTR) + XP
        YR(i) = L * Sin(PHI(i) * DTR) + YP
    Next i
    Close #1
'
    Plots graph, Status
    Phead
'
        PXSYMBOL = 1#
        PYSYMBOL = 16.4
        SYMBOL = "フォロワ出力角変位"
    Psymbol graph
'
        X0PLOT = 2#: Y0PLOT = 5#
        XSPLOT = 0#: YSPLOT = 0#
        XFPLOT = 10#: YFPLOT = 7#
        NXPLOT = 4: NYPLOT = 4
        NVXPLOT = 1: NVYPLOT = 1
        NDXPLOT = 0: NDYPLOT = 0
        XMINPLOT = 0#: YMINPLOT = 120
        XMAXPLOT = 360: YMAXPLOT = 160
        XANAME = "θ°": YANAME = "φ°"
    Pscale
    NDPLOT = 361
    For i = 1 To NDPLOT
        XPLOT(i) = THD(i)
        YPLOT(i) = PHI(i)
    Next i
    Gaxes graph
    NUMPEN = 1
    Sline graph
'
    Plote Status
End Sub

Private Sub Exenext()
    If P_page < 2 Then P_page = 1: Exe: GoTo PEND
    If P_page = 2 Then GoTo PAGE2
    If P_page = 3 Then GoTo PAGE3
    If P_page = 4 Then GoTo PAGE4
    If P_page = 5 Then GoTo PAGE5
    If P_page = 6 Then GoTo PAGE6
    If P_page = 7 Then GoTo PAGE7
    If P_page = 8 Then GoTo PAGE8
    If P_page > 8 Then GoTo PEND

PAGE2:
    Plots graph, Status
    Phead
        PXSYMBOL = 1#
        PYSYMBOL = 16.4
        SYMBOL = "カム輪郭"
    Psymbol graph
'
        X0PLOT = 2#: Y0PLOT = 2#
        XSPLOT = 0#: YSPLOT = 0#
        XFPLOT = 12#: YFPLOT = 12#
        NXPLOT = 24: NYPLOT = 24
        NVXPLOT = 2: NVYPLOT = 2
        NDXPLOT = 0: NDYPLOT = 0
        XMINPLOT = -120#: YMINPLOT = -120#
        XMAXPLOT = 120#: YMAXPLOT = 120#
        XANAME = "x mm": YANAME = "y mm"
    Pscale
    NDPLOT = 361
    For i = 1 To NDPLOT
        XPLOT(i) = XC(i)
        YPLOT(i) = YC(i)
    Next i
    Gaxes graph
    NUMPEN = 1
    Sline graph
    NDPLOT = 1
    XPLOT(1) = 0
    YPLOT(1) = 0
    Cplot graph
    Pcplot2
    Plote Status
    GoTo PEND
    
PAGE3:
    Plots graph, Status
    Phead
'
        PXSYMBOL = 1#
        PYSYMBOL = 16.4
        SYMBOL = "カム輪郭の座標"
    Psymbol graph
'
        X0PLOT = 2#: Y0PLOT = 1
        XSPLOT = 0#: YSPLOT = 0#
        XFPLOT = 10#: YFPLOT = 4#
        NXPLOT = 4: NYPLOT = 5
        NVXPLOT = 1: NVYPLOT = 1
        NDXPLOT = 0: NDYPLOT = 0
        XMINPLOT = -200#: YMINPLOT = -150
        XMAXPLOT = 200#: YMAXPLOT = 100
        XANAME = "ψ °": YANAME = "x mm"
    NDPLOT = 361
    Pscale
    For i = 1 To NDPLOT
        XPLOT(i) = PSIC(i)
        YPLOT(i) = XC(i)
    Next i
    Gaxes graph
    NUMPEN = 1
    Sline graph
'
        X0PLOT = 2#: Y0PLOT = 6.5
        XSPLOT = 0#: YSPLOT = 0#
        XFPLOT = 10#: YFPLOT = 4#
        NXPLOT = 4: NYPLOT = 5
        NVXPLOT = 1: NVYPLOT = 1
        NDXPLOT = 0: NDYPLOT = 0
        XMINPLOT = -200#: YMINPLOT = -100#
        XMAXPLOT = 200: YMAXPLOT = 150#
        XANAME = "ψ°": YANAME = "y mm"
    Pscale
    For i = 1 To NDPLOT
        YPLOT(i) = YC(i)
    Next i
    Gaxes graph
    NUMPEN = 1
    Sline graph
'
        X0PLOT = 2#: Y0PLOT = 12
        XSPLOT = 0#: YSPLOT = 0#
        XFPLOT = 10#: YFPLOT = 4#
        NXPLOT = 4: NYPLOT = 4
        NVXPLOT = 1: NVYPLOT = 1
        NDXPLOT = 0: NDYPLOT = 0
        XMINPLOT = -200#: YMINPLOT = 20
        XMAXPLOT = 200: YMAXPLOT = 100
        XANAME = "ψ°": YANAME = "r mm"
    Pscale
    For i = 1 To NDPLOT
        XPLOT(i) = PSIC(i)
        YPLOT(i) = RC(i)
    Next i
    Gaxes graph
    NUMPEN = 1
    Sline graph
'
    Plote Status
    GoTo PEND
'
PAGE4:
    Plots graph, Status
    Phead
        PXSYMBOL = 1#
        PYSYMBOL = 16.4
        SYMBOL = "カムとフォロワ"
    Psymbol graph
'
        X0PLOT = 2#: Y0PLOT = 1#
        XSPLOT = 0#: YSPLOT = 0#
        XFPLOT = 15#: YFPLOT = 15#
        NXPLOT = 6: NYPLOT = 6
        NVXPLOT = 1: NVYPLOT = 1
        NDXPLOT = 0: NDYPLOT = 0
        XMINPLOT = -150#: YMINPLOT = -150#
        XMAXPLOT = 150#: YMAXPLOT = 150#
        XANAME = "X mm": YANAME = "Y mm"
    Pscale
    Gaxes graph
    NDPLOT = 361
    For i = 1 To NDPLOT
        XPLOT(i) = XC(i)
        YPLOT(i) = YC(i)
    Next i
    NUMPEN = 1
    Sline graph
    NDPLOT = 1
    XPLOT(1) = 0#
    YPLOT(1) = 0#
    Cplot graph
    Pcplot2
'
    NDPLOTB = NDPLOT
    NDPLOT = 2
    XPLOT(1) = XB(1)
    YPLOT(1) = YB(1)
    XPLOT(2) = XP
    YPLOT(2) = YP
    NUMPEN = 2
    Sline graph
    Cplot graph
'
    NUMPEN = 2
    NDPLOT = NDPLOTB
    For k = 1 To 361 Step 10
      NDPLOT = 361
      TH = CDbl(k - 1) * DTR
      CT = Cos(TH)
      ST = Sin(TH)
      For i = 1 To NDPLOT
         XPLOT(i) = CT * XC(i) - ST * YC(i)
         YPLOT(i) = ST * XC(i) + CT * YC(i)
      Next i
    Sline graph
'
    NDPLOT = 1
    XPLOT(1) = XB(k)
    YPLOT(1) = YB(k)
    Cplot2
'
    NDPLOT = 2
    XPLOT(2) = XB(k)
    YPLOT(2) = YB(k)
    XPLOT(1) = XP
    YPLOT(1) = YP
    NUMPEN = 2
    Sline graph
    NDPLOT = 1
    Cplot graph
    Pcplot2
'
    Next k
    NDPLOT = 361
    For i = 1 To NDPLOT
        XPLOT(i) = XC(i)
        YPLOT(i) = YC(i)
    Next i
    NUMPEN = 1
    Sline graph
'
    NDPLOT = 1
    XPLOT(1) = XB(1)
    YPLOT(1) = YB(1)
    Cplot2
    Cplot3
    NDPLOT = 2
    XPLOT(2) = XB(1)
    YPLOT(2) = YB(1)
    XPLOT(1) = XP
    YPLOT(1) = YP
'
    NUMPEN = 1
    Sline graph
    NDPLOT = 1
    Cplot graph
    Pcplot2
    Plote Status
    GoTo PEND
'
PAGE5:
    Plots graph, Status
    Phead
        PXSYMBOL = 1#
        PYSYMBOL = 16.4
        SYMBOL = "カム座標系から"
    Psymbol graph
'
        X0PLOT = 2#: Y0PLOT = 1#
        XSPLOT = 0#: YSPLOT = 0#
        XFPLOT = 15#: YFPLOT = 15#
        NXPLOT = 6: NYPLOT = 6
        NVXPLOT = 1: NVYPLOT = 1
        NDXPLOT = 0: NDYPLOT = 0
        XMINPLOT = -150#: YMINPLOT = -150#
        XMAXPLOT = 150#: YMAXPLOT = 150#
        XANAME = "x mm": YANAME = "y mm"
    Pscale
    NDPLOT = 361
    For i = 1 To NDPLOT
        XPLOT(i) = XC(i)
        YPLOT(i) = YC(i)
    Next i
    Gaxes graph
    NUMPEN = 1
    Sline graph
    NDPLOT = 1
    XPLOT(1) = 0#
    YPLOT(1) = 0#
    Cplot graph
    Pcplot2

'
    NDPLOTB = NDPLOT
    NUMPEN = 2
    For k = 1 To 361 Step 10
      NDPLOT = 1
      TH = CDbl(k - 1) * DTR
      CT = Cos(-TH)
      ST = Sin(-TH)
      XPLOT(1) = CT * XR(k) - ST * YR(k)
      YPLOT(1) = ST * XR(k) + CT * YR(k)
      Cplot2
      Cplot3
      XPLOT(1) = CT * XR(k) - ST * YR(k)
      YPLOT(1) = ST * XR(k) + CT * YR(k)
      XPLOT(2) = CT * XP - ST * YP
      YPLOT(2) = ST * XP + CT * YP
      NDPLOT = 2
      Sline graph
      NDPLOT = 1
      Cplot3
      XPLOT(1) = XPLOT(2)
      YPLOT(1) = YPLOT(2)
      NDPLOT = 1
      Cplot graph
      Pcplot2
'
    Next k
    NDPLOT = NDPLOTB
    Plote Status
    GoTo PEND
'
PAGE6:
    For kk = 1 To 5 Step 1
        For k = 1 To 360 Step 1
            Plots graph, Status
            Phead
            PXSYMBOL = 1#
            PYSYMBOL = 16.4
            SYMBOL = "カムとフォロワ"
            Psymbol graph
'
            X0PLOT = 2#: Y0PLOT = 1#
            XSPLOT = 0#: YSPLOT = 0#
            XFPLOT = 15#: YFPLOT = 15#
            NXPLOT = 6: NYPLOT = 6
            NVXPLOT = 1: NVYPLOT = 1
            NDXPLOT = 0: NDYPLOT = 0
            XMINPLOT = -150#: YMINPLOT = -150#
            XMAXPLOT = 150#: YMAXPLOT = 150#
            XANAME = "X mm": YANAME = "Y mm"
            Pscale
            Gaxes graph
'
            NUMPEN = 1
            NDPLOT = 361
            TH = CDbl(k - 1) * DTR
            CT = Cos(TH)
            ST = Sin(TH)
            For i = 1 To NDPLOT
               XPLOT(i) = CT * XC(i) - ST * YC(i)
               YPLOT(i) = ST * XC(i) + CT * YC(i)
            Next i
            Sline graph
'
            NDPLOT = 1
            XPLOT(1) = 0#
            YPLOT(1) = 0#
            Cplot graph
            Pcplot2
            XPLOT(1) = XB(k)
            YPLOT(1) = YB(k)
            Cplot2
            Cplot3
'
            NDPLOT = 2
            XPLOT(2) = XB(k)
            YPLOT(2) = YB(k)
            XPLOT(1) = XP
            YPLOT(1) = YP
            NUMPEN = 1
            Sline graph
            NDPLOT = 1
            Cplot graph
            Pcplot2
'
            graph.Refresh
            DoEvents
            Sleep 2
'
            Plote Status
       Next k
   Next kk
   GoTo PEND
'
PAGE7:
    Plots graph, Status
    Phead
'
        PXSYMBOL = 1#
        PYSYMBOL = 16.4
        SYMBOL = "圧力角"
    Psymbol graph
'
        X0PLOT = 2#: Y0PLOT = 5#
        XSPLOT = 0#: YSPLOT = 0#
        XFPLOT = 10#: YFPLOT = 8#
        NXPLOT = 4: NYPLOT = 9
        NVXPLOT = 1: NVYPLOT = 3
        NDXPLOT = 0: NDYPLOT = 0
        XMINPLOT = 0#: YMINPLOT = 0
        XMAXPLOT = 360: YMAXPLOT = 90
        XANAME = "θ°": YANAME = "α°"
    Pscale
    NDPLOT = 361
    For i = 1 To NDPLOT
        XPLOT(i) = THD(i)
        YPLOT(i) = ALP(i)
    Next i
    Gaxes graph
    NUMPEN = 1
    Sline graph
'
    Plote Status
    GoTo PEND
'
PAGE8:
    Plots graph, Status
    Phead
        PXSYMBOL = 1#
        PYSYMBOL = 16.4
        SYMBOL = "カム輪郭"
    Psymbol graph
'
        X0PLOT = 0#: Y0PLOT = -3#
        XSPLOT = 0#: YSPLOT = 0#
        XFPLOT = 20#: YFPLOT = 20#
        NXPLOT = 4: NYPLOT = 4
        NVXPLOT = 1: NVYPLOT = 1
        NDXPLOT = 0: NDYPLOT = 0
        XMINPLOT = -100#: YMINPLOT = -100#
        XMAXPLOT = 100#: YMAXPLOT = 100#
        XANAME = "x mm": YANAME = "y mm"
    Pscale
    NDPLOT = 361
    For i = 1 To NDPLOT
        XPLOT(i) = XC(i)
        YPLOT(i) = YC(i)
    Next i
    NUMPEN = 7
    Sline graph
'
    NDPLOT = 2
    XPLOT(1) = 0
    YPLOT(1) = 0
    For k = 0 To 355 Step 5
       TH = CDbl(k) * DTR
       XPLOT(2) = 100# * Cos(TH)
       YPLOT(2) = 100# * Sin(TH)
       NUMPEN = 1
       If k Mod 10 = 0 Then PENTHICK = 1 Else PENTHICK = 2
       If k = 0 Then NUMPEN = 2
       If k = 90 Then NUMPEN = 2
       If k = 180 Then NUMPEN = 2
       If k = 270 Then NUMPEN = 2
       Sline graph
    Next k
'
    Plote Status
    GoTo PEND
'
PEND:
    
End Sub

Private Sub Phead()
        PXSYMBOL = 1#
        PYSYMBOL = 17.5
        SYMBOL = "揺動円端従節平面カムの輪郭計算 with PCAMPOR.BAS"
    Psymbol graph
        PXSYMBOL = 1#
        PYSYMBOL = 16.9
        SYMBOL = "設計者氏名：" + YN
    Psymbol graph
'
End Sub


Private Sub Cplot2()
    RTEMP = Int(R * P_XRA * P_SCF)
    graph.DrawWidth = 2
    Sublines graph
    graph.FillColor = RGB(255, 255, 255)
    graph.FillStyle = 0
    For P_I = 1 To NDPLOT
        Sublinec
        graph.Circle (P_XPF, P_H - P_YPF), RTEMP, P_COLOR
    Next P_I
    graph.DrawWidth = 1
    graph.FillColor = RGB(255, 255, 255)
    graph.FillStyle = 1
End Sub

Private Sub Cplot3()
    RTEMP = Int(R * P_XRA * P_SCF * 0.2)
    graph.DrawWidth = 2
    Sublines graph
    graph.FillColor = RGB(255, 255, 255)
    graph.FillStyle = 0
    For P_I = 1 To NDPLOT
        Sublinec
        graph.Circle (P_XPF, P_H - P_YPF), RTEMP, P_COLOR
    Next P_I
    graph.DrawWidth = 1
    graph.FillColor = RGB(255, 255, 255)
    graph.FillStyle = 1
End Sub

Private Sub Pcplot2()
    
    graph.DrawWidth = 2
    Sublines graph
    graph.FillColor = P_COLOR
    graph.FillStyle = 0
    For P_I = 1 To NDPLOT
        Sublinec
        graph.Circle (P_XPF, P_H - P_YPF), 3, P_COLOR
    Next P_I
    graph.DrawWidth = 1
    graph.FillColor = RGB(255, 255, 255)
    graph.FillStyle = 1

End Sub

Private Sub Form_Load()

    init_form Form1, Status
    init_components Status, graph

End Sub

Private Sub Form_Resize()

    init_components Status, graph

End Sub

Private Sub Movie_Click()
    P_page = 6
    Exenext
End Sub

Private Sub Next_Click()
    P_page = P_page + 1
    Exenext
End Sub

Private Sub Run_Click()

    P_page = 1
    Exe

End Sub

Private Sub Print_Click()
    
    On Error GoTo Err_Handle
    
    CommonDialog1.ShowPrinter
    
    Printer.PaintPicture graph.Image, 0, 0
    Printer.EndDoc
    Exit Sub
Err_Handle:
    Print "ERROR"
    Exit Sub

End Sub

Private Sub SaveBMP_Click()

  CommonDialog1.ShowSave
  savepath$ = CommonDialog1.FileName
  If InStr(savepath$, ".bmp") = 0 Then savepath$ = savepath$ + ".bmp"
  If savepath$ <> "" Then SavePicture graph.Image, savepath$

End Sub

