85e906e4c8
- aggiunta prima versione di Vein Matching - si eliminano spazi iniziali e finali da nomi utensili e lavorazioni - nuovo utensile come copia di esistente ora crea nuovo disegno - nuovo utensile ora assegna valori di default alla geometria.
624 lines
24 KiB
VB.net
624 lines
24 KiB
VB.net
Imports EgtUILib
|
|
|
|
Public Class SideAngleUC
|
|
|
|
' Costanti layer componenti
|
|
Friend Const COMPO_LAYER_AUX As String = "LayAux"
|
|
Friend Const COMPO_LAYER_QUOTATURE As String = "Quotature"
|
|
Friend Const COMPO_LAYER_ETICHETTE As String = "Etichette"
|
|
|
|
' 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
|
|
|
|
' Lista di tutte le entità inclinabili presenti nel progetto
|
|
Friend m_SideAngleEntityList As New List(Of SideAngleEntity)
|
|
|
|
Private Sub SideAngleUC_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
' Copio riferimento alla DrawPage
|
|
m_DrawPage = m_MainWindow.m_DrawPageUC
|
|
|
|
m_CallingPage = m_MainWindow.m_ActivePage
|
|
|
|
If m_CallingPage = MainWindow.Pages.Draw Then
|
|
' Imposto questa come pagina correntemente visualizzata nella drawpage
|
|
m_DrawPage.m_ActiveComponentPage = DrawPageUC.Pages.SideAngle
|
|
|
|
' Imposto contesto corrente
|
|
EgtSetCurrentContext(m_MainWindow.m_DrawPageUC.DrawScene.GetCtx())
|
|
' se la lista non è vuota la leggo e metto le inclinazioni giuste
|
|
If m_SideAngleEntityList.Count > 0 Then
|
|
' Aggiorno indici che potrebbero essere cambiati se sono state modificate le misure
|
|
RefreshGeomId()
|
|
' Aggiorno testi in base alla tabella
|
|
RefreshSideAngleText()
|
|
' Aggiorno elenco variabili
|
|
|
|
Else
|
|
' Inizializzo lati per angoli (ne compilo la lista e aggiungo la scritta nel disegno)
|
|
InitSideAngleLine()
|
|
End If
|
|
|
|
ElseIf m_CallingPage = MainWindow.Pages.Import Then
|
|
' Imposto contesto corrente
|
|
EgtSetCurrentContext(m_MainWindow.m_ImportPageUC.ImportScene.GetCtx())
|
|
DeleteSideAngle()
|
|
' Inizializzo lati per angoli (ne compilo la lista e aggiungo la scritta nel disegno)
|
|
InitSideAngleLine()
|
|
RefreshSideAngleText()
|
|
End If
|
|
|
|
' Gestisco Checkbox e nomi in base al numero di lati inclinabili
|
|
TxBlChBxView()
|
|
|
|
' Ricavo nome primo pezzo
|
|
Dim Part1 As Integer = EgtGetFirstInGroup(GDB_ID.ROOT)
|
|
' Nascondo layer delle misure
|
|
EgtSetStatus(EgtGetFirstNameInGroup(Part1, COMPO_LAYER_AUX), GDB_ST.OFF)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(Part1, COMPO_LAYER_QUOTATURE), GDB_ST.OFF)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(Part1, COMPO_LAYER_ETICHETTE), GDB_ST.OFF)
|
|
EgtZoom(ZM.ALL)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub TxBlChBxView()
|
|
For Index As Integer = 1 To 10 - m_SideAngleEntityList.Count
|
|
GetChBxFromIndex(Index).Visibility = Windows.Visibility.Hidden
|
|
GetTxBlFromIndex(Index).Visibility = Windows.Visibility.Hidden
|
|
Next
|
|
' Indice dei nomi per TxBl
|
|
Dim TxBlIndex As Integer = 1
|
|
For Index As Integer = 10 - m_SideAngleEntityList.Count + 1 To 10
|
|
GetChBxFromIndex(Index).Visibility = Windows.Visibility.Visible
|
|
GetTxBlFromIndex(Index).Text = "A" & TxBlIndex
|
|
GetTxBlFromIndex(Index).Visibility = Windows.Visibility.Visible
|
|
TxBlIndex += 1
|
|
Next
|
|
End Sub
|
|
|
|
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 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
|
|
|
|
Private Sub SideAngleUC_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded
|
|
Dim Part1 As Integer
|
|
If m_CallingPage = MainWindow.Pages.Draw Then
|
|
' Ricavo nome primo pezzo
|
|
Part1 = EgtGetFirstInGroup(GDB_ID.ROOT)
|
|
' Attivo layer delle misure
|
|
EgtSetStatus(EgtGetFirstNameInGroup(Part1, COMPO_LAYER_AUX), GDB_ST.ON_)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(Part1, COMPO_LAYER_QUOTATURE), GDB_ST.ON_)
|
|
EgtSetStatus(EgtGetFirstNameInGroup(Part1, COMPO_LAYER_ETICHETTE), GDB_ST.ON_)
|
|
' Svuoto layer in cui sono presenti i testi con le inclinazioni dei lati
|
|
EgtEmptyGroup(EgtGetFirstNameInGroup(Part1, SIDE_ANGLE_LAYER))
|
|
|
|
ElseIf m_CallingPage = MainWindow.Pages.Import Then
|
|
' Ricavo nome pezzo precedentemente selezionato
|
|
Part1 = m_MainWindow.m_ImportPageUC.m_PrevSelPart
|
|
EgtErase(EgtGetFirstNameInGroup(Part1, SIDE_ANGLE_LAYER))
|
|
End If
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub RefreshGeomId()
|
|
' Ricavo nome primo pezzo
|
|
Dim Part1 As Integer = EgtGetFirstInGroup(GDB_ID.ROOT)
|
|
' Ricavo nome layer con geometria esterna pezzo
|
|
Dim OutLoop As Integer = EgtGetFirstNameInGroup(Part1, NAME_OUTLOOP)
|
|
For Each Entity In m_SideAngleEntityList
|
|
Entity.nGeomId = EgtGetFirstNameInGroup(OutLoop, Entity.sEntityName)
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub ReadSideAngleText()
|
|
' Imposto contesto corrente
|
|
EgtSetCurrentContext(m_MainWindow.m_ImportPageUC.ImportScene.GetCtx())
|
|
' Ricavo nome primo pezzo
|
|
Dim Part1 As Integer = EgtGetFirstSelectedObj()
|
|
|
|
' Cancello testi già presenti
|
|
' Ricavo nome layer con geometria esterna pezzo
|
|
Dim OutLoop As Integer = EgtGetFirstNameInGroup(Part1, NAME_OUTLOOP)
|
|
' Calcolo dimensione ingombro OutLoop
|
|
Dim ptMin, ptMax As Point3d
|
|
EgtGetBBoxGlob(OutLoop, 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(Part1, SIDE_ANGLE_LAYER)
|
|
' Se presente lo svuoto
|
|
If TextLayer <> GDB_ID.NULL Then
|
|
EgtEmptyGroup(TextLayer)
|
|
Else
|
|
' altrimenti lo creo
|
|
TextLayer = EgtCreateGroup(Part1)
|
|
EgtSetName(TextLayer, SIDE_ANGLE_LAYER)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub RefreshSideAngleText()
|
|
Dim Part1 As Integer
|
|
' Imposto contesto corrente
|
|
If m_CallingPage = MainWindow.Pages.Draw Then
|
|
' Imposto contesto corrente
|
|
EgtSetCurrentContext(m_MainWindow.m_DrawPageUC.DrawScene.GetCtx())
|
|
' Ricavo nome primo pezzo
|
|
Part1 = EgtGetFirstInGroup(GDB_ID.ROOT)
|
|
ElseIf m_CallingPage = MainWindow.Pages.Import Then
|
|
' Imposto contesto corrente
|
|
EgtSetCurrentContext(m_MainWindow.m_ImportPageUC.ImportScene.GetCtx())
|
|
' Ricavo nome primo pezzo
|
|
Part1 = EgtGetFirstSelectedObj()
|
|
End If
|
|
|
|
' Cancello testi già presenti
|
|
' Ricavo nome layer con geometria esterna pezzo
|
|
Dim OutLoop As Integer = EgtGetFirstNameInGroup(Part1, NAME_OUTLOOP)
|
|
' Calcolo dimensione ingombro OutLoop
|
|
Dim ptMin, ptMax As Point3d
|
|
EgtGetBBoxGlob(OutLoop, 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(Part1, SIDE_ANGLE_LAYER)
|
|
' Se presente lo svuoto
|
|
If TextLayer <> GDB_ID.NULL Then
|
|
EgtEmptyGroup(TextLayer)
|
|
Else
|
|
' altrimenti lo creo
|
|
TextLayer = EgtCreateGroup(Part1)
|
|
EgtSetName(TextLayer, SIDE_ANGLE_LAYER)
|
|
End If
|
|
|
|
For Each Entity In m_SideAngleEntityList
|
|
' Creo testo con angolo di inclinazione
|
|
AddTextToLine(Entity.sEntityName & " = " & DoubleToString(Entity.dSideAngle, 1) & "°", Entity.nTextId, Entity.nGeomId, 10, dBBoxRad, True)
|
|
Next
|
|
|
|
'Aggiorno visualizzazione
|
|
EgtZoom(ZM.ALL)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub InitSideAngleLine()
|
|
Dim Part1 As Integer
|
|
If m_CallingPage = MainWindow.Pages.Draw Then
|
|
' Imposto contesto corrente
|
|
EgtSetCurrentContext(m_MainWindow.m_DrawPageUC.DrawScene.GetCtx())
|
|
' Ricavo nome primo pezzo
|
|
Part1 = EgtGetFirstInGroup(GDB_ID.ROOT)
|
|
Else
|
|
' Imposto contesto corrente
|
|
EgtSetCurrentContext(m_MainWindow.m_ImportPageUC.ImportScene.GetCtx())
|
|
' Ricavo nome primo pezzo
|
|
Part1 = EgtGetFirstSelectedObj()
|
|
End If
|
|
|
|
AdjustFlatPart(Part1)
|
|
' Ricavo nome layer con geometria esterna pezzo
|
|
Dim OutLoop As Integer = EgtGetFirstNameInGroup(Part1, NAME_OUTLOOP)
|
|
' Calcolo dimensione ingombro OutLoop
|
|
Dim ptMin, ptMax As Point3d
|
|
EgtGetBBoxGlob(OutLoop, GDB_BB.STANDARD, ptMin, ptMax)
|
|
Dim dBBoxRad As Double = 0.5 * Point3d.DistXY(ptMin, ptMax)
|
|
' Creo layer per testi
|
|
Dim TextLayer As Integer = EgtCreateGroup(Part1)
|
|
EgtSetName(TextLayer, SIDE_ANGLE_LAYER)
|
|
|
|
Dim LastLine As Integer = EgtGetLastInGroup(OutLoop)
|
|
Dim CurrLine As Integer = EgtGetFirstInGroup(OutLoop)
|
|
Dim NextLine As Integer = EgtGetNext(CurrLine)
|
|
'Creo indice per numerare le entità in ImportPage
|
|
Dim nEntityIndex As Integer = 1
|
|
' Ciclo che verifica se possibile inclinare la linea corrente fino alla penultima
|
|
While NextLine <> GDB_ID.NULL
|
|
If VerifyIsSideAnglePossible(LastLine, CurrLine, NextLine) Then
|
|
' Aggiungo il lato alla lista di quelli inclinabili e ne azzero l'inclinazione
|
|
AddSideAngle(CurrLine, TextLayer, dBBoxRad, nEntityIndex)
|
|
nEntityIndex += 1
|
|
End If
|
|
LastLine = CurrLine
|
|
CurrLine = NextLine
|
|
NextLine = EgtGetNext(CurrLine)
|
|
End While
|
|
' Verifico se possibile inclinare l'ultima linea
|
|
NextLine = EgtGetFirstInGroup(OutLoop)
|
|
If VerifyIsSideAnglePossible(LastLine, CurrLine, NextLine) Then
|
|
AddSideAngle(CurrLine, TextLayer, dBBoxRad, nEntityIndex)
|
|
End If
|
|
If m_CallingPage = MainWindow.Pages.Import Then
|
|
For Each Entity In m_SideAngleEntityList
|
|
If Entity.dSideAngle <> 0 Then
|
|
Dim nI As Integer = 0
|
|
StringToInt(Entity.sEntityName.Substring(1), nI)
|
|
CheckAngle(nI)
|
|
End If
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
'Funzione che checka gli angoli già inclinati
|
|
Private Sub CheckAngle(nIndex As Integer)
|
|
' Seleziono checkbox per angoli inclinati
|
|
GetChBxFromIndex(10 - (m_SideAngleEntityList.Count - nIndex)).IsChecked = True
|
|
End Sub
|
|
|
|
' Funzione che verifica se la linea corrente è inclinabile in base al tipo della precedente e successiva
|
|
Private Function VerifyIsSideAnglePossible(LastLine As Integer, CurrLine As Integer, NextLine As Integer) As Boolean
|
|
' Verifico se CurrLine è una linea
|
|
If EgtGetType(CurrLine) <> GDB_TY.CRV_LINE Then
|
|
Return False
|
|
End If
|
|
|
|
' Verifico se curva precedente mi permette di inclinare
|
|
Dim bLastOk As Boolean = False
|
|
If EgtGetType(LastLine) = GDB_TY.CRV_LINE Then
|
|
bLastOk = True
|
|
ElseIf EgtGetType(LastLine) = GDB_TY.CRV_ARC Then
|
|
' Ricavo direzione finale linea precedente
|
|
Dim vtLastEnd As Vector3d
|
|
EgtEndVector(LastLine, vtLastEnd)
|
|
' Ricavo direzione iniziale linea corrente
|
|
Dim vtCurrStart As Vector3d
|
|
EgtStartVector(CurrLine, vtCurrStart)
|
|
' Confronto direzioni per vedere se sono tangenti
|
|
' calcolo differenza dei vettori
|
|
Dim vtDiff As Vector3d = vtLastEnd - vtCurrStart
|
|
' verifico che sia nulla o quasi
|
|
bLastOk = Not vtDiff.IsSmall()
|
|
Else
|
|
EgtOutLog("Error in Compo Outloop: find an entity that is not a line or a arc")
|
|
End If
|
|
|
|
' Verifico se curva successiva mi permette di inclinare
|
|
Dim bNextOk As Boolean = False
|
|
If EgtGetType(NextLine) = GDB_TY.CRV_LINE Then
|
|
bNextOk = True
|
|
ElseIf EgtGetType(NextLine) = GDB_TY.CRV_ARC Then
|
|
' Ricavo direzione finale linea corrente
|
|
Dim vtCurrEnd As Vector3d
|
|
EgtEndVector(CurrLine, vtCurrEnd)
|
|
' Ricavo direzione iniziale linea successiva
|
|
Dim vtNextStart As Vector3d
|
|
EgtStartVector(NextLine, vtNextStart)
|
|
' Confronto direzioni per vedere se sono tangenti
|
|
' calcolo differenza dei vettori
|
|
Dim vtDiff As Vector3d = vtCurrEnd - vtNextStart
|
|
' verifico che sia nulla o quasi
|
|
bNextOk = Not vtDiff.IsSmall()
|
|
Else
|
|
EgtOutLog("Error in Compo Outloop: find an entity that is not a line or a arc")
|
|
End If
|
|
|
|
' Se entrambe me lo permettono restituisco vero
|
|
If bLastOk And bNextOk Then
|
|
Return True
|
|
End If
|
|
Return False
|
|
|
|
End Function
|
|
|
|
' Funzione che gestisce le operazioni sull'entità da inclinare
|
|
Private Sub AddSideAngle(CurrLine As Integer, TextLayer As Integer, dBBoxRad As Double, nEntityIndex As Integer)
|
|
' Se sono in importa
|
|
If m_CallingPage = MainWindow.Pages.Import Then
|
|
EgtSetName(CurrLine, "A" & nEntityIndex.ToString())
|
|
End If
|
|
'Ricavo angolo dell'entità
|
|
Dim dSideAngleVal As Double
|
|
If Not EgtGetInfo(CurrLine, INFO_SIDE_ANGLE, dSideAngleVal) Then
|
|
dSideAngleVal = 0
|
|
End If
|
|
' Aggiungo entità all'elenco di quelle inclinabili
|
|
Dim sEntityName As String = String.Empty
|
|
EgtGetName(CurrLine, sEntityName)
|
|
If m_CallingPage = MainWindow.Pages.Draw Then
|
|
m_SideAngleEntityList.Add(New SideAngleEntity(CurrLine, sEntityName, TextLayer, 0))
|
|
' Cancello inclinazione nell'apposito campo info
|
|
EgtRemoveInfo(CurrLine, INFO_SIDE_ANGLE)
|
|
' Creo testo con angolo di inclinazione 0
|
|
AddTextToLine(sEntityName & " = 0°", TextLayer, CurrLine, 10, dBBoxRad, True)
|
|
Else
|
|
m_SideAngleEntityList.Add(New SideAngleEntity(CurrLine, sEntityName, TextLayer, dSideAngleVal))
|
|
' Creo testo con angolo di inclinazione 0
|
|
AddTextToLine(sEntityName & " = " & DoubleToString(dSideAngleVal, 1) & "°", TextLayer, CurrLine, 10, dBBoxRad, True)
|
|
End If
|
|
End Sub
|
|
|
|
' Funzione che dato un segmento e una distanza, scrive il testo centrato alla sua destra
|
|
Friend Shared Sub AddTextToLine(sText As String, TextLayer As Integer, CurrLine As Integer, dDistance As Double, dBBoxRad As Double, bTextExt As Boolean)
|
|
' Calcolo altezza testo
|
|
Dim dH As Double = 0.075 * dBBoxRad
|
|
' Creo testo
|
|
Dim nText As Integer = EgtCreateTextAdv(TextLayer, New Point3d(0, 0, 0), 0, sText, "", 500, False, dH, 1, 0, INS_POS.MC)
|
|
' Calcolo punto in cui posizionare il testo
|
|
' calcolo BBox del testo
|
|
Dim ptMinBBox As Point3d
|
|
Dim ptMaxBBox As Point3d
|
|
EgtGetBBox(nText, GDB_BB.STANDARD, ptMinBBox, ptMaxBBox)
|
|
' calcolo centro del BBox
|
|
Dim ptMidBBox As Point3d
|
|
ptMidBBox = Point3d.Media(ptMinBBox, ptMaxBBox)
|
|
' calcolo vettore della CurrLine
|
|
Dim ptLineStart As Point3d
|
|
EgtStartPoint(CurrLine, nText, ptLineStart)
|
|
Dim ptLineEnd As Point3d
|
|
EgtEndPoint(CurrLine, nText, ptLineEnd)
|
|
Dim vtCurrLine As Vector3d = ptLineEnd - ptLineStart
|
|
' lo normalizzo per ottenerne il versore
|
|
vtCurrLine.Normalize()
|
|
' calcolo vettore dal centro del BBox all'estremo più vicino se testo esterno alla figura
|
|
Dim vtptExtptMC As Vector3d
|
|
If bTextExt Then
|
|
If vtCurrLine.x > 0 Then
|
|
If vtCurrLine.y > 0 Then
|
|
vtptExtptMC = ptMidBBox - New Point3d(ptMinBBox.x, ptMaxBBox.y, 0)
|
|
Else
|
|
vtptExtptMC = ptMidBBox - ptMaxBBox
|
|
End If
|
|
Else
|
|
If vtCurrLine.y > 0 Then
|
|
vtptExtptMC = ptMidBBox - ptMinBBox
|
|
Else
|
|
vtptExtptMC = ptMidBBox - New Point3d(ptMaxBBox.x, ptMinBBox.y, 0)
|
|
End If
|
|
End If
|
|
Else
|
|
If vtCurrLine.x > 0 Then
|
|
If vtCurrLine.y > 0 Then
|
|
vtptExtptMC = ptMidBBox - New Point3d(ptMaxBBox.x, ptMinBBox.y, 0)
|
|
Else
|
|
vtptExtptMC = ptMidBBox - ptMinBBox
|
|
End If
|
|
Else
|
|
If vtCurrLine.y > 0 Then
|
|
vtptExtptMC = ptMidBBox - ptMaxBBox
|
|
Else
|
|
vtptExtptMC = ptMidBBox - New Point3d(ptMinBBox.x, ptMaxBBox.y, 0)
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
' ruoto il vettore della CurrLine per ottenerne il perpendicolare
|
|
If bTextExt Then
|
|
vtCurrLine.Rotate(Vector3d.Z_AX, -90)
|
|
Else
|
|
vtCurrLine.Rotate(Vector3d.Z_AX, 90)
|
|
End If
|
|
' Calcolo il centro del testo
|
|
Dim ptTextMC As Point3d = Point3d.Media(ptLineStart, ptLineEnd) + vtCurrLine * (dDistance + (vtCurrLine * vtptExtptMC))
|
|
EgtMove(nText, (ptTextMC - Point3d.ORIG))
|
|
End Sub
|
|
|
|
Private Sub SideAng_Click(sender As Object, e As RoutedEventArgs) Handles A1.Click, A2.Click, A3.Click, A4.Click, A5.Click, A6.Click, A7.Click, A8.Click, A9.Click, A10.Click
|
|
Dim CurrCheckBox As CheckBox = e.Source
|
|
' Nuovo angolo di inclinazione
|
|
Dim dSideAngle As Double
|
|
' Se checked lo imposto al valore letto dalla TxBx
|
|
If CurrCheckBox.IsChecked() Then
|
|
StringToDouble(SideAngleTxBx.Text, dSideAngle)
|
|
Else
|
|
' altrimenti lo imposto a zero
|
|
dSideAngle = 0
|
|
End If
|
|
'Converto nome checkbox in nome elemento tenendo conto dello slittamento verso il basso
|
|
Dim nCurrSide As Integer = m_SideAngleEntityList.Count() - (10 - CInt(CurrCheckBox.Name.Substring(1)))
|
|
Dim sCurrSide As String = "A" & nCurrSide.ToString()
|
|
' Lo modifico nella geometria e nella lista inclinazioni
|
|
ModifySideAngle(sCurrSide, dSideAngle)
|
|
'Aggiorno tutti i testi
|
|
RefreshSideAngleText()
|
|
End Sub
|
|
|
|
' Funzione che modifica l'inclinazione di un lato
|
|
Friend Function ModifySideAngle(sEntityName As String, dSideAngle As Double) As Boolean
|
|
' Ricavo CurrEntity dal nome
|
|
Dim CurrEntity As SideAngleEntity = SideAngleEntity.FindEntity(sEntityName)
|
|
If IsNothing(CurrEntity) Then
|
|
EgtOutLog("Error in side angle definition: selected line not found in SideAngleList")
|
|
Return False
|
|
End If
|
|
' Scrivo nuovo angolo nelle info
|
|
If dSideAngle <> 0 Then
|
|
EgtSetInfo(CurrEntity.nGeomId, INFO_SIDE_ANGLE, dSideAngle)
|
|
Else
|
|
' Cancello inclinazione nell'apposito campo info
|
|
EgtRemoveInfo(CurrEntity.nGeomId, INFO_SIDE_ANGLE)
|
|
End If
|
|
' Aggiorno lista entità con nuova inclinazione
|
|
CurrEntity.dSideAngle = dSideAngle
|
|
Return True
|
|
End Function
|
|
|
|
Friend Sub DeleteSideAngle()
|
|
' Cancello lista lati inclinati
|
|
m_SideAngleEntityList.Clear()
|
|
' Annullo tutti i CheckBox
|
|
A1.IsChecked = False
|
|
A2.IsChecked = False
|
|
A3.IsChecked = False
|
|
A4.IsChecked = False
|
|
A5.IsChecked = False
|
|
A6.IsChecked = False
|
|
A7.IsChecked = False
|
|
A8.IsChecked = False
|
|
A9.IsChecked = False
|
|
A10.IsChecked = False
|
|
|
|
End Sub
|
|
|
|
Private Sub SideAngleTxBx_EgtClosed(sender As Object, e As EventArgs) Handles SideAngleTxBx.EgtClosed
|
|
' ciclo sui checkbox calcolati sul numero di lati inclinabili presenti
|
|
For Index As Integer = 10 - m_SideAngleEntityList.Count + 1 To 10
|
|
' Nuovo angolo di inclinazione
|
|
Dim dSideAngle As Double
|
|
' Se checked lo imposto al valore letto dalla TxBx
|
|
If GetChBxFromIndex(Index).IsChecked() Then
|
|
StringToDouble(SideAngleTxBx.Text, dSideAngle)
|
|
Else
|
|
' altrimenti lo imposto a zero
|
|
dSideAngle = 0
|
|
End If
|
|
'Converto nome checkbox in nome elemento tenendo conto dello slittamento verso il basso
|
|
Dim nCurrSide As Integer = m_SideAngleEntityList.Count() - (10 - CInt(GetChBxFromIndex(Index).Name.Substring(1)))
|
|
Dim sCurrSide As String = "A" & nCurrSide.ToString()
|
|
' Lo modifico nella geometria e nella lista inclinazioni
|
|
ModifySideAngle(sCurrSide, dSideAngle)
|
|
'Aggiorno tutti i testi
|
|
RefreshSideAngleText()
|
|
Next
|
|
|
|
End Sub
|
|
|
|
Friend Sub WriteSideAngleForNest(nCtx As Integer)
|
|
' Imposto contesto corrente
|
|
EgtSetCurrentContext(nCtx)
|
|
Dim CurrPart As Integer
|
|
CurrPart = EgtGetFirstInGroup(GDB_ID.ROOT)
|
|
While CurrPart <> GDB_ID.NULL
|
|
' Ricavo nome layer con geometria esterna pezzo
|
|
Dim OutLoop As Integer = EgtGetFirstNameInGroup(CurrPart, NAME_OUTLOOP)
|
|
' Calcolo dimensione ingombro OutLoop
|
|
Dim ptMin, ptMax As Point3d
|
|
EgtGetBBoxGlob(OutLoop, GDB_BB.STANDARD, ptMin, ptMax)
|
|
Dim dBBoxRad As Double = 0.5 * Point3d.DistXY(ptMin, ptMax)
|
|
' Creo layer per testi nesting
|
|
Dim TextLayer As Integer = EgtCreateGroup(CurrPart)
|
|
EgtSetName(TextLayer, SIDE_ANGLE_LAYER)
|
|
' Ciclo che verifica se possibile inclinare la linea corrente fino alla penultima
|
|
Dim CurrLine As Integer = EgtGetFirstInGroup(OutLoop)
|
|
While CurrLine <> GDB_ID.NULL
|
|
Dim dSideAngle As Double = 0
|
|
EgtGetInfo(CurrLine, INFO_SIDE_ANGLE, dSideAngle)
|
|
If Math.Abs(dSideAngle) > EPS_ANG_SMALL Then
|
|
' Creo testo con angolo di inclinazione
|
|
AddTextToLine(DoubleToString(dSideAngle, 1) & "°", TextLayer, CurrLine, 10, dBBoxRad, False)
|
|
End If
|
|
CurrLine = EgtGetNext(CurrLine)
|
|
End While
|
|
CurrPart = EgtGetNext(CurrPart)
|
|
End While
|
|
End Sub
|
|
|
|
Friend Sub ReLoadSideAnglePage()
|
|
SideAngleUC_Unloaded(Me, New RoutedEventArgs)
|
|
SideAngleUC_Loaded(Me, New RoutedEventArgs)
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Friend Class SideAngleEntity
|
|
|
|
Private Shared m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
|
|
Private m_nGeomId As Integer
|
|
Private m_sEntityName As String
|
|
Private m_nTextId As Integer
|
|
Private m_dSideAngle As Double
|
|
|
|
Public Property nGeomId As Integer
|
|
Get
|
|
Return m_nGeomId
|
|
End Get
|
|
Set(value As Integer)
|
|
m_nGeomId = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property sEntityName As String
|
|
Get
|
|
Return m_sEntityName
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property nTextId As Integer
|
|
Get
|
|
Return m_nTextId
|
|
End Get
|
|
End Property
|
|
|
|
Public Property dSideAngle As Double
|
|
Get
|
|
Return m_dSideAngle
|
|
End Get
|
|
Set(value As Double)
|
|
m_dSideAngle = value
|
|
End Set
|
|
End Property
|
|
|
|
Sub New(nId As Integer, sEntityName As String, nTextId As Integer, dSideAngle As Double)
|
|
m_nGeomId = nId
|
|
m_sEntityName = sEntityName
|
|
m_nTextId = nTextId
|
|
m_dSideAngle = dSideAngle
|
|
End Sub
|
|
|
|
Friend Shared Function FindEntity(sEntityName As String) As SideAngleEntity
|
|
Dim EntityList As List(Of SideAngleEntity) = Nothing
|
|
If m_MainWindow.m_ActivePage = MainWindow.Pages.Draw Then
|
|
EntityList = m_MainWindow.m_DrawPageUC.m_SideAngle.m_SideAngleEntityList
|
|
ElseIf m_MainWindow.m_ActivePage = MainWindow.Pages.Import Then
|
|
EntityList = m_MainWindow.m_ImportPageUC.m_SideAngleUC.m_SideAngleEntityList
|
|
End If
|
|
|
|
If IsNothing(EntityList) Then
|
|
Return Nothing
|
|
End If
|
|
|
|
For Each Entity In EntityList
|
|
If Entity.m_sEntityName = sEntityName Then
|
|
Return Entity
|
|
End If
|
|
Next
|
|
Return Nothing
|
|
End Function
|
|
|
|
End Class |