From b05bc34ebb3342310f5178e8d0211dc20bb0fa6a Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 7 Sep 2017 18:22:58 +0000 Subject: [PATCH] OmagOFFICE : - gestione inserimento pezzi in VeinMatching da parametrico e Csv - correzioni e migliorie a VeinMatching - correzioni su OpenProject. --- CompoWindow/CompoWindowVM.vb | 39 +++--- Constants/ConstIni.vb | 1 + DxfImportWindow/DxfImportWindowVM.vb | 5 +- EgtStoneLib/CsvM.vb | 62 ++++----- EgtStoneLib/VeinMatchingWindow.xaml | 9 +- EgtStoneLib/VeinMatchingWindow.xaml.vb | 161 ++++++++++++++++++++--- MainWindow/MainWindowM.vb | 16 +-- MainWindow/MainWindowVM.vb | 2 + OptionPanel/NestingTab/NestingTabVM.vb | 12 +- OptionWindow/OptionWindowV.xaml | 30 ++++- OptionWindow/OptionWindowVM.vb | 38 +++++- SceneHost/SceneHostV.xaml.vb | 9 +- SideEntityControl/SideEntityControlVM.vb | 37 +++--- 13 files changed, 308 insertions(+), 113 deletions(-) diff --git a/CompoWindow/CompoWindowVM.vb b/CompoWindow/CompoWindowVM.vb index 920e9a6..f0a5642 100644 --- a/CompoWindow/CompoWindowVM.vb +++ b/CompoWindow/CompoWindowVM.vb @@ -228,6 +228,9 @@ Public Class CompoWindowVM AdjustFlatPart(nId2) ' Inserisco in parcheggio EstCalc.StoreOnePart(nId2, True) + ' Aggiungo riferimento e lo inserisco in VeinMatching + VeinMatching.SetRefOnPart(nId2) + VeinMatching.AddPart(nId2, True) ' Se richiesto posizionamento diretto, lo eseguo If bDirect Then If EstCalc.InsertOnePart(nId2, CurrentMachine.bAligned, CurrentMachine.bReducedCut) Then @@ -277,25 +280,28 @@ Public Class CompoWindowVM ' Se presente lo svuoto If TextLayer <> GDB_ID.NULL Then EgtEmptyGroup(TextLayer) - ' altrimenti lo creo + ' altrimenti lo creo Else TextLayer = EgtCreateGroup(Pz) EgtSetName(TextLayer, SIDE_ANGLE_LAYER) End If - '' Modifico inclinazione lati - 'For Each Entity In m_SideAngle.m_SideAngleEntityList - ' Dim nCurrEntityName As Integer = EgtGetFirstNameInGroup(nOutLoopLayer, Entity.sEntityName) - ' If Math.Abs(Entity.dSideAngle) > EPS_ANG_SMALL Then - ' ' Scrivo nuovo angolo nelle info - ' EgtSetInfo(nCurrEntityName, INFO_SIDE_ANGLE, Entity.dSideAngle) - ' ' Creo testo con angolo di inclinazione per nesting - ' Dim sText As String = DoubleToString(Entity.dSideAngle, 1) & "°" - ' SideAngleUC.AddTextToLine(sText, TextLayer, nCurrEntityName, 10, dBBoxRad, False) - ' Else - ' ' Cancello inclinazione nell'apposito campo info - ' EgtRemoveInfo(nCurrEntityName, INFO_SIDE_ANGLE) - ' End If - 'Next + ' Modifico inclinazione lati + If Not IsNothing(CompoWindowMap.refCompoParamPageVM.m_SideAngleEntityList) Then + For Each Entity In CompoWindowMap.refCompoParamPageVM.m_SideAngleEntityList + Dim CurrSideAngleEntity As SideAngleEntity = DirectCast(Entity, SideAngleEntity) + Dim nCurrEntityName As Integer = EgtGetFirstNameInGroup(nOutLoopLayer, Entity.sEntityName) + If Math.Abs(CurrSideAngleEntity.dSideAngle) > EPS_ANG_SMALL Then + ' Scrivo nuovo angolo nelle info + EgtSetInfo(nCurrEntityName, INFO_SIDE_ANGLE, CurrSideAngleEntity.dSideAngle) + ' Creo testo con angolo di inclinazione per nesting + Dim sText As String = DoubleToString(CurrSideAngleEntity.dSideAngle, 1) & "°" + SideEntityControlVM.AddTextToLine(sText, TextLayer, nCurrEntityName, 10, dBBoxRad, False) + Else + ' Cancello inclinazione nell'apposito campo info + EgtRemoveInfo(nCurrEntityName, INFO_SIDE_ANGLE) + End If + Next + End If ' Esporto il pezzo in un file temporaneo Dim sTmpFile As String = OmagOFFICEMap.refMainWindowVM.MainWindowM.sTempDir & "\FlatPartCompo.Nge" If Not EgtSaveObjToFile(1, sTmpFile, NGE.BIN) Then @@ -335,6 +341,9 @@ Public Class CompoWindowVM AdjustFlatPart(nId2) ' Inserisco in parcheggio EstCalc.StoreOnePart(nId2, True) + ' Aggiungo riferimento e lo inserisco in VeinMatching + VeinMatching.SetRefOnPart(nId2) + VeinMatching.AddPart(nId2, True) ' Se richiesto posizionamento diretto, lo eseguo If bDirect Then If EstCalc.InsertOnePart(nId2, CurrentMachine.bAligned, CurrentMachine.bReducedCut) Then diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb index 859f917..69de6e1 100644 --- a/Constants/ConstIni.vb +++ b/Constants/ConstIni.vb @@ -99,6 +99,7 @@ Module ConstIni Public Const K_SNAPDIST As String = "SnapDist" Public Const S_CSV As String = "Csv" + Public Const K_CSVDIRECT As String = "Direct" Public Const K_MAXDIMONX As String = "MaxDimOnX" Public Const K_CSVCURRDIR As String = "CurrDir" Public Const K_CSVLASTFILE As String = "LastFile" diff --git a/DxfImportWindow/DxfImportWindowVM.vb b/DxfImportWindow/DxfImportWindowVM.vb index 0852285..7b756db 100644 --- a/DxfImportWindow/DxfImportWindowVM.vb +++ b/DxfImportWindow/DxfImportWindowVM.vb @@ -327,10 +327,9 @@ Public Class DxfImportWindowVM End Function Friend Sub LoadFlatParts() - ' Scrivo testi per nesting - 'm_SideAngleUC.WriteSideAngleForNest(ImportScene.GetCtx()) ' Imposto riferimento sul centro geometrico di ogni pezzo - VeinMatching.SetRefOnAllParts(DxfImportWindowMap.refDxfImportSceneHostV.ImportDxfScene.GetCtx()) + EgtSetCurrentContext(DxfImportWindowMap.refDxfImportSceneHostV.ImportDxfScene.GetCtx()) + VeinMatching.SetRefOnAllParts() ' Eventuale pulizia VeinMatching VeinMatching.Clear() ' Vettore nomi file temporanei diff --git a/EgtStoneLib/CsvM.vb b/EgtStoneLib/CsvM.vb index c92425d..e85e0a2 100644 --- a/EgtStoneLib/CsvM.vb +++ b/EgtStoneLib/CsvM.vb @@ -186,10 +186,11 @@ Module CsvM EgtLuaResetGlobVar("CMP") EgtLuaResetGlobVar("CMP_Draw") ' Provo ad inserire i pezzi + Dim bDirect As Boolean = (GetMainPrivateProfileInt(S_CSV, K_CSVDIRECT, 1) <> 0) For i As Integer = 1 To InsPartList.Count() Dim CurrPart As CsvPart = InsPartList(i - 1) While CurrPart.m_nToNest > 0 - If PackOnePart(CurrPart.m_nId) Then + If PackOnePart(CurrPart.m_nId, bDirect) Then CurrPart.m_nToNest -= 1 Else Exit While @@ -199,47 +200,38 @@ Module CsvM Return True End Function - Private Function PackOnePart(nId As Integer) As Boolean - ' Dimensioni del pezzo - Dim ptPartMin, ptPartMax As Point3d - If Not EgtGetBBox(nId, GDB_BB.IGNORE_DIM + GDB_BB.IGNORE_TEXT, ptPartMin, ptPartMax) Then Return False - Dim dPartLen As Double = ptPartMax.x - ptPartMin.x - Dim dPartHeight As Double = ptPartMax.y - ptPartMin.y - ' Centro del grezzo - Dim nRawCenId = EgtGetFirstNameInGroup(EstCalc.GetRawId(), NAME_RAW_CENTER) - Dim ptRawCenter As Point3d - EgtStartPoint(nRawCenId, GDB_ID.ROOT, ptRawCenter) - Dim dRawCenX = ptRawCenter.x - EstCalc.GetRawPtMin().x - Dim dRawCenY = ptRawCenter.y - EstCalc.GetRawPtMin().y - ' Inserisco il pezzo nel grezzo, in centro in XY e in alto in Z - Dim ptP As New Point3d(dRawCenX - 0.5 * dPartLen, dRawCenY - 0.5 * dPartHeight, EstCalc.GetRawHeight()) - ' Ne creo una copia nella radice + Private Function PackOnePart(nId As Integer, bDirect As Boolean) As Boolean + ' Creo una copia del pezzo nella radice Dim nId2 As Integer = EgtCopyGlob(nId, GDB_ID.ROOT) - If EgtAddPartToRawPart(nId2, ptP, EstCalc.GetRawId()) Then - ' Aggiungo le lavorazioni standard - AddMachinings(nId2, True, False) - ' Eseguo nesting - Dim bFit As Boolean = False - If EstCalc.UpdateNestRegions() Then - Dim bAligned As Boolean = (GetMainPrivateProfileInt(S_MACH_NEST, K_MACH_NEST_ALIGNED, 0) <> 0) - EstCalc.EnableReferenceRegion(bAligned) - If Not EgtExistsInfo(EstCalc.GetRawId(), KEY_RAWBYPOINTS) Then - bFit = EgtPackPartInRectangle(nId2, True, True) - End If - If Not bFit Then - bFit = EgtPackPart(nId2, True, True) - End If - End If - ' Gestione risultato nesting - If bFit Then + If nId2 = GDB_ID.NULL Then Return False + ' Lo inserisco direttamente + If bDirect Then + ' Aggiungo riferimento e lo inserisco in VeinMatching + VeinMatching.SetRefOnPart(nId2) + VeinMatching.AddPart(nId2, True) + ' Provo inserimento in lastra + If EstCalc.InsertOnePart(nId2, CurrentMachine.bAligned, CurrentMachine.bReducedCut) Then + ' Eventuale notifica al VeinMatching + VeinMatching.OnInsertPartInRaw(nId2) Return True Else + ' Eventuale cancellazione per VM + VeinMatching.OnRemovePart(nId2) + ' Cancellazione del pezzo EraseMachinings(nId2) EgtRemovePartFromRawPart(nId2) EgtErase(nId2) + Return False End If + ' altrimenti lo metto in parcheggio + Else + ' Aggiungo riferimento e lo inserisco in VeinMatching + VeinMatching.SetRefOnPart(nId2) + VeinMatching.AddPart(nId2, True) + ' Inserisco in parcheggio + EstCalc.StoreOnePart(nId2, True) + Return True End If - Return False End Function Public Sub Remove(ByRef bOther As Boolean, ByRef sOtherCsv As String) @@ -284,6 +276,8 @@ Module CsvM ' Rimuovo dal grezzo EgtRemovePartFromRawPart(nId) End If + ' Eventuale cancellazione per VM + VeinMatching.OnRemovePart(nId) ' Cancello il pezzo EgtErase(nId) ' Aggiorno il contatore diff --git a/EgtStoneLib/VeinMatchingWindow.xaml b/EgtStoneLib/VeinMatchingWindow.xaml index 41775df..a314fa6 100644 --- a/EgtStoneLib/VeinMatchingWindow.xaml +++ b/EgtStoneLib/VeinMatchingWindow.xaml @@ -10,9 +10,12 @@ -