ae795ae501
- Gestione click feature -Gestione movimento mouse pareti
275 lines
8.6 KiB
VB.net
275 lines
8.6 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class PartVM
|
|
Inherits Core.PartVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
#Region "Beam"
|
|
|
|
Public Overrides Property sOffset As String
|
|
Get
|
|
Return LenToString(m_PartM.dOffset, 3)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dValue As Double
|
|
If StringToLen(value, dValue) Then
|
|
Dim dOldValue As Double = m_PartM.dOffset
|
|
m_PartM.dOffset = dValue
|
|
' se prima trave della barra sostituisco valore anche a startoffset
|
|
Dim BeamMachGroup As MyMachGroupVM = DirectCast(ParentMachGroupVM, MyMachGroupVM)
|
|
If ParentMachGroupVM.PartVMList(0) Is Me Then
|
|
BeamMachGroup.dStartCut = dValue
|
|
End If
|
|
If Not BeamMachGroup.ReDrawBeamMachgroup() Then
|
|
' rispristino vecchio valore
|
|
m_PartM.dOffset = dOldValue
|
|
BeamMachGroup.dStartCut = dOldValue
|
|
BeamMachGroup.ReDrawBeamMachgroup()
|
|
End If
|
|
' resetto validazione del pezzo
|
|
ResetCalcPart()
|
|
Else
|
|
NotifyPropertyChanged(NameOf(sOffset))
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Beam
|
|
|
|
#Region "Wall"
|
|
|
|
Public Overrides Property sPOSX As String
|
|
Get
|
|
Return LenToString(m_PartM.dPOSX, 3)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dValue As Double
|
|
If StringToLen(value, dValue) Then
|
|
Dim dOldValue As Double = m_PartM.dPOSX
|
|
m_PartM.dPOSX = dValue
|
|
If EgtMovePartInRawPart(nPartId, New Vector3d(dValue - dOldValue, 0, 0)) Then
|
|
EgtSetInfo(nPartId, MGR_PRT_POSX, dValue)
|
|
Else
|
|
' rispristino vecchio valore
|
|
m_PartM.dPOSX = dOldValue
|
|
End If
|
|
EgtDraw()
|
|
Else
|
|
NotifyPropertyChanged(NameOf(sPOSX))
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Public Overrides Property sPOSY As String
|
|
Get
|
|
Return LenToString(m_PartM.dPOSY, 3)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dValue As Double
|
|
If StringToLen(value, dValue) Then
|
|
Dim dOldValue As Double = m_PartM.dPOSY
|
|
m_PartM.dPOSY = dValue
|
|
If EgtMovePartInRawPart(nPartId, New Vector3d(0, dValue - dOldValue, 0)) Then
|
|
EgtSetInfo(nPartId, MGR_PRT_POSY, dValue)
|
|
Else
|
|
' rispristino vecchio valore
|
|
m_PartM.dPOSY = dOldValue
|
|
End If
|
|
EgtDraw()
|
|
Else
|
|
NotifyPropertyChanged(NameOf(sPOSY))
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Public Overrides Property bFLIP As Boolean
|
|
Get
|
|
Return m_PartM.bFLIP
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_PartM.bFLIP Then
|
|
' salvo posizione
|
|
Dim dTempPosX As Double = m_PartM.dPOSX
|
|
Dim dTempPosY As Double = m_PartM.dPOSY
|
|
' tolgo il pezzo dal grezzo
|
|
EgtRemovePartFromRawPart(nPartId)
|
|
' recupero box del pezzo
|
|
Dim b3Part As New BBox3d
|
|
EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, b3Part)
|
|
If EgtRotate(nPartId, b3Part.Center, Vector3d.X_AX, 180) Then
|
|
m_PartM.bFLIP = value
|
|
EgtSetInfo(nPartId, MGR_PRT_FLIP, value)
|
|
Else
|
|
NotifyPropertyChanged(NameOf(bFLIP))
|
|
End If
|
|
' reinserisco il pezzo nel grezzo
|
|
EgtAddPartToRawPart(nPartId, New Point3d(dTempPosX, dTempPosY, 0), ParentMachGroupVM.MyMachGroupM.nRawPartId)
|
|
' lo riseleziono
|
|
EgtSelectObj(nPartId)
|
|
EgtDraw()
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Wall
|
|
|
|
' Definizione comandi
|
|
Private m_cmdBackRotation As ICommand
|
|
Private m_cmdForwardRotation As ICommand
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(PartM As PartM, ParentMachGroupVM As MyMachGroupVM)
|
|
MyBase.New(PartM, ParentMachGroupVM)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
#Region "Part"
|
|
|
|
Friend Sub ResetOffset()
|
|
m_PartM.dOffset = WarehouseHelper.GetOffset(nType)
|
|
NotifyPropertyChanged(NameOf(sOffset))
|
|
End Sub
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Overrides Sub DeletePart()
|
|
' elimino pezzo copia
|
|
EgtRemovePartFromRawPart(Me.nPartId)
|
|
' Recupero Id BTLPart originale
|
|
Dim BTLPart As BTLPartVM = BTLPartVM.RetrieveBTLPartFromPart(nPartId)
|
|
EgtErase(Me.nPartId)
|
|
' rimuovo dalla lista pezzi
|
|
Dim Index As Integer = ParentMachGroupVM.PartVMList.IndexOf(ParentMachGroupVM.PartVMList.FirstOrDefault(Function(x) x.nPartId = nPartId))
|
|
If Index = 0 Then
|
|
If ParentMachGroupVM.PartVMList.Count > 1 Then
|
|
ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(0)
|
|
Else
|
|
ParentMachGroupVM.SelPart = Nothing
|
|
End If
|
|
ElseIf Index = ParentMachGroupVM.PartVMList.Count - 1 Then
|
|
If ParentMachGroupVM.PartVMList.Count > 1 Then
|
|
ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(ParentMachGroupVM.PartVMList.Count - 2)
|
|
Else
|
|
ParentMachGroupVM.SelPart = Nothing
|
|
End If
|
|
Else
|
|
ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(Index - 1)
|
|
End If
|
|
ParentMachGroupVM.PartVMList.Remove(Me)
|
|
If nType = MachineType.BEAM Then
|
|
Dim BeamParentMachGroup As MyMachGroupVM = DirectCast(ParentMachGroupVM, MyMachGroupVM)
|
|
If Not IsNothing(BeamParentMachGroup) Then BeamParentMachGroup.ReDrawBeamMachgroup()
|
|
End If
|
|
' aggiorno contatore pezzi usati in Prod
|
|
If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd()
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub Rotate(IsPositive As Boolean)
|
|
' salvo posizione
|
|
Dim dTempPosX As Double = m_PartM.dPOSX
|
|
Dim dTempPosY As Double = m_PartM.dPOSY
|
|
' tolgo il pezzo dal grezzo
|
|
EgtRemovePartFromRawPart(nPartId)
|
|
' recupero box del pezzo
|
|
Dim b3Part As New BBox3d
|
|
EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, b3Part)
|
|
' se invertito lo reinverto
|
|
Dim bFliped As Boolean = bFLIP
|
|
If bFliped Then EgtRotate(nPartId, b3Part.Center, Vector3d.X_AX, 180)
|
|
Dim dAng As Double = If(IsPositive, 90, -90)
|
|
' eseguo rotazione
|
|
Dim bOk As Boolean = EgtRotate(nPartId, b3Part.Center, -Vector3d.Z_AX, dAng)
|
|
If bOk Then
|
|
Dim TempRot = m_PartM.dROT
|
|
TempRot += dAng
|
|
If TempRot >= 360 Then
|
|
TempRot -= 360
|
|
ElseIf TempRot < 0 Then
|
|
TempRot += 360
|
|
End If
|
|
m_PartM.dROT = TempRot
|
|
EgtSetInfo(nPartId, MGR_PRT_ROT, m_PartM.dROT)
|
|
End If
|
|
' ripristino eventuale inversione
|
|
If bFliped Then EgtRotate(nPartId, b3Part.Center, Vector3d.X_AX, 180)
|
|
' reinserisco il pezzo nel grezzo
|
|
EgtAddPartToRawPart(nPartId, New Point3d(dTempPosX, dTempPosY, 0), ParentMachGroupVM.MyMachGroupM.nRawPartId)
|
|
' lo riseleziono
|
|
EgtSelectObj(nPartId)
|
|
NotifyPropertyChanged(NameOf(sROT))
|
|
End Sub
|
|
|
|
#End Region ' Part
|
|
|
|
#Region "Feature"
|
|
|
|
Protected Overrides Sub CreateBTLFeatureVMList()
|
|
Dim all As List(Of BTLFeatureVM) = (From BTLFeatureM In m_PartM.GetBTLFeatures()
|
|
Select New BTLFeatureVM(BTLFeatureM)).ToList()
|
|
|
|
For Each BTLFeatureVM As BTLFeatureVM In all
|
|
AddHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged
|
|
Next
|
|
|
|
m_FeatureVMList = New ObservableCollection(Of Core.BTLFeatureVM)(all)
|
|
AddHandler m_FeatureVMList.CollectionChanged, AddressOf OnBTLFeatureVMListChanged
|
|
|
|
End Sub
|
|
|
|
#End Region ' Feature
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "BackRotation"
|
|
|
|
Public ReadOnly Property BackRotation_Command As ICommand
|
|
Get
|
|
If m_cmdBackRotation Is Nothing Then
|
|
m_cmdBackRotation = New Command(AddressOf BackRotation)
|
|
End If
|
|
Return m_cmdBackRotation
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub BackRotation()
|
|
Rotate(False)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' BackRotation
|
|
|
|
#Region "ForwardRotation"
|
|
|
|
Public ReadOnly Property ForwardRotation_Command As ICommand
|
|
Get
|
|
If m_cmdForwardRotation Is Nothing Then
|
|
m_cmdForwardRotation = New Command(AddressOf ForwardRotation)
|
|
End If
|
|
Return m_cmdForwardRotation
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ForwardRotation()
|
|
Rotate(True)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' ForwardRotation
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|