diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj
index fb5fbad..ca75f36 100644
--- a/EgtCAM5.vbproj
+++ b/EgtCAM5.vbproj
@@ -151,6 +151,10 @@
+
+ SelMachGroupWndV.xaml
+
+
@@ -357,6 +361,10 @@
MainWindowV.xamlCode
+
+ MSBuild:Compile
+ Designer
+ MSBuild:CompileDesigner
diff --git a/MachGroupPanel/MachGroupPanelVM.vb b/MachGroupPanel/MachGroupPanelVM.vb
index 0d9cea7..09f39e8 100644
--- a/MachGroupPanel/MachGroupPanelVM.vb
+++ b/MachGroupPanel/MachGroupPanelVM.vb
@@ -64,26 +64,177 @@ Public Class MachGroupPanelVM
#Region "METHODS"
Private Sub InitializeMachGroups()
- ' calcolo bbox di tutti i pezzi disegnati
- 'Dim bboxAllParts As New BBox3d
- 'CalculateAllPartsBbox(bboxAllParts)
Dim bOk As Boolean = False
- Dim nId = EgtGetLastMachGroup()
- If nId <> GDB_ID.NULL Then
- bOk = EgtSetCurrMachGroup(nId)
- Else
- bOk = AddNewMachGroup()
- End If
+ Dim nGroupId As Integer = GDB_ID.NULL
+ bOk = ManageDisposition(nGroupId)
If bOk Then
- 'CalculatePartsTranslationVt(bboxAllParts)
- 'TraslateParts()
LoadMachGroups()
- SelectedMachGroup = MachGroupList(MachGroupList.Count() - 1)
+ Dim MachGroupName As String = ""
+ EgtGetMachGroupName(nGroupId, MachGroupName)
+ SelectedMachGroup = MachGroupList(MachGroupList.IndexOf(MachGroupName))
End If
If IniFile.m_bShowOnlyTable Then EgtShowOnlyTable(True)
Application.Msn.NotifyColleagues(Application.MACHGROUPSRESULT, bOk)
End Sub
+ Private Function ManageDisposition(ByRef nGroupId As Integer) As Boolean
+ ' Ricerca pezzi selezionati
+ Dim bSelPart As Boolean = False
+ Dim vPart As New List(Of Integer)
+ Dim nId As Integer = EgtGetFirstSelectedObj()
+ While nId <> GDB_ID.NULL
+ Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
+ If nPartId <> GDB_ID.NULL Then
+ If Not vPart.Contains(nPartId) Then
+ vPart.Add(nPartId)
+ End If
+ End If
+ nId = EgtGetNextSelectedObj()
+ End While
+ bSelPart = vPart.Count > 0
+ EgtDeselectAll()
+ ' Verifica esistenza gruppi di lavorazione
+ Dim bMachGroup As Boolean = (EgtGetMachGroupCount() > 0)
+ ' Se ci sono pezzi selezionati
+ If bSelPart Then
+ ' se ci sono gruppi di lavorazione
+ If bMachGroup Then
+ ' Creo lista dei gruppi di lavorazione
+ Dim MachGroupList As New List(Of Integer)
+ Dim GrpId As Integer = EgtGetFirstMachGroup()
+ While GrpId <> GDB_ID.NULL
+ MachGroupList.Add(GrpId)
+ GrpId = EgtGetNextMachGroup(GrpId)
+ End While
+ ' Elimino gruppi che contengono già un pezzo selezionato
+ For Index = MachGroupList.Count - 1 To 0 Step -1
+ If PartsInMachGroup(vPart, MachGroupList(Index)) Then MachGroupList.Remove(MachGroupList(Index))
+ Next
+ ' se la lista gruppi è vuota creo un nuovo gruppo
+ If MachGroupList.Count = 0 Then
+ AddNewMachGroup(nGroupId, vPart)
+ Return True
+ End If
+ ' altrimenti creo dialogo per scelta gruppi esistenti o nuovo gruppo
+ Dim SelMachGroupWndVM As New SelMachGroupWndVM(MachGroupList)
+ Dim SelMachGroupWndV As New SelMachGroupWndV(Application.Current.MainWindow, SelMachGroupWndVM)
+ If SelMachGroupWndV.ShowDialog() = False Then Return False
+ ' Verifico selezione in dialogo
+ Dim bOk As Boolean = False
+ Select Case SelMachGroupWndVM.MachGroupType
+ Case EgtCAM5.SelMachGroupWndVM.MGroupType.CHOOSEMGROUP
+ nGroupId = SelMachGroupWndVM.SelMachGroupId
+ bOk = AddToMachGroup(nGroupId, vPart)
+ Case EgtCAM5.SelMachGroupWndVM.MGroupType.NEWMGROUP
+ bOk = AddNewMachGroup(nGroupId, vPart)
+ End Select
+ Return bOk
+ ' altrimenti creo il primo gruppo
+ Else
+ Return AddNewMachGroup(nGroupId, vPart)
+ End If
+ ' Se non ci sono pezzi selezionati
+ Else
+ ' se ci sono gruppi di lavorazione
+ If bMachGroup Then
+ nGroupId = EgtGetLastMachGroup()
+ Return EgtSetCurrMachGroup(nGroupId)
+ ' altrimenti esco
+ Else
+ Return False
+ End If
+ End If
+ End Function
+
+ Private Function ExecScript(sScriptPath As String, nGroupId As Integer, nPartId As Integer) As Boolean
+ EgtLuaCreateGlobTable("DISP")
+ EgtLuaSetGlobIntVar("DISP.GROUPID", nGroupId)
+ EgtLuaSetGlobIntVar("DISP.PARTID", nPartId)
+ If Not EgtLuaExecFile(sScriptPath) Then
+ EgtOutLog("Error executing disposition init script " & sScriptPath)
+ MessageBox.Show(EgtMsg(MSG_DISPOSITIONERRORS + 2) & " " & sScriptPath, EgtMsg(MSG_DISPOSITIONERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Exclamation)
+ Return False
+ End If
+ Dim nErr As Integer = 999
+ EgtLuaGetGlobIntVar("DISP.ERR", nErr)
+ EgtLuaResetGlobVar("DISP")
+ Return nErr = 0
+ End Function
+
+ Private Function PartsInMachGroup(SelPartList As List(Of Integer), nGroupId As Integer) As Boolean
+ If Not EgtSetCurrMachGroup(nGroupId) Then Return False
+ Dim nRawId As Integer = EgtGetFirstRawPart()
+ While nRawId <> GDB_ID.NULL
+ Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawId)
+ While nPartId <> GDB_ID.NULL
+ If SelPartList.Contains(nPartId) Then
+ EgtResetCurrMachGroup()
+ Return True
+ End If
+ nPartId = EgtGetNextPartInRawPart(nPartId)
+ End While
+ nRawId = EgtGetNextRawPart(nRawId)
+ End While
+ EgtResetCurrMachGroup()
+ Return False
+ End Function
+
+ Private Function AddToMachGroup(ByRef nGroupId As Integer, PartList As List(Of Integer)) As Boolean
+ ' leggo nome script di disposizione automatica
+ Dim bWithScript As Boolean = False
+ Dim sInitScriptPath As String = String.Empty
+ EgtUILib.GetPrivateProfileString(S_DISPOSITION, K_INITSCRIPT, "", sInitScriptPath, IniFile.m_sCurrMachIniFilePath)
+ ' se è attivo, uso lo script di disposizione
+ If OptionModule.m_bUseDispositionScript And Not String.IsNullOrEmpty(sInitScriptPath) Then
+ sInitScriptPath = IniFile.m_sCurrMachScriptsDirPath & "\" & sInitScriptPath
+ bWithScript = File.Exists(sInitScriptPath)
+ End If
+ If bWithScript Then
+ ' Rendo corrente il gruppo di lavoro
+ EgtSetCurrMachGroup(nGroupId)
+ ' Creo grezzo e posiziono i pezzi
+ For Each Part In PartList
+ ExecScript(sInitScriptPath, nGroupId, Part)
+ Next
+ Else
+ EgtOutLog("Machine without InitDisp script.")
+ Return False
+ End If
+ Return True
+ End Function
+
+ Private Function AddNewMachGroup(ByRef nGroupId As Integer, PartList As List(Of Integer)) As Boolean
+ ' leggo nome script di disposizione automatica
+ Dim bWithScript As Boolean = False
+ Dim sInitScriptPath As String = String.Empty
+ EgtUILib.GetPrivateProfileString(S_DISPOSITION, K_INITSCRIPT, "", sInitScriptPath, IniFile.m_sCurrMachIniFilePath)
+ ' se è attivo, uso lo script di disposizione
+ If OptionModule.m_bUseDispositionScript And Not String.IsNullOrEmpty(sInitScriptPath) Then
+ sInitScriptPath = IniFile.m_sCurrMachScriptsDirPath & "\" & sInitScriptPath
+ bWithScript = File.Exists(sInitScriptPath)
+ End If
+ If bWithScript Then
+ Dim sMgName As String = "Mach_1"
+ EgtGetMachGroupNewName(sMgName)
+ nGroupId = EgtAddMachGroup(sMgName)
+ If nGroupId = GDB_ID.NULL Then
+ EgtOutLog("Errore nella creazione del gruppo di lavoro " & sMgName)
+ MessageBox.Show("Errore nella creazione del gruppo di lavoro", "Lavora", MessageBoxButton.OK, MessageBoxImage.Error)
+ Return False
+ End If
+ ' Creo grezzo e posiziono i pezzi
+ For Each Part In PartList
+ ExecScript(sInitScriptPath, nGroupId, Part)
+ Next
+ Else
+ EgtOutLog("Machine without InitDisp script.")
+ Return False
+ End If
+ ' Gestisco eventuale attrezzaggio di default
+ ManageDefaultSetUp()
+ Return True
+ End Function
+
Private Sub CalculateAllPartsBbox(ByRef bboxAllParts As BBox3d)
Dim nPart As Integer = EgtGetFirstPart()
While nPart <> GDB_ID.NULL
@@ -128,34 +279,18 @@ Public Class MachGroupPanelVM
End While
End Sub
- Private Function AddNewMachGroup() As Boolean
- ' Creazione nuovo gruppo di lavorazione
- Dim sNewMachName As String = "Mach_1"
- EgtGetMachGroupNewName(sNewMachName)
- Dim bOk As Boolean = (EgtAddMachGroup(sNewMachName) <> GDB_ID.NULL)
- ' leggo nome script di disposizione automatica
- Dim sInitScriptPath As String = String.Empty
- EgtUILib.GetPrivateProfileString(S_DISPOSITION, K_INITSCRIPT, "", sInitScriptPath, IniFile.m_sCurrMachIniFilePath)
- ' se è attivo, uso lo script di disposizione
- If bOk AndAlso OptionModule.m_bUseDispositionScript And Not String.IsNullOrEmpty(sInitScriptPath) Then
- sInitScriptPath = IniFile.m_sCurrMachScriptsDirPath & "\" & sInitScriptPath
- If Not File.Exists(sInitScriptPath) OrElse Not EgtLuaExecFile(sInitScriptPath) Then
- EgtOutLog("Error executing disposition init script " & sInitScriptPath)
- MessageBox.Show(EgtMsg(MSG_DISPOSITIONERRORS + 2) & " " & sInitScriptPath, EgtMsg(MSG_DISPOSITIONERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Exclamation)
- End If
- End If
+ Private Sub ManageDefaultSetUp()
' leggo nome attrezzaggio di default
Dim sDefaultSetUpName As String = String.Empty
EgtUILib.GetPrivateProfileString(S_SETUP, K_DEFAULT, "", sDefaultSetUpName, IniFile.m_sCurrMachIniFilePath)
' se è attiva l'opzione, rendo corrente l'attrezzaggio di default
- If bOk And Not String.IsNullOrEmpty(sDefaultSetUpName) Then
+ If Not String.IsNullOrEmpty(sDefaultSetUpName) Then
If Not EgtImportSetup(String.Empty) 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 bOk
- End Function
+ End Sub
#End Region
@@ -200,15 +335,15 @@ Public Class MachGroupPanelVM
End Property
Public Sub AddMachGroup()
- If AddNewMachGroup() Then
- Dim sMachName As String = String.Empty
- EgtGetMachGroupName(EgtGetCurrMachGroup(), sMachName)
- MachGroupList.Add(sMachName)
- SelectedMachGroup = sMachName
- EgtDraw()
- Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, -1)
- Application.Msn.NotifyColleagues(Application.UPDATECURRENTMACHINE)
- End If
+ 'If AddNewMachGroup() Then
+ ' Dim sMachName As String = String.Empty
+ ' EgtGetMachGroupName(EgtGetCurrMachGroup(), sMachName)
+ ' MachGroupList.Add(sMachName)
+ ' SelectedMachGroup = sMachName
+ ' EgtDraw()
+ ' Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, -1)
+ ' Application.Msn.NotifyColleagues(Application.UPDATECURRENTMACHINE)
+ 'End If
End Sub
#End Region ' AddMachGroupCommand
diff --git a/SelMachGroupWnd/SelMachGroupWndV.xaml b/SelMachGroupWnd/SelMachGroupWndV.xaml
new file mode 100644
index 0000000..e3354f4
--- /dev/null
+++ b/SelMachGroupWnd/SelMachGroupWndV.xaml
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SelMachGroupWnd/SelMachGroupWndV.xaml.vb b/SelMachGroupWnd/SelMachGroupWndV.xaml.vb
new file mode 100644
index 0000000..b57ba62
--- /dev/null
+++ b/SelMachGroupWnd/SelMachGroupWndV.xaml.vb
@@ -0,0 +1,24 @@
+Public Class SelMachGroupWndV
+
+ Private m_SelMachGroupWndVM As SelMachGroupWndVM
+
+#Region "CONSTRUCTOR"
+
+ Sub New(Owner As Window, SelMachGroupWndVM As SelMachGroupWndVM)
+ ' Funzione che interpreta l'xaml
+ InitializeComponent()
+ Me.Owner = Owner
+ Me.DataContext = SelMachGroupWndVM
+ ' Assegno al riferimento locale al VM il VM preso dal DataContext
+ m_SelMachGroupWndVM = SelMachGroupWndVM
+ End Sub
+
+#End Region ' CONSTRUCTOR
+
+ Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
+ If m_SelMachGroupWndVM.IsValid Then
+ DialogResult = True
+ End If
+ End Sub
+
+End Class
diff --git a/SelMachGroupWnd/SelMachGroupWndVM.vb b/SelMachGroupWnd/SelMachGroupWndVM.vb
new file mode 100644
index 0000000..506ca90
--- /dev/null
+++ b/SelMachGroupWnd/SelMachGroupWndVM.vb
@@ -0,0 +1,276 @@
+Imports EgtUILib
+Imports EgtWPFLib5
+
+Public Class SelMachGroupWndVM
+ Inherits VMBase
+
+#Region "FIELDS & PROPERTIES"
+
+ Public Enum MGroupType As Integer
+ CHOOSEMGROUP = 1
+ NEWMGROUP = 2
+ End Enum
+
+ Private m_MachGroupType As MGroupType
+ Public ReadOnly Property MachGroupType As MGroupType
+ Get
+ Return m_MachGroupType
+ End Get
+ End Property
+
+ Private m_ChooseGroup_IsChecked As Boolean = Nothing
+ Public Property ChooseGroup_IsChecked As Boolean
+ Get
+ Return m_ChooseGroup_IsChecked
+ End Get
+ Set(value As Boolean)
+ m_ChooseGroup_IsChecked = value
+ If m_ChooseGroup_IsChecked Then
+ MachGroup_Visibility = Visibility.Visible
+ m_MachGroupType = MGroupType.CHOOSEMGROUP
+ End If
+ End Set
+ End Property
+
+ Private m_NewGroup_IsChecked As Boolean = Nothing
+ Public Property NewGroup_IsChecked As Boolean
+ Get
+ Return m_NewGroup_IsChecked
+ End Get
+ Set(value As Boolean)
+ m_NewGroup_IsChecked = value
+ If m_NewGroup_IsChecked Then
+ MachGroup_Visibility = Visibility.Collapsed
+ m_MachGroupType = MGroupType.NEWMGROUP
+ End If
+ End Set
+ End Property
+
+ Private m_ChooseGroup_Visibility As Visibility = Visibility.Collapsed
+ Public Property ChooseGroup_Visibility As Visibility
+ Get
+ Return m_ChooseGroup_Visibility
+ End Get
+ Set(value As Visibility)
+ m_ChooseGroup_Visibility = value
+ End Set
+ End Property
+
+ Private m_Name As String = Nothing
+ Public Property Name As String
+ Get
+ Return m_Name
+ End Get
+ Set(value As String)
+ m_Name = value
+ End Set
+ End Property
+
+ Private m_Name_Visibility As Visibility = Visibility.Collapsed
+ Public Property Name_Visibility As Visibility
+ Get
+ Return m_Name_Visibility
+ End Get
+ Set(value As Visibility)
+ m_Name_Visibility = value
+ End Set
+ End Property
+
+ ' Lista delle macchine disponibili
+ Private m_MachineList As List(Of Machine) = Nothing
+ Public Property MachineList As List(Of Machine)
+ Get
+ Return m_MachineList
+ End Get
+ Set(value As List(Of Machine))
+ m_MachineList = value
+ End Set
+ End Property
+
+ ' Macchina correntemente selezionata e quindi attiva
+ Private m_SelectedMachine As Machine = Nothing
+ Public Property SelectedMachine As Machine
+ Get
+ Return m_SelectedMachine
+ End Get
+ Set(value As Machine)
+ If value IsNot m_SelectedMachine Then
+ m_SelectedMachine = value
+ NotifyPropertyChanged("SelectedMachine")
+ End If
+ End Set
+ End Property
+
+ Private m_Machine_Visibility As Visibility = Visibility.Collapsed
+ Public Property Machine_Visibility As Visibility
+ Get
+ Return m_Machine_Visibility
+ End Get
+ Set(value As Visibility)
+ m_Machine_Visibility = value
+ End Set
+ End Property
+
+ ' Lista delle macchine disponibili
+ Private m_MachGroupList As New List(Of String)
+ Public Property MachGroupList As List(Of String)
+ Get
+ Return m_MachGroupList
+ End Get
+ Set(value As List(Of String))
+ m_MachGroupList = value
+ End Set
+ End Property
+
+ ' Gruppo di lavorazione
+ Private m_SelMachGroupId As Integer
+ Public ReadOnly Property SelMachGroupId As Integer
+ Get
+ Return m_SelMachGroupId
+ End Get
+ End Property
+
+ Private m_SelMachGroup As String = Nothing
+ Public Property SelMachGroup As String
+ Get
+ Return m_SelMachGroup
+ End Get
+ Set(value As String)
+ If value IsNot m_SelectedMachine Then
+ m_SelMachGroup = value
+ NotifyPropertyChanged("SelMachGroup")
+ End If
+ End Set
+ End Property
+
+ Private m_MachGroup_Visibility As Visibility = Visibility.Collapsed
+ Public Property MachGroup_Visibility As Visibility
+ Get
+ Return m_MachGroup_Visibility
+ End Get
+ Set(value As Visibility)
+ m_MachGroup_Visibility = value
+ NotifyPropertyChanged("MachGroup_Visibility")
+ End Set
+ End Property
+
+ Private m_IsClosable As Boolean = True
+ Public Property IsClosable As Boolean
+ Get
+ Return m_IsClosable
+ End Get
+ Set(value As Boolean)
+ m_IsClosable = value
+ End Set
+ End Property
+
+#Region "Messages"
+
+ Public ReadOnly Property TitleMsg As String
+ Get
+ Return EgtMsg(MSG_EGTWPFLIB5 + 900 + 1)
+ End Get
+ End Property
+ Public ReadOnly Property ChooseGroupMsg As String
+ Get
+ Return "Choose MGroup"
+ End Get
+ End Property
+ Public ReadOnly Property NewGroupMsg As String
+ Get
+ Return "New MGroup"
+ End Get
+ End Property
+ Public ReadOnly Property NameMsg As String
+ Get
+ Return EgtMsg(MSG_EGTWPFLIB5 + 900 + 2)
+ End Get
+ End Property
+ Public ReadOnly Property MachineMsg As String
+ Get
+ Return EgtMsg(MSG_EGTWPFLIB5 + 900 + 3)
+ End Get
+ End Property
+ Public ReadOnly Property MachGroupMsg As String
+ Get
+ Return "MachGroup"
+ End Get
+ End Property
+
+#End Region ' Messages
+
+ ' Definizione comandi
+ Private m_cmdOk As ICommand
+ Private m_cmdCancel As ICommand
+
+#End Region 'FIELDS & PROPERTIES
+
+#Region "CONSTRUCTOR"
+
+ Sub New(sName As String)
+ ChooseGroup_Visibility = Visibility.Collapsed
+ MachGroup_Visibility = Visibility.Collapsed
+ Name_Visibility = Visibility.Visible
+ Machine_Visibility = Visibility.Collapsed
+ m_Name = sName
+ End Sub
+ Sub New(sSelectedMachine As String, MachineList As List(Of Machine))
+ ChooseGroup_Visibility = Visibility.Collapsed
+ MachGroup_Visibility = Visibility.Collapsed
+ Name_Visibility = Visibility.Collapsed
+ Machine_Visibility = Visibility.Visible
+ m_MachineList = MachineList
+ If Not Machine.SearchMachine(sSelectedMachine, m_MachineList, m_SelectedMachine) Then
+ m_SelectedMachine = m_MachineList(0)
+ End If
+ End Sub
+ Sub New(sName As String, sSelectedMachine As String, MachineList As List(Of Machine))
+ ChooseGroup_Visibility = Visibility.Collapsed
+ MachGroup_Visibility = Visibility.Collapsed
+ Name_Visibility = Visibility.Visible
+ Machine_Visibility = Visibility.Visible
+ m_Name = sName
+ m_MachineList = MachineList
+ If Not Machine.SearchMachine(sSelectedMachine, m_MachineList, m_SelectedMachine) Then
+ m_SelectedMachine = m_MachineList(0)
+ End If
+ End Sub
+ Sub New(MachGroupList As List(Of Integer))
+ ChooseGroup_Visibility = Visibility.Visible
+ MachGroup_Visibility = Visibility.Visible
+ Name_Visibility = Visibility.Collapsed
+ Machine_Visibility = Visibility.Collapsed
+ ChooseGroup_IsChecked = True
+ Dim MachGroupName As String = String.Empty
+ For Each MachGroupId In MachGroupList
+ EgtGetMachGroupName(MachGroupId, MachGroupName)
+ m_MachGroupList.Add(MachGroupName)
+ Next
+ If m_MachGroupList.Count > 0 Then
+ m_SelMachGroup = m_MachGroupList(0)
+ End If
+ End Sub
+
+#End Region ' CONSTRUCTOR
+
+#Region "METHODS"
+
+ Friend Function IsValid() As Boolean
+ Dim bOk As Boolean
+ If m_Name_Visibility = Visibility.Visible Then
+ bOk = If(Not String.IsNullOrWhiteSpace(m_Name), True, False)
+ Else
+ bOk = True
+ End If
+ If m_Machine_Visibility = Visibility.Visible Then
+ bOk = If(Not IsNothing(m_SelectedMachine), True, False)
+ Else
+ bOk = True
+ End If
+ m_SelMachGroupId = EgtGetMachGroupId(m_SelMachGroup)
+ Return bOk
+ End Function
+
+#End Region ' METHODS
+
+End Class