6e8c52d297
- aggiunta gestione per pezzi rovinati reinseriti direttamente nel parcheggio (Hoffman) con gestione custom - predisposizioni per ribassi e righe di scolo.
1208 lines
51 KiB
VB.net
1208 lines
51 KiB
VB.net
Imports System.Windows.Input
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib
|
|
|
|
Public Class NestPageUC
|
|
' Riferimento alla MainWindow
|
|
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
Private WithEvents m_CurrProjPage As CurrentProjectPageUC
|
|
' Flag di pagina attiva
|
|
Private m_bActive As Boolean = False
|
|
' Flag per modalità nesting standard o registrazione posizione lastra
|
|
Friend m_bRegister 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_b3Raw As New BBox3d
|
|
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 tolleranza spessore Trf
|
|
Private m_dTrfThickTolerance As Double = 0
|
|
' Dati movimento registrazione grezzo
|
|
Private m_dRegStep As Double = 0
|
|
Private m_dRegAngStep As Double = 0
|
|
Private m_dMaxRegAng As Double = 10
|
|
' Dati per Drag
|
|
Private m_nRestRadius As Integer = 3
|
|
Private m_bDrag As Boolean = False
|
|
Private m_bDragToStart As Boolean = False
|
|
Private m_bVerify As Boolean = False
|
|
Private m_bDragging As Boolean = False
|
|
Private m_locPrev As System.Drawing.Point
|
|
Private m_ptPrev As Point3d
|
|
Private m_vtTotMove As Vector3d
|
|
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
|
|
End Sub
|
|
|
|
Private Sub NestPage_Loaded(sender As Object, e As RoutedEventArgs)
|
|
m_bActive = True
|
|
LoadParams()
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Public Sub CalcRawPart()
|
|
' determino il grezzo (è il primo con fase 1)
|
|
m_nRawId = GetCurrentRaw()
|
|
' recupero dimensioni del grezzo e kerf
|
|
If Not EgtGetRawPartBBox(m_nRawId, m_b3Raw) Then
|
|
m_nRawId = GDB_ID.NULL
|
|
m_b3Raw.Setup()
|
|
End If
|
|
If Not EgtGetInfo(m_nRawId, KEY_KERF, m_dKerf) Then m_dKerf = 0
|
|
End Sub
|
|
|
|
Friend Sub LoadParams()
|
|
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
|
' recupero dimensioni del grezzo e kerf
|
|
CalcRawPart()
|
|
' calcolo valore di minima distanza (da spessore lama corrente)
|
|
Dim dSawThick As Double = 0
|
|
If EgtTdbSetCurrTool(m_MainWindow.m_CurrentMachine.sCurrSaw) 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_b3Raw.DimX(), m_b3Raw.DimY())
|
|
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)
|
|
' Carico parametro tolleranza spessore per Trf
|
|
m_dTrfThickTolerance = Math.Max(GetPrivateProfileDouble(S_NEST, K_TRFTHICKTOLERANCE, 2, m_MainWindow.GetIniFile()), EPS_SMALL)
|
|
' carico i parametri di registrazione grezzo
|
|
m_dRegStep = GetPrivateProfileDouble(S_REG, K_REGSTEP, 10, m_MainWindow.GetIniFile())
|
|
m_dRegAngStep = GetPrivateProfileDouble(S_REG, K_REGANGSTEP, 1, m_MainWindow.GetIniFile())
|
|
m_dMaxRegAng = GetPrivateProfileDouble(S_MACH_REG, K_MACH_MAX_ROT_ANG, 10, m_MainWindow.GetMachIniFile())
|
|
' Garantisco visibilità pezzi parcheggiati
|
|
ShowParkedParts()
|
|
' Garantisco visibilità eventuale contorno da foto
|
|
m_CurrProjPage.ShowContour(True)
|
|
End Sub
|
|
|
|
Public Sub UpdateStepsOnUI()
|
|
If Not m_bRegister Then
|
|
StepMoveTxBx.Text = LenToString(m_dStep, 3)
|
|
RotationAngleTxBx.Text = DoubleToString(m_dAngStep, 2)
|
|
Else
|
|
StepMoveTxBx.Text = LenToString(m_dRegStep, 3)
|
|
RotationAngleTxBx.Text = DoubleToString(m_dRegAngStep, 2)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnMyMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_CurrProjPage.OnMouseDownScene
|
|
' Verifico di essere il gestore attivo e non in modalità registrazione
|
|
If Not m_bActive Or m_bRegister Then Return
|
|
' 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
|
|
EgtSetObjFilterForSelWin(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
|
|
m_bVerify = m_bDrag AndAlso (Keyboard.Modifiers And ModifierKeys.Shift) > 0
|
|
m_vtTotMove = Vector3d.NULL()
|
|
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 di 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
|
|
' Se movimento con sola verifica finale
|
|
If m_bVerify Then
|
|
EgtMove(nMoveId, vtMove)
|
|
m_vtTotMove += vtMove
|
|
' altrimenti caso con verifica durante il movimento
|
|
Else
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' muovo il pezzo
|
|
EgtMovePart(nMoveId, m_bReducedCut, vtMove)
|
|
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)
|
|
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, bAlignMoved)
|
|
If m_dSnapDist > EPS_SMALL Then
|
|
EgtRestoreCollInfo()
|
|
EgtMovePartToSnapPointOnCollision(nMoveId, m_bReducedCut, m_dSnapDist, bSnapMoved)
|
|
End If
|
|
End If
|
|
m_CurrProjPage.ResetOrderMachiningFlag()
|
|
End If
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
If nMoveId = GDB_ID.SEL Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Else
|
|
VeinMatching.OnMovePartInRaw(nMoveId)
|
|
End If
|
|
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
|
|
' Se movimento con sola verifica finale
|
|
If m_bVerify Then
|
|
' Determino cosa verificare
|
|
Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL)
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' Eseguo verifica
|
|
If EgtVerifyPart(nMoveId, m_bReducedCut) Then
|
|
m_CurrProjPage.ResetOrderMachiningFlag()
|
|
' Non superata riporto alla posizione iniziale
|
|
Else
|
|
EgtMove(nMoveId, -m_vtTotMove)
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
If nMoveId = GDB_ID.SEL Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Else
|
|
VeinMatching.OnMovePartInRaw(nMoveId)
|
|
End If
|
|
End If
|
|
' altrimenti caso con verifica durante il movimento
|
|
Else
|
|
' Basta reset alla fine
|
|
End If
|
|
' 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()
|
|
' Aggiornamento eventuale VeinMatching
|
|
VeinMatching.OnDeselectAll()
|
|
End If
|
|
' Eseguo la selezione
|
|
EgtSelectObj(m_nIdToSel)
|
|
' Eventuale aggiornamento VeinMatching
|
|
VeinMatching.OnSelectPart(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)
|
|
' Eventuale aggiornamento VeinMatching
|
|
VeinMatching.OnDeselectPart(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
|
|
|
|
Friend Function SelectPart(nPartId As Integer, bNotifyVM As Boolean) As Boolean
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
' Determino se pezzo in tavola o in parcheggio
|
|
Dim bPartInTable As Boolean = (EgtGetParent(nPartId) = m_nRawId)
|
|
' Se ci sono pezzi già selezionati nella posizione opposta, restituisco selezione non possibile
|
|
If (bPartInTable And m_nPartPos = PART_POS.OUT_TABLE) Or
|
|
(Not bPartInTable And m_nPartPos = PART_POS.IN_TABLE) Then
|
|
Return False
|
|
End If
|
|
' Eseguo la selezione
|
|
EgtSelectObj(nPartId)
|
|
' Eventuale aggiornamento VeinMatching
|
|
If bNotifyVM Then VeinMatching.OnSelectPart(nPartId)
|
|
' Set flag posizione selezionati
|
|
m_nPartPos = If(bPartInTable, PART_POS.IN_TABLE, PART_POS.OUT_TABLE)
|
|
' Selezione effettuata
|
|
EgtDraw()
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function DeselectPart(nPartId As Integer, bNotifyVM As Boolean) As Boolean
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
' Eseguo la deselezione
|
|
EgtDeselectObj(nPartId)
|
|
' Eventuale aggiornamento VeinMatching
|
|
If bNotifyVM Then VeinMatching.OnDeselectPart(nPartId)
|
|
' Se nessun pezzo selezionato, reset flag posizione selezionati
|
|
If EgtGetSelectedObjCount() = 0 Then m_nPartPos = PART_POS.NONE_TABLE
|
|
' Deselezione effettuata
|
|
EgtDraw()
|
|
Return True
|
|
End Function
|
|
|
|
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
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
If Not m_bRegister Then
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' eseguo movimento
|
|
Dim dStep As Double = If(m_bMaximizeMove, m_dMaxStep, m_dStep)
|
|
EgtMovePart(GDB_ID.SEL, m_bReducedCut, New Vector3d(0, dStep, 0))
|
|
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, bAlignMoved)
|
|
If m_dSnapDist > EPS_SMALL Then
|
|
EgtRestoreCollInfo()
|
|
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, bSnapMoved)
|
|
End If
|
|
End If
|
|
m_CurrProjPage.ResetOrderMachiningFlag()
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Else
|
|
MoveAllRawParts(New Vector3d(0, m_dRegStep, 0))
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub DownBtn_Click(sender As Object, e As RoutedEventArgs) Handles DownBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
If Not m_bRegister Then
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' eseguo movimento
|
|
Dim dStep As Double = If(m_bMaximizeMove, m_dMaxStep, m_dStep)
|
|
EgtMovePart(GDB_ID.SEL, m_bReducedCut, New Vector3d(0, -dStep, 0))
|
|
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, bAlignMoved)
|
|
If m_dSnapDist > EPS_SMALL Then
|
|
EgtRestoreCollInfo()
|
|
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, bSnapMoved)
|
|
End If
|
|
End If
|
|
m_CurrProjPage.ResetOrderMachiningFlag()
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Else
|
|
MoveAllRawParts(New Vector3d(0, -m_dRegStep, 0))
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub RightBtn_Click(sender As Object, e As RoutedEventArgs) Handles RightBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
If Not m_bRegister Then
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' eseguo movimento
|
|
Dim dStep As Double = If(m_bMaximizeMove, m_dMaxStep, m_dStep)
|
|
EgtMovePart(GDB_ID.SEL, m_bReducedCut, New Vector3d(dStep, 0, 0))
|
|
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, bAlignMoved)
|
|
If m_dSnapDist > EPS_SMALL Then
|
|
EgtRestoreCollInfo()
|
|
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, bSnapMoved)
|
|
End If
|
|
End If
|
|
m_CurrProjPage.ResetOrderMachiningFlag()
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Else
|
|
MoveAllRawParts(New Vector3d(m_dRegStep, 0, 0))
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub LeftBtn_Click(sender As Object, e As RoutedEventArgs) Handles LeftBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
If Not m_bRegister Then
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' eseguo movimento
|
|
Dim dStep As Double = If(m_bMaximizeMove, m_dMaxStep, m_dStep)
|
|
EgtMovePart(GDB_ID.SEL, m_bReducedCut, New Vector3d(-dStep, 0, 0))
|
|
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, bAlignMoved)
|
|
If m_dSnapDist > EPS_SMALL Then
|
|
EgtRestoreCollInfo()
|
|
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, m_bReducedCut, m_dSnapDist, bSnapMoved)
|
|
End If
|
|
End If
|
|
m_CurrProjPage.ResetOrderMachiningFlag()
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Else
|
|
MoveAllRawParts(New Vector3d(-m_dRegStep, 0, 0))
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub MoveAllRawParts(vtMove As Vector3d)
|
|
' Provo il movimento
|
|
Dim bMoveOk As Boolean = True
|
|
Dim nPhase As Integer = 1
|
|
Dim nRawId As Integer = GDB_ID.NULL
|
|
While nPhase <= EgtGetPhaseCount()
|
|
EgtSetCurrPhase(nPhase)
|
|
nRawId = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
If EgtVerifyRawPartPhase(nRawId, nPhase) Then
|
|
If Not EgtMoveRawPart(nRawId, vtMove) Then
|
|
bMoveOk = False
|
|
Exit While
|
|
End If
|
|
End If
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
If Not bMoveOk Then Exit While
|
|
nPhase += 1
|
|
End While
|
|
' Se movimento impossibile, ripristino posizione dei grezzi già spostati
|
|
If Not bMoveOk Then
|
|
Dim nRevPhase As Integer = 1
|
|
Dim nRevRawId As Integer = GDB_ID.NULL
|
|
While nRevPhase <= nPhase
|
|
EgtSetCurrPhase(nRevPhase)
|
|
nRevRawId = EgtGetFirstRawPart()
|
|
While nRevRawId <> GDB_ID.NULL And (nRevPhase < nPhase Or nRevRawId <> nRawId)
|
|
If EgtVerifyRawPartPhase(nRevRawId, nRevPhase) Then
|
|
EgtMoveRawPart(nRevRawId, -vtMove)
|
|
End If
|
|
nRevRawId = EgtGetNextRawPart(nRevRawId)
|
|
End While
|
|
nRevPhase += 1
|
|
End While
|
|
End If
|
|
' Ripristino lo stato iniziale
|
|
EgtSetCurrPhase(1)
|
|
HideAllMachinings()
|
|
End Sub
|
|
|
|
Private Sub RotateCounterClockwiseBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateCounterClockwiseBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
If Not m_bRegister Then
|
|
RotateCluster(m_dAngStep)
|
|
m_CurrProjPage.ResetOrderMachiningFlag()
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Else
|
|
RotateAllRawParts(m_dRegAngStep)
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub RotateClockwiseBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateClockwiseBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
If Not m_bRegister Then
|
|
RotateCluster(-m_dAngStep)
|
|
m_CurrProjPage.ResetOrderMachiningFlag()
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Else
|
|
RotateAllRawParts(-m_dRegAngStep)
|
|
EgtDraw()
|
|
End If
|
|
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
|
|
' Se pezzi in parcheggio, li ruoto liberamente e li risistemo (sempre possibile)
|
|
If m_nPartPos <> PART_POS.IN_TABLE Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
' Calcolo il centro di rotazione come centro del pezzo
|
|
Dim ptCen As Point3d
|
|
If Not EgtGetPartPartClusterCenterGlob(nId, ptCen) Then Return False
|
|
' Rotazione del pezzo attorno al suo centro
|
|
EgtRotate(nId, ptCen, Vector3d.Z_AX(), dAngRotDeg, GDB_RT.GLOB)
|
|
' Sistemazione nel parcheggio
|
|
PackPartInStore(nId)
|
|
' Passo al successivo selezionato
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Return True
|
|
' Altrimenti li ruoto tenendo conto delle collisioni
|
|
Else
|
|
' Calcolo il centro di rotazione come centro del cluster
|
|
Dim ptCen As Point3d
|
|
If Not EgtGetPartPartClusterCenterGlob(GDB_ID.SEL, ptCen) Then Return False
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' Verifico rotazione complessiva
|
|
EgtRotate(GDB_ID.SEL, ptCen, Vector3d.Z_AX(), dAngRotDeg, GDB_RT.GLOB)
|
|
If EgtVerifyPart(GDB_ID.SEL, m_bReducedCut) Then Return True
|
|
' Provo rotazione parziale (dopo aver annullato la complessiva)
|
|
EgtRotate(GDB_ID.SEL, ptCen, Vector3d.Z_AX(), -dAngRotDeg, GDB_RT.GLOB)
|
|
Return EgtRotatePart(GDB_ID.SEL, m_bReducedCut, ptCen, dAngRotDeg)
|
|
End If
|
|
End Function
|
|
|
|
Private Sub RotateAllRawParts(dAngDeg As Double)
|
|
' Recupero rotazione totale
|
|
Dim dRegRot As Double = GetRegistrationRotation()
|
|
' Verifico se nuova rotazione totale ammissibile
|
|
m_CurrProjPage.ClearMessage()
|
|
If Math.Abs(dRegRot + dAngDeg) > m_dMaxRegAng Then
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90338)) 'Angolo di registrazione oltre i limiti
|
|
Return
|
|
End If
|
|
' Recupero il centro del grezzo iniziale per usarlo come centro della rotazione
|
|
Dim ptCen As New Point3d
|
|
GetRawCenter(ptCen)
|
|
' Provo la rotazione
|
|
Dim bMoveOk As Boolean = True
|
|
Dim nPhase As Integer = 1
|
|
Dim nRawId As Integer = GDB_ID.NULL
|
|
While nPhase <= EgtGetPhaseCount()
|
|
EgtSetCurrPhase(nPhase)
|
|
nRawId = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
If EgtVerifyRawPartPhase(nRawId, nPhase) Then
|
|
' Rotazione del centro come spostamento grezzo più rotazione grezzo attorno al suo centro
|
|
Dim ptRawCen As New Point3d
|
|
EgtGetRawPartCenter(nRawId, ptRawCen)
|
|
Dim ptMovCen As New Point3d(ptRawCen)
|
|
ptMovCen.Rotate(ptCen, Vector3d.Z_AX(), dAngDeg)
|
|
If Not EgtMoveRawPart(nRawId, ptMovCen - ptRawCen) Then
|
|
bMoveOk = False
|
|
Exit While
|
|
End If
|
|
If Not EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAngDeg) Then
|
|
EgtMoveRawPart(nRawId, -(ptMovCen - ptRawCen))
|
|
bMoveOk = False
|
|
Exit While
|
|
End If
|
|
End If
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
If Not bMoveOk Then Exit While
|
|
nPhase += 1
|
|
End While
|
|
' Se rotazione impossibile, ripristino posizione dei grezzi già spostati
|
|
If Not bMoveOk Then
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90339)) 'Rotazione impossibile
|
|
Dim nRevPhase As Integer = 1
|
|
Dim nRevRawId As Integer = GDB_ID.NULL
|
|
While nRevPhase <= nPhase
|
|
EgtSetCurrPhase(nRevPhase)
|
|
nRevRawId = EgtGetFirstRawPart()
|
|
While nRevRawId <> GDB_ID.NULL And (nRevPhase < nPhase Or nRevRawId <> nRawId)
|
|
If EgtVerifyRawPartPhase(nRevRawId, nRevPhase) Then
|
|
' Eseguo al contrario
|
|
EgtRotateRawPart(nRevRawId, Vector3d.Z_AX(), -dAngDeg)
|
|
Dim ptRawCen As New Point3d
|
|
EgtGetRawPartCenter(nRevRawId, ptRawCen)
|
|
Dim ptMovCen As New Point3d(ptRawCen)
|
|
ptMovCen.Rotate(ptCen, Vector3d.Z_AX(), -dAngDeg)
|
|
EgtMoveRawPart(nRevRawId, (ptMovCen - ptRawCen))
|
|
End If
|
|
nRevRawId = EgtGetNextRawPart(nRevRawId)
|
|
End While
|
|
nRevPhase += 1
|
|
End While
|
|
' Altrimenti eseguo sistemazioni
|
|
Else
|
|
' Origine della tavola
|
|
Dim ptOri As Point3d
|
|
EgtGetTableRef(1, ptOri)
|
|
' Annullo rotazioni dei grezzi e le rifaccio sulle parti componenti
|
|
Dim nRevPhase As Integer = 1
|
|
Dim nRevRawId As Integer = GDB_ID.NULL
|
|
While nRevPhase <= EgtGetPhaseCount()
|
|
EgtSetCurrPhase(nRevPhase)
|
|
nRevRawId = EgtGetFirstRawPart()
|
|
While nRevRawId <> GDB_ID.NULL
|
|
If EgtVerifyRawPartPhase(nRevRawId, nRevPhase) Then
|
|
' Eseguo al contrario
|
|
EgtRotateRawPart(nRevRawId, Vector3d.Z_AX(), -dAngDeg)
|
|
Dim ptRawCen As New Point3d
|
|
EgtGetRawPartCenter(nRevRawId, ptRawCen)
|
|
Dim ptMovCen As New Point3d(ptRawCen)
|
|
ptMovCen.Rotate(ptCen, Vector3d.Z_AX(), -dAngDeg)
|
|
EgtMoveRawPart(nRevRawId, (ptMovCen - ptRawCen))
|
|
' Rifaccio sugli oggetti contenuti nel grezzo
|
|
Dim nId As Integer = EgtGetFirstInGroup(nRevRawId)
|
|
While nId <> GDB_ID.NULL
|
|
EgtRotate(nId, ptCen, Vector3d.Z_AX(), dAngDeg, GDB_RT.GLOB)
|
|
nId = EgtGetNext(nId)
|
|
End While
|
|
' Imposto posizione esatta del grezzo dopo rotazione
|
|
Dim b3Raw As New BBox3d
|
|
EgtGetRawPartBBox(nRevRawId, b3Raw)
|
|
EgtMoveToCornerRawPart(nRevRawId, (b3Raw.Min() - ptOri) + Point3d.ORIG(), MCH_CR.BL)
|
|
End If
|
|
nRevRawId = EgtGetNextRawPart(nRevRawId)
|
|
End While
|
|
nRevPhase += 1
|
|
End While
|
|
' Ruoto opportunamente anche i dati di movimento
|
|
Dim nOpeId As Integer = EgtGetFirstActiveOperation()
|
|
While nOpeId <> GDB_ID.NULL
|
|
If EgtGetOperationType(nOpeId) = MCH_OY.DISP Then
|
|
' Recupero i gruppi con i dati
|
|
Dim nRpmId As Integer = EgtGetFirstNameInGroup(nOpeId, "Rpm*")
|
|
While nRpmId <> GDB_ID.NULL
|
|
' Recupero le informazioni
|
|
Dim vtRawMove As New Vector3d
|
|
If EgtGetInfo(nRpmId, "Mv", vtRawMove) Then
|
|
vtRawMove.Rotate(Vector3d.Z_AX(), dAngDeg)
|
|
EgtSetInfo(nRpmId, "Mv", vtRawMove)
|
|
End If
|
|
Dim vtDelta As New Vector3d
|
|
If EgtGetInfo(nRpmId, "Dt", vtDelta) Then
|
|
vtDelta.Rotate(Vector3d.Z_AX(), dAngDeg)
|
|
EgtSetInfo(nRpmId, "Dt", vtDelta)
|
|
End If
|
|
Dim dAngRotDeg As Double = 0
|
|
If EgtGetInfo(nRpmId, "Ad", dAngRotDeg) Then
|
|
EgtSetInfo(nRpmId, "Ad", dAngRotDeg + dAngDeg)
|
|
End If
|
|
' Cerco un altro gruppo
|
|
nRpmId = EgtGetNextName(nRpmId, "Rpm*")
|
|
End While
|
|
End If
|
|
nOpeId = EgtGetNextActiveOperation(nOpeId)
|
|
End While
|
|
' Aggiorno rotazione totale
|
|
SetRegistrationRotation(dRegRot + dAngDeg)
|
|
' Dichiaro grezzo per punti
|
|
EgtSetInfo(GetCurrentRaw(), KEY_RAWBYPOINTS, 1)
|
|
End If
|
|
' Ripristino lo stato iniziale
|
|
EgtSetCurrPhase(1)
|
|
HideAllMachinings()
|
|
End Sub
|
|
|
|
Private Sub InsertPartBtn_Click(sender As Object, e As RoutedEventArgs) Handles InsertPartBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
Dim bWrongTrf As Boolean = False
|
|
m_CurrProjPage.ClearMessage()
|
|
' Ciclo di inserimento in tavola dei pezzi selezionati
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
' Recupero successivo selezionato
|
|
Dim nNextId = EgtGetNextSelectedObj()
|
|
' Se pezzo da Trf, verifico compatibilità
|
|
If Not VerifyTrfData(nId) Then
|
|
bWrongTrf = True
|
|
EgtSetStatus(nId, GDB_ST.ON_)
|
|
' Passo al successivo selezionato
|
|
nId = nNextId
|
|
Continue While
|
|
End If
|
|
' Lo metto in tavola, se possibile
|
|
If InsertOnePart(nId) Then
|
|
VeinMatching.OnInsertPartInRaw(nId)
|
|
Else
|
|
EgtSetStatus(nId, GDB_ST.ON_)
|
|
VeinMatching.OnDeselectPart(nId)
|
|
End If
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' 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)
|
|
' Eventuale segnalazione di pezzi Trf non adatti
|
|
If bWrongTrf Then
|
|
' Pezzi con spessore, materiale o finitura non compatibili
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_NESTPAGEUC + 7))
|
|
End If
|
|
End Sub
|
|
|
|
Private Function VerifyTrfData(nId As Integer) As Boolean
|
|
' Verifico se pezzo da Trf
|
|
If Not EgtExistsInfo(nId, "OC") Then Return True
|
|
' Recupero e verifico lo spessore del pezzo
|
|
Dim dTh As Double = 0
|
|
EgtGetInfo(nId, "T", dTh)
|
|
If Math.Abs(dTh - m_b3Raw.DimZ()) > m_dTrfThickTolerance Then Return False
|
|
' Recupero il materiale e la finitura superficiale del pezzo
|
|
Dim sMat As String = ""
|
|
EgtGetInfo(nId, "MT", sMat)
|
|
Dim sSurf As String = ""
|
|
EgtGetInfo(nId, "SRF", sSurf)
|
|
' Recupero materiale e finitura superficiale di pezzo già inserito (come dati di riferimento)
|
|
Dim sRefMat As String = ""
|
|
Dim sRefSurf As String = ""
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(m_nRawId)
|
|
While nPartId <> GDB_ID.NULL
|
|
If EgtGetInfo(nPartId, "MT", sRefMat) And EgtGetInfo(nPartId, "SRF", sRefSurf) Then Exit While
|
|
nPartId = EgtGetNextPartInRawPart(nPartId)
|
|
End While
|
|
If String.IsNullOrWhiteSpace(sRefMat) And String.IsNullOrWhiteSpace(sRefSurf) Then Return True
|
|
' Verifico materiale e finitura superficiale
|
|
If sMat <> sRefMat Or sSurf <> sRefSurf Then Return False
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function PreInsertOnePart(nId As Integer) As Boolean
|
|
' Se non esiste grezzo o pezzo non in parcheggio, esco
|
|
If m_nRawId = GDB_ID.NULL OrElse not EgtIsPart(nId) Then Return false
|
|
' Sistemazioni per eventuali lati inclinati con tallone
|
|
AdjustPartSideAngleHeel(nId, m_b3Raw.DimZ())
|
|
' Sistemazioni per eventuali lati esterni inclinati e/o offsettati
|
|
EgtCalcFlatPartUpRegion(nId, True)
|
|
EgtCalcFlatPartDownRegion(nId, m_b3Raw.DimZ())
|
|
' Dimensioni del pezzo
|
|
Dim b3Part As New BBox3d
|
|
If Not EgtGetBBoxGlob(nId, GDB_BB.IGNORE_DIM + GDB_BB.IGNORE_TEXT, b3Part) Then Return False
|
|
' Centro del grezzo
|
|
Dim ptRawCenter As Point3d
|
|
If Not EgtGetRawPartCenter(m_nRawId, ptRawCenter) Then Return False
|
|
Dim dRawCenX = ptRawCenter.x - m_b3Raw.Min().x
|
|
Dim dRawCenY = ptRawCenter.y - m_b3Raw.Min().y
|
|
' Inserisco il pezzo nel grezzo, in centro in XY e in alto in Z
|
|
Dim ptP As New Point3d(dRawCenX - 0.5 * b3Part.DimX(), dRawCenY - 0.5 * b3Part.DimY(), m_b3Raw.DimZ() - b3Part.DimZ() + DELTAZ_REG)
|
|
If not EgtAddPartToRawPart(nId, ptP, m_nRawId) Then Return false
|
|
' Aggiungo le lavorazioni standard
|
|
Dim nWarn As Integer = 0
|
|
AddMachinings(nId, nWarn)
|
|
If nWarn = 1 Then m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_SPLITPAGEUC + 11)) ' Lama troppo grande per utilizzo ventosa
|
|
Return true
|
|
End Function
|
|
|
|
Friend Function PreRemoveOnePart(nId As Integer) As Boolean
|
|
' Se non esiste il pezzo, esco
|
|
If nId = GDB_ID.NULL Then Return false
|
|
' Rimuovo le lavorazioni
|
|
EraseMachinings(nId)
|
|
' Elimino eventuali modifiche per lati esterni inclinati e/o offsettati
|
|
EgtCalcFlatPartUpRegion(nId, False)
|
|
EgtCalcFlatPartDownRegion(nId, 0)
|
|
' Eventuale cancellazione solido per taglio da sotto
|
|
EraseSolidForDrip(nId)
|
|
' Parcheggio
|
|
EgtRemovePartFromRawPart(nId)
|
|
EgtSetStatus(nId, GDB_ST.ON_)
|
|
Return true
|
|
End Function
|
|
|
|
Friend Function InsertOnePart(nId As Integer) As Boolean
|
|
' Se il pezzo non è in parcheggio, non si può inserire
|
|
If Not EgtIsPart(nId) Then Return False
|
|
' Metto pezzo in centro grezzo con lavorazioni e sistemazioni varie
|
|
Dim bFit As Boolean = False
|
|
If PreInsertOnePart( nId) Then
|
|
' Eseguo nesting
|
|
If UpdateNestRegions() Then
|
|
Dim bAligned As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_NEST_ALIGNED, 0, m_MainWindow.GetMachIniFile()) <> 0)
|
|
EnableReferenceRegion(bAligned)
|
|
If Not EgtExistsInfo(m_nRawId, KEY_RAWBYPOINTS) Then
|
|
bFit = EgtPackPartInRectangle(nId, m_bReducedCut, True)
|
|
End If
|
|
If Not bFit Then
|
|
bFit = EgtPackPart(nId, m_bReducedCut, True)
|
|
End If
|
|
End If
|
|
End if
|
|
' Gestione risultato nesting
|
|
If bFit Then
|
|
' Eventuale aggiunta solido per taglio da sotto
|
|
UpdateSolidForDrip(nId)
|
|
Return True
|
|
Else
|
|
' Ripristino lo stato originale
|
|
PreRemoveOnePart( nId)
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
Private Function AdjustPartSideAngleHeel(nPartId As Integer, dTh As Double) As Boolean
|
|
' Recupero entità del layer esterno e di quelli interni
|
|
Dim vEnt As New List(Of Integer)
|
|
Dim nEntId As Integer = EgtGetFirstInGroup(EgtGetFirstNameInGroup(nPartId, NAME_OUTLOOP))
|
|
While nEntId <> GDB_ID.NULL
|
|
vEnt.Add(nEntId)
|
|
nEntId = EgtGetNext(nEntId)
|
|
End While
|
|
Dim nLayId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_INLOOP)
|
|
While nLayId <> GDB_ID.NULL
|
|
nEntId = EgtGetFirstInGroup(nLayId)
|
|
While nEntId <> GDB_ID.NULL
|
|
vEnt.Add(nEntId)
|
|
nEntId = EgtGetNext(nEntId)
|
|
End While
|
|
nLayId = EgtGetNextName(nLayId, NAME_INLOOP)
|
|
End While
|
|
' Aggiorno le entità con tallone e quelle con angolo esterno
|
|
Const AGG_DEPTH As Double = 2.0
|
|
For Each nEnt As Integer In vEnt
|
|
' Se aggiornamento vietato, vado oltre
|
|
If EgtExistsInfo( nEnt, INFO_SIDE_FIXED) Then continue for
|
|
' Recupero eventuali tallone ed angolo originale
|
|
Dim dHeel As Double = 0
|
|
Dim dSideAng As Double = 0
|
|
EgtGetInfo(nEnt, INFO_HEEL, dHeel)
|
|
EgtGetInfo(nEnt, INFO_ORIG_SIDE_ANGLE, dSideAng)
|
|
' Se inclinazione con tallone
|
|
If Math.Abs(dSideAng) > EPS_ANG_SMALL And dHeel > 10 * EPS_SMALL Then
|
|
' Inclinazione esterna
|
|
If dSideAng > 0 Then
|
|
' Se tallone inferiore a spessore
|
|
If dHeel < dTh - 10 * EPS_SMALL Then
|
|
EgtSetInfo(nEnt, INFO_SIDE_ANGLE, 0.0)
|
|
EgtSetInfo(nEnt, INFO_SIDE_ANGLE2, dSideAng)
|
|
EgtSetInfo(nEnt, INFO_OFFSET2, -(dTh - dHeel) * Math.Tan(dSideAng * Math.PI / 180))
|
|
EgtSetInfo(nEnt, INFO_DEPTH2, (dTh - dHeel) + AGG_DEPTH)
|
|
' altrimenti, tallone superiore a spessore -> non c'è taglio inclinato
|
|
Else
|
|
EgtSetInfo(nEnt, INFO_SIDE_ANGLE, 0.0)
|
|
EgtSetInfo(nEnt, INFO_SIDE_ANGLE2, 0.0)
|
|
EgtRemoveInfo(nEnt, INFO_OFFSET2)
|
|
EgtRemoveInfo(nEnt, INFO_DEPTH2)
|
|
End If
|
|
' Inclinazione interna
|
|
Else
|
|
' Se tallone inferiore a spessore
|
|
If dHeel < dTh - 10 * EPS_SMALL Then
|
|
EgtSetInfo(nEnt, INFO_OFFSET, dHeel * Math.Tan(-dSideAng * Math.PI / 180))
|
|
EgtSetInfo(nEnt, INFO_SIDE_ANGLE2, 0.0)
|
|
EgtSetInfo(nEnt, INFO_DEPTH2, dHeel + AGG_DEPTH)
|
|
' altrimenti, tallone superiore a spessore -> non c'è taglio inclinato
|
|
Else
|
|
EgtSetInfo(nEnt, INFO_SIDE_ANGLE, 0.0)
|
|
EgtRemoveInfo(nEnt, INFO_OFFSET)
|
|
EgtRemoveInfo(nEnt, INFO_SIDE_ANGLE2)
|
|
EgtRemoveInfo(nEnt, INFO_DEPTH2)
|
|
End If
|
|
End If
|
|
' Se altrimenti inclinazione esterna
|
|
ElseIf dSideAng > EPS_ANG_SMALL Then
|
|
EgtSetInfo(nEnt, INFO_OFFSET, -dTh * Math.Tan(dSideAng * Math.PI / 180))
|
|
End If
|
|
Next
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub StorePartBtn_Click(sender As Object, e As RoutedEventArgs) Handles StorePartBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
' 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)
|
|
' Eventuale notifiche al VeinMatching
|
|
VeinMatching.OnRemovePartFromRaw(nId)
|
|
' Passo al successivo selezionato
|
|
nId = nNextId
|
|
End While
|
|
' Imposto flag posizione pezzi su parcheggio
|
|
m_nPartPos = PART_POS.NONE_TABLE
|
|
' Aggiorno vista
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Friend Function StoreOnePart(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
|
|
' Ripristino lo stato originale
|
|
PreRemoveOnePart( nId)
|
|
' Parcheggio
|
|
PackPartInStore(nId)
|
|
' Aggiusto la posizione in Z
|
|
Dim ptPartMin, ptPartMax As Point3d
|
|
If EgtGetBBoxGlob(nId, GDB_BB.IGNORE_DIM + GDB_BB.IGNORE_TEXT, ptPartMin, ptPartMax) And m_nRawId <> GDB_ID.NULL Then
|
|
EgtMove(nId, New Vector3d(0, 0, m_b3Raw.Max().z - ptPartMax.z), GDB_RT.GLOB)
|
|
End If
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
Friend Function PackPartInStore(nId As Integer) As Boolean
|
|
' Recupero box tavola
|
|
Dim b3Tab As New BBox3d
|
|
If Not EgtGetTableArea(1, b3Tab) Then
|
|
b3Tab.Add(New Point3d(0, 0, 0))
|
|
b3Tab.Add(New Point3d(-3600, -2600, 0))
|
|
End If
|
|
' Parcheggio
|
|
Const STORE_LARGH As Double = 6000
|
|
Const STORE_DIST As Double = 200
|
|
Const STORE_OFFS As Double = 20
|
|
Dim dStXmin As Double = b3Tab.Min().x - 0.5 * (STORE_LARGH - b3Tab.DimX())
|
|
Return EgtPackBox(nId, dStXmin, -INFINITO, dStXmin + STORE_LARGH, b3Tab.Min().y - STORE_DIST, STORE_OFFS, False)
|
|
End Function
|
|
|
|
Private Sub RemovePartBtn_Click(sender As Object, e As RoutedEventArgs) Handles RemovePartBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
' Se non ci sono pezzi selezionati, esco subito
|
|
If EgtGetFirstSelectedObj() = GDB_ID.NULL Then Return
|
|
' Chiedo conferma prima di procedere
|
|
Dim RemovePartWnd As EgtMsgBox = New EgtMsgBox(m_MainWindow, "", EgtMsg(MSG_EGTMSGBOX + 21), EgtMsgBox.Buttons.OK_CANCEL, EgtMsgBox.Icons.NULL)
|
|
If RemovePartWnd.m_nPressedBtn = 0 Then
|
|
Return
|
|
End If
|
|
' Verifico se ci sono pezzi provenienti da liste Csv
|
|
Dim bCsvParts As Boolean = False
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
If EgtExistsInfo(nId, INFO_CSV_PATH) Then
|
|
bCsvParts = True
|
|
Exit While
|
|
End If
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' Chiedo se si vogliono cancellare anche questi pezzi
|
|
Dim bEraseCsvParts As Boolean = False
|
|
If bCsvParts Then
|
|
' Vuoi cancellare anche i pezzi da lista Csv ?
|
|
Dim EraseCsvParts As New EgtMsgBox(m_MainWindow, "", EgtMsg(MSG_EGTMSGBOX + 12),
|
|
EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL)
|
|
Select Case EraseCsvParts.m_nPressedBtn
|
|
Case 0 ' Annulla
|
|
Return
|
|
Case 1 ' Si
|
|
bEraseCsvParts = True
|
|
Case 2 ' No
|
|
bEraseCsvParts = False
|
|
End Select
|
|
End If
|
|
' Ciclo di cancellazione dei pezzi selezionati
|
|
nId = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
' Recupero indice del successivo
|
|
Dim nNextId = EgtGetNextSelectedObj()
|
|
' Se abilitata cancellazione in ogni caso o pezzo non da Csv
|
|
If bEraseCsvParts OrElse Not EgtExistsInfo(nId, INFO_CSV_PATH) Then
|
|
' 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
|
|
' Eventuale notifica al VeinMatching
|
|
VeinMatching.OnRemovePartFromRaw(nId)
|
|
' Rimuovo le lavorazioni
|
|
EraseMachinings(nId)
|
|
'Cancello
|
|
EgtErase(nId)
|
|
End If
|
|
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
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
' Numero dei pezzi in tavola
|
|
Dim nPartTab As Integer = EgtGetPartInRawPartCount(m_nRawId)
|
|
' Se già selezionati in tavola o non ci sono selezionati e pezzi in tavola
|
|
If m_nPartPos = PART_POS.IN_TABLE Or
|
|
(m_nPartPos = PART_POS.NONE_TABLE And nPartTab > 0) Then
|
|
' Seleziono tutti i pezzi in tavola
|
|
Dim nPartId As Integer = EgtGetFirstGroupInGroup(m_nRawId)
|
|
While nPartId <> GDB_ID.NULL
|
|
EgtSelectObj(nPartId)
|
|
VeinMatching.OnSelectPart(nPartId, False)
|
|
nPartId = EgtGetNextGroup(nPartId)
|
|
End While
|
|
' Aggiorno flag
|
|
m_nPartPos = If(EgtGetSelectedObjCount() > 0, PART_POS.IN_TABLE, PART_POS.NONE_TABLE)
|
|
' Altrimenti
|
|
Else
|
|
' Seleziono tutti i pezzi in parcheggio
|
|
Dim nPartId As Integer = EgtGetFirstPart()
|
|
While nPartId <> GDB_ID.NULL
|
|
EgtSelectObj(nPartId)
|
|
VeinMatching.OnSelectPart(nPartId, False)
|
|
nPartId = EgtGetNextPart(nPartId)
|
|
End While
|
|
End If
|
|
' Aggiorno viste
|
|
EgtDraw()
|
|
VeinMatching.Draw()
|
|
End Sub
|
|
|
|
Private Sub DeselectAllBtn_Click(sender As Object, e As RoutedEventArgs) Handles DeselectAllBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
' Eseguo
|
|
EgtDeselectAll()
|
|
' Eventuale notifica al VeinMatching
|
|
VeinMatching.OnDeselectAll()
|
|
' 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 dVal As Double
|
|
If StringToLen(StepMoveTxBx.Text, dVal) Then
|
|
If Not m_bRegister Then
|
|
m_dStep = Math.Max(dVal, 2 * EPS_SMALL)
|
|
Else
|
|
m_dRegStep = Math.Max(dVal, 2 * EPS_SMALL)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub RotationAngleTxBx_EgtClosed(sender As Object, e As EventArgs) Handles RotationAngleTxBx.EgtClosed
|
|
Dim dVal As Double
|
|
If StringToDouble(RotationAngleTxBx.Text, dVal) Then
|
|
If Not m_bRegister Then
|
|
m_dAngStep = Math.Max(dVal, 50 * EPS_ANG_SMALL)
|
|
Else
|
|
m_dRegAngStep = Math.Max(dVal, 50 * EPS_ANG_SMALL)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub NestPage_Unloaded(sender As Object, e As RoutedEventArgs)
|
|
m_bActive = False
|
|
m_MainWindow.m_CadCutPageUC.m_ProjectMgr.VeinMatchingHide()
|
|
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
|
|
|
|
Friend Function VerifyPartsNesting(bReducedCut As Boolean) As Boolean
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' Ciclo su tutti i pezzi in tavola
|
|
Dim nPartId As Integer = EgtGetFirstGroupInGroup(m_nRawId)
|
|
While nPartId <> GDB_ID.NULL
|
|
If Not EgtVerifyPart(nPartId, bReducedCut) Then
|
|
Return False
|
|
End If
|
|
nPartId = EgtGetNextGroup(nPartId)
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function StoreCollisionParts(bReducedCut As Boolean) As Boolean
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' 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) Then
|
|
StoreOnePart(nPartId, True)
|
|
End If
|
|
nPartId = nPrevPartId
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function UpdateNestRegions() As Boolean
|
|
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
|
' Se necessario, creo la regione fuori kerf
|
|
Dim nKerfId As Integer = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, NAME_KERF)
|
|
EgtCreateOutRegion(m_CurrProjPage.m_nRawId, nKerfId)
|
|
' Se necessario, creo la regione di riferimento
|
|
EgtCreateReferenceRegion(m_CurrProjPage.m_nRawId, nKerfId, True)
|
|
' Se necessario, creo le regioni per le aree danneggiate
|
|
Dim nId As Integer = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, NAME_DAMAGED)
|
|
While nId <> GDB_ID.NULL
|
|
EgtCreateDamagedRegion(m_CurrProjPage.m_nRawId, nId)
|
|
nId = EgtGetNextName(nId, NAME_DAMAGED)
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function EnableReferenceRegion(bEnable As Boolean) As Boolean
|
|
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
|
' Recupero identificativo della regione di riferimento
|
|
Dim nRegId As Integer = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, NAME_REF_REG)
|
|
If nRegId = GDB_ID.NULL Then Return False
|
|
' Imposto l'abilitazione voluta
|
|
If bEnable Then
|
|
EgtRemoveInfo(nRegId, KEY_REF_REG_OFF)
|
|
Else
|
|
EgtSetInfo(nRegId, KEY_REF_REG_OFF, 1)
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
End Class
|