OmagOFFICE 2.2a4 :

- drag diretto del pezzo da parcheggio a lastra
- archi lavorati all'esterno con possibilità di inclinazione
- possibilità di allungare e accorciare gli estremi dei tagli di una quantità a piacere
- possibilità di bloccare la rotazione dei pezzi
- possibilità di nesting automatico.
This commit is contained in:
Dario Sassi
2020-01-27 14:49:11 +00:00
parent 73c63ab290
commit a4f75be46e
28 changed files with 963 additions and 210 deletions
+299 -73
View File
@@ -25,6 +25,7 @@ Public Class NestingTabVM
Private m_bDrag As Boolean = False
Private m_bDragToStart As Boolean = False
Private m_bVerify As Boolean = False
Private m_bFromParking As Boolean = False
Private m_bDragging As Boolean = False
Private m_locPrev As System.Drawing.Point
Private m_ptPrev As Point3d
@@ -147,6 +148,8 @@ Public Class NestingTabVM
' Definizione comandi
Private m_cmdDraw As ICommand
Private m_cmdImportDxf As ICommand
Private m_cmdPartRotOn As ICommand
Private m_cmdPartRotOff As ICommand
Private m_cmdUp As ICommand
Private m_cmdLeft As ICommand
Private m_cmdRight As ICommand
@@ -207,6 +210,111 @@ Public Class NestingTabVM
Return True
End Function
Private Sub StandardInsert()
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
Dim bWrongTrf As Boolean = False
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
' Ciclo di inserimento in tavola dei pezzi selezionati
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
' Recupero successivo selezionato
Dim nNextId = EgtGetNextSelectedObj()
' Se pezzo da Trf, verifico compatibilità
If Not VerifyTrfData(nId) Then
bWrongTrf = True
EgtSetStatus(nId, GDB_ST.ON_)
' Passo al successivo selezionato
nId = nNextId
Continue While
End If
' Lo metto in tavola, se possibile
If EstCalc.InsertOnePart(nId, CurrentMachine.bAligned, CurrentMachine.bReducedCut) Then
' Eventuale notifica al VeinMatching
VeinMatching.OnInsertPartInRaw(nId)
Else
VeinMatching.OnDeselectPart(nId)
End If
' Costringo ad aggiornare UI
UpdateUI()
' Passo al successivo selezionato
nId = nNextId
End While
' Aggiorno flag selezionati
m_nPartPos = If(EgtGetSelectedObjCount() > 0, PART_POS.IN_TABLE, PART_POS.NONE_TABLE)
' Aggiorno vista
EgtZoom(ZM.ALL)
' Eventuale segnalazione di pezzi Trf non adatti
If bWrongTrf Then
' Pezzi con spessore, materiale o finitura non compatibili
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_NESTPAGEUC + 7), MSG_TYPE.WARNING)
End If
End Sub
Private Sub AutomaticInsert()
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
OmagOFFICEMap.refStatusBarVM.SetOutputMessage( EgtMsg( 90340)) ' Nesting Automatico in corso
Dim bWrongTrf As Boolean = False
Dim vParts As New List(Of Integer)
' Ciclo di pre-inserimento in tavola dei pezzi selezionati
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
' Recupero successivo selezionato
Dim nNextId = EgtGetNextSelectedObj()
' Se pezzo da Trf, verifico compatibilità
If Not VerifyTrfData(nId) Then
bWrongTrf = True
EgtSetStatus(nId, GDB_ST.ON_)
' Passo al successivo selezionato
nId = nNextId
Continue While
End If
' Lo preparo in tavola, se possibile
If PreInsertOnePart(nId) Then
vParts.Add( nId)
Else
EgtSetStatus(nId, GDB_ST.ON_)
VeinMatching.OnDeselectPart(nId)
End If
' Costringo ad aggiornare UI
UpdateUI()
' Passo al successivo selezionato
nId = nNextId
End While
' Aggiorno le regioni per il nesting
UpdateNestRegions()
Dim bAligned As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_NEST_ALIGNED, 0, CurrentMachine.sMachIniFile) <> 0)
EnableReferenceRegion(bAligned)
' Eseguo nesting automatico
Dim bOpimizeOnX As Boolean = ( GetMainPrivateProfileInt( S_NEST, K_AUTOMATICOPTIMIZE, 2) = 1)
Dim nAutomaticMaxTime As Integer = GetMainPrivateProfileInt( S_NEST, K_AUTOMATICMAXTIME, 20)
Dim nMaxTime As Integer = Math.Min( 2 + 0.5 * vParts.Count(), nAutomaticMaxTime)
EgtAutomaticPackParts( vParts, bOpimizeOnX, CurrentMachine.bReducedCut, nMaxTime)
' Sistemo i pezzi
For Each nPartId As Integer In vParts
' se pezzo inserito
If nPartId > 0 Then
VeinMatching.OnInsertPartInRaw(nPartId)
' Eventuale aggiunta solido per taglio da sotto
UpdateSolidForDrip(nPartId)
' altrimenti rifiutato
else
' Ripristino lo stato originale
PreRemoveOnePart( Math.Abs( nPartId))
VeinMatching.OnDeselectPart( Math.Abs( nPartId))
End If
Next
' Aggiorno flag selezionati
m_nPartPos = If(EgtGetSelectedObjCount() > 0, PART_POS.IN_TABLE, PART_POS.NONE_TABLE)
' Aggiorno vista
EgtZoom(ZM.ALL)
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
' Eventuale segnalazione di pezzi Trf non adatti
If bWrongTrf Then
' Pezzi con spessore, materiale o finitura non compatibili
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_NESTPAGEUC + 7), MSG_TYPE.WARNING)
End If
End Sub
Private Function RotateCluster(ByVal dAngRotDeg As Double) As Boolean
' Se non ci sono pezzi selezionati, esco
If EgtGetSelectedObjCount() = 0 Then Return True
@@ -215,31 +323,60 @@ Public Class NestingTabVM
If m_nPartPos <> PART_POS.IN_TABLE Then
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
' Calcolo il centro di rotazione come centro del pezzo
Dim ptCen As Point3d
If Not EgtGetPartPartClusterCenterGlob(nId, ptCen) Then Return False
' Rotazione del pezzo attorno al suo centro
EgtRotate(nId, ptCen, Vector3d.Z_AX(), dAngRotDeg, GDB_RT.GLOB)
' Sistemazione nel parcheggio
PackPartInStore(nId)
' Se pezzo con rotazione libera
If Not EgtExistsInfo( nId, INFO_PARTROT) Then
' Calcolo il centro di rotazione come centro del pezzo
Dim ptCen As Point3d
If Not EgtGetPartPartClusterCenterGlob(nId, ptCen) Then Return False
' Rotazione del pezzo attorno al suo centro
EgtRotate(nId, ptCen, Vector3d.Z_AX(), dAngRotDeg, GDB_RT.GLOB)
' Sistemazione nel parcheggio
PackPartInStore(nId)
End If
' Passo al successivo selezionato
nId = EgtGetNextSelectedObj()
End While
Return True
' Altrimenti li ruoto tenendo conto delle collisioni
Else
' Calcolo il centro di rotazione come centro del cluster
Dim ptCen As Point3d
If Not EgtGetPartPartClusterCenterGlob(GDB_ID.SEL, ptCen) Then Return False
' Aggiorno regioni per nesting
UpdateNestRegions()
EnableReferenceRegion(False)
' Verifico rotazione complessiva
EgtRotate(GDB_ID.SEL, ptCen, Vector3d.Z_AX(), dAngRotDeg, GDB_RT.GLOB)
If EgtVerifyPart(GDB_ID.SEL, CurrentMachine.bReducedCut) Then Return True
' Provo rotazione parziale (dopo aver annullato la complessiva)
EgtRotate(GDB_ID.SEL, ptCen, Vector3d.Z_AX(), -dAngRotDeg, GDB_RT.GLOB)
Return EgtRotatePart(GDB_ID.SEL, CurrentMachine.bReducedCut, ptCen, dAngRotDeg)
' Verifico se ci sono dei pezzi bloccati in rotazione
Dim bLockedRot As Boolean = GetLockOnRotation( GDB_ID.SEL)
' Se tutti i pezzi possono ruotare
If Not bLockedRot Then
' Calcolo il centro di rotazione come centro del cluster
Dim ptCen As Point3d
If Not EgtGetPartPartClusterCenterGlob(GDB_ID.SEL, ptCen) Then Return False
' Aggiorno regioni per nesting
UpdateNestRegions()
EnableReferenceRegion(False)
' Verifico rotazione complessiva
EgtRotate(GDB_ID.SEL, ptCen, Vector3d.Z_AX(), dAngRotDeg, GDB_RT.GLOB)
If EgtVerifyPart(GDB_ID.SEL, CurrentMachine.bReducedCut) Then Return True
' Provo rotazione parziale (dopo aver annullato la complessiva)
EgtRotate(GDB_ID.SEL, ptCen, Vector3d.Z_AX(), -dAngRotDeg, GDB_RT.GLOB)
Return EgtRotatePart(GDB_ID.SEL, CurrentMachine.bReducedCut, ptCen, dAngRotDeg)
Else
Return False
End If
End If
End Function
Private Function GetLockOnRotation( nPartId As Integer) As Boolean
' Se singolo pezzo
If nPartId <> GDB_ID.SEL Then
Return EgtExistsInfo( nPartId, INFO_PARTROT)
' Altrimenti tutti i selezionati
Else
Dim bLockedRot As Boolean = False
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
If EgtExistsInfo( nId, INFO_PARTROT) Then
bLockedRot = True
Exit While
End If
nId = EgtGetNextSelectedObj()
End While
Return bLockedRot
End If
End Function
@@ -348,6 +485,94 @@ Public Class NestingTabVM
#End Region ' ImportDxfCommand
#Region "PartRotOnCommand"
Public ReadOnly Property PartRotOnCommand As ICommand
Get
If m_cmdPartRotOn Is Nothing Then
m_cmdPartRotOn = New Command(AddressOf PartRotOn)
End If
Return m_cmdPartRotOn
End Get
End Property
Public Sub PartRotOn(ByVal param As Object)
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
' Se non ci sono pezzi selezionati o non sono in parcheggio, esco
If EgtGetSelectedObjCount() = 0 OrElse m_nPartPos <> PART_POS.OUT_TABLE Then Return
' Tolgo blocco rotazione sui pezzi selezionati
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
' Se rotazione bloccata, tolgo blocco e aggiorno info
If EgtExistsInfo( nId, INFO_PARTROT) Then
' Rimuovo flag di rotazione bloccata
EgtRemoveInfo( nId, INFO_PARTROT)
' Tolgo da info sul pezzo Codice
Dim nTextId As Integer = EgtGetFirstInGroup( EgtGetFirstNameInGroup( nId, NAME_REGION))
While nTextId <> GDB_ID.NULL
If EgtGetType( nTextId) = GDB_TY.EXT_TEXT Then
Dim sText As String = ""
EgtTextGetContent( nTextId, sText)
sText = sText.Replace( "<br/>(X)", "")
EgtModifyText( nTextId, sText)
Exit While
End If
nTextId = EgtGetNext( nTextId)
End While
End If
' Passo al successivo selezionato
nId = EgtGetNextSelectedObj()
End While
' Aggiorno visualizzazione
EgtDraw()
End Sub
#End Region ' PartRotOnCommand
#Region "PartRotOffCommand"
Public ReadOnly Property PartRotOffCommand As ICommand
Get
If m_cmdPartRotOff Is Nothing Then
m_cmdPartRotOff = New Command(AddressOf PartRotOff)
End If
Return m_cmdPartRotOff
End Get
End Property
Public Sub PartRotOff(ByVal param As Object)
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
' Se non ci sono pezzi selezionati o non sono in parcheggio, esco
If EgtGetSelectedObjCount() = 0 OrElse m_nPartPos <> PART_POS.OUT_TABLE Then Return
' Metto blocco rotazione sui pezzi selezionati
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
' Se rotazione libera, applico blocco e aggiorno info
If Not EgtExistsInfo( nId, INFO_PARTROT) Then
' Imposto flag di rotazione bloccata
EgtSetInfo( nId, INFO_PARTROT, 0)
' Inserisco in info sul pezzo Codice
Dim nTextId As Integer = EgtGetFirstInGroup( EgtGetFirstNameInGroup( nId, NAME_REGION))
While nTextId <> GDB_ID.NULL
If EgtGetType( nTextId) = GDB_TY.EXT_TEXT Then
Dim sText As String = ""
EgtTextGetContent( nTextId, sText)
sText &= "<br/>(X)"
EgtModifyText( nTextId, sText)
Exit While
End If
nTextId = EgtGetNext( nTextId)
End While
End If
' Passo al successivo selezionato
nId = EgtGetNextSelectedObj()
End While
' Aggiorno visualizzazione
EgtDraw()
End Sub
#End Region ' PartRotOffCommand
#Region "UpCommand"
Public ReadOnly Property UpCommand As ICommand
@@ -372,7 +597,9 @@ Public Class NestingTabVM
Dim bAlignMoved As Boolean = False
Dim bSnapMoved As Boolean = False
If m_bMagnetic Then
EgtAlignPartOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, bAlignMoved)
If Not GetLockOnRotation( GDB_ID.SEL) Then
EgtAlignPartOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, bAlignMoved)
End If
If m_dSnapDist > EPS_SMALL Then
EgtRestoreCollInfo()
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, m_dSnapDist, bSnapMoved)
@@ -414,7 +641,9 @@ Public Class NestingTabVM
Dim bAlignMoved As Boolean = False
Dim bSnapMoved As Boolean = False
If m_bMagnetic Then
EgtAlignPartOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, bAlignMoved)
If Not GetLockOnRotation( GDB_ID.SEL) Then
EgtAlignPartOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, bAlignMoved)
End If
If m_dSnapDist > EPS_SMALL Then
EgtRestoreCollInfo()
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, m_dSnapDist, bSnapMoved)
@@ -456,7 +685,9 @@ Public Class NestingTabVM
Dim bAlignMoved As Boolean = False
Dim bSnapMoved As Boolean = False
If m_bMagnetic Then
EgtAlignPartOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, bAlignMoved)
If Not GetLockOnRotation( GDB_ID.SEL) Then
EgtAlignPartOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, bAlignMoved)
End If
If m_dSnapDist > EPS_SMALL Then
EgtRestoreCollInfo()
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, m_dSnapDist, bSnapMoved)
@@ -498,7 +729,9 @@ Public Class NestingTabVM
Dim bAlignMoved As Boolean = False
Dim bSnapMoved As Boolean = False
If m_bMagnetic Then
EgtAlignPartOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, bAlignMoved)
If Not GetLockOnRotation( GDB_ID.SEL) Then
EgtAlignPartOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, bAlignMoved)
End If
If m_dSnapDist > EPS_SMALL Then
EgtRestoreCollInfo()
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, m_dSnapDist, bSnapMoved)
@@ -580,42 +813,13 @@ Public Class NestingTabVM
End Property
Public Sub InsertPart(ByVal param As Object)
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
Dim bWrongTrf As Boolean = False
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
' Ciclo di inserimento in tavola dei pezzi selezionati
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
' Recupero successivo selezionato
Dim nNextId = EgtGetNextSelectedObj()
' Se pezzo da Trf, verifico compatibilità
If Not VerifyTrfData(nId) Then
bWrongTrf = True
EgtSetStatus(nId, GDB_ST.ON_)
' Passo al successivo selezionato
nId = nNextId
Continue While
End If
' Lo metto in tavola, se possibile
If EstCalc.InsertOnePart(nId, CurrentMachine.bAligned, CurrentMachine.bReducedCut) Then
' Eventuale notifica al VeinMatching
VeinMatching.OnInsertPartInRaw(nId)
Else
VeinMatching.OnDeselectPart(nId)
End If
' Costringo ad aggiornare UI
UpdateUI()
' Passo al successivo selezionato
nId = nNextId
End While
' Aggiorno flag selezionati
m_nPartPos = If(EgtGetSelectedObjCount() > 0, PART_POS.IN_TABLE, PART_POS.NONE_TABLE)
' Aggiorno vista
EgtZoom(ZM.ALL)
' Eventuale segnalazione di pezzi Trf non adatti
If bWrongTrf Then
' Pezzi con spessore, materiale o finitura non compatibili
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_NESTPAGEUC + 7), MSG_TYPE.WARNING)
' Se inserimento automatico
If CurrentMachine.bAutomatic And
OmagOFFICEMap.refMainWindowVM.MainWindowM.AutoNestOption() Then
AutomaticInsert()
' altrimenti inserimento standard
Else
StandardInsert()
End If
End Sub
@@ -879,9 +1083,25 @@ Public Class NestingTabVM
End If
' Determino cosa muovere
Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL)
' Verifico se in tavola
' Verifico se in tavola o in parcheggio
Dim nTestId = If(nMoveId <> GDB_ID.SEL, nMoveId, EgtGetFirstSelectedObj())
If (EgtGetParent(nTestId) <> GetRawId()) Then Return
If EgtGetParent(nTestId) <> GetRawId() Then
' Dal parcheggio ammesso drag di un singolo pezzo
If nMoveId = GDB_ID.SEL Then Return
' Applico le lavorazioni al pezzo
Dim b3Curr As new BBox3d
EgtGetBBoxGlob( EgtGetFirstNameInGroup(nTestId, NAME_REGION), BBFLAG, b3Curr)
if Not EstCalc.PreInsertOnePart( nTestId) Then Return
Dim b3Ins As new BBox3d
EgtGetBBoxGlob( EgtGetFirstNameInGroup( nTestId, NAME_REGION), BBFLAG, b3Ins)
Dim vtDiff As new Vector3d( b3Curr.Min().x - b3Ins.Min().x, b3Curr.Min().y - b3Ins.Min().y, 0)
EgtMove( nMoveId, vtDiff)
' Gestione VeinMatching
VeinMatching.OnInsertPartInRaw( nMoveId)
' Imposto stato
m_bVerify = True
m_bFromParking = True
End If
' Inizio esecuzione di drag
m_bDragging = True
' Ricavo il punto corrente in coordinate mondo
@@ -915,7 +1135,9 @@ Public Class NestingTabVM
Dim bAlignMoved As Boolean = False
Dim bSnapMoved As Boolean = False
If m_bMagnetic Then
EgtAlignPartOnCollision(nMoveId, CurrentMachine.bReducedCut, bAlignMoved)
If Not GetLockOnRotation( nMoveId) Then
EgtAlignPartOnCollision(nMoveId, CurrentMachine.bReducedCut, bAlignMoved)
End If
If m_dSnapDist > EPS_SMALL Then
EgtRestoreCollInfo()
EgtMovePartToSnapPointOnCollision(nMoveId, CurrentMachine.bReducedCut, m_dSnapDist, bSnapMoved)
@@ -936,7 +1158,6 @@ Public Class NestingTabVM
End If
End If
' Aggiorno il punto precedente
'm_ptPrev += vtMove
m_ptPrev = ptCurr
' Terminata esecuzione di drag
m_bDragging = False
@@ -957,19 +1178,24 @@ Public Class NestingTabVM
EstCalc.ResetOrderMachiningFlag()
' Non superata riporto alla posizione iniziale
Else
EgtMove(nMoveId, -m_vtTotMove)
EgtDraw()
' Eventuale notifica al VeinMatching
If nMoveId = GDB_ID.SEL Then
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
VeinMatching.OnMovePartInRaw(nId)
nId = EgtGetNextSelectedObj()
End While
If m_bFromParking Then
PreRemoveOnePart( nMoveId)
VeinMatching.OnRemovePartFromRaw( nMoveId)
Else
VeinMatching.OnMovePartInRaw(nMoveId)
EgtMove(nMoveId, -m_vtTotMove)
' Eventuale notifica al VeinMatching
If nMoveId = GDB_ID.SEL Then
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
VeinMatching.OnMovePartInRaw(nId)
nId = EgtGetNextSelectedObj()
End While
Else
VeinMatching.OnMovePartInRaw(nMoveId)
End If
End If
End If
m_bFromParking = False
' altrimenti caso con verifica durante il movimento
Else
' Basta reset alla fine