From 9d7842c068bd10cedeefeee8c1825d58a7bc98aa Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 2 Oct 2019 06:53:22 +0000 Subject: [PATCH] TestEIn 2.1j1 : - aggiornato e ricompilato. --- Controller.vb | 438 +++++++++++++++++++++++++++++++++---- EgtInterface.vb | 286 +++++++++++++++++++++++- My Project/AssemblyInfo.vb | 4 +- Scene.vb | 12 + 4 files changed, 693 insertions(+), 47 deletions(-) diff --git a/Controller.vb b/Controller.vb index e31c01b..296aa06 100644 --- a/Controller.vb +++ b/Controller.vb @@ -125,6 +125,12 @@ Public Class Controller SCALE3D OFFSET SELECTGROUP + MODIFYTEXT + EXTRACTSURFLOOPS + EXTRACTSURFFACETLOOPS + ADDSURF + SUBTRACTSURF + INTERSECTSURF End Enum Public Enum GRID_TYPE As Integer NONE = 0 @@ -160,10 +166,6 @@ Public Class Controller Private m_sLast As String = String.Empty Private m_bLast As Boolean = False Private m_bPnt3dVsDbl As Boolean = False - Private m_ptLastSel As Point3d ' punto da ultima selezione entità - Private m_nLastSel As Integer ' info aux da ultima selezione entità - Private m_ptPrevSel As Point3d ' unto da penultima selezione entità - Private m_nPrevSel As Integer ' info aux da penultima selezione entità Private m_ptCont As Point3d ' punto finale di entità precedente (per continuazione) Private m_vtCont As Vector3d = Vector3d.X_AX() ' direzione finale di entità precedente (per continuazione) Private m_dLastLen As Double = If(EgtUiUnitsAreMM(), 100, 101.6) ' ultima lunghezza per linea @@ -171,9 +173,11 @@ Public Class Controller Private m_dLastFillet As Double = If(EgtUiUnitsAreMM(), 10, 12.7) ' ultimo raggio per fillet Private m_dLastChamfer As Double = If(EgtUiUnitsAreMM(), 10, 12.7) ' ultima lunghezza per smusso Private m_dLastTextH As Double = If(EgtUiUnitsAreMM(), 10, 12.7) ' ultima altezza per testo - Private m_bLastExtrudeCheck As Boolean = False ' ultimo valore di check cap in estrusione + Private m_bLastCapEndsCheck As Boolean = False ' ultimo valore di check cap in estrusione e swept Private m_dLastExtrude As Double = If(EgtUiUnitsAreMM(), 20, 25.4) ' ultimo valore di estrusione per superficie Private m_dLastExtend As Double = If(EgtUiUnitsAreMM(), 50, 50.8) ' ultimo valore di allungamento + Private m_bLastRuledCheck As Boolean = False ' ultimo valore di check mindist in ruled + Private m_bLastBooleanCheck As Boolean = False ' ultimo valore di check cancella originali in booleane Private m_bLastTransfCheck As Boolean = False ' ultimo valore di check copia nelle trasformazioni Private m_bLastOffsetCheck As Boolean = True ' ultimo valore di check copia in offset Private m_dLastOffset As Double = If(EgtUiUnitsAreMM(), 10, 12.7) ' ultimo valore di offset @@ -538,9 +542,10 @@ Public Class Controller .Title = "Export", .Filter = "Drawing Exchange Fmt(*.dxf)|*.dxf" & "|Stereolithography (*.stl)|*.stl" & + "|Svg (*.svg)|*.svg" & "|Images (*.png;*.jpg;*.jpeg;*.bmp)|*.png;*.jpg;*.jpeg;*.bmp" & "|All Files (*.*)|*.*", - .FilterIndex = 4, + .FilterIndex = 5, .FileName = sFile } If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then @@ -548,7 +553,7 @@ Public Class Controller End If 'Riconoscimento tipo file Dim nFileType As Integer = EgtGetFileType(SaveFileDialog.FileName) - If nFileType <> FT.DXF And nFileType <> FT.STL And nFileType <> FT.IMG Then + If nFileType <> FT.DXF And nFileType <> FT.STL And nFileType <> FT.IMG And nFileType <> FT.SVG Then MessageBox.Show("File type unknown", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Return False End If @@ -566,6 +571,8 @@ Public Class Controller ElseIf nFileType = FT.IMG Then bOk = EgtGetImage(EgtGetShowMode(), New Color3d(255, 255, 255), New Color3d(255, 255, 255), m_nImgWidth, m_nImgHeight, sFileName) + ElseIf nFileType = FT.SVG Then + bOk = EgtExportSvg(GDB_ID.ROOT, sFileName) End If DisableCommandLog() 'Aggiornamento @@ -997,10 +1004,7 @@ Public Class Controller Public Sub SetPointFromSelection(nId As Integer, PtP As Point3d, nAux As Integer) If EgtIsSelectedObj(nId) Then - m_ptPrevSel = m_ptLastSel - m_nPrevSel = m_nLastSel - m_ptLastSel = PtP - m_nLastSel = nAux + EgtSetSelInfo( nId, nAux, ptP) End If End Sub @@ -1202,6 +1206,21 @@ Public Class Controller ' Invert Surface Case CMD.INVERTSURF Return ProcessInvertSurf() + ' Extract Surf Loops + Case CMD.EXTRACTSURFLOOPS + Return ProcessExtractSurfLoops() + ' Extract Facet Loops + Case CMD.EXTRACTSURFFACETLOOPS + Return ProcessExtractSurfFacetLoops() + ' Add Surface + Case CMD.ADDSURF + Return ProcessAddSurf() + ' Subtract Surface + Case CMD.SUBTRACTSURF + Return ProcessSubtractSurf() + ' Intersect Surface + Case CMD.INTERSECTSURF + Return ProcessIntersectSurf() ' Delete Case CMD.DELETE Return ProcessDelete() @@ -1244,6 +1263,9 @@ Public Class Controller ' Set Curve Thickness Case CMD.SETCURVETHICKNESS Return ProcessSetCurveThickness() + ' Modify Text + Case CMD.MODIFYTEXT + Return ModifyText() ' Move Case CMD.MOVE Return ProcessMove() @@ -1338,6 +1360,8 @@ Public Class Controller DragExtendCurve() Case CMD.SETCURVETHICKNESS DragSetCurveThickness() + Case CMD.MODIFYTEXT + DragModifyText() Case CMD.MOVE DragMove() Case CMD.ROTATE @@ -1703,7 +1727,10 @@ Public Class Controller EgtSetGridFrame(frNew) DisableCommandLog() Case GDB_TY.SRF_MESH - Dim nF As Integer = EgtSurfTmFacetFromTria(nId, m_nLastSel) + Dim nLastId, nLastSub As Integer + Dim ptLastSel As Point3d + EgtGetLastSelInfo( nLastId, nLastSub, ptLastSel) + Dim nF As Integer = EgtSurfTmFacetFromTria(nId, nLastSub) If nF >= 0 Then Dim ptOrig As Point3d Dim vtZ As Vector3d @@ -3161,11 +3188,13 @@ Public Class Controller ' reset scena m_Scene.ResetStatus(False) ' creo il fillet (i punti sono in globale) - Dim nId2 As Integer = EgtGetLastSelectedObj() - Dim nId1 As Integer = EgtGetPrevSelectedObj() + Dim nId1, nSub1, nId2, nSub2 As Integer + Dim ptSel1, ptSel2 As Point3d + EgtGetLastSelInfo( nId2, nSub2, ptSel2) + EgtGetPrevSelInfo( nId1, nSub1, ptSel1) EnableCommandLog() EgtCreateCurveFillet(GetCurrLayer(), - nId1, m_ptPrevSel.Loc(GDB_ID.GRID), nId2, m_ptLastSel.Loc(GDB_ID.GRID), + nId1, ptSel1.Loc(GDB_ID.GRID), nId2, ptSel2.Loc(GDB_ID.GRID), m_dLast, m_bLast, GDB_RT.GRID) DisableCommandLog() EgtDraw() @@ -3186,11 +3215,15 @@ Public Class Controller ' svuoto il gruppo di drag EgtEmptyGroup(m_Scene.GetDragGroup()) ' inserisco le due curve nel gruppo di drag - Dim nId2 As Integer = m_Scene.AddToDragGroup(EgtGetLastSelectedObj()) - Dim nId1 As Integer = m_Scene.AddToDragGroup(EgtGetPrevSelectedObj()) + Dim nId1, nSub1, nId2, nSub2 As Integer + Dim ptSel1, ptSel2 As Point3d + EgtGetLastSelInfo( nId2, nSub2, ptSel2) + EgtGetPrevSelInfo( nId1, nSub1, ptSel1) + nId2 = m_Scene.AddToDragGroup(nId2) + nId1 = m_Scene.AddToDragGroup(nId1) ' creo fillet (il gruppo di Drag ha riferimento globale) EgtCreateCurveFillet(m_Scene.GetDragGroup(), - nId1, m_ptPrevSel.Loc(GDB_ID.GRID), nId2, m_ptLastSel.Loc(GDB_ID.GRID), + nId1, ptSel1.Loc(GDB_ID.GRID), nId2, ptSel2.Loc(GDB_ID.GRID), m_dLast, m_bLast, GDB_RT.GRID) EgtDraw() End If @@ -3215,11 +3248,13 @@ Public Class Controller ' reset scena m_Scene.ResetStatus(False) ' creo il fillet (i punti sono in globale) - Dim nId2 As Integer = EgtGetLastSelectedObj() - Dim nId1 As Integer = EgtGetPrevSelectedObj() + Dim nId1, nSub1, nId2, nSub2 As Integer + Dim ptSel1, ptSel2 As Point3d + EgtGetLastSelInfo( nId2, nSub2, ptSel2) + EgtGetPrevSelInfo( nId1, nSub1, ptSel1) EnableCommandLog() EgtCreateCurveChamfer(GetCurrLayer(), - nId1, m_ptPrevSel.Loc(GDB_ID.GRID), nId2, m_ptLastSel.Loc(GDB_ID.GRID), + nId1, ptSel1.Loc(GDB_ID.GRID), nId2, ptSel2.Loc(GDB_ID.GRID), m_dLast, m_bLast, GDB_RT.GRID) DisableCommandLog() EgtDraw() @@ -3240,11 +3275,15 @@ Public Class Controller ' svuoto il gruppo di drag EgtEmptyGroup(m_Scene.GetDragGroup()) ' inserisco le due curve nel gruppo di drag - Dim nId2 As Integer = m_Scene.AddToDragGroup(EgtGetLastSelectedObj()) - Dim nId1 As Integer = m_Scene.AddToDragGroup(EgtGetPrevSelectedObj()) + Dim nId1, nSub1, nId2, nSub2 As Integer + Dim ptSel1, ptSel2 As Point3d + EgtGetLastSelInfo( nId2, nSub2, ptSel2) + EgtGetPrevSelInfo( nId1, nSub1, ptSel1) + nId2 = m_Scene.AddToDragGroup( nId2) + nId1 = m_Scene.AddToDragGroup( nId1) ' creo chamfer (il gruppo di Drag ha riferimento globale) EgtCreateCurveChamfer(m_Scene.GetDragGroup(), - nId1, m_ptPrevSel.Loc(GDB_ID.GRID), nId2, m_ptLastSel.Loc(GDB_ID.GRID), + nId1, ptSel1.Loc(GDB_ID.GRID), nId2, ptSel2.Loc(GDB_ID.GRID), m_dLast, m_bLast, GDB_RT.GRID) EgtDraw() End If @@ -3620,13 +3659,9 @@ Public Class Controller End Sub Private Function ProcessRegion() As Boolean - If m_nStep <> 0 Then - Return False - End If + If m_nStep <> 0 Then Return False ' posso partire solo se esiste un gruppo corrente - If GetCurrLayer() = GDB_ID.NULL Then - Return False - End If + If GetCurrLayer() = GDB_ID.NULL Then Return False ' creo la regione piana (a partire da uno o più contorni selezionati) EnableCommandLog() ' creo vettore di entità selezionate @@ -3701,7 +3736,7 @@ Public Class Controller m_Scene.SetStatusNull() ' abilito dialogo RaiseEvent PrepareInputBox("EXTRUSION", "Insert length", "CapEnds", False, True) - RaiseEvent SetInputBoxCheck(m_bLastExtrudeCheck) + RaiseEvent SetInputBoxCheck(m_bLastCapEndsCheck) m_nInpType = IBT.TY_LENGTH m_dLast = If(Math.Abs(m_dLastExtrude) > 10 * EPS_SMALL, m_dLastExtrude, 10 * EPS_SMALL) SetInputBoxDouble(m_dLast, True) @@ -3735,9 +3770,8 @@ Public Class Controller m_dEpsStm, GDB_RT.GRID) End If DisableCommandLog() - EgtDraw() ' aggiorno stato - m_bLastExtrudeCheck = m_bLast + m_bLastCapEndsCheck = m_bLast m_dLastExtrude = m_dLast m_nStep = 0 RaiseEvent UpdateUI(Me, True) @@ -3925,7 +3959,7 @@ Public Class Controller m_nStep = 1 ' abilito dialogo RaiseEvent PrepareInputBox("SWEPT", "", "CapEnds", False, True) - RaiseEvent SetInputBoxCheck(m_bLastExtrudeCheck) + RaiseEvent SetInputBoxCheck(m_bLastCapEndsCheck) m_nInpType = IBT.TY_NULL ' anteprima EgtDisableModified() @@ -3972,7 +4006,7 @@ Public Class Controller m_nStep = 1 ' abilito dialogo RaiseEvent PrepareInputBox("RULED", "", "MinDist", False, True) - RaiseEvent SetInputBoxCheck(m_bLastExtrudeCheck) + RaiseEvent SetInputBoxCheck(m_bLastRuledCheck) m_nInpType = IBT.TY_NULL ' anteprima EgtDisableModified() @@ -3985,6 +4019,8 @@ Public Class Controller Dim nPrevId As Integer = EgtGetPrevSelectedObj() EgtCreateSurfTmRuled(GetCurrLayer(), nPrevId, nLastId, If( m_bLast, RUL_TYPE.MINDIST, RUL_TYPE.ISOPAR), m_dEpsStm) DisableCommandLog() + ' aggiorno stato + m_bLastRuledCheck = m_bLast ' reset stato scena m_Scene.ResetStatus() ' reset stato @@ -4001,7 +4037,7 @@ Public Class Controller If m_nStep = 1 Then ' cancello eventuale vecchia superficie rigata EgtEmptyGroup(m_Scene.GetDragGroup()) - ' creo la superficie rigatat (a partire dai contorni selezionati) + ' creo la superficie rigata (a partire dai contorni selezionati) Dim nGuideId As Integer = EgtGetLastSelectedObj() Dim nSectId As Integer = EgtGetPrevSelectedObj() ' eseguo @@ -4072,7 +4108,7 @@ Public Class Controller End If ' lancio l'inversione delle superfici EnableCommandLog() - EgtInvertSurface(GDB_ID.SEL) + EgtInvertSurface( GDB_ID.SEL) DisableCommandLog() ' reset stato scena m_Scene.ResetStatus() @@ -4082,6 +4118,227 @@ Public Class Controller Return True End Function + Private Function ProcessExtractSurfLoops() As Boolean + If m_nStep <> 0 Then Return False + ' posso partire solo se esiste un gruppo corrente + If GetCurrLayer() = GDB_ID.NULL Then Return False + ' lancio l'estrazione dei contorni della superficie + EnableCommandLog() + Dim nCount As Integer = 0 + EgtExtractSurfTmLoops( EgtGetLastSelectedObj(), GetCurrLayer(), nCount) + DisableCommandLog() + ' reset stato scena + m_Scene.ResetStatus() + ' reset stato + m_nStep = 0 + RaiseEvent UpdateUI(Me, True) + Return True + End Function + + Private Function ProcessExtractSurfFacetLoops() As Boolean + If m_nStep <> 0 Then Return False + ' posso partire solo se esiste un gruppo corrente + If GetCurrLayer() = GDB_ID.NULL Then Return False + ' lancio l'estrazione dei contorni della superficie + EnableCommandLog() + Dim nLastId, nLastSub As Integer + Dim ptLastSel As Point3d + EgtGetLastSelInfo( nLastId, nLastSub, ptLastSel) + Dim nF As Integer = EgtSurfTmFacetFromTria(nLastId, nLastSub) + If nF >= 0 Then + Dim nCount As Integer = 0 + EgtExtractSurfTmFacetLoops( nLastId, nF, GetCurrLayer(), nCount) + End If + DisableCommandLog() + ' reset stato scena + m_Scene.ResetStatus() + ' reset stato + m_nStep = 0 + RaiseEvent UpdateUI(Me, True) + Return True + End Function + + Private Function ProcessAddSurf() As Boolean + Select Case m_nStep + Case 0 + ' deve esistere un gruppo corrente e devo poter creare il gruppo di drag + If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False + ' imposto nuovo stato + m_nStep = 1 + ' abilito dialogo + RaiseEvent PrepareInputBox("ADD SURF", "", "", False, False) + m_nInpType = IBT.TY_NULL + ' anteprima + EgtDisableModified() + DragAddSurf() + EgtEnableModified() + Case 1 + ' eseguo l'unione delle due superfici + EnableCommandLog() + Dim nLastId As Integer = EgtGetLastSelectedObj() + Dim nPrevId As Integer = EgtGetPrevSelectedObj() + If EgtGetType( nPrevId) = GDB_TY.SRF_FRGN And EgtGetType( nLastId) = GDB_TY.SRF_FRGN Then + EgtSurfFrAdd( nPrevId, nLastId) + EgtErase( nLastId) + ElseIf EgtGetType( nPrevId) = GDB_TY.SRF_MESH And EgtGetType( nLastId) = GDB_TY.SRF_MESH Then + EgtSurfTmAdd( nPrevId, nLastId) + EgtErase( nLastId) + End If + DisableCommandLog() + ' reset stato scena + m_Scene.ResetStatus() + ' reset stato + m_nStep = 0 + RaiseEvent UpdateUI(Me, True) + Case Else + m_nStep = 0 + Return False + End Select + Return True + End Function + + Private Sub DragAddSurf() + If m_nStep = 1 Then + ' cancello eventuale vecchia superficie unione + EgtEmptyGroup( m_Scene.GetDragGroup()) + ' creo la superficie unione delle due superfici + Dim nLastId As Integer = EgtGetLastSelectedObj() + Dim nPrevId As Integer = EgtGetPrevSelectedObj() + If EgtGetType( nPrevId) = GDB_TY.SRF_FRGN And EgtGetType( nLastId) = GDB_TY.SRF_FRGN Then + Dim nDragId As Integer = EgtCopyGlob( nPrevId, m_Scene.GetDragGroup()) + EgtSurfFrAdd( nDragId, nLastId) + ElseIf EgtGetType( nPrevId) = GDB_TY.SRF_MESH And EgtGetType( nLastId) = GDB_TY.SRF_MESH Then + Dim nDragId As Integer = EgtCopyGlob( nPrevId, m_Scene.GetDragGroup()) + EgtSurfTmAdd( nDragId, nLastId) + End If + EgtDraw() + End If + End Sub + + Private Function ProcessSubtractSurf() As Boolean + Select Case m_nStep + Case 0 + ' deve esistere un gruppo corrente e devo poter creare il gruppo di drag + If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False + ' imposto nuovo stato + m_nStep = 1 + ' abilito dialogo + RaiseEvent PrepareInputBox("SUBTRACT SURF", "", "Erase tool", False, True) + RaiseEvent SetInputBoxCheck( m_bLastBooleanCheck) + m_nInpType = IBT.TY_NULL + ' anteprima + EgtDisableModified() + DragAddSurf() + EgtEnableModified() + Case 1 + ' eseguo la sottrazione delle due superfici + EnableCommandLog() + Dim nLastId As Integer = EgtGetLastSelectedObj() + Dim nPrevId As Integer = EgtGetPrevSelectedObj() + If EgtGetType( nPrevId) = GDB_TY.SRF_FRGN And EgtGetType( nLastId) = GDB_TY.SRF_FRGN Then + EgtSurfFrSubtract( nPrevId, nLastId) + If m_bLast Then EgtErase( nLastId) + ElseIf EgtGetType( nPrevId) = GDB_TY.SRF_MESH And EgtGetType( nLastId) = GDB_TY.SRF_MESH Then + EgtSurfTmSubtract( nPrevId, nLastId) + If m_bLast Then EgtErase( nLastId) + End If + DisableCommandLog() + ' salvo stato + m_bLastBooleanCheck = m_bLast + ' reset stato scena + m_Scene.ResetStatus() + ' reset stato + m_nStep = 0 + RaiseEvent UpdateUI(Me, True) + Case Else + m_nStep = 0 + Return False + End Select + Return True + End Function + + Private Sub DragSubtractSurf() + If m_nStep = 1 Then + ' cancello eventuale vecchia superficie differenza + EgtEmptyGroup( m_Scene.GetDragGroup()) + ' creo la superficie differenza delle due superfici + Dim nLastId As Integer = EgtGetLastSelectedObj() + Dim nPrevId As Integer = EgtGetPrevSelectedObj() + If EgtGetType( nPrevId) = GDB_TY.SRF_FRGN And EgtGetType( nLastId) = GDB_TY.SRF_FRGN Then + Dim nDragId As Integer = EgtCopyGlob( nPrevId, m_Scene.GetDragGroup()) + EgtSurfFrSubtract( nDragId, nLastId) + ElseIf EgtGetType( nPrevId) = GDB_TY.SRF_MESH And EgtGetType( nLastId) = GDB_TY.SRF_MESH Then + Dim nDragId As Integer = EgtCopyGlob( nPrevId, m_Scene.GetDragGroup()) + EgtSurfTmSubtract( nDragId, nLastId) + End If + EgtDraw() + End If + End Sub + + Private Function ProcessIntersectSurf() As Boolean + Select Case m_nStep + Case 0 + ' deve esistere un gruppo corrente e devo poter creare il gruppo di drag + If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False + ' imposto nuovo stato + m_nStep = 1 + ' abilito dialogo + RaiseEvent PrepareInputBox( "INTERSECT SURF", "", "Erase original", False, True) + RaiseEvent SetInputBoxCheck( m_bLastBooleanCheck) + m_nInpType = IBT.TY_NULL + ' anteprima + EgtDisableModified() + DragAddSurf() + EgtEnableModified() + Case 1 + ' eseguo l'intersezione delle due superfici + EnableCommandLog() + Dim nLastId As Integer = EgtGetLastSelectedObj() + Dim nPrevId As Integer = EgtGetPrevSelectedObj() + If EgtGetType( nPrevId) = GDB_TY.SRF_FRGN And EgtGetType( nLastId) = GDB_TY.SRF_FRGN Then + EgtSurfFrIntersect( nPrevId, nLastId) + If m_bLast Then + EgtErase( nLastId) + End If + ElseIf EgtGetType( nPrevId) = GDB_TY.SRF_MESH And EgtGetType( nLastId) = GDB_TY.SRF_MESH Then + EgtSurfTmIntersect( nPrevId, nLastId) + If m_bLast Then + EgtErase( nLastId) + End If + End If + DisableCommandLog() + ' salvo stato + m_bLastBooleanCheck = m_bLast + ' reset stato scena + m_Scene.ResetStatus() + ' reset stato + m_nStep = 0 + RaiseEvent UpdateUI(Me, True) + Case Else + m_nStep = 0 + Return False + End Select + Return True + End Function + + Private Sub DragIntersectSurf() + If m_nStep = 1 Then + ' cancello eventuale vecchia superficie intersezione + EgtEmptyGroup( m_Scene.GetDragGroup()) + ' creo la superficie intersezione delle due superfici + Dim nLastId As Integer = EgtGetLastSelectedObj() + Dim nPrevId As Integer = EgtGetPrevSelectedObj() + If EgtGetType( nPrevId) = GDB_TY.SRF_FRGN And EgtGetType( nLastId) = GDB_TY.SRF_FRGN Then + Dim nDragId As Integer = EgtCopyGlob( nPrevId, m_Scene.GetDragGroup()) + EgtSurfFrIntersect( nDragId, nLastId) + ElseIf EgtGetType( nPrevId) = GDB_TY.SRF_MESH And EgtGetType( nLastId) = GDB_TY.SRF_MESH Then + Dim nDragId As Integer = EgtCopyGlob( nPrevId, m_Scene.GetDragGroup()) + EgtSurfTmIntersect( nDragId, nLastId) + End If + EgtDraw() + End If + End Sub + Private Function ProcessDelete() As Boolean If m_nStep <> 0 Then Return False @@ -4258,19 +4515,21 @@ Public Class Controller m_dLast = m_dLastExtend ' recupero dati estremo più vicino a punto di selezione per permettere drag lunghezza con mouse m_Scene.SetStatusSelPoint(False) - Dim nId As Integer = EgtGetLastSelectedObj() + Dim nId, nSub As Integer + Dim ptLastSel As Point3d + EgtGetLastSelInfo( nId, nSub, ptLastSel) EgtCurveLength(nId, m_dPrev) Dim bStart As Boolean = True - EgtCurveNearestExtremityToPoint(nId, m_ptLastSel.Loc(nId), bStart) + EgtCurveNearestExtremityToPoint(nId, ptLastSel.Loc(nId), bStart) If bStart Then m_bLast = True - m_ptP1 = m_ptLastSel + m_ptP1 = ptLastSel EgtStartVector(nId, m_vtCont) m_vtCont = -m_vtCont.Glob(nId) Else m_bLast = False EgtEndPoint(nId, m_ptP1) - m_ptP1 = m_ptLastSel + m_ptP1 = ptLastSel EgtEndVector(nId, m_vtCont) m_vtCont = m_vtCont.Glob(nId) End If @@ -4553,6 +4812,103 @@ Public Class Controller End If End Sub + Private Function ModifyText() As Boolean + Select Case m_nStep + Case 0 + ' verifico condizioni e preparo per il drag + Dim nId As Integer = EgtGetLastSelectedObj() + If EgtGetType(nId) <> GDB_TY.EXT_TEXT Then Return False + If Not PrepareTransform(False) Then Return False + ' imposto stato a modifica testo + m_nStep = 1 + m_Scene.SetStatusNull() + ' recupero il testo originale + m_sLast = String.Empty + EgtTextGetContent( nId, m_sLast) + ' abilito dialogo + RaiseEvent PrepareInputBox("MODIFY TEXT", "Modify Text", "", False, True) + m_nInpType = IBT.TY_STRING + SetInputBoxString(m_sLast) + Case 1 + m_nStep = 2 + m_Scene.SetStatusNull() + ' recupero gli attributi del testo + Dim nId As Integer = EgtGetLastSelectedObj() + Dim dH As Double = m_dLastTextH + EgtTextGetHeight( nId, dH) + Dim bItalic As Boolean = False + EgtTextGetItalic( nId, bItalic) + Dim sFont As String = string.Empty + EgtTextGetFont( nId, sFont) + if String.IsNullOrWhiteSpace( sFont) Then EgtGetDefaultFont( sFont) + RaiseEvent PrepareInputBox("MODIFY TEXT", "Insert Height", "Italic", True, True) + m_nInpType = IBT.TY_LENGTH + m_dLast = dH + SetInputBoxDouble(m_dLast, True) + m_bLast = bItalic + RaiseEvent SetInputBoxCheck(m_bLast) + LoadFonts() + For i As Integer = 0 To m_sFonts.Count() - 1 + Dim bSel = (String.Compare(m_sFonts(i), sFont, True) = 0) + RaiseEvent AddInputBoxCombo(m_sFonts(i), bSel) + Next + Case 2 + ' reset scena + m_Scene.ResetStatus(False) + Dim nId As Integer = EgtGetLastSelectedObj() + EnableCommandLog() + ' modifico il contenuto del testo + EgtModifyText( nId, m_sLast) + ' modifico l'altezza + EgtChangeTextHeight( nId, m_dLast) + ' modifico il flag di italico + EgtChangeTextItalic( nId, m_bLast) + ' modifico il font + Dim sFont As String = String.Empty + If m_nLast >= 0 And m_nLast < m_sFonts.Count() Then + sFont = m_sFonts(m_nLast) + End If + EgtChangeTextFont( nId, sFont) + DisableCommandLog() + EgtDraw() + ' aggiorno stato + m_dLastTextH = m_dLast + m_nStep = 0 + RaiseEvent UpdateUI(Me, True) + Case Else + m_nStep = 0 + Return False + End Select + Return True + End Function + + Private Sub DragModifyText() + ' il gruppo di Drag ha riferimento globale + If m_nStep = 1 Then + ' recupero entità testo già nel gruppo di drag + Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup()) + if nId = GDB_ID.NULL Then Return + ' modifico il contenuto del testo + EgtModifyText( nId, m_sLast) + EgtDraw() + ElseIf m_nStep = 2 Then + ' recupero entità testo già nel gruppo di drag + Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup()) + if nId = GDB_ID.NULL Then Return + ' modifico l'altezza + EgtChangeTextHeight( nId, m_dLast) + ' modifico il flag di italico + EgtChangeTextItalic( nId, m_bLast) + ' modifico il font + Dim sFont As String = String.Empty + If m_nLast >= 0 And m_nLast < m_sFonts.Count() Then + sFont = m_sFonts(m_nLast) + End If + EgtChangeTextFont( nId, sFont) + EgtDraw() + End If + End Sub + Private Function ProcessMove() As Boolean Select Case m_nStep Case 0 diff --git a/EgtInterface.vb b/EgtInterface.vb index 4aae891..4e27d4e 100644 --- a/EgtInterface.vb +++ b/EgtInterface.vb @@ -231,6 +231,17 @@ Structure Vector3d End Function End Structure +' Calcolo dell'angolo tra due vettori +Function GetAngle( ByRef vtV1 As Vector3d, ByRef vtV2 As Vector3d) As Double + ' quantità ugualmente proporzionali a coseno e seno + Dim dProSca As Double = vtV1 * vtV2 + Dim dProVett As Double = ( vtV1 ^ vtV2).Len() + ' se entrambe nulle + If Math.Abs( dProSca) < EPS_ZERO And Math.Abs( dProVett) < EPS_ZERO Then Return 0 + ' calcolo l'angolo + Return Math.Atan2( dProVett, dProSca) * 180 / Math.PI +End Function + Structure Point3d ' Membri Dim x, y, z As Double @@ -1899,6 +1910,20 @@ Public Function EgtExportStl(nId As Integer, sFilePath As String) As Boolean End If End Function + +Private Function EgtExportSvg_32(nId As Integer, sFilePath As String) As Boolean +End Function + +Private Function EgtExportSvg_64(nId As Integer, sFilePath As String) As Boolean +End Function +Public Function EgtExportSvg(nId As Integer, sFilePath As String) As Boolean + If IntPtr.Size = 4 Then + Return EgtExportSvg_32(nId, sFilePath) + Else + Return EgtExportSvg_64(nId, sFilePath) + End If +End Function + '---------- Tsc Executor ------------------------------------------------------- @@ -3198,6 +3223,48 @@ Public Function EgtModifyText(nId As Integer, sText As String) As Boolean End If End Function + +Private Function EgtChangeTextFont_32(nId As Integer, sNewFont As String) As Boolean +End Function + +Private Function EgtChangeTextFont_64(nId As Integer, sNewFont As String) As Boolean +End Function +Public Function EgtChangeTextFont(nId As Integer, sNewFont As String) As Boolean + If IntPtr.Size = 4 Then + Return EgtChangeTextFont_32(nId, sNewFont) + Else + Return EgtChangeTextFont_64(nId, sNewFont) + End If +End Function + + +Private Function EgtChangeTextHeight_32(nId As Integer, dNewH As Double) As Boolean +End Function + +Private Function EgtChangeTextHeight_64(nId As Integer, dNewH As Double) As Boolean +End Function +Public Function EgtChangeTextHeight(nId As Integer, dNewH As Double) As Boolean + If IntPtr.Size = 4 Then + Return EgtChangeTextHeight_32(nId, dNewH) + Else + Return EgtChangeTextHeight_64(nId, dNewH) + End If +End Function + + +Private Function EgtChangeTextItalic_32(nId As Integer, bNewItalic As Boolean) As Boolean +End Function + +Private Function EgtChangeTextItalic_64(nId As Integer, bNewItalic As Boolean) As Boolean +End Function +Public Function EgtChangeTextItalic(nId As Integer, bNewItalic As Boolean) As Boolean + If IntPtr.Size = 4 Then + Return EgtChangeTextItalic_32(nId, bNewItalic) + Else + Return EgtChangeTextItalic_64(nId, bNewItalic) + End If +End Function + Private Function EgtExplodeText_32(nId As Integer, ByRef nCount As Integer) As Integer End Function @@ -3798,6 +3865,20 @@ Public Function EgtGetSurfTmSilhouette(nId As Integer, vtDir As Vector3d, nDestG End If End Function + +Private Function EgtExtractSurfTmLoops_32(nId As Integer, nDestGrpId As Integer, ByRef nCount As Integer) As Integer +End Function + +Private Function EgtExtractSurfTmLoops_64(nId As Integer, nDestGrpId As Integer, ByRef nCount As Integer) As Integer +End Function +Public Function EgtExtractSurfTmLoops(nId As Integer, nDestGrpId As Integer, ByRef nCount As Integer) As Integer + If IntPtr.Size = 4 Then + Return EgtExtractSurfTmLoops_32(nId, nDestGrpId, nCount) + Else + Return EgtExtractSurfTmLoops_64(nId, nDestGrpId, nCount) + End If +End Function + Private Function EgtExtractSurfTmFacetLoops_32(nId As Integer, nFacet As Integer, nDestGrpId As Integer, ByRef nCount As Integer) As Integer End Function @@ -3826,6 +3907,48 @@ Public Function EgtCopySurfTmFacet(nId As Integer, nFacet As Integer, nDestGrpId End If End Function + +Private Function EgtSurfTmAdd_32(nId1 As Integer, nId2 As Integer) As Boolean +End Function + +Private Function EgtSurfTmAdd_64(nId1 As Integer, nId2 As Integer) As Boolean +End Function +Public Function EgtSurfTmAdd(nId1 As Integer, nId2 As Integer) As Boolean + If IntPtr.Size = 4 Then + Return EgtSurfTmAdd_32(nId1, nId2) + Else + Return EgtSurfTmAdd_64(nId1, nId2) + End If +End Function + + +Private Function EgtSurfTmSubtract_32(nId1 As Integer, nId2 As Integer) As Boolean +End Function + +Private Function EgtSurfTmSubtract_64(nId1 As Integer, nId2 As Integer) As Boolean +End Function +Public Function EgtSurfTmSubtract(nId1 As Integer, nId2 As Integer) As Boolean + If IntPtr.Size = 4 Then + Return EgtSurfTmSubtract_32(nId1, nId2) + Else + Return EgtSurfTmSubtract_64(nId1, nId2) + End If +End Function + + +Private Function EgtSurfTmIntersect_32(nId1 As Integer, nId2 As Integer) As Boolean +End Function + +Private Function EgtSurfTmIntersect_64(nId1 As Integer, nId2 As Integer) As Boolean +End Function +Public Function EgtSurfTmIntersect(nId1 As Integer, nId2 As Integer) As Boolean + If IntPtr.Size = 4 Then + Return EgtSurfTmIntersect_32(nId1, nId2) + Else + Return EgtSurfTmIntersect_64(nId1, nId2) + End If +End Function + '---------- GeomDb Parts & Layers ---------------------------------------------- Private Function EgtIsPart_32(nPartId As Integer) As Boolean @@ -5564,6 +5687,48 @@ Public Function EgtGetPrevSelectedObj() As Integer End If End Function + +Private Function EgtSetSelInfo_32( nId As Integer, nSub As Integer, ByRef ptSel As Point3d) As Boolean +End Function + +Private Function EgtSetSelInfo_64( nId As Integer, nSub As Integer, ByRef ptSel As Point3d) As Boolean +End Function +Public Function EgtSetSelInfo( nId As Integer, nSub As Integer, ByRef ptSel As Point3d) As Boolean + If IntPtr.Size = 4 Then + Return EgtSetSelInfo_32( nId, nSub, ptSel) + Else + Return EgtSetSelInfo_64( nId, nSub, ptSel) + End If +End Function + + +Private Function EgtGetLastSelInfo_32( ByRef nLastId As Integer, ByRef nLastSub As Integer, ByRef ptLastSel As Point3d) As Boolean +End Function + +Private Function EgtGetLastSelInfo_64( ByRef nLastId As Integer, ByRef nLastSub As Integer, ByRef ptLastSel As Point3d) As Boolean +End Function +Public Function EgtGetLastSelInfo( ByRef nLastId As Integer, ByRef nLastSub As Integer, ByRef ptLastSel As Point3d) As Boolean + If IntPtr.Size = 4 Then + Return EgtGetLastSelInfo_32(nLastId, nLastSub, ptLastSel) + Else + Return EgtGetLastSelInfo_64(nLastId, nLastSub, ptLastSel) + End If +End Function + + +Private Function EgtGetPrevSelInfo_32( ByRef nPrevId As Integer, ByRef nPrevSub As Integer, ByRef ptPrevSel As Point3d) As Boolean +End Function + +Private Function EgtGetPrevSelInfo_64( ByRef nPrevId As Integer, ByRef nPrevSub As Integer, ByRef ptPrevSel As Point3d) As Boolean +End Function +Public Function EgtGetPrevSelInfo( ByRef nPrevId As Integer, ByRef nPrevSub As Integer, ByRef ptPrevSel As Point3d) As Boolean + If IntPtr.Size = 4 Then + Return EgtGetPrevSelInfo_32(nPrevId, nPrevSub, ptPrevSel) + Else + Return EgtGetPrevSelInfo_64(nPrevId, nPrevSub, ptPrevSel) + End If +End Function + '---------- GeomDb Obj Transform ----------------------------------------------- @@ -6482,6 +6647,34 @@ Public Function EgtTextGetFont(nId As Integer, ByRef sFont As String) As Boolean Return bOk End Function + +Private Function EgtTextGetHeight_32(nId As Integer, ByRef dH As Double) As Boolean +End Function + +Private Function EgtTextGetHeight_64(nId As Integer, ByRef dH As Double) As Boolean +End Function +Public Function EgtTextGetHeight(nId As Integer, ByRef dH As Double) As Boolean + If IntPtr.Size = 4 Then + Return EgtTextGetHeight_32(nId, dH) + Else + Return EgtTextGetHeight_64(nId, dH) + End If +End Function + + +Private Function EgtTextGetItalic_32(nId As Integer, ByRef bItalic As Boolean) As Boolean +End Function + +Private Function EgtTextGetItalic_64(nId As Integer, ByRef bItalic As Boolean) As Boolean +End Function +Public Function EgtTextGetItalic(nId As Integer, ByRef bItalic As Boolean) As Boolean + If IntPtr.Size = 4 Then + Return EgtTextGetItalic_32(nId, bItalic) + Else + Return EgtTextGetItalic_64(nId, bItalic) + End If +End Function + Private Function EgtPointToIdGlob_32(ByRef PtP As Point3d, nId As Integer) As Boolean End Function @@ -7210,7 +7403,7 @@ Public Function EgtInitMachMgr(sMachinesDir As String, sToolMakersDir As String) End If End Function -' Errors +' Errors & Warnings Private Function EgtGetLastMachMgrErrorId_32() As Integer End Function @@ -7246,6 +7439,41 @@ Public Function EgtGetLastMachMgrErrorString() As String Return sErr End Function + +Private Function EgtGetMachMgrWarningId_32( nInd As Integer) As Integer +End Function + +Private Function EgtGetMachMgrWarningId_64( nInd As Integer) As Integer +End Function +Public Function EgtGetMachMgrWarningId( nInd As Integer) As Integer + If IntPtr.Size = 4 Then + Return EgtGetMachMgrWarningId_32( nInd) + Else + Return EgtGetMachMgrWarningId_64( nInd) + End If +End Function + + +Private Function EgtGetMachMgrWarningString_32( nInd As Integer) As IntPtr +End Function + +Private Function EgtGetMachMgrWarningString_64( nInd As Integer) As IntPtr +End Function +Public Function EgtGetMachMgrWarningString( nInd As Integer) As String + Dim sErr As String = String.Empty + Dim nTmp As IntPtr + If IntPtr.Size = 4 Then + nTmp = EgtGetMachMgrWarningString_32( nInd) + Else + nTmp = EgtGetMachMgrWarningString_64( nInd) + End If + If Not IsNothing(nTmp) Then + sErr = Marshal.PtrToStringUni(nTmp) + EgtFreeMemory(nTmp) + End If + Return sErr +End Function + ' Machines Private Function EgtSetCurrMachine_32(sMachineName As String) As Boolean @@ -12134,6 +12362,7 @@ Public Enum FT As Integer BTL = 15 IMG = 16 PNT = 17 + SVG = 18 TSC = 101 LUA = 102 End Enum @@ -12413,7 +12642,8 @@ Public Enum MCH_TF As Integer MILL = 1024 MORTISE = 2048 CHISEL = 4096 - COMPO = 8192 + WATERJET = 8192 + COMPO = 16384 End Enum 'Costanti : tipi di utensili Public Enum MCH_TY As Integer @@ -12426,11 +12656,13 @@ Public Enum MCH_TY As Integer MILL_NOTIP = 1025 MORTISE_STD = 2048 CHISEL_STD = 4096 - COMPO = 8192 + WATERJET = 8192 + COMPO = 16384 End Enum 'Costanti : parametri degli utensili Public Enum MCH_TP As Integer NONE = 0 + ACTIVE = 4096 CORR = 8192 EXIT_ = 8193 TYPE = 8194 @@ -12481,6 +12713,9 @@ Public Enum MCH_OY As Integer SAWFINISHING = 32768 GENMACHINING = 65536 CHISELING = 131072 + SURFROUGHING = 262144 + SURFFINISHING = 524288 + WATERJETTING = 1048576 End Enum ' Funzioni per famiglie di operazioni Public Function IsValidDispositionType(nType As Integer) As Boolean @@ -12491,7 +12726,8 @@ Public Function IsValidMachiningType(nType As Integer) As Boolean nType = MCH_OY.MILLING Or nType = MCH_OY.POCKETING Or nType = MCH_OY.MORTISING Or nType = MCH_OY.SAWROUGHING Or nType = MCH_OY.SAWFINISHING Or nType = MCH_OY.GENMACHINING Or - nType = MCH_OY.CHISELING) + nType = MCH_OY.CHISELING Or nType = MCH_OY.SURFROUGHING Or + nType = MCH_OY.SURFFINISHING Or nType = MCH_OY.WATERJETTING) End Function 'Costanti : tipi di lavorazioni (altre operazioni) Public Enum MCH_MY As Integer @@ -12505,6 +12741,9 @@ Public Enum MCH_MY As Integer SAWFINISHING = MCH_OY.SAWFINISHING GENMACHINING = MCH_OY.GENMACHINING CHISELING = MCH_OY.CHISELING + SURFROUGHING = MCH_OY.SURFROUGHING + SURFFINISHING = MCH_OY.SURFFINISHING + WATERJETTING = MCH_OY.WATERJETTING End Enum 'Costanti : parametri generali delle lavorazioni Public Enum MCH_GP As Integer @@ -12800,6 +13039,45 @@ Public Enum MCH_MORTISE_FU As Integer PARAL_LEFT = 5 PARAL_RIGHT = 6 End Enum +' Costanti per finitura superficie +Public Enum MCH_SURFFIN_SUB As Integer + ZIGZAG = 0 + ONEWAY = 1 + SPIRALIN = 2 + SPIRALOUT = 3 +End Enum +Public Enum MCH_SURFFIN_LI As Integer + NONE = 0 + LINEAR = 1 + TANGENT = 2 +End Enum +Public Enum MCH_SURFFIN_LL As Integer + STD = 0 + CENT = 1 +End Enum +Public Enum MCH_SURFFIN_LO As Integer + NONE = 0 + LINEAR = 1 + TANGENT = 2 + AS_LI = 3 +End Enum +' Costanti per lavorazione getto d'acqua (waterjetting) +Public Enum MCH_WATERJET_WS As Integer + CENTER = 0 + LEFT = 1 + RIGHT = 2 +End Enum +Public Enum MCH_WATERJET_LI As Integer + NONE = 0 + LINEAR = 1 + TANGENT = 2 +End Enum +Public Enum MCH_WATERJET_LO As Integer + NONE = 0 + LINEAR = 1 + TANGENT = 2 + AS_LI = 3 +End Enum 'Costanti : posizione per preview utensile in lavorazione Public Enum MCH_PTM As Integer CURR = 0 diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index f428f7b..8df7f2f 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -46,5 +46,5 @@ Imports System.Runtime.InteropServices ' utilizzando l'asterisco (*) come descritto di seguito: ' - - + + diff --git a/Scene.vb b/Scene.vb index 0f2515a..2981246 100644 --- a/Scene.vb +++ b/Scene.vb @@ -257,6 +257,7 @@ Public Class Scene Public Event OnMouseSelectedLayer(sender As Object, nId As Integer) Public Event OnMouseSelectedPath(sender As Object, nId As Integer, bHaltOnFork As Boolean) Public Event OnMouseAnalyzed(sender As Object, nId As Integer) + Public Event OnMouseAnalyzedEx(sender As Object, nId As Integer, nSub As Integer, ptP As Point3d) Public Event OnMousePointFromSelection(sender As Object, nId As Integer, PtP As Point3d, nAux As Integer) Public Event OnMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Public Event OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) @@ -353,7 +354,13 @@ Public Class Scene EgtSetObjFilterForSelWin(m_bZeroDimForSel, m_bCurveForSel, m_bSurfForSel, m_bVolumeForSel, m_bExtraForSel) Dim nId As Integer = ChooseOneSelectedObj(e.Location, m_nStatus) If nId <> GDB_ID.NULL Then + ' richiamo gestione evento standard RaiseEvent OnMouseAnalyzed(Me, nId) + ' determino subId e posizione punto di selezione + Dim PtTemp As Point3d + Dim nAux As Integer = -1 + EgtGetPointFromSelect(nId, e.Location, PtTemp, nAux) + RaiseEvent OnMouseAnalyzedEx( Me, nId, nAux, PtTemp) End If ' se stato GETDIST (primo punto per misura di distanza) ElseIf m_nStatus = ST.GETDIST Then @@ -386,6 +393,11 @@ Public Class Scene sOut.Append(EgtToUiUnits(vtDist.y).ToString("F4", CultureInfo.InvariantCulture)) sOut.Append(" dZ=") sOut.Append(EgtToUiUnits(vtDist.z).ToString("F4", CultureInfo.InvariantCulture)) + Dim dLen, dTheta, dPhi As double : vtDist.ToSpherical( dLen, dTheta, dPhi) + sOut.Append( " φ=") + sOut.Append( dPhi.ToString("F2", CultureInfo.InvariantCulture)) + sOut.Append( " θ=") + sOut.Append( dTheta.ToString("F2", CultureInfo.InvariantCulture)) ' lancio l'evento per visualizzare la distanza RaiseEvent OnShowDistance(Me, sOut.ToString()) RaiseEvent OnShowDistanceVector(Me, vtDist)