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 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 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) ' altrimenti, aggiorno visualizzazione Else EgtDraw() End If ' Carico i parametri di movimento m_dStep = GetPrivateProfileDouble(S_RAWMOVE, K_RAWSTEP, 50, m_MainWindow.GetIniFile()) StepMoveTxBx.Text = LenToString(m_dStep, 3) 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 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 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 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 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) If nStat = GDB_ST.SEL Then EgtSetStatus(nId, GDB_ST.ON_) ' Se con ventose, le nascondo If Not m_bByHand Then EgtSetStatus(GetVacuumId(), GDB_ST.OFF) Else EgtDeselectAll() EgtSetStatus(nId, GDB_ST.SEL) ' Se con ventose, le posiziono sul grezzo If Not m_bByHand Then Dim rmData As New RawMoveData 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 ' Aggiorno i dati m_bRawWithCups = False ' Messaggio di avvertimento m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2)) 'Pezzo troppo piccolo : non si può muovere End If End If End If EgtDraw() Exit While End If nId = EgtGetNextObjInSelWin() End While End Sub 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) If EgtMoveRawPart(nRawId, vtMove) Then EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB) AddRawMoveData(nRawId, vtMove, m_RawMoveDataList) 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) If EgtMoveRawPart(nRawId, vtMove) Then EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB) AddRawMoveData(nRawId, vtMove, m_RawMoveDataList) 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) If EgtMoveRawPart(nRawId, vtMove) Then EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB) AddRawMoveData(nRawId, vtMove, m_RawMoveDataList) 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) If EgtMoveRawPart(nRawId, vtMove) Then EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB) AddRawMoveData(nRawId, vtMove, m_RawMoveDataList) 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 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 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) 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 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) 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 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 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 If Not EgtMoveToCornerRawPart(nRawId, ptRef, nCorn) Then Return ' 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) ' altrimenti annullo il movimento Else EgtMoveRawPart(nRawId, ptRawCen - ptNewRawCen) 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 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 EgtMoveRawPart(nRawId, vtMove) AddRawMoveData(nRawId, vtMove, 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 ' 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 ' 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 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 ' 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 presenza rimozioni manuali SaveRemoveByHandInDisposition(nDispId, m_bRemovedRaw) ' Eseguo calcolo speciale dei movimenti SpecialApplyDisposition(nDispId, True) 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