From acf23b68a8597e152aa485132e34d5b3a5c36e07 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 22 Nov 2018 14:33:28 +0000 Subject: [PATCH] =?UTF-8?q?EgtCAM5=20:=20-=20aggiunta=20gestione=20script?= =?UTF-8?q?=20da=20lanciare=20a=20inizio=20e=20fine=20modalit=C3=A0=20Lavo?= =?UTF-8?q?razioni.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Constants/ConstMachIni.vb | 6 +- MachGroupPanel/MachGroupPanelVM.vb | 4 +- .../ManageLayerExpander/LayerTreeView.vb | 21 ++++-- .../ManageLayerExpanderV.xaml | 3 +- .../ManageLayerExpanderVM.vb | 24 +++++-- TopCommandBar/TopCommandBarVM.vb | 65 +++++++++++++++++-- 6 files changed, 102 insertions(+), 21 deletions(-) diff --git a/Constants/ConstMachIni.vb b/Constants/ConstMachIni.vb index 70bb417..39e5d88 100644 --- a/Constants/ConstMachIni.vb +++ b/Constants/ConstMachIni.vb @@ -45,7 +45,11 @@ Public Const K_MANUALNAME As String = "ManualName" Public Const S_DISPOSITION As String = "Disposition" - Public Const K_INITSCRIPT As String = "InitScript" + Public Const K_DISP_INITSCRIPT As String = "InitScript" + + Public Const S_MACHINING As String = "Machining" + Public Const K_MACH_INITSCRIPT As String = "InitScript" + Public Const K_MACH_EXITSCRIPT As String = "ExitScript" Public Const S_FIXTURES As String = "Fixtures" diff --git a/MachGroupPanel/MachGroupPanelVM.vb b/MachGroupPanel/MachGroupPanelVM.vb index 75631a5..8928566 100644 --- a/MachGroupPanel/MachGroupPanelVM.vb +++ b/MachGroupPanel/MachGroupPanelVM.vb @@ -196,7 +196,7 @@ Public Class MachGroupPanelVM ' 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) + EgtUILib.GetPrivateProfileString(S_DISPOSITION, K_DISP_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 @@ -222,7 +222,7 @@ Public Class MachGroupPanelVM ' 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) + EgtUILib.GetPrivateProfileString(S_DISPOSITION, K_DISP_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 diff --git a/OptionPanel/DrawOptionPanel/ManageLayerExpander/LayerTreeView.vb b/OptionPanel/DrawOptionPanel/ManageLayerExpander/LayerTreeView.vb index 89fcdef..69ed606 100644 --- a/OptionPanel/DrawOptionPanel/ManageLayerExpander/LayerTreeView.vb +++ b/OptionPanel/DrawOptionPanel/ManageLayerExpander/LayerTreeView.vb @@ -63,14 +63,14 @@ Public Class LayerTreeViewItem End Set End Property - Private m_OnOff As Boolean + Private m_bOnOff As Boolean = True Public Property OnOff As Boolean Get - Return m_OnOff + Return m_bOnOff End Get Set(value As Boolean) - If m_OnOff <> value Then - m_OnOff = value + If m_bOnOff <> value Then + m_bOnOff = value ' se abilitato, eseguo operazione If m_SendCmd Then Application.Msn.NotifyColleagues(Application.SETLASTINTEGER, Id) @@ -84,6 +84,19 @@ Public Class LayerTreeViewItem End Set End Property + Private m_bHidden As Boolean = False + Public ReadOnly Property IsHidden As Visibility + Get + Return If(m_bHidden, Visibility.Hidden, Visibility.Visible) + End Get + End Property + Public Sub SetHidden(bVal As Boolean) + If bVal <> m_bHidden Then + m_bHidden = bVal + NotifyPropertyChanged("IsHidden") + End If + End Sub + Private m_sPictureString As String Public Property PictureString As String Get diff --git a/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderV.xaml b/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderV.xaml index 07aa8a1..e8de67e 100644 --- a/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderV.xaml +++ b/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderV.xaml @@ -50,7 +50,8 @@ - + diff --git a/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderVM.vb b/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderVM.vb index 463e4da..6d67c67 100644 --- a/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderVM.vb +++ b/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderVM.vb @@ -582,7 +582,7 @@ Public Class ManageLayerExpanderVM Public Sub LoadObjTree() LayerTreeViewItem.m_SendCmd = False Dim nOldId As Integer = ClearObjTree() - AddGroupInObjTree(GDB_ID.ROOT, GDB_LV.USER, 0, LayerList) + AddGroupInObjTree(GDB_ID.ROOT, GDB_LV.USER, GDB_MD.STD, 0, LayerList) If nOldId <> GDB_ID.NULL Then m_bEnableUpdateObjInObjTree = False SelectIdInObjTree(nOldId, True) @@ -599,7 +599,7 @@ Public Class ManageLayerExpanderVM Return nOldId End Function - Private Sub AddGroupInObjTree(ByVal nGroupId As Integer, ByVal nLevel As Integer, ByVal nDepth As Integer, ByRef PrevNodColl As ObservableCollection(Of LayerTreeViewItem)) + Private Sub AddGroupInObjTree(nGroupId As Integer, nLevel As Integer, nMode As Integer, nDepth As Integer, ByRef PrevNodColl As ObservableCollection(Of LayerTreeViewItem)) Dim CurrNodColl As ObservableCollection(Of LayerTreeViewItem) @@ -614,6 +614,14 @@ Public Class ManageLayerExpanderVM ElseIf nLevel = GDB_LV.USER Then nLevel = nObjLev End If + ' modo + Dim nObjMode As Integer = GDB_MD.STD + EgtGetMode(nGroupId, nObjMode) + If nObjMode = GDB_MD.HIDDEN Then + nMode = GDB_MD.HIDDEN + ElseIf nObjMode = GDB_MD.STD Then + nMode = nObjMode + End If ' tipo Dim nGroupType As Integer = 0 ' 0=gruppo generico, 1=pezzo, 2=layer If nLevel = GDB_LV.USER Then @@ -639,8 +647,8 @@ Public Class ManageLayerExpanderVM sText = "Group " + nGroupId.ToString End If End If - ' per visualizzare oggetti di livello diverso da utente, si deve avere il permesso - If nLevel <> GDB_LV.USER And m_nUserLevel < 5 Then + ' per visualizzare oggetti di livello diverso da utente o di modo diverso da standard, si deve avere il permesso + If (nLevel <> GDB_LV.USER Or nMode <> GDB_MD.STD) And m_nUserLevel < 5 Then Return End If ' inserisco il nodo nell'albero @@ -653,6 +661,7 @@ Public Class ManageLayerExpanderVM Dim nStat As Integer = GDB_ST.ON_ EgtGetStatus(nGroupId, nStat) CurrNod.OnOff = (nStat <> GDB_ST.OFF) + CurrNod.SetHidden(nMode <> GDB_MD.STD) End If Dim nObjs As Integer = EgtGetGroupObjs(nGroupId) @@ -668,8 +677,8 @@ Public Class ManageLayerExpanderVM Dim nType As Integer = EgtGetType(nId) 'se gruppo If nType = GDB_TY.GROUP Then - AddGroupInObjTree(nId, nLevel, nDepth + 1, CurrNodColl) - 'se oggetto geometrico + AddGroupInObjTree(nId, nLevel, nMode, nDepth + 1, CurrNodColl) + 'se oggetto geometrico ElseIf nType >= GDB_TY.GEO_VECTOR Then Dim sTitle As String = String.Empty EgtGetTitle(nId, sTitle) @@ -688,6 +697,9 @@ Public Class ManageLayerExpanderVM Dim nStat As Integer = GDB_ST.ON_ EgtGetStatus(nId, nStat) CurrNod.OnOff = (nStat <> GDB_ST.OFF) + Dim nObjMode As Integer = GDB_MD.STD + EgtGetMode(nId, nObjMode) + CurrNod.SetHidden(nObjMode <> GDB_MD.STD) End If 'passo al successivo nId = EgtGetNext(nId) diff --git a/TopCommandBar/TopCommandBarVM.vb b/TopCommandBar/TopCommandBarVM.vb index f7fcb88..8c9f72e 100644 --- a/TopCommandBar/TopCommandBarVM.vb +++ b/TopCommandBar/TopCommandBarVM.vb @@ -93,7 +93,7 @@ Public Class TopCommandBarVM #End Region ' ToolTip - Private m_DrawIsChecked As Boolean + Private m_DrawIsChecked As Boolean = False Public Property DrawIsChecked As Boolean Get Return m_DrawIsChecked @@ -101,13 +101,14 @@ Public Class TopCommandBarVM Set(value As Boolean) If value <> m_DrawIsChecked Then m_DrawIsChecked = value - SetDrawMode(value) + ' se non sto uscendo dalle lavorazioni ricarico l'albero delle entità geometriche + SetDrawMode(value, Not m_MachiningIsChecked) OnPropertyChanged("DrawIsChecked") End If End Set End Property - Private m_MachiningIsChecked As Boolean + Private m_MachiningIsChecked As Boolean = False Public Property MachiningIsChecked As Boolean Get Return m_MachiningIsChecked @@ -163,28 +164,78 @@ Public Class TopCommandBarVM Return m_ProjectMode End Function - Private Sub SetDrawMode(value As Boolean) + Private Sub SetDrawMode(value As Boolean, bLoadObjTree As Boolean) If value Then Application.Msn.NotifyColleagues(Application.DRAWMODE_ISCHECKED) EgtResetCurrMachGroup() - EgtZoom(ZM.ALL) - Application.Msn.NotifyColleagues(Application.LOADOBJTREE) + EgtZoom(ZM.ALL, False) + If bLoadObjTree Then Application.Msn.NotifyColleagues(Application.LOADOBJTREE) IniFile.m_ProjectMode = ProjectModeOpt.DRAW End If End Sub Private Sub SetMachiningMode(value As Boolean) If value Then + ' Eventuale esecuzione script prima di inizio Mach + ExecInitMachScript() + ' Inizializzazione gruppo/i di lavoro Dim bAllowEmpty As Boolean = (Keyboard.IsKeyDown(Key.LeftShift) OrElse Keyboard.IsKeyDown(Key.RightShift)) Application.Msn.NotifyColleagues(Application.INITIALIZEMACHGROUPS, bAllowEmpty) + ' Se non riuscito il passaggio al Machining, lancio lo script di uscita + If EgtGetCurrMachGroup() = GDB_ID.NULL Then + ExecExitMachScript() + EgtDraw() + End If Else - ' Deevidenzio l'ultima operazione evidenziata + ' De-evidenzio l'ultima operazione evidenziata Application.Msn.NotifyColleagues(Application.REMOVEMARKFROMLASTOPERATION) ' e deseleziono tutto EgtDeselectAll() + ' Eventuale esecuzione script dopo fine Mach + ExecExitMachScript() + ' Ricarico albero entità geometriche + Application.Msn.NotifyColleagues(Application.LOADOBJTREE) End If End Sub + Private Function ExecInitMachScript() As Boolean + ' Recupero il nome dello script e verifico esista + Dim sInitMachScriptPath As String = "" + If EgtUILib.GetPrivateProfileString(S_MACHINING, K_MACH_INITSCRIPT, "", sInitMachScriptPath, IniFile.m_sCurrMachIniFilePath) = 0 Then Return True + sInitMachScriptPath = IniFile.m_sCurrMachScriptsDirPath & "\" & sInitMachScriptPath + If Not My.Computer.FileSystem.FileExists(sInitMachScriptPath) Then Return True + ' Eseguo lo script + EgtLuaCreateGlobTable("MACH") + If Not EgtLuaExecFile(sInitMachScriptPath) Then + EgtOutLog("Error executing Machining init script " & sInitMachScriptPath) + MessageBox.Show(EgtMsg(MSG_DISPOSITIONERRORS + 3) & " " & sInitMachScriptPath, EgtMsg(MSG_DISPOSITIONERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return False + End If + Dim nErr As Integer = 999 + EgtLuaGetGlobIntVar("MACH.ERR", nErr) + EgtLuaResetGlobVar("MACH") + Return nErr = 0 + End Function + + Private Function ExecExitMachScript() As Boolean + ' Recupero il nome dello script e verifico esista + Dim sExitMachScriptPath As String = "" + If EgtUILib.GetPrivateProfileString(S_MACHINING, K_MACH_EXITSCRIPT, "", sExitMachScriptPath, IniFile.m_sCurrMachIniFilePath) = 0 Then Return True + sExitMachScriptPath = IniFile.m_sCurrMachScriptsDirPath & "\" & sExitMachScriptPath + If Not My.Computer.FileSystem.FileExists(sExitMachScriptPath) Then Return True + ' Eseguo lo script + EgtLuaCreateGlobTable("MACH") + If Not EgtLuaExecFile(sExitMachScriptPath) Then + EgtOutLog("Error executing Machining exit script " & sExitMachScriptPath) + MessageBox.Show(EgtMsg(MSG_DISPOSITIONERRORS + 4) & " " & sExitMachScriptPath, EgtMsg(MSG_DISPOSITIONERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return False + End If + Dim nErr As Integer = 999 + EgtLuaGetGlobIntVar("MACH.ERR", nErr) + EgtLuaResetGlobVar("MACH") + Return nErr = 0 + End Function + #End Region ' Get & Set #Region "CONSTRUCTOR"