TestEIn 1.5k5 :
- aggiunta gestione linee tangenti - miglioramenti a trim/extend di curve.
This commit is contained in:
+207
-32
@@ -70,7 +70,7 @@ Public Class Controller
|
||||
CHANGECOLOR
|
||||
RESETCOLOR
|
||||
INVERTCRVSURF
|
||||
EXTENDCURVE
|
||||
TRIMEXTENDCURVE
|
||||
BREAKCURVE
|
||||
JOINCURVE
|
||||
EXPLODECURVE
|
||||
@@ -81,6 +81,7 @@ Public Class Controller
|
||||
MIRROR
|
||||
SCALE
|
||||
SCALE3D
|
||||
OFFSET
|
||||
End Enum
|
||||
Public Enum GRID_TYPE As Integer
|
||||
NONE = 0
|
||||
@@ -94,8 +95,14 @@ Public Class Controller
|
||||
Private m_nLastCmd As CMD = CMD.NULL
|
||||
Private m_nStep As Integer = 0
|
||||
Private m_ptP1 As Point3d
|
||||
Private m_sepP1 As SEP
|
||||
Private m_nIdP1 As Integer
|
||||
Private m_ptP2 As Point3d
|
||||
Private m_sepP2 As SEP
|
||||
Private m_nIdP2 As Integer
|
||||
Private m_ptLast As Point3d
|
||||
Private m_sepLast As SEP
|
||||
Private m_nIdLast As Integer
|
||||
Private m_dPrev As Double = 0
|
||||
Private m_dAux As Double = 0
|
||||
Private m_dLast As Double = 0
|
||||
@@ -109,12 +116,13 @@ Public Class Controller
|
||||
Private m_vtCont As Vector3d ' direzione finale di entità precedente (per continuazione)
|
||||
|
||||
' Input
|
||||
Public Enum IBT As Integer
|
||||
Private Enum IBT As Integer
|
||||
TY_NULL = 0
|
||||
TY_STRING
|
||||
TY_DOUBLE
|
||||
TY_DIRECTION
|
||||
TY_LENGTH
|
||||
TY_SPECIALDOUBLE
|
||||
TY_3DOUBLE
|
||||
TY_POINT3D
|
||||
End Enum
|
||||
@@ -125,6 +133,8 @@ Public Class Controller
|
||||
Private DIAM_STD As Double = 20
|
||||
Private EXTRUDE_STD As Double = 20
|
||||
Private EXTEND_STD As Double = 50
|
||||
Private EXTEND_ADD As Double = 10
|
||||
Private OFFSET_STD As Double = 10
|
||||
|
||||
' Metodi
|
||||
Public Sub MouseSelectedObj(ByVal nId As Integer, ByVal bLast As Boolean)
|
||||
@@ -160,33 +170,35 @@ Public Class Controller
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Public Sub MouseSelectedPoint(ByVal PtP As Point3d, ByVal bDone As Boolean)
|
||||
SetDataFromSelPoint(PtP)
|
||||
Public Sub MouseSelectedPoint(ByVal PtP As Point3d, ByVal nSep As SEP, ByVal nId As Integer, ByVal bDone As Boolean)
|
||||
SetDataFromSelPoint(PtP, nSep, nId)
|
||||
' avanzo di un passo
|
||||
If bDone Then
|
||||
ProcessStatus()
|
||||
' eseguo ultimo drag e passo in modalità input da box
|
||||
Else
|
||||
ExecuteDrag()
|
||||
m_Scene.DisableDrag()
|
||||
ExecuteDrag()
|
||||
Select Case m_nInpType
|
||||
Case IBT.TY_POINT3D
|
||||
SetInputBoxPoint3d(m_ptLast)
|
||||
Case IBT.TY_DIRECTION, IBT.TY_LENGTH
|
||||
Case IBT.TY_DIRECTION, IBT.TY_LENGTH, IBT.TY_SPECIALDOUBLE
|
||||
SetInputBoxDouble(m_dLast)
|
||||
End Select
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub MouseMoveInSelectionPoint(ByVal PtP As Point3d)
|
||||
SetDataFromSelPoint(PtP)
|
||||
SetDataFromSelPoint(PtP, SEP.PT_STD, GDB_ID.NULL)
|
||||
' eseguo drag
|
||||
ExecuteDrag()
|
||||
End Sub
|
||||
|
||||
Private Sub SetDataFromSelPoint(ByVal PtP As Point3d)
|
||||
' recupero il punto
|
||||
SetLastPoint3d(PtP)
|
||||
Private Sub SetDataFromSelPoint(ByVal PtP As Point3d, ByVal nSep As SEP, ByVal nId As Integer)
|
||||
' recupero il punto e le sue info ausiliarie
|
||||
m_ptLast = PtP
|
||||
m_sepLast = nSep
|
||||
m_nIdLast = nId
|
||||
' se usato per tipi speciali
|
||||
Select Case m_nInpType
|
||||
Case IBT.TY_DIRECTION
|
||||
@@ -194,6 +206,8 @@ Public Class Controller
|
||||
m_dAux = GridLenFromGlobLen(m_ptLast - m_ptP1)
|
||||
Case IBT.TY_LENGTH
|
||||
m_dLast = (m_ptLast - m_ptP1) * m_vtCont
|
||||
Case IBT.TY_SPECIALDOUBLE
|
||||
ExecuteSpecialData()
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
@@ -268,7 +282,7 @@ Public Class Controller
|
||||
Case IBT.TY_STRING
|
||||
m_sLast = sText
|
||||
Return True
|
||||
Case IBT.TY_DOUBLE, IBT.TY_DIRECTION, IBT.TY_LENGTH
|
||||
Case IBT.TY_DOUBLE, IBT.TY_DIRECTION, IBT.TY_LENGTH, IBT.TY_SPECIALDOUBLE
|
||||
Return TextToDouble(sText, m_dLast)
|
||||
Case IBT.TY_3DOUBLE
|
||||
Return TextTo3Double(sText, m_d3Last)
|
||||
@@ -354,6 +368,9 @@ Public Class Controller
|
||||
|
||||
Public Sub ResetStatus()
|
||||
m_nStep = 0
|
||||
m_sepP1 = SEP.PT_STD
|
||||
m_sepP2 = SEP.PT_STD
|
||||
m_sepLast = SEP.PT_STD
|
||||
m_Scene.ResetStatus()
|
||||
End Sub
|
||||
|
||||
@@ -485,7 +502,7 @@ Public Class Controller
|
||||
Case CMD.INVERTCRVSURF
|
||||
Return ProcessInvertCurveSurf()
|
||||
' Extend Curve
|
||||
Case CMD.EXTENDCURVE
|
||||
Case CMD.TRIMEXTENDCURVE
|
||||
Return ProcessExtendCurve()
|
||||
' Break Curve
|
||||
Case CMD.BREAKCURVE
|
||||
@@ -517,10 +534,11 @@ Public Class Controller
|
||||
' Scale 3d
|
||||
Case CMD.SCALE3D
|
||||
ProcessScale3D()
|
||||
Case Else
|
||||
Return False
|
||||
' Offset
|
||||
Case CMD.OFFSET
|
||||
ProcessOffset()
|
||||
End Select
|
||||
Return True
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Private Function ExecuteDrag() As Boolean
|
||||
@@ -547,7 +565,7 @@ Public Class Controller
|
||||
DragRevolve()
|
||||
Case CMD.REVOLVEPLUS
|
||||
DragRevolvePlus()
|
||||
Case CMD.EXTENDCURVE
|
||||
Case CMD.TRIMEXTENDCURVE
|
||||
DragExtendCurve()
|
||||
Case CMD.SETCURVETHICKNESS
|
||||
DragSetCurveThickness()
|
||||
@@ -563,12 +581,23 @@ Public Class Controller
|
||||
DragScale()
|
||||
Case CMD.SCALE3D
|
||||
DragScale3D()
|
||||
Case CMD.OFFSET
|
||||
DragOffset()
|
||||
Case Else
|
||||
Return False
|
||||
End Select
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function ExecuteSpecialData() As Boolean
|
||||
Select Case m_nLastCmd
|
||||
' Trim/Extend di curva
|
||||
Case CMD.TRIMEXTENDCURVE
|
||||
ExecuteSpecialDataExtendCurve()
|
||||
End Select
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Private Function ProcessGrid() As Boolean
|
||||
If m_nStep <> 0 Then
|
||||
Return False
|
||||
@@ -1208,18 +1237,32 @@ Public Class Controller
|
||||
RaiseEvent PrepareInputBox("LINE 2P", "Insert Start Point", "", False)
|
||||
m_nInpType = IBT.TY_POINT3D
|
||||
SetInputBoxPoint3d(m_ptCont)
|
||||
m_Scene.EnableTangentPoint()
|
||||
m_Scene.EnablePerpendicularPoint()
|
||||
m_Scene.EnableMinDistPoint()
|
||||
Case 1
|
||||
m_ptP1 = m_ptLast
|
||||
m_sepP1 = m_sepLast
|
||||
m_nIdP1 = m_nIdLast
|
||||
m_nStep = 2
|
||||
m_Scene.EnableDrag()
|
||||
RaiseEvent PrepareInputBox("LINE 2P", "Insert End Point ", "", True)
|
||||
m_nInpType = IBT.TY_POINT3D
|
||||
SetInputBoxPoint3d(m_ptLast.Loc(GetCurrLayer()))
|
||||
Select Case m_sepP1
|
||||
Case SEP.PT_TG, SEP.PT_PERP
|
||||
m_Scene.DisableMinDistPoint()
|
||||
Case SEP.PT_MINDIST
|
||||
m_Scene.DisableTangentPoint()
|
||||
m_Scene.DisablePerpendicularPoint()
|
||||
m_Scene.DisableMinDistPoint()
|
||||
End Select
|
||||
Case 2
|
||||
' reset scena
|
||||
m_Scene.ResetStatus(False)
|
||||
' creo la linea (i punti sono in globale)
|
||||
Dim nId As Integer = EgtCreateCurveLine(GetCurrLayer(), m_ptP1.Loc(GetCurrLayer()), m_ptLast.Loc(GetCurrLayer()))
|
||||
Dim nId As Integer = EgtCreateCurveLineEx(GetCurrLayer(), m_ptP1.Loc(GetCurrLayer()), m_sepP1, m_nIdP1,
|
||||
m_ptLast.Loc(GetCurrLayer()), m_sepLast, m_nIdLast)
|
||||
If nId <> GDB_ID.NULL Then
|
||||
m_ptCont = m_ptLast
|
||||
m_vtCont = (m_ptLast - m_ptP1)
|
||||
@@ -1237,13 +1280,21 @@ Public Class Controller
|
||||
End Function
|
||||
|
||||
Private Sub DragLine2P()
|
||||
' il gruppo di Drag ha riferimento globale
|
||||
If m_nStep = 2 Then
|
||||
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
|
||||
' recupero possibile entità già nel gruppo di drag
|
||||
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
||||
If nId = GDB_ID.NULL Then
|
||||
EgtCreateCurveLine(m_Scene.GetDragGroup(), m_ptP1, m_ptLast)
|
||||
' se punti entrambi già definiti
|
||||
If m_sepP1 = SEP.PT_STD And m_sepLast = SEP.PT_STD Then
|
||||
If nId = GDB_ID.NULL Then
|
||||
EgtCreateCurveLine(m_Scene.GetDragGroup(), m_ptP1, m_ptLast)
|
||||
Else
|
||||
EgtModifyCurveEndPoint(nId, m_ptLast)
|
||||
End If
|
||||
' altrimenti, uno dei punti tangente o normale
|
||||
Else
|
||||
EgtModifyCurveEndPoint(nId, m_ptLast)
|
||||
EgtErase(nId)
|
||||
EgtCreateCurveLineEx(m_Scene.GetDragGroup(), m_ptP1, m_sepP1, m_nIdP1, m_ptLast, m_sepLast, m_nIdLast)
|
||||
End If
|
||||
EgtDraw()
|
||||
End If
|
||||
@@ -1281,6 +1332,7 @@ Public Class Controller
|
||||
m_dLast = m_dAux
|
||||
m_nStep = 3
|
||||
m_Scene.DisableDrag()
|
||||
EgtUnselectableRemove(m_Scene.GetDragGroup())
|
||||
RaiseEvent PrepareInputBox("LINE PDL", "Insert Length", "", True)
|
||||
m_nInpType = IBT.TY_LENGTH
|
||||
SetInputBoxDouble(m_dLast)
|
||||
@@ -1996,21 +2048,42 @@ Public Class Controller
|
||||
Select Case m_nStep
|
||||
Case 0
|
||||
' verifico condizioni e preparo per il drag
|
||||
If Not PrepareTransform(False) Then
|
||||
If Not PrepareTransform(False, True) Then
|
||||
Return False
|
||||
End If
|
||||
' imposto stato a lunghezza di estensione
|
||||
m_nStep = 1
|
||||
m_dLast = EXTEND_STD
|
||||
' recupero dati estremo più vicino a punto di selezione per permettere drag lunghezza con mouse
|
||||
m_Scene.SetStatusSelPoint(False)
|
||||
Dim nId As Integer = EgtGetLastSelectedObj()
|
||||
EgtCurveLength(nId, m_dPrev)
|
||||
Dim ptStart As Point3d
|
||||
EgtStartPoint(nId, ptStart)
|
||||
ptStart = ptStart.Glob(nId)
|
||||
Dim ptEnd As Point3d
|
||||
EgtEndPoint(nId, ptEnd)
|
||||
ptEnd = ptEnd.Glob(nId)
|
||||
If ((ptStart - m_ptLast).SqLen() <= (ptEnd - m_ptLast).SqLen()) Then
|
||||
m_bLast = True
|
||||
m_ptP1 = ptStart
|
||||
EgtStartVector(nId, m_vtCont)
|
||||
m_vtCont = -m_vtCont.Glob(nId)
|
||||
Else
|
||||
m_bLast = False
|
||||
m_ptP1 = ptEnd
|
||||
EgtEndVector(nId, m_vtCont)
|
||||
m_vtCont = m_vtCont.Glob(nId)
|
||||
End If
|
||||
' abilito dialogo
|
||||
RaiseEvent PrepareInputBox("EXTEND", "Insert Length", "", True)
|
||||
m_nInpType = IBT.TY_DOUBLE
|
||||
m_nInpType = IBT.TY_SPECIALDOUBLE
|
||||
SetInputBoxDouble(m_dLast)
|
||||
DragExtendCurve()
|
||||
Case 1
|
||||
' eseguo estensione sull'estremo più vicino al punto di selezione
|
||||
Dim nId As Integer = EgtGetLastSelectedObj()
|
||||
EgtExtendCurveByLen(nId, m_dLast, m_ptLast.Loc(nId))
|
||||
EgtTrimExtendCurveByLen(nId, m_dLast, m_ptP1.Loc(nId))
|
||||
EgtDeselectAll()
|
||||
' reset stato scena
|
||||
m_Scene.ResetStatus()
|
||||
@@ -2024,17 +2097,51 @@ Public Class Controller
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Sub DragExtendCurve()
|
||||
Private Function DragExtendCurve() As Boolean
|
||||
If m_nStep = 1 Then
|
||||
' devo sempre partire dalla curva originale
|
||||
m_Scene.EraseDragGroup()
|
||||
PrepareTransform(False)
|
||||
' eseguo estensione sull'estremo più vicino al punto di selezione
|
||||
PrepareTransform(False, True)
|
||||
' verifico se caso speciale : estensione + drag + snap a punto intersezione
|
||||
Dim bSpecial As Boolean = (m_Scene.GetDragStatus() And
|
||||
m_Scene.GetSnapPointType() = SP.PT_INTERS)
|
||||
' lunghezza aggiuntiva per caso speciale
|
||||
Dim dAddLen As Double = IIf(bSpecial, EXTEND_ADD, 0)
|
||||
' eseguo trim/estensione sull'estremo più vicino al punto di selezione
|
||||
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
||||
EgtExtendCurveByLen(nId, m_dLast, m_ptLast)
|
||||
EgtTrimExtendCurveByLen(nId, m_dLast + dAddLen, m_ptP1)
|
||||
EgtDraw()
|
||||
End If
|
||||
End Sub
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Private Function ExecuteSpecialDataExtendCurve() As Boolean
|
||||
If m_nStep = 1 Then
|
||||
' verifico se caso speciale : estensione + drag + snap a punto intersezione
|
||||
Dim bSpecial As Boolean = (m_Scene.GetDragStatus() And
|
||||
m_Scene.GetSnapPointType() = SP.PT_INTERS)
|
||||
' se standard
|
||||
If Not bSpecial Then
|
||||
m_dLast = (m_ptLast - m_ptP1) * m_vtCont
|
||||
' altrimenti speciale
|
||||
Else
|
||||
Dim dLen As Double
|
||||
Dim nDragId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
||||
If EgtCurveLengthAtPoint(nDragId, m_ptLast, dLen) Then
|
||||
' modifico inizio (su drag inizio spostato di m_dLast)
|
||||
If m_bLast Then
|
||||
Dim dDragLen As Double
|
||||
EgtCurveLength(nDragId, dDragLen)
|
||||
m_dLast = dDragLen - dLen - m_dPrev
|
||||
' modifico fine (inizio fisso)
|
||||
Else
|
||||
m_dLast = dLen - m_dPrev
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Private Function ProcessBreakCurve() As Boolean
|
||||
Select Case m_nStep
|
||||
@@ -2047,7 +2154,8 @@ Public Class Controller
|
||||
m_nInpType = IBT.TY_POINT3D
|
||||
Case 1
|
||||
' eseguo spezzatura
|
||||
EgtSplitCurveAtPoint(EgtGetLastSelectedObj(), m_ptLast)
|
||||
Dim nId As Integer = EgtGetLastSelectedObj()
|
||||
EgtSplitCurveAtPoint(nId, m_ptLast.Loc(nId))
|
||||
EgtDeselectAll()
|
||||
' reset stato scena
|
||||
m_Scene.ResetStatus()
|
||||
@@ -2618,13 +2726,80 @@ Public Class Controller
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function PrepareTransform(Optional ByVal bAllSelected As Boolean = True) As Boolean
|
||||
Private Function ProcessOffset() As Boolean
|
||||
Select Case m_nStep
|
||||
Case 0
|
||||
' verifico condizioni e preparo per il drag
|
||||
If Not PrepareTransform(False) Then
|
||||
Return False
|
||||
End If
|
||||
' imposto stato a lunghezza di offset
|
||||
m_nStep = 1
|
||||
m_dLast = OFFSET_STD
|
||||
' abilito dialogo
|
||||
RaiseEvent PrepareInputBox("OFFSET", "Insert Distance", "Copy", True)
|
||||
m_nInpType = IBT.TY_DOUBLE
|
||||
SetInputBoxDouble(m_dLast)
|
||||
RaiseEvent SetInputBoxCheck(True)
|
||||
DragOffset()
|
||||
Case 1
|
||||
' parametri di offset
|
||||
Dim nSide As OFF_SIDE
|
||||
If m_dLast > 0 Then
|
||||
nSide = OFF_SIDE.LEFT
|
||||
Else
|
||||
nSide = OFF_SIDE.RIGHT
|
||||
End If
|
||||
' reset stato scena
|
||||
m_Scene.ResetStatus(False)
|
||||
' eseguo copia e offset
|
||||
If m_bLast Then
|
||||
Dim nId As Integer = EgtCopyGlob(EgtGetLastSelectedObj(), GetCurrLayer())
|
||||
EgtOffsetCurve(nId, Math.Abs(m_dLast), nSide, OFF_TYPE.FILLET)
|
||||
' altrimenti solo offset
|
||||
Else
|
||||
Dim nId As Integer = EgtGetLastSelectedObj()
|
||||
EgtOffsetCurve(nId, Math.Abs(m_dLast), nSide, OFF_TYPE.FILLET)
|
||||
End If
|
||||
EgtDeselectAll()
|
||||
EgtDraw()
|
||||
' aggiorno stato
|
||||
m_nStep = 0
|
||||
SetModified()
|
||||
Case Else
|
||||
m_nStep = 0
|
||||
Return False
|
||||
End Select
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Sub DragOffset()
|
||||
If m_nStep = 1 Then
|
||||
' devo sempre partire dalla curva originale
|
||||
m_Scene.EraseDragGroup()
|
||||
PrepareTransform(False)
|
||||
' parametri di offset
|
||||
Dim nSide As OFF_SIDE
|
||||
If m_dLast > 0 Then
|
||||
nSide = OFF_SIDE.LEFT
|
||||
Else
|
||||
nSide = OFF_SIDE.RIGHT
|
||||
End If
|
||||
' eseguo offset
|
||||
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
||||
EgtOffsetCurve(nId, Math.Abs(m_dLast), nSide, OFF_TYPE.FILLET)
|
||||
EgtDraw()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function PrepareTransform(Optional ByVal bAllSelected As Boolean = True,
|
||||
Optional ByVal bDragSelectable As Boolean = False) As Boolean
|
||||
' verifico ci sia qualcosa di selezionato
|
||||
If EgtGetFirstSelectedObj() = GDB_ID.NULL Then
|
||||
Return False
|
||||
End If
|
||||
' creo il gruppo di drag e vi copio le entità selezionate
|
||||
If Not m_Scene.CreateDragGroup() Then
|
||||
If Not m_Scene.CreateDragGroup(bDragSelectable) Then
|
||||
Return False
|
||||
End If
|
||||
' se devo prendere tutti
|
||||
|
||||
Reference in New Issue
Block a user