Files
EgtUILib/Controller.vb
Daniele Bariletti 32a4faf865 EgtUILib :
- aggiunta operazione per taglio di surfTm con curva chiusa.
2026-03-11 13:02:10 +01:00

8429 lines
320 KiB
VB.net

'----------------------------------------------------------------------------
' EgalTech 2014-2015
'----------------------------------------------------------------------------
' File : Controller.vb Data : 27.01.15 Versione : 1.6a6
' Contenuto : Classe Controller (parte di MVC).
'
'
'
' Modifiche : 04.11.14 DS Creazione modulo.
'
'
'----------------------------------------------------------------------------
Imports Microsoft.VisualBasic
Imports System.Globalization
Imports EgtUILib.EgtInterface
Imports System.Text
Imports System.IO
Public Class Controller
' Events
Public Event OnNewProject(sender As Object, bOk As Boolean)
Public Event OnOpeningProject(sender As Object)
Public Event OnOpenProject(sender As Object, sFile As String, bOk As Boolean)
Public Event OnInsertingProject(sender As Object, nType As Integer, ByRef nFlag As Integer)
Public Event OnInsertedProject(sender As Object, sFile As String, bOk As Boolean)
Public Event OnSavingProject(sender As Object, sFile As String)
Public Event OnSavedProject(sender As Object, sFile As String, bOk As Boolean)
Public Event OnSavingObject(sender As Object, sFile As String)
Public Event OnSavedObject(sender As Object, sFile As String, bOk As Boolean)
Public Event OnImportingProject(sender As Object, nType As Integer, ByRef nFlag As Integer)
Public Event OnImportedProject(sender As Object, sFile As String, bOk As Boolean)
Public Event OnExportingProject(sender As Object)
Public Event OnExportedProject(sender As Object, sFile As String, bOk As Boolean)
Public Event OnExecutingScript(sender As Object)
Public Event OnExecutedScript(sender As Object, sFile As String,
bOk As Boolean, sError As String)
Public Event PrepareInputBox(sTitle As String, sLabel As String, sCheckLabel As String,
bShowCombo As Boolean, bShowBtn As Boolean)
Public Event SetInputBoxText(sText As String)
Public Event SetInputBoxCheck(bCheck As Boolean)
Public Event AddInputBoxCombo(sText As String, bSelected As Boolean)
Public Event UpdateUI(sender As Object, bReloadUI As Boolean)
Public Event OutputInfo(sender As Object, sText As String)
Public Event OnExecCmdEnd(command As CMD)
' 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
EXECLINE
GRID
GRID_ELEVATION
GRID_ORIGIN
GRID_ROTATE
GRID_ROTATE3D
GRID_3P
GRID_PERPCURVE
GRID_OBJ
NEWPART
NEWLAYER
SETCURRPARTLAYER
RESETCURRPARTLAYER
LAYERCOLOR
SELECTPARTLAYEROBJ
DESELECTPARTLAYEROBJ
RELOCATEPARTLAYEROBJ
COPYPARTLAYEROBJ
SHOW
HIDE
SETNAME
SETINFO
POINT
VECTOR
FRAME
LINE2P
LINEPDL
LINEPVL
CIRCLECP
CIRCLECD
ARCCSE
ARC3P
ARCPDP
ARCPVP
FILLET
CHAMFER
RECTANGLE2P
POLYGON
POLYGONSIDE
TEXT
TEXTPLUS
REGION
PLANE
EXTRUDE
REVOLVE
SCREW
SWEPT
RULED
MERGESURF
EXPLODESURF
INVERTSURF
DELETE
CHANGELAYER
CHANGELAYERGLOB
CHANGECOLOR
RESETCOLOR
CHANGEALPHA
INVERTCURVE
CHANGESTARTCURVE
TRIMEXTENDCURVE
BREAKCURVE
SPLITCURVE
JOINCURVE
EXPLODECURVE
SETCURVETHICKNESS
MOVE
ROTATE
ROTATE3D
MIRROR
MIRROR3D
SCALE
SCALE3D
OFFSET
SELECTGROUP
MODIFYTEXT
EXTRACTSURFLOOPS
EXTRACTSURFFACETLOOPS
SOLIDADDSURF
SOLIDSUBTRACTSURF
SOLIDINTERSECTSURF
INTERSECTSURFSURF
LINEARDIMENSION
ALIGNEDDIMENSION
EXTRACTSURFFACET
CUTSURFSURF
INVCUTSURFSURF
MERGECURVESINCOMPO
CIRCLE3P
MODIFYCURVE
ADDPOINTCURVE
REMOVEPOINTCURVE
ARCFLIP
ARCEXPLEMENTARY
CURVETOARC
CURVETOLINE
CLOSECOMPO
OPENCOMPO
APPROXCURVE
APPROXCURVEWITHLINES
MODIFYARCRADIUS
SURFTMTOTRIANGLES
APPROXSURF
MOVESURFVERTEX
MOVESURFFACET
ANGULARDIMENSION
ANGULARDIMENSIONPLUS
DIAMETRALDIMENSION
RADIALDIMENSION
CHANGESTATUS
ARC2PR
GRID_INVERT
BIARC
CURVEBEZIER
TRIMSURFTMWITHCURVE
End Enum
Public Enum GRID_TYPE As Integer
NONE = 0
TOP
FRONT
RIGHT
BACK
LEFT
BOTTOM
VIEW
End Enum
Private m_nLastCmd As CMD = CMD.NULL
Private m_bLastContinue As Boolean = False
Private m_nStep As Integer = 0
Private m_bContinue As Boolean = False
Private m_nContinueId As Integer = GDB_ID.NULL
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_ptP3 As Point3d
Private m_ptV As Point3d
Private m_ptW As Point3d
Private m_ptLast As Point3d
Private m_sepLast As SEP
Private m_vtLast As Vector3d = Vector3d.X_AX()
Private m_nIdLast As Integer = GDB_ID.NULL
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_nLast As Integer = 0
Private m_sLast As String = String.Empty
Private m_bLast As Boolean = False
Private m_bPnt3dVsDbl As Boolean = False
Private m_ptCont As Point3d ' punto finale di entità precedente (per continuazione)
Private m_vtCont As Vector3d = Vector3d.X_AX() ' direzione finale di entità precedente (per continuazione)
Private m_dLastLen As Double = If(EgtUiUnitsAreMM(), 100, 101.6) ' ultima lunghezza per linea
Private m_dLastDiam As Double = If(EgtUiUnitsAreMM(), 20, 25.4) ' ultimo diametro per circonferenza
Private m_dLastFillet As Double = If(EgtUiUnitsAreMM(), 10, 12.7) ' ultimo raggio per fillet
Private m_dLastChamfer As Double = If(EgtUiUnitsAreMM(), 10, 12.7) ' ultima lunghezza per smusso
Private m_dLastTextH As Double = If(EgtUiUnitsAreMM(), 10, 12.7) ' ultima altezza per testo
Private m_bLastCapEndsCheck As Boolean = False ' ultimo valore di check cap in estrusione e swept
Private m_dLastExtrude As Double = If(EgtUiUnitsAreMM(), 20, 25.4) ' ultimo valore di estrusione per superficie
Private m_dLastExtend As Double = If(EgtUiUnitsAreMM(), 50, 50.8) ' ultimo valore di allungamento
Private m_bLastRuledCheck As Boolean = False ' ultimo valore di check mindist in ruled
Private m_bLastBooleanCheck As Boolean = False ' ultimo valore di check cancella originali in booleane
Private m_bLastTransfCheck As Boolean = False ' ultimo valore di check copia nelle trasformazioni
Private m_bLastAcceptOnCheck As Boolean = False ' ultimo valore di check accetta coincidenti nei tagli
Private m_bLastOffsetCheck As Boolean = True ' ultimo valore di check copia in offset
Private m_dLastOffset As Double = If(EgtUiUnitsAreMM(), 10, 12.7) ' ultimo valore di offset
Private m_nLinDimType As Integer = LINDIM_TYPE.NONE ' tipo quotatura lineare
Private m_bModifyCurveByMove As Boolean = False ' modifica curva semplice di composita per traslazione
' Tolleranza di disegno delle geometrie (curve, superfici,...)
Private m_dStmEps As Double = EPS_STM
Public Sub SetSurfTmTolerance(dStmEps As Double)
m_dStmEps = Math.Max(dStmEps, EPS_SMALL)
End Sub
' Input
Private Enum IBT As Integer
TY_NULL = 0
TY_STRING
TY_INTEGER
TY_DOUBLE
TY_DIRECTION
TY_LENGTH
TY_SPECIALDOUBLE
TY_2DOUBLE
TY_3DOUBLE
TY_POINT3D
TY_VECTOR3D
TY_DOUBLE_OR_POINT3d
End Enum
Private m_nInpType As IBT = IBT.TY_NULL
' Import
Private m_dDxfScale As Double = 1
Private m_dStlScale As Double = 1
Private m_dOffScale As Double = 1
Private m_dPlyScale As Double = 1
Private m_dImgScale As Double = 1
Private m_dAdvImpEps As Double = EPS_STM
Public Sub SetAdvImpTolerance(dAdvImpEps As Double)
m_dAdvImpEps = Math.Max(dAdvImpEps, EPS_SMALL)
End Sub
' Export
Private m_nExportFilter As Integer = EEX_FLT.DEFAULT
Private m_nExportDxfFlag As Integer = EEX_FL.COMP_LAYER
Private m_nImgWidth As Integer = 400
Private m_nImgHeight As Integer = 300
' Costanti
Private LEN_STD As Double = 100
Private EXTEND_ADD As Double = 10
Private EXTEND_BIG_ADD As Double = 200
' Metodi
Public Function NewProject(Optional bCreatePart As Boolean = False) As Boolean
' gestisco eventuale file corrente modificato
If Not ManageModified() Then Return False
' reset controller e scena
ResetStatus(False)
' eseguo
Cursor.Current = Cursors.WaitCursor
EnableCommandLog()
Dim bOk As Boolean = EgtNewFile()
If bOk And bCreatePart Then
' 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, aggiorno pezzo e layer correnti
If nIdNewPart <> GDB_ID.NULL And nIdNewLayer <> GDB_ID.NULL Then
EgtSetCurrPartLayer(nIdNewPart, nIdNewLayer)
End If
' reset flag di modificato
EgtResetModified()
End If
DisableCommandLog()
' Gestione risultato
RaiseEvent OnNewProject(Me, bOk)
' Aggiornamento
RaiseEvent UpdateUI(Me, True)
Cursor.Current = Cursors.Default
Return bOk
End Function
Public Function OpenProject(Optional sDir As String = "", Optional bWithDlg As Boolean = True) As Boolean
' gestisco eventuale file corrente modificato
If Not ManageModified() Then Return False
' reset controller e scena
ResetStatus(False)
' eseguo
Dim sFile As String = sDir
' Scelta file con dialogo
If bWithDlg Then
Dim OpenFileDialog As New OpenFileDialog With {
.Title = "Open",
.Filter = "New geometry EgalTech(*.nge)|*.nge" &
"|New font EgalTech(*.nfe)|*.nfe" &
"|All Files (*.*)|*.*",
.FilterIndex = 1,
.InitialDirectory = sDir
}
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
Return True
End If
sFile = OpenFileDialog.FileName
End If
' Prima del caricamento
RaiseEvent OnOpeningProject(Me)
' Caricamento del progetto
Cursor.Current = Cursors.WaitCursor
EnableCommandLog()
Dim bOk As Boolean = EgtOpenFile(sFile)
DisableCommandLog()
' Gestione risultato
RaiseEvent OnOpenProject(Me, sFile, bOk)
' Aggiornamento
RaiseEvent UpdateUI(Me, True)
Cursor.Current = Cursors.Default
Return bOk
End Function
Public Function InsertProject(Optional sDir As String = "", Optional bWithDlg As Boolean = True) As Boolean
Dim sFile As String = sDir
' Reset controller e scena
ResetStatus(False)
' Scelta file con dialogo
If bWithDlg Then
Dim OpenFileDialog As New OpenFileDialog With {
.Title = "Insert",
.Filter = "New geometry EgalTech(*.nge)|*.nge" &
"|Drawing Exchange Fmt(*.dxf)|*.dxf" &
"|Stereolithography (*.stl)|*.stl" &
"|Object file format (*.off)|*.off" &
"|Polygon file format (*.ply)|*.ply" &
"|3D Manufacturing format (*.3mf)|*.3mf" &
"|Rhino format (*.3dm)|*.3dm" &
"|Images (*.png;*.jpg;*.jpeg;*.bmp)|*.png;*.jpg;*.jpeg;*.bmp" &
"|New font EgalTech(*.nfe)|*.nfe" &
"|All Files (*.*)|*.*",
.FilterIndex = 1,
.InitialDirectory = sDir
}
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
Return True
End If
sFile = OpenFileDialog.FileName
End If
' Prima del caricamento
Dim nFileType As Integer = EgtGetFileType(sFile)
Dim nFlag As Integer = 0
RaiseEvent OnInsertingProject(Me, nFileType, nFlag)
'Inserimento del progetto
Dim bOk As Boolean = False
Cursor.Current = Cursors.WaitCursor
EnableCommandLog()
Select Case nFileType
Case FT.DXF
bOk = EgtImportDxf(sFile, m_dDxfScale)
Case FT.STL
bOk = EgtImportStl(sFile, m_dStlScale)
Case FT.OFF
bOk = EgtImportOff(sFile, m_dOffScale)
Case FT.PLY
bOk = EgtImportPly(sFile, m_dPlyScale)
Case FT.IMG
bOk = ImportPicture(sFile, m_dImgScale)
Case FT._3MF
bOk = EgtImport3MF(sFile)
Case FT._3DM
bOk = EgtImport3dm(sFile)
Case FT.OBJ, FT.IGES, FT.STEP_, FT.ACIS, FT.PARASOLID, FT.JT, FT.VRML, FT.C3D
If EgtAdvancedImportIsEnabled() Then bOk = EgtAdvancedImport(sFile, m_dAdvImpEps, nFlag)
Case Else
bOk = EgtInsertFile(sFile)
End Select
If GetCurrLayer() = GDB_ID.NULL Then EgtResetCurrPartLayer()
DisableCommandLog()
' Gestione risultato
RaiseEvent OnInsertedProject(Me, sFile, bOk)
' Aggiornamento
RaiseEvent UpdateUI(Me, True)
Cursor.Current = Cursors.Default
Return bOk
End Function
Public Function SaveProject(Optional nType As NGE = NGE.CMPTEXT) As Boolean
Dim sCurrFile As String = GetCurrFile()
If String.IsNullOrWhiteSpace(sCurrFile) Or EgtGetFileType(sCurrFile) <> FT.NGE Then
Return SaveAsProject(sCurrFile, nType)
Else
' Reset controller e scena
ResetStatus(False)
' Prima del salvataggio
RaiseEvent OnSavingProject(Me, sCurrFile)
' Salvataggio del progetto
Cursor.Current = Cursors.WaitCursor
EnableCommandLog()
Dim bOk As Boolean = EgtSaveFile(sCurrFile, nType)
DisableCommandLog()
' Aggiorno
RaiseEvent UpdateUI(Me, False)
Cursor.Current = Cursors.Default
' Gestione risultato
RaiseEvent OnSavedProject(Me, sCurrFile, bOk)
Return bOk
End If
End Function
Public Function SaveAsProject(Optional sFile As String = "", Optional nType As NGE = NGE.CMPTEXT) As Boolean
' Reset controller e scena
ResetStatus(False)
' Se nome vuoto o parziale, sistemo opportunamente
if String.IsNullOrWhiteSpace( sFile) Then
sFile = "New.nge"
Else
Dim sName As String = IO.Path.GetFileNameWithoutExtension( sFile)
If String.IsNullOrWhiteSpace(sName) Then
Dim sDir As String = IO.Path.GetDirectoryName( sFile)
if String.IsNullOrWhiteSpace(sDir) Then
sFile = "New.nge"
Else
sFile = IO.Path.Combine( sDir, "New.nge")
End If
Else
sFile = IO.Path.ChangeExtension(sFile, "nge")
End If
End If
' Assegnazione nome file con dialogo
Dim SaveFileDialog As New SaveFileDialog With {
.Title = "Save",
.Filter = "New geometry EgalTech(*.nge)|*.nge",
.FileName = sFile,
.InitialDirectory = IO.Path.GetDirectoryName(sFile)
}
If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then Return True
Dim sFileName As String = SaveFileDialog.FileName
' Prima del salvataggio
RaiseEvent OnSavingProject(Me, sFileName)
' Salvataggio del progetto
Cursor.Current = Cursors.WaitCursor
EnableCommandLog()
Dim bOk As Boolean = EgtSaveFile(sFileName, nType)
DisableCommandLog()
' Aggiorno
RaiseEvent UpdateUI(Me, False)
Cursor.Current = Cursors.Default
' Gestione risultato
RaiseEvent OnSavedProject(Me, sFileName, bOk)
Return bOk
End Function
Public Function SaveObject(nId As Integer, Optional sDir As String = "", Optional nType As NGE = NGE.CMPTEXT) As Boolean
' Reset controller e scena
ResetStatus(False)
' Creo nome di default
Dim sName As String = String.Empty
If Not EgtGetName(nId, sName) Then
Dim nObjType As Integer = EgtGetType(nId)
If nObjType = GDB_TY.GROUP Then
If EgtIsPart(nId) Then
sName = "Part" & nId.ToString()
ElseIf EgtIsLayer(nId) Then
sName = "Layer" & nId.ToString()
Else
sName = "Group" & nId.ToString()
End If
ElseIf nObjType <> GDB_TY.NONE Then
Dim sTitle As String = String.Empty
EgtGetTitle(nId, sTitle)
sName = sTitle & nId.ToString()
Else
sName = "Unknown" & nId.ToString()
End If
End If
' Sistemo path
Dim sFile As String
If String.IsNullOrWhiteSpace(sDir) Then
sFile = sName
Else
sFile = sDir.TrimEnd("\") & "\" & sName
End If
' Assegnazione nome file con dialogo
Dim SaveFileDialog As New SaveFileDialog With {
.Title = "Save Object",
.Filter = "New geometry EgalTech(*.nge)|*.nge",
.FileName = sFile,
.InitialDirectory = sDir.TrimEnd("\")
}
If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
Return True
End If
Dim sFileName As String = SaveFileDialog.FileName
' Prima del salvataggio
RaiseEvent OnSavingObject(Me, sFileName)
' Salvataggio dell'oggetto con la sua ascendenza
Cursor.Current = Cursors.WaitCursor
EnableCommandLog()
Dim bOk As Boolean = EgtSaveObjToFile(nId, sFileName, nType)
DisableCommandLog()
' Aggiorno
RaiseEvent UpdateUI(Me, False)
Cursor.Current = Cursors.Default
' Gestione risultato
RaiseEvent OnSavedObject(Me, sFileName, bOk)
Return bOk
End Function
Public Function ImportProject(Optional sDir As String = "", Optional bWithDlg As Boolean = True) As Boolean
' Gestisco eventuale file corrente modificato
If Not ManageModified() Then Return False
' Reset controller e scena
ResetStatus(False)
' Eseguo
Dim sFile As String = sDir
' Scelta file con dialogo
If bWithDlg Then
Dim sOptionalExts As String = ""
Dim sOptStrictExts As String = ""
Dim nOptionalExts As Integer = 0
If EgtAdvancedImportIsEnabled() Then
sOptionalExts = "|Iges files (*.igs;*.iges)|*.igs;*.iges" &
"|Step files (*.stp;*.step)|*.stp;*.step" &
"|ACIS files (*.sat)|*.sat" &
"|Parasolid files (*.x_t;*.x_b)|*.x_t;*.x_b" &
"|JT files (*.jt)|*.jt" &
"|OBJ (*.obj)|*.obj" &
"|VRML files (*.wrl;*.wrz)|*.vrl;*.wrz"
sOptStrictExts = ";*.igs;*.iges;*.stp;*.step;*.sat;*.x_t;*.x_b;*.jt;*.obj;*.wrl;*.wrz"
nOptionalExts = 7
End If
Dim OpenFileDialog As New OpenFileDialog With {
.Title = "Import",
.Filter = "AutoCAD drawing exchange (*.dxf)|*.dxf" &
"|Stereolithography (*.stl)|*.stl" &
"|Object file format (*.off)|*.off" &
"|Polygon file format (*.ply)|*.ply" &
"|3D Manufacturing format (*.3mf)|*.3mf" &
"|Rhino format (*.3dm)|*.3dm" &
"|Building parts (*.btl;*.btlx)|*.btl;*.btlx" &
"|G-code files (*.cnc;*.xpi;*.mpf;*.iso;*.eia)|*.cnc;*.xpi;*.mpf;*.iso;*.eia" &
"|Points (*.pnt;*.xyz)|*.pnt;*.xyz" &
"|Images (*.png;*.jpg;*.jpeg;*.bmp)|*.png;*.jpg;*.jpeg;*.bmp" &
"|Cms drawings (*.hed;*.ent;*.ens)|*.hed;*.ent;*.ens" &
sOptionalExts &
"|Imported Files (*.*)|" &
"*.dxf;*.stl;*.off;*.ply;*.3mf;*.3dm;*.btl;*.btlx;*.cnc;*.xpi;*.mpf;*.iso;*.eia;*.pnt;*.xyz;*.png;*.jpg;*.jpeg;*.bmp;*.hed;*.ent;*.ens" &
sOptStrictExts &
"|All Files (*.*)|*.*",
.FilterIndex = 12 + nOptionalExts,
.InitialDirectory = sDir
}
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
Return True
End If
sFile = OpenFileDialog.FileName
End If
' Riconoscimento tipo file
Dim nFileType As Integer = EgtGetFileType(sFile)
Dim bOkType = (nFileType = FT.BTL Or nFileType = FT.BTLX Or nFileType = FT.CNC Or
nFileType = FT.CSF Or nFileType = FT.DXF Or nFileType = FT.IMG Or
nFileType = FT.PNT Or nFileType = FT.STL Or nFileType = FT.OFF Or
nFileType = FT.PLY Or nFileType = FT._3MF Or nFileType = FT._3DM Or
nFileType = FT.OBJ Or nFileType = FT.IGES Or
nFileType = FT.STEP_ Or nFileType = FT.ACIS Or nFileType = FT.PARASOLID Or
nFileType = FT.JT Or nFileType = FT.VRML Or nFileType = FT.C3D)
If Not bOkType Then nFileType = FT.NULL
' Prima del caricamento
Dim nFlag As Integer = 0
RaiseEvent OnImportingProject(Me, nFileType, nFlag)
If Not bOkType Then Return False
' Pulizia GeomDB
Cursor.Current = Cursors.WaitCursor
' Importazione
EnableCommandLog()
Dim bOk As Boolean = EgtNewFile()
Select Case nFileType
Case FT.BTL
bOk = bOk AndAlso EgtImportBtl(sFile, nFlag)
Case FT.BTLX
bOk = bOk AndAlso EgtImportBtlx(sFile, nFlag)
Case FT.CNC
bOk = bOk AndAlso EgtImportCnc(sFile, nFlag)
Case FT.CSF
bOk = bOk AndAlso EgtImportCsf(sFile)
Case FT.DXF
bOk = bOk AndAlso EgtImportDxf(sFile, m_dDxfScale)
Case FT.IMG
bOk = bOk AndAlso ImportPicture(sFile, m_dImgScale)
Case FT.PNT
bOk = bOk AndAlso EgtImportPnt(sFile, nFlag)
Case FT.STL
bOk = bOk AndAlso EgtImportStl(sFile, m_dStlScale)
Case FT.OFF
bOk = bOk AndAlso EgtImportOff(sFile, m_dOffScale)
Case FT.PLY
bOk = bOk AndAlso EgtImportPly(sFile, m_dPlyScale)
Case FT._3MF
bOk = bOk AndAlso EgtImport3MF(sFile, nFlag)
Case FT._3DM
bOk = bOk AndAlso EgtImport3dm(sFile)
Case FT.OBJ, FT.IGES, FT.STEP_, FT.ACIS, FT.PARASOLID, FT.JT, FT.VRML, FT.C3D
bOk = bOk AndAlso EgtAdvancedImport(sFile, m_dAdvImpEps, nFlag)
End Select
EgtResetCurrPartLayer()
DisableCommandLog()
' Gestione risultato
RaiseEvent OnImportedProject(Me, sFile, bOk)
' Aggiornamento
RaiseEvent UpdateUI(Me, True)
Cursor.Current = Cursors.Default
Return bOk
End Function
Public Sub SetScaleForDxfImport(dScale As Double)
m_dDxfScale = dScale
End Sub
Public Sub SetScaleForStlImport(dScale As Double)
m_dStlScale = dScale
End Sub
Public Sub SetScaleForOffImport(dScale As Double)
m_dOffScale = dScale
End Sub
Public Sub SetScaleForPlyImport(dScale As Double)
m_dPlyScale = dScale
End Sub
Public Sub SetScaleForImageImport(dScale As Double)
m_dImgScale = dScale
End Sub
Private Function ImportPicture(sFile As String, dScaleFactor As Double) As Boolean
' Creo pezzo e layer
Dim nLayId As Integer = EgtCreateGroup(EgtCreateGroup(GDB_ID.ROOT))
If nLayId = GDB_ID.NULL Then Return False
' Recupero dimensioni immagine
Dim nPixelX, nPixelY As Integer
If Not EgtGetImagePixels(sFile, nPixelX, nPixelY) Then Return False
' Inserisco immagine
Dim sName As String = "Pic" + (nLayId + 1).ToString()
Return EgtAddPicture(nLayId, sName, sFile, dScaleFactor * nPixelX, dScaleFactor * nPixelY) <> GDB_ID.NULL
End Function
Public Function ExportProject(Optional sFile As String = "", Optional bWithDlg As Boolean = True) As Boolean
Return ExportGeomId(GDB_ID.ROOT, sFile, bWithDlg)
End Function
Public Function ExportGeomId(nId As Integer, Optional sFile As String = "", Optional bWithDlg As Boolean = True) As Boolean
' Reset controller e scena
ResetStatus()
Dim sFileName As String = sFile
'Assegnazione nome file con dialogo
If bWithDlg Then
Dim nFilter As Integer = 6
Select Case Path.GetExtension(sFile).ToLower()
Case ".dxf"
nFilter = 1
Case ".stl"
nFilter = 2
Case ".3mf"
nFilter = 3
Case ".3dm"
nFilter = 4
Case ".svg"
nFilter = 5
Case ".png", ".jpg", ".jpeg", ".bmp"
nFilter = 6
End Select
Dim SaveFileDialog As New SaveFileDialog With {
.Title = "Export",
.Filter = "AutoCAD drawing exchange (*.dxf)|*.dxf" &
"|Stereolithography (*.stl)|*.stl" &
"|3D Manufacturing format (*.3mf)|*.3mf" &
"|Rhino format (*.3dm)|*.3dm" &
"|Svg (*.svg)|*.svg" &
"|Images (*.png;*.jpg;*.jpeg;*.bmp)|*.png;*.jpg;*.jpeg;*.bmp" &
"|All Files (*.*)|*.*",
.FilterIndex = nFilter,
.FileName = sFile
}
If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
Return True
Else
sFileName = SaveFileDialog.FileName
End If
End If
'Riconoscimento tipo file
Dim nFileType As Integer = EgtGetFileType(sFileName)
If nFileType <> FT.DXF And nFileType <> FT._3MF And nFileType <> FT._3DM And
nFileType <> FT.STL And nFileType <> FT.IMG And nFileType <> FT.SVG And nFileType <> FT.HTML Then
MessageBox.Show("File type unknown", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End If
'Prima dell'esportazione
RaiseEvent OnExportingProject(Me)
'Esportazione del progetto
Cursor.Current = Cursors.WaitCursor
EnableCommandLog()
Dim bOk As Boolean = False
If nFileType = FT.DXF Then
bOk = EgtExportDxf(nId, sFileName, m_nExportDxfFlag, m_nExportFilter)
ElseIf nFileType = FT.STL Then
bOk = EgtExportStl(nId, sFileName, m_nExportFilter)
ElseIf nFileType = FT._3MF Then
bOk = EgtExport3MF(nId, sFileName, m_nExportFilter)
ElseIf nFileType = FT._3DM Then
bOk = EgtExport3dm(nId, sFileName, m_nExportFilter)
ElseIf nFileType = FT.IMG Then
bOk = EgtGetImage(EgtGetShowMode(), New Color3d(255, 255, 255), New Color3d(255, 255, 255),
m_nImgWidth, m_nImgHeight, sFileName)
ElseIf nFileType = FT.SVG Then
bOk = EgtExportSvg(nId, sFileName, m_nExportFilter)
ElseIf nFileType = FT.HTML Then
bOk = EgtExportThreeJS(nId, sFileName, m_nExportFilter)
End If
DisableCommandLog()
'Aggiornamento
RaiseEvent UpdateUI(Me, False)
Cursor.Current = Cursors.Default
'Gestione risultato
RaiseEvent OnExportedProject(Me, sFileName, bOk)
Return bOk
End Function
Public Sub SetDefaultFilterForExport(nFilter As Integer)
m_nExportFilter = nFilter
End Sub
Public Sub SetDefaultForDxfExport(nFlag As Integer)
m_nExportDxfFlag = nFlag
End Sub
Public Sub SetDefaultForImageExport(nWidth As Integer, nHeight As Integer)
m_nImgWidth = nWidth
m_nImgHeight = nHeight
End Sub
Public Function Exec(Optional sDir As String = "", Optional bWithDlg As Boolean = True) As Boolean
Dim sFile As String = sDir
'Scelta file con dialogo
If bWithDlg Then
Dim OpenFileDialog As New OpenFileDialog With {
.Title = "Exec Script",
.Filter = "Lua commands(*.lua)|*.lua" &
"|Test commands(*.tsc)|*.tsc" &
"|All Files (*.*)|*.*",
.FilterIndex = 1,
.InitialDirectory = sDir
}
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
Return True
End If
sFile = OpenFileDialog.FileName
End If
'Ne verifico il tipo
Dim sExt As String = UCase(IO.Path.GetExtension(sFile))
If sExt <> ".LUA" And sExt <> ".TSC" Then
MessageBox.Show("Script type unknow", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End If
'Prima dell'esecuzione
RaiseEvent OnExecutingScript(Me)
'Esecuzione
Cursor.Current = Cursors.WaitCursor
EnableCommandLog()
Dim bOk As Boolean = False
If sExt = ".LUA" Then
bOk = EgtLuaExecFile(sFile)
Else
bOk = EgtTscExecFile(sFile)
End If
DisableCommandLog()
' Aggiornamento
RaiseEvent UpdateUI(Me, True)
Cursor.Current = Cursors.Default
'Gestione risultato
Dim sError As String = String.Empty
If Not bOk Then
If sExt = ".LUA" Then
EgtLuaGetLastError(sError)
Else
sError = "Error executing script"
End If
End If
RaiseEvent OnExecutedScript(Me, sFile, bOk, sError)
Return bOk
End Function
Public Sub MouseSetObjFilterForSelect(bZeroDim As Boolean, bCurve As Boolean,
bSurf As Boolean, bVolume As Boolean, bExtra As Boolean)
EnableCommandLog()
EgtSetObjFilterForSelect(bZeroDim, bCurve, bSurf, bVolume, bExtra)
DisableCommandLog()
End Sub
Public Sub MouseSelectedAll(Optional bOnlyVisible As Boolean = True)
' eseguo la selezione ed aggiorno
EnableCommandLog()
EgtSelectAll(bOnlyVisible)
DisableCommandLog()
EgtDraw()
End Sub
Public Sub MouseDeselectedAll(Optional bTestStatus As Boolean = False)
' se devo verificare lo stato
if bTestStatus Then
if m_nStep <> 0 Then return
End If
' eseguo la selezione ed aggiorno
EnableCommandLog()
EgtDeselectAll()
DisableCommandLog()
EgtDraw()
End Sub
Public Sub MouseSelectedObj(nId As Integer, bLast As Boolean)
EnableCommandLog()
If EgtIsSelectedObj(nId) Then
EgtDeselectObj(nId)
Else
EgtSelectObj(nId)
End If
DisableCommandLog()
If bLast Then
EgtDraw()
End If
End Sub
Public Sub MouseSelectedColor(nId As Integer)
' recupero stato e colore
Dim nStat As Integer = GDB_ST.ON_
EgtGetStatus(nId, nStat)
Dim colRef As Color3d
EgtGetCalcColor( nId, colRef)
' eseguo selezione o deselezione ed aggiorno
EnableCommandLog()
Dim nPartId As Integer = EgtGetFirstPart( True)
While nPartId <> GDB_ID.NULL
Dim nLayerId As Integer = EgtGetFirstLayer( nPartId, True)
While nLayerId <> GDB_ID.NULL
Dim nEntId As Integer = EgtGetFirstInGroup( nLayerId)
While nEntId <> GDB_ID.NULL
Dim nEntStat As GDB_ST = GDB_ST.ON_
Dim colEnt As Color3d
If EgtGetCalcStatus( nEntId, nEntStat) AndAlso nEntStat <> GDB_ST.OFF AndAlso
EgtGetCalcColor( nEntId, colEnt) AndAlso Color3d.Similar( colEnt, colRef, 10) Then
If nStat <> GDB_ST.SEL Then
EgtSelectObj(nEntId)
Else
EgtDeselectObj(nEntId)
End If
End If
nEntId = EgtGetNext( nEntId)
End While
nLayerId = EgtGetNextLayer( nLayerId, True)
End While
nPartId = EgtGetNextPart( nPartId, True)
End While
DisableCommandLog()
EgtDraw()
End Sub
Public Sub MouseSelectedPart(nId As Integer)
' recupero il pezzo
Dim nPartId = EgtGetParent(EgtGetParent(nId))
If EgtGetParent(nPartId) <> GDB_ID.ROOT Then Return
' recupero stato
Dim nStat As Integer = GDB_ST.ON_
EgtGetStatus(nId, nStat)
' eseguo selezione o deselezione ed aggiorno
EnableCommandLog()
If nStat <> GDB_ST.SEL Then
EgtSelectPartObjs(nPartId)
Else
EgtDeselectPartObjs(nPartId)
End If
DisableCommandLog()
EgtDraw()
End Sub
Public Sub MouseSelectedLayer(nId As Integer)
' recupero il layer
Dim nLayerId = EgtGetParent(nId)
If EgtGetParent(EgtGetParent(nLayerId)) <> GDB_ID.ROOT Then Return
' recupero stato
Dim nStat As Integer = GDB_ST.ON_
EgtGetStatus(nId, nStat)
' eseguo selezione o deselezione ed aggiorno
EnableCommandLog()
If nStat <> GDB_ST.SEL Then
EgtSelectLayerObjs(nLayerId)
Else
EgtDeselectLayerObjs(nLayerId)
End If
DisableCommandLog()
EgtDraw()
End Sub
Public Sub MouseSelectedPath(nId As Integer, bHaltOnFork As Boolean)
' verifico sia parte di un layer
Dim nPartId = EgtGetParent(EgtGetParent(nId))
If Not (EgtIsPart(nPartId) OrElse EgtGetRawPartFromPart(nPartId) <> GDB_ID.NULL) Then
Return
End If
' eseguo la selezione ed aggiorno
EnableCommandLog()
EgtSelectPathObjs(nId, bHaltOnFork)
DisableCommandLog()
EgtDraw()
End Sub
Public Sub MouseSelectedPoint(PtP As Point3d, nSep As SEP, nId As Integer, 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_VECTOR3D
SetInputBoxVector3d(m_vtLast)
Case IBT.TY_DIRECTION
SetInputBoxDouble(m_dLast)
Case IBT.TY_LENGTH, IBT.TY_SPECIALDOUBLE
SetInputBoxDouble(m_dLast, True)
Case IBT.TY_DOUBLE_OR_POINT3d
SetInputBoxDouble(m_dLast)
End Select
End If
End Sub
Public Sub MouseMoveInSelectionPoint(PtP As Point3d)
SetDataFromSelPoint(PtP, SEP.PT_STD, GDB_ID.NULL)
' eseguo drag
ExecuteDrag()
End Sub
Private Sub SetDataFromSelPoint(PtP As Point3d, nSep As SEP, 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_VECTOR3D
m_vtLast = m_ptLast - m_ptP1
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_vtLast
Case IBT.TY_SPECIALDOUBLE
ExecuteSpecialData()
Case IBT.TY_DOUBLE_OR_POINT3d
m_bPnt3dVsDbl = True
End Select
End Sub
Public Sub Done(sText As String)
' recupero il dato
InputTextToLast(sText)
' avanzo di un passo
ProcessStatus()
End Sub
Public Sub Show(sText As String)
' recupero il dato
InputTextToLast(sText)
' disabilito drag da mouse
m_Scene.DisableDrag()
EgtResetGeoLine()
EgtResetGeoTria()
' aggiorno drag
ExecuteDrag()
End Sub
Private Sub SetInputBoxString(sText As String)
RaiseEvent SetInputBoxText(sText)
End Sub
Private Sub SetInputBoxInteger(nVal As Integer)
Dim sText As String = nVal.ToString()
RaiseEvent SetInputBoxText(sText)
End Sub
Private Function DoubleToString(dVal As Double, 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()).TrimEnd(".".ToCharArray())
Else
Return sVal
End If
End Function
Private Sub SetInputBoxDouble(dVal As Double, Optional bUiScale As Boolean = False)
Dim dTmp As Double = If(bUiScale, EgtToUiUnits(dVal), dVal)
Dim sText As String = DoubleToString(dTmp, 4)
RaiseEvent SetInputBoxText(sText)
End Sub
Private Sub SetInputBox2Double(d2Val() As Double)
' verifico ci siano almeno 2 elementi nell'array
If d2Val.Length < 2 Then Return
' visualizzo (senza scalare per UI perchè non sono punti o vettori)
Dim sText As New StringBuilder(128)
sText.Append(DoubleToString(d2Val(0), 4))
sText.Append(",")
sText.Append(DoubleToString(d2Val(1), 4))
RaiseEvent SetInputBoxText(sText.ToString())
End Sub
Private Sub SetInputBox3Double(d3Val() As Double)
' verifico ci siano almeno 3 elementi nell'array
If d3Val.Length < 3 Then Return
' visualizzo (senza scalare per UI perchè non sono punti o vettori)
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(ptVal As Point3d)
' converto da coordinate globali a griglia
ptVal = ptVal.Loc(GDB_ID.GRID)
' visualizzo
Dim sText As New StringBuilder(128)
sText.Append(DoubleToString(EgtToUiUnits(ptVal.x), 4))
sText.Append(",")
sText.Append(DoubleToString(EgtToUiUnits(ptVal.y), 4))
sText.Append(",")
sText.Append(DoubleToString(EgtToUiUnits(ptVal.z), 4))
RaiseEvent SetInputBoxText(sText.ToString())
End Sub
Private Sub SetInputBoxVector3d(vtVal As Vector3d)
' converto da coordinate globali a griglia
vtVal = vtVal.Loc(GDB_ID.GRID)
' visualizzo
Dim sText As New StringBuilder(128)
sText.Append(DoubleToString(EgtToUiUnits(vtVal.x), 6))
sText.Append(",")
sText.Append(DoubleToString(EgtToUiUnits(vtVal.y), 6))
sText.Append(",")
sText.Append(DoubleToString(EgtToUiUnits(vtVal.z), 6))
RaiseEvent SetInputBoxText(sText.ToString())
End Sub
Private Function InputTextToLast(ByRef sText As String) As Boolean
Select Case m_nInpType
Case IBT.TY_STRING
If Not EgtLuaEvalStringExpr(sText, m_sLast) Then
m_sLast = sText
End If
Return True
Case IBT.TY_INTEGER
Return TextToInteger(sText, m_nLast)
Case IBT.TY_DOUBLE, IBT.TY_DIRECTION
Return TextToDouble(sText, m_dLast)
Case IBT.TY_LENGTH, IBT.TY_SPECIALDOUBLE
Dim dVal As Double
If TextToDouble(sText, dVal) Then
m_dLast = EgtFromUiUnits(dVal)
Return True
Else
Return False
End If
Case IBT.TY_2DOUBLE
Return TextTo2Double(sText, m_d3Last)
Case IBT.TY_3DOUBLE
Return TextTo3Double(sText, m_d3Last)
Case IBT.TY_POINT3D
Dim d3Val(2) As Double
If TextTo3Double(sText, d3Val) Then
' converto da unità di misura in UI a unità standard
d3Val(0) = EgtFromUiUnits(d3Val(0))
d3Val(1) = EgtFromUiUnits(d3Val(1))
d3Val(2) = EgtFromUiUnits(d3Val(2))
' converto da riferimento griglia a globale
m_ptLast = New Point3d(d3Val(0), d3Val(1), d3Val(2)).Glob(GDB_ID.GRID)
Return True
End If
Case IBT.TY_VECTOR3D
Dim d3Val(2) As Double
If TextTo3Double(sText, d3Val) Then
' converto da unità di misura in UI a unità standard
d3Val(0) = EgtFromUiUnits(d3Val(0))
d3Val(1) = EgtFromUiUnits(d3Val(1))
d3Val(2) = EgtFromUiUnits(d3Val(2))
' converto da riferimento griglia a globale
m_vtLast = New Vector3d(d3Val(0), d3Val(1), d3Val(2)).Glob(GDB_ID.GRID)
Return True
End If
Case IBT.TY_DOUBLE_OR_POINT3d
Dim d3Val(2) As Double
If TextTo3Double(sText, d3Val) Then
m_bPnt3dVsDbl = True
' converto da unità di misura in UI a unità standard
d3Val(0) = EgtFromUiUnits(d3Val(0))
d3Val(1) = EgtFromUiUnits(d3Val(1))
d3Val(2) = EgtFromUiUnits(d3Val(2))
' converto da riferimento griglia a globale
m_ptLast = New Point3d(d3Val(0), d3Val(1), d3Val(2)).Glob(GDB_ID.GRID)
Return True
ElseIf TextToDouble(sText, m_dLast) Then
m_bPnt3dVsDbl = False
Return True
End If
End Select
Return False
End Function
Private Function TextToInteger(ByRef sText As String, ByRef nVal As Integer) As Boolean
Dim dVal As Double
If EgtLuaEvalNumExpr(sText, dVal) Then
nVal = CInt(dVal)
Return True
Else
Return False
End If
End Function
Private Function TextToDouble(ByRef sText As String, ByRef dVal As Double) As Boolean
Return EgtLuaEvalNumExpr(sText, dVal)
End Function
Private Function TextTo2Double(ByRef sText As String, ByRef d2Val() As Double) As Boolean
' verifico ci siano almeno 2 elementi nell'array
If d2Val.Length < 2 Then
Return False
End If
' leggo i due valori
Dim sItems() As String = sText.Split(",".ToCharArray)
Dim bOk As Boolean = True
For i As Integer = 0 To 1
d2Val(i) = 0
If sItems.Length() <= i OrElse Not EgtLuaEvalNumExpr(sItems(i), d2Val(i)) Then
bOk = False
End If
Next
Return bOk
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 = True
For i As Integer = 0 To 2
d3Val(i) = 0
If sItems.Length() <= i Then
If i = 2 Then
d3Val(i) = 0
Else
bOk = False
End If
ElseIf Not EgtLuaEvalNumExpr(sItems(i), d3Val(i)) Then
bOk = False
End If
Next
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(dVal As Double)
m_dLast = dVal
End Sub
Public Sub SetLast3Double(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 SetLastInteger(nVal As Integer)
m_nLast = nVal
If m_nLastCmd = CMD.TEXTPLUS Or m_nLastCmd = CMD.OFFSET Then
' aggiorno drag al cambio di font
ExecuteDrag()
End If
End Sub
Public Sub SetLastString(ByRef sVal As String)
m_sLast = sVal
End Sub
Public Sub SetLastBoolean(bVal As Boolean)
If m_nLastCmd = CMD.TRIMSURFTMWITHCURVE And m_bLast <> bVal Then
DragInvertCurve()
End If
m_bLast = bVal
If m_nLastCmd = CMD.TEXTPLUS Or m_nLastCmd = CMD.POLYGON Or m_nLastCmd = CMD.EXTRUDE Or m_nLastCmd = CMD.REVOLVE _
Or m_nLastCmd = CMD.SETCURVETHICKNESS Or m_nLastCmd = CMD.TRIMSURFTMWITHCURVE Then
' aggiorno drag al cambio di italic
ExecuteDrag()
End If
End Sub
Public Sub SetPointFromSelection(nId As Integer, PtP As Point3d, nAux As Integer)
If EgtIsSelectedObj(nId) Then
EgtSetSelInfo(nId, nAux, ptP)
End If
End Sub
Public Sub ResetStatus( Optional bRedraw As Boolean = True)
m_nStep = 0
Dim bOldContinue As Boolean = m_bContinue
If m_bContinue Then
m_bContinue = False
RaiseEvent UpdateUI(Me, False)
End If
m_nContinueId = GDB_ID.NULL
m_sepP1 = SEP.PT_STD
m_sepP2 = SEP.PT_STD
m_sepLast = SEP.PT_STD
m_Scene.ResetStatus(bRedraw)
If bOldContinue Then
RaiseEvent OnExecCmdEnd(m_nLastCmd)
End If
End Sub
Public Function GetStep() As Integer
Return m_nStep
End Function
Public Sub SetContinue()
m_bContinue = True
m_nContinueId = GDB_ID.NULL
End Sub
Public Function GetContinue() As Boolean
Return m_bContinue
End Function
Public Function GetContinueId() As Integer
Return m_nContinueId
End Function
Public Function RepeatLastCommand() As Boolean
if m_bLastContinue Then SetContinue()
Return ExecuteCommand(m_nLastCmd)
End Function
Public Function ExecuteCommand(nCmd As CMD) As Boolean
' Posso partire solo con stato libero
If m_nStep <> 0 Then Return False
' Reset eventuali analisi e distanza in corso
m_Scene.ResetStatusAnalyze()
m_Scene.ResetStatusGetDistance()
' Se non è linea 2P reset punti speciali (tg, perp e mindist)
If (nCmd <> CMD.LINE2P) Then
m_Scene.DisableTangentPoint()
m_Scene.DisablePerpendicularPoint()
m_Scene.DisableMinDistPoint()
End If
' Salvo ed eseguo il comando
m_nLastCmd = nCmd
m_bLastContinue = m_bContinue
Return ProcessStatus()
End Function
Private Function ProcessStatus() As Boolean
Dim bOk = False
Select Case m_nLastCmd
' Exec Line
Case CMD.EXECLINE
bOk = ProcessExecLine()
' Grid
Case CMD.GRID
bOk = ProcessGrid()
' Grid origin
Case CMD.GRID_ELEVATION
bOk = ProcessGridElevation()
Case CMD.GRID_ORIGIN
bOk = ProcessGridOrigin()
' rotazione Griglia/Cplane
Case CMD.GRID_ROTATE
bOk = ProcessGridRotate()
' rotazione 3d Griglia/Cplane
Case CMD.GRID_ROTATE3D
bOk = ProcessGridRotate3D()
' Griglia/Cplane dati 3 punti
Case CMD.GRID_3P
bOk = ProcessGrid3P()
' Griglia/Cplane perpendicolare a curva
Case CMD.GRID_PERPCURVE
bOk = ProcessGridPerpObj()
' Griglia/Cplane da oggetto geometrico
Case CMD.GRID_OBJ
bOk = ProcessGridObj()
' Griglia Inverti (ruota di 180deg attorno al suo X)
Case CMD.GRID_INVERT
bOk = ProcessGridInvert()
' Nuovo Pezzo
Case CMD.NEWPART
bOk = ProcessNewPart()
' Nuovo Layer
Case CMD.NEWLAYER
bOk = ProcessNewLayer()
' Imposto pezzo e layer correnti
Case CMD.SETCURRPARTLAYER
bOk = ProcessSetCurrPartLayer()
' Cancello pezzo e layer correnti
Case CMD.RESETCURRPARTLAYER
bOk = ProcessResetCurrPartLayer()
' Imposto colore del layer
Case CMD.LAYERCOLOR
bOk = ProcessLayerColor()
' Seleziono Pezzo/Layer/Oggetto
Case CMD.SELECTPARTLAYEROBJ
bOk = ProcessSelectPartLayerObj()
' Deseleziono Pezzo/Layer/Oggetto
Case CMD.DESELECTPARTLAYEROBJ
bOk = ProcessDeselectPartLayerObj()
' Riloco Pezzo/Layer/Oggetto
Case CMD.RELOCATEPARTLAYEROBJ
bOk = ProcessRelocatePartLayerObj()
' Copio Pezzo/Layer/Oggetto
Case CMD.COPYPARTLAYEROBJ
bOk = ProcessCopyPartLayerObj()
' Visualizza
Case CMD.SHOW
bOk = ProcessShow()
' Nascondi
Case CMD.HIDE
bOk = ProcessHide()
' Name
Case CMD.SETNAME
bOk = ProcessSetName()
' Info
Case CMD.SETINFO
bOk = ProcessSetInfo()
' Point
Case CMD.POINT
bOk = ProcessPoint()
' Vector
Case CMD.VECTOR
bOk = ProcessVector()
' Frame
Case CMD.FRAME
bOk = ProcessFrame()
' Line2P
Case CMD.LINE2P
bOk = ProcessLine2P()
' LinePDL
Case CMD.LINEPDL
bOk = ProcessLinePDL()
' LinePVL
Case CMD.LINEPVL
bOk = ProcessLinePVL()
' CircleCP
Case CMD.CIRCLECP
bOk = ProcessCircleCP()
' CircleCD
Case CMD.CIRCLECD
bOk = ProcessCircleCD()
' Circle3P
Case CMD.CIRCLE3P
bOk = ProcessCircle3P()
' ArcCSE
Case CMD.ARCCSE
bOk = ProcessArcCSE()
' Arc3P
Case CMD.ARC3P
bOk = ProcessArc3P()
' Arc2PRad
Case CMD.ARC2PR
bOk = ProcessArc2PR()
' ArcPDP
Case CMD.ARCPDP
bOk = ProcessArcPDP()
' ArcPVP
Case CMD.ARCPVP
bOk = ProcessArcPVP()
' BiArc
Case CMD.BIARC
bOk = ProcessBiArc()
' Bezier Curve
Case CMD.CURVEBEZIER
bOk = ProcessCurveBezier()
' Fillet
Case CMD.FILLET
bOk = ProcessFillet()
' Chamfer
Case CMD.CHAMFER
bOk = ProcessChamfer()
' Rectangle 2P
Case CMD.RECTANGLE2P
bOk = ProcessRectangle2P()
' Polygon
Case CMD.POLYGON
bOk = ProcessPolygon()
' Polygon Side
Case CMD.POLYGONSIDE
bOk = ProcessPolygonSide()
' Text
Case CMD.TEXT
bOk = ProcessText()
' Text Plus
Case CMD.TEXTPLUS
bOk = ProcessTextPlus()
' Linear Dimension
Case CMD.LINEARDIMENSION
bOk = ProcessLinearDimension()
' Aligned Dimension
Case CMD.ALIGNEDDIMENSION
bOk = ProcessAlignedDimension()
' Angular Dimension
Case CMD.ANGULARDIMENSION
bOk = ProcessAngularDimension()
' Angular Dimension Plus
Case CMD.ANGULARDIMENSIONPLUS
bOk = ProcessAngularDimensionPlus()
' Diametral Dimension
Case CMD.DIAMETRALDIMENSION
bOk = ProcessDiametralDimension()
' Radial Dimension
Case CMD.RADIALDIMENSION
bOk = ProcessRadialDimension()
' Region
Case CMD.REGION
bOk = ProcessRegion()
' Plane
Case CMD.PLANE
bOk = ProcessPlane()
' Extrude
Case CMD.EXTRUDE
bOk = ProcessExtrude()
' Revolve
Case CMD.REVOLVE
bOk = ProcessRevolve()
' Revolve Plus
Case CMD.SCREW
bOk = ProcessScrew()
' Swept
Case CMD.SWEPT
bOk = ProcessSwept()
' Ruled
Case CMD.RULED
bOk = ProcessRuled()
' Merge Surfaces
Case CMD.MERGESURF
bOk = ProcessMergeSurf()
' Explode Surfaces
Case CMD.EXPLODESURF
bOk = ProcessExplodeSurf()
' Approssima una superficie
Case CMD.APPROXSURF
bOk = ProcessApproxSurf()
' Invert Surface
Case CMD.INVERTSURF
bOk = ProcessInvertSurf()
' Move Surface Vertex
Case CMD.MOVESURFVERTEX
bOk = ProcessMoveSurfVertex()
' Move Surface Face
Case CMD.MOVESURFFACET
bOk = ProcessMoveSurfFacet()
' Extract Surf Loops
Case CMD.EXTRACTSURFLOOPS
bOk = ProcessExtractSurfLoops()
' Extract Facet Loops
Case CMD.EXTRACTSURFFACETLOOPS
bOk = ProcessExtractSurfFacetLoops()
' Explode To Triangles
Case CMD.SURFTMTOTRIANGLES
bOk = ProcessSurfTmToTriangles()
' Extract Facet
Case CMD.EXTRACTSURFFACET
bOk = ProcessExtractSurfFacet()
' Solid Add Surfaces
Case CMD.SOLIDADDSURF
bOk = ProcessSolidAddSurf()
' Solid Subtract Surfaces
Case CMD.SOLIDSUBTRACTSURF
bOk = ProcessSolidSubtractSurf()
' Solid Intersect Surfaces
Case CMD.SOLIDINTERSECTSURF
bOk = ProcessSolidIntersectSurf()
' Intersect Surfaces
Case CMD.INTERSECTSURFSURF
bOk = ProcessIntersectSurfSurf()
' Cut Surface with Another one
Case CMD.CUTSURFSURF
bOk = ProcessCutSurfSurf()
' Cut Surface with (Extrusion of a closed) Curve
Case CMD.TRIMSURFTMWITHCURVE
bOk = ProcessCutSurfTmWithCurve()
' Inverse Cut Surface with Another one
Case CMD.INVCUTSURFSURF
bOk = ProcessInvCutSurfSurf()
' Delete
Case CMD.DELETE
bOk = ProcessDelete()
' Change Layer
Case CMD.CHANGELAYER
bOk = ProcessChangeLayer(False)
' Change Layer Glob
Case CMD.CHANGELAYERGLOB
bOk = ProcessChangeLayer(True)
' Change Color
Case CMD.CHANGECOLOR
bOk = ProcessChangeColor()
' Reset Color
Case CMD.RESETCOLOR
bOk = ProcessResetColor()
' Change Alpha
Case CMD.CHANGEALPHA
bOk = ProcessChangeAlpha()
' Invert Curve
Case CMD.INVERTCURVE
bOk = ProcessInvertCurve()
' Extend Curve
Case CMD.TRIMEXTENDCURVE
bOk = ProcessExtendCurve()
' Break Curve
Case CMD.BREAKCURVE
bOk = ProcessBreakCurve()
' Split Curve in N parts
Case CMD.SPLITCURVE
bOk = ProcessSplitCurve()
' Join Curve
Case CMD.JOINCURVE
bOk = ProcessJoinCurve()
' Separate Curve
Case CMD.EXPLODECURVE
bOk = ProcessExplodeCurve()
' Merge Curves in Compo
Case CMD.MERGECURVESINCOMPO
bOk = ProcessMergeCurvesInCompo()
' Change Start Closed Curve
Case CMD.CHANGESTARTCURVE
bOk = ProcessChangeStartCurve()
' Set Curve Thickness
Case CMD.SETCURVETHICKNESS
bOk = ProcessSetCurveThickness()
' ArcFlip
Case CMD.ARCFLIP
bOk = ProcessArcFlip()
' ArcExplementary
Case CMD.ARCEXPLEMENTARY
bOk = ProcessArcExplementary()
' Modifica curva
Case CMD.MODIFYCURVE
bOk = ModifyCurve()
' Aggiungi punto alla curva
Case CMD.ADDPOINTCURVE
bOk = AddPointCurve()
' Rimuove punto dalla curva
Case CMD.REMOVEPOINTCURVE
bOk = RemovePointCurve()
' Trasforma una curva in arco
Case CMD.CURVETOARC
bOk = ProcessCurveToArc()
' Trasforma una curva in segmento di retta
Case CMD.CURVETOLINE
bOk = ProcessCurveToLine()
' Chiude una curva composita aperta
Case CMD.CLOSECOMPO
bOk = ProcessCloseCompo()
' Apre una curva composita chiusa
Case CMD.OPENCOMPO
bOk = ProcessOpenCompo()
' Approssima una curva con archi e rette
Case CMD.APPROXCURVE
bOk = ProcessApproxCurve(True)
' Approssima una curva con sole rette
Case CMD.APPROXCURVEWITHLINES
bOk = ProcessApproxCurve( false)
' Modify Arc Radius
Case CMD.MODIFYARCRADIUS
bOk = ModifyArcRadius()
' Modify Text
Case CMD.MODIFYTEXT
bOk = ModifyText()
' Move
Case CMD.MOVE
bOk = ProcessMove()
' Rotate
Case CMD.ROTATE
bOk = ProcessRotate()
' Rotate 3d
Case CMD.ROTATE3D
bOk = ProcessRotate3D()
' Mirror
Case CMD.MIRROR
bOk = ProcessMirror()
' Mirror 3d
Case CMD.MIRROR3D
bOk = ProcessMirror3D()
' Scale
Case CMD.SCALE
bOk = ProcessScale()
' Scale 3d
Case CMD.SCALE3D
bOk = ProcessScale3D()
' Offset
Case CMD.OFFSET
bOk = ProcessOffset()
' Selezione gruppo
Case CMD.SELECTGROUP
bOk = ProcessSelectGroup()
' Cambia lo stato di visualizzazione dell'oggetto e figli
Case CMD.CHANGESTATUS
bOk = ProcessChangeStatus()
End Select
If m_nStep = 0 Then
RaiseEvent OnExecCmdEnd(m_nLastCmd)
End If
Return bOk
End Function
Private Function ExecuteDrag() As Boolean
Dim bOk As Boolean = True
' Eseguo drag
EgtDisableModified()
Select Case m_nLastCmd
Case CMD.GRID_ROTATE
DragGridRotate()
Case CMD.GRID_ROTATE3D
DragGridRotate3D()
Case CMD.COPYPARTLAYEROBJ
DragCopyPartLayerObj()
Case CMD.POINT
DragPoint()
Case CMD.VECTOR
DragVector()
Case CMD.FRAME
DragFrame()
Case CMD.LINE2P
DragLine2P()
Case CMD.LINEPDL
DragLinePDL()
Case CMD.LINEPVL
DragLinePVL()
Case CMD.CIRCLECP
DragCircleCP()
Case CMD.CIRCLECD
DragCircleCD()
Case CMD.CIRCLE3P
DragCircle3P()
Case CMD.ARCCSE
DragArcCSE()
Case CMD.ARC3P
DragArc3P()
Case CMD.ARC2PR
DragArc2PR()
Case CMD.ARCPDP
DragArcPDP()
Case CMD.ARCPVP
DragArcPVP()
Case CMD.BIARC
DragBiArc()
Case CMD.CURVEBEZIER
DragCurveBezier()
Case CMD.FILLET
DragFillet()
Case CMD.CHAMFER
DragChamfer()
Case CMD.RECTANGLE2P
DragRectangle2P()
Case CMD.POLYGON
DragPolygon()
Case CMD.POLYGONSIDE
DragPolygonSide()
Case CMD.TEXT
DragText()
Case CMD.TEXTPLUS
DragTextPlus()
Case CMD.LINEARDIMENSION
DragLinearDimension()
Case CMD.ALIGNEDDIMENSION
DragAlignedDimension()
Case CMD.ANGULARDIMENSION
DragAngularDimension()
Case CMD.ANGULARDIMENSIONPLUS
DragAngularDimensionPlus()
Case CMD.DIAMETRALDIMENSION
DragDiametralDimension()
Case CMD.RADIALDIMENSION
DragRadialDimension()
Case CMD.EXTRUDE
DragExtrude()
Case CMD.REVOLVE
DragRevolve()
Case CMD.SCREW
DragScrew()
Case CMD.SWEPT
DragSwept()
Case CMD.RULED
DragRuled()
Case CMD.TRIMEXTENDCURVE
DragExtendCurve()
Case CMD.SETCURVETHICKNESS
DragSetCurveThickness()
Case CMD.MODIFYCURVE
DragModifyCurve()
Case CMD.ADDPOINTCURVE
DragAddPointCurve()
Case CMD.CURVETOARC
DragCurveToArc()
Case CMD.APPROXCURVE
DragApproxCurve( true)
Case CMD.APPROXCURVEWITHLINES
DragApproxCurve( false)
Case CMD.MODIFYARCRADIUS
DragModifyArcRadius()
Case CMD.MODIFYTEXT
DragModifyText()
Case CMD.MOVE
DragMove()
Case CMD.ROTATE
DragRotate()
Case CMD.ROTATE3D
DragRotate3D()
Case CMD.MIRROR
DragMirror()
Case CMD.MIRROR3D
DragMirror3D()
Case CMD.SCALE
DragScale()
Case CMD.SCALE3D
DragScale3D()
Case CMD.OFFSET
DragOffset()
Case CMD.SOLIDADDSURF
DragSolidAddSurf()
Case CMD.SOLIDINTERSECTSURF
DragSolidIntersectSurf()
Case CMD.SOLIDSUBTRACTSURF
DragSolidSubtractSurf()
Case CMD.INTERSECTSURFSURF
DragIntersectSurfSurf()
Case CMD.TRIMSURFTMWITHCURVE
DragTrimSurfTmWithCurve()
Case CMD.CUTSURFSURF
DragCutSurfSurf()
Case CMD.INVCUTSURFSURF
DragInvCutSurfSurf()
Case CMD.APPROXSURF
DragApproxSurf()
Case CMD.MOVESURFVERTEX
DragMoveSurfVertex()
Case CMD.MOVESURFFACET
DragMoveSurfFacet()
Case Else
bOk = False
End Select
EgtEnableModified()
Return bOk
End Function
Private Function ExecuteSpecialData() As Boolean
Select Case m_nLastCmd
' Trim/Extend di curva
Case CMD.TRIMEXTENDCURVE
ExecuteSpecialDataExtendCurve()
' Offset di curva
Case CMD.OFFSET
ExecuteSpecialDataOffset()
End Select
Return False
End Function
Private Function ProcessExecLine() As Boolean
If m_nStep <> 0 Then
Return False
End If
EnableCommandLog()
Dim bOk As Boolean = EgtLuaExecLine(m_sLast)
DisableCommandLog()
' Aggiornamento
RaiseEvent UpdateUI(Me, True)
EgtDraw()
Return bOk
End Function
Private Function ProcessGrid() As Boolean
If m_nStep <> 0 Then
Return False
End If
Dim frNew As New Frame3d
Select Case m_nLast
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 GRID_TYPE.VIEW
Dim dAngVertDeg As Double
Dim dAngHorizDeg As Double
EgtGetGenericView(dAngVertDeg, dAngHorizDeg)
Dim vtDir As Vector3d = Vector3d.FromSpherical(1, dAngVertDeg, dAngHorizDeg)
frNew.Setup(Point3d.ORIG, vtDir)
Case Else
Return False
End Select
EnableCommandLog()
EgtSetGridFrame(frNew)
DisableCommandLog()
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
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox("GRID", "Insert Elevation", "", False, False)
m_nInpType = IBT.TY_LENGTH
m_dLast = 0
SetInputBoxDouble(m_dLast, True)
Case 1
' recupero il piano di griglia corrente
Dim frCurr As New Frame3d(EgtGetGridFrame())
' cambio l'elevazione dell'origine
frCurr.Move(EgtGetGridVersZ() * m_dLast)
' imposto nuova griglia
EnableCommandLog()
EgtSetGridFrame(frCurr)
DisableCommandLog()
' 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, False)
m_nInpType = IBT.TY_POINT3D
Case 1
' recupero il piano di griglia corrente
Dim frCurr As New Frame3d(EgtGetGridFrame())
' ne modifico l'origine
frCurr.Move(m_ptLast - frCurr.Orig())
' imposto nuova griglia
EnableCommandLog()
EgtSetGridFrame(frCurr)
DisableCommandLog()
' 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 Center", "", False, False)
m_nInpType = IBT.TY_POINT3D
Case 1
m_ptP1 = m_ptLast
m_ptP2 = m_ptP1
m_nStep = 2
RaiseEvent PrepareInputBox("GRID ROTATE", "Insert Base Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Case 2
m_ptP2 = m_ptLast
m_nStep = 3
RaiseEvent PrepareInputBox("GRID ROTATE", "Insert Angle or Rotation Point", "", False, False)
m_nInpType = IBT.TY_DOUBLE_OR_POINT3d
Case 3
' calcolo parametri di rotazione
If m_bPnt3dVsDbl Then
Dim bDet As Boolean = True
EgtGetVectorRotation((m_ptP2 - m_ptP1), (m_ptLast - m_ptP1), EgtGetGridVersZ(), m_dLast, bDet)
End If
' eseguo rotazione
Dim frCurr As New Frame3d(EgtGetGridFrame())
frCurr.Rotate(m_ptP1, EgtGetGridVersZ(), m_dLast)
EnableCommandLog()
EgtSetGridFrame(frCurr)
DisableCommandLog()
' 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_ptLast)
EgtDraw()
End If
End Sub
Private Function ProcessGridRotate3D() 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 3D", "Insert First Point on Axis", "", False, False)
m_nInpType = IBT.TY_POINT3D
Case 1
m_ptP1 = m_ptLast
m_ptP2 = m_ptP1
m_nStep = 2
RaiseEvent PrepareInputBox("GRID ROTATE 3D", "Insert Second Point on Axis", "", False, False)
m_nInpType = IBT.TY_POINT3D
Case 2
m_ptP2 = m_ptLast
m_nStep = 3
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox("GRID ROTATE 3D", "Insert angle", "", False, 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.Rotate(m_ptP1, VtAx, m_dLast)
EnableCommandLog()
EgtSetGridFrame(frCurr)
DisableCommandLog()
' 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 DragGridRotate3D()
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, 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, 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, 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
EnableCommandLog()
EgtSetGridFrame(frCurr)
DisableCommandLog()
' 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 ProcessGridPerpObj() 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 OBJECT", "Insert Origin", "", False, 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
EnableCommandLog()
EgtSetGridFrame(frCurr)
DisableCommandLog()
' 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.GROUP
Dim frNew As New Frame3d
If Not EgtFrame(nId, GDB_ID.ROOT, frNew) Then Return False
EnableCommandLog()
EgtSetGridFrame(frNew)
DisableCommandLog()
Case GDB_TY.GEO_POINT
Dim ptOrig As Point3d
If Not EgtStartPoint(nId, GDB_ID.ROOT, ptOrig) Then Return False
Dim frNew As Frame3d = EgtGetGridFrame()
frNew.ChangeOrigin(ptOrig)
EnableCommandLog()
EgtSetGridFrame(frNew)
DisableCommandLog()
Case GDB_TY.GEO_VECTOR
Dim vtZ As Vector3d
If Not EgtStartVector( nId, GDB_ID.ROOT, vtZ) Then Return False
Dim ptOrig As Point3d
If Not EgtStartPoint(nId, GDB_ID.ROOT, ptOrig) Then Return False
Dim frNew As New Frame3d
frNew.Setup(ptOrig, vtZ)
EnableCommandLog()
EgtSetGridFrame(frNew)
DisableCommandLog()
Case GDB_TY.GEO_FRAME
Dim frNew As New Frame3d
If Not EgtFrame(nId, GDB_ID.ROOT, frNew) Then Return False
EnableCommandLog()
EgtSetGridFrame(frNew)
DisableCommandLog()
Case GDB_TY.CRV_LINE, GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO
Dim dThick As Double = 0
EgtCurveThickness( nId, dThick)
Dim dDist As Double = 0
Dim vtZ As Vector3d
If Not EgtCurveIsFlat( nId, Math.Abs( dThick) > EPS_SMALL, 10 * EPS_SMALL, vtZ, dDist) Then
If Not EgtCurveExtrusion(nId, vtZ) OrElse vtZ.IsSmall() Then vtZ = Vector3d.Z_AX
End If
Dim ptOrig As Point3d
EgtCentroid(nId, ptOrig)
Dim frNew As New Frame3d
frNew.Setup(ptOrig.Glob(nId), vtZ.Glob(nId))
EnableCommandLog()
EgtSetGridFrame(frNew)
DisableCommandLog()
Case GDB_TY.SRF_MESH
Dim nLastId, nLastSub As Integer
Dim ptLastSel As Point3d
EgtGetLastSelInfo(nLastId, nLastSub, ptLastSel)
Dim nF As Integer = EgtSurfTmFacetFromTria(nId, nLastSub)
If nF >= 0 Then
Dim ptOrig As Point3d
Dim vtZ As Vector3d
If EgtSurfTmFacetCenter(nId, nF, ptOrig, vtZ) Then
Dim frNew As New Frame3d
frNew.Setup(ptOrig.Glob(nId), vtZ.Glob(nId))
EnableCommandLog()
EgtSetGridFrame(frNew)
DisableCommandLog()
End If
End If
Case GDB_TY.SRF_FRGN
Dim ptOrig As Point3d
Dim vtZ As Vector3d
If EgtCenterPoint(nId, ptOrig) AndAlso EgtSurfFrNormVersor(nId, vtZ) Then
Dim frNew As New Frame3d
frNew.Setup(ptOrig.Glob(nId), vtZ.Glob(nId))
EnableCommandLog()
EgtSetGridFrame(frNew)
DisableCommandLog()
End If
Case GDB_TY.EXT_TEXT
Dim vtX As Vector3d
Dim vtZ As Vector3d
If EgtStartVector(nId, vtX) And EgtTextNormVersor(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))
EnableCommandLog()
EgtSetGridFrame(frNew)
DisableCommandLog()
End If
End Select
EgtDeselectAll()
EgtDraw()
Return True
End Function
Private Function ProcessGridInvert() As Boolean
If m_nStep <> 0 Then Return False
' eseguo inversione con rotazione di 180deg attorno a X griglia
Dim frCurr As New Frame3d(EgtGetGridFrame())
frCurr.Rotate( frCurr.Orig(), frCurr.VersX(), 180)
EnableCommandLog()
EgtSetGridFrame(frCurr)
DisableCommandLog()
EgtDraw()
Return True
End Function
Private Function ProcessNewPart() As Boolean
If m_nStep <> 0 Then
Return False
End If
EnableCommandLog()
' inserisco un nuovo gruppo (part) 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, Frame3d.GLOB(), GDB_RT.GRID)
' se ok, salvo nuova situazione
If nIdNewPart <> GDB_ID.NULL And nIdNewLayer <> GDB_ID.NULL Then
EgtSetCurrPartLayer(nIdNewPart, nIdNewLayer)
End If
DisableCommandLog()
RaiseEvent UpdateUI(Me, True)
Return True
End Function
Private Function ProcessNewLayer() As Boolean
If m_nStep <> 0 Then
Return False
End If
EnableCommandLog()
' inserisco un nuovo gruppo (layer) sotto il pezzo corrente
Dim nIdNewLayer As Integer = EgtCreateGroup(EgtGetCurrPart(), Frame3d.GLOB(), GDB_RT.GRID)
' se ok, salvo nuova situazione
If nIdNewLayer <> GDB_ID.NULL Then
EgtSetCurrPartLayer(EgtGetCurrPart(), nIdNewLayer)
End If
DisableCommandLog()
RaiseEvent UpdateUI(Me, True)
Return True
End Function
Private Function ProcessSetCurrPartLayer() As Boolean
If m_nStep <> 0 Then
Return False
End If
' se non è un gruppo ne cerco il padre
Dim nId As Integer = m_nLast
While EgtGetType(nId) <> GDB_TY.GROUP
nId = EgtGetParent(nId)
If nId = GDB_ID.NULL Then
Return False
End If
End While
' recupero il padre
EgtEnableCommandLogger()
Dim nParentId As Integer = EgtGetParent(nId)
If nParentId = GDB_ID.NULL Then
Return False
' se Part
ElseIf nParentId = GDB_ID.ROOT Then
' cerco il primo Layer visibile del Part
'Dim nIdLayer As Integer = EgtGetFirstLayer(nId, True)
'EgtSetCurrPartLayer(nId, nIdLayer)
EgtSetCurrPartLayer(nId, GDB_ID.NULL)
' se Layer
ElseIf EgtGetParent(nParentId) = GDB_ID.ROOT Then
EgtSetCurrPartLayer(nParentId, nId)
End If
EgtDisableCommandLogger()
RaiseEvent UpdateUI(Me, False)
Return True
End Function
Private Function ProcessResetCurrPartLayer() As Boolean
If m_nStep <> 0 Then
Return False
End If
EgtEnableCommandLogger()
EgtResetCurrPartLayer()
EgtDisableCommandLogger()
Return True
End Function
Private Function ProcessLayerColor() As Boolean
If m_nStep <> 0 Then Return False
Dim nCurrId As Integer
If EgtGetCurrPart() <> GDB_ID.NULL Then
nCurrId = EgtGetCurrPart()
If EgtGetCurrLayer() <> GDB_ID.NULL Then
nCurrId = EgtGetCurrLayer()
End If
Else
Return False
End If
Dim colObj As Color3d
EgtGetCalcColor(nCurrId, colObj)
If SelectColor(colObj, colObj) Then
EnableCommandLog()
EgtSetColor(nCurrId, colObj)
DisableCommandLog()
RaiseEvent UpdateUI(Me, False)
EgtDraw()
End If
Return True
End Function
Private Function ProcessSelectGroup() As Boolean
If m_nStep <> 0 Then Return False
' Lo seleziono
EnableCommandLog()
Dim bOk As Boolean = EgtSelectObj(m_nLast)
DisableCommandLog()
If Not bOk Then Return False
' Aggiorno visualizzazione
RaiseEvent UpdateUI(Me, False)
EgtDraw()
Return True
End Function
Private Function ProcessSelectPartLayerObj() As Boolean
If m_nStep <> 0 Then
Return False
End If
' se gruppo
If EgtGetType(m_nLast) = GDB_TY.GROUP Then
' se pezzo
If EgtGetParent(m_nLast) = GDB_ID.ROOT Then
' seleziono tutti gli oggetti del pezzo
EnableCommandLog()
Dim bOk As Boolean = EgtSelectPartObjs(m_nLast)
DisableCommandLog()
If Not bOk Then
Return False
End If
' se layer
ElseIf EgtGetParent(EgtGetParent(m_nLast)) = GDB_ID.ROOT Then
' seleziono tutti gli oggetti del layer
EnableCommandLog()
Dim bOk As Boolean = EgtSelectLayerObjs(m_nLast)
DisableCommandLog()
If Not bOk Then
Return False
End If
' altrimenti errore
Else
Return False
End If
' altrimenti entità
Else
' la seleziono
EnableCommandLog()
Dim bOk As Boolean = EgtSelectObj(m_nLast)
DisableCommandLog()
If Not bOk Then
Return False
End If
End If
RaiseEvent UpdateUI(Me, False)
EgtDraw()
Return True
End Function
Private Function ProcessDeselectPartLayerObj() As Boolean
If m_nStep <> 0 Then
Return False
End If
' se gruppo
If EgtGetType(m_nLast) = GDB_TY.GROUP Then
' se pezzo
If EgtGetParent(m_nLast) = GDB_ID.ROOT Then
' deseleziono tutti gli oggetti del pezzo
EnableCommandLog()
Dim bOk As Boolean = EgtDeselectPartObjs(m_nLast)
DisableCommandLog()
If Not bOk Then
Return False
End If
' se layer
ElseIf EgtGetParent(EgtGetParent(m_nLast)) = GDB_ID.ROOT Then
' deseleziono tutti gli oggetti del layer
EnableCommandLog()
Dim bOk As Boolean = EgtDeselectLayerObjs(m_nLast)
DisableCommandLog()
If Not bOk Then
Return False
End If
' altrimenti errore
Else
Return False
End If
' altrimenti entità
Else
' la deseleziono
EnableCommandLog()
Dim bOk As Boolean = EgtDeselectObj(m_nLast)
DisableCommandLog()
If Not bOk Then
Return False
End If
End If
RaiseEvent UpdateUI(Me, False)
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.LAST_SON
' se gruppo
If EgtGetType(m_nLast) = GDB_TY.GROUP Then
' se pezzo
If EgtGetParent(m_nLast) = 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_nLast)) = GDB_ID.ROOT Then
Dim nCurrPartId = EgtGetCurrPart()
' il riferimento è il pezzo corrente
nRefId = nCurrPartId
' se il pezzo sorgente è il corrente
If EgtGetParent(m_nLast) = nCurrPartId Then
' il riferimento è dopo l'ultimo sotto il pezzo
nRefId = EgtGetLastInGroup(nCurrPartId)
nPos = GDB_POS.AFTER
End If
' altrimenti errore
Else
Return False
End If
' altrimenti entità
Else
Dim nCurrLayerId As Integer = EgtGetCurrLayer()
' il riferimento è il layer corrente
nRefId = nCurrLayerId
' se il layer sorgente è il corrente
If EgtGetParent(m_nLast) = nCurrLayerId Then
' il riferimento è dopo l'ultimo sotto il layer
nRefId = EgtGetLastInGroup(nCurrLayerId)
nPos = GDB_POS.AFTER
End If
End If
EnableCommandLog()
EgtRelocateGlob(m_nLast, nRefId, nPos)
DisableCommandLog()
RaiseEvent UpdateUI(Me, True)
EgtDraw()
Return True
End Function
Private Function DoCopyPartLayerObj(nId As Integer, Optional bEnabGroup As Boolean = False) As Integer
Dim nNewId As Integer = GDB_ID.NULL
' se pezzo
If EgtIsPart(nId) Then
nNewId = EgtCopyGlob(nId, GDB_ID.ROOT)
' se layer
ElseIf EgtIsLayer(nId) Then
nNewId = EgtCopyGlob(nId, EgtGetCurrPart())
' se entità (anche gruppo se ammesso)
ElseIf bEnabGroup OrElse EgtGetType(nId) <> GDB_TY.GROUP Then
nNewId = EgtCopyGlob(nId, EgtGetCurrLayer())
End If
Return nNewId
End Function
Private Function ProcessCopyPartLayerObj() As Boolean
Select Case m_nStep
Case 0
EnableCommandLog()
EgtDeselectAll()
DisableCommandLog()
Dim bOk As Boolean = True
' se pezzo
If EgtIsPart(m_nLast) Then
' seleziono tutti gli oggetti del pezzo
bOk = EgtSelectPartObjs(m_nLast)
' se layer
ElseIf EgtIsLayer(m_nLast) Then
' seleziono tutti gli oggetti del layer
bOk = EgtSelectLayerObjs(m_nLast)
' altrimenti entità
ElseIf EgtGetType(m_nLast) <> GDB_TY.GROUP Then
' la seleziono
bOk = EgtSelectObj(m_nLast)
End If
' in caso di errore, esco
If Not bOk Then
Return False
End If
' se non ci sono oggetti selezionati copio ed esco subito
If EgtGetSelectedObjCount() = 0 Then
EnableCommandLog()
Dim nNewId = DoCopyPartLayerObj(m_nLast)
DisableCommandLog()
RaiseEvent UpdateUI(Me, True)
Return True
End If
' preparo per il drag
If Not PrepareTransform() Then
Return False
End If
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo "COPY", "Insert Base Point"
RaiseEvent PrepareInputBox(EgtMsg(2401), EgtMsg(2403), "", False, False)
m_nInpType = IBT.TY_POINT3D
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
m_Scene.EnableDrag()
' abilito dialogo "COPY", "Insert Target Point"
RaiseEvent PrepareInputBox(EgtMsg(2401), EgtMsg(2404), "", False, True)
m_nInpType = IBT.TY_POINT3D
Case 2
m_Scene.ResetStatus(False)
EgtDeselectAll()
EnableCommandLog()
' eseguo copia
Dim nNewId = DoCopyPartLayerObj(m_nLast)
' eseguo movimento
EgtMove(nNewId, (m_ptLast - m_ptP1).Loc(GDB_ID.GRID), GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragCopyPartLayerObj()
If m_nStep = 2 Then
' ripristino lo stato iniziale
EgtChangeGroupFrame(m_Scene.GetDragGroup(), Frame3d.GLOB)
' eseguo tutto il movimento
EgtMove(m_Scene.GetDragGroup(), (m_ptLast - m_ptP1), GDB_RT.GLOB)
EgtSetGeoLine(m_ptP1, m_ptLast)
EgtDraw()
End If
End Sub
Private Function ProcessShow() As Boolean
If m_nStep <> 0 Then Return False
If m_nLast <> GDB_ID.NULL Then
Dim nStat As GDB_ST = GDB_ST.ON_
EgtGetStatus(m_nLast, nStat)
If nStat = GDB_ST.OFF Then
EnableCommandLog()
EgtSetStatus(m_nLast, GDB_ST.ON_)
DisableCommandLog()
RaiseEvent UpdateUI(Me, False)
EgtDraw()
End If
End If
Return True
End Function
Private Function ProcessHide() As Boolean
If m_nStep <> 0 Then Return False
If m_nLast <> GDB_ID.NULL Then
Dim nStat As GDB_ST = GDB_ST.ON_
EgtGetStatus(m_nLast, nStat)
If nStat <> GDB_ST.OFF Then
' nascondo
EnableCommandLog()
EgtSetStatus(m_nLast, GDB_ST.OFF)
DisableCommandLog()
RaiseEvent UpdateUI(Me, False)
EgtDraw()
End If
End If
Return True
End Function
Private Function ProcessChangeStatus() As Boolean
If m_nStep <> 0 Then Return False
If m_nLast = GDB_ID.SEL Then
Dim nEntId As Integer = EgtGetFirstSelectedObj()
while nEntId <> GDB_ID.NULL
Dim nNextEntId As Integer = EgtGetNextSelectedObj()
EnableCommandLog()
EgtSetStatus( nEntId, If( m_bLast, GDB_ST.ON_, GDB_ST.OFF))
DisableCommandLog()
nEntId = nNextEntId
End While
ElseIf m_nLast = GDB_ID.SELLAYER Then
Dim nSelId As Integer = EgtGetLastSelectedObj()
Dim nLayId As Integer = nSelId
If Not EgtIsLayer( nLayId) Then
nLayId = EgtGetParent( nSelId)
End If
If EgtIsLayer( nLayId) Then
EnableCommandLog()
EgtSetStatus( nLayId, If( m_bLast, GDB_ST.ON_, GDB_ST.OFF))
Dim nEntId As Integer = EgtGetFirstInGroup( nLayId)
While nEntId <> GDB_ID.NULL
EgtSetStatus( nEntId, If( m_bLast, GDB_ST.ON_, GDB_ST.OFF))
nEntId = EgtGetNext( nEntId)
End While
DisableCommandLog()
End If
ElseIf m_nLast = GDB_ID.SELPART Then
Dim nSelId As Integer = EgtGetLastSelectedObj()
Dim nPartId As Integer = nSelId
if Not EgtIsPart( nPartId) Then
Dim nLayId As Integer = If( EgtIsLayer( nSelId), nSelId, EgtGetParent( nSelId))
nPartId = EgtGetParent( nLayId)
End If
If EgtIsPart( nPartId) Then
EnableCommandLog()
EgtSetStatus( nPartId, If( m_bLast, GDB_ST.ON_, GDB_ST.OFF))
Dim nGrpId As Integer = EgtGetFirstGroupInGroup( nPartId)
While nGrpId <> GDB_ID.NULL
EgtSetStatus( nGrpId, If( m_bLast, GDB_ST.ON_, GDB_ST.OFF))
Dim nEntId As Integer = EgtGetFirstInGroup( nGrpId)
While nEntId <> GDB_ID.NULL
EgtSetStatus( nEntId, If( m_bLast, GDB_ST.ON_, GDB_ST.OFF))
nEntId = EgtGetNext( nEntId)
End While
nGrpId = EgtGetNextGroup( nGrpId)
End While
DisableCommandLog()
End If
End If
RaiseEvent UpdateUI(Me, True)
EgtDraw()
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_nLast = GDB_ID.NULL Then
Return False
End If
' recupero e imposto eventuale nome già assegnato
m_sLast = String.Empty
EgtGetName(m_nLast, m_sLast)
' imposto stato a prima stringa per nome
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("NAME", "Insert Name", "", False, False)
m_nInpType = IBT.TY_STRING
SetInputBoxString(m_sLast)
Case 1
' assegno o rimuovo il nome
EnableCommandLog()
If Not String.IsNullOrWhiteSpace(m_sLast) Then
EgtSetName(m_nLast, m_sLast)
Else
EgtRemoveName(m_nLast)
End If
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
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_nLast = GDB_ID.NULL Then
Return False
End If
' imposto stato a prima stringa per info
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("INFO" & ";Sic=1", "Insert Info (Key=Val)", "", False, False)
m_nInpType = IBT.TY_STRING
Case 1
' divido su eventuali a capo (una Info per linea)
Dim sInfos() As String = m_sLast.Split(ControlChars.CrLf.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
For Each sInfo As String In sInfos
' divido la stringa in chiave e valore
Dim sItems() As String = sInfo.Split("=".ToCharArray, 2)
If sItems.Count() = 2 Then
' ammesse info standard oppure di sistema con livello utente adeguato
If Not sItems(0).Trim().StartsWith( "!") Or EgtGetUserLevel() >= 6 Then
' assegno o rimuovo l'info
EnableCommandLog()
If Not String.IsNullOrWhiteSpace(sItems(1)) Then
EgtSetInfo(m_nLast, sItems(0), sItems(1))
Else
EgtRemoveInfo(m_nLast, sItems(0))
End If
DisableCommandLog()
Else
EgtOutLog( "Warning : Try to set System Info without adequate User Level")
End If
End If
Next
' 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 ProcessPoint() 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.EnableDrag()
' imposto stato a primo punto per point
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("POINT", "Insert Point", "", False, True)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
' reset scena
m_Scene.ResetStatus(False)
' creo il punto (i dati sono in globale)
EnableCommandLog()
If EgtCreateGeoPoint(GetCurrLayer(), m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID) <> GDB_ID.NULL Then
m_ptCont = m_ptLast
End If
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragPoint()
' il gruppo di Drag ha riferimento globale
If m_nStep = 1 Then
' svuoto il gruppo di drag
EgtEmptyGroup(m_Scene.GetDragGroup())
' creo il punto
EgtCreateGeoPoint(m_Scene.GetDragGroup(), m_ptLast, GDB_RT.GLOB)
EgtDraw()
End If
End Sub
Private Function ProcessVector() 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.EnableDrag()
' imposto stato a primo punto per vector
m_Scene.SetStatusSelPoint(True)
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("VECTOR", "Insert Start Point", "", False, True)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_vtLast = 10 * m_vtCont
m_nStep = 2
m_Scene.DisableDrag()
RaiseEvent PrepareInputBox("VECTOR", "Insert Vector ", "", False, True)
m_nInpType = IBT.TY_VECTOR3D
SetInputBoxVector3d(m_vtLast)
EgtDisableModified()
DragVector()
EgtEnableModified()
Case 2
' reset scena
m_Scene.ResetStatus(False)
' creo il vettore (i dati sono in globale)
EnableCommandLog()
If EgtCreateGeoVector(GetCurrLayer(), m_vtLast.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID), GDB_RT.GRID) <> GDB_ID.NULL Then
m_ptCont = m_ptP1
m_vtCont = m_vtLast
m_vtCont.Normalize()
End If
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragVector()
' il gruppo di Drag ha riferimento globale
If m_nStep = 2 Then
' svuoto il gruppo di drag
EgtEmptyGroup(m_Scene.GetDragGroup())
' creo il vettore
EgtCreateGeoVector(m_Scene.GetDragGroup(), m_vtLast, m_ptP1, GDB_RT.GLOB)
EgtDraw()
End If
End Sub
Private Function ProcessFrame() 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.EnableDrag()
' imposto stato a primo punto per point
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("FRAME", "Insert Origin", "", False, True)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
' reset scena
m_Scene.ResetStatus(False)
' creo il frame allineato con grid (i dati sono in globale)
EnableCommandLog()
If EgtCreateGeoFrame(GetCurrLayer(), New Frame3d(m_ptLast.Loc(GDB_ID.GRID)), GDB_RT.GRID) <> GDB_ID.NULL Then
m_ptCont = m_ptLast
End If
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragFrame()
' il gruppo di Drag ha riferimento globale
If m_nStep = 1 Then
' svuoto il gruppo di drag
EgtEmptyGroup(m_Scene.GetDragGroup())
' creo il frame
Dim frNew As Frame3d = EgtGetGridFrame()
frNew.ChangeOrigin(m_ptLast)
EgtCreateGeoFrame(m_Scene.GetDragGroup(), frNew, GDB_RT.GLOB)
EgtDraw()
End If
End Sub
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, 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_ptCont = m_ptLast
m_nStep = 2
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("LINE 2P", "Insert End Point ", "", False, True)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptLast)
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)
EnableCommandLog()
Dim nId As Integer = EgtCreateLineEx(GetCurrLayer(),
m_ptP1.Loc(GDB_ID.GRID), m_sepP1, m_nIdP1,
m_ptLast.Loc(GDB_ID.GRID), m_sepLast, m_nIdLast, GDB_RT.GRID)
' se richiesta curva composita e creazione riuscita
If m_bContinue And nId <> GDB_ID.NULL Then
If m_nContinueId = GDB_ID.NULL Then
m_nContinueId = EgtCreateCurveCompo(GetCurrLayer(), nId, True)
nId = m_nContinueId
Else
If EgtAddCurveCompoCurve(m_nContinueId, nId, True) Then
nId = m_nContinueId
Else
nId = GDB_ID.NULL
End If
End If
End If
DisableCommandLog()
If nId <> GDB_ID.NULL Then
m_ptCont = m_ptLast
m_vtCont = (m_ptLast - m_ptP1)
m_vtCont.Normalize()
End If
EgtDraw()
' aggiorno stato
RaiseEvent UpdateUI(Me, True)
' se continuazione
If m_bContinue Then
' Se creazione riuscita e non ho chiuso la curva, vedo di continuare ...
If nId <> GDB_ID.NULL AndAlso Not EgtCurveIsClosed(nId) Then
ContinueLine2P()
Else
ResetStatus( False)
End If
Else
m_nStep = 0
End If
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
EgtCreateLine(m_Scene.GetDragGroup(), m_ptP1, m_ptLast, GDB_RT.GLOB)
Else
EgtModifyCurveEndPoint(nId, m_ptLast, GDB_RT.GLOB)
End If
' altrimenti, uno dei punti tangente o normale
Else
EgtErase(nId)
EgtCreateLineEx(m_Scene.GetDragGroup(), m_ptP1, m_sepP1, m_nIdP1, m_ptLast, m_sepLast, m_nIdLast, GDB_RT.GLOB)
End If
EgtDraw()
End If
End Sub
Public Sub ContinueLine2P()
' verifico di essere in modalità continua
If Not m_bContinue Then Return
' pulisco
m_Scene.ResetStatus(False)
' imposto per stato 1 di linea 2P
m_nLastCmd = CMD.LINE2P
m_nStep = 1
m_Scene.CreateDragGroup()
m_Scene.SetStatusSelPoint()
m_ptLast = m_ptCont
m_sepLast = SEP.PT_STD
m_nIdLast = GDB_ID.NULL
' processo stato 1 per essere sul 2
ProcessLine2P()
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, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_vtLast = m_vtCont
m_dAux = m_dLastLen
' 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", "", False, True)
m_nInpType = IBT.TY_DIRECTION
m_dLast = GridAngFromGlobDir(m_vtLast)
SetInputBoxDouble(m_dLast)
EgtDisableModified()
DragLinePDL()
EgtEnableModified()
Case 2
m_dPrev = m_dLast
m_vtLast = GlobDirFromGridAng(m_dPrev)
m_dLast = m_dAux
m_nStep = 3
m_Scene.DisableDrag()
EgtUnselectableRemove(m_Scene.GetDragGroup())
RaiseEvent PrepareInputBox("LINE PDL", "Insert Length", "", False, True)
m_nInpType = IBT.TY_LENGTH
SetInputBoxDouble(m_dLast, True)
EgtDisableModified()
DragLinePDL()
EgtEnableModified()
Case 3
' reset scena
m_Scene.ResetStatus(False)
' creo la linea (i punti sono in globale)
EnableCommandLog()
Dim nId As Integer = EgtCreateLinePDL(GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID),
m_dPrev, m_dLast, GDB_RT.GRID)
DisableCommandLog()
If nId <> GDB_ID.NULL Then
m_vtCont = m_vtLast
m_ptCont = m_ptP1 + m_vtCont * m_dLast
End If
EgtDraw()
' aggiorno stato
m_dLastLen = m_dLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragLinePDL()
If m_nStep = 2 Then ' inserimento direzione
' 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
EgtCreateLinePDL(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID), m_dLast, m_dAux, GDB_RT.GRID)
Else
Dim ptP2 As Point3d = m_ptP1.Loc(GDB_ID.GRID) + Vector3d.FromPolar(1, m_dLast) * m_dAux
EgtModifyCurveEndPoint(nId, ptP2, GDB_RT.GRID)
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
EgtCreateLinePDL(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID), m_dPrev, m_dLast, GDB_RT.GRID)
Else
Dim ptP2 As Point3d = m_ptP1.Loc(GDB_ID.GRID) + Vector3d.FromPolar(1, m_dPrev) * m_dLast
EgtModifyCurveEndPoint(nId, ptP2, GDB_RT.GRID)
End If
EgtDraw()
End If
End Sub
Private Function ProcessLinePVL() 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 PVL", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_vtLast = m_vtCont
m_dAux = m_dLastLen
' posso prendere punto per definire direzione, ma non prendo direzione notevole
m_Scene.SetStatusSelPoint(False)
m_nStep = 2
m_Scene.DisableDrag()
RaiseEvent PrepareInputBox("LINE PVL", "Insert Direction Vector", "", False, True)
m_nInpType = IBT.TY_VECTOR3D
SetInputBoxVector3d(m_vtLast)
EgtDisableModified()
DragLinePVL()
EgtEnableModified()
Case 2
m_dLast = m_dAux
m_nStep = 3
m_Scene.DisableDrag()
EgtUnselectableRemove(m_Scene.GetDragGroup())
RaiseEvent PrepareInputBox("LINE PVL", "Insert Length", "", False, True)
m_nInpType = IBT.TY_LENGTH
SetInputBoxDouble(m_dLast, True)
EgtDisableModified()
DragLinePVL()
EgtEnableModified()
Case 3
' reset scena
m_Scene.ResetStatus(False)
' creo la linea (i punti sono in globale)
EnableCommandLog()
Dim nId As Integer = EgtCreateLinePVL(GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID),
m_vtLast.Loc(GDB_ID.GRID), m_dLast, GDB_RT.GRID)
DisableCommandLog()
If nId <> GDB_ID.NULL Then
m_vtCont = m_vtLast
m_vtCont.Normalize()
m_ptCont = m_ptP1 + m_vtCont * m_dLast
End If
EgtDraw()
' aggiorno stato
m_dLastLen = m_dLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragLinePVL()
If m_nStep = 2 Then ' inserimento direzione
' 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
EgtCreateLinePVL(m_Scene.GetDragGroup(), m_ptP1, m_vtLast, m_dAux, GDB_RT.GLOB)
Else
m_vtLast.Normalize()
Dim ptP2 As Point3d = m_ptP1 + m_vtLast * m_dAux
EgtModifyCurveEndPoint(nId, ptP2, GDB_RT.GLOB)
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
EgtCreateLinePVL(m_Scene.GetDragGroup(), m_ptP1, m_vtLast, m_dLast, GDB_RT.GLOB)
Else
m_vtLast.Normalize()
Dim ptP2 As Point3d = m_ptP1 + m_vtLast * 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, False)
m_nInpType = IBT.TY_POINT3D
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("CIRCLE CP", "Insert Point", "", False, True)
m_nInpType = IBT.TY_POINT3D
m_Scene.EnableTangentPoint()
Case 2
' reset scena
m_Scene.ResetStatus(False)
' creo la circonferenza (i punti sono in globale)
EnableCommandLog()
Dim nId As Integer = EgtCreateCircleCPEx(GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), m_sepLast, m_nIdLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub 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
EgtCreateCircleCP(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
Else
EgtModifyCircleCP(nId, m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
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, False)
m_nInpType = IBT.TY_POINT3D
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
m_Scene.SetStatusNull()
m_Scene.DisableDrag()
RaiseEvent PrepareInputBox("CIRCLE CD", "Insert Diameter", "", False, True)
m_nInpType = IBT.TY_LENGTH
m_dLast = m_dLastDiam
SetInputBoxDouble(m_dLast, True)
EgtDisableModified()
DragCircleCD()
EgtEnableModified()
Case 2
' reset scena
m_Scene.ResetStatus(False)
' creo la circonferenza (i punti sono in globale)
EnableCommandLog()
Dim nId As Integer = EgtCreateCircle(GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID),
0.5 * m_dLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_dLastDiam = m_dLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
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
EgtCreateCircle(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID), 0.5 * m_dLast, GDB_RT.GRID)
Else
EgtModifyArcRadius(nId, 0.5 * m_dLast)
End If
EgtDraw()
End If
End Sub
Private Function ProcessCircle3P() 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 Circle3P
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("CIRCLE 3P", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("CIRCLE 3P", "Insert End Point", "", False, True)
m_nInpType = IBT.TY_POINT3D
Case 2
m_ptP2 = m_ptLast
m_nStep = 3
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("CIRCLE 3P", "Insert Mid Point", "", False, True)
m_nInpType = IBT.TY_POINT3D
Case 3
' reset scena
m_Scene.ResetStatus(False)
' creo l'arco (i punti sono in globale)
EnableCommandLog()
Dim nId As Integer = GDB_ID.NULL
If AreSamePointApprox( m_ptP1, m_ptP2) Then
nId = EgtCreateCircle2P( GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID), m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
ElseIf AreSamePointApprox( m_ptP1, m_ptLast) Then
nId = EgtCreateCircle2P( GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID), GDB_RT.GRID)
ElseIf AreSamePointApprox( m_ptLast, m_ptP2) Then
nId = EgtCreateCircle2P( GetCurrLayer(), m_ptLast.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID), GDB_RT.GRID)
Else
nId = EgtCreateCircle3P( GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID), GDB_RT.GRID)
End If
DisableCommandLog()
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
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragCircle3P()
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
EgtCreateLine(m_Scene.GetDragGroup(), m_ptP1, m_ptLast, GDB_RT.GLOB)
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
EgtEmptyGroup(m_Scene.GetDragGroup())
If AreSamePointApprox( m_ptP1, m_ptP2) Then
EgtCreateCircle2P( m_Scene.GetDragGroup(), m_ptP1, m_ptLast, GDB_RT.GLOB)
ElseIf AreSamePointApprox( m_ptP1, m_ptLast) Then
EgtCreateCircle2P( m_Scene.GetDragGroup(), m_ptP1, m_ptP2, GDB_RT.GLOB)
ElseIf AreSamePointApprox( m_ptLast, m_ptP2) Then
EgtCreateCircle2P( m_Scene.GetDragGroup(), m_ptLast, m_ptP1, GDB_RT.GLOB)
Else
EgtCreateCircle3P( m_Scene.GetDragGroup(), m_ptP1, m_ptLast, m_ptP2, GDB_RT.GLOB)
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, 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", "", False, True)
m_nInpType = IBT.TY_POINT3D
m_Scene.EnableTangentPoint()
Case 2
m_ptP2 = m_ptLast
m_sepP2 = m_sepLast
m_nIdP2 = m_nIdLast
m_nStep = 3
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("ARC CSE", "Insert Point Near End", "", False, True)
m_nInpType = IBT.TY_POINT3D
m_Scene.DisableTangentPoint()
Case 3
' reset scena
m_Scene.ResetStatus(False)
' creo l'arco (i punti sono in globale)
EnableCommandLog()
Dim nId = EgtCreateArcC2PEx(GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID),
m_ptP2.Loc(GDB_ID.GRID), m_sepP2, m_nIdP2,
m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
DisableCommandLog()
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
RaiseEvent UpdateUI(Me, True)
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)
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
EgtCreateArcC2PEx(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID),
m_ptP2.Loc(GDB_ID.GRID), m_sepP2, m_nIdP2,
m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
Else
EgtModifyArcC2P(nId, m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
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, 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", "", False, 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", "", False, True)
m_nInpType = IBT.TY_POINT3D
Case 3
' reset scena
m_Scene.ResetStatus(False)
' creo l'arco (i punti sono in globale)
EnableCommandLog()
Dim nId = EgtCreateArc3P(GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID), GDB_RT.GRID)
DisableCommandLog()
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
RaiseEvent UpdateUI(Me, True)
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
EgtCreateLine(m_Scene.GetDragGroup(), m_ptP1, m_ptLast, GDB_RT.GLOB)
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
' creazione arco 3P, in alcuni casi crea una retta
EgtCreateArc3P(m_Scene.GetDragGroup(), m_ptP1, m_ptLast, m_ptP2, GDB_RT.GLOB)
Else
' se modifica arco 3P impossibile, provo con una retta
If (Not EgtModifyArc3P(nId, m_ptLast, GDB_RT.GLOB) AndAlso
(m_ptLast - m_ptP1) * (m_ptP2 - m_ptLast) > EPS_ZERO) Then
EgtErase(nId)
EgtCreateLine(m_Scene.GetDragGroup(), m_ptP1, m_ptP2, GDB_RT.GLOB)
End If
End If
EgtDraw()
End If
End Sub
Private Function ProcessArc2PR() 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 2PR", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("ARC 2PR", "Insert End Point", "", False, True)
m_nInpType = IBT.TY_POINT3D
Case 2
m_ptP2 = m_ptLast
m_nStep = 3
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("ARC 2PR", "Insert Radius", "CCW", False, True)
m_nInpType = IBT.TY_DOUBLE
m_dLast = Point3d.Dist( m_ptP1, m_ptP2)
SetInputBoxDouble( m_dLast, True)
Case 3
' reset scena
m_Scene.ResetStatus(False)
' creo l'arco (i punti sono in globale)
EnableCommandLog()
Dim nId = EgtCreateArc2PR(GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID),
m_ptP2.Loc(GDB_ID.GRID), m_dLast, m_bLast, GDB_RT.GRID)
DisableCommandLog()
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
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragArc2PR()
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
EgtCreateLine(m_Scene.GetDragGroup(), m_ptP1, m_ptLast, GDB_RT.GLOB)
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())
EgtErase(nId)
' creazione arco 2PR
Dim dMinRad As Double = Point3d.Dist( m_ptP1, m_ptP2) / 2
if m_dLast < dMinRad Then
m_dLast = dMinRad
SetInputBoxDouble( m_dLast, True)
End If
EgtCreateArc2PR(m_Scene.GetDragGroup(), m_ptP1, m_ptP2, m_dLast, m_bLast, GDB_RT.GLOB)
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 ArcPDP
m_Scene.SetStatusSelPoint(True)
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("ARC PDP", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_vtLast = m_vtCont
m_dAux = LEN_STD
m_ptCont = m_ptLast
m_Scene.SetStatusSelPoint(False)
m_nStep = 2
m_Scene.DisableDrag()
RaiseEvent PrepareInputBox("ARC PDP", "Insert Direction", "", False, True)
m_nInpType = IBT.TY_DIRECTION
m_dLast = GridAngFromGlobDir(m_vtLast)
SetInputBoxDouble(m_dLast)
EgtDisableModified()
DragArcPDP()
EgtEnableModified()
Case 2
m_nStep = 3
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("ARC PDP", "Insert End Point", "", False, True)
m_nInpType = IBT.TY_POINT3D
m_Scene.EnableTangentPoint()
Case 3
' reset scena
m_Scene.ResetStatus(False)
' creo l'arco (i punti sono in globale)
EnableCommandLog()
Dim nId = EgtCreateArc2PDEx(GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID), m_ptLast.Loc(GDB_ID.GRID),
m_sepLast, m_nIdLast, m_dLast, GDB_RT.GRID)
' se richiesta curva composita e creazione riuscita
If m_bContinue And nId <> GDB_ID.NULL Then
If m_nContinueId = GDB_ID.NULL Then
m_nContinueId = EgtCreateCurveCompo(GetCurrLayer(), nId, True)
nId = m_nContinueId
Else
If EgtAddCurveCompoCurve(m_nContinueId, nId, True) Then
nId = m_nContinueId
Else
nId = GDB_ID.NULL
End If
End If
End If
DisableCommandLog()
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
RaiseEvent UpdateUI(Me, True)
' se continuazione, creazione riuscita e non ho chiuso la curva, vedo di continuare ...
If m_bContinue Then
If nId <> GDB_ID.NULL AndAlso Not EgtCurveIsClosed(nId) Then
ContinueArcPDP()
Else
ResetStatus( False)
End If
Else
m_nStep = 0
End If
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragArcPDP()
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
' creo la linea di direzione
EgtCreateLinePDL(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID),
m_dLast, m_dAux, GDB_RT.GRID)
Else
Dim ptP2 As Point3d = m_ptP1 + GlobDirFromGridAng(m_dLast) * m_dAux
EgtModifyCurveEndPoint(nId, ptP2.Loc(GDB_ID.GRID), GDB_RT.GRID)
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
' se arco da creare
If nId = GDB_ID.NULL Then
' creo l'arco (i punti sono in globale), in alcuni casi particolari crea una retta
EgtCreateArc2PD(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), m_dLast, GDB_RT.GRID)
' altrimenti da modificare
Else
' determino il versore direzione iniziale
Dim vtDirS As Vector3d = GlobDirFromGridAng(m_dLast)
' se modifica arco impossibile, provo con una retta
If (Not EgtModifyCurveEndPoint(nId, m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID) AndAlso
(m_ptLast - m_ptP1) * vtDirS > EPS_ZERO) Then
EgtErase(nId)
EgtCreateLine(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
End If
End If
EgtDraw()
End If
End Sub
Public Sub ContinueArcPDP()
' verifico di essere in modalità continua
If Not m_bContinue Then Return
' pulisco
m_Scene.ResetStatus(False)
' imposto per stato 1 di arco PDP
m_nLastCmd = CMD.ARCPDP
m_nStep = 1
m_Scene.CreateDragGroup()
m_Scene.SetStatusSelPoint(True)
m_ptLast = m_ptCont
m_vtLast = m_vtCont
' processo stato 1 per essere sul 2
ProcessArcPDP()
End Sub
Private Function ProcessArcPVP() 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 PVP", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_vtLast = m_vtCont
m_dAux = LEN_STD
m_Scene.SetStatusSelPoint(False)
m_nStep = 2
m_Scene.DisableDrag()
RaiseEvent PrepareInputBox("ARC PVP", "Insert Direction Vector", "", False, True)
m_nInpType = IBT.TY_VECTOR3D
SetInputBoxVector3d(m_vtLast)
EgtDisableModified()
DragArcPVP()
EgtEnableModified()
Case 2
m_nStep = 3
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("ARC PVP", "Insert End Point", "", False, True)
m_nInpType = IBT.TY_POINT3D
Case 3
' reset scena
m_Scene.ResetStatus(False)
' creo l'arco (i punti sono in globale)
EnableCommandLog()
Dim nId = EgtCreateArc2PV(GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID), m_ptLast.Loc(GDB_ID.GRID),
m_vtLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
DisableCommandLog()
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
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragArcPVP()
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
' creo la linea di direzione
EgtCreateLinePVL(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID),
m_vtLast.Loc(GDB_ID.GRID), m_dAux, GDB_RT.GRID)
Else
m_vtLast.Normalize()
Dim ptP2 As Point3d = m_ptP1 + m_vtLast * m_dAux
EgtModifyCurveEndPoint(nId, ptP2.Loc(GDB_ID.GRID), GDB_RT.GRID)
End If
EgtDraw()
ElseIf m_nStep = 3 Then
' svuoto il gruppo di drag
EgtEmptyGroup(m_Scene.GetDragGroup())
' creo l'arco (i punti sono in globale), in alcuni casi particolari crea una retta
EgtCreateArc2PV(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), m_vtLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessBiArc() 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 BiArc
m_Scene.SetStatusSelPoint(True)
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("BIARC", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_vtLast = m_vtCont
m_dAux = LEN_STD
m_ptCont = m_ptLast
m_Scene.SetStatusSelPoint(False)
m_nStep = 2
m_Scene.DisableDrag()
RaiseEvent PrepareInputBox("BIARC", "Insert Start Direction", "", False, False)
m_nInpType = IBT.TY_DIRECTION
m_dLast = GridAngFromGlobDir(m_vtLast)
SetInputBoxDouble(m_dLast)
EgtDisableModified()
DragBiArc()
EgtEnableModified()
Case 2
m_ptP2 = m_ptP1
m_dPrev = m_dLast
m_Scene.SetStatusSelPoint(True)
m_nStep = 3
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("BIARC", "Insert End Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Case 3
m_ptP1 = m_ptLast
m_ptCont = m_ptLast
m_vtLast = -m_vtCont
m_Scene.SetStatusSelPoint(False)
m_nStep = 4
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("BIARC", "Insert End Direction", "", False, True)
m_nInpType = IBT.TY_DIRECTION
m_dLast = GridAngFromGlobDir(m_vtLast)
SetInputBoxDouble(m_dLast)
Case 4
m_dAux = m_dLast
m_nStep = 5
m_Scene.DisableDrag()
RaiseEvent PrepareInputBox("BIARC", "Insert Param", "", False, True)
m_nInpType = IBT.TY_DOUBLE
m_dLast = 0.5
SetInputBoxDouble(m_dLast)
Case 5
' reset scena
m_Scene.ResetStatus(False)
' creo il biarco (i punti sono in globale)
m_dLast = Math.Max( Math.Min( m_dLast, 0.9), 0.1)
EnableCommandLog()
EgtCreateBiArc( GetCurrLayer(), m_ptP2.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID), m_dPrev, m_dAux, m_dLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
RaiseEvent UpdateUI(Me, True)
m_nStep = 0
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragBiArc()
If m_nStep = 2 Then
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
EgtEmptyGroup( m_Scene.GetDragGroup())
' creo la linea di direzione
EgtCreateLinePDL(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID), m_dLast, m_dAux, GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 3 Then
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
EgtEmptyGroup( m_Scene.GetDragGroup())
EgtCreateBiArc( m_Scene.GetDragGroup(), m_ptP2.Loc(GDB_ID.GRID), m_ptLast.Loc(GDB_ID.GRID), m_dPrev, 0, 0.5, GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 4 Then
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
EgtEmptyGroup( m_Scene.GetDragGroup())
EgtCreateBiArc( m_Scene.GetDragGroup(), m_ptP2.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID), m_dPrev, m_dLast, 0.5, GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 5 Then
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
EgtEmptyGroup( m_Scene.GetDragGroup())
m_dLast = Math.Max( Math.Min( m_dLast, 0.9), 0.1)
EgtCreateBiArc( m_Scene.GetDragGroup(), m_ptP2.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID), m_dPrev, m_dAux, m_dLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessCurveBezier() 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 BiArc
m_Scene.SetStatusSelPoint(True)
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("BEZIER CURVE", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_vtLast = m_vtCont
m_dAux = LEN_STD
m_ptCont = m_ptLast
m_Scene.SetStatusSelPoint(False)
m_nStep = 2
m_Scene.DisableDrag()
RaiseEvent PrepareInputBox("BEZIER CURVE", "Insert Start Direction", "", False, False)
m_nInpType = IBT.TY_DIRECTION
m_dLast = GridAngFromGlobDir(m_vtLast)
SetInputBoxDouble(m_dLast)
EgtDisableModified()
DragCurveBezier()
EgtEnableModified()
Case 2
m_ptP2 = m_ptP1
m_dPrev = m_dLast
m_Scene.SetStatusSelPoint(True)
m_nStep = 3
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("BEZIER CURVE", "Insert End Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Case 3
m_ptP1 = m_ptLast
m_ptCont = m_ptLast
m_vtLast = -m_vtCont
m_Scene.SetStatusSelPoint(False)
m_nStep = 4
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("BEZIER CURVE", "Insert End Direction", "", False, True)
m_nInpType = IBT.TY_DIRECTION
m_dLast = GridAngFromGlobDir(m_vtLast)
SetInputBoxDouble(m_dLast)
Case 4
m_dAux = m_dLast
m_nStep = 5
m_Scene.DisableDrag()
RaiseEvent PrepareInputBox("BEZIER CURVE", "Insert Params", "", False, True)
m_nInpType = IBT.TY_DOUBLE
m_d3Last(0) = 0.5
m_d3Last(1) = 0.5
m_nInpType = IBT.TY_2DOUBLE
SetInputBox2Double(m_d3Last)
Case 5
' reset scena
m_Scene.ResetStatus(False)
' creo il biarco (i punti sono in globale)
m_d3Last(0) = Math.Max( Math.Min( m_d3Last(0), 100), 0.01)
m_d3Last(1) = Math.Max( Math.Min( m_d3Last(1), 100), 0.01)
EnableCommandLog()
EgtCreateCurveBezier( GetCurrLayer(), m_ptP2.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID), m_dPrev, m_dAux, m_d3Last(0), m_d3Last(1), GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
RaiseEvent UpdateUI(Me, True)
m_nStep = 0
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragCurveBezier()
If m_nStep = 2 Then
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
EgtEmptyGroup( m_Scene.GetDragGroup())
' creo la linea di direzione
EgtCreateLinePDL(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID), m_dLast, m_dAux, GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 3 Then
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
EgtEmptyGroup( m_Scene.GetDragGroup())
EgtCreateCurveBezier( m_Scene.GetDragGroup(), m_ptP2.Loc(GDB_ID.GRID), m_ptLast.Loc(GDB_ID.GRID), m_dPrev, 0, 0.5, 0.5, GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 4 Then
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
EgtEmptyGroup( m_Scene.GetDragGroup())
EgtCreateCurveBezier( m_Scene.GetDragGroup(), m_ptP2.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID), m_dPrev, m_dLast, 0.5, 0.5, GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 5 Then
' durante la creazione di oggetti il gruppo di Drag ha riferimento globale
EgtEmptyGroup( m_Scene.GetDragGroup())
m_d3Last(0) = Math.Max( Math.Min( m_d3Last(0), 100), 0.01)
m_d3Last(1) = Math.Max( Math.Min( m_d3Last(1), 100), 0.01)
EgtCreateCurveBezier( m_Scene.GetDragGroup(), m_ptP2.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID), m_dPrev, m_dAux, m_d3Last(0), m_d3Last(1), GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessFillet() 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 raggio per Fillet
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("FILLET", "Insert Radius", "Trim", False, True)
RaiseEvent SetInputBoxCheck(True)
m_nInpType = IBT.TY_LENGTH
m_dLast = m_dLastFillet
SetInputBoxDouble(m_dLast, True)
Case 1
' reset scena
m_Scene.ResetStatus(False)
' creo il fillet (i punti sono in globale)
Dim nId1, nSub1, nId2, nSub2 As Integer
Dim ptSel1, ptSel2 As Point3d
EgtGetLastSelInfo(nId2, nSub2, ptSel2)
EgtGetPrevSelInfo(nId1, nSub1, ptSel1)
EnableCommandLog()
EgtCreateCurveFillet(GetCurrLayer(),
nId1, ptSel1.Loc(GDB_ID.GRID), nId2, ptSel2.Loc(GDB_ID.GRID),
m_dLast, m_bLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_dLastFillet = m_dLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragFillet()
' il gruppo di Drag ha riferimento globale
If m_nStep = 1 Then
' svuoto il gruppo di drag
EgtEmptyGroup(m_Scene.GetDragGroup())
' inserisco le due curve nel gruppo di drag
Dim nId1, nSub1, nId2, nSub2 As Integer
Dim ptSel1, ptSel2 As Point3d
EgtGetLastSelInfo(nId2, nSub2, ptSel2)
EgtGetPrevSelInfo(nId1, nSub1, ptSel1)
nId2 = m_Scene.AddToDragGroup(nId2)
nId1 = m_Scene.AddToDragGroup(nId1)
' creo fillet (il gruppo di Drag ha riferimento globale)
EgtCreateCurveFillet(m_Scene.GetDragGroup(),
nId1, ptSel1.Loc(GDB_ID.GRID), nId2, ptSel2.Loc(GDB_ID.GRID),
m_dLast, m_bLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessChamfer() 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 raggio per Fillet
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("CHAMFER", "Insert distance", "Trim", False, True)
RaiseEvent SetInputBoxCheck(True)
m_nInpType = IBT.TY_LENGTH
m_dLast = m_dLastChamfer
SetInputBoxDouble(m_dLast, True)
Case 1
' reset scena
m_Scene.ResetStatus(False)
' creo il fillet (i punti sono in globale)
Dim nId1, nSub1, nId2, nSub2 As Integer
Dim ptSel1, ptSel2 As Point3d
EgtGetLastSelInfo(nId2, nSub2, ptSel2)
EgtGetPrevSelInfo(nId1, nSub1, ptSel1)
EnableCommandLog()
EgtCreateCurveChamfer(GetCurrLayer(),
nId1, ptSel1.Loc(GDB_ID.GRID), nId2, ptSel2.Loc(GDB_ID.GRID),
m_dLast, m_bLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_dLastChamfer = m_dLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragChamfer()
' il gruppo di Drag ha riferimento globale
If m_nStep = 1 Then
' svuoto il gruppo di drag
EgtEmptyGroup(m_Scene.GetDragGroup())
' inserisco le due curve nel gruppo di drag
Dim nId1, nSub1, nId2, nSub2 As Integer
Dim ptSel1, ptSel2 As Point3d
EgtGetLastSelInfo(nId2, nSub2, ptSel2)
EgtGetPrevSelInfo(nId1, nSub1, ptSel1)
nId2 = m_Scene.AddToDragGroup(nId2)
nId1 = m_Scene.AddToDragGroup(nId1)
' creo chamfer (il gruppo di Drag ha riferimento globale)
EgtCreateCurveChamfer(m_Scene.GetDragGroup(),
nId1, ptSel1.Loc(GDB_ID.GRID), nId2, ptSel2.Loc(GDB_ID.GRID),
m_dLast, m_bLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessRectangle2P() 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 Rectangle2P
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("RECTANGLE 2P", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
RaiseEvent PrepareInputBox("RECTANGLE 2P", "Insert End Point", "", False, True)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptLast)
Case 2
' reset scena
m_Scene.ResetStatus(False)
' creo il rettangolo (i punti sono in globale)
EnableCommandLog()
Dim nId As Integer = EgtCreateRectangle2P(GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragRectangle2P()
' 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())
EgtErase(nId)
' creo il rettangolo (drag è in globale)
EgtCreateRectangle2P(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessPolygon() 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 numero lati per PolygonSide
m_nStep = 1
m_Scene.SetStatusNull()
' abilito dialogo
RaiseEvent PrepareInputBox("POLYGON", "Insert Side Nbr", "", False, False)
m_nInpType = IBT.TY_INTEGER
m_nLast = 3
SetInputBoxInteger(m_nLast)
Case 1
m_Scene.SetStatusSelPoint()
m_nStep = 2
RaiseEvent PrepareInputBox("POLYGON", "Insert Center Point", "Internal Radius", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
RaiseEvent SetInputBoxCheck(False)
Case 2
m_ptP1 = m_ptLast
m_nStep = 3
RaiseEvent PrepareInputBox("POLYGON", "Insert Side Point", "Internal Radius", False, True)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptLast)
Case 3
' reset scena
m_Scene.ResetStatus(False)
' creo il poligono (i punti sono in globale)
EnableCommandLog()
Dim nId As Integer = GDB_ID.NULL
If Not m_bLast Then
nId = EgtCreatePolygonFromRadius(GetCurrLayer(), m_nLast, m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
Else
nId = EgtCreatePolygonFromApothem(GetCurrLayer(), m_nLast, m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
End If
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragPolygon()
' il gruppo di Drag ha riferimento globale
If m_nStep = 3 Then
EgtSetGeoLine(m_ptP1, m_ptLast)
' recupero possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
EgtErase(nId)
' creo il poligono (drag è in globale)
If Not m_bLast Then
EgtCreatePolygonFromRadius(m_Scene.GetDragGroup(), m_nLast, m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
Else
EgtCreatePolygonFromApothem(m_Scene.GetDragGroup(), m_nLast, m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
End If
EgtDraw()
End If
End Sub
Private Function ProcessPolygonSide() 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 numero lati per PolygonSide
m_nStep = 1
m_Scene.SetStatusNull()
' abilito dialogo
RaiseEvent PrepareInputBox("POLYGON SIDE", "Insert Side Nbr", "", False, False)
m_nInpType = IBT.TY_INTEGER
m_nLast = 3
SetInputBoxInteger(m_nLast)
Case 1
m_Scene.SetStatusSelPoint()
m_nStep = 2
RaiseEvent PrepareInputBox("POLYGON SIDE", "Insert Side Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 2
m_ptP1 = m_ptLast
m_nStep = 3
RaiseEvent PrepareInputBox("POLYGON SIDE", "Insert Side End Point", "", False, True)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptLast)
Case 3
' reset scena
m_Scene.ResetStatus(False)
' creo il poligono (i punti sono in globale)
EnableCommandLog()
Dim nId As Integer = EgtCreatePolygonFromSide(GetCurrLayer(), m_nLast, m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragPolygonSide()
' il gruppo di Drag ha riferimento globale
If m_nStep = 3 Then
' recupero possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
EgtErase(nId)
' creo il poligono (drag è in globale)
EgtCreatePolygonFromSide(m_Scene.GetDragGroup(), m_nLast, m_ptP1.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessText() 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 Text
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("TEXT", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox("TEXT", "Insert Text", "", False, True)
m_nInpType = IBT.TY_STRING
m_sLast = String.Empty
Case 2
' aggiorno testo in drag (necessario se non è stato richiesto preview in precedenza)
EgtDisableModified()
DragText()
EgtEnableModified()
' gestisco altezza
m_nStep = 3
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox("TEXT", "Insert Height", "", False, True)
m_nInpType = IBT.TY_LENGTH
m_dLast = m_dLastTextH
SetInputBoxDouble(m_dLast, True)
Case 3
' reset scena
m_Scene.ResetStatus(False)
' creo l'entità testo (i punti sono in globale)
EnableCommandLog()
Dim nId As Integer = EgtCreateText(GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID),
m_sLast, m_dLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_dLastTextH = m_dLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragText()
' 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())
EgtErase(nId)
' creo il testo (drag è in globale)
EgtCreateText(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID),
m_sLast, m_dLastTextH, GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 3 Then
' recupero possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
EgtErase(nId)
' creo il testo (drag è in globale)
EgtCreateText(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID),
m_sLast, m_dLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessTextPlus() 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 Text Plus
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("TEXT+", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
RaiseEvent PrepareInputBox("TEXT+", "Insert Dir Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptP1 + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 2
m_ptP2 = m_ptLast
If Point3d.SameApprox(m_ptP1, m_ptP2) Then
m_ptP2.x += 10
End If
m_nStep = 3
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox("TEXT+", "Insert Text", "", False, True)
m_nInpType = IBT.TY_STRING
m_sLast = String.Empty
Case 3
m_nStep = 4
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox("TEXT+", "Insert Height", "Italic", True, True)
m_nInpType = IBT.TY_LENGTH
m_dLast = m_dLastTextH
SetInputBoxDouble(m_dLast, True)
m_bLast = False
RaiseEvent SetInputBoxCheck(m_bLast)
LoadFonts()
Dim sDefaultFont As String = String.Empty
EgtGetDefaultFont(sDefaultFont)
For i As Integer = 0 To m_sFonts.Count() - 1
Dim bSel = (String.Compare(m_sFonts(i), sDefaultFont, True) = 0)
RaiseEvent AddInputBoxCombo(m_sFonts(i), bSel)
Next
Case 4
' reset scena
m_Scene.ResetStatus(False)
' determino il font
Dim sFont As String = String.Empty
If m_nLast >= 0 And m_nLast < m_sFonts.Count() Then
sFont = m_sFonts(m_nLast)
End If
' determino l'angolo di rotazione
Dim vtDir As Vector3d = (m_ptP2 - m_ptP1).Loc(GDB_ID.GRID)
Dim dLen, dAngVertDeg, dAngRotDeg As Double
vtDir.ToSpherical(dLen, dAngVertDeg, dAngRotDeg)
' creo l'entità testo (i punti sono in globale)
EnableCommandLog()
Dim nId As Integer = EgtCreateTextEx(GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID), dAngRotDeg,
m_sLast, sFont, m_bLast, m_dLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_dLastTextH = m_dLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragTextPlus()
' il gruppo di Drag ha riferimento globale
If m_nStep = 2 Then
' linea di base
EgtSetGeoLine(m_ptP1, m_ptLast)
ElseIf m_nStep = 3 Then
' linea di base
EgtSetGeoLine(m_ptP1, m_ptP2)
' recupero possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
EgtErase(nId)
' determino l'angolo di rotazione
Dim vtDir As Vector3d = (m_ptP2 - m_ptP1).Loc(GDB_ID.GRID)
Dim dLen, dAngVertDeg, dAngRotDeg As Double
vtDir.ToSpherical(dLen, dAngVertDeg, dAngRotDeg)
' creo il testo (drag è in globale)
EgtCreateTextEx(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID), dAngRotDeg,
m_sLast, "", False, m_dLastTextH, GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 4 Then
' linea di base
EgtSetGeoLine(m_ptP1, m_ptP2)
' recupero possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
EgtErase(nId)
' determino il font
Dim sFont As String = String.Empty
If m_nLast >= 0 And m_nLast < m_sFonts.Count() Then
sFont = m_sFonts(m_nLast)
End If
' determino l'angolo di rotazione
Dim vtDir As Vector3d = (m_ptP2 - m_ptP1).Loc(GDB_ID.GRID)
Dim dLen, dAngVertDeg, dAngRotDeg As Double
vtDir.ToSpherical(dLen, dAngVertDeg, dAngRotDeg)
' creo il testo (drag è in globale)
EgtCreateTextEx(m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID), dAngRotDeg,
m_sLast, sFont, m_bLast, m_dLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessLinearDimension() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto stato a primo punto per AlignedDimension
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("LINEAR DIMENSION", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
RaiseEvent PrepareInputBox( "LINEAR DIMENSION", "Insert End Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptP1 + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 2
m_ptP2 = m_ptLast
m_nStep = 3
RaiseEvent PrepareInputBox( "LINEAR DIMENSION", "Insert Text Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptP2 + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 3
m_ptP3 = m_ptLast
m_nStep = 4
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox( "LINEAR DIMENSION", "Insert Text", "", False, True)
m_nInpType = IBT.TY_STRING
m_sLast = "<>"
SetInputBoxString( m_sLast)
Case 4
' reset scena
m_Scene.ResetStatus(False)
' creo l'entità quota lineare (i punti sono in globale)
EnableCommandLog()
Dim ptP3 As Point3d = AdjustPointForDimension(m_ptP3)
CalcLinearDimensionType(ptP3)
EgtCreateLinearDimension(GetCurrLayer(), m_nLinDimType, m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
ptP3.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragLinearDimension()
' il gruppo di Drag ha riferimento globale
If m_nStep = 2 Then
' linea di base
EgtSetGeoLine( m_ptP1, m_ptLast)
ElseIf m_nStep = 3 Then
' linea di base
EgtSetGeoLine( m_ptP1, m_ptP2)
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota lineare (drag è in globale)
Dim ptLast As Point3d = AdjustPointForDimension(m_ptLast)
CalcLinearDimensionType(m_ptLast)
EgtCreateLinearDimension(m_Scene.GetDragGroup(), m_nLinDimType, m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
ptLast.Loc(GDB_ID.GRID), "<>", GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 4 Then
' linea di base
EgtSetGeoLine( m_ptP1, m_ptP2)
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota allineata (drag è in globale)
Dim ptP3 As Point3d = AdjustPointForDimension(m_ptP3)
CalcLinearDimensionType(ptP3)
EgtCreateLinearDimension(m_Scene.GetDragGroup(), m_nLinDimType, m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
ptP3.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Sub CalcLinearDimensionType( ptText As Point3d)
Dim ptP1 As Point3d = m_ptP1.Loc(GDB_ID.GRID)
Dim ptP2 As Point3d = m_ptP2.Loc(GDB_ID.GRID)
if Point3d.SameApprox( ptP1, ptP2) Then
m_nLinDimType = LINDIM_TYPE.NONE
ElseIf Math.Abs( ptP1.y - ptP2.y) < EPS_SMALL Then
m_nLinDimType = LINDIM_TYPE.HORIZONTAL
ElseIf Math.Abs( ptP1.x - ptP2.x) < EPS_SMALL Then
m_nLinDimType = LINDIM_TYPE.VERTICAL
Else
Dim ptP3 As Point3d = ptText.Loc(GDB_ID.GRID)
Dim dXmin = Math.Min( ptP1.x, ptP2.x)
Dim dXmax = Math.Max( ptP1.x, ptP2.x)
Dim dYmin = Math.Min( ptP1.y, ptP2.y)
Dim dYmax = Math.Max( ptP1.y, ptP2.y)
if ptP3.x > dXmin And ptP3.x < dXmax Then
If ptP3.y <= dYmin Or ptP3.y >= dYmax Then
m_nLinDimType = LINDIM_TYPE.HORIZONTAL
End If
Elseif ptP3.y > dYmin And ptP3.y < dYmax Then
m_nLinDimType = LINDIM_TYPE.VERTICAL
End If
End If
End Sub
Private Function AdjustPointForDimension(ptP As Point3d) As Point3d
Dim ptP1 As Point3d = m_ptP1.Loc(GDB_ID.GRID)
If Math.Abs(ptP1.z) < EPS_SMALL Then Return ptP
Dim dAngV, dAngH As Double
EgtGetGenericView(dAngV, dAngH)
Dim vtView As Vector3d = Vector3d.FromSpherical(1, dAngV, dAngH)
vtView = vtView.Loc(GDB_ID.GRID)
Dim vtCorr As Vector3d = (ptP1.z * vtView / vtView.z).Glob(GDB_ID.GRID)
Return ptP + vtCorr
End Function
Private Function ProcessAlignedDimension() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto stato a primo punto per AlignedDimension
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("ALIGNED DIMENSION", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
RaiseEvent PrepareInputBox( "ALIGNED DIMENSION", "Insert End Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptP1 + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 2
m_ptP2 = m_ptLast
m_nStep = 3
RaiseEvent PrepareInputBox( "ALIGNED DIMENSION", "Insert Text Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptP2 + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 3
m_ptP3 = m_ptLast
m_nStep = 4
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox( "ALIGNED DIMENSION", "Insert Text", "", False, True)
m_nInpType = IBT.TY_STRING
m_sLast = "<>"
SetInputBoxString( m_sLast)
Case 4
' reset scena
m_Scene.ResetStatus(False)
' creo l'entità quota allineata (i punti sono in globale)
EnableCommandLog()
Dim nId As Integer = EgtCreateAlignedDimension( GetCurrLayer(), m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
m_ptP3.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragAlignedDimension()
' il gruppo di Drag ha riferimento globale
If m_nStep = 2 Then
' linea di base
EgtSetGeoLine( m_ptP1, m_ptLast)
ElseIf m_nStep = 3 Then
' linea di base
EgtSetGeoLine( m_ptP1, m_ptP2)
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota allineata (drag è in globale)
EgtCreateAlignedDimension( m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
m_ptLast.Loc(GDB_ID.GRID), "<>", GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 4 Then
' linea di base
EgtSetGeoLine( m_ptP1, m_ptP2)
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota allineata (drag è in globale)
EgtCreateAlignedDimension( m_Scene.GetDragGroup(), m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
m_ptP3.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessAngularDimension() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto stato a primo punto per AlignedDimension
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("ANGULAR DIMENSION", "Insert Vertex", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptV = m_ptLast
m_nStep = 2
RaiseEvent PrepareInputBox( "ANGULAR DIMENSION", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptP1 + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 2
m_ptP1 = m_ptLast
m_nStep = 3
RaiseEvent PrepareInputBox( "ANGULAR DIMENSION", "Insert End Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptP1 + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 3
m_ptP2 = m_ptLast
m_nStep = 4
RaiseEvent PrepareInputBox( "ANGULAR DIMENSION", "Insert Text Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptP2 + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 4
m_ptP3 = m_ptLast
m_nStep = 5
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox( "ANGULAR DIMENSION", "Insert Text", "", False, True)
m_nInpType = IBT.TY_STRING
m_sLast = "<>"
SetInputBoxString( m_sLast)
Case 5
' reset scena
m_Scene.ResetStatus(False)
' creo l'entità quota lineare (i punti sono in globale)
EnableCommandLog()
EgtCreateAngularDimension(GetCurrLayer(), m_ptV.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID),
m_ptP3.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragAngularDimension()
' il gruppo di Drag ha riferimento globale
If m_nStep = 2 Then
' linea di base
EgtSetGeoLine( m_ptV, m_ptLast)
ElseIf m_nStep = 3 Then
' triangolo di base
EgtResetGeoLine( False)
EgtSetGeoTria( m_ptV, m_ptP1, m_ptLast)
ElseIf m_nStep = 4 Then
' linea di base
EgtResetGeoLine( False)
EgtSetGeoTria( m_ptV, m_ptP1, m_ptP2)
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota angolare (drag è in globale)
Dim ptP3 As Point3d = m_ptLast
if AreSamePointApprox( ptP3, m_ptP1) OrElse AreSamePointApprox( ptP3, m_ptP2) OrElse AreSamePointApprox( ptP3, m_ptV) Then
ptP3 = Point3d.Media( m_ptP1, m_ptP2)
End If
EgtCreateAngularDimension(m_Scene.GetDragGroup(), m_ptV.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID),
m_ptP2.Loc(GDB_ID.GRID), ptP3.Loc(GDB_ID.GRID), "<>", GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 5 Then
' linea di base
EgtResetGeoLine( False)
EgtSetGeoTria( m_ptV, m_ptP1, m_ptP2)
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota angolare (drag è in globale)
EgtCreateAngularDimension(m_Scene.GetDragGroup(), m_ptV.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID),
m_ptP2.Loc(GDB_ID.GRID), m_ptP3.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessAngularDimensionPlus() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto stato a primo punto per AlignedDimension
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("ANGULAR DIMENSION+", "Insert Start Vertex", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
Case 1
m_ptV = m_ptLast
m_nStep = 2
RaiseEvent PrepareInputBox( "ANGULAR DIMENSION+", "Insert Start Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptV + New Vector3d(10, 0, 0)
SetInputBoxPoint3d(ptTemp)
Case 2
m_ptP1 = m_ptLast
m_nStep = 3
RaiseEvent PrepareInputBox( "ANGULAR DIMENSION+", "Insert End Vertex", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptV + New Vector3d(0, 10, 0)
SetInputBoxPoint3d(ptTemp)
Case 3
m_ptW = m_ptLast
m_nStep = 4
RaiseEvent PrepareInputBox( "ANGULAR DIMENSION+", "Insert End Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = m_ptW + New Vector3d(0, 10, 0)
SetInputBoxPoint3d(ptTemp)
Case 4
m_ptP2 = m_ptLast
m_nStep = 5
RaiseEvent PrepareInputBox( "ANGULAR DIMENSION+", "Insert Text Point", "", False, False)
m_nInpType = IBT.TY_POINT3D
Dim ptTemp As Point3d = Point3d.Media( m_ptP1, m_ptP2)
SetInputBoxPoint3d(ptTemp)
Case 5
m_ptP3 = m_ptLast
m_nStep = 6
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox( "ANGULAR DIMENSION+", "Insert Text", "", False, True)
m_nInpType = IBT.TY_STRING
m_sLast = "<>"
SetInputBoxString( m_sLast)
Case 6
' reset scena
m_Scene.ResetStatus(False)
' creo l'entità quota lineare (i punti sono in globale)
EnableCommandLog()
EgtCreateAngularDimensionEx(GetCurrLayer(), m_ptV.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID),
m_ptW.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID), m_ptP3.Loc(GDB_ID.GRID),
m_sLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragAngularDimensionPlus()
' il gruppo di Drag ha riferimento globale
If m_nStep = 2 Then
' linea di base
EgtSetGeoLine( m_ptV, m_ptLast)
ElseIf m_nStep = 3 Then
' triangolo di base
EgtResetGeoLine( False)
EgtSetGeoTria( m_ptV, m_ptP1, m_ptLast)
ElseIf m_nStep = 4 Then
' triangolo di base
EgtSetGeoLine( m_ptW, m_ptLast)
EgtSetGeoTria( m_ptV, m_ptP1, m_ptLast)
ElseIf m_nStep = 5 Then
EgtResetGeoLine( False)
EgtResetGeoTria( False)
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota angolare (drag è in globale)
Dim ptP3 As Point3d = m_ptLast
if AreSamePointApprox( ptP3, m_ptP1) OrElse AreSamePointApprox( ptP3, m_ptP2) OrElse AreSamePointApprox( ptP3, m_ptV) Then
ptP3 = Point3d.Media( m_ptP1, m_ptP2)
End If
EgtCreateAngularDimensionEx(m_Scene.GetDragGroup(), m_ptV.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID),
m_ptW.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID), ptP3.Loc(GDB_ID.GRID), "<>", GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 6 Then
' linea di base
EgtResetGeoLine( False)
EgtSetGeoTria( m_ptV, m_ptP1, m_ptP2)
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota angolare (drag è in globale)
EgtCreateAngularDimensionEx(m_Scene.GetDragGroup(), m_ptV.Loc(GDB_ID.GRID), m_ptP1.Loc(GDB_ID.GRID),
m_ptW.Loc(GDB_ID.GRID), m_ptP2.Loc(GDB_ID.GRID), m_ptP3.Loc(GDB_ID.GRID),
m_sLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessDiametralDimension() 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
' deve essere selezionata una circonferenza
Dim nArcId As Integer = EgtGetLastSelectedObj()
if EgtGetType( nArcId) <> GDB_TY.CRV_ARC Then Return False
Dim ptCen As Point3d
EgtCenterPoint( nArcId, GDB_ID.ROOT, ptCen)
' imposto stato a primo punto per AlignedDimension
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox( "DIAMETRAL DIMENSION", "Insert Text Point", "", False, True)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d( ptCen)
Case 1
m_nStep = 2
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox( "DIAMETRAL DIMENSION", "Insert Text", "", False, True)
m_nInpType = IBT.TY_STRING
m_sLast = "<>"
SetInputBoxString( m_sLast)
Case 2
' reset scena
m_Scene.ResetStatus(False)
' creo l'entità quota diametrale (i punti sono in globale)
EnableCommandLog()
Dim nArcId As Integer = EgtGetLastSelectedObj()
EgtCreateDiametralDimension(GetCurrLayer(), nArcId, m_ptLast.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragDiametralDimension()
' il gruppo di Drag ha riferimento globale
If m_nStep = 1 Then
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota diametrale (drag è in globale)
Dim nArcId As Integer = EgtGetLastSelectedObj()
EgtCreateDiametralDimension(m_Scene.GetDragGroup(), nArcId, m_ptLast.Loc(GDB_ID.GRID), "<>", GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 2 Then
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota diametrale (drag è in globale)
Dim nArcId As Integer = EgtGetLastSelectedObj()
EgtCreateDiametralDimension(m_Scene.GetDragGroup(), nArcId, m_ptLast.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessRadialDimension() 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
' deve essere selezionata una circonferenza
Dim nArcId As Integer = EgtGetLastSelectedObj()
if EgtGetType( nArcId) <> GDB_TY.CRV_ARC Then Return False
Dim ptCen As Point3d
EgtCenterPoint( nArcId, GDB_ID.ROOT, ptCen)
' imposto stato a primo punto per AlignedDimension
m_Scene.SetStatusSelPoint()
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox( "RADIAL DIMENSION", "Insert Text Point", "", False, True)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d( ptCen)
Case 1
m_nStep = 2
m_Scene.SetStatusNull()
RaiseEvent PrepareInputBox( "RADIAL DIMENSION", "Insert Text", "", False, True)
m_nInpType = IBT.TY_STRING
m_sLast = "<>"
SetInputBoxString( m_sLast)
Case 2
' reset scena
m_Scene.ResetStatus(False)
' creo l'entità quota radiale (i punti sono in globale)
EnableCommandLog()
Dim nArcId As Integer = EgtGetLastSelectedObj()
EgtCreateRadialDimension(GetCurrLayer(), nArcId, m_ptLast.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragRadialDimension()
' il gruppo di Drag ha riferimento globale
If m_nStep = 1 Then
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota radiale (drag è in globale)
Dim nArcId As Integer = EgtGetLastSelectedObj()
EgtCreateRadialDimension(m_Scene.GetDragGroup(), nArcId, m_ptLast.Loc(GDB_ID.GRID), "<>", GDB_RT.GRID)
EgtDraw()
ElseIf m_nStep = 2 Then
' cancello possibile entità già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup( m_Scene.GetDragGroup())
EgtErase(nId)
' creo la quota radiale (drag è in globale)
Dim nArcId As Integer = EgtGetLastSelectedObj()
EgtCreateRadialDimension(m_Scene.GetDragGroup(), nArcId, m_ptLast.Loc(GDB_ID.GRID), m_sLast, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessRegion() As Boolean
If m_nStep <> 0 Then Return False
' posso partire solo se esiste un gruppo corrente
If GetCurrLayer() = GDB_ID.NULL Then Return False
' creo la regione piana (a partire da uno o più contorni selezionati)
EnableCommandLog()
' creo vettore di entità selezionate
Dim nCrvNum As Integer = 0
Dim nCrvIds(EgtGetSelectedObjCount() - 1) As Integer
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
nCrvIds(nCrvNum) = nId
nCrvNum = nCrvNum + 1
End Select
nId = EgtGetNextSelectedObj()
End While
' creo la superficie
EgtCreateSurfFlatRegion(GetCurrLayer(), nCrvIds)
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Return True
End Function
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)
EnableCommandLog()
If EgtGetSelectedObjCount() = 1 Then
EgtCreateSurfTmByFlatContour(GetCurrLayer(), EgtGetLastSelectedObj(), m_dStmEps)
Else
' creo vettore di entità selezionate
Dim nCrvNum As Integer = 0
Dim nCrvIds(EgtGetSelectedObjCount() - 1) As Integer
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
nCrvIds(nCrvNum) = nId
nCrvNum = nCrvNum + 1
End Select
nId = EgtGetNextSelectedObj()
End While
' creo la superficie
EgtCreateSurfTmByRegion(GetCurrLayer(), nCrvIds, m_dStmEps)
End If
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
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_Scene.SetStatusNull()
' abilito dialogo
RaiseEvent PrepareInputBox("EXTRUSION", "Insert length", "CapEnds", False, True)
RaiseEvent SetInputBoxCheck(m_bLastCapEndsCheck)
m_nInpType = IBT.TY_LENGTH
m_dLast = If(Math.Abs(m_dLastExtrude) > 10 * EPS_SMALL, m_dLastExtrude, 10 * EPS_SMALL)
SetInputBoxDouble(m_dLast, True)
EgtDisableModified()
DragExtrude()
EgtEnableModified()
Case 1
' reset scena
m_Scene.ResetStatus(False)
' creo la superficie di estrusione (a partire da uno o più contorni selezionati)
Dim VtExtr As Vector3d = Vector3d.Z_AX * m_dLast
' creo vettore di entità selezionate
Dim nCrvNum As Integer = 0
Dim nCrvIds(EgtGetSelectedObjCount() - 1) As Integer
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
nCrvIds(nCrvNum) = nId
nCrvNum = nCrvNum + 1
End Select
nId = EgtGetNextSelectedObj()
End While
' eseguo
EnableCommandLog()
If Not m_bLast Then
EgtCreateSurfTmByExtrusion(GetCurrLayer(), nCrvNum, nCrvIds, VtExtr,
m_dStmEps, GDB_RT.GRID)
Else
EgtCreateSurfTmByRegionExtrusion(GetCurrLayer(), nCrvNum, nCrvIds, VtExtr,
m_dStmEps, GDB_RT.GRID)
End If
DisableCommandLog()
' aggiorno stato
m_bLastCapEndsCheck = m_bLast
m_dLastExtrude = m_dLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
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
EgtEmptyGroup(m_Scene.GetDragGroup())
' creo la superficie di estrusione (a partire da uno o più contorni selezionati)
Dim VtExtr As Vector3d = EgtGetGridVersZ() * m_dLast
Dim nCrvNum As Integer = 0
Dim nCrvIds(EgtGetSelectedObjCount() - 1) As Integer
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
nCrvIds(nCrvNum) = nId
nCrvNum = nCrvNum + 1
End Select
nId = EgtGetNextSelectedObj()
End While
' eseguo
If Not m_bLast Then
EgtCreateSurfTmByExtrusion(m_Scene.GetDragGroup(), nCrvNum, nCrvIds, VtExtr,
EPS_STM_DRAG, GDB_RT.GLOB)
Else
EgtCreateSurfTmByRegionExtrusion(m_Scene.GetDragGroup(), nCrvNum, nCrvIds, VtExtr,
EPS_STM_DRAG, GDB_RT.GLOB)
End If
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", "CapEnds", False, False)
RaiseEvent SetInputBoxCheck(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", "CapEnds", False, True)
m_nInpType = IBT.TY_POINT3D
Case 2
' reset scena
m_Scene.ResetStatus(False)
' creo la superficie di rivoluzione (i punti sono in globale)
EnableCommandLog()
Dim vtAx As Vector3d = m_ptLast - m_ptP1
EgtCreateSurfTmByRevolve(GetCurrLayer(), EgtGetLastSelectedObj(),
m_ptP1.Loc(GDB_ID.GRID), vtAx.Loc(GDB_ID.GRID),
m_bLast, m_dStmEps, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragRevolve()
If m_nStep = 2 Then
EgtSetGeoLine(m_ptP1, m_ptLast)
' cancello eventuale vecchia superficie
EgtEmptyGroup(m_Scene.GetDragGroup())
' creo la superficie di rivoluzione (i punti sono in globale)
Dim vtAx As Vector3d = m_ptLast - m_ptP1
EgtCreateSurfTmByRevolve(m_Scene.GetDragGroup(), EgtGetLastSelectedObj(),
m_ptP1, vtAx, m_bLast, EPS_STM_DRAG, GDB_RT.GLOB)
EgtDraw()
End If
End Sub
Private Function ProcessScrew() 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("SCREW", "Insert First Point on Axis", "CapEnds", False, False)
RaiseEvent SetInputBoxCheck(False)
m_nInpType = IBT.TY_POINT3D
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("SCREW", "Insert Second Point on Axis", "CapEnds", False, False)
m_nInpType = IBT.TY_POINT3D
Case 2
m_ptP2 = m_ptLast
m_nStep = 3
m_Scene.SetStatusNull()
m_Scene.DisableDrag()
RaiseEvent PrepareInputBox("SCREW", "Insert Angle", "CapEnds", False, True)
m_nInpType = IBT.TY_DOUBLE
m_dLast = 360
SetInputBoxDouble(m_dLast)
Case 3
m_ptP2 = m_ptLast
m_dPrev = m_dLast
m_nStep = 4
m_Scene.SetStatusNull()
m_Scene.DisableDrag()
RaiseEvent PrepareInputBox("SCREW", "Insert Move", "CapEnds", False, True)
m_nInpType = IBT.TY_LENGTH
m_dLast = 0
SetInputBoxDouble(m_dLast, True)
Case 4
' reset scena
m_Scene.ResetStatus(False)
' creo la superficie di rivoluzione (i punti sono in globale)
EnableCommandLog()
Dim vtAx As Vector3d = m_ptP2 - m_ptP1
EgtCreateSurfTmByScrewing(GetCurrLayer(), EgtGetLastSelectedObj(),
m_ptP1.Loc(GDB_ID.GRID), vtAx.Loc(GDB_ID.GRID),
m_dPrev, m_dLast, m_bLast, m_dStmEps, GDB_RT.GRID)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragScrew()
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
EgtCreateSurfTmByScrewing(m_Scene.GetDragGroup(), EgtGetLastSelectedObj(),
m_ptP1, vtAx, m_dLast, 0, m_bLast, EPS_STM_DRAG, GDB_RT.GLOB)
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
EgtCreateSurfTmByScrewing(m_Scene.GetDragGroup(), EgtGetLastSelectedObj(),
m_ptP1, vtAx, m_dPrev, m_dLast, m_bLast, EPS_STM_DRAG, GDB_RT.GLOB)
EgtDraw()
End If
End Sub
Private Function ProcessSwept() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto nuovo stato
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("SWEPT", "", "CapEnds", True, True)
RaiseEvent SetInputBoxCheck(m_bLastCapEndsCheck)
RaiseEvent AddInputBoxCombo("Rotation X plane", True)
RaiseEvent AddInputBoxCombo("Rotation Minimizing", False)
m_nInpType = IBT.TY_NULL
' anteprima
EgtDisableModified()
DragSwept()
EgtEnableModified()
Case 1
' creo la superficie swept (a partire da due contorni selezionati)
EnableCommandLog()
Dim nGuideId As Integer = EgtGetLastSelectedObj()
Dim nSectId As Integer = EgtGetPrevSelectedObj()
Dim vtAx As Vector3d = If( m_nLast = 0, Vector3d.Z_AX(), Vector3d.NULL())
EgtCreateSurfTmSwept(GetCurrLayer(), nSectId, nGuideId, vtAx, m_bLast, m_dStmEps, GDB_RT.GRID)
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragSwept()
If m_nStep = 1 Then
' cancello eventuale vecchia superficie di swept
EgtEmptyGroup(m_Scene.GetDragGroup())
' creo la superficie di swept (a partire dai contorni selezionati)
Dim nGuideId As Integer = EgtGetLastSelectedObj()
Dim nSectId As Integer = EgtGetPrevSelectedObj()
Dim vtAx As Vector3d = If( m_nLast = 0, Vector3d.Z_AX(), Vector3d.NULL())
' eseguo
EgtCreateSurfTmSwept(m_Scene.GetDragGroup(), nSectId, nGuideId, vtAx, m_bLast, EPS_STM_DRAG, GDB_RT.GRID)
EgtDraw()
End If
End Sub
Private Function ProcessRuled() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto nuovo stato
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("RULED", "", "MinDist", False, True)
RaiseEvent SetInputBoxCheck(m_bLastRuledCheck)
m_nInpType = IBT.TY_NULL
' anteprima
EgtDisableModified()
DragRuled()
EgtEnableModified()
Case 1
' creo la superficie rigata (a partire da due contorni selezionati)
EnableCommandLog()
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
EgtCreateSurfTmRuled(GetCurrLayer(), nPrevId, nLastId, If(m_bLast, RUL_TYPE.MINDIST, RUL_TYPE.ISOPAR_SMOOTH), m_dStmEps)
DisableCommandLog()
' aggiorno stato
m_bLastRuledCheck = m_bLast
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragRuled()
If m_nStep = 1 Then
' cancello eventuale vecchia superficie rigata
EgtEmptyGroup(m_Scene.GetDragGroup())
' creo la superficie rigata (a partire dai contorni selezionati)
Dim nGuideId As Integer = EgtGetLastSelectedObj()
Dim nSectId As Integer = EgtGetPrevSelectedObj()
' eseguo
EgtCreateSurfTmRuled(m_Scene.GetDragGroup(), nSectId, nGuideId, If(m_bLast, RUL_TYPE.MINDIST, RUL_TYPE.ISOPAR_SMOOTH), EPS_STM_DRAG)
EgtDraw()
End If
End Sub
Private Function ProcessMergeSurf() As Boolean
If m_nStep <> 0 Then
Return False
End If
' creo vettore di superfici selezionate
Dim nSurfNum As Integer = 0
Dim nSurfIds(EgtGetSelectedObjCount() - 1) As Integer
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
Select Case EgtGetType(nId)
Case GDB_TY.SRF_MESH
nSurfIds(nSurfNum) = nId
nSurfNum = nSurfNum + 1
End Select
nId = EgtGetNextSelectedObj()
End While ' lancio la combinazione delle superfici
EnableCommandLog()
If nSurfNum <= 10 Then
EgtCreateSurfTmBySewing(GetCurrLayer(), nSurfNum, nSurfIds, True)
Else
EgtCreateSurfTmByTriangles(GetCurrLayer(), nSurfNum, nSurfIds, True)
End If
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Return True
End Function
Private Function ProcessExplodeSurf() As Boolean
If m_nStep <> 0 Then
Return False
End If
' opero su tutti gli oggetti selezionati
EnableCommandLog()
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
' recupero il successivo, perchè il corrente verrà cancellato
Dim nNextId = EgtGetNextSelectedObj()
' eseguo esplosione
Select EgtGetType( nId)
Case GDB_TY.SRF_FRGN, GDB_TY.SRF_MESH
Dim nCount As Integer
Dim nFirstId As Integer = EgtExplodeSurface(nId, nCount)
Case GDB_TY.VOL_ZMAP
Dim nCount As Integer
Dim nFirstId As Integer = EgtExplodeVolume(nId, nCount)
End Select
' passo al successivo
nId = nNextId
End While
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Return True
End Function
Private Function ProcessApproxSurf() As Boolean
Select Case m_nStep
Case 0
' verifico condizioni
Dim nId As Integer = EgtGetLastSelectedObj()
Dim nType As Integer = EgtGetType(nId)
If nType <> GDB_TY.SRF_MESH AndAlso nType <> GDB_TY.SRF_FRGN AndAlso
nType <> GDB_TY.SRF_BEZ Then Return False
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto stato a cambio alpha (trasparenza)
m_nStep = 1
m_Scene.SetStatusNull()
' abilito dialogo ..., ..., "Copy"
Dim sTitle As String = "APPROX SURFACE"
RaiseEvent PrepareInputBox( sTitle, "Insert Tolerance", EgtMsg(2001), False, True)
m_nInpType = IBT.TY_DOUBLE
SetInputBoxDouble( m_dStmEps)
Case 1
Dim nId As Integer = EgtGetLastSelectedObj()
' Eseguo approssimazione
EnableCommandLog()
If m_bLast Then nId = EgtCopy( nId, nId, GDB_POS.AFTER)
EgtApproxSurface( nId, m_dLast)
DisableCommandLog()
' reset
m_Scene.ResetStatus()
m_nStep = 0
RaiseEvent UpdateUI( Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Function DragApproxSurf() As Boolean
If m_nStep = 1 Then
' devo sempre partire dalla superficie originale
EgtEmptyGroup( m_Scene.GetDragGroup())
Dim nId As Integer = EgtGetLastSelectedObj()
Dim nGrpEntId As Integer = m_Scene.AddToDragGroup( nId)
EgtApproxSurface( nGrpEntId, m_dLast)
EgtDraw()
End If
Return False
End Function
Private Function ProcessInvertSurf() As Boolean
If m_nStep <> 0 Then
Return False
End If
' lancio l'inversione delle superfici
EnableCommandLog()
EgtInvertSurface(GDB_ID.SEL)
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, False)
Return True
End Function
Private Function ProcessMoveSurfVertex() As Boolean
Select Case m_nStep
Case 0
' verifico condizioni e preparo per il drag
If Not PrepareTransform() Then Return False
m_Scene.SetStatusSelPoint()
' imposto stato a primo punto per Move
m_nStep = 1
' abilito dialogo "MOVE SURFACE VERTEX", "Insert Base Point"
RaiseEvent PrepareInputBox("MOVE SURFACE VERTEX", EgtMsg(2403), "", False, False)
m_nInpType = IBT.TY_POINT3D
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
m_Scene.EnableDrag()
' abilito dialogo "MOVE SURFACE VERTEX", "Insert Target Point"
RaiseEvent PrepareInputBox("MOVE SURFACE VERTEX", EgtMsg(2404), "", False, True)
SetInputBoxPoint3d(m_ptLast)
m_nInpType = IBT.TY_POINT3D
Case 2
m_Scene.ResetStatus(False)
EnableCommandLog()
' eseguo movimento
Dim nLastId, nLastSub As Integer
Dim ptLastSel As Point3d
EgtGetLastSelInfo( nLastId, nLastSub, ptLastSel)
Dim nVert As Integer
Dim ptVert As Point3d
EgtSurfTmGetNearestVertex( nLastId, ptLastSel, GDB_ID.ROOT, nVert, ptVert)
EgtSurfTmMoveVertex(nLastId, nVert, (ptVert + ( m_ptLast - m_ptP1)).Loc(GDB_ID.GRID), GDB_RT.GRID, true)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_bLastTransfCheck = m_bLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Function DragMoveSurfVertex() As Boolean
If m_nStep = 2 Then
' devo sempre partire dalla superficie originale
EgtEmptyGroup( m_Scene.GetDragGroup())
Dim nLastId, nLastSub As Integer
Dim ptLastSel As Point3d
EgtGetLastSelInfo( nLastId, nLastSub, ptLastSel)
Dim nVert As Integer
Dim ptVert As Point3d
EgtSurfTmGetNearestVertex( nLastId, ptLastSel, GDB_ID.ROOT, nVert, ptVert)
Dim nNewId As Integer = EgtCopyGlob( nLastId, m_Scene.GetDragGroup())
EgtSurfTmMoveVertex(nNewId, nVert, (ptVert + ( m_ptLast - m_ptP1)), GDB_RT.GLOB, true)
EgtSetGeoLine(m_ptP1, m_ptLast)
EgtDraw()
End If
Return False
End Function
Private Function ProcessMoveSurfFacet() As Boolean
Select Case m_nStep
Case 0
' verifico condizioni e preparo per il drag
If Not PrepareTransform() Then Return False
m_Scene.SetStatusSelPoint()
' imposto stato a primo punto per Move
m_nStep = 1
' abilito dialogo "MOVE SURFACE FACET", "Insert Base Point"
RaiseEvent PrepareInputBox("MOVE SURFACE FACET", EgtMsg(2403), "", False, False)
m_nInpType = IBT.TY_POINT3D
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
m_Scene.EnableDrag()
' abilito dialogo "MOVE SURFACE FACET", "Insert Target Point"
RaiseEvent PrepareInputBox("MOVE SURFACE FACET", EgtMsg(2404), "", False, True)
SetInputBoxPoint3d(m_ptLast)
m_nInpType = IBT.TY_POINT3D
Case 2
m_Scene.ResetStatus(False)
EnableCommandLog()
' eseguo movimento
Dim nLastId, nLastSub As Integer
Dim ptLastSel As Point3d
EgtGetLastSelInfo( nLastId, nLastSub, ptLastSel)
Dim nF As Integer = EgtSurfTmFacetFromTria( nLastId, nLastSub)
EgtSurfTmMoveFacet(nLastId, nF, (m_ptLast - m_ptP1).Loc(GDB_ID.GRID), GDB_RT.GRID, true)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_bLastTransfCheck = m_bLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Function DragMoveSurfFacet() As Boolean
If m_nStep = 2 Then
' devo sempre partire dalla superficie originale
EgtEmptyGroup( m_Scene.GetDragGroup())
Dim nLastId, nLastSub As Integer
Dim ptLastSel As Point3d
EgtGetLastSelInfo( nLastId, nLastSub, ptLastSel)
Dim nF As Integer = EgtSurfTmFacetFromTria( nLastId, nLastSub)
Dim nNewId As Integer = EgtCopyGlob( nLastId, m_Scene.GetDragGroup())
EgtSurfTmMoveFacet(nNewId, nF, (m_ptLast - m_ptP1), GDB_RT.GLOB, true)
EgtSetGeoLine(m_ptP1, m_ptLast)
EgtDraw()
End If
Return False
End Function
Private Function ProcessExtractSurfLoops() As Boolean
If m_nStep <> 0 Then Return False
' posso partire solo se esiste un gruppo corrente
If GetCurrLayer() = GDB_ID.NULL Then Return False
' lancio l'estrazione dei contorni della superficie
EnableCommandLog()
Dim nLastId As Integer = EgtGetLastSelectedObj()
If EgtGetType( nLastId) = GDB_TY.SRF_FRGN Then
For nChunk As Integer = 0 To EgtSurfFrChunkCount( nLastId) - 1
Dim nCount As Integer = 0
EgtExtractSurfFrChunkLoops( nLastId, nChunk, GetCurrLayer(), nCount)
Next
ElseIf EgtGetType( nLastId) = GDB_TY.SRF_MESH Then
Dim nCount As Integer = 0
EgtExtractSurfTmLoops( nLastId, GetCurrLayer(), nCount)
ElseIf EgtGetType( nLastId) = GDB_TY.SRF_BEZ Then
Dim nCount As Integer = 0
EgtExtractSurfBezierLoops( nLastId, GetCurrLayer(), nCount)
End If
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Return True
End Function
Private Function ProcessExtractSurfFacetLoops() As Boolean
If m_nStep <> 0 Then Return False
' posso partire solo se esiste un gruppo corrente
If GetCurrLayer() = GDB_ID.NULL Then Return False
' lancio l'estrazione dei contorni della faccia della superficie
EnableCommandLog()
Dim nLastId, nLastSub As Integer
Dim ptLastSel As Point3d
EgtGetLastSelInfo( nLastId, nLastSub, ptLastSel)
If EgtGetType( nLastId) = GDB_TY.SRF_FRGN Then
Dim nCount As Integer = 0
EgtExtractSurfFrChunkLoops( nLastId, nLastSub, GetCurrLayer(), nCount)
ElseIf EgtGetType( nLastId) = GDB_TY.SRF_MESH Then
Dim nF As Integer = EgtSurfTmFacetFromTria( nLastId, nLastSub)
If nF >= 0 Then
Dim nCount As Integer = 0
EgtExtractSurfTmFacetLoops( nLastId, nF, GetCurrLayer(), nCount)
End If
End If
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Return True
End Function
Private Function ProcessSurfTmToTriangles() As Boolean
If m_nStep <> 0 Then
Return False
End If
' opero su tutti gli oggetti selezionati
EnableCommandLog()
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
' recupero il successivo, perchè il corrente verrà cancellato
Dim nNextId = EgtGetNextSelectedObj()
' eseguo esplosione in triangoli delle superfici trimesh
If EgtGetType( nId) = GDB_TY.SRF_MESH Then
Dim nCount As Integer
Dim nFirstId As Integer = EgtSurfTmToTriangles(nId, nCount)
End If
' passo al successivo
nId = nNextId
End While
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Return True
End Function
Private Function ProcessExtractSurfFacet() As Boolean
If m_nStep <> 0 Then Return False
' posso partire solo se esiste un gruppo corrente
If GetCurrLayer() = GDB_ID.NULL Then Return False
' lancio l'estrazione della faccia della superficie
EnableCommandLog()
Dim nLastId, nLastSub As Integer
Dim ptLastSel As Point3d
EgtGetLastSelInfo( nLastId, nLastSub, ptLastSel)
If EgtGetType( nLastId) = GDB_TY.SRF_MESH Then
Dim nF As Integer = EgtSurfTmFacetFromTria( nLastId, nLastSub)
If nF >= 0 Then
Dim nNewId As Integer = EgtCopySurfTmFacet( nLastId, nF, GetCurrLayer())
if nNewId <> GDB_ID.NULL Then
EgtSurfTmRemoveFacet( nLastId, nF)
EgtSetAlpha( nNewId, 80)
End If
End If
End If
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Return True
End Function
Private Function ProcessSolidAddSurf() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto nuovo stato
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("SOLID ADD SURF", "", "", False, False)
m_nInpType = IBT.TY_NULL
' anteprima
EgtDisableModified()
DragSolidAddSurf()
EgtEnableModified()
Case 1
' eseguo l'unione delle due superfici
EnableCommandLog()
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_FRGN And EgtGetType(nLastId) = GDB_TY.SRF_FRGN Then
EgtSurfFrAdd(nPrevId, nLastId)
EgtErase(nLastId)
ElseIf EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
EgtSurfTmAdd(nPrevId, nLastId)
EgtErase(nLastId)
End If
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragSolidAddSurf()
If m_nStep = 1 Then
' cancello eventuale vecchia superficie unione
EgtEmptyGroup(m_Scene.GetDragGroup())
' creo la superficie unione delle due superfici
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_FRGN And EgtGetType(nLastId) = GDB_TY.SRF_FRGN Then
Dim nDragId As Integer = EgtCopyGlob(nPrevId, m_Scene.GetDragGroup())
EgtSurfFrAdd(nDragId, nLastId)
ElseIf EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
Dim nDragId As Integer = EgtCopyGlob(nPrevId, m_Scene.GetDragGroup())
EgtSurfTmAdd(nDragId, nLastId)
End If
EgtDraw()
End If
End Sub
Private Function ProcessSolidSubtractSurf() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto nuovo stato
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("SOLID SUBTRACT SURF", "", "Erase tool", False, True)
RaiseEvent SetInputBoxCheck(m_bLastBooleanCheck)
m_nInpType = IBT.TY_NULL
' anteprima
EgtDisableModified()
DragSolidSubtractSurf()
EgtEnableModified()
Case 1
' eseguo la sottrazione delle due superfici
EnableCommandLog()
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_FRGN And EgtGetType(nLastId) = GDB_TY.SRF_FRGN Then
EgtSurfFrSubtract(nPrevId, nLastId)
If m_bLast Then EgtErase(nLastId)
ElseIf EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
EgtSurfTmSubtract(nPrevId, nLastId)
If m_bLast Then EgtErase(nLastId)
End If
DisableCommandLog()
' salvo stato
m_bLastBooleanCheck = m_bLast
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragSolidSubtractSurf()
If m_nStep = 1 Then
' cancello eventuale vecchia superficie differenza
EgtEmptyGroup(m_Scene.GetDragGroup())
' creo la superficie differenza delle due superfici
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_FRGN And EgtGetType(nLastId) = GDB_TY.SRF_FRGN Then
Dim nDragId As Integer = EgtCopyGlob(nPrevId, m_Scene.GetDragGroup())
EgtSurfFrSubtract(nDragId, nLastId)
ElseIf EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
Dim nDragId As Integer = EgtCopyGlob(nPrevId, m_Scene.GetDragGroup())
EgtSurfTmSubtract(nDragId, nLastId)
End If
EgtDraw()
End If
End Sub
Private Function ProcessSolidIntersectSurf() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto nuovo stato
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("SOLID INTERSECT SURF", "", "Erase original", False, True)
RaiseEvent SetInputBoxCheck(m_bLastBooleanCheck)
m_nInpType = IBT.TY_NULL
' anteprima
EgtDisableModified()
DragSolidIntersectSurf()
EgtEnableModified()
Case 1
' eseguo l'intersezione delle due superfici
EnableCommandLog()
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_FRGN And EgtGetType(nLastId) = GDB_TY.SRF_FRGN Then
EgtSurfFrIntersect(nPrevId, nLastId)
If m_bLast Then
EgtErase(nLastId)
End If
ElseIf EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
EgtSurfTmIntersect(nPrevId, nLastId)
If m_bLast Then
EgtErase(nLastId)
End If
End If
DisableCommandLog()
' salvo stato
m_bLastBooleanCheck = m_bLast
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragSolidIntersectSurf()
If m_nStep = 1 Then
' cancello eventuale vecchia superficie intersezione
EgtEmptyGroup(m_Scene.GetDragGroup())
' creo la superficie intersezione delle due superfici
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_FRGN And EgtGetType(nLastId) = GDB_TY.SRF_FRGN Then
Dim nDragId As Integer = EgtCopyGlob(nPrevId, m_Scene.GetDragGroup())
EgtSurfFrIntersect(nDragId, nLastId)
ElseIf EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
Dim nDragId As Integer = EgtCopyGlob(nPrevId, m_Scene.GetDragGroup())
EgtSurfTmIntersect(nDragId, nLastId)
End If
EgtDraw()
End If
End Sub
Private Function ProcessIntersectSurfSurf() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto nuovo stato
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("INTERSECT SURF", "", "", False, True)
' anteprima
EgtDisableModified()
DragIntersectSurfSurf()
EgtEnableModified()
Case 1
' eseguo l'intersezione delle due superfici
EnableCommandLog()
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
Dim nPntCount, nCrvCount, nSrfCount As Integer
Dim nFirstId As Integer = EgtSurfTmSurfTmInters( nPrevId, nLastId, GetCurrLayer(), 20 * EPS_SMALL, nPntCount, nCrvCount, nSrfCount)
End If
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragIntersectSurfSurf()
If m_nStep = 1 Then
' cancello eventuale vecchia superficie intersezione
EgtEmptyGroup(m_Scene.GetDragGroup())
' creo la superficie intersezione delle due superfici
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
Dim nPntCount, nCrvCount, nSrfCount As Integer
Dim nFirstId As Integer = EgtSurfTmSurfTmInters( nPrevId, nLastId, m_Scene.GetDragGroup(), 20 * EPS_SMALL, nPntCount, nCrvCount, nSrfCount)
End If
EgtDraw()
End If
End Sub
Private Function ProcessCutSurfSurf() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto nuovo stato
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("CUT SURF", "", "Accept On", False, True)
RaiseEvent SetInputBoxCheck(m_bLastAcceptOnCheck)
' anteprima
EgtDisableModified()
DragCutSurfSurf()
EgtEnableModified()
Case 1
' eseguo il taglio della prima superficie con la seconda
EnableCommandLog()
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
Dim bOk As Boolean = EgtSurfTmCut( nPrevId, nLastId, true, m_bLast)
End If
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' aggiorno stato
m_bLastAcceptOnCheck = m_bLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragCutSurfSurf()
If m_nStep = 1 Then
' cancello eventuale vecchia superficie taglio
EgtEmptyGroup(m_Scene.GetDragGroup())
' eseguo il taglio della prima superficie con la seconda
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
Dim nDragId As Integer = EgtCopyGlob(nPrevId, m_Scene.GetDragGroup())
Dim bOk As Boolean = EgtSurfTmCut( nDragId, nLastId, true, m_bLast)
End If
EgtDraw()
End If
End Sub
Private Function ProcessCutSurfTmWithCurve() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto nuovo stato
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("TRIM SURF WITH CURVE", "", "Invert Curve", True, True)
RaiseEvent SetInputBoxCheck(m_bLastBooleanCheck)
RaiseEvent AddInputBoxCombo("Delete trim curve", True)
RaiseEvent AddInputBoxCombo("Keep trim curve", False)
' anteprima
EgtDisableModified()
DragTrimSurfTmWithCurve()
EgtEnableModified()
Case 1
' eseguo il taglio della superficie
EnableCommandLog()
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.CRV_COMPO Then
EgtCutSurfTmClosedCurve(nPrevId, nLastId, False)
If m_nLast = 0 Then
EgtErase(nLastId)
End If
ElseIf EgtGetType(nPrevId) = GDB_TY.CRV_COMPO And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
EgtCutSurfTmClosedCurve(nLastId, nPrevId, False)
If m_nLast = 0 Then
EgtErase(nPrevId)
End If
End If
DisableCommandLog()
' salvo stato
m_bLastBooleanCheck = m_bLast
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragTrimSurfTmWithCurve()
If m_nStep = 1 Then
' cancello eventuale vecchia superficie taglio
EgtEmptyGroup(m_Scene.GetDragGroup())
' eseguo il taglio della prima superficie con la seconda
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.CRV_COMPO Then
Dim nDragId As Integer = EgtCopyGlob(nPrevId, m_Scene.GetDragGroup())
EgtCutSurfTmClosedCurve(nDragId, nLastId, False)
ElseIf EgtGetType(nPrevId) = GDB_TY.CRV_COMPO And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
Dim nDragId As Integer = EgtCopyGlob(nLastId, m_Scene.GetDragGroup())
EgtCutSurfTmClosedCurve(nDragId, nPrevId, False)
End If
EgtDraw()
End If
End Sub
Private Sub DragInvertCurve()
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.CRV_COMPO Then
EgtInvertCurve(nLastId)
ElseIf EgtGetType(nPrevId) = GDB_TY.CRV_COMPO And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
EgtInvertCurve(nPrevId)
End If
End Sub
Private Function ProcessInvCutSurfSurf() As Boolean
Select Case m_nStep
Case 0
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto nuovo stato
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("CUT SURF", "", "Accept On", False, True)
RaiseEvent SetInputBoxCheck(m_bLastAcceptOnCheck)
' anteprima
EgtDisableModified()
DragInvCutSurfSurf()
EgtEnableModified()
Case 1
' eseguo il taglio della prima superficie con la seconda
EnableCommandLog()
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
Dim bOk As Boolean = EgtSurfTmCut( nPrevId, nLastId, false, m_bLast)
End If
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' aggiorno stato
m_bLastAcceptOnCheck = m_bLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragInvCutSurfSurf()
If m_nStep = 1 Then
' cancello eventuale vecchia superficie taglio
EgtEmptyGroup(m_Scene.GetDragGroup())
' eseguo il taglio della prima superficie con la seconda
Dim nLastId As Integer = EgtGetLastSelectedObj()
Dim nPrevId As Integer = EgtGetPrevSelectedObj()
If EgtGetType(nPrevId) = GDB_TY.SRF_MESH And EgtGetType(nLastId) = GDB_TY.SRF_MESH Then
Dim nDragId As Integer = EgtCopyGlob(nPrevId, m_Scene.GetDragGroup())
Dim bOk As Boolean = EgtSurfTmCut( nDragId, nLastId, false, m_bLast)
End If
EgtDraw()
End If
End Sub
Private Function ProcessDelete() As Boolean
If m_nStep <> 0 Then Return False
If m_nLast = GDB_ID.NULL Then Return True
EnableCommandLog()
EgtErase( m_nLast)
DisableCommandLog()
' reset
m_Scene.ResetStatus()
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Return True
End Function
Private Function ProcessChangeLayer(bGlob As Boolean) 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
' verifico ci sia un layer corrente
Dim nCurrLayerId As Integer = EgtGetCurrLayer()
If nCurrLayerId = GDB_ID.NULL Then Return False
' il riferimento è il layer corrente
Dim nRefId As Integer = nCurrLayerId
' la posizione è come ultimo figlio
Dim nPos As GDB_POS = GDB_POS.LAST_SON
' ciclo di cambiamento layer (rilocazione)
While nId <> GDB_ID.NULL
EnableCommandLog()
If bGlob Then
EgtRelocateGlob(nId, nRefId, nPos)
Else
EgtRelocate(nId, nRefId, nPos)
End If
DisableCommandLog()
nId = EgtGetNextSelectedObj()
End While
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Return True
End Function
Private Function ProcessChangeColor() As Boolean
If m_nStep <> 0 Then Return False
' verifico ci sia qualcosa di selezionato
Dim nId As Integer = EgtGetLastSelectedObj()
If nId = GDB_ID.NULL Then Return False
' ne recupero il colore
Dim colObj As Color3d
EgtGetCalcColor(nId, colObj)
' lancio dialogo scelta colore
If Not SelectColor(colObj, colObj) Then Return False
' assegno nuovo colore (tenendo alpha del vecchio)
EnableCommandLog()
EgtSetColor(GDB_ID.SEL, colObj, False)
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
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
EnableCommandLog()
EgtResetColor(GDB_ID.SEL)
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, False)
Return True
End Function
Private Function ProcessChangeAlpha() As Boolean
Select Case m_nStep
Case 0
' verifico ci sia qualcosa di selezionato
Dim nId As Integer = EgtGetFirstSelectedObj()
If nId = GDB_ID.NULL Then
Return False
End If
' imposto stato a cambio alpha (trasparenza)
m_nStep = 1
m_Scene.SetStatusNull()
' abilito dialogo
RaiseEvent PrepareInputBox("TRANSPARENCY", "Insert Alpha (10-100)", "", False, False)
m_nInpType = IBT.TY_INTEGER
' recupero trasparenza dell'ultima entità selezionata
Dim colObj As Color3d
EgtGetCalcColor(EgtGetLastSelectedObj(), colObj)
SetInputBoxInteger(colObj.A)
Case 1
' non accetto valori fuori dall'intervallo 10-100 a parte 0
If m_nLast <> 0 And m_nLast < 10 Then
m_nLast = 10
ElseIf m_nLast > 100 Then
m_nLast = 100
End If
' assegnazione trasparenza
EnableCommandLog()
EgtSetAlpha(GDB_ID.SEL, m_nLast)
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, False)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Function ProcessInvertCurve() As Boolean
If m_nStep <> 0 Then
Return False
End If
' lancio l'inversione delle curve e dei vettori
EnableCommandLog()
Dim vCrvId As New List(Of Integer)
Dim vVecId As New List(Of Integer)
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
vCrvId.Add(nId)
Case GDB_TY.GEO_VECTOR
vVecId.Add(nId)
End Select
nId = EgtGetNextSelectedObj()
End While
If vCrvId.Count() > 0 Then EgtInvertCurve(vCrvId.ToArray())
If vVecId.Count() > 0 Then EgtInvertVector(vVecId.ToArray())
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, False)
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) Then
Return False
End If
EgtUnselectableAdd(EgtGetLastSelectedObj())
m_Scene.SetDragIntersForSelPoint(True)
' imposto stato a lunghezza di estensione
m_nStep = 1
m_dLast = m_dLastExtend
' recupero dati estremo più vicino a punto di selezione per permettere drag lunghezza con mouse
m_Scene.SetStatusSelPoint(False)
Dim nId, nSub As Integer
Dim ptLastSel As Point3d
EgtGetLastSelInfo(nId, nSub, ptLastSel)
EgtCurveLength(nId, m_dPrev)
Dim bStart As Boolean = True
EgtCurveNearestExtremityToPoint(nId, ptLastSel.Loc(nId), bStart)
If bStart Then
m_bLast = True
m_ptP1 = ptLastSel
EgtStartVector(nId, m_vtCont)
m_vtCont = -m_vtCont.Glob(nId)
Else
m_bLast = False
EgtEndPoint(nId, m_ptP1)
m_ptP1 = ptLastSel
EgtEndVector(nId, m_vtCont)
m_vtCont = m_vtCont.Glob(nId)
End If
' abilito dialogo
RaiseEvent PrepareInputBox("TRIM-EXTEND", "Insert Length", "", False, True)
m_nInpType = IBT.TY_SPECIALDOUBLE
SetInputBoxDouble(m_dLast, True)
EgtDisableModified()
DragExtendCurve()
EgtEnableModified()
Case 1
' eseguo estensione sull'estremo più vicino al punto di selezione
Dim nId As Integer = EgtGetLastSelectedObj()
EnableCommandLog()
EgtTrimExtendCurveByLen(nId, m_dLast, m_ptP1.Loc(GDB_ID.GRID), GDB_RT.GRID)
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' aggiorno stato
m_dLastExtend = m_dLast
m_nStep = 0
RaiseEvent UpdateUI(Me, False)
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
EgtEmptyGroup(m_Scene.GetDragGroup())
PrepareTransform(False)
' verifico se caso speciale : drag
Dim bSpecial As Boolean = m_Scene.GetDragStatus()
' 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, GDB_RT.GLOB)
EgtDraw()
End If
Return False
End Function
Private Function ExecuteSpecialDataExtendCurve() As Boolean
If m_nStep = 1 Then
' verifico se caso speciale : drag
Dim bSpecial As Boolean = m_Scene.GetDragStatus()
' 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())
Dim bFound = false
Dim ptStart As New Point3d : EgtStartPoint( nDragId, ptStart)
Dim ptEnd As New Point3d : EgtEndPoint( nDragId, ptEnd)
if Math.Abs( ptStart.Loc( GDB_ID.GRID).z - ptEnd.Loc( GDB_ID.GRID).z) > 100 * EPS_SMALL Then
Dim nCopyId As Integer = EgtCopy( nDragId, m_Scene.GetDragGroup())
EgtProjectCurveOnPlane( nCopyId, Point3d.ORIG(), Vector3d.Z_AX(), GDB_RT.GRID)
bFound = EgtCurveLengthAtPoint(nCopyId, m_ptLast.Loc(nCopyId), EXTEND_BIG_ADD, dLen)
Dim dDragLen As Double
Dim dCopyLen As Double
if EgtCurveLength(nDragId, dDragLen) AndAlso EgtCurveLength(nCopyId, dCopyLen) Then
dLen *= dDragLen / dCopyLen
End If
EgtErase( nCopyId)
else
bFound = EgtCurveLengthAtPoint(nDragId, m_ptLast.Loc(nDragId), EXTEND_BIG_ADD, dLen)
End If
If bFound 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, False)
m_nInpType = IBT.TY_POINT3D
Case 1
' eseguo spezzatura
Dim nId As Integer = EgtGetLastSelectedObj()
EnableCommandLog()
EgtSplitCurveAtPoint(nId, m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
EgtDeselectObj(nId)
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Function ProcessSplitCurve() As Boolean
Select Case m_nStep
Case 0
' imposto stato a numero di pezzi
m_nStep = 1
m_Scene.SetStatusNull()
' abilito dialogo
RaiseEvent PrepareInputBox("SPLIT", "Insert Pieces Number", "", False, False)
m_nInpType = IBT.TY_INTEGER
m_nLast = 2
SetInputBoxInteger(m_nLast)
Case 1
' eseguo spezzatura in parti
Dim nId As Integer = EgtGetLastSelectedObj()
EnableCommandLog()
EgtSplitCurve(nId, m_nLast)
EgtDeselectObj(nId)
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
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
' Determino il punto suggerito per l'inizio del concatenamento come punto iniziale della prima curva selezionata
Dim ptStart As New Point3d
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
Dim nType As Integer = EgtGetType( nId)
if nType = GDB_TY.CRV_LINE Or nType = GDB_TY.CRV_ARC Or nType = GDB_TY.CRV_BEZ Or nType = GDB_TY.CRV_COMPO Then
EgtStartPoint( nId, GDB_RT.GRID, ptStart)
Dim vtStart As Vector3d
If EgtStartVector( nId, GDB_RT.GRID, vtStart) Then
ptStart += vtStart
End If
Exit While
End If
nId = EgtGetNextSelectedObj()
End While
' creo la curva composita (concatenando le curve selezionate)
EnableCommandLog()
EgtCreateCurveCompoByChain(GetCurrLayer(), 1, {GDB_ID.SEL}, ptStart, Not m_bLast, GDB_RT.GRID)
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Return True
End Function
Private Function ProcessExplodeCurve() As Boolean
If m_nStep <> 0 Then
Return False
End If
' opero su tutti gli oggetti selezionati
EnableCommandLog()
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
Dim nCount As Integer
Dim nFirstId As Integer = EgtExplodeCurveCompo(nId, nCount)
Case GDB_TY.CRV_BEZ
' approssimo la curva di Bezier con archi
Dim nNewId As Integer = EgtApproxCurve(nId, APP_TYPE.ARCS, 10 * EPS_SMALL)
Case GDB_TY.EXT_TEXT
' esplodo il testo nei suoi contorni
Dim nCount As Integer
Dim nFirstId As Integer = EgtExplodeText(nId, nCount)
End Select
' passo al successivo
nId = nNextId
End While
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Return True
End Function
Private Function ProcessMergeCurvesInCompo() As Boolean
If m_nStep <> 0 Then Return False
' unisco le curve compatibili nella curva composita selezionata
EnableCommandLog()
EgtMergeCurvesInCurveCompo( EgtGetFirstSelectedObj(), m_dStmEps)
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, False)
Return True
End Function
Private Function ProcessChangeStartCurve() As Boolean
Select Case m_nStep
Case 0
m_Scene.SetStatusSelPoint()
' imposto stato a punto per Change Start Curve
m_nStep = 1
' abilito dialogo
RaiseEvent PrepareInputBox("CHANGE START", "Insert Point on Curve", "", False, False)
m_nInpType = IBT.TY_POINT3D
Case 1
' eseguo cambio inizio
Dim nId As Integer = EgtGetLastSelectedObj()
EnableCommandLog()
EgtChangeClosedCurveStartPoint(nId, m_ptLast.Loc(GDB_ID.GRID), GDB_RT.GRID)
EgtDeselectObj(nId)
DisableCommandLog()
' 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 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
m_Scene.SetStatusNull()
' abilito dialogo
RaiseEvent PrepareInputBox("CURVE THICKNESS", "Insert Thickness", "Extrusion from CPlane", False, True)
m_nInpType = IBT.TY_LENGTH
' recupero spessore dell'ultima entità selezionata
Dim dThick As Double
If EgtCurveThickness(EgtGetLastSelectedObj(), dThick) Then
m_dLast = dThick
Else
m_dLast = 0
End If
SetInputBoxDouble(m_dLast, True)
RaiseEvent SetInputBoxCheck(False)
Case 1
EnableCommandLog()
' se richiesto, imposto direzione estrusione
If m_bLast Then
EgtModifyCurveExtrusion(GDB_ID.SEL, Vector3d.Z_AX, GDB_RT.GRID)
End If
' eseguo impostazione spessore curve selezionate
EgtModifyCurveThickness(GDB_ID.SEL, m_dLast)
DisableCommandLog()
' 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 Sub DragSetCurveThickness()
If m_nStep = 1 Then
' imposto direzione estrusione da Z griglia
If m_bLast Then
EgtModifyCurveExtrusion(m_Scene.GetDragGroup(), EgtGetGridVersZ(), GDB_RT.GLOB)
' ripristino direzione estrusione originale
Else
' ogni entità deve riprendere la sua propria estrusione originale
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
While nId <> GDB_ID.NULL
Dim nOrigId As Integer
Dim vtOrigExtr As Vector3d
If EgtGetInfo(nId, "Id", nOrigId) And EgtCurveExtrusion(nOrigId, vtOrigExtr) Then
EgtModifyCurveExtrusion(nId, vtOrigExtr.Glob(nOrigId), GDB_RT.GLOB)
End If
nId = EgtGetNext(nId)
End While
End If
' eseguo impostazione spessore curve selezionate
EgtModifyCurveThickness(m_Scene.GetDragGroup(), m_dLast)
EgtDraw()
End If
End Sub
Private Function ProcessArcFlip() As Boolean
If m_nStep <> 0 Then
Return False
End If
' lancio il capovolgimento dell'arco
EnableCommandLog()
Dim nId As Integer = EgtGetFirstSelectedObj()
if nId <> GDB_ID.NULL Then
EgtModifyArcByFlip( nId)
End If
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, False)
Return True
End Function
Private Function ProcessArcExplementary() As Boolean
If m_nStep <> 0 Then
Return False
End If
' lancio il capovolgimento dell'arco
EnableCommandLog()
Dim nId As Integer = EgtGetFirstSelectedObj()
if nId <> GDB_ID.NULL Then
EgtModifyArcToExplementary( nId)
End If
DisableCommandLog()
' reset stato scena
m_Scene.ResetStatus()
' reset stato
m_nStep = 0
RaiseEvent UpdateUI(Me, False)
Return True
End Function
Private Function ModifyArcRadius() As Boolean
Select Case m_nStep
Case 0
' verifico condizioni e preparo per il drag
Dim nId As Integer = EgtGetLastSelectedObj()
If EgtGetType(nId) <> GDB_TY.CRV_ARC Then Return False
If Not PrepareTransform(False) Then Return False
' imposto stato a modifica raggio arco
m_nStep = 1
m_Scene.SetStatusNull()
' recupero il raggio originale
m_dLast = 1
EgtArcRadius( nId, m_dLast)
m_dPrev = m_dLast
' abilito dialogo
RaiseEvent PrepareInputBox("MODIFY ARC RADIUS", "Modify Arc Radius", "", False, True)
m_nInpType = IBT.TY_DOUBLE
SetInputBoxDouble( m_dLast)
Case 1
' reset scena
m_Scene.ResetStatus(False)
Dim nId As Integer = EgtGetLastSelectedObj()
EnableCommandLog()
' modifico il raggio dell'arco
EgtModifyArcRadius( nId, m_dLast, False)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragModifyArcRadius()
' il gruppo di Drag ha riferimento globale
If m_nStep = 1 Then
' recupero entità arco già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
if nId = GDB_ID.NULL Then Return
' modifico il raggio dell'arco
if Not EgtModifyArcRadius( nId, m_dLast, False) Then
EgtModifyArcRadius( nId, m_dPrev, False)
End If
EgtDraw()
End If
End Sub
Private Function ModifyText() As Boolean
Select Case m_nStep
Case 0
' verifico condizioni e preparo per il drag
Dim nId As Integer = EgtGetLastSelectedObj()
If EgtGetType(nId) <> GDB_TY.EXT_TEXT Then Return False
If Not PrepareTransform(False) Then Return False
' imposto stato a modifica testo
m_nStep = 1
m_Scene.SetStatusNull()
' recupero il testo originale
m_sLast = String.Empty
EgtTextGetContent(nId, m_sLast)
' abilito dialogo
RaiseEvent PrepareInputBox("MODIFY TEXT", "Modify Text", "", False, True)
m_nInpType = IBT.TY_STRING
SetInputBoxString(m_sLast)
Case 1
' aggiorno testo in drag (necessario se non è stato richiesto preview in precedenza)
EgtDisableModified()
DragModifyText()
EgtEnableModified()
' imposto stato a modifica attributi
m_nStep = 2
m_Scene.SetStatusNull()
' recupero gli attributi del testo
Dim nId As Integer = EgtGetLastSelectedObj()
Dim dH As Double = m_dLastTextH
EgtTextGetHeight(nId, dH)
Dim bItalic As Boolean = False
EgtTextGetItalic(nId, bItalic)
Dim sFont As String = string.Empty
EgtTextGetFont(nId, sFont)
if String.IsNullOrWhiteSpace(sFont) Then EgtGetDefaultFont(sFont)
RaiseEvent PrepareInputBox("MODIFY TEXT", "Insert Height", "Italic", True, True)
m_nInpType = IBT.TY_LENGTH
m_dLast = dH
SetInputBoxDouble(m_dLast, True)
m_bLast = bItalic
RaiseEvent SetInputBoxCheck(m_bLast)
LoadFonts()
For i As Integer = 0 To m_sFonts.Count() - 1
Dim bSel = (String.Compare(m_sFonts(i), sFont, True) = 0)
RaiseEvent AddInputBoxCombo(m_sFonts(i), bSel)
Next
Case 2
' reset scena
m_Scene.ResetStatus(False)
Dim nId As Integer = EgtGetLastSelectedObj()
EnableCommandLog()
' modifico il contenuto del testo
EgtModifyText(nId, m_sLast)
' modifico l'altezza
EgtChangeTextHeight(nId, m_dLast)
' modifico il flag di italico
EgtChangeTextItalic(nId, m_bLast)
' modifico il font
Dim sFont As String = String.Empty
If m_nLast >= 0 And m_nLast < m_sFonts.Count() Then
sFont = m_sFonts(m_nLast)
End If
EgtChangeTextFont(nId, sFont)
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_dLastTextH = m_dLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragModifyText()
' il gruppo di Drag ha riferimento globale
If m_nStep = 1 Then
' recupero entità testo già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
if nId = GDB_ID.NULL Then Return
' modifico il contenuto del testo
EgtModifyText(nId, m_sLast)
EgtDraw()
ElseIf m_nStep = 2 Then
' recupero entità testo già nel gruppo di drag
Dim nId As Integer = EgtGetFirstInGroup(m_Scene.GetDragGroup())
if nId = GDB_ID.NULL Then Return
' modifico l'altezza
EgtChangeTextHeight(nId, m_dLast)
' modifico il flag di italico
EgtChangeTextItalic(nId, m_bLast)
' modifico il font
Dim sFont As String = String.Empty
If m_nLast >= 0 And m_nLast < m_sFonts.Count() Then
sFont = m_sFonts(m_nLast)
End If
EgtChangeTextFont(nId, sFont)
EgtDraw()
End If
End Sub
Private Function ModifyCurve() As Boolean
Select Case m_nStep
Case 0
' verifico condizioni e preparo per il drag
Dim nId As Integer = EgtGetLastSelectedObj()
Dim nType As Integer = EgtGetType(nId)
If nType <> GDB_TY.CRV_LINE AndAlso nType <> GDB_TY.CRV_ARC AndAlso
nType <> GDB_TY.CRV_BEZ AndAlso nType <> GDB_TY.CRV_COMPO Then Return False
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto stato a primo punto per modifica curva
m_Scene.SetStatusSelPoint()
m_nStep = 1
RaiseEvent PrepareInputBox("MODIFY CURVE", "Insert Start Point ", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d( m_ptCont)
m_Scene.DisableTangentPoint()
m_Scene.DisablePerpendicularPoint()
m_Scene.DisableMinDistPoint()
Case 1
m_ptP1 = m_ptLast
m_sepP1 = m_sepLast
m_nIdP1 = m_nIdLast
m_ptCont = m_ptLast
Dim nId As Integer = EgtGetLastSelectedObj()
' recupero il punto sulla curva
Dim dDist, dU As Double
If Not EgtPointCurveDist( m_ptLast.Loc(nId), nId, nId, dDist, dU) Then m_bDrag = False
m_dAux = CInt(Math.Round(dU))
' riconosco il tipo di deformazione (spostamento vertice o traslazione entità)
If Math.Abs( dU - m_dAux) < 0.3 Or EgtGetType( nId) <> GDB_TY.CRV_COMPO Then
m_bModifyCurveByMove = False
Else
m_bModifyCurveByMove = True
if m_dAux > dU Then m_dAux -= 1
End If
m_nStep = 2
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("MODIFY CURVE", "Insert End Point ", "", False, True)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d( m_ptLast)
m_Scene.DisableTangentPoint()
m_Scene.DisablePerpendicularPoint()
m_Scene.DisableMinDistPoint()
Case 2
' reset scena
m_Scene.ResetStatus(False)
EnableCommandLog()
Dim nId As Integer = EgtGetLastSelectedObj()
' se modifica per traslazione
If m_bModifyCurveByMove Then
' Ricavo il vettore di movimento (tengo solo XY)
Dim vtMove As Vector3d = m_ptLast - m_ptP1
vtMove.z = 0
Dim vtNormU As Vector3d
EgtAtParamVector(nId, m_dAux + 0.5, -1, GDB_RT.GLOB, vtNormU)
' ottengo il versore ortogonale
vtNormU.Rotate(Vector3d.Z_AX, 90)
vtNormU.Normalize()
Dim vtDelta As Vector3d = vtMove * vtNormU * vtNormU
EgtMoveCurveCompoCurve( nId, m_dAux, vtDelta, GDB_RT.GLOB)
' altrimenti modifica per spostamento di vertice
Else
If EgtGetType( nId) = GDB_TY.CRV_COMPO then
EgtModifyCurveCompoJoint(nId, m_dAux, m_ptLast, GDB_RT.GLOB)
Else
if m_dAux < 0.5 Then
EgtModifyCurveStartPoint( nId, m_ptLast, GDB_RT.GLOB)
Else
EgtModifyCurveEndPoint( nId, m_ptLast, GDB_RT.GLOB)
End If
End If
End If
DisableCommandLog()
EgtDraw()
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragModifyCurve()
' il gruppo di Drag ha riferimento globale
If m_nStep = 2 Then
' svuoto il gruppo di drag
EgtEmptyGroup( m_Scene.GetDragGroup())
' creo una copia della curva nel layer per il drag
Dim nOrigId As Integer = EgtGetLastSelectedObj()
Dim nId As Integer = m_Scene.AddToDragGroup( nOrigId)
' se modifica per traslazione
If m_bModifyCurveByMove Then
' Ricavo il vettore di movimento (tengo solo XY)
Dim vtMove As Vector3d = m_ptLast - m_ptP1
vtMove.z = 0
Dim vtNormU As Vector3d
EgtAtParamVector( nId, m_dAux + 0.5, -1, GDB_RT.GLOB, vtNormU)
' ottengo il versore ortogonale
vtNormU.Rotate( Vector3d.Z_AX, 90)
vtNormU.Normalize()
Dim vtDelta As Vector3d = vtMove * vtNormU * vtNormU
EgtMoveCurveCompoCurve( nId, m_dAux, vtDelta, GDB_RT.GLOB)
' altrimenti modifica per spostamento di vertice
Else
If EgtGetType( nId) = GDB_TY.CRV_COMPO then
EgtModifyCurveCompoJoint( nId, m_dAux, m_ptLast, GDB_RT.GLOB)
Else
if m_dAux < 0.5 Then
EgtModifyCurveStartPoint( nId, m_ptLast, GDB_RT.GLOB)
Else
EgtModifyCurveEndPoint( nId, m_ptLast, GDB_RT.GLOB)
End If
End If
End If
EgtDraw()
End If
End Sub
Private Function AddPointCurve() As Boolean
Select Case m_nStep
Case 0
' verifico condizioni e preparo per il drag
Dim nId As Integer = EgtGetLastSelectedObj()
Dim nType As Integer = EgtGetType(nId)
If nType <> GDB_TY.CRV_LINE AndAlso nType <> GDB_TY.CRV_ARC AndAlso
nType <> GDB_TY.CRV_BEZ AndAlso nType <> GDB_TY.CRV_COMPO Then Return False
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto stato a primo punto per aggiungere un punto curva
m_Scene.SetStatusSelPoint()
m_nStep = 1
RaiseEvent PrepareInputBox("ADD POINT TO CURVE", "Insert Start Point ", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
m_Scene.DisableTangentPoint()
m_Scene.DisablePerpendicularPoint()
m_Scene.DisableMinDistPoint()
Case 1
m_ptP1 = m_ptLast
m_sepP1 = m_sepLast
m_nIdP1 = m_nIdLast
m_ptCont = m_ptLast
' recupero il punto sulla curva
Dim nId As Integer = EgtGetLastSelectedObj()
Dim dDist, dU As Double
If Not EgtPointCurveDist( m_ptP1.Loc( nId), nId, nId, dDist, dU) Then Return False
m_dPrev = dU
m_dAux = CInt( Math.Ceiling( dU))
Dim dUs, dUe As Double
EgtCurveDomain( nId, dUs, dUe)
If m_dPrev > dUe - 0.1 AndAlso Not EgtCurveIsClosed( nId) Then m_dAux += 1
' passo allo step successivo
m_nStep = 2
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("ADD POINT TO CURVE", "Insert End Point ", "", False, True)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptLast)
m_Scene.DisableTangentPoint()
m_Scene.DisablePerpendicularPoint()
m_Scene.DisableMinDistPoint()
Case 2
' reset scena
m_Scene.ResetStatus(False)
EnableCommandLog()
Dim nId As Integer = EgtGetLastSelectedObj()
If EgtGetType( nId) <> GDB_TY.CRV_COMPO Then
Dim nNewId As Integer = EgtCreateCurveCompo( EgtGetParent( nId), nId, True)
EgtChangeId( nNewId, nId)
End If
' aggiungo il punto
Dim dUs, dUe As Double
EgtCurveDomain( nId, dUs, dUe)
If m_dPrev < 0.1 AndAlso Not EgtCurveIsClosed( nId) Then
EgtAddCurveCompoLine( nId, m_ptLast.Loc( nId), False)
ElseIf m_dPrev > dUe - 0.1 AndAlso Not EgtCurveIsClosed( nId) Then
EgtAddCurveCompoLine( nId, m_ptLast.Loc( nId), True)
Else
EgtAddCurveCompoJoint( nId, m_dPrev)
EgtModifyCurveCompoJoint( nId, m_dAux, m_ptLast, GDB_RT.GLOB)
End If
DisableCommandLog()
EgtDraw()
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragAddPointCurve()
If m_nStep = 2 Then
' svuoto il gruppo di drag
EgtEmptyGroup( m_Scene.GetDragGroup())
' creo una copia della curva nel layer per il drag
Dim nId As Integer
Dim nOrigId As Integer = EgtGetLastSelectedObj()
If EgtGetType( nOrigId) = GDB_TY.CRV_COMPO Then
nId = m_Scene.AddToDragGroup( nOrigId)
Else
EgtDisableModified()
nId = EgtCreateCurveCompo( m_Scene.GetDragGroup(), nOrigId, False)
EgtEnableModified()
End If
' dominio della curva
Dim dUs, dUe As Double
EgtCurveDomain( nId, dUs, dUe)
' aggiungo il punto alla curva nel gruppo di drag
If m_dPrev < 0.1 AndAlso Not EgtCurveIsClosed( nId) Then
Dim ptStart As Point3d
Dim vtStart As Vector3d
EgtStartPoint( nId, ptStart)
EgtStartVector( nId, vtStart)
EgtAddCurveCompoLine( nId, ptStart - vtStart * 1, False)
ElseIf m_dPrev > dUe - 0.1 AndAlso Not EgtCurveIsClosed( nId) Then
Dim ptEnd As Point3d
Dim vtEnd As Vector3d
EgtEndPoint( nId, ptEnd)
EgtEndVector( nId, vtEnd)
EgtAddCurveCompoLine( nId, ptEnd + vtEnd * 1, True)
Else
EgtAddCurveCompoJoint( nId, m_dPrev)
End If
' sposto il punto
EgtModifyCurveCompoJoint( nId, m_dAux, m_ptLast, GDB_RT.GLOB)
EgtDraw()
End If
End Sub
Private Function RemovePointCurve() As Boolean
Select Case m_nStep
Case 0
' verifico condizioni
Dim nId As Integer = EgtGetLastSelectedObj()
If EgtGetType(nId) <> GDB_TY.CRV_COMPO Then Return False
' imposto stato a primo punto per aggiungere un punto curva
m_Scene.SetStatusSelPoint()
m_nStep = 1
RaiseEvent PrepareInputBox("REMOVE POINT TO CURVE", "Insert Point ", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
m_Scene.DisableTangentPoint()
m_Scene.DisablePerpendicularPoint()
m_Scene.DisableMinDistPoint()
Case 1
m_ptP1 = m_ptLast
m_sepP1 = m_sepLast
m_nIdP1 = m_nIdLast
m_ptCont = m_ptLast
Dim nId As Integer = EgtGetLastSelectedObj()
Dim dDist, dU As Double
' recupero il punto sulla curva
If EgtPointCurveDist(m_ptLast.Loc(nId), nId, nId, dDist, dU) Then
Dim nUEnt As Integer = CInt(Math.Round(dU))
' reset scena
m_Scene.ResetStatus(False)
EnableCommandLog()
'Rimuovo il punto e modifico la curva
EgtRemoveCurveCompoJoint(nId, nUEnt)
DisableCommandLog()
End If
EgtDraw()
m_nStep = 0
RaiseEvent UpdateUI(Me, False)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Function ProcessCurveToArc() As Boolean
Select Case m_nStep
Case 0
' verifico condizioni e preparo per il drag
Dim nId As Integer = EgtGetLastSelectedObj()
Dim nType As Integer = EgtGetType(nId)
If nType <> GDB_TY.CRV_LINE AndAlso nType <> GDB_TY.CRV_ARC AndAlso
nType <> GDB_TY.CRV_BEZ AndAlso nType <> GDB_TY.CRV_COMPO Then Return False
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto stato a primo punto per modifica curva
m_Scene.SetStatusSelPoint()
m_nStep = 1
RaiseEvent PrepareInputBox("CURVE TO ARC", "Insert Start Point ", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d( m_ptCont)
m_Scene.DisableTangentPoint()
m_Scene.DisablePerpendicularPoint()
m_Scene.DisableMinDistPoint()
Case 1
m_ptP1 = m_ptLast
m_sepP1 = m_sepLast
m_nIdP1 = m_nIdLast
m_ptCont = m_ptLast
Dim nId As Integer = EgtGetLastSelectedObj()
' recupero il punto sulla curva
Dim dDist, dU As Double
If Not EgtPointCurveDist( m_ptLast.Loc(nId), nId, nId, dDist, dU) Then m_bDrag = False
m_dAux = CInt(Math.Floor(dU))
m_nStep = 2
m_Scene.EnableDrag()
RaiseEvent PrepareInputBox("CURVE TO ARC", "Insert End Point ", "", False, True)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d( m_ptLast)
m_Scene.DisableTangentPoint()
m_Scene.DisablePerpendicularPoint()
m_Scene.DisableMinDistPoint()
Case 2
' reset scena
m_Scene.ResetStatus(False)
EnableCommandLog()
Dim nId As Integer = EgtGetLastSelectedObj()
' nuovo arco
If EgtGetType( nId) = GDB_TY.CRV_COMPO Then
EgtModifyCurveCompoCurveToArc(nId, m_dAux, m_ptLast, GDB_RT.GLOB)
Else
Dim ptStart, ptEnd As Point3d
If EgtStartPoint( nId, GDB_RT.GLOB, ptStart) AndAlso EgtEndPoint( nId, GDB_RT.GLOB, ptEnd) Then
Dim nNewId As Integer = EgtCreateArc3P( EgtGetParent( nId), ptStart, m_ptLast, ptEnd, GDB_RT.GLOB)
If nNewId <> GDB_ID.NULL Then
EgtErase( nId)
EgtChangeId( nNewId, nId)
End If
End If
End If
DisableCommandLog()
EgtDraw()
m_nStep = 0
RaiseEvent UpdateUI(Me, False)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragCurveToArc()
' il gruppo di Drag ha riferimento globale
If m_nStep = 2 Then
' svuoto il gruppo di drag
EgtEmptyGroup( m_Scene.GetDragGroup())
' recupero l'entità selezionata
Dim nOrigId As Integer = EgtGetLastSelectedObj()
If EgtGetType( nOrigId) = GDB_TY.CRV_COMPO Then
' creo una copia della curva nel layer per il drag
Dim nId As Integer = m_Scene.AddToDragGroup( nOrigId)
' nuovo arco
EgtModifyCurveCompoCurveToArc(nId, m_dAux, m_ptLast, GDB_RT.GLOB)
Else
Dim ptStart, ptEnd As Point3d
If EgtStartPoint( nOrigId, GDB_RT.GLOB, ptStart) AndAlso EgtEndPoint( nOrigId, GDB_RT.GLOB, ptEnd) Then
EgtCreateArc3P( m_Scene.GetDragGroup(), ptStart, m_ptLast, ptEnd, GDB_RT.GLOB)
End If
End If
EgtDraw()
End If
End Sub
Private Function ProcessCurveToLine() As Boolean
Select Case m_nStep
Case 0
' verifico condizioni
Dim nId As Integer = EgtGetLastSelectedObj()
Dim nType As Integer = EgtGetType(nId)
If nType <> GDB_TY.CRV_LINE AndAlso nType <> GDB_TY.CRV_ARC AndAlso
nType <> GDB_TY.CRV_BEZ AndAlso nType <> GDB_TY.CRV_COMPO Then Return False
' imposto stato a primo punto per aggiungere un punto curva
m_Scene.SetStatusSelPoint()
m_nStep = 1
RaiseEvent PrepareInputBox("CURVE TO LINE", "Insert Point ", "", False, False)
m_nInpType = IBT.TY_POINT3D
SetInputBoxPoint3d(m_ptCont)
m_Scene.DisableTangentPoint()
m_Scene.DisablePerpendicularPoint()
m_Scene.DisableMinDistPoint()
Case 1
m_ptP1 = m_ptLast
m_sepP1 = m_sepLast
m_nIdP1 = m_nIdLast
m_ptCont = m_ptLast
' reset scena
m_Scene.ResetStatus(False)
EnableCommandLog()
Dim nId As Integer = EgtGetLastSelectedObj()
If EgtGetType( nId) = GDB_TY.CRV_COMPO Then
Dim dDist, dU As Double
' recupero il punto sulla curva
If EgtPointCurveDist(m_ptLast.Loc(nId), nId, nId, dDist, dU) Then
Dim nCrv As Integer = CInt(Math.Floor(dU))
' Modifico la curva
EgtModifyCurveCompoCurveToLine(nId, nCrv)
End If
Else
Dim ptStart, ptEnd As Point3d
If EgtStartPoint( nId, GDB_RT.GLOB, ptStart) AndAlso EgtEndPoint( nId, GDB_RT.GLOB, ptEnd) Then
Dim nNewId As Integer = EgtCreateLine( EgtGetParent( nId), ptStart, ptEnd, GDB_RT.GLOB)
If nNewId <> GDB_ID.NULL Then
EgtErase( nId)
EgtChangeId( nNewId, nId)
End If
End If
End If
DisableCommandLog()
EgtDraw()
m_nStep = 0
RaiseEvent UpdateUI(Me, False)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Function ProcessCloseCompo() As Boolean
If m_nStep <> 0 Then Return False
' verifico condizioni
Dim nId As Integer = EgtGetLastSelectedObj()
if nId = GDB_ID.NULL Then Return True
If EgtGetType( nId) <> GDB_TY.CRV_COMPO OrElse EgtCurveIsClosed( nId) Then Return False
' eseguo
EnableCommandLog()
EgtCloseCurveCompo( nId)
DisableCommandLog()
' reset
m_Scene.ResetStatus()
m_nStep = 0
RaiseEvent UpdateUI( Me, False)
Return True
End Function
Private Function ProcessOpenCompo() As Boolean
If m_nStep <> 0 Then Return False
' verifico condizioni
Dim nLastId, nLastSub As Integer
Dim ptLastSel As Point3d
EgtGetLastSelInfo( nLastId, nLastSub, ptLastSel)
If nLastId = GDB_ID.NULL Then Return True
If EgtGetType( nLastId) <> GDB_TY.CRV_COMPO OrElse Not EgtCurveIsClosed( nLastId) Then Return False
EnableCommandLog()
' Cambio inizio curva composita e rimuovo l'ultima entità
Dim ptEnd As Point3d
if EgtAtParamPoint( nLastId, nLastSub + 1, ptEnd) Then
EgtChangeClosedCurveStartPoint( nLastId, ptEnd)
EgtRemoveCurveCompoCurve( nLastId)
End If
DisableCommandLog()
' reset
m_Scene.ResetStatus()
m_nStep = 0
RaiseEvent UpdateUI( Me, False)
Return True
End Function
Private Function ProcessApproxCurve( bArcAndLines As Boolean) As Boolean
Select Case m_nStep
Case 0
' verifico condizioni
Dim nId As Integer = EgtGetLastSelectedObj()
Dim nType As Integer = EgtGetType(nId)
If nType <> GDB_TY.CRV_LINE AndAlso nType <> GDB_TY.CRV_ARC AndAlso
nType <> GDB_TY.CRV_BEZ AndAlso nType <> GDB_TY.CRV_COMPO Then Return False
' deve esistere un gruppo corrente e devo poter creare il gruppo di drag
If GetCurrLayer() = GDB_ID.NULL Or Not m_Scene.CreateDragGroup() Then Return False
' imposto stato a cambio alpha (trasparenza)
m_nStep = 1
m_Scene.SetStatusNull()
' abilito dialogo ..., ..., "Copy"
Dim sTitle As String = If( bArcAndLines, "APPROX CURVE", "APPROX CURVE WITH LINES")
RaiseEvent PrepareInputBox( sTitle, "Insert Tolerance", EgtMsg(2001), False, True)
m_nInpType = IBT.TY_DOUBLE
SetInputBoxDouble( m_dStmEps)
Case 1
Dim nId As Integer = EgtGetLastSelectedObj()
' Eseguo approssimazione
EnableCommandLog()
If m_bLast Then nId = EgtCopy( nId, nId, GDB_POS.AFTER)
EgtApproxCurve( nId, If( bArcAndLines, APP_TYPE.ARCS, APP_TYPE.LINES), m_dLast)
DisableCommandLog()
' reset
m_Scene.ResetStatus()
m_nStep = 0
RaiseEvent UpdateUI( Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Function DragApproxCurve( bArcAndLines As Boolean) As Boolean
If m_nStep = 1 Then
' devo sempre partire dalla curva originale
EgtEmptyGroup( m_Scene.GetDragGroup())
Dim nId As Integer = EgtGetLastSelectedObj()
Dim nGrpEntId As Integer = m_Scene.AddToDragGroup( nId)
EgtApproxCurve( nGrpEntId, If( bArcAndLines, APP_TYPE.ARCS, APP_TYPE.LINES), m_dLast)
EgtDraw()
End If
Return False
End Function
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 "MOVE", "Insert Base Point", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2402), EgtMsg(2403), EgtMsg(2001), False, False)
m_nInpType = IBT.TY_POINT3D
RaiseEvent SetInputBoxCheck(m_bLastTransfCheck)
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
m_Scene.EnableDrag()
' abilito dialogo "MOVE", "Insert Target Point", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2402), EgtMsg(2404), EgtMsg(2001), False, True)
SetInputBoxPoint3d(m_ptLast)
m_nInpType = IBT.TY_POINT3D
Case 2
m_Scene.ResetStatus(False)
EnableCommandLog()
' eseguo copia e movimento
If m_bLast Then
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
Dim nCopyId As Integer = DoCopyPartLayerObj( nId, True)
EgtMove(nCopyId, (m_ptLast - m_ptP1).Loc(GDB_ID.GRID), GDB_RT.GRID)
nId = EgtGetNextSelectedObj()
End While
' eseguo movimento
Else
EgtMove(GDB_ID.SEL, (m_ptLast - m_ptP1).Loc(GDB_ID.GRID), GDB_RT.GRID)
End If
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_bLastTransfCheck = m_bLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
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
EgtMove(m_Scene.GetDragGroup(), (m_ptLast - m_ptP1), GDB_RT.GLOB)
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 "ROTATE", "Insert Center", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2406), EgtMsg(2407), EgtMsg(2001), False, False)
m_nInpType = IBT.TY_POINT3D
RaiseEvent SetInputBoxCheck(m_bLastTransfCheck)
Case 1
m_ptP1 = m_ptLast
m_nStep = 2
m_Scene.EnableDrag()
' abilito dialogo "ROTATE", "Insert Base Point", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2406), EgtMsg(2408), EgtMsg(2001), False, False)
m_nInpType = IBT.TY_POINT3D
Case 2
If Point3d.SameApprox(m_ptP1, m_ptLast) Then
RaiseEvent OutputInfo(Me, EgtMsg(2051)) ' Point must be different from previous
Return False
Else
RaiseEvent OutputInfo(Me, "")
End If
m_ptP2 = m_ptLast
m_nStep = 3
m_Scene.EnableDrag()
EgtSetGeoLine(m_ptP1, m_ptLast)
' abilito dialogo "ROTATE", "Insert Angle or Rotation Point", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2406), EgtMsg(2409), EgtMsg(2001), False, True)
m_nInpType = IBT.TY_DOUBLE_OR_POINT3d
Case 3
m_Scene.ResetStatus(False)
' calcolo parametri di rotazione
If m_bPnt3dVsDbl Then
Dim bDet As Boolean = True
EgtGetVectorRotation((m_ptP2 - m_ptP1), (m_ptLast - m_ptP1), EgtGetGridVersZ(), m_dLast, bDet)
End If
EnableCommandLog()
' eseguo copia e rotazione
If m_bLast Then
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
Dim nCopyId As Integer = DoCopyPartLayerObj( nId, True)
EgtRotate(nCopyId, m_ptP1.Loc(GDB_ID.GRID), Vector3d.Z_AX, m_dLast, GDB_RT.GRID)
nId = EgtGetNextSelectedObj()
End While
' eseguo rotazione
Else
EgtRotate(GDB_ID.SEL, m_ptP1.Loc(GDB_ID.GRID), Vector3d.Z_AX, m_dLast, GDB_RT.GRID)
End If
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_bLastTransfCheck = m_bLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
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
' ripristino lo stato iniziale
EgtChangeGroupFrame(m_Scene.GetDragGroup(), Frame3d.GLOB)
' calcolo parametri rotazione
If m_bPnt3dVsDbl Then
Dim bDet As Boolean = True
EgtGetVectorRotation((m_ptP2 - m_ptP1), (m_ptLast - m_ptP1), EgtGetGridVersZ(), m_dLast, bDet)
Else
m_ptLast = m_ptP2
m_ptLast.Rotate(m_ptP1, EgtGetGridVersZ(), m_dLast)
End If
' aggiorno linea di drag
EgtSetGeoLine(m_ptP1, m_ptLast, False)
' eseguo rotazione
EgtRotate(m_Scene.GetDragGroup(), m_ptP1, EgtGetGridVersZ(), m_dLast, GDB_RT.GLOB)
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 "ROTATE 3D", "Insert First Point on Axis", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2411), EgtMsg(2412), EgtMsg(2001), False, False)
m_nInpType = IBT.TY_POINT3D
RaiseEvent SetInputBoxCheck(m_bLastTransfCheck)
Case 1
m_ptP1 = m_ptLast
m_ptP2 = m_ptP1
m_nStep = 2
m_Scene.EnableDrag()
' abilito dialogo "ROTATE 3D", "Insert Second Point on Axis", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2411), EgtMsg(2413), EgtMsg(2001), False, True)
m_nInpType = IBT.TY_POINT3D
Case 2
If Point3d.SameApprox(m_ptP1, m_ptLast) Then
RaiseEvent OutputInfo(Me, EgtMsg(2051)) ' Point must be different from previous
Return False
Else
RaiseEvent OutputInfo(Me, "")
End If
m_ptP2 = m_ptLast
m_nStep = 3
m_Scene.EnableDrag()
' abilito dialogo "ROTATE 3D", "Insert Base Point", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2411), EgtMsg(2414), EgtMsg(2001), False, True)
m_nInpType = IBT.TY_DOUBLE
Case 3
Dim VtNorm As Vector3d = (m_ptLast - m_ptP1) ^ (m_ptP2 - m_ptP1)
If VtNorm.IsSmall() Then
RaiseEvent OutputInfo(Me, EgtMsg(2052)) ' The points must be not aligned
Return False
Else
RaiseEvent OutputInfo(Me, "")
End If
m_ptP3 = m_ptLast
m_nStep = 4
m_Scene.EnableDrag()
' abilito dialogo "ROTATE 3D", "Insert Angle or Rotation Point", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2411), EgtMsg(2415), EgtMsg(2001), False, True)
m_nInpType = IBT.TY_DOUBLE_OR_POINT3d
Case 4
m_Scene.ResetStatus(False)
' calcolo parametri di rotazione
Dim VtAx As Vector3d = m_ptP2 - m_ptP1
If m_bPnt3dVsDbl Then
Dim bDet As Boolean = True
EgtGetVectorRotation((m_ptP3 - m_ptP1), (m_ptLast - m_ptP1), VtAx, m_dLast, bDet)
Else
m_ptLast = m_ptP3
m_ptLast.Rotate(m_ptP1, VtAx, m_dLast)
End If
EnableCommandLog()
' eseguo copia e rotazione
If m_bLast Then
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
Dim nCopyId As Integer = DoCopyPartLayerObj( nId, True)
EgtRotate(nCopyId, m_ptP1.Loc(GDB_ID.GRID), VtAx.Loc(GDB_ID.GRID), m_dLast, GDB_RT.GRID)
nId = EgtGetNextSelectedObj()
End While
' eseguo rotazione
Else
EgtRotate(GDB_ID.SEL, m_ptP1.Loc(GDB_ID.GRID), VtAx.Loc(GDB_ID.GRID), m_dLast, GDB_RT.GRID)
End If
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_bLastTransfCheck = m_bLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
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
EgtResetGeoLine(False)
EgtSetGeoTria(m_ptP1, m_ptP2, m_ptLast)
EgtDraw()
ElseIf m_nStep = 4 Then
' ripristino lo stato iniziale
EgtChangeGroupFrame(m_Scene.GetDragGroup(), Frame3d.GLOB)
' calcolo parametri rotazione
Dim VtAx As Vector3d = m_ptP2 - m_ptP1
If m_bPnt3dVsDbl Then
Dim bDet As Boolean = True
EgtGetVectorRotation((m_ptP3 - m_ptP1), (m_ptLast - m_ptP1), VtAx, m_dLast, bDet)
Else
m_ptLast = m_ptP3
m_ptLast.Rotate(m_ptP1, VtAx, m_dLast)
End If
' aggiorno triangolo di drag
EgtSetGeoTria(m_ptP1, m_ptP2, m_ptLast, False)
' eseguo rotazione
EgtRotate(m_Scene.GetDragGroup(), m_ptP1, VtAx, m_dLast, GDB_RT.GLOB)
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 "MIRROR", "Insert First Point", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2416), EgtMsg(2417), EgtMsg(2001), False, False)
m_nInpType = IBT.TY_POINT3D
RaiseEvent SetInputBoxCheck(m_bLastTransfCheck)
Case 1
m_ptP1 = m_ptLast
m_ptP2 = m_ptP1
m_nStep = 2
m_Scene.EnableDrag()
' abilito dialogo "MIRROR", "Insert Second Point", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2416), EgtMsg(2418), EgtMsg(2001), False, True)
m_nInpType = IBT.TY_POINT3D
Case 2
If Point3d.SameApprox(m_ptP1, m_ptLast) Then
RaiseEvent OutputInfo(Me, EgtMsg(2051)) ' Point must be different from previous
Return False
Else
RaiseEvent OutputInfo(Me, "")
End If
m_Scene.ResetStatus(False)
' esecuzione
Dim VtNorm As Vector3d = (m_ptLast - m_ptP1) ^ EgtGetGridVersZ()
If VtNorm.Len > EPS_SMALL Then
EnableCommandLog()
' eseguo copia e mirror
If m_bLast Then
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
Dim nCopyId As Integer = DoCopyPartLayerObj( nId, True)
EgtMirror(nCopyId, m_ptP1.Loc(GDB_ID.GRID), VtNorm.Loc(GDB_ID.GRID), GDB_RT.GRID)
nId = EgtGetNextSelectedObj()
End While
' eseguo mirror
Else
EgtMirror(GDB_ID.SEL, m_ptP1.Loc(GDB_ID.GRID), VtNorm.Loc(GDB_ID.GRID), GDB_RT.GRID)
End If
DisableCommandLog()
End If
EgtDraw()
' aggiorno stato
m_bLastTransfCheck = m_bLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
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
EgtMirror(m_Scene.GetDragGroup(), m_ptP1, VtNorm, GDB_RT.GLOB)
End If
' eseguo mirror
VtNorm = (m_ptLast - m_ptP1) ^ EgtGetGridVersZ()
If VtNorm.Len > EPS_SMALL Then
EgtMirror(m_Scene.GetDragGroup(), m_ptP1, VtNorm, GDB_RT.GLOB)
RaiseEvent OutputInfo(Me, "")
Else
RaiseEvent OutputInfo(Me, EgtMsg(2051)) ' Point must be different from previous
End If
' salvo il punto
m_ptP2 = m_ptLast
EgtDraw()
End If
End Sub
Private Function ProcessMirror3D() 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 "MIRROR 3D", "Insert First Point", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2421), EgtMsg(2422), EgtMsg(2001), False, False)
m_nInpType = IBT.TY_POINT3D
RaiseEvent SetInputBoxCheck(m_bLastTransfCheck)
Case 1
m_ptP1 = m_ptLast
m_ptP2 = m_ptP1
m_nStep = 2
m_Scene.EnableDrag()
' abilito dialogo "MIRROR 3D", "Insert Second Point", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2421), EgtMsg(2423), EgtMsg(2001), False, True)
m_nInpType = IBT.TY_POINT3D
Case 2
If Point3d.SameApprox(m_ptP1, m_ptLast) Then
RaiseEvent OutputInfo(Me, EgtMsg(2051)) ' The Point must be different from previous
Return False
Else
RaiseEvent OutputInfo(Me, "")
End If
m_ptP2 = m_ptLast
m_ptP3 = m_ptP2
m_nStep = 3
m_Scene.EnableDrag()
' abilito dialogo "MIRROR 3D", "Insert Third Point", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2421), EgtMsg(2424), EgtMsg(2001), False, True)
m_nInpType = IBT.TY_POINT3D
Case 3
Dim VtNorm As Vector3d = (m_ptLast - m_ptP1) ^ (m_ptP2 - m_ptP1)
If VtNorm.IsSmall() Then
RaiseEvent OutputInfo(Me, EgtMsg(2052)) ' The points must be not aligned
Return False
Else
RaiseEvent OutputInfo(Me, "")
End If
m_Scene.ResetStatus(False)
' esecuzione
If Not VtNorm.IsSmall() Then
EnableCommandLog()
' eseguo copia e mirror
If m_bLast Then
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
Dim nCopyId As Integer = DoCopyPartLayerObj( nId, True)
EgtMirror(nCopyId, m_ptP1.Loc(GDB_ID.GRID), VtNorm.Loc(GDB_ID.GRID), GDB_RT.GRID)
nId = EgtGetNextSelectedObj()
End While
' eseguo mirror
Else
EgtMirror(GDB_ID.SEL, m_ptP1.Loc(GDB_ID.GRID), VtNorm.Loc(GDB_ID.GRID), GDB_RT.GRID)
End If
DisableCommandLog()
End If
EgtDraw()
' aggiorno stato
m_bLastTransfCheck = m_bLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragMirror3D()
If m_nStep = 2 Then
' linea di mirror
EgtSetGeoLine(m_ptP1, m_ptLast)
ElseIf m_nStep = 3 Then
' triangolo di mirror
EgtResetGeoLine()
EgtSetGeoTria(m_ptP1, m_ptP2, m_ptLast)
' ripristino lo stato iniziale, tramite undo di mirror precedente
Dim VtNorm As Vector3d = (m_ptP3 - m_ptP1) ^ (m_ptP2 - m_ptP1)
If VtNorm.Len > EPS_SMALL Then
EgtMirror(m_Scene.GetDragGroup(), m_ptP1, VtNorm, GDB_RT.GLOB)
End If
' eseguo mirror
VtNorm = (m_ptLast - m_ptP1) ^ (m_ptP2 - m_ptP1)
If VtNorm.Len > EPS_SMALL Then
EgtMirror(m_Scene.GetDragGroup(), m_ptP1, VtNorm, GDB_RT.GLOB)
End If
' salvo il punto
m_ptP3 = 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 "SCALE", "Insert Center", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2426), EgtMsg(2427), EgtMsg(2001), False, False)
m_nInpType = IBT.TY_POINT3D
RaiseEvent SetInputBoxCheck(m_bLastTransfCheck)
Case 1
m_ptP1 = m_ptLast
m_dPrev = 1
m_dLast = 1
m_nStep = 2
m_Scene.SetStatusNull()
' abilito dialogo "SCALE", "Insert Factor", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2426), EgtMsg(2428), EgtMsg(2001), False, True)
m_nInpType = IBT.TY_DOUBLE
SetInputBoxDouble(m_dLast)
Case 2
If m_dLast < EPS_SMALL Then
RaiseEvent OutputInfo(Me, EgtMsg(2053)) ' Zero or Negative Values not allowed
Return False
Else
RaiseEvent OutputInfo(Me, "")
End If
m_Scene.ResetStatus(False)
EnableCommandLog()
' eseguo copia e scalatura
If m_bLast Then
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
Dim nCopyId As Integer = DoCopyPartLayerObj( nId, True)
EgtScale(nCopyId, New Frame3d(m_ptP1.Loc(GDB_ID.GRID)), m_dLast, m_dLast, m_dLast, GDB_RT.GRID)
nId = EgtGetNextSelectedObj()
End While
' eseguo scalatura
Else
EgtScale(GDB_ID.SEL, New Frame3d(m_ptP1.Loc(GDB_ID.GRID)), m_dLast, m_dLast, m_dLast, GDB_RT.GRID)
End If
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_bLastTransfCheck = m_bLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragScale()
If m_nStep = 2 Then
If m_dLast < EPS_SMALL Then
RaiseEvent OutputInfo(Me, EgtMsg(2053)) ' Zero or Negative Values not allowed
Return
Else
RaiseEvent OutputInfo(Me, "")
End If
' calcolo parametri di scalatura
Dim frScale As New Frame3d(EgtGetGridFrame())
frScale.ChangeOrigin(m_ptP1)
Dim dScale As Double = m_dLast / m_dPrev
' eseguo scalatura
EgtScale(m_Scene.GetDragGroup(), frScale, dScale, dScale, dScale, GDB_RT.GLOB)
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 "SCALE 3D", "Insert Center", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2431), EgtMsg(2432), EgtMsg(2001), False, False)
m_nInpType = IBT.TY_POINT3D
RaiseEvent SetInputBoxCheck(m_bLastTransfCheck)
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.SetStatusNull()
m_Scene.DisableDrag()
' abilito dialogo "SCALE 3D", "Insert Factors", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2431), EgtMsg(2433), EgtMsg(2001), False, True)
m_nInpType = IBT.TY_3DOUBLE
SetInputBox3Double(m_d3Last)
Case 2
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) Or
(m_d3Last(0) < EPS_SMALL And m_d3Last(2) < EPS_SMALL) Or
(m_d3Last(1) < EPS_SMALL And m_d3Last(2) < EPS_SMALL) Then
RaiseEvent OutputInfo(Me, EgtMsg(2054)) ' Two Zero or Negative Values not allowed
Return False
Else
RaiseEvent OutputInfo(Me, "")
End If
m_Scene.ResetStatus(False)
EnableCommandLog()
' eseguo copia e scalatura
If m_bLast Then
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
Dim nCopyId As Integer = DoCopyPartLayerObj( nId, True)
EgtScale(nCopyId, New Frame3d(m_ptP1.Loc(GDB_ID.GRID)), m_d3Last(0), m_d3Last(1), m_d3Last(2), GDB_RT.GRID)
nId = EgtGetNextSelectedObj()
End While
' eseguo scalatura
Else
Dim bOk = EgtScale(GDB_ID.SEL, New Frame3d(m_ptP1.Loc(GDB_ID.GRID)), m_d3Last(0), m_d3Last(1), m_d3Last(2), GDB_RT.GRID)
If Not bOk Then
' "Some entities are not scalable" "Warning"
MessageBox.Show(EgtMsg(2055), EgtMsg(2003), MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End If
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_bLastTransfCheck = m_bLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragScale3D()
If m_nStep = 2 Then
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) Or
(m_d3Last(0) < EPS_SMALL And m_d3Last(2) < EPS_SMALL) Or
(m_d3Last(1) < EPS_SMALL And m_d3Last(2) < EPS_SMALL) Then
RaiseEvent OutputInfo(Me, EgtMsg(2054)) ' Two Zero or Negative Values not allowed
Return
Else
RaiseEvent OutputInfo(Me, "")
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.ChangeOrigin(m_ptP1)
Dim d3Scale(2) 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
Dim bOk = EgtScale(m_Scene.GetDragGroup(), frScale, d3Scale(0), d3Scale(1), d3Scale(2), GDB_RT.GLOB)
If bOk Then
m_d3Prev(0) = m_d3Last(0)
m_d3Prev(1) = m_d3Last(1)
m_d3Prev(2) = m_d3Last(2)
Else
RaiseEvent OutputInfo(Me, EgtMsg(2055)) ' Some entities are not scalable
' forzo ripartenza da zero su prossimo drag
m_d3Prev(0) = 0
m_d3Prev(1) = 0
m_d3Prev(2) = 0
End If
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, True) Then Return False
' imposto stato a lunghezza di offset
m_nStep = 1
m_dLast = m_dLastOffset
m_dPrev = m_dLast
m_nLast = 0
m_Scene.SetStatusSelPoint(False)
' abilito dialogo "OFFSET", "Insert Distance", "Copy"
RaiseEvent PrepareInputBox(EgtMsg(2436), EgtMsg(2437), EgtMsg(2001), True, True)
m_nInpType = IBT.TY_SPECIALDOUBLE
SetInputBoxDouble(m_dLast, True)
RaiseEvent SetInputBoxCheck(m_bLastOffsetCheck)
RaiseEvent AddInputBoxCombo(EgtMsg(2438), True) ' Fillet
RaiseEvent AddInputBoxCombo(EgtMsg(2439), False) ' Chamfer
RaiseEvent AddInputBoxCombo(EgtMsg(2440), False) ' Extend
EgtDraw()
Case 1
' reset stato scena
m_Scene.ResetStatus(False)
EnableCommandLog()
' eseguo offset con copia
Dim nCount As Integer
If m_bLast Then
EgtOffsetCurveAdv(EgtGetLastSelectedObj(), m_dLast, m_nLast, nCount)
' altrimenti solo offset
Else
Dim nId As Integer = EgtGetLastSelectedObj()
Dim nFirstId As Integer = EgtOffsetCurveAdv( nId, m_dLast, m_nLast, nCount)
If nCount > 0 Then
EgtErase( nId)
if nCount = 1 Then EgtChangeId( nFirstId, nId)
End If
End If
DisableCommandLog()
EgtDraw()
' aggiorno stato
m_bLastOffsetCheck = m_bLast
m_dLastOffset = m_dLast
m_nStep = 0
RaiseEvent UpdateUI(Me, True)
Case Else
m_nStep = 0
Return False
End Select
Return True
End Function
Private Sub DragOffset()
If m_nStep = 1 Then
' linea di distanza
EgtSetGeoLine(m_ptP1, m_ptLast)
' devo sempre partire dalla curva originale
m_Scene.EraseDragGroup()
PrepareTransform(False, True)
' eseguo offset
Dim nId As Integer = EgtGetLastSelectedObj()
Dim nCount As Integer
Dim nNewId = EgtOffsetCurveAdv(nId, m_dLast, m_nLast, nCount)
If nCount <= 0 Then
Dim vtPlaN As Vector3d
Dim dPlaDist As Double
If EgtCurveIsFlat(nId, vtPlaN, dPlaDist) Then
RaiseEvent OutputInfo(Me, EgtMsg(2056)) ' Distance too big
Else
RaiseEvent OutputInfo(Me, EgtMsg(2057)) ' Curve not flat (in its plane)
End If
Else
For i As Integer = 0 To nCount - 1
EgtRelocateGlob( nNewId + i, m_Scene.GetDragGroup())
Next
RaiseEvent OutputInfo(Me, "")
End If
EgtDraw()
End If
End Sub
Private Function ExecuteSpecialDataOffset() As Boolean
If m_nStep = 1 Then
Dim dDist As Double
Dim nSide As Integer
Dim ptMin As Point3d
Dim nId As Integer = EgtGetLastSelectedObj()
If EgtPointCurveDistSide(m_ptLast.Loc(nId), nId, EgtGetGridVersZ().Loc(nId), nId, dDist, ptMin, nSide) Then
' calcolo la distanza tra m_ptLast e ptMin sul piano griglia
m_ptP1 = ptMin.Glob(nId)
Dim vtDiff As Vector3d = m_ptLast - m_ptP1
vtDiff -= vtDiff * EgtGetGridVersZ() * EgtGetGridVersZ()
Dim dDistFr As Double = vtDiff.Len()
' assegno la distanza di offset tenendo conto del lato ( sx=-1, dx=+1)
m_dLast = dDistFr * nSide
' se vettore estrusione della curva opposto al versore Z della griglia, devo cambiare segno alla distanza
Dim vtExtr As Vector3d
If EgtCurveExtrusion(nId, vtExtr) And Not vtExtr.IsSmall() Then
If vtExtr * EgtGetGridVersZ().Loc(nId) < -EPS_SMALL Then m_dLast = -m_dLast
End If
End If
End If
Return False
End Function
Private Function PrepareTransform(Optional bAllSelected As Boolean = True, Optional bOnlyPrepare As Boolean = False) As Boolean
' verifico ci sia qualcosa di selezionato
If EgtGetFirstSelectedObj() = GDB_ID.NULL Then
Return False
End If
' se non esiste già, creo il gruppo di drag e vi copio le entità selezionate
If m_Scene.GetDragGroup() = GDB_ID.NULL Then
If Not m_Scene.CreateDragGroup() Then
Return False
End If
End If
' se non richiesta copia
If bOnlyPrepare Then Return True
' se devo prendere tutti
If bAllSelected Then
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
If m_Scene.AddToDragGroup(nId) = GDB_ID.NULL 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 Or m_Scene.AddToDragGroup(nId) = GDB_ID.NULL Then
m_Scene.EraseDragGroup()
Return False
End If
End If
Return True
End Function
Private Function GridLenFromGlobLen(vtLen As Vector3d) As Double
vtLen.ToLoc(EgtGetGridFrame())
Return Math.Sqrt(vtLen.x * vtLen.x + vtLen.y * vtLen.y)
End Function
Private Function GridAngFromGlobDir(vtDir As Vector3d) As Double
vtDir.ToLoc(EgtGetGridFrame())
Dim dLen As Double
Dim dAngVertDeg As Double
Dim dAngOrizzDeg As Double
vtDir.ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg)
If dAngOrizzDeg > 180 Then
dAngOrizzDeg -= 360
ElseIf dAngOrizzDeg < -180 Then
dAngOrizzDeg += 360
End If
Return dAngOrizzDeg
End Function
Private Function GlobDirFromGridAng(dGridAngDeg As Double) As Vector3d
Dim vtDir As Vector3d = Vector3d.X_AX()
vtDir.Rotate(Vector3d.Z_AX, dGridAngDeg)
vtDir.ToGlob(EgtGetGridFrame())
Return vtDir
End Function
'-------------------------------- Current Part and Layer -----------------------------------------
Public Function GetCurrPart() As Integer
Return EgtGetCurrPart()
End Function
Public Function GetCurrLayer() As Integer
Return EgtGetCurrLayer()
End Function
'-------------------------------- Modified Status ------------------------------------------------
Public Function SetCurrFile(sFile As String) As Boolean
Return EgtSetCurrFilePath(sFile)
End Function
Public Function ResetCurrFile() As Boolean
Return EgtSetCurrFilePath("")
End Function
Public Function GetCurrFile() As String
Dim sCurrFile As String = String.Empty
EgtGetCurrFilePath(sCurrFile)
Return sCurrFile
End Function
Public Sub SetModified(Optional bReloadUI As Boolean = True)
EgtSetModified()
RaiseEvent UpdateUI(Me, bReloadUI)
End Sub
Public Sub ResetModified(Optional bReloadUI As Boolean = True)
EgtResetModified()
RaiseEvent UpdateUI(Me, bReloadUI)
End Sub
Public Function GetModified() As Boolean
Return EgtGetModified()
End Function
Public Function ManageModified() As Boolean
' se non modificato, procedo normalmente
If Not GetModified() Then
Return True
End If
' chiedo cosa fare
Dim sMsg As String = "Save changes"
Dim sCurrFile = GetCurrFile()
If Not String.IsNullOrEmpty(sCurrFile) Then
sMsg += " to " + sCurrFile
End If
sMsg += " ?"
Dim nRes = MessageBox.Show(m_Scene, sMsg, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
Select Case nRes
Case Windows.Forms.DialogResult.Yes
SaveProject()
Return True
Case Windows.Forms.DialogResult.No
Return True
Case Else
Return False
End Select
End Function
'-------------------------------- Fonts ----------------------------------------------------------
Private m_sFonts As New ArrayList
Private Sub LoadFonts()
' pulisco eventuale vecchio array
m_sFonts.Clear()
' carico font Nfe
Dim sNfeDir As String = String.Empty
EgtGetNfeFontDir(sNfeDir)
If Not String.IsNullOrWhiteSpace(sNfeDir) Then
For Each File As String In IO.Directory.GetFiles(sNfeDir, "*.nfe")
m_sFonts.Add(IO.Path.GetFileName(File))
Next
End If
' carico font di sistema
Dim oneFontFamily As FontFamily
For Each oneFontFamily In FontFamily.Families
m_sFonts.Add(oneFontFamily.Name)
Next
End Sub
'-------------------------------- Colors ---------------------------------------------------------
Private m_bCustomColors As Boolean = False
Private m_sCustColSect As String = ""
Private m_sCustColKey As String = ""
Public Function SetUseCustomColors(bUse As Boolean, sCustColSect As String, sCustColKey As String) As Boolean
m_bCustomColors = bUse
If m_bCustomColors Then
m_sCustColSect = sCustColSect
m_sCustColKey = sCustColKey
Else
m_sCustColSect = ""
m_sCustColKey = ""
End If
Return True
End Function
Private Function SelectColor(Col As Color3d, ByRef NewCol As Color3d) As Boolean
' Path file Ini
Dim sIniFile As String = ""
EgtGetIniFile(sIniFile)
' Se richiesto, recupero i colori custom
Dim nCustomColors As New List(Of Integer)
If m_bCustomColors Then
' Recupero colori custom
Dim sCustomColors As String = ""
GetPrivateProfileString(m_sCustColSect, m_sCustColKey, "", sCustomColors, sIniFile)
Dim CustomColors() As String = sCustomColors.Split(","c)
For Each Color In CustomColors
Dim nColor As Integer
If Integer.TryParse(Color, nColor) Then
nCustomColors.Add(nColor)
End If
Next
End If
' Creo dialogo colori
Dim ColorDlg As New System.Windows.Forms.ColorDialog
ColorDlg.FullOpen = True
ColorDlg.CustomColors = nCustomColors.ToArray()
ColorDlg.Color = Col.ToColor()
' Visualizzo dialogo
If ColorDlg.ShowDialog() <> Windows.Forms.DialogResult.OK Then Return False
' Recupero colore scelto
NewCol.FromColor(ColorDlg.Color)
' Se richiesto, salvo eventuali modifiche ai colori custom
If m_bCustomColors Then
Dim sCustomColors As String = ""
For Each Color In ColorDlg.CustomColors
sCustomColors &= Color.ToString() & ","
Next
sCustomColors = sCustomColors.Trim({" "c, ","c})
WritePrivateProfileString(m_sCustColSect, m_sCustColKey, sCustomColors, sIniFile)
End If
Return True
End Function
'-------------------------------- Registrazione Comandi (in Lua) ---------------------------------
Private m_bCommandLog As Boolean = False
Public Function SetCommandLog(bCmdLog As Boolean, sCmdLogDir As String, sCmdLogFile As String) As Boolean
' imposto stato
m_bCommandLog = bCmdLog
' se necessario inizializzo logger
If m_bCommandLog Then
Dim sCmdBakFile As String = sCmdLogFile & ".bak"
Dim sFile = sCmdLogDir & "\" & sCmdLogFile
Dim sBackup = sCmdLogDir & "\" & sCmdBakFile
' se logger già in uso, non faccio alcunchè e non lo avvio
If FileInUse(sFile) Then
m_bCommandLog = False
Return False
End If
' backup di eventuale log già presente
If My.Computer.FileSystem.FileExists(sFile) Then
' cancello eventuale vecchio backup
If My.Computer.FileSystem.FileExists(sBackup) Then
My.Computer.FileSystem.DeleteFile(sBackup)
End If
' rinomino il file
My.Computer.FileSystem.RenameFile(sFile, sCmdBakFile)
End If
' avvio logger
EgtSetCommandLogger(sFile)
End If
Return True
End Function
Public Function GetCommandLog() As Boolean
Return m_bCommandLog
End Function
Private Sub EnableCommandLog()
If m_bCommandLog Then
EgtEnableCommandLogger()
End If
End Sub
Private Sub DisableCommandLog()
EgtDisableCommandLogger()
End Sub
End Class