Imports EgtUILib Public Class NestPageUC ' Riferimento alla MainWindow Private m_MainWindow As MainWindow = Application.Current.MainWindow Private WithEvents m_CurrProjPage As CurrentProjectPageUC ' Flag di pagina attiva Private m_bActive As Boolean = False ' Flag per pezzi selezionati in tavola o fuori Private m_nPartPos As Integer = PART_POS.NONE_TABLE Enum PART_POS As Integer IN_TABLE = -1 NONE_TABLE = 0 OUT_TABLE = 1 End Enum ' Identificativi per pezzo da selezionare/deselezionare Private m_nIdToSel As Integer = GDB_ID.NULL Private m_nIdToDesel As Integer = GDB_ID.NULL ' Dati del grezzo Private m_nRawId As Integer = GDB_ID.NULL Private m_ptRawMin As Point3d Private m_ptRawMax As Point3d Private m_dKerf As Double Private m_dMinDist As Double = 0 ' Dati movimento Private m_dStep As Double = 0 Private m_dMaxStep As Double = 0 Private m_bMaximizeMove As Boolean = False Private m_dAngStep As Double = 0 Private m_bReducedCut As Boolean = False ' Dati per Drag Private m_nRestRadius As Integer = 3 Private m_bDrag As Boolean = False Private m_bDragToStart As Boolean = False Private m_bDragging As Boolean = False Private m_locPrev As System.Drawing.Point Private m_ptPrev As Point3d Private m_bMagnetic As Boolean = False Private m_dSnapDist As Double = 0 Private Sub NestPage_Initialized(sender As Object, e As EventArgs) ' Imposto i messaggi letti dal file dei messaggi InsertPartBtn.Content = EgtMsg(MSG_NESTPAGEUC + 1) 'Insert part - Inserisci pezzo StorePartBtn.Content = EgtMsg(MSG_NESTPAGEUC + 2) 'Store part - Parcheggia pezzo RemovePartBtn.Content = EgtMsg(MSG_NESTPAGEUC + 3) 'Remove part - Elimina pezzo SelectAllBtn.Content = EgtMsg(MSG_NESTPAGEUC + 4) 'Select All - Seleziona Tutto DeselectAllBtn.Content = EgtMsg(MSG_NESTPAGEUC + 5) 'Deselect All - Deseleziona Tutto ResetCutBtn.Content = EgtMsg(MSG_NESTPAGEUC + 6) End Sub Private Sub NestPage_Loaded(sender As Object, e As RoutedEventArgs) m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC m_bActive = True ' recupero dimensioni del grezzo e kerf CalcRawPart() ' calcolo valore di minima distanza (da spessore lama corrente) Dim sSawTool As String = String.Empty GetPrivateProfileString(S_MACH_MACH, K_CURRSAW, "", sSawTool, m_MainWindow.GetMachIniFile()) Dim dSawThick As Double = 0 If EgtTdbSetCurrTool(sSawTool) AndAlso EgtTdbGetCurrToolParam(MCH_TP.THICK, dSawThick) Then m_dMinDist = dSawThick Else EgtOutLog("Not found current saw for nesting mindist") m_dMinDist = 0 End If ' carico e calcolo i parametri di movimento e drag m_dStep = GetPrivateProfileDouble(S_NEST, K_STEP, 10, m_MainWindow.GetIniFile()) StepMoveTxBx.Text = LenToString(m_dStep, 3) m_dMaxStep = Math.Max(m_ptRawMax.x - m_ptRawMin.x, m_ptRawMax.y - m_ptRawMin.y) m_dAngStep = GetPrivateProfileDouble(S_NEST, K_ANGSTEP, 15, m_MainWindow.GetIniFile()) RotationAngleTxBx.Text = DoubleToString(m_dAngStep, 2) m_nRestRadius = GetPrivateProfileInt(S_NEST, K_RESTRADIUS, 3, m_MainWindow.GetIniFile()) m_dSnapDist = GetPrivateProfileDouble(S_NEST, K_SNAPDIST, 50, m_MainWindow.GetIniFile()) m_bReducedCut = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_REDUCEDCUT, 0, m_MainWindow.GetMachIniFile()) <> 0) End Sub Public Sub CalcRawPart() ' recupero dimensioni del grezzo e kerf m_nRawId = EgtGetFirstRawPart() GetRawBox(m_ptRawMin, m_ptRawMax) EgtGetInfo(m_nRawId, KEY_KERF, m_dKerf) End Sub Private Sub OnMyMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_CurrProjPage.OnMouseDownScene ' Verifico di essere il gestore attivo If Not m_bActive Then Return End If ' Si può selezionare solo con il tasto sinistro e se stato NULL If e.Button <> Windows.Forms.MouseButtons.Left Or Not m_CurrProjPage.CurrentProjectScene.IsStatusNull() Then Return End If ' Per default no drag m_bDrag = False ' Verifico se selezionato indicativo di pezzo EgtSetObjFilterForSelect(True, True, True, True, True) Dim nSel As Integer EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel) Dim nId As Integer = EgtGetFirstObjInSelWin() While nId <> GDB_ID.NULL ' Recupero l'identificativo del pezzo cui appartiene Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId)) Dim bPartInTable As Boolean = (EgtGetParent(nPartId) = m_nRawId) If EgtIsPart(nPartId) Or bPartInTable Then Dim nStat As Integer = GDB_ST.ON_ EgtGetStatus(nPartId, nStat) ' Se già selezionato o posizione oggetto incompatibile con flag posizione selezionati If nStat = GDB_ST.SEL Then ' Memorizzo Id da deselezionare m_nIdToDesel = nPartId Else ' Memorizzo Id da selezionare m_nIdToSel = nPartId End If ' Drag possibile m_bDrag = True Exit While End If nId = EgtGetNextObjInSelWin() End While ' Dati per drag m_locPrev = e.Location m_bDrag = m_bDrag AndAlso EgtUnProjectPoint(e.Location, m_ptPrev) m_bDragToStart = m_bDrag End Sub Private Sub OnMyMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_CurrProjPage.OnMouseMoveScene ' Verifico di essere il gestore attivo If Not m_bActive Then Return ' Se drag non abilitato o già in esecuzione, esco If Not m_bDrag Or m_bDragging Then Return ' Se primo movimento di drag, verifico si aver superato la soglia di movimento in pixel If m_bDragToStart Then If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then Return End If m_bDragToStart = False End If ' Determino cosa muovere Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL) ' Verifico se in tavola Dim nTestId = If(nMoveId <> GDB_ID.SEL, nMoveId, EgtGetFirstSelectedObj()) If (EgtGetParent(nTestId) <> m_nRawId) Then Return ' Inizio esecuzione di drag m_bDragging = True ' Ricavo il punto corrente in coordinate mondo Dim ptCurr As Point3d EgtUnProjectPoint(e.Location, ptCurr) ' Ricavo il vettore di movimento Dim vtMove As Vector3d = ptCurr - m_ptPrev ' Muovo i pezzi selezionati di quanto possibile If vtMove.SqLen() > EPS_SMALL * EPS_SMALL Then ' muovo il pezzo EgtMovePart(nMoveId, m_bReducedCut, vtMove, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf) EgtSaveCollInfo() ' se movimento risultante nullo, provo con movimento tangente Dim bTgMoved As Boolean = False If vtMove.IsSmall() Then ' riprovo con movimento tangente Dim vtTgMove As Vector3d = ptCurr - m_ptPrev EgtTgMovePartOnCollision(nMoveId, m_bReducedCut, vtTgMove, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf) bTgMoved = (Not vtTgMove.IsSmall()) End If ' se abilitato magnetico (allineamento + snap), lo provo Dim bAlignMoved As Boolean = False Dim bSnapMoved As Boolean = False If m_bMagnetic Then EgtAlignPartOnCollision(nMoveId, m_bReducedCut, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf, bAlignMoved) If m_dSnapDist > EPS_SMALL Then EgtRestoreCollInfo() EgtMovePartToSnapPointOnCollision(nMoveId, m_bReducedCut, m_dSnapDist, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf, bSnapMoved) End If End If EgtDraw() m_CurrProjPage.ResetOrderMachiningFlag() End If ' Aggiorno il punto precedente 'm_ptPrev += vtMove m_ptPrev = ptCurr ' Terminata esecuzione di drag m_bDragging = False End Sub Private Sub OnMyMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_CurrProjPage.OnMouseUpScene ' Verifico di essere il gestore attivo If Not m_bActive Then Return End If ' Se eseguito drag If Not m_bDragToStart Then ' Basta reset alla fine ' Se selezione da eseguire ElseIf m_nIdToSel <> GDB_ID.NULL Then ' Determino se pezzo in tavola o in parcheggio Dim bPartInTable As Boolean = (EgtGetParent(m_nIdToSel) = m_nRawId) ' Se ci sono pezzi già selezionati nella posizione opposta, li deseleziono If (bPartInTable And m_nPartPos = PART_POS.OUT_TABLE) Or (Not bPartInTable And m_nPartPos = PART_POS.IN_TABLE) Then EgtDeselectAll() End If ' Eseguo la selezione EgtSelectObj(m_nIdToSel) ' Set flag posizione selezionati m_nPartPos = If(bPartInTable, PART_POS.IN_TABLE, PART_POS.OUT_TABLE) ' Se deselezione da eseguire ElseIf m_nIdToDesel <> GDB_ID.NULL Then EgtDeselectObj(m_nIdToDesel) End If ' Reset m_bDrag = False m_nIdToSel = GDB_ID.NULL m_nIdToDesel = GDB_ID.NULL ' Se nessun pezzo selezionato, reset flag posizione selezionati If EgtGetSelectedObjCount() = 0 Then m_nPartPos = PART_POS.NONE_TABLE End If EgtDraw() End Sub Private Sub MaximizeMoveBtn_Click(sender As Object, e As RoutedEventArgs) Handles MaximizeMoveBtn.Click If MaximizeMoveBtn.IsChecked Then m_bMaximizeMove = True Else m_bMaximizeMove = False End If End Sub Private Sub UpBtn_Click(sender As Object, e As RoutedEventArgs) Handles UpBtn.Click Dim dStep As Double = If(m_bMaximizeMove, m_dMaxStep, m_dStep) EgtMovePart(GDB_ID.SEL, m_bReducedCut, New Vector3d(0, dStep, 0), m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf) EgtSaveCollInfo() ' se abilitato magnetico (allineamento + snap), lo provo Dim bAlignMoved As Boolean = False Dim bSnapMoved As Boolean = False If m_bMagnetic Then EgtAlignPartOnCollision(GDB_ID.SEL, m_bReducedCut, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf, bAlignMoved) If m_dSnapDist > EPS_SMALL Then EgtRestoreCollInfo() EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf, bSnapMoved) End If End If m_CurrProjPage.ResetOrderMachiningFlag() EgtDraw() End Sub Private Sub DownBtn_Click(sender As Object, e As RoutedEventArgs) Handles DownBtn.Click Dim dStep As Double = If(m_bMaximizeMove, m_dMaxStep, m_dStep) EgtMovePart(GDB_ID.SEL, m_bReducedCut, New Vector3d(0, -dStep, 0), m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf) EgtSaveCollInfo() ' se abilitato magnetico (allineamento + snap), lo provo Dim bAlignMoved As Boolean = False Dim bSnapMoved As Boolean = False If m_bMagnetic Then EgtAlignPartOnCollision(GDB_ID.SEL, m_bReducedCut, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf, bAlignMoved) If m_dSnapDist > EPS_SMALL Then EgtRestoreCollInfo() EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf, bSnapMoved) End If End If m_CurrProjPage.ResetOrderMachiningFlag() EgtDraw() End Sub Private Sub RightBtn_Click(sender As Object, e As RoutedEventArgs) Handles RightBtn.Click Dim dStep As Double = If(m_bMaximizeMove, m_dMaxStep, m_dStep) EgtMovePart(GDB_ID.SEL, m_bReducedCut, New Vector3d(dStep, 0, 0), m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf) EgtSaveCollInfo() ' se abilitato magnetico (allineamento + snap), lo provo Dim bAlignMoved As Boolean = False Dim bSnapMoved As Boolean = False If m_bMagnetic Then EgtAlignPartOnCollision(GDB_ID.SEL, m_bReducedCut, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf, bAlignMoved) If m_dSnapDist > EPS_SMALL Then EgtRestoreCollInfo() EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf, bSnapMoved) End If End If m_CurrProjPage.ResetOrderMachiningFlag() EgtDraw() End Sub Private Sub LeftBtn_Click(sender As Object, e As RoutedEventArgs) Handles LeftBtn.Click Dim dStep As Double = If(m_bMaximizeMove, m_dMaxStep, m_dStep) EgtMovePart(GDB_ID.SEL, m_bReducedCut, New Vector3d(-dStep, 0, 0), m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf) EgtSaveCollInfo() ' se abilitato magnetico (allineamento + snap), lo provo Dim bAlignMoved As Boolean = False Dim bSnapMoved As Boolean = False If m_bMagnetic Then EgtAlignPartOnCollision(GDB_ID.SEL, m_bReducedCut, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf, bAlignMoved) If m_dSnapDist > EPS_SMALL Then EgtRestoreCollInfo() EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf, bSnapMoved) End If End If m_CurrProjPage.ResetOrderMachiningFlag() EgtDraw() End Sub Private Sub RotateCounterClockwiseBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateCounterClockwiseBtn.Click RotateCluster(m_dAngStep) m_CurrProjPage.ResetOrderMachiningFlag() EgtDraw() End Sub Private Sub RotateClockwiseBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateClockwiseBtn.Click RotateCluster(-m_dAngStep) m_CurrProjPage.ResetOrderMachiningFlag() EgtDraw() End Sub Private Function RotateCluster(ByVal dAngRotDeg As Double) As Boolean ' Se non ci sono pezzi selezionati, esco If EgtGetSelectedObjCount() = 0 Then Return True End If ' Calcolo il centro di rotazione come centro del cluster Dim ptCen As Point3d If Not EgtGetPartPartClusterCenterGlob(GDB_ID.SEL, ptCen) Then Return False End If ' Se pezzi in parcheggio, li ruoto liberamente e li risistemo (sempre possibile) If m_nPartPos <> PART_POS.IN_TABLE Then ' Rotazione dei pezzi attorno al loro centro EgtRotate(GDB_ID.SEL, ptCen, Vector3d.Z_AX(), dAngRotDeg, GDB_RT.GLOB) ' Sistemazione nel parcheggio EgtPackBox(GDB_ID.SEL, -5000, -INFINITO, 1000, -3000, 20, False) Return True ' Altrimenti li ruoto tenendo conto delle collisioni Else Return EgtRotatePart(GDB_ID.SEL, m_bReducedCut, ptCen, dAngRotDeg, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf) End If End Function Private Sub InsertPartBtn_Click(sender As Object, e As RoutedEventArgs) Handles InsertPartBtn.Click ' Ciclo di inserimento in tavola dei pezzi selezionati Dim nId As Integer = EgtGetFirstSelectedObj() While nId <> GDB_ID.NULL ' Recupero successivo selezionato Dim nNextId = EgtGetNextSelectedObj() ' Lo metto in tavola, se possibile InsertOnePart(nId) ' Passo al successivo selezionato nId = nNextId End While ' Aggiorno flag selezionati m_nPartPos = If(EgtGetSelectedObjCount() > 0, PART_POS.IN_TABLE, PART_POS.NONE_TABLE) ' Aggiorno vista EgtZoom(ZM.ALL) End Sub Public Function InsertOnePart(ByVal nId As Integer) As Boolean ' Se esiste grezzo e pezzo in parcheggio, lo metto nella tavola If m_nRawId <> GDB_ID.NULL AndAlso EgtIsPart(nId) Then ' Inserisco il pezzo nel grezzo, in basso a sinistra Dim ptP As New Point3d(m_dKerf, m_dKerf, m_ptRawMax.z - m_ptRawMin.z) If EgtAddPartToRawPart(nId, ptP, m_nRawId) Then ' Aggiungo le lavorazioni standard AddMachinings(nId, True, False) ' Eseguo nesting Dim bOk As Boolean = EgtPackPart(nId, m_bReducedCut, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf, True) ' Gestione risultato nesting If bOk Then Return True Else EraseMachinings(nId) EgtRemovePartFromRawPart(nId) EgtSetStatus(nId, GDB_ST.ON_) End If End If End If Return False End Function Private Sub SetAllPreviewsStatus(bShow As Boolean) Dim nPartId = EgtGetFirstPartInRawPart(m_nRawId) While nPartId <> GDB_ID.NULL ' Recupero il layer preview del pezzo e ne imposto lo stato di visualizzazione Dim nPvId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_PREVIEW) EgtSetStatus(nPvId, If(bShow, GDB_ST.ON_, GDB_ST.OFF)) ' Passo al pezzo successivo nPartId = EgtGetNextPartInRawPart(nPartId) End While End Sub Private Sub StorePartBtn_Click(sender As Object, e As RoutedEventArgs) Handles StorePartBtn.Click ' Ciclo di parcheggio dei pezzi selezionati Dim nId As Integer = EgtGetFirstSelectedObj() While nId <> GDB_ID.NULL ' Recupero indice del successivo Dim nNextId = EgtGetNextSelectedObj() ' Metto in parcheggio, se in grezzo StoreOnePart(nId) ' Passo al successivo selezionato nId = nNextId End While ' Imposto flag posizione pezzi su parcheggio m_nPartPos = PART_POS.OUT_TABLE ' Aggiorno vista EgtZoom(ZM.ALL) End Sub Public Function StoreOnePart(ByVal nId As Integer, Optional ByVal bForced As Boolean = False) As Boolean ' Se pezzo in grezzo, metto in parcheggio (sempre possibile) If bForced OrElse (m_nRawId <> GDB_ID.NULL AndAlso EgtGetParent(nId) = m_nRawId) Then ' Rimuovo le lavorazioni EraseMachinings(nId) ' Parcheggio EgtRemovePartFromRawPart(nId) EgtSetStatus(nId, GDB_ST.ON_) EgtPackBox(nId, -5000, -INFINITO, 1000, -3000, 20, False) Return True End If Return False End Function Private Sub RemovePartBtn_Click(sender As Object, e As RoutedEventArgs) Handles RemovePartBtn.Click ' Ciclo di cancellazione dei pezzi selezionati Dim nId As Integer = EgtGetFirstSelectedObj() While nId <> GDB_ID.NULL ' Recupero indice del successivo Dim nNextId = EgtGetNextSelectedObj() ' Se pezzo in parcheggio cancello direttamente If EgtIsPart(nId) Then ' Rimuovo le lavorazioni EraseMachinings(nId) ' Cancello EgtErase(nId) ' Altrimenti pezzo nel grezzo ElseIf EgtGetParent(nId) = m_nRawId Then If EgtRemovePartFromRawPart(nId) Then ' Rimuovo le lavorazioni EraseMachinings(nId) 'Cancello EgtErase(nId) End If End If ' Passo al successivo selezionato nId = nNextId End While ' Imposto flag posizione pezzi m_nPartPos = PART_POS.NONE_TABLE ' Aggiorno vista EgtZoom(ZM.ALL) End Sub Private Sub SelectAllBtn_Click(sender As Object, e As RoutedEventArgs) Handles SelectAllBtn.Click ' Se già selezionati in tavola o non ci sono selezionati If m_nPartPos = PART_POS.IN_TABLE Or m_nPartPos = PART_POS.NONE_TABLE Then ' Seleziono tutti i pezzi in tavola Dim nPartId As Integer = EgtGetFirstGroupInGroup(m_nRawId) While nPartId <> GDB_ID.NULL EgtSetStatus(nPartId, GDB_ST.SEL) nPartId = EgtGetNextGroup(nPartId) End While ' Aggiorno flag m_nPartPos = If(EgtGetSelectedObjCount() > 0, PART_POS.IN_TABLE, PART_POS.NONE_TABLE) ' Se già selezionati in parcheggio ElseIf m_nPartPos = PART_POS.OUT_TABLE Then ' Seleziono tutti i pezzi in parcheggio Dim nPartId As Integer = EgtGetFirstPart() While nPartId <> GDB_ID.NULL EgtSetStatus(nPartId, GDB_ST.SEL) nPartId = EgtGetNextPart(nPartId) End While End If ' Aggiorno vista EgtDraw() End Sub Private Sub DeselectAllBtn_Click(sender As Object, e As RoutedEventArgs) Handles DeselectAllBtn.Click ' Eseguo EgtDeselectAll() ' Imposto flag posizione pezzi m_nPartPos = PART_POS.NONE_TABLE ' Aggiorno vista EgtDraw() End Sub Private Sub StepMoveTxBx_EgtClosed(sender As Object, e As EventArgs) Handles StepMoveTxBx.EgtClosed Dim dStep As Double If StringToLen(StepMoveTxBx.Text, dStep) Then m_dStep = Math.Max(dStep, 2 * EPS_SMALL) End If End Sub Private Sub RotationAngleTxBx_EgtClosed(sender As Object, e As EventArgs) Handles RotationAngleTxBx.EgtClosed Dim dAngStep As Double If StringToDouble(RotationAngleTxBx.Text, dAngStep) Then m_dAngStep = Math.Max(dAngStep, 50 * EPS_ANG_SMALL) End If End Sub Private Sub NestPage_Unloaded(sender As Object, e As RoutedEventArgs) m_bActive = False End Sub Private Sub MagneticPiecesBtn_Click(sender As Object, e As RoutedEventArgs) Handles MagneticPiecesBtn.Click If MagneticPiecesBtn.IsChecked() Then m_bMagnetic = True Else m_bMagnetic = False End If End Sub Private Sub ResetCutBtn_Click(sender As Object, e As RoutedEventArgs) Handles ResetCutBtn.Click ' Cancello eventuali messaggi m_CurrProjPage.ClearMessage() ' Cancello tutte le lavorazioni EraseMachinings(GDB_ID.NULL) ' Reinserisco tutte le lavorazioni AddMachinings(GDB_ID.NULL, True, False) ' Aggiorno visualizzazione EgtDraw() End Sub Friend Function VerifyPartsNesting(bReducedCut As Boolean) As Boolean ' Ciclo su tutti i pezzi in tavola Dim nPartId As Integer = EgtGetFirstGroupInGroup(m_nRawId) While nPartId <> GDB_ID.NULL If Not EgtVerifyPart(nPartId, bReducedCut, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf) Then Return False End If nPartId = EgtGetNextGroup(nPartId) End While Return True End Function Friend Function StoreCollisionParts(bReducedCut As Boolean) As Boolean ' Ciclo su tutti i pezzi in tavola (dall'ultimo) Dim nPartId As Integer = EgtGetLastGroupInGroup(m_nRawId) While nPartId <> GDB_ID.NULL Dim nPrevPartId As Integer = EgtGetPrevGroup(nPartId) If Not EgtVerifyPart(nPartId, bReducedCut, m_ptRawMin.x + m_dKerf, m_ptRawMin.y + m_dKerf, m_ptRawMax.x - m_dKerf, m_ptRawMax.y - m_dKerf) Then StoreOnePart(nPartId, True) End If nPartId = nPrevPartId End While Return True End Function End Class