EgtUILib 1.6a6 :
- allineamento con TestEIn.
This commit is contained in:
+312
-3
@@ -1,7 +1,7 @@
|
||||
'----------------------------------------------------------------------------
|
||||
' EgalTech 2014-2015
|
||||
'----------------------------------------------------------------------------
|
||||
' File : Controller.vb Data : 04.11.14 Versione : 1.6a3
|
||||
' File : Controller.vb Data : 27.01.15 Versione : 1.6a6
|
||||
' Contenuto : Classe Controller (parte di MVC).
|
||||
'
|
||||
'
|
||||
@@ -19,7 +19,18 @@ Imports System.Text
|
||||
Public Class Controller
|
||||
|
||||
' Events
|
||||
Public Event PrepareInputBox(ByVal sTitle As String, ByVal sLabel As String, ByRef sCheckLabel As String,
|
||||
Public Event OnNewProject(ByVal sender As Object, ByVal bOk As Boolean)
|
||||
Public Event OnOpeningProject(ByVal sender As Object)
|
||||
Public Event OnOpenProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean)
|
||||
Public Event OnSavingProject(ByVal sender As Object, ByVal sFile As String)
|
||||
Public Event OnSavedProject(ByVal sender As Object, ByVal bOk As Boolean)
|
||||
Public Event OnImportingProject(ByVal sender As Object, ByVal bOkType As Boolean)
|
||||
Public Event OnImportedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean)
|
||||
Public Event OnExportingProject(ByVal sender As Object, ByVal sFile As String)
|
||||
Public Event OnExportedProject(ByVal sender As Object, ByVal bOk As Boolean)
|
||||
Public Event OnExecutingScript(ByVal sender As Object, ByVal sFile As String)
|
||||
Public Event OnExecutedScript(ByVal sender As Object, ByVal bOk As Boolean, ByVal sError As String)
|
||||
Public Event PrepareInputBox(ByVal sTitle As String, ByVal sLabel As String, ByVal sCheckLabel As String,
|
||||
ByVal bShowCombo As Boolean, ByVal bShowBtn As Boolean)
|
||||
Public Event SetInputBoxText(ByVal sText As String)
|
||||
Public Event SetInputBoxCheck(ByVal bCheck As Boolean)
|
||||
@@ -149,6 +160,304 @@ Public Class Controller
|
||||
Private OFFSET_STD As Double = 0
|
||||
|
||||
' Metodi
|
||||
Public Function NewProject(Optional ByVal bCreatePart As Boolean = False) As Boolean
|
||||
' gestisco eventuale file corrente modificato
|
||||
If Not ManageModified() Then
|
||||
Return False
|
||||
End If
|
||||
' eseguo
|
||||
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)
|
||||
End If
|
||||
DisableCommandLog()
|
||||
' aggiorno
|
||||
EgtZoom(ZM.ALL)
|
||||
ResetCurrFile()
|
||||
ResetCurrPartLayer()
|
||||
ResetModified()
|
||||
' Gestione risultato
|
||||
RaiseEvent OnNewProject(Me, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function OpenProject(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
' gestisco eventuale file corrente modificato
|
||||
If Not ManageModified() Then
|
||||
Return False
|
||||
End If
|
||||
' eseguo
|
||||
Dim sFile As String = sDir
|
||||
' Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Open"
|
||||
OpenFileDialog.Filter = "New geometry EgalTech(*.nge)|*.nge" &
|
||||
"|New font EgalTech(*.nfe)|*.nfe" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 1
|
||||
OpenFileDialog.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
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
EnableCommandLog()
|
||||
Dim bOk As Boolean = EgtOpenFile(sFile)
|
||||
DisableCommandLog()
|
||||
EgtZoom(ZM.ALL)
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
' Aggiornamento
|
||||
SetCurrFile(sFile)
|
||||
ResetCurrPartLayer()
|
||||
ResetModified()
|
||||
'Gestione risultato
|
||||
RaiseEvent OnOpenProject(Me, sFile, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function InsertProject(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
Dim sFile As String = sDir
|
||||
' Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Insert"
|
||||
OpenFileDialog.Filter = "New geometry EgalTech(*.nge)|*.nge" &
|
||||
"|New font EgalTech(*.nfe)|*.nfe" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 1
|
||||
OpenFileDialog.InitialDirectory = sDir
|
||||
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
sFile = OpenFileDialog.FileName
|
||||
End If
|
||||
'Inserimento del progetto
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtInsertFile(sFile)
|
||||
EgtZoom(ZM.ALL)
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
' Aggiornamento
|
||||
SetModified()
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function SaveProject(Optional ByVal sFile As String = "", Optional ByVal nType As NGE = NGE.CMPTEXT) As Boolean
|
||||
If String.IsNullOrWhiteSpace(sFile) Or EgtGetFileType(sFile) <> FT.NGE Then
|
||||
Return SaveAsProject(sFile, nType)
|
||||
Else
|
||||
'Prima del salvataggio
|
||||
SetCurrFile(sFile)
|
||||
RaiseEvent OnSavingProject(Me, sFile)
|
||||
'Salvataggio del progetto
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
EnableCommandLog()
|
||||
Dim bOk As Boolean = EgtSaveFile(sFile, nType)
|
||||
DisableCommandLog()
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
If bOk Then
|
||||
ResetModified()
|
||||
End If
|
||||
RaiseEvent OnSavedProject(Me, bOk)
|
||||
Return bOk
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function SaveAsProject(Optional ByVal sFile As String = "", Optional ByVal nType As NGE = NGE.CMPTEXT) As Boolean
|
||||
'Eventuale sistemazione estensione
|
||||
sFile = IO.Path.ChangeExtension(sFile, "nge")
|
||||
'Assegnazione nome file con dialogo
|
||||
Dim SaveFileDialog As New SaveFileDialog
|
||||
SaveFileDialog.Title = "Save"
|
||||
SaveFileDialog.Filter = "New geometry EgalTech(*.nge)|*.nge"
|
||||
SaveFileDialog.FileName = sFile
|
||||
SaveFileDialog.InitialDirectory = IO.Path.GetDirectoryName(sFile)
|
||||
If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
'Prima del salvataggio
|
||||
SetCurrFile(SaveFileDialog.FileName)
|
||||
RaiseEvent OnSavingProject(Me, SaveFileDialog.FileName)
|
||||
'Salvataggio del progetto
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
EnableCommandLog()
|
||||
Dim bOk As Boolean = EgtSaveFile(SaveFileDialog.FileName, nType)
|
||||
DisableCommandLog()
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
If bOk Then
|
||||
ResetModified()
|
||||
End If
|
||||
RaiseEvent OnSavedProject(Me, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function ImportProject(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
' gestisco eventuale file corrente modificato
|
||||
If Not ManageModified() Then
|
||||
Return False
|
||||
End If
|
||||
' eseguo
|
||||
Dim sFile As String = sDir
|
||||
'Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Import"
|
||||
OpenFileDialog.Filter = "Drawing Exchange Fmt(*.dxf)|*.dxf" &
|
||||
"|Stereolithography (*.stl)|*.stl" &
|
||||
"|Part program ISO (*.cnc)|*.cnc" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 4
|
||||
OpenFileDialog.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.DXF Or nFileType = FT.STL Or nFileType = FT.CNC)
|
||||
'Prima del caricamento
|
||||
RaiseEvent OnImportingProject(Me, bOkType)
|
||||
If Not bOkType Then
|
||||
Return False
|
||||
End If
|
||||
'Pulizia GeomDB
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtNewFile()
|
||||
'Importazione
|
||||
EnableCommandLog()
|
||||
If nFileType = FT.DXF Then
|
||||
bOk = bOk And EgtImportDxf(sFile)
|
||||
ElseIf nFileType = FT.STL Then
|
||||
bOk = bOk And EgtImportStl(sFile)
|
||||
ElseIf nFileType = FT.CNC Then
|
||||
bOk = bOk And EgtImportCnc(sFile)
|
||||
End If
|
||||
DisableCommandLog()
|
||||
EgtZoom(ZM.ALL)
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
' Aggiornamento
|
||||
SetCurrFile(sFile)
|
||||
ResetCurrPartLayer()
|
||||
SetModified()
|
||||
'Gestione risultato
|
||||
RaiseEvent OnImportedProject(Me, sFile, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function ExportProject(Optional ByVal sFile As String = "") As Boolean
|
||||
'Assegnazione nome file con dialogo
|
||||
Dim SaveFileDialog As New SaveFileDialog
|
||||
SaveFileDialog.Title = "Export"
|
||||
SaveFileDialog.Filter = "Drawing Exchange Fmt(*.dxf)|*.dxf" &
|
||||
"|Stereolithography (*.stl)|*.stl" &
|
||||
"|All Files (*.*)|*.*"
|
||||
SaveFileDialog.FilterIndex = 3
|
||||
SaveFileDialog.FileName = sFile
|
||||
If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
'Riconoscimento tipo file
|
||||
Dim nFileType As Integer = EgtGetFileType(SaveFileDialog.FileName)
|
||||
If nFileType <> FT.DXF And nFileType <> FT.STL Then
|
||||
MessageBox.Show("File type unknown", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
Return False
|
||||
End If
|
||||
'Prima dell'esportazione
|
||||
RaiseEvent OnExportingProject(Me, SaveFileDialog.FileName)
|
||||
'Esportazione del progetto
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
EnableCommandLog()
|
||||
Dim bOk As Boolean = False
|
||||
If nFileType = FT.DXF Then
|
||||
bOk = EgtExportDxf(GDB_ID.ROOT, SaveFileDialog.FileName)
|
||||
ElseIf nFileType = FT.STL Then
|
||||
bOk = EgtExportStl(GDB_ID.ROOT, SaveFileDialog.FileName)
|
||||
End If
|
||||
DisableCommandLog()
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
RaiseEvent OnExportedProject(Me, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function Exec(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
Dim sFile As String = sDir
|
||||
'Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Exec Script"
|
||||
OpenFileDialog.Filter = "Lua commands(*.lua)|*.lua" &
|
||||
"|Test commands(*.tsc)|*.tsc" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 1
|
||||
OpenFileDialog.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, sFile)
|
||||
'Esecuzione
|
||||
m_Scene.Cursor = Cursors.WaitCursor
|
||||
EnableCommandLog()
|
||||
Dim bOk As Boolean = False
|
||||
If (sExt = ".LUA") Then
|
||||
bOk = EgtLuaExecFile(sFile)
|
||||
Else
|
||||
bOk = EgtTscExecFile(sFile)
|
||||
End If
|
||||
DisableCommandLog()
|
||||
EgtZoom(ZM.ALL)
|
||||
m_Scene.Cursor = Cursors.Default
|
||||
' Aggiornamento
|
||||
SetModified()
|
||||
'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, bOk, sError)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Sub MouseSelectedAll()
|
||||
' eseguo la selezione ed aggiorno
|
||||
EnableCommandLog()
|
||||
EgtSelectAll(True)
|
||||
DisableCommandLog()
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Public Sub MouseDeselectedAll()
|
||||
' eseguo la selezione ed aggiorno
|
||||
EnableCommandLog()
|
||||
EgtDeselectAll()
|
||||
DisableCommandLog()
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Public Sub MouseSelectedObj(ByVal nId As Integer, ByVal bLast As Boolean)
|
||||
EnableCommandLog()
|
||||
If EgtIsSelectedObj(nId) Then
|
||||
@@ -3624,7 +3933,7 @@ Public Class Controller
|
||||
Dim nRes = MessageBox.Show(sMsg, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
|
||||
Select Case nRes
|
||||
Case Windows.Forms.DialogResult.Yes
|
||||
m_Scene.SaveProject(m_sCurrFile)
|
||||
SaveProject(m_sCurrFile)
|
||||
Return True
|
||||
Case Windows.Forms.DialogResult.No
|
||||
Return True
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
'----------------------------------------------------------------------------
|
||||
' EgalTech 2014-2015
|
||||
'----------------------------------------------------------------------------
|
||||
' File : EgtInterface.vb Data : 18.01.15 Versione : 1.6a3
|
||||
' File : EgtInterface.vb Data : 27.01.15 Versione : 1.6a6
|
||||
' Contenuto : Modulo EgtInterface (interfaccia verso il motore EgalTech).
|
||||
'
|
||||
'
|
||||
@@ -804,7 +804,7 @@ Public Function EgtOpenFile(ByVal sFilePath As String) As Boolean
|
||||
End Function
|
||||
|
||||
<DllImport(EgtIntDll, CharSet:=CharSet.Unicode)>
|
||||
Public Function EgtImportFile(ByVal sFilePath As String) As Boolean
|
||||
Public Function EgtInsertFile(ByVal sFilePath As String) As Boolean
|
||||
End Function
|
||||
|
||||
<DllImport(EgtIntDll, CharSet:=CharSet.Unicode)>
|
||||
|
||||
@@ -42,5 +42,5 @@ Imports System.Runtime.InteropServices
|
||||
' È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
|
||||
' utilizzando l'asterisco (*) come descritto di seguito:
|
||||
|
||||
<Assembly: AssemblyVersion("1.6.1.4")>
|
||||
<Assembly: AssemblyFileVersion("1.6.1.4")>
|
||||
<Assembly: AssemblyVersion("1.6.1.6")>
|
||||
<Assembly: AssemblyFileVersion("1.6.1.6")>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'----------------------------------------------------------------------------
|
||||
' EgalTech 2014-2015
|
||||
'----------------------------------------------------------------------------
|
||||
' File : Scene.vb Data : 18.01.15 Versione : 1.6a3
|
||||
' File : Scene.vb Data : 27.01.15 Versione : 1.6a6
|
||||
' Contenuto : Classe Scene (parte di MVC).
|
||||
'
|
||||
'
|
||||
@@ -183,6 +183,8 @@ Public Class Scene
|
||||
End Sub
|
||||
|
||||
'---- Events ----------
|
||||
Public Event OnMouseSelectedAll(ByVal sender As Object)
|
||||
Public Event OnMouseDeselectedAll(ByVal sender As Object)
|
||||
Public Event OnMouseSelectedObj(ByVal sender As Object, ByVal nId As Integer, ByVal bLast As Boolean)
|
||||
Public Event OnMouseSelectedPart(ByVal sender As Object, ByVal nId As Integer)
|
||||
Public Event OnMouseSelectedLayer(ByVal sender As Object, ByVal nId As Integer)
|
||||
@@ -197,24 +199,8 @@ Public Class Scene
|
||||
Public Event OnMouseSelectedDir(ByVal sender As Object, ByVal VtDir As Vector3d)
|
||||
Public Event OnMouseMoveSelPoint(ByVal sender As Object, ByVal PtP As Point3d)
|
||||
Public Event OnChangedSnapPointType(ByVal sender As Object, ByVal nSpType As SP)
|
||||
Public Event OnNewProject(ByVal sender As Object, ByVal bOk As Boolean)
|
||||
Public Event OnOpeningProject(ByVal sender As Object)
|
||||
Public Event OnOpenProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean)
|
||||
Public Event OnSavingProject(ByVal sender As Object, ByVal sFile As String)
|
||||
Public Event OnSavedProject(ByVal sender As Object, ByVal bOk As Boolean)
|
||||
Public Event OnImportingProject(ByVal sender As Object, ByVal bOkType As Boolean)
|
||||
Public Event OnImportedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean)
|
||||
Public Event OnExportingProject(ByVal sender As Object, ByVal sFile As String)
|
||||
Public Event OnExportedProject(ByVal sender As Object, ByVal bOk As Boolean)
|
||||
Public Event OnExecutingScript(ByVal sender As Object, ByVal sFile As String)
|
||||
Public Event OnExecutedScript(ByVal sender As Object, ByVal bOk As Boolean, ByVal sError As String)
|
||||
|
||||
'---- Mouse -----------
|
||||
Protected Overrides Sub OnMouseEnter(e As System.EventArgs)
|
||||
MyBase.OnMouseEnter(e)
|
||||
Focus()
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnMouseDown(e As System.Windows.Forms.MouseEventArgs)
|
||||
' Imposto il contesto della scena come corrente
|
||||
EgtSetCurrentContext(m_nGseContext)
|
||||
@@ -306,7 +292,26 @@ Public Class Scene
|
||||
' se stato selezione punto
|
||||
ElseIf m_nStatus = ST.SELPOINT Then
|
||||
If Not m_bDragOn Then
|
||||
RaiseEvent OnMouseDone(Me)
|
||||
' rendo selezionabile gruppo di drag
|
||||
If Not m_bDragSelectable Then
|
||||
EgtUnselectableRemove(m_nDragGroup)
|
||||
End If
|
||||
' eseguo selezione
|
||||
Dim nSel As Integer = GDB_ID.NULL
|
||||
EgtSelect(e.Location, DIM_SEL, DIM_SEL, nSel)
|
||||
' ripristino stato precedente di selezionabilità drag
|
||||
If Not m_bDragSelectable Then
|
||||
EgtUnselectableAdd(m_nDragGroup)
|
||||
End If
|
||||
' click su geometria di drag equivale a Done
|
||||
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
||||
While nId <> GDB_ID.NULL
|
||||
If EgtGetParent(nId) = m_nDragGroup Then
|
||||
RaiseEvent OnMouseDone(Me)
|
||||
Exit While
|
||||
End If
|
||||
nId = EgtGetNextObjInSelWin()
|
||||
End While
|
||||
ElseIf EgtGetGraphicSnapPoint(m_nSnapType, e.Location, DIM_SEL, DIM_SEL, m_ptPrev) Then
|
||||
' se Snap Sketch o Grid e premuto SHIFT si passa a modalità elevatore
|
||||
If (m_nSnapType = SP.PT_SKETCH Or m_nSnapType = SP.PT_GRID) And
|
||||
@@ -434,11 +439,16 @@ Public Class Scene
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnMouseMove(e As System.Windows.Forms.MouseEventArgs)
|
||||
' salvo il contesto corrente e imposto quello della scena
|
||||
' Salvo il contesto corrente e imposto quello della scena
|
||||
Dim nOldGseCtx = EgtGetCurrentContext()
|
||||
If nOldGseCtx <> m_nGseContext Then
|
||||
EgtSetCurrentContext(m_nGseContext)
|
||||
End If
|
||||
' Se sono abbastanza all'interno della scena (10% della dimensione), imposto il focus
|
||||
If e.Location.X > 0.1 * Size.Width AndAlso e.Location.X < 0.9 * Size.Width AndAlso
|
||||
e.Location.Y > 0.1 * Size.Height AndAlso e.Location.Y < 0.9 * Size.Height Then
|
||||
Focus()
|
||||
End If
|
||||
' Visualizzo le coordinate del mouse
|
||||
ShowCursorPos(e.Location)
|
||||
' --- Premuto tasto sinistro ---
|
||||
@@ -732,9 +742,9 @@ Public Class Scene
|
||||
i.Visible = False
|
||||
End If
|
||||
Case "sepSelPnt1"
|
||||
i.Visible = True
|
||||
i.Visible = (m_nStatus <> ST.GETDIST And m_nStatus <> ST.GETDIST2)
|
||||
Case "cmdStopDrag"
|
||||
i.Visible = True
|
||||
i.Visible = (m_nStatus <> ST.GETDIST And m_nStatus <> ST.GETDIST2)
|
||||
Case Else
|
||||
i.Visible = False
|
||||
End Select
|
||||
@@ -758,15 +768,9 @@ Public Class Scene
|
||||
Private Sub MenuScene_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) Handles MenuScene.ItemClicked
|
||||
' Per selezione
|
||||
If e.ClickedItem.Name = "cmdSelectAll" Then
|
||||
EgtEnableCommandLogger()
|
||||
EgtSelectAll(True)
|
||||
EgtDisableCommandLogger()
|
||||
EgtDraw()
|
||||
RaiseEvent OnMouseSelectedAll(Me)
|
||||
ElseIf e.ClickedItem.Name = "cmdDeselectAll" Then
|
||||
EgtEnableCommandLogger()
|
||||
EgtDeselectAll()
|
||||
EgtDisableCommandLogger()
|
||||
EgtDraw()
|
||||
RaiseEvent OnMouseDeselectedAll(Me)
|
||||
ElseIf e.ClickedItem.Name = "cmdWinSelect" Then
|
||||
m_nStatus = ST.WINSEL
|
||||
ElseIf e.ClickedItem.Name = "cmdSelectPart" Then
|
||||
@@ -915,6 +919,7 @@ Public Class Scene
|
||||
|
||||
'---- Drag Group ------
|
||||
Private m_bDragOn As Boolean = True
|
||||
Private m_bDragSelectable As Boolean = False
|
||||
Private m_nDragGroup As Integer = GDB_ID.NULL
|
||||
|
||||
Public Sub EnableDrag()
|
||||
@@ -936,7 +941,10 @@ Public Class Scene
|
||||
End If
|
||||
EgtSetLevel(m_nDragGroup, GDB_LV.TEMP)
|
||||
EgtSetMark(m_nDragGroup)
|
||||
If Not bSelectable Then
|
||||
m_bDragSelectable = bSelectable
|
||||
If m_bDragSelectable Then
|
||||
EgtUnselectableRemove(m_nDragGroup)
|
||||
Else
|
||||
EgtUnselectableAdd(m_nDragGroup)
|
||||
End If
|
||||
Return True
|
||||
@@ -944,6 +952,7 @@ Public Class Scene
|
||||
|
||||
Public Function EraseDragGroup() As Boolean
|
||||
EgtErase(m_nDragGroup)
|
||||
m_bDragSelectable = False
|
||||
EgtUnselectableRemove(m_nDragGroup)
|
||||
m_nDragGroup = GDB_ID.NULL
|
||||
Return True
|
||||
@@ -968,236 +977,6 @@ Public Class Scene
|
||||
Return m_nDragGroup
|
||||
End Function
|
||||
|
||||
'---- Main Buttons ----
|
||||
Public Function NewProject(Optional ByVal bCreatePart As Boolean = False) As Boolean
|
||||
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)
|
||||
End If
|
||||
EgtZoom(ZM.ALL)
|
||||
' Gestione risultato
|
||||
RaiseEvent OnNewProject(Me, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function OpenProject(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
Dim sFile As String = sDir
|
||||
' Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Open"
|
||||
OpenFileDialog.Filter = "New geometry EgalTech(*.nge)|*.nge" &
|
||||
"|New font EgalTech(*.nfe)|*.nfe" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 1
|
||||
OpenFileDialog.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 = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtOpenFile(sFile)
|
||||
EgtZoom(ZM.ALL)
|
||||
Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
RaiseEvent OnOpenProject(Me, sFile, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function InsertProject(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
Dim sFile As String = sDir
|
||||
' Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Insert"
|
||||
OpenFileDialog.Filter = "New geometry EgalTech(*.nge)|*.nge" &
|
||||
"|New font EgalTech(*.nfe)|*.nfe" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 1
|
||||
OpenFileDialog.InitialDirectory = sDir
|
||||
If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
sFile = OpenFileDialog.FileName
|
||||
End If
|
||||
'Inserimento del progetto
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtImportFile(sFile)
|
||||
EgtZoom(ZM.ALL)
|
||||
Cursor = Cursors.Default
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function SaveProject(Optional ByVal sFile As String = "", Optional ByVal nType As NGE = NGE.CMPTEXT) As Boolean
|
||||
If String.IsNullOrWhiteSpace(sFile) Or EgtGetFileType(sFile) <> FT.NGE Then
|
||||
Return SaveAsProject(sFile, nType)
|
||||
Else
|
||||
'Prima del salvataggio
|
||||
RaiseEvent OnSavingProject(Me, sFile)
|
||||
'Salvataggio del progetto
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtSaveFile(sFile, nType)
|
||||
Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
RaiseEvent OnSavedProject(Me, bOk)
|
||||
Return bOk
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function SaveAsProject(Optional ByVal sFile As String = "", Optional ByVal nType As NGE = NGE.CMPTEXT) As Boolean
|
||||
'Eventuale sistemazione estensione
|
||||
sFile = Path.ChangeExtension(sFile, "nge")
|
||||
'Assegnazione nome file con dialogo
|
||||
Dim SaveFileDialog As New SaveFileDialog
|
||||
SaveFileDialog.Title = "Save"
|
||||
SaveFileDialog.Filter = "New geometry EgalTech(*.nge)|*.nge"
|
||||
SaveFileDialog.FileName = sFile
|
||||
SaveFileDialog.InitialDirectory = Path.GetDirectoryName(sFile)
|
||||
If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
'Prima del salvataggio
|
||||
RaiseEvent OnSavingProject(Me, SaveFileDialog.FileName)
|
||||
'Salvataggio del progetto
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtSaveFile(SaveFileDialog.FileName, nType)
|
||||
Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
RaiseEvent OnSavedProject(Me, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function ImportProject(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
Dim sFile As String = sDir
|
||||
'Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Import"
|
||||
OpenFileDialog.Filter = "Drawing Exchange Fmt(*.dxf)|*.dxf" &
|
||||
"|Stereolithography (*.stl)|*.stl" &
|
||||
"|Part program ISO (*.cnc)|*.cnc" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 4
|
||||
OpenFileDialog.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.DXF Or nFileType = FT.STL Or nFileType = FT.CNC)
|
||||
'Prima del caricamento
|
||||
RaiseEvent OnImportingProject(Me, bOkType)
|
||||
If Not bOkType Then
|
||||
Return False
|
||||
End If
|
||||
'Pulizia GeomDB
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = EgtNewFile()
|
||||
'Importazione
|
||||
If nFileType = FT.DXF Then
|
||||
bOk = bOk And EgtImportDxf(sFile)
|
||||
ElseIf nFileType = FT.STL Then
|
||||
bOk = bOk And EgtImportStl(sFile)
|
||||
ElseIf nFileType = FT.CNC Then
|
||||
bOk = bOk And EgtImportCnc(sFile)
|
||||
End If
|
||||
EgtZoom(ZM.ALL)
|
||||
Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
RaiseEvent OnImportedProject(Me, sFile, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function ExportProject(Optional ByVal sFile As String = "") As Boolean
|
||||
'Assegnazione nome file con dialogo
|
||||
Dim SaveFileDialog As New SaveFileDialog
|
||||
SaveFileDialog.Title = "Export"
|
||||
SaveFileDialog.Filter = "Drawing Exchange Fmt(*.dxf)|*.dxf" &
|
||||
"|Stereolithography (*.stl)|*.stl" &
|
||||
"|All Files (*.*)|*.*"
|
||||
SaveFileDialog.FilterIndex = 3
|
||||
SaveFileDialog.FileName = sFile
|
||||
If SaveFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then
|
||||
Return True
|
||||
End If
|
||||
'Riconoscimento tipo file
|
||||
Dim nFileType As Integer = EgtGetFileType(SaveFileDialog.FileName)
|
||||
If nFileType <> FT.DXF And nFileType <> FT.STL Then
|
||||
MessageBox.Show("File type unknown", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
Return False
|
||||
End If
|
||||
'Prima dell'esportazione
|
||||
RaiseEvent OnExportingProject(Me, SaveFileDialog.FileName)
|
||||
'Esportazione del progetto
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = False
|
||||
If nFileType = FT.DXF Then
|
||||
bOk = EgtExportDxf(GDB_ID.ROOT, SaveFileDialog.FileName)
|
||||
ElseIf nFileType = FT.STL Then
|
||||
bOk = EgtExportStl(GDB_ID.ROOT, SaveFileDialog.FileName)
|
||||
End If
|
||||
Cursor = Cursors.Default
|
||||
'Gestione risultato
|
||||
RaiseEvent OnExportedProject(Me, bOk)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
Public Function Exec(Optional ByVal sDir As String = "", Optional ByVal bWithDlg As Boolean = True) As Boolean
|
||||
Dim sFile As String = sDir
|
||||
'Scelta file con dialogo
|
||||
If bWithDlg Then
|
||||
Dim OpenFileDialog As New OpenFileDialog
|
||||
OpenFileDialog.Title = "Exec Script"
|
||||
OpenFileDialog.Filter = "Lua commands(*.lua)|*.lua" &
|
||||
"|Test commands(*.tsc)|*.tsc" &
|
||||
"|All Files (*.*)|*.*"
|
||||
OpenFileDialog.FilterIndex = 1
|
||||
OpenFileDialog.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(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, sFile)
|
||||
'Esecuzione
|
||||
Cursor = Cursors.WaitCursor
|
||||
Dim bOk As Boolean = False
|
||||
If (sExt = ".LUA") Then
|
||||
bOk = EgtLuaExecFile(sFile)
|
||||
Else
|
||||
bOk = EgtTscExecFile(sFile)
|
||||
End If
|
||||
EgtZoom(ZM.ALL)
|
||||
Cursor = 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, bOk, sError)
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
'---- Zoom Buttons ----
|
||||
Public Sub ZoomAll()
|
||||
EgtZoom(ZM.ALL)
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
Public Class btnExec
|
||||
|
||||
Private m_scene As Scene
|
||||
Private m_Controller As Controller
|
||||
|
||||
Sub New()
|
||||
' Chiamata richiesta dalla finestra di progettazione.
|
||||
@@ -9,12 +9,12 @@
|
||||
Me.Text = "Exec"
|
||||
End Sub
|
||||
|
||||
Public Sub SetScene(ByRef scene As Scene)
|
||||
m_scene = scene
|
||||
Public Sub SetController(ByRef controller As Controller)
|
||||
m_Controller = controller
|
||||
End Sub
|
||||
|
||||
Private Sub btnExec_Click(sender As System.Object, e As System.EventArgs) Handles Me.Click
|
||||
m_scene.Exec()
|
||||
m_Controller.Exec()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
Public Class btnExport
|
||||
|
||||
Private m_scene As Scene
|
||||
Private m_Controller As Controller
|
||||
|
||||
Sub New()
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub SetScene(ByRef scene As Scene)
|
||||
m_scene = scene
|
||||
Public Sub SetController(ByRef controller As Controller)
|
||||
m_Controller = controller
|
||||
End Sub
|
||||
|
||||
Private Sub btnExport_Click(sender As System.Object, e As System.EventArgs) Handles Me.Click
|
||||
m_scene.ExportProject()
|
||||
m_Controller.ExportProject()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
Public Class btnImport
|
||||
|
||||
Private m_scene As Scene
|
||||
Private m_Controller As Controller
|
||||
|
||||
Sub New()
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub SetScene(ByRef scene As Scene)
|
||||
m_scene = scene
|
||||
Public Sub SetController(ByRef controller As Controller)
|
||||
m_Controller = controller
|
||||
End Sub
|
||||
|
||||
Private Sub btnImport_Click(sender As System.Object, e As System.EventArgs) Handles Me.Click
|
||||
m_scene.ImportProject()
|
||||
m_Controller.ImportProject()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Public Class btnNew
|
||||
|
||||
Private m_scene As Scene
|
||||
Private m_Controller As Controller
|
||||
|
||||
Sub New()
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub SetScene(ByRef scene As Scene)
|
||||
m_scene = scene
|
||||
Public Sub SetController(ByRef controller As Controller)
|
||||
m_Controller = controller
|
||||
End Sub
|
||||
|
||||
Private Sub btnNew_Click(sender As System.Object, e As System.EventArgs) Handles Me.Click
|
||||
m_scene.NewProject()
|
||||
m_Controller.NewProject()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
Public Class btnOpen
|
||||
|
||||
Private m_scene As Scene
|
||||
Private m_Controller As Controller
|
||||
|
||||
Sub New()
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub SetScene(ByRef scene As Scene)
|
||||
m_scene = scene
|
||||
Public Sub SetController(ByRef controller As Controller)
|
||||
m_Controller = controller
|
||||
End Sub
|
||||
|
||||
Private Sub btnOpen_Click(sender As System.Object, e As System.EventArgs) Handles Me.Click
|
||||
m_scene.OpenProject()
|
||||
m_Controller.OpenProject()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
Public Class btnSave
|
||||
|
||||
Private m_scene As Scene
|
||||
Private m_Controller As Controller
|
||||
|
||||
Sub New()
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub SetScene(ByRef scene As Scene)
|
||||
m_scene = scene
|
||||
Public Sub SetController(ByRef controller As Controller)
|
||||
m_Controller = controller
|
||||
End Sub
|
||||
|
||||
Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles Me.Click
|
||||
m_scene.SaveProject()
|
||||
m_Controller.SaveProject()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Public Class tsExec
|
||||
|
||||
Private m_scene As Scene
|
||||
Private m_Controller As Controller
|
||||
|
||||
'Create button
|
||||
Dim btnExec As New ToolStripButton
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub SetScene(ByRef scene As Scene)
|
||||
m_scene = scene
|
||||
Public Sub SetController(ByRef controller As Controller)
|
||||
m_Controller = controller
|
||||
End Sub
|
||||
|
||||
Public Sub AddButtons()
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
'The Click Events
|
||||
Private Sub btnExec_Click(sender As Object, e As System.EventArgs)
|
||||
m_scene.Exec()
|
||||
m_Controller.Exec()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Public Class tsMain
|
||||
|
||||
Private m_scene As Scene
|
||||
Private m_Controller As Controller
|
||||
|
||||
'Create buttons
|
||||
Dim btnNew As New ToolStripButton
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub SetScene(ByRef scene As Scene)
|
||||
m_scene = scene
|
||||
Public Sub SetController(ByRef controller As Controller)
|
||||
m_Controller = controller
|
||||
End Sub
|
||||
|
||||
Public Sub AddButtons()
|
||||
@@ -95,23 +95,23 @@
|
||||
|
||||
'The Click Events
|
||||
Private Sub btnNew_Click(sender As Object, e As System.EventArgs)
|
||||
m_scene.NewProject()
|
||||
m_Controller.NewProject()
|
||||
End Sub
|
||||
|
||||
Private Sub btnOpen_Click(sender As Object, e As System.EventArgs)
|
||||
m_scene.OpenProject()
|
||||
m_Controller.OpenProject()
|
||||
End Sub
|
||||
|
||||
Private Sub btnSave_Click(sender As Object, e As System.EventArgs)
|
||||
m_scene.SaveProject()
|
||||
m_Controller.SaveProject()
|
||||
End Sub
|
||||
|
||||
Private Sub btnImport_Click(sender As Object, e As System.EventArgs)
|
||||
m_scene.ImportProject()
|
||||
m_Controller.ImportProject()
|
||||
End Sub
|
||||
|
||||
Private Sub btnExport_Click(sender As Object, e As System.EventArgs)
|
||||
m_scene.ExportProject()
|
||||
m_Controller.ExportProject()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user