729 lines
26 KiB
VB.net
729 lines
26 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class MyMachGroupPanelVM
|
|
Inherits MachGroupPanelVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
MyBase.New()
|
|
' Recupero la macchina di default
|
|
Dim sDefaultMachine As String = String.Empty
|
|
GetMainPrivateProfileString(S_MACH, K_CURRMACH, "", sDefaultMachine)
|
|
' Creo riferimento a questa classe in Map
|
|
Map.SetRefMachGroupPanelVM(Me)
|
|
InitMachGroupPanel(True, Map.refMachinePanelVM.MachineList.ToList(), sDefaultMachine)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Public Overrides Function InitMachGroupList(Optional bUseDefaults As Boolean = False) As Boolean
|
|
' Svuoto precedente lista di MachGroup
|
|
MachGroupList.Clear()
|
|
' aggiorno copie
|
|
UpdateDuplo()
|
|
' verifico se esistono già gruppi di lavorazione o se devo creare il primo
|
|
Dim bOk As Boolean = False
|
|
Dim nId = EgtGetFirstMachGroup()
|
|
If nId <> GDB_ID.NULL Then
|
|
bOk = EgtSetCurrMachGroup(nId)
|
|
End If
|
|
If Not bOk Then Return True
|
|
' carico lista dei gruppi di lavorazione
|
|
LoadMachGroupList()
|
|
' elimino copie da cancellare
|
|
DeleteDuplo()
|
|
If bOk Then SelectedMachGroup = MachGroupList(0)
|
|
EgtZoom(ZM.ALL)
|
|
Return True
|
|
End Function
|
|
|
|
Public Overrides Sub AddMachGroup()
|
|
Dim nNewMachGroupID As Integer = EgtAddMachGroup(NewMachGroupID().ToString, Map.refMachinePanelVM.SelectedMachine.Name)
|
|
If nNewMachGroupID <> GDB_ID.NULL Then
|
|
' creo oggetto gruppo creato
|
|
Dim sNewMachGroupName As String = String.Empty
|
|
Dim sNewMachGroupMachineName As String = String.Empty
|
|
EgtGetMachGroupName(nNewMachGroupID, sNewMachGroupName)
|
|
EgtGetMachGroupMachineName(nNewMachGroupID, sNewMachGroupMachineName)
|
|
Dim MyMachGroup As Core.MyMachGroup
|
|
If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then
|
|
MyMachGroup = New BeamMachGroup(nNewMachGroupID, sNewMachGroupName, sNewMachGroupMachineName)
|
|
Else
|
|
MyMachGroup = New WallMachGroup(nNewMachGroupID, sNewMachGroupName, sNewMachGroupMachineName)
|
|
End If
|
|
' lo aggiungo alla lista
|
|
MachGroupList.Add(MyMachGroup)
|
|
' e lo seleziono
|
|
SelectedMachGroup = MyMachGroup
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides Sub LoadMachGroupList()
|
|
' Carico i gruppi di lavorazione nella lista
|
|
Dim nId = EgtGetFirstMachGroup()
|
|
While nId <> GDB_ID.NULL
|
|
EgtSetCurrMachGroup(nId)
|
|
Dim sName As String = String.Empty
|
|
Dim sMachine As String = String.Empty
|
|
EgtGetMachGroupName(nId, sName)
|
|
EgtGetMachGroupMachineName(nId, sMachine)
|
|
' cerco la macchina tra quelle presenti
|
|
Dim MachGroupMachine As MyMachine = Nothing
|
|
Machine.SearchMachine(sMachine, Map.refMachinePanelVM.MachineList, MachGroupMachine)
|
|
If IsNothing(MachGroupMachine) OrElse MachGroupMachine.nType = MachineType.NULL Then
|
|
EgtOutLog("Machine incompatible with beam & wall machining!!")
|
|
Return
|
|
ElseIf MachGroupMachine.nType = MachineType.BEAM Then
|
|
MachGroupList.Add(New BeamMachGroup(nId, sName, sMachine))
|
|
ElseIf MachGroupMachine.nType = MachineType.WALL Then
|
|
MachGroupList.Add(New WallMachGroup(nId, sName, sMachine))
|
|
End If
|
|
nId = EgtGetNextMachGroup(nId)
|
|
End While
|
|
EgtResetCurrMachGroup()
|
|
End Sub
|
|
|
|
Public Overrides Function OnPreNewMachGroup() As Boolean
|
|
EgtSetCurrentContext(Map.refSceneHostVM.MainScene.GetCtx())
|
|
Return True
|
|
End Function
|
|
|
|
' NB: Anche se ho già aggiunto il nuovo gruppo di lavorazione, non l'ho ancora reso corrente (viene fatto dopo), quindi
|
|
' non posso usare CurrentMachine perchè è ancora impostata quella precedente!!!
|
|
Public Overrides Function OnPostNewMachGroup() As Boolean
|
|
' Salvo macchina del gruppo come nuovo default
|
|
Dim sCurrMachName As String = String.Empty
|
|
EgtGetCurrMachineName(sCurrMachName)
|
|
WriteMainPrivateProfileString(S_MACH, K_CURRMACH, sCurrMachName)
|
|
' leggo nome attrezzaggio di default
|
|
Dim sDefaultSetUpName As String = String.Empty
|
|
Dim sMachineIniPath As String = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & sCurrMachName & "\" & sCurrMachName & ".ini"
|
|
EgtUILib.GetPrivateProfileString(S_SETUP, K_DEFAULT, "", sDefaultSetUpName, sMachineIniPath)
|
|
' se è attiva l'opzione, rendo corrente l'attrezzaggio di default
|
|
If Not String.IsNullOrEmpty(sDefaultSetUpName) Then
|
|
If Not EgtImportSetup(sDefaultSetUpName) Then
|
|
EgtOutLog("Error loading default setup " & sDefaultSetUpName)
|
|
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 9) & " " & sDefaultSetUpName, EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
End If
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Public Overrides Function OnPreSetCurrMachGroup() As Boolean
|
|
EgtSetCurrentContext(Map.refSceneHostVM.MainScene.GetCtx())
|
|
Return True
|
|
End Function
|
|
|
|
Public Overrides Function OnPostSetCurrMachGroup() As Boolean
|
|
' Imposto vista solo tavola
|
|
EgtSetMachineLook(MCH_LOOK.TAB)
|
|
EgtSetView(VT.ISO_SW, False)
|
|
EgtZoom(ZM.ALL)
|
|
Return True
|
|
End Function
|
|
|
|
Public Overrides Function OnPreRemoveCurrMachGroup() As Boolean
|
|
EgtSetCurrentContext(Map.refSceneHostVM.MainScene.GetCtx())
|
|
Return True
|
|
End Function
|
|
|
|
Private Function NewMachGroupID() As Integer
|
|
If Not IsNothing(MachGroupList) AndAlso MachGroupList.Count > 0 Then Return MachGroupList.Max(Function(x) x.Name) + 1
|
|
Return 1
|
|
End Function
|
|
|
|
' funzione che fa l'update di tutte le copie dei pezzi modificati
|
|
Friend Sub UpdateDuplo()
|
|
Dim nPartId As Integer = EgtGetFirstPart()
|
|
While nPartId <> GDB_ID.NULL
|
|
Dim bIsModified As Boolean = False
|
|
If EgtDuploGetModified(nPartId, bIsModified) AndAlso bIsModified Then
|
|
EgtDuploUpdate(nPartId)
|
|
End If
|
|
nPartId = EgtGetNextPart(nPartId)
|
|
End While
|
|
End Sub
|
|
|
|
' funzione che cancella tutti i pezzi segnati da eliminare
|
|
Friend Sub DeleteDuplo()
|
|
Dim nPartId As Integer = EgtGetFirstPart()
|
|
While nPartId <> GDB_ID.NULL
|
|
Dim bIsToDelete As Boolean = False
|
|
If DuploGetToDelete(nPartId, bIsToDelete) AndAlso bIsToDelete Then
|
|
' verifico se ci sono copie
|
|
Dim nDuploCount As Integer = 0
|
|
EgtDuploCount(nPartId, nDuploCount)
|
|
Dim DuploList As New List(Of Integer)
|
|
If nDuploCount > 0 AndAlso EgtDuploList(nPartId, DuploList) Then
|
|
' cancello tutti i pezzi copia nelle barre
|
|
For Each nDuploId In DuploList
|
|
' reset necessario per poter accedere direttamente al grezzo dalle info pezzo e al MachGroup tramite la gerarchia Db geometrico
|
|
EgtResetCurrMachGroup()
|
|
' recupero grezzo cui appartiene
|
|
Dim nRawPartId As Integer
|
|
EgtGetInfo(nDuploId, "!LST", nRawPartId)
|
|
' recupero gruppo di lavorazione
|
|
Dim nMachGroupId As Integer = EgtGetParent(EgtGetParent(EgtGetParent(nRawPartId)))
|
|
' recupero gruppo di lavorazione e trave dell'interfaccia
|
|
Dim BeamMachGroup As BeamMachGroup = Map.refProjectVM.MachGroupPanelVM.MachGroupList.FirstOrDefault(Function(x) x.Id = nMachGroupId)
|
|
Dim Beam As Beam = BeamMachGroup.PartList.FirstOrDefault(Function(x) x.nPartId = nDuploId)
|
|
EgtSetCurrMachGroup(BeamMachGroup.Id)
|
|
Beam.DeletePart()
|
|
Next
|
|
End If
|
|
DuploResetToDelete(nPartId)
|
|
End If
|
|
nPartId = EgtGetNextPart(nPartId)
|
|
End While
|
|
EgtResetCurrMachGroup()
|
|
End Sub
|
|
|
|
Friend Shared Function DuploGetToDelete(nSouId As Integer, ByRef bToDelete As Boolean) As Boolean
|
|
If IsNothing(nSouId) Then Return False
|
|
Return EgtGetInfo(nSouId, DUPLO_TODELETE, bToDelete)
|
|
End Function
|
|
|
|
Friend Shared Function DuploSetToDelete(nSouId As Integer) As Boolean
|
|
If IsNothing(nSouId) Then Return False
|
|
Return EgtSetInfo(nSouId, DUPLO_TODELETE, True)
|
|
End Function
|
|
|
|
Private Function DuploResetToDelete(nSouId As Integer) As Boolean
|
|
If IsNothing(nSouId) Then Return False
|
|
Return EgtSetInfo(nSouId, DUPLO_TODELETE, "")
|
|
End Function
|
|
|
|
' funzione che seleziona ultimo gruppo
|
|
Friend Sub SelLastMachGroup()
|
|
If Not IsNothing(Me) AndAlso Not IsNothing(MachGroupList) AndAlso MachGroupList.Count > 0 Then
|
|
SelectedMachGroup = MachGroupList(MachGroupList.Count - 1)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
End Class
|
|
|
|
Public Class BeamMachGroup
|
|
Inherits Core.BeamMachGroup
|
|
|
|
Public Property sStartCut As String
|
|
Get
|
|
Return LenToString(m_dStartCut, 3)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dValue As Double
|
|
If StringToLen(value, dValue) Then
|
|
Dim dOldValue As Double = m_dStartCut
|
|
m_dStartCut = dValue
|
|
If Not ReDrawBeamMachgroup() Then
|
|
' rispristino vecchio valore
|
|
m_dStartCut = dOldValue
|
|
ReDrawBeamMachgroup()
|
|
End If
|
|
m_dStartCut = dValue
|
|
EgtDraw()
|
|
If PartList.Count > 0 Then
|
|
Dim Beam As Beam = DirectCast(PartList(0), Beam)
|
|
Beam.UpdateOffset()
|
|
Beam.NotifyPropertyChanged("sOffset")
|
|
End If
|
|
Else
|
|
NotifyPropertyChanged("sStartCut")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
' definizione comandi
|
|
Private m_cmdDeleteMachGroup As ICommand
|
|
|
|
Sub New(nId As Integer, sName As String, sMachine As String)
|
|
MyBase.New(nId, sName, sMachine)
|
|
SetMachineType(MachineType.BEAM)
|
|
EgtGetInfo(nId, MGR_RPT_BARLEN, dL)
|
|
EgtGetInfo(nId, MGR_RPT_BARHEIGHT, dH)
|
|
EgtGetInfo(nId, MGR_RPT_BARWIDTH, dW)
|
|
m_dTotMat = dL
|
|
For Each Part In PartList
|
|
m_dMatForPart += Part.dL
|
|
Next
|
|
End Sub
|
|
|
|
Public Overrides Sub RefreshPartList()
|
|
' leggo StartCut da posizione primo pezzo
|
|
Dim sInfo As String = ""
|
|
Dim sSplitInfo() As String
|
|
Dim bFound As Boolean = False
|
|
EgtGetInfo(Id, MGR_RPT_PART & 1, sInfo)
|
|
If Not String.IsNullOrWhiteSpace(sInfo) Then
|
|
sSplitInfo = sInfo.Split(","c)
|
|
StringToDouble(sSplitInfo(1), m_dStartCut)
|
|
Else
|
|
m_dStartCut = 0
|
|
End If
|
|
' aggiorno lista pezzi
|
|
PartList.Clear()
|
|
Dim nRawPartId As Integer = EgtGetFirstRawPart()
|
|
While nRawPartId <> GDB_ID.NULL
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawPartId)
|
|
If nPartId <> GDB_ID.NULL Then
|
|
Dim NewBeam As Beam = New Beam(Me, nPartId, nRawPartId)
|
|
PartList.Add(NewBeam)
|
|
NewBeam.UpdateOffset()
|
|
End If
|
|
nRawPartId = EgtGetNextRawPart(nRawPartId)
|
|
End While
|
|
End Sub
|
|
|
|
Friend Sub UpdateUsage()
|
|
m_dTotMat = dL
|
|
m_dMatForPart = 0
|
|
For Each Part In PartList
|
|
m_dMatForPart += Part.dL
|
|
Next
|
|
NotifyPropertyChanged("dUsage")
|
|
NotifyPropertyChanged("dWaste")
|
|
End Sub
|
|
|
|
Friend Function ReDrawBeamMachgroup() As Boolean
|
|
' scrivo dati di tutti i pezzi
|
|
Dim dPosX As Double = dStartCut
|
|
Dim nIndex As Integer
|
|
For nIndex = 0 To PartList.Count - 1
|
|
If nIndex <> 0 Then
|
|
Dim Beam As Beam = DirectCast(PartList(nIndex), Beam)
|
|
dPosX += Beam.dOffset
|
|
End If
|
|
PartList(nIndex).dPOSX = dPosX
|
|
EgtSetInfo(Id, MGR_RPT_PART & nIndex + 1, PartList(nIndex).nPartId & "," & dPosX)
|
|
dPosX += PartList(nIndex).dL
|
|
Next
|
|
' elimino eventuali successive info pezzi di troppo
|
|
nIndex = PartList.Count + 1
|
|
Dim sTemp As String = ""
|
|
While EgtGetInfo(Id, MGR_RPT_PART & nIndex, sTemp)
|
|
EgtSetInfo(Id, MGR_RPT_PART & nIndex, "")
|
|
End While
|
|
' elimino vecchio grezzo ed eseguo script creazione nuovo
|
|
Dim nRawId As Integer = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
EgtRemoveRawPart(nRawId)
|
|
nRawId = EgtGetFirstRawPart()
|
|
End While
|
|
If Not ExecBeam(Map.refMainWindowVM.MainWindowM.sTempDir, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdType.RAWPART, False) Then Return False
|
|
Return True
|
|
End Function
|
|
|
|
Friend Sub MoveBeam(Beam As Beam, MoveDirection As MoveDirections)
|
|
Dim nBeamIndex As Integer = PartList.IndexOf(Beam)
|
|
If nBeamIndex = 0 AndAlso MoveDirection = MoveDirections.UP Then Return
|
|
If nBeamIndex = PartList.Count - 1 AndAlso MoveDirection = MoveDirections.DOWN Then Return
|
|
' se pezzo mosso diventa primo
|
|
Dim FirstBeam As Beam
|
|
If (nBeamIndex = 1 AndAlso MoveDirection = MoveDirections.UP) OrElse (nBeamIndex = 0 AndAlso MoveDirection = MoveDirections.DOWN) Then
|
|
'' resetto offset per vecchio primo
|
|
FirstBeam = DirectCast(PartList(0), Beam)
|
|
FirstBeam.ResetOffset()
|
|
End If
|
|
PartList.Move(nBeamIndex, nBeamIndex + MoveDirection)
|
|
ReDrawBeamMachgroup()
|
|
' aggiorno offset primo pezzo
|
|
FirstBeam = DirectCast(PartList(0), Beam)
|
|
FirstBeam.UpdateOffset()
|
|
FirstBeam.NotifyPropertyChanged("sOffset")
|
|
End Sub
|
|
|
|
Friend Sub ReorderBeam()
|
|
Dim TempPartList = PartList.OrderBy(Function(x) x.dL).ToList()
|
|
' verifico se non sono già in oridne
|
|
Dim bSort As Boolean = False
|
|
For PartIndex = 0 To PartList.Count - 1
|
|
If PartList(PartIndex).nPartId <> TempPartList(PartIndex).nPartId Then
|
|
bSort = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
If Not bSort Then Return
|
|
' resetto offset primo pezzo
|
|
Dim FirstBeam As Beam = DirectCast(PartList(0), Beam)
|
|
FirstBeam.ResetOffset()
|
|
PartList.Clear()
|
|
For Each Part In TempPartList
|
|
PartList.Add(Part)
|
|
Next
|
|
ReDrawBeamMachgroup()
|
|
' aggiorno offset primo pezzo
|
|
FirstBeam = DirectCast(PartList(0), Beam)
|
|
FirstBeam.UpdateOffset()
|
|
FirstBeam.NotifyPropertyChanged("sOffset")
|
|
End Sub
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "DeleteMachGroup"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property DeleteMachGroup_Command As ICommand
|
|
Get
|
|
If m_cmdDeleteMachGroup Is Nothing Then
|
|
m_cmdDeleteMachGroup = New Command(AddressOf DeleteMachGroup)
|
|
End If
|
|
Return m_cmdDeleteMachGroup
|
|
End Get
|
|
End Property
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Overrides Sub DeleteMachGroup()
|
|
' elimino tutte le copie
|
|
Dim nRawPartId As Integer = EgtGetFirstRawPart()
|
|
Dim nBeamId As Integer = EgtGetFirstPartInRawPart(nRawPartId)
|
|
While nRawPartId <> GDB_ID.NULL
|
|
EgtRemovePartFromRawPart(nBeamId)
|
|
EgtErase(nBeamId)
|
|
nRawPartId = EgtGetNextRawPart(nRawPartId)
|
|
nBeamId = EgtGetFirstPartInRawPart(nRawPartId)
|
|
End While
|
|
' elimino MachGroup
|
|
EgtRemoveMachGroup(Me.Id)
|
|
' rimuovo dalla lista grezzi
|
|
Dim Index As Integer = Map.refMachGroupPanelVM.MachGroupList.IndexOf(Me)
|
|
If Index = 0 Then
|
|
If Map.refMachGroupPanelVM.MachGroupList.Count > 0 Then
|
|
Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupList(0)
|
|
Else
|
|
Map.refMachGroupPanelVM.SelectedMachGroup = Nothing
|
|
End If
|
|
ElseIf Index = Map.refMachGroupPanelVM.MachGroupList.Count - 1 Then
|
|
If Map.refMachGroupPanelVM.MachGroupList.Count > 1 Then
|
|
Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupList(Map.refMachGroupPanelVM.MachGroupList.Count - 2)
|
|
Else
|
|
Map.refMachGroupPanelVM.SelectedMachGroup = Nothing
|
|
End If
|
|
Else
|
|
Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupList(Index - 1)
|
|
End If
|
|
Map.refMachGroupPanelVM.MachGroupList.Remove(Me)
|
|
End Sub
|
|
|
|
#End Region ' DeleteMachGroup
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|
|
|
|
Public Class WallMachGroup
|
|
Inherits Core.WallMachGroup
|
|
|
|
' definizione comandi
|
|
Private m_cmdDeleteMachGroup As ICommand
|
|
|
|
Sub New(nId As Integer, sName As String, sMachine As String)
|
|
MyBase.New(nId, sName, sMachine)
|
|
SetMachineType(MachineType.WALL)
|
|
m_nRawPartId = EgtGetFirstRawPart()
|
|
EgtGetInfo(nId, MGR_RPT_PANELLEN, dL)
|
|
EgtGetInfo(nId, MGR_RPT_PANELWIDTH, dW)
|
|
EgtGetInfo(nId, MGR_RPT_PANELHEIGHT, dH)
|
|
m_dTotMat = dL * dW
|
|
For Each Part In PartList
|
|
m_dMatForPart += (Part.dL * Part.dW)
|
|
Next
|
|
End Sub
|
|
|
|
Friend Sub UpdateUsage()
|
|
m_dTotMat = dL * dW
|
|
m_dMatForPart = 0
|
|
For Each Part In PartList
|
|
m_dMatForPart += (Part.dL * Part.dW)
|
|
Next
|
|
NotifyPropertyChanged("dUsage")
|
|
NotifyPropertyChanged("dWaste")
|
|
End Sub
|
|
|
|
Public Overrides Sub RefreshPartList()
|
|
m_nRawPartId = EgtGetFirstRawPart()
|
|
PartList.Clear()
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(m_nRawPartId)
|
|
While nPartId <> GDB_ID.NULL
|
|
PartList.Add(New Wall(Me, nPartId))
|
|
nPartId = EgtGetNextPartInRawPart(nPartId)
|
|
End While
|
|
End Sub
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "DeleteMachGroup"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property DeleteMachGroup_Command As ICommand
|
|
Get
|
|
If m_cmdDeleteMachGroup Is Nothing Then
|
|
m_cmdDeleteMachGroup = New Command(AddressOf DeleteMachGroup)
|
|
End If
|
|
Return m_cmdDeleteMachGroup
|
|
End Get
|
|
End Property
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Overrides Sub DeleteMachGroup()
|
|
' elimino tutte le copie
|
|
Dim nRawPartId As Integer = EgtGetFirstRawPart()
|
|
Dim nBeamId As Integer = EgtGetFirstPartInRawPart(nRawPartId)
|
|
While nRawPartId <> GDB_ID.NULL
|
|
EgtRemovePartFromRawPart(nBeamId)
|
|
EgtErase(nBeamId)
|
|
nRawPartId = EgtGetNextRawPart(nRawPartId)
|
|
nBeamId = EgtGetFirstPartInRawPart(nRawPartId)
|
|
End While
|
|
' elimino MachGroup
|
|
EgtRemoveMachGroup(Me.Id)
|
|
' rimuovo dalla lista grezzi
|
|
Dim Index As Integer = Map.refMachGroupPanelVM.MachGroupList.IndexOf(Me)
|
|
If Index = 0 Then
|
|
If Map.refMachGroupPanelVM.MachGroupList.Count > 0 Then
|
|
Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupList(0)
|
|
Else
|
|
Map.refMachGroupPanelVM.SelectedMachGroup = Nothing
|
|
End If
|
|
ElseIf Index = Map.refMachGroupPanelVM.MachGroupList.Count - 1 Then
|
|
If Map.refMachGroupPanelVM.MachGroupList.Count > 1 Then
|
|
Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupList(Map.refMachGroupPanelVM.MachGroupList.Count - 2)
|
|
Else
|
|
Map.refMachGroupPanelVM.SelectedMachGroup = Nothing
|
|
End If
|
|
Else
|
|
Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupList(Index - 1)
|
|
End If
|
|
Map.refMachGroupPanelVM.MachGroupList.Remove(Me)
|
|
End Sub
|
|
|
|
#End Region ' DeleteMachGroup
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|
|
|
|
Public Class Beam
|
|
Inherits Core.Beam
|
|
|
|
Public Property sOffset As String
|
|
Get
|
|
Return LenToString(m_dOffset, 3)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dValue As Double
|
|
If StringToLen(value, dValue) Then
|
|
Dim dOldValue As Double = m_dOffset
|
|
m_dOffset = dValue
|
|
Dim BeamMachGroup As BeamMachGroup = DirectCast(ParentMachGroup, BeamMachGroup)
|
|
If Not BeamMachGroup.ReDrawBeamMachgroup() Then
|
|
' rispristino vecchio valore
|
|
m_dOffset = dOldValue
|
|
BeamMachGroup.ReDrawBeamMachgroup()
|
|
End If
|
|
Else
|
|
NotifyPropertyChanged("sOffset")
|
|
End If
|
|
End Set
|
|
End Property
|
|
Friend Sub ResetOffset()
|
|
m_dOffset = RawPartConfiguration.dBeamDist
|
|
NotifyPropertyChanged("sOffset")
|
|
End Sub
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(nParentMachGroup As Core.MyMachGroup, nPartId As Integer, nRawPartId As Integer)
|
|
MyBase.New(nParentMachGroup, nPartId, nRawPartId)
|
|
' leggo info pezzo
|
|
EgtGetInfo(nPartId, BTL_PRT_PROJ, nProjId)
|
|
EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN)
|
|
EgtGetInfo(nPartId, BTL_PRT_NAM, sNAM)
|
|
EgtGetInfo(nPartId, BTL_PRT_L, dL)
|
|
EgtGetInfo(nPartId, BTL_PRT_W, dW)
|
|
EgtGetInfo(nPartId, BTL_PRT_H, dH)
|
|
EgtGetInfo(nPartId, BTL_PRT_CNT, nCNT)
|
|
Dim nTemp As Integer = 0
|
|
If Not EgtGetInfo(nPartId, BTL_PRT_ROTATED, nTemp) Then
|
|
nTemp = 0
|
|
End If
|
|
SetRotated(nTemp)
|
|
If Not EgtGetInfo(nPartId, BTL_PRT_INVERTED, nTemp) Then
|
|
nTemp = 0
|
|
End If
|
|
SetInverted(nTemp)
|
|
' leggo PosX
|
|
Dim sInfo As String = ""
|
|
Dim Index = 1
|
|
Dim sSplitInfo() As String
|
|
Dim bFound As Boolean = False
|
|
While EgtGetInfo(m_ParentMachGroup.Id, MGR_RPT_PART & Index, sInfo)
|
|
If Not String.IsNullOrWhiteSpace(sInfo) Then
|
|
sSplitInfo = sInfo.Split(","c)
|
|
If sSplitInfo(0) = nPartId Then
|
|
bFound = True
|
|
Exit While
|
|
End If
|
|
End If
|
|
Index += 1
|
|
End While
|
|
If bFound Then
|
|
StringToDouble(sSplitInfo(1), dPOSX)
|
|
End If
|
|
' leggo feature
|
|
Dim nProcessingId As Integer = EgtGetFirstNameInGroup(nPartId, PROCESSINGS)
|
|
Dim nFeatureId As Integer = EgtGetFirstInGroup(nProcessingId)
|
|
While nFeatureId <> GDB_ID.NULL
|
|
' verifico che sia una feature
|
|
Dim nGRP As Integer
|
|
If EgtGetInfo(nFeatureId, BTL_FTR_GRP, nGRP) Then
|
|
' creo la feature
|
|
FeatureList.Add(New BTLFeature(Nothing, nFeatureId))
|
|
End If
|
|
nFeatureId = EgtGetNext(nFeatureId)
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
Friend Sub UpdateOffset()
|
|
' calcolo offset
|
|
Dim nBeamIndex As Integer = ParentMachGroup.PartList.IndexOf(Me)
|
|
If nBeamIndex > 0 Then
|
|
m_dOffset = dPOSX - (ParentMachGroup.PartList(nBeamIndex - 1).dPOSX + ParentMachGroup.PartList(nBeamIndex - 1).dL)
|
|
Else
|
|
Dim BeamMachGroup As BeamMachGroup = DirectCast(ParentMachGroup, BeamMachGroup)
|
|
m_dOffset = BeamMachGroup.dStartCut
|
|
End If
|
|
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)
|
|
EgtErase(Me.nPartId)
|
|
' rimuovo dalla lista pezzi
|
|
Dim Index As Integer = ParentMachGroup.PartList.IndexOf(Me)
|
|
If Index = 0 Then
|
|
If ParentMachGroup.PartList.Count > 0 Then
|
|
ParentMachGroup.SelPart = ParentMachGroup.PartList(0)
|
|
Else
|
|
ParentMachGroup.SelPart = Nothing
|
|
End If
|
|
ElseIf Index = ParentMachGroup.PartList.Count - 1 Then
|
|
If ParentMachGroup.PartList.Count > 1 Then
|
|
ParentMachGroup.SelPart = ParentMachGroup.PartList(ParentMachGroup.PartList.Count - 2)
|
|
Else
|
|
ParentMachGroup.SelPart = Nothing
|
|
End If
|
|
Else
|
|
ParentMachGroup.SelPart = ParentMachGroup.PartList(Index - 1)
|
|
End If
|
|
ParentMachGroup.PartList.Remove(Me)
|
|
Dim BeamParentMachGroup As BeamMachGroup = DirectCast(ParentMachGroup, BeamMachGroup)
|
|
If Not IsNothing(BeamParentMachGroup) Then BeamParentMachGroup.ReDrawBeamMachgroup()
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class Wall
|
|
Inherits Core.Wall
|
|
|
|
Public Property sPOSY As String
|
|
Get
|
|
Return LenToString(m_dPOSY, 3)
|
|
End Get
|
|
Set(value As String)
|
|
StringToLen(value, m_dPOSY)
|
|
End Set
|
|
End Property
|
|
|
|
Public Property sROT As String
|
|
Get
|
|
Return LenToString(m_dROT, 3)
|
|
End Get
|
|
Set(value As String)
|
|
StringToLen(value, m_dROT)
|
|
End Set
|
|
End Property
|
|
|
|
Public Property sFLIP As String
|
|
Get
|
|
Return LenToString(m_dFLIP, 3)
|
|
End Get
|
|
Set(value As String)
|
|
StringToLen(value, m_dFLIP)
|
|
End Set
|
|
End Property
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(nParentMachGroup As Core.MyMachGroup, nPartId As Integer)
|
|
MyBase.New(nParentMachGroup, nPartId)
|
|
' leggo info pezzo
|
|
EgtGetInfo(nPartId, BTL_PRT_PROJ, m_nProjId)
|
|
EgtGetInfo(nPartId, BTL_PRT_PDN, m_nPDN)
|
|
EgtGetInfo(nPartId, BTL_PRT_NAM, m_sNAM)
|
|
EgtGetInfo(nPartId, BTL_PRT_L, m_dL)
|
|
EgtGetInfo(nPartId, BTL_PRT_W, m_dW)
|
|
EgtGetInfo(nPartId, BTL_PRT_H, m_dH)
|
|
EgtGetInfo(nPartId, BTL_PRT_CNT, m_nCNT)
|
|
Dim nTemp As Integer = 0
|
|
If Not EgtGetInfo(nPartId, BTL_PRT_ROTATED, nTemp) Then
|
|
nTemp = 0
|
|
End If
|
|
SetRotated(nTemp)
|
|
If Not EgtGetInfo(nPartId, BTL_PRT_INVERTED, nTemp) Then
|
|
nTemp = 0
|
|
End If
|
|
SetInverted(nTemp)
|
|
' leggo PosX, PosY, Rot e Flip
|
|
Dim sInfo As String = ""
|
|
Dim Index = 1
|
|
Dim sSplitInfo() As String
|
|
Dim bFound As Boolean = False
|
|
While EgtGetInfo(m_ParentMachGroup.Id, MGR_RPT_PART & Index, sInfo)
|
|
If Not String.IsNullOrWhiteSpace(sInfo) Then
|
|
sSplitInfo = sInfo.Split(","c)
|
|
If sSplitInfo(0) = nPartId Then
|
|
bFound = True
|
|
Exit While
|
|
End If
|
|
End If
|
|
Index += 1
|
|
End While
|
|
If bFound Then
|
|
StringToDouble(sSplitInfo(1), m_dPOSX)
|
|
StringToDouble(sSplitInfo(2), m_dPOSY)
|
|
StringToDouble(sSplitInfo(3), m_dROT)
|
|
StringToDouble(sSplitInfo(4), m_dFLIP)
|
|
End If
|
|
' vado sul layer delle feature
|
|
Dim nProcessingId As Integer = EgtGetFirstNameInGroup(nPartId, PROCESSINGS)
|
|
Dim nFeatureId As Integer = EgtGetFirstInGroup(nProcessingId)
|
|
While nFeatureId <> GDB_ID.NULL
|
|
' verifico che sia una feature
|
|
Dim nGRP As Integer
|
|
If EgtGetInfo(nFeatureId, BTL_FTR_GRP, nGRP) Then
|
|
' creo la feature
|
|
FeatureList.Add(New BTLFeature(Nothing, nFeatureId))
|
|
End If
|
|
nFeatureId = EgtGetNext(nFeatureId)
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
End Class
|