diff --git a/3dPrinting.ini b/3dPrinting.ini index b84435a..25e9d21 100644 --- a/3dPrinting.ini +++ b/3dPrinting.ini @@ -8,8 +8,9 @@ Button4=GcodeGenerate.lua,Images\GcodeGenerate.png,Genera codice CN Button5=ShowManager.lua,Images\ShowManager.png,Gestore visualizzazione Button6=ViewManager.lua,Images\ViewManager.png,Nascondi Visualizza strato Button7=SliceAdvancement.lua,Images\SliceAdvancement.png,Mostra avanzamento strato -Button8=MachiningParamEdit.lua,Images\MachiningParamEdit.png,Edita i parametri di stampa -Button9=MaterialParamEdit.lua,Images\MaterialParamEdit.png,Edita i parametri del materiale +Button8=SlicePalette.lua,Images\SlicePalette.png,Gestore colori strato +Button9=MachiningParamEdit.lua,Images\MachiningParamEdit.png,Edita i parametri di stampa +Button10=MaterialParamEdit.lua,Images\MaterialParamEdit.png,Edita i parametri del materiale ParamFile=C:\EgtData\3dPrinting\Machinings\Params.ini ResultReadProg="C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE" MachiningEditProg="C:\Windows\System32\notepad.exe" \ No newline at end of file diff --git a/Images/MachiningParamCalc.png b/Images/MachiningParamCalc.png index d94842b..ffe23a7 100644 Binary files a/Images/MachiningParamCalc.png and b/Images/MachiningParamCalc.png differ diff --git a/Images/MaterialParamEdit.png b/Images/MaterialParamEdit.png index f65d28c..eef5977 100644 Binary files a/Images/MaterialParamEdit.png and b/Images/MaterialParamEdit.png differ diff --git a/Images/SlicePalette.png b/Images/SlicePalette.png new file mode 100644 index 0000000..0918ad5 Binary files /dev/null and b/Images/SlicePalette.png differ diff --git a/LuaLibs/AddManData.lua b/LuaLibs/AddManData.lua index 8c57b40..320ca23 100644 --- a/LuaLibs/AddManData.lua +++ b/LuaLibs/AddManData.lua @@ -90,5 +90,18 @@ VIEWPARAMS = 'ViewParams' IMPORTED_SOLID = 'ImportedSolid' RESULT_READ_PROG = 'ResultReadProg' +KEY_RESULT = 'Result' +KEY_PALETTE = 'Palette' + +RESULT = { + OK = 0, + KO_MINUS = 1, + KO_PLUS = 2, +} + +PALETTE_TYPE = { + IN_OUT = 0, + RESULTS = 1, +} --------------------------------------------------------------------- return AddManData diff --git a/LuaLibs/RunMachiningParamCalc.lua b/LuaLibs/RunMachiningParamCalc.lua index eb0cdee..3958e6e 100644 --- a/LuaLibs/RunMachiningParamCalc.lua +++ b/LuaLibs/RunMachiningParamCalc.lua @@ -127,13 +127,16 @@ function RunMachiningParamCalc.Exec() EgtSetInfo( nToolPathId, KEY_SPEED, dSpeed) nCrvId = EgtGetNext( nCrvId) end - -- riporto valori calcolati in tabella per csv + -- salvo e riporto valori calcolati in tabella per csv local sStatus = '' if dEsteemedTime < dMinTime then + EgtSetInfo( nLayerId, KEY_RESULT, RESULT.KO_MINUS) sStatus = 'KO(-)' elseif dEsteemedTime > dMinTime and dEsteemedTime < dMaxTime then + EgtSetInfo( nLayerId, KEY_RESULT, RESULT.OK) sStatus = 'OK' elseif dEsteemedTime > dMaxTime then + EgtSetInfo( nLayerId, KEY_RESULT, RESULT.KO_PLUS) sStatus = 'KO(+)' end --table.insert( CSVOutTable, { Index = nLayerIndex, EsteemedTime = dEsteemedTime, Feed = dLayerFeed, Speed = dSpeed}) @@ -144,7 +147,13 @@ function RunMachiningParamCalc.Exec() nPartIndex = nPartIndex + 1 nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex) end - + + -- aggiorno palette + local nPaletteType = EgtGetInfo( nParamsGrp, KEY_PALETTE, 'i') + if nPaletteType == PALETTE_TYPE.RESULTS then + local RSP = require( 'RunSlicePalette') + RSP.UpdateColors( nPaletteType) + end -- scrivo nuovo file csv di risultato local file = io.open( sResultFile, "w") if file then diff --git a/LuaLibs/RunSlicePalette.lua b/LuaLibs/RunSlicePalette.lua new file mode 100644 index 0000000..35fbd73 --- /dev/null +++ b/LuaLibs/RunSlicePalette.lua @@ -0,0 +1,89 @@ +-- RunSlicePalette.lua by Egaltech s.r.l. 2022/04/05 +-- Gestione visualizzazione per Stampa 3d + +-- Tabella per definizione modulo +local RunSlicePalette = {} + +-- Intestazioni +require( 'EgtBase') + +EgtOutLog( ' RunSlicePalette started', 1) + +-- Costanti generali +local AMD = require( 'AddManData') + +function RunSlicePalette.UpdateColors( nPaletteType) + -- ciclo sui pezzi + local nPartIndex = 1 + local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex) + while nPartId do + -- ciclo sui layer per dis/attivare il resto + local nLayerIndex = 1 + local nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex) + while nLayerId do + local nCrvId = EgtGetFirstGroupInGroup( nLayerId) + while nCrvId do + local nSolidId = EgtGetFirstNameInGroup( nCrvId, SOLID_GRP) + local nSurfId = EgtGetFirstInGroup( nSolidId) + local nOldType = 0 + while nSurfId do + local Color = EgtStdColor( 'GRAY') + if nPaletteType == PALETTE_TYPE.IN_OUT then + local nType = EgtGetInfo( nSurfId, KEY_TYPE, 'i') + if not nType or ( nType ~= 0 and nType ~= 1) then nType = nOldType end + nOldType = nType + -- scelta del colore + if nType == TYPE.OUTER_SHELL then + Color = EgtStdColor( 'ORANGE') + elseif nType == TYPE.INNER_SHELL or nType == TYPE.LINK then + Color = EgtStdColor( 'TEAL') + elseif nType == TYPE.INFILL then + Color = EgtStdColor( 'YELLOW') + end + else + local nResult = EgtGetInfo( nLayerId, KEY_RESULT, 'i') + if nResult == RESULT.OK then + Color = EgtStdColor( 'GREEN') + elseif nResult == RESULT.KO_MINUS then + Color = EgtStdColor( 'ORANGE') + elseif nResult == RESULT.KO_PLUS then + Color = EgtStdColor( 'RED') + end + end + EgtSetColor( nSurfId, Color) + nSurfId = EgtGetNext( nSurfId) + end + nCrvId = EgtGetNext( nCrvId) + end + nLayerIndex = nLayerIndex + 1 + nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex) + end + nPartIndex = nPartIndex + 1 + nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex) + end + + EgtDraw() + +end + +function RunSlicePalette.Exec() + + local nParamsGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, PARAMS_GRP) or GDB_ID.NULL + local nOldPaletteType = EgtGetInfo( nParamsGrp, KEY_PALETTE, 'i') + local sCombo = EgtIf( not nOldPaletteType or nOldPaletteType == 0, 'CB:*In/Out,Results', 'CB:In/Out,*Results') + ViewValues = EgtDialogBox( 'Slice Palette', { 'Type', sCombo}) + if not ViewValues or #ViewValues < 1 then return end + + local nPaletteType = PALETTE_TYPE.IN_OUT -- 1 = In/Out, 2 = Results + if ViewValues[1] == 'In/Out' then + nPaletteType = PALETTE_TYPE.IN_OUT + elseif ViewValues[1] == 'Results' then + nPaletteType = PALETTE_TYPE.RESULTS + end + EgtSetInfo( nParamsGrp, KEY_PALETTE, nPaletteType) + + RunSlicePalette.UpdateColors( nPaletteType) +end + +--------------------------------------------------------------------- +return RunSlicePalette diff --git a/SlicePalette.lua b/SlicePalette.lua new file mode 100644 index 0000000..e47e78f --- /dev/null +++ b/SlicePalette.lua @@ -0,0 +1,18 @@ +-- SlicePalette.lua by Egaltech s.r.l. 2022/04/05 +-- Gestione visualizzazione per Stampa 3d + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +-- Imposto direttorio libreria specializzata per Stampa 3d +local sBaseDir = EgtGetSourceDir() +EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') + +-- Librerie +_G.package.loaded.RunSlicePalette = nil +local RSP = require( 'RunSlicePalette') + +-- Calcolo +RSP.Exec()