diff --git a/CadCuts/NestPageUC.xaml.vb b/CadCuts/NestPageUC.xaml.vb index 3dff327..2e85fd7 100644 --- a/CadCuts/NestPageUC.xaml.vb +++ b/CadCuts/NestPageUC.xaml.vb @@ -345,586 +345,6 @@ Public Class NestPageUC Return End Sub - ' funzione per la selezione dei lati su cui operare la separazione del tagli waterjet - Private Sub OnMyMouseDownSceneSplitCurv(sender As Object, e As System.Windows.Forms.MouseEventArgs) - ' Verifico di essere il gestore attivo e non in modalità registrazione - If Not m_bActive Or m_bRegister Then Return - ' Se non abilitata separazione lato waterjet o bottone mouse non Left, esco - If Not m_bIsCheckedSplitCurveWJ Or e.Button <> Windows.Forms.MouseButtons.Left Then Return - - EgtResetMark(m_nIdSelectedWaterJet) - ' Imposto riconoscimento entità in finestra di selezione - EgtSetObjFilterForSelWin(False, True, False, False, False) - Dim nSelMy As Integer - EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSelMy) - ' Ciclo su entità in finestra di selezione - Dim nMyId As Integer = EgtGetFirstObjInSelWin() - While nMyId <> GDB_ID.NULL - ' Recupero layer di appartenenza e suo nome - Dim nLayerId As Integer = EgtGetParent(nMyId) - Dim sLayer As String = String.Empty - EgtGetName(nLayerId, sLayer) - ' solo se il nome del layer è quello associato ad un lato esterno allora procedo con l'evidenziazione - If sLayer = NAME_OUTLOOP Then - If EgtGetType(nMyId) = GDB_TY.CRV_ARC OrElse EgtGetType(nMyId) = GDB_TY.CRV_COMPO OrElse EgtGetType(nMyId) = GDB_TY.CRV_LINE Then - If m_nIdSelectedSideWJ <> GDB_ID.NULL Or m_nIdSelectedSideWJ = nMyId Then - EgtDeselectObj(m_nIdSelectedSideWJ) - End If - ' recupero il gruppo della lavorazione associata - Dim nPartId As Integer = EgtGetParent(nLayerId) - Dim nPartPvId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_PREVIEW) - ' recupero Preview di tipo WaterJet associato all'entità - Dim nWjPvId As Integer = GetCurrentPreViewFromSide( nMyId, nPartPvId) - If nWjPvId <> GDB_ID.NULL Then - m_nIdSelectedSideWJ = nMyId - Dim nValInfo As Integer = 0 - If EgtGetInfo(nMyId, INFO_JOINENTITY, nValInfo) Then - nValInfo = If( nValInfo = 1, 0, 1) - End If - EgtSetInfo(nMyId, INFO_JOINENTITY, nValInfo) - ' Ricalcolo tutte le lavorazioni - Dim nWarn As Integer = 0 - ResetAllMachinings(nWarn) - ' Recupero nuovo Preview associato alla lavorazione dell'entità - nWjPvId = GetCurrentPreViewFromSide( nMyId, nPartPvId) - ' Assegno un identificativo grafico per indicare che è un taglio separato - If nValInfo = 0 Then - AssignFlagOnGraphic(nMyId, nPartId) - Else - EraseFlagOnGraphic(nMyId, nPartId) - End If - ' Salvo il valore del PreView evidenziato - m_nIdSelectedWaterJet = nWjPvId - EgtSetMark(nWjPvId) - EgtSelectObj(nMyId) - EgtDraw() - Exit While - End If - End If - End If - nMyId = EgtGetNextObjInSelWin() - End While - End Sub - - ' funzione per l'indicazione del punto di inizio dei tagli waterjet (percorso chiuso) - Private Sub OnMyMouseDownSceneStartCurv(sender As Object, e As System.Windows.Forms.MouseEventArgs) - ' Verifico di essere il gestore attivo e non in modalità registrazione - If Not m_bActive Or m_bRegister Then Return - ' Se non abilitato spostamento punto inizio waterjet o bottone mouse non Left, esco - If Not m_bIsCheckedStartCurveWJ Or e.Button <> Windows.Forms.MouseButtons.Left Then Return - - ' Acquisisco punto di selezione - Dim ptStartCurv As New Point3d - EgtUnProjectPoint(e.Location, ptStartCurv) - ' Aggiusto Z punto acquisito (è in globale) - Dim ptRawMax As New Point3d - Dim ptRawMin As New Point3d - If GetRawBox(ptRawMin, ptRawMax) Then - ptStartCurv.z = ptRawMax.z - End If - - EgtResetMark(m_nIdSelectedWaterJet) - ' Imposto riconoscimento entità in finestra di selezione - EgtSetObjFilterForSelWin(False, True, False, False, False) - Dim nMySel As Integer - EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nMySel) - ' Ciclo su entità in finestra di selezione - Dim nEntId As Integer = EgtGetFirstObjInSelWin() - While nEntId <> GDB_ID.NULL - ' Recupero layer di appartenenza e suo nome - Dim nLayerId As Integer = EgtGetParent(nEntId) - Dim sLayer As String = String.Empty - EgtGetName(nLayerId, sLayer) - ' Se il nome del layer è quello associato ad un lato esterno o interno allora procedo - If sLayer = NAME_OUTLOOP Or sLayer = NAME_INLOOP Then - If EgtGetType(nEntId) = GDB_TY.CRV_ARC OrElse EgtGetType(nEntId) = GDB_TY.CRV_COMPO OrElse EgtGetType(nEntId) = GDB_TY.CRV_LINE Then - ' Verifico che il contorno sia chiuso, altrimenti esco - If Not VerifyOutLoopIsClosed(nLayerId) Then - m_CurrProjPage.SetWarningMessage(EgtMsg(91131)) ' Il contorno non è chiuso - Exit While - End If - ' Recupero il gruppo della lavorazione associata - Dim nPartId As Integer = EgtGetParent(nLayerId) - Dim nPartPvId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_PREVIEW) - ' Recupero l'elenco delle Preview di Tipo WaterJetNN_S associate a questo layer - Dim lstWjPV As List(Of Integer) = ResearchGroupWJ(nLayerId, nPartPvId) - ' Recupero l'elenco delle Preview di Tipo Saw associate a questo layer - Dim lstSawPV As List(Of Integer) = ResearchGroupSaw(nLayerId, nPartPvId) - ' Se esiste 1 Preview di tipo WaterJet e nessuno di tipo Saw, cambio inizio - If lstWjPV.Count = 1 And lstSawPV.Count = 0 Then - ' Imposto punto di inizio - EgtSetInfo(nLayerId, INFO_START, ptStartCurv) - ' Ricalcolo tutte le lavorazioni - Dim nWarn As Integer = 0 - ResetAllMachinings(nWarn) - ' Recupero nuovo Preview associato alla lavorazione dell'entità - Dim nWjPvId As Integer = GetCurrentPreViewFromSide( nEntId, nPartPvId) - ' Salvo il valore del PreView evidenziato - m_nIdSelectedWaterJet = nWjPvId - EgtSetMark(nWjPvId) - EgtDraw() - Exit While - Else - m_CurrProjPage.SetWarningMessage(EgtMsg(91131)) ' Il contorno non è chiuso - Exit While - End If - End If - End If - nEntId = EgtGetNextObjInSelWin() - End While - End Sub - -#Region "DRAG RETTANGLE" - - ' funzione chiamata da OnMyMouseMoveScene: verifica che la selezione sia corretta (deve essere il lato di una figura rettangolare) - Private Sub OnMyMouseDownSceneSelSideRectangle(sender As Object, e As System.Windows.Forms.MouseEventArgs) - ' Verifico di essere il gestore attivo e non in modalità registrazione - If Not m_bActive Or m_bRegister Then Return - ' Si può selezionare solo con il tasto sinistro e se il bottone TEST Attivo - If e.Button <> Windows.Forms.MouseButtons.Left Then - Return - End If - ' Verifico se selezionato indicativo di pezzo - EgtSetObjFilterForSelWin(False, True, False, False, False) - Dim nSelMy As Integer - EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSelMy) - Dim nIdMy As Integer = EgtGetFirstObjInSelWin() - While nIdMy <> GDB_ID.NULL - Dim sLayer As String = String.Empty - ' layer di origine - Dim nIdParent As Integer = EgtGetParent(nIdMy) - ' recupero il nome del Layer - EgtGetName(nIdParent, sLayer) - ' solo se il nome del layer è quello associato ad un lato esterno allora procedo con l'evidenziazione - If sLayer = NAME_OUTLOOP Then - If EgtGetType(nIdMy) = GDB_TY.CRV_LINE Then - ' -------------------------------- INIZIO VERIFICHE -------------------------------- - m_nIdSelectedOutLoopRectangle = nIdParent - If Not IsRectangle(m_SideListRectangle) Then - m_CurrProjPage.ClearMessage() - m_CurrProjPage.SetWarningMessage(EgtMsg(91209)) ' Non è un rettangolo (0) - Return - End If - ' recupero il gruppo della lavorazione associata - Dim nIdParentPart As Integer = EgtGetParent(nIdParent) - Dim nIdPV As Integer = EgtGetFirstNameInGroup(nIdParentPart, "PV") - ' se non esiste un gruppo di lavorazione associato allora esco - If nIdPV = GDB_ID.NULL Then - m_CurrProjPage.ClearMessage() - m_CurrProjPage.SetWarningMessage(EgtMsg(91210)) ' Pezzo in parcheggio (1) - Return - End If - ' se esiste ma è vuoto (pezzo scaricato da tavola) - If EgtGetFirstInGroup(nIdPV) = GDB_ID.NULL Then - m_CurrProjPage.ClearMessage() - m_CurrProjPage.SetWarningMessage(EgtMsg(91211)) ' Pezzo in parcheggio (2) - Return - End If - ' Devo verificare che sia una lavorazione solo di lama? - Dim nIdSaw As Integer = EgtGetFirstNameInGroup(nIdPV, "Saw" & nIdMy.ToString) - ' -------------------------------- FINE VERIFICHE -------------------------------- - - If Not EgtGetGroupObjs(nIdSaw) Then - m_nIdSelectedSawRectangle = nIdSaw - m_nIdSelectedCurvRectangle = nIdMy - - m_nIdSelectedRegionRectangle = EgtGetFirstNameInGroup(nIdParentPart, NAME_REGION) - ' recupero i testi cintenuti nel layer Region - If m_nIdSelectedRegionRectangle <> GDB_ID.NULL Then - Dim nCurrId As Integer = EgtGetFirstInGroup(m_nIdSelectedRegionRectangle) - While nCurrId <> GDB_ID.NULL - If EgtGetType(nCurrId) = GDB_TY.EXT_TEXT Then - Dim sVal As String = String.Empty - EgtTextGetContent(nCurrId, sVal) - If sVal = "*TOP*" Then - m_nIdSelectedTextTopRectangle = nCurrId - Else - m_nIdSelectedTextRectangle = nCurrId - m_sTextContent = GetMyRectangleText(sVal) - End If - ElseIf EgtGetType(nCurrId) = GDB_TY.SRF_FRGN Then - m_nIdSelectedFlatSurfRectangle = nCurrId - End If - nCurrId = EgtGetNext(nCurrId) - End While - End If - ' seleziono ed evidenzio il lato selezionato - EgtSelectObj(nIdSaw) - EgtSetMark(nIdSaw) - EgtSelectObj(nIdMy) - EgtDraw() - Exit While - End If - End If - ' se le'elemto corrente non è una linea - End If - ' se le'elemto corrente non appartiene al layer OutLoop passo al prossimo elemento dell'elenco - nIdMy = EgtGetNextObjInSelWin() - End While - End Sub - - ' restituisce il valore del Text ripulito dalle dimensioni - Private Function GetMyRectangleText(sTextPz As String) As String - ' da DrawPageUC.xaml.vb/MultipleInsert - Dim sText As String = String.Empty - If sTextPz.Contains("
") Then - Dim nLastIndex As Integer = sTextPz.LastIndexOf(">") - sText = sTextPz.Remove(nLastIndex + 1) - Return sText - End If - If sTextPz.Contains(" ") Then - Dim sInfo() As String = sTextPz.Split(" ") - If sInfo.Count > 3 Then - Return sText = sInfo(0) & " " & sInfo(1) & " " - End If - End If - Return sText - End Function - - ' verifico che la figura selezionata sia realmente un rettangolo - Private Function IsRectangle(ByRef IdSideList() As Integer) As Boolean - ' creo una lista con i lati del rettangolo - Dim nCounter As Integer = 0 - ' recupero i lati dal leyer "OutLoop" - Dim IdSideRectangle As Integer = EgtGetFirstInGroup(m_nIdSelectedOutLoopRectangle) - While IdSideRectangle <> GDB_ID.NULL And nCounter < 4 - Dim sVal As String = String.Empty - Dim dPrevAng As Double = 0 - EgtGetInfo(IdSideRectangle, "PrevAng", sVal) - StringToDouble(sVal, dPrevAng) - Dim dNextAng As Double = 0 - EgtGetInfo(IdSideRectangle, "NextAng", sVal) - StringToDouble(sVal, dNextAng) - ' se gli angoli non sono retti allora esco senza caricare il lato corrente - If Math.Abs(dPrevAng - 90) > EPS_ANG_SMALL OrElse Math.Abs(dNextAng - 90) > EPS_ANG_SMALL Then - Exit While - End If - IdSideList(nCounter) = IdSideRectangle - nCounter += 1 - IdSideRectangle = EgtGetNext(IdSideRectangle) - End While - ' verifico che siano solo quattro lati - If IdSideRectangle = GDB_ID.NULL And nCounter = 4 Then - ' solo se la figura ha 4 lati ortogonali - Return True - End If - - m_nIdSelectedOutLoopRectangle = GDB_ID.NULL - ' la figura presenta più/meno di 4 lati - Return False - End Function - - ' recupero le informazioni correnti per sapere se la figura è mdificabile - Private Function GetRectangleInfoScale(ByRef frFixed As Frame3d, ByRef MaxLen As Double, ByRef MinLen As Double) As Vector3d - ' determino la direzione del lato selezionato - Dim vtDirSelectedCurv As New Vector3d - EgtStartVector(m_nIdSelectedCurvRectangle, GDB_ID.ROOT, vtDirSelectedCurv) - - ' recupero il lato successivo a quello selezionato - Dim Index As Integer = 0 - Dim Len As Double = 0 - For Ind As Integer = 0 To 3 - If m_SideListRectangle(Ind) = m_nIdSelectedCurvRectangle Then - ' verifico se esiste un lato Precedente altrimenti recupero l'ultimo della lista - If Ind = 0 Then - Index = 3 - Else - Index = Ind - 1 - End If - End If - Next - ' recupero la dimensione del lato - EgtCurveLength(m_SideListRectangle(Index), MaxLen) - EgtCurveLength(m_nIdSelectedCurvRectangle, MinLen) - - ' verifico che il lato selezionato sia il maggiore - If MinLen > MaxLen Then Return Nothing - - ' determimo il versore dal lato appena calcolato - Dim vtDir As New Vector3d - - EgtStartVector(m_SideListRectangle(Index), GDB_ID.ROOT, vtDir) - vtDir.Normalize() - Dim dProjectionBaseX As Double = vtDir * Vector3d.X_AX - Dim ptFixed As New Point3d - EgtStartPoint(m_SideListRectangle(Index), GDB_ID.ROOT, ptFixed) - - Dim vtPerp As New Vector3d(vtDir.x, vtDir.y, vtDir.z) - vtPerp.Rotate(Vector3d.Z_AX, 90) - - ' determino il Frame corrente - frFixed = New Frame3d(ptFixed, vtDir, vtPerp, Vector3d.Z_AX) - - Return vtDir - - End Function - - ' funzione chiamata da OnMyMouseMoveScene: gestisce la modifica lungo una dimensione del rettangolo selezionato - Private Sub OnMyMouseMoveSawRectangle(sender As Object, e As System.Windows.Forms.MouseEventArgs) - ' Verifico di essere il gestore attivo - If Not m_bActive Then Return - ' Se drag non abilitato o già in esecuzione, esco - If Not m_bDrag Or m_bDragging Then Return - ' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel - If m_bDragToStart Then - If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And - Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then - Return - End If - m_bDragToStart = False - End If - - ' riferiemento che deve rimanere fisso del rettangolo - Dim frFixed As Frame3d = Nothing - ' lunghezza del lato da modificare - Dim MaxLen As Double = 0 - Dim MinLen As Double = 0 - ' recupero info sul rettangolo selezionato - Dim vtDir As Vector3d = GetRectangleInfoScale(frFixed, MaxLen, MinLen) - If vtDir.Equals(Vector3d.NULL) Then - Return - End If - - ' Inizio esecuzione di drag - m_bDragging = True - - ' Ricavo il punto corrente in coordinate mondo - Dim ptCurr As Point3d - EgtUnProjectPoint(e.Location, ptCurr) - ' Ricavo il vettore di movimento - Dim vtMove As Vector3d = ptCurr - m_ptPrev - ' ricavo il valore efficace di allungamento (la proiezione) - Dim dProjection As Double = vtMove * vtDir - vtMove = vtDir * dProjection - ' recupero il valore di scalatura - Dim dScalefactor = dProjection / MaxLen + 1 - - ' Modifico dimensione figura - If Math.Abs(dScalefactor) > EPS_SMALL * EPS_SMALL Then - EgtScale(m_nIdSelectedOutLoopRectangle, frFixed, dScalefactor, 1, 1, GDB_ID.ROOT) - EgtScale(m_nIdSelectedFlatSurfRectangle, frFixed, dScalefactor, 1, 1, GDB_ID.ROOT) - Dim ptCen As Point3d - EgtCenterPoint(m_nIdSelectedTextRectangle, ptCen) - EgtModifyText(m_nIdSelectedTextRectangle, m_sTextContent & LenToString(MaxLen + dProjection, 2) & " x " & LenToString(MinLen, 2)) - EgtMove(m_nIdSelectedTextRectangle, vtMove * 0.5, GDB_ID.ROOT) - If m_nIdSelectedTextTopRectangle <> GDB_ID.NULL Then - EgtMove(m_nIdSelectedTextTopRectangle, vtMove * 0.5, GDB_ID.ROOT) - End If - ' il rettangolo è stato modifica almeno una volta - m_dRectangleIsModified = True - End If - - ' verifico che il il lato maggiore rimanga semore il lato maggiore - Dim bRectangleCorrect As Boolean = False - If (MaxLen + dProjection - MinLen) > EPS_SMALL Then bRectangleCorrect = True - - Dim nWarn As Integer = 0 - ResetAllMachinings(nWarn) - EnableReferenceRegion(False) - ' se la modifica genera un errore allora ripristino la figura prima della defomrazione - If Not EgtVerifyPart(EgtGetParent(m_nIdSelectedOutLoopRectangle), True) Or Not bRectangleCorrect Then - EgtScale(m_nIdSelectedOutLoopRectangle, frFixed, 1 / dScalefactor, 1, 1, GDB_ID.ROOT) - EgtScale(m_nIdSelectedFlatSurfRectangle, frFixed, 1 / dScalefactor, 1, 1, GDB_ID.ROOT) - Dim ptCen As Point3d - EgtCenterPoint(m_nIdSelectedTextRectangle, ptCen) - EgtModifyText(m_nIdSelectedTextRectangle, m_sTextContent & LenToString(MaxLen, 2) & " x " & LenToString(MinLen, 2)) - EgtMove(m_nIdSelectedTextRectangle, -vtMove * 0.5, GDB_ID.ROOT) - If m_nIdSelectedTextTopRectangle <> GDB_ID.NULL Then - EgtMove(m_nIdSelectedTextTopRectangle, -vtMove * 0.5, GDB_ID.ROOT) - End If - End If - - EgtDraw() - ' Aggiorno il punto precedente - m_ptPrev = ptCurr - ' Terminata esecuzione di drag - m_bDragging = False - End Sub - - ' funzione chiamata da OnMyMouseUp: gestisce il reset di tutti gli indici in uso - Public Sub ResetDragRectangleParam() - ' deseleziono l'elemento corrente - EgtDeselectObj(m_nIdSelectedSawRectangle) - EgtDeselectObj(m_nIdSelectedCurvRectangle) - EgtResetMark(m_nIdSelectedSawRectangle) - If m_dRectangleIsModified Then - ' elimino eventuali riferienti con la famiglia di appartenenza - Dim nCurrPart As Integer = EgtGetParent(m_nIdSelectedRegionRectangle) - EgtRemoveInfo(nCurrPart, INFO_REFGROUP) - ' elimino il Layer che contiene l'informazione del numero di pezzi - Dim nCounterLayer As Integer = EgtGetFirstNameInGroup(nCurrPart, INFO_COUNTERLY) - EgtErase(nCounterLayer) - End If - m_dRectangleIsModified = False - ' resetto gli indici - m_nIdSelectedOutLoopRectangle = GDB_ID.NULL - m_nIdSelectedRegionRectangle = GDB_ID.NULL - m_nIdSelectedSawRectangle = GDB_ID.NULL - m_nIdSelectedCurvRectangle = GDB_ID.NULL - m_nIdSelectedTextRectangle = GDB_ID.NULL - m_nIdSelectedTextTopRectangle = GDB_ID.NULL - m_nIdSelectedFlatSurfRectangle = GDB_ID.NULL - m_SideListRectangle = {GDB_ID.NULL, GDB_ID.NULL, GDB_ID.NULL, GDB_ID.NULL} - m_sTextContent = String.Empty - ' disattivo il drag - m_bDrag = False - ' aggiorno le lavorazioni - Dim nWarn As Integer = 0 - ResetAllMachinings(nWarn) - EgtDraw() - End Sub - -#End Region ' Drag Rettangolo - -#Region "SPLIT/START CURVE" - - ' restituisce l'elenco dei Gruppi Waterjet associati al contorno indicato - Public Function ResearchGroupWJ(nLayId As Integer, nPvId As Integer) As List(Of Integer) - Dim lstPvGroup As New List(Of Integer) - ' ciclo sui lati del layer OutLoop - Dim nMyId As Integer = EgtGetFirstInGroup(nLayId) - While nMyId <> GDB_ID.NULL - ' verifico se esiste una Preview associata al lato - Dim nGroupId As Integer = EgtGetFirstNameInGroup(nPvId, "Waterjet" & nMyId.ToString() & "S") - If nGroupId <> GDB_ID.NULL Then - lstPvGroup.Add(nGroupId) - End If - nMyId = EgtGetNext(nMyId) - End While - Return lstPvGroup - End Function - - ' restituisce l'elenco dei Gruppi Saw associati al contorno indicato - Public Function ResearchGroupSaw(nLayId As Integer, nIdPV As Integer) As List(Of Integer) - Dim lstPvGroup As New List(Of Integer) - ' recupero il primo lato dall'elenco dei lati della figura - Dim nMyId As Integer = EgtGetFirstInGroup(nLayId) - ' altrimenti cerco all'interno del layer OutLoop per ogni lato la lavorazione associata - While nMyId <> GDB_ID.NULL - ' verifico se esiste una Preview associata al lato - Dim nIdGroup As Integer = EgtGetFirstNameInGroup(nIdPV, "Saw" & nMyId.ToString) - If nIdGroup <> GDB_ID.NULL Then - lstPvGroup.Add(nIdGroup) - End If - nMyId = EgtGetNext(nMyId) - End While - Return lstPvGroup - End Function - - Private Function GetDirectPreViewFromSide( nSideId As Integer, nPvGroupId As Integer) As Integer - ' Radice del nome del gruppo di Preview - Dim sRefName As String = "Waterjet" & nSideId.ToString() & "S" - ' Ricerca nei gruppi all'interno del gruppo di Preview - Dim nEntId As Integer = EgtGetFirstInGroup( nPvGroupId) - While nEntId <> GDB_ID.NULL - Dim sName As String = "" - If EgtGetName( nEntId, sName) AndAlso sName.StartsWith( sRefName) Then - Return nEntId - End If - nEntId = EgtGetNext( nEntId) - End While - ' Non è stato trovato - return GDB_ID.NULL - End Function - - Public Function GetCurrentPreViewFromSide( nSideId As Integer, nPvGroupId As Integer) As Integer - ' Cerco Preview diretta - Dim nPvId As Integer = GetDirectPreViewFromSide( nSideId, nPvGroupId) - ' Se trovata, esco con successo - If nPvId <> GDB_ID.NULL Then Return nPvId - ' Se elemento non collegato, esco con insuccesso - Dim nJoint As Integer = 1 - If EgtGetInfo( nSideId, INFO_JOINENTITY, nJoint) AndAlso nJoint = 0 Then Return GDB_ID.NULL - ' Cerco su elementi successivi collegati - Dim nNextId = EgtGetNext( nSideId) - While nNextId <> GDB_ID.NULL - Dim nNextJoint As Integer = 1 - If EgtGetInfo( nNextId, INFO_JOINENTITY, nNextJoint) AndAlso nNextJoint = 0 Then Exit While - nPvId = GetDirectPreViewFromSide( nNextId, nPvGroupId) - If nPvId <> GDB_ID.NULL Then Return nPvId - nNextId = EgtGetNext( nNextId) - End While - ' Cerco su elementi precedenti collegati - Dim nPrevId = EgtGetPrev( nSideId) - While nPrevId <> GDB_ID.NULL - Dim nPrevJoint As Integer = 1 - If EgtGetInfo( nPrevId, INFO_JOINENTITY, nPrevJoint) AndAlso nPrevJoint = 0 Then Exit While - nPvId = GetDirectPreViewFromSide( nPrevId, nPvGroupId) - If nPvId <> GDB_ID.NULL Then Return nPvId - nPrevId = EgtGetPrev( nPrevId) - End While - ' Non trovato - Return GDB_ID.NULL - End Function - - Public Sub ResetSplitCurvWJParam() - EgtDeselectObj(m_nIdSelectedSideWJ) - EgtResetMark(m_nIdSelectedWaterJet) - m_nIdSelectedSideWJ = GDB_ID.NULL - m_nIdSelectedWaterJet = GDB_ID.NULL - EgtDraw() - End Sub - - ' ricevo l'ID del percorso di lavorazione WJ al quale associo una etichetta grafica con scritto "S" - Private Sub AssignFlagOnGraphic(nMyId As Integer, NPartId As Integer) - ' cerco se esiste già un layer nominato "AUX_SPLIT_WJ", altrimenti lo creo - Dim nAuxLayerId As Integer = EgtGetFirstNameInGroup(NPartId, LAY_AUX_SPLIT_WJ) - If nAuxLayerId = GDB_ID.NULL Then - nAuxLayerId = EgtCreateGroup(NPartId) - EgtSetName(nAuxLayerId, LAY_AUX_SPLIT_WJ) - End If - ' inserisco flag - Dim nIdTextFlag As Integer = GetCreateFlagText(nMyId, nAuxLayerId) - EgtSetColor(nIdTextFlag, New Color3d(255, 0, 0)) - EgtSetName(nIdTextFlag, "RefSide_" & nMyId.ToString) - End Sub - - Private Function GetCreateFlagText(nId As Integer, nLayerId As Integer, Optional sText As String = "*") As Integer - ' Recupero il punto medio - Dim MidPoint As Point3d - EgtMidPoint(nId, GDB_RT.GLOB, MidPoint) - ' Recupero la direzione della curva nel punto medio e la ruota 90deg CCW - Dim vVers As Vector3d - EgtMidVector(nId, GDB_RT.GLOB, vVers) - vVers.Normalize() - vVers.Rotate(Vector3d.Z_AX, 90) - ' Ingombro complessivo della lavorazione - Dim b3Ent As New BBox3d - EgtGetBBoxGlob(nId, BBFLAG, b3Ent) - ' Metto il numero nel centro - Dim dRadXY = Point3d.DistXY(b3Ent.Min(), b3Ent.Max()) - Dim dHtxt As Double = 50 - Dim dRat As Double = 0.75 - If dRadXY < 200 Then - dHtxt = 40 - dRat = 0.6 - ElseIf dRadXY < 25 Then - dHtxt = 25 - dRat = 0.5 - End If - ' Determino la posizione - MidPoint.x += dHtxt / 2 * vVers.x - MidPoint.y += dHtxt / 2 * vVers.y - ' Creo il testo - Return EgtCreateTextAdv(nLayerId, MidPoint, 0, sText, "", 300, False, dHtxt, dRat, 0, INS_POS.MC, GDB_RT.GLOB) - End Function - - Private Sub EraseFlagOnGraphic(nMyId As Integer, nPartId As Integer) - ' cerco se esiste già un layer nominato "AUX_SPLIT_WJ" - Dim nAuxLayerId As Integer = EgtGetFirstNameInGroup(nPartId, LAY_AUX_SPLIT_WJ) - If nAuxLayerId = GDB_ID.NULL Then Return - Dim nIdTextFlag As Integer = EgtGetFirstNameInGroup(nAuxLayerId, "RefSide_" & nMyId.ToString) - EgtErase(nIdTextFlag) - End Sub - - Public Sub ResetStartCurvWJParam() - EgtResetMark(m_nIdSelectedWaterJet) - m_nIdSelectedWaterJet = GDB_ID.NULL - EgtDraw() - End Sub - -#End Region ' Split/Start Curve - Private Sub OnMyMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_CurrProjPage.OnMouseDownScene ' Se gestore non attivo o modalità registrazione If Not m_bActive Or m_bRegister Then @@ -2211,7 +1631,6 @@ Public Class NestPageUC Return bMoveOk End Function - Private Sub InsertPartBtn_Click(sender As Object, e As RoutedEventArgs) Handles InsertPartBtn.Click ' Se inserimento automatico If GetPrivateProfileInt(S_NEST, K_AUTOMATICOPTIMIZE, 0, m_MainWindow.GetIniFile()) <> 0 And @@ -2757,7 +2176,7 @@ Public Class NestPageUC End Sub ' ripulisco la lista dei pezzi in parcheggio - Friend Sub ResetListOfGruopInPark() + Friend Sub ResetListOfGroupInPark() m_ListOfGroupInPark.Clear() End Sub @@ -3093,7 +2512,6 @@ Public Class NestPageUC UpdateImageParkInd(False) End Sub - Private Sub PartRotOnBtn_Click(sender As Object, e As RoutedEventArgs) Handles PartRotOnBtn.Click EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx()) ' Se non ci sono pezzi selezionati o non sono in parcheggio, esco @@ -3297,7 +2715,587 @@ Public Class NestPageUC Return True End Function -#Region "SPOT REG" +#Region "DRAG RETTANGLE" + + ' funzione chiamata da OnMyMouseMoveScene: verifica che la selezione sia corretta (deve essere il lato di una figura rettangolare) + Private Sub OnMyMouseDownSceneSelSideRectangle(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Verifico di essere il gestore attivo e non in modalità registrazione + If Not m_bActive Or m_bRegister Then Return + ' Si può selezionare solo con il tasto sinistro e se il bottone TEST Attivo + If e.Button <> Windows.Forms.MouseButtons.Left Then + Return + End If + ' Verifico se selezionato indicativo di pezzo + EgtSetObjFilterForSelWin(False, True, False, False, False) + Dim nSelMy As Integer + EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSelMy) + Dim nIdMy As Integer = EgtGetFirstObjInSelWin() + While nIdMy <> GDB_ID.NULL + Dim sLayer As String = String.Empty + ' layer di origine + Dim nIdParent As Integer = EgtGetParent(nIdMy) + ' recupero il nome del Layer + EgtGetName(nIdParent, sLayer) + ' solo se il nome del layer è quello associato ad un lato esterno allora procedo con l'evidenziazione + If sLayer = NAME_OUTLOOP Then + If EgtGetType(nIdMy) = GDB_TY.CRV_LINE Then + ' -------------------------------- INIZIO VERIFICHE -------------------------------- + m_nIdSelectedOutLoopRectangle = nIdParent + If Not IsRectangle(m_SideListRectangle) Then + m_CurrProjPage.ClearMessage() + m_CurrProjPage.SetWarningMessage(EgtMsg(91209)) ' Non è un rettangolo (0) + Return + End If + ' recupero il gruppo della lavorazione associata + Dim nIdParentPart As Integer = EgtGetParent(nIdParent) + Dim nIdPV As Integer = EgtGetFirstNameInGroup(nIdParentPart, "PV") + ' se non esiste un gruppo di lavorazione associato allora esco + If nIdPV = GDB_ID.NULL Then + m_CurrProjPage.ClearMessage() + m_CurrProjPage.SetWarningMessage(EgtMsg(91210)) ' Pezzo in parcheggio (1) + Return + End If + ' se esiste ma è vuoto (pezzo scaricato da tavola) + If EgtGetFirstInGroup(nIdPV) = GDB_ID.NULL Then + m_CurrProjPage.ClearMessage() + m_CurrProjPage.SetWarningMessage(EgtMsg(91211)) ' Pezzo in parcheggio (2) + Return + End If + ' Devo verificare che sia una lavorazione solo di lama? + Dim nIdSaw As Integer = EgtGetFirstNameInGroup(nIdPV, "Saw" & nIdMy.ToString) + ' -------------------------------- FINE VERIFICHE -------------------------------- + + If Not EgtGetGroupObjs(nIdSaw) Then + m_nIdSelectedSawRectangle = nIdSaw + m_nIdSelectedCurvRectangle = nIdMy + + m_nIdSelectedRegionRectangle = EgtGetFirstNameInGroup(nIdParentPart, NAME_REGION) + ' recupero i testi cintenuti nel layer Region + If m_nIdSelectedRegionRectangle <> GDB_ID.NULL Then + Dim nCurrId As Integer = EgtGetFirstInGroup(m_nIdSelectedRegionRectangle) + While nCurrId <> GDB_ID.NULL + If EgtGetType(nCurrId) = GDB_TY.EXT_TEXT Then + Dim sVal As String = String.Empty + EgtTextGetContent(nCurrId, sVal) + If sVal = "*TOP*" Then + m_nIdSelectedTextTopRectangle = nCurrId + Else + m_nIdSelectedTextRectangle = nCurrId + m_sTextContent = GetMyRectangleText(sVal) + End If + ElseIf EgtGetType(nCurrId) = GDB_TY.SRF_FRGN Then + m_nIdSelectedFlatSurfRectangle = nCurrId + End If + nCurrId = EgtGetNext(nCurrId) + End While + End If + ' seleziono ed evidenzio il lato selezionato + EgtSelectObj(nIdSaw) + EgtSetMark(nIdSaw) + EgtSelectObj(nIdMy) + EgtDraw() + Exit While + End If + End If + ' se le'elemto corrente non è una linea + End If + ' se le'elemto corrente non appartiene al layer OutLoop passo al prossimo elemento dell'elenco + nIdMy = EgtGetNextObjInSelWin() + End While + End Sub + + ' restituisce il valore del Text ripulito dalle dimensioni + Private Function GetMyRectangleText(sTextPz As String) As String + ' da DrawPageUC.xaml.vb/MultipleInsert + Dim sText As String = String.Empty + If sTextPz.Contains("
") Then + Dim nLastIndex As Integer = sTextPz.LastIndexOf(">") + sText = sTextPz.Remove(nLastIndex + 1) + Return sText + End If + If sTextPz.Contains(" ") Then + Dim sInfo() As String = sTextPz.Split(" ") + If sInfo.Count > 3 Then + Return sText = sInfo(0) & " " & sInfo(1) & " " + End If + End If + Return sText + End Function + + ' verifico che la figura selezionata sia realmente un rettangolo + Private Function IsRectangle(ByRef IdSideList() As Integer) As Boolean + ' creo una lista con i lati del rettangolo + Dim nCounter As Integer = 0 + ' recupero i lati dal leyer "OutLoop" + Dim IdSideRectangle As Integer = EgtGetFirstInGroup(m_nIdSelectedOutLoopRectangle) + While IdSideRectangle <> GDB_ID.NULL And nCounter < 4 + Dim sVal As String = String.Empty + Dim dPrevAng As Double = 0 + EgtGetInfo(IdSideRectangle, "PrevAng", sVal) + StringToDouble(sVal, dPrevAng) + Dim dNextAng As Double = 0 + EgtGetInfo(IdSideRectangle, "NextAng", sVal) + StringToDouble(sVal, dNextAng) + ' se gli angoli non sono retti allora esco senza caricare il lato corrente + If Math.Abs(dPrevAng - 90) > EPS_ANG_SMALL OrElse Math.Abs(dNextAng - 90) > EPS_ANG_SMALL Then + Exit While + End If + IdSideList(nCounter) = IdSideRectangle + nCounter += 1 + IdSideRectangle = EgtGetNext(IdSideRectangle) + End While + ' verifico che siano solo quattro lati + If IdSideRectangle = GDB_ID.NULL And nCounter = 4 Then + ' solo se la figura ha 4 lati ortogonali + Return True + End If + + m_nIdSelectedOutLoopRectangle = GDB_ID.NULL + ' la figura presenta più/meno di 4 lati + Return False + End Function + + ' recupero le informazioni correnti per sapere se la figura è mdificabile + Private Function GetRectangleInfoScale(ByRef frFixed As Frame3d, ByRef MaxLen As Double, ByRef MinLen As Double) As Vector3d + ' determino la direzione del lato selezionato + Dim vtDirSelectedCurv As New Vector3d + EgtStartVector(m_nIdSelectedCurvRectangle, GDB_ID.ROOT, vtDirSelectedCurv) + + ' recupero il lato successivo a quello selezionato + Dim Index As Integer = 0 + Dim Len As Double = 0 + For Ind As Integer = 0 To 3 + If m_SideListRectangle(Ind) = m_nIdSelectedCurvRectangle Then + ' verifico se esiste un lato Precedente altrimenti recupero l'ultimo della lista + If Ind = 0 Then + Index = 3 + Else + Index = Ind - 1 + End If + End If + Next + ' recupero la dimensione del lato + EgtCurveLength(m_SideListRectangle(Index), MaxLen) + EgtCurveLength(m_nIdSelectedCurvRectangle, MinLen) + + ' verifico che il lato selezionato sia il maggiore + If MinLen > MaxLen Then Return Nothing + + ' determimo il versore dal lato appena calcolato + Dim vtDir As New Vector3d + + EgtStartVector(m_SideListRectangle(Index), GDB_ID.ROOT, vtDir) + vtDir.Normalize() + Dim dProjectionBaseX As Double = vtDir * Vector3d.X_AX + Dim ptFixed As New Point3d + EgtStartPoint(m_SideListRectangle(Index), GDB_ID.ROOT, ptFixed) + + Dim vtPerp As New Vector3d(vtDir.x, vtDir.y, vtDir.z) + vtPerp.Rotate(Vector3d.Z_AX, 90) + + ' determino il Frame corrente + frFixed = New Frame3d(ptFixed, vtDir, vtPerp, Vector3d.Z_AX) + + Return vtDir + + End Function + + ' funzione chiamata da OnMyMouseMoveScene: gestisce la modifica lungo una dimensione del rettangolo selezionato + Private Sub OnMyMouseMoveSawRectangle(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Verifico di essere il gestore attivo + If Not m_bActive Then Return + ' Se drag non abilitato o già in esecuzione, esco + If Not m_bDrag Or m_bDragging Then Return + ' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel + If m_bDragToStart Then + If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And + Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then + Return + End If + m_bDragToStart = False + End If + + ' riferiemento che deve rimanere fisso del rettangolo + Dim frFixed As Frame3d = Nothing + ' lunghezza del lato da modificare + Dim MaxLen As Double = 0 + Dim MinLen As Double = 0 + ' recupero info sul rettangolo selezionato + Dim vtDir As Vector3d = GetRectangleInfoScale(frFixed, MaxLen, MinLen) + If vtDir.Equals(Vector3d.NULL) Then + Return + End If + + ' Inizio esecuzione di drag + m_bDragging = True + + ' Ricavo il punto corrente in coordinate mondo + Dim ptCurr As Point3d + EgtUnProjectPoint(e.Location, ptCurr) + ' Ricavo il vettore di movimento + Dim vtMove As Vector3d = ptCurr - m_ptPrev + ' ricavo il valore efficace di allungamento (la proiezione) + Dim dProjection As Double = vtMove * vtDir + vtMove = vtDir * dProjection + ' recupero il valore di scalatura + Dim dScalefactor = dProjection / MaxLen + 1 + + ' Modifico dimensione figura + If Math.Abs(dScalefactor) > EPS_SMALL * EPS_SMALL Then + EgtScale(m_nIdSelectedOutLoopRectangle, frFixed, dScalefactor, 1, 1, GDB_ID.ROOT) + EgtScale(m_nIdSelectedFlatSurfRectangle, frFixed, dScalefactor, 1, 1, GDB_ID.ROOT) + Dim ptCen As Point3d + EgtCenterPoint(m_nIdSelectedTextRectangle, ptCen) + EgtModifyText(m_nIdSelectedTextRectangle, m_sTextContent & LenToString(MaxLen + dProjection, 2) & " x " & LenToString(MinLen, 2)) + EgtMove(m_nIdSelectedTextRectangle, vtMove * 0.5, GDB_ID.ROOT) + If m_nIdSelectedTextTopRectangle <> GDB_ID.NULL Then + EgtMove(m_nIdSelectedTextTopRectangle, vtMove * 0.5, GDB_ID.ROOT) + End If + ' il rettangolo è stato modifica almeno una volta + m_dRectangleIsModified = True + End If + + ' verifico che il il lato maggiore rimanga semore il lato maggiore + Dim bRectangleCorrect As Boolean = False + If (MaxLen + dProjection - MinLen) > EPS_SMALL Then bRectangleCorrect = True + + Dim nWarn As Integer = 0 + ResetAllMachinings(nWarn) + EnableReferenceRegion(False) + ' se la modifica genera un errore allora ripristino la figura prima della defomrazione + If Not EgtVerifyPart(EgtGetParent(m_nIdSelectedOutLoopRectangle), True) Or Not bRectangleCorrect Then + EgtScale(m_nIdSelectedOutLoopRectangle, frFixed, 1 / dScalefactor, 1, 1, GDB_ID.ROOT) + EgtScale(m_nIdSelectedFlatSurfRectangle, frFixed, 1 / dScalefactor, 1, 1, GDB_ID.ROOT) + Dim ptCen As Point3d + EgtCenterPoint(m_nIdSelectedTextRectangle, ptCen) + EgtModifyText(m_nIdSelectedTextRectangle, m_sTextContent & LenToString(MaxLen, 2) & " x " & LenToString(MinLen, 2)) + EgtMove(m_nIdSelectedTextRectangle, -vtMove * 0.5, GDB_ID.ROOT) + If m_nIdSelectedTextTopRectangle <> GDB_ID.NULL Then + EgtMove(m_nIdSelectedTextTopRectangle, -vtMove * 0.5, GDB_ID.ROOT) + End If + End If + + EgtDraw() + ' Aggiorno il punto precedente + m_ptPrev = ptCurr + ' Terminata esecuzione di drag + m_bDragging = False + End Sub + + ' funzione chiamata da OnMyMouseUp: gestisce il reset di tutti gli indici in uso + Public Sub ResetDragRectangleParam() + ' deseleziono l'elemento corrente + EgtDeselectObj(m_nIdSelectedSawRectangle) + EgtDeselectObj(m_nIdSelectedCurvRectangle) + EgtResetMark(m_nIdSelectedSawRectangle) + If m_dRectangleIsModified Then + ' elimino eventuali riferienti con la famiglia di appartenenza + Dim nCurrPart As Integer = EgtGetParent(m_nIdSelectedRegionRectangle) + EgtRemoveInfo(nCurrPart, INFO_REFGROUP) + ' elimino il Layer che contiene l'informazione del numero di pezzi + Dim nCounterLayer As Integer = EgtGetFirstNameInGroup(nCurrPart, INFO_COUNTERLY) + EgtErase(nCounterLayer) + End If + m_dRectangleIsModified = False + ' resetto gli indici + m_nIdSelectedOutLoopRectangle = GDB_ID.NULL + m_nIdSelectedRegionRectangle = GDB_ID.NULL + m_nIdSelectedSawRectangle = GDB_ID.NULL + m_nIdSelectedCurvRectangle = GDB_ID.NULL + m_nIdSelectedTextRectangle = GDB_ID.NULL + m_nIdSelectedTextTopRectangle = GDB_ID.NULL + m_nIdSelectedFlatSurfRectangle = GDB_ID.NULL + m_SideListRectangle = {GDB_ID.NULL, GDB_ID.NULL, GDB_ID.NULL, GDB_ID.NULL} + m_sTextContent = String.Empty + ' disattivo il drag + m_bDrag = False + ' aggiorno le lavorazioni + Dim nWarn As Integer = 0 + ResetAllMachinings(nWarn) + EgtDraw() + End Sub + +#End Region ' Drag Rettangolo + +#Region "SPLIT/START CURVE" + + ' funzione per la selezione dei lati su cui operare la separazione del tagli waterjet + Private Sub OnMyMouseDownSceneSplitCurv(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Verifico di essere il gestore attivo e non in modalità registrazione + If Not m_bActive Or m_bRegister Then Return + ' Se non abilitata separazione lato waterjet o bottone mouse non Left, esco + If Not m_bIsCheckedSplitCurveWJ Or e.Button <> Windows.Forms.MouseButtons.Left Then Return + + EgtResetMark(m_nIdSelectedWaterJet) + ' Imposto riconoscimento entità in finestra di selezione + EgtSetObjFilterForSelWin(False, True, False, False, False) + Dim nSelMy As Integer + EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSelMy) + ' Ciclo su entità in finestra di selezione + Dim nMyId As Integer = EgtGetFirstObjInSelWin() + While nMyId <> GDB_ID.NULL + ' Recupero layer di appartenenza e suo nome + Dim nLayerId As Integer = EgtGetParent(nMyId) + Dim sLayer As String = String.Empty + EgtGetName(nLayerId, sLayer) + ' solo se il nome del layer è quello associato ad un lato esterno allora procedo con l'evidenziazione + If sLayer = NAME_OUTLOOP Then + If EgtGetType(nMyId) = GDB_TY.CRV_ARC OrElse EgtGetType(nMyId) = GDB_TY.CRV_COMPO OrElse EgtGetType(nMyId) = GDB_TY.CRV_LINE Then + If m_nIdSelectedSideWJ <> GDB_ID.NULL Or m_nIdSelectedSideWJ = nMyId Then + EgtDeselectObj(m_nIdSelectedSideWJ) + End If + ' recupero il gruppo della lavorazione associata + Dim nPartId As Integer = EgtGetParent(nLayerId) + Dim nPartPvId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_PREVIEW) + ' recupero Preview di tipo WaterJet associato all'entità + Dim nWjPvId As Integer = GetCurrentPreViewFromSide( nMyId, nPartPvId) + If nWjPvId <> GDB_ID.NULL Then + m_nIdSelectedSideWJ = nMyId + Dim nValInfo As Integer = 0 + If EgtGetInfo(nMyId, INFO_JOINENTITY, nValInfo) Then + nValInfo = If( nValInfo = 1, 0, 1) + End If + EgtSetInfo(nMyId, INFO_JOINENTITY, nValInfo) + ' Ricalcolo tutte le lavorazioni + Dim nWarn As Integer = 0 + ResetAllMachinings(nWarn) + ' Recupero nuovo Preview associato alla lavorazione dell'entità + nWjPvId = GetCurrentPreViewFromSide( nMyId, nPartPvId) + ' Assegno un identificativo grafico per indicare che è un taglio separato + If nValInfo = 0 Then + AssignFlagOnGraphic(nMyId, nPartId) + Else + EraseFlagOnGraphic(nMyId, nPartId) + End If + ' Salvo il valore del PreView evidenziato + m_nIdSelectedWaterJet = nWjPvId + EgtSetMark(nWjPvId) + EgtSelectObj(nMyId) + EgtDraw() + Exit While + End If + End If + End If + nMyId = EgtGetNextObjInSelWin() + End While + End Sub + + ' funzione per l'indicazione del punto di inizio dei tagli waterjet (percorso chiuso) + Private Sub OnMyMouseDownSceneStartCurv(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Verifico di essere il gestore attivo e non in modalità registrazione + If Not m_bActive Or m_bRegister Then Return + ' Se non abilitato spostamento punto inizio waterjet o bottone mouse non Left, esco + If Not m_bIsCheckedStartCurveWJ Or e.Button <> Windows.Forms.MouseButtons.Left Then Return + + ' Acquisisco punto di selezione + Dim ptStartCurv As New Point3d + EgtUnProjectPoint(e.Location, ptStartCurv) + ' Aggiusto Z punto acquisito (è in globale) + Dim ptRawMax As New Point3d + Dim ptRawMin As New Point3d + If GetRawBox(ptRawMin, ptRawMax) Then + ptStartCurv.z = ptRawMax.z + End If + + EgtResetMark(m_nIdSelectedWaterJet) + ' Imposto riconoscimento entità in finestra di selezione + EgtSetObjFilterForSelWin(False, True, False, False, False) + Dim nMySel As Integer + EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nMySel) + ' Ciclo su entità in finestra di selezione + Dim nEntId As Integer = EgtGetFirstObjInSelWin() + While nEntId <> GDB_ID.NULL + ' Recupero layer di appartenenza e suo nome + Dim nLayerId As Integer = EgtGetParent(nEntId) + Dim sLayer As String = String.Empty + EgtGetName(nLayerId, sLayer) + ' Se il nome del layer è quello associato ad un lato esterno o interno allora procedo + If sLayer = NAME_OUTLOOP Or sLayer = NAME_INLOOP Then + If EgtGetType(nEntId) = GDB_TY.CRV_ARC OrElse EgtGetType(nEntId) = GDB_TY.CRV_COMPO OrElse EgtGetType(nEntId) = GDB_TY.CRV_LINE Then + ' Verifico che il contorno sia chiuso, altrimenti esco + If Not VerifyOutLoopIsClosed(nLayerId) Then + m_CurrProjPage.SetWarningMessage(EgtMsg(91131)) ' Il contorno non è chiuso + Exit While + End If + ' Recupero il gruppo della lavorazione associata + Dim nPartId As Integer = EgtGetParent(nLayerId) + Dim nPartPvId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_PREVIEW) + ' Recupero l'elenco delle Preview di Tipo WaterJetNN_S associate a questo layer + Dim lstWjPV As List(Of Integer) = ResearchGroupWJ(nLayerId, nPartPvId) + ' Recupero l'elenco delle Preview di Tipo Saw associate a questo layer + Dim lstSawPV As List(Of Integer) = ResearchGroupSaw(nLayerId, nPartPvId) + ' Se esiste 1 Preview di tipo WaterJet e nessuno di tipo Saw, cambio inizio + If lstWjPV.Count = 1 And lstSawPV.Count = 0 Then + ' Imposto punto di inizio + EgtSetInfo(nLayerId, INFO_START, ptStartCurv) + ' Ricalcolo tutte le lavorazioni + Dim nWarn As Integer = 0 + ResetAllMachinings(nWarn) + ' Recupero nuovo Preview associato alla lavorazione dell'entità + Dim nWjPvId As Integer = GetCurrentPreViewFromSide( nEntId, nPartPvId) + ' Salvo il valore del PreView evidenziato + m_nIdSelectedWaterJet = nWjPvId + EgtSetMark(nWjPvId) + EgtDraw() + Exit While + Else + m_CurrProjPage.SetWarningMessage(EgtMsg(91131)) ' Il contorno non è chiuso + Exit While + End If + End If + End If + nEntId = EgtGetNextObjInSelWin() + End While + End Sub + + ' restituisce l'elenco dei Gruppi Waterjet associati al contorno indicato + Public Function ResearchGroupWJ(nLayId As Integer, nPvId As Integer) As List(Of Integer) + Dim lstPvGroup As New List(Of Integer) + ' ciclo sui lati del layer OutLoop + Dim nMyId As Integer = EgtGetFirstInGroup(nLayId) + While nMyId <> GDB_ID.NULL + ' verifico se esiste una Preview associata al lato + Dim nGroupId As Integer = EgtGetFirstNameInGroup(nPvId, "Waterjet" & nMyId.ToString() & "S") + If nGroupId <> GDB_ID.NULL Then + lstPvGroup.Add(nGroupId) + End If + nMyId = EgtGetNext(nMyId) + End While + Return lstPvGroup + End Function + + ' restituisce l'elenco dei Gruppi Saw associati al contorno indicato + Public Function ResearchGroupSaw(nLayId As Integer, nIdPV As Integer) As List(Of Integer) + Dim lstPvGroup As New List(Of Integer) + ' recupero il primo lato dall'elenco dei lati della figura + Dim nMyId As Integer = EgtGetFirstInGroup(nLayId) + ' altrimenti cerco all'interno del layer OutLoop per ogni lato la lavorazione associata + While nMyId <> GDB_ID.NULL + ' verifico se esiste una Preview associata al lato + Dim nIdGroup As Integer = EgtGetFirstNameInGroup(nIdPV, "Saw" & nMyId.ToString) + If nIdGroup <> GDB_ID.NULL Then + lstPvGroup.Add(nIdGroup) + End If + nMyId = EgtGetNext(nMyId) + End While + Return lstPvGroup + End Function + + Private Function GetDirectPreViewFromSide( nSideId As Integer, nPvGroupId As Integer) As Integer + ' Radice del nome del gruppo di Preview + Dim sRefName As String = "Waterjet" & nSideId.ToString() & "S" + ' Ricerca nei gruppi all'interno del gruppo di Preview + Dim nEntId As Integer = EgtGetFirstInGroup( nPvGroupId) + While nEntId <> GDB_ID.NULL + Dim sName As String = "" + If EgtGetName( nEntId, sName) AndAlso sName.StartsWith( sRefName) Then + Return nEntId + End If + nEntId = EgtGetNext( nEntId) + End While + ' Non è stato trovato + return GDB_ID.NULL + End Function + + Public Function GetCurrentPreViewFromSide( nSideId As Integer, nPvGroupId As Integer) As Integer + ' Cerco Preview diretta + Dim nPvId As Integer = GetDirectPreViewFromSide( nSideId, nPvGroupId) + ' Se trovata, esco con successo + If nPvId <> GDB_ID.NULL Then Return nPvId + ' Se elemento non collegato, esco con insuccesso + Dim nJoint As Integer = 1 + If EgtGetInfo( nSideId, INFO_JOINENTITY, nJoint) AndAlso nJoint = 0 Then Return GDB_ID.NULL + ' Cerco su elementi successivi collegati + Dim nNextId = EgtGetNext( nSideId) + While nNextId <> GDB_ID.NULL + Dim nNextJoint As Integer = 1 + If EgtGetInfo( nNextId, INFO_JOINENTITY, nNextJoint) AndAlso nNextJoint = 0 Then Exit While + nPvId = GetDirectPreViewFromSide( nNextId, nPvGroupId) + If nPvId <> GDB_ID.NULL Then Return nPvId + nNextId = EgtGetNext( nNextId) + End While + ' Cerco su elementi precedenti collegati + Dim nPrevId = EgtGetPrev( nSideId) + While nPrevId <> GDB_ID.NULL + Dim nPrevJoint As Integer = 1 + If EgtGetInfo( nPrevId, INFO_JOINENTITY, nPrevJoint) AndAlso nPrevJoint = 0 Then Exit While + nPvId = GetDirectPreViewFromSide( nPrevId, nPvGroupId) + If nPvId <> GDB_ID.NULL Then Return nPvId + nPrevId = EgtGetPrev( nPrevId) + End While + ' Non trovato + Return GDB_ID.NULL + End Function + + Public Sub ResetSplitCurvWJParam() + EgtDeselectObj(m_nIdSelectedSideWJ) + EgtResetMark(m_nIdSelectedWaterJet) + m_nIdSelectedSideWJ = GDB_ID.NULL + m_nIdSelectedWaterJet = GDB_ID.NULL + EgtDraw() + End Sub + + ' ricevo l'ID del percorso di lavorazione WJ al quale associo una etichetta grafica con scritto "S" + Private Sub AssignFlagOnGraphic(nMyId As Integer, NPartId As Integer) + ' cerco se esiste già un layer nominato "AUX_SPLIT_WJ", altrimenti lo creo + Dim nAuxLayerId As Integer = EgtGetFirstNameInGroup(NPartId, LAY_AUX_SPLIT_WJ) + If nAuxLayerId = GDB_ID.NULL Then + nAuxLayerId = EgtCreateGroup(NPartId) + EgtSetName(nAuxLayerId, LAY_AUX_SPLIT_WJ) + End If + ' inserisco flag + Dim nIdTextFlag As Integer = GetCreateFlagText(nMyId, nAuxLayerId) + EgtSetColor(nIdTextFlag, New Color3d(255, 0, 0)) + EgtSetName(nIdTextFlag, "RefSide_" & nMyId.ToString) + End Sub + + Private Function GetCreateFlagText(nId As Integer, nLayerId As Integer, Optional sText As String = "*") As Integer + ' Recupero il punto medio + Dim MidPoint As Point3d + EgtMidPoint(nId, GDB_RT.GLOB, MidPoint) + ' Recupero la direzione della curva nel punto medio e la ruota 90deg CCW + Dim vVers As Vector3d + EgtMidVector(nId, GDB_RT.GLOB, vVers) + vVers.Normalize() + vVers.Rotate(Vector3d.Z_AX, 90) + ' Ingombro complessivo della lavorazione + Dim b3Ent As New BBox3d + EgtGetBBoxGlob(nId, BBFLAG, b3Ent) + ' Metto il numero nel centro + Dim dRadXY = Point3d.DistXY(b3Ent.Min(), b3Ent.Max()) + Dim dHtxt As Double = 50 + Dim dRat As Double = 0.75 + If dRadXY < 200 Then + dHtxt = 40 + dRat = 0.6 + ElseIf dRadXY < 25 Then + dHtxt = 25 + dRat = 0.5 + End If + ' Determino la posizione + MidPoint.x += dHtxt / 2 * vVers.x + MidPoint.y += dHtxt / 2 * vVers.y + ' Creo il testo + Return EgtCreateTextAdv(nLayerId, MidPoint, 0, sText, "", 300, False, dHtxt, dRat, 0, INS_POS.MC, GDB_RT.GLOB) + End Function + + Private Sub EraseFlagOnGraphic(nMyId As Integer, nPartId As Integer) + ' cerco se esiste già un layer nominato "AUX_SPLIT_WJ" + Dim nAuxLayerId As Integer = EgtGetFirstNameInGroup(nPartId, LAY_AUX_SPLIT_WJ) + If nAuxLayerId = GDB_ID.NULL Then Return + Dim nIdTextFlag As Integer = EgtGetFirstNameInGroup(nAuxLayerId, "RefSide_" & nMyId.ToString) + EgtErase(nIdTextFlag) + End Sub + + Public Sub ResetStartCurvWJParam() + EgtResetMark(m_nIdSelectedWaterJet) + m_nIdSelectedWaterJet = GDB_ID.NULL + EgtDraw() + End Sub + +#End Region ' Split/Start Curve + +#Region "SPOT REGISTRATION" ' Layer per crocette dei punti REG (creato in Office) Public m_nRegGroupId As Integer = GDB_ID.NULL @@ -3695,7 +3693,7 @@ Public Class NestPageUC Return False End Function -#End Region +#End Region ' SPOT REGISTRATION End Class diff --git a/DirectCuts/VarMdiCommand.vb b/DirectCuts/VarMdiCommand.vb index 90408b4..24b3ba5 100644 --- a/DirectCuts/VarMdiCommand.vb +++ b/DirectCuts/VarMdiCommand.vb @@ -106,46 +106,53 @@ Module VarMdiCommand System.Threading.Thread.Sleep(100) ' salvo la stringa di comando ricevuta dal file lua CurrCN.sz_ManualDataInput = CmdString - ' esguo la funzione che ha il compito di scrivere il comando MDI + ' eseguo la funzione che ha il compito di scrivere il comando MDI CurrCN.MDI_command() End If ' attivo modalità Manuale CurrCN.DGeneralFunctions_WriteCncMode(7) System.Threading.Thread.Sleep(100) - If String.IsNullOrWhiteSpace(sEValue) Then - ' EActive: impulsivo "D#####" - CurrCN.NC_pulse_bit(sENumber) - EgtOutLog("Fanuc : DNumber=" & sENumber) - Else - ' EActive + EValue: scrittura comando invariabile Short oppure Bit - If sENumber.Contains(".") Then - ' D#####.# - Dim bEValue As Boolean - If sEValue.Trim = "0" Then bEValue = False - CurrCN.NC_write_var_bit(sENumber, bEValue) + ' eventuale caricamento prima variabile + If Not String.IsNullOrEmpty(sENumber) Then + If String.IsNullOrWhiteSpace(sEValue) Then + ' EActive: impulsivo "D#####" + CurrCN.NC_pulse_bit(sENumber) + EgtOutLog("Fanuc : DNumber=" & sENumber) Else - ' D##### - CurrCN.NC_write_var_short(sENumber, CShort(sEValue)) + ' EActive + EValue: scrittura comando invariabile Short oppure Bit + If sENumber.Contains(".") Then + ' D#####.# + Dim bEValue As Boolean = ( sEValue.Trim <> "0") + CurrCN.NC_write_var_bit(sENumber, bEValue) + Else + ' D##### + CurrCN.NC_write_var_short(sENumber, CShort(sEValue)) + End If + EgtOutLog("Fanuc : DNumber=" & sENumber & " DValue=" & sEValue) End If - EgtOutLog("Fanuc : DNumber=" & sENumber & " DValue=" & sEValue) + Else + EgtOutLog("Fanuc : DNumber=NullOrEmpty") End If ' eventale caricamento seconda variabile - If String.IsNullOrWhiteSpace(sEValue2) Then - ' EActive: impulsivo "D#####" - CurrCN.NC_pulse_bit(sENumber2) - EgtOutLog("Fanuc : DNumber2=" & sENumber2) - Else - ' EActive + EValue: scrittura comando invariabile Short oppure Bit - If sENumber2.Contains(".") Then - ' D#####.# - Dim bEValue2 As Boolean - If sEValue2.Trim = "0" Then bEValue2 = False - CurrCN.NC_write_var_bit(sENumber2, bEValue2) + If Not String.IsNullOrEmpty(sENumber2) Then + If String.IsNullOrWhiteSpace(sEValue2) Then + ' EActive: impulsivo "D#####" + CurrCN.NC_pulse_bit(sENumber2) + EgtOutLog("Fanuc : DNumber2=" & sENumber2) Else - ' D##### - CurrCN.NC_write_var_short(sENumber2, CShort(sEValue2)) + ' EActive + EValue: scrittura comando invariabile Short oppure Bit + If sENumber2.Contains(".") Then + ' D#####.# + Dim bEValue2 As Boolean = ( sEValue2.Trim <> "0") + CurrCN.NC_write_var_bit(sENumber2, bEValue2) + Else + ' D##### + CurrCN.NC_write_var_short(sENumber2, CShort(sEValue2)) + End If + EgtOutLog("Fanuc : DNumber2=" & sENumber2 & " DValue2=" & sEValue2) End If - EgtOutLog("Fanuc : DNumber2=" & sENumber2 & " DValue2=" & sEValue2) + Else + EgtOutLog("Fanuc : DNumber2=NullOrEmpty") End If Return Case Else ' Demo diff --git a/Machine/AlarmsPageUC.xaml.vb b/Machine/AlarmsPageUC.xaml.vb index ce1c2f8..691ecfb 100644 --- a/Machine/AlarmsPageUC.xaml.vb +++ b/Machine/AlarmsPageUC.xaml.vb @@ -351,7 +351,7 @@ Public Class AlarmsPageUC ' Flag per nesting automatico AutomaticChBx.IsChecked = (GetPrivateProfileInt(S_NEST, K_AUTOMATICOPTIMIZE, 0, m_MainWindow.GetIniFile()) <> 0) AdjustGhigliottinaTextOnAutomaticOrCompleteCuts() - ' Flag per inserire la puasa dopo la sgrossatura delle cornici + ' Flag per inserire la pausa dopo la sgrossatura delle cornici If m_CurrentMachine.bSawRoughing Then FrameGpBx.Visibility = Visibility.Visible FramePauseChBx.IsChecked = (GetPrivateProfileInt(S_MACH_FRAME, K_MACH_PAUSE, 1, m_MainWindow.GetMachIniFile()) <> 0) diff --git a/NcComm/M_Fanuc_hi.vb b/NcComm/M_Fanuc_hi.vb index a8281b0..5132dc5 100644 --- a/NcComm/M_Fanuc_hi.vb +++ b/NcComm/M_Fanuc_hi.vb @@ -648,8 +648,11 @@ Namespace Fanuc d_spindle_eff(0) = CDbl(n_temp) Case CnData.SpeedOvr ' (5) Potenziom. speed = ... n_spindle_override(0) = n_temp - Case CnData.Power ' (6) Ampère = * 0.01 + Case CnData.Power ' (6) Ampère = * 0.001 d_spindle_power = CDbl(n_temp) + If d_spindle_power < 0 Then + d_spindle_power = 65536 + d_spindle_power + End If b_spindle_power_changed = True Case CnData.PowerOvr ' (10) valore assorbimento massimo mandrino con l'utensile corrente bPowerOvr = CDbl(n_temp) diff --git a/Project/CurrentProjectPageUC.xaml.vb b/Project/CurrentProjectPageUC.xaml.vb index 8145fb8..8a9ed8d 100644 --- a/Project/CurrentProjectPageUC.xaml.vb +++ b/Project/CurrentProjectPageUC.xaml.vb @@ -439,7 +439,7 @@ Public Class CurrentProjectPageUC m_dRawHeight = 0 UpdateHeightTxBx() ' prima di parcheggiare svuoto dei pezzi in parcheggio sia vuota - m_MainWindow.m_CadCutPageUC.m_NestPage.ResetListOfGruopInPark() + m_MainWindow.m_CadCutPageUC.m_NestPage.ResetListOfGroupInPark() ' Parcheggio correttamente i pezzi precedentemente salvati Dim nIdList As New List(Of Integer) Dim nStatList As New List(Of Integer)