Imports System.Collections.ObjectModel Imports System.Collections.Specialized Imports System.ComponentModel Imports System.Windows.Threading Imports EgtBEAMWALL.Core Imports EgtUILib Imports EgtWPFLib5 Public Class BTLStructureVM Inherits VMBase #Region "FIELDS & PROPERTIES" 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 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_SelBTLPart As BTLPartVM = Nothing Public Property SelBTLPart As BTLPartVM Get Return m_SelBTLPart End Get Set(value As BTLPartVM) If Not IsNothing(m_SelBTLPart) Then ' se necessario tolgo solido dal precedentemente selezionato If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then Map.refShowBeamPanelVM.SetShowSolid(False) End If ' disabilito eventuale feature selezionata If Not IsNothing(m_SelBTLPart.m_SelBTLFeatureVM) Then m_SelBTLPart.SelBTLFeatureVM = Nothing End If m_SelBTLPart = value ' se seleziono un pezzo If Not IsNothing(m_SelBTLPart) Then If Map.refMainMenuVM.SelPage = Pages.VIEW Then ' se modalità building, la tolgo If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then ShowBuilding(False, False) End If ' seleziono pezzo nella scena SceneSelPartSelection() ' seleziono pezzo in Db geometrico EgtBeamSetPart(m_SelBTLPart.nPartId) ' seleziono pagina BottomPanel Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.PART) ' mostro barra di gestione pezzo Map.refProjectVM.SetPartManager_Visibility(True) Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProjectVM.PartManager_Visibility)) ' deseleziono le feature If Not IsNothing(m_SelBTLPart.SelBTLFeatureVM) Then SelBTLPart.SelBTLFeatureVM = Nothing ' 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) ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then ' resetto gruppo di lavorazione corrente EgtResetCurrMachGroup() ' seleziono pezzo nella scena SceneSelPartSelection() Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) EgtZoom(ZM.ALL) End If End If NotifyPropertyChanged(NameOf(SelBTLPart)) End Set End Property ' funzione che imposta pezzo BTL selezionato senza aggiornare nulla Friend Sub SetSelBTLPart(BTLPart As BTLPartVM) m_SelBTLPart = BTLPart NotifyPropertyChanged(NameOf(SelBTLPart)) End Sub ' lista parametri per ricerca testuale Private m_SearchParamList As New ObservableCollection(Of IdNameStruct)({New IdNameStruct(BTLPartParam.NULL, ""), New IdNameStruct(BTLPartParam.PDN, "PDN"), New IdNameStruct(BTLPartParam.NAM, "Descrizione"), New IdNameStruct(BTLPartParam.GRP, "Gruppo")}) 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 materiali utilizzati Private m_MaterialList_View As CollectionView = Nothing Private m_MaterialList As New ObservableCollection(Of String)({""}) Public Property MaterialList As ObservableCollection(Of String) Get Return m_MaterialList End Get Set(value As ObservableCollection(Of String)) m_MaterialList = value End Set End Property Private m_SelMaterial As String = "" Public Property SelMaterial As String Get Return m_SelMaterial End Get Set(value As String) m_SelMaterial = value m_BTLPartVMList_View.Refresh() m_SectionList_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_MaterialList_View.Refresh() End If End Set End Property 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_MaterialList_View.Refresh() m_SectionList_View.Refresh() 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("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("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("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("sPROJGUID") End If End Set End Property Public ReadOnly Property nPROJTYPE As BWType Get Select Case Map.refMainMenuVM.SelPage Case Pages.VIEW Return Map.refProjManagerVM.nProjType Case Pages.MACHINING Return Map.refProdManagerVM.nProdType Case Else Return BWType.NULL End Select 'Return m_BTLStructureM.m_nPROJTYPE End Get 'Set(value As BWType) ' If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_PROJTYPE, value) Then ' m_BTLStructureM.m_nPROJTYPE = value ' Else ' NotifyPropertyChanged(NameOf(nPROJTYPE)) ' End If 'End Set 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(Map.refProjManagerVM.CurrProj.nProjId, value) m_BTLStructureM.m_sLISTNAME = value Else NotifyPropertyChanged("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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("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 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 Public ReadOnly Property PDN_Msg As String Get Return EgtMsg(61809) End Get End Property #End Region #Region "CONSTRUCTOR" Sub New(BTLStructureM As BTLStructureM) m_BTLStructureM = BTLStructureM AddHandler m_BTLStructureM.BTLPartAdded, AddressOf OnBTLPartAdded ' creo lista di BTLPartVM CreateBTLPartVMList() m_BTLPartVMList_View = CollectionViewSource.GetDefaultView(m_BTLPartVMList) m_MaterialList_View = CollectionViewSource.GetDefaultView(m_MaterialList) m_SectionList_View = CollectionViewSource.GetDefaultView(m_SectionList) m_BTLPartVMList_View.Filter = AddressOf PartFilter m_MaterialList_View.Filter = AddressOf MaterialFilter m_SectionList_View.Filter = AddressOf SectionFilter m_Calc_PartEnd.Interval = TimeSpan.FromMilliseconds(500) AddHandler m_Calc_PartEnd.Tick, AddressOf Calc_PartEnd_Tick m_Calc_PartEnd.Start() 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 ' verifico sezione e materiale per inserirli nei filtri If Not MaterialList.Contains(BTLPartVM.sMATERIAL) Then MaterialList.Add(BTLPartVM.sMATERIAL) End If If Not SectionList.Contains(BTLPartVM.Section) Then SectionList.Add(BTLPartVM.Section) End If Next m_BTLPartVMList = New ObservableCollection(Of BTLPartVM)(all) AddHandler m_BTLPartVMList.CollectionChanged, AddressOf OnBTLPartVMListChanged 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 Private Sub SceneSelPartSelection() ' deseleziono tutto EgtDeselectAll() ' disabilito impostazione modificato Dim DisableMgr As New DisableModifiedMgr ' ciclo sui pezzi For Each Part As BTLPartVM In m_BTLPartVMList ' se non è quello selezionato, lo nasondo If Part IsNot m_SelBTLPart Then EgtSetMode(Part.nPartId, GDB_MD.HIDDEN) Else EgtSetMode(Part.nPartId, GDB_MD.STD) End If Next ' ripristino precedente impostazione modificato DisableMgr.ReEnable() End Sub Friend Sub ShowAll(Optional bRedraw As Boolean = True) ' disabilito impostazione modificato Dim DisableMgr As New DisableModifiedMgr If Not IsNothing(SelBTLPart) Then ' se pezzo solido, lo riporto normale If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then ShowSolid(False) Map.refShowBeamPanelVM.SetShowSolid(False) End If ' tolgo pezzo selezionato SelBTLPart.SelBTLFeatureVM = Nothing End If SelBTLPart = Nothing ' 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) 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 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 If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then ShowSolid(False) Map.refShowBeamPanelVM.SetShowSolid(False) End If ' tolgo pezzo selezionato SelBTLPart.SelBTLFeatureVM = Nothing End If SelBTLPart = 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 'For Each Part As BTLPartVM In BTLPartVMList ' Dim nMode As Integer ' EgtGetMode(Part.nPartId, nMode) ' If nMode <> GDB_MD.HIDDEN Then ' EgtSetMode(Part.nPartId, GDB_MD.HIDDEN) ' End If 'Next ' 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(bShow As Boolean, Optional bRedraw As Boolean = True) ' disabilito impostazione modificato Dim DisableMgr As New DisableModifiedMgr ' recupero progetto del primo pezzo 'Dim nFirstPartId As Integer = EgtGetFirstPart(True) 'Dim nCurrProjId As Integer 'If nFirstPartId = GDB_ID.NULL Then ' DisableMgr.ReEnable() ' Return 'End If 'If Not EgtGetInfo(nFirstPartId, BTL_PRT_PROJ, nCurrProjId) Then ' DisableMgr.ReEnable() ' Return 'End If Dim nCurrProjId As Integer If IsNothing(Map.refProjManagerVM) OrElse IsNothing(Map.refProjManagerVM.CurrProj) Then DisableMgr.ReEnable() Return End If If Map.refProjectVM.BTLStructureVM.BTLStructureM.nAsseBaseId = GDB_ID.NULL Then DisableMgr.ReEnable() Return End If ' recupero il primo oggetto nel gruppo e verifico se devo assemblare o disassemblare Dim AsseId As Integer = EgtGetFirstInGroup(Map.refProjectVM.BTLStructureVM.BTLStructureM.nAsseBaseId) If AsseId = GDB_ID.NULL Then DisableMgr.ReEnable() Return End If Dim bMake As Boolean = (EgtGetGroupObjs(AsseId) = 0) If bMake <> bShow Then DisableMgr.ReEnable() Return End If ' ciclo sul gruppo di assemblaggio While AsseId <> GDB_ID.NULL ' salvo il successivo nel gruppo dell'assemblato Dim NextId As Integer = EgtGetNext(AsseId) ' costruisco l'assemblato If bMake Then ' recupero il pezzo sorgente Dim SouId As Integer If EgtGetInfo(AsseId, GDB_SI_SOURCE, SouId) Then EgtSetMode(SouId, GDB_MD.STD) EgtSetStatus(SouId, GDB_ST.ON_) ' se già utilizzato, ne faccio una copia If Not EgtIsPart(SouId) Then Dim CopyId As Integer = EgtCopy(SouId, GDB_ID.ROOT) If CopyId <> GDB_ID.NULL Then EgtRemoveInfo(CopyId, GDB_SI_BASE) EgtRemoveInfo(CopyId, GDB_SI_LIST) EgtSetInfo(CopyId, GDB_SI_COPY, SouId) EgtSetInfo(AsseId, GDB_SI_SOURCE, CopyId) SouId = CopyId End If End If EgtSetStatus(EgtGetFirstNameInGroup(SouId, "Box"), GDB_ST.OFF) EgtGroupSwap(SouId, AsseId, True, True) End If ' ritorno ai pezzi Else Dim BasId As Integer If EgtGetInfo(AsseId, GDB_SI_BASE, BasId) Then EgtGroupSwap(AsseId, BasId, True, True) Dim CopId As Integer If EgtGetInfo(AsseId, GDB_SI_COPY, CopId) Then EgtErase(AsseId) EgtSetInfo(BasId, GDB_SI_SOURCE, CopId) Else EgtSetStatus(EgtGetFirstNameInGroup(AsseId, "Box"), GDB_ST.ON_) End If End If End If ' passo al successivo AsseId = NextId End While ' ripristino precedente impostazione modificato DisableMgr.ReEnable() ' aggiorno visualizzazione Core.ViewPanelVM.BWSetView(VT.ISO_SW, False) EgtZoom(ZM.ALL, bRedraw) End Sub Friend Sub ShowSolid(Optional bRedraw As Boolean = True) ' Recupero il pezzo del primo oggetto selezionato Dim nPartId As Integer = If(Not IsNothing(SelBTLPart), SelBTLPart.nPartId, GDB_ID.NULL) If nPartId = GDB_ID.NULL Or Not EgtIsPart(nPartId) Then Map.refMyStatusBarVM.SetOutputMessage("ERROR: Nessuna trave selezionata ", 5, MSG_TYPE.ERROR_) Return End If EgtDeselectAll() ' disabilito impostazione modificato Dim DisableMgr As New DisableModifiedMgr Dim nSolId As Integer = EgtBeamGetSolid(nPartId) If nSolId = GDB_ID.NULL OrElse Not EgtExistsInfo(nSolId, "VALID") Then EgtBeamCalcSolid(nPartId) EgtBeamShowSolid(nPartId, True) Else Dim nStat As Integer EgtGetStatus(EgtGetParent(nSolId), nStat) EgtBeamShowSolid(nPartId, (nStat = GDB_ST.OFF)) End If 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 bMaterialOk As Boolean = True Dim bSectionOk As Boolean = True Dim bSearchTextOk As Boolean = True If SelMaterial <> "" AndAlso CurrBTLPart.sMATERIAL <> SelMaterial Then bMaterialOk = False If SelSection <> SectionXMaterial.Empty AndAlso CurrBTLPart.Section <> SelSection Then bSectionOk = False 'If SearchText <> "" AndAlso CurrBTLPart.sNAM.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) < 0 Then bSectionOk = 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) OrElse (m_SelSearchParam.Id = BTLPartParam.GRP AndAlso (IsNothing(CurrBTLPart.sGROUP) OrElse CurrBTLPart.sGROUP.ToString.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase)) < 0)) Then bSectionOk = False Return (bMaterialOk AndAlso bSectionOk) End Function Private Function MaterialFilter(Material As Object) As Boolean Dim CurrMaterial As String = DirectCast(Material, String) Dim bOk As Boolean = True If SelSection <> SectionXMaterial.Empty AndAlso SearchText <> "" AndAlso CurrMaterial <> "" Then bOk = m_BTLPartVMList.Any(Function(x) x.sMATERIAL = CurrMaterial AndAlso x.Section = SelSection AndAlso 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 SelMaterial <> "" AndAlso SearchText <> "" AndAlso CurrSection <> Section.Empty Then bOk = m_BTLPartVMList.Any(Function(x) x.sMATERIAL = SelMaterial AndAlso x.Section = CurrSection AndAlso 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 'If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then ' 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 'ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then ' ' se ruoto o inverto parete, la sezione non cambia 'End If End Sub ' funzione che aggiorna totale tempi a fine calcolo Friend Sub CalcGlobalTime() NotifyPropertyChanged(NameOf(sBTLTotTime)) 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(sBTLRemainingTime)) End Sub ' funzione utilizata per aggiornare rot e flip dopo calcolo Public Function RefreshRotFlip() As Boolean 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 Function #End Region ' METHODS #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 e.PropertyName Case NameOf(sender.sMATERIAL) If Not MaterialList.Contains(sender.sMATERIAL) Then MaterialList.Add(sender.sMATERIAL) End If Case NameOf(sender.sW), NameOf(sender.sH), NameOf(sender.sL) 'If Not SectionList.Contains(sender.Section) Then ' SectionList.Add(sender.Section) 'End If 'Case NameOf(sender.sROTATED) ' UpdateSection(CType(sender, BTLPartVM).BTLPartM) Case NameOf(sender.nDONE) NotifyPropertyChanged(NameOf(sBTLRemainingTime)) End Select End Sub #End Region ' EVENTS End Class