From c9b492da9b4d37cfc7212e9c8a67b17fcb61da0b Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 16 Feb 2018 15:45:53 +0000 Subject: [PATCH] OmagCUT : - migliorie su finestra inclinazione lati. --- DrawPageUC.xaml.vb | 36 ++++++------------------------------ ImportPageUC.xaml.vb | 35 ++++++++++++++++++++++++++++------- SideAngleUc.xaml.vb | 26 +++++++++++++++++--------- 3 files changed, 51 insertions(+), 46 deletions(-) diff --git a/DrawPageUC.xaml.vb b/DrawPageUC.xaml.vb index ea65aec..ef108b3 100644 --- a/DrawPageUC.xaml.vb +++ b/DrawPageUC.xaml.vb @@ -299,6 +299,7 @@ Public Class DrawPageUC If nStat = GDB_ST.SEL Then EgtDeselectAll() m_nSelectedLayer = GDB_ID.NULL + m_SideAngleUC.WriteSideAngleForNest(DrawScene.GetCtx()) ' Messaggio di selezione da effettuare MessageTxBx.Text = EgtMsg(MSG_DRAWPAGEUC + 6) ' Selezionare un contorno MessageBrd.Background = Application.Current.FindResource("OmagCut_Green") @@ -547,6 +548,7 @@ Public Class DrawPageUC EgtLuaGetGlobIntVar(LUA_CMP_VARS & ".ERR", nErr) m_bDrawOk = (nErr = 0) End If + AdjustFlatPart(EgtGetFirstPart()) Return m_bDrawOk End Function @@ -577,40 +579,12 @@ Public Class DrawPageUC End If nId = EgtGetNext(nId) End While - ' Layer OutLoop + ' Calcolo dimensione ingombro Pezzo tramite OutLoop Dim nOutLoopLayer = EgtGetFirstNameInGroup(Pz, NAME_OUTLOOP) - ' Calcolo dimensione ingombro OutLoop Dim ptMin, ptMax As Point3d EgtGetBBoxGlob(nOutLoopLayer, GDB_BB.STANDARD, ptMin, ptMax) - Dim dBBoxRad As Double = 0.5 * Point3d.DistXY(ptMin, ptMax) - ' Ricavo nome layer con testi inclinazioni - Dim TextLayer As Integer = EgtGetFirstNameInGroup(Pz, SIDE_ANGLE_LAYER) - ' Se presente lo svuoto - If TextLayer <> GDB_ID.NULL Then - EgtEmptyGroup(TextLayer) - ' altrimenti lo creo - Else - TextLayer = EgtCreateGroup(Pz) - EgtSetName(TextLayer, SIDE_ANGLE_LAYER) - EgtSetColor(TextLayer, New Color3d(0, 0, 0)) - End If ' Scrivo testi per nesting m_SideAngleUC.WriteSideAngleForNest(DrawScene.GetCtx()) - - ' Modifico inclinazione lati - 'For Each Entity In m_SideAngleUC.m_SideAngleEntityList - ' Dim nCurrEntityName As Integer = EgtGetFirstNameInGroup(nOutLoopLayer, Entity.sEntityName) - ' If Math.Abs(Entity.dSideAngle) > EPS_ANG_SMALL Then - ' ' Scrivo nuovo angolo nelle info - ' EgtSetInfo(nCurrEntityName, INFO_SIDE_ANGLE, Entity.dSideAngle) - ' ' Creo testo con angolo di inclinazione per nesting - ' Dim sText As String = DoubleToString(Entity.dSideAngle, 1) & "°" - ' SideAngleUC.AddTextToLine(sText, TextLayer, nCurrEntityName, 20, dBBoxRad, False) - ' Else - ' ' Cancello inclinazione nell'apposito campo info - ' EgtRemoveInfo(nCurrEntityName, INFO_SIDE_ANGLE) - ' End If - 'Next ' Esporto il pezzo in un file temporaneo Dim sTmpFile As String = m_MainWindow.GetTempDir() & "\FlatPartCompo.Nge" If Not EgtSaveObjToFile(1, sTmpFile, NGE.BIN) Then @@ -647,7 +621,7 @@ Public Class DrawPageUC End While End If ' Eventuale testo per indicare il sopra (solo nel caso di rettangolo) - If TopChBx.IsChecked() Then + If TopChBx.IsVisible() And TopChBx.IsChecked() Then Dim dDimX As Double = ptMax.x - ptMin.x Dim dDimY As Double = ptMax.y - ptMin.y Dim dH As Double = Math.Min(0.1 * dDimY, 30) @@ -770,6 +744,8 @@ Public Class DrawPageUC Else MessageTxBx.Text = EgtMsg(MSG_DRAWPAGEUC + 6) ' Selezionare un contorno MessageBrd.Background = Application.Current.FindResource("OmagCut_Green") + ' Aggiungo testi su lati già inclinati + m_SideAngleUC.WriteSideAngleForNest(DrawScene.GetCtx()) End If ' In ogni caso, nascondo layer delle misure Dim PartId As Integer = EgtGetFirstInGroup(GDB_ID.ROOT) diff --git a/ImportPageUC.xaml.vb b/ImportPageUC.xaml.vb index 3a01430..a704ff0 100644 --- a/ImportPageUC.xaml.vb +++ b/ImportPageUC.xaml.vb @@ -364,6 +364,9 @@ Public Class ImportPageUC m_nSelectedPart = GDB_ID.NULL m_nSelectedLayer = GDB_ID.NULL m_SideAngleUC.WriteSideAngleForNest(ImportScene.GetCtx()) + ' Messaggio di selezione da effettuare + MessageTxBx.Text = EgtMsg(MSG_DRAWPAGEUC + 6) ' Selezionare un contorno + MessageBrd.Background = Application.Current.FindResource("OmagCut_Green") Else Dim nLayId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_OUTLOOP) EgtGetInfo(nId, "ID", nLayId) @@ -372,6 +375,9 @@ Public Class ImportPageUC EgtSelectObj(nLayId) m_nSelectedPart = nPartId m_nSelectedLayer = nLayId + ' Pulisco area messaggi + MessageTxBx.Text = "" + MessageBrd.Background = Brushes.Transparent End If SelectedPartChanged() EgtDraw() @@ -536,13 +542,6 @@ Public Class ImportPageUC m_SceneButtons.MeasureBtn.IsChecked = False ' Se import per pezzi piatti If m_MainWindow.m_PrevActivePage = MainWindow.Pages.CadCut Then - ' Cancello testi e regioni di selezione dai pezzi - Dim PartId As Integer = EgtGetFirstPart() - While PartId <> GDB_ID.NULL - EgtErase(EgtGetFirstNameInGroup(PartId, SIDE_ANGLE_LAYER)) - EgtErase(EgtGetFirstNameInGroup(PartId, SELECT_REGION_LAYER)) - PartId = EgtGetNextPart(PartId) - End While ' Eseguo importazione pezzi piatti LoadFlatParts() ' altrimenti import per cornici @@ -556,6 +555,12 @@ Public Class ImportPageUC End Sub Private Sub LoadFlatParts() + ' Cancello regioni di selezione dai pezzi + Dim PartId As Integer = EgtGetFirstPart() + While PartId <> GDB_ID.NULL + EgtErase(EgtGetFirstNameInGroup(PartId, SELECT_REGION_LAYER)) + PartId = EgtGetNextPart(PartId) + End While ' Scrivo testi per nesting m_SideAngleUC.WriteSideAngleForNest(ImportScene.GetCtx()) ' Imposto riferimento sul centro geometrico di ogni pezzo @@ -676,6 +681,9 @@ Public Class ImportPageUC inchBtn.IsEnabled = False ' Disabilito bottone reset ResetBtn.IsEnabled = False + ' Messaggio di selezione da effettuare + MessageTxBx.Text = EgtMsg(MSG_DRAWPAGEUC + 6) ' Selezionare un contorno + MessageBrd.Background = Application.Current.FindResource("OmagCut_Green") Else FilePathTxBl.Visibility = Windows.Visibility.Visible FileListBox.Visibility = Windows.Visibility.Visible @@ -692,11 +700,17 @@ Public Class ImportPageUC m_SideAngleUC.WriteSideAngleForNest(ImportScene.GetCtx()) ' Riabilito bottone reset ResetBtn.IsEnabled = True + ' Pulisco area messaggi + MessageTxBx.Text = "" + MessageBrd.Background = Brushes.Transparent End If + EgtZoom(ZM.ALL) End Sub Private Sub DripBtn_Click(sender As Object, e As RoutedEventArgs) Handles DripBtn.Click If DripBtn.IsChecked() Then + ' Aggiungo regioni per percorsi interni + AdjustSelectRegions() ' Imposto modalità drip m_SideAngleUC.m_Mode = SideAngleUC.ModeOpt.DRIP LeftGrid.Children.Add(m_SideAngleUC) @@ -708,6 +722,9 @@ Public Class ImportPageUC inchBtn.IsEnabled = False ' Disabilito bottone reset ResetBtn.IsEnabled = False + ' Messaggio di selezione da effettuare + MessageTxBx.Text = EgtMsg(MSG_DRAWPAGEUC + 6) ' Selezionare un contorno + MessageBrd.Background = Application.Current.FindResource("OmagCut_Green") Else FilePathTxBl.Visibility = Windows.Visibility.Visible FileListBox.Visibility = Windows.Visibility.Visible @@ -725,7 +742,11 @@ Public Class ImportPageUC EgtErase(EgtGetFirstNameInGroup(Part1, SIDE_ANGLE_LAYER)) ' Riabilito bottone reset ResetBtn.IsEnabled = True + ' Pulisco area messaggi + MessageTxBx.Text = "" + MessageBrd.Background = Brushes.Transparent End If + EgtZoom(ZM.ALL) End Sub Private Function AdjustSelectRegions() As Boolean diff --git a/SideAngleUc.xaml.vb b/SideAngleUc.xaml.vb index 185746c..af162ca 100644 --- a/SideAngleUc.xaml.vb +++ b/SideAngleUc.xaml.vb @@ -2,6 +2,8 @@ Public Class SideAngleUC + Friend Const MAX_SIDEANG As Double = 67.5 + Public Enum ModeOpt As Integer SIDEANGLE = 0 DRIP = 1 @@ -11,7 +13,6 @@ Public Class SideAngleUC ' Riferimento alla MainWindow Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow) - Private m_DrawPage As DrawPageUC ' Riferimento alla pagina che ha aperto SideAngleUC Private m_CallingPage As MainWindow.Pages @@ -25,7 +26,6 @@ Public Class SideAngleUC Private Sub SideAngleUC_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded ' Imposto riferimenti ad altre pagine - m_DrawPage = m_MainWindow.m_DrawPageUC m_CallingPage = m_MainWindow.m_ActivePage ' Imposto messaggi @@ -52,7 +52,7 @@ Public Class SideAngleUC If m_CallingPage = MainWindow.Pages.Draw Then ' Imposto questa come pagina correntemente visualizzata nella drawpage - m_DrawPage.m_ActiveComponentPage = DrawPageUC.Pages.SideAngle + m_MainWindow.m_DrawPageUC.m_ActiveComponentPage = DrawPageUC.Pages.SideAngle ' Imposto contesto corrente EgtSetCurrentContext(m_MainWindow.m_DrawPageUC.DrawScene.GetCtx()) ' Inizializzo @@ -129,6 +129,7 @@ Public Class SideAngleUC Parameter2TxBx.Text = LenToString(m_dDripDepth, 3) Parameter3TxBx.Text = LenToString(m_dDripShort, 3) End If + ' Aggiorno visualizzazione If m_CallingPage = MainWindow.Pages.Draw Then EgtZoom(ZM.ALL) @@ -282,7 +283,7 @@ Public Class SideAngleUC ' Imposto contesto corrente EgtSetCurrentContext(m_MainWindow.m_DrawPageUC.DrawScene.GetCtx()) ' Ricavo nome primo pezzo - PartId = EgtGetFirstInGroup(GDB_ID.ROOT) + PartId = If(m_MainWindow.m_DrawPageUC.SelectedLayer <> GDB_ID.NULL, EgtGetFirstPart(), GDB_ID.NULL) ' Recupero nome layer con geometria di contorno (esterno o interno) del pezzo LoopId = m_MainWindow.m_DrawPageUC.SelectedLayer ElseIf m_CallingPage = MainWindow.Pages.Import Then @@ -303,7 +304,7 @@ Public Class SideAngleUC Dim TextLayer As Integer = EgtGetFirstNameInGroup(PartId, SIDE_ANGLE_LAYER) If TextLayer <> GDB_ID.NULL Then EgtEmptyGroup(TextLayer) - Else + ElseIf PartId <> GDB_ID.NULL Then TextLayer = EgtCreateGroup(PartId) EgtSetName(TextLayer, SIDE_ANGLE_LAYER) EgtSetColor(TextLayer, New Color3d(0, 0, 0)) @@ -336,8 +337,7 @@ Public Class SideAngleUC ' Imposto contesto corrente EgtSetCurrentContext(m_MainWindow.m_DrawPageUC.DrawScene.GetCtx()) ' Ricavo nome primo pezzo e lo sistemo - PartId = EgtGetFirstInGroup(GDB_ID.ROOT) - AdjustFlatPart(PartId) + PartId = If(m_MainWindow.m_DrawPageUC.SelectedLayer <> GDB_ID.NULL, EgtGetFirstPart(), GDB_ID.NULL) ' Recupero nome layer con geometria di contorno (esterno o interno) del pezzo LoopId = m_MainWindow.m_DrawPageUC.SelectedLayer Else @@ -355,7 +355,7 @@ Public Class SideAngleUC Dim dBBoxRad As Double = 0.5 * Point3d.DistXY(ptMin, ptMax) ' Creo layer per testi se non esiste già Dim TextLayer As Integer = EgtGetFirstNameInGroup(PartId, SIDE_ANGLE_LAYER) - If TextLayer = GDB_ID.NULL Then + If TextLayer = GDB_ID.NULL And PartId <> GDB_ID.NULL Then TextLayer = EgtCreateGroup(PartId) EgtSetName(TextLayer, SIDE_ANGLE_LAYER) EgtSetColor(TextLayer, New Color3d(0, 0, 0)) @@ -751,6 +751,14 @@ Public Class SideAngleUC ' Nuovo angolo di inclinazione Dim dSideAngle As Double StringToDouble(AngleTxBx.Text, dSideAngle) + ' Verifico stia nei limiti + If dSideAngle < -MAX_SIDEANG Then + dSideAngle = -MAX_SIDEANG + AngleTxBx.Text = DoubleToString(dSideAngle, 2) + ElseIf dSideAngle > MAX_SIDEANG Then + dSideAngle = MAX_SIDEANG + AngleTxBx.Text = DoubleToString(dSideAngle, 2) + End If ' Converto nome checkbox in nome elemento tenendo conto dello slittamento verso il basso Dim nCurrSide As Integer = m_SideAngleEntityList.Count() - (10 - SideIndex) Dim sCurrSide As String = m_SideAngleEntityList(nCurrSide - 1).sEntityName @@ -907,7 +915,7 @@ Public Class SideAngleUC End Function Friend Sub ReLoadSideAnglePage() - SideAngleUC_Unloaded(Me, New RoutedEventArgs) + 'SideAngleUC_Unloaded(Me, New RoutedEventArgs) SideAngleUC_Loaded(Me, New RoutedEventArgs) End Sub