Fixed so we calculate all points correctly
This commit is contained in:
parent
997f0523d6
commit
ce896750f1
|
|
@ -7,7 +7,10 @@ Public Class GUI
|
|||
Dim drawW, drawH As Integer
|
||||
Dim drawAspect, gratingAspect As Decimal
|
||||
Dim scaleDiff As Decimal
|
||||
Dim pCon1X, pCon1Y, pCon2X, pCon2Y, pCon3X, pCon3Y, pCon4X, pCon4Y As Integer
|
||||
Dim pCon1(3) As Decimal 'pCon(0) = pixel X, pCon(2) = SW X
|
||||
Dim pCon2(3) As Decimal
|
||||
Dim pCon3(3) As Decimal
|
||||
Dim pCon4(3) As Decimal
|
||||
|
||||
' --- Start method when GUI loads ---
|
||||
Sub GUI_load() Handles MyBase.Load
|
||||
|
|
@ -39,27 +42,27 @@ Public Class GUI
|
|||
|
||||
' --- Set containers points X-values ---
|
||||
Private Sub Set_ContainerPointsX()
|
||||
pCon1X = containerMidX - CInt(drawW / 2)
|
||||
pCon2X = containerMidX + CInt(drawW / 2)
|
||||
pCon3X = containerMidX + CInt(drawW / 2)
|
||||
pCon4X = containerMidX - CInt(drawW / 2)
|
||||
pCon1(0) = containerMidX - drawW / 2
|
||||
pCon2(0) = containerMidX + drawW / 2
|
||||
pCon3(0) = containerMidX + drawW / 2
|
||||
pCon4(0) = containerMidX - drawW / 2
|
||||
End Sub
|
||||
|
||||
' --- Set containers points Y-values ---
|
||||
Private Sub Set_ContainerPointsY()
|
||||
pCon1Y = containerMidY - CInt(drawH / 2)
|
||||
pCon2Y = containerMidY - CInt(drawH / 2)
|
||||
pCon3Y = containerMidY + CInt(drawH / 2)
|
||||
pCon4Y = containerMidY + CInt(drawH / 2)
|
||||
pCon1(1) = containerMidY - drawH / 2
|
||||
pCon2(1) = containerMidY - drawH / 2
|
||||
pCon3(1) = containerMidY + drawH / 2
|
||||
pCon4(1) = containerMidY + drawH / 2
|
||||
End Sub
|
||||
|
||||
' --- Draw all the lines for the container ---
|
||||
Private Sub DrawingPanel_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs)
|
||||
Dim pen As Pen = New Pen(Color.Black, 1)
|
||||
e.Graphics.DrawLine(pen, pCon1X, pCon1Y, pCon2X, pCon2Y)
|
||||
e.Graphics.DrawLine(pen, pCon2X, pCon2Y, pCon3X, pCon3Y)
|
||||
e.Graphics.DrawLine(pen, pCon3X, pCon3Y, pCon4X, pCon4Y)
|
||||
e.Graphics.DrawLine(pen, pCon4X, pCon4Y, pCon1X, pCon1Y)
|
||||
e.Graphics.DrawLine(pen, CInt(pCon1(0)), CInt(pCon1(1)), CInt(pCon2(0)), CInt(pCon2(1)))
|
||||
e.Graphics.DrawLine(pen, CInt(pCon2(0)), CInt(pCon2(1)), CInt(pCon3(0)), CInt(pCon3(1)))
|
||||
e.Graphics.DrawLine(pen, CInt(pCon3(0)), CInt(pCon3(1)), CInt(pCon4(0)), CInt(pCon4(1)))
|
||||
e.Graphics.DrawLine(pen, CInt(pCon4(0)), CInt(pCon4(1)), CInt(pCon1(0)), CInt(pCon1(1)))
|
||||
'Här måste den anpassa sig till antal punkter som ska ritas och i vilken ordning
|
||||
End Sub
|
||||
|
||||
|
|
@ -69,28 +72,18 @@ Public Class GUI
|
|||
pointTable.Columns.Add("X", GetType(Decimal))
|
||||
pointTable.Columns.Add("Y", GetType(Decimal))
|
||||
|
||||
'For i = 0 To 3
|
||||
' pointTable.Rows.Add()
|
||||
' Dim tempPX, tempPY As Decimal
|
||||
' tempPX = (boxMidX - CallByName(Me, "p" & i + 1 & "X", vbGet)) * pDiff / 1000
|
||||
' tempPY = (boxMidY - CallByName(Me, "p" & i + 1 & "Y", vbGet)) * pDiff / 1000
|
||||
|
||||
' pointTable.Rows(i)("X") = tempPX
|
||||
' pointTable.Rows(i)("Y") = tempPY
|
||||
'Next
|
||||
|
||||
pointTable.Rows.Add()
|
||||
pointTable.Rows(0)("X") = -(containerMidX - pCon1X) * scaleDiff / 1000
|
||||
pointTable.Rows(0)("Y") = (containerMidY - pCon1Y) * scaleDiff / 1000
|
||||
pointTable.Rows(0)("X") = pCon1(2)
|
||||
pointTable.Rows(0)("Y") = pCon1(3)
|
||||
pointTable.Rows.Add()
|
||||
pointTable.Rows(1)("X") = (pCon2X - containerMidX) * scaleDiff / 1000
|
||||
pointTable.Rows(1)("Y") = (containerMidY - pCon2Y) * scaleDiff / 1000
|
||||
pointTable.Rows(1)("X") = pCon2(2)
|
||||
pointTable.Rows(1)("Y") = pCon2(3)
|
||||
pointTable.Rows.Add()
|
||||
pointTable.Rows(2)("X") = (pCon3X - containerMidX) * scaleDiff / 1000
|
||||
pointTable.Rows(2)("Y") = -(pCon3Y - containerMidY) * scaleDiff / 1000
|
||||
pointTable.Rows(2)("X") = pCon3(2)
|
||||
pointTable.Rows(2)("Y") = pCon3(3)
|
||||
pointTable.Rows.Add()
|
||||
pointTable.Rows(3)("X") = -(containerMidX - pCon4X) * scaleDiff / 1000
|
||||
pointTable.Rows(3)("Y") = -(pCon4Y - containerMidY) * scaleDiff / 1000
|
||||
pointTable.Rows(3)("X") = pCon4(2)
|
||||
pointTable.Rows(3)("Y") = pCon4(3)
|
||||
|
||||
Return pointTable
|
||||
End Function
|
||||
|
|
@ -107,26 +100,38 @@ Public Class GUI
|
|||
'Change draw height
|
||||
scaleDiff = gratingMaxW / drawW
|
||||
|
||||
pCon1Y = containerMidY - CInt(gratingMaxH / (scaleDiff * 2))
|
||||
pCon2Y = containerMidY - CInt(gratingMaxH / (scaleDiff * 2))
|
||||
pCon3Y = containerMidY + CInt(gratingMaxH / (scaleDiff * 2))
|
||||
pCon4Y = containerMidY + CInt(gratingMaxH / (scaleDiff * 2))
|
||||
pCon1(1) = containerMidY - gratingMaxH / (scaleDiff * 2)
|
||||
pCon2(1) = containerMidY - gratingMaxH / (scaleDiff * 2)
|
||||
pCon3(1) = containerMidY + gratingMaxH / (scaleDiff * 2)
|
||||
pCon4(1) = containerMidY + gratingMaxH / (scaleDiff * 2)
|
||||
|
||||
Set_ContainerPointsX()
|
||||
Else
|
||||
'Change draw width
|
||||
scaleDiff = gratingMaxH / drawH
|
||||
|
||||
pCon1X = containerMidX - CInt(gratingMaxW / (scaleDiff * 2))
|
||||
pCon2X = containerMidX + CInt(gratingMaxW / (scaleDiff * 2))
|
||||
pCon3X = containerMidX + CInt(gratingMaxW / (scaleDiff * 2))
|
||||
pCon4X = containerMidX - CInt(gratingMaxW / (scaleDiff * 2))
|
||||
pCon1(0) = containerMidX - gratingMaxW / (scaleDiff * 2)
|
||||
pCon2(0) = containerMidX + gratingMaxW / (scaleDiff * 2)
|
||||
pCon3(0) = containerMidX + gratingMaxW / (scaleDiff * 2)
|
||||
pCon4(0) = containerMidX - gratingMaxW / (scaleDiff * 2)
|
||||
|
||||
Set_ContainerPointsY()
|
||||
End If
|
||||
|
||||
'Redraw rectangle
|
||||
Me.Refresh()
|
||||
|
||||
'SW X-values
|
||||
pCon1(2) = (-gratingMaxW / 2) / 1000
|
||||
pCon2(2) = (gratingMaxW / 2) / 1000
|
||||
pCon3(2) = (gratingMaxW / 2) / 1000
|
||||
pCon4(2) = (-gratingMaxW / 2) / 1000
|
||||
|
||||
'SW Y-values
|
||||
pCon1(3) = (gratingMaxH / 2) / 1000
|
||||
pCon2(3) = (gratingMaxH / 2) / 1000
|
||||
pCon3(3) = (-gratingMaxH / 2) / 1000
|
||||
pCon4(3) = (-gratingMaxH / 2) / 1000
|
||||
End Sub
|
||||
|
||||
' --- When export to SW button is pressed ---
|
||||
|
|
@ -139,4 +144,5 @@ Public Class GUI
|
|||
|
||||
End Class
|
||||
|
||||
'SEPERATE HOW WE CALCULATE POINTS IN GUI AND ACTUAL MEASURMENTS
|
||||
|
||||
' CallByName(Me, "p" & i + 1 & "X", vbGet)
|
||||
Loading…
Reference in New Issue