402 lines
14 KiB
VB.net
402 lines
14 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)
|
|
Dim b3Print As New BBox3d
|
|
EgtGetBBoxGlob(Map.refTopPanelVM.SelPart.nPrintSolidId, GDB_BB.EXACT, b3Print)
|
|
If EgtGetGroupObjs(Map.refTopPanelVM.SelPart.nRibsLayerId) > 0 Then
|
|
Dim b3Ribs As New BBox3d()
|
|
Dim nRibId As Integer = EgtGetFirstInGroup(Map.refTopPanelVM.SelPart.nRibsLayerId)
|
|
While nRibId <> GDB_ID.NULL
|
|
Dim nRibType As Integer = Machining.MPAR_RIBSTYPE.INTERNAL
|
|
EgtGetInfo(nRibId, MAC_RIBSTYPE, nRibType)
|
|
If nRibType = Machining.MPAR_RIBSTYPE.EXTERNAL OrElse nRibType = Machining.MPAR_RIBSTYPE.UNBOUNDED Then
|
|
Dim b3Rib As New BBox3d
|
|
EgtGetBBoxGlob(nRibId, GDB_BB.EXACT, b3Rib)
|
|
b3Ribs.Add(b3Rib)
|
|
End If
|
|
nRibId = EgtGetNext(nRibId)
|
|
End While
|
|
If b3Ribs.Min.x <> INFINITO Then
|
|
b3Print.Add(b3Ribs)
|
|
End If
|
|
End If
|
|
Dim dMin As Double = 0
|
|
Dim dMax As Double = CurrentMachine.b3Tab.DimX
|
|
If b3Print.Max.x > ptReference.x Then
|
|
dMax -= b3Print.Max.x - ptReference.x
|
|
End If
|
|
If b3Print.Min.x < ptReference.x Then
|
|
dMin += ptReference.x - b3Print.Min.x
|
|
End If
|
|
If dNewXPos >= dMin AndAlso dNewXPos <= dMax Then
|
|
EgtMove(Map.refTopPanelVM.SelPart.nPartId, New Point3d(dNewXPos, ptReference.y, ptReference.z) - ptReference, GDB_RT.GLOB)
|
|
Map.refReferencePanelVM.UpdateFramePosition()
|
|
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)
|
|
Dim b3Print As New BBox3d
|
|
EgtGetBBoxGlob(Map.refTopPanelVM.SelPart.nPrintSolidId, GDB_BB.EXACT, b3Print)
|
|
If EgtGetGroupObjs(Map.refTopPanelVM.SelPart.nRibsLayerId) > 0 Then
|
|
Dim b3Ribs As New BBox3d()
|
|
Dim nRibId As Integer = EgtGetFirstInGroup(Map.refTopPanelVM.SelPart.nRibsLayerId)
|
|
While nRibId <> GDB_ID.NULL
|
|
Dim nRibType As Integer = Machining.MPAR_RIBSTYPE.INTERNAL
|
|
EgtGetInfo(nRibId, MAC_RIBSTYPE, nRibType)
|
|
If nRibType = Machining.MPAR_RIBSTYPE.EXTERNAL OrElse nRibType = Machining.MPAR_RIBSTYPE.UNBOUNDED Then
|
|
Dim b3Rib As New BBox3d
|
|
EgtGetBBoxGlob(nRibId, GDB_BB.EXACT, b3Rib)
|
|
b3Ribs.Add(b3Rib)
|
|
End If
|
|
nRibId = EgtGetNext(nRibId)
|
|
End While
|
|
If b3Ribs.Min.x <> INFINITO Then
|
|
b3Print.Add(b3Ribs)
|
|
End If
|
|
End If
|
|
Dim dMin As Double = 0
|
|
Dim dMax As Double = CurrentMachine.b3Tab.DimY
|
|
If b3Print.Max.y > ptReference.y Then
|
|
dMax -= b3Print.Max.y - ptReference.y
|
|
End If
|
|
If b3Print.Min.y < ptReference.y Then
|
|
dMin += ptReference.y - b3Print.Min.y
|
|
End If
|
|
If dNewYPos >= dMin AndAlso dNewYPos <= dMax Then
|
|
EgtMove(Map.refTopPanelVM.SelPart.nPartId, New Point3d(ptReference.x, dNewYPos, ptReference.z) - ptReference, GDB_RT.GLOB)
|
|
Map.refReferencePanelVM.UpdateFramePosition()
|
|
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, GDB_RT.GLOB)
|
|
Map.refReferencePanelVM.UpdateFramePosition()
|
|
EgtDraw()
|
|
Else
|
|
NotifyPropertyChanged(NameOf(sZPos))
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_RotAxes As Boolean() = { False, False, False}
|
|
Public Property RotX As Boolean
|
|
Get
|
|
Return m_RotAxes(0)
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_RotAxes(0) = value
|
|
End Set
|
|
End Property
|
|
Public Property RotY As Boolean
|
|
Get
|
|
Return m_RotAxes(1)
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_RotAxes(1) = value
|
|
End Set
|
|
End Property
|
|
Public Property RotZ As Boolean
|
|
Get
|
|
Return m_RotAxes(2)
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_RotAxes(2) = 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
|
|
Else
|
|
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 IsNothing( value) OrElse Not StringToLen(value, dNewAngle) Then
|
|
m_sRotAngle = 0
|
|
NotifyPropertyChanged(NameOf(sRotAngle))
|
|
Return
|
|
End If
|
|
Dim vtMovedPart As Vector3d
|
|
if EgtGetInfo(Map.refTopPanelVM.SelPart.nPartId, "MovedPart", vtMovedPart) Then
|
|
Dim nEntId = EgtGetFirstInGroup( Map.refTopPanelVM.SelPart.nPrintSolidLayerId)
|
|
While nEntId <> GDB_ID.NULL
|
|
EgtMove(nEntId, -vtMovedPart, GDB_RT.GLOB)
|
|
nEntId = EgtGetNext( nEntId)
|
|
End While
|
|
EgtRemoveInfo(Map.refTopPanelVM.SelPart.nPartId, "MovedPart")
|
|
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, GDB_RT.GLOB) Then
|
|
m_sRotAngle = 0
|
|
Map.refReferencePanelVM.UpdateFramePosition()
|
|
RefreshPos()
|
|
EgtDraw()
|
|
NotifyPropertyChanged(NameOf(sRotAngle))
|
|
' Imposto flag di ricalcolo slice
|
|
EgtSetInfo(Map.refTopPanelVM.SelPart.nPartId, MAC_TORECALC_SLICE, True)
|
|
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)
|
|
If Map.refSceneHostVM.MainController.GetStep = 0 Then
|
|
m_bMove_IsChecked = value
|
|
If value Then
|
|
m_bRotate_IsChecked = False
|
|
NotifyPropertyChanged(NameOf(bRotate_IsChecked))
|
|
End If
|
|
Else
|
|
NotifyPropertyChanged(NameOf(bMove_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)
|
|
If Map.refSceneHostVM.MainController.GetStep = 0 Then
|
|
m_bRotate_IsChecked = value
|
|
If value Then
|
|
m_bMove_IsChecked = False
|
|
NotifyPropertyChanged(NameOf(bMove_IsChecked))
|
|
End If
|
|
Else
|
|
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()
|
|
RotZ = True
|
|
NotifyPropertyChanged(NameOf(RotZ))
|
|
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)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Friend Sub UpdateUI()
|
|
RefreshPos()
|
|
If m_bRotating Then
|
|
m_bRotating = False
|
|
' ripristino griglia
|
|
EgtSetGridFrame(m_PrevGridOrigin)
|
|
End If
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
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)
|
|
End If
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
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()
|
|
If Map.refSceneHostVM.MainController.GetStep <> 0 Then Return
|
|
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()
|
|
If Map.refSceneHostVM.MainController.GetStep <> 0 Then Return
|
|
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
|
|
|
|
Public Class FromBooleanToVisibility
|
|
Implements IValueConverter
|
|
|
|
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.Convert
|
|
If IsNothing(value) OrElse TypeOf value IsNot Boolean Then
|
|
Return Visibility.Collapsed
|
|
End If
|
|
Return If(CBool(value), Visibility.Visible, Visibility.Collapsed)
|
|
End Function
|
|
|
|
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
|
|
Throw New NotSupportedException()
|
|
End Function
|
|
|
|
End Class
|