Files
icarus/3dPrintApp/DispositionPanel/DispositionPanelVM.vb
T
Emmanuele Sassi 185293847f - migliorie varie
- impostazione struttura programma
- esecuzione slicing
- gestione lavorazione e materiali
- importazione migliorata
2022-08-16 09:37:17 +02:00

191 lines
6.0 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
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
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