EgtUILib :

- aggiunti prototipi per funzioni di quotatura lineare
- aggiunta gestione quotature lineari in Controller.
This commit is contained in:
Dario Sassi
2019-12-30 19:05:29 +00:00
parent 2f1db4d42a
commit 74bbe09d3a
2 changed files with 272 additions and 6 deletions
+197 -2
View File
@@ -132,6 +132,8 @@ Public Class Controller
SOLIDSUBTRACTSURF
SOLIDINTERSECTSURF
INTERSECTSURFSURF
LINEARDIMENSION
ALIGNEDDIMENSION
End Enum
Public Enum GRID_TYPE As Integer
NONE = 0
@@ -167,8 +169,8 @@ Public Class Controller
Private m_sLast As String = String.Empty
Private m_bLast As Boolean = False
Private m_bPnt3dVsDbl As Boolean = False
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_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
Private m_dLastDiam As Double = If(EgtUiUnitsAreMM(), 20, 25.4) ' ultimo diametro per circonferenza
Private m_dLastFillet As Double = If(EgtUiUnitsAreMM(), 10, 12.7) ' ultimo raggio per fillet
@@ -182,6 +184,7 @@ Public Class Controller
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
Private m_nLinDimType As Integer = LINDIM_TYPE.NONE ' tipo quotatura lineare
' Tolleranza di disegno delle superfici
Private m_dEpsStm As Double = EPS_STM
@@ -1177,6 +1180,12 @@ Public Class Controller
' Text Plus
Case CMD.TEXTPLUS
Return ProcessTextPlus()
' Linear Dimension
Case CMD.LINEARDIMENSION
Return ProcessLinearDimension()
' Aligned Dimension
Case CMD.ALIGNEDDIMENSION
Return ProcessAlignedDimension()
' Region
Case CMD.REGION
Return ProcessRegion()
@@ -1350,6 +1359,10 @@ Public Class Controller
DragText()
Case CMD.TEXTPLUS
DragTextPlus()
Case CMD.LINEARDIMENSION
DragLinearDimension()
Case CMD.ALIGNEDDIMENSION
DragAlignedDimension()
Case CMD.EXTRUDE
DragExtrude()
Case CMD.REVOLVE
@@ -3666,6 +3679,188 @@ Public Class Controller
End If
End Sub
Private Function ProcessLinearDimension() 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 stato a primo punto per AlignedDimension
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("LINEAR DIMENSION", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
RaiseEvent PrepareInputBox( "LINEAR DIMENSION", "Insert End Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptP1 + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 2
m_ptP2 = m_ptLast
m_nStep = 3
RaiseEvent PrepareInputBox( "LINEAR DIMENSION", "Insert Text Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptP2 + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 3
m_ptP3 = m_ptLast
m_nStep = 4
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox( "LINEAR DIMENSION", "Insert Text", "", False, True)
m_nInpType = IBT.TY_STRING
m_sLast = "<>"
SetInputBoxString( m_sLast)
Case 4
' reset scena
m_Scene.ResetStatus(False)
' creo l'entità quota lineare (i punti sono in globale)
EnableCommandLog()
CalcLinearDimensionType( m_ptP3)
EgtCreateLinearDimension( GetCurrLayer(), m_nLinDimType, m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
m_ptP3.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragLinearDimension()
' il gruppo di Drag ha riferimento globale
If m_nStep = 2 Then
' linea di base
EgtSetGeoLine( m_ptP1, m_ptLast)
ElseIf m_nStep = 3 Then
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota lineare (drag è in globale)
CalcLinearDimensionType( m_ptLast)
EgtCreateLinearDimension( m_Scene.GetDragGroup(), m_nLinDimType, m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), "<>", GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 4 Then
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota allineata (drag è in globale)
CalcLinearDimensionType( m_ptP3)
EgtCreateLinearDimension( m_Scene.GetDragGroup(), m_nLinDimType, m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
m_ptP3.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Sub CalcLinearDimensionType( ptText As Point3d)
Dim ptP1 As Point3d = m_ptP1.Loc(GDB_ID.GRID)
Dim ptP2 As Point3d = m_ptP2.Loc(GDB_ID.GRID)
if Point3d.SameApprox( ptP1, ptP2) Then
m_nLinDimType = LINDIM_TYPE.NONE
ElseIf Math.Abs( ptP1.y - ptP2.y) < EPS_SMALL Then
m_nLinDimType = LINDIM_TYPE.HORIZONTAL
ElseIf Math.Abs( ptP1.x - ptP2.x) < EPS_SMALL Then
m_nLinDimType = LINDIM_TYPE.VERTICAL
Else
Dim ptP3 As Point3d = ptText.Loc(GDB_ID.GRID)
Dim dXmin = Math.Min( ptP1.x, ptP2.x)
Dim dXmax = Math.Max( ptP1.x, ptP2.x)
Dim dYmin = Math.Min( ptP1.y, ptP2.y)
Dim dYmax = Math.Max( ptP1.y, ptP2.y)
if ptP3.x > dXmin And ptP3.x < dXmax Then
If ptP3.y <= dYmin Or ptP3.y >= dYmax Then
m_nLinDimType = LINDIM_TYPE.HORIZONTAL
End If
Elseif ptP3.y > dYmin And ptP3.y < dYmax Then
m_nLinDimType = LINDIM_TYPE.VERTICAL
End If
End If
End Sub
Private Function ProcessAlignedDimension() 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 stato a primo punto per AlignedDimension
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("ALIGNED DIMENSION", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
RaiseEvent PrepareInputBox( "ALIGNED DIMENSION", "Insert End Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptP1 + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 2
m_ptP2 = m_ptLast
m_nStep = 3
RaiseEvent PrepareInputBox( "ALIGNED DIMENSION", "Insert Text Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptP2 + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 3
m_ptP3 = m_ptLast
m_nStep = 4
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox( "ALIGNED DIMENSION", "Insert Text", "", False, True)
m_nInpType = IBT.TY_STRING
m_sLast = "<>"
SetInputBoxString( m_sLast)
Case 4
' reset scena
m_Scene.ResetStatus(False)
' creo l'entità quota allineata (i punti sono in globale)
EnableCommandLog()
Dim nId As Integer = EgtCreateAlignedDimension( GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
m_ptP3.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragAlignedDimension()
' il gruppo di Drag ha riferimento globale
If m_nStep = 2 Then
' linea di base
EgtSetGeoLine( m_ptP1, m_ptLast)
ElseIf m_nStep = 3 Then
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota allineata (drag è in globale)
EgtCreateAlignedDimension( m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), "<>", GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 4 Then
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota allineata (drag è in globale)
EgtCreateAlignedDimension( m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
m_ptP3.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessRegion() As Boolean
If m_nStep <> 0 Then Return False
' posso partire solo se esiste un gruppo corrente
+75 -4
View File
@@ -816,11 +816,11 @@ Structure FlagPar
End Structure
#If DEBUG Then
Const EgtIntDll32 As String = "EgtInterfaceD32.dll"
Const EgtIntDll64 As String = "EgtInterfaceD64.dll"
Const EgtIntDll32 As String = "EgtInterfaceD32.dll"
Const EgtIntDll64 As String = "EgtInterfaceD64.dll"
#Else
Const EgtIntDll32 As String = "EgtInterfaceR32.dll"
Const EgtIntDll64 As String = "EgtInterfaceR64.dll"
Const EgtIntDll32 As String = "EgtInterfaceR32.dll"
Const EgtIntDll64 As String = "EgtInterfaceR64.dll"
#End If
@@ -3149,6 +3149,70 @@ Public Function EgtCreateTextAdv(nParentId As Integer, ByRef ptP As Point3d, dAn
End If
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtCreateHorizontalDimension"), SuppressUnmanagedCodeSecurity()>
Private Function EgtCreateHorizontalDimension_32( nParentId As Integer, ByRef ptP1 As Point3d, ByRef ptP2 As Point3d,
ByRef ptDim As Point3d, sText As String, Optional nRefType As GDB_RT = GDB_RT.LOC) As Integer
End Function
<DllImport(EgtIntDll64, CharSet:=CharSet.Unicode, EntryPoint:="EgtCreateHorizontalDimension"), SuppressUnmanagedCodeSecurity()>
Private Function EgtCreateHorizontalDimension_64( nParentId As Integer, ByRef ptP1 As Point3d, ByRef ptP2 As Point3d,
ByRef ptDim As Point3d, sText As String, Optional nRefType As GDB_RT = GDB_RT.LOC) As Integer
End Function
Public Function EgtCreateHorizontalDimension( nParentId As Integer, ByRef ptP1 As Point3d, ByRef ptP2 As Point3d,
ByRef ptDim As Point3d, sText As String, Optional nRefType As GDB_RT = GDB_RT.LOC) As Integer
If IntPtr.Size = 4 Then
Return EgtCreateHorizontalDimension_32( nParentId, ptP1, ptP2, ptDim, sText, nRefType)
Else
Return EgtCreateHorizontalDimension_64( nParentId, ptP1, ptP2, ptDim, sText, nRefType)
End If
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtCreateVerticalDimension"), SuppressUnmanagedCodeSecurity()>
Private Function EgtCreateVerticalDimension_32( nParentId As Integer, ByRef ptP1 As Point3d, ByRef ptP2 As Point3d,
ByRef ptDim As Point3d, sText As String, Optional nRefType As GDB_RT = GDB_RT.LOC) As Integer
End Function
<DllImport(EgtIntDll64, CharSet:=CharSet.Unicode, EntryPoint:="EgtCreateVerticalDimension"), SuppressUnmanagedCodeSecurity()>
Private Function EgtCreateVerticalDimension_64( nParentId As Integer, ByRef ptP1 As Point3d, ByRef ptP2 As Point3d,
ByRef ptDim As Point3d, sText As String, Optional nRefType As GDB_RT = GDB_RT.LOC) As Integer
End Function
Public Function EgtCreateVerticalDimension( nParentId As Integer, ByRef ptP1 As Point3d, ByRef ptP2 As Point3d,
ByRef ptDim As Point3d, sText As String, Optional nRefType As GDB_RT = GDB_RT.LOC) As Integer
If IntPtr.Size = 4 Then
Return EgtCreateVerticalDimension_32( nParentId, ptP1, ptP2, ptDim, sText, nRefType)
Else
Return EgtCreateVerticalDimension_64( nParentId, ptP1, ptP2, ptDim, sText, nRefType)
End If
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtCreateAlignedDimension"), SuppressUnmanagedCodeSecurity()>
Private Function EgtCreateAlignedDimension_32( nParentId As Integer, ByRef ptP1 As Point3d, ByRef ptP2 As Point3d,
ByRef ptDim As Point3d, sText As String, Optional nRefType As GDB_RT = GDB_RT.LOC) As Integer
End Function
<DllImport(EgtIntDll64, CharSet:=CharSet.Unicode, EntryPoint:="EgtCreateAlignedDimension"), SuppressUnmanagedCodeSecurity()>
Private Function EgtCreateAlignedDimension_64( nParentId As Integer, ByRef ptP1 As Point3d, ByRef ptP2 As Point3d,
ByRef ptDim As Point3d, sText As String, Optional nRefType As GDB_RT = GDB_RT.LOC) As Integer
End Function
Public Function EgtCreateAlignedDimension( nParentId As Integer, ByRef ptP1 As Point3d, ByRef ptP2 As Point3d,
ByRef ptDim As Point3d, sText As String, Optional nRefType As GDB_RT = GDB_RT.LOC) As Integer
If IntPtr.Size = 4 Then
Return EgtCreateAlignedDimension_32( nParentId, ptP1, ptP2, ptDim, sText, nRefType)
Else
Return EgtCreateAlignedDimension_64( nParentId, ptP1, ptP2, ptDim, sText, nRefType)
End If
End Function
Public Function EgtCreateLinearDimension( nParentId As Integer, nType As Integer, ByRef ptP1 As Point3d, ByRef ptP2 As Point3d,
ByRef ptDim As Point3d, sText As String, Optional nRefType As GDB_RT = GDB_RT.LOC) As Integer
If nType = LINDIM_TYPE.HORIZONTAL Then
Return EgtCreateHorizontalDimension( nParentId, ptP1, ptP2, ptDim, sText, nRefType)
ElseIf nType = LINDIM_TYPE.VERTICAL Then
Return EgtCreateVerticalDimension( nParentId, ptP1, ptP2, ptDim, sText, nRefType)
ElseIf nType = LINDIM_TYPE.ALIGNED Then
Return EgtCreateAlignedDimension( nParentId, ptP1, ptP2, ptDim, sText, nRefType)
Else
Return False
End If
End Function
'---------- GeomDb Objects Modify ----------------------------------------------
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtChangeGroupFrame"), SuppressUnmanagedCodeSecurity()>
@@ -12611,6 +12675,13 @@ Public Enum APP_TYPE As Integer
RIGHT_CONVEX_LINES = 12
ARCS = 3
End Enum
'Costanti : tipo di quotatura lineare
Public Enum LINDIM_TYPE As Integer
NONE = 0
HORIZONTAL = 1
VERTICAL = 2
ALIGNED = 3
End Enum
'Costanti : posizione di inserimento per testi
Public Enum INS_POS As Integer
TL = 1