diff --git a/CurrentProjectPageUC.xaml.vb b/CurrentProjectPageUC.xaml.vb index 29e139b..ea38e3f 100644 --- a/CurrentProjectPageUC.xaml.vb +++ b/CurrentProjectPageUC.xaml.vb @@ -66,7 +66,6 @@ Public Class CurrentProjectPageUC End Sub Private Sub CurrentProjectPage_Loaded(sender As Object, e As RoutedEventArgs) - ClearMessage() If m_bFirst Then ' imposto colore di default Dim DefColor As New Color3d(0, 0, 0) @@ -276,7 +275,12 @@ Public Class CurrentProjectPageUC SetErrorMessage(sOut) ' Cancello il gruppo di lavoro EgtRemoveMachGroup(nMachGrpId) - ' Ne creo uno nuovo con la macchina corrente + ' Cancello eventuale foto + EgtErase(GetPhoto()) + ' Cancello eventuali preview rimaste nei pezzi + ' (cancellare tramite cancellazione lavorazioni può non essere sufficiente) + RemovePreviewFromParts() + ' Creo un nuovo gruppo di lavoro con la macchina corrente If EgtAddMachGroup(MACH_GROUP, m_MainWindow.GetCurrMachine()) = GDB_ID.NULL Then Return False End If @@ -338,6 +342,29 @@ Public Class CurrentProjectPageUC Return bOk End Function + Friend Function RemovePreviewFromParts() As Boolean + ' Processo i sottogruppi, se di livello System li rimuovo + Dim nGrpId As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT) + While nGrpId <> GDB_ID.NULL + ' Ciclo sui sottogruppi + Dim nSubId As Integer = EgtGetFirstGroupInGroup(nGrpId) + While nSubId <> GDB_ID.NULL + ' Recupero il prossimo sottogruppo + Dim nNextSubId = EgtGetNextGroup(nSubId) + ' Verifico il livello, eventuale cancellazione + Dim nLevel As Integer = GDB_LV.USER + EgtGetLevel(nSubId, nLevel) + If nLevel = GDB_LV.SYSTEM Then + EgtErase(nSubId) + End If + nSubId = nNextSubId + End While + ' Passo al prossimo gruppo + nGrpId = EgtGetNextGroup(nGrpId) + End While + Return True + End Function + Friend Function AddProjectMark() As Integer ' Se assente, inserisco contrassegno di progetto OmagCut valido Dim nMarkId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_PROJMARK) diff --git a/ImportPageUC.xaml.vb b/ImportPageUC.xaml.vb index 6c06002..29d0bf8 100644 --- a/ImportPageUC.xaml.vb +++ b/ImportPageUC.xaml.vb @@ -245,7 +245,7 @@ Public Class ImportPageUC Private Function LoadCurrFile() As Boolean ' Pulisco il DB geometrico locale Dim bOk As Boolean = EgtNewFile() - ' Costruisco path completa del componente + ' Costruisco path completa del file Dim sPath = IO.Path.Combine(m_sCurrDir, m_sCurrFile) ' Riconoscimento tipo m_nFileType = EgtGetFileType(sPath) @@ -257,9 +257,10 @@ Public Class ImportPageUC ElseIf m_nFileType = FT.NGE Then ' Carico Nge bOk = bOk AndAlso EgtOpenFile(sPath) + ' Filtro Nge + bOk = bOk AndAlso FilterNge() Else ' Formato sconosciuto - EgtNewFile() bOk = False End If ' Eseguo zoom @@ -346,6 +347,45 @@ Public Class ImportPageUC OkBtn.IsEnabled = True End Sub + Private Function FilterNge() As Boolean + ' Rimuovo eventuali gruppi con livello System + Dim nId As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT) + While nId <> GDB_ID.NULL + ' Recupero il prossimo gruppo + Dim nNextId = EgtGetNextGroup(nId) + ' Verifico il livello e se necessario cancello + Dim nLevel As Integer = GDB_LV.USER + EgtGetLevel(nId, nLevel) + If nLevel = GDB_LV.SYSTEM Then + EgtErase(nId) + End If + ' Passo al prossimo gruppo + nId = nNextId + End While + ' Processo i sottogruppi, se di livello System li rimuovo altrimenti ne cancello il nome + Dim nGrpId As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT) + While nGrpId <> GDB_ID.NULL + ' Ciclo sui sottogruppi + Dim nSubId As Integer = EgtGetFirstGroupInGroup(nGrpId) + While nSubId <> GDB_ID.NULL + ' Recupero il prossimo sottogruppo + Dim nNextSubId = EgtGetNextGroup(nSubId) + ' Verifico il livello, eventuale cancellazione o rimozione nome + Dim nLevel As Integer = GDB_LV.USER + EgtGetLevel(nSubId, nLevel) + If nLevel = GDB_LV.SYSTEM Then + EgtErase(nSubId) + Else + EgtRemoveName(nSubId) + End If + nSubId = nNextSubId + End While + ' Passo al prossimo gruppo + nGrpId = EgtGetNextGroup(nGrpId) + End While + Return True + End Function + Private Sub AdjustFlatParts() ' Ciclo sui pezzi Dim nPartId As Integer = EgtGetFirstPart() diff --git a/NestPageUC.xaml.vb b/NestPageUC.xaml.vb index e52a2b0..c93bec3 100644 --- a/NestPageUC.xaml.vb +++ b/NestPageUC.xaml.vb @@ -13,7 +13,8 @@ Public Class NestPageUC NONE_TABLE = 0 OUT_TABLE = 1 End Enum - ' Flag per pezzo da deselezionare + ' 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 @@ -106,28 +107,23 @@ Public Class NestPageUC If EgtIsPart(nPartId) Or bPartInTable Then Dim nStat As Integer = GDB_ST.ON_ EgtGetStatus(nPartId, nStat) - ' Se selezionato o posizione oggetto incompatibile con flag posizione selezionati - If nStat = GDB_ST.SEL Or - (bPartInTable And m_nPartPos = PART_POS.OUT_TABLE) Or - (Not bPartInTable And m_nPartPos = PART_POS.IN_TABLE) Then + ' Se già selezionato o posizione oggetto incompatibile con flag posizione selezionati + If nStat = GDB_ST.SEL Then + 'If nStat = GDB_ST.SEL Or + ' (bPartInTable And m_nPartPos = PART_POS.OUT_TABLE) Or + ' (Not bPartInTable And m_nPartPos = PART_POS.IN_TABLE) Then ' Memorizzo Id da deselezionare m_nIdToDesel = nPartId Else - EgtSelectObj(nPartId) - ' Set flag posizione selezionati - m_nPartPos = If(bPartInTable, PART_POS.IN_TABLE, PART_POS.OUT_TABLE) + ' Memorizzo Id da selezionare + m_nIdToSel = nPartId End If - EgtDraw() ' Drag possibile m_bDrag = True Exit While End If nId = EgtGetNextObjInSelWin() End While - ' Se nessun pezzo selezionato, reset flag posizione selezionati - If EgtGetSelectedObjCount() = 0 Then - m_nPartPos = PART_POS.NONE_TABLE - End If ' Dati per drag m_locPrev = e.Location m_bDrag = m_bDrag AndAlso EgtUnProjectPoint(e.Location, m_ptPrev) @@ -136,13 +132,9 @@ Public Class NestPageUC 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 - End If - ' Se drag non abilitato o pezzo non in tavola o drag già in esecuzione, esco - If Not m_bDrag Or m_nPartPos <> PART_POS.IN_TABLE Or m_bDragging Then - Return - End If + 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 @@ -151,6 +143,11 @@ Public Class NestPageUC 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 @@ -160,10 +157,8 @@ Public Class NestPageUC Dim vtMove As Vector3d = ptCurr - m_ptPrev ' Muovo i pezzi selezionati di quanto possibile If vtMove.SqLen() > EPS_SMALL * EPS_SMALL Then - ' annullo deselezione - m_nIdToDesel = GDB_ID.NULL ' muovo il pezzo - EgtMovePart(GDB_ID.SEL, m_bReducedCut, vtMove, + 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() @@ -172,7 +167,7 @@ Public Class NestPageUC If vtMove.IsSmall() Then ' riprovo con movimento tangente Dim vtTgMove As Vector3d = ptCurr - m_ptPrev - EgtTgMovePartOnCollision(GDB_ID.SEL, m_bReducedCut, vtTgMove, + 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()) @@ -181,12 +176,12 @@ Public Class NestPageUC Dim bAlignMoved As Boolean = False Dim bSnapMoved As Boolean = False If m_bMagnetic Then - EgtAlignPartOnCollision(GDB_ID.SEL, m_bReducedCut, + 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(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, + 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 @@ -206,14 +201,35 @@ Public Class NestPageUC 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 - If m_nIdToDesel <> GDB_ID.NULL Then + ElseIf m_nIdToDesel <> GDB_ID.NULL Then EgtDeselectObj(m_nIdToDesel) - m_nIdToDesel = GDB_ID.NULL - EgtDraw() End If - ' Disabilito modalità drag + ' 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 diff --git a/OpenPageUC.xaml.vb b/OpenPageUC.xaml.vb index 9b8e82d..79ba5ec 100644 --- a/OpenPageUC.xaml.vb +++ b/OpenPageUC.xaml.vb @@ -266,7 +266,6 @@ Public Class OpenPageUC Return True End Function - Private Sub OnMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles OpenScene.OnMouseDownScene End Sub