Imports EgtUILib Public Class MoveRawPartPage ' Riferimento alla MainWindow Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow) Private WithEvents m_CurrProjPage As CurrentProjectPageUC = Nothing Private m_SplitPage As SplitPageUC = Nothing ' Flag di pagina attiva Private m_bActive As Boolean = False ' Eventuale tavola ausiliaria Private m_nAuxTabId As Integer = GDB_ID.NULL ' Fase corrente Private m_nCurrPhase As Integer = 0 ' Premuto Prev Private m_bPrev As Boolean = False ' Dati movimento Private m_dStep As Double = 0 Private m_dRotation As Double = 0 ' Tipo movimento dei grezzi (manuale o con testa ventosa) Private m_bByHand As Boolean = True ' Gestione movimento manuale perpendicolare Private m_vtDir As New Vector3d ' direzione di movimento Private m_ptMid As New Point3d ' punto medio del taglio Private m_dOrigDist As Double = 0 ' distanza iniziale (spessore taglio) Private m_dCurrDist As Double = 0 ' distanza corrente ' Gestione movimento con ventose Private m_bRemovedRaw As Boolean = False ' flag per rimozione manuale pezzi Private m_RawMoveDataList As New List(Of RawMoveData) ' dati di movimento Private m_bRawWithCups As Boolean = False ' flag per pezzo corrente con ventose Private m_CurrRawOnVacuum As Integer = GDB_ID.NULL Private Sub MoveRawPartPage_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized ' Assegno testi RemovePartBtn.Content = EgtMsg(MSG_MOVERAWPAGEUC + 1) 'Rimuovi ModifyBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 17) 'Modifica ResetBtn.Content = EgtMsg(MSG_NESTPAGEUC + 6) 'Reset End Sub Private Sub MoveRawPartPage_Loaded(sender As Object, e As EventArgs) Handles Me.Loaded m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC m_SplitPage = m_MainWindow.m_CadCutPageUC.m_SplitPage m_bActive = True ' Leggo tipo movimento grezzi m_bByHand = (GetVacuumType() = 0 Or Not m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.AUTO_MANIP) Or (GetPrivateProfileInt(S_RAWMOVE, K_PERPENDICULAR, 0, m_MainWindow.GetIniFile()) <> 0)) ' Se movimento con ventosa, verifico se lama troppo grande If Not m_bByHand And Not m_MainWindow.m_CurrentMachine.IsVacuumMovePossible() Then m_bByHand = True m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_SPLITPAGEUC + 11)) ' Lama troppo grande per utilizzo ventosa End If ' Deseleziono tutto EgtDeselectAll() ' Recupero i tagli allungati prima definiti Dim Cuts(0) As Integer m_SplitPage.GetEnabledCuts(Cuts) ' Fase precedente Dim nPrevPhase As Integer = EgtGetCurrPhase() If Not m_SplitPage.m_bShow Then ' Creo nuova fase, eseguo spezzatura grezzi e vi sposto le lavorazioni Dim vNewRaws As New List(Of Integer) SplitRawParts(nPrevPhase, Cuts, vNewRaws) Else EgtSetCurrPhase(nPrevPhase + 1) HideAllMachinings() End If m_nCurrPhase = EgtGetCurrPhase() ' Se movimento pezzi finale, sistemazioni per tavolo ausiliario If m_SplitPage.m_bOnAuxTab Then ' assegnazione delle info tavola ausiliaria alla dispozione corrente SetAuxTabInCurrDisposition() ' altrimenti, aggiorno visualizzazione Else EgtDraw() End If ' Carico i parametri di movimento m_dStep = GetPrivateProfileDouble(S_RAWMOVE, K_RAWSTEP, 50, m_MainWindow.GetIniFile()) ' Ricavo la lunghezza del baffo di taglio m_dStep = SplitAuto.MaxCuttingMustache(m_dStep) StepMoveTxBx.Text = LenToString(m_dStep, 1) & "+1" m_dRotation = GetPrivateProfileDouble(S_RAWMOVE, K_RAWROTATION, 30, m_MainWindow.GetIniFile()) RotationAngleTxBx.Text = DoubleToString(m_dRotation, 3) ' Se movimento manuale perpendicolare If m_bByHand Then ' Se esiste taglio passante determino direzione di movimento If Cuts.Length() > 0 Then ' recupero taglio di separazione Dim nCutId As Integer = Cuts(0) ' recupero linea di base del taglio EgtSetCurrMachining(nCutId) ' Recupero la prima entità geometrica della lavorazione Dim nEntId, nSub As Integer If EgtGetMachiningGeometry(0, nEntId, nSub) Then ' Direzione perpendicolare al taglio EgtStartVector(nEntId, GDB_ID.ROOT, m_vtDir) m_vtDir.Rotate(Vector3d.Z_AX(), 90) ' Punto medio del taglio EgtMidPoint(nEntId, GDB_ID.ROOT, m_ptMid) ' Recupero il preview della lavorazione Dim nPvId As Integer = GDB_ID.NULL EgtGetInfo(EgtGetFirstNameInGroup(nCutId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId) ' Recupero la larghezza del taglio Dim nGrpId As Integer = EgtGetFirstGroupInGroup(nPvId) If Not EgtGetInfo(nGrpId, "WT", m_dOrigDist) Then m_dOrigDist = 4 End If ' Distanza iniziale m_dCurrDist = 0 End If ' Non dovrebbe mai accadere, ma inizializzo con default Else m_vtDir = Vector3d.Y_AX() m_ptMid = Point3d.ORIG() m_dOrigDist = 0 m_dCurrDist = 0 End If ' Altrimenti movimento con ventose Else m_bRemovedRaw = False m_bRawWithCups = False ' Pulisco lista info per grezzi m_RawMoveDataList.Clear() m_RawMoveDataList.Capacity() = 10 ' Se solo visualizzazione carico flag rimozione manuale e i movimenti già fatti nella fase If m_SplitPage.m_bShow Then Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase) m_bRemovedRaw = GetRemoveByHandInDisposition(nDispId) GetMoveInfoInDisposition(nDispId, m_RawMoveDataList) End If End If ' Aggiorno interfaccia per taglio perpendicolare If m_bByHand Then UpBtn.Visibility = Windows.Visibility.Visible LeftBtn.Visibility = Windows.Visibility.Hidden RightBtn.Visibility = Windows.Visibility.Hidden DownBtn.Visibility = Windows.Visibility.Visible StepMoveTxBx.Visibility = Windows.Visibility.Visible RotateClockwiseBtn.Visibility = Windows.Visibility.Hidden RotateCounterClockwiseBtn.Visibility = Windows.Visibility.Hidden RotationAngle.Visibility = Windows.Visibility.Hidden RemovePartBtn.Visibility = Windows.Visibility.Visible TopLBtn.Visibility = Windows.Visibility.Hidden TopRBtn.Visibility = Windows.Visibility.Hidden BottomLBtn.Visibility = Windows.Visibility.Hidden BottomRBtn.Visibility = Windows.Visibility.Hidden PauseBtn.Visibility = Windows.Visibility.Hidden ResetBtn.Visibility = Windows.Visibility.Hidden ' altrimenti per movimento con ventose ElseIf Not m_SplitPage.m_bOnAuxTab Then UpBtn.Visibility = Windows.Visibility.Visible LeftBtn.Visibility = Windows.Visibility.Visible RightBtn.Visibility = Windows.Visibility.Visible DownBtn.Visibility = Windows.Visibility.Visible StepMoveTxBx.Visibility = Windows.Visibility.Visible RotateClockwiseBtn.Visibility = If(m_MainWindow.m_CurrentMachine.bRawSplMovRotate, Windows.Visibility.Visible, Windows.Visibility.Hidden) RotateCounterClockwiseBtn.Visibility = If(m_MainWindow.m_CurrentMachine.bRawSplMovRotate, Windows.Visibility.Visible, Windows.Visibility.Hidden) RotationAngle.Visibility = If(m_MainWindow.m_CurrentMachine.bRawSplMovRotate, Windows.Visibility.Visible, Windows.Visibility.Hidden) RemovePartBtn.Visibility = Windows.Visibility.Visible TopLBtn.Visibility = Windows.Visibility.Hidden TopRBtn.Visibility = Windows.Visibility.Hidden BottomLBtn.Visibility = Windows.Visibility.Hidden BottomRBtn.Visibility = Windows.Visibility.Hidden PauseBtn.Visibility = Windows.Visibility.Hidden ResetBtn.Visibility = Windows.Visibility.Hidden ' altrimenti per movimento finale dei pezzi Else UpBtn.Visibility = Windows.Visibility.Hidden LeftBtn.Visibility = Windows.Visibility.Hidden RightBtn.Visibility = Windows.Visibility.Hidden DownBtn.Visibility = Windows.Visibility.Hidden StepMoveTxBx.Visibility = Windows.Visibility.Hidden RotateClockwiseBtn.Visibility = Windows.Visibility.Hidden RotateCounterClockwiseBtn.Visibility = Windows.Visibility.Hidden RotationAngle.Visibility = Windows.Visibility.Hidden RemovePartBtn.Visibility = Windows.Visibility.Hidden TopLBtn.Visibility = Windows.Visibility.Visible TopRBtn.Visibility = Windows.Visibility.Visible BottomLBtn.Visibility = Windows.Visibility.Visible BottomRBtn.Visibility = Windows.Visibility.Visible PauseBtn.Visibility = Windows.Visibility.Visible ResetBtn.Visibility = Windows.Visibility.Visible End If ' Abilitazione bottone modifica ModifyBtn.IsEnabled = m_SplitPage.m_bShow ' gestione abilitazione altri bottoni EnableButtons() End Sub Private Sub SetAuxTabInCurrDisposition() ' Se movimento pezzi finale, sistemazioni per tavolo ausiliario m_nAuxTabId = EgtGetTableId(AUX_TAB) ' Visualizzo tavolo ausiliario Dim bOldEnMod As Boolean = EgtGetEnableModified() If bOldEnMod Then EgtDisableModified() EgtSetStatus(m_nAuxTabId, GDB_ST.ON_) If bOldEnMod Then EgtEnableModified() ' Se definizione movimenti If Not m_SplitPage.m_bShow Then ' Area tavolo ausiliario Dim b3AuxTab As New BBox3d EgtGetBBoxGlob(EgtGetFirstNameInGroup(m_nAuxTabId, "A1"), GDB_BB.STANDARD, b3AuxTab) ' Area tavolo principale Dim b3Tab As New BBox3d EgtGetTableArea(1, b3Tab) ' Imposto offset su tavolo principale per includere anche il secondario Dim dOffsXP As Double = Math.Max(b3AuxTab.Max().x - b3Tab.Max().x, 0) Dim dOffsYP As Double = Math.Max(b3AuxTab.Max().y - b3Tab.Max().y, 0) Dim dOffsXM As Double = Math.Max(b3Tab.Min().x - b3AuxTab.Min().x, 0) Dim dOffsYM As Double = Math.Max(b3Tab.Min().y - b3AuxTab.Min().y, 0) EgtSetTableAreaOffset(dOffsXP, dOffsYP, dOffsXM, dOffsYM) End If EgtZoom(ZM.ALL) ' verifico che siano state salvate correttamente le info della tavola di scarico EgtSaveFile("c:\EgtData\OmagCUT\Temp\AuxTab.nge", NGE.BIN) 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 ' Verifico di non essere in modalità solo visualizzazione If m_SplitPage.m_bShow 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 ' Gruppo dei grezzi Dim nRawGroupId = EgtGetParent(EgtGetFirstRawPart()) ' Verifico se selezionato indicativo di grezzo attivo 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 ' Cerco l'identificativo del grezzo cui appartiene Dim nParentId = EgtGetParent(nId) While nParentId <> GDB_ID.NULL And nParentId <> nRawGroupId nId = nParentId nParentId = EgtGetParent(nId) End While ' Se trovato il grezzo If nParentId = nRawGroupId Then Dim nStat As Integer = GDB_ST.ON_ EgtGetStatus(nId, nStat) ' Se il pezzo corrente è selezionato allora lo disattivo -> deposito del pezzo If nStat = GDB_ST.SEL Then EgtSetStatus(nId, GDB_ST.ON_) ' prima di rilasciare il pezzo verifico che non vada in collisione con altri pezzi sulla tavola (evito il controllo se ultima fase) If VerifyCollisionWithOtherRawPart(nId) Then ' mantengo la selezione del pezzo EgtSetStatus(nId, GDB_ST.SEL) m_CurrProjPage.SetErrorMessage("Collisione pezzi") Else ' Se con ventose, le nascondo If Not m_bByHand Then EgtSetStatus(GetVacuumId(), GDB_ST.OFF) End If Else ' verifico che il pezzo precedente possa essere depositato correttamente If VerifyCollisionWithOtherRawPart(m_CurrRawOnVacuum) Then ' mantengo la selezione del pezzo EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL) m_CurrProjPage.SetErrorMessage("Collisione pezzi") EgtDraw() ' esco dal ciclo, prima devo depositare correttamente il pezzo Exit While End If ' salvo l'indice del pezzo correntemente attaccato alle ventose m_CurrRawOnVacuum = nId ' Deseleziono tutto e abilito la selezione del pezzo corrente EgtDeselectAll() EgtSetStatus(nId, GDB_ST.SEL) ' Se con ventose, le posiziono sul grezzo If Not m_bByHand Then Dim rmData As New RawMoveData ' inizializzo i dati del grezzo per il cacolo del peso Dim MaxSinglePlugger As Double = 250 MaxSinglePlugger = GetPrivateProfileDouble(S_MACH_RAWMOVE, K_MACH_WEIGHT_SINGLEPLUGGER, MaxSinglePlugger, m_MainWindow.GetMachIniFile()) Dim MaxDoublePlugger As Double = 750 MaxDoublePlugger = GetPrivateProfileDouble(S_MACH_RAWMOVE, K_MACH_WEIGHT_DOUBLEPLUGGER, MaxDoublePlugger, m_MainWindow.GetMachIniFile()) Dim AverageDensity As Double = 2700 AverageDensity = GetPrivateProfileDouble(S_MATERIALS, K_AVERAGEDENSITY, AverageDensity, m_MainWindow.GetMachIniFile()) VacuumCups.GetWeightInformation(AverageDensity, MaxSinglePlugger, MaxDoublePlugger) VacuumCups.GetRotationForExtraStrokeY(GetPrivateProfileInt(S_MACH_RAWMOVE, K_MACH_ROTATEVACUUMFOREXTRASTROKEY, 0, m_MainWindow.GetMachIniFile()) <> 0) VacuumCups.GetRotationForExtraStrokeX(GetPrivateProfileInt(S_MACH_RAWMOVE, K_MACH_ROTATEVACUUMFOREXTRASTROKEX, 0, m_MainWindow.GetMachIniFile()) <> 0) If PutVacuumCupsOnRaw(nId, rmData) Then ' Visualizzo le ventose EgtSetStatus(GetVacuumId(), GDB_ST.ON_) ' Aggiorno i dati AddRawMoveData(rmData, m_RawMoveDataList) m_bRawWithCups = True ' Reset eventuale messaggio m_CurrProjPage.ClearMessage() Else ' nascondo la visualizzazione delle ventose EgtSetStatus(GetVacuumId(), GDB_ST.OFF) ' Aggiorno i dati m_bRawWithCups = False If VacuumCups.bOverWeight Then m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_MOVERAWPAGEUC + 4)) 'Pezzo troppo pesante : non si può muovere ElseIf VacuumCups.bExtraStroke Then m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_MOVERAWPAGEUC + 5)) 'Pezzo oltre le corse : non si può muovere Else ' Messaggio di avvertimento m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2)) 'Pezzo troppo piccolo : non si può muovere End If End If End If End If EgtDraw() Exit While End If nId = EgtGetNextObjInSelWin() End While ' clicco su un oggetto che non è un grezzo -> verifico che il pezzo precedente possa essere depositato correttamente If VerifyCollisionWithOtherRawPart(m_CurrRawOnVacuum) Then ' mantengo la selezione del pezzo EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL) m_CurrProjPage.SetErrorMessage("Collisione pezzi") EgtDraw() End If End Sub ' Veririfica che il grezzo non entri in colliosione con altri pezzi Private Function VerifyCollisionWithOtherRawPart(nIdOnVacumm As Integer) As Boolean ' se movimento su tavola di scarico non eseguo il controllo (evito di segnalre errori per pezzi ricavati interni al grezzo...) If m_SplitPage.m_bOnAuxTab Then Return False If nIdOnVacumm = GDB_ID.NULL Then Return False ' Creo gruppo temporaneo in cui generare le superfici per la veririfica di collisione Dim m_nTempId As Integer = EgtCreateGroup(GDB_ID.ROOT) If m_nTempId = GDB_ID.NULL Then Return False EgtSetName(m_nTempId, "RawTemp") Dim nIdActualRawOutLine As Integer = EgtGetFirstNameInGroup(nIdOnVacumm, "RawOutline") Dim ActualRawFlatRegion As Integer = EgtCreateSurfFlatRegion(m_nTempId, nIdActualRawOutLine) Dim nCurrPhase As Integer = EgtGetCurrPhase() Dim nRawGroupId = EgtGetParent(EgtGetFirstRawPart()) Dim nIdRaw As Integer = EgtGetFirstRawPart() ' ciclo su tutti i grezzi per veririficare eventuali collisioni While nIdRaw <> GDB_ID.NULL ' verifico la fase del grezzo If EgtVerifyRawPartCurrPhase(nIdRaw) And nIdOnVacumm <> nIdRaw Then ' recupero il contorno del pezzo Dim nIdRawOutLine As Integer = EgtGetFirstNameInGroup(nIdRaw, "RawOutline") Dim nIdRawFlatRegion As Integer = EgtCreateSurfFlatRegion(m_nTempId, nIdRawOutLine) If EgtSurfFrIntersect(nIdRawFlatRegion, ActualRawFlatRegion) Then If EgtExistsObj(nIdRawFlatRegion) Then EgtErase(m_nTempId) ' esiste una intersezione delle superfici Return True End If End If End If nIdRaw = EgtGetNextRawPart(nIdRaw) End While EgtErase(m_nTempId) Return False End Function #Region "Move Up/Down/Left/Right" Private Sub UpBtn_Click(sender As Object, e As RoutedEventArgs) Handles UpBtn.Click Dim nRawId As Integer = EgtGetFirstSelectedObj() While nRawId <> GDB_ID.NULL ' Se movimento perpendicolare, è allontanamento If m_bByHand Then ' Recupero il centro del grezzo Dim ptRawCen As Point3d EgtGetRawPartCenter(nRawId, ptRawCen) ' Calcolo la distanza di movimento Dim dMove As Double = m_dStep If m_dCurrDist < EPS_SMALL Then dMove -= m_dOrigDist End If If (m_vtDir * (ptRawCen - m_ptMid) < 0) Then dMove *= -1 ' Eseguo il movimento If EgtMoveRawPart(nRawId, dMove * m_vtDir) Then m_dCurrDist += Math.Abs(dMove) End If ' Altrimenti movimento Y + Else If m_bRawWithCups Then Dim vtMove As New Vector3d(0, m_dStep, 0) ' ----------- INIZIO verifica di essere entro i limiti macchina ----------- m_CurrProjPage.ClearMessage() VerifyReleasdPositionIsValid(vtMove) ' ----------- FINE verifica di essere entro i limiti macchina ----------- If EgtMoveRawPart(nRawId, vtMove) Then EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB) AddRawMoveData(nRawId, vtMove, m_RawMoveDataList) Else VacuumCups.ptStartPointLift.y -= vtMove.y End If Else m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2)) 'Pezzo troppo piccolo : non si può muovere End If End If nRawId = EgtGetNextSelectedObj() End While EgtDraw() End Sub Private Sub DownBtn_Click(sender As Object, e As RoutedEventArgs) Handles DownBtn.Click Dim nRawId As Integer = EgtGetFirstSelectedObj() While nRawId <> GDB_ID.NULL ' Se movimento perpendicolare, è avvicinamento If m_bByHand Then ' Se sono già a contatto, non devo fare alcunché If m_dCurrDist < EPS_SMALL Then Return ' Recupero il centro del grezzo Dim ptRawCen As Point3d EgtGetRawPartCenter(nRawId, ptRawCen) ' Calcolo la distanza di movimento Dim dMove As Double = m_dStep If m_dCurrDist < m_dStep Then dMove -= m_dOrigDist End If If (m_vtDir * (ptRawCen - m_ptMid) > 0) Then dMove *= -1 ' Eseguo il movimento If EgtMoveRawPart(nRawId, dMove * m_vtDir) Then m_dCurrDist -= Math.Abs(dMove) End If ' Altrimenti movimento Y - Else If m_bRawWithCups Then Dim vtMove As New Vector3d(0, -m_dStep, 0) ' ----------- INIZIO verifica di essere entro i limiti macchina ----------- m_CurrProjPage.ClearMessage() VerifyReleasdPositionIsValid(vtMove) ' ----------- FINE verifica di essere entro i limiti macchina ----------- If EgtMoveRawPart(nRawId, vtMove) Then EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB) AddRawMoveData(nRawId, vtMove, m_RawMoveDataList) Else VacuumCups.ptStartPointLift.y -= vtMove.y End If Else m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2)) 'Pezzo troppo piccolo : non si può muovere End If End If nRawId = EgtGetNextSelectedObj() End While EgtDraw() End Sub Private Sub RightBtn_Click(sender As Object, e As RoutedEventArgs) Handles RightBtn.Click ' Solo movimento con ventose If m_bByHand Then Return Dim nRawId As Integer = EgtGetFirstSelectedObj() While nRawId <> GDB_ID.NULL If m_bRawWithCups Then Dim vtMove As New Vector3d(m_dStep, 0, 0) ' ----------- INIZIO verifica di essere entro i limiti macchina ----------- m_CurrProjPage.ClearMessage() VerifyReleasdPositionIsValid(vtMove) ' ----------- FINE verifica di essere entro i limiti macchina ----------- If EgtMoveRawPart(nRawId, vtMove) Then EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB) AddRawMoveData(nRawId, vtMove, m_RawMoveDataList) Else VacuumCups.ptStartPointLift.x -= vtMove.x End If Else m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2)) 'Pezzo troppo piccolo : non si può muovere End If nRawId = EgtGetNextSelectedObj() End While EgtDraw() End Sub Private Sub LeftBtn_Click(sender As Object, e As RoutedEventArgs) Handles LeftBtn.Click ' Solo movimento con ventose If m_bByHand Then Return Dim nRawId As Integer = EgtGetFirstSelectedObj() While nRawId <> GDB_ID.NULL If m_bRawWithCups Then Dim vtMove As New Vector3d(-m_dStep, 0, 0) ' ----------- INIZIO verifica di essere entro i limiti macchina ----------- m_CurrProjPage.ClearMessage() VerifyReleasdPositionIsValid(vtMove) ' ----------- FINE verifica di essere entro i limiti macchina ----------- If EgtMoveRawPart(nRawId, vtMove) Then EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB) AddRawMoveData(nRawId, vtMove, m_RawMoveDataList) Else VacuumCups.ptStartPointLift.x -= vtMove.x End If Else m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2)) 'Pezzo troppo piccolo : non si può muovere End If nRawId = EgtGetNextSelectedObj() End While EgtDraw() End Sub #End Region 'Move Up/Down/Left/Right ' verifica che la poszione da raggiungere sia nei limiti delle corse Private Function VerifyReleasdPositionIsValid(ByRef vtMove As Vector3d) As Boolean Dim bOk As Boolean = True ' determino il punto finale dello spostamento Dim ptEndPointLift As Point3d = VacuumCups.ptStartPointLift ptEndPointLift.x += vtMove.x ptEndPointLift.y += vtMove.y Dim sInfo As String = String.Empty Select Case VacuumCups.VerifyOutOfStrokes(ptEndPointLift, VacuumCups.dDegRotStartAng) Case 1 ' extra corsa sulla x-: devo ridurre del valore di extra corsa EgtGetOutstrokeInfo(sInfo) m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo) 'Extracorsa ... ptEndPointLift.x -= vtMove.x Dim dMaxMove As Double = VacuumCups.GetExtraStrokeValue(sInfo) If Math.Abs(dMaxMove - vtMove.x) <= EPS_SMALL * 100 Then vtMove.x = 0 Else vtMove.x -= dMaxMove - EPS_SMALL * 100 End If ptEndPointLift.x += vtMove.x bOk = False Case 2 ' extra corsa sulla x+: devo ridurre del valore di extra corsa EgtGetOutstrokeInfo(sInfo) m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo) 'Extracorsa ... ptEndPointLift.x -= vtMove.x Dim dMaxMove As Double = VacuumCups.GetExtraStrokeValue(sInfo) If Math.Abs(dMaxMove - vtMove.x) <= EPS_SMALL * 100 Then vtMove.x = 0 Else vtMove.x -= dMaxMove + EPS_SMALL * 100 End If ptEndPointLift.x += vtMove.x bOk = False Case 4 ' extra corsa sulla y- EgtGetOutstrokeInfo(sInfo) m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo) 'Extracorsa ... ptEndPointLift.y -= vtMove.y Dim dMaxMove As Double = VacuumCups.GetExtraStrokeValue(sInfo) If Math.Abs(dMaxMove - vtMove.y) <= EPS_SMALL * 100 Then vtMove.y = 0 Else vtMove.y -= dMaxMove - EPS_SMALL * 100 End If ptEndPointLift.y += vtMove.y bOk = False Case 8 ' extra corsa sulla y+ EgtGetOutstrokeInfo(sInfo) m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo) 'Extracorsa ... ptEndPointLift.y -= vtMove.y Dim dMaxMove As Double = VacuumCups.GetExtraStrokeValue(sInfo) If Math.Abs(dMaxMove - vtMove.y) <= EPS_SMALL * 100 Then vtMove.y = 0 Else vtMove.y -= dMaxMove + EPS_SMALL * 100 End If ptEndPointLift.y += vtMove.y bOk = False End Select ' il movimento del pezzo è accettabile, aggiorno le posizione per la verifica dello step successivo VacuumCups.ptStartPointLift = ptEndPointLift Return bOk End Function #Region "Rotate CounterClockWise/ClockWise" Private Sub RotateCounterClockwiseBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateCounterClockwiseBtn.Click ' Solo movimento con ventose If m_bByHand Then Return Dim nRawId As Integer = EgtGetFirstSelectedObj() While nRawId <> GDB_ID.NULL If m_bRawWithCups Then Dim dAng As Double = m_dRotation ' ----------- INIZIO verifica di essere entro i limiti macchina ----------- ' Recupero il centro del grezzo Dim ptRawCen As Point3d EgtGetRawPartCenter(nRawId, ptRawCen) m_CurrProjPage.ClearMessage() VerifyReleasdAngleIsValid(dAng, ptRawCen) ' ----------- FINE verifica di essere entro i limiti macchina ----------- If EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAng) Then '' Recupero il centro del grezzo 'Dim ptRawCen As Point3d 'EgtGetRawPartCenter(nRawId, ptRawCen) ' Eseguo la rotazione della ventosa EgtRotate(GetVacuumId(), ptRawCen, Vector3d.Z_AX(), dAng, GDB_RT.GLOB) ' Memorizzo AddRawMoveData(nRawId, dAng, m_RawMoveDataList) Else VacuumCups.ptStartPointLift.Rotate(ptRawCen, Vector3d.Z_AX(), dAng) VacuumCups.dDegRotStartAng -= dAng End If Else m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2)) 'Pezzo troppo piccolo : non si può muovere End If nRawId = EgtGetNextSelectedObj() End While EgtDraw() End Sub Private Sub RotateClockwiseBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateClockwiseBtn.Click ' Solo movimento con ventose If m_bByHand Then Return Dim nRawId As Integer = EgtGetFirstSelectedObj() While nRawId <> GDB_ID.NULL If m_bRawWithCups Then Dim dAng As Double = -m_dRotation ' ----------- INIZIO verifica di essere entro i limiti macchina ----------- ' Recupero il centro del grezzo Dim ptRawCen As Point3d EgtGetRawPartCenter(nRawId, ptRawCen) m_CurrProjPage.ClearMessage() VerifyReleasdAngleIsValid(dAng, ptRawCen) ' ----------- FINE verifica di essere entro i limiti macchina ----------- If EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAng) Then '' Recupero il centro del grezzo 'Dim ptRawCen As Point3d 'EgtGetRawPartCenter(nRawId, ptRawCen) ' Eseguo la rotazione della ventosa EgtRotate(GetVacuumId(), ptRawCen, Vector3d.Z_AX(), dAng, GDB_RT.GLOB) ' Memorizzo AddRawMoveData(nRawId, dAng, m_RawMoveDataList) Else VacuumCups.ptStartPointLift.Rotate(ptRawCen, Vector3d.Z_AX(), dAng) VacuumCups.dDegRotStartAng -= dAng End If Else m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2)) 'Pezzo troppo piccolo : non si può muovere End If nRawId = EgtGetNextSelectedObj() End While EgtDraw() End Sub #End Region ' Rotate CounterClockWise/ClockWise ' verifica che la rotazione da raggiungere sia nei limiti delle corse Private Function VerifyReleasdAngleIsValid(ByRef dAngDeg As Double, ByVal ptCenter As Point3d) As Boolean Dim bOk As Boolean = True ' determino il punto finale dello spostamento Dim ptEndPointLift As Point3d = VacuumCups.ptStartPointLift Dim dDegRotEndAng As Double = VacuumCups.dDegRotStartAng + dAngDeg ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), dAngDeg) Dim sInfo As String = String.Empty Select Case VacuumCups.VerifyOutOfStrokes(ptEndPointLift, dDegRotEndAng) Case 16 ' extra corsa sulla c- EgtGetOutstrokeInfo(sInfo) m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo) 'Extracorsa ... ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), -dAngDeg) dDegRotEndAng -= dAngDeg dAngDeg += VacuumCups.GetExtraStrokeValue(sInfo) + EPS_SMALL dDegRotEndAng += dAngDeg ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), dAngDeg) bOk = False Case 34 ' extra corsa sulla c+ EgtGetOutstrokeInfo(sInfo) m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo) 'Extracorsa ... ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), -dAngDeg) dDegRotEndAng -= dAngDeg dAngDeg -= VacuumCups.GetExtraStrokeValue(sInfo) + EPS_SMALL dDegRotEndAng += dAngDeg ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), dAngDeg) bOk = False End Select ' il movimento del pezzo è accettabile, aggiorno le posizione per la verifica dello step successivo VacuumCups.ptStartPointLift = ptEndPointLift VacuumCups.dDegRotStartAng = dDegRotEndAng Return bOk End Function Private Sub RemovePartBtn_Click(sender As Object, e As RoutedEventArgs) Handles RemovePartBtn.Click Dim nRawId As Integer = EgtGetFirstSelectedObj() While nRawId <> GDB_ID.NULL EgtRemoveRawPartFromCurrPhase(nRawId) ' Se con ventose If Not m_bByHand Then m_bRemovedRaw = True ' rimuovo eventuali indicazioni di movimento RemoveRawMoveData(nRawId, m_RawMoveDataList) ' nascondo le ventose EgtSetStatus(GetVacuumId(), GDB_ST.OFF) ' Reset eventuale messaggio m_CurrProjPage.ClearMessage() End If nRawId = EgtGetFirstSelectedObj() End While 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 dRotation As Double If StringToDouble(RotationAngleTxBx.Text, dRotation) Then m_dRotation = Math.Max(dRotation, 2 * EPS_ANG_SMALL) End If End Sub Private Sub TopLBtn_Click(sender As Object, e As RoutedEventArgs) Handles TopLBtn.Click MoveOnRef("REF4", MCH_CR.TL) End Sub Private Sub TopRBtn_Click(sender As Object, e As RoutedEventArgs) Handles TopRBtn.Click MoveOnRef("REF3", MCH_CR.TR) End Sub Private Sub BottomLBtn_Click(sender As Object, e As RoutedEventArgs) Handles BottomLBtn.Click MoveOnRef("REF1", MCH_CR.BL) End Sub Private Sub BottomRBtn_Click(sender As Object, e As RoutedEventArgs) Handles BottomRBtn.Click MoveOnRef("REF2", MCH_CR.BR) End Sub ' posiziono il pezzo sulla tavola Private Sub MoveOnRef(sRef As String, nCorn As Integer) ' Recupero il primo grezzo selezionato Dim nRawId As Integer = EgtGetFirstSelectedObj() If nRawId = GDB_ID.NULL Then Return ' Recupero la posizione e il tipo corner del riferimento TL (4) Dim nRefId As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(m_nAuxTabId, "SOLID"), sRef) If nRefId = GDB_ID.NULL Then Return Dim ptRef As Point3d If Not EgtGetInfo(nRefId, "Pos", ptRef) Then Return Dim sCorn As String = "" EgtGetInfo( nRefId, "COR", sCorn) Select sCorn Case "TL" nCorn = MCH_CR.TL Case "TR" nCorn = MCH_CR.TR Case "BL" nCorn = MCH_CR.BL Case "BR" nCorn = MCH_CR.BR End Select ' Recupero il centro del grezzo Dim ptRawCen As Point3d EgtGetRawPartCenter(nRawId, ptRawCen) ' Sposto il grezzo in battuta sul corner Dim dAngRaw As Double = 0 Dim AngRotList As New List(Of Double) ' ricavo l'angolo di posizionamento del grezzo/pezzo sulla tavola If Not DispositionRawOnTable(nRawId, dAngRaw, AngRotList) Then Return ' provo a verificare di poter depositare il pezzo (senza applicare delle rotazioni) If Not EgtMoveToCornerRawPart(nRawId, ptRef, nCorn) Then ' se sono impostati degli step di rotazione If AngRotList.Count > 0 Then Dim bOkRotate As Boolean = False ' allora provo a ruotare il pezzo nel verso di rotazione della ventosa For Each AngStep As Double In AngRotList If EgtRotateRawPart(nRawId, Vector3d.Z_AX(), -AngStep) Then If Not EgtMoveToCornerRawPart(nRawId, ptRef, nCorn) Then ' riposiziono il pezzo come era prima EgtRotateRawPart(nRawId, Vector3d.Z_AX(), AngStep) Else bOkRotate = True ' salvo l'angolo di deposito utilizzato dAngRaw = -AngStep Exit For End If End If Next If Not bOkRotate Then Return Else If EgtRotateRawPart(nRawId, Vector3d.Z_AX(), -dAngRaw) Then If Not EgtMoveToCornerRawPart(nRawId, ptRef, nCorn) Then ' riposiziono il pezzo come era prima EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAngRaw) Return End If Else Return End If End If Else ' significa che già il primo posizionamento è andato bene, quindi non devo impostare nessuna rotazione dAngRaw = 0 End If ' Verifico non interferisca con altri grezzi Dim bRawOk As Boolean = True Dim b3Raw As New BBox3d EgtGetRawPartBBox(nRawId, b3Raw) Dim nOtherRaw As Integer = EgtGetFirstRawPart() While nOtherRaw <> GDB_ID.NULL If nOtherRaw <> nRawId AndAlso EgtVerifyRawPartCurrPhase(nOtherRaw) Then Dim b3OtherRaw As New BBox3d EgtGetRawPartBBox(nOtherRaw, b3OtherRaw) If b3Raw.OverlapsXY(b3OtherRaw) Then bRawOk = False Exit While End If End If nOtherRaw = EgtGetNextRawPart(nOtherRaw) End While ' Determino il movimento effettuato Dim ptNewRawCen As Point3d EgtGetRawPartCenter(nRawId, ptNewRawCen) ' Se tutto bene, aggiorno lista movimenti If bRawOk Then AddRawMoveData(nRawId, ptNewRawCen - ptRawCen, m_RawMoveDataList) If dAngRaw <> 0 Then AddRawMoveData(nRawId, -dAngRaw, m_RawMoveDataList) ' altrimenti annullo il movimento Else EgtMoveRawPart(nRawId, ptRawCen - ptNewRawCen) EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAngRaw) m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_MOVERAWPAGEUC + 3)) ' Posizione scelta già occupata End If ' Disabilito pezzo e nascondo le ventose EgtSetStatus(nRawId, GDB_ST.ON_) EgtSetStatus(GetVacuumId(), GDB_ST.OFF) EgtDraw() End Sub ' calcolo la poszione del Pezzo/Grezzo presente sulla tavola Private Function DispositionRawOnTable(nRawId As Integer, ByRef dMyAngH As Double, ByRef AngVacList As List(Of Double)) As Boolean Dim nPartId As Integer If EgtVerifyRawPartCurrPhase(nRawId) Then nPartId = EgtGetFirstPartInRawPart(nRawId) Dim nTempPart As Integer = nPartId While nTempPart <> GDB_ID.NULL nTempPart = EgtGetNextPartInRawPart(nPartId) ' significa che il grezzo contiene più di un pezzo If nTempPart <> GDB_ID.NULL Then Return False End While End If ' Verifico sia veramente un pezzo If EgtGetRawPartFromPart(nPartId) = GDB_ID.NULL Then Return False ' Recupero la regione del pezzo Dim nGrpRegId As Integer = EgtGetFirstNameInGroup(nPartId, "Region") Dim nRegId As Integer = EgtGetFirstInGroup(nGrpRegId) While nRegId <> GDB_ID.NULL If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then Exit While nRegId = EgtGetNext(nRegId) End While If nRegId = GDB_ID.NULL Then Return False ' recupero il contorno del pezzo Dim nIdCurve As Integer = GetRegionOutLoop(nRegId, nGrpRegId) If nIdCurve = GDB_ID.NULL Then Return False ' recupero il versore Dim frFrame As New Frame3d ' recupero le dimensioni del minimo rettangolo Dim dLengthX As Double = 0 Dim dLengthY As Double = 0 EgtCurveMinAreaRectangleXY(nIdCurve, GDB_ID.ROOT, frFrame, dLengthX, dLengthY) ' recupero la direzione del lato più lungo (versore X) Dim vtDir As Vector3d = frFrame.VersX() ' recupero le coordinate sferiche Dim dMyLen, dMyAngV As Double vtDir.ToSpherical(dMyLen, dMyAngV, dMyAngH) ' mi riconduco sempre agli angoli If dMyAngH >= 180 Then dMyAngH = dMyAngH - 180 End If If Math.Abs(dMyAngH - 180) < EPS_ANG_SMALL Then dMyAngH = 0 End If ' Recupero l'asse rotante della testa ventosa Dim nRotAxId As Integer = EgtGetParent(EgtGetHeadId(VACUUM_HEAD)) ' Verifico se contiene info con STEPS Dim sSteps As String = "" If Not EgtGetInfo(nRotAxId, KEY_ROTVAC_STEPS, sSteps) Then Return True ' Leggo gli step previsti Dim vStep() As String = sSteps.Split(",".ToCharArray) For Each sStep As String In vStep Dim dStep As Double = 0 If StringToDouble(sStep, dStep) Then AngVacList.Add(dStep) End If Next Return True End Function Private Sub PauseBtn_Click(sender As Object, e As RoutedEventArgs) Handles PauseBtn.Click ' verifico che ci sia un elemto selezionato Dim nRawIdSlected As Integer = EgtGetFirstSelectedObj() 'If nRawIdSlected = GDB_ID.NULL Then Return If m_RawMoveDataList.Count = 0 Then Return ' recupero disposizione fase corrente Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase) ' aggiungo al gruppo disposizione dei sottogruppi con i dati di movimento dei grezzi spostati SaveMoveInfoInDisposition(nDispId, m_RawMoveDataList) ' imposto eventuale movimento pezzi su tavola ausiliaria SaveMovePartsOnAuxTable(nDispId, m_SplitPage.m_bOnAuxTab) ' Eseguo calcolo speciale dei movimenti SpecialApplyDisposition(nDispId, True, Not m_SplitPage.m_bOnAuxTab) ' Creo nuova fase Dim nNewPhase As Integer = EgtAddPhase() ' Eseguo eventuali spezzature dei grezzi e vi sposto i pezzi (i grezzi devono essere sempre copiati per Registrazione con rotazione) Dim nRawId As Integer = EgtGetFirstRawPart() While nRawId <> GDB_ID.NULL '' se il grezzo è presente nella fase precedente e non è quello selezionato allora procedo a creare una copia nella nuova fase 'If EgtVerifyRawPartPhase(nRawId, nNewPhase - 1) And nRawId <> nRawIdSlected Then ' EgtKeepRawPart(nRawId, nNewPhase - 1) 'End If ' se il grezzo è presente nella fase precedente e non è quello selezionato allora procedo a creare una copia nella nuova fase If EgtVerifyRawPartPhase(nRawId, nNewPhase - 1) Then Dim bKeepRawPart As Boolean = True For Each RawOnAuxTabData As RawMoveData In m_RawMoveDataList If nRawId = RawOnAuxTabData.m_nId Then bKeepRawPart = False Exit For End If Next If bKeepRawPart Then EgtKeepRawPart(nRawId, nNewPhase - 1) End If ' passo al successivo grezzo nRawId = EgtGetNextRawPart(nRawId) End While Dim nCurrDisposition As Integer = EgtGetPhaseDisposition(nNewPhase) SetPause(nCurrDisposition) ' EgtSetStatus(nRawIdSlected, GDB_ST.OFF) EgtSetStatus(GetVacuumId(), GDB_ST.OFF) EgtSetCurrPhase(nNewPhase) SetAuxTabInCurrDisposition() ' ripulisco la lista degli spostamenti m_RawMoveDataList.Clear() ' aggiorno la fase corrente m_nCurrPhase = EgtGetCurrPhase() End Sub Private Sub ResetBtn_Click(sender As Object, e As RoutedEventArgs) Handles ResetBtn.Click ' Recupero il primo grezzo selezionato Dim nRawId As Integer = EgtGetFirstSelectedObj() If nRawId = GDB_ID.NULL Then Return ' Lo riporto nella posizione originale Dim nInd As Integer = FindRawMoveData(nRawId, m_RawMoveDataList) If nInd = -1 Then Return Dim vtMove As Vector3d = -m_RawMoveDataList(nInd).m_vtRawMove Dim dAngRaw As Double = -m_RawMoveDataList(nInd).m_dRawAngRotDeg EgtMoveRawPart(nRawId, vtMove) EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAngRaw) AddRawMoveData(nRawId, vtMove, m_RawMoveDataList) RemoveRawMoveData(nRawId, m_RawMoveDataList) ' Disabilito pezzo e nascondo le ventose EgtSetStatus(nRawId, GDB_ST.ON_) EgtSetStatus(GetVacuumId(), GDB_ST.OFF) EgtDraw() End Sub Private Sub PrevBtn_Click(sender As Object, e As RoutedEventArgs) Handles PrevBtn.Click ' verifico che il pezzo sia depositabile If VerifyCollisionWithOtherRawPart(m_CurrRawOnVacuum) Then ' mantengo la selezione del pezzo EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL) m_CurrProjPage.SetErrorMessage("Collisione pezzi") EgtDraw() ' non cambio pagina Return End If ' resetto l'inidice del pezzo da mnovimentare m_CurrRawOnVacuum = GDB_ID.NULL ' Deseleziono tutto EgtDeselectAll() ' Torno alla fase precedente m_bPrev = True ' Passo alla pagina delle spezzature m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Remove(Me) m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Add(m_SplitPage) m_MainWindow.m_CadCutPageUC.m_CadCutMode = CadCutPageUC.CadCutModes.Split End Sub Private Sub NextBtn_Click(sender As Object, e As RoutedEventArgs) Handles NextBtn.Click ' verifico che il pezzo sia depositabile If VerifyCollisionWithOtherRawPart(m_CurrRawOnVacuum) Then ' mantengo la selezione del pezzo EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL) m_CurrProjPage.SetErrorMessage("Collisione pezzi") EgtDraw() ' non cambio pagina Return End If ' resetto l'inidice del pezzo da mnovimentare m_CurrRawOnVacuum = GDB_ID.NULL ' Deseleziono tutto EgtDeselectAll() ' Passo alla pagina delle spezzature m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Remove(Me) m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Add(m_SplitPage) m_MainWindow.m_CadCutPageUC.m_CadCutMode = CadCutPageUC.CadCutModes.Split End Sub Private Sub ModifyBtn_Click(sender As Object, e As RoutedEventArgs) Handles ModifyBtn.Click ' Dichiaro uscita da sola visualizzazione m_SplitPage.m_bShow = False ' Elimino le fasi successive alla corrente While EgtGetPhaseCount() > m_nCurrPhase RemoveLastPhase() End While ' Svuoto gruppo disposizione Dim nDispId = EgtGetPhaseDisposition(m_nCurrPhase) EgtEmptyGroup(nDispId) ' Disabilito le lavorazioni della fase corrente e ne nascondo i percorsi utensile Dim nOpeId As Integer = EgtGetNextOperation(nDispId) While nOpeId <> GDB_ID.NULL EgtSetOperationMode(nOpeId, False) EgtSetInfo(nOpeId, INFO_MCH_USER_OFF, True) EgtSetOperationStatus(nOpeId, False) nOpeId = EgtGetNextOperation(nOpeId) End While ' Preparo la lista delle lavorazioni Dim MachiningList As New List(Of SplitMach) CalculateSplitMachList(m_nCurrPhase, MachiningList) ' Aggiorno visualizzazione delle lavorazioni For nI As Integer = 0 To MachiningList.Count() - 1 ' sistemo colore ColorMachining(MachiningList(nI)) Next ' Visualizzo solo anteprime di lavorazioni della fase ShowOnePhaseMachiningPreview(m_nCurrPhase) EgtDraw() ' disabilito bottone ModifyBtn.IsEnabled = False ' gestione abilitazione altri bottoni EnableButtons() End Sub Private Sub EnableButtons() UpBtn.IsEnabled = Not m_SplitPage.m_bShow LeftBtn.IsEnabled = Not m_SplitPage.m_bShow RightBtn.IsEnabled = Not m_SplitPage.m_bShow DownBtn.IsEnabled = Not m_SplitPage.m_bShow StepMoveTxBx.IsEnabled = Not m_SplitPage.m_bShow RotateClockwiseBtn.IsEnabled = Not m_SplitPage.m_bShow RotateCounterClockwiseBtn.IsEnabled = Not m_SplitPage.m_bShow RotationAngle.IsEnabled = Not m_SplitPage.m_bShow RemovePartBtn.IsEnabled = Not m_SplitPage.m_bShow TopLBtn.IsEnabled = Not m_SplitPage.m_bShow TopRBtn.IsEnabled = Not m_SplitPage.m_bShow BottomLBtn.IsEnabled = Not m_SplitPage.m_bShow BottomRBtn.IsEnabled = Not m_SplitPage.m_bShow PauseBtn.IsEnabled = Not m_SplitPage.m_bShow ResetBtn.IsEnabled = Not m_SplitPage.m_bShow NextBtn.IsEnabled = Not m_SplitPage.m_bOnAuxTab End Sub Private Sub MoveRawPartPage_Unloaded(sender As Object, e As EventArgs) Handles Me.Unloaded ' verifico che la fase corrente non sia vuota Dim nLastDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase) If EgtIsOperationEmpty(nLastDispId) And m_SplitPage.m_bOnAuxTab And m_RawMoveDataList.Count = 0 Then EgtErase(nLastDispId) End If ' Se movimento con ventose If Not m_bByHand Then ' nascondo le ventose EgtDisableModified() EgtSetStatus(GetVacuumId(), GDB_ST.OFF) EgtEnableModified() ' se non solo visualizzazione If Not m_SplitPage.m_bShow Then ' recupero disposizione fase corrente Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase) ' aggiungo al gruppo disposizione dei sottogruppi con i dati di movimento dei grezzi spostati SaveMoveInfoInDisposition(nDispId, m_RawMoveDataList) ' imposto eventuale presenza rimozioni manuali SaveRemoveByHandInDisposition(nDispId, m_bRemovedRaw) ' imposto eventuale movimento pezzi su tavola ausiliaria SaveMovePartsOnAuxTable(nDispId, m_SplitPage.m_bOnAuxTab) ' Eseguo calcolo speciale dei movimenti SpecialApplyDisposition(nDispId, True, Not m_SplitPage.m_bOnAuxTab) End If ' se altrimenti movimento senza ventose perchè lama troppo grande ElseIf GetVacuumType() > 0 Then ' se non solo visualizzazione If Not m_SplitPage.m_bShow Then ' recupero disposizione fase corrente Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase) ' imposto presenza operazioni manuali SaveRemoveByHandInDisposition(nDispId, True) ' Eseguo calcolo speciale dei movimenti SpecialApplyDisposition(nDispId, True) End If End If ' Nascondo eventuale tavola ausiliaria If m_SplitPage.m_bOnAuxTab Then EgtDisableModified() EgtSetStatus(m_nAuxTabId, GDB_ST.OFF) EgtEnableModified() EgtZoom(ZM.ALL, False) If Not m_bPrev Then ' Cancello eventuale manipolatore pezzi EgtDisableModified() RemoveVacuumCups() EgtEnableModified() ' ritorno a fase 1 EgtSetCurrPhase(1) ' Ripristino visualizzazione preview lavorazioni ShowAllPhasesMachiningPreview() End If End If ' Se torno indietro If m_bPrev Then EgtSetCurrPhase(m_nCurrPhase - 1) m_bPrev = False m_SplitPage.m_bShow = True End If ' Dichiaro pagina non attiva m_bActive = False End Sub End Class