Files
icarus/Icarus/DispositionPanel/DispositionPanelVM.vb
T
Emmanuele Sassi 0532c0c486 - cambio nome del progetto in Icarus
- gestione ribs completata
- nuove funzionalita' introdotte su tabella TFS
- correzioni e migliorie varie
2022-09-08 17:36:35 +02:00

287 lines
8.8 KiB
VB.net

Imports System.Globalization
Imports EgtUILib
Imports EgtWPFLib5
Public Class DispositionPanelVM
Inherits VMBase
Public Property sXPos As String
Get
If Not IsNothing(Map.refTopPanelVM.SelPart) Then
Dim ptReference As New Point3d
EgtStartPoint(Map.refTopPanelVM.SelPart.nReferenceId, GDB_ID.ROOT, ptReference)
Return LenToString(ptReference.x, 1)
Else
Return ""
End If
End Get
Set(value As String)
Dim ptReference As New Point3d
EgtStartPoint(Map.refTopPanelVM.SelPart.nReferenceId, GDB_ID.ROOT, ptReference)
Dim dNewXPos As Double = ptReference.x
StringToLen(value, dNewXPos)
If dNewXPos >= 0 AndAlso dNewXPos <= CurrentMachine.b3Tab.DimX Then
EgtMove(Map.refTopPanelVM.SelPart.nPartId, New Point3d(dNewXPos, ptReference.y, ptReference.z) - ptReference)
EgtDraw()
Else
NotifyPropertyChanged(NameOf(sXPos))
End If
End Set
End Property
Public Property sYPos As String
Get
If Not IsNothing(Map.refTopPanelVM.SelPart) Then
Dim ptReference As New Point3d
EgtStartPoint(Map.refTopPanelVM.SelPart.nReferenceId, GDB_ID.ROOT, ptReference)
Return LenToString(ptReference.y, 1)
Else
Return ""
End If
End Get
Set(value As String)
Dim ptReference As New Point3d
EgtStartPoint(Map.refTopPanelVM.SelPart.nReferenceId, GDB_ID.ROOT, ptReference)
Dim dNewYPos As Double = ptReference.y
StringToLen(value, dNewYPos)
If dNewYPos >= 0 AndAlso dNewYPos <= CurrentMachine.b3Tab.DimY Then
EgtMove(Map.refTopPanelVM.SelPart.nPartId, New Point3d(ptReference.x, dNewYPos, ptReference.z) - ptReference)
EgtDraw()
Else
NotifyPropertyChanged(NameOf(sYPos))
End If
End Set
End Property
Public Property sZPos As String
Get
If Not IsNothing(Map.refTopPanelVM.SelPart) Then
Dim ptReference As New Point3d
EgtStartPoint(Map.refTopPanelVM.SelPart.nReferenceId, GDB_ID.ROOT, ptReference)
Return LenToString(ptReference.z, 1)
Else
Return ""
End If
End Get
Set(value As String)
Dim ptReference As New Point3d
EgtStartPoint(Map.refTopPanelVM.SelPart.nReferenceId, GDB_ID.ROOT, ptReference)
Dim dNewZPos As Double = ptReference.z
StringToLen(value, dNewZPos)
If dNewZPos >= 0 Then
EgtMove(Map.refTopPanelVM.SelPart.nPartId, New Point3d(ptReference.x, ptReference.y, dNewZPos) - ptReference)
EgtDraw()
Else
NotifyPropertyChanged(NameOf(sZPos))
End If
End Set
End Property
Private m_RotAxes() As Boolean = {False, False, True}
Public Property RotAxes As Boolean()
Get
Return m_RotAxes
End Get
Set(value As Boolean())
m_RotAxes = value
End Set
End Property
Public ReadOnly Property vtSelRotAxes As Vector3d
Get
If m_RotAxes(0) Then
Return Vector3d.X_AX
ElseIf m_RotAxes(1) Then
Return Vector3d.Y_AX
ElseIf m_RotAxes(2) Then
Return Vector3d.Z_AX
End If
End Get
End Property
Private m_sRotAngle As String
Public Property sRotAngle As String
Get
Return m_sRotAngle
End Get
Set(value As String)
Dim dNewAngle As Double = 0
If Not StringToLen(value, dNewAngle) Then
m_sRotAngle = 0
NotifyPropertyChanged(NameOf(sRotAngle))
Return
End If
Dim b3PrintSolid As New BBox3d
EgtGetBBoxGlob(Map.refTopPanelVM.SelPart.nPartId, GDB_BB.STANDARD, b3PrintSolid)
If EgtRotate(Map.refTopPanelVM.SelPart.nPartId, b3PrintSolid.Center, vtSelRotAxes, dNewAngle) Then
EgtDraw()
RefreshPos()
m_sRotAngle = 0
NotifyPropertyChanged(NameOf(sRotAngle))
Else
m_sRotAngle = value
End If
End Set
End Property
Private m_bMove_IsChecked As Boolean
Public Property bMove_IsChecked As Boolean
Get
Return m_bMove_IsChecked
End Get
Set(value As Boolean)
m_bMove_IsChecked = value
If value Then
m_bRotate_IsChecked = False
NotifyPropertyChanged(NameOf(bRotate_IsChecked))
End If
End Set
End Property
Private m_bRotate_IsChecked As Boolean
Public Property bRotate_IsChecked As Boolean
Get
Return m_bRotate_IsChecked
End Get
Set(value As Boolean)
m_bRotate_IsChecked = value
If value Then
m_bMove_IsChecked = False
NotifyPropertyChanged(NameOf(bMove_IsChecked))
End If
End Set
End Property
' riferimento griglia prima della rotazione
Private m_PrevGridOrigin As New Frame3d
Private m_bRotating As Boolean
' Definizione comandi
Private m_cmdDragMove As ICommand
Private m_cmdDragRotate As ICommand
Sub New()
' Creo riferimento a questa classe in EgtCAM5Map
Map.SetRefDispositionPanelVM(Me)
End Sub
Friend Sub Init()
End Sub
Friend Sub RefreshPos()
NotifyPropertyChanged(NameOf(sXPos))
NotifyPropertyChanged(NameOf(sYPos))
NotifyPropertyChanged(NameOf(sZPos))
End Sub
Private Sub InitCommand()
' attivo modifiche su scena
Map.refSceneHostVM.MainScene.ResetStatus()
' seleziono percorso corrente
EgtDeselectAll()
EgtSelectObj(Map.refTopPanelVM.SelPart.nPartId)
End Sub
Friend Sub UpdateUi()
RefreshPos()
If m_bRotating Then
m_bRotating = False
' ripristino griglia
EgtSetGridFrame(m_PrevGridOrigin)
EgtDraw()
End If
End Sub
Friend Sub OnKeyDown(Key As Forms.Keys)
If Key = Forms.Keys.Escape Then
If m_bRotating Then
m_bRotating = False
' ripristino griglia
EgtSetGridFrame(m_PrevGridOrigin)
EgtDraw()
End If
End If
End Sub
#Region "COMMANDS"
#Region "DragMove"
Public ReadOnly Property DragMove_Command As ICommand
Get
If m_cmdDragMove Is Nothing Then
m_cmdDragMove = New Command(AddressOf DragMove)
End If
Return m_cmdDragMove
End Get
End Property
Public Sub DragMove()
InitCommand()
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.MOVE)
End Sub
#End Region ' DragMove
#Region "DragRotate"
Public ReadOnly Property DragRotate_Command As ICommand
Get
If m_cmdDragRotate Is Nothing Then
m_cmdDragRotate = New Command(AddressOf DragRotate)
End If
Return m_cmdDragRotate
End Get
End Property
Public Sub DragRotate()
m_bRotating = True
m_PrevGridOrigin = EgtGetGridFrame()
InitCommand()
If AreSameVectorApprox(vtSelRotAxes, Vector3d.X_AX) Then
Map.refSceneHostVM.MainController.SetLastInteger(Controller.GRID_TYPE.RIGHT)
ElseIf AreSameVectorApprox(vtSelRotAxes, Vector3d.Y_AX) Then
Map.refSceneHostVM.MainController.SetLastInteger(Controller.GRID_TYPE.FRONT)
ElseIf AreSameVectorApprox(vtSelRotAxes, Vector3d.Z_AX) Then
Map.refSceneHostVM.MainController.SetLastInteger(Controller.GRID_TYPE.TOP)
End If
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.GRID)
' recupero il piano di griglia corrente
Dim frCurr As New Frame3d(EgtGetGridFrame())
' ne modifico l'origine per portarla sullo stesso piano del punto( o punto inizio della curva)
Dim StartPoint As Point3d
EgtStartPoint(Map.refTopPanelVM.SelPart.nPartId, StartPoint)
frCurr.Move(StartPoint - frCurr.Orig())
' imposto nuova griglia
EgtSetGridFrame(frCurr)
EgtDraw()
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.ROTATE)
End Sub
#End Region ' DragRotate
#End Region ' COMMANDS
End Class
Public Class CenterToolTipConverter
Implements IMultiValueConverter
Public Function Convert(ByVal values As Object(), ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IMultiValueConverter.Convert
For Each value In values
If TypeOf (value) IsNot Double Then
Return Double.NaN
End If
Next
Dim placementTargetHeight As Double = CDbl(values(0))
Dim toolTipHeight As Double = CDbl(values(1))
Return (placementTargetHeight / 2.0) - (toolTipHeight / 2.0)
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetTypes As Type(), ByVal parameter As Object, ByVal culture As CultureInfo) As Object() Implements IMultiValueConverter.ConvertBack
Throw New NotSupportedException()
End Function
End Class