3ccffe53b4
- sistemazioni per ventose manipolatore su pezzi a L - PrevBtn attivo anche in muovi grezzi - migliorata gestione componenti interni - griglia ora si adatta all'unità di misura.
407 lines
17 KiB
VB.net
407 lines
17 KiB
VB.net
Imports EgtUILib
|
|
|
|
Public Class MoveRawPartPage
|
|
' 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
|
|
' Fase corrente
|
|
Private m_nCurrPhase As Integer = 0
|
|
' Dati movimento
|
|
Private m_dStep 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
|
|
End Sub
|
|
|
|
Private Sub MoveRawPartPage_Loaded(sender As Object, e As EventArgs) Handles Me.Loaded
|
|
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
|
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_MainWindow.m_CadCutPageUC.m_SplitPage.GetEnabledCuts(Cuts)
|
|
' Fase precedente
|
|
Dim nPrevPhase As Integer = EgtGetCurrPhase()
|
|
' Creo nuova fase, eseguo spezzatura grezzi e vi sposto le lavorazioni
|
|
Dim vNewRaws As New List(Of Integer)
|
|
SplitRawParts(nPrevPhase, Cuts, vNewRaws)
|
|
m_nCurrPhase = EgtGetCurrPhase()
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
' Carico i parametri di movimento
|
|
m_dStep = GetPrivateProfileDouble(S_RAWMOVE, K_RAWSTEP, 50, m_MainWindow.GetIniFile())
|
|
StepMoveTxBx.Text = LenToString(m_dStep, 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
|
|
End If
|
|
' Aggiorno interfaccia per taglio perpendicolare
|
|
If m_bByHand Then
|
|
LeftBtn.Visibility = Windows.Visibility.Hidden
|
|
RightBtn.Visibility = Windows.Visibility.Hidden
|
|
' Altrimeni per movimento con ventose
|
|
Else
|
|
LeftBtn.Visibility = Windows.Visibility.Visible
|
|
RightBtn.Visibility = Windows.Visibility.Visible
|
|
End If
|
|
RemovePartBtn.Visibility = Windows.Visibility.Visible
|
|
|
|
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
|
|
' 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
|
|
EgtSetObjFilterForSelect(True, True, True, True, True)
|
|
Dim nSel As Integer
|
|
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
|
|
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
|
While nId <> GDB_ID.NULL
|
|
' 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_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
|
|
GetRawCenter(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)
|
|
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
|
|
GetRawCenter(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)
|
|
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)
|
|
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)
|
|
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)
|
|
' 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 PrevBtn_Click(sender As Object, e As RoutedEventArgs) Handles PrevBtn.Click
|
|
' Deseleziono tutto
|
|
EgtDeselectAll()
|
|
' Elimino la fase corrente
|
|
RemoveLastPhase()
|
|
' Passo alla pagina delle lavorazioni
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC.m_MoveRawPartPage)
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Add(m_MainWindow.m_CadCutPageUC.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 lavorazioni
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC.m_MoveRawPartPage)
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Add(m_MainWindow.m_CadCutPageUC.m_SplitPage)
|
|
m_MainWindow.m_CadCutPageUC.m_CadCutMode = CadCutPageUC.CadCutModes.Split
|
|
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
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
' 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
|
|
For Each rmData As RawMoveData In m_RawMoveDataList
|
|
' Se movimento significativo
|
|
If Not rmData.m_vtMove.IsSmall() Then
|
|
' Creo gruppo e salvo dati per movimento grezzo
|
|
SaveMoveInfoInDisposition(nDispId, rmData)
|
|
End If
|
|
Next
|
|
' imposto presenza operazioni manuali
|
|
SaveRemoveByHandInDisposition(nDispId, m_bRemovedRaw)
|
|
' Eseguo calcolo speciale dei movimenti
|
|
EgtSpecialApplyDisposition(nDispId, True)
|
|
End If
|
|
' Dichiaro pagina non attiva
|
|
m_bActive = False
|
|
End Sub
|
|
|
|
Private Function AddRawMoveData(nRawId As Integer) As Integer
|
|
' Cerco in lista record con dati del grezzo indicato
|
|
Dim nInd As Integer = -1
|
|
For i As Integer = 0 To m_RawMoveDataList.Count() - 1
|
|
If m_RawMoveDataList(i).m_nId = nRawId Then
|
|
nInd = i
|
|
Exit For
|
|
End If
|
|
Next
|
|
' Se non trovato, lo accodo
|
|
If nInd = -1 Then
|
|
m_RawMoveDataList.Add(New RawMoveData(nRawId))
|
|
nInd = m_RawMoveDataList.Count() - 1
|
|
End If
|
|
Return nInd
|
|
End Function
|
|
|
|
Private Function AddRawMoveData(nRawId As Integer, vtMove As Vector3d) As Integer
|
|
' Recupero o creo record con dati del grezzo indicato
|
|
Dim nInd As Integer = AddRawMoveData(nRawId)
|
|
If nInd = -1 Then Return -1
|
|
' Aggiorno i valori
|
|
m_RawMoveDataList(nInd).m_vtMove += vtMove
|
|
Return nInd
|
|
End Function
|
|
|
|
Private Function AddRawMoveData(rmData As RawMoveData) As Integer
|
|
' Recupero o creo record con dati del grezzo indicato
|
|
Dim nInd As Integer = AddRawMoveData(rmData.m_nId)
|
|
If nInd = -1 Then Return -1
|
|
' Aggiorno i valori
|
|
m_RawMoveDataList(nInd).m_vtDelta = rmData.m_vtDelta
|
|
m_RawMoveDataList(nInd).m_dAngRotDeg = rmData.m_dAngRotDeg
|
|
m_RawMoveDataList(nInd).m_sCups = rmData.m_sCups
|
|
Return nInd
|
|
End Function
|
|
|
|
Private Sub RemoveRawMoveData(nRawId As Integer)
|
|
' Cerco in lista record con dati del grezzo indicato
|
|
Dim nInd As Integer = -1
|
|
For i As Integer = 0 To m_RawMoveDataList.Count() - 1
|
|
If m_RawMoveDataList(i).m_nId = nRawId Then
|
|
nInd = i
|
|
Exit For
|
|
End If
|
|
Next
|
|
' Se trovato, lo elimino
|
|
If nInd >= 0 Then
|
|
m_RawMoveDataList.RemoveAt(nInd)
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
|