d9253bd21d
- corretto taglio diretto per test lama (lettura lato di lavoro da lavorazione corrente) - corrette cornici per ricalcolo al cambio dei parametri di spostamento (impostare grezzo corrente in Nest).
619 lines
26 KiB
VB.net
619 lines
26 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
|
|
Public Class FrameCutPageUC
|
|
|
|
' Riferimenti a pagine
|
|
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
Private WithEvents m_CurrProjPage As CurrentProjectPageUC
|
|
Friend m_ProjectMgr As ProjectMgrUC
|
|
Private m_CurrMachine As CurrentMachine
|
|
|
|
' Flag di pagina attiva
|
|
Private m_bActive As Boolean = False
|
|
' Dati del grezzo
|
|
Private m_nRawId As Integer = GDB_ID.NULL
|
|
Private m_RawBox As New BBox3d
|
|
Private m_dKerf As Double = 0
|
|
' Array per combo direzioni
|
|
Private m_AlongAx(1) As String
|
|
' Direzione corrente
|
|
Private m_CurrAx As Integer = 0
|
|
' Lista per lavorazioni di sgrossatura con lama
|
|
Private m_SawRoughingList As New ObservableCollection(Of String)
|
|
' Lista per lavorazioni di finitura con lama
|
|
Private m_SawFinishingList As New ObservableCollection(Of String)
|
|
' Lista per lavorazioni di spatolatura con lama
|
|
Private m_SawSideFinList As New ObservableCollection(Of String)
|
|
' Flag per disabilitare ricalcolo lavorazioni su impostazione selezione combo
|
|
Private m_DisableCalc As Boolean = False
|
|
' Oggetto di gestione della macchina fotografica
|
|
Friend m_Camera As New Camera
|
|
|
|
' Costante per lavorazione non definita
|
|
Private Const NO_MACHINING As String = "-----"
|
|
|
|
Private Sub FrameCutPage_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
|
|
' Creazione delle Page UserControl
|
|
m_ProjectMgr = New ProjectMgrUC
|
|
|
|
' Posizionamento nella griglia delle Page UserControl
|
|
m_ProjectMgr.SetValue(Grid.RowProperty, 2)
|
|
m_ProjectMgr.SetValue(Grid.ColumnProperty, 1)
|
|
|
|
' Assegno UC a questa pagina
|
|
FrameCutPageGrid.Children.Add(m_ProjectMgr)
|
|
|
|
' Associo ComboBox e Liste
|
|
AlongAxCmBx.ItemsSource = m_AlongAx
|
|
SawRoughingCmBx.ItemsSource = m_SawRoughingList
|
|
SawFinishingCmBx.ItemsSource = m_SawFinishingList
|
|
SawSideFinCmBx.ItemsSource = m_SawSideFinList
|
|
|
|
' Imposto offset in Z dal sopra del grezzo e in XY da angolo in basso a sx
|
|
Dim dOffsZ As Double = GetPrivateProfileDouble(S_FRAME, K_OFFSZ, 5, m_MainWindow.GetIniFile())
|
|
OffsZTxBx.Text = LenToString(dOffsZ, 3)
|
|
Dim dOffsXY As Double = GetPrivateProfileDouble(S_FRAME, K_OFFSXY, 5, m_MainWindow.GetIniFile())
|
|
OffsXyTxBx.Text = LenToString(dOffsXY, 3)
|
|
|
|
' Imposto i messaggi letti dal file dei messaggi
|
|
m_AlongAx(0) = EgtMsg(MSG_FRAMECUTPAGEUC + 1) 'Lungo X
|
|
m_AlongAx(1) = EgtMsg(MSG_FRAMECUTPAGEUC + 2) 'Lungo Y
|
|
MirrorPartBtn.Content = EgtMsg(MSG_FRAMECUTPAGEUC + 7) 'Mirror cornice
|
|
RemovePartBtn.Content = EgtMsg(MSG_FRAMECUTPAGEUC + 3) 'Rimuovi cornice
|
|
OffsZTxBl.Text = EgtMsg(MSG_FRAMECUTPAGEUC + 8) 'Distanza da sopra
|
|
OffsXyTxBl.Text = EgtMsg(MSG_FRAMECUTPAGEUC + 9) 'Distanza da inizio
|
|
SawRoughingTxBl.Text = EgtMsg(MSG_FRAMECUTPAGEUC + 4) 'Sgrossatura
|
|
SawFinishingTxBl.Text = EgtMsg(MSG_FRAMECUTPAGEUC + 5) 'Finitura
|
|
SawSideFinTxBl.Text = EgtMsg(MSG_FRAMECUTPAGEUC + 6) 'Spatolatura
|
|
End Sub
|
|
|
|
Private Sub FrameCutPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
|
m_CurrMachine = m_MainWindow.m_CurrentMachine
|
|
m_bActive = True
|
|
' Nascondo bottoni CSV e VeinMatching
|
|
m_ProjectMgr.CSVBtn.Visibility = Windows.Visibility.Hidden
|
|
m_ProjectMgr.VeinMatchingBtn.Visibility = Windows.Visibility.Hidden
|
|
' Recupero dimensioni e kerf del grezzo
|
|
m_nRawId = EgtGetFirstRawPart()
|
|
GetRawBox(m_RawBox)
|
|
EgtGetInfo(m_nRawId, KEY_KERF, m_dKerf)
|
|
' Imposto direzione cornici
|
|
UpdateAlongAxCmbBx()
|
|
' Aggiorno liste lavorazioni disponibili
|
|
UpdateMachiningList(MCH_MY.SAWROUGHING, m_CurrMachine.sCurrSaw, m_SawRoughingList)
|
|
UpdateMachiningList(MCH_MY.SAWFINISHING, MCH_SAWFIN_SUB.ALONG, m_CurrMachine.sCurrSaw, m_SawFinishingList)
|
|
UpdateMachiningList(MCH_MY.SAWFINISHING, MCH_SAWFIN_SUB.ACROSS, m_CurrMachine.sCurrSaw, m_SawSideFinList)
|
|
' Imposto lavorazioni correnti
|
|
m_DisableCalc = True
|
|
If Not String.IsNullOrEmpty(m_CurrMachine.sCurrSawRoughing) Then
|
|
SawRoughingCmBx.SelectedItem = m_CurrMachine.sCurrSawRoughing
|
|
Else
|
|
SawRoughingCmBx.SelectedItem = NO_MACHINING
|
|
End If
|
|
If Not String.IsNullOrEmpty(m_CurrMachine.sCurrSawFinishing) Then
|
|
SawFinishingCmBx.SelectedItem = m_CurrMachine.sCurrSawFinishing
|
|
Else
|
|
SawFinishingCmBx.SelectedItem = NO_MACHINING
|
|
End If
|
|
If Not String.IsNullOrEmpty(m_CurrMachine.sCurrSawSideFinishing) Then
|
|
SawSideFinCmBx.SelectedItem = m_CurrMachine.sCurrSawSideFinishing
|
|
Else
|
|
SawSideFinCmBx.SelectedItem = NO_MACHINING
|
|
End If
|
|
m_DisableCalc = False
|
|
' Se macchina fotografica abilitata
|
|
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.MAN_PHOTO) Then
|
|
PhotoBtn.IsEnabled = True
|
|
' Inizializzo gestore macchina fotografica
|
|
m_Camera.Init()
|
|
Else
|
|
PhotoBtn.IsEnabled = False
|
|
End If
|
|
' Se provengo da grezzo, sistemo eventuali cornici
|
|
If m_MainWindow.m_PrevActivePage = MainWindow.Pages.RawPart Then
|
|
' Aggiorno geometria
|
|
UpdateFrames()
|
|
' Ricalcolo lavorazioni
|
|
AddFrameMachinings()
|
|
End If
|
|
' Abilito visualizzazione delle lavorazioni
|
|
EgtSetCurrPhase(1)
|
|
ShowAllCurrPhaseMachinings()
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Private Sub UpdateAlongAxCmbBx()
|
|
' Se già presenti cornici, visualizzo direzione senza poterla modificare
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(m_nRawId)
|
|
If nPartId <> GDB_ID.NULL Then
|
|
Dim nDir As Integer
|
|
If EgtGetInfo(nPartId, INFO_FRAME_DIR, nDir) Then m_CurrAx = nDir
|
|
AlongAxCmBx.SelectedIndex = m_CurrAx
|
|
AlongAxCmBx.IsEnabled = False
|
|
' Altrimenti, abilito cambio direzione
|
|
Else
|
|
AlongAxCmBx.SelectedIndex = m_CurrAx
|
|
AlongAxCmBx.IsEnabled = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub UpdateMachiningList(MachiningType As Integer, CurrTool As String, MachiningList As ObservableCollection(Of String))
|
|
' Pulisco la lista
|
|
MachiningList.Clear()
|
|
' Cerco tutte le lavorazioni che utilizzano l'utensile corrente e le aggiungo alla lista
|
|
Dim MachiningName As String = String.Empty
|
|
Dim bFound As Boolean = EgtMdbGetFirstMachining(MachiningType, MachiningName)
|
|
While bFound
|
|
EgtMdbSetCurrMachining(MachiningName)
|
|
Dim Tool As String = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.TOOL, Tool)
|
|
If Tool = CurrTool And VerifyMatThickCompatibility() Then
|
|
MachiningList.Add(MachiningName)
|
|
End If
|
|
bFound = EgtMdbGetNextMachining(MachiningType, MachiningName)
|
|
End While
|
|
' Aggiungo la lavorazione nulla
|
|
MachiningList.Add(NO_MACHINING)
|
|
End Sub
|
|
|
|
Private Sub UpdateMachiningList(MachiningType As Integer, MachiningSubType As Integer, CurrTool As String, MachiningList As ObservableCollection(Of String))
|
|
' Pulisco la lista
|
|
MachiningList.Clear()
|
|
' Cerco tutte le lavorazioni che utilizzano l'utensile corrente e le aggiungo alla lista
|
|
Dim MachiningName As String = String.Empty
|
|
Dim bFound As Boolean = EgtMdbGetFirstMachining(MachiningType, MachiningName)
|
|
While bFound
|
|
EgtMdbSetCurrMachining(MachiningName)
|
|
Dim SubType As Integer
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.SUBTYPE, SubType)
|
|
Dim Tool As String = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.TOOL, Tool)
|
|
If Tool = CurrTool And SubType = MachiningSubType And VerifyMatThickCompatibility() Then
|
|
MachiningList.Add(MachiningName)
|
|
End If
|
|
bFound = EgtMdbGetNextMachining(MachiningType, MachiningName)
|
|
End While
|
|
' Aggiungo la lavorazione nulla
|
|
MachiningList.Add(NO_MACHINING)
|
|
End Sub
|
|
|
|
Private Function VerifyMatThickCompatibility() As Boolean
|
|
If Not IsNothing(m_CurrMachine.CurrMat) Then
|
|
Dim SysNotes As String = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.SYSNOTES, SysNotes)
|
|
If SysNotes <> String.Empty Then
|
|
Dim MachiningMaterials() = SysNotes.Split(";".ToCharArray)
|
|
SysNotes = String.Empty
|
|
For Each Material In MachiningMaterials
|
|
Dim Param() As String = Material.Split(",".ToCharArray)
|
|
If Param(0) = m_CurrMachine.CurrMat.nId.ToString() Then
|
|
Dim dRawHeight = GetRawHeight()
|
|
Dim MatMinH As Double = 0
|
|
StringToDouble(Param(1), MatMinH)
|
|
Dim MatMaxH As Double = 0
|
|
StringToDouble(Param(2), MatMaxH)
|
|
If dRawHeight > MatMinH - EPS_SMALL And dRawHeight < MatMaxH + EPS_SMALL Then
|
|
Return True
|
|
End If
|
|
End If
|
|
Next
|
|
Return False
|
|
Else
|
|
Return True
|
|
End If
|
|
Else
|
|
Return True
|
|
End If
|
|
End Function
|
|
|
|
Private Sub FrameCutPage_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded
|
|
' Nascondo tutte le lavorazioni
|
|
HideAllMachinings()
|
|
' La dichiaro non attiva
|
|
m_bActive = False
|
|
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
|
|
' Verifico se selezionato indicativo di pezzo
|
|
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
|
|
' Recupero l'identificativo del pezzo cui appartiene
|
|
Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
|
|
Dim bPartInTable As Boolean = (EgtGetParent(nPartId) = m_nRawId)
|
|
If bPartInTable Then
|
|
Dim nStat As Integer = GDB_ST.ON_
|
|
EgtGetStatus(nPartId, nStat)
|
|
EgtSetStatus(nPartId, If(nStat = GDB_ST.SEL, GDB_ST.ON_, GDB_ST.SEL))
|
|
EgtDraw()
|
|
Exit While
|
|
End If
|
|
nId = EgtGetNextObjInSelWin()
|
|
End While
|
|
End Sub
|
|
|
|
Private Sub OffsXXTxBx_EgtClosed(sender As Object, e As EventArgs) Handles OffsZTxBx.EgtClosed, OffsXyTxBx.EgtClosed
|
|
' Forzo aggiornamento grezzo nella pagina di Nesting
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.CalcRawPart()
|
|
' Parcheggio pezzi presenti nel grezzo
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(m_CurrProjPage.m_nRawId)
|
|
While nPartId <> GDB_ID.NULL
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.StoreOnePart(nPartId)
|
|
nPartId = EgtGetFirstPartInRawPart(m_CurrProjPage.m_nRawId)
|
|
End While
|
|
' Aggiorno geometria
|
|
UpdateFrames()
|
|
' Ricalcolo lavorazioni
|
|
AddFrameMachinings()
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
' Salvo offset in Z dal sopra del grezzo e in XY da angolo in basso a sx
|
|
Dim dOffsZ As Double = 0
|
|
If StringToLen(OffsZTxBx.Text, dOffsZ) Then
|
|
WritePrivateProfileString(S_FRAME, K_OFFSZ, DoubleToString(dOffsZ, 3), m_MainWindow.GetIniFile())
|
|
End If
|
|
Dim dOffsXy As Double = 0
|
|
If StringToLen(OffsXyTxBx.Text, dOffsXy) Then
|
|
WritePrivateProfileString(S_FRAME, K_OFFSXY, DoubleToString(dOffsXy, 3), m_MainWindow.GetIniFile())
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub MirrorPartBtn_Click(sender As Object, e As RoutedEventArgs) Handles MirrorPartBtn.Click
|
|
' Se non ci sono pezzi selezionati, esco subito
|
|
If EgtGetSelectedObjCount() = 0 Then Return
|
|
' Ciclo di mirror dei pezzi selezionati
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
' Recupero box del pezzo
|
|
Dim b3Box As New BBox3d
|
|
EgtGetBBoxGlob(nId, GDB_BB.STANDARD, b3Box)
|
|
' Eseguo mirror
|
|
EgtMirror(nId, b3Box.Center(), If(m_CurrAx = 0, Vector3d.Y_AX(), Vector3d.X_AX()), GDB_RT.GLOB)
|
|
' Passo al successivo selezionato
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' Ricalcolo lavorazioni
|
|
AddFrameMachinings()
|
|
' Aggiorno vista
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub RemovePartBtn_Click(sender As Object, e As RoutedEventArgs) Handles RemovePartBtn.Click
|
|
' Se non ci sono pezzi selezionati, esco subito
|
|
If EgtGetSelectedObjCount() = 0 Then Return
|
|
' Ciclo di cancellazione dei pezzi selezionati
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
' Recupero indice del successivo
|
|
Dim nNextId = EgtGetNextSelectedObj()
|
|
' Cancello il pezzo
|
|
If EgtRemovePartFromRawPart(nId) Then
|
|
' Rimuovo le lavorazioni
|
|
EraseMachinings(nId)
|
|
' Cancello
|
|
EgtErase(nId)
|
|
End If
|
|
' Passo al successivo selezionato
|
|
nId = nNextId
|
|
End While
|
|
' Aggiusto posizione dei rimanenti pezzi nel grezzo
|
|
nId = EgtGetFirstPartInRawPart(m_nRawId)
|
|
While nId <> GDB_ID.NULL
|
|
EgtRemovePartFromRawPart(nId)
|
|
nId = EgtGetFirstPartInRawPart(m_nRawId)
|
|
End While
|
|
nId = EgtGetFirstPart()
|
|
While nId <> GDB_ID.NULL
|
|
InsertPartInRawPart(nId)
|
|
nId = EgtGetFirstPart()
|
|
End While
|
|
' Ricalcolo lavorazioni
|
|
AddFrameMachinings()
|
|
' Aggiorno vista
|
|
EgtDraw()
|
|
' Aggiorno combo per direzioni
|
|
UpdateAlongAxCmbBx()
|
|
End Sub
|
|
|
|
Private Sub SawRoughingCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles SawRoughingCmBx.SelectionChanged
|
|
If m_DisableCalc Or IsNothing(SawRoughingCmBx.SelectedItem) Then Return
|
|
' La imposto come lavorazione corrente di sgrossatura con lama
|
|
If SawRoughingCmBx.SelectedItem.ToString() <> NO_MACHINING Then
|
|
m_CurrMachine.sCurrSawRoughing = SawRoughingCmBx.SelectedItem.ToString()
|
|
Else
|
|
m_CurrMachine.sCurrSawRoughing = String.Empty
|
|
End If
|
|
' La inserisco
|
|
AddFrameSawRoughing()
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub SawFinishingCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles SawFinishingCmBx.SelectionChanged
|
|
If m_DisableCalc Or IsNothing(SawFinishingCmBx.SelectedItem) Then Return
|
|
' La imposto come lavorazione corrente di finitura con lama
|
|
If SawFinishingCmBx.SelectedItem.ToString() <> NO_MACHINING Then
|
|
m_CurrMachine.sCurrSawFinishing = SawFinishingCmBx.SelectedItem.ToString()
|
|
Else
|
|
m_CurrMachine.sCurrSawFinishing = String.Empty
|
|
End If
|
|
' La inserisco
|
|
AddFrameSawFinishing()
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub SawSideFinCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles SawSideFinCmBx.SelectionChanged
|
|
If m_DisableCalc Or IsNothing(SawSideFinCmBx.SelectedItem) Then Return
|
|
' La imposto come lavorazione corrente di finitura con lama
|
|
If SawSideFinCmBx.SelectedItem.ToString() <> NO_MACHINING Then
|
|
m_CurrMachine.sCurrSawSideFinishing = SawSideFinCmBx.SelectedItem.ToString()
|
|
Else
|
|
m_CurrMachine.sCurrSawSideFinishing = String.Empty
|
|
End If
|
|
' La inserisco
|
|
AddFrameSawSideFinishing()
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub PhotoBtn_Click(sender As Object, e As RoutedEventArgs) Handles PhotoBtn.Click
|
|
' Se macchina fotografica abilitata, faccio una foto
|
|
If m_Camera.GetCameraLink() Then
|
|
If Not m_Camera.CameraClick() Then
|
|
m_CurrProjPage.SetErrorMessage(EgtMsg(90313)) 'Fotografia non riuscita
|
|
End If
|
|
' Altrimenti lancio browser di immagini
|
|
Else
|
|
m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_CurrentProjectPageUC)
|
|
m_MainWindow.MainWindowGrid.Children.Add(m_MainWindow.m_PhotoPage)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.Photo
|
|
m_MainWindow.m_PrevActivePage = MainWindow.Pages.FrameCut
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub RawPartBtn_Click(sender As Object, e As RoutedEventArgs) Handles RawPartBtn.Click
|
|
m_MainWindow.m_CurrentProjectPageUC.CurrProjGrid.Visibility = Windows.Visibility.Hidden
|
|
m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Remove(Me)
|
|
m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_RawPartPage)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.RawPart
|
|
m_MainWindow.m_PrevActivePage = MainWindow.Pages.FrameCut
|
|
End Sub
|
|
|
|
Private Sub ImportBtn_Click(sender As Object, e As RoutedEventArgs) Handles ImportBtn.Click
|
|
m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_CurrentProjectPageUC)
|
|
m_MainWindow.MainWindowGrid.Children.Add(m_MainWindow.m_ImportPageUC)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.Import
|
|
m_MainWindow.m_PrevActivePage = MainWindow.Pages.FrameCut
|
|
End Sub
|
|
|
|
Friend Function CreateFrame(nPartId As Integer) As Boolean
|
|
' Aggiorno direzione corrente
|
|
m_CurrAx = AlongAxCmBx.SelectedIndex
|
|
' Sistemo la sezione della cornice
|
|
If Not AdjustSection(nPartId) Then Return False
|
|
' Recupero layer e curva della sezione
|
|
Dim nSectLayId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_SECT)
|
|
Dim nCrvId As Integer = EgtGetFirstInGroup(nSectLayId)
|
|
If nCrvId = GDB_ID.NULL Then Return False
|
|
' Porto la sezione nel piano opportuno e calcolo il vettore di estrusione
|
|
Dim vtExtr As Vector3d
|
|
If m_CurrAx = 0 Then
|
|
' Se lungo X nel piano YZ
|
|
EgtChangeGroupFrame(nSectLayId, New Frame3d(Point3d.ORIG, Frame3d.TYPE.LEFT))
|
|
vtExtr = New Vector3d(m_RawBox.DimX() - 2 * m_dKerf, 0, 0)
|
|
Else
|
|
' Se lungo Y nel piano XZ
|
|
EgtChangeGroupFrame(nSectLayId, New Frame3d(Point3d.ORIG, Frame3d.TYPE.FRONT))
|
|
vtExtr = New Vector3d(0, m_RawBox.DimY() - 2 * m_dKerf, 0)
|
|
End If
|
|
' Creo layer per la linea guida
|
|
Dim nGuideLayId As Integer = EgtCreateGroup(nPartId, New Frame3d())
|
|
EgtSetName(nGuideLayId, NAME_GUIDE)
|
|
EgtSetColor(nGuideLayId, COL_FRAME())
|
|
' Creo la linea guida
|
|
Dim ptStart As Point3d
|
|
EgtStartPoint(nCrvId, nGuideLayId, ptStart)
|
|
EgtCreateLine(nGuideLayId, ptStart, ptStart + vtExtr)
|
|
' Creo layer per la superficie
|
|
Dim nSurfLayId As Integer = EgtCreateGroup(nPartId, New Frame3d())
|
|
EgtSetName(nSurfLayId, NAME_SURF)
|
|
EgtSetColor(nSurfLayId, COL_FRAME())
|
|
' Creo la superficie di estrusione
|
|
Dim nSectIds(0) As Integer
|
|
nSectIds(0) = nCrvId
|
|
Dim nSurfId As Integer = EgtCreateSurfTmByRegionExtrusion(nSurfLayId, 1, nSectIds, vtExtr, GDB_RT.GLOB)
|
|
' Assegno nome e direzione a pezzo
|
|
EgtSetName(nPartId, NAME_FRAME)
|
|
EgtSetInfo(nPartId, INFO_FRAME_DIR, m_CurrAx)
|
|
' Inserisco il pezzo nel grezzo
|
|
Return InsertPartInRawPart(nPartId)
|
|
End Function
|
|
|
|
Friend Function UpdateFrames() As Boolean
|
|
Dim nId As Integer = EgtGetFirstPart()
|
|
While nId <> GDB_ID.NULL
|
|
If Not UpdateFrame(nId) Then
|
|
EgtErase(nId)
|
|
End If
|
|
nId = EgtGetFirstPart()
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function UpdateFrame(nPartId As Integer) As Boolean
|
|
' Aggiorno direzione corrente
|
|
m_CurrAx = AlongAxCmBx.SelectedIndex
|
|
' Recupero layer e curva della sezione
|
|
Dim nSectLayId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_SECT)
|
|
Dim nCrvId As Integer = EgtGetFirstInGroup(nSectLayId)
|
|
If nCrvId = GDB_ID.NULL Then Return False
|
|
' Porto la sezione nel piano opportuno e calcolo il vettore di estrusione
|
|
Dim vtExtr As Vector3d
|
|
If m_CurrAx = 0 Then
|
|
' Se lungo X nel piano YZ
|
|
EgtChangeGroupFrame(nSectLayId, New Frame3d(Point3d.ORIG, Frame3d.TYPE.LEFT))
|
|
vtExtr = New Vector3d(m_RawBox.DimX() - 2 * m_dKerf, 0, 0)
|
|
Else
|
|
' Se lungo Y nel piano XZ
|
|
EgtChangeGroupFrame(nSectLayId, New Frame3d(Point3d.ORIG, Frame3d.TYPE.FRONT))
|
|
vtExtr = New Vector3d(0, m_RawBox.DimY() - 2 * m_dKerf, 0)
|
|
End If
|
|
' Recupero layer per la linea guida
|
|
Dim nGuideLayId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_GUIDE)
|
|
If nGuideLayId = GDB_ID.NULL Then
|
|
nGuideLayId = EgtCreateGroup(nPartId, New Frame3d())
|
|
EgtSetName(nGuideLayId, NAME_GUIDE)
|
|
Else
|
|
EgtEmptyGroup(nGuideLayId)
|
|
End If
|
|
EgtSetColor(nGuideLayId, COL_FRAME())
|
|
' Creo la linea guida
|
|
Dim ptStart As Point3d
|
|
EgtStartPoint(nCrvId, nGuideLayId, ptStart)
|
|
EgtCreateLine(nGuideLayId, ptStart, ptStart + vtExtr)
|
|
' Recupero layer per la superficie
|
|
Dim nSurfLayId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_SURF)
|
|
If nSurfLayId = GDB_ID.NULL Then
|
|
nSurfLayId = EgtCreateGroup(nPartId, New Frame3d())
|
|
EgtSetName(nSurfLayId, NAME_SURF)
|
|
Else
|
|
EgtEmptyGroup(nSurfLayId)
|
|
End If
|
|
EgtSetColor(nSurfLayId, COL_FRAME())
|
|
' Creo la superficie di estrusione
|
|
Dim nSectIds(0) As Integer
|
|
nSectIds(0) = nCrvId
|
|
Dim nSurfId As Integer = EgtCreateSurfTmByRegionExtrusion(nSurfLayId, 1, nSectIds, vtExtr, GDB_RT.GLOB)
|
|
' Assegno nome e direzione a pezzo
|
|
EgtSetName(nPartId, NAME_FRAME)
|
|
EgtSetInfo(nPartId, INFO_FRAME_DIR, m_CurrAx)
|
|
' Inserisco il pezzo nel grezzo
|
|
Return InsertPartInRawPart(nPartId)
|
|
End Function
|
|
|
|
Private Function AdjustSection(nPartId As Integer) As Boolean
|
|
' Recupero identificativo del primo layer
|
|
Dim nLayerId As Integer = EgtGetFirstLayer(nPartId)
|
|
' Concateno le curve del primo layer
|
|
EgtSelectLayerObjs(nLayerId)
|
|
Dim nCrvIds(0) As Integer
|
|
nCrvIds(0) = GDB_ID.SEL
|
|
Dim nCrvId As Integer = EgtCreateCurveCompoByChain(nLayerId, 1, nCrvIds, New Point3d(), True)
|
|
If nCrvId = GDB_ID.NULL Then Return False
|
|
' Elimino eventuali curve oltre la prima
|
|
Dim nId As Integer = EgtGetNext(nCrvId)
|
|
While nId <> GDB_ID.NULL
|
|
Dim nNextId = EgtGetNext(nId)
|
|
EgtErase(nId)
|
|
nId = nNextId
|
|
End While
|
|
' Verifico se curva piana e ne recupero il piano medio
|
|
Dim vtN As Vector3d
|
|
Dim dDist As Double
|
|
If Not EgtCurveIsFlat(nCrvId, vtN, dDist) Then
|
|
EgtProjectCurveOnPlane(nCrvId, Point3d.ORIG + dDist * vtN, vtN)
|
|
End If
|
|
' Creo layer sezione con riferimento OCS del piano
|
|
Dim frPlane As New Frame3d
|
|
frPlane.Setup(Point3d.ORIG, vtN.Glob(nLayerId))
|
|
Dim nSectLayId As Integer = EgtCreateGroup(nPartId, frPlane, GDB_RT.GLOB)
|
|
EgtSetName(nSectLayId, NAME_SECT)
|
|
EgtSetColor(nSectLayId, COL_FRAME())
|
|
EgtRelocateGlob(nCrvId, nSectLayId)
|
|
' Elimino vecchio layer
|
|
EgtErase(nLayerId)
|
|
' Verifico chiusura sezione
|
|
If Not EgtCurveIsClosed(nCrvId) Then
|
|
' Recupero ingombro locale
|
|
Dim b3Box As New BBox3d
|
|
EgtGetBBox(nCrvId, GDB_BB.STANDARD, b3Box)
|
|
' Recupero estremi
|
|
Dim ptStart, ptEnd As Point3d
|
|
EgtStartPoint(nCrvId, ptStart)
|
|
EgtEndPoint(nCrvId, ptEnd)
|
|
' Deve andare da dx a sn
|
|
If ptStart.x < ptEnd.x Then
|
|
EgtInvertCurve(nCrvId)
|
|
Dim ptTmp As Point3d = New Point3d(ptEnd)
|
|
ptEnd = ptStart
|
|
ptStart = ptTmp
|
|
End If
|
|
' Eseguo chiusura
|
|
If ptEnd.y > b3Box.Min().y + 5 * EPS_SMALL Then
|
|
EgtAddCurveCompoLine(nCrvId, New Point3d(ptEnd.x, b3Box.Min().y, ptEnd.z))
|
|
ElseIf ptStart.y > b3Box.Min().y + 5 * EPS_SMALL Then
|
|
EgtInvertCurve(nCrvId)
|
|
EgtAddCurveCompoLine(nCrvId, New Point3d(ptStart.x, b3Box.Min().y, ptStart.z))
|
|
EgtInvertCurve(nCrvId)
|
|
End If
|
|
EgtCloseCurveCompo(nCrvId)
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Private Function InsertPartInRawPart(nPartId As Integer) As Boolean
|
|
' Determino ingombro del pezzo
|
|
Dim PartBox As New BBox3d
|
|
EgtGetBBoxGlob(nPartId, GDB_BB.IGNORE_TEXT + GDB_BB.IGNORE_DIM, PartBox)
|
|
' Determino ingombro di eventuali pezzi già presenti
|
|
Dim OtherBox As New BBox3d
|
|
Dim nId2 As Integer = EgtGetFirstPartInRawPart(m_nRawId)
|
|
While nId2 <> GDB_ID.NULL
|
|
Dim TmpBox As New BBox3d
|
|
If EgtGetBBoxGlob(nId2, GDB_BB.IGNORE_TEXT + GDB_BB.IGNORE_DIM, TmpBox) Then
|
|
OtherBox.Add(TmpBox)
|
|
End If
|
|
nId2 = EgtGetNextPartInRawPart(nId2)
|
|
End While
|
|
' Determino distanza da spessore lama
|
|
Dim dMinDist As Double = 0
|
|
Dim dSawThick As Double = 0
|
|
If EgtTdbSetCurrTool(m_MainWindow.m_CurrentMachine.sCurrSaw) AndAlso
|
|
EgtTdbGetCurrToolParam(MCH_TP.THICK, dSawThick) Then
|
|
dMinDist = dSawThick + 5 * EPS_SMALL
|
|
Else
|
|
EgtOutLog("Not found current saw for frames mindist")
|
|
dMinDist = 0
|
|
End If
|
|
' Inserisco il pezzo nel grezzo
|
|
Dim ptIns As Point3d
|
|
If OtherBox.IsEmpty() Then
|
|
Dim dOffsXy As Double = 0
|
|
StringToLen(OffsXyTxBx.Text, dOffsXy)
|
|
If m_CurrAx = 0 Then
|
|
ptIns.x = m_dKerf
|
|
ptIns.y = m_dKerf + dOffsXy
|
|
Else
|
|
ptIns.x = m_dKerf + dOffsXy
|
|
ptIns.y = m_dKerf
|
|
End If
|
|
Else
|
|
If m_CurrAx = 0 Then
|
|
ptIns.x = m_dKerf
|
|
ptIns.y = OtherBox.Max().y - m_RawBox.Min().y + dMinDist
|
|
Else
|
|
ptIns.x = OtherBox.Max().x - m_RawBox.Min().x + dMinDist
|
|
ptIns.y = m_dKerf
|
|
End If
|
|
End If
|
|
Dim dOffsZ As Double = 0
|
|
StringToLen(OffsZTxBx.Text, dOffsZ)
|
|
ptIns.z = (m_RawBox.Max().z - m_RawBox.Min().z) - (PartBox.Max().z - PartBox.Min().z) - dOffsZ
|
|
ptIns.z = Math.Max(ptIns.z, 0)
|
|
Return EgtAddPartToRawPart(nPartId, ptIns, EgtGetFirstRawPart())
|
|
End Function
|
|
|
|
End Class
|