OmagCUT :
- Aggiunta modalità FastGrid che permette di avere delle dimensioni preimpostate di rettangoli da creare in automatico.
This commit is contained in:
@@ -0,0 +1,272 @@
|
||||
Imports EgtUILib
|
||||
|
||||
Public Class FastGridSlabManager
|
||||
|
||||
' Riferimento alla MainWindow
|
||||
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
||||
Private WithEvents m_CurrProjPage As CurrentProjectPageUC
|
||||
|
||||
' Flag tipologia
|
||||
Private m_bFull As Boolean = False
|
||||
' Flag prima apertura
|
||||
Private m_bFirst As Boolean = True
|
||||
' Dati ordine
|
||||
Private m_nCurrSlab As Integer = 0
|
||||
Private m_nPieceType As Integer = 0
|
||||
Private m_PieceDimensionsX(4) As Integer
|
||||
Private m_PieceDimensionsY(4) As Integer
|
||||
Private m_sCompoDir As String = String.Empty
|
||||
'' Dati del grezzo
|
||||
'Private m_nRawId As Integer = GDB_ID.NULL
|
||||
'Private m_ptRawMin As Point3d
|
||||
'Private m_ptRawMax As Point3d
|
||||
|
||||
Private Sub NestPage_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
|
||||
' Imposto i messaggi letti dal file dei messaggi
|
||||
OrderTxBl.Text = EgtMsg(MSG_FASTGRIDPAGEUC) 'Order name - Nome ordine
|
||||
CurrSlabTxBl.Text = EgtMsg(MSG_FASTGRIDPAGEUC + 1) 'Curr slab - Lastra corrente
|
||||
PieceTypeGpBx.Header = EgtMsg(MSG_FASTGRIDPAGEUC + 3) 'Piece type - Tipo pezzo
|
||||
ConfirmOrderBtn.Content = EgtMsg(MSG_FASTGRIDPAGEUC + 5) 'Confirm order - Conferma ordine
|
||||
InsertPiecesBtn.Content = EgtMsg(MSG_FASTGRIDPAGEUC + 4) 'Insert pieces - Inserisci pezzi
|
||||
LastSlabBtn.Content = EgtMsg(MSG_FASTGRIDPAGEUC + 2) 'Last slab - Ultima lastra
|
||||
|
||||
' Determino se versione semplificata
|
||||
m_bFull = m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.AUTO_NESTING) And
|
||||
(GetPrivateProfileInt(S_CSV, K_FULL, 1, m_MainWindow.GetIniFile()) <> 0)
|
||||
' Leggo dati da ini
|
||||
GetPrivateProfileString(S_FASTGRID, K_FG_ORDER, "", OrderTxBx.Text, m_MainWindow.GetIniFile())
|
||||
m_nCurrSlab = GetPrivateProfileInt(S_FASTGRID, K_FG_CURRSLAB, 0, m_MainWindow.GetIniFile())
|
||||
m_nPieceType = GetPrivateProfileInt(S_FASTGRID, K_FG_PIECETYPE, 0, m_MainWindow.GetIniFile())
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub NestPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
||||
' Impostazioni
|
||||
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
||||
' Se prima esecuzione
|
||||
If m_bFirst Then
|
||||
' Leggo direttorio componenti
|
||||
GetPrivateProfileString(S_COMPO, K_COMPODIR, "", m_sCompoDir, m_MainWindow.GetIniFile())
|
||||
m_bFirst = False
|
||||
End If
|
||||
' recupero dimensioni del grezzo e kerf
|
||||
m_MainWindow.m_CadCutPageUC.m_NestPage.LoadParams()
|
||||
' Recupero dimensioni pezzi da ini
|
||||
For Index = 1 To 5
|
||||
GetPieceDimensions(Index)
|
||||
Next
|
||||
' Ne imposto i valori
|
||||
CurrSlabTxBx.Text = m_nCurrSlab
|
||||
Type1Btn.IsChecked = False
|
||||
Type2Btn.IsChecked = False
|
||||
Type3Btn.IsChecked = False
|
||||
Type4Btn.IsChecked = False
|
||||
Type5Btn.IsChecked = False
|
||||
Select Case m_nPieceType
|
||||
Case 1
|
||||
Type1Btn.IsChecked = True
|
||||
Case 2
|
||||
Type2Btn.IsChecked = True
|
||||
Case 3
|
||||
Type3Btn.IsChecked = True
|
||||
Case 4
|
||||
Type4Btn.IsChecked = True
|
||||
Case 5
|
||||
Type5Btn.IsChecked = True
|
||||
End Select
|
||||
' Verifico se c'e' un ordine in corso
|
||||
CurrSlabTxBx.IsEnabled = False
|
||||
If m_nCurrSlab > 0 Then
|
||||
OrderTxBx.IsEnabled = False
|
||||
PieceTypeGpBx.IsEnabled = False
|
||||
ConfirmOrderBtn.IsEnabled = False
|
||||
InsertPiecesBtn.IsEnabled = True
|
||||
LastSlabBtn.IsEnabled = True
|
||||
Else
|
||||
OrderTxBx.IsEnabled = True
|
||||
PieceTypeGpBx.IsEnabled = True
|
||||
ConfirmOrderBtn.IsEnabled = True
|
||||
InsertPiecesBtn.IsEnabled = False
|
||||
LastSlabBtn.IsEnabled = False
|
||||
End If
|
||||
EgtZoom(ZM.ALL)
|
||||
End Sub
|
||||
|
||||
Private Sub InsertPiecesBtn_Click(sender As Object, e As RoutedEventArgs) Handles InsertPiecesBtn.Click
|
||||
m_MainWindow.m_CurrentProjectPageUC.SetProjectOrder(OrderTxBx.Text)
|
||||
' Lancio l'inserimento dei pezzi
|
||||
ExecInsert()
|
||||
' Aggiorno visualizzazione
|
||||
EgtZoom(ZM.ALL)
|
||||
End Sub
|
||||
|
||||
Private Sub LastSlabBtn_Click(sender As Object, e As RoutedEventArgs) Handles LastSlabBtn.Click
|
||||
CheckLastSlab()
|
||||
End Sub
|
||||
|
||||
Friend Sub CheckLastSlab()
|
||||
If LastSlabBtn.IsChecked Then
|
||||
m_MainWindow.m_CurrentProjectPageUC.SetLastSlab(True)
|
||||
Else
|
||||
m_MainWindow.m_CurrentProjectPageUC.SetLastSlab(False)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function ExecInsert() As Boolean
|
||||
' Creo o svuoto gruppo temporaneo per i pezzi
|
||||
Dim nIpGrp As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, "FASTGRID")
|
||||
If nIpGrp = GDB_ID.NULL Then
|
||||
nIpGrp = EgtCreateGroup(GDB_ID.ROOT)
|
||||
If nIpGrp = GDB_ID.NULL Then Return False
|
||||
EgtSetName(nIpGrp, "FASTGRID")
|
||||
Else
|
||||
EgtEmptyGroup(nIpGrp)
|
||||
End If
|
||||
EgtSetLevel(nIpGrp, GDB_LV.TEMP)
|
||||
EgtSetStatus(nIpGrp, GDB_ST.OFF)
|
||||
' Carico lua per creare rettangoli
|
||||
Dim sLuaPath = m_sCompoDir & "\Rettangolo.lua"
|
||||
If Not EgtLuaExecFile(sLuaPath) Then Return False
|
||||
' Inserisco nel gruppo un nuovo componente per ogni pezzo da inserire
|
||||
Dim PartIdList As New List(Of Integer)
|
||||
For i As Integer = 1 To 100
|
||||
EgtLuaSetGlobNumVar("CMP.V1", m_PieceDimensionsX(m_nPieceType - 1))
|
||||
EgtLuaSetGlobNumVar("CMP.V2", m_PieceDimensionsY(m_nPieceType - 1))
|
||||
' Esecuzione componente
|
||||
If Not EgtLuaExecLine("CMP_Draw(false)") Then Continue For
|
||||
' Recupero Id del nuovo componente
|
||||
Dim nId As Integer = EgtGetLastPart()
|
||||
If nId = GDB_ID.NULL Then Continue For
|
||||
PartIdList.Add(nId)
|
||||
' Muovo la regione in Z per evitare problemi in visualizzazione
|
||||
Dim nRegId = EgtGetFirstNameInGroup(nId, NAME_REGION)
|
||||
EgtMove(nRegId, New Vector3d(0, 0, DELTAZ_REG), GDB_RT.GLOB)
|
||||
' Aggiusto per lavorazioni
|
||||
AdjustFlatPart(nId)
|
||||
' Lo sposto nel gruppo speciale
|
||||
EgtRelocate(nId, nIpGrp)
|
||||
Next
|
||||
EgtLuaResetGlobVar("CMP")
|
||||
EgtLuaResetGlobVar("CMP_Draw")
|
||||
' Provo ad inserire i pezzi
|
||||
For i As Integer = 1 To PartIdList.Count
|
||||
If Not NestOnePart(PartIdList(i - 1)) Then Exit For
|
||||
Next
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function NestOnePart(nId As Integer) As Boolean
|
||||
' Inserisco una copia del pezzo nel grezzo
|
||||
Dim nId2 As Integer = EgtCopyGlob(nId, GDB_ID.ROOT)
|
||||
If Not m_MainWindow.m_CadCutPageUC.m_NestPage.InsertOnePart(nId2) Then
|
||||
EgtErase(nId2)
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Sub OrderTxBx_EgtClosed(sender As Object, e As EventArgs) Handles OrderTxBx.EgtClosed
|
||||
WritePrivateProfileString(S_FASTGRID, K_FG_ORDER, OrderTxBx.Text, m_MainWindow.GetIniFile())
|
||||
End Sub
|
||||
|
||||
Private Sub PiecesTypeBtn_Click(sender As Object, e As RoutedEventArgs) Handles Type1Btn.Click, Type2Btn.Click, Type3Btn.Click, Type4Btn.Click, Type5Btn.Click
|
||||
If sender Is Type1Btn Then
|
||||
m_nPieceType = 1
|
||||
Type1Btn.IsChecked = True
|
||||
Type2Btn.IsChecked = False
|
||||
Type3Btn.IsChecked = False
|
||||
Type4Btn.IsChecked = False
|
||||
Type5Btn.IsChecked = False
|
||||
ElseIf sender Is Type2Btn Then
|
||||
m_nPieceType = 2
|
||||
Type1Btn.IsChecked = False
|
||||
Type2Btn.IsChecked = True
|
||||
Type3Btn.IsChecked = False
|
||||
Type4Btn.IsChecked = False
|
||||
Type5Btn.IsChecked = False
|
||||
ElseIf sender Is Type3Btn Then
|
||||
m_nPieceType = 3
|
||||
Type1Btn.IsChecked = False
|
||||
Type2Btn.IsChecked = False
|
||||
Type3Btn.IsChecked = True
|
||||
Type4Btn.IsChecked = False
|
||||
Type5Btn.IsChecked = False
|
||||
ElseIf sender Is Type4Btn Then
|
||||
m_nPieceType = 4
|
||||
Type1Btn.IsChecked = False
|
||||
Type2Btn.IsChecked = False
|
||||
Type3Btn.IsChecked = False
|
||||
Type4Btn.IsChecked = True
|
||||
Type5Btn.IsChecked = False
|
||||
ElseIf sender Is Type5Btn Then
|
||||
m_nPieceType = 5
|
||||
Type1Btn.IsChecked = False
|
||||
Type2Btn.IsChecked = False
|
||||
Type3Btn.IsChecked = False
|
||||
Type4Btn.IsChecked = False
|
||||
Type5Btn.IsChecked = True
|
||||
Else
|
||||
Return
|
||||
End If
|
||||
WritePrivateProfileString(S_FASTGRID, K_FG_PIECETYPE, m_nPieceType, m_MainWindow.GetIniFile())
|
||||
End Sub
|
||||
|
||||
Private Sub ConfirmOrderBtn_Click(sender As Object, e As RoutedEventArgs) Handles ConfirmOrderBtn.Click
|
||||
If Not String.IsNullOrEmpty(OrderTxBx.Text) And m_nPieceType > 0 And m_nPieceType <= 5 Then
|
||||
m_nCurrSlab = 1
|
||||
CurrSlabTxBx.Text = 1
|
||||
WritePrivateProfileString(S_FASTGRID, K_FG_CURRSLAB, m_nCurrSlab, m_MainWindow.GetIniFile())
|
||||
OrderTxBx.IsEnabled = False
|
||||
PieceTypeGpBx.IsEnabled = False
|
||||
ConfirmOrderBtn.IsEnabled = False
|
||||
InsertPiecesBtn.IsEnabled = True
|
||||
LastSlabBtn.IsEnabled = True
|
||||
Else
|
||||
' segnalare che i dati ordine non sono accettabili
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub GetPieceDimensions(Index As Integer)
|
||||
Dim DimensionString As String = ""
|
||||
GetPrivateProfileString(S_FASTGRID, Index, "", DimensionString, m_MainWindow.GetIniFile())
|
||||
Dim DimensionSplit() As String = DimensionString.Split(","c)
|
||||
If DimensionSplit.Count = 3 Then
|
||||
m_PieceDimensionsX(Index - 1) = DimensionSplit(0)
|
||||
m_PieceDimensionsY(Index - 1) = DimensionSplit(1)
|
||||
Select Case Index
|
||||
Case 1
|
||||
Type1Btn.Content = DimensionSplit(2)
|
||||
Case 2
|
||||
Type2Btn.Content = DimensionSplit(2)
|
||||
Case 3
|
||||
Type3Btn.Content = DimensionSplit(2)
|
||||
Case 4
|
||||
Type4Btn.Content = DimensionSplit(2)
|
||||
Case 5
|
||||
Type5Btn.Content = DimensionSplit(2)
|
||||
End Select
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Friend Sub CurrSlabIncrement()
|
||||
' verifico se è attiva l'opzione ultima lastra
|
||||
If LastSlabBtn.IsChecked Then
|
||||
' l'ordine è finito
|
||||
m_nCurrSlab = 0
|
||||
OrderTxBx.Text = ""
|
||||
OrderTxBx.IsEnabled = True
|
||||
PieceTypeGpBx.IsEnabled = True
|
||||
ConfirmOrderBtn.IsEnabled = True
|
||||
InsertPiecesBtn.IsEnabled = False
|
||||
LastSlabBtn.IsEnabled = False
|
||||
Else
|
||||
' incremento il contatore lastra
|
||||
m_nCurrSlab += 1
|
||||
WritePrivateProfileString(S_FASTGRID, K_FG_CURRSLAB, m_nCurrSlab, m_MainWindow.GetIniFile())
|
||||
End If
|
||||
CurrSlabTxBx.Text = m_nCurrSlab
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user