c1e60221c5
- aggiunta gestione linee tangenti - miglioramenti a trim/extend di curve.
2958 lines
96 KiB
VB.net
2958 lines
96 KiB
VB.net
'----------------------------------------------------------------------------
|
|
' EgalTech 2014-2014
|
|
'----------------------------------------------------------------------------
|
|
' File : Controller.vb Data : 04.11.14 Versione : 1.5k1
|
|
' Contenuto : Classe Controller (parte di MCV).
|
|
'
|
|
'
|
|
'
|
|
' Modifiche : 04.11.14 DS Creazione modulo.
|
|
'
|
|
'
|
|
'----------------------------------------------------------------------------
|
|
|
|
Imports Microsoft.VisualBasic
|
|
Imports System.Globalization
|
|
Imports TestEIn.EgtInterface
|
|
Imports System.Text
|
|
|
|
Public Class Controller
|
|
|
|
' Events
|
|
Public Event PrepareInputBox(ByVal sTitle As String, ByVal sLabel As String, ByRef sCheckLabel As String, ByVal bShowBtn As Boolean)
|
|
Public Event SetInputBoxText(ByVal sText As String)
|
|
Public Event SetInputBoxCheck(ByVal bCheck As Boolean)
|
|
Public Event UpdateUI(ByVal sender As Object, ByVal bReloadUI As Boolean)
|
|
|
|
' Documento e Vista
|
|
Private m_Scene As Scene
|
|
Public Sub SetScene(ByRef scene As Scene)
|
|
m_Scene = scene
|
|
End Sub
|
|
|
|
' Comandi e Stati
|
|
Public Enum CMD As Integer
|
|
NULL = 0
|
|
GRID
|
|
GRID_ELEVATION
|
|
GRID_ORIGIN
|
|
GRID_ROTATE
|
|
GRID_3P
|
|
GRID_PERPCURVE
|
|
GRID_OBJ
|
|
NEWPART
|
|
NEWLAYER
|
|
SETCURRPARTLAYER
|
|
RESETCURRPARTLAYER
|
|
LAYERCOLOR
|
|
SELECTPARTLAYEROBJ
|
|
DESELECTPARTLAYEROBJ
|
|
RELOCATEPARTLAYEROBJ
|
|
COPYPARTLAYEROBJ
|
|
SHOW
|
|
HIDE
|
|
SETNAME
|
|
SETINFO
|
|
POINT
|
|
LINE2P
|
|
LINEPDL
|
|
CIRCLECP
|
|
CIRCLECD
|
|
ARCCSE
|
|
ARC3P
|
|
ARCPDP
|
|
PLANE
|
|
EXTRUDE
|
|
REVOLVE
|
|
REVOLVEPLUS
|
|
RULED
|
|
DELETE
|
|
CHANGECOLOR
|
|
RESETCOLOR
|
|
INVERTCRVSURF
|
|
TRIMEXTENDCURVE
|
|
BREAKCURVE
|
|
JOINCURVE
|
|
EXPLODECURVE
|
|
SETCURVETHICKNESS
|
|
MOVE
|
|
ROTATE
|
|
ROTATE3D
|
|
MIRROR
|
|
SCALE
|
|
SCALE3D
|
|
OFFSET
|
|
End Enum
|
|
Public Enum GRID_TYPE As Integer
|
|
NONE = 0
|
|
TOP
|
|
FRONT
|
|
RIGHT
|
|
BACK
|
|
LEFT
|
|
BOTTOM
|
|
End Enum
|
|
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
|
|
Private m_d3Last() As Double = {0, 0, 0}
|
|
Private m_d3Prev() As Double = {0, 0, 0}
|
|
Private m_nLast1 As Integer = 0
|
|
Private m_nLast2 As Integer = 0
|
|
Private m_sLast As String = String.Empty
|
|
Private m_bLast As Boolean = False
|
|
Private m_ptCont As Point3d ' punto finale di entità precedente (per continuazione)
|
|
Private m_vtCont As Vector3d ' direzione finale di entità precedente (per continuazione)
|
|
|
|
' Input
|
|
Private Enum IBT As Integer
|
|
TY_NULL = 0
|
|
TY_STRING
|
|
TY_DOUBLE
|
|
TY_DIRECTION
|
|
TY_LENGTH
|
|
TY_SPECIALDOUBLE
|
|
TY_3DOUBLE
|
|
TY_POINT3D
|
|
End Enum
|
|
Private m_nInpType As IBT = IBT.TY_NULL
|
|
|
|
' Costanti
|
|
Private LEN_STD As Double = 100
|
|
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)
|
|
If EgtIsSelectedObj(nId) Then
|
|
EgtDeselectObj(nId)
|
|
Else
|
|
EgtSelectObj(nId)
|
|
End If
|
|
If bLast Then
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub MouseSelectedPart(ByVal nId As Integer)
|
|
' recupero il pezzo
|
|
Dim nPartId = EgtGetParent(EgtGetParent(nId))
|
|
If EgtGetParent(nPartId) <> GDB_ID.ROOT Then
|
|
Return
|
|
End If
|
|
' eseguo la selezione ed aggiorno
|
|
EgtSelectPartObjs(nPartId)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Public Sub MouseSelectedLayer(ByVal nId As Integer)
|
|
' recupero il layer
|
|
Dim nLayerId = EgtGetParent(nId)
|
|
If EgtGetParent(EgtGetParent(nLayerId)) <> GDB_ID.ROOT Then
|
|
Return
|
|
End If
|
|
' eseguo la selezione ed aggiorno
|
|
EgtSelectLayerObjs(nLayerId)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
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
|
|
m_Scene.DisableDrag()
|
|
ExecuteDrag()
|
|
Select Case m_nInpType
|
|
Case IBT.TY_POINT3D
|
|
SetInputBoxPoint3d(m_ptLast)
|
|
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, SEP.PT_STD, GDB_ID.NULL)
|
|
' eseguo drag
|
|
ExecuteDrag()
|
|
End Sub
|
|
|
|
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
|
|
m_dLast = GridAngFromGlobDir(m_ptLast - m_ptP1)
|
|
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
|
|
|
|
Public Sub Done(ByVal sText As String)
|
|
' recupero il dato
|
|
InputTextToLast(sText)
|
|
' avanzo di un passo
|
|
ProcessStatus()
|
|
End Sub
|
|
|
|
Public Sub Show(ByVal sText As String)
|
|
' recupero il dato
|
|
InputTextToLast(sText)
|
|
' disabilito drag da mouse
|
|
m_Scene.DisableDrag()
|
|
EgtResetGeoLine()
|
|
' aggiorno drag
|
|
ExecuteDrag()
|
|
End Sub
|
|
|
|
Private Sub SetInputBoxString(ByVal sText As String)
|
|
RaiseEvent SetInputBoxText(sText)
|
|
End Sub
|
|
|
|
Private Function DoubleToString(ByVal dVal As Double, ByVal nNumDec As UInteger) As String
|
|
Dim sFormat As String = "F" + nNumDec.ToString()
|
|
Dim sVal As String = dVal.ToString(sFormat, CultureInfo.InvariantCulture)
|
|
If nNumDec > 0 Then
|
|
Return sVal.TrimEnd("0".ToCharArray())
|
|
Else
|
|
Return sVal
|
|
End If
|
|
End Function
|
|
|
|
Private Sub SetInputBoxDouble(ByVal dVal As Double)
|
|
Dim sText As String = DoubleToString(dVal, 4)
|
|
RaiseEvent SetInputBoxText(sText)
|
|
End Sub
|
|
|
|
Private Sub SetInputBox3Double(ByVal d3Val() As Double)
|
|
' verifico ci siano almeno 3 elementi nell'array
|
|
If d3Val.Length < 3 Then
|
|
Return
|
|
End If
|
|
' visualizzo
|
|
Dim sText As New StringBuilder(128)
|
|
sText.Append(DoubleToString(d3Val(0), 4))
|
|
sText.Append(",")
|
|
sText.Append(DoubleToString(d3Val(1), 4))
|
|
sText.Append(",")
|
|
sText.Append(DoubleToString(d3Val(2), 4))
|
|
RaiseEvent SetInputBoxText(sText.ToString())
|
|
End Sub
|
|
|
|
Private Sub SetInputBoxPoint3d(ByVal ptVal As Point3d)
|
|
' converto da coordinate globali a griglia
|
|
Dim frGrid As New Frame3d
|
|
EgtGetGridFrame(frGrid)
|
|
ptVal.ToLoc(frGrid)
|
|
' visualizzo
|
|
Dim sText As New StringBuilder(128)
|
|
sText.Append(DoubleToString(ptVal.x, 4))
|
|
sText.Append(",")
|
|
sText.Append(DoubleToString(ptVal.y, 4))
|
|
sText.Append(",")
|
|
sText.Append(DoubleToString(ptVal.z, 4))
|
|
RaiseEvent SetInputBoxText(sText.ToString())
|
|
End Sub
|
|
|
|
Private Function InputTextToLast(ByRef sText As String) As Boolean
|
|
Select Case m_nInpType
|
|
Case IBT.TY_STRING
|
|
m_sLast = sText
|
|
Return True
|
|
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)
|
|
Case IBT.TY_POINT3D
|
|
Dim d3Val(3) As Double
|
|
If TextTo3Double(sText, d3Val) Then
|
|
m_ptLast.x = d3Val(0)
|
|
m_ptLast.y = d3Val(1)
|
|
m_ptLast.z = d3Val(2)
|
|
' converto da riferimento griglia a globale
|
|
Dim frGrid As New Frame3d
|
|
EgtGetGridFrame(frGrid)
|
|
m_ptLast.ToGlob(frGrid)
|
|
Return True
|
|
End If
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
Private Function TextToDouble(ByRef sText As String, ByRef dVal As Double) As Boolean
|
|
Return Double.TryParse(sText, NumberStyles.Float, CultureInfo.InvariantCulture, dVal)
|
|
End Function
|
|
|
|
Private Function TextTo3Double(ByRef sText As String, ByRef d3Val() As Double) As Boolean
|
|
' verifico ci siano almeno 3 elementi nell'array
|
|
If d3Val.Length < 3 Then
|
|
Return False
|
|
End If
|
|
' leggo i tre valori
|
|
Dim sItems() As String = sText.Split(",".ToCharArray)
|
|
Dim bOk As Boolean = False
|
|
d3Val(0) = 0
|
|
d3Val(1) = 0
|
|
d3Val(2) = 0
|
|
If sItems.Count() >= 1 Then
|
|
bOk = Double.TryParse(sItems(0), NumberStyles.Float, CultureInfo.InvariantCulture, d3Val(0))
|
|
If sItems.Count() >= 2 Then
|
|
bOk = Double.TryParse(sItems(1), NumberStyles.Float, CultureInfo.InvariantCulture, d3Val(1)) And bOk
|
|
If sItems.Count() >= 3 Then
|
|
bOk = Double.TryParse(sItems(2), NumberStyles.Float, CultureInfo.InvariantCulture, d3Val(2)) And bOk
|
|
End If
|
|
End If
|
|
End If
|
|
Return bOk
|
|
End Function
|
|
|
|
Public Sub SetLastPoint3d(ByRef ptP As Point3d)
|
|
m_ptLast = ptP
|
|
End Sub
|
|
|
|
Public Sub SetLastVector3d(ByRef vtV As Vector3d)
|
|
m_vtCont = vtV
|
|
End Sub
|
|
|
|
Public Sub SetLastDouble(ByVal dVal As Double)
|
|
m_dLast = dVal
|
|
End Sub
|
|
|
|
Public Sub SetLast3Double(ByVal d3Val() As Double)
|
|
If d3Val.Length >= 1 Then
|
|
m_d3Last(0) = d3Val(0)
|
|
If d3Val.Length >= 2 Then
|
|
m_d3Last(1) = d3Val(1)
|
|
If d3Val.Length >= 3 Then
|
|
m_d3Last(2) = d3Val(2)
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub SetLastIntegers(ByVal nVal1 As Integer, ByVal nVal2 As Integer)
|
|
m_nLast1 = nVal1
|
|
m_nLast2 = nVal2
|
|
End Sub
|
|
|
|
Public Sub SetLastString(ByRef sVal As String)
|
|
m_sLast = sVal
|
|
End Sub
|
|
|
|
Public Sub SetLastBoolean(ByVal bVal As Boolean)
|
|
m_bLast = bVal
|
|
End Sub
|
|
|
|
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
|
|
|
|
Public Function RepeatLastCommand() As Boolean
|
|
Return ExecuteCommand(m_nLastCmd)
|
|
End Function
|
|
|
|
Public Function ExecuteCommand(ByVal nCmd As CMD) As Boolean
|
|
' posso partire solo con stato libero
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
' salvo ed eseguo il comando
|
|
m_nLastCmd = nCmd
|
|
ProcessStatus()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessStatus() As Boolean
|
|
Select Case m_nLastCmd
|
|
' Grid
|
|
Case CMD.GRID
|
|
Return ProcessGrid()
|
|
' Grid origin
|
|
Case CMD.GRID_ELEVATION
|
|
Return ProcessGridElevation()
|
|
Case CMD.GRID_ORIGIN
|
|
Return ProcessGridOrigin()
|
|
' rotazione Griglia/Cplane
|
|
Case CMD.GRID_ROTATE
|
|
Return ProcessGridRotate()
|
|
' Griglia/Cplane dati 3 punti
|
|
Case CMD.GRID_3P
|
|
Return ProcessGrid3P()
|
|
' Griglia/Cplane perpendicolare a curva
|
|
Case CMD.GRID_PERPCURVE
|
|
Return ProcessGridPerpCurve()
|
|
' Griglia/Cplane da oggetto geometrico
|
|
Case CMD.GRID_OBJ
|
|
Return ProcessGridObj()
|
|
' Nuovo Pezzo
|
|
Case CMD.NEWPART
|
|
Return ProcessNewPart()
|
|
' Nuovo Layer
|
|
Case CMD.NEWLAYER
|
|
Return ProcessNewLayer()
|
|
' Imposto pezzo e layer correnti
|
|
Case CMD.SETCURRPARTLAYER
|
|
Return ProcessSetCurrPartLayer()
|
|
' Cancello pezzo e layer correnti
|
|
Case CMD.RESETCURRPARTLAYER
|
|
Return ProcessResetCurrPartLayer()
|
|
' Imposto colore del layer
|
|
Case CMD.LAYERCOLOR
|
|
Return ProcessLayerColor()
|
|
' Seleziono Pezzo/Layer/Oggetto
|
|
Case CMD.SELECTPARTLAYEROBJ
|
|
Return ProcessSelectPartLayerObj()
|
|
' Deseleziono Pezzo/Layer/Oggetto
|
|
Case CMD.DESELECTPARTLAYEROBJ
|
|
Return ProcessDeselectPartLayerObj()
|
|
' Riloco Pezzo/Layer/Oggetto
|
|
Case CMD.RELOCATEPARTLAYEROBJ
|
|
Return ProcessRelocatePartLayerObj()
|
|
' Copio Pezzo/Layer/Oggetto
|
|
Case CMD.COPYPARTLAYEROBJ
|
|
Return ProcessCopyPartLayerObj()
|
|
' Visualizza
|
|
Case CMD.SHOW
|
|
Return ProcessShow()
|
|
' Nascondi
|
|
Case CMD.HIDE
|
|
Return ProcessHide()
|
|
' Name
|
|
Case CMD.SETNAME
|
|
Return ProcessSetName()
|
|
' Info
|
|
Case CMD.SETINFO
|
|
Return ProcessSetInfo()
|
|
' Point
|
|
Case CMD.POINT
|
|
Return ProcessPoint()
|
|
' Line2P
|
|
Case CMD.LINE2P
|
|
Return ProcessLine2P()
|
|
' LinePDL
|
|
Case CMD.LINEPDL
|
|
Return ProcessLinePDL()
|
|
' CircleCP
|
|
Case CMD.CIRCLECP
|
|
Return ProcessCircleCP()
|
|
' CircleCD
|
|
Case CMD.CIRCLECD
|
|
Return ProcessCircleCD()
|
|
' ArcCSE
|
|
Case CMD.ARCCSE
|
|
Return ProcessArcCSE()
|
|
' Arc3P
|
|
Case CMD.ARC3P
|
|
Return ProcessArc3P()
|
|
' ArcPDP
|
|
Case CMD.ARCPDP
|
|
Return ProcessArcPDP()
|
|
' Plane
|
|
Case CMD.PLANE
|
|
Return ProcessPlane()
|
|
' Extrude
|
|
Case CMD.EXTRUDE
|
|
Return ProcessExtrude()
|
|
' Revolve
|
|
Case CMD.REVOLVE
|
|
Return ProcessRevolve()
|
|
' Revolve Plus
|
|
Case CMD.REVOLVEPLUS
|
|
Return ProcessRevolvePlus()
|
|
' Ruled
|
|
Case CMD.RULED
|
|
Return ProcessRuled()
|
|
' Delete
|
|
Case CMD.DELETE
|
|
Return ProcessDelete()
|
|
' Change Color
|
|
Case CMD.CHANGECOLOR
|
|
Return ProcessChangeColor()
|
|
' Reset Color
|
|
Case CMD.RESETCOLOR
|
|
Return ProcessResetColor()
|
|
' Invert Curve or Surface
|
|
Case CMD.INVERTCRVSURF
|
|
Return ProcessInvertCurveSurf()
|
|
' Extend Curve
|
|
Case CMD.TRIMEXTENDCURVE
|
|
Return ProcessExtendCurve()
|
|
' Break Curve
|
|
Case CMD.BREAKCURVE
|
|
Return ProcessBreakCurve()
|
|
' Join Curve
|
|
Case CMD.JOINCURVE
|
|
Return ProcessJoinCurve()
|
|
' Separate Curve
|
|
Case CMD.EXPLODECURVE
|
|
Return ProcessExplodeCurve()
|
|
' Set Curve Thickness
|
|
Case CMD.SETCURVETHICKNESS
|
|
Return ProcessSetCurveThickness()
|
|
' Move
|
|
Case CMD.MOVE
|
|
Return ProcessMove()
|
|
' Rotate
|
|
Case CMD.ROTATE
|
|
ProcessRotate()
|
|
' Rotate 3d
|
|
Case CMD.ROTATE3D
|
|
ProcessRotate3D()
|
|
' Mirror
|
|
Case CMD.MIRROR
|
|
ProcessMirror()
|
|
' Scale
|
|
Case CMD.SCALE
|
|
ProcessScale()
|
|
' Scale 3d
|
|
Case CMD.SCALE3D
|
|
ProcessScale3D()
|
|
' Offset
|
|
Case CMD.OFFSET
|
|
ProcessOffset()
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
Private Function ExecuteDrag() As Boolean
|
|
Select Case m_nLastCmd
|
|
Case CMD.GRID_ROTATE
|
|
DragGridRotate()
|
|
Case CMD.LINE2P
|
|
DragLine2P()
|
|
Case CMD.LINEPDL
|
|
DragLinePDL()
|
|
Case CMD.CIRCLECP
|
|
DragCircleCP()
|
|
Case CMD.CIRCLECD
|
|
DragCircleCD()
|
|
Case CMD.ARCCSE
|
|
DragArcCSE()
|
|
Case CMD.ARC3P
|
|
DragArc3P()
|
|
Case CMD.ARCPDP
|
|
DragArcPDP()
|
|
Case CMD.EXTRUDE
|
|
DragExtrude()
|
|
Case CMD.REVOLVE
|
|
DragRevolve()
|
|
Case CMD.REVOLVEPLUS
|
|
DragRevolvePlus()
|
|
Case CMD.TRIMEXTENDCURVE
|
|
DragExtendCurve()
|
|
Case CMD.SETCURVETHICKNESS
|
|
DragSetCurveThickness()
|
|
Case CMD.MOVE
|
|
DragMove()
|
|
Case CMD.ROTATE
|
|
DragRotate()
|
|
Case CMD.ROTATE3D
|
|
DragRotate3D()
|
|
Case CMD.MIRROR
|
|
DragMirror()
|
|
Case CMD.SCALE
|
|
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
|
|
End If
|
|
Dim frNew As New Frame3d
|
|
Select Case m_nLast1
|
|
Case GRID_TYPE.TOP
|
|
frNew.Setup(Point3d.ORIG, Vector3d.X_AX, Vector3d.Y_AX, Vector3d.Z_AX)
|
|
Case GRID_TYPE.FRONT
|
|
frNew.Setup(Point3d.ORIG, Vector3d.X_AX, Vector3d.Z_AX, -Vector3d.Y_AX)
|
|
Case GRID_TYPE.RIGHT
|
|
frNew.Setup(Point3d.ORIG, Vector3d.Y_AX, Vector3d.Z_AX, Vector3d.X_AX)
|
|
Case GRID_TYPE.BACK
|
|
frNew.Setup(Point3d.ORIG, -Vector3d.X_AX, Vector3d.Z_AX, Vector3d.Y_AX)
|
|
Case GRID_TYPE.LEFT
|
|
frNew.Setup(Point3d.ORIG, -Vector3d.Y_AX, Vector3d.Z_AX, -Vector3d.X_AX)
|
|
Case GRID_TYPE.BOTTOM
|
|
frNew.Setup(Point3d.ORIG, -Vector3d.X_AX, Vector3d.Y_AX, -Vector3d.Z_AX)
|
|
Case Else
|
|
Return False
|
|
End Select
|
|
EgtSetGridFrame(frNew)
|
|
EgtDraw()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessGridElevation() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' non serve il gruppo di drag
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a lunghezza per elevazione griglia
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("GRID", "Insert Elevation", "", False)
|
|
m_nInpType = IBT.TY_DOUBLE
|
|
Case 1
|
|
' recupero il piano di griglia corrente
|
|
Dim frCurr As New Frame3d
|
|
EgtGetGridFrame(frCurr)
|
|
' cambio l'elevazione dell'origine
|
|
frCurr.Move(EgtGetGridVersZ() * m_dLast)
|
|
' imposto nuova griglia
|
|
EgtSetGridFrame(frCurr)
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
RaiseEvent UpdateUI(Me, False)
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessGridOrigin() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' non serve il gruppo di drag
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a primo punto per origine griglia
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("GRID", "Insert Origin", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 1
|
|
' recupero il piano di griglia corrente
|
|
Dim frCurr As New Frame3d
|
|
EgtGetGridFrame(frCurr)
|
|
' ne modifico l'origine
|
|
frCurr.Move(m_ptLast - frCurr.Orig())
|
|
' imposto nuova griglia
|
|
EgtSetGridFrame(frCurr)
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
RaiseEvent UpdateUI(Me, False)
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessGridRotate() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' non serve il gruppo di drag
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a primo punto per rotazione griglia
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("GRID ROTATE", "Insert First Point on Axis", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_ptP2 = m_ptP1
|
|
m_nStep = 2
|
|
RaiseEvent PrepareInputBox("GRID ROTATE", "Insert Second Point on Axis", "", True)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 2
|
|
m_ptP2 = m_ptLast
|
|
m_nStep = 3
|
|
RaiseEvent PrepareInputBox("GRID ROTATE", "Insert angle", "", False)
|
|
m_nInpType = IBT.TY_DOUBLE
|
|
Case 3
|
|
' eseguo rotazione
|
|
Dim VtAx As Vector3d = m_ptP2 - m_ptP1
|
|
Dim frCurr As New Frame3d
|
|
EgtGetGridFrame(frCurr)
|
|
frCurr.Rotate(m_ptP1, VtAx, m_dLast)
|
|
EgtSetGridFrame(frCurr)
|
|
' reset
|
|
m_Scene.ResetStatus()
|
|
m_nStep = 0
|
|
RaiseEvent UpdateUI(Me, False)
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub DragGridRotate()
|
|
If m_nStep = 2 Then
|
|
EgtSetGeoLine(m_ptP1, m_ptLast)
|
|
EgtDraw()
|
|
ElseIf m_nStep = 3 Then
|
|
EgtSetGeoLine(m_ptP1, m_ptP2)
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessGrid3P() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' non serve il gruppo di drag
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a primo punto per rotazione griglia
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("GRID 3 POINTS", "Insert Origin", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_ptP2 = m_ptP1
|
|
m_nStep = 2
|
|
RaiseEvent PrepareInputBox("GRID 3 POINTS", "Insert Point on X Axis", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 2
|
|
m_ptP2 = m_ptLast
|
|
m_nStep = 3
|
|
RaiseEvent PrepareInputBox("GRID 3 POINTS", "Insert Point Near Y Axis", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 3
|
|
' calcolo griglia per 3 punti
|
|
Dim frCurr As New Frame3d
|
|
If Not frCurr.Setup(m_ptP1, m_ptP2, m_ptLast) Then
|
|
m_Scene.ResetStatus()
|
|
m_nStep = 0
|
|
Return False
|
|
End If
|
|
EgtSetGridFrame(frCurr)
|
|
' reset
|
|
m_Scene.ResetStatus()
|
|
m_nStep = 0
|
|
RaiseEvent UpdateUI(Me, False)
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessGridPerpCurve() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' non serve il gruppo di drag
|
|
m_Scene.SetStatusSelPoint(True)
|
|
' imposto stato a primo punto per rotazione griglia
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("GRID PERP CURVE", "Insert Origin", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 1
|
|
' calcolo griglia dato punto e versore Z
|
|
Dim frCurr As New Frame3d
|
|
If Not frCurr.Setup(m_ptLast, m_vtCont) Then
|
|
m_Scene.ResetStatus()
|
|
m_nStep = 0
|
|
Return False
|
|
End If
|
|
EgtSetGridFrame(frCurr)
|
|
' reset
|
|
m_Scene.ResetStatus()
|
|
m_nStep = 0
|
|
RaiseEvent UpdateUI(Me, False)
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessGridObj() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
Dim nId As Integer = EgtGetLastSelectedObj()
|
|
Select Case EgtGetType(nId)
|
|
Case GDB_TY.CRV_ARC
|
|
Dim vtZ As Vector3d
|
|
If EgtCurveExtrusion(nId, vtZ) Or EgtCurveArcNormVersor(nId, vtZ) Then
|
|
Dim ptOrig As Point3d
|
|
EgtCenterPoint(nId, ptOrig)
|
|
Dim frNew As New Frame3d
|
|
frNew.Setup(ptOrig.Glob(nId), vtZ.Glob(nId))
|
|
EgtSetGridFrame(frNew)
|
|
EgtDraw()
|
|
End If
|
|
Case GDB_TY.CRV_LINE, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO
|
|
Dim vtZ As Vector3d
|
|
If EgtCurveExtrusion(nId, vtZ) Then
|
|
Dim ptOrig As Point3d
|
|
EgtCenterPoint(nId, ptOrig)
|
|
Dim frNew As New Frame3d
|
|
frNew.Setup(ptOrig.Glob(nId), vtZ.Glob(nId))
|
|
EgtSetGridFrame(frNew)
|
|
EgtDraw()
|
|
End If
|
|
Case GDB_TY.EXT_TEXT
|
|
Dim vtX As Vector3d
|
|
Dim vtZ As Vector3d
|
|
If EgtStartVector(nId, vtX) And EgtExtTextNormVersor(nId, vtZ) Then
|
|
Dim vtY As Vector3d = vtZ ^ vtX
|
|
Dim ptOrig As Point3d
|
|
EgtStartPoint(nId, ptOrig)
|
|
Dim frNew As New Frame3d
|
|
frNew.Setup(ptOrig.Glob(nId), vtX.Glob(nId), vtY.Glob(nId), vtZ.Glob(nId))
|
|
EgtSetGridFrame(frNew)
|
|
EgtDraw()
|
|
End If
|
|
End Select
|
|
EgtDeselectAll()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessNewPart() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
' inserisco un nuovo gruppo (piece) sotto la radice
|
|
Dim nIdNewPart As Integer = EgtCreateGroup(GDB_ID.ROOT)
|
|
' inserisco un nuovo gruppo (layer) sotto quello appena creato
|
|
Dim nIdNewLayer As Integer = EgtCreateGroup(nIdNewPart)
|
|
' se ok, salvo nuova situazione
|
|
If nIdNewPart <> GDB_ID.NULL And nIdNewLayer <> GDB_ID.NULL Then
|
|
m_nCurrPart = nIdNewPart
|
|
m_nCurrLayer = nIdNewLayer
|
|
SetModified()
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessNewLayer() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
' inserisco un nuovo gruppo (layer) sotto il pezzo corrente
|
|
Dim nIdNewLayer As Integer = EgtCreateGroup(m_nCurrPart)
|
|
' se ok, salvo nuova situazione
|
|
If nIdNewLayer <> GDB_ID.NULL Then
|
|
m_nCurrLayer = nIdNewLayer
|
|
SetModified()
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessSetCurrPartLayer() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
SetCurrPartLayer(m_nLast1, m_nLast2)
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessResetCurrPartLayer() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
ResetCurrPartLayer()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessLayerColor() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
Dim nCurrId As Integer
|
|
If m_nCurrPart <> GDB_ID.NULL Then
|
|
nCurrId = m_nCurrPart
|
|
If m_nCurrLayer <> GDB_ID.NULL Then
|
|
nCurrId = m_nCurrLayer
|
|
End If
|
|
Else
|
|
Return False
|
|
End If
|
|
Dim ColDlg As New ColorDialog
|
|
ColDlg.AnyColor = True
|
|
Dim colObj As Color3d
|
|
EgtGetCalcColor(nCurrId, colObj)
|
|
ColDlg.Color = colObj.ToColor()
|
|
ColDlg.FullOpen = True
|
|
If ColDlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
|
|
colObj.FromColor(ColDlg.Color)
|
|
EgtSetColor(nCurrId, colObj)
|
|
SetModified()
|
|
EgtDraw()
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessSelectPartLayerObj() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
' se gruppo
|
|
If EgtGetType(m_nLast1) = GDB_TY.GROUP Then
|
|
' se pezzo
|
|
If EgtGetParent(m_nLast1) = GDB_ID.ROOT Then
|
|
' seleziono tutti gli oggetti del pezzo
|
|
If Not EgtSelectPartObjs(m_nLast1) Then
|
|
Return False
|
|
End If
|
|
' se layer
|
|
ElseIf EgtGetParent(EgtGetParent(m_nLast1)) = GDB_ID.ROOT Then
|
|
' seleziono tutti gli oggetti del layer
|
|
If Not EgtSelectLayerObjs(m_nLast1) Then
|
|
Return False
|
|
End If
|
|
' altrimenti errore
|
|
Else
|
|
Return False
|
|
End If
|
|
' altrimenti entità
|
|
Else
|
|
' la seleziono
|
|
If Not EgtSelectObj(m_nLast1) Then
|
|
Return False
|
|
End If
|
|
End If
|
|
SetModified()
|
|
EgtDraw()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessDeselectPartLayerObj() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
' se gruppo
|
|
If EgtGetType(m_nLast1) = GDB_TY.GROUP Then
|
|
' se pezzo
|
|
If EgtGetParent(m_nLast1) = GDB_ID.ROOT Then
|
|
' deseleziono tutti gli oggetti del pezzo
|
|
If Not EgtDeselectPartObjs(m_nLast1) Then
|
|
Return False
|
|
End If
|
|
' se layer
|
|
ElseIf EgtGetParent(EgtGetParent(m_nLast1)) = GDB_ID.ROOT Then
|
|
' deseleziono tutti gli oggetti del layer
|
|
If Not EgtDeselectLayerObjs(m_nLast1) Then
|
|
Return False
|
|
End If
|
|
' altrimenti errore
|
|
Else
|
|
Return False
|
|
End If
|
|
' altrimenti entità
|
|
Else
|
|
' la deseleziono
|
|
If Not EgtDeselectObj(m_nLast1) Then
|
|
Return False
|
|
End If
|
|
End If
|
|
SetModified()
|
|
EgtDraw()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessRelocatePartLayerObj() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
Dim nRefId As Integer = GDB_ID.NULL
|
|
Dim nPos As GDB_POS = GDB_POS.SON
|
|
' se gruppo
|
|
If EgtGetType(m_nLast1) = GDB_TY.GROUP Then
|
|
' se pezzo
|
|
If EgtGetParent(m_nLast1) = GDB_ID.ROOT Then
|
|
' il riferimento è dopo l'ultimo sotto la radice
|
|
nRefId = EgtGetLastInGroup(GDB_ID.ROOT)
|
|
nPos = GDB_POS.AFTER
|
|
' se layer
|
|
ElseIf EgtGetParent(EgtGetParent(m_nLast1)) = GDB_ID.ROOT Then
|
|
' il riferimento è il pezzo corrente
|
|
nRefId = m_nCurrPart
|
|
' se il pezzo sorgente è il corrente
|
|
If EgtGetParent(m_nLast1) = m_nCurrPart Then
|
|
' il riferimento è dopo l'ultimo sotto il pezzo
|
|
nRefId = EgtGetLastInGroup(m_nCurrPart)
|
|
nPos = GDB_POS.AFTER
|
|
End If
|
|
' altrimenti errore
|
|
Else
|
|
Return False
|
|
End If
|
|
' altrimenti entità
|
|
Else
|
|
' il riferimento è il layer corrente
|
|
nRefId = m_nCurrLayer
|
|
' se il layer sorgente è il corrente
|
|
If EgtGetParent(m_nLast1) = m_nCurrLayer Then
|
|
' il riferimento è dopo l'ultimo sotto il layer
|
|
nRefId = EgtGetLastInGroup(m_nCurrLayer)
|
|
nPos = GDB_POS.AFTER
|
|
End If
|
|
End If
|
|
EgtRelocateGlob(m_nLast1, nRefId, nPos)
|
|
SetModified()
|
|
EgtDraw()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessCopyPartLayerObj() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
EgtDeselectAll()
|
|
Dim nNewId = GDB_ID.NULL
|
|
' se gruppo
|
|
If EgtGetType(m_nLast1) = GDB_TY.GROUP Then
|
|
' se pezzo
|
|
If EgtGetParent(m_nLast1) = GDB_ID.ROOT Then
|
|
' eseguo copia
|
|
nNewId = EgtCopyGlob(m_nLast1, GDB_ID.ROOT)
|
|
' seleziono tutti gli oggetti del pezzo
|
|
If Not EgtSelectPartObjs(nNewId) Then
|
|
Return False
|
|
End If
|
|
' se layer
|
|
ElseIf EgtGetParent(EgtGetParent(m_nLast1)) = GDB_ID.ROOT Then
|
|
' eseguo copia
|
|
nNewId = EgtCopyGlob(m_nLast1, m_nCurrPart)
|
|
' seleziono tutti gli oggetti del layer
|
|
If Not EgtSelectLayerObjs(nNewId) Then
|
|
Return False
|
|
End If
|
|
' altrimenti errore
|
|
Else
|
|
Return False
|
|
End If
|
|
' altrimenti entità
|
|
Else
|
|
' eseguo copia
|
|
nNewId = EgtCopyGlob(m_nLast1, m_nCurrLayer)
|
|
' la seleziono
|
|
If Not EgtSelectObj(nNewId) Then
|
|
Return False
|
|
End If
|
|
End If
|
|
' dichiaro modifica
|
|
SetModified()
|
|
' preparo per il drag
|
|
If Not PrepareTransform() Then
|
|
Return False
|
|
End If
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a primo punto per Move
|
|
m_nLastCmd = CMD.MOVE
|
|
m_bLast = False
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("MOVE", "Insert Base Point", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessShow() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
If m_nLast1 <> GDB_ID.NULL Then
|
|
Dim nStat As GDB_ST = GDB_ST.ON_
|
|
EgtGetStatus(m_nLast1, nStat)
|
|
If nStat = GDB_ST.OFF Then
|
|
EgtSetStatus(m_nLast1, GDB_ST.ON_)
|
|
SetModified(False)
|
|
EgtDraw()
|
|
End If
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessHide() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
If m_nLast1 <> GDB_ID.NULL Then
|
|
Dim nStat As GDB_ST = GDB_ST.ON_
|
|
EgtGetStatus(m_nLast1, nStat)
|
|
If nStat <> GDB_ST.OFF Then
|
|
EgtSetStatus(m_nLast1, GDB_ST.OFF)
|
|
SetModified(False)
|
|
EgtDraw()
|
|
End If
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessSetName() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' posso partire solo se esiste una entità riferita
|
|
If m_nLast1 = GDB_ID.NULL Then
|
|
Return False
|
|
End If
|
|
' recupero e imposto eventuale nome già assegnato
|
|
m_sLast = String.Empty
|
|
EgtGetName(m_nLast1, m_sLast)
|
|
' imposto stato a prima stringa per nome
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("NAME", "Insert Name", "", False)
|
|
m_nInpType = IBT.TY_STRING
|
|
SetInputBoxString(m_sLast)
|
|
Case 1
|
|
' assegno il nome
|
|
If Not String.IsNullOrWhiteSpace(m_sLast) Then
|
|
EgtSetName(m_nLast1, m_sLast)
|
|
Else
|
|
EgtRemoveName(m_nLast1)
|
|
End If
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessSetInfo() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' posso partire solo se esiste una entità riferita
|
|
If m_nLast1 = GDB_ID.NULL Then
|
|
Return False
|
|
End If
|
|
' imposto stato a prima stringa per info
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("INFO", "Insert Info (Key=Val)", "", False)
|
|
m_nInpType = IBT.TY_STRING
|
|
Case 1
|
|
' divido la stringa in chiave e valore
|
|
Dim sItems() As String = m_sLast.Split("=".ToCharArray)
|
|
If sItems.Count() = 2 Then
|
|
' assegno l'info
|
|
If Not String.IsNullOrWhiteSpace(sItems(1)) Then
|
|
EgtSetInfo(m_nLast1, sItems(0), sItems(1))
|
|
' rimuovo l'info
|
|
Else
|
|
EgtRemoveInfo(m_nLast1, sItems(0))
|
|
End If
|
|
End If
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessPoint() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' deve esistere un gruppo corrente
|
|
If GetCurrLayer() = GDB_ID.NULL Then
|
|
Return False
|
|
End If
|
|
' non serve il gruppo di drag
|
|
' imposto stato a primo punto per point
|
|
m_Scene.SetStatusSelPoint()
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("POINT", "Insert Point", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
SetInputBoxPoint3d(m_ptCont)
|
|
Case 1
|
|
' creo il punto (i dati sono in globale)
|
|
If EgtCreateGeoPoint(GetCurrLayer(), m_ptLast.Loc(GetCurrLayer())) Then
|
|
m_ptCont = m_ptLast
|
|
End If
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessLine2P() 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
|
|
End If
|
|
' imposto stato a primo punto per Line2P
|
|
m_Scene.SetStatusSelPoint()
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
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 = 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)
|
|
m_vtCont.Normalize()
|
|
End If
|
|
EgtDraw()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub DragLine2P()
|
|
' il gruppo di Drag ha riferimento globale
|
|
If m_nStep = 2 Then
|
|
' recupero possibile entità già nel gruppo di drag
|
|
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
|
' 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
|
|
EgtErase(nId)
|
|
EgtCreateCurveLineEx(m_Scene.GetDragGroup(), m_ptP1, m_sepP1, m_nIdP1, m_ptLast, m_sepLast, m_nIdLast)
|
|
End If
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessLinePDL() 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
|
|
End If
|
|
' imposto stato a primo punto per Line2P
|
|
m_Scene.SetStatusSelPoint(True)
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("LINE PDL", "Insert Start Point", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
SetInputBoxPoint3d(m_ptCont)
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_dAux = LEN_STD
|
|
' posso prendere punto per definire direzione, ma non prendo direzione notevole
|
|
m_Scene.SetStatusSelPoint(False)
|
|
m_nStep = 2
|
|
m_Scene.DisableDrag()
|
|
RaiseEvent PrepareInputBox("LINE PDL", "Insert Direction", "", True)
|
|
m_nInpType = IBT.TY_DIRECTION
|
|
m_dLast = GridAngFromGlobDir(m_vtCont)
|
|
SetInputBoxDouble(m_dLast)
|
|
DragLinePDL()
|
|
Case 2
|
|
m_dPrev = m_dLast
|
|
m_vtCont = GlobDirFromGridAng(m_dPrev)
|
|
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)
|
|
DragLinePDL()
|
|
Case 3
|
|
' reset scena
|
|
m_Scene.ResetStatus(False)
|
|
' creo la linea (i punti sono in globale)
|
|
Dim nId As Integer = EgtCreateCurveLinePVL(GetCurrLayer(), m_ptP1.Loc(GetCurrLayer()), m_vtCont.Loc(GetCurrLayer()), m_dLast)
|
|
If nId <> GDB_ID.NULL Then
|
|
m_ptCont = m_ptLast
|
|
m_vtCont = (m_ptLast - m_ptP1)
|
|
m_vtCont.Normalize()
|
|
End If
|
|
EgtDraw()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub DragLinePDL()
|
|
If m_nStep = 2 Then ' inserimento direzione
|
|
' determino il versore direzione iniziale
|
|
Dim vtDirS = GlobDirFromGridAng(m_dLast)
|
|
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
|
|
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
|
If nId = GDB_ID.NULL Then
|
|
' creo la linea di direzione
|
|
EgtCreateCurveLinePVL(m_Scene.GetDragGroup(), m_ptP1, vtDirS, m_dAux)
|
|
Else
|
|
Dim ptP2 As Point3d = m_ptP1 + vtDirS * m_dAux
|
|
EgtModifyCurveEndPoint(nId, ptP2)
|
|
End If
|
|
EgtDraw()
|
|
ElseIf m_nStep = 3 Then ' inserimento lunghezza
|
|
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
|
|
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
|
If nId = GDB_ID.NULL Then
|
|
' creo la linea di direzione
|
|
EgtCreateCurveLinePVL(m_Scene.GetDragGroup(), m_ptP1, m_vtCont, m_dLast)
|
|
Else
|
|
Dim ptP2 As Point3d = m_ptP1 + m_vtCont * m_dLast
|
|
EgtModifyCurveEndPoint(nId, ptP2)
|
|
End If
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessCircleCP() 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
|
|
End If
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a primo punto per CircleCR
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("CIRCLE CP", "Insert Center", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_nStep = 2
|
|
m_Scene.EnableDrag()
|
|
RaiseEvent PrepareInputBox("CIRCLE CP", "Insert Point", "", True)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 2
|
|
' reset scena
|
|
m_Scene.ResetStatus(False)
|
|
' creo la circonferenza (i punti sono in globale)
|
|
EgtCreateCurveCircleCPN(GetCurrLayer(), m_ptP1.Loc(GetCurrLayer()), m_ptLast.Loc(GetCurrLayer()), EgtGetGridVersZ().Loc(GetCurrLayer()))
|
|
EgtDraw()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub DragCircleCP()
|
|
If m_nStep = 2 Then
|
|
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
|
|
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
|
If nId = GDB_ID.NULL Then
|
|
EgtCreateCurveCircleCPN(m_Scene.GetDragGroup(), m_ptP1, m_ptLast, EgtGetGridVersZ())
|
|
Else
|
|
EgtModifyCurveCircleCPN(nId, m_ptLast)
|
|
End If
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessCircleCD() 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
|
|
End If
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a primo punto per CircleCR
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("CIRCLE CD", "Insert Center", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_dLast = DIAM_STD
|
|
m_nStep = 2
|
|
m_Scene.DisableDrag()
|
|
RaiseEvent PrepareInputBox("CIRCLE CD", "Insert Diameter", "", True)
|
|
m_nInpType = IBT.TY_DOUBLE
|
|
SetInputBoxDouble(m_dLast)
|
|
DragCircleCD()
|
|
Case 2
|
|
' reset scena
|
|
m_Scene.ResetStatus(False)
|
|
' creo la circonferenza (i punti sono in globale)
|
|
EgtCreateCurveCircle(GetCurrLayer(), m_ptP1.Loc(GetCurrLayer()), EgtGetGridVersZ().Loc(GetCurrLayer()), 0.5 * m_dLast)
|
|
EgtDraw()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub DragCircleCD()
|
|
If m_nStep = 2 Then
|
|
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
|
|
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
|
If nId = GDB_ID.NULL Then
|
|
EgtCreateCurveCircle(m_Scene.GetDragGroup(), m_ptP1, EgtGetGridVersZ(), 0.5 * m_dLast)
|
|
Else
|
|
EgtModifyCurveArcRadius(nId, 0.5 * m_dLast)
|
|
End If
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessArcCSE() 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
|
|
End If
|
|
' imposto stato a primo punto per ArcCSE
|
|
m_Scene.SetStatusSelPoint()
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("ARC CSE", "Insert Center", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_nStep = 2
|
|
m_Scene.EnableDrag()
|
|
RaiseEvent PrepareInputBox("ARC CSE", "Insert Start Point", "", True)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 2
|
|
m_ptP2 = m_ptLast
|
|
m_nStep = 3
|
|
m_Scene.EnableDrag()
|
|
RaiseEvent PrepareInputBox("ARC CSE", "Insert Point Near End", "", True)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 3
|
|
' reset scena
|
|
m_Scene.ResetStatus(False)
|
|
' creo l'arco (i punti sono in globale)
|
|
Dim nId = EgtCreateCurveArcC2PN(GetCurrLayer(), m_ptP1.Loc(GetCurrLayer()), m_ptP2.Loc(GetCurrLayer()),
|
|
m_ptLast.Loc(GetCurrLayer()), EgtGetGridVersZ().Loc(GetCurrLayer()))
|
|
If nId <> GDB_ID.NULL Then
|
|
Dim PtP As Point3d
|
|
EgtEndPoint(nId, PtP)
|
|
m_ptCont = PtP.Glob(GetCurrLayer())
|
|
Dim VtV As Vector3d
|
|
EgtEndVector(nId, VtV)
|
|
m_vtCont = VtV.Glob(GetCurrLayer())
|
|
End If
|
|
EgtDraw()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub DragArcCSE()
|
|
If m_nStep = 2 Then
|
|
EgtSetGeoLine(m_ptP1, m_ptLast)
|
|
'' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
|
|
'Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
|
'If nId = GDB_ID.NULL Then
|
|
' EgtCreateCurveLine(m_Scene.GetDragGroup(), m_ptP1, m_ptLast)
|
|
'Else
|
|
' EgtModifyCurveEndPoint(nId, m_ptLast)
|
|
'End If
|
|
EgtDraw()
|
|
ElseIf m_nStep = 3 Then
|
|
EgtSetGeoLine(m_ptP1, m_ptLast)
|
|
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
|
|
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
|
If EgtGetType(nId) <> GDB_TY.CRV_ARC Then
|
|
EgtErase(nId)
|
|
nId = GDB_ID.NULL
|
|
End If
|
|
If nId = GDB_ID.NULL Then
|
|
EgtCreateCurveArcC2PN(m_Scene.GetDragGroup(), m_ptP1, m_ptP2, m_ptLast, EgtGetGridVersZ())
|
|
Else
|
|
EgtModifyCurveArcC2PN(nId, m_ptLast)
|
|
End If
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessArc3P() 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
|
|
End If
|
|
' imposto stato a primo punto per Arc3P
|
|
m_Scene.SetStatusSelPoint()
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("ARC 3P", "Insert Start Point", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
SetInputBoxPoint3d(m_ptCont)
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_nStep = 2
|
|
m_Scene.EnableDrag()
|
|
RaiseEvent PrepareInputBox("ARC 3P", "Insert End Point", "", True)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 2
|
|
m_ptP2 = m_ptLast
|
|
m_nStep = 3
|
|
m_Scene.EnableDrag()
|
|
RaiseEvent PrepareInputBox("ARC 3P", "Insert Mid Point", "", True)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 3
|
|
' reset scena
|
|
m_Scene.ResetStatus(False)
|
|
' creo l'arco (i punti sono in globale)
|
|
Dim nId = EgtCreateCurveArc3P(GetCurrLayer(), m_ptP1.Loc(GetCurrLayer()), m_ptLast.Loc(GetCurrLayer()), m_ptP2.Loc(GetCurrLayer()))
|
|
If nId <> GDB_ID.NULL Then
|
|
m_ptCont = m_ptP2
|
|
Dim VtV As Vector3d
|
|
EgtEndVector(nId, VtV)
|
|
m_vtCont = VtV.Glob(GetCurrLayer())
|
|
End If
|
|
EgtDraw()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub DragArc3P()
|
|
If m_nStep = 2 Then
|
|
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
|
|
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
|
If nId = GDB_ID.NULL Then
|
|
EgtCreateCurveLine(m_Scene.GetDragGroup(), m_ptP1, m_ptLast)
|
|
Else
|
|
EgtModifyCurveEndPoint(nId, m_ptLast)
|
|
End If
|
|
EgtDraw()
|
|
ElseIf m_nStep = 3 Then
|
|
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
|
|
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
|
If EgtGetType(nId) <> GDB_TY.CRV_ARC Then
|
|
EgtErase(nId)
|
|
nId = GDB_ID.NULL
|
|
End If
|
|
If nId = GDB_ID.NULL Then
|
|
If EgtCreateCurveArc3P(m_Scene.GetDragGroup(), m_ptP1, m_ptLast, m_ptP2) = GDB_ID.NULL And
|
|
(m_ptLast - m_ptP1) * (m_ptP2 - m_ptLast) > EPS_ZERO Then
|
|
EgtCreateCurveLine(m_Scene.GetDragGroup(), m_ptP1, m_ptP2)
|
|
End If
|
|
Else
|
|
If Not EgtModifyCurveArc3P(nId, m_ptLast) And (m_ptLast - m_ptP1) * (m_ptP2 - m_ptLast) > EPS_ZERO Then
|
|
EgtErase(nId)
|
|
EgtCreateCurveLine(m_Scene.GetDragGroup(), m_ptP1, m_ptP2)
|
|
End If
|
|
End If
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessArcPDP() 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
|
|
End If
|
|
' imposto stato a primo punto per Arc3P
|
|
m_Scene.SetStatusSelPoint(True)
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("ARC PDP", "Insert Start Point", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
SetInputBoxPoint3d(m_ptCont)
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_dAux = LEN_STD
|
|
m_Scene.SetStatusSelPoint(False)
|
|
m_nStep = 2
|
|
m_Scene.DisableDrag()
|
|
RaiseEvent PrepareInputBox("ARC PDP", "Insert Direction", "", True)
|
|
m_nInpType = IBT.TY_DIRECTION
|
|
m_dLast = GridAngFromGlobDir(m_vtCont)
|
|
SetInputBoxDouble(m_dLast)
|
|
DragArcPDP()
|
|
Case 2
|
|
m_nStep = 3
|
|
m_Scene.EnableDrag()
|
|
RaiseEvent PrepareInputBox("ARC PDP", "Insert End Point", "", True)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 3
|
|
' reset scena
|
|
m_Scene.ResetStatus(False)
|
|
' determino il versore direzione iniziale
|
|
Dim vtDirS As Vector3d = GlobDirFromGridAng(m_dLast)
|
|
' creo l'arco (i punti sono in globale)
|
|
Dim nId = EgtCreateCurveArc2PVN(GetCurrLayer(), m_ptP1.Loc(GetCurrLayer()), m_ptLast.Loc(GetCurrLayer()),
|
|
vtDirS.Loc(GetCurrLayer()), EgtGetGridVersZ().Loc(GetCurrLayer()))
|
|
If nId <> GDB_ID.NULL Then
|
|
m_ptCont = m_ptLast
|
|
Dim VtV As Vector3d
|
|
EgtEndVector(nId, VtV)
|
|
m_vtCont = VtV.Glob(GetCurrLayer())
|
|
End If
|
|
EgtDraw()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub DragArcPDP()
|
|
If m_nStep = 2 Then
|
|
' determino il versore direzione iniziale
|
|
Dim vtDirS = GlobDirFromGridAng(m_dLast)
|
|
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
|
|
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
|
If nId = GDB_ID.NULL Then
|
|
' creo la linea di direzione
|
|
EgtCreateCurveLinePVL(m_Scene.GetDragGroup(), m_ptP1, vtDirS, m_dAux)
|
|
Else
|
|
Dim ptP2 As Point3d = m_ptP1 + vtDirS * m_dAux
|
|
EgtModifyCurveEndPoint(nId, ptP2)
|
|
End If
|
|
EgtDraw()
|
|
ElseIf m_nStep = 3 Then
|
|
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
|
|
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
|
If EgtGetType(nId) <> GDB_TY.CRV_ARC Then
|
|
EgtErase(nId)
|
|
nId = GDB_ID.NULL
|
|
End If
|
|
' determino il versore direzione iniziale
|
|
Dim vtDirS As Vector3d = GlobDirFromGridAng(m_dLast)
|
|
' se arco da creare
|
|
If nId = GDB_ID.NULL Then
|
|
' creo l'arco (i punti sono in globale)
|
|
If EgtCreateCurveArc2PVN(m_Scene.GetDragGroup(), m_ptP1, m_ptLast, vtDirS, EgtGetGridVersZ()) = GDB_ID.NULL And
|
|
(m_ptLast - m_ptP1) * vtDirS > EPS_ZERO Then
|
|
EgtCreateCurveLine(m_Scene.GetDragGroup(), m_ptP1, m_ptLast)
|
|
End If
|
|
' altrimenti da modificare
|
|
Else
|
|
If Not EgtModifyCurveEndPoint(nId, m_ptLast) And (m_ptLast - m_ptP1) * vtDirS > EPS_ZERO Then
|
|
EgtErase(nId)
|
|
EgtCreateCurveLine(m_Scene.GetDragGroup(), m_ptP1, m_ptLast)
|
|
End If
|
|
End If
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessPlane() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
' posso partire solo se esiste un gruppo corrente
|
|
If GetCurrLayer() = GDB_ID.NULL Then
|
|
Return False
|
|
End If
|
|
' creo la superficie piana (a partire da un contorno selezionato)
|
|
EgtCreateSurfTriMeshByContour(GetCurrLayer(), EgtGetLastSelectedObj(), EPS_STM)
|
|
EgtDeselectAll()
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' reset stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessExtrude() 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
|
|
End If
|
|
' imposto stato a lunghezza di estrusione
|
|
m_nStep = 1
|
|
m_dLast = EXTRUDE_STD
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("EXTRUSION", "Insert length", "", True)
|
|
m_nInpType = IBT.TY_DOUBLE
|
|
SetInputBoxDouble(m_dLast)
|
|
DragExtrude()
|
|
Case 1
|
|
' reset scena
|
|
m_Scene.ResetStatus(False)
|
|
' creo la superficie di estrusione (a partire da un contorno selezionato)
|
|
Dim VtExtr As Vector3d = EgtGetGridVersZ().Loc(GetCurrLayer()) * m_dLast
|
|
EgtCreateSurfTriMeshByExtrusion(GetCurrLayer(), EgtGetLastSelectedObj(), VtExtr, EPS_STM)
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub DragExtrude()
|
|
If m_nStep = 1 Then
|
|
' cancello eventuale vecchia superficie di estrusione
|
|
EgtErase(EgtGetFirstInGroup(m_Scene.GetDragGroup()))
|
|
' creo la superficie di estrusione (a partire da un contorno selezionato)
|
|
Dim VtExtr As Vector3d = EgtGetGridVersZ() * m_dLast
|
|
EgtCreateSurfTriMeshByExtrusion(m_Scene.GetDragGroup(), EgtGetLastSelectedObj(), VtExtr, EPS_STM_DRAG)
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessRevolve() 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
|
|
End If
|
|
' imposto stato a primo punto
|
|
m_Scene.SetStatusSelPoint()
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("REVOLVE", "Insert First Point on Axis", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_nStep = 2
|
|
m_Scene.EnableDrag()
|
|
RaiseEvent PrepareInputBox("REVOLVE", "Insert Second Point on Axis", "", True)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 2
|
|
' reset scena
|
|
m_Scene.ResetStatus(False)
|
|
' creo la superficie di rivoluzione (i punti sono in globale)
|
|
Dim vtAx As Vector3d = m_ptLast - m_ptP1
|
|
EgtCreateSurfTriMeshByScrewing(GetCurrLayer(), EgtGetLastSelectedObj(),
|
|
m_ptP1.Loc(GetCurrLayer()), vtAx.Loc(GetCurrLayer()),
|
|
360, 0, EPS_STM)
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub DragRevolve()
|
|
If m_nStep = 2 Then
|
|
EgtSetGeoLine(m_ptP1, m_ptLast)
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessRevolvePlus() 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
|
|
End If
|
|
' imposto stato a primo punto
|
|
m_Scene.SetStatusSelPoint()
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("REVOLVE+", "Insert First Point on Axis", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_nStep = 2
|
|
m_Scene.EnableDrag()
|
|
RaiseEvent PrepareInputBox("REVOLVE+", "Insert Second Point on Axis", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 2
|
|
m_ptP2 = m_ptLast
|
|
m_dLast = 360
|
|
m_nStep = 3
|
|
m_Scene.DisableDrag()
|
|
RaiseEvent PrepareInputBox("REVOLVE+", "Insert Angle", "", True)
|
|
m_nInpType = IBT.TY_DOUBLE
|
|
SetInputBoxDouble(m_dLast)
|
|
Case 3
|
|
m_ptP2 = m_ptLast
|
|
m_dPrev = m_dLast
|
|
m_dLast = 0
|
|
m_nStep = 4
|
|
m_Scene.DisableDrag()
|
|
RaiseEvent PrepareInputBox("REVOLVE+", "Insert Move", "", True)
|
|
m_nInpType = IBT.TY_DOUBLE
|
|
SetInputBoxDouble(m_dLast)
|
|
Case 4
|
|
' reset scena
|
|
m_Scene.ResetStatus(False)
|
|
' creo la superficie di rivoluzione (i punti sono in globale)
|
|
Dim vtAx As Vector3d = m_ptP2 - m_ptP1
|
|
EgtCreateSurfTriMeshByScrewing(GetCurrLayer(), EgtGetLastSelectedObj(),
|
|
m_ptP1.Loc(GetCurrLayer()), vtAx.Loc(GetCurrLayer()),
|
|
m_dPrev, m_dLast, EPS_STM)
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub DragRevolvePlus()
|
|
If m_nStep = 2 Then
|
|
EgtSetGeoLine(m_ptP1, m_ptLast)
|
|
EgtDraw()
|
|
ElseIf m_nStep = 3 Then
|
|
EgtSetGeoLine(m_ptP1, m_ptP2)
|
|
' cancello eventuale vecchia superficie
|
|
EgtErase(EgtGetFirstInGroup(m_Scene.GetDragGroup()))
|
|
' creo la superficie di rivoluzione (i punti sono in globale)
|
|
Dim vtAx As Vector3d = m_ptP2 - m_ptP1
|
|
EgtCreateSurfTriMeshByScrewing(m_Scene.GetDragGroup(), EgtGetLastSelectedObj(),
|
|
m_ptP1, vtAx, m_dLast, 0, EPS_STM_DRAG)
|
|
EgtDraw()
|
|
ElseIf m_nStep = 4 Then
|
|
EgtSetGeoLine(m_ptP1, m_ptP2)
|
|
' cancello eventuale vecchia superficie
|
|
EgtErase(EgtGetFirstInGroup(m_Scene.GetDragGroup()))
|
|
' creo la superficie di rivoluzione (i punti sono in globale)
|
|
Dim vtAx As Vector3d = m_ptP2 - m_ptP1
|
|
EgtCreateSurfTriMeshByScrewing(m_Scene.GetDragGroup(), EgtGetLastSelectedObj(),
|
|
m_ptP1, vtAx, m_dPrev, m_dLast, EPS_STM_DRAG)
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessRuled() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
' posso partire solo se esiste un gruppo corrente
|
|
If GetCurrLayer() = GDB_ID.NULL Then
|
|
Return False
|
|
End If
|
|
' creo la superficie rigata (a partire da due contorni selezionati)
|
|
Dim nLastId As Integer = EgtGetLastSelectedObj()
|
|
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
|
|
EgtCreateSurfTriMeshRuled(GetCurrLayer(), nPrevId, nLastId, EPS_STM)
|
|
EgtDeselectAll()
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' reset stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessDelete() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
If m_nLast1 <> GDB_ID.NULL Then
|
|
EgtErase(m_nLast1)
|
|
If m_nLast1 = m_nCurrPart Then
|
|
ResetCurrPartLayer()
|
|
ElseIf m_nLast1 = m_nCurrLayer Then
|
|
SetCurrPartLayer(m_nCurrPart, EgtGetFirstGroupInGroup(m_nCurrPart))
|
|
End If
|
|
' reset
|
|
m_Scene.ResetStatus()
|
|
m_nStep = 0
|
|
SetModified()
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessChangeColor() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
' verifico ci sia qualcosa di selezionato
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
If nId = GDB_ID.NULL Then
|
|
Return False
|
|
End If
|
|
' lancio dialogo scelta colore
|
|
Dim ColDlg As New ColorDialog()
|
|
ColDlg.AnyColor = True
|
|
Dim colObj As Color3d
|
|
EgtGetCalcColor(nId, colObj)
|
|
ColDlg.Color = colObj.ToColor()
|
|
ColDlg.FullOpen = True
|
|
If ColDlg.ShowDialog() <> Windows.Forms.DialogResult.OK Then
|
|
Return False
|
|
End If
|
|
' assegno nuovo colore
|
|
colObj.FromColor(ColDlg.Color)
|
|
EgtSetColor(GDB_ID.SEL, colObj)
|
|
EgtDeselectAll()
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' reset stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessResetColor() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
' verifico ci sia qualcosa di selezionato
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
If nId = GDB_ID.NULL Then
|
|
Return False
|
|
End If
|
|
' reset colore
|
|
EgtResetColor(GDB_ID.SEL)
|
|
EgtDeselectAll()
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' reset stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessInvertCurveSurf() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
' lancio l'inversione delle curve/superfici
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
Select Case EgtGetType(nId)
|
|
Case GDB_TY.CRV_LINE, GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO
|
|
EgtInvertCurve(nId)
|
|
Case GDB_TY.SRF_MESH
|
|
EgtInvertSurface(nId)
|
|
End Select
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDeselectAll()
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' reset stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessExtendCurve() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' verifico condizioni e preparo per il drag
|
|
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_SPECIALDOUBLE
|
|
SetInputBoxDouble(m_dLast)
|
|
DragExtendCurve()
|
|
Case 1
|
|
' eseguo estensione sull'estremo più vicino al punto di selezione
|
|
Dim nId As Integer = EgtGetLastSelectedObj()
|
|
EgtTrimExtendCurveByLen(nId, m_dLast, m_ptP1.Loc(nId))
|
|
EgtDeselectAll()
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Function DragExtendCurve() As Boolean
|
|
If m_nStep = 1 Then
|
|
' devo sempre partire dalla curva originale
|
|
m_Scene.EraseDragGroup()
|
|
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())
|
|
EgtTrimExtendCurveByLen(nId, m_dLast + dAddLen, m_ptP1)
|
|
EgtDraw()
|
|
End If
|
|
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
|
|
Case 0
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a punto per BreakCurve
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("BREAK", "Insert Point on Curve", "", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 1
|
|
' eseguo spezzatura
|
|
Dim nId As Integer = EgtGetLastSelectedObj()
|
|
EgtSplitCurveAtPoint(nId, m_ptLast.Loc(nId))
|
|
EgtDeselectAll()
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessJoinCurve() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
' posso partire solo se esiste un gruppo corrente
|
|
If GetCurrLayer() = GDB_ID.NULL Then
|
|
Return False
|
|
End If
|
|
' creo vettore di entità selezionate
|
|
Dim nCrvNum As Integer = 0
|
|
Dim nCrvIds(EgtGetSelectedObjNbr() - 1) As Integer
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
nCrvIds(nCrvNum) = nId
|
|
nCrvNum = nCrvNum + 1
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' creo la curva composita (concatenando le curve selezionate)
|
|
EgtCreateCurveCompoByChain(GetCurrLayer(), nCrvNum, nCrvIds, New Point3d, True)
|
|
EgtDeselectAll()
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' reset stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessExplodeCurve() As Boolean
|
|
If m_nStep <> 0 Then
|
|
Return False
|
|
End If
|
|
' opero su tutti gli oggetti selezionati
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
' recupero il successivo, perchè il corrente verrà cancellato
|
|
Dim nNextId = EgtGetNextSelectedObj()
|
|
' eseguo esplosione
|
|
Select Case EgtGetType(nId)
|
|
Case GDB_TY.CRV_COMPO
|
|
' separo la curva composita nelle curve componenti
|
|
EgtSeparateCurveCompo(nId)
|
|
Case GDB_TY.CRV_BEZ
|
|
' approssimo la curva di Bezier con archi
|
|
EgtExplodeCurveBezier(nId, 10 * EPS_SMALL, True)
|
|
Case GDB_TY.EXT_TEXT
|
|
' esplodo il testo nei suoi contorni
|
|
EgtExplodeText(nId)
|
|
End Select
|
|
' passo al successivo
|
|
nId = nNextId
|
|
End While
|
|
EgtDeselectAll()
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' reset stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ProcessSetCurveThickness() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' verifico condizioni e preparo per il drag
|
|
If Not PrepareTransform() Then
|
|
Return False
|
|
End If
|
|
' imposto stato a impostazione spessore curva
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("CURVE THICKNESS", "Insert Thickness", "Extraction from CPlane", True)
|
|
m_nInpType = IBT.TY_DOUBLE
|
|
' recupero spessore dell'ultima entità selezionata
|
|
Dim dThick As Double
|
|
If EgtCurveThickness(EgtGetLastSelectedObj(), dThick) Then
|
|
SetInputBoxDouble(dThick)
|
|
End If
|
|
RaiseEvent SetInputBoxCheck(False)
|
|
Case 1
|
|
' eseguo impostazione spessore curve selezionate
|
|
Dim vtExtr = EgtGetGridVersZ()
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
If m_bLast Then
|
|
EgtModifyCurveExtrusion(nId, vtExtr.Loc(nId))
|
|
End If
|
|
EgtModifyCurveThickness(nId, m_dLast)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDeselectAll()
|
|
' reset stato scena
|
|
m_Scene.ResetStatus()
|
|
' aggiorno stato
|
|
m_nStep = 0
|
|
SetModified()
|
|
Case Else
|
|
m_nStep = 0
|
|
Return False
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub DragSetCurveThickness()
|
|
If m_nStep = 1 Then
|
|
' eseguo impostazione spessore curve selezionate
|
|
Dim vtExtr = EgtGetGridVersZ()
|
|
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
|
|
While nId <> GDB_ID.NULL
|
|
If m_bLast Then
|
|
EgtModifyCurveExtrusion(nId, vtExtr.Loc(nId))
|
|
Else
|
|
Dim nOrigId As Integer
|
|
Dim vtOrigExtr As Vector3d
|
|
If EgtGetInfo(nId, "Id", nOrigId) And EgtCurveExtrusion(nOrigId, vtOrigExtr) Then
|
|
EgtModifyCurveExtrusion(nId, vtOrigExtr.Glob(nOrigId))
|
|
End If
|
|
End If
|
|
EgtModifyCurveThickness(nId, m_dLast)
|
|
nId = EgtGetNext(nId)
|
|
End While
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessMove() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' verifico condizioni e preparo per il drag
|
|
If Not PrepareTransform() Then
|
|
Return False
|
|
End If
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a primo punto per Move
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("MOVE", "Insert Base Point", "Copy", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
RaiseEvent SetInputBoxCheck(False)
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_nStep = 2
|
|
m_Scene.EnableDrag()
|
|
RaiseEvent PrepareInputBox("MOVE", "Insert Target Point", "Copy", True)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 2
|
|
m_Scene.ResetStatus(False)
|
|
' eseguo copia e movimento
|
|
If m_bLast Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer())
|
|
EgtMoveGlob(nCopyId, (m_ptLast - m_ptP1))
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' eseguo movimento
|
|
Else
|
|
EgtMoveGlob(GDB_ID.SEL, (m_ptLast - m_ptP1))
|
|
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 DragMove()
|
|
If m_nStep = 2 Then
|
|
' ripristino lo stato iniziale
|
|
EgtChangeGroupFrame(m_Scene.GetDragGroup(), Frame3d.GLOB)
|
|
' eseguo tutto il movimento
|
|
EgtMoveGlob(m_Scene.GetDragGroup(), (m_ptLast - m_ptP1))
|
|
EgtSetGeoLine(m_ptP1, m_ptLast)
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessRotate() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' verifico condizioni e preparo per il drag
|
|
If Not PrepareTransform() Then
|
|
Return False
|
|
End If
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a primo punto per Rotate
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("ROTATE", "Insert Center", "Copy", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
RaiseEvent SetInputBoxCheck(False)
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_nStep = 2
|
|
m_Scene.EnableDrag()
|
|
RaiseEvent PrepareInputBox("ROTATE", "Insert Base Point", "Copy", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 2
|
|
m_ptP2 = m_ptLast
|
|
m_nStep = 3
|
|
m_Scene.EnableDrag()
|
|
EgtSetGeoLine(m_ptP1, m_ptLast)
|
|
RaiseEvent PrepareInputBox("ROTATE", "Insert Rotation Point", "Copy", True)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 3
|
|
m_Scene.ResetStatus(False)
|
|
' calcolo parametri di rotazione
|
|
Dim dAngRotDeg As Double = 0
|
|
Dim bDet As Boolean = True
|
|
EgtGetVectorRotation((m_ptP2 - m_ptP1), (m_ptLast - m_ptP1), EgtGetGridVersZ(), dAngRotDeg, bDet)
|
|
' eseguo copia e rotazione
|
|
If m_bLast Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer())
|
|
EgtRotateGlob(nCopyId, m_ptP1, EgtGetGridVersZ(), dAngRotDeg)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' eseguo rotazione
|
|
Else
|
|
EgtRotateGlob(GDB_ID.SEL, m_ptP1, EgtGetGridVersZ(), dAngRotDeg)
|
|
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 DragRotate()
|
|
If m_nStep = 2 Then
|
|
EgtSetGeoLine(m_ptP1, m_ptLast)
|
|
EgtDraw()
|
|
ElseIf m_nStep = 3 Then
|
|
EgtSetGeoLine(m_ptP1, m_ptLast)
|
|
' ripristino lo stato iniziale
|
|
EgtChangeGroupFrame(m_Scene.GetDragGroup(), Frame3d.GLOB)
|
|
' eseguo rotazione
|
|
Dim dAngRotDeg As Double = 0
|
|
Dim bDet As Boolean = True
|
|
EgtGetVectorRotation((m_ptP2 - m_ptP1), (m_ptLast - m_ptP1), EgtGetGridVersZ(), dAngRotDeg, bDet)
|
|
EgtRotateGlob(m_Scene.GetDragGroup(), m_ptP1, EgtGetGridVersZ(), dAngRotDeg)
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessRotate3D() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' verifico condizioni e preparo per il drag
|
|
If Not PrepareTransform() Then
|
|
Return False
|
|
End If
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a primo punto per Rotate3d
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("ROTATE 3D", "Insert First Point on Axis", "Copy", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
RaiseEvent SetInputBoxCheck(False)
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_ptP2 = m_ptP1
|
|
m_nStep = 2
|
|
m_Scene.EnableDrag()
|
|
RaiseEvent PrepareInputBox("ROTATE 3D", "Insert Second Point on Axis", "Copy", True)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 2
|
|
m_ptP2 = m_ptLast
|
|
m_nStep = 3
|
|
m_dLast = 0
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("ROTATE 3D", "Insert angle", "Copy", True)
|
|
m_nInpType = IBT.TY_DOUBLE
|
|
Case 3
|
|
m_Scene.ResetStatus(False)
|
|
' calcolo parametri di rotazione
|
|
Dim VtAx As Vector3d = m_ptP2 - m_ptP1
|
|
' eseguo copia e rotazione
|
|
If m_bLast Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer())
|
|
EgtRotateGlob(nCopyId, m_ptP1, VtAx, m_dLast)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' eseguo rotazione
|
|
Else
|
|
EgtRotateGlob(GDB_ID.SEL, m_ptP1, VtAx, m_dLast)
|
|
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 DragRotate3D()
|
|
If m_nStep = 2 Then
|
|
EgtSetGeoLine(m_ptP1, m_ptLast)
|
|
EgtDraw()
|
|
ElseIf m_nStep = 3 Then
|
|
EgtSetGeoLine(m_ptP1, m_ptP2)
|
|
' ripristino lo stato iniziale
|
|
EgtChangeGroupFrame(m_Scene.GetDragGroup(), Frame3d.GLOB)
|
|
' eseguo rotazione
|
|
Dim VtAx As Vector3d = m_ptP2 - m_ptP1
|
|
EgtRotateGlob(m_Scene.GetDragGroup(), m_ptP1, VtAx, m_dLast)
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessMirror() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' verifico condizioni e preparo per il drag
|
|
If Not PrepareTransform() Then
|
|
Return False
|
|
End If
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a primo punto per Mirror
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("MIRROR", "Insert Start Point", "Copy", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
RaiseEvent SetInputBoxCheck(False)
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_ptP2 = m_ptP1
|
|
m_nStep = 2
|
|
m_Scene.EnableDrag()
|
|
RaiseEvent PrepareInputBox("MIRROR", "Insert End Point", "Copy", True)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
Case 2
|
|
m_Scene.ResetStatus(False)
|
|
' esecuzione
|
|
Dim VtNorm As Vector3d = (m_ptLast - m_ptP1) ^ EgtGetGridVersZ()
|
|
If VtNorm.Len > EPS_SMALL Then
|
|
' eseguo copia e mirror
|
|
If m_bLast Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer())
|
|
EgtMirrorGlob(nCopyId, m_ptP1, VtNorm)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' eseguo rotazione
|
|
Else
|
|
EgtMirrorGlob(GDB_ID.SEL, m_ptP1, VtNorm)
|
|
End If
|
|
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 DragMirror()
|
|
If m_nStep = 2 Then
|
|
' linea di mirror
|
|
EgtSetGeoLine(m_ptP1, m_ptLast)
|
|
' ripristino lo stato iniziale, tramite annullo mirror precedente
|
|
Dim VtNorm As Vector3d = (m_ptP2 - m_ptP1) ^ EgtGetGridVersZ()
|
|
If VtNorm.Len > EPS_SMALL Then
|
|
EgtMirrorGlob(m_Scene.GetDragGroup(), m_ptP1, VtNorm)
|
|
End If
|
|
' eseguo mirror
|
|
VtNorm = (m_ptLast - m_ptP1) ^ EgtGetGridVersZ()
|
|
If VtNorm.Len > EPS_SMALL Then
|
|
EgtMirrorGlob(m_Scene.GetDragGroup(), m_ptP1, VtNorm)
|
|
End If
|
|
' salvo il punto
|
|
m_ptP2 = m_ptLast
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessScale() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' verifico condizioni e preparo per il drag
|
|
If Not PrepareTransform() Then
|
|
Return False
|
|
End If
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a primo punto per Rotate
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("SCALE", "Insert Center", "Copy", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
RaiseEvent SetInputBoxCheck(False)
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_dPrev = 1
|
|
m_dLast = 1
|
|
m_nStep = 2
|
|
RaiseEvent PrepareInputBox("SCALE", "Insert Factor", "Copy", True)
|
|
m_nInpType = IBT.TY_DOUBLE
|
|
SetInputBoxDouble(m_dLast)
|
|
Case 2
|
|
m_Scene.ResetStatus(False)
|
|
' calcolo parametri di scalatura
|
|
Dim frScale As New Frame3d
|
|
EgtGetGridFrame(frScale)
|
|
frScale.ChangeOrigin(m_ptP1)
|
|
' eseguo copia e scalatura
|
|
If m_bLast Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer())
|
|
EgtScaleGlob(nCopyId, frScale, m_dLast, m_dLast, m_dLast)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' eseguo scalatura
|
|
Else
|
|
EgtScaleGlob(GDB_ID.SEL, frScale, m_dLast, m_dLast, m_dLast)
|
|
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 DragScale()
|
|
If m_nStep = 2 Then
|
|
' il fattore non può essere troppo piccolo o negativo
|
|
If m_dLast < EPS_SMALL Then
|
|
Return
|
|
End If
|
|
' calcolo parametri di scalatura
|
|
Dim frScale As New Frame3d
|
|
EgtGetGridFrame(frScale)
|
|
frScale.ChangeOrigin(m_ptP1)
|
|
Dim dScale As Double = m_dLast / m_dPrev
|
|
' eseguo scalatura
|
|
EgtScaleGlob(m_Scene.GetDragGroup(), frScale, dScale, dScale, dScale)
|
|
m_dPrev = m_dLast
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ProcessScale3D() As Boolean
|
|
Select Case m_nStep
|
|
Case 0
|
|
' verifico condizioni e preparo per il drag
|
|
If Not PrepareTransform() Then
|
|
Return False
|
|
End If
|
|
m_Scene.SetStatusSelPoint()
|
|
' imposto stato a primo punto per Rotate
|
|
m_nStep = 1
|
|
' abilito dialogo
|
|
RaiseEvent PrepareInputBox("SCALE 3D", "Insert Center", "Copy", False)
|
|
m_nInpType = IBT.TY_POINT3D
|
|
RaiseEvent SetInputBoxCheck(False)
|
|
Case 1
|
|
m_ptP1 = m_ptLast
|
|
m_d3Prev(0) = 1
|
|
m_d3Prev(1) = 1
|
|
m_d3Prev(2) = 1
|
|
m_d3Last(0) = 1
|
|
m_d3Last(1) = 1
|
|
m_d3Last(2) = 1
|
|
m_nStep = 2
|
|
m_Scene.DisableDrag()
|
|
RaiseEvent PrepareInputBox("SCALE 3D", "Insert Factor", "Copy", True)
|
|
m_nInpType = IBT.TY_3DOUBLE
|
|
SetInputBox3Double(m_d3Last)
|
|
Case 2
|
|
m_Scene.ResetStatus(False)
|
|
' calcolo parametri di scalatura
|
|
Dim frScale As New Frame3d
|
|
EgtGetGridFrame(frScale)
|
|
frScale.ChangeOrigin(m_ptP1)
|
|
' eseguo copia e scalatura
|
|
If m_bLast Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
Dim nCopyId As Integer = EgtCopyGlob(nId, GetCurrLayer())
|
|
EgtScaleGlob(nCopyId, frScale, m_d3Last(0), m_d3Last(1), m_d3Last(2))
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' eseguo scalatura
|
|
Else
|
|
EgtScaleGlob(GDB_ID.SEL, frScale, m_d3Last(0), m_d3Last(1), m_d3Last(2))
|
|
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 DragScale3D()
|
|
If m_nStep = 2 Then
|
|
' nessun coefficiente può essere negativo e non possono essere tutti e tre nulli
|
|
If m_d3Last(0) < 0 Or m_d3Last(1) < 0 Or m_d3Last(2) < 0 Or
|
|
(m_d3Last(0) < EPS_SMALL And m_d3Last(1) < EPS_SMALL And m_d3Last(2) < EPS_SMALL) Then
|
|
Return
|
|
End If
|
|
' se uno dei tre precedenti coefficienti era nullo, devo ricreare il gruppo di drag
|
|
If m_d3Prev(0) < EPS_SMALL Or m_d3Prev(1) < EPS_SMALL Or m_d3Prev(2) < EPS_SMALL Then
|
|
m_Scene.EraseDragGroup()
|
|
PrepareTransform()
|
|
m_d3Prev(0) = 1
|
|
m_d3Prev(1) = 1
|
|
m_d3Prev(2) = 1
|
|
End If
|
|
' calcolo parametri di scalatura
|
|
Dim frScale As New Frame3d
|
|
EgtGetGridFrame(frScale)
|
|
frScale.ChangeOrigin(m_ptP1)
|
|
Dim d3Scale(3) As Double
|
|
d3Scale(0) = m_d3Last(0) / m_d3Prev(0)
|
|
d3Scale(1) = m_d3Last(1) / m_d3Prev(1)
|
|
d3Scale(2) = m_d3Last(2) / m_d3Prev(2)
|
|
' eseguo scalatura
|
|
EgtScaleGlob(m_Scene.GetDragGroup(), frScale, d3Scale(0), d3Scale(1), d3Scale(2))
|
|
m_d3Prev(0) = m_d3Last(0)
|
|
m_d3Prev(1) = m_d3Last(1)
|
|
m_d3Prev(2) = m_d3Last(2)
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
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(bDragSelectable) Then
|
|
Return False
|
|
End If
|
|
' se devo prendere tutti
|
|
If bAllSelected Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
If Not m_Scene.AddToDragGroup(nId) Then
|
|
m_Scene.EraseDragGroup()
|
|
Return False
|
|
End If
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' altrimenti solo l'ultimo
|
|
Else
|
|
Dim nId As Integer = EgtGetLastSelectedObj()
|
|
If nId = GDB_ID.NULL And Not m_Scene.AddToDragGroup(nId) Then
|
|
m_Scene.EraseDragGroup()
|
|
Return False
|
|
End If
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Private Function GridLenFromGlobLen(ByVal vtLen As Vector3d) As Double
|
|
Dim frGrid As New Frame3d
|
|
EgtGetGridFrame(frGrid)
|
|
vtLen.ToLoc(frGrid)
|
|
Return Math.Sqrt(vtLen.x * vtLen.x + vtLen.y * vtLen.y)
|
|
End Function
|
|
|
|
Private Function GridAngFromGlobDir(ByVal vtDir As Vector3d) As Double
|
|
Dim frGrid As New Frame3d
|
|
EgtGetGridFrame(frGrid)
|
|
vtDir.ToLoc(frGrid)
|
|
Dim dLen As Double
|
|
Dim dAngVertDeg As Double
|
|
Dim dAngOrizzDeg As Double
|
|
vtDir.ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg)
|
|
Return dAngOrizzDeg
|
|
End Function
|
|
|
|
Private Function GlobDirFromGridAng(ByVal dGridAngDeg As Double) As Vector3d
|
|
Dim frGrid As New Frame3d
|
|
EgtGetGridFrame(frGrid)
|
|
Dim vtDir As Vector3d = Vector3d.X_AX()
|
|
vtDir.Rotate(Vector3d.Z_AX, dGridAngDeg)
|
|
vtDir.ToGlob(frGrid)
|
|
Return vtDir
|
|
End Function
|
|
|
|
'-------------------------------- Currente Part and Layer ----------------------------------------
|
|
Private m_nCurrPart = GDB_ID.NULL
|
|
Private m_nCurrLayer = GDB_ID.NULL
|
|
|
|
Public Function GetCurrPart() As Integer
|
|
Return m_nCurrPart
|
|
End Function
|
|
|
|
Public Function GetCurrLayer() As Integer
|
|
Return m_nCurrLayer
|
|
End Function
|
|
|
|
Private Function SetCurrPartLayer(ByVal nPart As Integer, ByVal nLayer As Integer) As Boolean
|
|
' reset
|
|
m_nCurrPart = GDB_ID.NULL
|
|
m_nCurrLayer = GDB_ID.NULL
|
|
' verifico esistenza e validità pezzo
|
|
If EgtExistsObj(nPart) And EgtGetParent(nPart) = GDB_ID.ROOT Then
|
|
m_nCurrPart = nPart
|
|
Else
|
|
Return False
|
|
End If
|
|
' verifico esistenza e validità layer
|
|
If EgtExistsObj(nLayer) And EgtGetParent(nLayer) = nPart Then
|
|
m_nCurrLayer = nLayer
|
|
Else
|
|
Return False
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ResetCurrPartLayer() As Boolean
|
|
' reset
|
|
m_nCurrPart = GDB_ID.NULL
|
|
m_nCurrLayer = GDB_ID.NULL
|
|
' cerco il primo pezzo
|
|
Dim nIdPart As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT)
|
|
If nIdPart <> GDB_ID.NULL Then
|
|
' assegno il pezzo corrente
|
|
m_nCurrPart = nIdPart
|
|
' cerco il primo layer del pezzo
|
|
Dim nIdLayer As Integer = EgtGetFirstGroupInGroup(m_nCurrPart)
|
|
If nIdLayer <> GDB_ID.NULL Then
|
|
' assegno il layer corrente
|
|
m_nCurrLayer = nIdLayer
|
|
End If
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
|
|
'-------------------------------- Modified Status ------------------------------------------------
|
|
Private m_sCurrFile As String = String.Empty
|
|
Private m_bModified As Boolean = False
|
|
|
|
Public Sub SetCurrFile(ByRef sFile As String)
|
|
m_sCurrFile = sFile
|
|
End Sub
|
|
|
|
Public Sub ResetCurrFile()
|
|
m_sCurrFile = String.Empty
|
|
End Sub
|
|
|
|
Public Function GetCurrFile() As String
|
|
Return m_sCurrFile
|
|
End Function
|
|
|
|
Public Sub SetModified(Optional ByVal bReloadUI As Boolean = True)
|
|
m_bModified = True
|
|
RaiseEvent UpdateUI(Me, bReloadUI)
|
|
End Sub
|
|
|
|
Public Sub ResetModified(Optional ByVal bReloadUI As Boolean = True)
|
|
m_bModified = False
|
|
RaiseEvent UpdateUI(Me, bReloadUI)
|
|
End Sub
|
|
|
|
Public Function GetModified() As Boolean
|
|
Return m_bModified
|
|
End Function
|
|
|
|
Public Function ManageModified() As Boolean
|
|
' se non modificato, procedo normalmente
|
|
If Not m_bModified Then
|
|
Return True
|
|
End If
|
|
' chiedo cosa fare
|
|
Dim sMsg As String = "Salvare le modifiche"
|
|
If Not String.IsNullOrEmpty(m_sCurrFile) Then
|
|
sMsg += " a " + m_sCurrFile
|
|
End If
|
|
sMsg += " ?"
|
|
Dim nRes = MessageBox.Show(sMsg, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
|
|
Select Case nRes
|
|
Case Windows.Forms.DialogResult.Yes
|
|
m_Scene.SaveProject(m_sCurrFile)
|
|
Return True
|
|
Case Windows.Forms.DialogResult.No
|
|
Return True
|
|
Case Else
|
|
Return False
|
|
End Select
|
|
End Function
|
|
|
|
End Class
|