Files
icarus/Icarus/ViewLayerManager/ViewLayerManagerVM.vb
T
Emmanuele Sassi 53b515135f - aggiunta visualizzazione layer
- migliorata importazione rib, aux solid e shell number
- aggiunti parametri aux solid e shell number
- correzioni e migliorie
2022-09-20 14:42:09 +02:00

224 lines
9.5 KiB
VB.net

Imports System.Collections.ObjectModel
Imports EgtWPFLib5
Imports EgtUILib
Public Class ViewLayerManagerVM
Private m_LayerList As ObservableCollection(Of ViewLayer)
Public ReadOnly Property LayerList As ObservableCollection(Of ViewLayer)
Get
Return m_LayerList
End Get
End Property
Sub New()
' Creo riferimento a questa classe in EgtCAM5Map
Map.SetRefViewLayerManagerVM(Me)
m_LayerList = New ObservableCollection(Of ViewLayer)({New ViewLayer(ViewLayer.ViewLayerType.PRINT_SOLID, "Print", True),
New ViewLayer(ViewLayer.ViewLayerType.REFERENCE, "Origin Point", True),
New ViewLayer(ViewLayer.ViewLayerType.START_MACHINING, "Layer Start", True),
New ViewLayer(ViewLayer.ViewLayerType.RIBS, "Ribs", True),
New ViewLayer(ViewLayer.ViewLayerType.SHELL_NUMBER, "Reduce Shell Number", True),
New ViewLayer(ViewLayer.ViewLayerType.AUX_SOLIDS, "Filled Solids", True)})
End Sub
Friend Sub UpdateIsVisibleFromIni()
For Each Layer In LayerList
Layer.UpdateIsVisibleFromIni()
Next
EgtDraw()
End Sub
Friend Sub UpdateForced()
For Each Layer In LayerList
Layer.UpdateForced()
Next
EgtDraw()
End Sub
End Class
Public Class ViewLayer
Inherits VMBase
Enum VisibilityType As Integer
OFF = 0
ON_ = 1
FORCED = 2
End Enum
Public Enum ViewLayerType As Integer
PRINT_SOLID = 1
REFERENCE = 2
START_MACHINING = 3
RIBS = 4
SHELL_NUMBER = 5
AUX_SOLIDS = 6
End Enum
Private m_Type As ViewLayerType
Public ReadOnly Property Type As ViewLayerType
Get
Return m_Type
End Get
End Property
Private m_sName As String
Public ReadOnly Property sName As String
Get
Return m_sName
End Get
End Property
Private m_IsVisible As VisibilityType
Public Property bIsVisible As Boolean?
Get
Select Case m_IsVisible
Case VisibilityType.OFF
Return False
Case VisibilityType.ON_
Return True
Case VisibilityType.FORCED
Return Nothing
End Select
End Get
Set(value As Boolean?)
If m_IsVisible = VisibilityType.FORCED Then
NotifyPropertyChanged(NameOf(bIsVisible))
Return
End If
m_IsVisible = If(value, VisibilityType.ON_, VisibilityType.OFF)
'If Not bIsVisible AndAlso ((m_Type = ViewLayerType.REFERENCE AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.REFERENCE) OrElse
' (m_Type = ViewLayerType.START_MACHINING AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.STARTMACH) OrElse
' (m_Type = ViewLayerType.RIBS AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.RIBS) OrElse
' (m_Type = ViewLayerType.SHELL_NUMBER AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.SHELLNUMBER) OrElse
' (m_Type = ViewLayerType.AUX_SOLIDS AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.AUXSOLIDS)) Then
' m_bIsVisible = True
' NotifyPropertyChanged(NameOf(bIsVisible))
'Else
UpdateVisibility(m_IsVisible)
WriteIsVisibleToIni()
EgtDraw()
'End If
End Set
End Property
Sub New(Type As ViewLayerType, sName As String, bIsVisible As Boolean)
m_Type = Type
m_sName = sName
m_IsVisible = bIsVisible
End Sub
Friend Sub UpdateVisibility(bIsVisible As Boolean)
Dim Status As GDB_ST = If(bIsVisible, GDB_ST.ON_, GDB_ST.OFF)
For Each CurrPart In Map.refTopPanelVM.PartList
Select Case m_Type
Case ViewLayerType.PRINT_SOLID
EgtSetStatus(CurrPart.nPrintSolidLayerId, Status)
Case ViewLayerType.REFERENCE
EgtSetStatus(CurrPart.nReferenceId, Status)
Case ViewLayerType.START_MACHINING
EgtSetStatus(CurrPart.nMachStartLayerId, Status)
Case ViewLayerType.RIBS
EgtSetStatus(CurrPart.nRibsLayerId, Status)
Case ViewLayerType.SHELL_NUMBER
EgtSetStatus(CurrPart.nShellNumberLayerId, Status)
Case ViewLayerType.AUX_SOLIDS
EgtSetStatus(CurrPart.nAuxSolidsLayerId, Status)
End Select
Next
End Sub
Friend Sub UpdateForced()
If Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso
((m_Type = ViewLayerType.REFERENCE AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.REFERENCE) OrElse
(m_Type = ViewLayerType.START_MACHINING AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.STARTMACH) OrElse
(m_Type = ViewLayerType.RIBS AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.RIBS) OrElse
(m_Type = ViewLayerType.SHELL_NUMBER AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.SHELLNUMBER) OrElse
(m_Type = ViewLayerType.AUX_SOLIDS AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.AUXSOLIDS)) Then
m_IsVisible = VisibilityType.FORCED
UpdateVisibility(True)
ElseIf m_IsVisible = VisibilityType.FORCED Then
m_IsVisible = VisibilityType.OFF
UpdateVisibility(False)
End If
NotifyPropertyChanged(NameOf(bIsVisible))
End Sub
Friend Sub UpdateIsVisibleFromIni()
If m_IsVisible = VisibilityType.FORCED Then Return
Dim nStatus As Integer = 1
Select Case Map.refTopPanelVM.SelPage
Case Pages.MODIFY, Pages.NULL
Select Case m_Type
Case ViewLayerType.PRINT_SOLID
nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_PRINTSOLID, 1)
Case ViewLayerType.REFERENCE
nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_REFERENCE, 1)
Case ViewLayerType.START_MACHINING
nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_STARTMACHINING, 1)
Case ViewLayerType.RIBS
nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_RIBS, 1)
Case ViewLayerType.SHELL_NUMBER
nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_SHELLNUMBER, 1)
Case ViewLayerType.AUX_SOLIDS
nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_AUXSOLIDS, 1)
End Select
Case Pages.SLICE
Select Case m_Type
Case ViewLayerType.PRINT_SOLID
nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_PRINTSOLID, 1)
Case ViewLayerType.REFERENCE
nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_REFERENCE, 1)
Case ViewLayerType.START_MACHINING
nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_STARTMACHINING, 1)
Case ViewLayerType.RIBS
nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_RIBS, 1)
Case ViewLayerType.SHELL_NUMBER
nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_SHELLNUMBER, 1)
Case ViewLayerType.AUX_SOLIDS
nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_AUXSOLIDS, 1)
End Select
End Select
m_IsVisible = nStatus
UpdateVisibility(m_IsVisible)
NotifyPropertyChanged(NameOf(bIsVisible))
End Sub
Friend Sub WriteIsVisibleToIni()
Dim nStatus As Integer = If(m_IsVisible, 1, 0)
Select Case Map.refTopPanelVM.SelPage
Case Pages.MODIFY
Select Case m_Type
Case ViewLayerType.PRINT_SOLID
WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_PRINTSOLID, nStatus)
Case ViewLayerType.REFERENCE
WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_REFERENCE, nStatus)
Case ViewLayerType.START_MACHINING
WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_STARTMACHINING, nStatus)
Case ViewLayerType.RIBS
WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_RIBS, nStatus)
Case ViewLayerType.SHELL_NUMBER
WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_SHELLNUMBER, nStatus)
Case ViewLayerType.AUX_SOLIDS
WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_AUXSOLIDS, nStatus)
End Select
Case Pages.SLICE
Select Case m_Type
Case ViewLayerType.PRINT_SOLID
WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_PRINTSOLID, nStatus)
Case ViewLayerType.REFERENCE
WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_REFERENCE, nStatus)
Case ViewLayerType.START_MACHINING
WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_STARTMACHINING, nStatus)
Case ViewLayerType.RIBS
WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_RIBS, nStatus)
Case ViewLayerType.SHELL_NUMBER
WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_SHELLNUMBER, nStatus)
Case ViewLayerType.AUX_SOLIDS
WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_AUXSOLIDS, nStatus)
End Select
End Select
End Sub
End Class