diff --git a/Controller.vb b/Controller.vb index db3b636..151b371 100644 --- a/Controller.vb +++ b/Controller.vb @@ -173,13 +173,15 @@ Public Class Controller Dim nIdNewPart As Integer = EgtCreateGroup(GDB_ID.ROOT) ' inserisco un nuovo gruppo (layer) sotto quello appena creato Dim nIdNewLayer As Integer = EgtCreateGroup(nIdNewPart) + ' reset flag di modificato + EgtResetModified() End If + ' aggiorno pezzo e layer correnti + EgtResetCurrPartLayer() DisableCommandLog() ' aggiorno EgtZoom(ZM.ALL) - ResetCurrFile() - ResetCurrPartLayer() - ResetModified() + RaiseEvent UpdateUI(Me, True) ' Gestione risultato RaiseEvent OnNewProject(Me, bOk) Return bOk @@ -212,13 +214,12 @@ Public Class Controller m_Scene.Cursor = Cursors.WaitCursor EnableCommandLog() Dim bOk As Boolean = EgtOpenFile(sFile) + EgtResetCurrPartLayer() DisableCommandLog() EgtZoom(ZM.ALL) m_Scene.Cursor = Cursors.Default ' Aggiornamento - SetCurrFile(sFile) - ResetCurrPartLayer() - ResetModified() + RaiseEvent UpdateUI(Me, True) 'Gestione risultato RaiseEvent OnOpenProject(Me, sFile, bOk) Return bOk @@ -242,31 +243,32 @@ Public Class Controller End If 'Inserimento del progetto m_Scene.Cursor = Cursors.WaitCursor + EnableCommandLog() Dim bOk As Boolean = EgtInsertFile(sFile) + DisableCommandLog() EgtZoom(ZM.ALL) m_Scene.Cursor = Cursors.Default ' Aggiornamento - SetModified() + RaiseEvent UpdateUI(Me, True) 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) + Public Function SaveProject(Optional ByVal 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 'Prima del salvataggio - SetCurrFile(sFile) - RaiseEvent OnSavingProject(Me, sFile) + RaiseEvent OnSavingProject(Me, sCurrFile) 'Salvataggio del progetto m_Scene.Cursor = Cursors.WaitCursor EnableCommandLog() - Dim bOk As Boolean = EgtSaveFile(sFile, nType) + Dim bOk As Boolean = EgtSaveFile(sCurrFile, nType) DisableCommandLog() m_Scene.Cursor = Cursors.Default + 'Aggiorno + RaiseEvent UpdateUI(Me, False) 'Gestione risultato - If bOk Then - ResetModified() - End If RaiseEvent OnSavedProject(Me, bOk) Return bOk End If @@ -285,7 +287,6 @@ Public Class Controller Return True End If 'Prima del salvataggio - SetCurrFile(SaveFileDialog.FileName) RaiseEvent OnSavingProject(Me, SaveFileDialog.FileName) 'Salvataggio del progetto m_Scene.Cursor = Cursors.WaitCursor @@ -293,10 +294,9 @@ Public Class Controller Dim bOk As Boolean = EgtSaveFile(SaveFileDialog.FileName, nType) DisableCommandLog() m_Scene.Cursor = Cursors.Default + 'Aggiorno + RaiseEvent UpdateUI(Me, False) 'Gestione risultato - If bOk Then - ResetModified() - End If RaiseEvent OnSavedProject(Me, bOk) Return bOk End Function @@ -343,13 +343,12 @@ Public Class Controller ElseIf nFileType = FT.CNC Then bOk = bOk And EgtImportCnc(sFile) End If + EgtResetCurrPartLayer() DisableCommandLog() EgtZoom(ZM.ALL) m_Scene.Cursor = Cursors.Default ' Aggiornamento - SetCurrFile(sFile) - ResetCurrPartLayer() - SetModified() + RaiseEvent UpdateUI(Me, True) 'Gestione risultato RaiseEvent OnImportedProject(Me, sFile, bOk) Return bOk @@ -386,6 +385,8 @@ Public Class Controller End If DisableCommandLog() m_Scene.Cursor = Cursors.Default + 'Aggiornamento + RaiseEvent UpdateUI(Me, False) 'Gestione risultato RaiseEvent OnExportedProject(Me, bOk) Return bOk @@ -428,7 +429,7 @@ Public Class Controller EgtZoom(ZM.ALL) m_Scene.Cursor = Cursors.Default ' Aggiornamento - SetModified() + RaiseEvent UpdateUI(Me, True) 'Gestione risultato Dim sError As String = String.Empty If Not bOk Then @@ -907,6 +908,7 @@ Public Class Controller End Function Private Function ExecuteDrag() As Boolean + EgtDisableModified() Select Case m_nLastCmd Case CMD.GRID_ROTATE DragGridRotate() @@ -961,8 +963,10 @@ Public Class Controller Case CMD.OFFSET DragOffset() Case Else + EgtEnableModified() Return False End Select + EgtEnableModified() Return True End Function @@ -985,7 +989,8 @@ Public Class Controller EnableCommandLog() Dim bOk As Boolean = EgtLuaExecLine(m_sLast) DisableCommandLog() - SetModified() + ' Aggiornamento + RaiseEvent UpdateUI(Me, True) EgtDraw() Return bOk End Function @@ -1316,13 +1321,12 @@ Public Class Controller Dim nIdNewPart As Integer = EgtCreateGroup(GDB_ID.ROOT) ' inserisco un nuovo gruppo (layer) sotto quello appena creato Dim nIdNewLayer As Integer = EgtCreateGroup(nIdNewPart) - DisableCommandLog() ' se ok, salvo nuova situazione If nIdNewPart <> GDB_ID.NULL And nIdNewLayer <> GDB_ID.NULL Then - m_nCurrPart = nIdNewPart - m_nCurrLayer = nIdNewLayer - SetModified() + EgtSetCurrPartLayer(nIdNewPart, nIdNewLayer) End If + DisableCommandLog() + RaiseEvent UpdateUI(Me, True) Return True End Function @@ -1332,13 +1336,13 @@ Public Class Controller End If EnableCommandLog() ' inserisco un nuovo gruppo (layer) sotto il pezzo corrente - Dim nIdNewLayer As Integer = EgtCreateGroup(m_nCurrPart, Frame3d.GLOB(), REF_TY.GRID) - DisableCommandLog() + Dim nIdNewLayer As Integer = EgtCreateGroup(EgtGetCurrPart(), Frame3d.GLOB(), REF_TY.GRID) ' se ok, salvo nuova situazione If nIdNewLayer <> GDB_ID.NULL Then - m_nCurrLayer = nIdNewLayer - SetModified() + EgtSetCurrPartLayer(EgtGetCurrPart(), nIdNewLayer) End If + DisableCommandLog() + RaiseEvent UpdateUI(Me, True) Return True End Function @@ -1355,18 +1359,20 @@ Public Class Controller End If End While ' recupero il padre - Dim nIdParent As Integer = EgtGetParent(nId) - If nIdParent = GDB_ID.NULL Then + EgtEnableCommandLogger() + Dim nParentId As Integer = EgtGetParent(nId) + If nParentId = GDB_ID.NULL Then Return False ' se Part - ElseIf nIdParent = GDB_ID.ROOT Then + ElseIf nParentId = GDB_ID.ROOT Then ' cerco il primo Layer del Part Dim nIdLayer As Integer = EgtGetFirstVisibleLayer(nId) - SetCurrPartLayer(nId, nIdLayer) + EgtSetCurrPartLayer(nId, nIdLayer) ' se Layer - ElseIf EgtGetParent(nIdParent) = GDB_ID.ROOT Then - SetCurrPartLayer(nIdParent, nId) + ElseIf EgtGetParent(nParentId) = GDB_ID.ROOT Then + EgtSetCurrPartLayer(nParentId, nId) End If + EgtDisableCommandLogger() RaiseEvent UpdateUI(Me, False) Return True End Function @@ -1375,7 +1381,9 @@ Public Class Controller If m_nStep <> 0 Then Return False End If - ResetCurrPartLayer() + EgtEnableCommandLogger() + EgtResetCurrPartLayer() + EgtDisableCommandLogger() Return True End Function @@ -1384,10 +1392,10 @@ Public Class Controller Return False End If Dim nCurrId As Integer - If m_nCurrPart <> GDB_ID.NULL Then - nCurrId = m_nCurrPart - If m_nCurrLayer <> GDB_ID.NULL Then - nCurrId = m_nCurrLayer + If EgtGetCurrPart() <> GDB_ID.NULL Then + nCurrId = EgtGetCurrPart() + If EgtGetCurrLayer() <> GDB_ID.NULL Then + nCurrId = EgtGetCurrLayer() End If Else Return False @@ -1403,7 +1411,7 @@ Public Class Controller EnableCommandLog() EgtSetColor(nCurrId, colObj) DisableCommandLog() - SetModified() + RaiseEvent UpdateUI(Me, False) EgtDraw() End If Return True @@ -1447,7 +1455,7 @@ Public Class Controller Return False End If End If - SetModified() + RaiseEvent UpdateUI(Me, False) EgtDraw() Return True End Function @@ -1490,7 +1498,7 @@ Public Class Controller Return False End If End If - SetModified() + RaiseEvent UpdateUI(Me, False) EgtDraw() Return True End Function @@ -1510,12 +1518,13 @@ Public Class Controller nPos = GDB_POS.AFTER ' se layer ElseIf EgtGetParent(EgtGetParent(m_nLast)) = GDB_ID.ROOT Then + Dim nCurrPartId = EgtGetCurrPart() ' il riferimento è il pezzo corrente - nRefId = m_nCurrPart + nRefId = nCurrPartId ' se il pezzo sorgente è il corrente - If EgtGetParent(m_nLast) = m_nCurrPart Then + If EgtGetParent(m_nLast) = nCurrPartId Then ' il riferimento è dopo l'ultimo sotto il pezzo - nRefId = EgtGetLastInGroup(m_nCurrPart) + nRefId = EgtGetLastInGroup(nCurrPartId) nPos = GDB_POS.AFTER End If ' altrimenti errore @@ -1524,19 +1533,20 @@ Public Class Controller End If ' altrimenti entità Else + Dim nCurrLayerId As Integer = EgtGetCurrLayer() ' il riferimento è il layer corrente - nRefId = m_nCurrLayer + nRefId = nCurrLayerId ' se il layer sorgente è il corrente - If EgtGetParent(m_nLast) = m_nCurrLayer Then + If EgtGetParent(m_nLast) = nCurrLayerId Then ' il riferimento è dopo l'ultimo sotto il layer - nRefId = EgtGetLastInGroup(m_nCurrLayer) + nRefId = EgtGetLastInGroup(nCurrLayerId) nPos = GDB_POS.AFTER End If End If EnableCommandLog() EgtRelocateGlob(m_nLast, nRefId, nPos) DisableCommandLog() - SetModified() + RaiseEvent UpdateUI(Me, True) EgtDraw() Return True End Function @@ -1562,7 +1572,7 @@ Public Class Controller ElseIf EgtGetParent(EgtGetParent(m_nLast)) = GDB_ID.ROOT Then EnableCommandLog() ' eseguo copia - nNewId = EgtCopyGlob(m_nLast, m_nCurrPart) + nNewId = EgtCopyGlob(m_nLast, EgtGetCurrPart()) ' seleziono tutti gli oggetti del layer bOk = EgtSelectLayerObjs(nNewId) DisableCommandLog() @@ -1574,7 +1584,7 @@ Public Class Controller Else EnableCommandLog() ' eseguo copia - nNewId = EgtCopyGlob(m_nLast, m_nCurrLayer) + nNewId = EgtCopyGlob(m_nLast, EgtGetCurrLayer()) ' la seleziono bOk = EgtSelectObj(nNewId) DisableCommandLog() @@ -1583,8 +1593,8 @@ Public Class Controller If Not bOk Then Return False End If - ' dichiaro modifica - SetModified() + ' aggiorno + RaiseEvent UpdateUI(Me, True) ' se non ci sono oggetti selezionati esco subito If EgtGetSelectedObjNbr() = 0 Then Return True @@ -1615,7 +1625,7 @@ Public Class Controller EnableCommandLog() EgtSetStatus(m_nLast, GDB_ST.ON_) DisableCommandLog() - SetModified(False) + RaiseEvent UpdateUI(Me, False) EgtDraw() End If End If @@ -1634,13 +1644,7 @@ Public Class Controller EnableCommandLog() EgtSetStatus(m_nLast, GDB_ST.OFF) DisableCommandLog() - ' eventuale aggiustamento pezzo/percorso correnti - If m_nLast = m_nCurrPart Then - ResetCurrPartLayer() - ElseIf m_nLast = m_nCurrLayer Then - SetCurrPartLayer(m_nCurrPart, EgtGetFirstVisibleLayer(m_nCurrPart)) - End If - SetModified(False) + RaiseEvent UpdateUI(Me, False) EgtDraw() End If End If @@ -1676,7 +1680,7 @@ Public Class Controller m_Scene.ResetStatus() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -1713,7 +1717,7 @@ Public Class Controller m_Scene.ResetStatus() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, False) Case Else m_nStep = 0 Return False @@ -1747,7 +1751,7 @@ Public Class Controller m_Scene.ResetStatus() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -1806,7 +1810,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -1888,7 +1892,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -1954,7 +1958,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -2008,7 +2012,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -2073,7 +2077,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -2145,7 +2149,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -2234,7 +2238,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -2315,7 +2319,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -2374,7 +2378,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -2431,7 +2435,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -2522,7 +2526,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -2579,7 +2583,7 @@ Public Class Controller m_Scene.ResetStatus() ' reset stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Return True End Function @@ -2609,7 +2613,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -2660,7 +2664,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -2724,7 +2728,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -2775,7 +2779,7 @@ Public Class Controller m_Scene.ResetStatus() ' reset stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Return True End Function @@ -2787,15 +2791,10 @@ Public Class Controller EnableCommandLog() EgtErase(m_nLast) DisableCommandLog() - If m_nLast = m_nCurrPart Then - ResetCurrPartLayer() - ElseIf m_nLast = m_nCurrLayer Then - SetCurrPartLayer(m_nCurrPart, EgtGetFirstVisibleLayer(m_nCurrPart)) - End If ' reset m_Scene.ResetStatus() m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) End If Return True End Function @@ -2810,19 +2809,20 @@ Public Class Controller Return False End If ' verifico ci sia un layer corrente - If m_nCurrLayer = GDB_ID.NULL Then + Dim nCurrLayerId As Integer = EgtGetCurrLayer() + If nCurrLayerId = GDB_ID.NULL Then Return False End If ' ciclo di cambiamento layer (rilocazione) While nId <> GDB_ID.NULL ' il riferimento è il layer corrente - Dim nRefId As Integer = m_nCurrLayer + Dim nRefId As Integer = nCurrLayerId ' la posizione è come figlio Dim nPos As GDB_POS = GDB_POS.SON ' se il layer sorgente è il corrente - If EgtGetParent(nId) = m_nCurrLayer Then + If EgtGetParent(nId) = nCurrLayerId Then ' il riferimento è dopo l'ultimo sotto il layer - nRefId = EgtGetLastInGroup(m_nCurrLayer) + nRefId = EgtGetLastInGroup(nCurrLayerId) nPos = GDB_POS.AFTER End If EnableCommandLog() @@ -2834,7 +2834,7 @@ Public Class Controller m_Scene.ResetStatus() ' reset stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Return True End Function @@ -2866,7 +2866,7 @@ Public Class Controller m_Scene.ResetStatus() ' reset stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, False) Return True End Function @@ -2887,7 +2887,7 @@ Public Class Controller m_Scene.ResetStatus() ' reset stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, False) Return True End Function @@ -2903,7 +2903,7 @@ Public Class Controller m_Scene.ResetStatus() ' reset stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, False) Return True End Function @@ -2955,7 +2955,7 @@ Public Class Controller m_Scene.ResetStatus() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, False) Case Else m_nStep = 0 Return False @@ -3028,7 +3028,7 @@ Public Class Controller m_Scene.ResetStatus() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, False) Case Else m_nStep = 0 Return False @@ -3064,7 +3064,7 @@ Public Class Controller m_Scene.ResetStatus() ' reset stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Return True End Function @@ -3098,7 +3098,7 @@ Public Class Controller m_Scene.ResetStatus() ' reset stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Return True End Function @@ -3133,7 +3133,7 @@ Public Class Controller m_Scene.ResetStatus() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, False) Case Else m_nStep = 0 Return False @@ -3177,7 +3177,7 @@ Public Class Controller m_Scene.ResetStatus() ' reset stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, False) Return True End Function @@ -3220,7 +3220,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -3289,7 +3289,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -3363,7 +3363,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -3430,7 +3430,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -3509,7 +3509,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -3582,7 +3582,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -3653,7 +3653,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -3732,7 +3732,7 @@ Public Class Controller EgtDraw() ' aggiorno stato m_nStep = 0 - SetModified() + RaiseEvent UpdateUI(Me, True) Case Else m_nStep = 0 Return False @@ -3826,114 +3826,59 @@ Public Class Controller End Function '-------------------------------- Current Part and Layer ----------------------------------------- - Private m_nCurrPart As Integer = GDB_ID.NULL - Private m_nCurrLayer As Integer = GDB_ID.NULL - Public Function GetCurrPart() As Integer - Return m_nCurrPart + Return EgtGetCurrPart() End Function Public Function GetCurrLayer() As Integer - Return m_nCurrLayer - End Function - - Private Function SetCurrPartLayer(ByVal nPartId As Integer, ByVal nLayerId As Integer) As Boolean - ' verifico validità e visibilità pezzo - If EgtGetParent(nPartId) = GDB_ID.ROOT AndAlso EgtIsVisibleObj(nPartId) Then - If nPartId <> m_nCurrPart Then - m_nCurrLayer = GDB_ID.NULL - End If - m_nCurrPart = nPartId - Else - If nPartId = m_nCurrPart Or nPartId = GDB_ID.NULL Then - m_nCurrPart = GDB_ID.NULL - m_nCurrLayer = GDB_ID.NULL - End If - Return False - End If - ' verifico validità e visibilità layer - If EgtGetParent(nLayerId) = nPartId AndAlso EgtIsVisibleObj(nLayerId) Then - m_nCurrLayer = nLayerId - Else - If nLayerId = m_nCurrLayer Or nLayerId = GDB_ID.NULL Then - m_nCurrLayer = GDB_ID.NULL - End If - Return False - End If - Return True - End Function - - Private Function ResetCurrPartLayer() As Boolean - ' reset - m_nCurrPart = GDB_ID.NULL - m_nCurrLayer = GDB_ID.NULL - ' cerco il primo pezzo con un layer visibile - Dim nPartId As Integer = EgtGetFirstVisiblePart() - While nPartId <> GDB_ID.NULL - ' cerco il primo layer visibile del pezzo - Dim nLayerId As Integer = EgtGetFirstVisibleLayer(nPartId) - If nLayerId <> GDB_ID.NULL Then - ' assegno il pezzo corrente - m_nCurrPart = nPartId - ' assegno il layer corrente - m_nCurrLayer = nLayerId - ' esco dal ciclo di ricerca - Exit While - End If - nPartId = EgtGetNextVisiblePart(nPartId) - End While - ' se non ho trovato layer visibile mi accontento del primo pezzo visibile - If m_nCurrPart = GDB_ID.NULL Then - m_nCurrPart = EgtGetFirstVisiblePart() - End If - Return True + Return EgtGetCurrLayer() End Function '-------------------------------- Modified Status ------------------------------------------------ - Private m_sCurrFile As String = String.Empty - Private m_bModified As Boolean = False + Public Function SetCurrFile(ByVal sFile As String) As Boolean + Return EgtSetCurrFilePath(sFile) + End Function - Public Sub SetCurrFile(ByRef sFile As String) - m_sCurrFile = sFile - End Sub - - Public Sub ResetCurrFile() - m_sCurrFile = String.Empty - End Sub + Public Function ResetCurrFile() As Boolean + Return EgtSetCurrFilePath("") + End Function Public Function GetCurrFile() As String - Return m_sCurrFile + Dim sCurrFile As String = String.Empty + EgtGetCurrFilePath(sCurrFile) + Return sCurrFile End Function Public Sub SetModified(Optional ByVal bReloadUI As Boolean = True) - m_bModified = True + EgtSetModified() RaiseEvent UpdateUI(Me, bReloadUI) End Sub Public Sub ResetModified(Optional ByVal bReloadUI As Boolean = True) - m_bModified = False + EgtResetModified() RaiseEvent UpdateUI(Me, bReloadUI) End Sub Public Function GetModified() As Boolean - Return m_bModified + Return EgtGetModified() End Function Public Function ManageModified() As Boolean ' se non modificato, procedo normalmente - If Not m_bModified Then + If Not GetModified() Then Return True End If ' chiedo cosa fare - Dim sMsg As String = "Salvare le modifiche" - If Not String.IsNullOrEmpty(m_sCurrFile) Then - sMsg += " a " + m_sCurrFile + 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(sMsg, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) Select Case nRes Case Windows.Forms.DialogResult.Yes - SaveProject(m_sCurrFile) + SaveProject() Return True Case Windows.Forms.DialogResult.No Return True diff --git a/EgtInterface.vb b/EgtInterface.vb index a49eb8e..2782a8b 100644 --- a/EgtInterface.vb +++ b/EgtInterface.vb @@ -556,8 +556,12 @@ End Function Public Function EgtGetNfeFontDir(ByRef sNfeFontDir As String) As Boolean Dim psNfeFontDir As IntPtr Dim bOk As Boolean = EgtGetNfeFontDir(psNfeFontDir) - sNfeFontDir = Marshal.PtrToStringUni(psNfeFontDir) - EgtFreeMemory(psNfeFontDir) + If bOk Then + sNfeFontDir = Marshal.PtrToStringUni(psNfeFontDir) + EgtFreeMemory(psNfeFontDir) + Else + sNfeFontDir = String.Empty + End If Return bOk End Function @@ -567,8 +571,12 @@ End Function Public Function EgtGetDefaultFont(ByRef sDefaultFont As String) As Boolean Dim psDefaultFont As IntPtr Dim bOk As Boolean = EgtGetDefaultFont(psDefaultFont) - sDefaultFont = Marshal.PtrToStringUni(psDefaultFont) - EgtFreeMemory(psDefaultFont) + If bOk Then + sDefaultFont = Marshal.PtrToStringUni(psDefaultFont) + EgtFreeMemory(psDefaultFont) + Else + sDefaultFont = String.Empty + End If Return bOk End Function @@ -597,133 +605,6 @@ Public Function EgtOutLog(ByVal sMag As String) As Boolean End Function -'---------- Geo Base ----------------------------------------------------------- - -Private Function EgtVectorNormalize(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - Optional ByVal dEps As Double = EPS_SMALL) As Boolean -End Function - - -Private Function EgtVectorRotate(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef VtAx As Vector3d, ByVal dAngRotDeg As Double) As Boolean -End Function - - -Private Function EgtVectorScale(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, - ByVal dCoeffX As Double, ByVal dCoeffY As Double, ByVal dCoeffZ As Double) As Boolean -End Function - - -Private Function EgtVectorMirror(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef VtNorm As Vector3d) As Boolean -End Function - - -Private Function EgtVectorShear(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef VtNorm As Vector3d, ByRef VtDir As Vector3d, ByVal dCoeff As Double) As Boolean -End Function - - -Private Function EgtVectorToGlob(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean -End Function - - -Private Function EgtVectorToLoc(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean -End Function - - -Private Function EgtVectorLocToLoc(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef PtO1 As Point3d, ByRef VtX1 As Vector3d, ByRef VtY1 As Vector3d, ByRef VtZ1 As Vector3d, - ByRef PtO2 As Point3d, ByRef VtX2 As Vector3d, ByRef VtY2 As Vector3d, ByRef VtZ2 As Vector3d) As Boolean -End Function - - -Public Function EgtGetVectorRotation(ByRef VtS As Vector3d, ByRef VtE As Vector3d, ByRef VtAx As Vector3d, - ByRef dAngRotDeg As Double, ByRef bDet As Boolean) As Boolean -End Function - - -Private Function EgtPointTranslate(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef VtMove As Vector3d) As Boolean -End Function - - -Private Function EgtPointRotate(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef PtAx As Point3d, ByRef VtAx As Vector3d, ByVal dAngRotDeg As Double) As Boolean -End Function - - -Private Function EgtPointScale(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, - ByVal dCoeffX As Double, ByVal dCoeffY As Double, ByVal dCoeffZ As Double) As Boolean -End Function - - -Private Function EgtPointMirror(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef PtOn As Point3d, ByRef VtNorm As Vector3d) As Boolean -End Function - - -Private Function EgtPointShear(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef PtOn As Point3d, ByRef VtNorm As Vector3d, ByRef VtDir As Vector3d, ByVal dCoeff As Double) As Boolean -End Function - - -Private Function EgtPointToGlob(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean -End Function - - -Private Function EgtPointToLoc(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean -End Function - - -Private Function EgtPointLocToLoc(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, - ByRef PtO1 As Point3d, ByRef VtX1 As Vector3d, ByRef VtY1 As Vector3d, ByRef VtZ1 As Vector3d, - ByRef PtO2 As Point3d, ByRef VtX2 As Vector3d, ByRef VtY2 As Vector3d, ByRef VtZ2 As Vector3d) As Boolean -End Function - - -Private Function EgtFrameFrom3Points(ByRef PtO As Point3d, ByRef PtOnX As Point3d, ByRef PtOnY As Point3d, - ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean -End Function - - -Private Function EgtFrameOCS(ByRef PtO As Point3d, ByRef VtDirZ As Vector3d, - ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean -End Function - - -Private Function EgtFrameTranslate(ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, - ByRef VtMove As Vector3d) As Boolean -End Function - - -Private Function EgtFrameRotate(ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, - ByRef PtAx As Point3d, ByRef VtAx As Vector3d, ByVal dAngRotDeg As Double) As Boolean -End Function - - -Private Function EgtFrameToGlob(ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, - ByRef PtO1 As Point3d, ByRef VtX1 As Vector3d, ByRef VtY1 As Vector3d, ByRef VtZ1 As Vector3d) As Boolean -End Function - - -Private Function EgtFrameToLoc(ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, - ByRef PtO1 As Point3d, ByRef VtX1 As Vector3d, ByRef VtY1 As Vector3d, ByRef VtZ1 As Vector3d) As Boolean -End Function - - -Private Function EgtFrameLocToLoc(ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, - ByRef PtO1 As Point3d, ByRef VtX1 As Vector3d, ByRef VtY1 As Vector3d, ByRef VtZ1 As Vector3d, - ByRef PtO2 As Point3d, ByRef VtX2 As Vector3d, ByRef VtY2 As Vector3d, ByRef VtZ2 As Vector3d) As Boolean -End Function - - '---------- GeomDb ------------------------------------------------------------- Public Function EgtInitGeomDB() As Integer @@ -795,6 +676,45 @@ Public Function EgtGetGridVersZ() As Vector3d Return VtDirZ End Function + +Public Function EgtSetCurrFilePath(ByVal sFilePath As String) As Boolean +End Function + + +Private Function EgtGetCurrFilePath(ByRef psFilePath As IntPtr) As Boolean +End Function +Public Function EgtGetCurrFilePath(ByRef sFilePath As String) As Boolean + Dim psFilePath As IntPtr + Dim bOk As Boolean = EgtGetCurrFilePath(psFilePath) + If bOk Then + sFilePath = Marshal.PtrToStringUni(psFilePath) + EgtFreeMemory(psFilePath) + Else + sFilePath = String.Empty + End If + Return bOk +End Function + + +Public Function EgtEnableModified() As Boolean +End Function + + +Public Function EgtDisableModified() As Boolean +End Function + + +Public Function EgtSetModified() As Boolean +End Function + + +Public Function EgtResetModified() As Boolean +End Function + + +Public Function EgtGetModified() As Boolean +End Function + Public Function EgtNewFile() As Boolean End Function @@ -811,6 +731,8 @@ End Function Public Function EgtSaveFile(ByVal sFilePath As String, ByVal nFlag As NGE) As Boolean End Function + +'---------- Exchange ----------------------------------------------------------- Public Function EgtGetFileType(ByVal sFilePath As String) As Integer End Function @@ -836,6 +758,68 @@ Public Function EgtExportStl(ByVal nId As Integer, ByVal sFilePath As String) As End Function +'---------- Tsc Executor ------------------------------------------------------- + +Public Function EgtInitTscExec() As Boolean +End Function + + +Public Function EgtTscExecFile(ByVal sFilePath As String) As Boolean +End Function + + +Public Function EgtTscExecLine(ByVal sLine As String) As Boolean +End Function + + +'---------- LUA Executor ------------------------------------------------------- + +Public Function EgtLuaEvalNumExpr(ByVal sLine As String, ByRef dVal As Double) As Boolean +End Function + + +Private Function EgtLuaEvalStringExpr(ByVal sLine As String, ByRef psVal As IntPtr) As Boolean +End Function +Public Function EgtLuaEvalStringExpr(ByVal sLine As String, ByRef sVal As String) As Boolean + Dim psVal As IntPtr + Dim bOk As Boolean = EgtLuaEvalStringExpr(sLine, psVal) + If bOk Then + sVal = Marshal.PtrToStringUni(psVal) + EgtFreeMemory(psVal) + Else + sVal = String.Empty + End If + Return bOk +End Function + + +Public Function EgtLuaExecLine(ByVal sLine As String) As Boolean +End Function + + +Public Function EgtLuaExecFile(ByVal sFilePath As String) As Boolean +End Function + + +Public Function EgtLuaRequire(ByVal sFilePath As String) As Boolean +End Function + + +Private Function EgtLuaGetLastError(ByRef psError As IntPtr) As Boolean +End Function +Public Function EgtLuaGetLastError(ByRef sError As String) As Boolean + Dim psError As IntPtr + Dim bOk As Boolean = EgtLuaGetLastError(psError) + If bOk Then + sError = Marshal.PtrToStringUni(psError) + EgtFreeMemory(psError) + Else + sError = String.Empty + End If + Return bOk +End Function + + '---------- GeomDb Objects Create ---------------------------------------------- Private Function EgtCreateGroup(ByVal nParentId As Integer, @@ -963,6 +947,7 @@ Public Function EgtCreateTextAdv(ByVal nParentId As Integer, ByRef ptP As Point3 Optional ByVal nRefType As REF_TY = REF_TY.LOC) As Integer End Function + '---------- GeomDb Objects Modify ---------------------------------------------- Private Function EgtChangeGroupFrame(ByVal nId As Integer, ByRef PtOrig As Point3d, @@ -1059,6 +1044,56 @@ Public Function EgtExplodeCurveBezier(ByVal nId As Integer, ByVal dTolLin As Dou End Function +'---------- GeomDb Parts & Layers ---------------------------------------------- + +Public Function EgtGetCurrPart() As Integer +End Function + + +Public Function EgtGetCurrLayer() As Integer +End Function + + +Public Function EgtSetCurrPartLayer(ByVal nPartId As Integer, ByVal nLayerId As Integer) As Integer +End Function + + +Public Function EgtResetCurrPartLayer() As Integer +End Function + + +Public Function EgtGetFirstVisiblePart() As Integer +End Function + + +Public Function EgtGetNextVisiblePart(ByVal nPartId As Integer) As Integer +End Function + + +Public Function EgtGetFirstVisibleLayer(ByVal nPartId As Integer) As Integer +End Function + + +Public Function EgtGetNextVisibleLayer(ByVal nLayerId As Integer) As Integer +End Function + + +Public Function EgtSelectPartObjs(ByVal nPartId As Integer) As Boolean +End Function + + +Public Function EgtDeselectPartObjs(ByVal nPartId As Integer) As Boolean +End Function + + +Public Function EgtSelectLayerObjs(ByVal nLayerId As Integer) As Boolean +End Function + + +Public Function EgtDeselectLayerObjs(ByVal nLayerId As Integer) As Boolean +End Function + + '---------- GeomDb Objects ----------------------------------------------------- Public Function EgtExistsObj(ByVal nId As Integer) As Boolean @@ -1118,42 +1153,6 @@ End Function Public Function EgtGetPrevGroup(ByVal nId As Integer) As Integer End Function -Public Function EgtGetFirstVisiblePart() As Integer - Dim nPartId As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT) - Return EgtVerifyOrNextVisible(nPartId) -End Function - -Public Function EgtGetNextVisiblePart(ByVal nPartId As Integer) As Integer - Dim nNextId As Integer = EgtGetNextGroup(nPartId) - Return EgtVerifyOrNextVisible(nNextId) -End Function - -Public Function EgtGetFirstVisibleLayer(ByVal nPartId As Integer) As Integer - ' verifico visibilità del pezzo - If Not EgtIsVisibleObj(nPartId) Then - Return GDB_ID.NULL - End If - ' cerco il primo layer visibile - Dim nLayerId As Integer = EgtGetFirstGroupInGroup(nPartId) - Return EgtVerifyOrNextVisible(nLayerId) -End Function - -Public Function EgtGetNextVisibleLayer(ByVal nLayerId As Integer) As Integer - Dim nNextId As Integer = EgtGetNextGroup(nLayerId) - Return EgtVerifyOrNextVisible(nNextId) -End Function - -Private Function EgtVerifyOrNextVisible(ByVal nId As Integer) As Integer - While nId <> GDB_ID.NULL - If EgtIsVisibleObj(nId) Then - Return nId - End If - nId = EgtGetNextGroup(nId) - End While - Return GDB_ID.NULL -End Function - - Public Function EgtGetBBox(ByVal nId As Integer, ByVal nFlag As Integer, ByRef PtMin As Point3d, ByRef PtMax As Point3d) As Boolean @@ -1194,8 +1193,12 @@ End Function Public Function EgtGetTitle(ByVal nId As Integer, ByRef sTitle As String) As Boolean Dim psTitle As IntPtr Dim bOk As Boolean = EgtGetTitle(nId, psTitle) - sTitle = Marshal.PtrToStringUni(psTitle) - EgtFreeMemory(psTitle) + If bOk Then + sTitle = Marshal.PtrToStringUni(psTitle) + EgtFreeMemory(psTitle) + Else + sTitle = String.Empty + End If Return bOk End Function @@ -1205,8 +1208,12 @@ End Function Public Function EgtGroupDump(ByVal nId As Integer, ByRef sDump As String) As Boolean Dim psDump As IntPtr Dim bOk As Boolean = EgtGroupDump(nId, psDump) - sDump = Marshal.PtrToStringUni(psDump) - EgtFreeMemory(psDump) + If bOk Then + sDump = Marshal.PtrToStringUni(psDump) + EgtFreeMemory(psDump) + Else + sDump = String.Empty + End If Return bOk End Function @@ -1216,8 +1223,12 @@ End Function Public Function EgtGeoObjDump(ByVal nId As Integer, ByRef sDump As String) As Boolean Dim psDump As IntPtr Dim bOk As Boolean = EgtGeoObjDump(nId, psDump) - sDump = Marshal.PtrToStringUni(psDump) - EgtFreeMemory(psDump) + If bOk Then + sDump = Marshal.PtrToStringUni(psDump) + EgtFreeMemory(psDump) + Else + sDump = String.Empty + End If Return bOk End Function @@ -1318,8 +1329,12 @@ End Function Public Function EgtGetName(ByVal nId As Integer, ByRef sName As String) As Boolean Dim psName As IntPtr Dim bOk As Boolean = EgtGetName(nId, psName) - sName = Marshal.PtrToStringUni(psName) - EgtFreeMemory(psName) + If bOk Then + sName = Marshal.PtrToStringUni(psName) + EgtFreeMemory(psName) + Else + sName = String.Empty + End If Return bOk End Function @@ -1341,8 +1356,12 @@ End Function Public Function EgtGetInfo(ByVal nId As Integer, ByVal sKey As String, ByRef sInfo As String) As Boolean Dim psInfo As IntPtr Dim bOk As Boolean = EgtGetInfo(nId, sKey, psInfo) - sInfo = Marshal.PtrToStringUni(psInfo) - EgtFreeMemory(psInfo) + If bOk Then + sInfo = Marshal.PtrToStringUni(psInfo) + EgtFreeMemory(psInfo) + Else + sInfo = String.Empty + End If Return bOk End Function @@ -1380,19 +1399,11 @@ Public Function EgtDeselectAll() As Boolean End Function -Public Function EgtSelectPartObjs(ByVal nPartId As Integer) As Boolean +Public Function EgtSelectGroupObjs(ByVal nGroupId As Integer) As Boolean End Function -Public Function EgtDeselectPartObjs(ByVal nPartId As Integer) As Boolean -End Function - - -Public Function EgtSelectLayerObjs(ByVal nLayerId As Integer) As Boolean -End Function - - -Public Function EgtDeselectLayerObjs(ByVal nLayerId As Integer) As Boolean +Public Function EgtDeselectGroupObjs(ByVal nGroupId As Integer) As Boolean End Function @@ -1618,7 +1629,7 @@ End Function '---------- Scene -------------------------------------------------------------- Public Function EgtInitScene(ByVal hWnd As IntPtr, ByVal nDriver As Integer, - ByVal b2Buff As Boolean, ByVal nColorBits As Integer, ByVal nDepthBits As Integer) As Boolean + ByVal b2Buff As Boolean, ByVal nColorBits As Integer, ByVal nDepthBits As Integer) As Boolean End Function @@ -1627,12 +1638,15 @@ End Function Public Function EgtGetSceneInfo(ByRef sInfo As String) As Boolean Dim psInfo As IntPtr Dim bOk As Boolean = EgtGetSceneInfo(psInfo) - sInfo = Marshal.PtrToStringUni(psInfo) - EgtFreeMemory(psInfo) + If bOk Then + sInfo = Marshal.PtrToStringUni(psInfo) + EgtFreeMemory(psInfo) + Else + sInfo = String.Empty + End If Return bOk End Function - Public Function EgtSetBackground(ByRef colTop As Color3d, ByRef colBottom As Color3d, Optional ByVal bRedraw As Boolean = True) As Boolean End Function @@ -1843,59 +1857,134 @@ Public Function EgtUnProjectPoint(ByVal Curr As Point, ByRef ptP As Point3d) As End Function -'---------- Tsc Executor ------------------------------------------------------- +'---------- Geo Base ----------------------------------------------------------- -Public Function EgtInitTscExec() As Boolean +Private Function EgtVectorNormalize(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + Optional ByVal dEps As Double = EPS_SMALL) As Boolean End Function -Public Function EgtTscExecFile(ByVal sFilePath As String) As Boolean +Private Function EgtVectorRotate(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef VtAx As Vector3d, ByVal dAngRotDeg As Double) As Boolean End Function -Public Function EgtTscExecLine(ByVal sLine As String) As Boolean -End Function - - -'---------- LUA Executor ------------------------------------------------------- - -Public Function EgtLuaEvalNumExpr(ByVal sLine As String, ByRef dVal As Double) As Boolean +Private Function EgtVectorScale(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, + ByVal dCoeffX As Double, ByVal dCoeffY As Double, ByVal dCoeffZ As Double) As Boolean End Function -Private Function EgtLuaEvalStringExpr(ByVal sLine As String, ByRef psVal As IntPtr) As Boolean -End Function -Public Function EgtLuaEvalStringExpr(ByVal sLine As String, ByRef sVal As String) As Boolean - Dim psVal As IntPtr - Dim bOk As Boolean = EgtLuaEvalStringExpr(sLine, psVal) - sVal = Marshal.PtrToStringUni(psVal) - EgtFreeMemory(psVal) - Return bOk +Private Function EgtVectorMirror(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef VtNorm As Vector3d) As Boolean End Function -Public Function EgtLuaExecLine(ByVal sLine As String) As Boolean +Private Function EgtVectorShear(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef VtNorm As Vector3d, ByRef VtDir As Vector3d, ByVal dCoeff As Double) As Boolean End Function -Public Function EgtLuaExecFile(ByVal sFilePath As String) As Boolean +Private Function EgtVectorToGlob(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean End Function -Public Function EgtLuaRequire(ByVal sFilePath As String) As Boolean +Private Function EgtVectorToLoc(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean End Function -Private Function EgtLuaGetLastError(ByRef psError As IntPtr) As Boolean -End Function -Public Function EgtLuaGetLastError(ByRef sError As String) As Boolean - Dim psError As IntPtr - Dim bOk As Boolean = EgtLuaGetLastError(psError) - sError = Marshal.PtrToStringUni(psError) - EgtFreeMemory(psError) - Return bOk +Private Function EgtVectorLocToLoc(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef PtO1 As Point3d, ByRef VtX1 As Vector3d, ByRef VtY1 As Vector3d, ByRef VtZ1 As Vector3d, + ByRef PtO2 As Point3d, ByRef VtX2 As Vector3d, ByRef VtY2 As Vector3d, ByRef VtZ2 As Vector3d) As Boolean End Function + +Public Function EgtGetVectorRotation(ByRef VtS As Vector3d, ByRef VtE As Vector3d, ByRef VtAx As Vector3d, + ByRef dAngRotDeg As Double, ByRef bDet As Boolean) As Boolean +End Function + + +Private Function EgtPointTranslate(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef VtMove As Vector3d) As Boolean +End Function + + +Private Function EgtPointRotate(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef PtAx As Point3d, ByRef VtAx As Vector3d, ByVal dAngRotDeg As Double) As Boolean +End Function + + +Private Function EgtPointScale(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, + ByVal dCoeffX As Double, ByVal dCoeffY As Double, ByVal dCoeffZ As Double) As Boolean +End Function + + +Private Function EgtPointMirror(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef PtOn As Point3d, ByRef VtNorm As Vector3d) As Boolean +End Function + + +Private Function EgtPointShear(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef PtOn As Point3d, ByRef VtNorm As Vector3d, ByRef VtDir As Vector3d, ByVal dCoeff As Double) As Boolean +End Function + + +Private Function EgtPointToGlob(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean +End Function + + +Private Function EgtPointToLoc(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean +End Function + + +Private Function EgtPointLocToLoc(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, + ByRef PtO1 As Point3d, ByRef VtX1 As Vector3d, ByRef VtY1 As Vector3d, ByRef VtZ1 As Vector3d, + ByRef PtO2 As Point3d, ByRef VtX2 As Vector3d, ByRef VtY2 As Vector3d, ByRef VtZ2 As Vector3d) As Boolean +End Function + + +Private Function EgtFrameFrom3Points(ByRef PtO As Point3d, ByRef PtOnX As Point3d, ByRef PtOnY As Point3d, + ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean +End Function + + +Private Function EgtFrameOCS(ByRef PtO As Point3d, ByRef VtDirZ As Vector3d, + ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d) As Boolean +End Function + + +Private Function EgtFrameTranslate(ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, + ByRef VtMove As Vector3d) As Boolean +End Function + + +Private Function EgtFrameRotate(ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, + ByRef PtAx As Point3d, ByRef VtAx As Vector3d, ByVal dAngRotDeg As Double) As Boolean +End Function + + +Private Function EgtFrameToGlob(ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, + ByRef PtO1 As Point3d, ByRef VtX1 As Vector3d, ByRef VtY1 As Vector3d, ByRef VtZ1 As Vector3d) As Boolean +End Function + + +Private Function EgtFrameToLoc(ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, + ByRef PtO1 As Point3d, ByRef VtX1 As Vector3d, ByRef VtY1 As Vector3d, ByRef VtZ1 As Vector3d) As Boolean +End Function + + +Private Function EgtFrameLocToLoc(ByRef PtOrig As Point3d, ByRef VtX As Vector3d, ByRef VtY As Vector3d, ByRef VtZ As Vector3d, + ByRef PtO1 As Point3d, ByRef VtX1 As Vector3d, ByRef VtY1 As Vector3d, ByRef VtZ1 As Vector3d, + ByRef PtO2 As Point3d, ByRef VtX2 As Vector3d, ByRef VtY2 As Vector3d, ByRef VtZ2 As Vector3d) As Boolean +End Function + + +'---------- Costanti ----------------------------------------------------------- 'Costanti : GEOMETRIA Public Const EPS_SMALL As Double = 0.001 Public Const EPS_ZERO As Double = 0.0000001 diff --git a/Form1.vb b/Form1.vb index 476eba0..e66a7df 100644 --- a/Form1.vb +++ b/Form1.vb @@ -487,7 +487,7 @@ Public Class Form1 Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click Dim nType As NGE = GetPrivateProfileInt("GeomDB", "SaveType", NGE.CMPTEXT, m_sIniFile) If Not String.IsNullOrWhiteSpace(m_Controller.GetCurrFile()) Then - m_Controller.SaveProject(m_Controller.GetCurrFile(), nType) + m_Controller.SaveProject(nType) Else Dim sFile As String = String.Empty GetPrivateProfileString("General", "LastNgeDir", "", sFile, m_sIniFile) diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 558b77c..f6f68d6 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -43,5 +43,5 @@ Imports System.Runtime.InteropServices ' utilizzando l'asterisco (*) come descritto di seguito: ' - - + + diff --git a/Scene.vb b/Scene.vb index 7fb2f27..cd7efa9 100644 --- a/Scene.vb +++ b/Scene.vb @@ -935,42 +935,56 @@ Public Class Scene End Function Public Function CreateDragGroup(Optional bSelectable As Boolean = False) As Boolean + ' le azioni successive sono temporanee -> non devono cambiare lo stato di modifica del progetto + EgtDisableModified() + ' creo il gruppo di drag m_nDragGroup = EgtCreateGroup(GDB_ID.ROOT) - If m_nDragGroup = GDB_ID.NULL Then - Return False + Dim bOk As Boolean = (m_nDragGroup <> GDB_ID.NULL) + If bOk Then + EgtSetLevel(m_nDragGroup, GDB_LV.TEMP) + EgtSetMark(m_nDragGroup) + m_bDragSelectable = bSelectable + If m_bDragSelectable Then + EgtUnselectableRemove(m_nDragGroup) + Else + EgtUnselectableAdd(m_nDragGroup) + End If End If - EgtSetLevel(m_nDragGroup, GDB_LV.TEMP) - EgtSetMark(m_nDragGroup) - m_bDragSelectable = bSelectable - If m_bDragSelectable Then - EgtUnselectableRemove(m_nDragGroup) - Else - EgtUnselectableAdd(m_nDragGroup) - End If - Return True + ' riabilito possibilità modifica stato progetto + EgtEnableModified() + Return bOk End Function Public Function EraseDragGroup() As Boolean + ' le azioni successive sono temporanee -> non devono cambiare lo stato di modifica del progetto + EgtDisableModified() + ' cancello il gruppo di drag EgtErase(m_nDragGroup) m_bDragSelectable = False EgtUnselectableRemove(m_nDragGroup) m_nDragGroup = GDB_ID.NULL + ' riabilito possibilità modifica stato progetto + EgtEnableModified() Return True End Function Public Function AddToDragGroup(ByVal nId As Integer) As Boolean + ' le azioni successive sono temporanee -> non devono cambiare lo stato di modifica del progetto + EgtDisableModified() ' copio entità Dim nNewId As Integer = EgtCopyGlob(nId, m_nDragGroup, GDB_POS.SON) - If nNewId = GDB_ID.NULL Then - Return False + Dim bOk As Boolean = (nNewId <> GDB_ID.NULL) + If bOk Then + ' assegno il colore (potrebbe essere da layer, quindi va fatto) + Dim ColObj As Color3d + EgtGetCalcColor(nId, ColObj) + EgtSetColor(nNewId, ColObj) + ' assegno Id entità origine + EgtSetInfo(nNewId, "Id", nId.ToString()) End If - ' assegno il colore (potrebbe essere da layer, quindi va fatto) - Dim ColObj As Color3d - EgtGetCalcColor(nId, ColObj) - EgtSetColor(nNewId, ColObj) - ' assegno Id entità origine - EgtSetInfo(nNewId, "Id", nId.ToString()) - Return True + ' riabilito possibilità modifica stato progetto + EgtEnableModified() + Return bOk End Function Public Function GetDragGroup() As Integer