Files
egtbeamwall/EgtBEAMWALL.ViewerOptimizer/OptimizePanel/OptimizePanelVM.vb
T
Emmanuele Sassi 28ca22ee35 - Correzione aggiornamento messaggio errore dopo CALC
- Aggiunta opzione abilitadisabilita area pnte lunghe in nesting
2021-12-02 11:43:54 +01:00

291 lines
9.5 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.Threading
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5
Public Class OptimizePanelVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Friend m_bNestingRunning As Boolean = False
Friend m_StopNesting As Boolean = False
Public Enum PartType As Integer
MATERIAL = 0
ALL = 1
End Enum
Friend Enum OriginType As Integer
STANDARD = 0
FROM_BTL = 1
End Enum
Private m_PartTypeList As New List(Of IdNameStruct)({New IdNameStruct(PartType.MATERIAL, "Materiale"),
New IdNameStruct(PartType.ALL, "Tutti")})
Public ReadOnly Property PartTypeList As List(Of IdNameStruct)
Get
Return m_PartTypeList
End Get
End Property
Private m_SelPartType As IdNameStruct
Public Property SelPartType As IdNameStruct
Get
Return m_SelPartType
End Get
Set(value As IdNameStruct)
m_SelPartType = value
End Set
End Property
Private m_OriginTypeList As New List(Of IdNameStruct)({New IdNameStruct(OriginType.STANDARD, "Standard"),
New IdNameStruct(OriginType.FROM_BTL, "Da BTL")})
Public ReadOnly Property OriginTypeList As List(Of IdNameStruct)
Get
Return m_OriginTypeList
End Get
End Property
Private m_SelOriginType As IdNameStruct
Public Property SelOriginType As IdNameStruct
Get
Return m_SelOriginType
End Get
Set(value As IdNameStruct)
m_SelOriginType = value
End Set
End Property
Private m_bLDIntersOther As Boolean
Public Property bLDIntersOther As Boolean
Get
Return m_bLDIntersOther
End Get
Set(value As Boolean)
m_bLDIntersOther = value
End Set
End Property
Private m_Optimize_IsEnabled As Boolean = True
Public ReadOnly Property Optimize_IsEnabled As Boolean
Get
Return m_Optimize_IsEnabled
End Get
End Property
Private m_CalcDisp_IsEnabled As Boolean = True
Public ReadOnly Property CalcDisp_IsEnabled As Boolean
Get
Return m_CalcDisp_IsEnabled
End Get
End Property
Public ReadOnly Property ViewPage_Visibility As Visibility
Get
Return If(Map.refMainMenuVM.SelPage = Pages.VIEW, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Public ReadOnly Property MachiningPage_Visibility As Visibility
Get
Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
#Region "Messages"
Public ReadOnly Property Optimize_Msg As String
Get
Return EgtMsg(61833)
End Get
End Property
Public ReadOnly Property Warehouse_ToolTip As String
Get
Return EgtMsg(61920)
End Get
End Property
#End Region ' Messages
' Definizione comandi
Private m_cmdOptimize As ICommand
Private m_cmdCalcRotFlip As ICommand
Private m_cmdWarehouse As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Sub New()
' aggiungo riferimento a Map
Map.SetRefOptimizePanelVM(Me)
m_SelPartType = PartTypeList(0)
m_SelOriginType = OriginTypeList(0)
m_bLDIntersOther = False
NotifyPropertyChanged(NameOf(SelPartType))
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Friend Sub SetOptimizePanelIsEnabled(bIsEnabled As Boolean)
' se pareti e senza opzione nesting, lascio disabilitato
If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Not Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO) Then
m_Optimize_IsEnabled = False
m_CalcDisp_IsEnabled = False
Else
m_Optimize_IsEnabled = bIsEnabled
m_CalcDisp_IsEnabled = bIsEnabled
End If
NotifyPropertyChanged(NameOf(Optimize_IsEnabled))
End Sub
Friend Function ProcessEvents(ByVal nProg As Integer, ByVal nPause As Integer) As Integer
If nProg > 0 And nProg <= 100 Then
NestingRunningWndVM.m_CurrState = SectionProgress.NestStates.NEST
NestingRunningWndVM.m_CurrTime = nProg
ElseIf nProg > 100 And nProg <= 200 Then
NestingRunningWndVM.m_CurrState = SectionProgress.NestStates.ADDPART
NestingRunningWndVM.m_CurrTime = nProg - 100
ElseIf nProg > 200 And nProg <= 300 Then
NestingRunningWndVM.m_CurrState = SectionProgress.NestStates.CALCRAWPART
NestingRunningWndVM.m_CurrTime = nProg - 200
End If
' Costringo ad aggiornare
UpdateUI()
' Eventuale attesa
Thread.Sleep(nPause)
' Ritorno eventuale stop
If m_StopNesting Then
m_StopNesting = False
Return 1
Else
Return 0
End If
End Function
#End Region ' METHODS
#Region "COMMANDS"
#Region "CalcRotFlip"
''' <summary>
''' Returns a command that do Open.
''' </summary>
Public ReadOnly Property CalcRotFlip_Command As ICommand
Get
If m_cmdCalcRotFlip Is Nothing Then
m_cmdCalcRotFlip = New Command(AddressOf CalcRotFlip)
End If
Return m_cmdCalcRotFlip
End Get
End Property
''' <summary>
''' Execute the Open. This method is invoked by the OpenCommand.
''' </summary>
Friend Sub CalcRotFlip()
If IsNothing(Map.refProjectVM.BTLStructureVM) OrElse IsNothing(Map.refProjectVM.BTLStructureVM.BTLPartVMList) OrElse Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count = 0 Then Return
' apro finestra di attesa nesting
m_bNestingRunning = True
Dim NestingRunningWndVM As New NestingRunningWndVM(NestingRunningWndVM.OperationTypes.ROTFLIP, m_SelPartType.Id)
Dim NestingRunningWnd As New NestingRunningWndV(Application.Current.MainWindow, NestingRunningWndVM)
NestingRunningWnd.ShowDialog()
m_bNestingRunning = False
'' mostro risultati
'Dim sResult As String = ""
'For Each Section In NestingRunningWndVM.SectionProgressList
' If Section.SParamList.Count = 0 Then
' sResult &= Section.Section.sSectionXMaterial & ": no raw part found in the warehouse!" & Environment.NewLine
' End If
' For Each Part In Section.SectionPartList
' If Part.nINPROD <> Part.nCNT + Part.nADDED Then
' sResult &= Section.Section.sSectionXMaterial & " - " & Part.nPDN & ": partially nested!" & "(" & Part.nINPROD & "/" & Part.nCNT + Part.nADDED & ")" & Environment.NewLine
' End If
' Next
'Next
'If Not String.IsNullOrWhiteSpace(sResult) Then
' MessageBox.Show(Application.Current.MainWindow, sResult, "", MessageBoxButton.OK, MessageBoxImage.Warning)
'End If
End Sub
#End Region ' CalcRotFlip
#Region "Optimize"
''' <summary>
''' Returns a command that do Open.
''' </summary>
Public ReadOnly Property Optimize_Command As ICommand
Get
If m_cmdOptimize Is Nothing Then
m_cmdOptimize = New Command(AddressOf Optimize)
End If
Return m_cmdOptimize
End Get
End Property
''' <summary>
''' Execute the Open. This method is invoked by the OpenCommand.
''' </summary>
Friend Sub Optimize()
If IsNothing(m_SelPartType) OrElse IsNothing(m_SelOriginType) Then Return
If IsNothing(Map.refProjectVM.BTLStructureVM) OrElse IsNothing(Map.refProjectVM.BTLStructureVM.BTLPartVMList) OrElse Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count = 0 Then Return
' apro finestra di attesa nesting
m_bNestingRunning = True
Dim NestingRunningWndVM As New NestingRunningWndVM(NestingRunningWndVM.OperationTypes.NESTING, m_SelPartType.Id, m_bLDIntersOther)
Dim NestingRunningWnd As New NestingRunningWndV(Application.Current.MainWindow, NestingRunningWndVM)
NestingRunningWnd.ShowDialog()
m_bNestingRunning = False
' mostro risultati
Dim sResult As String = ""
For Each Section In NestingRunningWndVM.SectionProgressList
If Section.SParamList.Count = 0 Then
sResult &= Section.Section.sSectionXMaterial & ": no raw part found in the warehouse!" & Environment.NewLine
End If
For Each Part In Section.SectionPartList
If Part.nINPROD <> Part.nCNT + Part.nADDED Then
sResult &= Section.Section.sSectionXMaterial & " - " & Part.nPDN & ": partially nested!" & "(" & Part.nINPROD & "/" & Part.nCNT + Part.nADDED & ")" & Environment.NewLine
End If
Next
Next
If Not String.IsNullOrWhiteSpace(sResult) Then
MessageBox.Show(Application.Current.MainWindow, sResult, "", MessageBoxButton.OK, MessageBoxImage.Warning)
End If
End Sub
#End Region ' Optimize
#Region "Warehouse"
''' <summary>
''' Returns a command that do Open.
''' </summary>
Public ReadOnly Property Warehouse_Command As ICommand
Get
If m_cmdWarehouse Is Nothing Then
m_cmdWarehouse = New Command(AddressOf Warehouse)
End If
Return m_cmdWarehouse
End Get
End Property
''' <summary>
''' Execute the Open. This method is invoked by the OpenCommand.
''' </summary>
Friend Sub Warehouse()
If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then 'If Not IsNothing(Map.refProdManagerVM.CurrProd) Then
Dim WarehouseWnd As New WarehouseWndV(Application.Current.MainWindow, New WarehouseWndVM())
WarehouseWnd.ShowDialog()
End If
End Sub
#End Region ' Warehouse
#End Region ' COMMANDS
End Class