a8dc3d2642
- aggiunto log dei comandi diretti 3assi e 5assi - aggiunta rimozione manuale sfridi anche con movimento pezzi con ventose - aggiunta possibilità di eliminare home finale nei tagli diretti - con NUOVO progetto e pezzi parcheggiati si chiede se conservarli - spessore pezzo con 3 decimali (per inches) - migliorata visualizzazione coordinate assi in simulazione - in lista lavorazioni aggiunto flag sui tagli inclinati - corretta visualizzazione famiglie utensili da Ini.
739 lines
29 KiB
VB.net
739 lines
29 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.ComponentModel
|
|
Imports EgtUILib
|
|
|
|
Public Class SplitPageUC
|
|
|
|
' Riferimento alla MainWindow
|
|
Private m_MainWindow As MainWindow = Application.Current.MainWindow
|
|
' Tipo movimento dei grezzi (manuale o con testa ventosa)
|
|
Private m_bByHand As Boolean = True
|
|
' Stato
|
|
Private m_nCurrPhase As Integer = 0
|
|
Private m_MachiningList As New List(Of SplitMach)
|
|
Private m_ItemList As New ObservableCollection(Of NameIdLsBxItem)
|
|
Private m_CurrInd As Integer = -1
|
|
Private m_bModified As Boolean = False
|
|
Private m_nNbrGrpId As Integer = GDB_ID.NULL
|
|
Private m_bToNext As Boolean = False
|
|
|
|
Private Sub SplitPageUC_Initialized(sender As Object, e As EventArgs)
|
|
PrevBtn.IsEnabled = False
|
|
' Collego lista di oggetti a ListBox
|
|
MachiningLsBx.ItemsSource = m_ItemList
|
|
' Assegno testi
|
|
OnOffBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 1) ' On/Off
|
|
AllOnBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 2) ' Tutti On
|
|
AllOffBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 3) ' Tutti Off
|
|
CutBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 4) ' Allunga/Accorcia
|
|
CutStartBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 5) ' Inizio Allunga/Accorcia
|
|
CutEndBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 6) ' Fine Allunga/Accorcia
|
|
OutCenStartBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 7) ' Inizio Centro/Fuori
|
|
AllOutStartBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 8) ' Inizi Tutti Fuori
|
|
AllCenStartBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 9) ' Inizi Tutti Centro
|
|
AutoBtn.Content = "Auto"
|
|
End Sub
|
|
|
|
Private Sub SplitPageUC_Loaded(sender As Object, e As EventArgs) Handles Me.Loaded
|
|
' Leggo tipo movimento grezzi
|
|
m_bByHand = (EgtGetHeadId(VACUUM_HEAD) = GDB_ID.NULL 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_MainWindow.m_CurrentProjectPageUC.SetWarningMessage(EgtMsg(MSG_SPLITPAGEUC + 11)) ' Lama troppo grande per utilizzo ventosa
|
|
End If
|
|
' Nascondo eventuali pezzi in parcheggio
|
|
HideParkedParts()
|
|
EgtZoom(ZM.ALL)
|
|
' Faccio ordine automatico delle lavorazioni
|
|
Dim bOk As Boolean = SortAllMachinings()
|
|
If bOk Then
|
|
m_MainWindow.m_CurrentProjectPageUC.SetOrderMachiningFlag()
|
|
End If
|
|
' Disabilito impostazione modificato
|
|
EgtDisableModified()
|
|
' Creo gruppo per numeri identificativi di lavorazione (colore default grigio)
|
|
m_nNbrGrpId = EgtCreateGroup(GDB_ID.ROOT)
|
|
EgtSetColor(m_nNbrGrpId, COL_MCH_DISABLED)
|
|
EgtSetStatus(m_nNbrGrpId, GDB_ST.SEL)
|
|
EgtSetLevel(m_nNbrGrpId, GDB_LV.TEMP)
|
|
' Recupero l'indice della fase corrente
|
|
m_nCurrPhase = EgtGetCurrPhase()
|
|
' Preparo la lista delle lavorazioni
|
|
CalculateSplitMachList(m_nCurrPhase, m_MachiningList)
|
|
' Aggiorno visualizzazione delle lavorazioni
|
|
For nI As Integer = 0 To m_MachiningList.Count() - 1
|
|
' sistemo colore
|
|
ColorMachining(m_MachiningList(nI))
|
|
' assegno numerazione
|
|
NumberMachining(nI)
|
|
Next
|
|
' Preparo la lista degli Item
|
|
m_ItemList.Clear()
|
|
For i As Integer = 1 To m_MachiningList.Count()
|
|
Dim Mach As SplitMach = m_MachiningList(i - 1)
|
|
If Mach.m_nType = MCH_OY.SAWING Then ' Taglio
|
|
Dim sText As String = String.Empty
|
|
If Math.Abs(Mach.m_dSideAng) < EPS_ANG_SMALL Then
|
|
sText = EgtMsg(90791) & " " & i.ToString()
|
|
ElseIf Mach.m_dSideAng > 0 Then
|
|
sText = EgtMsg(90791) & " _\ " & i.ToString()
|
|
Else
|
|
sText = EgtMsg(90791) & " _/ " & i.ToString()
|
|
End If
|
|
m_ItemList.Add(New NameIdLsBxItem(sText, i - 1, Mach.m_bEnabled))
|
|
ElseIf Mach.m_nType = MCH_OY.DRILLING Then ' Foratura
|
|
Dim sText As String = EgtMsg(90792) & " " & i.ToString()
|
|
m_ItemList.Add(New NameIdLsBxItem(sText, i - 1, Mach.m_bEnabled))
|
|
ElseIf Mach.m_nType = MCH_OY.MILLING Then ' Fresatura
|
|
Dim sText As String = EgtMsg(90793) & " " & i.ToString()
|
|
m_ItemList.Add(New NameIdLsBxItem(sText, i - 1, Mach.m_bEnabled))
|
|
End If
|
|
Next
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
' Abilito impostazione modificato
|
|
EgtEnableModified()
|
|
' Nessun item corrente
|
|
m_CurrInd = -1
|
|
' Reset flag di modifica
|
|
m_bModified = False
|
|
' Reset flag tipo uscita
|
|
m_bToNext = False
|
|
' Abilitazione bottone Next
|
|
EnableButtons()
|
|
End Sub
|
|
|
|
Private Sub MachiningLsBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles MachiningLsBx.SelectionChanged
|
|
Dim SelItem As NameIdLsBxItem = MachiningLsBx.SelectedItem
|
|
If IsNothing(SelItem) Then Return
|
|
Dim nInd As Integer = SelItem.Ind
|
|
If nInd <> m_CurrInd Then
|
|
MarkMachining(m_CurrInd, False)
|
|
MarkMachining(nInd, True)
|
|
m_CurrInd = nInd
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub MoveUpBtn_Click(sender As Object, e As RoutedEventArgs) Handles MoveUpBtn.Click
|
|
MoveItem(-1)
|
|
End Sub
|
|
|
|
Private Sub MoveDownBtn_Click(sender As Object, e As RoutedEventArgs) Handles MoveDownBtn.Click
|
|
MoveItem(1)
|
|
End Sub
|
|
|
|
Private Sub MoveItem(direction As Integer)
|
|
' Checking selected item
|
|
If MachiningLsBx.SelectedItem Is Nothing OrElse MachiningLsBx.SelectedIndex < 0 OrElse MachiningLsBx.SelectedItems.Count > 1 Then
|
|
Return
|
|
End If
|
|
' No selected item - nothing to do
|
|
' Calculate new index using move direction
|
|
Dim newIndex As Integer = MachiningLsBx.SelectedIndex + direction
|
|
|
|
' Checking bounds of the range
|
|
If newIndex < 0 OrElse newIndex >= MachiningLsBx.Items.Count Then
|
|
Return
|
|
End If
|
|
' Index out of range - nothing to do
|
|
Dim selected As Object = MachiningLsBx.SelectedItem
|
|
|
|
' Removing removable element
|
|
m_ItemList.Remove(selected)
|
|
' Insert it in new position
|
|
m_ItemList.Insert(newIndex, selected)
|
|
' Restore selection
|
|
MachiningLsBx.SelectedItem = selected
|
|
|
|
' Imposto flag di modifica
|
|
m_bModified = True
|
|
End Sub
|
|
|
|
Private Sub OnOffBtn_Click(sender As Object, e As RoutedEventArgs) Handles OnOffBtn.Click
|
|
Dim SelItem As NameIdLsBxItem = MachiningLsBx.SelectedItem
|
|
If IsNothing(SelItem) Then
|
|
Return
|
|
End If
|
|
Dim nI As Integer = SelItem.Ind
|
|
If m_MachiningList(nI).m_bEnabled Then
|
|
m_MachiningList(nI).m_bEnabled = False
|
|
SelItem.bIsActive = False
|
|
Else
|
|
m_MachiningList(nI).m_bEnabled = True
|
|
SelItem.bIsActive = True
|
|
End If
|
|
ColorMachining(m_MachiningList(nI))
|
|
ColorNumber(nI)
|
|
EgtDraw()
|
|
' Imposto flag di modifica
|
|
m_bModified = True
|
|
' Abilitazione bottone Next
|
|
EnableButtons()
|
|
End Sub
|
|
|
|
Private Sub AllOnBtn_Click(sender As Object, e As RoutedEventArgs) Handles AllOnBtn.Click
|
|
For nI As Integer = 0 To m_MachiningList.Count() - 1
|
|
If Not m_MachiningList(nI).m_bEnabled Then
|
|
m_MachiningList(nI).m_bEnabled = True
|
|
m_ItemList(nI).bIsActive = True
|
|
ColorMachining(m_MachiningList(nI))
|
|
ColorNumber(nI)
|
|
End If
|
|
Next
|
|
EgtDraw()
|
|
' Imposto flag di modifica
|
|
m_bModified = True
|
|
' Abilitazione bottone Next
|
|
EnableButtons()
|
|
End Sub
|
|
|
|
Private Sub AllOffBtn_Click(sender As Object, e As RoutedEventArgs) Handles AllOffBtn.Click
|
|
For nI As Integer = 0 To m_MachiningList.Count() - 1
|
|
If m_MachiningList(nI).m_bEnabled Then
|
|
m_MachiningList(nI).m_bEnabled = False
|
|
m_ItemList(nI).bIsActive = False
|
|
ColorMachining(m_MachiningList(nI))
|
|
ColorNumber(nI)
|
|
End If
|
|
Next
|
|
EgtDraw()
|
|
' Imposto flag di modifica
|
|
m_bModified = True
|
|
' Abilitazione bottone Next
|
|
EnableButtons()
|
|
End Sub
|
|
|
|
Private Sub CutBtn_Click(sender As Object, e As RoutedEventArgs) Handles CutBtn.Click
|
|
Dim SelItem As NameIdLsBxItem = MachiningLsBx.SelectedItem
|
|
If IsNothing(SelItem) Then
|
|
Return
|
|
End If
|
|
Dim nI As Integer = SelItem.Ind
|
|
If m_MachiningList(nI).m_bCanStartAll And m_MachiningList(nI).m_bCanEndAll Then
|
|
EgtSetCurrMachining(m_MachiningList(nI).m_nId)
|
|
Dim nLiPrev As Integer
|
|
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev)
|
|
If m_MachiningList(nI).m_bStartAll Or m_MachiningList(nI).m_bEndAll Then
|
|
' accorcio
|
|
If nLiPrev = MCH_SAW_LI.EXT_OUT Then
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.OUT)
|
|
Else
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT)
|
|
End If
|
|
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT)
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
m_MachiningList(nI).m_bStartAll = False
|
|
m_MachiningList(nI).m_bEndAll = False
|
|
Else
|
|
' allungo
|
|
If nLiPrev = MCH_SAW_LI.OUT Then
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_OUT)
|
|
Else
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_CENT)
|
|
End If
|
|
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT)
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
m_MachiningList(nI).m_bStartAll = True
|
|
m_MachiningList(nI).m_bEndAll = True
|
|
End If
|
|
ColorMachining(m_MachiningList(nI))
|
|
EgtDraw()
|
|
End If
|
|
' Abilitazione bottone Next
|
|
EnableButtons()
|
|
End Sub
|
|
|
|
Private Sub CutStartBtn_Click(sender As Object, e As RoutedEventArgs) Handles CutStartBtn.Click
|
|
Dim SelItem As NameIdLsBxItem = MachiningLsBx.SelectedItem
|
|
If IsNothing(SelItem) Then
|
|
Return
|
|
End If
|
|
Dim nI As Integer = SelItem.Ind
|
|
If m_MachiningList(nI).m_bCanStartAll Then
|
|
EgtSetCurrMachining(m_MachiningList(nI).m_nId)
|
|
Dim nLiPrev As Integer
|
|
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev)
|
|
If m_MachiningList(nI).m_bStartAll Then
|
|
' accorcio
|
|
If nLiPrev = MCH_SAW_LI.EXT_OUT Then
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.OUT)
|
|
Else
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT)
|
|
End If
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
m_MachiningList(nI).m_bStartAll = False
|
|
Else
|
|
' allungo
|
|
If nLiPrev = MCH_SAW_LI.OUT Then
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_OUT)
|
|
Else
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_CENT)
|
|
End If
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
m_MachiningList(nI).m_bStartAll = True
|
|
End If
|
|
ColorMachining(m_MachiningList(nI))
|
|
EgtDraw()
|
|
End If
|
|
' Abilitazione bottone Next
|
|
EnableButtons()
|
|
End Sub
|
|
|
|
Private Sub CutEndBtn_Click(sender As Object, e As RoutedEventArgs) Handles CutEndBtn.Click
|
|
Dim SelItem As NameIdLsBxItem = MachiningLsBx.SelectedItem
|
|
If IsNothing(SelItem) Then
|
|
Return
|
|
End If
|
|
Dim nI As Integer = SelItem.Ind
|
|
If m_MachiningList(nI).m_bCanEndAll Then
|
|
EgtSetCurrMachining(m_MachiningList(nI).m_nId)
|
|
If m_MachiningList(nI).m_bEndAll Then
|
|
' accorcio
|
|
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT)
|
|
m_MachiningList(nI).m_bEndAll = False
|
|
Else
|
|
' allungo
|
|
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT)
|
|
m_MachiningList(nI).m_bEndAll = True
|
|
End If
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
ColorMachining(m_MachiningList(nI))
|
|
EgtDraw()
|
|
End If
|
|
' Abilitazione bottone Next
|
|
EnableButtons()
|
|
End Sub
|
|
|
|
Private Sub OutCenStartBtn_Click(sender As Object, e As RoutedEventArgs) Handles OutCenStartBtn.Click
|
|
Dim SelItem As NameIdLsBxItem = MachiningLsBx.SelectedItem
|
|
If IsNothing(SelItem) Then
|
|
Return
|
|
End If
|
|
Dim nI As Integer = SelItem.Ind
|
|
If m_MachiningList(nI).m_sLay = NAME_OUTLOOP Then
|
|
EgtSetCurrMachining(m_MachiningList(nI).m_nId)
|
|
Dim nLiPrev As Integer
|
|
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev)
|
|
If nLiPrev = MCH_SAW_LI.OUT Then
|
|
' accorcio
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT)
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
ModifyOtherLeadIn(nI, MCH_SAW_LI.CENT)
|
|
' ri-verifico interferenza
|
|
EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf)
|
|
ElseIf nLiPrev = MCH_SAW_LI.EXT_OUT Then
|
|
' accorcio
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_CENT)
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
ModifyOtherLeadIn(nI, MCH_SAW_LI.CENT)
|
|
ElseIf nLiPrev = MCH_SAW_LI.CENT Then
|
|
' allungo
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.OUT)
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
ModifyOtherLeadIn(nI, MCH_SAW_LI.OUT)
|
|
' ri-verifico interferenza
|
|
EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf)
|
|
ElseIf nLiPrev = MCH_SAW_LI.EXT_CENT Then
|
|
' allungo
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_OUT)
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
ModifyOtherLeadIn(nI, MCH_SAW_LI.OUT)
|
|
End If
|
|
ColorMachining(m_MachiningList(nI))
|
|
ColorNumber(nI)
|
|
EgtDraw()
|
|
' Imposto flag di modifica
|
|
m_bModified = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub AllOutStartBtn_Click(sender As Object, e As RoutedEventArgs) Handles AllOutStartBtn.Click
|
|
For nI As Integer = 0 To m_MachiningList.Count() - 1
|
|
EgtSetCurrMachining(m_MachiningList(nI).m_nId)
|
|
Dim nLiPrev As Integer
|
|
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev)
|
|
If nLiPrev = MCH_SAW_LI.CENT Then
|
|
' allungo
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.OUT)
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
ModifyOtherLeadIn(nI, MCH_SAW_LI.OUT)
|
|
' ri-verifico interferenza
|
|
EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf)
|
|
ElseIf nLiPrev = MCH_SAW_LI.EXT_CENT Then
|
|
' allungo
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_OUT)
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
ModifyOtherLeadIn(nI, MCH_SAW_LI.OUT)
|
|
End If
|
|
ColorMachining(m_MachiningList(nI))
|
|
ColorNumber(nI)
|
|
Next
|
|
EgtDraw()
|
|
' Imposto flag di modifica
|
|
m_bModified = True
|
|
End Sub
|
|
|
|
Private Sub AllCenStartBtn_Click(sender As Object, e As RoutedEventArgs) Handles AllCenStartBtn.Click
|
|
For nI As Integer = 0 To m_MachiningList.Count() - 1
|
|
EgtSetCurrMachining(m_MachiningList(nI).m_nId)
|
|
Dim nLiPrev As Integer
|
|
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev)
|
|
If nLiPrev = MCH_SAW_LI.OUT Then
|
|
' accorcio
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT)
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
ModifyOtherLeadIn(nI, MCH_SAW_LI.CENT)
|
|
' ri-verifico interferenza
|
|
EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf)
|
|
ElseIf nLiPrev = MCH_SAW_LI.EXT_OUT Then
|
|
' accorcio
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_CENT)
|
|
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
|
|
ModifyOtherLeadIn(nI, MCH_SAW_LI.CENT)
|
|
End If
|
|
ColorMachining(m_MachiningList(nI))
|
|
ColorNumber(nI)
|
|
Next
|
|
EgtDraw()
|
|
' Imposto flag di modifica
|
|
m_bModified = True
|
|
End Sub
|
|
|
|
Private Sub PrevBtn_Click(sender As Object, e As RoutedEventArgs) Handles PrevBtn.Click
|
|
ExitSplit(False)
|
|
' Elimino la fase corrente
|
|
RemoveLastPhase()
|
|
' Reimposto la precedente
|
|
SplitPageUC_Loaded(Nothing, Nothing)
|
|
End Sub
|
|
|
|
Private Sub NextBtn_Click(sender As Object, e As RoutedEventArgs) Handles NextBtn.Click
|
|
m_bToNext = True
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC.m_SplitPage)
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Add(m_MainWindow.m_CadCutPageUC.m_MoveRawPartPage)
|
|
m_MainWindow.m_CadCutPageUC.m_CadCutMode = CadCutPageUC.CadCutModes.MoveRawPart
|
|
End Sub
|
|
|
|
Private Sub AutoBtn_Click(sender As Object, e As RoutedEventArgs) Handles AutoBtn.Click
|
|
' Con movimento manuale, non disponibile movimento automatico
|
|
If m_bByHand Then Return
|
|
' Elimino evidenziazione e numerazione
|
|
RemoveMarkAndNumbers()
|
|
' Calcolo automatico
|
|
Dim bFinished As Boolean = False
|
|
Dim bOk As Boolean = CalculateOnePhaseSplitAuto(bFinished)
|
|
If Not bOk Then
|
|
m_MainWindow.m_CurrentProjectPageUC.SetWarningMessage(EgtMsg(90350)) 'Calcolo automatico non riuscito
|
|
End If
|
|
' Ricarico
|
|
SplitPageUC_Loaded(Nothing, Nothing)
|
|
End Sub
|
|
|
|
Private Sub SplitPageUC_Unloaded(sender As Object, e As EventArgs) Handles Me.Unloaded
|
|
ExitSplit(Not m_bToNext)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Friend Sub ExitSplit(Optional bTrueExit As Boolean = True)
|
|
' Rimuovo evidenziazione e numeri
|
|
RemoveMarkAndNumbers()
|
|
' Ripristino colori lavorazioni
|
|
EgtDisableModified()
|
|
For i As Integer = 0 To m_MachiningList.Count() - 1
|
|
ColorMachining(m_MachiningList(i), True)
|
|
Next
|
|
EgtEnableModified()
|
|
' se modificato salvo ordine e stato delle lavorazioni
|
|
If m_bModified Or bTrueExit Then
|
|
' Al primo posto deve rimanere la disposizione della fase
|
|
Dim nFirstOperId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
For i = m_ItemList.Count() - 1 To 0 Step -1
|
|
Dim nI As Integer = m_ItemList(i).Ind
|
|
Dim nMchId As Integer = m_MachiningList(nI).m_nId
|
|
EgtRelocate(nMchId, nFirstOperId, GDB_POS.AFTER)
|
|
If m_MachiningList(nI).m_bEnabled Then
|
|
EgtSetOperationMode(m_MachiningList(nI).m_nId, True)
|
|
EgtRemoveInfo(m_MachiningList(nI).m_nId, INFO_MCH_USER_OFF)
|
|
Else
|
|
EgtSetOperationMode(m_MachiningList(nI).m_nId, False)
|
|
EgtSetInfo(m_MachiningList(nI).m_nId, INFO_MCH_USER_OFF, 1)
|
|
End If
|
|
Next
|
|
' dichiaro ordine salvato
|
|
m_MainWindow.m_CurrentProjectPageUC.SetOrderMachiningFlag()
|
|
End If
|
|
' Affondamento ridotto
|
|
Dim dReducedDepth As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_REDUCEDDEPTH, 1, m_MainWindow.GetMachIniFile())
|
|
' Restringo o rialzo lavorazioni abilitate ma con interferenza
|
|
Dim bModified As Boolean = False
|
|
For Each Mach As SplitMach In m_MachiningList
|
|
If Mach.m_bEnabled And Mach.m_nInterf <> FMI_TYPE.NONE Then
|
|
If AdjustMachining(Mach.m_nId, Mach.m_nInterf, dReducedDepth) Then
|
|
bModified = True
|
|
End If
|
|
End If
|
|
Next
|
|
If bTrueExit Then
|
|
' ritorno a fase 1
|
|
EgtSetCurrPhase(1)
|
|
End If
|
|
If bModified Then
|
|
m_MainWindow.m_CurrentProjectPageUC.SetWarningMessage(EgtMsg(90321)) 'Ridotte alcune lavorazioni per evitare interferenze
|
|
End If
|
|
End Sub
|
|
|
|
Friend Function GetDisabledCutsCount() As Integer
|
|
' Determino il numero di tagli disabilitati
|
|
Dim nCount As Integer = 0
|
|
For nI As Integer = 0 To m_MachiningList.Count() - 1
|
|
If Not m_MachiningList(nI).m_bEnabled Then
|
|
nCount += 1
|
|
End If
|
|
Next
|
|
Return nCount
|
|
End Function
|
|
|
|
Friend Function GetSplitCutsCount() As Integer
|
|
' Determino il numero di tagli disabilitati
|
|
Dim nCount As Integer = 0
|
|
For nI As Integer = 0 To m_MachiningList.Count() - 1
|
|
If m_MachiningList(nI).m_bEnabled And
|
|
(m_MachiningList(nI).m_bStartAll Or m_MachiningList(nI).m_bEndAll) Then
|
|
nCount += 1
|
|
End If
|
|
Next
|
|
Return nCount
|
|
End Function
|
|
|
|
Friend Sub GetSplitCuts(ByRef Cuts() As Integer)
|
|
' Determino il numero di tagli di separazione
|
|
Dim nCount As Integer = 0
|
|
For nI As Integer = 0 To m_MachiningList.Count() - 1
|
|
If m_MachiningList(nI).m_bEnabled And
|
|
(m_MachiningList(nI).m_bStartAll Or m_MachiningList(nI).m_bEndAll) Then
|
|
nCount += 1
|
|
End If
|
|
Next
|
|
' Creo l'array con gli indici
|
|
Dim MyCuts(nCount - 1) As Integer
|
|
Dim nInd As Integer = 0
|
|
For nI As Integer = 0 To m_MachiningList.Count() - 1
|
|
If m_MachiningList(nI).m_bEnabled And
|
|
(m_MachiningList(nI).m_bStartAll Or m_MachiningList(nI).m_bEndAll) Then
|
|
MyCuts(nInd) = m_MachiningList(nI).m_nId
|
|
nInd += 1
|
|
End If
|
|
Next
|
|
' Lo restituisco
|
|
Cuts = MyCuts
|
|
End Sub
|
|
|
|
Private Sub EnableButtons()
|
|
' Per bottone PREV
|
|
PrevBtn.IsEnabled = (m_nCurrPhase > 1)
|
|
' Per bottone NEXT
|
|
' Se abilitato manipolatore
|
|
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.MAN_MANIP) Or
|
|
m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.AUTO_MANIP) Then
|
|
' Se allontanamento perpendicolare
|
|
If m_bByHand Then
|
|
' Ci deve essere almeno 1 taglio disabilitato e 1 e 1 solo passante
|
|
NextBtn.IsEnabled = (GetDisabledCutsCount() > 0 And GetSplitCutsCount() = 1)
|
|
' Altrimenti
|
|
Else
|
|
' Ci deve essere almeno 1 taglio disabilitato e almeno 1 passante
|
|
NextBtn.IsEnabled = (GetDisabledCutsCount() > 0 And GetSplitCutsCount() > 0)
|
|
End If
|
|
Else
|
|
NextBtn.IsEnabled = False
|
|
End If
|
|
' Per bottone AUTO
|
|
AutoBtn.IsEnabled = ((GetDisabledCutsCount() > 0 Or m_nCurrPhase = 1) And Not m_bByHand)
|
|
End Sub
|
|
|
|
Private Function ModifyOtherLeadIn(nI As Integer, nLiOthType As Integer) As Boolean
|
|
' Modifico l'attacco delle lavorazioni inglobate
|
|
For Each nMchId As Integer In m_MachiningList(nI).m_vOthId
|
|
EgtSetCurrMachining(nMchId)
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, nLiOthType)
|
|
Next
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub NumberMachining(nI As Integer)
|
|
' Ingombro complessivo della lavorazione
|
|
Dim ptMin, ptMax As Point3d
|
|
If Not BoxFromMachining(nI, ptMin, ptMax) Then Return
|
|
' Metto il numero nel centro
|
|
Dim ptCen As Point3d = ptMin + 0.5 * (ptMax - ptMin)
|
|
ptCen.z = ptMax.z + 1
|
|
Dim dRadXY = Point3d.DistXY(ptMin, ptMax)
|
|
Dim dHtxt As Double = 75
|
|
Dim dRat As Double = 1
|
|
If dRadXY < 200 Then
|
|
dHtxt = 50
|
|
dRat = 0.75
|
|
ElseIf dRadXY < 25 Then
|
|
dHtxt = 25
|
|
dRat = 0.5
|
|
End If
|
|
Dim nNbrId As Integer = EgtCreateTextAdv(m_nNbrGrpId, ptCen, 0, (nI + 1).ToString(), "",
|
|
300, False, dHtxt, dRat, 0, INS_POS.MC)
|
|
m_MachiningList(nI).m_nNbrId = nNbrId
|
|
ColorNumber(nI)
|
|
EgtSetInfo(nNbrId, "MId", m_MachiningList(nI).m_nId)
|
|
' Aggiungo a lavorazione info con identificativo del numero e viceversa
|
|
EgtSetInfo(m_MachiningList(nI).m_nId, "NbrId", nNbrId)
|
|
End Sub
|
|
|
|
Private Function BoxFromMachining(nI As Integer, ByRef ptMin As Point3d, ByRef ptMax As Point3d) As Boolean
|
|
If nI < 0 Then Return False
|
|
' Lavorazione principale
|
|
If Not BoxFromSingleMachining(m_MachiningList(nI).m_nId, ptMin, ptMax) Then
|
|
Return False
|
|
End If
|
|
' Eventuali lavorazioni inglobate
|
|
For Each nId As Integer In m_MachiningList(nI).m_vOthId
|
|
Dim ptMchMin, ptMchMax As Point3d
|
|
If BoxFromSingleMachining(nId, ptMchMin, ptMchMax) Then
|
|
ptMin.x = Math.Min(ptMin.x, ptMchMin.x)
|
|
ptMin.y = Math.Min(ptMin.y, ptMchMin.y)
|
|
ptMin.z = Math.Min(ptMin.z, ptMchMin.z)
|
|
ptMax.x = Math.Max(ptMax.x, ptMchMax.x)
|
|
ptMax.y = Math.Max(ptMax.y, ptMchMax.y)
|
|
ptMax.z = Math.Max(ptMax.z, ptMchMax.z)
|
|
End If
|
|
Next
|
|
Return True
|
|
End Function
|
|
|
|
Private Function BoxFromSingleMachining(nOperId As Integer, ByRef ptMin As Point3d, ByRef ptMax As Point3d) As Boolean
|
|
' Recupero il preview della lavorazione
|
|
Dim nPvId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(EgtGetFirstNameInGroup(nOperId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId)
|
|
Return EgtGetBBoxGlob(nPvId, GDB_BB.STANDARD, ptMin, ptMax)
|
|
End Function
|
|
|
|
Private Sub MarkMachining(nI As Integer, bMark As Boolean)
|
|
If nI < 0 Then Return
|
|
Dim nOperId As Integer = m_MachiningList(nI).m_nId
|
|
' Evidenzio la lavorazione principale
|
|
MarkSingleMachining(nOperId, bMark)
|
|
' Evidenzio l'eventuale numero della lavorazione
|
|
MarkNumber(nI, bMark)
|
|
' Marco anche le lavorazioni inglobate
|
|
For Each nId As Integer In m_MachiningList(nI).m_vOthId
|
|
MarkSingleMachining(nId, bMark)
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub MarkSingleMachining(nOperId As Integer, bMark As Boolean)
|
|
Dim nPvId As Integer = GDB_ID.NULL
|
|
If EgtGetInfo(EgtGetFirstNameInGroup(nOperId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId) Then
|
|
If bMark Then
|
|
EgtSetMark(nPvId)
|
|
Else
|
|
EgtResetMark(nPvId)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub MarkNumber(nI As Integer, bMark As Boolean)
|
|
If nI < 0 Then Return
|
|
Dim nNbrId As Integer = m_MachiningList(nI).m_nNbrId
|
|
If bMark Then
|
|
EgtSetMark(nNbrId)
|
|
Else
|
|
EgtResetMark(nNbrId)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ColorNumber(nI As Integer)
|
|
If nI < 0 Then Return
|
|
If Not m_MachiningList(nI).m_bEnabled And m_MachiningList(nI).m_nInterf = FMI_TYPE.NONE Then
|
|
EgtResetColor(m_MachiningList(nI).m_nNbrId)
|
|
ElseIf Not m_MachiningList(nI).m_bEnabled Then
|
|
EgtSetColor(m_MachiningList(nI).m_nNbrId, COL_MCH_DIS_INTERF)
|
|
ElseIf m_MachiningList(nI).m_nInterf = FMI_TYPE.NONE Then
|
|
EgtSetColor(m_MachiningList(nI).m_nNbrId, COL_MCH_FREE)
|
|
Else
|
|
EgtSetColor(m_MachiningList(nI).m_nNbrId, COL_MCH_INTERF)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub RemoveMarkAndNumbers()
|
|
' cancello evidenziazione
|
|
If m_CurrInd >= 0 Then
|
|
MarkMachining(m_CurrInd, False)
|
|
m_CurrInd = -1
|
|
End If
|
|
' cancello gruppo di numerazione e ripristino colori lavorazioni
|
|
EgtDisableModified()
|
|
EgtErase(m_nNbrGrpId)
|
|
For i As Integer = 0 To m_MachiningList.Count() - 1
|
|
ColorMachining(m_MachiningList(i), True)
|
|
Next
|
|
EgtEnableModified()
|
|
End Sub
|
|
|
|
'-----------------------------------------------------------------------------------------------
|
|
Private Class NameIdLsBxItem
|
|
Implements INotifyPropertyChanged
|
|
|
|
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
|
|
|
|
Private m_nInd As Integer
|
|
Private m_sName As String
|
|
Private m_bIsActive As Boolean
|
|
|
|
Public Property Ind As Integer
|
|
Get
|
|
Return m_nInd
|
|
End Get
|
|
Set(value As Integer)
|
|
m_nInd = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property Name As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_sName Then
|
|
m_sName = value
|
|
NotifyPropertyChanged("Name")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Public Property bIsActive As Boolean
|
|
Get
|
|
Return m_bIsActive
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_bIsActive Then
|
|
m_bIsActive = value
|
|
NotifyPropertyChanged("bIsActive")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Sub New(Name As String, Ind As Integer, bIsActive As Boolean)
|
|
Me.m_sName = Name
|
|
Me.m_nInd = Ind
|
|
Me.m_bIsActive = bIsActive
|
|
End Sub
|
|
|
|
Public Sub NotifyPropertyChanged(propName As String)
|
|
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
End Class
|