Files
3dprinting/LuaLibs/RunSlicePalette.lua
T
DarioS 1459253e57 3dPrinting :
- modifiche e correzioni per Costolature (Setti -> Ribs).
2022-07-03 19:04:07 +02:00

101 lines
3.8 KiB
Lua

-- 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 < TYPE.OUTER_SHELL or nType > TYPE.RIB then nType = nOldType end
nOldType = nType
-- scelta del colore
if nType == TYPE.OUTER_SHELL then
Color = EgtStdColor( 'TEAL')
elseif nType == TYPE.INNER_SHELL then
Color = EgtStdColor( 'ORANGE')
elseif nType == TYPE.INFILL then
Color = EgtStdColor( 'YELLOW')
elseif nType == TYPE.LINK then
Color = EgtStdColor( 'GRAY')
elseif nType == TYPE.COASTING then
Color = EgtStdColor( 'BLUE')
elseif nType == TYPE.WIPE then
Color = EgtStdColor( 'LIME')
elseif nType == TYPE.RIB then
Color = EgtStdColor( 'OLIVE')
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 nViewId = EgtGetFirstNameInGroup( GDB_ID.ROOT, VIEWPARAMS) or GDB_ID.NULL
local nOldPaletteType = EgtGetInfo( nViewId, KEY_PALETTE, 'i')
local sCombo = EgtIf( not nOldPaletteType or nOldPaletteType == 1, '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( nViewId, KEY_PALETTE, nPaletteType)
RunSlicePalette.UpdateColors( nPaletteType)
end
---------------------------------------------------------------------
return RunSlicePalette