diff --git a/ConstGen.vb b/ConstGen.vb index 812254d..19383e9 100644 --- a/ConstGen.vb +++ b/ConstGen.vb @@ -83,8 +83,6 @@ Module ConstGen ' Nome della superficie del grezzo Public Const NAME_RAW_SOLID As String = "RawSolid" - ' Nome del centro del grezzo - Public Const NAME_RAW_CENTER As String = "RawCenter" ' Nome del contorno di kerf nel grezzo Public Const NAME_KERF As String = "Kerf" ' Chiave per info di kerf nel grezzo @@ -213,6 +211,9 @@ Module ConstGen ' Nome della lavorazione di spatolatura cornici Public Const NAME_FRAME_SAWSIDEFIN As String = "FrameSawSideFin" + ' Nome di pezzo per tagli diretti + Public Const NAME_DIRECTCUT As String = "DirectCut" + ' Nome di pezzo temporaneo che serve per copia dime Public Const NAME_COPYTEMPLATE As String = "CopyTemplate" diff --git a/CurrentProjectPageUC.xaml.vb b/CurrentProjectPageUC.xaml.vb index 6b87b44..2b23d39 100644 --- a/CurrentProjectPageUC.xaml.vb +++ b/CurrentProjectPageUC.xaml.vb @@ -101,11 +101,11 @@ Public Class CurrentProjectPageUC ' Rimuovo l'host della scena perchè altrimenti rimarrebbe il buco!! Me.CurrentProjectPageGrid.Children.Remove(CurrentProjectSceneHost) Dim MissingKeyWnd As EgtMsgBox - If m_MainWindow.IsSiemensPc Then - MissingKeyWnd = New EgtMsgBox(m_MainWindow, Me.ActualWidth / 15 * 5, EgtMsgBox.WidthType.PIXEL, EgtMsg(MSG_MISSINGKEYWD + 1), EgtMsg(MSG_MISSINGKEYWD + 2) & " " & EgtMsg(MSG_MISSINGKEYWD + 3), EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.NULL) - Else - MissingKeyWnd = New EgtMsgBox(m_MainWindow, EgtMsg(MSG_MISSINGKEYWD + 1), EgtMsg(MSG_MISSINGKEYWD + 2) & " " & EgtMsg(MSG_MISSINGKEYWD + 3), EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.NULL) - End If +#If TRIAL Then + MissingKeyWnd = New EgtMsgBox(m_MainWindow, EgtMsg(MSG_MISSINGKEYWD + 1), EgtMsg(MSG_MISSINGKEYWD + 5) & " " & EgtMsg(MSG_MISSINGKEYWD + 7), EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.NULL, 0, 1) +#Else + MissingKeyWnd = New EgtMsgBox(m_MainWindow, EgtMsg(MSG_MISSINGKEYWD + 1), EgtMsg(MSG_MISSINGKEYWD + 2) & " " & EgtMsg(MSG_MISSINGKEYWD + 3), EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.NULL) +#End If m_MainWindow.Close() End If ' dimensione lineare max in pixel delle textures diff --git a/DirectCut.vb b/DirectCut.vb new file mode 100644 index 0000000..5ae503b --- /dev/null +++ b/DirectCut.vb @@ -0,0 +1,30 @@ +Imports EgtUILib + +Module DirectCut + ' Riferimenti a pagine + Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow) + + Friend Function CreateDirectCutPart() As Integer + Dim nPartId = EgtCreateGroup(GDB_ID.ROOT) + EgtSetName(nPartId, NAME_DIRECTCUT) + Return nPartId + End Function + + Friend Function EraseDirectCutPart() As Boolean + ' Recupero identificativo del pezzo + Dim nPartId As Integer = EgtGetFirstNameInGroup(m_MainWindow.m_CurrentProjectPageUC.m_nRawId, NAME_DIRECTCUT) + If nPartId = GDB_ID.NULL Then Return True + ' Cancello le lavorazioni + EraseMachinings(nPartId) + ' Tolgo il pezzo dal grezzo + EgtRemovePartFromRawPart(nPartId) + ' Cancello il pezzo + EgtErase(nPartId) + Return True + End Function + + Friend Function GetDirectCutPart() As Integer + Return EgtGetFirstNameInGroup(m_MainWindow.m_CurrentProjectPageUC.m_nRawId, NAME_DIRECTCUT) + End Function + +End Module diff --git a/DirectCutPageUC.xaml.vb b/DirectCutPageUC.xaml.vb index e7a917a..9d8ef57 100644 --- a/DirectCutPageUC.xaml.vb +++ b/DirectCutPageUC.xaml.vb @@ -20,7 +20,7 @@ Public Class DirectCutPageUC Friend m_CN As CN_generico Private m_bFirst As Boolean = True ' Riferimento alla pagina correntemente attiva - Friend m_ActiveDirectCutPage As DirectCutPages + Friend m_ActiveDirectCutPage As DirectCutPages = DirectCutPages.DirectCut Enum DirectCutPages DirectCut @@ -72,14 +72,30 @@ Public Class DirectCutPageUC End Sub Private Sub DirectCutPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded + + ' Se rientro da simulazione + If m_ActiveDirectCutPage = DirectCutPages.SingleCut Then + LeftButtonGrid.Children.Add(m_SingleCut) + Return + ElseIf m_ActiveDirectCutPage = DirectCutPages.MultipleCut Then + LeftButtonGrid.Children.Add(m_MultipleCut) + Return + ElseIf m_ActiveDirectCutPage = DirectCutPages.GridCut Then + LeftButtonGrid.Children.Add(m_GridCut) + Return + ElseIf m_ActiveDirectCutPage = DirectCutPages.FlatteningCut Then + LeftButtonGrid.Children.Add(m_FlatteningCut) + Return + ElseIf m_ActiveDirectCutPage = DirectCutPages.SawTest Then + LeftButtonGrid.Children.Add(m_SawTest) + Return + End If + + ' Caso standard m_ActiveDirectCutPage = DirectCutPages.DirectCut ' Se macchina fotografica abilitata - If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.MAN_PHOTO) Then - PhotoBtn.IsEnabled = True - Else - PhotoBtn.IsEnabled = False - End If + PhotoBtn.IsEnabled = m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.MAN_PHOTO) ' Attivo le lavorazioni solo se esiste il grezzo Dim bRawOk As Boolean = (GetRawHeight() > EPS_SMALL) diff --git a/FlatteningCut.xaml b/FlatteningCut.xaml index 75b2e3c..b08593a 100644 --- a/FlatteningCut.xaml +++ b/FlatteningCut.xaml @@ -85,11 +85,19 @@ - + + diff --git a/FlatteningCut.xaml.vb b/FlatteningCut.xaml.vb index a176f84..d3ffa3c 100644 --- a/FlatteningCut.xaml.vb +++ b/FlatteningCut.xaml.vb @@ -7,6 +7,8 @@ Public Class FlatteningCut Private WithEvents m_CurrProjPage As CurrentProjectPageUC ' Flag di pagina attiva Private m_bActive As Boolean = False + ' Flag di simulazione in corso + Private m_bSimul As Boolean = False ' Origine tavola e dati grezzo Private m_bRawOk As Boolean = False @@ -45,8 +47,6 @@ Public Class FlatteningCut Private Const MIN_CUT_LEN As Double = 10.0 Private Const MIN_CUT_WID As Double = 10.0 Private Const MAX_SIDE_ANG As Double = 60.0 - Private Const DIRECTCUT As String = "DirectCut" - Private Const RAW_CENTER As String = "RawCenter" ' Costanti che indicano la modalità di acquisizione dei punti Private Enum PT_MODE As Integer SAW = 0 @@ -71,12 +71,12 @@ Public Class FlatteningCut m_PointsModeArray(PT_MODE.DRAW) = EgtMsg(MSG_DIRECTCUTPAGEUC + 25) ' la associo alla combobox PointModeCmBx.ItemsSource = m_PointsModeArray - + ' Creo lista tipo lavorazione m_TypeArray(MACH_TYPE.ONEWAY) = EgtMsg(MSG_COMBOBOXPARAM + 39) m_TypeArray(MACH_TYPE.ZIGZAG) = EgtMsg(MSG_COMBOBOXPARAM + 38) ' la associo alla combobox TypeCmBx.ItemsSource = m_TypeArray - + ' assegno messaggi Point1Btn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 10) Point2Btn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 11) DepthTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 13) @@ -85,18 +85,25 @@ Public Class FlatteningCut WidthTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 26) OverlapTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 27) SideChBx.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 23) + SimulBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 1) OkBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 30) - End Sub Private Sub FlatteningCut_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded + ' Attivo la pagina m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC m_bActive = True + ' Se rientro da simulazione + If m_bSimul Then + m_bSimul = False + ' Disabilito registrazione progetto modificato + EgtDisableModified() + Return + End If ' Reset punto acquisito m_bPointP1Ok = False ' Inizializzo primo punto acquisito dal disegno come centro del grezzo - Dim nRawPartCenter As Integer = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, RAW_CENTER) - EgtStartPoint(nRawPartCenter, GDB_ID.ROOT, m_ptPrev) + GetRawCenter(m_ptPrev) ' Imposto modalità di acquisizione punti PointModeCmBx.SelectedIndex = PT_MODE.DRAW ' Imposto tipo di lavorazione della spianatura @@ -121,7 +128,7 @@ Public Class FlatteningCut End If ' Reset taglio e disabilito bottone esecuzione m_bCutOk = False - UpdateOkBtn() + UpdateSimulOkBtn() ' Disabilito bottone secondo punto Point2Btn.IsEnabled = False ' Deseleziono bottone primo punto @@ -134,27 +141,35 @@ Public Class FlatteningCut End Sub Friend Sub FlatteningCut_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded - ' Rimuovo layer temporaneo per crocette - EgtErase(m_nTempLay) - ' Rimuovo eventuale pezzo per taglio diretto - EraseDirectCutPart() - ' Riattivo eventuali lavorazioni presenti - ActivateAllMachinings() - ' Abilito registrazione progetto modificato - EgtEnableModified() - ' Nascondo la macchina - m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False - EgtSetMachineLook(MCH_LOOK.TAB) - EgtDraw() + If Not m_bSimul Then + ' Dichiaro sottopagina da non riattivare + m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut + ' Rimuovo layer temporaneo per crocette + EgtErase(m_nTempLay) + ' Rimuovo eventuale pezzo per taglio diretto + EraseDirectCutPart() + ' Riattivo eventuali lavorazioni presenti + ActivateAllMachinings() + ' Abilito registrazione progetto modificato + EgtEnableModified() + ' Nascondo la macchina + m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False + EgtSetMachineLook(MCH_LOOK.TAB) + EgtDraw() + End If ' Dichiaro pagina non attiva m_bActive = False End Sub - Private Sub UpdateOkBtn() + Private Sub UpdateSimulOkBtn() If m_bCutOk Then + SimulBtn.IsEnabled = True + SimulBtn.Foreground = Brushes.Black OkBtn.IsEnabled = True OkBtn.Foreground = Brushes.Black Else + SimulBtn.IsEnabled = False + SimulBtn.Foreground = Brushes.DarkGray OkBtn.IsEnabled = False OkBtn.Foreground = Brushes.DarkGray End If @@ -195,48 +210,31 @@ Public Class FlatteningCut ' Reset punto non acquisito m_bPointP1Ok = False ' Verifico configurazione tavola e grezzo - If Not m_bRawOk Then - Return - End If + If Not m_bRawOk Then Return ' Se acquisizone lama o laser If PointModeCmBx.SelectedIndex = PT_MODE.SAW Or PointModeCmBx.SelectedIndex = PT_MODE.LASER Then - ' Recupero la posizione macchina Dim dL1, dL2, dL3, dR1, dR2 As Double - If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then - Return - End If + If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then Return ' Ricavo dati lama corrente Dim sSaw As String = m_MainWindow.m_CurrentMachine.sCurrSaw ' Se punto da laser If PointModeCmBx.SelectedIndex = PT_MODE.LASER Then ' Imposto come testa corrente il laser (senza utensile ovviamente) - If Not EgtSetCalcTool("", "H3", 1) Then - Return - End If + If Not EgtSetCalcTool("", "H3", 1) Then Return ' Trasformo in posizione punta utensile in basso - If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP1) Then - Return - End If + If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP1) Then Return ' Ora imposto la lama corrente - If Not EgtSetCalcTool(sSaw, "H1", 1) Then - Return - End If - ' Altrimenti da lama + If Not EgtSetCalcTool(sSaw, "H1", 1) Then Return + ' Altrimenti da lama Else ' Imposto la lama corrente - If Not EgtSetCalcTool(sSaw, "H1", 1) Then - Return - End If + If Not EgtSetCalcTool(sSaw, "H1", 1) Then Return ' Trasformo in posizione punta utensile in basso - If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP1) Then - Return - End If + If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP1) Then Return End If ' Calcolo direzione asse lama - If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtToolP1) Then - Return - End If + If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtToolP1) Then Return ' Porto il tip nell'origine tavola m_ptTipP1.ToLoc(New Frame3d(m_ptTabOri)) m_bPointP1Ok = True @@ -264,6 +262,7 @@ Public Class FlatteningCut m_dAngO = dTAngO + 90 m_dAngV = 90 - dTAngV DirectionTxBx.Text = DoubleToString(m_dAngO - m_MainWindow.m_CurrentMachine.dDeltaC, 2) + ' Altrimenti da disegno Else ' Assegno punto selezionato nel disegno a m_ptTipP1 m_ptTipP1 = m_ptPrev @@ -273,9 +272,7 @@ Public Class FlatteningCut ' Ricavo dati lama corrente Dim sSaw As String = m_MainWindow.m_CurrentMachine.sCurrSaw ' Imposto la lama corrente - If Not EgtSetCalcTool(sSaw, "H1", 1) Then - Return - End If + If Not EgtSetCalcTool(sSaw, "H1", 1) Then Return 'Disegno macchina nella sua posizione reale Dim dL1, dL2, dL3, dR1, dR2 As Double m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) @@ -315,48 +312,31 @@ Public Class FlatteningCut ' Reset punto non acquisito m_bPointP2Ok = False ' Verifico configurazione tavola e grezzo - If Not m_bRawOk Then - Return - End If + If Not m_bRawOk Then Return ' Se acquisizone lama o laser If PointModeCmBx.SelectedIndex = PT_MODE.SAW Or PointModeCmBx.SelectedIndex = PT_MODE.LASER Then - ' Recupero la posizione macchina Dim dL1, dL2, dL3, dR1, dR2 As Double - If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then - Return - End If + If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then Return ' Ricavo dati lama corrente Dim sSaw As String = m_MainWindow.m_CurrentMachine.sCurrSaw ' Se punto da laser If PointModeCmBx.SelectedIndex = PT_MODE.LASER Then ' Imposto come testa corrente il laser (senza utensile ovviamente) - If Not EgtSetCalcTool("", "H3", 1) Then - Return - End If + If Not EgtSetCalcTool("", "H3", 1) Then Return ' Trasformo in posizione punta utensile in basso - If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP2) Then - Return - End If + If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP2) Then Return ' Ora imposto la lama corrente - If Not EgtSetCalcTool(sSaw, "H1", 1) Then - Return - End If - ' Altrimenti da lama + If Not EgtSetCalcTool(sSaw, "H1", 1) Then Return + ' Altrimenti da lama Else ' Imposto la lama corrente - If Not EgtSetCalcTool(sSaw, "H1", 1) Then - Return - End If + If Not EgtSetCalcTool(sSaw, "H1", 1) Then Return ' Trasformo in posizione punta utensile in basso - If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP2) Then - Return - End If + If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP2) Then Return End If ' Calcolo direzione asse lama - If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtToolP2) Then - Return - End If + If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtToolP2) Then Return ' Porto il tip nell'origine tavola m_ptTipP2.ToLoc(New Frame3d(m_ptTabOri)) m_bPointP2Ok = True @@ -382,6 +362,7 @@ Public Class FlatteningCut Dim dTLen, dTAngV, dTAngO As Double m_vtToolP2.ToSpherical(dTLen, dTAngV, dTAngO) m_dAngV = 90 - dTAngV + ' Altrimenti da disegno Else ' Assegno punto selezionato nel disegno a m_ptTipP2 m_ptTipP2 = m_ptPrev @@ -391,9 +372,7 @@ Public Class FlatteningCut ' Ricavo dati lama corrente Dim sSaw As String = m_MainWindow.m_CurrentMachine.sCurrSaw ' Imposto la lama corrente - If Not EgtSetCalcTool(sSaw, "H1", 1) Then - Return - End If + If Not EgtSetCalcTool(sSaw, "H1", 1) Then Return 'Disegno macchina nella sua posizione reale Dim dL1, dL2, dL3, dR1, dR2 As Double m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) @@ -491,6 +470,9 @@ Public Class FlatteningCut StringToDouble(DirectionTxBx.Text, dDirection) dDirection += m_MainWindow.m_CurrentMachine.dDeltaC m_dAngO = dDirection + ' Dichiaro non più usato P2 + m_bPointP2Ok = False + Point2Btn.IsChecked = False ' Disegno il taglio CreateFlatteningCut() EgtDraw() @@ -536,6 +518,23 @@ Public Class FlatteningCut EgtDraw() End Sub + Private Sub SimulBtn_Click(sender As Object, e As RoutedEventArgs) Handles SimulBtn.Click + ' Verifico ci sia un taglio valido + If Not m_bCutOk Then Return + ' Salvo il progetto con le lavorazioni + EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx()) + Dim sMchPath As String = m_MainWindow.GetTempDir() & "\" & "DirectProj.nge" + m_MainWindow.m_CurrentProjectPageUC.SaveFile(sMchPath, False) + ' Predispongo passaggio a simulazione + m_bSimul = True + m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False + m_CurrProjPage.CurrProjGrid.Visibility = Windows.Visibility.Hidden + m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_DirectCutPageUC) + m_MainWindow.m_PrevActivePage = MainWindow.Pages.DirectCut + m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_SimulationPage) + m_MainWindow.m_ActivePage = MainWindow.Pages.Simulation + End Sub + Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click #If TRIAL Then m_CurrProjPage.SetWarningMessage("Trial Version") @@ -564,7 +563,6 @@ Public Class FlatteningCut Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click m_MainWindow.m_DirectCutPageUC.LeftButtonGrid.Children.Remove(Me) - m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut End Sub Private Function CreateFlatteningCut() As Boolean @@ -581,7 +579,7 @@ Public Class FlatteningCut DeactivateAllMachinings() ' Creo nuovo pezzo per il taglio diretto Dim nPartId = EgtCreateGroup(GDB_ID.ROOT) - EgtSetName(nPartId, DIRECTCUT) + EgtSetName(nPartId, NAME_DIRECTCUT) Dim nLayerId = EgtCreateGroup(nPartId) EgtSetName(nLayerId, NAME_OUTLOOP) ' Creo il taglio @@ -613,7 +611,7 @@ Public Class FlatteningCut If Not m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome Then RemoveFinalHome() End If - UpdateOkBtn() + UpdateSimulOkBtn() Return m_bCutOk End Function @@ -631,7 +629,7 @@ Public Class FlatteningCut DeactivateAllMachinings() ' Creo nuovo pezzo per il taglio diretto Dim nPartId = EgtCreateGroup(GDB_ID.ROOT) - EgtSetName(nPartId, DIRECTCUT) + EgtSetName(nPartId, NAME_DIRECTCUT) ' Creo layer di taglio Dim nLayerId = EgtCreateGroup(nPartId) EgtSetName(nLayerId, NAME_OUTLOOP) @@ -667,7 +665,7 @@ Public Class FlatteningCut If Not m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome Then RemoveFinalHome() End If - UpdateOkBtn() + UpdateSimulOkBtn() Return m_bCutOk End Function @@ -716,21 +714,6 @@ Public Class FlatteningCut Return True End Function - Private Function EraseDirectCutPart() As Boolean - ' Recupero identificativo del pezzo - Dim nDirPartId As Integer = EgtGetFirstNameInGroup(m_MainWindow.m_CurrentProjectPageUC.m_nRawId, DIRECTCUT) - If nDirPartId = GDB_ID.NULL Then - Return True - End If - ' Cancello le lavorazioni - EraseMachinings(nDirPartId) - ' Tolgo il pezzo dal grezzo - EgtRemovePartFromRawPart(nDirPartId) - ' Cancello il pezzo - EgtErase(nDirPartId) - Return True - End Function - Private Function CreateCross(nLayerId As Integer, ptP As Point3d) As Boolean ' Aggiungo crocette Dim vtCrossX As New Vector3d(20, 0, 0) diff --git a/GridCut.xaml b/GridCut.xaml index 8c285f3..ee3f8cf 100644 --- a/GridCut.xaml +++ b/GridCut.xaml @@ -103,11 +103,19 @@ - + + diff --git a/GridCut.xaml.vb b/GridCut.xaml.vb index 58d63b9..4cabf6e 100644 --- a/GridCut.xaml.vb +++ b/GridCut.xaml.vb @@ -6,6 +6,8 @@ Public Class GridCut Private WithEvents m_CurrProjPage As CurrentProjectPageUC ' Flag di pagina attiva Private m_bActive As Boolean = False + ' Flag di simulazione in corso + Private m_bSimul As Boolean = False ' Origine tavola e dati grezzo Private m_bRawOk As Boolean = False @@ -39,8 +41,6 @@ Public Class GridCut Private Const MAX_TAB_DEPTH As Double = 10.0 Private Const MIN_CUT_LEN As Double = 10.0 Private Const MAX_SIDE_ANG As Double = 60.0 - Private Const DIRECTCUT As String = "DirectCut" - Private Const RAW_CENTER As String = "RawCenter" ' Costanti che indicano la modalità di acquisizione dei punti Private Enum PT_MODE As Integer SAW = 0 @@ -60,7 +60,7 @@ Public Class GridCut m_PointsModeArray(PT_MODE.DRAW) = EgtMsg(MSG_DIRECTCUTPAGEUC + 25) ' la associo alla combobox PointModeCmBx.ItemsSource = m_PointsModeArray - + ' assegno messaggi Point1Btn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 10) Point2Btn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 11) DepthTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 13) @@ -71,17 +71,25 @@ Public Class GridCut NumPzYTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 21) DimPzYTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 22) SideChBx.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 23) + SimulBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 1) OkBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 30) End Sub Private Sub GridCut_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded + ' Attivo la pagina m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC m_bActive = True + ' Se rientro da simulazione + If m_bSimul Then + m_bSimul = False + ' Disabilito registrazione progetto modificato + EgtDisableModified() + Return + End If ' Reset punto acquisito m_bPointP1Ok = False ' Inizializzo primo punto acquisito dal disegno come centro del grezzo - Dim nRawPartCenter As Integer = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, RAW_CENTER) - EgtStartPoint(nRawPartCenter, GDB_ID.ROOT, m_ptPrev) + GetRawCenter(m_ptPrev) ' Imposto modalità di acquisizione punti PointModeCmBx.SelectedIndex = PT_MODE.DRAW ' Assegno parametri di lavorazione già definiti @@ -102,7 +110,7 @@ Public Class GridCut End If ' Reset taglio e disabilito bottone esecuzione m_bCutOk = False - UpdateOkBtn() + UpdateSimulOkBtn() ' Disabilito bottone secondo punto Point2Btn.IsEnabled = False ' Deseleziono bottone primo punto @@ -115,27 +123,35 @@ Public Class GridCut End Sub Friend Sub GridCut_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded - ' Rimuovo layer temporaneo per crocette - EgtErase(m_nTempLay) - ' Rimuovo eventuale pezzo per taglio diretto - EraseDirectCutPart() - ' Riattivo eventuali lavorazioni presenti - ActivateAllMachinings() - ' Abilito registrazione progetto modificato - EgtEnableModified() - ' Nascondo la macchina - m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False - EgtSetMachineLook(MCH_LOOK.TAB) - EgtDraw() + If Not m_bSimul Then + ' Dichiaro sottopagina da non riattivare + m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut + ' Rimuovo layer temporaneo per crocette + EgtErase(m_nTempLay) + ' Rimuovo eventuale pezzo per taglio diretto + EraseDirectCutPart() + ' Riattivo eventuali lavorazioni presenti + ActivateAllMachinings() + ' Abilito registrazione progetto modificato + EgtEnableModified() + ' Nascondo la macchina + m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False + EgtSetMachineLook(MCH_LOOK.TAB) + EgtDraw() + End If ' Dichiaro pagina non attiva m_bActive = False End Sub - Private Sub UpdateOkBtn() + Private Sub UpdateSimulOkBtn() If m_bCutOk Then + SimulBtn.IsEnabled = True + SimulBtn.Foreground = Brushes.Black OkBtn.IsEnabled = True OkBtn.Foreground = Brushes.Black Else + SimulBtn.IsEnabled = False + SimulBtn.Foreground = Brushes.DarkGray OkBtn.IsEnabled = False OkBtn.Foreground = Brushes.DarkGray End If @@ -443,6 +459,9 @@ Public Class GridCut StringToDouble(DirectionTxBx.Text, dDirection) dDirection += m_MainWindow.m_CurrentMachine.dDeltaC m_dAngO = dDirection + ' Dichiaro non più usato P2 + m_bPointP2Ok = False + Point2Btn.IsChecked = False ' Disegno il taglio CreateGridCut() EgtDraw() @@ -465,6 +484,23 @@ Public Class GridCut EgtDraw() End Sub + Private Sub SimulBtn_Click(sender As Object, e As RoutedEventArgs) Handles SimulBtn.Click + ' Verifico ci sia un taglio valido + If Not m_bCutOk Then Return + ' Salvo il progetto con le lavorazioni + EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx()) + Dim sMchPath As String = m_MainWindow.GetTempDir() & "\" & "DirectProj.nge" + m_MainWindow.m_CurrentProjectPageUC.SaveFile(sMchPath, False) + ' Predispongo passaggio a simulazione + m_bSimul = True + m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False + m_CurrProjPage.CurrProjGrid.Visibility = Windows.Visibility.Hidden + m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_DirectCutPageUC) + m_MainWindow.m_PrevActivePage = MainWindow.Pages.DirectCut + m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_SimulationPage) + m_MainWindow.m_ActivePage = MainWindow.Pages.Simulation + End Sub + Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click #If TRIAL Then m_CurrProjPage.SetWarningMessage("Trial Version") @@ -493,7 +529,6 @@ Public Class GridCut Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click m_MainWindow.m_DirectCutPageUC.LeftButtonGrid.Children.Remove(Me) - m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut End Sub Private Function CreateGridCut() As Boolean @@ -510,7 +545,7 @@ Public Class GridCut DeactivateAllMachinings() ' Creo nuovo pezzo per il taglio diretto Dim nPartId = EgtCreateGroup(GDB_ID.ROOT) - EgtSetName(nPartId, DIRECTCUT) + EgtSetName(nPartId, NAME_DIRECTCUT) Dim nLayerId = EgtCreateGroup(nPartId) EgtSetName(nLayerId, NAME_OUTLOOP) ' Creo il taglio parallelo alla lama @@ -536,7 +571,7 @@ Public Class GridCut If Not m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome Then RemoveFinalHome() End If - UpdateOkBtn() + UpdateSimulOkBtn() Return m_bCutOk End Function @@ -554,7 +589,7 @@ Public Class GridCut DeactivateAllMachinings() ' Creo nuovo pezzo per il taglio diretto Dim nPartId = EgtCreateGroup(GDB_ID.ROOT) - EgtSetName(nPartId, DIRECTCUT) + EgtSetName(nPartId, NAME_DIRECTCUT) ' Creo layer di taglio Dim nLayerId = EgtCreateGroup(nPartId) EgtSetName(nLayerId, NAME_OUTLOOP) @@ -584,7 +619,7 @@ Public Class GridCut If Not m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome Then RemoveFinalHome() End If - UpdateOkBtn() + UpdateSimulOkBtn() Return m_bCutOk End Function @@ -652,21 +687,6 @@ Public Class GridCut Return True End Function - Private Function EraseDirectCutPart() As Boolean - ' Recupero identificativo del pezzo - Dim nDirPartId As Integer = EgtGetFirstNameInGroup(m_MainWindow.m_CurrentProjectPageUC.m_nRawId, DIRECTCUT) - If nDirPartId = GDB_ID.NULL Then - Return True - End If - ' Cancello le lavorazioni - EraseMachinings(nDirPartId) - ' Tolgo il pezzo dal grezzo - EgtRemovePartFromRawPart(nDirPartId) - ' Cancello il pezzo - EgtErase(nDirPartId) - Return True - End Function - Private Function CreateCross(nLayerId As Integer, ptP As Point3d) As Boolean ' Aggiungo crocette Dim vtCrossX As New Vector3d(20, 0, 0) diff --git a/MultipleCut.xaml b/MultipleCut.xaml index 76493a3..0feae6e 100644 --- a/MultipleCut.xaml +++ b/MultipleCut.xaml @@ -108,11 +108,19 @@ - + + diff --git a/MultipleCut.xaml.vb b/MultipleCut.xaml.vb index 8254a38..b2bdaed 100644 --- a/MultipleCut.xaml.vb +++ b/MultipleCut.xaml.vb @@ -7,6 +7,8 @@ Public Class MultipleCut Private WithEvents m_CurrProjPage As CurrentProjectPageUC ' Flag di pagina attiva Private m_bActive As Boolean = False + ' Flag di simulazione in corso + Private m_bSimul As Boolean = False ' Origine tavola e dati grezzo Private m_bRawOk As Boolean = False @@ -40,8 +42,6 @@ Public Class MultipleCut Private Const MAX_TAB_DEPTH As Double = 10.0 Private Const MIN_CUT_LEN As Double = 10.0 Private Const MAX_SIDE_ANG As Double = 60.0 - Private Const DIRECTCUT As String = "DirectCut" - Private Const RAW_CENTER As String = "RawCenter" ' Costanti che indicano la modalità di acquisizione dei punti Private Enum PT_MODE As Integer SAW = 0 @@ -61,7 +61,7 @@ Public Class MultipleCut m_PointsModeArray(PT_MODE.DRAW) = EgtMsg(MSG_DIRECTCUTPAGEUC + 25) ' la associo alla combobox PointModeCmBx.ItemsSource = m_PointsModeArray - + ' assegno messaggi Point1Btn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 10) Point2Btn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 11) DepthTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 13) @@ -71,18 +71,25 @@ Public Class MultipleCut NumPzTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 17) DimPzTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 18) SideChBx.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 23) + SimulBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 1) OkBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 30) - End Sub Private Sub MultipleCut_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded + ' Attivo la pagina m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC m_bActive = True + ' Se rientro da simulazione + If m_bSimul Then + m_bSimul = False + ' Disabilito registrazione progetto modificato + EgtDisableModified() + Return + End If ' Reset punto acquisito m_bPointP1Ok = False ' Inizializzo primo punto acquisito dal disegno come centro del grezzo - Dim nRawPartCenter As Integer = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, RAW_CENTER) - EgtStartPoint(nRawPartCenter, GDB_ID.ROOT, m_ptPrev) + GetRawCenter(m_ptPrev) ' Imposto modalità di acquisizione punti PointModeCmBx.SelectedIndex = PT_MODE.DRAW ' Assegno parametri di lavorazione già definiti @@ -104,7 +111,7 @@ Public Class MultipleCut End If ' Reset taglio e disabilito bottone esecuzione m_bCutOk = False - UpdateOkBtn() + UpdateSimulOkBtn() ' Disabilito bottone secondo punto Point2Btn.IsEnabled = False ' Deseleziono bottone primo punto @@ -117,27 +124,35 @@ Public Class MultipleCut End Sub Friend Sub MultipleCut_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded - ' Rimuovo layer temporaneo per crocette - EgtErase(m_nTempLay) - ' Rimuovo eventuale pezzo per taglio diretto - EraseDirectCutPart() - ' Riattivo eventuali lavorazioni presenti - ActivateAllMachinings() - ' Abilito registrazione progetto modificato - EgtEnableModified() - ' Nascondo la macchina - m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False - EgtSetMachineLook(MCH_LOOK.TAB) - EgtDraw() + If Not m_bSimul Then + ' Dichiaro sottopagina da non riattivare + m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut + ' Rimuovo layer temporaneo per crocette + EgtErase(m_nTempLay) + ' Rimuovo eventuale pezzo per taglio diretto + EraseDirectCutPart() + ' Riattivo eventuali lavorazioni presenti + ActivateAllMachinings() + ' Abilito registrazione progetto modificato + EgtEnableModified() + ' Nascondo la macchina + m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False + EgtSetMachineLook(MCH_LOOK.TAB) + EgtDraw() + End If ' Dichiaro pagina non attiva m_bActive = False End Sub - Private Sub UpdateOkBtn() + Private Sub UpdateSimulOkBtn() If m_bCutOk Then + SimulBtn.IsEnabled = True + SimulBtn.Foreground = Brushes.Black OkBtn.IsEnabled = True OkBtn.Foreground = Brushes.Black Else + SimulBtn.IsEnabled = False + SimulBtn.Foreground = Brushes.DarkGray OkBtn.IsEnabled = False OkBtn.Foreground = Brushes.DarkGray End If @@ -462,6 +477,9 @@ Public Class MultipleCut StringToDouble(DirectionTxBx.Text, dDirection) dDirection += m_MainWindow.m_CurrentMachine.dDeltaC m_dAngO = dDirection + ' Dichiaro non più usato P2 + m_bPointP2Ok = False + Point2Btn.IsChecked = False ' Disegno il taglio CreateMultipleCut() EgtDraw() @@ -484,6 +502,23 @@ Public Class MultipleCut EgtDraw() End Sub + Private Sub SimulBtn_Click(sender As Object, e As RoutedEventArgs) Handles SimulBtn.Click + ' Verifico ci sia un taglio valido + If Not m_bCutOk Then Return + ' Salvo il progetto con le lavorazioni + EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx()) + Dim sMchPath As String = m_MainWindow.GetTempDir() & "\" & "DirectProj.nge" + m_MainWindow.m_CurrentProjectPageUC.SaveFile(sMchPath, False) + ' Predispongo passaggio a simulazione + m_bSimul = True + m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False + m_CurrProjPage.CurrProjGrid.Visibility = Windows.Visibility.Hidden + m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_DirectCutPageUC) + m_MainWindow.m_PrevActivePage = MainWindow.Pages.DirectCut + m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_SimulationPage) + m_MainWindow.m_ActivePage = MainWindow.Pages.Simulation + End Sub + Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click #If TRIAL Then m_CurrProjPage.SetWarningMessage("Trial Version") @@ -512,7 +547,6 @@ Public Class MultipleCut Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click m_MainWindow.m_DirectCutPageUC.LeftButtonGrid.Children.Remove(Me) - m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut End Sub Private Function CreateMultipleCut() As Boolean @@ -529,7 +563,7 @@ Public Class MultipleCut DeactivateAllMachinings() ' Creo nuovo pezzo per il taglio diretto Dim nPartId = EgtCreateGroup(GDB_ID.ROOT) - EgtSetName(nPartId, DIRECTCUT) + EgtSetName(nPartId, NAME_DIRECTCUT) Dim nLayerId = EgtCreateGroup(nPartId) EgtSetName(nLayerId, NAME_OUTLOOP) ' Creo il taglio @@ -559,7 +593,7 @@ Public Class MultipleCut If Not m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome Then RemoveFinalHome() End If - UpdateOkBtn() + UpdateSimulOkBtn() Return m_bCutOk End Function @@ -577,7 +611,7 @@ Public Class MultipleCut DeactivateAllMachinings() ' Creo nuovo pezzo per il taglio diretto Dim nPartId = EgtCreateGroup(GDB_ID.ROOT) - EgtSetName(nPartId, DIRECTCUT) + EgtSetName(nPartId, NAME_DIRECTCUT) ' Creo layer di taglio Dim nLayerId = EgtCreateGroup(nPartId) EgtSetName(nLayerId, NAME_OUTLOOP) @@ -611,7 +645,7 @@ Public Class MultipleCut If Not m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome Then RemoveFinalHome() End If - UpdateOkBtn() + UpdateSimulOkBtn() Return m_bCutOk End Function @@ -678,21 +712,6 @@ Public Class MultipleCut Return True End Function - Private Function EraseDirectCutPart() As Boolean - ' Recupero identificativo del pezzo - Dim nDirPartId As Integer = EgtGetFirstNameInGroup(m_MainWindow.m_CurrentProjectPageUC.m_nRawId, DIRECTCUT) - If nDirPartId = GDB_ID.NULL Then - Return True - End If - ' Cancello le lavorazioni - EraseMachinings(nDirPartId) - ' Tolgo il pezzo dal grezzo - EgtRemovePartFromRawPart(nDirPartId) - ' Cancello il pezzo - EgtErase(nDirPartId) - Return True - End Function - Private Function CreateCross(nLayerId As Integer, ptP As Point3d) As Boolean ' Aggiungo crocette Dim vtCrossX As New Vector3d(20, 0, 0) diff --git a/OmagCUT.vbproj b/OmagCUT.vbproj index f4fd74d..ac78718 100644 --- a/OmagCUT.vbproj +++ b/OmagCUT.vbproj @@ -194,6 +194,7 @@ CurrentProjectPageUC.xaml + DirectCutPageUC.xaml diff --git a/SawTestUC.xaml b/SawTestUC.xaml index d9a6d68..8095505 100644 --- a/SawTestUC.xaml +++ b/SawTestUC.xaml @@ -74,12 +74,20 @@ - - + + + + + + + + + + diff --git a/SawTestUC.xaml.vb b/SawTestUC.xaml.vb index ae5d43d..12d29b6 100644 --- a/SawTestUC.xaml.vb +++ b/SawTestUC.xaml.vb @@ -7,6 +7,8 @@ Public Class SawTestUC Private WithEvents m_CurrProjPage As CurrentProjectPageUC ' Flag di pagina attiva Private m_bActive As Boolean = False + ' Flag di simulazione in corso + Private m_bSimul As Boolean = False ' Origine tavola e dati grezzo Private m_bRawOk As Boolean = False @@ -40,7 +42,6 @@ Public Class SawTestUC Private Const MAX_TAB_DEPTH As Double = 10.0 Private Const MIN_CUT_LEN As Double = 10.0 Private Const MAX_SIDE_ANG As Double = 60.0 - Private Const DIRECTCUT As String = "DirectCut" ' Costanti che indicano la modalità di acquisizione dei punti Private Enum PT_MODE As Integer SAW = 0 @@ -55,18 +56,27 @@ Public Class SawTestUC m_PointsModeArray(PT_MODE.DRAW) = EgtMsg(MSG_DIRECTCUTPAGEUC + 25) ' la associo alla combobox PointModeCmBx.ItemsSource = m_PointsModeArray - + ' assegno messaggi Point1Btn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 10) Point2Btn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 11) DepthTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 13) LenghtTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 14) DirectionTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 15) + SimulBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 1) OkBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 30) End Sub Private Sub SawTest_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded + ' Attivo la pagina m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC m_bActive = True + ' Se rientro da simulazione + If m_bSimul Then + m_bSimul = False + ' Disabilito registrazione progetto modificato + EgtDisableModified() + Return + End If ' Reset punto acquisito m_bPointP1Ok = False m_bPointP2Ok = False @@ -97,7 +107,7 @@ Public Class SawTestUC EgtMdbSetCurrMachining(m_sSawing) ' Reset taglio e disabilito bottone esecuzione m_bCutOk = False - UpdateOkBtn() + UpdateSimulOkBtn() ' Disabilito bottone secondo punto Point2Btn.IsEnabled = False ' Deseleziono bottone primo punto @@ -110,27 +120,35 @@ Public Class SawTestUC End Sub Friend Sub SawTest_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded - ' Rimuovo layer temporaneo per crocette - EgtErase(m_nTempLay) - ' Rimuovo eventuale pezzo per taglio diretto - EraseDirectCutPart() - ' Riattivo eventuali lavorazioni presenti - ActivateAllMachinings() - ' Abilito registrazione progetto modificato - EgtEnableModified() - ' Nascondo la macchina - m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False - EgtSetMachineLook(MCH_LOOK.TAB) - EgtDraw() + If Not m_bSimul Then + ' Dichiaro sottopagina da non riattivare + m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut + ' Rimuovo layer temporaneo per crocette + EgtErase(m_nTempLay) + ' Rimuovo eventuale pezzo per taglio diretto + EraseDirectCutPart() + ' Riattivo eventuali lavorazioni presenti + ActivateAllMachinings() + ' Abilito registrazione progetto modificato + EgtEnableModified() + ' Nascondo la macchina + m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False + EgtSetMachineLook(MCH_LOOK.TAB) + EgtDraw() + End If ' Dichiaro pagina non attiva m_bActive = False End Sub - Private Sub UpdateOkBtn() + Private Sub UpdateSimulOkBtn() If m_bCutOk Then + SimulBtn.IsEnabled = True + SimulBtn.Foreground = Brushes.Black OkBtn.IsEnabled = True OkBtn.Foreground = Brushes.Black Else + SimulBtn.IsEnabled = False + SimulBtn.Foreground = Brushes.DarkGray OkBtn.IsEnabled = False OkBtn.Foreground = Brushes.DarkGray End If @@ -451,11 +469,31 @@ Public Class SawTestUC StringToDouble(DirectionTxBx.Text, dDirection) dDirection += m_MainWindow.m_CurrentMachine.dDeltaC m_dAngO = dDirection + ' Dichiaro non più usato P2 + m_bPointP2Ok = False + Point2Btn.IsChecked = False ' Disegno il taglio CreateSingleCut() EgtDraw() End Sub + Private Sub SimulBtn_Click(sender As Object, e As RoutedEventArgs) Handles SimulBtn.Click + ' Verifico ci sia un taglio valido + If Not m_bCutOk Then Return + ' Salvo il progetto con le lavorazioni + EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx()) + Dim sMchPath As String = m_MainWindow.GetTempDir() & "\" & "DirectProj.nge" + m_MainWindow.m_CurrentProjectPageUC.SaveFile(sMchPath, False) + ' Predispongo passaggio a simulazione + m_bSimul = True + m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False + m_CurrProjPage.CurrProjGrid.Visibility = Windows.Visibility.Hidden + m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_DirectCutPageUC) + m_MainWindow.m_PrevActivePage = MainWindow.Pages.DirectCut + m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_SimulationPage) + m_MainWindow.m_ActivePage = MainWindow.Pages.Simulation + End Sub + Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click #If TRIAL Then m_CurrProjPage.SetWarningMessage("Trial Version") @@ -484,7 +522,6 @@ Public Class SawTestUC Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click m_MainWindow.m_DirectCutPageUC.LeftButtonGrid.Children.Remove(Me) - m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut End Sub Private Function CreateSingleCut() As Boolean @@ -509,7 +546,7 @@ Public Class SawTestUC DeactivateAllMachinings() ' Creo nuovo pezzo per il taglio diretto Dim nPartId = EgtCreateGroup(GDB_ID.ROOT) - EgtSetName(nPartId, DIRECTCUT) + EgtSetName(nPartId, NAME_DIRECTCUT) Dim nLayerId = EgtCreateGroup(nPartId) EgtSetName(nLayerId, NAME_OUTLOOP) ' Creo il taglio @@ -558,25 +595,10 @@ Public Class SawTestUC If Not m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome Then RemoveFinalHome() End If - UpdateOkBtn() + UpdateSimulOkBtn() Return m_bCutOk End Function - Private Function EraseDirectCutPart() As Boolean - ' Recupero identificativo del pezzo - Dim nDirPartId As Integer = EgtGetFirstNameInGroup(m_MainWindow.m_CurrentProjectPageUC.m_nRawId, DIRECTCUT) - If nDirPartId = GDB_ID.NULL Then - Return True - End If - ' Cancello le lavorazioni - EraseMachinings(nDirPartId) - ' Tolgo il pezzo dal grezzo - EgtRemovePartFromRawPart(nDirPartId) - ' Cancello il pezzo - EgtErase(nDirPartId) - Return True - End Function - Private Function CreateCross(nLayerId As Integer, ptP As Point3d) As Boolean ' Aggiungo crocette Dim vtCrossX As New Vector3d(20, 0, 0) diff --git a/SimulationPageUC.xaml.vb b/SimulationPageUC.xaml.vb index 0b25d1d..1a29949 100644 --- a/SimulationPageUC.xaml.vb +++ b/SimulationPageUC.xaml.vb @@ -75,19 +75,17 @@ Public Class SimulationPageUC UpdateUI() ' Aggiorno flag per lavaggio m_CurrProjPage.UpdateWashingFlag() - ' Se pezzi piani e non c'è ordine delle lavorazioni, ricalcolo tutto e ne faccio uno automatico + ' Se pezzi piani e non taglio diretto e non c'è ordine delle lavorazioni, ricalcolo tutto e ne faccio uno automatico Dim nPrjType As Integer = m_CurrProjPage.GetCurrentProjectType() + Dim bDirectCut As Boolean = (GetDirectCutPart() <> GDB_ID.NULL) If nPrjType = CurrentProjectPageUC.PRJ_TYPE.FLATS And + Not bDirectCut And Not m_CurrProjPage.GetOrderMachiningFlag() Then RemoveFinalEmptyPhases() bOk = SortAllMachinings() - If bOk Then - m_CurrProjPage.SetOrderMachiningFlag() - End If + If bOk Then m_CurrProjPage.SetOrderMachiningFlag() Dim bModif As Boolean = TestAllMachiningsForStrict() - If bModif Then - m_CurrProjPage.SetWarningMessage(EgtMsg(90321)) 'Ridotte alcune lavorazioni per evitare interferenze - End If + If bModif Then m_CurrProjPage.SetWarningMessage(EgtMsg(90321)) 'Ridotte alcune lavorazioni per evitare interferenze End If ' Costringo ad aggiornare UI UpdateUI() @@ -95,6 +93,10 @@ Public Class SimulationPageUC EgtDisableModified() ' Aggiorno le lavorazioni bOk = UpdateAllMachiningsToolpaths() And bOk + ' Eventuale eliminazione Home finale + If bDirectCut And Not m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome Then + RemoveFinalHome() + End If ' Aggiorno posizionamento ventose sui pezzi per eventuali tagli da sotto con lama bOk = UpdateVacuumsForDrip() And bOk ' Se errore in setup, lo segnalo @@ -423,9 +425,12 @@ Public Class SimulationPageUC If m_MainWindow.m_PrevActivePage = MainWindow.Pages.CadCut Then m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_CadCutPageUC) m_MainWindow.m_ActivePage = MainWindow.Pages.CadCut - Else + ElseIf m_MainWindow.m_PrevActivePage = MainWindow.Pages.FrameCut Then m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_FrameCutPageUC) m_MainWindow.m_ActivePage = MainWindow.Pages.FrameCut + Else + m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_DirectCutPageUC) + m_MainWindow.m_ActivePage = MainWindow.Pages.DirectCut End If End Sub diff --git a/SingleCutUC.xaml b/SingleCutUC.xaml index 2ec3e7e..b014182 100644 --- a/SingleCutUC.xaml +++ b/SingleCutUC.xaml @@ -73,13 +73,21 @@ - - - + + + + + + + + + + + diff --git a/SingleCutUC.xaml.vb b/SingleCutUC.xaml.vb index 472b54a..a54acf8 100644 --- a/SingleCutUC.xaml.vb +++ b/SingleCutUC.xaml.vb @@ -7,6 +7,8 @@ Public Class SingleCutUC Private WithEvents m_CurrProjPage As CurrentProjectPageUC ' Flag di pagina attiva Private m_bActive As Boolean = False + ' Flag di simulazione in corso + Private m_bSimul As Boolean = False ' Origine tavola e dati grezzo Private m_bRawOk As Boolean = False @@ -38,8 +40,6 @@ Public Class SingleCutUC Private Const MAX_TAB_DEPTH As Double = 10.0 Private Const MIN_CUT_LEN As Double = 10.0 Private Const MAX_SIDE_ANG As Double = 60.0 - Private Const DIRECTCUT As String = "DirectCut" - Private Const RAW_CENTER As String = "RawCenter" ' Costanti che indicano la modalità di acquisizione dei punti Private Enum PT_MODE As Integer SAW = 0 @@ -54,25 +54,33 @@ Public Class SingleCutUC m_PointsModeArray(PT_MODE.DRAW) = EgtMsg(MSG_DIRECTCUTPAGEUC + 25) ' la associo alla combobox PointModeCmBx.ItemsSource = m_PointsModeArray - + ' assegno messaggi Point1Btn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 10) Point2Btn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 11) DepthTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 13) LenghtTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 14) DirectionTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 15) SideAngleTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 16) + SimulBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 1) OkBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 30) End Sub Private Sub SingleCut_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded + ' Attivo la pagina m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC m_bActive = True + ' Se rientro da simulazione + If m_bSimul Then + m_bSimul = False + ' Disabilito registrazione progetto modificato + EgtDisableModified() + Return + End If ' Reset punto acquisito m_bPointP1Ok = False SawTipTxBl.Text = String.Empty ' Inizializzo primo punto acquisito dal disegno come centro del grezzo - Dim nRawPartCenter As Integer = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, RAW_CENTER) - EgtStartPoint(nRawPartCenter, GDB_ID.ROOT, m_ptPrev) + GetRawCenter(m_ptPrev) ' Imposto modalità di acquisizione punti PointModeCmBx.SelectedIndex = PT_MODE.DRAW ' Assegno parametri di lavorazione già definiti @@ -94,7 +102,7 @@ Public Class SingleCutUC End If ' Reset taglio e disabilito bottone esecuzione m_bCutOk = False - UpdateOkBtn() + UpdateSimulOkBtn() ' Disabilito bottone secondo punto Point2Btn.IsEnabled = False ' Deseleziono bottone primo punto @@ -107,27 +115,35 @@ Public Class SingleCutUC End Sub Friend Sub SingleCut_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded - ' Rimuovo layer temporaneo per crocette - EgtErase(m_nTempLay) - ' Rimuovo eventuale pezzo per taglio diretto - EraseDirectCutPart() - ' Riattivo eventuali lavorazioni presenti - ActivateAllMachinings() - ' Abilito registrazione progetto modificato - EgtEnableModified() - ' Nascondo la macchina - m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False - EgtSetMachineLook(MCH_LOOK.TAB) - EgtDraw() + If Not m_bSimul Then + ' Dichiaro sottopagina da non riattivare + m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut + ' Rimuovo layer temporaneo per crocette + EgtErase(m_nTempLay) + ' Rimuovo eventuale pezzo per taglio diretto + EraseDirectCutPart() + ' Riattivo eventuali lavorazioni presenti + ActivateAllMachinings() + ' Abilito registrazione progetto modificato + EgtEnableModified() + ' Nascondo la macchina + m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False + EgtSetMachineLook(MCH_LOOK.TAB) + EgtDraw() + End If ' Dichiaro pagina non attiva m_bActive = False End Sub - Private Sub UpdateOkBtn() + Private Sub UpdateSimulOkBtn() If m_bCutOk Then + SimulBtn.IsEnabled = True + SimulBtn.Foreground = Brushes.Black OkBtn.IsEnabled = True OkBtn.Foreground = Brushes.Black Else + SimulBtn.IsEnabled = False + SimulBtn.Foreground = Brushes.DarkGray OkBtn.IsEnabled = False OkBtn.Foreground = Brushes.DarkGray End If @@ -460,6 +476,9 @@ Public Class SingleCutUC StringToDouble(DirectionTxBx.Text, dDirection) dDirection += m_MainWindow.m_CurrentMachine.dDeltaC m_dAngO = dDirection + ' Dichiaro non più usato P2 + m_bPointP2Ok = False + Point2Btn.IsChecked = False ' Disegno il taglio CreateSingleCut() EgtDraw() @@ -482,6 +501,23 @@ Public Class SingleCutUC EgtDraw() End Sub + Private Sub SimulBtn_Click(sender As Object, e As RoutedEventArgs) Handles SimulBtn.Click + ' Verifico ci sia un taglio valido + If Not m_bCutOk Then Return + ' Salvo il progetto con le lavorazioni + EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx()) + Dim sMchPath As String = m_MainWindow.GetTempDir() & "\" & "DirectProj.nge" + m_MainWindow.m_CurrentProjectPageUC.SaveFile(sMchPath, False) + ' Predispongo passaggio a simulazione + m_bSimul = True + m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False + m_CurrProjPage.CurrProjGrid.Visibility = Windows.Visibility.Hidden + m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_DirectCutPageUC) + m_MainWindow.m_PrevActivePage = MainWindow.Pages.DirectCut + m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_SimulationPage) + m_MainWindow.m_ActivePage = MainWindow.Pages.Simulation + End Sub + Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click #If TRIAL Then m_CurrProjPage.SetWarningMessage("Trial Version") @@ -510,7 +546,6 @@ Public Class SingleCutUC Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click m_MainWindow.m_DirectCutPageUC.LeftButtonGrid.Children.Remove(Me) - m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut End Sub Private Function CreateSingleCut() As Boolean @@ -528,8 +563,7 @@ Public Class SingleCutUC ' Disattivo eventuali lavorazioni presenti DeactivateAllMachinings() ' Creo nuovo pezzo per il taglio diretto - Dim nPartId = EgtCreateGroup(GDB_ID.ROOT) - EgtSetName(nPartId, DIRECTCUT) + Dim nPartId = CreateDirectCutPart() Dim nLayerId = EgtCreateGroup(nPartId) EgtSetName(nLayerId, NAME_OUTLOOP) ' Creo il taglio @@ -564,25 +598,10 @@ Public Class SingleCutUC If Not m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome Then RemoveFinalHome() End If - UpdateOkBtn() + UpdateSimulOkBtn() Return m_bCutOk End Function - Private Function EraseDirectCutPart() As Boolean - ' Recupero identificativo del pezzo - Dim nDirPartId As Integer = EgtGetFirstNameInGroup(m_MainWindow.m_CurrentProjectPageUC.m_nRawId, DIRECTCUT) - If nDirPartId = GDB_ID.NULL Then - Return True - End If - ' Cancello le lavorazioni - EraseMachinings(nDirPartId) - ' Tolgo il pezzo dal grezzo - EgtRemovePartFromRawPart(nDirPartId) - ' Cancello il pezzo - EgtErase(nDirPartId) - Return True - End Function - Private Function CreateCross(nLayerId As Integer, ptP As Point3d) As Boolean ' Aggiungo crocette Dim vtCrossX As New Vector3d(20, 0, 0) diff --git a/WorkInProgressPageUC.xaml.vb b/WorkInProgressPageUC.xaml.vb index 33f0c79..6f12c7c 100644 --- a/WorkInProgressPageUC.xaml.vb +++ b/WorkInProgressPageUC.xaml.vb @@ -313,7 +313,12 @@ Public Class WorkInProgressPageUC If Not WorkInProgressScene.Init() Then ' Rimuovo l'host della scena perchè altrimenti rimarrebbe il buco!! Me.WorkInProgressPageGrid.Children.Remove(WorkInProgressSceneHost) - Dim MissingKeyWnd As New EgtMsgBox(m_MainWindow, EgtMsg(MSG_MISSINGKEYWD + 1), EgtMsg(MSG_MISSINGKEYWD + 2) & " " & EgtMsg(MSG_MISSINGKEYWD + 3), EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.NULL) + Dim MissingKeyWnd As EgtMsgBox +#If TRIAL Then + MissingKeyWnd = New EgtMsgBox(m_MainWindow, EgtMsg(MSG_MISSINGKEYWD + 1), EgtMsg(MSG_MISSINGKEYWD + 5) & " " & EgtMsg(MSG_MISSINGKEYWD + 7), EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.NULL, 0, 1) +#Else + MissingKeyWnd = New EgtMsgBox(m_MainWindow, EgtMsg(MSG_MISSINGKEYWD + 1), EgtMsg(MSG_MISSINGKEYWD + 2) & " " & EgtMsg(MSG_MISSINGKEYWD + 3), EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.NULL) +#End If m_MainWindow.Close() End If ' dimensione lineare max in pixel delle textures