Major code cleanup and reconstruction
This commit is contained in:
parent
9ea5db86a2
commit
9b3cd22265
220
Wardrobe/GUI.vb
220
Wardrobe/GUI.vb
|
|
@ -1,220 +0,0 @@
|
|||
Imports XCCLibrary
|
||||
Imports Excel = Microsoft.Office.Interop.Excel
|
||||
|
||||
Public Class GUI
|
||||
'Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb"
|
||||
Public Shared filepath As String = "C:\Users\xperd\Documents"
|
||||
|
||||
Dim excelApp As Excel.Application = New Excel.Application
|
||||
Dim excelWB As Excel.Workbook
|
||||
|
||||
Public Shared dataBase As New Dictionary(Of String, DataTable)
|
||||
|
||||
' --- Start method (main) for GUI ---
|
||||
Sub GUI_load() Handles MyBase.Load
|
||||
Me.Width = 1400
|
||||
Me.Height = 800
|
||||
|
||||
AddHandler DrawingPanel.Paint, AddressOf GUI_Drawing_Panel.DrawingPanel_Paint
|
||||
GUI_Drawing_Panel.Load_DrawingPanel()
|
||||
|
||||
adminClass.loadSettings(GUI_Settings.filesFolder, GUI_Settings.HLCtFolder, "SolidWorks")
|
||||
|
||||
Get_Database()
|
||||
|
||||
CheckBox_WholeMeshWidths.Checked = True
|
||||
|
||||
GUI_Functions.pointsMeasurements.Add("Lmes", {1, 2, 1})
|
||||
GUI_Functions.pointsMeasurements.Add("Wmes", {2, 3, 2})
|
||||
|
||||
GUI_Functions.recessData.Columns.Add("RECESS TYPE", GetType(String))
|
||||
GUI_Functions.recessData.Columns.Add("CORNER", GetType(Integer))
|
||||
GUI_Functions.recessData.Columns.Add("SIDE", GetType(Integer))
|
||||
GUI_Functions.recessData.Columns.Add("WIDTH", GetType(Integer))
|
||||
GUI_Functions.recessData.Columns.Add("LENGTH", GetType(Integer))
|
||||
GUI_Functions.recessData.Columns.Add("OFFSET", GetType(Integer))
|
||||
End Sub
|
||||
|
||||
Private Sub Get_Database()
|
||||
'Make csv files of each sheet in excel
|
||||
Dim excelApp As Excel.Application = New Excel.Application
|
||||
Dim excelWB As Excel.Workbook
|
||||
excelApp.DisplayAlerts = False
|
||||
Dim wSNames As New List(Of String)
|
||||
excelWB = excelApp.Workbooks.Open(GUI_Settings.HLCtFolder & "\Database\Databas.xlsx")
|
||||
|
||||
For i = 1 To 4
|
||||
Dim activeSheet As Excel.Worksheet
|
||||
activeSheet = excelWB.Sheets(i)
|
||||
wSNames.Add(activeSheet.Name)
|
||||
activeSheet.SaveAs(GUI_Settings.HLCtFolder & "\Database\" & wSNames(i - 1), Excel.XlFileFormat.xlCSV)
|
||||
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(activeSheet)
|
||||
Next
|
||||
excelWB.Close()
|
||||
excelApp.Quit()
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(excelWB)
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp)
|
||||
|
||||
'For Each WS In excelWB.Worksheets
|
||||
' WS.SaveAs(GUI_Settings.HLCtFolder & ("\") & WS.Name, Excel.XlFileFormat.xlCSV)
|
||||
'Next
|
||||
|
||||
'Read all CSV files to datatables
|
||||
For i = 0 To wSNames.Count - 1
|
||||
Dim lines = IO.File.ReadAllLines(GUI_Settings.HLCtFolder & "\Database\" & wSNames(i) & ".csv")
|
||||
Dim tempDT As New DataTable
|
||||
Dim words As String() = lines(0).Split(New Char() {","c})
|
||||
|
||||
For j = 0 To words.Count - 1
|
||||
Dim colName As String = words(j).Split("[")(0)
|
||||
colName = colName.Substring(0, colName.Length - 1)
|
||||
Dim type As String = words(j).Split("[")(1).Split("]")(0)
|
||||
|
||||
If type = "str" Then
|
||||
tempDT.Columns.Add(colName, GetType(String))
|
||||
ElseIf type = "int" Then
|
||||
tempDT.Columns.Add(colName, GetType(Integer))
|
||||
ElseIf type = "doub" Then
|
||||
tempDT.Columns.Add(colName, GetType(String)) 'FIXA
|
||||
Else
|
||||
tempDT.Columns.Add(colName, GetType(Boolean))
|
||||
End If
|
||||
Next
|
||||
|
||||
For j = 1 To lines.Count - 1
|
||||
Dim values As String() = lines(j).Split(New Char() {","c})
|
||||
tempDT.Rows.Add()
|
||||
For k = 0 To values.Count - 1
|
||||
Try
|
||||
tempDT.Rows(tempDT.Rows.Count - 1)(k) = values(k)
|
||||
Catch ex As Exception
|
||||
If values(k) <> "" AndAlso values(k) = 0 Then
|
||||
tempDT.Rows(tempDT.Rows.Count - 1)(k) = False
|
||||
ElseIf values(k) <> "" AndAlso values(k) = 1 Then
|
||||
tempDT.Rows(tempDT.Rows.Count - 1)(k) = True
|
||||
End If
|
||||
End Try
|
||||
Next
|
||||
Next
|
||||
dataBase.Add(wSNames(i), tempDT)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Public Sub Create_TextBox(TextBoxName As String, TextBoxText As String, TextBoxLeft As Integer, TextBoxTop As Integer,
|
||||
TextBoxWidth As Integer)
|
||||
Dim textBoxTemp As New TextBox
|
||||
textBoxTemp.Name = TextBoxName
|
||||
textBoxTemp.Text = TextBoxText
|
||||
textBoxTemp.Left = TextBoxLeft
|
||||
textBoxTemp.Top = TextBoxTop
|
||||
textBoxTemp.Width = TextBoxWidth
|
||||
textBoxTemp.Font = New Font("Microsoft Sans Serif", 10)
|
||||
Me.Controls.Add(textBoxTemp)
|
||||
End Sub
|
||||
|
||||
Public Sub Create_LabelGUI(LabelName As String, LabelText As String, LabelLeft As Integer, LabelTop As Integer)
|
||||
Dim LabelTemp As New Label
|
||||
LabelTemp.Name = LabelName
|
||||
LabelTemp.Text = LabelText
|
||||
LabelTemp.Left = LabelLeft
|
||||
LabelTemp.Top = LabelTop
|
||||
LabelTemp.Font = New Font("Microsoft Sans Serif", 10)
|
||||
Me.Controls.Add(LabelTemp)
|
||||
End Sub
|
||||
|
||||
Public Sub Create_LabelPanel(LabelName As String, LabelText As String, LabelLeft As Integer, LabelTop As Integer)
|
||||
Dim LabelTemp As New Label
|
||||
LabelTemp.Name = LabelName
|
||||
LabelTemp.Text = LabelText
|
||||
LabelTemp.Left = LabelLeft
|
||||
LabelTemp.Top = LabelTop
|
||||
LabelTemp.Font = New Font("Microsoft Sans Serif", 7)
|
||||
LabelTemp.BackColor = Color.Transparent
|
||||
DrawingPanel.Controls.Add(LabelTemp)
|
||||
End Sub
|
||||
|
||||
' ---------------------------------- Gratings Data ----------------------------------
|
||||
' --- When user changes grating type ---
|
||||
Private Sub ComboBox_TypeChooser_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_TypeChooser.TextChanged
|
||||
GUI_Gratings_Data.TypeChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
|
||||
' --- When user changes grating material ---
|
||||
Private Sub ComboBox_Material_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Material.TextChanged
|
||||
GUI_Gratings_Data.MaterialChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- When user changes mesh size ---
|
||||
Private Sub ComboBox_MeshSize_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_MeshSize.TextChanged
|
||||
GUI_Gratings_Data.MeshChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- When user changes grating height ---
|
||||
Private Sub ComboBox_Height_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Height.TextChanged
|
||||
GUI_Gratings_Data.HeightChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- When user changes grating thickness ---
|
||||
Private Sub ComboBox_Thickness_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Thickness.TextChanged
|
||||
GUI_Gratings_Data.ThicknessChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
Private Sub CheckBox_WholeMeshWidths_CheckedChanged(sender As Object, e As EventArgs) _
|
||||
Handles CheckBox_WholeMeshWidths.CheckedChanged
|
||||
|
||||
GUI_Gratings_Data.WholeMeshWidthsChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- Grating width changed ---
|
||||
Private Sub WidthB_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Width.TextChanged
|
||||
GUI_Gratings_Data.WidthChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- Check if width is a number ---
|
||||
Private Sub ComboBox_Width_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ComboBox_Width.KeyPress
|
||||
GUI_Gratings_Data.Check_IfNumber(e)
|
||||
End Sub
|
||||
|
||||
' --- Grating length changed ---
|
||||
Private Sub LengthBox_TextChanged(sender As Object, e As EventArgs) Handles TextBox_Length.TextChanged
|
||||
GUI_Gratings_Data.LengthChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- Check if length is a number ---
|
||||
Private Sub ComboBox_Length_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox_Length.KeyPress
|
||||
GUI_Gratings_Data.Check_IfNumber(e)
|
||||
End Sub
|
||||
|
||||
' ---------------------------------- Functions ----------------------------------
|
||||
' --- When angle button is pressed ---
|
||||
Private Sub AngleButton_Click(sender As Object, e As EventArgs) Handles AngleButton.Click
|
||||
GUI_Functions.AngleButton(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- When square corner button is pressed ---
|
||||
Private Sub Button_Square_Click(sender As Object, e As EventArgs) Handles Button_Square.Click
|
||||
GUI_Functions.SquareButtton(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- When square side button is pressed ---
|
||||
Private Sub Button_SquareSide_Click(sender As Object, e As EventArgs) Handles Button_SquareSide.Click
|
||||
GUI_Functions.SquareSideButtton(sender, e)
|
||||
End Sub
|
||||
|
||||
' ---------------------------------- Settings ----------------------------------
|
||||
' --- Settings button clicked ---
|
||||
Private Sub SettingsButton_Click(sender As Object, e As EventArgs) Handles SettingsButton.Click
|
||||
GUI_Settings.ButtonClicked(sender, e)
|
||||
End Sub
|
||||
|
||||
' ---------------------------------- Export to SW ----------------------------------
|
||||
' --- When export to SW button is pressed ---
|
||||
Private Sub ExportSWButton_Click(sender As Object, e As EventArgs) Handles ExportSWButton.Click
|
||||
SW_HLCt_Gratings.BuildGrating()
|
||||
'SW_Drawing_Gratings.CreateDrawing()
|
||||
End Sub
|
||||
|
||||
|
||||
End Class
|
||||
|
|
@ -0,0 +1,245 @@
|
|||
Public Class Draw_Grating
|
||||
Private Shared guiPanelL, guiPanelW As Integer
|
||||
|
||||
Private Shared DirSymbolPoints As New Dictionary(Of String, Integer())
|
||||
Private Shared ArrowSymbolPoints As New Dictionary(Of String, Integer())
|
||||
|
||||
Public Shared measureLabels As New Dictionary(Of String, Integer())
|
||||
|
||||
Public Shared sideSquareMesLine As New Dictionary(Of String, Integer())
|
||||
|
||||
|
||||
Public Shared Sub Load_DrawingPanel()
|
||||
AddHandler GUI.DrawingPanel.Paint, AddressOf DrawingPanel_Paint
|
||||
|
||||
Get_DrawboxParameters()
|
||||
|
||||
Create_DirSymbolPoints()
|
||||
Create_ArrowSymbolPoints()
|
||||
|
||||
' Initialize start points
|
||||
Data.Init_GrossAreaPoints()
|
||||
Data.Init_GratingPoints()
|
||||
|
||||
Update_GratingPoints()
|
||||
End Sub
|
||||
|
||||
' --- Retrive parameters for the drawing box ---
|
||||
Private Shared Sub Get_DrawboxParameters()
|
||||
guiPanelL = GUI.DrawingPanel.Size.Width
|
||||
guiPanelW = GUI.DrawingPanel.Size.Height
|
||||
|
||||
Data.guiPanelMidX = guiPanelL / 2
|
||||
Data.guiPanelMidY = guiPanelW / 2
|
||||
|
||||
Data.guiMaxDrawL = guiPanelL - 80
|
||||
Data.guiMaxDrawW = guiPanelW - 80
|
||||
|
||||
Data.drawAR = Data.guiMaxDrawL / Data.guiMaxDrawW
|
||||
|
||||
Data.gratingAR = Data.gratingL / Data.gratingW
|
||||
End Sub
|
||||
|
||||
' --- Create points for grating direction symbol ---
|
||||
Private Shared Sub Create_DirSymbolPoints()
|
||||
DirSymbolPoints.Add("p1", {-30 + Data.guiPanelMidX, -2 + Data.guiPanelMidY})
|
||||
DirSymbolPoints.Add("p2", {20 + Data.guiPanelMidX, -2 + Data.guiPanelMidY})
|
||||
DirSymbolPoints.Add("p3", {12 + Data.guiPanelMidX, -10 + Data.guiPanelMidY})
|
||||
DirSymbolPoints.Add("p4", {15 + Data.guiPanelMidX, -13 + Data.guiPanelMidY})
|
||||
DirSymbolPoints.Add("p5", {30 + Data.guiPanelMidX, 2 + Data.guiPanelMidY})
|
||||
DirSymbolPoints.Add("p6", {-20 + Data.guiPanelMidX, 2 + Data.guiPanelMidY})
|
||||
DirSymbolPoints.Add("p7", {-12 + Data.guiPanelMidX, 10 + Data.guiPanelMidY})
|
||||
DirSymbolPoints.Add("p8", {-15 + Data.guiPanelMidX, 13 + Data.guiPanelMidY})
|
||||
DirSymbolPoints.Add("p9", {-30 + Data.guiPanelMidX, -2 + Data.guiPanelMidY})
|
||||
End Sub
|
||||
|
||||
' --- Create points for arrow symbol ---
|
||||
Private Shared Sub Create_ArrowSymbolPoints()
|
||||
Dim offset As Integer = 20
|
||||
ArrowSymbolPoints.Add("p1", {offset, guiPanelW - offset})
|
||||
ArrowSymbolPoints.Add("p2", {offset, guiPanelW - offset - 40})
|
||||
ArrowSymbolPoints.Add("p3", {offset - 5, guiPanelW - offset - 35})
|
||||
ArrowSymbolPoints.Add("p4", {offset, guiPanelW - offset - 40})
|
||||
ArrowSymbolPoints.Add("p5", {offset + 5, guiPanelW - offset - 35})
|
||||
ArrowSymbolPoints.Add("p6", {offset, guiPanelW - offset - 40})
|
||||
ArrowSymbolPoints.Add("p7", {offset, guiPanelW - offset})
|
||||
ArrowSymbolPoints.Add("p8", {offset + 40, guiPanelW - offset})
|
||||
ArrowSymbolPoints.Add("p9", {offset + 35, guiPanelW - offset - 5})
|
||||
ArrowSymbolPoints.Add("p10", {offset + 40, guiPanelW - offset})
|
||||
ArrowSymbolPoints.Add("p11", {offset + 35, guiPanelW - offset + 5})
|
||||
End Sub
|
||||
|
||||
' --- Updates all the gratings points ---
|
||||
Public Shared Sub Update_GratingPoints()
|
||||
Data.gratingAR = Data.gratingL / Data.gratingW
|
||||
|
||||
If Data.gratingAR < Data.drawAR Then
|
||||
' Change draw width
|
||||
Data.scaleDiff = Data.gratingW / Data.guiMaxDrawW
|
||||
' Gross area points
|
||||
Data.grossAreaPoints.Rows(0)("GUI X") = Data.guiPanelMidX - Data.gratingL / (Data.scaleDiff * 2)
|
||||
Data.grossAreaPoints.Rows(0)("GUI Y") = Data.guiPanelMidY - Data.guiMaxDrawW / 2
|
||||
Data.grossAreaPoints.Rows(1)("GUI X") = Data.guiPanelMidX + Data.gratingL / (Data.scaleDiff * 2)
|
||||
Data.grossAreaPoints.Rows(1)("GUI Y") = Data.guiPanelMidY - Data.guiMaxDrawW / 2
|
||||
Data.grossAreaPoints.Rows(2)("GUI X") = Data.guiPanelMidX + Data.gratingL / (Data.scaleDiff * 2)
|
||||
Data.grossAreaPoints.Rows(2)("GUI Y") = Data.guiPanelMidY + Data.guiMaxDrawW / 2
|
||||
Data.grossAreaPoints.Rows(3)("GUI X") = Data.guiPanelMidX - Data.gratingL / (Data.scaleDiff * 2)
|
||||
Data.grossAreaPoints.Rows(3)("GUI Y") = Data.guiPanelMidY + Data.guiMaxDrawW / 2
|
||||
|
||||
' Grating points
|
||||
Data.gratingPoints.Rows(0)("GUI X") = Data.guiPanelMidX - Data.gratingL / (Data.scaleDiff * 2)
|
||||
Data.gratingPoints.Rows(0)("GUI Y") = Data.guiPanelMidY - Data.guiMaxDrawW / 2
|
||||
Data.gratingPoints.Rows(1)("GUI X") = Data.guiPanelMidX + Data.gratingL / (Data.scaleDiff * 2)
|
||||
Data.gratingPoints.Rows(1)("GUI Y") = Data.guiPanelMidY - Data.guiMaxDrawW / 2
|
||||
Data.gratingPoints.Rows(2)("GUI X") = Data.guiPanelMidX + Data.gratingL / (Data.scaleDiff * 2)
|
||||
Data.gratingPoints.Rows(2)("GUI Y") = Data.guiPanelMidY + Data.guiMaxDrawW / 2
|
||||
Data.gratingPoints.Rows(3)("GUI X") = Data.guiPanelMidX - Data.gratingL / (Data.scaleDiff * 2)
|
||||
Data.gratingPoints.Rows(3)("GUI Y") = Data.guiPanelMidY + Data.guiMaxDrawW / 2
|
||||
|
||||
Else
|
||||
' Change draw height
|
||||
Data.scaleDiff = Data.gratingL / Data.guiMaxDrawL
|
||||
|
||||
' Gross area points
|
||||
Data.grossAreaPoints.Rows(0)("GUI X") = Data.guiPanelMidX - Data.guiMaxDrawL / 2
|
||||
Data.grossAreaPoints.Rows(0)("GUI Y") = Data.guiPanelMidY - Data.gratingW / (Data.scaleDiff * 2)
|
||||
Data.grossAreaPoints.Rows(1)("GUI X") = Data.guiPanelMidX + Data.guiMaxDrawL / 2
|
||||
Data.grossAreaPoints.Rows(1)("GUI Y") = Data.guiPanelMidY - Data.gratingW / (Data.scaleDiff * 2)
|
||||
Data.grossAreaPoints.Rows(2)("GUI X") = Data.guiPanelMidX + Data.guiMaxDrawL / 2
|
||||
Data.grossAreaPoints.Rows(2)("GUI Y") = Data.guiPanelMidY + Data.gratingW / (Data.scaleDiff * 2)
|
||||
Data.grossAreaPoints.Rows(3)("GUI X") = Data.guiPanelMidX - Data.guiMaxDrawL / 2
|
||||
Data.grossAreaPoints.Rows(3)("GUI Y") = Data.guiPanelMidY + Data.gratingW / (Data.scaleDiff * 2)
|
||||
|
||||
' Grating points
|
||||
Data.gratingPoints.Rows(0)("GUI X") = Data.guiPanelMidX - Data.guiMaxDrawL / 2
|
||||
Data.gratingPoints.Rows(0)("GUI Y") = Data.guiPanelMidY - Data.gratingW / (Data.scaleDiff * 2)
|
||||
Data.gratingPoints.Rows(1)("GUI X") = Data.guiPanelMidX + Data.guiMaxDrawL / 2
|
||||
Data.gratingPoints.Rows(1)("GUI Y") = Data.guiPanelMidY - Data.gratingW / (Data.scaleDiff * 2)
|
||||
Data.gratingPoints.Rows(2)("GUI X") = Data.guiPanelMidX + Data.guiMaxDrawL / 2
|
||||
Data.gratingPoints.Rows(2)("GUI Y") = Data.guiPanelMidY + Data.gratingW / (Data.scaleDiff * 2)
|
||||
Data.gratingPoints.Rows(3)("GUI X") = Data.guiPanelMidX - Data.guiMaxDrawL / 2
|
||||
Data.gratingPoints.Rows(3)("GUI Y") = Data.guiPanelMidY + Data.gratingW / (Data.scaleDiff * 2)
|
||||
End If
|
||||
|
||||
' Gross area points
|
||||
Data.grossAreaPoints.Rows(0)("X") = (-Data.gratingL / 2) / 1000
|
||||
Data.grossAreaPoints.Rows(0)("Y") = (Data.gratingW / 2) / 1000
|
||||
Data.grossAreaPoints.Rows(1)("X") = (Data.gratingL / 2) / 1000
|
||||
Data.grossAreaPoints.Rows(1)("Y") = (Data.gratingW / 2) / 1000
|
||||
Data.grossAreaPoints.Rows(2)("X") = (Data.gratingL / 2) / 1000
|
||||
Data.grossAreaPoints.Rows(2)("Y") = (-Data.gratingW / 2) / 1000
|
||||
Data.grossAreaPoints.Rows(3)("X") = (-Data.gratingL / 2) / 1000
|
||||
Data.grossAreaPoints.Rows(3)("Y") = (-Data.gratingW / 2) / 1000
|
||||
|
||||
' Grating points
|
||||
Data.gratingPoints.Rows(0)("X") = (-Data.gratingL / 2) / 1000
|
||||
Data.gratingPoints.Rows(0)("Y") = (Data.gratingW / 2) / 1000
|
||||
Data.gratingPoints.Rows(1)("X") = (Data.gratingL / 2) / 1000
|
||||
Data.gratingPoints.Rows(1)("Y") = (Data.gratingW / 2) / 1000
|
||||
Data.gratingPoints.Rows(2)("X") = (Data.gratingL / 2) / 1000
|
||||
Data.gratingPoints.Rows(2)("Y") = (-Data.gratingW / 2) / 1000
|
||||
Data.gratingPoints.Rows(3)("X") = (-Data.gratingL / 2) / 1000
|
||||
Data.gratingPoints.Rows(3)("Y") = (-Data.gratingW / 2) / 1000
|
||||
|
||||
GUI.DrawingPanel.Refresh()
|
||||
End Sub
|
||||
|
||||
' --- Draw all the lines for the panel and grating ---
|
||||
Public Shared Sub DrawingPanel_Paint(sender As Object, e As PaintEventArgs)
|
||||
' Draw grating gross area (red)
|
||||
Dim penCon As Pen = New Pen(Color.Red, 2)
|
||||
penCon.DashPattern = {4, 6}
|
||||
e.Graphics.DrawLine(penCon, Data.grossAreaPoints(0)("GUI X"), Data.grossAreaPoints(0)("GUI Y"),
|
||||
Data.grossAreaPoints(1)("GUI X"), Data.grossAreaPoints(1)("GUI Y"))
|
||||
e.Graphics.DrawLine(penCon, Data.grossAreaPoints(1)("GUI X"), Data.grossAreaPoints(1)("GUI Y"),
|
||||
Data.grossAreaPoints(2)("GUI X"), Data.grossAreaPoints(2)("GUI Y"))
|
||||
e.Graphics.DrawLine(penCon, Data.grossAreaPoints(2)("GUI X"), Data.grossAreaPoints(2)("GUI Y"),
|
||||
Data.grossAreaPoints(3)("GUI X"), Data.grossAreaPoints(3)("GUI Y"))
|
||||
e.Graphics.DrawLine(penCon, Data.grossAreaPoints(3)("GUI X"), Data.grossAreaPoints(3)("GUI Y"),
|
||||
Data.grossAreaPoints(0)("GUI X"), Data.grossAreaPoints(0)("GUI Y"))
|
||||
|
||||
' Draw grating direction symbol
|
||||
Dim symPen As Pen = New Pen(Color.Black, 1)
|
||||
For i = 1 To DirSymbolPoints.Count - 1
|
||||
e.Graphics.DrawLine(symPen, DirSymbolPoints("p" & i)(0), DirSymbolPoints("p" & i)(1),
|
||||
DirSymbolPoints("p" & i + 1)(0), DirSymbolPoints("p" & i + 1)(1))
|
||||
Next
|
||||
|
||||
' Draw arrow symbol
|
||||
For i = 1 To ArrowSymbolPoints.Count - 1
|
||||
e.Graphics.DrawLine(symPen, ArrowSymbolPoints("p" & i)(0), ArrowSymbolPoints("p" & i)(1),
|
||||
ArrowSymbolPoints("p" & i + 1)(0), ArrowSymbolPoints("p" & i + 1)(1))
|
||||
Next
|
||||
|
||||
' Draw measure labels
|
||||
For i = 0 To measureLabels.Count - 1
|
||||
Dim mesName As String = measureLabels.Keys(i)
|
||||
e.Graphics.DrawString(measureLabels(mesName)(0), New Font("Microsoft Sans Serif", 7), Brushes.Black,
|
||||
New Point(measureLabels(mesName)(1), measureLabels(mesName)(2)))
|
||||
Next
|
||||
|
||||
'Stöd measurement linje för sidesquare
|
||||
Dim penMes As Pen = New Pen(Color.Gray, 1)
|
||||
For i = 0 To sideSquareMesLine.Count - 1
|
||||
Dim mesName As String = sideSquareMesLine.Keys(i)
|
||||
e.Graphics.DrawLine(penMes, sideSquareMesLine(mesName)(0), sideSquareMesLine(mesName)(1),
|
||||
sideSquareMesLine(mesName)(2), sideSquareMesLine(mesName)(3))
|
||||
|
||||
If Data.pointsMeasurements(mesName)(2) = 1 OrElse Data.pointsMeasurements(mesName)(2) = 3 Then
|
||||
e.Graphics.DrawLine(penMes, sideSquareMesLine(mesName)(0), sideSquareMesLine(mesName)(1) + 2,
|
||||
sideSquareMesLine(mesName)(0), sideSquareMesLine(mesName)(1) - 2)
|
||||
e.Graphics.DrawLine(penMes, sideSquareMesLine(mesName)(2), sideSquareMesLine(mesName)(1) + 2,
|
||||
sideSquareMesLine(mesName)(2), sideSquareMesLine(mesName)(1) - 2)
|
||||
Else
|
||||
e.Graphics.DrawLine(penMes, sideSquareMesLine(mesName)(0) + 2, sideSquareMesLine(mesName)(1),
|
||||
sideSquareMesLine(mesName)(0) - 2, sideSquareMesLine(mesName)(1))
|
||||
e.Graphics.DrawLine(penMes, sideSquareMesLine(mesName)(0) + 2, sideSquareMesLine(mesName)(3),
|
||||
sideSquareMesLine(mesName)(0) - 2, sideSquareMesLine(mesName)(3))
|
||||
End If
|
||||
Next
|
||||
|
||||
' Draw angle recess help lines
|
||||
Dim Pendot As Pen = New Pen(Color.Gray, 1)
|
||||
Pendot.DashPattern = {2, 4}
|
||||
|
||||
For i = 0 To Data.angleRecessPoints.Rows.Count - 1
|
||||
Dim angleQuadrant As String = Data.angleRecessPoints.Rows(i)("QUADRANT")
|
||||
Dim p1XGUI, p1YGUI, p2XGUI, p2YGUI As Integer
|
||||
For Each DR As DataRow In Data.gratingPoints.Rows
|
||||
If DR("NAME").Split("_")(0) = "CA" & angleQuadrant Then
|
||||
Dim index As Integer = Data.gratingPoints.Rows.IndexOf(DR)
|
||||
p1XGUI = Data.gratingPoints.Rows(index)("GUI X")
|
||||
p1YGUI = Data.gratingPoints.Rows(index)("GUI Y")
|
||||
p2XGUI = Data.gratingPoints.Rows(index + 1)("GUI X")
|
||||
p2YGUI = Data.gratingPoints.Rows(index + 1)("GUI Y")
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
e.Graphics.DrawLine(Pendot, Data.angleRecessPoints.Rows(i)("GUI X"), Data.angleRecessPoints.Rows(i)("GUI Y"),
|
||||
p1XGUI, p1YGUI)
|
||||
e.Graphics.DrawLine(Pendot, Data.angleRecessPoints.Rows(i)("GUI X"), Data.angleRecessPoints.Rows(i)("GUI Y"),
|
||||
p2XGUI, p2YGUI)
|
||||
Next
|
||||
|
||||
|
||||
' Draw actual grating (black)
|
||||
Dim pen As Pen = New Pen(Color.Black, 2)
|
||||
For i = 0 To Data.gratingPoints.Rows.Count - 1
|
||||
Dim pTemp1(2) As Integer
|
||||
Dim pTemp2(2) As Integer
|
||||
|
||||
pTemp1(0) = Data.gratingPoints.Rows(i)("GUI X")
|
||||
pTemp1(1) = Data.gratingPoints.Rows(i)("GUI Y")
|
||||
Try
|
||||
pTemp2(0) = Data.gratingPoints.Rows(i + 1)("GUI X")
|
||||
pTemp2(1) = Data.gratingPoints.Rows(i + 1)("GUI Y")
|
||||
Catch ex As Exception
|
||||
pTemp2(0) = Data.gratingPoints.Rows(0)("GUI X")
|
||||
pTemp2(1) = Data.gratingPoints.Rows(0)("GUI Y")
|
||||
End Try
|
||||
|
||||
e.Graphics.DrawLine(pen, pTemp1(0), pTemp1(1), pTemp2(0), pTemp2(1))
|
||||
Next
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
|
@ -125,6 +125,7 @@ Partial Class GUI
|
|||
'
|
||||
'AngleButton
|
||||
'
|
||||
Me.AngleButton.Enabled = False
|
||||
Me.AngleButton.Location = New System.Drawing.Point(705, 68)
|
||||
Me.AngleButton.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
|
||||
Me.AngleButton.Name = "AngleButton"
|
||||
|
|
@ -260,8 +261,9 @@ Partial Class GUI
|
|||
'
|
||||
'Button_Square
|
||||
'
|
||||
Me.Button_Square.Enabled = False
|
||||
Me.Button_Square.Location = New System.Drawing.Point(955, 68)
|
||||
Me.Button_Square.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)
|
||||
Me.Button_Square.Margin = New System.Windows.Forms.Padding(4)
|
||||
Me.Button_Square.Name = "Button_Square"
|
||||
Me.Button_Square.Size = New System.Drawing.Size(123, 34)
|
||||
Me.Button_Square.TabIndex = 25
|
||||
|
|
@ -326,6 +328,7 @@ Partial Class GUI
|
|||
'
|
||||
'Button_SquareSide
|
||||
'
|
||||
Me.Button_SquareSide.Enabled = False
|
||||
Me.Button_SquareSide.Location = New System.Drawing.Point(1224, 68)
|
||||
Me.Button_SquareSide.Name = "Button_SquareSide"
|
||||
Me.Button_SquareSide.Size = New System.Drawing.Size(121, 35)
|
||||
|
|
@ -363,7 +366,7 @@ Partial Class GUI
|
|||
Me.Controls.Add(Me.DrawingPanel)
|
||||
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
|
||||
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
|
||||
Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)
|
||||
Me.Margin = New System.Windows.Forms.Padding(4)
|
||||
Me.MaximizeBox = False
|
||||
Me.Name = "GUI"
|
||||
Me.Text = "Floor Gratings"
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
Imports XCCLibrary
|
||||
Public Class GUI
|
||||
Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb"
|
||||
'Public Shared filepath As String = "C:\Users\xperd\Documents"
|
||||
|
||||
' --- Start method (main) for GUI ---
|
||||
Sub GUI_load() Handles MyBase.Load
|
||||
' Initialize GUI
|
||||
Init_Form()
|
||||
|
||||
' Initialize DataTables, Measurments and more
|
||||
Data.Init_Data()
|
||||
|
||||
' Initialize DrawingPanel
|
||||
Draw_Grating.Load_DrawingPanel()
|
||||
|
||||
' Get floor gratings database
|
||||
Database.Retrive_Database()
|
||||
|
||||
' Load XCC settings
|
||||
adminClass.loadSettings(Settings.filesFolder, Settings.HLCtFolder, "SolidWorks")
|
||||
End Sub
|
||||
|
||||
' --- Initialize GUI (form) size and position ---
|
||||
Private Sub Init_Form()
|
||||
Me.Width = 1400
|
||||
Me.Height = 800
|
||||
Me.Top = 20
|
||||
Me.Left = 50
|
||||
End Sub
|
||||
|
||||
|
||||
' ---------------------------------- GUI Templates ----------------------------------
|
||||
' --- TextBox Template ---
|
||||
Public Sub Create_TextBox(TextBoxName As String, TextBoxText As String, TextBoxLeft As Integer, TextBoxTop As Integer,
|
||||
TextBoxWidth As Integer)
|
||||
Dim textBoxTemp As New TextBox With {
|
||||
.Name = TextBoxName,
|
||||
.Text = TextBoxText,
|
||||
.Left = TextBoxLeft,
|
||||
.Top = TextBoxTop,
|
||||
.Width = TextBoxWidth,
|
||||
.Font = New Font("Microsoft Sans Serif", 10)
|
||||
}
|
||||
Me.Controls.Add(textBoxTemp)
|
||||
End Sub
|
||||
|
||||
' --- Label Template for GUI ---
|
||||
Public Sub Create_LabelGUI(LabelName As String, LabelText As String, LabelLeft As Integer, LabelTop As Integer)
|
||||
Dim LabelTemp As New Label With {
|
||||
.Name = LabelName,
|
||||
.Text = LabelText,
|
||||
.Left = LabelLeft,
|
||||
.Top = LabelTop,
|
||||
.Font = New Font("Microsoft Sans Serif", 10)
|
||||
}
|
||||
Me.Controls.Add(LabelTemp)
|
||||
End Sub
|
||||
|
||||
|
||||
' ---------------------------------- Gratings Data ----------------------------------
|
||||
' --- When user changes grating type ---
|
||||
Private Sub ComboBox_TypeChooser_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_TypeChooser.TextChanged
|
||||
User_Input.TypeChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
|
||||
' --- When user changes grating material ---
|
||||
Private Sub ComboBox_Material_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Material.TextChanged
|
||||
User_Input.MaterialChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- When user changes mesh size ---
|
||||
Private Sub ComboBox_MeshSize_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_MeshSize.TextChanged
|
||||
User_Input.MeshChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- When user changes grating height ---
|
||||
Private Sub ComboBox_Height_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Height.TextChanged
|
||||
User_Input.HeightChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- When user changes grating thickness ---
|
||||
Private Sub ComboBox_Thickness_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Thickness.TextChanged
|
||||
User_Input.ThicknessChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- When user checkes/uncheckes whole meshes ---
|
||||
Private Sub CheckBox_WholeMeshWidths_CheckedChanged(sender As Object, e As EventArgs) _
|
||||
Handles CheckBox_WholeMeshWidths.CheckedChanged
|
||||
|
||||
User_Input.WholeMeshWidthsChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- Grating width changed ---
|
||||
Private Sub WidthB_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Width.TextChanged
|
||||
User_Input.WidthChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- Check if width is a number ---
|
||||
Private Sub ComboBox_Width_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ComboBox_Width.KeyPress
|
||||
User_Input.Check_IfNumber(e)
|
||||
End Sub
|
||||
|
||||
' --- Grating length changed ---
|
||||
Private Sub LengthBox_TextChanged(sender As Object, e As EventArgs) Handles TextBox_Length.TextChanged
|
||||
User_Input.LengthChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- Check if length is a number ---
|
||||
Private Sub ComboBox_Length_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox_Length.KeyPress
|
||||
User_Input.Check_IfNumber(e)
|
||||
End Sub
|
||||
|
||||
' ---------------------------------- Functions ----------------------------------
|
||||
' --- When angle button is pressed ---
|
||||
Private Sub AngleButton_Click(sender As Object, e As EventArgs) Handles AngleButton.Click
|
||||
Corner_Angle.AngleButton(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- When square corner button is pressed ---
|
||||
Private Sub Button_Square_Click(sender As Object, e As EventArgs) Handles Button_Square.Click
|
||||
Corner_Rectangle.SquareButtton(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- When square side button is pressed ---
|
||||
Private Sub Button_SquareSide_Click(sender As Object, e As EventArgs) Handles Button_SquareSide.Click
|
||||
Side_Rectangle.SquareSideButtton(sender, e)
|
||||
End Sub
|
||||
|
||||
' ---------------------------------- Settings ----------------------------------
|
||||
' --- Settings button clicked ---
|
||||
Private Sub SettingsButton_Click(sender As Object, e As EventArgs) Handles SettingsButton.Click
|
||||
Settings.ButtonClicked(sender, e)
|
||||
End Sub
|
||||
|
||||
' ---------------------------------- Export to SW ----------------------------------
|
||||
' --- When export to SW button is pressed ---
|
||||
Private Sub ExportSWButton_Click(sender As Object, e As EventArgs) Handles ExportSWButton.Click
|
||||
Model_3D.BuildGrating()
|
||||
Drawing.CreateDrawing()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
|
@ -1,14 +1,10 @@
|
|||
Imports XCCLibrary
|
||||
Imports Excel = Microsoft.Office.Interop.Excel
|
||||
|
||||
Public Class GUI_Settings
|
||||
Public Class Settings
|
||||
Public Shared filesFolder As String = GUI.filepath ' Hämta från settings
|
||||
Public Shared HLCtFolder As String = GUI.filepath & "\X2021" ' Hämta från settings
|
||||
|
||||
' --- Settings button clicked ---
|
||||
Public Shared Sub ButtonClicked(sender As Object, e As EventArgs)
|
||||
|
||||
|
||||
adminClass.updateDatabase() 'Update KB
|
||||
adminClass.updateDatabase() 'Update KB - should be its own button inside of a settings form
|
||||
End Sub
|
||||
End Class
|
||||
|
|
@ -1,240 +0,0 @@
|
|||
Public Class GUI_Drawing_Panel
|
||||
Public Shared pCon1(3) As Decimal 'pCon(0) = pixel X, pCon(2) = SW X, etc.
|
||||
Public Shared pCon2(3) As Decimal
|
||||
Public Shared pCon3(3) As Decimal
|
||||
Public Shared pCon4(3) As Decimal
|
||||
|
||||
Public Shared containerL, containerW, containerMidX, containerMidY As Integer
|
||||
Private Shared drawL As Integer = 1
|
||||
Private Shared drawW As Integer = 1
|
||||
|
||||
Private Shared DirSymbolPoints As New Dictionary(Of String, Decimal())
|
||||
Private Shared ArrowSymbolPoints As New Dictionary(Of String, Decimal())
|
||||
|
||||
Public Shared measureLabels As New Dictionary(Of String, Integer())
|
||||
|
||||
Private Shared drawAspect, gratingAspect As Decimal
|
||||
Public Shared scaleDiff As Decimal = 1
|
||||
|
||||
Public Shared pointsOrder As New List(Of String)
|
||||
Public Shared points As New Dictionary(Of String, Decimal())
|
||||
|
||||
Public Shared anglePoints As New Dictionary(Of String, Integer())
|
||||
Public Shared anglePointsComp As New Dictionary(Of String, String())
|
||||
|
||||
Public Shared sideSquareMesLine As New Dictionary(Of String, Integer())
|
||||
|
||||
|
||||
Public Shared Sub Load_DrawingPanel()
|
||||
Get_DrawboxParameters()
|
||||
Set_ContainerPointsX()
|
||||
Set_ContainerPointsY()
|
||||
|
||||
Create_DirSymbolPoints()
|
||||
Create_ArrowSymbolPoints()
|
||||
Update_GratingPoints()
|
||||
Create_StartPoints()
|
||||
End Sub
|
||||
|
||||
' --- Retrive parameters for the drawing box ---
|
||||
Private Shared Sub Get_DrawboxParameters()
|
||||
containerL = GUI.DrawingPanel.Size.Width
|
||||
containerW = GUI.DrawingPanel.Size.Height
|
||||
|
||||
containerMidX = containerL / 2
|
||||
containerMidY = containerW / 2
|
||||
|
||||
drawL = containerL - 80
|
||||
drawW = containerW - 80
|
||||
|
||||
drawAspect = drawL / drawW
|
||||
End Sub
|
||||
|
||||
' --- Set containers points X-values ---
|
||||
Private Shared Sub Set_ContainerPointsX()
|
||||
pCon1(0) = containerMidX - drawL / 2
|
||||
pCon2(0) = containerMidX + drawL / 2
|
||||
pCon3(0) = containerMidX + drawL / 2
|
||||
pCon4(0) = containerMidX - drawL / 2
|
||||
End Sub
|
||||
|
||||
' --- Set containers points Y-values ---
|
||||
Private Shared Sub Set_ContainerPointsY()
|
||||
pCon1(1) = containerMidY - drawW / 2
|
||||
pCon2(1) = containerMidY - drawW / 2
|
||||
pCon3(1) = containerMidY + drawW / 2
|
||||
pCon4(1) = containerMidY + drawW / 2
|
||||
End Sub
|
||||
|
||||
|
||||
' --- Create points for grating direction symbol ---
|
||||
Private Shared Sub Create_DirSymbolPoints()
|
||||
DirSymbolPoints.Add("p1", {-30 + containerMidX, -2 + containerMidY})
|
||||
DirSymbolPoints.Add("p2", {20 + containerMidX, -2 + containerMidY})
|
||||
DirSymbolPoints.Add("p3", {12 + containerMidX, -10 + containerMidY})
|
||||
DirSymbolPoints.Add("p4", {15 + containerMidX, -13 + containerMidY})
|
||||
DirSymbolPoints.Add("p5", {30 + containerMidX, 2 + containerMidY})
|
||||
DirSymbolPoints.Add("p6", {-20 + containerMidX, 2 + containerMidY})
|
||||
DirSymbolPoints.Add("p7", {-12 + containerMidX, 10 + containerMidY})
|
||||
DirSymbolPoints.Add("p8", {-15 + containerMidX, 13 + containerMidY})
|
||||
DirSymbolPoints.Add("p9", {-30 + containerMidX, -2 + containerMidY})
|
||||
End Sub
|
||||
|
||||
' --- Create points for arrow symbol ---
|
||||
Private Shared Sub Create_ArrowSymbolPoints()
|
||||
Dim offset As Integer = 20
|
||||
ArrowSymbolPoints.Add("p1", {offset, containerW - offset})
|
||||
ArrowSymbolPoints.Add("p2", {offset, containerW - offset - 40})
|
||||
ArrowSymbolPoints.Add("p3", {offset - 5, containerW - offset - 35})
|
||||
ArrowSymbolPoints.Add("p4", {offset, containerW - offset - 40})
|
||||
ArrowSymbolPoints.Add("p5", {offset + 5, containerW - offset - 35})
|
||||
ArrowSymbolPoints.Add("p6", {offset, containerW - offset - 40})
|
||||
ArrowSymbolPoints.Add("p7", {offset, containerW - offset})
|
||||
ArrowSymbolPoints.Add("p8", {offset + 40, containerW - offset})
|
||||
ArrowSymbolPoints.Add("p9", {offset + 35, containerW - offset - 5})
|
||||
ArrowSymbolPoints.Add("p10", {offset + 40, containerW - offset})
|
||||
ArrowSymbolPoints.Add("p11", {offset + 35, containerW - offset + 5})
|
||||
End Sub
|
||||
|
||||
' --- Updates all the gratings points ---
|
||||
Public Shared Sub Update_GratingPoints()
|
||||
gratingAspect = GUI_Gratings_Data.gratingMaxL / GUI_Gratings_Data.gratingMaxW
|
||||
|
||||
If gratingAspect > drawAspect Then
|
||||
'Change draw height
|
||||
scaleDiff = GUI_Gratings_Data.gratingMaxL / drawL
|
||||
|
||||
pCon1(1) = containerMidY - GUI_Gratings_Data.gratingMaxW / (scaleDiff * 2)
|
||||
pCon2(1) = containerMidY - GUI_Gratings_Data.gratingMaxW / (scaleDiff * 2)
|
||||
pCon3(1) = containerMidY + GUI_Gratings_Data.gratingMaxW / (scaleDiff * 2)
|
||||
pCon4(1) = containerMidY + GUI_Gratings_Data.gratingMaxW / (scaleDiff * 2)
|
||||
|
||||
Set_ContainerPointsX()
|
||||
Else
|
||||
'Change draw width
|
||||
scaleDiff = GUI_Gratings_Data.gratingMaxW / drawW
|
||||
|
||||
pCon1(0) = containerMidX - GUI_Gratings_Data.gratingMaxL / (scaleDiff * 2)
|
||||
pCon2(0) = containerMidX + GUI_Gratings_Data.gratingMaxL / (scaleDiff * 2)
|
||||
pCon3(0) = containerMidX + GUI_Gratings_Data.gratingMaxL / (scaleDiff * 2)
|
||||
pCon4(0) = containerMidX - GUI_Gratings_Data.gratingMaxL / (scaleDiff * 2)
|
||||
|
||||
Set_ContainerPointsY()
|
||||
End If
|
||||
|
||||
'Redraw grating
|
||||
GUI.DrawingPanel.Refresh()
|
||||
|
||||
'SW X-values
|
||||
pCon1(2) = (-GUI_Gratings_Data.gratingMaxL / 2) / 1000
|
||||
pCon2(2) = (GUI_Gratings_Data.gratingMaxL / 2) / 1000
|
||||
pCon3(2) = (GUI_Gratings_Data.gratingMaxL / 2) / 1000
|
||||
pCon4(2) = (-GUI_Gratings_Data.gratingMaxL / 2) / 1000
|
||||
|
||||
'SW Y-values
|
||||
pCon1(3) = (GUI_Gratings_Data.gratingMaxW / 2) / 1000
|
||||
pCon2(3) = (GUI_Gratings_Data.gratingMaxW / 2) / 1000
|
||||
pCon3(3) = (-GUI_Gratings_Data.gratingMaxW / 2) / 1000
|
||||
pCon4(3) = (-GUI_Gratings_Data.gratingMaxW / 2) / 1000
|
||||
End Sub
|
||||
|
||||
' --- Sets the start points for the grating ---
|
||||
Private Shared Sub Create_StartPoints()
|
||||
points.Add("p1", pCon1)
|
||||
GUI_Functions.pointsFunc.Add("p1", True)
|
||||
pointsOrder.Add("p1")
|
||||
|
||||
points.Add("p2", pCon2)
|
||||
GUI_Functions.pointsFunc.Add("p2", True)
|
||||
pointsOrder.Add("p2")
|
||||
|
||||
points.Add("p3", pCon3)
|
||||
GUI_Functions.pointsFunc.Add("p3", True)
|
||||
pointsOrder.Add("p3")
|
||||
|
||||
points.Add("p4", pCon4)
|
||||
GUI_Functions.pointsFunc.Add("p4", True)
|
||||
pointsOrder.Add("p4")
|
||||
End Sub
|
||||
|
||||
' --- Draw all the lines for the container and grating ---
|
||||
Public Shared Sub DrawingPanel_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs)
|
||||
' Draw outer grating (red)
|
||||
Dim penCon As Pen = New Pen(Color.Red, 2)
|
||||
penCon.DashPattern = {4, 6}
|
||||
e.Graphics.DrawLine(penCon, CInt(pCon1(0)), CInt(pCon1(1)), CInt(pCon2(0)), CInt(pCon2(1)))
|
||||
e.Graphics.DrawLine(penCon, CInt(pCon2(0)), CInt(pCon2(1)), CInt(pCon3(0)), CInt(pCon3(1)))
|
||||
e.Graphics.DrawLine(penCon, CInt(pCon3(0)), CInt(pCon3(1)), CInt(pCon4(0)), CInt(pCon4(1)))
|
||||
e.Graphics.DrawLine(penCon, CInt(pCon4(0)), CInt(pCon4(1)), CInt(pCon1(0)), CInt(pCon1(1)))
|
||||
|
||||
' Draw grating direction symbol
|
||||
Dim symPen As Pen = New Pen(Color.Black, 1)
|
||||
For i = 1 To DirSymbolPoints.Count - 1
|
||||
e.Graphics.DrawLine(symPen, DirSymbolPoints("p" & i)(0), DirSymbolPoints("p" & i)(1),
|
||||
DirSymbolPoints("p" & i + 1)(0), DirSymbolPoints("p" & i + 1)(1))
|
||||
Next
|
||||
|
||||
' Draw arrow symbol
|
||||
For i = 1 To ArrowSymbolPoints.Count - 1
|
||||
e.Graphics.DrawLine(symPen, ArrowSymbolPoints("p" & i)(0), ArrowSymbolPoints("p" & i)(1),
|
||||
ArrowSymbolPoints("p" & i + 1)(0), ArrowSymbolPoints("p" & i + 1)(1))
|
||||
Next
|
||||
|
||||
' Draw measure labels
|
||||
For i = 0 To measureLabels.Count - 1
|
||||
Dim mesName As String = measureLabels.Keys(i)
|
||||
e.Graphics.DrawString(measureLabels(mesName)(0), New Font("Microsoft Sans Serif", 7), Brushes.Black,
|
||||
New Point(measureLabels(mesName)(1), measureLabels(mesName)(2)))
|
||||
Next
|
||||
|
||||
'Stöd measurement linje för sidesquare
|
||||
Dim penMes As Pen = New Pen(Color.Gray, 1)
|
||||
For i = 0 To sideSquareMesLine.Count - 1
|
||||
Dim mesName As String = sideSquareMesLine.Keys(i)
|
||||
e.Graphics.DrawLine(penMes, sideSquareMesLine(mesName)(0), sideSquareMesLine(mesName)(1),
|
||||
sideSquareMesLine(mesName)(2), sideSquareMesLine(mesName)(3))
|
||||
|
||||
If GUI_Functions.pointsMeasurements(mesName)(2) = 1 OrElse GUI_Functions.pointsMeasurements(mesName)(2) = 3 Then
|
||||
e.Graphics.DrawLine(penMes, sideSquareMesLine(mesName)(0), sideSquareMesLine(mesName)(1) + 2,
|
||||
sideSquareMesLine(mesName)(0), sideSquareMesLine(mesName)(1) - 2)
|
||||
e.Graphics.DrawLine(penMes, sideSquareMesLine(mesName)(2), sideSquareMesLine(mesName)(1) + 2,
|
||||
sideSquareMesLine(mesName)(2), sideSquareMesLine(mesName)(1) - 2)
|
||||
Else
|
||||
e.Graphics.DrawLine(penMes, sideSquareMesLine(mesName)(0) + 2, sideSquareMesLine(mesName)(1),
|
||||
sideSquareMesLine(mesName)(0) - 2, sideSquareMesLine(mesName)(1))
|
||||
e.Graphics.DrawLine(penMes, sideSquareMesLine(mesName)(0) + 2, sideSquareMesLine(mesName)(3),
|
||||
sideSquareMesLine(mesName)(0) - 2, sideSquareMesLine(mesName)(3))
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
|
||||
Dim Pendot As Pen = New Pen(Color.Gray, 1)
|
||||
Pendot.DashPattern = {2, 4}
|
||||
|
||||
For i = 0 To anglePoints.Count - 1
|
||||
Dim angleName As String = anglePoints.Keys(i)
|
||||
e.Graphics.DrawLine(Pendot, anglePoints(angleName)(0), anglePoints(angleName)(1),
|
||||
points(anglePointsComp(angleName)(0))(0), points(anglePointsComp(angleName)(0))(1))
|
||||
e.Graphics.DrawLine(Pendot, anglePoints(angleName)(0), anglePoints(angleName)(1),
|
||||
points(anglePointsComp(angleName)(1))(0), points(anglePointsComp(angleName)(1))(1))
|
||||
Next
|
||||
|
||||
|
||||
' Draw actual grating (black)
|
||||
Dim pen As Pen = New Pen(Color.Black, 2)
|
||||
For i = 0 To pointsOrder.Count - 1
|
||||
Dim pTemp1() As Decimal
|
||||
Dim pTemp2() As Decimal
|
||||
|
||||
pTemp1 = points(pointsOrder(i))
|
||||
Try
|
||||
pTemp2 = points(pointsOrder(i + 1))
|
||||
Catch ex As Exception
|
||||
pTemp2 = points(pointsOrder(0))
|
||||
End Try
|
||||
|
||||
e.Graphics.DrawLine(pen, CInt(pTemp1(0)), CInt(pTemp1(1)), CInt(pTemp2(0)), CInt(pTemp2(1)))
|
||||
Next
|
||||
End Sub
|
||||
End Class
|
||||
|
|
@ -1,967 +0,0 @@
|
|||
Public Class GUI_Functions
|
||||
Private Shared angleFunctionActive As Boolean = False
|
||||
Private Shared squareFunctionActive As Boolean = False
|
||||
Private Shared squareSideFunctionActive As Boolean = False
|
||||
|
||||
Private Shared pointCounter As Integer
|
||||
|
||||
Public Shared pointsFunc As New Dictionary(Of String, Boolean)
|
||||
|
||||
Public Shared pointsMeasurements As New Dictionary(Of String, Integer())
|
||||
|
||||
Private Shared sideSquareValues As Integer() = {0, 0, 0}
|
||||
|
||||
Public Shared recessData As New DataTable
|
||||
|
||||
Public Shared Sub AngleButton(sender As Object, e As EventArgs)
|
||||
GUI.Controls("AngleButton").Enabled = False
|
||||
GUI.Controls("Button_Square").Enabled = False
|
||||
GUI.Controls("Button_SquareSide").Enabled = False
|
||||
|
||||
Dim buttonX As Integer = GUI.Controls("AngleButton").Location.X
|
||||
Dim buttonY As Integer = GUI.Controls("AngleButton").Location.Y
|
||||
|
||||
GUI.Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
AddHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("X_Label", "1", buttonX, buttonY + 43)
|
||||
|
||||
GUI.Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
AddHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("Y_Label", "2", buttonX + 110, buttonY + 43)
|
||||
|
||||
angleFunctionActive = True
|
||||
End Sub
|
||||
|
||||
Public Shared Sub SquareButtton(sender As Object, e As EventArgs)
|
||||
GUI.Controls("AngleButton").Enabled = False
|
||||
GUI.Controls("Button_Square").Enabled = False
|
||||
GUI.Controls("Button_SquareSide").Enabled = False
|
||||
|
||||
Dim buttonX As Integer = GUI.Controls("Button_Square").Location.X
|
||||
Dim buttonY As Integer = GUI.Controls("Button_Square").Location.Y
|
||||
|
||||
GUI.Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
AddHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("X_Label", "1", buttonX, buttonY + 43)
|
||||
|
||||
GUI.Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
AddHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("Y_Label", "2", buttonX + 110, buttonY + 43)
|
||||
|
||||
' Add option for corner or side
|
||||
|
||||
squareFunctionActive = True
|
||||
End Sub
|
||||
|
||||
Public Shared Sub SquareSideButtton(sender As Object, e As EventArgs)
|
||||
GUI.Controls("AngleButton").Enabled = False
|
||||
GUI.Controls("Button_Square").Enabled = False
|
||||
GUI.Controls("Button_SquareSide").Enabled = False
|
||||
|
||||
Dim buttonX As Integer = GUI.Controls("Button_SquareSide").Location.X
|
||||
Dim buttonY As Integer = GUI.Controls("Button_SquareSide").Location.Y
|
||||
|
||||
GUI.Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
|
||||
AddHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("X_Label", "L", buttonX, buttonY + 43)
|
||||
|
||||
GUI.Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
|
||||
AddHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("Y_Label", "W", buttonX + 110, buttonY + 43)
|
||||
|
||||
GUI.Create_TextBox("Off_TextBox", "", buttonX + 250, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("Off_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
|
||||
AddHandler GUI.Controls("Off_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("Off_Label", "Offset", buttonX + 210, buttonY + 43)
|
||||
|
||||
' Add option for corner or side
|
||||
|
||||
'squareSideFunctionActive = True
|
||||
End Sub
|
||||
|
||||
Private Shared Sub FunctionText_KeyPress(sender As Object, e As KeyPressEventArgs)
|
||||
GUI_Gratings_Data.Check_IfNumber(e)
|
||||
End Sub
|
||||
|
||||
Private Shared Sub FunctionTextCorner_Changed(sender As TextBox, e As EventArgs)
|
||||
Dim value1, value2 As Integer
|
||||
Try
|
||||
value1 = CInt(GUI.Controls("X_TextBox").Text)
|
||||
value2 = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
Catch ex As Exception
|
||||
value1 = 0
|
||||
value2 = 0
|
||||
End Try
|
||||
If value1 > 0 AndAlso value2 > 0 Then
|
||||
If GUI.DrawingPanel.Controls.Count = 2 Then
|
||||
For i = 0 To GUI_Drawing_Panel.pointsOrder.Count - 1
|
||||
If pointsFunc(GUI_Drawing_Panel.pointsOrder(i)) Then
|
||||
Dim pointButton As New Button
|
||||
pointButton.Width = 30
|
||||
pointButton.Height = 30
|
||||
|
||||
pointButton.Left = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(i))(0) - pointButton.Width / 2
|
||||
pointButton.Top = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(i))(1) - pointButton.Height / 2
|
||||
|
||||
pointButton.Name = GUI_Drawing_Panel.pointsOrder(i) & "_Button"
|
||||
pointButton.Text = ""
|
||||
|
||||
pointButton.BackColor = Color.FromArgb(50, Color.Red)
|
||||
pointButton.FlatStyle = FlatStyle.Flat
|
||||
pointButton.FlatAppearance.BorderSize = 0
|
||||
pointButton.FlatAppearance.MouseOverBackColor = Color.Red
|
||||
pointButton.FlatAppearance.MouseDownBackColor = Color.DarkRed
|
||||
|
||||
Dim gp As New Drawing.Drawing2D.GraphicsPath
|
||||
gp.AddEllipse(New Rectangle(New Point(0, 0), New Size(30, 30)))
|
||||
pointButton.Region = New Region(gp)
|
||||
|
||||
GUI.DrawingPanel.Controls.Add(pointButton)
|
||||
|
||||
AddHandler pointButton.Click, AddressOf PointButton_Click
|
||||
End If
|
||||
Next
|
||||
pointCounter += 1
|
||||
End If
|
||||
|
||||
ElseIf GUI.DrawingPanel.Controls.Count > 2 Then
|
||||
For i = 0 To GUI_Drawing_Panel.pointsOrder.Count - 1
|
||||
If pointsFunc(GUI_Drawing_Panel.pointsOrder(i)) Then
|
||||
RemoveHandler GUI.DrawingPanel.Controls(GUI_Drawing_Panel.pointsOrder(i) & "_Button").Click,
|
||||
AddressOf PointButton_Click
|
||||
GUI.DrawingPanel.Controls.RemoveByKey(GUI_Drawing_Panel.pointsOrder(i) & "_Button")
|
||||
End If
|
||||
Next
|
||||
|
||||
pointCounter -= 1
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Private Shared Sub FunctionTextSide_Changed(sender As TextBox, e As EventArgs)
|
||||
Try
|
||||
sideSquareValues(0) = CInt(GUI.Controls("X_TextBox").Text)
|
||||
sideSquareValues(1) = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
sideSquareValues(2) = CInt(GUI.Controls("Off_TextBox").Text)
|
||||
Catch ex As Exception
|
||||
sideSquareValues(0) = 0
|
||||
sideSquareValues(1) = 0
|
||||
sideSquareValues(2) = 0
|
||||
End Try
|
||||
|
||||
If sideSquareValues(0) > 0 AndAlso sideSquareValues(1) > 0 AndAlso sideSquareValues(2) > 0 Then
|
||||
If GUI.DrawingPanel.Controls.Count = 2 Then
|
||||
For i = 1 To 4
|
||||
Dim sidePoints As New List(Of String)
|
||||
If i = 1 Then
|
||||
Create_SideButton(sideSquareValues(0) / (GUI_Drawing_Panel.scaleDiff), 30,
|
||||
GUI_Drawing_Panel.pCon1(0) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon1(1) - 30 / 2, "Button_" & i)
|
||||
ElseIf i = 2 Then
|
||||
Create_SideButton(30, sideSquareValues(1) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon2(0) - 30 / 2,
|
||||
GUI_Drawing_Panel.pCon1(1) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff), "Button_" & i)
|
||||
ElseIf i = 3 Then
|
||||
Create_SideButton(sideSquareValues(0) / (GUI_Drawing_Panel.scaleDiff), 30,
|
||||
GUI_Drawing_Panel.pCon3(0) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) - sideSquareValues(0) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon3(1) - 30 / 2, "Button_" & i)
|
||||
Else
|
||||
Create_SideButton(30, sideSquareValues(1) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon1(0) - 30 / 2,
|
||||
GUI_Drawing_Panel.pCon4(1) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) - sideSquareValues(1) / (GUI_Drawing_Panel.scaleDiff),
|
||||
"Button_" & i)
|
||||
End If
|
||||
|
||||
Next
|
||||
pointCounter = pointCounter + 1
|
||||
|
||||
Else
|
||||
|
||||
'flytta knapparna/ändra storlek
|
||||
For i = 2 To GUI.DrawingPanel.Controls.Count - 1
|
||||
Dim buttonSide As Integer = CInt(GUI.DrawingPanel.Controls(i).Name.Split("_")(1))
|
||||
If buttonSide = 1 Then
|
||||
GUI.DrawingPanel.Controls(i).Width = sideSquareValues(0) / (GUI_Drawing_Panel.scaleDiff)
|
||||
GUI.DrawingPanel.Controls(i).Left = GUI_Drawing_Panel.pCon1(0) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff)
|
||||
ElseIf buttonSide = 2 Then
|
||||
GUI.DrawingPanel.Controls(i).Height = sideSquareValues(1) / (GUI_Drawing_Panel.scaleDiff)
|
||||
GUI.DrawingPanel.Controls(i).Top = GUI_Drawing_Panel.pCon1(1) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff)
|
||||
ElseIf buttonSide = 3 Then
|
||||
GUI.DrawingPanel.Controls(i).Width = sideSquareValues(0) / (GUI_Drawing_Panel.scaleDiff)
|
||||
GUI.DrawingPanel.Controls(i).Left = GUI_Drawing_Panel.pCon3(0) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) - GUI.DrawingPanel.Controls(i).Width
|
||||
Else
|
||||
GUI.DrawingPanel.Controls(i).Height = sideSquareValues(1) / (GUI_Drawing_Panel.scaleDiff)
|
||||
GUI.DrawingPanel.Controls(i).Top = GUI_Drawing_Panel.pCon4(1) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) - GUI.DrawingPanel.Controls(i).Height
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
ElseIf GUI.DrawingPanel.Controls.Count > 2 Then
|
||||
For i = 2 To GUI.DrawingPanel.Controls.Count - 1
|
||||
RemoveHandler GUI.DrawingPanel.Controls(2).Click, AddressOf SideButton_Click
|
||||
GUI.DrawingPanel.Controls.RemoveAt(2)
|
||||
Next
|
||||
|
||||
pointCounter -= 1
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Shared Sub Create_SideButton(bWidth As Integer, bHeight As Integer, bLeft As Integer, bTop As Integer, bName As String)
|
||||
Dim sideButton As New Button
|
||||
|
||||
sideButton.Width = bWidth
|
||||
sideButton.Height = bHeight
|
||||
|
||||
sideButton.Left = bLeft
|
||||
sideButton.Top = bTop
|
||||
|
||||
sideButton.Name = bName
|
||||
sideButton.Text = ""
|
||||
|
||||
sideButton.BackColor = Color.FromArgb(50, Color.Red)
|
||||
sideButton.FlatStyle = FlatStyle.Flat
|
||||
sideButton.FlatAppearance.BorderSize = 0
|
||||
sideButton.FlatAppearance.MouseOverBackColor = Color.Red
|
||||
sideButton.FlatAppearance.MouseDownBackColor = Color.DarkRed
|
||||
|
||||
GUI.DrawingPanel.Controls.Add(sideButton)
|
||||
|
||||
AddHandler sideButton.Click, AddressOf SideButton_Click
|
||||
End Sub
|
||||
|
||||
|
||||
' --- When a side function button is pressed ---
|
||||
Private Shared Sub SideButton_Click(sender As Button, e As EventArgs)
|
||||
'Determine which side is being pressed
|
||||
Dim sidePressed As Integer = CInt(sender.Name.Split("_")(1))
|
||||
|
||||
' Remove point buttons
|
||||
For i = 2 To GUI.DrawingPanel.Controls.Count - 1
|
||||
RemoveHandler GUI.DrawingPanel.Controls(2).Click, AddressOf SideButton_Click
|
||||
GUI.DrawingPanel.Controls.RemoveAt(2)
|
||||
Next
|
||||
|
||||
Dim numOfNewPoints As Integer
|
||||
|
||||
Dim sidePoints As New List(Of String)
|
||||
Dim index As Integer
|
||||
|
||||
If sidePressed = 1 Then
|
||||
For j = 0 To GUI_Drawing_Panel.pointsOrder.Count - 1
|
||||
If GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(j))(1) = GUI_Drawing_Panel.pCon1(1) Then
|
||||
sidePoints.Add(GUI_Drawing_Panel.pointsOrder(j))
|
||||
End If
|
||||
Next
|
||||
index = GUI_Drawing_Panel.pointsOrder.IndexOf(sidePoints(0))
|
||||
If sidePoints.Count > 2 Then
|
||||
For i = sidePoints.Count / 2 To 2 Step -1
|
||||
If GUI_Drawing_Panel.points(sidePoints(i * 2 - 2))(0) <
|
||||
GUI_Drawing_Panel.pCon1(0) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) Then
|
||||
|
||||
index = GUI_Drawing_Panel.pointsOrder.IndexOf(sidePoints(i * 2 - 2))
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
ElseIf sidePressed = 2 Then
|
||||
For j = 1 To GUI_Drawing_Panel.pointsOrder.Count - 1
|
||||
If GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(j))(0) = GUI_Drawing_Panel.pCon2(0) Then
|
||||
sidePoints.Add(GUI_Drawing_Panel.pointsOrder(j))
|
||||
End If
|
||||
Next
|
||||
index = GUI_Drawing_Panel.pointsOrder.IndexOf(sidePoints(0))
|
||||
If sidePoints.Count > 2 Then
|
||||
For i = sidePoints.Count / 2 To 2 Step -1
|
||||
If GUI_Drawing_Panel.points(sidePoints(i * 2 - 2))(1) <
|
||||
GUI_Drawing_Panel.pCon2(1) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) Then
|
||||
|
||||
index = GUI_Drawing_Panel.pointsOrder.IndexOf(sidePoints(i * 2 - 2))
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
ElseIf sidePressed = 3 Then
|
||||
For j = 2 To GUI_Drawing_Panel.pointsOrder.Count - 1
|
||||
If GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(j))(1) = GUI_Drawing_Panel.pCon3(1) Then
|
||||
sidePoints.Add(GUI_Drawing_Panel.pointsOrder(j))
|
||||
End If
|
||||
Next
|
||||
index = GUI_Drawing_Panel.pointsOrder.IndexOf(sidePoints(0))
|
||||
If sidePoints.Count > 2 Then
|
||||
For i = sidePoints.Count / 2 To 2 Step -1
|
||||
If GUI_Drawing_Panel.points(sidePoints(i * 2 - 2))(0) >
|
||||
GUI_Drawing_Panel.pCon3(0) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) Then
|
||||
|
||||
index = GUI_Drawing_Panel.pointsOrder.IndexOf(sidePoints(i * 2 - 2))
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
Else
|
||||
For j = 3 To GUI_Drawing_Panel.pointsOrder.Count - 1
|
||||
If GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(j))(0) = GUI_Drawing_Panel.pCon1(0) Then
|
||||
sidePoints.Add(GUI_Drawing_Panel.pointsOrder(j))
|
||||
End If
|
||||
Next
|
||||
sidePoints.Add(GUI_Drawing_Panel.pointsOrder(0))
|
||||
|
||||
index = GUI_Drawing_Panel.pointsOrder.IndexOf(sidePoints(0))
|
||||
If sidePoints.Count > 2 Then
|
||||
For i = sidePoints.Count / 2 To 2 Step -1
|
||||
If GUI_Drawing_Panel.points(sidePoints(i * 2 - 2))(1) >
|
||||
GUI_Drawing_Panel.pCon4(1) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) Then
|
||||
|
||||
index = GUI_Drawing_Panel.pointsOrder.IndexOf(sidePoints(i * 2 - 2))
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
|
||||
For i = 2 To pointsMeasurements.Count - 1
|
||||
Dim mesName As String = pointsMeasurements.Keys(i)
|
||||
If mesName.Split("_")(0) = "SS1" Then
|
||||
If index + 2 = pointsMeasurements(mesName)(1) Then
|
||||
If GUI_Drawing_Panel.measureLabels(mesName)(3) = 1 Then
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index + 1))(2) * 1000 -
|
||||
GUI_Drawing_Panel.pCon1(2) * 1000 - (sideSquareValues(2) + sideSquareValues(0))
|
||||
|
||||
GUI_Drawing_Panel.sideSquareMesLine(mesName)(0) = GUI_Drawing_Panel.pCon1(0) + (sideSquareValues(2) + sideSquareValues(0)) / (GUI_Drawing_Panel.scaleDiff)
|
||||
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(1) = (GUI_Drawing_Panel.sideSquareMesLine(mesName)(0) + GUI_Drawing_Panel.sideSquareMesLine(mesName)(2)) / 2 - 8
|
||||
|
||||
ElseIf GUI_Drawing_Panel.measureLabels(mesName)(3) = 2 Then
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.pCon2(3) * 1000 - GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index + 1))(3) * 1000 -
|
||||
(sideSquareValues(2) + sideSquareValues(1))
|
||||
|
||||
GUI_Drawing_Panel.sideSquareMesLine(mesName)(1) = GUI_Drawing_Panel.pCon2(1) + (sideSquareValues(2) + sideSquareValues(1)) / (GUI_Drawing_Panel.scaleDiff)
|
||||
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(2) = (GUI_Drawing_Panel.sideSquareMesLine(mesName)(1) + GUI_Drawing_Panel.sideSquareMesLine(mesName)(3)) / 2 - 6
|
||||
|
||||
ElseIf GUI_Drawing_Panel.measureLabels(mesName)(3) = 3 Then
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.pCon3(2) * 1000 - GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index + 1))(2) * 1000 _
|
||||
- (sideSquareValues(2) + sideSquareValues(0))
|
||||
|
||||
GUI_Drawing_Panel.sideSquareMesLine(mesName)(0) = GUI_Drawing_Panel.pCon3(0) - (sideSquareValues(2) + sideSquareValues(0)) / (GUI_Drawing_Panel.scaleDiff)
|
||||
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(1) = (GUI_Drawing_Panel.sideSquareMesLine(mesName)(0) + GUI_Drawing_Panel.sideSquareMesLine(mesName)(2)) / 2 - 8
|
||||
|
||||
Else
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index + 1))(3) * 1000 -
|
||||
GUI_Drawing_Panel.pCon4(3) * 1000 - (sideSquareValues(2) + sideSquareValues(1))
|
||||
|
||||
GUI_Drawing_Panel.sideSquareMesLine(mesName)(1) = GUI_Drawing_Panel.pCon4(1) - (sideSquareValues(2) + sideSquareValues(1)) / (GUI_Drawing_Panel.scaleDiff)
|
||||
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(2) = (GUI_Drawing_Panel.sideSquareMesLine(mesName)(1) + GUI_Drawing_Panel.sideSquareMesLine(mesName)(3)) / 2 - 6
|
||||
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
|
||||
For i = 2 To pointsMeasurements.Count - 1
|
||||
Dim mesName As String = pointsMeasurements.Keys(i)
|
||||
If mesName.Split("_")(0) <> "SS1" AndAlso index + 1 < pointsMeasurements(mesName)(0) Then
|
||||
pointsMeasurements(mesName)(0) = pointsMeasurements(mesName)(0) + 4
|
||||
pointsMeasurements(mesName)(1) = pointsMeasurements(mesName)(1) + 4
|
||||
ElseIf mesName.Split("_")(0) = "SS1" AndAlso index + 2 <= pointsMeasurements(mesName)(1) Then
|
||||
pointsMeasurements(mesName)(1) = pointsMeasurements(mesName)(1) + 4
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim mesNum As Integer = pointsMeasurements.Count - 1
|
||||
If sidePressed = 1 Then
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4 - 3,
|
||||
{GUI_Drawing_Panel.pCon1(0) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon1(1),
|
||||
GUI_Drawing_Panel.pCon1(2) + sideSquareValues(2) / 1000,
|
||||
GUI_Drawing_Panel.pCon1(3)})
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4 - 2,
|
||||
{GUI_Drawing_Panel.pCon1(0) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon1(1) + sideSquareValues(1) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon1(2) + sideSquareValues(2) / 1000,
|
||||
GUI_Drawing_Panel.pCon1(3) - sideSquareValues(1) / 1000})
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4 - 1,
|
||||
{GUI_Drawing_Panel.pCon1(0) + (sideSquareValues(2) + sideSquareValues(0)) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon1(1) + sideSquareValues(1) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon1(2) + (sideSquareValues(2) + sideSquareValues(0)) / 1000,
|
||||
GUI_Drawing_Panel.pCon1(3) - sideSquareValues(1) / 1000})
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4,
|
||||
{GUI_Drawing_Panel.pCon1(0) + (sideSquareValues(2) + sideSquareValues(0)) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon1(1),
|
||||
GUI_Drawing_Panel.pCon1(2) + (sideSquareValues(2) + sideSquareValues(0)) / 1000,
|
||||
GUI_Drawing_Panel.pCon1(3)})
|
||||
'Outer measuements
|
||||
pointsMeasurements("Lmes")(1) = pointsMeasurements("Lmes")(1) + 4
|
||||
pointsMeasurements("Wmes")(0) = pointsMeasurements("Wmes")(0) + 4
|
||||
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 4
|
||||
|
||||
'SideSquare measurements
|
||||
pointsMeasurements.Add("SS1_" & mesNum, {GUI_Drawing_Panel.pointsOrder.IndexOf(sidePoints(0)) + 1, index + 2, 1})
|
||||
pointsMeasurements.Add("SS_" & mesNum + 1, {index + 2, index + 5, 1})
|
||||
pointsMeasurements.Add("SS_" & mesNum + 2, {index + 2, index + 3, 4})
|
||||
|
||||
'Support Line for sidesquare measurement
|
||||
GUI_Drawing_Panel.sideSquareMesLine.Add("SS1_" & mesNum, {GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index))(0),
|
||||
GUI_Drawing_Panel.pCon1(1) - 15,
|
||||
GUI_Drawing_Panel.pCon1(0) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon1(1) - 15})
|
||||
|
||||
|
||||
'Label
|
||||
GUI_Drawing_Panel.measureLabels.Add("SS1_" & mesNum, {CInt(GUI.Controls("Off_TextBox").Text) - (GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index))(2) * 1000 + GUI_Gratings_Data.gratingMaxL / 2),
|
||||
(GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index))(0) + GUI_Drawing_Panel.pCon1(0) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff)) / 2 - 8,
|
||||
GUI_Drawing_Panel.pCon1(1) - 15 - 12 - 3,
|
||||
1}) '15 är linjen, 12 är textens höjd, 3 är lite extra
|
||||
GUI_Drawing_Panel.measureLabels.Add("SS_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text),
|
||||
GUI_Drawing_Panel.pCon1(0) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) + CInt(GUI.Controls("X_TextBox").Text) / (2 * GUI_Drawing_Panel.scaleDiff) - 8,
|
||||
GUI_Drawing_Panel.pCon1(1) + sideSquareValues(1) / (GUI_Drawing_Panel.scaleDiff) + 3,
|
||||
1})
|
||||
GUI_Drawing_Panel.measureLabels.Add("SS_" & mesNum + 2, {CInt(GUI.Controls("Y_TextBox").Text),
|
||||
GUI_Drawing_Panel.pCon1(0) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) - 18 - 3,
|
||||
GUI_Drawing_Panel.pCon1(1) + CInt(GUI.Controls("Y_TextBox").Text) / (2 * GUI_Drawing_Panel.scaleDiff) - 4,
|
||||
1})
|
||||
|
||||
|
||||
ElseIf sidePressed = 2 Then
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4 - 3,
|
||||
{GUI_Drawing_Panel.pCon2(0),
|
||||
GUI_Drawing_Panel.pCon2(1) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon2(2),
|
||||
GUI_Drawing_Panel.pCon2(3) - sideSquareValues(2) / 1000})
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4 - 2,
|
||||
{GUI_Drawing_Panel.pCon2(0) - sideSquareValues(0) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon2(1) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon2(2) - sideSquareValues(0) / 1000,
|
||||
GUI_Drawing_Panel.pCon2(3) - sideSquareValues(2) / 1000})
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4 - 1,
|
||||
{GUI_Drawing_Panel.pCon2(0) - sideSquareValues(0) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon2(1) + (sideSquareValues(2) + sideSquareValues(1)) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon2(2) - sideSquareValues(0) / 1000,
|
||||
GUI_Drawing_Panel.pCon2(3) - (sideSquareValues(2) + sideSquareValues(1)) / 1000})
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4,
|
||||
{GUI_Drawing_Panel.pCon2(0),
|
||||
GUI_Drawing_Panel.pCon2(1) + (sideSquareValues(2) + sideSquareValues(1)) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon2(2),
|
||||
GUI_Drawing_Panel.pCon2(3) - (sideSquareValues(2) + sideSquareValues(1)) / 1000})
|
||||
'Outer measuements
|
||||
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 4
|
||||
|
||||
'SideSquare measurements
|
||||
pointsMeasurements.Add("SS1_" & mesNum, {GUI_Drawing_Panel.pointsOrder.IndexOf(sidePoints(0)) + 1, index + 2, 2})
|
||||
pointsMeasurements.Add("SS_" & mesNum + 1, {index + 2, index + 5, 2})
|
||||
pointsMeasurements.Add("SS_" & mesNum + 2, {index + 2, index + 3, 3})
|
||||
|
||||
'Support Line for sidesquare measurement
|
||||
GUI_Drawing_Panel.sideSquareMesLine.Add("SS1_" & mesNum, {GUI_Drawing_Panel.pCon2(0) + 15,
|
||||
GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index))(1),
|
||||
GUI_Drawing_Panel.pCon2(0) + 15,
|
||||
GUI_Drawing_Panel.pCon2(1) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff)})
|
||||
|
||||
'Label
|
||||
GUI_Drawing_Panel.measureLabels.Add("SS1_" & mesNum, {CInt(GUI.Controls("Off_TextBox").Text) - (GUI_Gratings_Data.gratingMaxW / 2 - GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index))(3) * 1000),
|
||||
GUI_Drawing_Panel.pCon2(0) + 15 + 3,
|
||||
(GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index))(1) + GUI_Drawing_Panel.pCon2(1) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff)) / 2 - 4,
|
||||
2})
|
||||
|
||||
GUI_Drawing_Panel.measureLabels.Add("SS_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text),
|
||||
GUI_Drawing_Panel.pCon2(0) - sideSquareValues(0) / (GUI_Drawing_Panel.scaleDiff) - 18 - 3,
|
||||
GUI_Drawing_Panel.pCon2(1) + (sideSquareValues(2) + sideSquareValues(1) / 2) / GUI_Drawing_Panel.scaleDiff - 4,
|
||||
2})
|
||||
|
||||
GUI_Drawing_Panel.measureLabels.Add("SS_" & mesNum + 2, {CInt(GUI.Controls("X_TextBox").Text),
|
||||
GUI_Drawing_Panel.pCon2(0) - sideSquareValues(0) / (2 * GUI_Drawing_Panel.scaleDiff) - 8,
|
||||
GUI_Drawing_Panel.pCon2(1) + sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) - 15 - 3,
|
||||
2})
|
||||
|
||||
ElseIf sidePressed = 3 Then
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4 - 3,
|
||||
{GUI_Drawing_Panel.pCon3(0) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon3(1),
|
||||
GUI_Drawing_Panel.pCon3(2) - sideSquareValues(2) / 1000,
|
||||
GUI_Drawing_Panel.pCon3(3)})
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4 - 2,
|
||||
{GUI_Drawing_Panel.pCon3(0) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon3(1) - sideSquareValues(1) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon3(2) - sideSquareValues(2) / 1000,
|
||||
GUI_Drawing_Panel.pCon3(3) + sideSquareValues(1) / 1000})
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4 - 1,
|
||||
{GUI_Drawing_Panel.pCon3(0) - (sideSquareValues(2) + sideSquareValues(0)) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon3(1) - sideSquareValues(1) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon3(2) - (sideSquareValues(2) + sideSquareValues(0)) / 1000,
|
||||
GUI_Drawing_Panel.pCon3(3) + sideSquareValues(1) / 1000})
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4,
|
||||
{GUI_Drawing_Panel.pCon3(0) - (sideSquareValues(2) + sideSquareValues(0)) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon3(1),
|
||||
GUI_Drawing_Panel.pCon3(2) - (sideSquareValues(2) + sideSquareValues(0)) / 1000,
|
||||
GUI_Drawing_Panel.pCon3(3)})
|
||||
|
||||
pointsMeasurements.Add("SS1_" & mesNum, {GUI_Drawing_Panel.pointsOrder.IndexOf(sidePoints(0)) + 1, index + 2, 3})
|
||||
pointsMeasurements.Add("SS_" & mesNum + 1, {index + 2, index + 5, 3})
|
||||
pointsMeasurements.Add("SS_" & mesNum + 2, {index + 2, index + 3, 4})
|
||||
|
||||
'Support Line for sidesquare measurement
|
||||
GUI_Drawing_Panel.sideSquareMesLine.Add("SS1_" & mesNum, {GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index))(0),
|
||||
GUI_Drawing_Panel.pCon3(1) + 15,
|
||||
GUI_Drawing_Panel.pCon3(0) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon3(1) + 15})
|
||||
|
||||
'Label
|
||||
GUI_Drawing_Panel.measureLabels.Add("SS1_" & mesNum, {CInt(GUI.Controls("Off_TextBox").Text) - (GUI_Gratings_Data.gratingMaxL / 2 - GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index))(2) * 1000),
|
||||
(GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index))(0) + GUI_Drawing_Panel.pCon3(0) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff)) / 2 - 8,
|
||||
GUI_Drawing_Panel.pCon3(1) + 15 + 3,
|
||||
3}) '15 är linjen, 12 är textens höjd, 3 är lite extra
|
||||
GUI_Drawing_Panel.measureLabels.Add("SS_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text),
|
||||
GUI_Drawing_Panel.pCon3(0) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) - CInt(GUI.Controls("X_TextBox").Text) / (2 * GUI_Drawing_Panel.scaleDiff) - 8,
|
||||
GUI_Drawing_Panel.pCon3(1) - sideSquareValues(1) / (GUI_Drawing_Panel.scaleDiff) - 12 - 3,
|
||||
3})
|
||||
GUI_Drawing_Panel.measureLabels.Add("SS_" & mesNum + 2, {CInt(GUI.Controls("Y_TextBox").Text),
|
||||
GUI_Drawing_Panel.pCon3(0) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) + 3,
|
||||
GUI_Drawing_Panel.pCon3(1) - CInt(GUI.Controls("Y_TextBox").Text) / (2 * GUI_Drawing_Panel.scaleDiff) - 4,
|
||||
3})
|
||||
|
||||
Else
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4 - 3,
|
||||
{GUI_Drawing_Panel.pCon4(0),
|
||||
GUI_Drawing_Panel.pCon4(1) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon4(2),
|
||||
GUI_Drawing_Panel.pCon4(3) + sideSquareValues(2) / 1000})
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4 - 2,
|
||||
{GUI_Drawing_Panel.pCon4(0) + sideSquareValues(0) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon4(1) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon4(2) + sideSquareValues(0) / 1000,
|
||||
GUI_Drawing_Panel.pCon4(3) + sideSquareValues(2) / 1000})
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4 - 1,
|
||||
{GUI_Drawing_Panel.pCon4(0) + sideSquareValues(0) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon4(1) - (sideSquareValues(2) + sideSquareValues(1)) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon4(2) + sideSquareValues(0) / 1000,
|
||||
GUI_Drawing_Panel.pCon4(3) + (sideSquareValues(2) + sideSquareValues(1)) / 1000})
|
||||
GUI_Drawing_Panel.points.Add("pSS" & pointCounter * 4,
|
||||
{GUI_Drawing_Panel.pCon4(0),
|
||||
GUI_Drawing_Panel.pCon4(1) - (sideSquareValues(2) + sideSquareValues(1)) / (GUI_Drawing_Panel.scaleDiff),
|
||||
GUI_Drawing_Panel.pCon4(2),
|
||||
GUI_Drawing_Panel.pCon4(3) + (sideSquareValues(2) + sideSquareValues(1)) / 1000})
|
||||
|
||||
pointsMeasurements.Add("SS1_" & mesNum, {GUI_Drawing_Panel.pointsOrder.IndexOf(sidePoints(0)) + 1, index + 2, 4})
|
||||
pointsMeasurements.Add("SS_" & mesNum + 1, {index + 2, index + 5, 4})
|
||||
pointsMeasurements.Add("SS_" & mesNum + 2, {index + 2, index + 3, 3})
|
||||
|
||||
'Support Line for sidesquare measurement
|
||||
GUI_Drawing_Panel.sideSquareMesLine.Add("SS1_" & mesNum, {GUI_Drawing_Panel.pCon4(0) - 15,
|
||||
GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index))(1),
|
||||
GUI_Drawing_Panel.pCon4(0) - 15,
|
||||
GUI_Drawing_Panel.pCon4(1) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff)})
|
||||
|
||||
'Label
|
||||
GUI_Drawing_Panel.measureLabels.Add("SS1_" & mesNum, {CInt(GUI.Controls("Off_TextBox").Text) - (GUI_Gratings_Data.gratingMaxW / 2 + GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index))(3) * 1000),
|
||||
GUI_Drawing_Panel.pCon4(0) - 15 - 18 - 3,
|
||||
(GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(index))(1) + GUI_Drawing_Panel.pCon4(1) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff)) / 2 - 4,
|
||||
4})
|
||||
|
||||
GUI_Drawing_Panel.measureLabels.Add("SS_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text),
|
||||
GUI_Drawing_Panel.pCon4(0) + sideSquareValues(0) / (GUI_Drawing_Panel.scaleDiff) + 3,
|
||||
GUI_Drawing_Panel.pCon4(1) - (sideSquareValues(2) + sideSquareValues(1) / 2) / GUI_Drawing_Panel.scaleDiff - 4,
|
||||
4})
|
||||
|
||||
GUI_Drawing_Panel.measureLabels.Add("SS_" & mesNum + 2, {CInt(GUI.Controls("X_TextBox").Text),
|
||||
GUI_Drawing_Panel.pCon4(0) + sideSquareValues(0) / (2 * GUI_Drawing_Panel.scaleDiff) - 8,
|
||||
GUI_Drawing_Panel.pCon4(1) - sideSquareValues(2) / (GUI_Drawing_Panel.scaleDiff) + 3,
|
||||
4})
|
||||
|
||||
End If
|
||||
|
||||
pointsFunc.Add("pSS" & pointCounter * 4 - 3, False)
|
||||
pointsFunc.Add("pSS" & pointCounter * 4 - 2, False)
|
||||
pointsFunc.Add("pSS" & pointCounter * 4 - 1, False)
|
||||
pointsFunc.Add("pSS" & pointCounter * 4, False)
|
||||
|
||||
'Insert four new points
|
||||
GUI_Drawing_Panel.pointsOrder.Insert(index + 1, "pSS" & pointCounter * 4 - 3)
|
||||
GUI_Drawing_Panel.pointsOrder.Insert(index + 2, "pSS" & pointCounter * 4 - 2)
|
||||
GUI_Drawing_Panel.pointsOrder.Insert(index + 3, "pSS" & pointCounter * 4 - 1)
|
||||
GUI_Drawing_Panel.pointsOrder.Insert(index + 4, "pSS" & pointCounter * 4)
|
||||
|
||||
numOfNewPoints = 4
|
||||
|
||||
'Redraw grating
|
||||
GUI.DrawingPanel.Refresh()
|
||||
|
||||
RemoveHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
|
||||
RemoveHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Controls.RemoveByKey("X_TextBox")
|
||||
|
||||
RemoveHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
|
||||
RemoveHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Controls.RemoveByKey("Y_TextBox")
|
||||
|
||||
RemoveHandler GUI.Controls("Off_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
|
||||
RemoveHandler GUI.Controls("Off_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Controls.RemoveByKey("Off_TextBox")
|
||||
|
||||
GUI.Controls.RemoveByKey("X_Label")
|
||||
GUI.Controls.RemoveByKey("Y_Label")
|
||||
GUI.Controls.RemoveByKey("Off_Label")
|
||||
|
||||
GUI.Controls("AngleButton").Enabled = True
|
||||
GUI.Controls("Button_Square").Enabled = True
|
||||
GUI.Controls("Button_SquareSide").Enabled = True
|
||||
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
' --- When a corner function button is pressed ---
|
||||
Private Shared Sub PointButton_Click(sender As Button, e As EventArgs)
|
||||
'Determine which point is being pressed
|
||||
Dim pointPressed As String = sender.Name.Split("_")(0)
|
||||
Dim index As Integer = GUI_Drawing_Panel.pointsOrder.IndexOf(pointPressed)
|
||||
|
||||
' Remove point buttons
|
||||
For i = 0 To GUI_Drawing_Panel.pointsOrder.Count - 1
|
||||
If pointsFunc(GUI_Drawing_Panel.pointsOrder(i)) Then
|
||||
RemoveHandler GUI.DrawingPanel.Controls(GUI_Drawing_Panel.pointsOrder(i) & "_Button").Click,
|
||||
AddressOf PointButton_Click
|
||||
GUI.DrawingPanel.Controls.RemoveByKey(GUI_Drawing_Panel.pointsOrder(i) & "_Button")
|
||||
End If
|
||||
Next
|
||||
|
||||
'Retrive that points coords
|
||||
Dim pXP As Decimal = GUI_Drawing_Panel.points(pointPressed)(0)
|
||||
Dim pYP As Decimal = GUI_Drawing_Panel.points(pointPressed)(1)
|
||||
Dim pXSW As Decimal = GUI_Drawing_Panel.points(pointPressed)(2)
|
||||
Dim pYSW As Decimal = GUI_Drawing_Panel.points(pointPressed)(3)
|
||||
|
||||
Dim d1P As Decimal = GUI.Controls("X_TextBox").Text / GUI_Drawing_Panel.scaleDiff ' BEHÖVS Cdec??
|
||||
Dim d2P As Decimal = GUI.Controls("Y_TextBox").Text / GUI_Drawing_Panel.scaleDiff
|
||||
Dim d1SW As Decimal = GUI.Controls("X_TextBox").Text / 1000
|
||||
Dim d2SW As Decimal = GUI.Controls("Y_TextBox").Text / 1000
|
||||
|
||||
Dim numOfNewPoints As Integer
|
||||
|
||||
|
||||
|
||||
recessData.Rows.Add()
|
||||
|
||||
|
||||
For i = 2 To pointsMeasurements.Count - 1
|
||||
Dim mesName As String = pointsMeasurements.Keys(i)
|
||||
If mesName.Split("_")(0) <> "SS1" AndAlso mesName.Split("_")(0) <> "SS" Then
|
||||
If index + 1 = pointsMeasurements(mesName)(0) Then
|
||||
If GUI_Drawing_Panel.measureLabels(mesName)(3) = 1 Then
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(1) = GUI_Drawing_Panel.measureLabels(mesName)(1) + d1P / 2
|
||||
ElseIf GUI_Drawing_Panel.measureLabels(mesName)(3) = 2 Then
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.measureLabels(mesName)(0) - GUI.Controls("Y_TextBox").Text
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(2) = GUI_Drawing_Panel.measureLabels(mesName)(2) + d2P / 2
|
||||
ElseIf GUI_Drawing_Panel.measureLabels(mesName)(3) = 3 Then
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(1) = GUI_Drawing_Panel.measureLabels(mesName)(1) - d1P / 2
|
||||
Else
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.measureLabels(mesName)(0) - GUI.Controls("Y_TextBox").Text
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(2) = GUI_Drawing_Panel.measureLabels(mesName)(2) - d2P / 2
|
||||
End If
|
||||
ElseIf index + 1 = pointsMeasurements(mesName)(1) Then
|
||||
If GUI_Drawing_Panel.measureLabels(mesName)(3) = 1 Then
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.measureLabels(mesName)(0) - GUI.Controls("Y_TextBox").Text
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(2) = GUI_Drawing_Panel.measureLabels(mesName)(2) + d2P / 2
|
||||
ElseIf GUI_Drawing_Panel.measureLabels(mesName)(3) = 2 Then
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(1) = GUI_Drawing_Panel.measureLabels(mesName)(1) - d1P / 2
|
||||
ElseIf GUI_Drawing_Panel.measureLabels(mesName)(3) = 3 Then
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.measureLabels(mesName)(0) - GUI.Controls("Y_TextBox").Text
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(2) = GUI_Drawing_Panel.measureLabels(mesName)(2) - d2P / 2
|
||||
Else
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(1) = GUI_Drawing_Panel.measureLabels(mesName)(1) + d1P / 2
|
||||
End If
|
||||
End If
|
||||
|
||||
ElseIf mesName.Split("_")(0) = "SS1" AndAlso index + 2 = pointsMeasurements(mesName)(1) Then
|
||||
If GUI_Drawing_Panel.measureLabels(mesName)(3) = 1 Then
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(0) = GUI_Drawing_Panel.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
GUI_Drawing_Panel.measureLabels(mesName)(1) = GUI_Drawing_Panel.measureLabels(mesName)(1) + d1P / 2
|
||||
|
||||
GUI_Drawing_Panel.sideSquareMesLine(mesName)(0) = GUI_Drawing_Panel.sideSquareMesLine(mesName)(0) + d1P
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim mesNum As Integer = pointsMeasurements.Count - 1
|
||||
If angleFunctionActive Then
|
||||
For i = 2 To pointsMeasurements.Count - 1
|
||||
Dim mesName As String = pointsMeasurements.Keys(i)
|
||||
If index + 1 < pointsMeasurements(mesName)(0) Then
|
||||
pointsMeasurements(mesName)(0) = pointsMeasurements(mesName)(0) + 1
|
||||
pointsMeasurements(mesName)(1) = pointsMeasurements(mesName)(1) + 1
|
||||
ElseIf index + 1 = pointsMeasurements(mesName)(0) OrElse index + 1 = pointsMeasurements(mesName)(1) Then
|
||||
pointsMeasurements(mesName)(1) = pointsMeasurements(mesName)(1) + 1
|
||||
End If
|
||||
Next
|
||||
|
||||
If pXP < GUI_Drawing_Panel.containerMidX Then
|
||||
If pYP > GUI_Drawing_Panel.containerMidY Then
|
||||
'Kvadrant 4
|
||||
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2 - 1, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
|
||||
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
|
||||
|
||||
'Recess measuements
|
||||
pointsMeasurements.Add("A_" & mesNum, {index + 1, index + 2, 3})
|
||||
pointsMeasurements.Add("A_" & mesNum + 1, {index + 1, index + 2, 4})
|
||||
|
||||
'Panel recess measurements
|
||||
GUI_Drawing_Panel.anglePoints.Add("A" & pointCounter * 2 - 1, {pXP + d1P, pYP - d2P})
|
||||
GUI_Drawing_Panel.anglePointsComp.Add("A" & pointCounter * 2 - 1, {"pA" & pointCounter * 2 - 1, "pA" & pointCounter * 2})
|
||||
|
||||
'Label
|
||||
GUI_Drawing_Panel.measureLabels.Add("A_" & mesNum, {CInt(GUI.Controls("Y_TextBox").Text), pXP + d1P + 3,
|
||||
pYP - d2P / 2 - 4, 4})
|
||||
GUI_Drawing_Panel.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXP + d1P / 2 - 8,
|
||||
pYP - d2P - 12 - 3, 4})
|
||||
Else
|
||||
'Kvadrant 1
|
||||
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2 - 1, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
|
||||
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
|
||||
|
||||
'Outer measuements
|
||||
pointsMeasurements("Lmes")(1) = pointsMeasurements("Lmes")(1) + 1
|
||||
pointsMeasurements("Wmes")(0) = pointsMeasurements("Wmes")(0) + 1
|
||||
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 1
|
||||
|
||||
'SW Recess measuements
|
||||
pointsMeasurements.Add("A_" & mesNum, {index + 1, index + 2, 1})
|
||||
pointsMeasurements.Add("A_" & mesNum + 1, {index + 1, index + 2, 4})
|
||||
|
||||
'Panel recess measurements
|
||||
GUI_Drawing_Panel.anglePoints.Add("A" & pointCounter * 2 - 1, {pXP + d1P, pYP + d2P})
|
||||
GUI_Drawing_Panel.anglePointsComp.Add("A" & pointCounter * 2 - 1, {"pA" & pointCounter * 2 - 1, "pA" & pointCounter * 2})
|
||||
|
||||
'Label
|
||||
GUI_Drawing_Panel.measureLabels.Add("A_" & mesNum, {CInt(GUI.Controls("X_TextBox").Text), pXP + d1P / 2 - 8,
|
||||
pYP + d2P + 3, 1})
|
||||
GUI_Drawing_Panel.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXP + d1P + 3,
|
||||
pYP + d2P / 2 - 4, 1})
|
||||
End If
|
||||
Else
|
||||
If pYP > GUI_Drawing_Panel.containerMidY Then
|
||||
'Kvadrant 3
|
||||
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2 - 1, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
|
||||
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
|
||||
|
||||
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 1
|
||||
|
||||
'Recess measuements
|
||||
pointsMeasurements.Add("A_" & mesNum, {index + 1, index + 2, 2})
|
||||
pointsMeasurements.Add("A_" & mesNum + 1, {index + 1, index + 2, 3})
|
||||
|
||||
'Panel recess measurements
|
||||
GUI_Drawing_Panel.anglePoints.Add("A" & pointCounter * 2 - 1, {pXP - d1P, pYP - d2P})
|
||||
GUI_Drawing_Panel.anglePointsComp.Add("A" & pointCounter * 2 - 1, {"pA" & pointCounter * 2 - 1, "pA" & pointCounter * 2})
|
||||
|
||||
'Label
|
||||
GUI_Drawing_Panel.measureLabels.Add("A_" & mesNum, {CInt(GUI.Controls("X_TextBox").Text), pXP - d1P / 2 - 8,
|
||||
pYP - d2P - 12 - 3, 3})
|
||||
GUI_Drawing_Panel.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXP - d1P - 18 - 3,
|
||||
pYP - d2P / 2 - 4, 3})
|
||||
Else
|
||||
'Kvadrant 2
|
||||
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2 - 1, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
|
||||
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
|
||||
|
||||
pointsMeasurements("Lmes")(1) = pointsMeasurements("Lmes")(1) + 1
|
||||
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 1
|
||||
|
||||
'Recess measuements
|
||||
pointsMeasurements.Add("A_" & mesNum, {index + 1, index + 2, 1})
|
||||
pointsMeasurements.Add("A_" & mesNum + 1, {index + 1, index + 2, 2})
|
||||
|
||||
'Panel recess measurements
|
||||
GUI_Drawing_Panel.anglePoints.Add("A" & pointCounter * 2 - 1, {pXP - d1P, pYP + d2P})
|
||||
GUI_Drawing_Panel.anglePointsComp.Add("A" & pointCounter * 2 - 1, {"pA" & pointCounter * 2 - 1, "pA" & pointCounter * 2})
|
||||
|
||||
'Label
|
||||
GUI_Drawing_Panel.measureLabels.Add("A_" & mesNum, {CInt(GUI.Controls("Y_TextBox").Text), pXP - d1P - 18 - 3,
|
||||
pYP + d2P / 2 - 4, 2})
|
||||
GUI_Drawing_Panel.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXP - d1P / 2 - 8,
|
||||
pYP + d2P + 3, 2})
|
||||
End If
|
||||
End If
|
||||
pointsFunc.Add("pA" & pointCounter * 2 - 1, False)
|
||||
pointsFunc.Add("pA" & pointCounter * 2, False)
|
||||
|
||||
'Insert two new points
|
||||
GUI_Drawing_Panel.pointsOrder.Insert(index + 1, "pA" & pointCounter * 2 - 1)
|
||||
GUI_Drawing_Panel.pointsOrder.Insert(index + 2, "pA" & pointCounter * 2)
|
||||
|
||||
numOfNewPoints = 2
|
||||
angleFunctionActive = False
|
||||
|
||||
|
||||
Else ' square
|
||||
|
||||
For i = 2 To pointsMeasurements.Count - 1
|
||||
Dim mesName As String = pointsMeasurements.Keys(i)
|
||||
If index + 1 < pointsMeasurements(mesName)(0) Then
|
||||
pointsMeasurements(mesName)(0) = pointsMeasurements(mesName)(0) + 2
|
||||
pointsMeasurements(mesName)(1) = pointsMeasurements(mesName)(1) + 2
|
||||
ElseIf index + 1 = pointsMeasurements(mesName)(0) Then
|
||||
pointsMeasurements(mesName)(1) = pointsMeasurements(mesName)(1) + 2
|
||||
ElseIf index + 1 = pointsMeasurements(mesName)(1) Then
|
||||
pointsMeasurements(mesName)(1) = pointsMeasurements(mesName)(1) + 2
|
||||
End If
|
||||
Next
|
||||
If pXP < GUI_Drawing_Panel.containerMidX Then
|
||||
If pYP > GUI_Drawing_Panel.containerMidY Then
|
||||
'Kvadrant 4
|
||||
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 2, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
|
||||
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 1, {pXP + d1P, pYP - d2P, pXSW + d1SW, pYSW + d2SW})
|
||||
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
|
||||
|
||||
'Recess measuements
|
||||
pointsMeasurements.Add("S_" & mesNum, {index + 1, index + 2, 4})
|
||||
pointsMeasurements.Add("S_" & mesNum + 1, {index + 2, index + 3, 3})
|
||||
|
||||
'Label
|
||||
GUI_Drawing_Panel.measureLabels.Add("S_" & mesNum, {CInt(GUI.Controls("Y_TextBox").Text), pXP + d1P + 3,
|
||||
pYP - d2P / 2 - 4, 4})
|
||||
GUI_Drawing_Panel.measureLabels.Add("S_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXP + d1P / 2 - 8,
|
||||
pYP - d2P - 12 - 3, 4})
|
||||
|
||||
'Recess Data
|
||||
recessData.Rows(recessData.Rows.Count - 1)("RECESS TYPE") = "SQUARE"
|
||||
recessData.Rows(recessData.Rows.Count - 1)("CORNER") = 4
|
||||
recessData.Rows(recessData.Rows.Count - 1)("WIDTH") = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
recessData.Rows(recessData.Rows.Count - 1)("LENGTH") = CInt(GUI.Controls("X_TextBox").Text)
|
||||
Else
|
||||
'Kvadrant 1
|
||||
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 2, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
|
||||
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 1, {pXP + d1P, pYP + d2P, pXSW + d1SW, pYSW - d2SW})
|
||||
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
|
||||
|
||||
pointsMeasurements("Lmes")(1) = pointsMeasurements("Lmes")(1) + 2
|
||||
pointsMeasurements("Wmes")(0) = pointsMeasurements("Wmes")(0) + 2
|
||||
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 2
|
||||
|
||||
'Recess measuements
|
||||
pointsMeasurements.Add("S_" & mesNum, {index + 1, index + 2, 1})
|
||||
pointsMeasurements.Add("S_" & mesNum + 1, {index + 2, index + 3, 4})
|
||||
|
||||
'Label
|
||||
GUI_Drawing_Panel.measureLabels.Add("S_" & mesNum, {CInt(GUI.Controls("X_TextBox").Text), pXP + d1P / 2 - 8,
|
||||
pYP + d2P + 3, 1})
|
||||
GUI_Drawing_Panel.measureLabels.Add("S_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXP + d1P + 3,
|
||||
pYP + d2P / 2 - 4, 1})
|
||||
|
||||
'Recess Data
|
||||
recessData.Rows(recessData.Rows.Count - 1)("RECESS TYPE") = "SQUARE"
|
||||
recessData.Rows(recessData.Rows.Count - 1)("CORNER") = 1
|
||||
recessData.Rows(recessData.Rows.Count - 1)("WIDTH") = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
recessData.Rows(recessData.Rows.Count - 1)("LENGTH") = CInt(GUI.Controls("X_TextBox").Text)
|
||||
|
||||
End If
|
||||
Else
|
||||
If pYP > GUI_Drawing_Panel.containerMidY Then
|
||||
'Kvadrant 3
|
||||
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 2, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
|
||||
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 1, {pXP - d1P, pYP - d2P, pXSW - d1SW, pYSW + d2SW})
|
||||
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
|
||||
|
||||
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 2
|
||||
|
||||
'Recess measuements
|
||||
pointsMeasurements.Add("S_" & mesNum, {index + 1, index + 2, 3})
|
||||
pointsMeasurements.Add("S_" & mesNum + 1, {index + 2, index + 3, 2})
|
||||
|
||||
'Label
|
||||
GUI_Drawing_Panel.measureLabels.Add("S_" & mesNum, {CInt(GUI.Controls("X_TextBox").Text), pXP - d1P / 2 - 8,
|
||||
pYP - d2P - 12 - 3, 3})
|
||||
GUI_Drawing_Panel.measureLabels.Add("S_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXP - d1P - 18 - 3,
|
||||
pYP - d2P / 2 - 4, 3})
|
||||
|
||||
'Recess Data
|
||||
recessData.Rows(recessData.Rows.Count - 1)("RECESS TYPE") = "SQUARE"
|
||||
recessData.Rows(recessData.Rows.Count - 1)("CORNER") = 3
|
||||
recessData.Rows(recessData.Rows.Count - 1)("WIDTH") = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
recessData.Rows(recessData.Rows.Count - 1)("LENGTH") = CInt(GUI.Controls("X_TextBox").Text)
|
||||
Else
|
||||
'Kvadrant 2
|
||||
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 2, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
|
||||
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 1, {pXP - d1P, pYP + d2P, pXSW - d1SW, pYSW - d2SW})
|
||||
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
|
||||
|
||||
pointsMeasurements("Lmes")(1) = pointsMeasurements("Lmes")(1) + 2
|
||||
pointsMeasurements("Wmes")(1) = pointsMeasurements("Wmes")(1) + 2
|
||||
|
||||
'Recess measuements
|
||||
pointsMeasurements.Add("S_" & mesNum, {index + 1, index + 2, 2})
|
||||
pointsMeasurements.Add("S_" & mesNum + 1, {index + 2, index + 3, 1})
|
||||
|
||||
'Label
|
||||
GUI_Drawing_Panel.measureLabels.Add("S_" & mesNum, {CInt(GUI.Controls("Y_TextBox").Text), pXP - d1P - 18 - 3,
|
||||
pYP + d2P / 2 - 4, 2})
|
||||
GUI_Drawing_Panel.measureLabels.Add("S_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXP - d1P / 2 - 8,
|
||||
pYP + d2P + 3, 2})
|
||||
|
||||
'Recess Data
|
||||
recessData.Rows(recessData.Rows.Count - 1)("RECESS TYPE") = "SQUARE"
|
||||
recessData.Rows(recessData.Rows.Count - 1)("CORNER") = 2
|
||||
recessData.Rows(recessData.Rows.Count - 1)("WIDTH") = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
recessData.Rows(recessData.Rows.Count - 1)("LENGTH") = CInt(GUI.Controls("X_TextBox").Text)
|
||||
|
||||
End If
|
||||
End If
|
||||
pointsFunc.Add("pS" & pointCounter * 3 - 2, True)
|
||||
pointsFunc.Add("pS" & pointCounter * 3 - 1, False)
|
||||
pointsFunc.Add("pS" & pointCounter * 3, True)
|
||||
|
||||
'Insert new points
|
||||
GUI_Drawing_Panel.pointsOrder.Insert(index + 1, "pS" & pointCounter * 3 - 2)
|
||||
GUI_Drawing_Panel.pointsOrder.Insert(index + 2, "pS" & pointCounter * 3 - 1)
|
||||
GUI_Drawing_Panel.pointsOrder.Insert(index + 3, "pS" & pointCounter * 3)
|
||||
|
||||
numOfNewPoints = 3
|
||||
|
||||
squareFunctionActive = False
|
||||
|
||||
End If
|
||||
GUI_Drawing_Panel.pointsOrder.RemoveAt(index)
|
||||
|
||||
'Redraw grating
|
||||
GUI.DrawingPanel.Refresh()
|
||||
|
||||
RemoveHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
RemoveHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Controls.RemoveByKey("X_TextBox")
|
||||
|
||||
RemoveHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
RemoveHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Controls.RemoveByKey("Y_TextBox")
|
||||
|
||||
GUI.Controls.RemoveByKey("X_Label")
|
||||
GUI.Controls.RemoveByKey("Y_Label")
|
||||
|
||||
GUI.Controls("AngleButton").Enabled = True
|
||||
GUI.Controls("Button_Square").Enabled = True
|
||||
GUI.Controls("Button_SquareSide").Enabled = True
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
Public Class Data
|
||||
Public Shared grossAreaPoints As New DataTable
|
||||
Public Shared gratingPoints As New DataTable
|
||||
Public Shared angleRecessPoints As New DataTable
|
||||
|
||||
Public Shared guiPanelMidX, guiPanelMidY As Integer
|
||||
Public Shared guiMaxDrawL As Integer = 1
|
||||
Public Shared guiMaxDrawW As Integer = 1
|
||||
|
||||
Public Shared gratingW As Integer = 1000
|
||||
Public Shared gratingL As Integer = 1000
|
||||
|
||||
Public Shared drawAR, gratingAR As Decimal
|
||||
Public Shared scaleDiff As Decimal = 1
|
||||
|
||||
Public Shared recessData As New DataTable
|
||||
|
||||
Public Shared pointCounter As Integer
|
||||
Public Shared pointsMeasurements As New Dictionary(Of String, Integer())
|
||||
|
||||
' --- Initialize Datatables, measurments and more ---
|
||||
Public Shared Sub Init_Data()
|
||||
' Gross area points
|
||||
grossAreaPoints.Columns.Add("NAME", GetType(String))
|
||||
grossAreaPoints.Columns.Add("QUADRANT", GetType(String))
|
||||
grossAreaPoints.Columns.Add("X", GetType(Decimal))
|
||||
grossAreaPoints.Columns.Add("Y", GetType(Decimal))
|
||||
grossAreaPoints.Columns.Add("GUI X", GetType(Integer))
|
||||
grossAreaPoints.Columns.Add("GUI Y", GetType(Integer))
|
||||
|
||||
' Grating points
|
||||
gratingPoints.Columns.Add("NAME", GetType(String))
|
||||
gratingPoints.Columns.Add("QUADRANT", GetType(String))
|
||||
gratingPoints.Columns.Add("X", GetType(Decimal))
|
||||
gratingPoints.Columns.Add("Y", GetType(Decimal))
|
||||
gratingPoints.Columns.Add("GUI X", GetType(Integer))
|
||||
gratingPoints.Columns.Add("GUI Y", GetType(Integer))
|
||||
gratingPoints.Columns.Add("RECESS OK", GetType(Boolean))
|
||||
|
||||
' Angle recess points
|
||||
angleRecessPoints.Columns.Add("NAME", GetType(String))
|
||||
angleRecessPoints.Columns.Add("QUADRANT", GetType(String))
|
||||
angleRecessPoints.Columns.Add("GUI X", GetType(Integer))
|
||||
angleRecessPoints.Columns.Add("GUI Y", GetType(Integer))
|
||||
|
||||
GUI.CheckBox_WholeMeshWidths.Checked = True
|
||||
|
||||
pointsMeasurements.Add("Lmes", {1, 2, 1})
|
||||
pointsMeasurements.Add("Wmes", {2, 3, 2})
|
||||
|
||||
recessData.Columns.Add("RECESS TYPE", GetType(String))
|
||||
recessData.Columns.Add("CORNER", GetType(Integer))
|
||||
recessData.Columns.Add("SIDE", GetType(Integer))
|
||||
recessData.Columns.Add("WIDTH", GetType(Integer))
|
||||
recessData.Columns.Add("LENGTH", GetType(Integer))
|
||||
recessData.Columns.Add("OFFSET", GetType(Integer))
|
||||
End Sub
|
||||
|
||||
Public Shared Sub Init_GrossAreaPoints()
|
||||
Dim pointRow As DataRow = grossAreaPoints.NewRow
|
||||
pointRow("NAME") = "P1"
|
||||
pointRow("QUADRANT") = 1
|
||||
pointRow("X") = (-gratingL / 2) / 1000
|
||||
pointRow("Y") = (gratingW / 2) / 1000
|
||||
pointRow("GUI X") = guiPanelMidX - guiMaxDrawL / 2
|
||||
pointRow("GUI Y") = guiPanelMidY - guiMaxDrawW / 2
|
||||
grossAreaPoints.Rows.Add(pointRow)
|
||||
|
||||
pointRow = grossAreaPoints.NewRow
|
||||
pointRow("NAME") = "P2"
|
||||
pointRow("QUADRANT") = 2
|
||||
pointRow("X") = (gratingL / 2) / 1000
|
||||
pointRow("Y") = (gratingW / 2) / 1000
|
||||
pointRow("GUI X") = guiPanelMidX + guiMaxDrawL / 2
|
||||
pointRow("GUI Y") = guiPanelMidY - guiMaxDrawW / 2
|
||||
grossAreaPoints.Rows.Add(pointRow)
|
||||
|
||||
pointRow = grossAreaPoints.NewRow
|
||||
pointRow("NAME") = "P3"
|
||||
pointRow("QUADRANT") = 3
|
||||
pointRow("X") = (gratingL / 2) / 1000
|
||||
pointRow("Y") = (-gratingW / 2) / 1000
|
||||
pointRow("GUI X") = guiPanelMidX + guiMaxDrawL / 2
|
||||
pointRow("GUI Y") = guiPanelMidY + guiMaxDrawW / 2
|
||||
grossAreaPoints.Rows.Add(pointRow)
|
||||
|
||||
pointRow = grossAreaPoints.NewRow
|
||||
pointRow("NAME") = "P4"
|
||||
pointRow("QUADRANT") = 4
|
||||
pointRow("X") = (-gratingL / 2) / 1000
|
||||
pointRow("Y") = (-gratingW / 2) / 1000
|
||||
pointRow("GUI X") = guiPanelMidX - guiMaxDrawL / 2
|
||||
pointRow("GUI Y") = guiPanelMidY + guiMaxDrawW / 2
|
||||
grossAreaPoints.Rows.Add(pointRow)
|
||||
End Sub
|
||||
|
||||
Public Shared Sub Init_GratingPoints()
|
||||
Dim pointRow As DataRow = gratingPoints.NewRow
|
||||
pointRow("NAME") = "P1"
|
||||
pointRow("QUADRANT") = 1
|
||||
pointRow("X") = (-gratingL / 2) / 1000
|
||||
pointRow("Y") = (gratingW / 2) / 1000
|
||||
pointRow("GUI X") = guiPanelMidX - guiMaxDrawL / 2
|
||||
pointRow("GUI Y") = guiPanelMidY - guiMaxDrawW / 2
|
||||
pointRow("RECESS OK") = True
|
||||
gratingPoints.Rows.Add(pointRow)
|
||||
|
||||
pointRow = gratingPoints.NewRow
|
||||
pointRow("NAME") = "P2"
|
||||
pointRow("QUADRANT") = 2
|
||||
pointRow("X") = (gratingL / 2) / 1000
|
||||
pointRow("Y") = (gratingW / 2) / 1000
|
||||
pointRow("GUI X") = guiPanelMidX + guiMaxDrawL / 2
|
||||
pointRow("GUI Y") = guiPanelMidY - guiMaxDrawW / 2
|
||||
pointRow("RECESS OK") = True
|
||||
gratingPoints.Rows.Add(pointRow)
|
||||
|
||||
pointRow = gratingPoints.NewRow
|
||||
pointRow("NAME") = "P3"
|
||||
pointRow("QUADRANT") = 3
|
||||
pointRow("X") = (gratingL / 2) / 1000
|
||||
pointRow("Y") = (-gratingW / 2) / 1000
|
||||
pointRow("GUI X") = guiPanelMidX + guiMaxDrawL / 2
|
||||
pointRow("GUI Y") = guiPanelMidY + guiMaxDrawW / 2
|
||||
pointRow("RECESS OK") = True
|
||||
gratingPoints.Rows.Add(pointRow)
|
||||
|
||||
pointRow = gratingPoints.NewRow
|
||||
pointRow("NAME") = "P4"
|
||||
pointRow("QUADRANT") = 4
|
||||
pointRow("X") = (-gratingL / 2) / 1000
|
||||
pointRow("Y") = (-gratingW / 2) / 1000
|
||||
pointRow("GUI X") = guiPanelMidX - guiMaxDrawL / 2
|
||||
pointRow("GUI Y") = guiPanelMidY + guiMaxDrawW / 2
|
||||
pointRow("RECESS OK") = True
|
||||
gratingPoints.Rows.Add(pointRow)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
Imports Excel = Microsoft.Office.Interop.Excel
|
||||
Public Class Database
|
||||
Public Shared database As New DataSet
|
||||
|
||||
' --- Retrive the Excel database ---
|
||||
Public Shared Sub Retrive_Database()
|
||||
Dim excelApp As Excel.Application = New Excel.Application
|
||||
Dim excelWB As Excel.Workbook
|
||||
|
||||
' Make .csv files of each sheet in Excel
|
||||
excelApp.DisplayAlerts = False
|
||||
Dim wSNames As New List(Of String)
|
||||
excelWB = excelApp.Workbooks.Open(Settings.HLCtFolder & "\Database\Databas.xlsx")
|
||||
|
||||
For i = 1 To 4
|
||||
Dim activeSheet As Excel.Worksheet
|
||||
activeSheet = excelWB.Sheets(i)
|
||||
wSNames.Add(activeSheet.Name)
|
||||
activeSheet.SaveAs(Settings.HLCtFolder & "\Database\" & wSNames(i - 1), Excel.XlFileFormat.xlCSV)
|
||||
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(activeSheet)
|
||||
Next
|
||||
excelWB.Close()
|
||||
excelApp.Quit()
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(excelWB)
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp)
|
||||
|
||||
' USe this when all sheets are to be read
|
||||
'For Each WS In excelWB.Worksheets
|
||||
' WS.SaveAs(GUI_Settings.HLCtFolder & ("\") & WS.Name, Excel.XlFileFormat.xlCSV)
|
||||
'Next
|
||||
|
||||
|
||||
' Read all .csv files to local database
|
||||
For i = 0 To wSNames.Count - 1
|
||||
Dim tempDT As New DataTable With {
|
||||
.TableName = wSNames(i)
|
||||
}
|
||||
|
||||
Dim lines = IO.File.ReadAllLines(Settings.HLCtFolder & "\Database\" & wSNames(i) & ".csv")
|
||||
|
||||
' Create DataTable columns
|
||||
Dim words As String() = lines(0).Split(New Char() {","c})
|
||||
For j = 0 To words.Count - 1
|
||||
Dim colName As String = words(j).Split("[")(0)
|
||||
colName = colName.Substring(0, colName.Length - 1)
|
||||
Dim type As String = words(j).Split("[")(1).Split("]")(0)
|
||||
|
||||
If type = "str" Then
|
||||
tempDT.Columns.Add(colName, GetType(String))
|
||||
ElseIf type = "int" Then
|
||||
tempDT.Columns.Add(colName, GetType(Integer))
|
||||
ElseIf type = "doub" Then
|
||||
tempDT.Columns.Add(colName, GetType(String)) 'FIXA
|
||||
Else
|
||||
tempDT.Columns.Add(colName, GetType(Boolean))
|
||||
End If
|
||||
Next
|
||||
|
||||
' Fill the DataTable with all data
|
||||
For j = 1 To lines.Count - 1
|
||||
Dim values As String() = lines(j).Split(New Char() {","c})
|
||||
tempDT.Rows.Add()
|
||||
For k = 0 To values.Count - 1
|
||||
Try
|
||||
tempDT.Rows(tempDT.Rows.Count - 1)(k) = values(k)
|
||||
Catch ex As Exception
|
||||
If values(k) <> "" AndAlso values(k) = 0 Then
|
||||
tempDT.Rows(tempDT.Rows.Count - 1)(k) = False
|
||||
ElseIf values(k) <> "" AndAlso values(k) = 1 Then
|
||||
tempDT.Rows(tempDT.Rows.Count - 1)(k) = True
|
||||
End If
|
||||
End Try
|
||||
Next
|
||||
Next
|
||||
|
||||
' Add DataTable to local database (DataSet)
|
||||
database.Tables.Add(tempDT)
|
||||
Next
|
||||
End Sub
|
||||
End Class
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
Public Class GUI_Gratings_Data
|
||||
Public Shared gratingMaxW As Integer = 1000
|
||||
Public Shared gratingMaxL As Integer = 1000
|
||||
|
||||
Public Class User_Input
|
||||
Private Shared gratingType, gratingMaterial, gratingMesh, gratingName As String
|
||||
Private Shared gratingSerrated As Boolean = False
|
||||
Private Shared loadBarSpacing, crossBarSpacing, gratingHeight, loadBarThickness As Integer
|
||||
|
|
@ -9,22 +6,20 @@
|
|||
Private Shared serratedCheckBox As New CheckBox
|
||||
Private Shared serratedCheckBoxBol As Boolean = False
|
||||
|
||||
|
||||
Private Shared lacqueredCheckBox As New CheckBox
|
||||
Private Shared lacqueredCheckBoxBol As Boolean = False
|
||||
Private Shared gratingLacquered As Boolean = False
|
||||
|
||||
|
||||
Public Shared Sub TypeChanged(sender As Object, e As EventArgs)
|
||||
GUI.ComboBox_Material.Enabled = True
|
||||
GUI.ComboBox_Material.Items.Clear()
|
||||
gratingType = GUI.ComboBox_TypeChooser.Text
|
||||
|
||||
Dim materialDT As DataTable = GUI.dataBase("Material")
|
||||
Dim materialDT As DataTable = Database.database.Tables("Material")
|
||||
|
||||
Dim typeInDT As String = materialDT.Rows(0)("TYPE")
|
||||
For i = 0 To materialDT.Rows.Count - 1
|
||||
If gratingType = materialDT.Rows(i)("TYPE") Then
|
||||
If gratingType = typeInDT Then
|
||||
GUI.ComboBox_Material.Items.Add(materialDT.Rows(i)("MATERIAL"))
|
||||
End If
|
||||
Try
|
||||
|
|
@ -40,7 +35,7 @@
|
|||
GUI.ComboBox_MeshSize.Enabled = True
|
||||
gratingMaterial = GUI.ComboBox_Material.Text
|
||||
|
||||
Dim serratedDT As DataTable = GUI.dataBase("Serrated")
|
||||
Dim serratedDT As DataTable = Database.database.Tables("Serrated")
|
||||
|
||||
Dim removeCheckBox As Boolean = True
|
||||
Dim typeInDT As String = serratedDT.Rows(0)("TYPE")
|
||||
|
|
@ -136,7 +131,7 @@
|
|||
|
||||
GUI.ComboBox_MeshSize.Items.Clear()
|
||||
|
||||
Dim meshesDT As DataTable = GUI.dataBase("Meshes")
|
||||
Dim meshesDT As DataTable = Database.database.Tables("Meshes")
|
||||
|
||||
Dim typeInDT As String = meshesDT.Rows(0)("TYPE")
|
||||
Dim materialInDT As String = meshesDT.Rows(0)("MATERIAL")
|
||||
|
|
@ -183,7 +178,7 @@
|
|||
gratingName = gratingMesh.Split("(")(1).Split(")")(0)
|
||||
|
||||
' Add heights
|
||||
Dim meshesDT As DataTable = GUI.dataBase("Meshes")
|
||||
Dim meshesDT As DataTable = Database.database.Tables("Meshes")
|
||||
|
||||
Dim nameInDT As String = meshesDT.Rows(0)("NAME")
|
||||
Dim materialInDT As String = meshesDT.Rows(0)("MATERIAL")
|
||||
|
|
@ -230,7 +225,7 @@
|
|||
GUI.ComboBox_Thickness.Items.Clear()
|
||||
gratingHeight = CInt(GUI.ComboBox_Height.Text)
|
||||
|
||||
Dim meshesDT As DataTable = GUI.dataBase("Meshes")
|
||||
Dim meshesDT As DataTable = Database.database.Tables("Meshes")
|
||||
|
||||
Dim nameInDT As String = meshesDT.Rows(0)("NAME")
|
||||
Dim materialInDT As String = meshesDT.Rows(0)("MATERIAL")
|
||||
|
|
@ -293,7 +288,7 @@
|
|||
|
||||
loadBarThickness = CInt(GUI.ComboBox_Thickness.Text)
|
||||
|
||||
Dim meshesDT As DataTable = GUI.dataBase("Meshes")
|
||||
Dim meshesDT As DataTable = Database.database.Tables("Meshes")
|
||||
|
||||
Dim nameInDT As String = meshesDT.Rows(0)("NAME")
|
||||
Dim materialInDT As String = meshesDT.Rows(0)("MATERIAL")
|
||||
|
|
@ -325,7 +320,7 @@
|
|||
End Try
|
||||
Next
|
||||
|
||||
Dim wholeMeshesDT As DataTable = GUI.dataBase("Whole Meshes")
|
||||
Dim wholeMeshesDT As DataTable = Database.database.Tables("Whole Meshes")
|
||||
For i = 0 To wholeMeshesDT.Rows.Count - 1
|
||||
If Not IsDBNull(wholeMeshesDT.Rows(i)(wholeMeshesColumn)) Then
|
||||
GUI.ComboBox_Width.Items.Add(wholeMeshesDT.Rows(i)(wholeMeshesColumn))
|
||||
|
|
@ -339,24 +334,32 @@
|
|||
If GUI.ComboBox_Width.Text <> "" Then
|
||||
If CInt(GUI.ComboBox_Width.Text) >= GUI.ComboBox_Width.Items(GUI.ComboBox_Width.Items.Count - 1) AndAlso
|
||||
CInt(GUI.ComboBox_Width.Text) <= GUI.ComboBox_Width.Items(0) Then
|
||||
gratingMaxW = CInt(GUI.ComboBox_Width.Text)
|
||||
GUI_Drawing_Panel.Update_GratingPoints()
|
||||
Data.gratingW = CInt(GUI.ComboBox_Width.Text)
|
||||
Draw_Grating.Update_GratingPoints()
|
||||
End If
|
||||
Enable_Recesses()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Shared Sub LengthChanged(sender As Object, e As EventArgs)
|
||||
If GUI.TextBox_Length.Text <> "" Then
|
||||
If CInt(GUI.TextBox_Length.Text) >= 200 AndAlso CInt(GUI.TextBox_Length.Text) <= 6000 Then
|
||||
gratingMaxL = CInt(GUI.TextBox_Length.Text)
|
||||
GUI_Drawing_Panel.Update_GratingPoints()
|
||||
Data.gratingL = CInt(GUI.TextBox_Length.Text)
|
||||
Draw_Grating.Update_GratingPoints()
|
||||
Else
|
||||
'Message: Out of boundary
|
||||
End If
|
||||
Enable_Recesses()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Private Shared Sub Enable_Recesses()
|
||||
If GUI.ComboBox_Width.Text <> "" AndAlso GUI.TextBox_Length.Text <> "" Then
|
||||
GUI.AngleButton.Enabled = True
|
||||
GUI.Button_Square.Enabled = True
|
||||
GUI.Button_SquareSide.Enabled = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
' --- Creates the table with points data used in SW ---
|
||||
|
|
@ -367,25 +370,25 @@
|
|||
Dim gratingTable As New DataTable
|
||||
gratingTable.Columns.Add("TYPE", GetType(String))
|
||||
gratingTable.Columns.Add("SERRATED", GetType(Boolean))
|
||||
gratingTable.Columns.Add("WIDTH", GetType(Decimal))
|
||||
gratingTable.Columns.Add("LENGTH", GetType(Decimal))
|
||||
gratingTable.Columns.Add("LOADBAR_THICKNESS", GetType(Decimal))
|
||||
gratingTable.Columns.Add("LOADBAR_HEIGHT", GetType(Decimal))
|
||||
gratingTable.Columns.Add("LOADBAR_SPACING", GetType(Decimal))
|
||||
gratingTable.Columns.Add("CROSSBAR_SPACING", GetType(Decimal))
|
||||
gratingTable.Columns.Add("CROSSBAR_DIAMETER", GetType(Decimal))
|
||||
gratingTable.Columns.Add("CROSSBAR_THICKNESS", GetType(Decimal))
|
||||
gratingTable.Columns.Add("CROSSBAR_HEIGHT", GetType(Decimal))
|
||||
gratingTable.Columns.Add("WIDTH", GetType(Integer))
|
||||
gratingTable.Columns.Add("LENGTH", GetType(Integer))
|
||||
gratingTable.Columns.Add("LOADBAR_THICKNESS", GetType(Integer))
|
||||
gratingTable.Columns.Add("LOADBAR_HEIGHT", GetType(Integer))
|
||||
gratingTable.Columns.Add("LOADBAR_SPACING", GetType(Integer))
|
||||
gratingTable.Columns.Add("CROSSBAR_SPACING", GetType(Integer))
|
||||
gratingTable.Columns.Add("CROSSBAR_DIAMETER", GetType(Integer))
|
||||
gratingTable.Columns.Add("CROSSBAR_THICKNESS", GetType(Integer))
|
||||
gratingTable.Columns.Add("CROSSBAR_HEIGHT", GetType(Integer))
|
||||
|
||||
gratingTable.Rows.Add()
|
||||
|
||||
gratingTable.Rows(0)("SERRATED") = False 'Hämta från GUI
|
||||
gratingTable.Rows(0)("WIDTH") = CDec(GUI.ComboBox_Width.Text)
|
||||
gratingTable.Rows(0)("LENGTH") = CDec(GUI.TextBox_Length.Text)
|
||||
gratingTable.Rows(0)("LOADBAR_THICKNESS") = CDec(GUI.ComboBox_Thickness.Text)
|
||||
gratingTable.Rows(0)("LOADBAR_HEIGHT") = CDec(GUI.ComboBox_Height.Text)
|
||||
gratingTable.Rows(0)("LOADBAR_SPACING") = CDec(lSpacing)
|
||||
gratingTable.Rows(0)("CROSSBAR_SPACING") = CDec(cSpacing)
|
||||
gratingTable.Rows(0)("WIDTH") = CInt(GUI.ComboBox_Width.Text)
|
||||
gratingTable.Rows(0)("LENGTH") = CInt(GUI.TextBox_Length.Text)
|
||||
gratingTable.Rows(0)("LOADBAR_THICKNESS") = CInt(GUI.ComboBox_Thickness.Text)
|
||||
gratingTable.Rows(0)("LOADBAR_HEIGHT") = CInt(GUI.ComboBox_Height.Text)
|
||||
gratingTable.Rows(0)("LOADBAR_SPACING") = CInt(lSpacing)
|
||||
gratingTable.Rows(0)("CROSSBAR_SPACING") = CInt(cSpacing)
|
||||
|
||||
If GUI.ComboBox_TypeChooser.Text = "Pressure Welded" Then
|
||||
gratingTable.Rows(0)("TYPE") = "pressure_welded" ' Här behövs namn på HLCt modellen
|
||||
|
|
@ -403,25 +406,6 @@
|
|||
End Function
|
||||
|
||||
|
||||
' --- Generate a table containing all the points X- and Y-values ---
|
||||
Public Shared Function Create_PointTable()
|
||||
Dim pointTable As New DataTable
|
||||
pointTable.Columns.Add("X", GetType(Decimal))
|
||||
pointTable.Columns.Add("Y", GetType(Decimal))
|
||||
|
||||
For i = 0 To GUI_Drawing_Panel.pointsOrder.Count - 1
|
||||
Dim pTemp() As Decimal
|
||||
pTemp = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(i))
|
||||
|
||||
pointTable.Rows.Add()
|
||||
pointTable.Rows(i)("X") = pTemp(2)
|
||||
pointTable.Rows(i)("Y") = pTemp(3)
|
||||
Next
|
||||
|
||||
Return pointTable
|
||||
End Function
|
||||
|
||||
|
||||
' --- Check if the key pressed is a number ---
|
||||
Public Shared Sub Check_IfNumber(e As KeyPressEventArgs)
|
||||
If Asc(e.KeyChar) <> 8 Then
|
||||
|
|
@ -431,4 +415,4 @@
|
|||
End If
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
End Class
|
||||
|
|
@ -0,0 +1,351 @@
|
|||
Public Class Corner_Angle
|
||||
|
||||
' --- Create textboxes when user clicks the angle corner recess button ---
|
||||
Public Shared Sub AngleButton(sender As Object, e As EventArgs)
|
||||
GUI.Controls("AngleButton").Enabled = False
|
||||
GUI.Controls("Button_Square").Enabled = False
|
||||
GUI.Controls("Button_SquareSide").Enabled = False
|
||||
|
||||
Dim buttonX As Integer = GUI.Controls("AngleButton").Location.X
|
||||
Dim buttonY As Integer = GUI.Controls("AngleButton").Location.Y
|
||||
|
||||
GUI.Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
AddHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("X_Label", "L", buttonX, buttonY + 43)
|
||||
|
||||
GUI.Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
AddHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("Y_Label", "W", buttonX + 110, buttonY + 43)
|
||||
End Sub
|
||||
|
||||
' --- Check the key pressed by the user ---
|
||||
Private Shared Sub FunctionText_KeyPress(sender As Object, e As KeyPressEventArgs)
|
||||
User_Input.Check_IfNumber(e)
|
||||
End Sub
|
||||
|
||||
' --- Adds clickable buttons for all corners if conditions are met ---
|
||||
Private Shared Sub FunctionTextCorner_Changed(sender As TextBox, e As EventArgs)
|
||||
Dim value1, value2 As Integer
|
||||
Try
|
||||
value1 = CInt(GUI.Controls("X_TextBox").Text)
|
||||
value2 = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
Catch ex As Exception
|
||||
value1 = 0
|
||||
value2 = 0
|
||||
End Try
|
||||
|
||||
If value1 > 0 AndAlso value2 > 0 Then
|
||||
If GUI.DrawingPanel.Controls.Count = 2 Then
|
||||
For i = 0 To Data.gratingPoints.Rows.Count - 1
|
||||
If Data.gratingPoints.Rows(i)("RECESS OK") Then
|
||||
Dim pointButton As New Button With {
|
||||
.Width = 30,
|
||||
.Height = 30,
|
||||
.Left = Data.gratingPoints.Rows(i)("GUI X") - 30 / 2,
|
||||
.Top = Data.gratingPoints.Rows(i)("GUI Y") - 30 / 2,
|
||||
.Name = Data.gratingPoints.Rows(i)("NAME") & "_Button",
|
||||
.Text = ""
|
||||
}
|
||||
|
||||
pointButton.BackColor = Color.FromArgb(50, Color.Red)
|
||||
pointButton.FlatStyle = FlatStyle.Flat
|
||||
pointButton.FlatAppearance.BorderSize = 0
|
||||
pointButton.FlatAppearance.MouseOverBackColor = Color.Red
|
||||
pointButton.FlatAppearance.MouseDownBackColor = Color.DarkRed
|
||||
Dim gp As New Drawing2D.GraphicsPath
|
||||
gp.AddEllipse(New Rectangle(New Point(0, 0), New Size(30, 30)))
|
||||
pointButton.Region = New Region(gp)
|
||||
|
||||
GUI.DrawingPanel.Controls.Add(pointButton)
|
||||
|
||||
AddHandler pointButton.Click, AddressOf PointButton_Click
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
ElseIf GUI.DrawingPanel.Controls.Count > 2 Then
|
||||
For i = 0 To Data.gratingPoints.Rows.Count - 1
|
||||
If Data.gratingPoints.Rows(i)("RECESS OK") Then
|
||||
Dim buttonName As String = Data.gratingPoints.Rows(i)("NAME") & "_Button"
|
||||
RemoveHandler GUI.DrawingPanel.Controls(buttonName).Click, AddressOf PointButton_Click
|
||||
GUI.DrawingPanel.Controls.RemoveByKey(Data.gratingPoints.Rows(i)("NAME") & "_Button")
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' --- When a corner function button is pressed ---
|
||||
Private Shared Sub PointButton_Click(sender As Button, e As EventArgs)
|
||||
'Determine which point is being pressed
|
||||
Dim pointPressed As String = sender.Name.Split("_")(0)
|
||||
Dim index As Integer
|
||||
For Each DR As DataRow In Data.gratingPoints.Rows
|
||||
If DR("NAME") = pointPressed Then
|
||||
index = Data.gratingPoints.Rows.IndexOf(DR)
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
' Remove point buttons
|
||||
For i = 0 To Data.gratingPoints.Rows.Count - 1
|
||||
If Data.gratingPoints.Rows(i)("RECESS OK") Then
|
||||
Dim buttonName As String = Data.gratingPoints.Rows(i)("NAME") & "_Button"
|
||||
RemoveHandler GUI.DrawingPanel.Controls(buttonName).Click, AddressOf PointButton_Click
|
||||
GUI.DrawingPanel.Controls.RemoveByKey(Data.gratingPoints.Rows(i)("NAME") & "_Button")
|
||||
End If
|
||||
Next
|
||||
|
||||
'Retrive that points coords
|
||||
Dim pXGUI As Integer = Data.gratingPoints.Rows(index)("GUI X")
|
||||
Dim pYGUI As Integer = Data.gratingPoints.Rows(index)("GUI Y")
|
||||
Dim pX As Decimal = Data.gratingPoints.Rows(index)("X")
|
||||
Dim pY As Decimal = Data.gratingPoints.Rows(index)("Y")
|
||||
|
||||
Dim dXGUI As Integer = CInt(GUI.Controls("X_TextBox").Text / Data.scaleDiff)
|
||||
Dim dYGUI As Integer = CInt(GUI.Controls("Y_TextBox").Text / Data.scaleDiff)
|
||||
Dim dX As Decimal = GUI.Controls("X_TextBox").Text / 1000
|
||||
Dim dY As Decimal = GUI.Controls("Y_TextBox").Text / 1000
|
||||
|
||||
'Data.recessData.Rows.Add()
|
||||
|
||||
For i = 2 To Data.pointsMeasurements.Count - 1
|
||||
Dim mesName As String = Data.pointsMeasurements.Keys(i)
|
||||
If mesName.Split("_")(0) <> "SS1" AndAlso mesName.Split("_")(0) <> "SS" Then
|
||||
If index + 1 = Data.pointsMeasurements(mesName)(0) Then
|
||||
If Draw_Grating.measureLabels(mesName)(3) = 1 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) + dXGUI / 2
|
||||
ElseIf Draw_Grating.measureLabels(mesName)(3) = 2 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("Y_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) + dYGUI / 2
|
||||
ElseIf Draw_Grating.measureLabels(mesName)(3) = 3 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) - dXGUI / 2
|
||||
Else
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("Y_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) - dYGUI / 2
|
||||
End If
|
||||
ElseIf index + 1 = Data.pointsMeasurements(mesName)(1) Then
|
||||
If Draw_Grating.measureLabels(mesName)(3) = 1 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("Y_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) + dYGUI / 2
|
||||
ElseIf Draw_Grating.measureLabels(mesName)(3) = 2 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) - dXGUI / 2
|
||||
ElseIf Draw_Grating.measureLabels(mesName)(3) = 3 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("Y_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) - dYGUI / 2
|
||||
Else
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) + dXGUI / 2
|
||||
End If
|
||||
End If
|
||||
|
||||
ElseIf mesName.Split("_")(0) = "SS1" AndAlso index + 2 = Data.pointsMeasurements(mesName)(1) Then
|
||||
If Draw_Grating.measureLabels(mesName)(3) = 1 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) + dXGUI / 2
|
||||
|
||||
Draw_Grating.sideSquareMesLine(mesName)(0) = Draw_Grating.sideSquareMesLine(mesName)(0) + dXGUI
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim mesNum As Integer = Data.pointsMeasurements.Count - 1
|
||||
|
||||
For i = 2 To Data.pointsMeasurements.Count - 1
|
||||
Dim mesName As String = Data.pointsMeasurements.Keys(i)
|
||||
If index + 1 < Data.pointsMeasurements(mesName)(0) Then
|
||||
Data.pointsMeasurements(mesName)(0) = Data.pointsMeasurements(mesName)(0) + 1
|
||||
Data.pointsMeasurements(mesName)(1) = Data.pointsMeasurements(mesName)(1) + 1
|
||||
ElseIf index + 1 = Data.pointsMeasurements(mesName)(0) OrElse index + 1 = Data.pointsMeasurements(mesName)(1) Then
|
||||
Data.pointsMeasurements(mesName)(1) = Data.pointsMeasurements(mesName)(1) + 1
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim pointQuadrant As Integer = Get_PointQuadrant(pXGUI, pYGUI)
|
||||
Dim pointRow1 As DataRow = Data.gratingPoints.NewRow
|
||||
Dim pointRow2 As DataRow = Data.gratingPoints.NewRow
|
||||
|
||||
pointRow1("NAME") = "CA" & pointQuadrant & "_" & 1
|
||||
pointRow1("QUADRANT") = pointQuadrant
|
||||
pointRow1("RECESS OK") = False
|
||||
|
||||
pointRow2("NAME") = "CA" & pointQuadrant & "_" & 2
|
||||
pointRow2("QUADRANT") = pointQuadrant
|
||||
pointRow2("RECESS OK") = False
|
||||
If pointQuadrant = 1 Then
|
||||
' Add the new points
|
||||
pointRow1("X") = pX
|
||||
pointRow1("Y") = pY - dY
|
||||
pointRow1("GUI X") = pXGUI
|
||||
pointRow1("GUI Y") = pYGUI + dYGUI
|
||||
|
||||
pointRow2("X") = pX + dX
|
||||
pointRow2("Y") = pY
|
||||
pointRow2("GUI X") = pXGUI + dXGUI
|
||||
pointRow2("GUI Y") = pYGUI
|
||||
|
||||
' Update outer measuements (SW)
|
||||
Data.pointsMeasurements("Lmes")(1) = Data.pointsMeasurements("Lmes")(1) + 1
|
||||
Data.pointsMeasurements("Wmes")(0) = Data.pointsMeasurements("Wmes")(0) + 1
|
||||
Data.pointsMeasurements("Wmes")(1) = Data.pointsMeasurements("Wmes")(1) + 1
|
||||
|
||||
' Add recess measuements (SW)
|
||||
Data.pointsMeasurements.Add("A_" & mesNum, {index + 1, index + 2, 1})
|
||||
Data.pointsMeasurements.Add("A_" & mesNum + 1, {index + 1, index + 2, 4})
|
||||
|
||||
' Add angle recess help point (GUI)
|
||||
Dim pointRow = Data.angleRecessPoints.NewRow
|
||||
pointRow("NAME") = "CA" & pointQuadrant
|
||||
pointRow("QUADRANT") = pointQuadrant
|
||||
pointRow("GUI X") = pXGUI + dXGUI
|
||||
pointRow("GUI Y") = pYGUI + dYGUI
|
||||
Data.angleRecessPoints.Rows.Add(pointRow)
|
||||
|
||||
' Add recess measurments (GUI)
|
||||
Draw_Grating.measureLabels.Add("A_" & mesNum, {CInt(GUI.Controls("X_TextBox").Text), pXGUI + dXGUI / 2 - 8,
|
||||
pYGUI + dYGUI + 3, 1})
|
||||
Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI + dXGUI + 3,
|
||||
pYGUI + dYGUI / 2 - 4, 1})
|
||||
ElseIf pointQuadrant = 2 Then
|
||||
' Add the new points
|
||||
pointRow1("X") = pX - dX
|
||||
pointRow1("Y") = pY
|
||||
pointRow1("GUI X") = pXGUI - dXGUI
|
||||
pointRow1("GUI Y") = pYGUI
|
||||
|
||||
pointRow2("X") = pX
|
||||
pointRow2("Y") = pY - dY
|
||||
pointRow2("GUI X") = pXGUI
|
||||
pointRow2("GUI Y") = pYGUI + dYGUI
|
||||
|
||||
' Update outer measuements (SW)
|
||||
Data.pointsMeasurements("Lmes")(1) = Data.pointsMeasurements("Lmes")(1) + 1
|
||||
Data.pointsMeasurements("Wmes")(1) = Data.pointsMeasurements("Wmes")(1) + 1
|
||||
|
||||
' Add recess measuements (SW)
|
||||
Data.pointsMeasurements.Add("A_" & mesNum, {index + 1, index + 2, 1})
|
||||
Data.pointsMeasurements.Add("A_" & mesNum + 1, {index + 1, index + 2, 2})
|
||||
|
||||
' Add angle recess help point (GUI)
|
||||
Dim pointRow = Data.angleRecessPoints.NewRow
|
||||
pointRow("NAME") = "CA" & pointQuadrant
|
||||
pointRow("QUADRANT") = pointQuadrant
|
||||
pointRow("GUI X") = pXGUI - dXGUI
|
||||
pointRow("GUI Y") = pYGUI + dYGUI
|
||||
Data.angleRecessPoints.Rows.Add(pointRow)
|
||||
|
||||
' Add recess measurments (GUI)
|
||||
Draw_Grating.measureLabels.Add("A_" & mesNum, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI - dXGUI - 18 - 3,
|
||||
pYGUI + dYGUI / 2 - 4, 2})
|
||||
Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXGUI - dXGUI / 2 - 8,
|
||||
pYGUI + dYGUI + 3, 2})
|
||||
ElseIf pointQuadrant = 3 Then
|
||||
' Add the new points
|
||||
pointRow1("X") = pX
|
||||
pointRow1("Y") = pY + dY
|
||||
pointRow1("GUI X") = pXGUI
|
||||
pointRow1("GUI Y") = pYGUI - dYGUI
|
||||
|
||||
pointRow2("X") = pX - dX
|
||||
pointRow2("Y") = pY
|
||||
pointRow2("GUI X") = pXGUI - dXGUI
|
||||
pointRow2("GUI Y") = pYGUI
|
||||
|
||||
' Update outer measuements (SW)
|
||||
Data.pointsMeasurements("Wmes")(1) = Data.pointsMeasurements("Wmes")(1) + 1
|
||||
|
||||
' Add recess measuements (SW)
|
||||
Data.pointsMeasurements.Add("A_" & mesNum, {index + 1, index + 2, 2})
|
||||
Data.pointsMeasurements.Add("A_" & mesNum + 1, {index + 1, index + 2, 3})
|
||||
|
||||
' Add angle recess help point (GUI)
|
||||
Dim pointRow = Data.angleRecessPoints.NewRow
|
||||
pointRow("NAME") = "CA" & pointQuadrant
|
||||
pointRow("QUADRANT") = pointQuadrant
|
||||
pointRow("GUI X") = pXGUI - dXGUI
|
||||
pointRow("GUI Y") = pYGUI - dYGUI
|
||||
Data.angleRecessPoints.Rows.Add(pointRow)
|
||||
|
||||
' Add recess measurments (GUI)
|
||||
Draw_Grating.measureLabels.Add("A_" & mesNum, {CInt(GUI.Controls("X_TextBox").Text), pXGUI - dXGUI / 2 - 8,
|
||||
pYGUI - dYGUI - 12 - 3, 3})
|
||||
Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI - dXGUI - 18 - 3,
|
||||
pYGUI - dYGUI / 2 - 4, 3})
|
||||
Else
|
||||
' Add the new points
|
||||
pointRow1("X") = pX + dX
|
||||
pointRow1("Y") = pY
|
||||
pointRow1("GUI X") = pXGUI + dXGUI
|
||||
pointRow1("GUI Y") = pYGUI
|
||||
|
||||
pointRow2("X") = pX
|
||||
pointRow2("Y") = pY + dY
|
||||
pointRow2("GUI X") = pXGUI
|
||||
pointRow2("GUI Y") = pYGUI - dYGUI
|
||||
|
||||
' Add recess measuements (SW)
|
||||
Data.pointsMeasurements.Add("A_" & mesNum, {index + 1, index + 2, 3})
|
||||
Data.pointsMeasurements.Add("A_" & mesNum + 1, {index + 1, index + 2, 4})
|
||||
|
||||
' Add angle recess help point (GUI)
|
||||
Dim pointRow = Data.angleRecessPoints.NewRow
|
||||
pointRow("NAME") = "CA" & pointQuadrant
|
||||
pointRow("QUADRANT") = pointQuadrant
|
||||
pointRow("GUI X") = pXGUI + dXGUI
|
||||
pointRow("GUI Y") = pYGUI - dYGUI
|
||||
Data.angleRecessPoints.Rows.Add(pointRow)
|
||||
|
||||
' Add recess measurments (GUI)
|
||||
Draw_Grating.measureLabels.Add("A_" & mesNum, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI + dXGUI + 3,
|
||||
pYGUI - dYGUI / 2 - 4, 4})
|
||||
Draw_Grating.measureLabels.Add("A_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXGUI + dXGUI / 2 - 8,
|
||||
pYGUI - dYGUI - 12 - 3, 4})
|
||||
End If
|
||||
|
||||
Data.gratingPoints.Rows.InsertAt(pointRow1, index + 1)
|
||||
Data.gratingPoints.Rows.InsertAt(pointRow2, index + 2)
|
||||
Data.gratingPoints.Rows.RemoveAt(index)
|
||||
|
||||
'Redraw grating
|
||||
GUI.DrawingPanel.Refresh()
|
||||
|
||||
RemoveHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
RemoveHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Controls.RemoveByKey("X_TextBox")
|
||||
|
||||
RemoveHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
RemoveHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Controls.RemoveByKey("Y_TextBox")
|
||||
|
||||
GUI.Controls.RemoveByKey("X_Label")
|
||||
GUI.Controls.RemoveByKey("Y_Label")
|
||||
|
||||
GUI.Controls("AngleButton").Enabled = True
|
||||
GUI.Controls("Button_Square").Enabled = True
|
||||
GUI.Controls("Button_SquareSide").Enabled = True
|
||||
End Sub
|
||||
|
||||
' --- Determines the clicked points quadrant ---
|
||||
Private Shared Function Get_PointQuadrant(pXGUI As Integer, pYGUI As Integer)
|
||||
Dim quadrant As Integer
|
||||
If pXGUI < Data.guiPanelMidX Then
|
||||
If pYGUI > Data.guiPanelMidY Then
|
||||
quadrant = 4
|
||||
Else
|
||||
quadrant = 1
|
||||
End If
|
||||
Else
|
||||
If pYGUI > Data.guiPanelMidY Then
|
||||
quadrant = 3
|
||||
Else
|
||||
quadrant = 2
|
||||
End If
|
||||
End If
|
||||
|
||||
Return quadrant
|
||||
End Function
|
||||
End Class
|
||||
|
|
@ -0,0 +1,373 @@
|
|||
Public Class Corner_Rectangle
|
||||
|
||||
' --- Create textboxes when user clicks the rectangle corner recess button ---
|
||||
Public Shared Sub SquareButtton(sender As Object, e As EventArgs)
|
||||
GUI.Controls("AngleButton").Enabled = False
|
||||
GUI.Controls("Button_Square").Enabled = False
|
||||
GUI.Controls("Button_SquareSide").Enabled = False
|
||||
|
||||
Dim buttonX As Integer = GUI.Controls("Button_Square").Location.X
|
||||
Dim buttonY As Integer = GUI.Controls("Button_Square").Location.Y
|
||||
|
||||
GUI.Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
AddHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("X_Label", "L", buttonX, buttonY + 43)
|
||||
|
||||
GUI.Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
AddHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("Y_Label", "W", buttonX + 110, buttonY + 43)
|
||||
End Sub
|
||||
|
||||
' --- Check the key pressed by the user ---
|
||||
Private Shared Sub FunctionText_KeyPress(sender As Object, e As KeyPressEventArgs)
|
||||
User_Input.Check_IfNumber(e)
|
||||
End Sub
|
||||
|
||||
' --- Adds clickable buttons for all corners if conditions are met ---
|
||||
Private Shared Sub FunctionTextCorner_Changed(sender As TextBox, e As EventArgs)
|
||||
Dim value1, value2 As Integer
|
||||
Try
|
||||
value1 = CInt(GUI.Controls("X_TextBox").Text)
|
||||
value2 = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
Catch ex As Exception
|
||||
value1 = 0
|
||||
value2 = 0
|
||||
End Try
|
||||
|
||||
If value1 > 0 AndAlso value2 > 0 Then
|
||||
If GUI.DrawingPanel.Controls.Count = 2 Then
|
||||
For i = 0 To Data.gratingPoints.Rows.Count - 1
|
||||
If Data.gratingPoints.Rows(i)("RECESS OK") Then
|
||||
Dim pointButton As New Button With {
|
||||
.Width = 30,
|
||||
.Height = 30,
|
||||
.Left = Data.gratingPoints.Rows(i)("GUI X") - 30 / 2,
|
||||
.Top = Data.gratingPoints.Rows(i)("GUI Y") - 30 / 2,
|
||||
.Name = Data.gratingPoints.Rows(i)("NAME") & "_Button",
|
||||
.Text = ""
|
||||
}
|
||||
|
||||
pointButton.BackColor = Color.FromArgb(50, Color.Red)
|
||||
pointButton.FlatStyle = FlatStyle.Flat
|
||||
pointButton.FlatAppearance.BorderSize = 0
|
||||
pointButton.FlatAppearance.MouseOverBackColor = Color.Red
|
||||
pointButton.FlatAppearance.MouseDownBackColor = Color.DarkRed
|
||||
Dim gp As New Drawing2D.GraphicsPath
|
||||
gp.AddEllipse(New Rectangle(New Point(0, 0), New Size(30, 30)))
|
||||
pointButton.Region = New Region(gp)
|
||||
|
||||
GUI.DrawingPanel.Controls.Add(pointButton)
|
||||
|
||||
AddHandler pointButton.Click, AddressOf PointButton_Click
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
ElseIf GUI.DrawingPanel.Controls.Count > 2 Then
|
||||
For i = 0 To Data.gratingPoints.Rows.Count - 1
|
||||
If Data.gratingPoints.Rows(i)("RECESS OK") Then
|
||||
Dim buttonName As String = Data.gratingPoints.Rows(i)("NAME") & "_Button"
|
||||
RemoveHandler GUI.DrawingPanel.Controls(buttonName).Click, AddressOf PointButton_Click
|
||||
GUI.DrawingPanel.Controls.RemoveByKey(Data.gratingPoints.Rows(i)("NAME") & "_Button")
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' --- When a corner function button is pressed ---
|
||||
Private Shared Sub PointButton_Click(sender As Button, e As EventArgs)
|
||||
'Determine which point is being pressed
|
||||
Dim pointPressed As String = sender.Name.Split("_")(0)
|
||||
Dim index As Integer
|
||||
For Each DR As DataRow In Data.gratingPoints.Rows
|
||||
If DR("NAME") = pointPressed Then
|
||||
index = Data.gratingPoints.Rows.IndexOf(DR)
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
' Remove point buttons
|
||||
For i = 0 To Data.gratingPoints.Rows.Count - 1
|
||||
If Data.gratingPoints.Rows(i)("RECESS OK") Then
|
||||
Dim buttonName As String = Data.gratingPoints.Rows(i)("NAME") & "_Button"
|
||||
RemoveHandler GUI.DrawingPanel.Controls(buttonName).Click, AddressOf PointButton_Click
|
||||
GUI.DrawingPanel.Controls.RemoveByKey(Data.gratingPoints.Rows(i)("NAME") & "_Button")
|
||||
End If
|
||||
Next
|
||||
|
||||
'Retrive the points coords
|
||||
Dim pXGUI As Integer = Data.gratingPoints.Rows(index)("GUI X")
|
||||
Dim pYGUI As Integer = Data.gratingPoints.Rows(index)("GUI Y")
|
||||
Dim pX As Decimal = Data.gratingPoints.Rows(index)("X")
|
||||
Dim pY As Decimal = Data.gratingPoints.Rows(index)("Y")
|
||||
|
||||
Dim dXGUI As Integer = CInt(GUI.Controls("X_TextBox").Text / Data.scaleDiff)
|
||||
Dim dYGUI As Integer = CInt(GUI.Controls("Y_TextBox").Text / Data.scaleDiff)
|
||||
Dim dX As Decimal = GUI.Controls("X_TextBox").Text / 1000
|
||||
Dim dY As Decimal = GUI.Controls("Y_TextBox").Text / 1000
|
||||
|
||||
Data.recessData.Rows.Add()
|
||||
|
||||
For i = 2 To Data.pointsMeasurements.Count - 1
|
||||
Dim mesName As String = Data.pointsMeasurements.Keys(i)
|
||||
If mesName.Split("_")(0) <> "SS1" AndAlso mesName.Split("_")(0) <> "SS" Then
|
||||
If index + 1 = Data.pointsMeasurements(mesName)(0) Then
|
||||
If Draw_Grating.measureLabels(mesName)(3) = 1 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) + dXGUI / 2
|
||||
ElseIf Draw_Grating.measureLabels(mesName)(3) = 2 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("Y_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) + dYGUI / 2
|
||||
ElseIf Draw_Grating.measureLabels(mesName)(3) = 3 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) - dXGUI / 2
|
||||
Else
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("Y_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) - dYGUI / 2
|
||||
End If
|
||||
ElseIf index + 1 = Data.pointsMeasurements(mesName)(1) Then
|
||||
If Draw_Grating.measureLabels(mesName)(3) = 1 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("Y_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) + dYGUI / 2
|
||||
ElseIf Draw_Grating.measureLabels(mesName)(3) = 2 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) - dXGUI / 2
|
||||
ElseIf Draw_Grating.measureLabels(mesName)(3) = 3 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("Y_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(2) = Draw_Grating.measureLabels(mesName)(2) - dYGUI / 2
|
||||
Else
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) + dXGUI / 2
|
||||
End If
|
||||
End If
|
||||
|
||||
ElseIf mesName.Split("_")(0) = "SS1" AndAlso index + 2 = Data.pointsMeasurements(mesName)(1) Then
|
||||
If Draw_Grating.measureLabels(mesName)(3) = 1 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Draw_Grating.measureLabels(mesName)(0) - GUI.Controls("X_TextBox").Text
|
||||
Draw_Grating.measureLabels(mesName)(1) = Draw_Grating.measureLabels(mesName)(1) + dXGUI / 2
|
||||
|
||||
Draw_Grating.sideSquareMesLine(mesName)(0) = Draw_Grating.sideSquareMesLine(mesName)(0) + dXGUI
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim mesNum As Integer = Data.pointsMeasurements.Count - 1
|
||||
|
||||
For i = 2 To Data.pointsMeasurements.Count - 1
|
||||
Dim mesName As String = Data.pointsMeasurements.Keys(i)
|
||||
If index + 1 < Data.pointsMeasurements(mesName)(0) Then
|
||||
Data.pointsMeasurements(mesName)(0) = Data.pointsMeasurements(mesName)(0) + 1
|
||||
Data.pointsMeasurements(mesName)(1) = Data.pointsMeasurements(mesName)(1) + 1
|
||||
ElseIf index + 1 = Data.pointsMeasurements(mesName)(0) OrElse index + 1 = Data.pointsMeasurements(mesName)(1) Then
|
||||
Data.pointsMeasurements(mesName)(1) = Data.pointsMeasurements(mesName)(1) + 1
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim pointQuadrant As Integer = Get_PointQuadrant(pXGUI, pYGUI)
|
||||
Dim pointRow1 As DataRow = Data.gratingPoints.NewRow
|
||||
Dim pointRow2 As DataRow = Data.gratingPoints.NewRow
|
||||
Dim pointRow3 As DataRow = Data.gratingPoints.NewRow
|
||||
|
||||
pointRow1("NAME") = "CR" & pointQuadrant & "_" & 1
|
||||
pointRow1("QUADRANT") = pointQuadrant
|
||||
pointRow1("RECESS OK") = True
|
||||
|
||||
pointRow2("NAME") = "CR" & pointQuadrant & "_" & 2
|
||||
pointRow2("QUADRANT") = pointQuadrant
|
||||
pointRow2("RECESS OK") = False
|
||||
|
||||
pointRow3("NAME") = "CR" & pointQuadrant & "_" & 3
|
||||
pointRow3("QUADRANT") = pointQuadrant
|
||||
pointRow3("RECESS OK") = True
|
||||
|
||||
If pointQuadrant = 1 Then
|
||||
' Add the new points
|
||||
pointRow1("X") = pX
|
||||
pointRow1("Y") = pY - dY
|
||||
pointRow1("GUI X") = pXGUI
|
||||
pointRow1("GUI Y") = pYGUI + dYGUI
|
||||
|
||||
pointRow2("X") = pX + dX
|
||||
pointRow2("Y") = pY - dY
|
||||
pointRow2("GUI X") = pXGUI + dXGUI
|
||||
pointRow2("GUI Y") = pYGUI + dYGUI
|
||||
|
||||
pointRow3("X") = pX + dX
|
||||
pointRow3("Y") = pY
|
||||
pointRow3("GUI X") = pXGUI + dXGUI
|
||||
pointRow3("GUI Y") = pYGUI
|
||||
|
||||
' Update outer measuements (SW)
|
||||
Data.pointsMeasurements("Lmes")(1) = Data.pointsMeasurements("Lmes")(1) + 2
|
||||
Data.pointsMeasurements("Wmes")(0) = Data.pointsMeasurements("Wmes")(0) + 2
|
||||
Data.pointsMeasurements("Wmes")(1) = Data.pointsMeasurements("Wmes")(1) + 2
|
||||
|
||||
' Add recess measuements (SW)
|
||||
Data.pointsMeasurements.Add("S_" & mesNum, {index + 1, index + 2, 1})
|
||||
Data.pointsMeasurements.Add("S_" & mesNum + 1, {index + 2, index + 3, 4})
|
||||
|
||||
' Add recess measurments (GUI)
|
||||
Draw_Grating.measureLabels.Add("S_" & mesNum, {CInt(GUI.Controls("X_TextBox").Text), pXGUI + dXGUI / 2 - 8,
|
||||
pYGUI + dYGUI + 3, 1})
|
||||
Draw_Grating.measureLabels.Add("S_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI + dXGUI + 3,
|
||||
pYGUI + dYGUI / 2 - 4, 1})
|
||||
|
||||
' Recess Data
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("RECESS TYPE") = "SQUARE"
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("CORNER") = 1
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("WIDTH") = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("LENGTH") = CInt(GUI.Controls("X_TextBox").Text)
|
||||
|
||||
ElseIf pointQuadrant = 2 Then
|
||||
' Add the new points
|
||||
pointRow1("X") = pX - dX
|
||||
pointRow1("Y") = pY
|
||||
pointRow1("GUI X") = pXGUI - dXGUI
|
||||
pointRow1("GUI Y") = pYGUI
|
||||
|
||||
pointRow2("X") = pX - dX
|
||||
pointRow2("Y") = pY - dY
|
||||
pointRow2("GUI X") = pXGUI - dXGUI
|
||||
pointRow2("GUI Y") = pYGUI + dYGUI
|
||||
|
||||
pointRow3("X") = pX
|
||||
pointRow3("Y") = pY - dY
|
||||
pointRow3("GUI X") = pXGUI
|
||||
pointRow3("GUI Y") = pYGUI + dYGUI
|
||||
|
||||
' Update outer measuements (SW)
|
||||
Data.pointsMeasurements("Lmes")(1) = Data.pointsMeasurements("Lmes")(1) + 2
|
||||
Data.pointsMeasurements("Wmes")(1) = Data.pointsMeasurements("Wmes")(1) + 2
|
||||
|
||||
' Add recess measuements (SW)
|
||||
Data.pointsMeasurements.Add("S_" & mesNum, {index + 1, index + 2, 2})
|
||||
Data.pointsMeasurements.Add("S_" & mesNum + 1, {index + 2, index + 3, 1})
|
||||
|
||||
' Add recess measurments (GUI)
|
||||
Draw_Grating.measureLabels.Add("S_" & mesNum, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI - dXGUI - 18 - 3,
|
||||
pYGUI + dYGUI / 2 - 4, 2})
|
||||
Draw_Grating.measureLabels.Add("S_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXGUI - dXGUI / 2 - 8,
|
||||
pYGUI + dYGUI + 3, 2})
|
||||
|
||||
' Recess Data
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("RECESS TYPE") = "SQUARE"
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("CORNER") = 2
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("WIDTH") = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("LENGTH") = CInt(GUI.Controls("X_TextBox").Text)
|
||||
|
||||
ElseIf pointQuadrant = 3 Then
|
||||
' Add the new points
|
||||
pointRow1("X") = pX
|
||||
pointRow1("Y") = pY + dY
|
||||
pointRow1("GUI X") = pXGUI
|
||||
pointRow1("GUI Y") = pYGUI - dYGUI
|
||||
|
||||
pointRow2("X") = pX - dX
|
||||
pointRow2("Y") = pY + dY
|
||||
pointRow2("GUI X") = pXGUI - dXGUI
|
||||
pointRow2("GUI Y") = pYGUI - dYGUI
|
||||
|
||||
pointRow3("X") = pX - dX
|
||||
pointRow3("Y") = pY
|
||||
pointRow3("GUI X") = pXGUI - dXGUI
|
||||
pointRow3("GUI Y") = pYGUI
|
||||
|
||||
' Update outer measuements (SW)
|
||||
Data.pointsMeasurements("Wmes")(1) = Data.pointsMeasurements("Wmes")(1) + 2
|
||||
|
||||
' Add recess measuements (SW)
|
||||
Data.pointsMeasurements.Add("S_" & mesNum, {index + 1, index + 2, 3})
|
||||
Data.pointsMeasurements.Add("S_" & mesNum + 1, {index + 2, index + 3, 2})
|
||||
|
||||
' Add recess measurments (GUI)
|
||||
Draw_Grating.measureLabels.Add("S_" & mesNum, {CInt(GUI.Controls("X_TextBox").Text), pXGUI - dXGUI / 2 - 8,
|
||||
pYGUI - dYGUI - 12 - 3, 3})
|
||||
Draw_Grating.measureLabels.Add("S_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI - dXGUI - 18 - 3,
|
||||
pYGUI - dYGUI / 2 - 4, 3})
|
||||
|
||||
' Recess Data
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("RECESS TYPE") = "SQUARE"
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("CORNER") = 3
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("WIDTH") = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("LENGTH") = CInt(GUI.Controls("X_TextBox").Text)
|
||||
|
||||
Else
|
||||
' Add the new points
|
||||
pointRow1("X") = pX + dX
|
||||
pointRow1("Y") = pY
|
||||
pointRow1("GUI X") = pXGUI + dXGUI
|
||||
pointRow1("GUI Y") = pYGUI
|
||||
|
||||
pointRow2("X") = pX + dX
|
||||
pointRow2("Y") = pY + dY
|
||||
pointRow2("GUI X") = pXGUI + dXGUI
|
||||
pointRow2("GUI Y") = pYGUI - dYGUI
|
||||
|
||||
pointRow3("X") = pX
|
||||
pointRow3("Y") = pY + dY
|
||||
pointRow3("GUI X") = pXGUI
|
||||
pointRow3("GUI Y") = pYGUI - dYGUI
|
||||
|
||||
' Add recess measuements (SW)
|
||||
Data.pointsMeasurements.Add("S_" & mesNum, {index + 1, index + 2, 4})
|
||||
Data.pointsMeasurements.Add("S_" & mesNum + 1, {index + 2, index + 3, 3})
|
||||
|
||||
' Add recess measurments (GUI)
|
||||
Draw_Grating.measureLabels.Add("S_" & mesNum, {CInt(GUI.Controls("Y_TextBox").Text), pXGUI + dXGUI + 3,
|
||||
pYGUI - dYGUI / 2 - 4, 4})
|
||||
Draw_Grating.measureLabels.Add("S_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text), pXGUI + dXGUI / 2 - 8,
|
||||
pYGUI - dYGUI - 12 - 3, 4})
|
||||
|
||||
' Recess Data
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("RECESS TYPE") = "SQUARE"
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("CORNER") = 4
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("WIDTH") = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("LENGTH") = CInt(GUI.Controls("X_TextBox").Text)
|
||||
End If
|
||||
|
||||
Data.gratingPoints.Rows.InsertAt(pointRow1, index + 1)
|
||||
Data.gratingPoints.Rows.InsertAt(pointRow2, index + 2)
|
||||
Data.gratingPoints.Rows.InsertAt(pointRow3, index + 3)
|
||||
Data.gratingPoints.Rows.RemoveAt(index)
|
||||
|
||||
'Redraw grating
|
||||
GUI.DrawingPanel.Refresh()
|
||||
|
||||
RemoveHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
RemoveHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Controls.RemoveByKey("X_TextBox")
|
||||
|
||||
RemoveHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
|
||||
RemoveHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Controls.RemoveByKey("Y_TextBox")
|
||||
|
||||
GUI.Controls.RemoveByKey("X_Label")
|
||||
GUI.Controls.RemoveByKey("Y_Label")
|
||||
|
||||
GUI.Controls("AngleButton").Enabled = True
|
||||
GUI.Controls("Button_Square").Enabled = True
|
||||
GUI.Controls("Button_SquareSide").Enabled = True
|
||||
End Sub
|
||||
|
||||
' --- Determines the clicked points quadrant ---
|
||||
Private Shared Function Get_PointQuadrant(pXGUI As Integer, pYGUI As Integer)
|
||||
Dim quadrant As Integer
|
||||
If pXGUI < Data.guiPanelMidX Then
|
||||
If pYGUI > Data.guiPanelMidY Then
|
||||
quadrant = 4
|
||||
Else
|
||||
quadrant = 1
|
||||
End If
|
||||
Else
|
||||
If pYGUI > Data.guiPanelMidY Then
|
||||
quadrant = 3
|
||||
Else
|
||||
quadrant = 2
|
||||
End If
|
||||
End If
|
||||
|
||||
Return quadrant
|
||||
End Function
|
||||
End Class
|
||||
|
|
@ -0,0 +1,512 @@
|
|||
Public Class Side_Rectangle
|
||||
Private Shared sideSquareValues(3) As Integer
|
||||
Private Shared numOfSideRectangles As Integer = 0
|
||||
|
||||
' --- Create textboxes when user clicks the rectangle side recess button ---
|
||||
Public Shared Sub SquareSideButtton(sender As Object, e As EventArgs)
|
||||
GUI.Controls("AngleButton").Enabled = False
|
||||
GUI.Controls("Button_Square").Enabled = False
|
||||
GUI.Controls("Button_SquareSide").Enabled = False
|
||||
|
||||
Dim buttonX As Integer = GUI.Controls("Button_SquareSide").Location.X
|
||||
Dim buttonY As Integer = GUI.Controls("Button_SquareSide").Location.Y
|
||||
|
||||
GUI.Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
|
||||
AddHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("X_Label", "L", buttonX, buttonY + 43)
|
||||
|
||||
GUI.Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
|
||||
AddHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("Y_Label", "W", buttonX + 110, buttonY + 43)
|
||||
|
||||
GUI.Create_TextBox("Off_TextBox", "", buttonX + 250, buttonY + 40, 60)
|
||||
AddHandler GUI.Controls("Off_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
|
||||
AddHandler GUI.Controls("Off_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Create_LabelGUI("Off_Label", "Offset", buttonX + 210, buttonY + 43)
|
||||
End Sub
|
||||
|
||||
' --- Check the key pressed by the user ---
|
||||
Private Shared Sub FunctionText_KeyPress(sender As Object, e As KeyPressEventArgs)
|
||||
User_Input.Check_IfNumber(e)
|
||||
End Sub
|
||||
|
||||
' --- Adds clickable buttons for all sides if conditions are met ---
|
||||
Private Shared Sub FunctionTextSide_Changed(sender As TextBox, e As EventArgs)
|
||||
Try
|
||||
sideSquareValues(0) = CInt(GUI.Controls("X_TextBox").Text)
|
||||
sideSquareValues(1) = CInt(GUI.Controls("Y_TextBox").Text)
|
||||
sideSquareValues(2) = CInt(GUI.Controls("Off_TextBox").Text)
|
||||
Catch ex As Exception
|
||||
sideSquareValues(0) = 0
|
||||
sideSquareValues(1) = 0
|
||||
sideSquareValues(2) = 0
|
||||
End Try
|
||||
|
||||
If sideSquareValues(0) > 0 AndAlso sideSquareValues(1) > 0 AndAlso sideSquareValues(2) > 0 Then
|
||||
If GUI.DrawingPanel.Controls.Count = 2 Then
|
||||
For i = 1 To 4
|
||||
Dim sidePoints As New List(Of String)
|
||||
If i = 1 Then
|
||||
Create_SideButton(sideSquareValues(0) / (Data.scaleDiff), 30,
|
||||
Data.grossAreaPoints.Rows(0)("GUI X") + sideSquareValues(2) / (Data.scaleDiff),
|
||||
Data.grossAreaPoints.Rows(0)("GUI Y") - 30 / 2,
|
||||
"Button_" & i)
|
||||
ElseIf i = 2 Then
|
||||
Create_SideButton(30, sideSquareValues(1) / (Data.scaleDiff),
|
||||
Data.grossAreaPoints.Rows(1)("GUI X") - 30 / 2,
|
||||
Data.grossAreaPoints.Rows(1)("GUI Y") + sideSquareValues(2) / (Data.scaleDiff), "Button_" & i)
|
||||
ElseIf i = 3 Then
|
||||
Create_SideButton(sideSquareValues(0) / (Data.scaleDiff), 30,
|
||||
Data.grossAreaPoints.Rows(2)("GUI X") - sideSquareValues(2) / (Data.scaleDiff) - sideSquareValues(0) / (Data.scaleDiff),
|
||||
Data.grossAreaPoints.Rows(2)("GUI Y") - 30 / 2,
|
||||
"Button_" & i)
|
||||
Else
|
||||
Create_SideButton(30, sideSquareValues(1) / (Data.scaleDiff),
|
||||
Data.grossAreaPoints.Rows(3)("GUI X") - 30 / 2,
|
||||
Data.grossAreaPoints.Rows(3)("GUI Y") - sideSquareValues(2) / (Data.scaleDiff) - sideSquareValues(1) / (Data.scaleDiff),
|
||||
"Button_" & i)
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
' Update button size and position
|
||||
For i = 2 To GUI.DrawingPanel.Controls.Count - 1
|
||||
Dim buttonSide As Integer = CInt(GUI.DrawingPanel.Controls(i).Name.Split("_")(1))
|
||||
If buttonSide = 1 Then
|
||||
GUI.DrawingPanel.Controls(i).Width = sideSquareValues(0) / (Data.scaleDiff)
|
||||
GUI.DrawingPanel.Controls(i).Left = Data.grossAreaPoints.Rows(0)("GUI X") + sideSquareValues(2) / (Data.scaleDiff)
|
||||
ElseIf buttonSide = 2 Then
|
||||
GUI.DrawingPanel.Controls(i).Height = sideSquareValues(1) / (Data.scaleDiff)
|
||||
GUI.DrawingPanel.Controls(i).Top = Data.grossAreaPoints.Rows(1)("GUI Y") + sideSquareValues(2) / (Data.scaleDiff)
|
||||
ElseIf buttonSide = 3 Then
|
||||
GUI.DrawingPanel.Controls(i).Width = sideSquareValues(0) / (Data.scaleDiff)
|
||||
GUI.DrawingPanel.Controls(i).Left = Data.grossAreaPoints.Rows(2)("GUI X") - sideSquareValues(2) / (Data.scaleDiff) - GUI.DrawingPanel.Controls(i).Width
|
||||
Else
|
||||
GUI.DrawingPanel.Controls(i).Height = sideSquareValues(1) / (Data.scaleDiff)
|
||||
GUI.DrawingPanel.Controls(i).Top = Data.grossAreaPoints.Rows(3)("GUI Y") - sideSquareValues(2) / (Data.scaleDiff) - GUI.DrawingPanel.Controls(i).Height
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
ElseIf GUI.DrawingPanel.Controls.Count > 2 Then
|
||||
For i = 2 To GUI.DrawingPanel.Controls.Count - 1
|
||||
RemoveHandler GUI.DrawingPanel.Controls(2).Click, AddressOf SideButton_Click
|
||||
GUI.DrawingPanel.Controls.RemoveAt(2)
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' --- Template to create corner buttons ---
|
||||
Private Shared Sub Create_SideButton(bWidth As Integer, bHeight As Integer, bLeft As Integer, bTop As Integer, bName As String)
|
||||
Dim sideButton As New Button With {
|
||||
.Width = bWidth,
|
||||
.Height = bHeight,
|
||||
.Left = bLeft,
|
||||
.Top = bTop,
|
||||
.Name = bName,
|
||||
.Text = ""
|
||||
}
|
||||
|
||||
sideButton.BackColor = Color.FromArgb(50, Color.Red)
|
||||
sideButton.FlatStyle = FlatStyle.Flat
|
||||
sideButton.FlatAppearance.BorderSize = 0
|
||||
sideButton.FlatAppearance.MouseOverBackColor = Color.Red
|
||||
sideButton.FlatAppearance.MouseDownBackColor = Color.DarkRed
|
||||
|
||||
GUI.DrawingPanel.Controls.Add(sideButton)
|
||||
|
||||
AddHandler sideButton.Click, AddressOf SideButton_Click
|
||||
End Sub
|
||||
|
||||
' --- When a side function button is pressed ---
|
||||
Private Shared Sub SideButton_Click(sender As Button, e As EventArgs)
|
||||
'Determine which side is being pressed
|
||||
Dim sidePressed As Integer = CInt(sender.Name.Split("_")(1))
|
||||
|
||||
' Remove point buttons
|
||||
For i = 2 To GUI.DrawingPanel.Controls.Count - 1
|
||||
RemoveHandler GUI.DrawingPanel.Controls(2).Click, AddressOf SideButton_Click
|
||||
GUI.DrawingPanel.Controls.RemoveAt(2)
|
||||
Next
|
||||
|
||||
Dim sidePoints As New List(Of Integer)
|
||||
Dim index As Integer
|
||||
|
||||
If sidePressed = 1 Then
|
||||
For j = 0 To Data.gratingPoints.Rows.Count - 1
|
||||
If Data.gratingPoints.Rows(j)("GUI Y") = Data.grossAreaPoints.Rows(0)("GUI Y") Then
|
||||
sidePoints.Add(j)
|
||||
End If
|
||||
Next
|
||||
index = sidePoints(0)
|
||||
If sidePoints.Count > 2 Then
|
||||
For i = sidePoints.Count / 2 To 2 Step -1
|
||||
If Data.gratingPoints.Rows(sidePoints(i * 2 - 2))("GUI X") <
|
||||
Data.grossAreaPoints.Rows(0)("GUI X") + sideSquareValues(2) / Data.scaleDiff Then
|
||||
index = sidePoints(i * 2 - 2)
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
ElseIf sidePressed = 2 Then
|
||||
For j = 1 To Data.gratingPoints.Rows.Count - 1
|
||||
If Data.gratingPoints.Rows(j)("GUI X") = Data.grossAreaPoints.Rows(1)("GUI X") Then
|
||||
sidePoints.Add(j)
|
||||
End If
|
||||
Next
|
||||
index = sidePoints(0)
|
||||
If sidePoints.Count > 2 Then
|
||||
For i = sidePoints.Count / 2 To 2 Step -1
|
||||
If Data.gratingPoints.Rows(sidePoints(i * 2 - 2))("GUI Y") <
|
||||
Data.grossAreaPoints.Rows(1)("GUI Y") + sideSquareValues(2) / Data.scaleDiff Then
|
||||
index = sidePoints(i * 2 - 2)
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
ElseIf sidePressed = 3 Then
|
||||
For j = 2 To Data.gratingPoints.Rows.Count - 1
|
||||
If Data.gratingPoints.Rows(j)("GUI Y") = Data.grossAreaPoints.Rows(2)("GUI Y") Then
|
||||
sidePoints.Add(j)
|
||||
End If
|
||||
Next
|
||||
index = sidePoints(0)
|
||||
If sidePoints.Count > 2 Then
|
||||
For i = sidePoints.Count / 2 To 2 Step -1
|
||||
If Data.gratingPoints.Rows(sidePoints(i * 2 - 2))("GUI X") >
|
||||
Data.grossAreaPoints.Rows(2)("GUI X") - sideSquareValues(2) / Data.scaleDiff Then
|
||||
index = sidePoints(i * 2 - 2)
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
Else
|
||||
For j = 3 To Data.gratingPoints.Rows.Count - 1
|
||||
If Data.gratingPoints.Rows(j)("GUI X") = Data.grossAreaPoints.Rows(3)("GUI X") Then
|
||||
sidePoints.Add(j)
|
||||
End If
|
||||
Next
|
||||
sidePoints.Add(0)
|
||||
index = sidePoints(0)
|
||||
If sidePoints.Count > 2 Then
|
||||
For i = sidePoints.Count / 2 To 2 Step -1
|
||||
If Data.gratingPoints.Rows(sidePoints(i * 2 - 2))("GUI Y") >
|
||||
Data.grossAreaPoints.Rows(3)("GUI Y") - sideSquareValues(2) / Data.scaleDiff Then
|
||||
index = sidePoints(i * 2 - 2)
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
For i = 2 To Data.pointsMeasurements.Count - 1
|
||||
Dim mesName As String = Data.pointsMeasurements.Keys(i)
|
||||
If mesName.Split("_")(0) = "SS1" Then
|
||||
If index + 2 = Data.pointsMeasurements(mesName)(1) Then
|
||||
If Draw_Grating.measureLabels(mesName)(3) = 1 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Data.gratingPoints.Rows(index + 1)("X") * 1000 -
|
||||
Data.grossAreaPoints.Rows(0)("X") * 1000 - (sideSquareValues(2) + sideSquareValues(0))
|
||||
|
||||
Draw_Grating.sideSquareMesLine(mesName)(0) = Data.grossAreaPoints.Rows(0)("GUI X") + (sideSquareValues(2) + sideSquareValues(0)) / Data.scaleDiff
|
||||
|
||||
Draw_Grating.measureLabels(mesName)(1) = (Draw_Grating.sideSquareMesLine(mesName)(0) + Draw_Grating.sideSquareMesLine(mesName)(2)) / 2 - 8
|
||||
|
||||
ElseIf Draw_Grating.measureLabels(mesName)(3) = 2 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Data.grossAreaPoints.Rows(1)("Y") * 1000 - Data.gratingPoints.Rows(index + 1)("Y") * 1000 -
|
||||
(sideSquareValues(2) + sideSquareValues(1))
|
||||
|
||||
Draw_Grating.sideSquareMesLine(mesName)(1) = Data.grossAreaPoints.Rows(1)("GUI Y") + (sideSquareValues(2) + sideSquareValues(1)) / Data.scaleDiff
|
||||
|
||||
Draw_Grating.measureLabels(mesName)(2) = (Draw_Grating.sideSquareMesLine(mesName)(1) + Draw_Grating.sideSquareMesLine(mesName)(3)) / 2 - 6
|
||||
|
||||
ElseIf Draw_Grating.measureLabels(mesName)(3) = 3 Then
|
||||
Draw_Grating.measureLabels(mesName)(0) = Data.grossAreaPoints.Rows(2)("X") * 1000 - Data.gratingPoints.Rows(index + 1)("X") * 1000 -
|
||||
(sideSquareValues(2) + sideSquareValues(0))
|
||||
|
||||
Draw_Grating.sideSquareMesLine(mesName)(0) = Data.grossAreaPoints.Rows(2)("GUI X") - (sideSquareValues(2) + sideSquareValues(0)) / Data.scaleDiff
|
||||
|
||||
Draw_Grating.measureLabels(mesName)(1) = (Draw_Grating.sideSquareMesLine(mesName)(0) + Draw_Grating.sideSquareMesLine(mesName)(2)) / 2 - 8
|
||||
|
||||
Else
|
||||
Draw_Grating.measureLabels(mesName)(0) = Data.gratingPoints.Rows(index + 1)("Y") * 1000 -
|
||||
Data.grossAreaPoints.Rows(3)("Y") * 1000 - (sideSquareValues(2) + sideSquareValues(1))
|
||||
|
||||
Draw_Grating.sideSquareMesLine(mesName)(1) = Data.grossAreaPoints.Rows(3)("GUI Y") - (sideSquareValues(2) + sideSquareValues(1)) / Data.scaleDiff
|
||||
|
||||
Draw_Grating.measureLabels(mesName)(2) = (Draw_Grating.sideSquareMesLine(mesName)(1) + Draw_Grating.sideSquareMesLine(mesName)(3)) / 2 - 6
|
||||
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
For i = 2 To Data.pointsMeasurements.Count - 1
|
||||
Dim mesName As String = Data.pointsMeasurements.Keys(i)
|
||||
If mesName.Split("_")(0) <> "SS1" AndAlso index + 1 < Data.pointsMeasurements(mesName)(0) Then
|
||||
Data.pointsMeasurements(mesName)(0) = Data.pointsMeasurements(mesName)(0) + 4
|
||||
Data.pointsMeasurements(mesName)(1) = Data.pointsMeasurements(mesName)(1) + 4
|
||||
ElseIf mesName.Split("_")(0) = "SS1" AndAlso index + 2 <= Data.pointsMeasurements(mesName)(1) Then
|
||||
Data.pointsMeasurements(mesName)(1) = Data.pointsMeasurements(mesName)(1) + 4
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim mesNum As Integer = Data.pointsMeasurements.Count - 1
|
||||
|
||||
Dim pointRow1 As DataRow = Data.gratingPoints.NewRow
|
||||
Dim pointRow2 As DataRow = Data.gratingPoints.NewRow
|
||||
Dim pointRow3 As DataRow = Data.gratingPoints.NewRow
|
||||
Dim pointRow4 As DataRow = Data.gratingPoints.NewRow
|
||||
|
||||
pointRow1("NAME") = "CS" & numOfSideRectangles & "_" & 1
|
||||
pointRow1("QUADRANT") = 1
|
||||
pointRow1("RECESS OK") = False
|
||||
|
||||
pointRow2("NAME") = "CS" & numOfSideRectangles & "_" & 2
|
||||
pointRow2("QUADRANT") = 1
|
||||
pointRow2("RECESS OK") = False
|
||||
|
||||
pointRow3("NAME") = "CS" & numOfSideRectangles & "_" & 3
|
||||
pointRow3("QUADRANT") = 1
|
||||
pointRow3("RECESS OK") = False
|
||||
|
||||
pointRow4("NAME") = "CS" & numOfSideRectangles & "_" & 4
|
||||
pointRow4("QUADRANT") = 1
|
||||
pointRow4("RECESS OK") = False
|
||||
If sidePressed = 1 Then
|
||||
' Add the new points
|
||||
pointRow1("X") = Data.grossAreaPoints.Rows(0)("X") + sideSquareValues(2) / 1000
|
||||
pointRow1("Y") = Data.grossAreaPoints.Rows(0)("Y")
|
||||
pointRow1("GUI X") = Data.grossAreaPoints.Rows(0)("GUI X") + sideSquareValues(2) / Data.scaleDiff
|
||||
pointRow1("GUI Y") = Data.grossAreaPoints.Rows(0)("GUI Y")
|
||||
|
||||
pointRow2("X") = Data.grossAreaPoints.Rows(0)("X") + sideSquareValues(2) / 1000
|
||||
pointRow2("Y") = Data.grossAreaPoints.Rows(0)("Y") - sideSquareValues(1) / 1000
|
||||
pointRow2("GUI X") = Data.grossAreaPoints.Rows(0)("GUI X") + sideSquareValues(2) / Data.scaleDiff
|
||||
pointRow2("GUI Y") = Data.grossAreaPoints.Rows(0)("GUI Y") + sideSquareValues(1) / Data.scaleDiff
|
||||
|
||||
pointRow3("X") = Data.grossAreaPoints.Rows(0)("X") + (sideSquareValues(2) + sideSquareValues(0)) / 1000
|
||||
pointRow3("Y") = Data.grossAreaPoints.Rows(0)("Y") - sideSquareValues(1) / 1000
|
||||
pointRow3("GUI X") = Data.grossAreaPoints.Rows(0)("GUI X") + (sideSquareValues(2) + sideSquareValues(0)) / Data.scaleDiff
|
||||
pointRow3("GUI Y") = Data.grossAreaPoints.Rows(0)("GUI Y") + sideSquareValues(1) / Data.scaleDiff
|
||||
|
||||
pointRow4("X") = Data.grossAreaPoints.Rows(0)("X") + (sideSquareValues(2) + sideSquareValues(0)) / 1000
|
||||
pointRow4("Y") = Data.grossAreaPoints.Rows(0)("Y")
|
||||
pointRow4("GUI X") = Data.grossAreaPoints.Rows(0)("GUI X") + (sideSquareValues(2) + sideSquareValues(0)) / Data.scaleDiff
|
||||
pointRow4("GUI Y") = Data.grossAreaPoints.Rows(0)("GUI Y")
|
||||
|
||||
' Update outer measuements (SW)
|
||||
Data.pointsMeasurements("Lmes")(1) = Data.pointsMeasurements("Lmes")(1) + 4
|
||||
Data.pointsMeasurements("Wmes")(0) = Data.pointsMeasurements("Wmes")(0) + 4
|
||||
Data.pointsMeasurements("Wmes")(1) = Data.pointsMeasurements("Wmes")(1) + 4
|
||||
|
||||
' Add recess measuements (SW)
|
||||
Data.pointsMeasurements.Add("SS1_" & mesNum, {sidePoints(0) + 1, index + 2, 1})
|
||||
Data.pointsMeasurements.Add("SS_" & mesNum + 1, {index + 2, index + 5, 1})
|
||||
Data.pointsMeasurements.Add("SS_" & mesNum + 2, {index + 2, index + 3, 4})
|
||||
|
||||
' Add support line data for sidesquare measurement
|
||||
Draw_Grating.sideSquareMesLine.Add("SS1_" & mesNum, {Data.gratingPoints.Rows(index)("GUI X"),
|
||||
Data.grossAreaPoints.Rows(0)("GUI Y") - 15,
|
||||
Data.grossAreaPoints.Rows(0)("GUI X") + sideSquareValues(2) / Data.scaleDiff,
|
||||
Data.grossAreaPoints.Rows(0)("GUI Y") - 15})
|
||||
|
||||
' Add recess measurments (GUI)
|
||||
Draw_Grating.measureLabels.Add("SS1_" & mesNum, {CInt(GUI.Controls("Off_TextBox").Text) - (Data.gratingPoints.Rows(index)("X") * 1000 + Data.gratingL / 2),
|
||||
(Data.gratingPoints.Rows(index)("GUI X") + Data.grossAreaPoints.Rows(0)("GUI X") + sideSquareValues(2) / Data.scaleDiff) / 2 - 8,
|
||||
Data.grossAreaPoints.Rows(0)("GUI Y") - 15 - 12 - 3,
|
||||
1}) '15 är linjen, 12 är textens höjd, 3 är lite extra
|
||||
Draw_Grating.measureLabels.Add("SS_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text),
|
||||
Data.grossAreaPoints.Rows(0)("GUI X") + sideSquareValues(2) / (Data.scaleDiff) + CInt(GUI.Controls("X_TextBox").Text) / (2 * Data.scaleDiff) - 8,
|
||||
Data.grossAreaPoints.Rows(0)("GUI Y") + sideSquareValues(1) / (Data.scaleDiff) + 3,
|
||||
1})
|
||||
Draw_Grating.measureLabels.Add("SS_" & mesNum + 2, {CInt(GUI.Controls("Y_TextBox").Text),
|
||||
Data.grossAreaPoints.Rows(0)("GUI X") + sideSquareValues(2) / Data.scaleDiff - 18 - 3,
|
||||
Data.grossAreaPoints.Rows(0)("GUI Y") + CInt(GUI.Controls("Y_TextBox").Text) / (2 * Data.scaleDiff) - 4,
|
||||
1})
|
||||
|
||||
ElseIf sidePressed = 2 Then
|
||||
' Add the new points
|
||||
pointRow1("X") = Data.grossAreaPoints.Rows(1)("X")
|
||||
pointRow1("Y") = Data.grossAreaPoints.Rows(1)("Y") - sideSquareValues(2) / 1000
|
||||
pointRow1("GUI X") = Data.grossAreaPoints.Rows(1)("GUI X")
|
||||
pointRow1("GUI Y") = Data.grossAreaPoints.Rows(1)("GUI Y") + sideSquareValues(2) / Data.scaleDiff
|
||||
|
||||
pointRow2("X") = Data.grossAreaPoints.Rows(1)("X") - sideSquareValues(0) / 1000
|
||||
pointRow2("Y") = Data.grossAreaPoints.Rows(1)("Y") - sideSquareValues(2) / 1000
|
||||
pointRow2("GUI X") = Data.grossAreaPoints.Rows(1)("GUI X") - sideSquareValues(0) / Data.scaleDiff
|
||||
pointRow2("GUI Y") = Data.grossAreaPoints.Rows(1)("GUI Y") + sideSquareValues(2) / Data.scaleDiff
|
||||
|
||||
pointRow3("X") = Data.grossAreaPoints.Rows(1)("X") - sideSquareValues(0) / 1000
|
||||
pointRow3("Y") = Data.grossAreaPoints.Rows(1)("Y") - (sideSquareValues(2) + sideSquareValues(1)) / 1000
|
||||
pointRow3("GUI X") = Data.grossAreaPoints.Rows(1)("GUI X") - sideSquareValues(0) / Data.scaleDiff
|
||||
pointRow3("GUI Y") = Data.grossAreaPoints.Rows(1)("GUI Y") + (sideSquareValues(2) + sideSquareValues(1)) / Data.scaleDiff
|
||||
|
||||
pointRow4("X") = Data.grossAreaPoints.Rows(1)("X")
|
||||
pointRow4("Y") = Data.grossAreaPoints.Rows(1)("Y") - (sideSquareValues(2) + sideSquareValues(1)) / 1000
|
||||
pointRow4("GUI X") = Data.grossAreaPoints.Rows(1)("GUI X")
|
||||
pointRow4("GUI Y") = Data.grossAreaPoints.Rows(1)("GUI Y") + (sideSquareValues(2) + sideSquareValues(1)) / Data.scaleDiff
|
||||
|
||||
' Update outer measuements (SW)
|
||||
Data.pointsMeasurements("Wmes")(1) = Data.pointsMeasurements("Wmes")(1) + 4
|
||||
|
||||
' Add recess measuements (SW)
|
||||
Data.pointsMeasurements.Add("SS1_" & mesNum, {sidePoints(0) + 1, index + 2, 2})
|
||||
Data.pointsMeasurements.Add("SS_" & mesNum + 1, {index + 2, index + 5, 2})
|
||||
Data.pointsMeasurements.Add("SS_" & mesNum + 2, {index + 2, index + 3, 3})
|
||||
|
||||
' Add support line data for sidesquare measurement
|
||||
Draw_Grating.sideSquareMesLine.Add("SS1_" & mesNum, {Data.grossAreaPoints.Rows(1)("GUI X") + 15,
|
||||
Data.gratingPoints.Rows(index)("GUI Y"),
|
||||
Data.grossAreaPoints.Rows(1)("GUI X") + 15,
|
||||
Data.grossAreaPoints.Rows(1)("GUI Y") + sideSquareValues(2) / Data.scaleDiff})
|
||||
|
||||
' Add recess measurments (GUI)
|
||||
Draw_Grating.measureLabels.Add("SS1_" & mesNum, {CInt(GUI.Controls("Off_TextBox").Text) - (Data.gratingW / 2 - Data.gratingPoints.Rows(index)("Y") * 1000),
|
||||
Data.grossAreaPoints.Rows(1)("GUI X") + 15 + 3,
|
||||
(Data.gratingPoints.Rows(index)("GUI Y") + Data.grossAreaPoints.Rows(1)("GUI Y") + sideSquareValues(2) / Data.scaleDiff) / 2 - 4,
|
||||
2})
|
||||
|
||||
Draw_Grating.measureLabels.Add("SS_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text),
|
||||
Data.grossAreaPoints.Rows(1)("GUI X") - sideSquareValues(0) / Data.scaleDiff - 18 - 3,
|
||||
Data.grossAreaPoints.Rows(1)("GUI Y") + (sideSquareValues(2) + sideSquareValues(1) / 2) / Data.scaleDiff - 4,
|
||||
2})
|
||||
|
||||
Draw_Grating.measureLabels.Add("SS_" & mesNum + 2, {CInt(GUI.Controls("X_TextBox").Text),
|
||||
Data.grossAreaPoints.Rows(1)("GUI X") - sideSquareValues(0) / (2 * Data.scaleDiff) - 8,
|
||||
Data.grossAreaPoints.Rows(1)("GUI Y") + sideSquareValues(2) / Data.scaleDiff - 15 - 3,
|
||||
2})
|
||||
|
||||
ElseIf sidePressed = 3 Then
|
||||
' Add the new points
|
||||
pointRow1("X") = Data.grossAreaPoints.Rows(2)("X") - sideSquareValues(2) / 1000
|
||||
pointRow1("Y") = Data.grossAreaPoints.Rows(2)("Y")
|
||||
pointRow1("GUI X") = Data.grossAreaPoints.Rows(2)("GUI X") - sideSquareValues(2) / Data.scaleDiff
|
||||
pointRow1("GUI Y") = Data.grossAreaPoints.Rows(2)("GUI Y")
|
||||
|
||||
pointRow2("X") = Data.grossAreaPoints.Rows(2)("X") - sideSquareValues(2) / 1000
|
||||
pointRow2("Y") = Data.grossAreaPoints.Rows(2)("Y") + sideSquareValues(1) / 1000
|
||||
pointRow2("GUI X") = Data.grossAreaPoints.Rows(2)("GUI X") - sideSquareValues(2) / Data.scaleDiff
|
||||
pointRow2("GUI Y") = Data.grossAreaPoints.Rows(2)("GUI Y") - sideSquareValues(1) / Data.scaleDiff
|
||||
|
||||
pointRow3("X") = Data.grossAreaPoints.Rows(2)("X") - (sideSquareValues(2) + sideSquareValues(0)) / 1000
|
||||
pointRow3("Y") = Data.grossAreaPoints.Rows(2)("Y") + sideSquareValues(1) / 1000
|
||||
pointRow3("GUI X") = Data.grossAreaPoints.Rows(2)("GUI X") - (sideSquareValues(2) + sideSquareValues(0)) / Data.scaleDiff
|
||||
pointRow3("GUI Y") = Data.grossAreaPoints.Rows(2)("GUI Y") - sideSquareValues(1) / Data.scaleDiff
|
||||
|
||||
pointRow4("X") = Data.grossAreaPoints.Rows(2)("X") - (sideSquareValues(2) + sideSquareValues(0)) / 1000
|
||||
pointRow4("Y") = Data.grossAreaPoints.Rows(2)("Y")
|
||||
pointRow4("GUI X") = Data.grossAreaPoints.Rows(2)("GUI X") - (sideSquareValues(2) + sideSquareValues(0)) / Data.scaleDiff
|
||||
pointRow4("GUI Y") = Data.grossAreaPoints.Rows(2)("GUI Y")
|
||||
|
||||
' Add recess measuements (SW)
|
||||
Data.pointsMeasurements.Add("SS1_" & mesNum, {sidePoints(0) + 1, index + 2, 3})
|
||||
Data.pointsMeasurements.Add("SS_" & mesNum + 1, {index + 2, index + 5, 3})
|
||||
Data.pointsMeasurements.Add("SS_" & mesNum + 2, {index + 2, index + 3, 4})
|
||||
|
||||
' Add support line data for sidesquare measurement
|
||||
Draw_Grating.sideSquareMesLine.Add("SS1_" & mesNum, {Data.gratingPoints.Rows(index)("GUI X"),
|
||||
Data.grossAreaPoints.Rows(2)("GUI Y") + 15,
|
||||
Data.grossAreaPoints.Rows(2)("GUI X") - sideSquareValues(2) / Data.scaleDiff,
|
||||
Data.grossAreaPoints.Rows(2)("GUI Y") + 15})
|
||||
|
||||
' Add recess measurments (GUI)
|
||||
Draw_Grating.measureLabels.Add("SS1_" & mesNum, {CInt(GUI.Controls("Off_TextBox").Text) - (Data.gratingL / 2 - Data.gratingPoints.Rows(index)("X") * 1000),
|
||||
(Data.gratingPoints.Rows(index)("GUI X") + Data.grossAreaPoints.Rows(2)("GUI X") - sideSquareValues(2) / Data.scaleDiff) / 2 - 8,
|
||||
Data.grossAreaPoints.Rows(2)("GUI Y") + 15 + 3,
|
||||
3}) '15 är linjen, 12 är textens höjd, 3 är lite extra
|
||||
Draw_Grating.measureLabels.Add("SS_" & mesNum + 1, {CInt(GUI.Controls("X_TextBox").Text),
|
||||
Data.grossAreaPoints.Rows(2)("GUI X") - sideSquareValues(2) / (Data.scaleDiff) - CInt(GUI.Controls("X_TextBox").Text) / (2 * Data.scaleDiff) - 8,
|
||||
Data.grossAreaPoints.Rows(2)("GUI Y") - sideSquareValues(1) / (Data.scaleDiff) - 12 - 3,
|
||||
3})
|
||||
Draw_Grating.measureLabels.Add("SS_" & mesNum + 2, {CInt(GUI.Controls("Y_TextBox").Text),
|
||||
Data.grossAreaPoints.Rows(2)("GUI X") - sideSquareValues(2) / Data.scaleDiff + 3,
|
||||
Data.grossAreaPoints.Rows(2)("GUI Y") - CInt(GUI.Controls("Y_TextBox").Text) / (2 * Data.scaleDiff) - 4,
|
||||
3})
|
||||
|
||||
Else
|
||||
' Add the new points
|
||||
pointRow1("X") = Data.grossAreaPoints.Rows(3)("X")
|
||||
pointRow1("Y") = Data.grossAreaPoints.Rows(3)("Y") + sideSquareValues(2) / 1000
|
||||
pointRow1("GUI X") = Data.grossAreaPoints.Rows(3)("GUI X")
|
||||
pointRow1("GUI Y") = Data.grossAreaPoints.Rows(3)("GUI Y") - sideSquareValues(2) / Data.scaleDiff
|
||||
|
||||
pointRow2("X") = Data.grossAreaPoints.Rows(3)("X") + sideSquareValues(0) / 1000
|
||||
pointRow2("Y") = Data.grossAreaPoints.Rows(3)("Y") + sideSquareValues(2) / 1000
|
||||
pointRow2("GUI X") = Data.grossAreaPoints.Rows(3)("GUI X") + sideSquareValues(0) / Data.scaleDiff
|
||||
pointRow2("GUI Y") = Data.grossAreaPoints.Rows(3)("GUI Y") - sideSquareValues(2) / Data.scaleDiff
|
||||
|
||||
pointRow3("X") = Data.grossAreaPoints.Rows(3)("X") + sideSquareValues(0) / 1000
|
||||
pointRow3("Y") = Data.grossAreaPoints.Rows(3)("Y") + (sideSquareValues(2) + sideSquareValues(1)) / 1000
|
||||
pointRow3("GUI X") = Data.grossAreaPoints.Rows(3)("GUI X") + sideSquareValues(0) / Data.scaleDiff
|
||||
pointRow3("GUI Y") = Data.grossAreaPoints.Rows(3)("GUI Y") - (sideSquareValues(2) + sideSquareValues(1)) / Data.scaleDiff
|
||||
|
||||
pointRow4("X") = Data.grossAreaPoints.Rows(3)("X")
|
||||
pointRow4("Y") = Data.grossAreaPoints.Rows(3)("Y") + (sideSquareValues(2) + sideSquareValues(1)) / 1000
|
||||
pointRow4("GUI X") = Data.grossAreaPoints.Rows(3)("GUI X")
|
||||
pointRow4("GUI Y") = Data.grossAreaPoints.Rows(3)("GUI Y") - (sideSquareValues(2) + sideSquareValues(1)) / Data.scaleDiff
|
||||
|
||||
' Add recess measuements (SW)
|
||||
Data.pointsMeasurements.Add("SS1_" & mesNum, {sidePoints(0) + 1, index + 2, 4})
|
||||
Data.pointsMeasurements.Add("SS_" & mesNum + 1, {index + 2, index + 5, 4})
|
||||
Data.pointsMeasurements.Add("SS_" & mesNum + 2, {index + 2, index + 3, 3})
|
||||
|
||||
' Add support line data for sidesquare measurement
|
||||
Draw_Grating.sideSquareMesLine.Add("SS1_" & mesNum, {Data.grossAreaPoints.Rows(3)("GUI X") - 15,
|
||||
Data.gratingPoints.Rows(index)("GUI Y"),
|
||||
Data.grossAreaPoints.Rows(3)("GUI X") - 15,
|
||||
Data.grossAreaPoints.Rows(3)("GUI Y") - sideSquareValues(2) / Data.scaleDiff})
|
||||
|
||||
' Add recess measurments (GUI)
|
||||
Draw_Grating.measureLabels.Add("SS1_" & mesNum, {CInt(GUI.Controls("Off_TextBox").Text) - (Data.gratingW / 2 + Data.gratingPoints.Rows(index)("Y") * 1000),
|
||||
Data.grossAreaPoints.Rows(3)("GUI X") - 15 - 18 - 3,
|
||||
(Data.gratingPoints.Rows(index)("GUI Y") + Data.grossAreaPoints.Rows(3)("GUI Y") - sideSquareValues(2) / Data.scaleDiff) / 2 - 4,
|
||||
4})
|
||||
|
||||
Draw_Grating.measureLabels.Add("SS_" & mesNum + 1, {CInt(GUI.Controls("Y_TextBox").Text),
|
||||
Data.grossAreaPoints.Rows(3)("GUI X") + sideSquareValues(0) / Data.scaleDiff + 3,
|
||||
Data.grossAreaPoints.Rows(3)("GUI Y") - (sideSquareValues(2) + sideSquareValues(1) / 2) / Data.scaleDiff - 4,
|
||||
4})
|
||||
|
||||
Draw_Grating.measureLabels.Add("SS_" & mesNum + 2, {CInt(GUI.Controls("X_TextBox").Text),
|
||||
Data.grossAreaPoints.Rows(3)("GUI X") + sideSquareValues(0) / (2 * Data.scaleDiff) - 8,
|
||||
Data.grossAreaPoints.Rows(3)("GUI Y") - sideSquareValues(2) / Data.scaleDiff + 3,
|
||||
4})
|
||||
End If
|
||||
|
||||
Data.gratingPoints.Rows.InsertAt(pointRow1, index + 1)
|
||||
Data.gratingPoints.Rows.InsertAt(pointRow2, index + 2)
|
||||
Data.gratingPoints.Rows.InsertAt(pointRow3, index + 3)
|
||||
Data.gratingPoints.Rows.InsertAt(pointRow4, index + 4)
|
||||
|
||||
numOfSideRectangles += 1
|
||||
|
||||
'Redraw grating
|
||||
GUI.DrawingPanel.Refresh()
|
||||
|
||||
RemoveHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
|
||||
RemoveHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Controls.RemoveByKey("X_TextBox")
|
||||
|
||||
RemoveHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
|
||||
RemoveHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Controls.RemoveByKey("Y_TextBox")
|
||||
|
||||
RemoveHandler GUI.Controls("Off_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
|
||||
RemoveHandler GUI.Controls("Off_TextBox").KeyPress, AddressOf FunctionText_KeyPress
|
||||
GUI.Controls.RemoveByKey("Off_TextBox")
|
||||
|
||||
GUI.Controls.RemoveByKey("X_Label")
|
||||
GUI.Controls.RemoveByKey("Y_Label")
|
||||
GUI.Controls.RemoveByKey("Off_Label")
|
||||
|
||||
GUI.Controls("AngleButton").Enabled = True
|
||||
GUI.Controls("Button_Square").Enabled = True
|
||||
GUI.Controls("Button_SquareSide").Enabled = True
|
||||
End Sub
|
||||
End Class
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
Imports XCCLibrary
|
||||
Imports SldWorks
|
||||
Public Class SW_Drawing_Gratings
|
||||
Imports SldWorks
|
||||
Public Class Drawing
|
||||
Private Shared sideCounter As Integer()
|
||||
Public Shared Sub CreateDrawing()
|
||||
Dim pointTable As New DataTable
|
||||
pointTable = GUI_Gratings_Data.Create_PointTable()
|
||||
Dim pointTable As DataTable
|
||||
pointTable = Data.gratingPoints
|
||||
|
||||
Dim gratingHeight As Decimal = 0.025 ' Behövs variabel
|
||||
Dim swApp As SldWorks.SldWorks
|
||||
|
|
@ -108,8 +107,8 @@ Public Class SW_Drawing_Gratings
|
|||
myView = iDrawing.CreateDrawViewFromModelView3(GUI.filepath & "\Temp\TESTPART1.SLDPRT", "*Front", swSheetWidth / 2, swSheetHeight / 2, 0)
|
||||
'Dim viewScale = myView.ScaleDecimal()
|
||||
Dim viewScale As Double
|
||||
Dim lengthForDrawing As Integer = GUI_Gratings_Data.gratingMaxL
|
||||
Dim widthForDrawing As Integer = GUI_Gratings_Data.gratingMaxW
|
||||
Dim lengthForDrawing As Integer = Data.gratingL
|
||||
Dim widthForDrawing As Integer = Data.gratingW
|
||||
If lengthForDrawing < widthForDrawing * 3 Then
|
||||
'W styr
|
||||
If widthForDrawing < 100 Then
|
||||
|
|
@ -150,13 +149,13 @@ Public Class SW_Drawing_Gratings
|
|||
Dim Y_Mid = (OutLine(3) - OutLine(1)) / 2 + OutLine(1)
|
||||
|
||||
|
||||
For i = 2 To GUI_Functions.pointsMeasurements.Count - 1
|
||||
Dim mesName As String = GUI_Functions.pointsMeasurements.Keys(i)
|
||||
Add_Dimensions(GUI_Functions.pointsMeasurements(mesName), CompName, myView, iDrawing, swExtensions, OutLine, viewScale, X_Mid, Y_Mid)
|
||||
For i = 2 To Data.pointsMeasurements.Count - 1
|
||||
Dim mesName As String = Data.pointsMeasurements.Keys(i)
|
||||
Add_Dimensions(Data.pointsMeasurements(mesName), CompName, myView, iDrawing, swExtensions, OutLine, viewScale, X_Mid, Y_Mid)
|
||||
Next
|
||||
|
||||
Add_Dimensions(GUI_Functions.pointsMeasurements("Lmes"), CompName, myView, iDrawing, swExtensions, OutLine, viewScale, X_Mid, Y_Mid)
|
||||
Add_Dimensions(GUI_Functions.pointsMeasurements("Wmes"), CompName, myView, iDrawing, swExtensions, OutLine, viewScale, X_Mid, Y_Mid)
|
||||
Add_Dimensions(Data.pointsMeasurements("Lmes"), CompName, myView, iDrawing, swExtensions, OutLine, viewScale, X_Mid, Y_Mid)
|
||||
Add_Dimensions(Data.pointsMeasurements("Wmes"), CompName, myView, iDrawing, swExtensions, OutLine, viewScale, X_Mid, Y_Mid)
|
||||
Dim myView2 As View
|
||||
myView2 = iDrawing.CreateDrawViewFromModelView3(GUI.filepath & "\Temp\TESTPART1.SLDPRT", "*Bottom", swSheetWidth / 2, OutLine(3) + sideCounter(0) * 0.01 + 0.03, 0)
|
||||
myView2.ScaleDecimal() = viewScale
|
||||
|
|
@ -200,8 +199,10 @@ Public Class SW_Drawing_Gratings
|
|||
|
||||
Dim mesOffset = 0.01
|
||||
If points(2) = 1 OrElse points(2) = 3 Then
|
||||
Dim point1 As Decimal = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(points(0) - 1))(2)
|
||||
Dim point2 As Decimal = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(points(1) - 1))(2)
|
||||
'Dim point1 As Decimal = Draw_Grating.points(Draw_Grating.pointsOrder(points(0) - 1))(2)
|
||||
Dim point1 As Integer = Data.gratingPoints.Rows(points(0) - 1)("X")
|
||||
'Dim point2 As Decimal = Draw_Grating.points(Draw_Grating.pointsOrder(points(1) - 1))(2)
|
||||
Dim point2 As Integer = Data.gratingPoints.Rows(points(1) - 1)("X")
|
||||
|
||||
Dim xPos As Decimal
|
||||
If Math.Abs(point1) > Math.Abs(point2) Then
|
||||
|
|
@ -216,8 +217,10 @@ Public Class SW_Drawing_Gratings
|
|||
measurement = iDrawing.AddHorizontalDimension2(X_Mid + xPos * viewScale, OutLine(1) - 0.005 - mesOffset * sideCounter(2), 0)
|
||||
End If
|
||||
Else
|
||||
Dim point1 As Decimal = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(points(0) - 1))(3)
|
||||
Dim point2 As Decimal = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(points(1) - 1))(3)
|
||||
'Dim point1 As Decimal = Draw_Grating.points(Draw_Grating.pointsOrder(points(0) - 1))(3)
|
||||
Dim point1 As Integer = Data.gratingPoints.Rows(points(0) - 1)("Y")
|
||||
'Dim point2 As Decimal = Draw_Grating.points(Draw_Grating.pointsOrder(points(1) - 1))(3)
|
||||
Dim point2 As Integer = Data.gratingPoints.Rows(points(1) - 1)("Y")
|
||||
|
||||
Dim yPos As Decimal
|
||||
If Math.Abs(point1) > Math.Abs(point2) Then
|
||||
|
|
@ -240,5 +243,4 @@ Public Class SW_Drawing_Gratings
|
|||
measurement.CenterText = True
|
||||
measurement.SetPrecision3(0, 0, 0, 0)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
Imports XCCLibrary
|
||||
Imports SldWorks
|
||||
Public Class SW_HLCt_Gratings
|
||||
Public Class Model_3D
|
||||
Public Shared Sub BuildGrating()
|
||||
Dim exportTable As DataTable
|
||||
exportTable = GUI_Gratings_Data.Create_ExportTable()
|
||||
exportTable = User_Input.Create_ExportTable()
|
||||
|
||||
XCCBaseClass.newDesign()
|
||||
ExternalClass.PopulateTamplateXMLGroup()
|
||||
|
|
@ -28,7 +27,7 @@ Public Class SW_HLCt_Gratings
|
|||
|
||||
'Instantiate recess rectangle
|
||||
parentID = inst_
|
||||
For Each recessDR As DataRow In GUI_Functions.recessData.Rows
|
||||
For Each recessDR As DataRow In Data.recessData.Rows
|
||||
Inst_Recesses(parentID, gratingParameters, recessDR)
|
||||
Next
|
||||
|
||||
|
|
@ -57,23 +56,22 @@ Public Class SW_HLCt_Gratings
|
|||
End If
|
||||
Dim squareL As Integer = recessDR("LENGTH") + gratingParameters("LOADBAR_THICKNESS")
|
||||
Dim squareW As Integer = recessDR("WIDTH") + gratingParameters("LOADBAR_THICKNESS")
|
||||
ExternalClass.modify_parameter_value("DP_LENGTH", inst_, squareL)
|
||||
ExternalClass.modify_parameter_value("DP_LENGTH", inst_, squareL + gratingParameters("LOADBAR_THICKNESS"))
|
||||
ExternalClass.modify_parameter_value("DP_WIDTH", inst_, squareW)
|
||||
ExternalClass.modify_parameter_value("DP_EDGEBAR_HEIGHT", inst_, gratingParameters("LOADBAR_HEIGHT"))
|
||||
ExternalClass.modify_parameter_value("DP_EDGEBAR_THICKNESS", inst_, gratingParameters("LOADBAR_THICKNESS"))
|
||||
|
||||
|
||||
If recessDR("CORNER") = 1 Then
|
||||
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, gratingParameters("WIDTH") - squareW - gratingParameters("LOADBAR_THICKNESS"))
|
||||
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, gratingParameters("WIDTH") - squareW)
|
||||
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, 0)
|
||||
|
||||
'Position
|
||||
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_POS", inst_, squareL - gratingParameters("LOADBAR_THICKNESS"))
|
||||
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_POS", inst_, squareL)
|
||||
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_BOTTOM", inst_, gratingParameters("LOADBAR_THICKNESS"))
|
||||
ExternalClass.modify_parameter_value("DP_H_EDGEBAR_POS", inst_, 0)
|
||||
|
||||
ElseIf recessDR("CORNER") = 2 Then
|
||||
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, gratingParameters("WIDTH") - squareW - gratingParameters("LOADBAR_THICKNESS"))
|
||||
ExternalClass.modify_parameter_value("DP_OFFSET_W", inst_, gratingParameters("WIDTH") - squareW)
|
||||
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, gratingParameters("LENGTH") - squareL - gratingParameters("LOADBAR_THICKNESS"))
|
||||
|
||||
'Position
|
||||
|
|
@ -94,7 +92,7 @@ Public Class SW_HLCt_Gratings
|
|||
ExternalClass.modify_parameter_value("DP_OFFSET_L", inst_, 0)
|
||||
|
||||
'Position
|
||||
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_POS", inst_, squareL - gratingParameters("LOADBAR_THICKNESS"))
|
||||
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_POS", inst_, squareL)
|
||||
ExternalClass.modify_parameter_value("DP_V_EDGEBAR_BOTTOM", inst_, 0)
|
||||
ExternalClass.modify_parameter_value("DP_H_EDGEBAR_POS", inst_, squareW - gratingParameters("LOADBAR_THICKNESS"))
|
||||
End If
|
||||
|
|
@ -103,4 +101,5 @@ Public Class SW_HLCt_Gratings
|
|||
'???
|
||||
End If
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
|
@ -74,14 +74,15 @@
|
|||
<Import Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="GUI_Drawing_Panel.vb" />
|
||||
<Compile Include="GUI_Functions.vb" />
|
||||
<Compile Include="GUI_Gratings_Data.vb" />
|
||||
<Compile Include="GUI_Settings.vb" />
|
||||
<Compile Include="GUI.vb">
|
||||
<Compile Include="Gratings Data\Database.vb" />
|
||||
<Compile Include="Gratings Data\Data.vb" />
|
||||
<Compile Include="Gratings Data\User_Input.vb" />
|
||||
<Compile Include="GUI\Draw_Grating.vb" />
|
||||
<Compile Include="GUI\Settings.vb" />
|
||||
<Compile Include="GUI\GUI.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GUI.Designer.vb">
|
||||
<Compile Include="GUI\GUI.Designer.vb">
|
||||
<DependentUpon>GUI.vb</DependentUpon>
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
@ -101,11 +102,14 @@
|
|||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="SW_Drawing_Gratings.vb" />
|
||||
<Compile Include="SW_HLCt_Gratings.vb" />
|
||||
<Compile Include="Recess Functions\Corner_Angle.vb" />
|
||||
<Compile Include="Recess Functions\Corner_Rectangle.vb" />
|
||||
<Compile Include="Recess Functions\Side_Rectangle.vb" />
|
||||
<Compile Include="SolidWorks\Drawing.vb" />
|
||||
<Compile Include="SolidWorks\Model_3D.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="GUI.resx">
|
||||
<EmbeddedResource Include="GUI\GUI.resx">
|
||||
<DependentUpon>GUI.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
|
|
|
|||
Loading…
Reference in New Issue