Files
egtbeamwall/EgtBEAMWALL.Optimizer/BTLViewModel/BTLStructureVM.vb
T
Demetrio Cassarino 647614e67e Optimizer 2.7.10.2
-Eliminato classi e pagine nascoste
-Rinominato pagine e classi
2025-10-27 09:15:16 +01:00

1884 lines
78 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.Collections.Specialized
Imports System.ComponentModel
Imports System.IO
Imports System.Web.UI.WebControls.WebParts
Imports System.Windows.Threading
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5
Public Class BTLStructureVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
' Nome file NGE con i pezzi selezionati per effettuare UpdateBTL
Friend Const UPDATEBTL_NGE As String = "UpdateBTL.nge"
Friend Enum SelectionTypes As Integer
NULL = 0
SELECT_ = 1
HIGHLIGHT = 2
End Enum
Private m_Calc_PartEnd As New DispatcherTimer
Private WithEvents m_BTLStructureM As BTLStructureM
Public ReadOnly Property BTLStructureM As BTLStructureM
Get
Return m_BTLStructureM
End Get
End Property
' pezzi da BTL
Private m_BTLPartVMList_View As CollectionView = Nothing
Public ReadOnly Property BTLPartVMList_View As CollectionView
Get
Return m_BTLPartVMList_View
End Get
End Property
Private m_BTLPartVMList As ObservableCollection(Of BTLPartVM)
Public Property BTLPartVMList As ObservableCollection(Of BTLPartVM)
Get
Return m_BTLPartVMList
End Get
Set(value As ObservableCollection(Of BTLPartVM))
m_BTLPartVMList = value
End Set
End Property
Private m_bOnlySelectItem As Boolean = False
Public Property bOnlySelectItem As Boolean
Get
Return m_bOnlySelectItem
End Get
Set(value As Boolean)
m_bOnlySelectItem = value
End Set
End Property
'Private m_PrevSelectionType As SelectionTypes = SelectionTypes.NULL
'Friend ReadOnly Property PrevSelectionType As SelectionTypes
' Get
' Return m_PrevSelectionType
' End Get
'End Property
'Private m_SelectionType As SelectionTypes = SelectionTypes.NULL
'Friend ReadOnly Property SelectionType As SelectionTypes
' Get
' Return m_SelectionType
' End Get
'End Property
'Friend Sub SetSelectionType(value As SelectionTypes)
' If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then
' ' resetto gruppo di lavorazione corrente
' EgtResetCurrMachGroup()
' End If
' If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then
' ' rimuovo selezione da pezzo in MachGroup
' If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) AndAlso Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup) Then
' If Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart) Then
' Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart = Nothing
' End If
' End If
' End If
' m_PrevSelectionType = m_SelectionType
' If value = m_SelectionType And (Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART Or Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST) Then
' For Each BTLPart In m_BTLPartVMList
' BTLPart.SetOpenFeatureList(False)
' Next
' Return
' End If
' m_SelectionType = value
' Select Case m_SelectionType
' Case SelectionTypes.SELECT_
' ' verifico reset mark su tutti i pezzi
' For Each BTLPart In m_BTLPartVMList
' EgtResetMark(BTLPart.nPartId)
' Next
' Case SelectionTypes.HIGHLIGHT
' If m_PrevSelectionType = SelectionTypes.SELECT_ Then
' EgtBeamShowFacesName(False)
' EgtBeamShowLoadingSide(False, False)
' End If
' If Not IsNothing(m_SelBTLPart) Then
' m_SelBTLPart = Nothing
' NotifyPropertyChanged(NameOf(SelBTLPart))
' End If
' ' mostro pezzi selezionati
' Map.refProjectVM.BTLStructureVM.ShowAll(False)
' ' se attivata opzione, li assemblo
' 'Map.refProjectVM.BTLStructureVM.ShowBuilding(If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Map.refShowBeamPanelVM.ShowBuilding_IsChecked, False), False)
' End Select
' ' aggiornamento grafica
' If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.PartShowAllChanged()
' If Not IsNothing(Map.refBTLPartManagerVM) Then Map.refBTLPartManagerVM.PartShowAllChanged()
' If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.FeatureSelectionChanged()
'End Sub
Private m_SelBTLParts As New PartsObservableCollection(Of BTLPartVM)
Public ReadOnly Property SelBTLParts As PartsObservableCollection(Of BTLPartVM)
Get
Return m_SelBTLParts
End Get
End Property
Private Sub SelBTLParts_CollectionChanged(sender As Object, e As NotifyCollectionChangedEventArgs)
' Setto contesto finestra principale
If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then EgtSetCurrentContext(Map.refSceneHostVM.MainScene.GetCtx())
If m_bOnlySelectItem Then Return
Select Case e.Action
Case NotifyCollectionChangedAction.Add
If e.NewItems.Count > 0 AndAlso Not IsNothing(e.NewItems(0)) Then
SelectBTLPart(e.NewItems(0))
End If
Case NotifyCollectionChangedAction.Remove
If e.OldItems.Count > 0 AndAlso Not IsNothing(e.OldItems(0)) Then
DeselectBTLPart(e.OldItems(0))
End If
Case NotifyCollectionChangedAction.Reset
If Not IsNothing(m_SelBTLPart) Then
DeselectBTLPart(m_SelBTLPart)
End If
End Select
' gestione pulsanti ruota, inverti tutti e modifica multipla
If m_SelBTLParts.Count > 1 Then
Map.refLeftPanelVM.SetRotateAll_IsEnabled(True)
Else
Map.refLeftPanelVM.SetRotateAll_IsEnabled(False)
End If
' aggiornamento grafica
If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.PartShowAllChanged()
If Not IsNothing(Map.refBTLPartManagerVM) Then Map.refBTLPartManagerVM.PartShowAllChanged()
End Sub
Public Sub SelectBTLPart(BtlPart As BTLPartVM, Optional bIsReselect As Boolean = False)
m_SelBTLPart = BtlPart
If Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then
' resetto gruppo di lavorazione corrente
EgtResetCurrMachGroup()
End If
If Not IsNothing(BtlPart) Then
' gestisco selezione pezzo
EgtBeamShowFacesName(False)
EgtBeamShowLoadingSide(False, False)
Map.refProjectVM.MacroFeature_IsEnabled = True
' se modalità building, la tolgo
If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then
ShowBuilding(False, False)
Map.refShowBeamPanelVM.SetShowBuilding(False)
Map.refProjectVM.SetSceneShowBuldingVisibility(Visibility.Collapsed)
Map.refProjectVM.SetManagerTabVisibility(Visibility.Visible)
If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then Map.refProjectVM.SetFeatureListVisibility(Visibility.Visible)
End If
SceneSelPartSelection()
' seleziono pezzo in Db geometrico
EgtBeamSetPart(BtlPart.nPartId)
EgtBeamShowFacesName(True)
Dim bLoadingSideShow As Boolean = (nPROJTYPE = BWType.BEAM)
Dim bLeftToRight As Boolean = Not (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE)
EgtBeamShowLoadingSide(bLoadingSideShow, bLeftToRight)
' imposto tipo di grid selezionata
Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.PART)
' trovo ed evidenzio MachGroup e Duplo di questo pezzo
If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then
Dim MachGroupList As New List(Of MyMachGroupVM)
For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList
Dim bFound As Boolean = False
For Each Part As PartVM In Machgroup.PartVMList
If EgtDuploGetOriginal(Part.nPartId) = BtlPart.nPartId Then
Part.SetSearchFound()
bFound = True
Else
Part.ResetSearchFound()
End If
Next
If bFound Then
Machgroup.SetSearchFound()
Else
Machgroup.ResetSearchFound()
End If
Next
End If
End If
' seleziono la prima feature
If Not IsNothing(BtlPart) AndAlso Not IsNothing(BtlPart.BTLFeatureVMList) AndAlso BtlPart.BTLFeatureVMList.Count > 0 Then SelBTLPart.SelBTLFeatureVM = BtlPart.BTLFeatureVMList(0)
' aggiorno stato selezionato tutto
Map.refShowBeamPanelVM.bShowAll = False
Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False)
EgtZoom(ZM.ALL)
NotifyPropertyChanged(NameOf(SelBTLPart))
If Not bIsReselect AndAlso m_SelBTLParts.Count = 1 Then
BtlPart.SetOpenFeatureList(True)
End If
End Sub
Private Sub DeselectBTLPart(BtlPart As BTLPartVM)
' se necessario tolgo solido dal precedentemente selezionato
Configuration.DeselectSolid(BtlPart.nPartId, True)
If m_SelBTLPart Is BtlPart Then
EgtBeamShowFacesName(False)
EgtBeamShowLoadingSide(False, False)
m_SelBTLPart = Nothing
NotifyPropertyChanged(NameOf(SelBTLPart))
End If
' disabilito eventuale feature selezionata
If Not IsNothing(BtlPart.m_SelBTLFeatureVM) Then
BtlPart.SelBTLFeatureVM = Nothing
End If
EgtDraw()
If m_SelBTLParts.Count = 1 Then
m_SelBTLParts(0).SetOpenFeatureList(True)
End If
If BtlPart.bOpenFeatureList Then
BtlPart.SetOpenFeatureList(False)
End If
End Sub
Private m_SelBTLPart As BTLPartVM = Nothing
Public ReadOnly Property SelBTLPart As BTLPartVM
Get
Return m_SelBTLPart
End Get
End Property
Friend Sub SetSelBTLPart(SelBTLPart As BTLPartVM, Optional bByOptim As Boolean = False, Optional bSingleHighlight As Boolean = False)
If bByOptim Then
' annullo evidenziazione MachGroup e Duplo
If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then
For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList
For Each Part As PartVM In Machgroup.PartVMList
Part.ResetSearchFound()
Next
Machgroup.ResetSearchFound()
Next
End If
End If
If bByOptim Then
m_bOnlySelectItem = True
End If
If bByOptim Or bSingleHighlight Then
If SelBTLParts.Contains(SelBTLPart) Then
For Each Part In SelBTLParts.ToList()
If Part IsNot SelBTLPart Then SelBTLParts.Remove(Part)
Next
Else
SelBTLParts.Clear()
End If
End If
If Not IsNothing(SelBTLPart) Then SelBTLParts.AddToList(SelBTLPart)
If bByOptim Then
m_bOnlySelectItem = False
End If
End Sub
' lista parametri per ricerca testuale
Private m_SearchParamList As New ObservableCollection(Of IdNameStruct)({New IdNameStruct(BTLPartParam.NULL, ""),
New IdNameStruct(BTLPartParam.PDN, EgtMsg(61809)),
New IdNameStruct(BTLPartParam.NAM, EgtMsg(61603))})
Public ReadOnly Property SearchParamList As ObservableCollection(Of IdNameStruct)
Get
Return m_SearchParamList
End Get
End Property
Private m_SelSearchParam As IdNameStruct = m_SearchParamList(0)
Public Property SelSearchParam As IdNameStruct
Get
Return m_SelSearchParam
End Get
Set(value As IdNameStruct)
' resetto il contenuto della barra di ricerca testuale e refresho la lista dei Part (in modo da averli visibili tutti)
SearchText = ""
NotifyPropertyChanged(NameOf(SearchText))
' ora setto il valore scelto come Parameter Type
m_SelSearchParam = value
End Set
End Property
' lista dei gruppi
Private m_GroupList_View As CollectionView = Nothing
Private m_GroupList As New ObservableCollection(Of String)({""})
Public Property GroupList As ObservableCollection(Of String)
Get
Return m_GroupList
End Get
Set(value As ObservableCollection(Of String))
m_GroupList = value
End Set
End Property
Private m_SelGroup As String = ""
Public Property SelGroup As String
Get
Return m_SelGroup
End Get
Set(value As String)
m_SelGroup = value
m_BTLPartVMList_View.Refresh()
m_SectionList_View.Refresh()
m_SubGroupList_View.Refresh()
End Set
End Property
' lista dei SubGroup
Private m_SubGroupList_View As CollectionView = Nothing
Private m_SubGroupList As New ObservableCollection(Of String)({""})
Public Property SubGroupList As ObservableCollection(Of String)
Get
Return m_SubGroupList
End Get
Set(value As ObservableCollection(Of String))
m_SubGroupList = value
End Set
End Property
Private m_SelSubGroup As String = ""
Public Property SelSubGroup As String
Get
Return m_SelSubGroup
End Get
Set(value As String)
m_SelSubGroup = value
m_BTLPartVMList_View.Refresh()
m_SectionList_View.Refresh()
m_GroupList_View.Refresh()
End Set
End Property
' lista delle sezioni utilizzate
Private m_SectionList_View As CollectionView = Nothing
Private m_SectionList As New ObservableCollection(Of SectionXMaterial)({SectionXMaterial.Empty})
Public Property SectionList As ObservableCollection(Of SectionXMaterial)
Get
Return m_SectionList
End Get
Set(value As ObservableCollection(Of SectionXMaterial))
m_SectionList = value
End Set
End Property
Private m_SelSection As SectionXMaterial = SectionXMaterial.Empty
Public Property SelSection As SectionXMaterial
Get
Return m_SelSection
End Get
Set(value As SectionXMaterial)
If Not IsNothing(value) Then
m_SelSection = value
m_BTLPartVMList_View.Refresh()
m_GroupList_View.Refresh()
m_SubGroupList_View.Refresh()
End If
End Set
End Property
Friend Sub SetSelSection(value As SectionXMaterial)
If Not IsNothing(value) Then
m_SelSection = value
m_BTLPartVMList_View.Refresh()
m_GroupList_View.Refresh()
m_SubGroupList_View.Refresh()
End If
NotifyPropertyChanged(NameOf(SelSection))
End Sub
Private m_SearchText As String = ""
Public Property SearchText As String
Get
Return m_SearchText
End Get
Set(value As String)
m_SearchText = value
m_BTLPartVMList_View.Refresh()
m_GroupList_View.Refresh()
m_SectionList_View.Refresh()
End Set
End Property
Public Property bDOALL As Boolean?
Get
If BTLPartVMList.Count = 0 Then Return False
Dim bTemp As Boolean = BTLPartVMList(0).bDO
For FeatureIndex = 1 To BTLPartVMList.Count - 1
If BTLPartVMList(FeatureIndex).bDO <> bTemp Then Return Nothing
Next
Return bTemp
End Get
Set(value As Boolean?)
If BTLPartVMList.Count = 0 Then
NotifyPropertyChanged(NameOf(bDOALL))
Return
End If
For PartIndex = 0 To BTLPartVMList.Count - 1
Dim Part As BTLPartVM = BTLPartVMList(PartIndex)
If (IsNothing(m_SelSection) OrElse m_SelSection.dH = -1 OrElse Part.Section = m_SelSection) AndAlso
(SelGroup = "" OrElse Part.sGROUP = SelGroup) AndAlso
(SelSubGroup = "" OrElse Part.sSTOREY = SelSubGroup) AndAlso
(SelSearchParam.Id = BTLPartParam.NULL OrElse SearchText = String.Empty OrElse (
(SelSearchParam.Id = BTLPartParam.PDN AndAlso Part.nPDN.ToString.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0) OrElse
(SelSearchParam.Id = BTLPartParam.NAM AndAlso Part.sNAM.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0))) Then
Part.bDO = value
Part.NotifyPropertyChanged(NameOf(Part.bDO))
End If
Next
End Set
End Property
#Region "Parametri generici"
Public Property sPROJNUM As String
Get
Return m_BTLStructureM.m_sPROJNUM
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_PROJNUM, value) Then
m_BTLStructureM.m_sPROJNUM = value
Else
NotifyPropertyChanged(NameOf(sPROJNUM))
End If
End Set
End Property
Public Property sPROJNAME As String
Get
Return m_BTLStructureM.m_sPROJNAME
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_PROJNAME, value) Then
m_BTLStructureM.m_sPROJNAME = value
Else
NotifyPropertyChanged(NameOf(sPROJNAME))
End If
End Set
End Property
Public Property sPROJPART As String
Get
Return m_BTLStructureM.m_sPROJPART
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_PROJPART, value) Then
m_BTLStructureM.m_sPROJPART = value
Else
NotifyPropertyChanged(NameOf(sPROJPART))
End If
End Set
End Property
Public Property sPROJGUID As String
Get
Return m_BTLStructureM.m_sPROJGUID
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_PROJGUID, value) Then
m_BTLStructureM.m_sPROJGUID = value
Else
NotifyPropertyChanged(NameOf(sPROJGUID))
End If
End Set
End Property
Public ReadOnly Property nPROJTYPE As BWType
Get
Select Case Map.refMainMenuVM.SelPage
Case Pages.ONLYPRODPAGE
Return Map.refProdManagerVM.nProdType
Case Else
Return BWType.NULL
End Select
End Get
End Property
Public Property sLISTNAME As String
Get
Return m_BTLStructureM.m_sLISTNAME
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_LISTNAME, value) Then
DbControllers.m_ProjController.UpdateListName(ProjectManagerVM.CurrProj.nProjId, value)
m_BTLStructureM.m_sLISTNAME = value
Else
NotifyPropertyChanged(NameOf(sLISTNAME))
End If
End Set
End Property
Public Property sCUSTOMER As String
Get
Return m_BTLStructureM.m_sCUSTOMER
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_CUSTOMER, value) Then
m_BTLStructureM.m_sCUSTOMER = value
Else
NotifyPropertyChanged(NameOf(sCUSTOMER))
End If
End Set
End Property
Public Property sARCHITECT As String
Get
Return m_BTLStructureM.m_sARCHITECT
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_ARCHITECT, value) Then
m_BTLStructureM.m_sARCHITECT = value
Else
NotifyPropertyChanged(NameOf(sARCHITECT))
End If
End Set
End Property
Public Property sEDITOR As String
Get
Return m_BTLStructureM.m_sEDITOR
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_EDITOR, value) Then
m_BTLStructureM.m_sEDITOR = value
Else
NotifyPropertyChanged(NameOf(sEDITOR))
End If
End Set
End Property
Public Property sDELIVDATE As String
Get
Return m_BTLStructureM.m_sDELIVDATE
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_DELIVDATE, value) Then
m_BTLStructureM.m_sDELIVDATE = value
Else
NotifyPropertyChanged(NameOf(sDELIVDATE))
End If
End Set
End Property
Public Property sEXPDATE As String
Get
Return m_BTLStructureM.m_sEXPDATE
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_EXPDATE, value) Then
m_BTLStructureM.m_sEXPDATE = value
Else
NotifyPropertyChanged(NameOf(sEXPDATE))
End If
End Set
End Property
Public Property sEXPTIME As String
Get
Return m_BTLStructureM.m_sEXPTIME
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_EXPTIME, value) Then
m_BTLStructureM.m_sEXPTIME = value
Else
NotifyPropertyChanged(NameOf(sEXPTIME))
End If
End Set
End Property
Public Property sEXPRELEASE As String
Get
Return m_BTLStructureM.m_sEXPRELEASE
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_EXPRELEASE, value) Then
m_BTLStructureM.m_sEXPRELEASE = value
Else
NotifyPropertyChanged(NameOf(sEXPRELEASE))
End If
End Set
End Property
Public Property sLANGUAGE As String
Get
Return m_BTLStructureM.m_sLANGUAGE
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_LANGUAGE, value) Then
m_BTLStructureM.m_sLANGUAGE = value
Else
NotifyPropertyChanged(NameOf(sLANGUAGE))
End If
End Set
End Property
Public ReadOnly Property ocRANGE As List(Of Object)
Get
Return m_BTLStructureM.ocRANGE
End Get
End Property
Public Property SelRANGE As Integer
Get
Return m_BTLStructureM.m_SelRANGE
End Get
Set(value As Integer)
Dim nValue As Integer = IdNameStruct.IdFromInd(value, m_BTLStructureM.ocRANGE)
Dim sValue As String = [Enum].GetName(GetType(Range), nValue)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_RANGE, sValue) Then
m_BTLStructureM.m_SelRANGE = value
Else
NotifyPropertyChanged(NameOf(SelRANGE))
End If
End Set
End Property
Public ReadOnly Property ocPROCESSINGQUALITY As List(Of Object)
Get
Return m_BTLStructureM.ocPROCESSINGQUALITY
End Get
End Property
Public Property SelPROCESSINGQUALITY As Integer
Get
Return m_BTLStructureM.m_SelPROCESSINGQUALITY
End Get
Set(value As Integer)
Dim nValue As Integer = IdNameStruct.IdFromInd(value, m_BTLStructureM.ocPROCESSINGQUALITY)
Dim sValue As String = [Enum].GetName(GetType(ProcessingQuality), nValue)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_PRT_PROCESSINGQUALITY, sValue) Then
m_BTLStructureM.m_SelPROCESSINGQUALITY = value
Else
NotifyPropertyChanged(NameOf(SelPROCESSINGQUALITY))
End If
End Set
End Property
Public Property sCOMPUTERNAME As String
Get
Return m_BTLStructureM.m_sCOMPUTERNAME
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_COMPUTERNAME, value) Then
m_BTLStructureM.m_sCOMPUTERNAME = value
Else
NotifyPropertyChanged(NameOf(sCOMPUTERNAME))
End If
End Set
End Property
Public Property sUSER As String
Get
Return m_BTLStructureM.m_sUSER
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_USER, value) Then
m_BTLStructureM.m_sUSER = value
Else
NotifyPropertyChanged(NameOf(sUSER))
End If
End Set
End Property
Public Property sSRCFILE As String
Get
Return m_BTLStructureM.m_sSRCFILE
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_SRCFILE, value) Then
m_BTLStructureM.m_sSRCFILE = value
Else
NotifyPropertyChanged(NameOf(sSRCFILE))
End If
End Set
End Property
Public Property sEXPFILE As String
Get
Return m_BTLStructureM.m_sEXPFILE
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_EXPFILE, value) Then
m_BTLStructureM.m_sEXPFILE = value
Else
NotifyPropertyChanged(NameOf(sEXPFILE))
End If
End Set
End Property
Public ReadOnly Property ocRECESS As List(Of Object)
Get
Return m_BTLStructureM.ocRECESS
End Get
End Property
Public Property SelRECESS As Integer
Get
Return m_BTLStructureM.m_SelRECESS
End Get
Set(value As Integer)
Dim nValue As Integer = IdNameStruct.IdFromInd(value, m_BTLStructureM.ocRECESS)
Dim sValue As String = [Enum].GetName(GetType(Recess), nValue)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_PRT_RECESS, sValue) Then
m_BTLStructureM.m_SelRECESS = value
Else
NotifyPropertyChanged(NameOf(SelRECESS))
End If
End Set
End Property
Public Property sUSERATTRIBUTE As String
Get
Return m_BTLStructureM.m_sUSERATTRIBUTE
End Get
Set(value As String)
If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_USERATTRIBUTE, value) Then
m_BTLStructureM.m_sUSERATTRIBUTE = value
Else
NotifyPropertyChanged(NameOf(sUSERATTRIBUTE))
End If
End Set
End Property
Public ReadOnly Property sBTLTotParts As String
Get
Return m_BTLPartVMList.Sum(Function(x) x.nCNT + x.nADDED)
End Get
End Property
Public ReadOnly Property sBTLTotVolume As String
Get
Dim dMMTotVolume As Double = m_BTLPartVMList.Sum(Function(x) x.dUnitVolume * (x.nCNT + x.nADDED))
Return If(EgtUiUnitsAreMM(), DoubleToString(dMMTotVolume / 1000000000, 3), DoubleToString(dMMTotVolume * (12 / ONEINCH), 3))
End Get
End Property
Public ReadOnly Property dBTLTotTime As Double
Get
Return m_BTLPartVMList.Sum(Function(x) x.nCALC_TIME * (x.nCNT + x.nADDED))
End Get
End Property
Public ReadOnly Property sBTLTotTime As String
Get
Return TimeSpan.FromSeconds(dBTLTotTime).ToString()
End Get
End Property
Public ReadOnly Property sBTLDoneTime As String
Get
Return TimeSpan.FromSeconds(m_BTLPartVMList.Sum(Function(x) x.nCALC_TIME * x.nDONE)).ToString()
End Get
End Property
Public ReadOnly Property sBTLRemainingTime As String
Get
Return TimeSpan.FromSeconds(dBTLTotTime - m_BTLPartVMList.Sum(Function(x) x.nCALC_TIME * x.nDONE)).ToString()
End Get
End Property
Public ReadOnly Property sTotCNTParts As String
Get
Return m_BTLPartVMList.Sum(Function(x) x.nCNT)
End Get
End Property
Public ReadOnly Property sTotADDEDParts As String
Get
Return m_BTLPartVMList.Sum(Function(x) x.nADDED)
End Get
End Property
Public ReadOnly Property sTotINPRODParts As String
Get
Return m_BTLPartVMList.Sum(Function(x) x.nINPROD)
End Get
End Property
Public ReadOnly Property sTotDONEParts As String
Get
Return m_BTLPartVMList.Sum(Function(x) x.nDONE)
End Get
End Property
#End Region ' Parametri generici
' Definizione comandi
Private m_cmdDeletePart As ICommand
Private m_cmdData As ICommand
Private m_cmdAddPart As ICommand
Private m_cmdUpdateBTL As ICommand
#Region "Messages"
Public ReadOnly Property PDN_Msg As String
Get
Return EgtMsg(61809)
End Get
End Property
Public ReadOnly Property AddPart_ToolTip As String
Get
Return EgtMsg(61906)
End Get
End Property
Public ReadOnly Property Data_ToolTip As String
Get
Return EgtMsg(61897)
End Get
End Property
Public ReadOnly Property UpdateBTL_ToolTip As String
Get
Return EgtMsg(61834)
End Get
End Property
#End Region ' Messages
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
Sub New(BTLStructureM As BTLStructureM)
m_BTLStructureM = BTLStructureM
AddHandler m_BTLStructureM.BTLPartAdded, AddressOf OnBTLPartAdded
AddHandler m_SelBTLParts.CollectionChanged, AddressOf SelBTLParts_CollectionChanged
' creo lista di BTLPartVM
CreateBTLPartVMList()
m_BTLPartVMList_View = CollectionViewSource.GetDefaultView(m_BTLPartVMList)
m_GroupList_View = CollectionViewSource.GetDefaultView(m_GroupList)
m_SubGroupList_View = CollectionViewSource.GetDefaultView(m_SubGroupList)
m_SectionList_View = CollectionViewSource.GetDefaultView(m_SectionList)
m_BTLPartVMList_View.Filter = AddressOf PartFilter
m_GroupList_View.Filter = AddressOf GroupFilter
m_SectionList_View.Filter = AddressOf SectionFilter
m_BTLPartVMList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(BTLPartVM.nPROJ)))
m_Calc_PartEnd.Interval = TimeSpan.FromMilliseconds(500)
AddHandler m_Calc_PartEnd.Tick, AddressOf Calc_PartEnd_Tick
m_Calc_PartEnd.Start()
' Aggiorno check DOALL
NotifyPropertyChanged(NameOf(bDOALL))
If BTLStructureM.nAsseBaseId = GDB_ID.NULL Then
Map.refShowBeamPanelVM.SetShowBuilding(False)
End If
End Sub
#End Region ' Constructor
#Region "METHODS"
Private Sub CreateBTLPartVMList()
Dim all As List(Of BTLPartVM) = (From BTLPartM In m_BTLStructureM.GetBTLParts()
Select New BTLPartVM(BTLPartM, m_BTLStructureM)).ToList()
For Each BTLPartVM As BTLPartVM In all
AddHandler BTLPartVM.PropertyChanged, AddressOf OnBTLPartVMPropertyChanged
Next
m_BTLPartVMList = New ObservableCollection(Of BTLPartVM)(all)
AddHandler m_BTLPartVMList.CollectionChanged, AddressOf OnBTLPartVMListChanged
End Sub
Friend Sub LoadFilters()
For Each BTLPartVM As BTLPartVM In m_BTLPartVMList
' verifico sezione, gruppo e sottogruppo per inserirli nei filtri
If Not SectionList.Contains(BTLPartVM.Section) Then
SectionList.Add(BTLPartVM.Section)
End If
If Not GroupList.Contains(BTLPartVM.sGROUP) Then
GroupList.Add(BTLPartVM.sGROUP)
End If
If Not SubGroupList.Contains(BTLPartVM.sSTOREY) Then
SubGroupList.Add(BTLPartVM.sSTOREY)
End If
Next
End Sub
Private Sub Calc_PartEnd_Tick()
' se calcolo non in corso (mainmenu e' attivo), esco
If Map.refMainMenuVM.MainMenu_IsEnabled Then Return
' aggiorno iconcina delle feature dei part che hanno finito calcolo
For Each BTLPart In BTLPartVMList
If BTLPart.Calc_PartEnd Then
BTLPart.BTLFeatureVMList_View.Refresh()
BTLPart.ResetCalcPartEnd()
End If
Next
End Sub
Friend Sub SceneSelPartSelection()
' deseleziono tutto
EgtDeselectAll()
' disabilito impostazione modificato
Dim DisableMgr As New DisableModifiedMgr
' ciclo sui pezzi
If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then
EgtSetMode(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId, GDB_MD.STD)
Else
For Each Part As BTLPartVM In m_BTLPartVMList
' se non è quello selezionato, lo nascondo
If Part IsNot m_SelBTLPart Then
EgtSetMode(Part.nPartId, GDB_MD.HIDDEN)
Else
EgtSetMode(Part.nPartId, GDB_MD.STD)
End If
Next
End If
' ripristino precedente impostazione modificato
DisableMgr.ReEnable()
End Sub
Friend Sub ShowAll(Optional bRedraw As Boolean = True, Optional bOnlySelected As Boolean = False)
' disabilito impostazione modificato
Dim DisableMgr As New DisableModifiedMgr
If Not IsNothing(SelBTLPart) Then
' se pezzo solido, lo riporto normale
Configuration.DeselectSolid()
' tolgo pezzo selezionato
SelBTLPart.SelBTLFeatureVM = Nothing
End If
' mostro tutti i pezzi
' creo lista id presenti
Dim BTLPartIdList As List(Of Integer) = (From Part In BTLPartVMList
Select Part.nPartId).ToList()
BTLPartIdList.Sort()
Dim nGeomPartId As Integer = EgtGetFirstPart()
While nGeomPartId <> GDB_ID.NULL
Dim CurrPart As BTLPartVM = BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nGeomPartId)
If Not IsNothing(CurrPart) AndAlso Not bOnlySelected Then
Dim nMode As Integer
EgtGetMode(CurrPart.nPartId, nMode)
If nMode <> GDB_MD.STD Then
EgtSetMode(CurrPart.nPartId, GDB_MD.STD)
End If
Else
EgtSetMode(nGeomPartId, GDB_MD.HIDDEN)
End If
nGeomPartId = EgtGetNextPart(nGeomPartId)
End While
' ripristino precedente impostazione modificato
DisableMgr.ReEnable()
Core.ViewPanelVM.BWSetView(VT.ISO_SW, False)
EgtZoom(ZM.ALL, bRedraw)
' imposto stato per ShowBeamPanel
If Not bOnlySelected Then Map.refShowBeamPanelVM.bShowAll = True
End Sub
Friend Sub HideAll(Optional bRedraw As Boolean = True)
' disabilito impostazione modificato
Dim DisableMgr As New DisableModifiedMgr
If Not IsNothing(SelBTLPart) Then
' se pezzo solido, lo riporto normale
Configuration.DeselectSolid(GDB_ID.NULL, True)
' tolgo pezzo selezionato
SelBTLPart.SelBTLFeatureVM = Nothing
End If
SetSelBTLPart(Nothing)
' nascondo tutti i pezzi
Dim nPartId As Integer = EgtGetFirstPart()
While nPartId <> GDB_ID.NULL
Dim nMode As Integer
EgtGetMode(nPartId, nMode)
If nMode <> GDB_MD.HIDDEN Then
EgtSetMode(nPartId, GDB_MD.HIDDEN)
End If
nPartId = EgtGetNextPart(nPartId)
End While
' ripristino precedente impostazione modificato
DisableMgr.ReEnable()
Core.ViewPanelVM.BWSetView(VT.ISO_SW, False)
EgtZoom(ZM.ALL, bRedraw)
' imposto stato per ShowBeamPanel
Map.refShowBeamPanelVM.bShowAll = True
End Sub
Friend Sub ShowBuilding(nIdAsseBase As Integer, bShow As Boolean, Optional bRedraw As Boolean = True)
' disabilito impostazione modificato
Dim DisableMgr As New DisableModifiedMgr
Dim bOn As Boolean = EgtBeamGetBuildingIsOn(nIdAsseBase)
If bShow <> bOn Then
If bShow Then EgtBeamCalcAllSolids(True)
EgtBeamShowBuilding(nIdAsseBase, bShow)
If Not bShow Then EgtBeamShowAllSolids(False)
End If
' ripristino precedente impostazione modificato
DisableMgr.ReEnable()
' aggiorno visualizzazione
Core.ViewPanelVM.BWSetView(VT.ISO_SW, False)
EgtZoom(ZM.ALL, bRedraw)
End Sub
Friend Sub ShowSolid(nPartId As Integer, bShow As Boolean, Optional bRedraw As Boolean = True)
' se non viene passato, recupero il pezzo del primo oggetto selezionato
If nPartId = GDB_ID.NULL And Not IsNothing(SelBTLPart) Then
nPartId = SelBTLPart.nPartId
End If
If Not EgtIsPart(nPartId) Then
Dim nLayerId As Integer = EgtGetParent(nPartId)
Dim sLayerName As String = ""
EgtGetName(nLayerId, sLayerName)
If sLayerName <> ASSEBASE Then
Map.refMyStatusBarVM.SetOutputMessage("ERROR: Nessuna trave selezionata ", 5, MSG_TYPE.ERROR_)
Return
End If
End If
EgtDeselectAll()
' disabilito impostazione modificato
Dim DisableMgr As New DisableModifiedMgr
If bShow Then EgtBeamCalcSolid(nPartId)
EgtBeamShowSolid(nPartId, bShow)
If bRedraw Then EgtDraw()
' ripristino precedente impostazione modificato
DisableMgr.ReEnable()
End Sub
' Funzione per regolarizzare, se necessario, la superficie della feature
Private Function RegularizeTriMesh(SurfId As Integer, DestGrpId As Integer, dStep As Double) As Integer
' solo per superfici trimesh con poche facce (max4)
Dim nFacetCnt As Integer = EgtSurfTmFacetCount(SurfId)
If nFacetCnt > 4 Then
Return SurfId
End If
' box della superficie
Dim b3Surf As New BBox3d
EgtGetBBox(SurfId, GDB_BB.STANDARD, b3Surf)
If b3Surf.IsEmpty() Or b3Surf.DimX() < 2 * dStep Then
Return SurfId
End If
' recupero le facce e le divido in X
Dim dXmin As Double = b3Surf.Min().x - 1
Dim dXmax As Double = b3Surf.Max().x + 1
Dim nStep As Integer = CInt(Math.Floor((dXmax - dXmin) / dStep + 0.9))
dStep = (dXmax - dXmin) / nStep
Dim NewSurfId As Integer = GDB_ID.NULL
For nF = 0 To nFacetCnt - 1
Dim FacId As Integer = EgtCopySurfTmFacet(SurfId, nF, DestGrpId)
Dim b3Fac As New BBox3d
EgtGetBBox(FacId, GDB_BB.STANDARD, b3Fac)
Dim dX2 As Double = dXmin
For nI = 1 To nStep
Dim dX1 As Double = dX2
dX2 = dX2 + dStep
If b3Fac.Min().x < dX2 And b3Fac.Max().x > dX1 Then
EgtCutSurfTmPlane(FacId, New Point3d(dX1, 0, 0), -Vector3d.X_AX, True)
EgtCutSurfTmPlane(FacId, New Point3d(dX2, 0, 0), Vector3d.X_AX, False)
Dim nCount As Integer = 0
Dim LoopId As Integer = EgtExtractSurfTmFacetLoops(FacId, 0, DestGrpId, nCount)
EgtMergeCurvesInCurveCompo(LoopId, 0.001)
Dim TmpSurfId As Integer = EgtCreateSurfTmByFlatContour(DestGrpId, LoopId, 0.01)
EgtErase(LoopId)
If NewSurfId <> GDB_ID.NULL Then
NewSurfId = EgtCreateSurfTmBySewing(DestGrpId, 2, {NewSurfId, TmpSurfId}, True)
Else
NewSurfId = TmpSurfId
End If
EgtErase(FacId)
FacId = EgtCopySurfTmFacet(SurfId, nF, DestGrpId)
End If
Next
EgtErase(FacId)
Next
Return NewSurfId
End Function
Private Function PartFilter(Part As Object) As Boolean
Dim CurrBTLPart As BTLPartVM = DirectCast(Part, BTLPartVM)
Dim bGroupOk As Boolean = True
Dim bSubGroupOk As Boolean = True
Dim bSectionOk As Boolean = True
Dim bSearchTextOk As Boolean = True
If Not Map.refLeftPanelVM.IsFilterBtnOpen Then
m_SelSearchParam.Id = 2
m_SelSearchParam.Name = "Descrizione"
End If
If SelSection <> SectionXMaterial.Empty AndAlso CurrBTLPart.Section <> SelSection Then bSectionOk = False
If SelGroup <> "" AndAlso CurrBTLPart.sGROUP <> SelGroup Then bGroupOk = False
If SelSubGroup <> "" AndAlso CurrBTLPart.sSTOREY <> SelSubGroup Then bSubGroupOk = False
If m_SelSearchParam.Id <> BTLPartParam.NULL AndAlso m_SearchText <> String.Empty AndAlso (
(m_SelSearchParam.Id = BTLPartParam.PDN AndAlso CurrBTLPart.nPDN.ToString.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) < 0) OrElse
(m_SelSearchParam.Id = BTLPartParam.NAM AndAlso CurrBTLPart.sNAM.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) < 0)) Then
bSearchTextOk = False
End If
Dim bResult As Boolean = bSectionOk AndAlso bGroupOk AndAlso bSubGroupOk AndAlso bSearchTextOk
' If Not bResult And CurrBTLPart.IsSelected Then CurrBTLPart.IsSelected = False
Return bResult
End Function
Private Function GroupFilter(Group As Object) As Boolean
Dim CurrGroup As String = DirectCast(Group, String)
Dim bOk As Boolean = True
If CurrGroup <> "" AndAlso (SelSection <> SectionXMaterial.Empty OrElse SelSubGroup <> "" OrElse SearchText <> "") Then
bOk = m_BTLPartVMList.Any(Function(x) x.sGROUP = CurrGroup AndAlso
(SelSection = SectionXMaterial.Empty OrElse x.Section = SelSection) AndAlso
(SelSubGroup = "" OrElse x.sSTOREY = SelSubGroup) AndAlso
(SearchText = "" OrElse Not x.sNAM.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0))
End If
Return bOk
End Function
Private Function SubGroupFilter(SubGroup As Object) As Boolean
Dim CurrSubGroup As String = DirectCast(SubGroup, String)
Dim bOk As Boolean = True
If CurrSubGroup <> "" AndAlso (SelSection <> SectionXMaterial.Empty OrElse SearchText <> "" OrElse SelGroup <> "") Then
bOk = m_BTLPartVMList.Any(Function(x) x.sGROUP = CurrSubGroup AndAlso
(SelSection = SectionXMaterial.Empty OrElse x.Section = SelSection) AndAlso
(SelGroup = "" OrElse x.sGROUP = SelGroup) AndAlso
(SearchText = "" OrElse Not x.sNAM.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0))
End If
Return bOk
End Function
Private Function SectionFilter(Section As Object) As Boolean
Dim CurrSection As SectionXMaterial = DirectCast(Section, SectionXMaterial)
Dim bOk As Boolean = True
If CurrSection <> Section.Empty AndAlso (SelGroup <> "" OrElse SelSubGroup <> "" OrElse SearchText <> "") Then
bOk = m_BTLPartVMList.Any(Function(x) x.Section = CurrSection AndAlso
(SelGroup = "" OrElse x.sGROUP = SelGroup) AndAlso
(SelSubGroup = "" OrElse x.sSTOREY = SelSubGroup) AndAlso
(SearchText = "" OrElse Not x.sNAM.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0))
End If
Return bOk
End Function
Friend Sub UpdateSection(NewPartSection As SectionXMaterial, OldPartSection As SectionXMaterial)
If IsNothing(BTLPartVMList) Then Return
' verifico se era unico con vecchia sezione
If Not m_BTLPartVMList.Any(Function(x) x.Section = OldPartSection) Then
' nel caso seleziono filtro generico
SelSection = m_SectionList(0)
' e poi lo cerco ed elimino
m_SectionList.FirstOrDefault(Function(x) x = OldPartSection)
m_SectionList.Remove(m_SectionList.FirstOrDefault(Function(x) x = OldPartSection))
End If
' verifico se esiste già nuova sezione
If Not m_SectionList.Any(Function(x) x = NewPartSection) Then
m_SectionList.Add(NewPartSection)
End If
End Sub
' funzione che aggiorna totale tempi a fine calcolo
Friend Sub CalcGlobalTime()
NotifyPropertyChanged(NameOf(sBTLTotTime))
NotifyPropertyChanged(NameOf(sBTLDoneTime))
NotifyPropertyChanged(NameOf(sBTLRemainingTime))
End Sub
' funzione che aggiorna numero pezzi, volume e tempo totali
Friend Sub CalcGlobalUpdate()
NotifyPropertyChanged(NameOf(sBTLTotParts))
NotifyPropertyChanged(NameOf(sBTLTotVolume))
NotifyPropertyChanged(NameOf(sBTLTotTime))
NotifyPropertyChanged(NameOf(sBTLDoneTime))
NotifyPropertyChanged(NameOf(sBTLRemainingTime))
End Sub
' funzione utilizata per aggiornare rot e flip dopo calcolo
Public Sub RefreshRotFlip()
For Each BTLPart In BTLPartVMList
If Not EgtGetInfo(BTLPart.nPartId, BTL_PRT_ROTATED, BTLPart.BTLPartM.nROTATED) Then
BTLPart.BTLPartM.nROTATED = 0
End If
If Not EgtGetInfo(BTLPart.nPartId, BTL_PRT_INVERTED, BTLPart.BTLPartM.nINVERTED) Then
BTLPart.BTLPartM.nINVERTED = 0
End If
BTLPart.NotifyPropertyChanged(NameOf(BTLPart.sROTATED))
BTLPart.NotifyPropertyChanged(NameOf(BTLPart.sINVERTED))
Next
End Sub
Private Sub ReloadBTLStructure()
Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(0))
' verifico se volume pezzi calcolato
Dim bIsCalculated As Boolean = False
For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList
If BTLPart.BTLPartM.dVolume > 0 Then Continue For
bIsCalculated = True
BTLPart.CalcBTLPartVolume()
Next
If bIsCalculated Then
Dim CurrProject As String = ""
EgtGetCurrFilePath(CurrProject)
EgtSaveFile(CurrProject, NGE.CMPTEXT)
End If
End Sub
#End Region ' Methods
#Region "COMMANDS"
#Region "DeletePart"
Public ReadOnly Property DeletePart_Command As ICommand
Get
If m_cmdDeletePart Is Nothing Then
m_cmdDeletePart = New Command(AddressOf DeletePart)
End If
Return m_cmdDeletePart
End Get
End Property
Public Sub DeletePart()
Map.refBTLPartManagerVM.RemovePartCmd()
End Sub
#End Region ' DeletePart
#Region "Data"
Public ReadOnly Property Data_Command As ICommand
Get
If m_cmdData Is Nothing Then
m_cmdData = New Command(AddressOf Data)
End If
Return m_cmdData
End Get
End Property
Friend Sub Data(nProjId As Integer)
Dim BTLDataWnd As New BTLDataWndV(Application.Current.MainWindow, New BTLDataWndVM(nProjId))
BTLDataWnd.ShowDialog()
End Sub
#End Region ' Data
#Region "AddPart"
Public ReadOnly Property AddPart_Command As ICommand
Get
If m_cmdAddPart Is Nothing Then
m_cmdAddPart = New Command(AddressOf AddPart)
End If
Return m_cmdAddPart
End Get
End Property
Public Sub AddPart(nProjId As Integer)
' apro finestra di definizione nuovo part
Dim AddPartWndVM As New AddPartWndVM()
Dim AddPartWnd As New AddPartWndV(Application.Current.MainWindow, AddPartWndVM)
If AddPartWnd.ShowDialog() Then
' creo nuovo part
Dim nNewPartId As Integer = EgtBeamCreatePart()
' scrivo info proj
EgtSetInfo(nNewPartId, BTL_PRT_PROJ, nProjId)
EgtBeamSetPartProdNbr(AddPartWndVM.nPDN)
If Not IsNothing(AddPartWndVM.sNAM) Then EgtBeamSetPartName(AddPartWndVM.sNAM)
EgtBeamSetPartCount(AddPartWndVM.nCNT)
EgtBeamSetPartBox(AddPartWndVM.dL, AddPartWndVM.dH, AddPartWndVM.dW)
' se progetto pareti e vista ruotata
If nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then
' recupero il box del pezzo
Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nNewPartId, "Box")
Dim b3Solid As New BBox3d
EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Solid)
Dim bOk As Boolean = EgtRotate(nNewPartId, b3Solid.Center, Vector3d.Z_AX, 180, GDB_RT.GLOB)
If bOk Then
EgtSetInfo(nNewPartId, BTL_PRT_ROTATED, 180)
End If
End If
' aggiungo dati pezzo
Dim NewPart As BTLPartM = BTLPartM.CreateBTLPart(nNewPartId)
' aggiungo pezzo alla lista
Map.refProjectVM.BTLStructureVM.BTLStructureM.AddBTLPart(NewPart)
Dim NewPartVM As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.BTLPartM Is NewPart)
If Not IsNothing(NewPartVM) Then
EgtZoom(ZM.ALL)
Map.refProjectVM.BTLStructureVM.SetSelBTLPart(NewPartVM, False, True)
' verifico se aggiungere sezione alla lista
If Not Map.refProjectVM.BTLStructureVM.SectionList.Contains(NewPartVM.Section) Then
Map.refProjectVM.BTLStructureVM.SectionList.Add(NewPartVM.Section)
End If
End If
End If
End Sub
#End Region ' AddPart
#Region "UpdateBTL"
Public ReadOnly Property UpdateBTL_Command As ICommand
Get
If m_cmdUpdateBTL Is Nothing Then
m_cmdUpdateBTL = New Command(AddressOf UpdateBTL)
End If
Return m_cmdUpdateBTL
End Get
End Property
Public Sub UpdateBTL(nProjId As Integer, Optional sFile As String = "", Optional bWithDlg As Boolean = True)
If IsNothing(CurrProd) Then Return
' verifico se progetto modificato, e chiedo se salvare
If CurrProd.bIsNew Or EgtGetModified() OrElse Map.refCALCPanelVM.IsMachineModified() Then
Select Case MessageBox.Show(EgtMsg(61877), "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question)
Case MessageBoxResult.Yes
Map.refProdManagerVM.Save()
Case MessageBoxResult.Cancel
Return
Case Else ' No
MessageBox.Show(EgtMsg(61892), "", MessageBoxButton.OK, MessageBoxImage.Exclamation)
Return
End Select
End If
' se vista tutti i pezzi
Dim bShowBuilding As Boolean = False
Dim bShowSolid As Boolean = False
Dim nSelPartId As Integer = GDB_ID.NULL
If Map.refShowBeamPanelVM.bShowAll Then
' verifico se assemblato e lo annullo per salvataggio
bShowBuilding = Map.refShowBeamPanelVM.ShowBuilding_IsChecked
If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(False, False)
' se vista singolo pezzo
Else
bShowSolid = Map.refShowBeamPanelVM.ShowSolid_IsChecked
If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, False, False)
' se pezzo selezionato lo segno e metto vista tutti
If Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then
nSelPartId = Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId
End If
Map.refProjectVM.BTLStructureVM.ShowAll(False)
End If
Dim sDir As String = String.Empty
GetMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, "", sDir)
If bWithDlg Then
' apro finestra scelta file
Dim BTLDlg As New Microsoft.Win32.OpenFileDialog() With {
.DefaultExt = ".btl",
.Filter = "BTL (*.btl)|*.btl" &
"|BTLX (*.btlx)|*.btlx",
.InitialDirectory = If(Directory.Exists(sDir), sDir, ""),
.CheckFileExists = True,
.ValidateNames = True}
If BTLDlg.ShowDialog() Then
sFile = BTLDlg.FileName
Else
' se assemblato lo ripristino
If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False)
If nSelPartId <> GDB_ID.NULL Then
Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId)
If Not IsNothing(SelPart) Then
If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False)
End If
End If
EgtZoom(ZM.ALL)
Return
End If
End If
' salvo lista pezzi del progetto originale
Dim OrigPartlist As ObservableCollection(Of BTLPartVM) = Map.refProjectVM.BTLStructureVM.BTLPartVMList
' creo un nuovo contesto su cui aprire il file BTL
Dim nCurrCtx As Integer = EgtGetCurrentContext()
Dim nTempCtx As Integer = EgtInitContext()
' setto il flag per inizializzazione gestore travi e pareti per importare progetto
Dim nFlag As Integer
Dim sBTLFlag As String
If Map.refProdManagerVM.nProdType = BWType.BEAM Then
sBTLFlag = K_BTLFLAG
Else
sBTLFlag = K_WALLBTLFLAG
End If
nFlag = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR)
' inizializzo gestore travi e pareti
EgtInitBeamMgr(nFlag)
Dim bOk As Boolean = nTempCtx <> 0
If bOk Then
' importo il file BTL
bOk = bOk AndAlso EgtImportBtl(sFile, nFlag)
' carico la lista dei Part importati e rimuovo i parametri generali del BTL
Dim AsseBaseId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE)
Dim BtlInfoId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO)
Dim PartToUpdateList As New List(Of BTLPartToUpdate)
' cerco tra i layer BTLInfo
While BtlInfoId <> GDB_ID.NULL
' verifico se il layer appartiene al ProjId
Dim nBTLInfoLayerProjId As Integer
EgtGetInfo(BtlInfoId, BTL_PRT_PROJ, nBTLInfoLayerProjId)
' carico la lista con i PDN dei pezzi del BTL importato
Dim nPDN As Integer = 0
Dim sNAM As String = String.Empty
Dim nUID As Integer = 0
Dim nPartId As Integer = EgtGetFirstPart()
While nPartId <> GDB_ID.NULL
Dim UIDList As New List(Of Integer)
Dim nIndUID As Integer = 1
' se devo filtrare un progetto
If nBTLInfoLayerProjId > 0 Then
' verifico se il pezzo appartiene al ProjId
Dim nPartProjId As Integer
EgtGetInfo(nPartId, BTL_PRT_PROJ, nPartProjId)
If nPartProjId = nBTLInfoLayerProjId Then
EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN)
EgtGetInfo(nPartId, BTL_PRT_NAM, sNAM)
While EgtGetInfo(nPartId, BTL_PRT_UID & nIndUID, nUID)
UIDList.Add(nUID)
nIndUID += 1
End While
PartToUpdateList.Add(New BTLPartToUpdate(nPartId, nPDN, sNAM, UIDList, OrigPartlist.Any(Function(x) x.nPDN = nPDN)))
End If
Else
' altrimenti carico tutti
EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN)
EgtGetInfo(nPartId, BTL_PRT_NAM, sNAM)
While EgtGetInfo(nPartId, BTL_PRT_UID & nUID, nUID)
UIDList.Add(nUID)
nIndUID += 1
End While
PartToUpdateList.Add(New BTLPartToUpdate(nPartId, nPDN, sNAM, UIDList, OrigPartlist.Any(Function(x) x.nPDN = nPDN)))
End If
nPartId = EgtGetNextPart(nPartId)
End While
EgtErase(BtlInfoId)
BtlInfoId = EgtGetNextName(BtlInfoId, BTLINFO)
End While
' costruisco un dizionario con gli id dei sottonodi di AsseBase del BTL importato e il valore dell'Info N degli stessi
Dim AsseBaseSubNodeDict As New Dictionary(Of Integer, Integer)
Dim nAsseBaseSubNodeId As Integer = EgtGetFirstInGroup(AsseBaseId)
Dim sAsseBaseUID As String = String.Empty
Dim nAsseBaseUID As Integer = 0
While nAsseBaseSubNodeId <> GDB_ID.NULL
If EgtGetInfo(nAsseBaseSubNodeId, BTL_ASSEBASE_N, sAsseBaseUID) Then
sAsseBaseUID = sAsseBaseUID.Remove(0, 4)
Integer.TryParse(sAsseBaseUID, nAsseBaseUID)
AsseBaseSubNodeDict.Add(nAsseBaseSubNodeId, sAsseBaseUID)
End If
nAsseBaseSubNodeId = EgtGetNext(nAsseBaseSubNodeId)
End While
' salvo il file BTL da cui abbiamo rimosso BtlInfo come file NGE
EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE, NGE.CMPTEXT)
Dim bAppend As Boolean = False
' se UserLevel > 5 e fra i Part importati ce ne sta almeno 1 con PDN uguale ai Part già presenti
' apro la finestra per chiedere se si vuole aggiornare o accodare
If Map.refMainWindowVM.MainWindowM.nUserLevel > 5 Then
For Each PartToUpdate In PartToUpdateList
Dim bExitFor As Boolean = False
For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLStructureM.BTLPartMList
If PartToUpdate.nPDN = BTLPart.nPDN Then
Dim UpdateOrAppendWndVM As New UpdateOrAppendWndVM()
Dim UpdateOrAppendWnd As New UpdateOrAppendWndV(Application.Current.MainWindow, UpdateOrAppendWndVM)
If Not UpdateOrAppendWnd.ShowDialog() Then
' torno sul contesto corrente
EgtSetCurrentContext(nCurrCtx)
EgtDeleteContext(nTempCtx)
' rileggo la struttura BTL
ReloadBTLStructure()
' se assemblato lo ripristino
If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False)
If nSelPartId <> GDB_ID.NULL Then
Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId)
If Not IsNothing(SelPart) Then
'SelPart.IsSelected = True
If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False)
End If
End If
EgtZoom(ZM.ALL)
Return
End If
' salvo lo stato del bottone per accodare
bAppend = UpdateOrAppendWndVM.AppendIsChecked
bExitFor = True
Exit For
End If
Next
If bExitFor Then Exit For
Next
End If
' se selezionato Append li accodo tutti
If bAppend Then
' torno sul contesto corrente
EgtSetCurrentContext(nCurrCtx)
EgtDeleteContext(nTempCtx)
' rileggo la struttura BTL del progetto corrente per non avere quella del contesto temporaneo ancora presente
ReloadBTLStructure()
' salvo gli id degli AsseBase presenti nel progetto corrente
Dim AsseBaseIdList As New List(Of Integer)
AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE)
While AsseBaseId <> GDB_ID.NULL
AsseBaseIdList.Add(AsseBaseId)
AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE)
End While
' calcolo BBox globale del progetto iniziale
Dim b3Parts As New BBox3d
Dim nProjPartId As Integer = EgtGetFirstPart()
Dim nLastProjPartId As Integer = 0
While nProjPartId <> GDB_ID.NULL
Dim b3Part As New BBox3d
EgtGetBBoxGlob(nProjPartId, GDB_BB.ONLY_VISIBLE, b3Part)
b3Parts.Add(b3Part)
nLastProjPartId = nProjPartId
nProjPartId = EgtGetNextPart(nProjPartId)
End While
' inserisco il file importato nel progetto corrente
bOk = bOk AndAlso EgtInsertFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE)
' deseleziono tutto
EgtDeselectAll()
' ciclo sui pezzi aggiunti
Dim nAddedPartId As Integer = EgtGetNextPart(nLastProjPartId)
Dim bFirstLoop As Boolean = True
Dim LastPartMaxY As Double
Dim nIncrPDN As Integer = 0
While nAddedPartId <> GDB_ID.NULL
' incremento il PDN del Part aggiunto rispetto al PDN maggiore attualmente presente
EgtSetInfo(nAddedPartId, BTL_PRT_PDN, Map.refProjectVM.BTLStructureVM.BTLStructureM.NewPDN() + nIncrPDN)
' recupero layer del box
Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nAddedPartId, "Box")
' recupero box del layer box
Dim b3Box As New BBox3d
EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Box)
' ricaviamo il box globale del part appena aggiunto
Dim b3Part As New BBox3d
EgtGetBBoxGlob(nAddedPartId, 1, b3Part)
' sposto il pezzo per distanziarlo dall'ultimo di un offset pari a 500
bOk = bOk AndAlso EgtMove(nAddedPartId, New Vector3d(0, If(bFirstLoop, b3Parts.Max.y, LastPartMaxY - b3Part.Min.y) + 500, 0))
bFirstLoop = False
' ricaviamo il box globale del part appena spostato, salviamo la sua Y massima e lo aggiungiamo al box globale di tutti i part
EgtGetBBoxGlob(nAddedPartId, 1, b3Part)
LastPartMaxY = b3Part.Max.y
b3Parts.Add(b3Part)
nAddedPartId = EgtGetNextPart(nAddedPartId)
nIncrPDN += 1
End While
' aggiungo i part inseriti alla lista
Dim nNewPartId As Integer = EgtGetNextPart(nLastProjPartId)
While nNewPartId <> GDB_ID.NULL
' aggiungo dati pezzo
Dim NewPart As BTLPartM = BTLPartM.CreateBTLPart(nNewPartId)
' aggiungo pezzo alla lista
Map.refProjectVM.BTLStructureVM.BTLStructureM.AddBTLPart(NewPart)
Dim AddedBTLPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.BTLPartM Is NewPart)
' verifico se aggiungere sezione alla lista
If Not Map.refProjectVM.BTLStructureVM.SectionList.Contains(AddedBTLPart.Section) Then
Map.refProjectVM.BTLStructureVM.SectionList.Add(AddedBTLPart.Section)
End If
nNewPartId = EgtGetNextPart(nNewPartId)
End While
' elimino gli AsseBase del progetto importato
AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE)
While AsseBaseId <> GDB_ID.NULL
Dim CurrAsseBaseId = AsseBaseId
AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE)
If Not AsseBaseIdList.Contains(CurrAsseBaseId) Then EgtErase(CurrAsseBaseId)
End While
WriteMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, Path.GetDirectoryName(sFile))
Else
' altrimenti apro la finestra con l'elenco dei Part da checkare per l'inserimento nel progetto (unica strada se UserLevel <= 5),
' che prevederà la sovrascrittura di quelli già presenti e l'aggiunta di quelli nuovi
Dim UpdateBTLWndVM As New UpdateBTLWndVM(PartToUpdateList)
Dim UpdateBTLWnd As New UpdateBTLWndV(Application.Current.MainWindow, UpdateBTLWndVM)
If Not UpdateBTLWnd.ShowDialog() Then
' torno sul contesto corrente
EgtSetCurrentContext(nCurrCtx)
EgtDeleteContext(nTempCtx)
' rileggo la struttura BTL
ReloadBTLStructure()
' se assemblato lo ripristino
If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False)
If nSelPartId <> GDB_ID.NULL Then
Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId)
If Not IsNothing(SelPart) Then
If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False)
End If
End If
EgtZoom(ZM.ALL)
Return
End If
If UpdateBTLWndVM.BTLPartList.Count > 0 Then
' sovrascrivo i Part nel progetto aperto con i Part checkati nella lista
Dim BTLPartToOverwriteWithList As New ObservableCollection(Of BTLPartToUpdate)
' Elimino dal TempCtx i Part non checkati
For Each BTLPartToOverwriteWith In UpdateBTLWndVM.BTLPartList
If BTLPartToOverwriteWith.bInsert Then
BTLPartToOverwriteWithList.Add(BTLPartToOverwriteWith)
Else
' elimino pezzo copia
Dim nCurrPartId = EgtGetCurrPart()
EgtErase(BTLPartToOverwriteWith.nPartId)
nCurrPartId = EgtGetCurrPart()
End If
Next
' costruisco un nuovo dizionario dei sottonodi di AsseBase contenente solo quelli corrispondenti agli UID contenuti
' nei soli Part checkati del BTL nella finestra UpdateBTLWnd
Dim NewAsseBaseSubNodeDict As New Dictionary(Of Integer, Integer)
For Each AsseBaseSubNodeItem In AsseBaseSubNodeDict
For Each BTLPartToOverwriteWithItem In BTLPartToOverwriteWithList
Dim bExitFor As Boolean = False
For Each UIDItem In BTLPartToOverwriteWithItem.UIDList
If AsseBaseSubNodeItem.Value = UIDItem Then
NewAsseBaseSubNodeDict.Add(AsseBaseSubNodeItem.Key, AsseBaseSubNodeItem.Value)
bExitFor = True
Exit For
End If
Next
If bExitFor Then Exit For
Next
Next
' confronto la lista appena costruita con quella originale ed elimino dal contesto i sottonodi con i valori non più presenti
For Each AsseBaseSubNodeItem In AsseBaseSubNodeDict
If Not NewAsseBaseSubNodeDict.ContainsValue(AsseBaseSubNodeItem.Value) Then
EgtErase(AsseBaseSubNodeItem.Key)
End If
Next
' salvo il file NGE inserito a cui abbiamo rimosso i Part non checkati e gli AsseBase non più associati
EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE, NGE.CMPTEXT)
' torno sul contesto corrente
EgtDeleteContext(nTempCtx)
EgtSetCurrentContext(nCurrCtx)
' aggiungo informazioni su pezzi
Dim nPartId As Integer = EgtGetFirstPart(GDB_ID.ROOT)
While nPartId <> GDB_ID.NULL
' scrivo in ogni pezzo ProjId
EgtSetInfo(nPartId, BTL_PRT_PROJ, ProjectManagerVM.CurrProd.nProjId)
' scrivo Id negli outline
Dim nPRId As Integer = 1
Dim nOutlineLayer As Integer = EgtGetFirstNameInGroup(nPartId, OUTLINE)
If nOutlineLayer <> GDB_ID.NULL Then
Dim nOutlineId As Integer = EgtGetFirstInGroup(nOutlineLayer)
While nOutlineId <> GDB_ID.NULL
' verifico che sia feature
If EgtExistsInfo(nOutlineId, MGR_FTR_PRC) Then
EgtSetInfo(nOutlineId, MGR_FTR_PRID, nPRId)
nPRId += 1
End If
nOutlineId = EgtGetNext(nOutlineId)
End While
End If
nPartId = EgtGetNextPart(nPartId)
End While
' scrivo info proj e type su layer BtlInfo
Dim nBTLInfoLayer As Integer = EgtGetLastNameInGroup(GDB_ID.ROOT, BTLINFO)
EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, ProjectManagerVM.CurrProd.nProjId)
EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, nType)
' rileggo la struttura BTL del progetto corrente per non avere quella del contesto temporaneo ancora presente
ReloadBTLStructure()
' elimino i pezzi da sovrascrivere nel progetto corrente
For Each BTLPartToOverwriteWith In UpdateBTLWndVM.BTLPartList
If BTLPartToOverwriteWith.bInsert Then
Dim BTLPartToUpdate As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPDN = BTLPartToOverwriteWith.nPDN)
' se BTLPartToUpdate è Nothing significa che il pezzo è nuovo e quindi basta accodarlo senza eliminare nulla
If Not IsNothing(BTLPartToUpdate) Then
Dim nPartToDeleteId As Integer = BTLPartToUpdate.nPartId
Dim nCurrPartId = EgtGetCurrPart()
EgtErase(nPartToDeleteId)
nCurrPartId = EgtGetCurrPart()
' verifico se rimuovere sezione dalla lista
If Not Map.refProjectVM.BTLStructureVM.BTLPartVMList.Any(Function(x) x IsNot BTLPartToUpdate AndAlso x.Section = BTLPartToUpdate.Section) Then
Map.refProjectVM.BTLStructureVM.SectionList.Remove(BTLPartToUpdate.Section)
End If
' rimuovo dalla lista pezzi
Dim Index As Integer = Map.refProjectVM.BTLStructureVM.BTLPartVMList.IndexOf(BTLPartToUpdate)
Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Nothing)
Map.refProjectVM.BTLStructureVM.BTLPartVMList.RemoveAt(Index)
End If
End If
Next
' salvo gli id degli AsseBase presenti nel progetto corrente
Dim AsseBaseIdList As New List(Of Integer)
AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE)
While AsseBaseId <> GDB_ID.NULL
AsseBaseIdList.Add(AsseBaseId)
' elimino i sottonodi di AsseBase da sovrascrivere
AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE)
nAsseBaseSubNodeId = EgtGetFirstInGroup(AsseBaseId)
'While nAsseBaseSubNodeId <> GDB_ID.NULL
' If NewAsseBaseSubNodeDict.ContainsKey(nAsseBaseSubNodeId) Then
' ' se sottonodo da cancellare salvo il suo id e ricavo il seguente prima di cancellarlo
' Dim nCurrAsseBaseSubNodeId = nAsseBaseSubNodeId
' nAsseBaseSubNodeId = EgtGetNext(nCurrAsseBaseSubNodeId)
' bOk = EgtErase(nCurrAsseBaseSubNodeId)
' Else
' ' altrimenti ricavo il seguente e basta
' nAsseBaseSubNodeId = EgtGetNext(nAsseBaseSubNodeId)
' End If
'End While
AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE)
End While
' calcolo BBox globale del progetto corrente
Dim b3Parts As New BBox3d
Dim nProjPartId As Integer = EgtGetFirstPart()
Dim nLastProjPartId As Integer = GDB_ID.NULL
While nProjPartId <> GDB_ID.NULL
Dim b3Part As New BBox3d
If EgtGetBBoxGlob(nProjPartId, GDB_BB.ONLY_VISIBLE, b3Part) Then
b3Parts.Add(b3Part)
End If
nLastProjPartId = nProjPartId
nProjPartId = EgtGetNextPart(nProjPartId)
End While
' se sovrascrivo tutti e bbox esce nullo
If b3Parts.IsEmpty Then
b3Parts = New BBox3d(Point3d.ORIG)
End If
' inserisco il file NGE (ricavato dal BTL importato) nel progetto corrente
bOk = bOk AndAlso EgtInsertFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE)
' ciclo su tutti gli AsseBase del progetto corrente
Dim nAsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE)
While nAsseBaseId <> GDB_ID.NULL
Dim nAsseBaseProjId As Integer
Dim nAsseBaseToEraseId As Integer = 0
EgtGetInfo(nAsseBaseId, BTL_PRT_PROJ, nAsseBaseProjId)
' se AsseBase di questo step del ciclo è nuovo e suo ProjId uguale a quello del progetto corrente
If Not AsseBaseIdList.Contains(nAsseBaseId) AndAlso nAsseBaseProjId = CurrProd.nProdId Then
' riloco i sottonodi del nuovo AsseBase nell'AsseBase del progetto aperto col medesimo ProjId
Dim AsseBaseSubNodeId As Integer = EgtGetFirstInGroup(nAsseBaseId)
While AsseBaseSubNodeId <> GDB_ID.NULL
' ciclo su tutti gli AsseBase per trovare l'id di quello con ProjId uguale al progetto corrente
Dim FindAsseBaseId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE)
While FindAsseBaseId <> GDB_ID.NULL
Dim SameAsseBaseProjId As Integer
EgtGetInfo(FindAsseBaseId, BTL_PRT_PROJ, SameAsseBaseProjId)
' se l'ho trovato esco dal While (FindAsseBaseId è l'id dell'AsseBase in cui vogliamo rilocare i sottonodi)
If SameAsseBaseProjId = CurrProd.nProdId Then Exit While
FindAsseBaseId = EgtGetNextName(FindAsseBaseId, ASSEBASE)
End While
' salvo id dell'AsseBase corrente per ottenere il seguente prima di rilocarlo
Dim CurrAsseBaseSubNodeId = AsseBaseSubNodeId
AsseBaseSubNodeId = EgtGetNext(CurrAsseBaseSubNodeId)
bOk = bOk AndAlso EgtRelocate(CurrAsseBaseSubNodeId, FindAsseBaseId, GDB_POS.LAST_SON)
End While
' salvo id dell'AsseBase per cancellarlo
nAsseBaseToEraseId = nAsseBaseId
End If
' ricavo id del prossimo AsseBase
nAsseBaseId = EgtGetNextName(nAsseBaseId, ASSEBASE)
' se salvato id dell'AsseBase per cancellarlo lo cancello
If nAsseBaseToEraseId <> 0 Then bOk = bOk AndAlso EgtErase(nAsseBaseToEraseId)
End While
' deseleziono tutto
EgtDeselectAll()
' ciclo sui pezzi aggiunti
Dim nAddedPartId As Integer = If(nLastProjPartId <> GDB_ID.NULL, EgtGetNextPart(nLastProjPartId), EgtGetFirstPart())
Dim LastPartMaxY As Double
While nAddedPartId <> GDB_ID.NULL
' recupero layer del box
Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nAddedPartId, "Box")
' recupero box del layer box
Dim b3Box As New BBox3d
EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Box)
' ricaviamo il box globale del part appena aggiunto e ruotato
Dim b3Part As New BBox3d
EgtGetBBoxGlob(nAddedPartId, 1, b3Part)
' salviamo la Y massima del box globale di tutti i part
LastPartMaxY = b3Parts.Max.y
' sposto il pezzo per distanziarlo dall'ultimo di un offset pari a 500
bOk = bOk AndAlso EgtMove(nAddedPartId, New Vector3d(0, LastPartMaxY - b3Part.Min.y + 500, 0))
' ricaviamo il box globale del part appena spostato e lo aggiungiamo al box globale di tutti i part
EgtGetBBoxGlob(nAddedPartId, 1, b3Part)
b3Parts.Add(b3Part)
' aggiungo dati pezzo
Dim NewPart As BTLPartM = BTLPartM.CreateBTLPart(nAddedPartId)
' aggiungo pezzo alla lista
Map.refProjectVM.BTLStructureVM.BTLStructureM.AddBTLPart(NewPart)
Dim AddedBTLPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.BTLPartM Is NewPart)
' se progetto pareti e vista ruotata
If nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then
' ruoto le pareti di 180 per raddrizzarle rispetto alla vista
AddedBTLPart.Rotation(True, Map.refProjectVM.BTLStructureVM.nPROJTYPE, True, 180, False)
End If
' verifico se aggiungere sezione alla lista
If Not Map.refProjectVM.BTLStructureVM.SectionList.Contains(AddedBTLPart.Section) Then
Map.refProjectVM.BTLStructureVM.SectionList.Add(AddedBTLPart.Section)
End If
nAddedPartId = EgtGetNextPart(nAddedPartId)
End While
WriteMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, Path.GetDirectoryName(sFile))
End If
End If
Map.refProdManagerVM.CopyBuilding()
' copio il file originale scelto nel dialog per l'Update nella cartella Proj del progetto corrente
If File.Exists(sFile) Then
'Dim sDestPath As String = ProjectManagerVM.CurrProj.sProjDirPath & "\" & Path.GetFileNameWithoutExtension(sFile)
Dim sDestPath As String = CurrProd.sProdDirPath & "\Projs\" & ProjectManagerVM.CurrProd.nProjIdList(0).ToString("0000") & "\" & Path.GetFileNameWithoutExtension(sFile)
While File.Exists(sDestPath & ".btl")
sDestPath &= "_1"
End While
File.Copy(sFile, sDestPath & ".btl", False)
End If
End If
' se assemblato lo ripristino
If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False)
If nSelPartId <> GDB_ID.NULL Then
Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId)
If Not IsNothing(SelPart) Then
If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False)
End If
End If
EgtZoom(ZM.ALL)
End Sub
#End Region ' UpdateBTL
#End Region ' Commands
#Region "EVENTS"
Private Sub OnBTLPartAdded(sender As Object, e As BTLPartAddedEventArgs)
Dim BTLPartVM As BTLPartVM = New BTLPartVM(e.NewBTLPart, m_BTLStructureM)
m_BTLPartVMList.Add(BTLPartVM)
NotifyPropertyChanged(NameOf(BTLPartVMList))
End Sub
Private Sub OnBTLPartVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs)
If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then
For Each BTLPartVM As BTLPartVM In e.NewItems
AddHandler BTLPartVM.PropertyChanged, AddressOf OnBTLPartVMPropertyChanged
Next
End If
If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then
For Each BTLPartVM As BTLPartVM In e.OldItems
RemoveHandler BTLPartVM.PropertyChanged, AddressOf OnBTLPartVMPropertyChanged
m_BTLStructureM.BTLPartMList.Remove(BTLPartVM.BTLPartM)
Next
End If
End Sub
Private Sub OnBTLPartVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs)
Select Case "bDO"
Case NameOf(sender.sMATERIAL)
If Not GroupList.Contains(sender.sMATERIAL) Then
GroupList.Add(sender.sMATERIAL)
End If
Case NameOf(sender.sW), NameOf(sender.sH), NameOf(sender.sL)
Case NameOf(sender.nDONE)
NotifyPropertyChanged(NameOf(sBTLDoneTime))
NotifyPropertyChanged(NameOf(sBTLRemainingTime))
Case NameOf(sender.bDO), NameOf(sender.sPriority)
NotifyPropertyChanged(NameOf(bDOALL))
End Select
End Sub
#End Region ' Events
End Class