home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 March
/
Chip_1998-03_cd.bin
/
tema
/
jpcad
/
ACC
/
SAMPLES
/
DLINE
/
DLINE.FR_
/
DLINE.FR
Wrap
Text File
|
1998-01-21
|
8KB
|
241 lines
VERSION 4.00
Begin VB.Form frmDline
Caption = "Form1"
ClientHeight = 840
ClientLeft = 6135
ClientTop = 1455
ClientWidth = 1560
Height = 1200
Left = 6075
LinkTopic = "Form1"
ScaleHeight = 840
ScaleWidth = 1560
Top = 1155
Width = 1680
Begin ACCLib.Amoeba Amoeba
Left = 120
Top = 240
_Version = 65536
_ExtentX = 847
_ExtentY = 847
_StockProps = 0
End
End
Attribute VB_Name = "frmDline"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Base 0
Private Sub ProcedureCall(ByVal nProcedureCode As Long)
'calls different procedures according to registered command id
'in this case only one command was registered
Select Case nProcedureCode
Case 0
Dline
Case Else
'Bad procedure code
End Select
End Sub
Private Sub Amoeba_Drag(ByVal UserData As Variant, ByVal Point As Object, Trans As Object, nStatus As Long)
'drag function
Amoeba.DrawLine UserData, Point
End Sub
Private Sub Amoeba_Error(ByVal nErrorCode As Long)
'processes error messages
MsgBox "JPCAD Error " + Str$(nErrorCode), vbCritical
End Sub
Private Sub Amoeba_Status(ByVal nStatus As Long, ByVal nCmdCode As Long)
Dim result As Long
Select Case nStatus
Case A_LOAD
'program was loaded into Amoeba
result = Amoeba.DefCmd("dline", 0, 0)
Amoeba.Prompt Chr(10) + "DLINE - command defined"
Case A_CMD_CALL
'command was called - nCmdCode = command id
ProcedureCall nCmdCode
Case A_UNLOAD
'program was unloaded from Amoeba
Amoeba.Prompt Chr(10) + "DLINE - unloading"
' do not quit yet...
Case A_END
' ... quit here
Unload Me
End Select
End Sub
Private Sub Form_Load()
Hide
End Sub
'
' DLINE (c) 1997, ANTEK CS
'
'Description:
' Sample file for demonstrating the use of ACC (Amoeba Custom Control).
' Draws double lines with chosen width.
'
'
' THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
' WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
' PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
'
'
' Program registeres only one command ("DLINE") for use with Amoeba.
' Communication with Amoeba takes place in Sub Amoeba_Status.
'
'
Public Sub Dline()
' test area
Dim Variable As Variant
Dim VarT As Long
Amoeba.V_Get "LASTPOINT", VarT, Variable
' end of test area
Const EPSILON As Double = 0.000000001
'declarations
Dim StartPoint As Object, EndPoint As Object
Dim SP As Object, EP As Object
Dim L1StartPoint As Object, L1EndPoint As Object, L2StartPoint As Object, L2EndPoint As Object
Dim PrevLine1 As Long, PrevLine2 As Long
Dim Vector As Object, V As Object, W As Object, PVector As Object
Dim PrevVector As Object, Vector1 As Object, Vector2 As Object
Dim Intersect1 As Object, Intersect2 As Object
Dim S1 As Object, S2 As Object, E1 As Object, E2 As Object
'Dim Vector As Variant, V As Variant, W As Variant, PVector As Variant
'Dim PrevVector As Variant, Vector1 As Variant, Vector2 As Variant
'Dim Intersect1 As Variant, Intersect2 As Variant
Dim DlineWidth As Double
Dim result As Long
Dim pLayer As Long, pLineType As Long, pColor As Long
Dim pWidth As Double
Dim t1 As Double, t2 As Double
Dim IsPrevLine As Boolean
'create Point objects
Set StartPoint = CreateObject("acc.point")
Set EndPoint = CreateObject("acc.point")
Set SP = CreateObject("acc.point")
Set EP = CreateObject("acc.point")
Set L1StartPoint = CreateObject("acc.point")
Set L1EndPoint = CreateObject("acc.point")
Set L2StartPoint = CreateObject("acc.point")
Set L2EndPoint = CreateObject("acc.point")
'vectors
Set Vector = CreateObject("acc.point")
Set PrevVector = CreateObject("acc.point")
Set V = CreateObject("acc.point")
Set W = CreateObject("acc.point")
Set PVector = CreateObject("acc.point")
Set Vector1 = CreateObject("acc.point")
Set Vector2 = CreateObject("acc.point")
Set Intersect1 = CreateObject("acc.point")
Set Intersect2 = CreateObject("acc.point")
Set S1 = CreateObject("acc.point")
Set S2 = CreateObject("acc.point")
Set E1 = CreateObject("acc.point")
Set E2 = CreateObject("acc.point")
'Get double line width
result = Amoeba.GetDouble("Double line width ", vbNullString, "10.0", DlineWidth)
Select Case result
Case A_GET_CANCEL
Exit Sub
Case A_GET_DEFAULT
DlineWidth = 10# 'default is 10.0
End Select
'Get first point
result = Amoeba.GetPoint("First dline point", vbNullString, vbNullString, StartPoint)
If result = A_GET_CANCEL Then
Exit Sub
End If
IsPrevLine = False
Do While True 'while there are any points...
result = Amoeba.GetPointDrag("Next dline point", vbNullString, vbNullString, 0, 0, StartPoint, EndPoint)
If result = A_GET_CANCEL Or result = A_GET_DEFAULT Or result = A_GET_KWORD Then
Exit Do 'Cancelled, so exit
End If
'continue prompting if distance of start and end points is less than EPSILON
Vector = Amoeba.G_SubVV(StartPoint, EndPoint)
If Amoeba.G_LenV(Vector) < EPSILON Then
GoTo LoopLabel
End If
'compute starting and ending points of double lines
Vector = Amoeba.G_SubVV(StartPoint, EndPoint)
PVector = Amoeba.G_PerpenV(Vector, 1)
V = Amoeba.G_MulVR(Amoeba.G_NormV(PVector), DlineWidth / 2)
S1 = Amoeba.G_AddVV(StartPoint, V)
E1 = Amoeba.G_AddVV(EndPoint, V)
PVector = Amoeba.G_PerpenV(Vector, 0)
V = Amoeba.G_MulVR(Amoeba.G_NormV(PVector), DlineWidth / 2)
S2 = Amoeba.G_AddVV(StartPoint, V)
E2 = Amoeba.G_AddVV(EndPoint, V)
If IsPrevLine Then
'this line is not the first one, so modify preceding lines according to computed intersections
Amoeba.LINE_Get PrevLine1, L1StartPoint, L1EndPoint, pLayer, pColor, pLineType, pWidth
Amoeba.LINE_Get PrevLine2, L2StartPoint, L2EndPoint, pLayer, pColor, pLineType, pWidth
Vector1 = Amoeba.G_SubVV(S1, E1)
Vector2 = Amoeba.G_SubVV(S2, E2)
'compute intersection of previous and new line #1
If Amoeba.G_IntersLL(L1StartPoint, Amoeba.G_SubVV(L1StartPoint, L1EndPoint), S1, Vector1, t1, t2) = 0 Then
Intersect1 = Amoeba.G_AddVV(Amoeba.G_MulVR(Amoeba.G_SubVV(L1StartPoint, L1EndPoint), t1), L1StartPoint)
'change previous line #1
Amoeba.LINE_Change PrevLine1, L1StartPoint, Intersect1, A_USE_CURRENT, A_USE_CURRENT, A_USE_CURRENT, 0
'compute intersection of previous and new line #2
If Amoeba.G_IntersLL(L2StartPoint, Amoeba.G_SubVV(L2StartPoint, L2EndPoint), S2, Vector2, t1, t2) = 0 Then
Intersect2 = Amoeba.G_AddVV(Amoeba.G_MulVR(Amoeba.G_SubVV(L2StartPoint, L2EndPoint), t1), L2StartPoint)
'change previous line #2
Amoeba.LINE_Change PrevLine2, L2StartPoint, Intersect2, A_USE_CURRENT, A_USE_CURRENT, A_USE_CURRENT, 0
End If
Else
If Amoeba.G_SMulVV(Amoeba.G_NormV(PrevVector), Amoeba.G_NormV(Vector)) < 0 Then
Intersect1 = L2EndPoint
Else
Intersect1 = L1EndPoint
End If
If Amoeba.G_SMulVV(Amoeba.G_NormV(PrevVector), Amoeba.G_NormV(Vector)) < 0 Then
Intersect2 = L1EndPoint
Else
Intersect2 = L2EndPoint
End If
End If
'draw first line
Amoeba.LINE_Make Intersect1, E1, A_USE_CURRENT, A_USE_CURRENT, A_USE_CURRENT, 0, False, PrevLine1
'draw second line
Amoeba.LINE_Make Intersect2, E2, A_USE_CURRENT, A_USE_CURRENT, A_USE_CURRENT, 0, False, PrevLine2
Else 'this is the first double line
'draw first line
Amoeba.LINE_Make S1, E1, A_USE_CURRENT, A_USE_CURRENT, A_USE_CURRENT, 0, False, PrevLine1
'draw second line
Amoeba.LINE_Make S2, E2, A_USE_CURRENT, A_USE_CURRENT, A_USE_CURRENT, 0, False, PrevLine2
End If
StartPoint = EndPoint
PrevVector = Vector
IsPrevLine = True
LoopLabel:
Loop
End Sub