-
Notifications
You must be signed in to change notification settings - Fork 1
/
FrmManualRoute.vb
143 lines (122 loc) · 5.62 KB
/
FrmManualRoute.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
Public Class FrmManualRoute
Public WithEvents PCB As PCB
Dim PadToCheck As Pad
Dim CheckWithPad As Pad
Dim Skipped As New List(Of Pad)
Private Sub FrmAutoRoute_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
PCB.UnHighlightAllObjects()
End Sub
Public Sub New(ByVal PCB As PCB)
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.PCB = PCB
End Sub
''' <summary>
''' Goes to the next check, takes selected pad as to check with or if none selected, takes the first pad found
''' </summary>
''' <remarks></remarks>
Public Sub NextCheck()
Dim SelectedPads As List(Of SelectableLayerObject)
If CheckWithPad IsNot Nothing Then
PCB.UnHighlightObject(CheckWithPad)
End If
If PadToCheck Is Nothing Then
SelectedPads = PCB.GetSelectedLayerObjects(GetType(Pad))
PCB.DeselectAllObjects()
If SelectedPads.Count > 0 Then
PadToCheck = CType(SelectedPads(0), Pad)
Else
PadToCheck = PCB.ConnectionMatrix.GetFirstUnconnectedPad()
End If
End If
If PadToCheck IsNot Nothing Then
CheckWithPad = PCB.ConnectionMatrix.GetNextToCheckPad(PadToCheck, True, Skipped)
If CheckWithPad IsNot Nothing Then
PCB.HighlightObject(CheckWithPad)
PCB.HighlightObject(PadToCheck)
lblCurrentPads.Text = PadToCheck.Name & " with " & CheckWithPad.Name
Else
PCB.UnHighlightObject(PadToCheck)
PadToCheck = Nothing
MsgBox("All connections tested for this pad, switching main pad!", MsgBoxStyle.Information)
NextCheck() 'go to next padtocheck
End If
Else
If Skipped.Count > 0 Then
MsgBox("All connections are tested except for the skipped items, will now test the skipped items", MsgBoxStyle.Information)
Skipped.Clear()
NextCheck()
Else
PCB.UnHighlightAllObjects()
MsgBox("Everything is connected!", MsgBoxStyle.Information)
End If
End If
PgbCompleted.Minimum = 0
PgbCompleted.Maximum = PCB.ConnectionMatrix.GetTotalConnections()
PgbCompleted.Value = PgbCompleted.Maximum - PCB.ConnectionMatrix.GetUnknownConnections()
End Sub
Private Sub CmdConnected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdConnected.Click
If PadToCheck IsNot Nothing AndAlso CheckWithPad IsNot Nothing Then
PCB.AddUndoItem(New UndoRedoConnect(PCB, True))
PCB.ConnectionMatrix.ConnectPads(PadToCheck, CheckWithPad)
NextCheck()
Else
MsgBox("Error no pads to check found", MsgBoxStyle.Critical)
End If
End Sub
Private Sub CmdNotConnected_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdNotConnected.Click
If PadToCheck IsNot Nothing AndAlso CheckWithPad IsNot Nothing Then
PCB.AddUndoItem(New UndoRedoConnect(PCB, True))
PCB.ConnectionMatrix.NotConnectPads(PadToCheck, CheckWithPad)
NextCheck()
Else
MsgBox("Error no pads to check found", MsgBoxStyle.Critical)
End If
End Sub
Private Sub CmdNotConnectedToAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdNotConnectedToAll.Click
If PadToCheck IsNot Nothing Then
PCB.AddUndoItem(New UndoRedoConnect(PCB, True))
PCB.ConnectionMatrix.NotConnectToAllPads(PadToCheck)
NextCheck()
End If
End Sub
Private Sub CmdSkip_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdSkip.Click
Skipped.Add(CheckWithPad)
NextCheck()
End Sub
Private Sub CmdNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdNext.Click
If FrmLayer.GetDrawstate() <> FrmLayer.DrawStates.AutoRouter Then
FrmLayer.ResetDrawState()
FrmLayer.SetDrawState(FrmLayer.DrawStates.AutoRouter) 'we go to autorouter mode
End If
NextCheck()
Me.CmdConnected.Enabled = True
Me.CmdNotConnectedToAll.Enabled = True
Me.CmdNotConnected.Enabled = True
Me.CmdSkip.Enabled = True
End Sub
Private Sub FrmAutoRoute_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ToolTip.SetToolTip(CmdNext, "Search and highlight pads to test.")
ToolTip.SetToolTip(CmdNotConnected, "The highlighted pads are NOT connected.")
ToolTip.SetToolTip(CmdSkip, "Skip this pad for now and go to the next one.")
ToolTip.SetToolTip(CmdConnected, "The highlighted pads are connected.")
End Sub
Public Sub MustSearchNext()
Me.CmdConnected.Enabled = False 'Objects were dehighlighted! we must search next first
Me.CmdNotConnected.Enabled = False
Me.CmdNotConnectedToAll.Enabled = False
Me.CmdSkip.Enabled = False
End Sub
''' <summary>
'''
''' </summary>
''' <param name="Sender"></param>
''' <param name="Objects"></param>
''' <remarks></remarks>
Private Sub PCB_ObjectsDeHighlighted(ByVal Sender As PCB, ByVal Objects As System.Collections.Generic.List(Of SelectableLayerObject)) Handles PCB.ObjectsDeHighlighted
If FrmLayer.GetDrawstate() <> FrmLayer.DrawStates.AutoRouter Then
MustSearchNext()
End If
End Sub
End Class