From 4e79447e5987be368d161eb7ca868b6d476562dc Mon Sep 17 00:00:00 2001 From: NicolaP Date: Wed, 16 Jun 2021 20:44:10 +0200 Subject: [PATCH] Prototipo pagina Alz/Front --- DrawImport/AlzFrontUC.xaml | 210 +++++++++ DrawImport/AlzFrontUC.xaml.vb | 485 +++++++++++++++++++++ DrawImport/CompoDimensionUC.xaml | 18 +- DrawImport/CompoDimensionUC.xaml.vb | 45 +- DrawImport/DrawPageUC.xaml.vb | 31 +- DrawImport/InternalComponentPageUC.xaml.vb | 3 +- OmagCUT.vbproj | 7 + 7 files changed, 783 insertions(+), 16 deletions(-) create mode 100644 DrawImport/AlzFrontUC.xaml create mode 100644 DrawImport/AlzFrontUC.xaml.vb diff --git a/DrawImport/AlzFrontUC.xaml b/DrawImport/AlzFrontUC.xaml new file mode 100644 index 0000000..8d6f67f --- /dev/null +++ b/DrawImport/AlzFrontUC.xaml @@ -0,0 +1,210 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DrawImport/AlzFrontUC.xaml.vb b/DrawImport/AlzFrontUC.xaml.vb new file mode 100644 index 0000000..c75e05e --- /dev/null +++ b/DrawImport/AlzFrontUC.xaml.vb @@ -0,0 +1,485 @@ +Imports EgtUILib + +Public Class AlzFrontUC + ' Riferimento alla MainWindow + Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow) + ' Riferimento alla pagina che ha aperto SideAngleUC + Private m_CallingPage As MainWindow.Pages + + ' Gestione pagine + Private Const MAX_LINES As Integer = 10 + ' lista dei lati, in cui indico il tipo di entità da associare + Private AlzFrontEntityList As New List(Of AlzFrontEntity) + + ' numero di lati presenti nella figura + Private m_nCount As Integer = 0 + ' numero di righe rese disponibili nella pagina -> m_nShow = min(m_nCount, MAX_LINE) + Private m_nShow As Integer = MAX_LINES + + ' layer per inserire le descrizione dei lati + Private m_AlzLayer As Integer + Private m_Frontlayer As Integer + Private m_dBBoxRad As Double + + Private Sub AlzFrontPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded + + m_MainWindow.m_DrawPageUC.m_ActiveComponentPage = DrawPageUC.Pages.AlzFront + + ' numero di elemnti presenti nella lista SideAngle/DripEntity + m_nCount = 0 + ' numero di righe rese disponibili nella pagina -> m_nShow = min(m_nCount, MAX_LINE) + m_nShow = 0 + + ' carico la lista dei lati della figura + InitSides() + ' aggiorno la visualizzazione delle TextBox e dei CheckBox + TxBlChBxView() + + ' nascondo il bottone Back della pagina Draw + m_MainWindow.m_DrawPageUC.BackBtn.Visibility = Visibility.Hidden + m_MainWindow.m_DrawPageUC.MessageGrid.Visibility = Visibility.Hidden + ' Abilito bottoni angoli di fianco e lavorazioni da sotto + m_MainWindow.m_DrawPageUC.SideAngleBtn.IsEnabled = m_MainWindow.m_DrawPageUC.bEnableSideAngle + m_MainWindow.m_DrawPageUC.FiloTopBtn.IsEnabled = m_MainWindow.m_CurrentMachine.bMilling + m_MainWindow.m_DrawPageUC.EngraveBtn.IsEnabled = True + m_MainWindow.m_DrawPageUC.DripCutBtn.IsEnabled = m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.UNDER_CUT) And + Not String.IsNullOrWhiteSpace(m_MainWindow.m_CurrentMachine.sCurrDripSaw) + + ' nome dei parametri condivisi + Parameter1TxBl.Text = "Altezza" + Parameter2TxBl.Text = "Delta angolo" + + EgtZoom(ZM.ALL) + End Sub + + ' carico la lista dei lati della figura corrente + Private Sub InitSides() + ' pulisco la lista dei lati + AlzFrontEntityList.Clear() + Dim PartId As Integer = GDB_ID.NULL + ' Id del loop eseterno + Dim LoopId As Integer = GDB_ID.NULL + + ' Imposto contesto corrente + EgtSetCurrentContext(m_MainWindow.m_DrawPageUC.DrawScene.GetCtx()) + ' Ricavo nome primo pezzo + PartId = EgtGetFirstPart() + ' Recupero nome layer con geometria di contorno (esterno o interno) del pezzo + LoopId = EgtGetFirstNameInGroup(EgtGetFirstPart(), NAME_OUTLOOP) + + 'Determino se loop esterno o interno + Dim sLoopName As String = "" + Dim bOutLoop As Boolean = (EgtGetName(LoopId, sLoopName) AndAlso sLoopName = NAME_OUTLOOP) + ' Calcolo dimensione ingombro Loop + Dim ptMin, ptMax As Point3d + EgtGetBBoxGlob(LoopId, GDB_BB.STANDARD, ptMin, ptMax) + ' utilizzato per definire la dimensione dei caratteri delle label per i lati + m_dBBoxRad = 0.5 * Point3d.DistXY(ptMin, ptMax) + + ' Creo layer per testi ALZATINE + m_AlzLayer = EgtGetFirstNameInGroup(PartId, "Alzatina") + If m_AlzLayer = GDB_ID.NULL And PartId <> GDB_ID.NULL Then + m_AlzLayer = EgtCreateGroup(PartId) + EgtSetName(m_AlzLayer, "Alzatina") + EgtSetColor(m_AlzLayer, New Color3d(0, 0, 0)) + End If + + ' Creo layer per testi FRONTALINI + m_Frontlayer = EgtGetFirstNameInGroup(PartId, "Frontalino") + If m_Frontlayer = GDB_ID.NULL And PartId <> GDB_ID.NULL Then + m_Frontlayer = EgtCreateGroup(PartId) + EgtSetName(m_Frontlayer, "Frontalino") + EgtSetColor(m_Frontlayer, New Color3d(0, 100, 0)) + End If + + ' Recupero Id della curva del Loop Esterno + Dim PrevLine As Integer = EgtGetLastInGroup(LoopId) + Dim CurrLine As Integer = EgtGetFirstInGroup(LoopId) + ' Creo indice per numerare le entità in ImportPage + Dim nEntityIndex As Integer = 1 + Dim nOtherIndex As Integer = 1 + + ' Ciclo che verifica se possibile inclinare la curva corrente o inserire un gocciolatoio + While CurrLine <> GDB_ID.NULL + Dim NextLine As Integer = EgtGetNext(CurrLine) + If NextLine = GDB_ID.NULL Then NextLine = EgtGetFirstInGroup(LoopId) + + If EgtGetType(CurrLine) = GDB_TY.CRV_LINE Then + ' Aggiungo il lato alla lista di quelli su cui è possibile mettere il gocciolatoio + Dim sNameCurrLine As String = String.Empty + EgtGetName(CurrLine, sNameCurrLine) + AlzFrontEntityList.Add(New AlzFrontEntity(sNameCurrLine, CurrLine)) + nEntityIndex += 1 + End If + + PrevLine = CurrLine + CurrLine = EgtGetNext(CurrLine) + End While + + ' Aggiorno numero di lati carciati + m_nCount = AlzFrontEntityList.Count() + ' Aggiorno numero item visualizzati nella pagina iniziale + m_nShow = Math.Min(m_nCount, MAX_LINES) + + ' Se non ci sono lati su cui operare, messaggio utente + If LoopId <> GDB_ID.NULL Then + If m_nCount = 0 Then + If m_CallingPage = MainWindow.Pages.Draw Then + m_MainWindow.m_DrawPageUC.MessageTxBx.Text = EgtMsg(MSG_DRAWPAGEUC + 7) ' Non ci sono lati modificabili + m_MainWindow.m_DrawPageUC.MessageBrd.Background = Application.Current.FindResource("OmagCut_Yellow") + Else + m_MainWindow.m_ImportPageUC.MessageTxBx.Text = EgtMsg(MSG_DRAWPAGEUC + 7) ' Non ci sono lati modificabili + m_MainWindow.m_ImportPageUC.MessageBrd.Background = Application.Current.FindResource("OmagCut_Yellow") + End If + Else + If m_CallingPage = MainWindow.Pages.Draw Then + m_MainWindow.m_DrawPageUC.MessageTxBx.Text = "" + m_MainWindow.m_DrawPageUC.MessageBrd.Background = Brushes.Transparent + Else + m_MainWindow.m_ImportPageUC.MessageTxBx.Text = "" + m_MainWindow.m_ImportPageUC.MessageBrd.Background = Brushes.Transparent + End If + End If + End If + + End Sub + + ' Imposto la visibilità degli oggetti nella pagina: qui eseguo l'impaginazione + Private Sub TxBlChBxView() + + If m_nCount = 0 Then + ' nascondo il nome delle colonne + SideAngleBl.Visibility = Windows.Visibility.Hidden + HeelBl.Visibility = Windows.Visibility.Hidden + Else + ' definisco il posizionamento del nome (Alz.) delle colonne all'interno della grigia + Grid.SetRow(SideAngleBl, MAX_LINES - m_nShow) + SideAngleBl.Text = "Alz." + SideAngleBl.Visibility = Windows.Visibility.Visible + ' definisco il posizionamento del nome (Front.) delle colonne all'interno della grigia + Grid.SetRow(HeelBl, MAX_LINES - m_nShow) + HeelBl.Text = "Front." + HeelBl.Visibility = Windows.Visibility.Visible + End If + + ' Lati visibili + For nI As Integer = 1 To m_nShow + Dim Index As Integer = MAX_LINES - m_nShow + nI + ' definisco la visibilità della label + GetTxBlFromIndex(Index).Visibility = Windows.Visibility.Visible + ' definisco il nome della label (se volessi associare direttamente il nome della linea dovrei riordinare la lista!) + GetTxBlFromIndex(Index).Text = "A" & nI.ToString + + GetChBxFromIndex(Index).Visibility = Windows.Visibility.Visible + ' aggiungo i campi per allungare e accorciare i lati + GetAngleTxBxFromIndex(Index).Visibility = Windows.Visibility.Visible + GetHeelTxBxFromIndex(Index).Visibility = Windows.Visibility.Visible + Next + + ' Lati nascosti: nascondo i lati partendo dall'alto (se ho 4 lati la prima TextBx disponibile è la settima -> 11-4 = 7 lati nascosti) + For Index As Integer = 1 To MAX_LINES - m_nShow + GetChBxFromIndex(Index).Visibility = Windows.Visibility.Hidden + GetAngleTxBxFromIndex(Index).Visibility = Windows.Visibility.Hidden + GetHeelTxBxFromIndex(Index).Visibility = Windows.Visibility.Hidden + GetTxBlFromIndex(Index).Visibility = Windows.Visibility.Hidden + + Next + End Sub + + ' Permette di aggiugere accanto alla linea passata + Friend Function AddTextToLine(sText As String, TextLayer As Integer, CurrLine As Integer, dDistance As Double, + dBBoxRad As Double, bTextExt As Boolean, Optional bRot As Boolean = False) As Integer + ' Calcolo altezza testo + Dim dH As Double = 0.05 * dBBoxRad + ' Creo testo + Dim nText As Integer = EgtCreateTextAdv(TextLayer, Point3d.ORIG(), 0, sText, "", 500, False, dH, 1, 0, INS_POS.MC) + ' Calcolo posizionamento + ' BBox del testo e suo centro + Dim ptMinBBox As Point3d + Dim ptMaxBBox As Point3d + EgtGetBBox(nText, GDB_BB.STANDARD, ptMinBBox, ptMaxBBox) + Dim ptMidBBox As Point3d + ptMidBBox = Point3d.Media(ptMinBBox, ptMaxBBox) + ' Punto medio della curva + Dim ptMid As Point3d + EgtMidPoint(CurrLine, nText, ptMid) + ' Versore sul punto medio della curva + Dim vtMid As Vector3d + EgtMidVector(CurrLine, nText, vtMid) + ' versore perpendicolare alla CurrLine che punta verso il testo + Dim vtOrto As New Vector3d(vtMid) + If bTextExt Then + vtOrto.Rotate(Vector3d.Z_AX(), -90) + Else + vtOrto.Rotate(Vector3d.Z_AX(), 90) + End If + ' eventuale rotazione del testo + Dim dRotAng As Double = 0 + If bRot Then + dRotAng = Math.Atan2(vtMid.y, vtMid.x) * 180 / Math.PI + Dim dSpecRotAng = dRotAng + If dSpecRotAng > 91 Then + dSpecRotAng -= 180 + ElseIf dSpecRotAng < -89 Then + dSpecRotAng += 180 + End If + EgtRotate(nText, Point3d.ORIG(), Vector3d.Z_AX(), dSpecRotAng) + End If + ' vettore dal centro del BBox all'estremo più vicino + Dim vtptExtptMC As Vector3d + If bRot Then + vtptExtptMC = New Vector3d(0, ptMidBBox.y - ptMinBBox.y, 0) + vtptExtptMC.Rotate(Vector3d.Z_AX(), dRotAng) + Else + If bTextExt Then + If vtMid.x > 0 Then + If vtMid.y > 0 Then + vtptExtptMC = ptMidBBox - New Point3d(ptMinBBox.x, ptMaxBBox.y, 0) + Else + vtptExtptMC = ptMidBBox - ptMaxBBox + End If + Else + If vtMid.y > 0 Then + vtptExtptMC = ptMidBBox - ptMinBBox + Else + vtptExtptMC = ptMidBBox - New Point3d(ptMaxBBox.x, ptMinBBox.y, 0) + End If + End If + Else + If vtMid.x > 0 Then + If vtMid.y > 0 Then + vtptExtptMC = ptMidBBox - New Point3d(ptMaxBBox.x, ptMinBBox.y, 0) + Else + vtptExtptMC = ptMidBBox - ptMinBBox + End If + Else + If vtMid.y > 0 Then + vtptExtptMC = ptMidBBox - ptMaxBBox + Else + vtptExtptMC = ptMidBBox - New Point3d(ptMinBBox.x, ptMaxBBox.y, 0) + End If + End If + End If + End If + ' Calcolo il centro del testo + Dim ptTextMC As Point3d = ptMid + vtOrto * (dDistance + (vtOrto * vtptExtptMC)) + EgtMove(nText, (ptTextMC - Point3d.ORIG())) + Return nText + End Function + +#Region "CHIAMATA ALLE TEXT/CHECK/LABEL" + Private Function GetChBxFromIndex(Index As Integer) As CheckBox + Select Case Index + Case 1 + Return A1 + Case 2 + Return A2 + Case 3 + Return A3 + Case 4 + Return A4 + Case 5 + Return A5 + Case 6 + Return A6 + Case 7 + Return A7 + Case 8 + Return A8 + Case 9 + Return A9 + Case Else + Return A10 + End Select + End Function + + Private Function GetAngleTxBxFromIndex(Index As Integer) As EgtWPFLib.EgtTextBox + Select Case Index + Case 1 + Return A1TxBx + Case 2 + Return A2TxBx + Case 3 + Return A3TxBx + Case 4 + Return A4TxBx + Case 5 + Return A5TxBx + Case 6 + Return A6TxBx + Case 7 + Return A7TxBx + Case 8 + Return A8TxBx + Case 9 + Return A9TxBx + Case Else + Return A10TxBx + End Select + End Function + + Private Function GetHeelTxBxFromIndex(Index As Integer) As EgtWPFLib.EgtTextBox + Select Case Index + Case 1 + Return H1TxBx + Case 2 + Return H2TxBx + Case 3 + Return H3TxBx + Case 4 + Return H4TxBx + Case 5 + Return H5TxBx + Case 6 + Return H6TxBx + Case 7 + Return H7TxBx + Case 8 + Return H8TxBx + Case 9 + Return H9TxBx + Case Else + Return H10TxBx + End Select + End Function + + Private Function GetTxBlFromIndex(Index As Integer) As TextBlock + Select Case Index + Case 1 + Return Entity1 + Case 2 + Return Entity2 + Case 3 + Return Entity3 + Case 4 + Return Entity4 + Case 5 + Return Entity5 + Case 6 + Return Entity6 + Case 7 + Return Entity7 + Case 8 + Return Entity8 + Case 9 + Return Entity9 + Case Else + Return Entity10 + End Select + End Function + +#End Region ' Chiamata elle Text/Check/Label + + ' Per gestire la selezione delle Alzatine (devo ancora definire la CheckBox: An) + Private Sub A_Checked(sender As Object, e As RoutedEventArgs) Handles A1.Checked, A2.Checked, A3.Checked, A4.Checked + ' recupero il nome della Check selezionata + Dim sChName As String = DirectCast(sender, CheckBox).Name + Dim sItems As String() = Split(sChName, "A") + Dim nIndex As Integer + If sItems.Count > 1 Then + nIndex = CInt(sItems(1)) + End If + Dim j As Integer = nIndex - (MAX_LINES - m_nShow) + AddTextToLine(AlzFrontEntityList(j).SideName, m_AlzLayer, AlzFrontEntityList(j).Id, 20, m_dBBoxRad, True) + + 'For j = 0 To AlzFrontEntityList.Count() - 1 + ' If AlzFrontEntityList(j).SideName = sChName Then + ' If sChName = "A1" Or sChName = "A3" Or sChName = "A5" Or sChName = "A7" Then + ' AddTextToLine(AlzFrontEntityList(j).SideName, m_AlzLayer, AlzFrontEntityList(j).Id, 20, m_dBBoxRad, True) + ' Else + ' AddTextToLine(AlzFrontEntityList(j).SideName, m_Frontlayer, AlzFrontEntityList(j).Id, 20, m_dBBoxRad, True) + ' End If + ' Exit For + ' End If + 'Next + + EgtDraw() + End Sub + + ' Per gestire la selezione dei Frontalini (devo ancora definire la CheckBox: Fn) + 'Private Sub F_Checked(sender As Object, e As RoutedEventArgs) Handles A1.Checked, A2.Checked, A3.Checked, A4.Checked, A5.Checked, A6.Checked, A7.Checked, A8.Checked + ' ' recupero il nome della Check selezionata + ' Dim sChName As String = DirectCast(sender, CheckBox).Name + + ' For j = 0 To AlzFrontEntityList.Count() - 1 + ' If AlzFrontEntityList(j).SideName = sChName Then + ' If sChName = "A1" Or sChName = "A3" Or sChName = "A5" Or sChName = "A7" Then + ' AddTextToLine(AlzFrontEntityList(j).SideName, m_AlzLayer, AlzFrontEntityList(j).Id, 20, m_dBBoxRad, True) + ' Else + ' AddTextToLine(AlzFrontEntityList(j).SideName, m_Frontlayer, AlzFrontEntityList(j).Id, 20, m_dBBoxRad, True) + ' End If + ' Exit For + ' End If + ' Next + + ' EgtDraw() + 'End Sub + + ' metodo utilizzato per tornare indietro alla pagina di selezione "CompoInterni/Alz&Front" + Private Sub BackBtn_Click(sender As Object, e As RoutedEventArgs) Handles BackBtn.Click + m_MainWindow.m_DrawPageUC.m_SceneButtons.MeasureBtn.IsChecked = False + + ' torno alla pagina iniziale di selezione del piano (Compo) + 'm_MainWindow.m_DrawPageUC.BackBtn_Click(sender, e) + + '--------- NUOVA GESTIONE --------- + ' rimuovo l'elenco di bottoni per selezionare il tipo di componente interna + m_MainWindow.m_DrawPageUC.LeftButtonGrd.Children.Remove(Me) + ' inserisco nella Grid VaribalsesGrid lo UeserControl per definire le dimensioni della componente + m_MainWindow.m_DrawPageUC.VariablesGrd.Children.Add(m_MainWindow.m_DrawPageUC.m_CompoDimension) + ' nascondo la lista dei parametri + m_MainWindow.m_DrawPageUC.m_CompoDimension.CollapsedAllParam() + ' sto uscendo dalla componente interna (quindi comunico il cambio di componente) + m_MainWindow.m_DrawPageUC.m_bInternalCompo = False + ' comunico che sto arrivando da una componente interna + m_MainWindow.m_DrawPageUC.m_bBackFromInternalCompo = True + + 'm_MainWindow.m_DrawPageUC.SelectedComponent(m_MainWindow.m_DrawPageUC.m_sMainCompo) + 'm_MainWindow.m_DrawPageUC.m_ActiveComponentPage = DrawPageUC.Pages.CompoDimension + End Sub + +End Class + +Public Class AlzFrontEntity + Public Enum AlzFront + ALZATINA + FRONTALINO + End Enum + + Private m_SideName As String + Private m_Type As AlzFront + Private m_Id As Integer + + Public Property SideName As String + Get + Return m_SideName + End Get + Set(value As String) + m_SideName = value + End Set + End Property + + Public Property Type As AlzFront + Get + Return m_Type + End Get + Set(value As AlzFront) + m_Type = value + End Set + End Property + + Public Property Id As Integer + Get + Return m_Id + End Get + Set(value As Integer) + m_Id = value + End Set + End Property + + Sub New(Name As String, CurrId As Integer) + m_SideName = Name + m_Id = CurrId + End Sub + +End Class \ No newline at end of file diff --git a/DrawImport/CompoDimensionUC.xaml b/DrawImport/CompoDimensionUC.xaml index dcb6a28..02ee754 100644 --- a/DrawImport/CompoDimensionUC.xaml +++ b/DrawImport/CompoDimensionUC.xaml @@ -26,7 +26,7 @@ - + @@ -69,12 +69,18 @@ -