Files
egtbeamwall/EgtBEAMWALL.ViewerOptimizer/FreeContourManager/FreeContourManagerVM.vb
T
2022-07-07 19:08:50 +02:00

995 lines
34 KiB
VB.net

Imports EgtUILib
Imports EgtWPFLib5
Imports EgtBEAMWALL.Core
Public Class FreeContourManagerVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Public Enum FreeContourTypes As Integer
ONE = 0
ONEWITHANGLES = 1
TWO = 2
End Enum
Public Enum Paths As Integer
FIRST = 0
SECOND = 1
End Enum
Private m_bPrevShowSolid As Boolean
Private m_bIsActive As Boolean = False
Public ReadOnly Property bIsActive As Boolean
Get
Return m_bIsActive
End Get
End Property
Private m_nSelTextId As Integer = GDB_ID.NULL
' parametro che indica se e' in corso l'editing di un angolo
Private m_bIsModifyingTextAngle As Boolean = False
Public ReadOnly Property bIsModifyingTextAngle As Boolean
Get
Return m_bIsModifyingTextAngle
End Get
End Property
' parametro che indica se e' in corso il disegno di un percorso
Private m_bIsCreatingPath As Boolean = False
Public ReadOnly Property bIsCreatingPath As Boolean
Get
Return m_bIsCreatingPath
End Get
End Property
Private m_TypeList As New List(Of String)({"Un percorso", "Un percorso con angoli", "Due percorsi"})
Public Property TypeList As List(Of String)
Get
Return m_TypeList
End Get
Set(value As List(Of String))
m_TypeList = value
End Set
End Property
Private m_SelType As Integer
Public Property SelType As Integer
Get
Return m_SelType
End Get
Set(value As Integer)
' se precedentemente impostato 2 percorsi
Select Case m_SelType
Case FreeContourTypes.ONEWITHANGLES
' elimino layer testi angoli e layer copia
EgtErase(nSideAngTextLayer)
EgtErase(m_nNewPathCopyForSideAngleId)
nSideAngTextLayer = GDB_ID.NULL
m_TextAngle_Visibility = Visibility.Collapsed
NotifyPropertyChanged(NameOf(TextAngle_Visibility))
Case FreeContourTypes.TWO
' chiedo conferma
If MessageBox.Show(EgtMsg(61862), "", MessageBoxButton.YesNo, MessageBoxImage.Warning) <> MessageBoxResult.Yes Then
m_SelType = FreeContourTypes.TWO
NotifyPropertyChanged(NameOf(SelType))
Return
Else
' elimino secondo percorso
EgtErase(m_nNewSecondPathId)
m_PathList_Visibility = Visibility.Collapsed
NotifyPropertyChanged(NameOf(PathList_Visibility))
End If
End Select
m_SelType = value
' se nuova impostazione e' uno con angoli
Select Case m_SelType
Case FreeContourTypes.ONEWITHANGLES
' creo testi angoli sul percorso
CreateSideAngText("")
m_TextAngle_Visibility = Visibility.Visible
Case FreeContourTypes.TWO
m_PathList_Visibility = Visibility.Visible
NotifyPropertyChanged(NameOf(PathList_Visibility))
SelPath = Paths.FIRST
NotifyPropertyChanged(NameOf(SelPath))
End Select
NotifyPropertyChanged(NameOf(TextAngle_Visibility))
EgtDraw()
End Set
End Property
Private m_PathList As New List(Of String)({"1° Percorso", "2° Percorso"})
Public Property PathList As List(Of String)
Get
Return m_PathList
End Get
Set(value As List(Of String))
m_PathList = value
End Set
End Property
Private m_SelPath As Paths
Public Property SelPath As Integer
Get
Return m_SelPath
End Get
Set(value As Integer)
m_SelPath = value
Select Case m_SelPath
Case Paths.FIRST
EgtDeselectAll()
EgtResetMark(m_nNewSecondPathId)
If m_nNewPathId = GDB_ID.NULL OrElse EgtGetType(m_nNewPathId) = GDB_TY.NONE Then
m_Line2P_IsEnabled = True
NotifyPropertyChanged(NameOf(Line2P_IsEnabled))
Else
EgtSetMark(m_nNewPathId)
If m_Line2P_IsEnabled Then
m_Line2P_IsEnabled = False
NotifyPropertyChanged(NameOf(Line2P_IsEnabled))
End If
End If
Case Paths.SECOND
EgtDeselectAll()
EgtResetMark(m_nNewPathId)
If m_nNewSecondPathId = GDB_ID.NULL OrElse EgtGetType(m_nNewSecondPathId) = GDB_TY.NONE Then
m_Line2P_IsEnabled = True
NotifyPropertyChanged(NameOf(Line2P_IsEnabled))
Else
EgtSetMark(m_nNewSecondPathId)
If m_Line2P_IsEnabled Then
m_Line2P_IsEnabled = False
NotifyPropertyChanged(NameOf(Line2P_IsEnabled))
End If
End If
End Select
EgtDraw()
End Set
End Property
Private m_Line2P_IsEnabled As Boolean = False
Public Property Line2P_IsEnabled As Boolean
Get
Return m_Line2P_IsEnabled
End Get
Set(value As Boolean)
m_Line2P_IsEnabled = value
End Set
End Property
Private m_TextAngle_Visibility As Visibility = Visibility.Collapsed
Public Property TextAngle_Visibility As Visibility
Get
Return m_TextAngle_Visibility
End Get
Set(value As Visibility)
m_TextAngle_Visibility = value
End Set
End Property
Private m_PathList_Visibility As Visibility = Visibility.Collapsed
Public Property PathList_Visibility As Visibility
Get
Return m_PathList_Visibility
End Get
Set(value As Visibility)
m_PathList_Visibility = value
End Set
End Property
Friend SelPart As BTLPartVM
Friend SelFeature As BTLFeatureVM
Friend nSelPartId As Integer
Friend nSelFeatureId As Integer
Friend nProcessingLayerId As Integer
Friend nAuxId As Integer = 0
Friend nSecondAuxId As Integer = 0
Friend nOrigPathId As Integer = GDB_ID.NULL
Friend m_nNewPathId As Integer = GDB_ID.NULL
Friend m_nNewPathCopyForSideAngleId As Integer = GDB_ID.NULL
Friend nOrigSecondPathId As Integer = GDB_ID.NULL
Friend m_nNewSecondPathId As Integer = GDB_ID.NULL
Friend nSideAngTextLayer As Integer = GDB_ID.NULL
Friend SideAngValues As New List(Of SideAngle)
' Definizione comandi
Private m_cmdLine2P As ICommand
Private m_cmdDelete As ICommand
Private m_cmdModifyCurve As ICommand
Private m_cmdAddPointCurve As ICommand
Private m_cmdArcflip As ICommand
Private m_cmdMove As ICommand
Private m_cmdRotate As ICommand
Private m_cmdMirror As ICommand
Private m_cmdScale As ICommand
Private m_cmdRemovePointCurve As ICommand
Private m_cmdChangeStart As ICommand
Private m_cmdInvertCurve As ICommand
Private m_cmdTextAngle As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTORS"
Sub New()
' imposto riferimento in Map
Map.SetRefFreeContourManagerVM(Me)
End Sub
#End Region ' CONSTRUCTORS
#Region "METHODS"
Friend Sub Open()
m_bIsActive = True
'resetto tutte le variabili
SelPart = Nothing
SelFeature = Nothing
nSelPartId = GDB_ID.NULL
nSelFeatureId = GDB_ID.NULL
nProcessingLayerId = GDB_ID.NULL
nAuxId = 0
nSecondAuxId = 0
nOrigPathId = GDB_ID.NULL
m_nNewPathId = GDB_ID.NULL
m_nNewPathCopyForSideAngleId = GDB_ID.NULL
nOrigSecondPathId = GDB_ID.NULL
m_nNewSecondPathId = GDB_ID.NULL
nSideAngTextLayer = GDB_ID.NULL
SideAngValues.Clear()
' nascondo PartManager
Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility))
' verifico se solido attivo
m_bPrevShowSolid = Map.refShowBeamPanelVM.ShowSolid_IsChecked
If m_bPrevShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(False)
' attivo visualizzazione direzione curve
EgtSetShowCurveDirection(True)
' elimino eventuale vecchio layer testi
EgtErase(nSideAngTextLayer)
nSideAngTextLayer = GDB_ID.NULL
' imposto Part/Feature/Layer Processing ...
SelPart = Map.refProjectVM.BTLStructureVM.SelBTLPart
SelFeature = Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM
nSelPartId = Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId
nSelFeatureId = Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.nFeatureId
nProcessingLayerId = EgtGetFirstNameInGroup(nSelPartId, PROCESSINGS)
Dim sAuxId As String = ""
If EgtGetInfo(nSelFeatureId, "AUXID", sAuxId) Then
' verifico se ha uno o due percorsi
Dim sAuxIdSplit() As String = sAuxId.Split(","c)
If Integer.TryParse(sAuxIdSplit(0), nAuxId) Then
nOrigPathId = nSelFeatureId + nAuxId
' faccio copia del percorso feature
m_nNewPathId = EgtCopyGlob(nOrigPathId, nSelFeatureId, GDB_POS.AFTER)
EgtModifyCurveThickness(m_nNewPathId, 0)
' verifico se c'e' info angoli
Dim sSideAng As String = ""
If EgtGetInfo(nOrigPathId, "SideAngs", sSideAng) Then
' creo testi angoli sul percorso
CreateSideAngText(sSideAng)
' imposto modalita' con angoli
m_SelType = FreeContourTypes.ONEWITHANGLES
Else
' imposto modalita' un percorso
m_SelType = FreeContourTypes.ONE
End If
End If
If sAuxIdSplit.Count > 1 AndAlso Not String.IsNullOrWhiteSpace(sAuxIdSplit(1)) Then
If Integer.TryParse(sAuxIdSplit(1), nSecondAuxId) Then
nOrigSecondPathId = nSelFeatureId + nSecondAuxId
' faccio copia del percorso feature
m_nNewSecondPathId = EgtCopyGlob(nOrigSecondPathId, nSelFeatureId, GDB_POS.AFTER)
EgtModifyCurveThickness(m_nNewSecondPathId, 0)
' imposto modalita' due percorsi
m_SelType = FreeContourTypes.TWO
End If
End If
' se nuova senza percorsi
Else
' imposto modalita' un percorso
m_SelType = FreeContourTypes.ONE
End If
NotifyPropertyChanged(NameOf(SelType))
' imposto filtro selezione solo su curve
Map.refSceneHostVM.MainScene.SetObjFilterForSel(False, True, False, False, False)
' imposto layer corrente per disegno
EgtSetCurrPartLayer(nSelPartId, nProcessingLayerId)
' nascondo tutte le feature
Dim nTempFeatureId As Integer = EgtGetFirstInGroup(nProcessingLayerId)
While nTempFeatureId <> GDB_ID.NULL
EgtSetMode(nTempFeatureId, GDB_MD.HIDDEN)
nTempFeatureId = EgtGetNext(nTempFeatureId)
End While
' nascondo tutti gli outline
Dim nOutlineLayerId As Integer = EgtGetFirstNameInGroup(nSelPartId, OUTLINE)
Dim nTempOutlineId As Integer = EgtGetFirstInGroup(nOutlineLayerId)
While nTempOutlineId <> GDB_ID.NULL
EgtSetMode(nTempOutlineId, GDB_MD.HIDDEN)
nTempOutlineId = EgtGetNext(nTempOutlineId)
End While
' deseleziono tutto
EgtDeselectAll()
' rendo visibile solo percorso feature
EgtSetMode(m_nNewPathId, GDB_MD.STD)
If m_SelType = FreeContourTypes.TWO Then
EgtSetMode(m_nNewSecondPathId, GDB_MD.STD)
End If
' verifico se modalita' uno o due percorsi
Select Case m_SelType
Case FreeContourTypes.ONE
' se c'e' gia' un percorso disattivo la possibilita' di aggiungerne
m_Line2P_IsEnabled = (m_nNewPathId = GDB_ID.NULL)
m_TextAngle_Visibility = Visibility.Collapsed
m_PathList_Visibility = Visibility.Collapsed
Case FreeContourTypes.ONEWITHANGLES
' se c'e' gia' un percorso disattivo la possibilita' di aggiungerne
m_Line2P_IsEnabled = (m_nNewPathId = GDB_ID.NULL)
m_TextAngle_Visibility = Visibility.Visible
m_PathList_Visibility = Visibility.Collapsed
Case FreeContourTypes.TWO
' se ci sono gia' due percorsi
' disattivo la possibilita' di aggiungerne
m_Line2P_IsEnabled = (m_nNewPathId = GDB_ID.NULL OrElse m_nNewSecondPathId = GDB_ID.NULL)
m_TextAngle_Visibility = Visibility.Collapsed
m_PathList_Visibility = Visibility.Visible
' seleziono primo percorso
SelPath = Paths.FIRST
NotifyPropertyChanged(NameOf(SelPath))
End Select
NotifyPropertyChanged(NameOf(Line2P_IsEnabled))
NotifyPropertyChanged(NameOf(TextAngle_Visibility))
NotifyPropertyChanged(NameOf(PathList_Visibility))
' posiziono la griglia sulla faccia attiva
Dim frFace As New Frame3d
EgtBeamGetSideData(SelFeature.nSelSIDE, frFace)
EgtSetGridFrame(frFace)
Dim dLen As Double = 0
Dim dAngVertDeg As Double = 0
Dim dAngOrizzDeg As Double = 0
frFace.VersZ.ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg)
If AreSameVectorApprox(frFace.VersZ, Vector3d.Z_AX) OrElse AreSameVectorApprox(frFace.VersZ, -Vector3d.Z_AX) Then
EgtSetGenericView(dAngVertDeg, dAngOrizzDeg + 90)
ElseIf AreSameVectorApprox(frFace.VersZ, Vector3d.Y_AX) Then
EgtSetGenericView(dAngVertDeg, dAngOrizzDeg)
ElseIf AreSameVectorApprox(frFace.VersZ, -Vector3d.Y_AX) Then
EgtSetGenericView(dAngVertDeg + 180, dAngOrizzDeg)
End If
EgtSetGridShow(True, True)
' rimetto la selezione scena a null
Map.refSceneHostVM.MainScene.SetStatusNull()
' attivo bottoni save e cancel
SelFeature.RefreshFCMBtnVisibility()
' nascondo Part Manager
Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility))
' attivo pannello
Map.refProjectVM.SetFreeContourManager_Visibility(True)
EgtDraw()
End Sub
Friend Sub Close(bSave As Boolean)
If m_bIsActive Then
m_bIsActive = False
Else
Return
End If
' gestisco salvataggio
If bSave Then
Select Case m_SelType
Case FreeContourManagerVM.FreeContourTypes.ONE
EgtSetInfo(m_nNewPathId, "SideAngs", "")
' ricalcolo auxid
EgtSetInfo(nSelFeatureId, "AUXID", (m_nNewPathId - nSelFeatureId).ToString("+#;-#;0"))
Case FreeContourManagerVM.FreeContourTypes.ONEWITHANGLES
SideAngValues = SideAngValues.OrderBy(Function(x) x.nIndex).ToList()
Dim sSideAngInfo As String = ""
For Index = 0 To SideAngValues.Count - 1
If Index > 0 Then sSideAngInfo &= ","
sSideAngInfo &= SideAngValues(Index).dValue
Next
EgtSetInfo(m_nNewPathId, "SideAngs", sSideAngInfo)
EgtSetInfo(nSelFeatureId, "AUXID", (m_nNewPathId - nSelFeatureId).ToString("+#;-#;0"))
Case FreeContourManagerVM.FreeContourTypes.TWO
' ricalcolo auxid
EgtSetInfo(nSelFeatureId, "AUXID", (m_nNewPathId - nSelFeatureId).ToString("+#;-#;0") & "," & (m_nNewSecondPathId - nSelFeatureId).ToString("+#;-#;0"))
End Select
' aggiorno la feature con nuovo valore
Dim vPar() As Double = Nothing
Dim sPar As String = String.Empty
Dim vParQ() As String = Nothing
Dim BTLFeatureM As BTLFeatureM = SelFeature.BTLFeatureM
BTLFeatureM.CalcParamArray(vPar, sPar, vParQ)
Dim bOK As Boolean = BTLFeatureM.UpdateParams(BTLFeatureM.nSelGRP, BTLFeatureM.nPRC, BTLFeatureM.nSelSIDE, BTLFeatureM.sDES, BTLFeatureM.nPRID,
BTLFeatureM.frFRAME, vPar, sPar, vParQ)
If bOK Then
SelFeature.SelGeomFeature()
' rendo non calcolata questa feature
SelFeature.ResetCalcFeature()
SelPart.CalcGlobalUpdate(True)
' cancello vecchi percorsi
EgtErase(nOrigPathId)
If nOrigSecondPathId <> GDB_ID.NULL Then
EgtErase(nOrigSecondPathId)
End If
End If
Else
' elimino nuovo percorso
EgtErase(m_nNewPathId)
If m_nNewSecondPathId <> GDB_ID.NULL Then
EgtErase(m_nNewSecondPathId)
End If
End If
' se con angoli elimino percorso copia
If SelType = FreeContourTypes.ONEWITHANGLES Then
EgtErase(m_nNewPathCopyForSideAngleId)
End If
' se non e' a due percorsi ma e' rimasto il secondo originale, lo cancello
If SelType <> FreeContourTypes.TWO AndAlso nOrigSecondPathId <> GDB_ID.NULL Then
EgtErase(nOrigSecondPathId)
End If
' mostro tutte le altre feature
Dim nTempFeatureId As Integer = EgtGetFirstInGroup(nProcessingLayerId)
While nTempFeatureId <> GDB_ID.NULL
'If nTempFeatureId <> nSelFeatureId Then
EgtSetMode(nTempFeatureId, GDB_MD.STD)
'End If
nTempFeatureId = EgtGetNext(nTempFeatureId)
End While
' mostro outline
Dim nOutlineLayerId As Integer = EgtGetFirstNameInGroup(nSelPartId, OUTLINE)
Dim nTempOutlineId As Integer = EgtGetFirstInGroup(nOutlineLayerId)
While nTempOutlineId <> GDB_ID.NULL
EgtSetMode(nTempOutlineId, GDB_MD.STD)
nTempOutlineId = EgtGetNext(nTempOutlineId)
End While
' elimino eventuale layer dei testi angoli
EgtErase(nSideAngTextLayer)
nSideAngTextLayer = GDB_ID.NULL
' nascondo la griglia
EgtSetGridShow(False, False)
' disattivo pannello
Map.refProjectVM.SetFreeContourManager_Visibility(False)
' imposto filtro selezione solo su curve
Map.refSceneHostVM.MainScene.SetObjFilterForSel(False, True, False, False, False)
' attivo bottone edit
SelFeature.RefreshFCMBtnVisibility()
' resetto tutte le variabili correnti
SelPart = Nothing
SelFeature = Nothing
nSelPartId = GDB_ID.NULL
nSelFeatureId = GDB_ID.NULL
nProcessingLayerId = GDB_ID.NULL
' riattivo Part Manager
Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility))
' disattivo modifiche su scena
Map.refSceneHostVM.MainScene.SetStatusNull()
If m_bPrevShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(False)
' disattivo visualizzazione direzione curve
EgtSetShowCurveDirection(False)
' rimetto PartManager
Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility))
End Sub
' funzione lanciata su fine creazione percorso
Friend Sub CreatingPathEnd()
m_bIsCreatingPath = False
Dim nNewPathId As Integer = EgtGetLastInGroup(nProcessingLayerId)
If nNewPathId <> GDB_ID.NULL Then
If SelType = FreeContourTypes.TWO Then
Select Case m_SelPath
Case Paths.FIRST
m_nNewPathId = nNewPathId
Case Paths.SECOND
m_nNewSecondPathId = nNewPathId
End Select
Else
m_nNewPathId = nNewPathId
End If
m_Line2P_IsEnabled = False
NotifyPropertyChanged(NameOf(Line2P_IsEnabled))
End If
End Sub
Friend Sub UpdateUi()
' se operazione in piu' passaggi, esco
If Map.refSceneHostVM.MainController.GetContinue() Then Return
' se non ci sono piu' i percorsi, permetto di aggiungerli
If EgtGetType(m_nNewPathId) = GDB_TY.NONE Then
m_nNewPathId = GDB_ID.NULL
m_Line2P_IsEnabled = True
NotifyPropertyChanged(NameOf(Line2P_IsEnabled))
End If
If m_SelType = FreeContourTypes.TWO AndAlso m_SelPath = Paths.SECOND AndAlso EgtGetType(m_nNewSecondPathId) = GDB_TY.NONE Then
m_nNewSecondPathId = GDB_ID.NULL
m_Line2P_IsEnabled = True
NotifyPropertyChanged(NameOf(Line2P_IsEnabled))
End If
' se modalita' angoli
If m_SelType = FreeContourTypes.ONEWITHANGLES Then
UpdateSideAngText()
End If
' rimetto la selezione scena a null
Map.refSceneHostVM.MainScene.SetStatusNull()
End Sub
Private Sub CreateSideAngText(SideAng As String)
SideAngValues.Clear()
' faccio copia per modifiche future
m_nNewPathCopyForSideAngleId = EgtCopyGlob(m_nNewPathId, nSelFeatureId)
' creo testi angoli sul percorso
If nSideAngTextLayer = GDB_ID.NULL Then
nSideAngTextLayer = EgtCreateGroup(nSelPartId)
End If
Dim sSideAngSplit() As String = SideAng.Split(","c)
Dim nSideFirst As Integer
Dim nSideLast As Integer
EgtCurveDomain(m_nNewPathId, nSideFirst, nSideLast)
Dim nSideCnt As Integer = nSideLast - nSideFirst
For Index = 0 To nSideCnt - 1
' riporto angoli nel disegno
Dim ptText As Point3d
EgtAtParamPoint(m_nNewPathId, Index + 0.5, ptText)
Dim nSideAng As Double = 0
If sSideAngSplit.Count - 1 >= Index Then
StringToDouble(sSideAngSplit(Index), nSideAng)
End If
Dim TextId As Integer = EgtCreateText(nSideAngTextLayer, ptText, nSideAng & "°", 20)
SideAngValues.Add(New SideAngle(TextId, Index, nSideAng))
Next
End Sub
Private Sub UpdateSideAngText()
Dim NewSideAngValues As New List(Of SideAngle)
Dim nSideFirst As Integer
Dim nSideLast As Integer
EgtCurveDomain(nOrigPathId, nSideFirst, nSideLast)
Dim nSideCnt As Integer = nSideLast - nSideFirst
If SideAngValues.Count() <> nSideCnt Then
Dim NewAngleList As New List(Of Point3d)
Dim OldAngleList As New List(Of Point3d)
' leggo punti nuovi
For Index = 0 To nSideCnt - 1
Dim ptNew As Point3d
EgtAtParamPoint(m_nNewPathId, Index + 0.5, ptNew)
NewAngleList.Add(ptNew)
Next
' leggo punti vecchi
For Index = 0 To SideAngValues.Count() - 1
Dim ptOld As Point3d
EgtAtParamPoint(m_nNewPathId, Index + 0.5, ptOld)
OldAngleList.Add(ptOld)
Next
' confronto
Dim nNewIndex As Integer = 0
Dim nOldIndex As Integer = 0
For Index = 0 To Math.Max(SideAngValues.Count(), nSideCnt) - 1
If AreSamePointApprox(NewAngleList(Index), OldAngleList(Index)) Then
NewSideAngValues.Add(New SideAngle(SideAngValues(Index).nId, SideAngValues.Count, SideAngValues(Index).dValue))
ElseIf AreSamePointApprox(NewAngleList(Index + 1), OldAngleList(Index)) Then
' punto aggiunto, quindi lo aggiungo e incremento indice di confronto per riallineare successivo
NewSideAngValues.Add(New SideAngle(SideAngValues(Index).nId, SideAngValues.Count, 0))
nNewIndex += 1
ElseIf AreSamePointApprox(NewAngleList(Index), OldAngleList(Index + 1)) Then
' punto tolto, quindi non aggiungo nulla, ma cancello testo
EgtErase(SideAngValues(Index).nId)
nNewIndex -= 1
End If
nNewIndex += 1
nOldIndex += 1
Next
End If
End Sub
Friend Sub CloseIsModifyingTextAngle(bResult As Boolean)
If bResult Then
' scrivo info con nuova inclinazione
Dim dAng As Double
StringToDouble(Map.refFreeContourInputVM.Text, dAng)
EgtSetInfo(m_nSelTextId, "SideAng", dAng)
EgtModifyText(m_nSelTextId, dAng & "°")
Dim SideAngValue As SideAngle = SideAngValues.First(Function(x) x.nId = m_nSelTextId)
SideAngValue.dValue = dAng
End If
m_nSelTextId = GDB_ID.NULL
Map.refSceneHostVM.MainScene.SetObjFilterForSel(False, True, False, False, False)
Map.refFreeContourInputVM.ResetInputBox()
EgtDraw()
m_bIsModifyingTextAngle = False
End Sub
Friend Sub TextAngleSelected(nId As Integer)
m_nSelTextId = nId
' mostro campo da editare
Map.refFreeContourInputVM.PrepareInputBox("Inclinazione lato", "Indicare inclinazione lato selezionato", "", False, False)
Dim dSideAng As Double = 0
EgtGetInfo(nId, "SideAng", dSideAng)
Map.refFreeContourInputVM.SetInputBoxText(dSideAng)
End Sub
Private Sub InitCommand()
' attivo modifiche su scena
Map.refSceneHostVM.MainScene.ResetStatus()
' seleziono percorso corrente
EgtDeselectAll()
EgtSelectObj(If(SelType = FreeContourTypes.TWO AndAlso m_SelPath = Paths.SECOND, m_nNewSecondPathId, m_nNewPathId))
End Sub
#End Region ' METHODS
#Region "COMMANDS"
#Region "Line2P"
''' <summary>
''' Returns a command that do Line2P.
''' </summary>
Public ReadOnly Property Line2P_Command As ICommand
Get
If m_cmdLine2P Is Nothing Then
m_cmdLine2P = New Command(AddressOf Line2P)
End If
Return m_cmdLine2P
End Get
End Property
''' <summary>
''' Execute the Line2P. This method is invoked by the Line2PCommand.
''' </summary>
Public Sub Line2P(ByVal param As Object)
InitCommand()
Map.refSceneHostVM.MainController.SetContinue()
If Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.LINE2P) Then
m_bIsCreatingPath = True
End If
End Sub
#End Region ' Line2P
#Region "Delete"
''' <summary>
''' Returns a command that do Line2P.
''' </summary>
Public ReadOnly Property Delete_Command As ICommand
Get
If m_cmdDelete Is Nothing Then
m_cmdDelete = New Command(AddressOf Delete)
End If
Return m_cmdDelete
End Get
End Property
''' <summary>
''' Execute the Line2P. This method is invoked by the Line2PCommand.
''' </summary>
Public Sub Delete(ByVal param As Object)
InitCommand()
Map.refSceneHostVM.MainController.SetLastInteger(GDB_ID.SEL)
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.DELETE)
End Sub
#End Region ' Line2P
#Region "ModifyCurve"
''' <summary>
''' Returns a command that do Linear Dimension.
''' </summary>
Public ReadOnly Property ModifyCurve_Command As ICommand
Get
If m_cmdModifyCurve Is Nothing Then
m_cmdModifyCurve = New Command(AddressOf ModifyCurve)
End If
Return m_cmdModifyCurve
End Get
End Property
''' <summary>
''' Execute the LinearDimension. This method is invoked by the LinDimCommand.
''' </summary>
Public Sub ModifyCurve(ByVal param As Object)
InitCommand()
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.MODIFYCURVE)
End Sub
#End Region ' ModifyCurve
#Region "AddPointCurve"
''' <summary>
''' Returns a command that do Linear Dimension.
''' </summary>
Public ReadOnly Property AddPointCurve_Command As ICommand
Get
If m_cmdAddPointCurve Is Nothing Then
m_cmdAddPointCurve = New Command(AddressOf AddPointCurve)
End If
Return m_cmdAddPointCurve
End Get
End Property
''' <summary>
''' Execute the LinearDimension. This method is invoked by the LinDimCommand.
''' </summary>
Public Sub AddPointCurve(ByVal param As Object)
InitCommand()
If (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.CLOSECOMPO)
ElseIf (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.CURVETOARC)
Else
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.ADDPOINTCURVE)
End If
End Sub
#End Region ' AddPointCurve
#Region "RemovePointCurve"
''' <summary>
''' Returns a command that do Linear Dimension.
''' </summary>
Public ReadOnly Property RemovePointCurve_Command As ICommand
Get
If m_cmdRemovePointCurve Is Nothing Then
m_cmdRemovePointCurve = New Command(AddressOf RemovePointCurve)
End If
Return m_cmdRemovePointCurve
End Get
End Property
''' <summary>
''' Execute the LinearDimension. This method is invoked by the LinDimCommand.
''' </summary>
Public Sub RemovePointCurve(ByVal param As Object)
InitCommand()
If (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.OPENCOMPO)
ElseIf (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.CURVETOLINE)
Else
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.REMOVEPOINTCURVE)
End If
End Sub
#End Region ' RemovePointCurve
#Region "ArcFlip"
''' <summary>
''' Returns a command that do Arc Flip.
''' </summary>
Public ReadOnly Property ArcFlip_Command As ICommand
Get
If m_cmdArcflip Is Nothing Then
m_cmdArcflip = New Command(AddressOf ArcFlip)
End If
Return m_cmdArcflip
End Get
End Property
''' <summary>
''' Execute the ArcFlip. This method is invoked by the ArcFlipCommand.
''' </summary>
Public Sub ArcFlip(ByVal param As Object)
InitCommand()
If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.ARCEXPLEMENTARY)
Else
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.ARCFLIP)
End If
End Sub
#End Region ' ArcFlip
#Region "Move"
''' <summary>
''' Returns a command that do Move.
''' </summary>
Public ReadOnly Property Move_Command As ICommand
Get
If m_cmdMove Is Nothing Then
m_cmdMove = New Command(AddressOf Move)
End If
Return m_cmdMove
End Get
End Property
''' <summary>
''' Execute the Move. This method is invoked by the MoveCommand.
''' </summary>
Public Sub Move(ByVal param As Object)
InitCommand()
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.MOVE)
End Sub
#End Region ' Move
#Region "Rotate"
''' <summary>
''' Returns a command that do Rotate.
''' </summary>
Public ReadOnly Property Rotate_Command As ICommand
Get
If m_cmdRotate Is Nothing Then
m_cmdRotate = New Command(AddressOf Rotate)
End If
Return m_cmdRotate
End Get
End Property
''' <summary>
''' Execute the Rotate. This method is invoked by the RotateCommand.
''' </summary>
Public Sub Rotate(ByVal param As Object)
InitCommand()
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.ROTATE)
End Sub
#End Region ' Rotate
#Region "Mirror"
''' <summary>
''' Returns a command that do Mirror.
''' </summary>
Public ReadOnly Property Mirror_Command As ICommand
Get
If m_cmdMirror Is Nothing Then
m_cmdMirror = New Command(AddressOf Mirror)
End If
Return m_cmdMirror
End Get
End Property
''' <summary>
''' Execute the Mirror. This method is invoked by the MirrorCommand.
''' </summary>
Public Sub Mirror(ByVal param As Object)
InitCommand()
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.MIRROR)
End Sub
#End Region ' Mirror
#Region "Scale"
''' <summary>
''' Returns a command that do Scale.
''' </summary>
Public ReadOnly Property Scale_Command As ICommand
Get
If m_cmdScale Is Nothing Then
m_cmdScale = New Command(AddressOf Scale)
End If
Return m_cmdScale
End Get
End Property
''' <summary>
''' Execute the Scale. This method is invoked by the ScaleCommand.
''' </summary>
Public Sub Scale(ByVal param As Object)
InitCommand()
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.SCALE)
End Sub
#End Region ' Scale
#Region "ChangeStart"
''' <summary>
''' Returns a command that do Scale.
''' </summary>
Public ReadOnly Property ChangeStart_Command As ICommand
Get
If m_cmdChangeStart Is Nothing Then
m_cmdChangeStart = New Command(AddressOf ChangeStart)
End If
Return m_cmdChangeStart
End Get
End Property
''' <summary>
''' Execute the Scale. This method is invoked by the ScaleCommand.
''' </summary>
Public Sub ChangeStart(ByVal param As Object)
InitCommand()
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.CHANGESTARTCURVE)
End Sub
#End Region ' ChangeStart
#Region "InvertCurve"
''' <summary>
''' Returns a command that do Scale.
''' </summary>
Public ReadOnly Property InvertCurve_Command As ICommand
Get
If m_cmdInvertCurve Is Nothing Then
m_cmdInvertCurve = New Command(AddressOf InvertCurve)
End If
Return m_cmdInvertCurve
End Get
End Property
''' <summary>
''' Execute the Scale. This method is invoked by the ScaleCommand.
''' </summary>
Public Sub InvertCurve(ByVal param As Object)
InitCommand()
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.INVERTCURVE)
End Sub
#End Region ' InvertCurve
#Region "TextAngle"
''' <summary>
''' Returns a command that do Scale.
''' </summary>
Public ReadOnly Property TextAngle_Command As ICommand
Get
If m_cmdTextAngle Is Nothing Then
m_cmdTextAngle = New Command(AddressOf TextAngle)
End If
Return m_cmdTextAngle
End Get
End Property
''' <summary>
''' Execute the Scale. This method is invoked by the ScaleCommand.
''' </summary>
Public Sub TextAngle(ByVal param As Object)
InitCommand()
' imposto selezione solo testi
Map.refSceneHostVM.MainScene.SetObjFilterForSel(False, False, False, False, True)
m_bIsModifyingTextAngle = True
End Sub
#End Region ' ScaleCommand
#End Region ' COMMANDS
End Class
Public Class SideAngle
' Id geometrico dell'entita' text
Private m_nId As Integer
Public ReadOnly Property nId As Integer
Get
Return m_nId
End Get
End Property
' indice della posizione di questo lato all'interno del percorso
Private m_nIndex As Integer
Public Property nIndex As Integer
Get
Return m_nIndex
End Get
Set(value As Integer)
m_nIndex = value
End Set
End Property
Private m_dValue As Double
Friend Property dValue As Double
Get
Return m_dValue
End Get
Set(value As Double)
m_dValue = value
End Set
End Property
Sub New(Id As Integer, Index As Integer, Value As Double)
m_nId = Id
m_nIndex = Index
m_dValue = Value
End Sub
End Class