e8e0ffaa2b
- aggiunto aggiornamento text lav. corrente all'uscita dal grezzo - corretta separazione senza attivare alcuna lavorazione - migliorata gestion eutensili.
316 lines
13 KiB
VB.net
316 lines
13 KiB
VB.net
Imports EgtUILib
|
|
|
|
Public Class MoveRawPartPage
|
|
' Riferimento alla MainWindow
|
|
Private m_MainWindow As MainWindow = Application.Current.MainWindow
|
|
Private WithEvents m_CurrProjPage As CurrentProjectPageUC
|
|
' Flag di pagina attiva
|
|
Private m_bActive As Boolean = False
|
|
' Tipo movimento dei grezzi
|
|
Private m_bPerp As Boolean = False
|
|
' Fase corrente
|
|
Private m_nCurrPhase As Integer = 0
|
|
' Dati movimento
|
|
Private m_dStep As Double = 0
|
|
' Direzione di movimento se perpendicolare
|
|
Private m_vtDir As Vector3d
|
|
' Punto medio del taglio
|
|
Private m_ptMid As Point3d
|
|
' Distanza corrente
|
|
Private m_dCurrDist As Double = 0
|
|
' Distanza iniziale (spessore taglio)
|
|
Private m_dOrigDist As Double = 0
|
|
|
|
Private Sub MoveRawPartPage_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
|
|
PrevBtn.IsEnabled = False
|
|
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_bPerp = (GetPrivateProfileInt(S_RAWMOVE, K_PERPENDICULAR, 0, m_MainWindow.GetIniFile()) <> 0)
|
|
' Deseleziono tutto
|
|
EgtDeselectAll()
|
|
' Recupero i tagli allungati prima definiti
|
|
Dim Cuts(0) As Integer
|
|
m_MainWindow.m_CadCutPageUC.m_SplitPage.GetSplitCuts(Cuts)
|
|
' Aggiorno preview di questi tagli lasciandoli nella lavorazione
|
|
For Each nCut As Integer In Cuts
|
|
UpdateMachiningPreview(nCut, False)
|
|
Next
|
|
' Fase precedente
|
|
Dim nPrevPhase As Integer = EgtGetCurrPhase()
|
|
' Creo nuova fase
|
|
m_nCurrPhase = EgtAddPhase()
|
|
' Origine tavola
|
|
Dim ptOri As Point3d
|
|
EgtGetTableRef(1, ptOri)
|
|
Dim vtOri As New Vector3d(ptOri.x, ptOri.y, ptOri.z)
|
|
' Se non ci sono tagli allungati, confermo i grezzi
|
|
If Cuts.Length() = 0 Then
|
|
' Ciclo sui grezzi
|
|
Dim nRawId As Integer = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
If EgtVerifyRawPartPhase(nRawId, nPrevPhase) Then
|
|
' Confermo il grezzo
|
|
EgtKeepRawPart(nRawId)
|
|
' Fisso posizione del grezzo
|
|
Dim ptMin, ptMax As Point3d
|
|
GetRawBox(nRawId, ptMin, ptMax)
|
|
EgtMoveToCornerRawPart(nRawId, ptMin - vtOri, MCH_CR.BL)
|
|
End If
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
' Altrimenti eseguo eventuali spezzature dei grezzi e vi sposto i pezzi
|
|
Else
|
|
' eseguo spezzature
|
|
Dim nRawId As Integer = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
' se il grezzo è presente nella fase precedente
|
|
If EgtVerifyRawPartPhase(nRawId, nPrevPhase) Then
|
|
' Calcolo nuovi grezzi
|
|
Dim nRaw1Id = EgtSplitFlatRawPartWithMachinings(nRawId, Cuts)
|
|
' Fisso posizione dei nuovi grezzi
|
|
Dim nNewRawId = nRaw1Id
|
|
While nNewRawId <> GDB_ID.NULL
|
|
Dim ptMin, ptMax As Point3d
|
|
GetRawBox(nNewRawId, ptMin, ptMax)
|
|
EgtMoveToCornerRawPart(nNewRawId, ptMin - vtOri, MCH_CR.BL)
|
|
nNewRawId = EgtGetNextRawPart(nNewRawId)
|
|
End While
|
|
' Assegno ai nuovi grezzi eventuale texture del grezzo originale
|
|
Dim nSolidId = EgtGetFirstNameInGroup(nRawId, NAME_RAW_SOLID)
|
|
Dim nameTxr As String = String.Empty
|
|
If EgtGetTextureName(nSolidId, nameTxr) Then
|
|
Dim refTxr As New Frame3d
|
|
EgtGetTextureFrame(nSolidId, GDB_ID.ROOT, refTxr)
|
|
nNewRawId = nRaw1Id
|
|
While nNewRawId <> GDB_ID.NULL
|
|
' Carico la texture sul nuovo grezzo
|
|
Dim nNewSolidId = EgtGetFirstNameInGroup(nNewRawId, NAME_RAW_SOLID)
|
|
EgtSetTextureName(nNewSolidId, nameTxr)
|
|
' Sistemo il riferimento della texture
|
|
EgtSetTextureFrame(nNewSolidId, refTxr, GDB_RT.GLOB)
|
|
' Passo al grezzo successivo
|
|
nNewRawId = EgtGetNextRawPart(nNewRawId)
|
|
End While
|
|
End If
|
|
End If
|
|
' passo al successivo grezzo
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
End If
|
|
' Sposto tutte le lavorazioni disabilitate e le eventuali inglobate nella nuova fase
|
|
Dim nId = EgtGetFirstOperation()
|
|
While nId <> GDB_ID.NULL
|
|
Dim nNextId = EgtGetNextOperation(nId)
|
|
If IsValidMachining(nId) And EgtGetOperationPhase(nId) = m_nCurrPhase - 1 And EgtExistsInfo(nId, INFO_MCH_USER_OFF) Then
|
|
' sposto la lavorazione
|
|
EgtChangeOperationPhase(nId, m_nCurrPhase)
|
|
' sposto le inglobate
|
|
Dim sInfo As String = String.Empty
|
|
If EgtGetInfo(nId, INFO_MCH_OTHMID, sInfo) Then
|
|
Dim sItems() As String = sInfo.Split(",".ToCharArray)
|
|
For Each sId In sItems
|
|
EgtChangeOperationPhase(CInt(sId), m_nCurrPhase)
|
|
Next
|
|
End If
|
|
End If
|
|
nId = nNextId
|
|
End While
|
|
' 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 perpendicolare ed esiste taglio passante determino direzione di movimento
|
|
If m_bPerp And 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
|
|
Else
|
|
m_bPerp = False
|
|
End If
|
|
' Aggirono interfaccia per taglio perpendicolare
|
|
If m_bPerp Then
|
|
LeftBtn.Visibility = Windows.Visibility.Hidden
|
|
RightBtn.Visibility = Windows.Visibility.Hidden
|
|
Else
|
|
LeftBtn.Visibility = Windows.Visibility.Visible
|
|
RightBtn.Visibility = Windows.Visibility.Visible
|
|
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
|
|
If Not m_bActive Then
|
|
Return
|
|
End If
|
|
' 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_)
|
|
Else
|
|
EgtSetStatus(nId, GDB_ST.SEL)
|
|
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_bPerp Then
|
|
' Recupero il centro del grezzo
|
|
Dim nCentId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_RAW_CENTER)
|
|
Dim ptRawCen As Point3d
|
|
EgtStartPoint(nCentId, GDB_ID.ROOT, 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
|
|
EgtMoveRawPart(nRawId, New Vector3d(0, m_dStep, 0))
|
|
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_bPerp Then
|
|
' Se sono già a contatto, non devo fare alcunché
|
|
If m_dCurrDist < EPS_SMALL Then Return
|
|
' Recupero il centro del grezzo
|
|
Dim nCentId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_RAW_CENTER)
|
|
Dim ptRawCen As Point3d
|
|
EgtStartPoint(nCentId, GDB_ID.ROOT, 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
|
|
EgtMoveRawPart(nRawId, New Vector3d(0, -m_dStep, 0))
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub RightBtn_Click(sender As Object, e As RoutedEventArgs) Handles RightBtn.Click
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
EgtMoveRawPart(nRawId, New Vector3d(m_dStep, 0, 0))
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub LeftBtn_Click(sender As Object, e As RoutedEventArgs) Handles LeftBtn.Click
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
EgtMoveRawPart(nRawId, New Vector3d(-m_dStep, 0, 0))
|
|
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)
|
|
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 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_MovePartPage = CadCutPageUC.MovePartsPages.Split
|
|
End Sub
|
|
|
|
Private Sub MoveRawPartPage_Unloaded(sender As Object, e As EventArgs) Handles Me.Unloaded
|
|
m_bActive = False
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
|