diff --git a/Controller.vb b/Controller.vb index f5372e6..87bf0c7 100644 --- a/Controller.vb +++ b/Controller.vb @@ -277,6 +277,7 @@ Public Class Controller .Filter = "New geometry EgalTech(*.nge)|*.nge" & "|Drawing Exchange Fmt(*.dxf)|*.dxf" & "|Stereolithography (*.stl)|*.stl" & + "|Images (*.png;*.jpg;*.jpeg;*.bmp)|*.png;*.jpg;*.jpeg;*.bmp" & "|New font EgalTech(*.nfe)|*.nfe" & "|All Files (*.*)|*.*", .FilterIndex = 1, @@ -296,12 +297,12 @@ Public Class Controller bOk = EgtImportDxf(sFile, 1) ElseIf nFileType = FT.STL Then bOk = EgtImportStl(sFile, 1) + ElseIf nFileType = FT.IMG Then + bOk = ImportPicture(sFile, 1) Else bOk = EgtInsertFile(sFile) End If - If GetCurrLayer() = GDB_ID.NULL Then - EgtResetCurrPartLayer() - End If + If GetCurrLayer() = GDB_ID.NULL Then EgtResetCurrPartLayer() DisableCommandLog() ' Aggiornamento RaiseEvent UpdateUI(Me, True) @@ -434,9 +435,10 @@ Public Class Controller "|Stereolithography (*.stl)|*.stl" & "|Building parts (*.btl)|*.btl" & "|Part program ISO (*.cnc;*.xpi;*.mpf)|*.cnc;*.xpi;*.mpf" & + "|Images (*.png;*.jpg;*.jpeg;*.bmp)|*.png;*.jpg;*.jpeg;*.bmp" & "|Cms file format (*.hed;*.ent;*.ens)|*.hed;*.ent;*.ens" & "|All Files (*.*)|*.*", - .FilterIndex = 6, + .FilterIndex = 7, .InitialDirectory = sDir } If OpenFileDialog.ShowDialog <> Windows.Forms.DialogResult.OK Then @@ -447,7 +449,7 @@ Public Class Controller 'Riconoscimento tipo file Dim nFileType As Integer = EgtGetFileType(sFile) Dim bOkType = (nFileType = FT.DXF Or nFileType = FT.STL Or nFileType = FT.CNC Or - nFileType = FT.CSF Or nFileType = FT.BTL) + nFileType = FT.CSF Or nFileType = FT.BTL Or nFileType = FT.IMG) If Not bOkType Then nFileType = FT.NULL 'Prima del caricamento Dim nFlag As Integer = 0 @@ -468,6 +470,8 @@ Public Class Controller bOk = bOk And EgtImportCsf(sFile) ElseIf nFileType = FT.BTL Then bOk = bOk And EgtImportBtl(sFile, nFlag) + ElseIf nFileType = FT.IMG Then + bOk = bOk And ImportPicture(sFile, 1) End If EgtResetCurrPartLayer() DisableCommandLog() @@ -479,6 +483,18 @@ Public Class Controller Return bOk End Function + 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 ByVal sFile As String = "") As Boolean 'Assegnazione nome file con dialogo Dim SaveFileDialog As New SaveFileDialog With { diff --git a/EgtInterface.vb b/EgtInterface.vb index 09706a6..d935650 100644 --- a/EgtInterface.vb +++ b/EgtInterface.vb @@ -9339,18 +9339,18 @@ End Function End Function - Private Function EgtApplyAllMachinings_32(bStopOnFirstErr As Boolean, ByRef psErrList As IntPtr) As Boolean + Private Function EgtApplyAllMachinings_32(bRecalc As Boolean, bStopOnFirstErr As Boolean, ByRef psErrList As IntPtr) As Boolean End Function - Private Function EgtApplyAllMachinings_64(bStopOnFirstErr As Boolean, ByRef psErrList As IntPtr) As Boolean + Private Function EgtApplyAllMachinings_64(bRecalc As Boolean, bStopOnFirstErr As Boolean, ByRef psErrList As IntPtr) As Boolean End Function - Public Function EgtApplyAllMachinings(bStopOnFirstErr As Boolean, ByRef sErrList As String) As Boolean + Public Function EgtApplyAllMachinings(bRecalc As Boolean, bStopOnFirstErr As Boolean, ByRef sErrList As String) As Boolean Dim psErrList As IntPtr Dim bOk As Boolean If IntPtr.Size = 4 Then - bOk = EgtApplyAllMachinings_32(bStopOnFirstErr, psErrList) + bOk = EgtApplyAllMachinings_32(bRecalc, bStopOnFirstErr, psErrList) Else - bOk = EgtApplyAllMachinings_64(bStopOnFirstErr, psErrList) + bOk = EgtApplyAllMachinings_64(bRecalc, bStopOnFirstErr, psErrList) End If If Not IsNothing(psErrList) Then sErrList = Marshal.PtrToStringUni(psErrList) @@ -10712,6 +10712,23 @@ Public Function EgtGetImage(nShowMode As SM, ByRef colTop As Color3d, ByRef colB End Function +'---------- Image -------------------------------------------------------------- + + +Private Function EgtGetImagePixels_32(sFile As String, ByRef nPixelX As Integer, ByRef nPixelY As Integer) As Boolean +End Function + +Private Function EgtGetImagePixels_64(sFile As String, ByRef nPixelX As Integer, ByRef nPixelY As Integer) As Boolean +End Function +Public Function EgtGetImagePixels(sFile As String, ByRef nPixelX As Integer, ByRef nPixelY As Integer) As Boolean + If IntPtr.Size = 4 Then + Return EgtGetImagePixels_32(sFile, nPixelX, nPixelY) + Else + Return EgtGetImagePixels_64(sFile, nPixelX, nPixelY) + End If +End Function + + '---------- Photo -------------------------------------------------------------- Private Function EgtAddPhoto_32(sName As String, sFile As String, @@ -10889,6 +10906,25 @@ Public Function EgtGetPhotoImagePixels(nId As Integer, ByRef nPixelX As Integer, End Function +'---------- Picture ------------------------------------------------------------ + +Private Function EgtAddPicture_32(nParentId As Integer, sName As String, sFile As String, + dDimX As Double, dDimY As Double, nRefType As GDB_RT) As Integer +End Function + +Private Function EgtAddPicture_64(nParentId As Integer, sName As String, sFile As String, + dDimX As Double, dDimY As Double, nRefType As GDB_RT) As Integer +End Function +Public Function EgtAddPicture(nParentId As Integer, sName As String, sFile As String, + dDimX As Double, dDimY As Double, Optional nRefType As GDB_RT = GDB_RT.LOC) As Integer + If IntPtr.Size = 4 Then + Return EgtAddPicture_32(nParentId, sName, sFile, dDimX, dDimY, nRefType) + Else + Return EgtAddPicture_64(nParentId, sName, sFile, dDimX, dDimY, nRefType) + End If +End Function + + '---------- Geo Base ----------------------------------------------------------- Private Function EgtVectorNormalize_32(ByRef X As Double, ByRef Y As Double, ByRef Z As Double, diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 8031ffa..c8a3e77 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -46,5 +46,5 @@ Imports System.Runtime.InteropServices ' utilizzando l'asterisco (*) come descritto di seguito: ' - - + +