90adb8b200
- Corretto slice senza parametri di lavorazione - Corretta aggiunta di piu' none in lista lavorazioni - Aggiunto modulo per gestione colori delle superfici
444 lines
18 KiB
VB.net
444 lines
18 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class ImportPanelVM
|
|
Inherits VMBase
|
|
|
|
Private m_nImportedPartId As Integer = GDB_ID.NULL
|
|
Friend ReadOnly Property nImportedPartId As Integer
|
|
Get
|
|
Return m_nImportedPartId
|
|
End Get
|
|
End Property
|
|
|
|
Private m_ImportedEntityList As New ObservableCollection(Of GeomEntity)
|
|
Public Property ImportedEntityList As ObservableCollection(Of GeomEntity)
|
|
Get
|
|
Return m_ImportedEntityList
|
|
End Get
|
|
Set(value As ObservableCollection(Of GeomEntity))
|
|
m_ImportedEntityList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelImportedEntity As GeomEntity
|
|
Public Property SelImportedEntity As GeomEntity
|
|
Get
|
|
Return m_SelImportedEntity
|
|
End Get
|
|
Set(value As GeomEntity)
|
|
m_SelImportedEntity = value
|
|
EgtDeselectAll()
|
|
If Not IsNothing(m_SelImportedEntity) Then
|
|
EgtSelectObj(m_SelImportedEntity.nId)
|
|
End If
|
|
EgtDraw()
|
|
End Set
|
|
End Property
|
|
Friend Sub SetSelImportedEntity(nId As Integer)
|
|
m_SelImportedEntity = Map.refImportPanelVM.ImportedEntityList.FirstOrDefault(Function(x) x.nId = nId)
|
|
EgtDeselectAll()
|
|
If Not IsNothing(m_SelImportedEntity) Then
|
|
EgtSelectObj(m_SelImportedEntity.nId)
|
|
End If
|
|
EgtDraw()
|
|
NotifyPropertyChanged(NameOf(SelImportedEntity))
|
|
End Sub
|
|
|
|
Private m_ImportPartList As New ObservableCollection(Of ImportPart)
|
|
Public ReadOnly Property ImportPartList As ObservableCollection(Of ImportPart)
|
|
Get
|
|
Return m_ImportPartList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelImportPart As ImportPart
|
|
Friend Sub SetSelImportPart(SelImportPart As ImportPart)
|
|
m_SelImportPart = SelImportPart
|
|
m_SelImportLayer = Nothing
|
|
End Sub
|
|
Public ReadOnly Property SelImportPart As ImportPart
|
|
Get
|
|
Return m_SelImportPart
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelImportLayer As ImportLayer
|
|
Public ReadOnly Property SelImportLayer As ImportLayer
|
|
Get
|
|
Return m_SelImportLayer
|
|
End Get
|
|
End Property
|
|
Friend Sub SetSelImportLayer(SelImportLayer As ImportLayer)
|
|
m_SelImportPart = m_ImportPartList.FirstOrDefault(Function(x) x.LayerList.Contains(SelImportLayer))
|
|
m_SelImportLayer = SelImportLayer
|
|
End Sub
|
|
|
|
Private m_SelGeomEntity As GeomEntity
|
|
Public ReadOnly Property SelGeomEntity As GeomEntity
|
|
Get
|
|
Return m_SelGeomEntity
|
|
End Get
|
|
End Property
|
|
Friend Sub SetSelGeomEntity(SelGeomEntity As GeomEntity)
|
|
For Each CurrPart In m_ImportPartList
|
|
Dim CurrLayer As ImportLayer = CurrPart.LayerList.FirstOrDefault(Function(x) x.EntityList.Contains(SelGeomEntity))
|
|
If Not IsNothing(CurrLayer) Then
|
|
m_SelImportPart = CurrPart
|
|
m_SelImportLayer = CurrLayer
|
|
Exit For
|
|
End If
|
|
Next
|
|
m_SelGeomEntity = SelGeomEntity
|
|
End Sub
|
|
|
|
' Definizione comandi
|
|
Private m_cmdSetReference As ICommand
|
|
Private m_cmdAddPart As ICommand
|
|
Private m_cmdRemovePart As ICommand
|
|
Private m_cmdOk As ICommand
|
|
Private m_cmdCancel As ICommand
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in EgtCAM5Map
|
|
Map.SetRefImportPanelVM(Me)
|
|
End Sub
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub Init()
|
|
m_ImportedEntityList.Clear()
|
|
m_ImportPartList.Clear()
|
|
' aggiungo geometrie importate a lista
|
|
m_nImportedPartId = EgtGetLastPart()
|
|
Dim nLayerId As Integer = EgtGetFirstLayer(m_nImportedPartId)
|
|
Dim nGeometryId As Integer = EgtGetFirstInGroup(nLayerId)
|
|
While nGeometryId <> GDB_ID.NULL
|
|
Dim sGeometryName As String = ""
|
|
EgtGetName(nGeometryId, sGeometryName)
|
|
m_ImportedEntityList.Add(New GeomEntity(nGeometryId, sGeometryName))
|
|
nGeometryId = EgtGetNext(nGeometryId)
|
|
End While
|
|
' aggiungo primo pezzo
|
|
m_ImportPartList.Add(New ImportPart())
|
|
m_ImportPartList(0).LayerList.FirstOrDefault(Function(x) x.Type = ImportLayer.LayerType.PRINT_SOLID).bIsSelected = True
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "SetReference"
|
|
|
|
Public ReadOnly Property SetReference_Command As ICommand
|
|
Get
|
|
If m_cmdSetReference Is Nothing Then
|
|
m_cmdSetReference = New Command(AddressOf SetReference)
|
|
End If
|
|
Return m_cmdSetReference
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub SetReference()
|
|
If Not IsNothing(SelGeomEntity) Then
|
|
Dim ChooseReferenceWndVM As New ChooseReferenceWndVM
|
|
Dim ChooseReferenceWndV As New ChooseReferenceWndV(Application.Current.MainWindow, ChooseReferenceWndVM)
|
|
If Not ChooseReferenceWndV.ShowDialog() Then Return
|
|
SelGeomEntity.Reference = ChooseReferenceWndVM.SelReference
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' SetReference
|
|
|
|
#Region "AddPart"
|
|
|
|
Public ReadOnly Property AddPart_Command As ICommand
|
|
Get
|
|
If m_cmdAddPart Is Nothing Then
|
|
m_cmdAddPart = New Command(AddressOf AddPart)
|
|
End If
|
|
Return m_cmdAddPart
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub AddPart()
|
|
m_ImportPartList.Add(New ImportPart)
|
|
End Sub
|
|
|
|
#End Region ' AddPart
|
|
|
|
#Region "RemovePart"
|
|
|
|
Public ReadOnly Property RemovePart_Command As ICommand
|
|
Get
|
|
If m_cmdRemovePart Is Nothing Then
|
|
m_cmdRemovePart = New Command(AddressOf RemovePart)
|
|
End If
|
|
Return m_cmdRemovePart
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub RemovePart()
|
|
If IsNothing(SelImportLayer) Then
|
|
' rimuovo pezzo
|
|
m_ImportPartList.Remove(SelImportPart)
|
|
Else
|
|
' rimuovo geometria
|
|
Dim CurrEntity As GeomEntity = m_SelGeomEntity
|
|
SelImportLayer.EntityList.Remove(m_SelGeomEntity)
|
|
' la rimetto in lista importati
|
|
ImportedEntityList.Add(CurrEntity)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' RemovePart
|
|
|
|
#Region "Ok"
|
|
|
|
Public ReadOnly Property Ok_Command As ICommand
|
|
Get
|
|
If m_cmdOk Is Nothing Then
|
|
m_cmdOk = New Command(AddressOf Ok)
|
|
End If
|
|
Return m_cmdOk
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Ok()
|
|
Dim sErr As New List(Of String)
|
|
' verifico che tutti i pezzi abbiano una superficie da stampare nel layer apposito
|
|
For Each CurrPart In m_ImportPartList
|
|
For Each CurrLayer In CurrPart.LayerList
|
|
Select Case CurrLayer.Type
|
|
Case ImportLayer.LayerType.PRINT_SOLID
|
|
If CurrLayer.EntityList.Count = 0 Then
|
|
If sErr.Count > 0 Then sErr(sErr.Count - 1) &= Environment.NewLine
|
|
sErr.Add(CurrPart.ghName & " - No print surface defined!")
|
|
End If
|
|
End Select
|
|
Next
|
|
Next
|
|
If sErr.Count > 0 Then
|
|
MessageBox.Show(String.Concat(sErr), "Error")
|
|
Return
|
|
Else
|
|
' Creo pezzi e layer necessari
|
|
For ImportPartIndex = 0 To m_ImportPartList.Count - 1
|
|
Dim ImportPart As ImportPart = m_ImportPartList(ImportPartIndex)
|
|
Dim frImportedPart As New Frame3d
|
|
EgtGetGroupGlobFrame(m_nImportedPartId, frImportedPart)
|
|
Dim nPartId As Integer = EgtCreateGroup(GDB_ID.ROOT, frImportedPart)
|
|
EgtSetName(nPartId, PART)
|
|
Dim nFrameId As Integer = GDB_ID.NULL
|
|
Dim b3PrintSolid As New BBox3d
|
|
Dim nPrintPartLayerId As Integer = GDB_ID.NULL
|
|
Dim PrintSolidEntity As GeomEntity = Nothing
|
|
Dim nOriginalPartLayerId As Integer = GDB_ID.NULL
|
|
Dim nRibsLayerId As Integer = GDB_ID.NULL
|
|
Dim nShellNumberLayerId As Integer = GDB_ID.NULL
|
|
Dim nAuxSolidsLayerId As Integer = GDB_ID.NULL
|
|
Dim nMachStartLayerId As Integer = GDB_ID.NULL
|
|
Dim nOthersLayerId As Integer = GDB_ID.NULL
|
|
For Each ImportLayer In ImportPart.LayerList
|
|
Select Case ImportLayer.Type
|
|
Case ImportLayer.LayerType.PRINT_SOLID
|
|
nPrintPartLayerId = EgtCreateGroup(nPartId)
|
|
EgtSetName(nPrintPartLayerId, PRINT_SOLID)
|
|
If ImportLayer.EntityList.Count > 0 Then
|
|
PrintSolidEntity = ImportLayer.EntityList(0)
|
|
EgtRelocateGlob(PrintSolidEntity.nId, nPrintPartLayerId, GDB_POS.LAST_SON)
|
|
' calcolo box superficie per creazione riferimento
|
|
EgtGetBBoxGlob(PrintSolidEntity.nId, GDB_BB.STANDARD, b3PrintSolid)
|
|
End If
|
|
'Case ImportLayer.LayerType.ORIGINAL_SOLID
|
|
' nOriginalPartLayerId = EgtCreateGroup(nPartId)
|
|
' EgtSetName(nOriginalPartLayerId, ORIGINAL_SOLID)
|
|
' For Each GeomEntity In ImportLayer.EntityList
|
|
' EgtRelocateGlob(GeomEntity.nId, nOriginalPartLayerId, GDB_POS.LAST_SON)
|
|
' Next
|
|
Case ImportLayer.LayerType.MACH_START
|
|
nMachStartLayerId = EgtCreateGroup(nPartId)
|
|
EgtSetName(nMachStartLayerId, LAY_MACH_START)
|
|
Dim nMachStartId As Integer = GDB_ID.NULL
|
|
If ImportLayer.EntityList.Count > 0 Then
|
|
For Each GeomEntity In ImportLayer.EntityList
|
|
' se punto o curva compo
|
|
Dim EntityType As GDB_TY = EgtGetType(GeomEntity.nId)
|
|
Select Case EntityType
|
|
Case GDB_TY.GEO_POINT, GDB_TY.CRV_COMPO
|
|
' gli cambio layer
|
|
EgtRelocateGlob(GeomEntity.nId, nMachStartLayerId, GDB_POS.LAST_SON)
|
|
nMachStartId = GeomEntity.nId
|
|
Case GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_LINE
|
|
' altrimenti la trasformo in curva compo
|
|
nMachStartId = EgtCreateCurveCompo(nMachStartLayerId, GeomEntity.nId, True)
|
|
End Select
|
|
EgtSetName(nMachStartId, START_GEOM)
|
|
' coloro l'entita' di rosso
|
|
Dim c3Red As Color3d
|
|
c3Red.FromColor(System.Drawing.Color.Red)
|
|
EgtSetColor(nMachStartId, c3Red)
|
|
Next
|
|
Else
|
|
' creo punto di partenza
|
|
Dim ptStart As Point3d = b3PrintSolid.Center() - 0.6 * b3PrintSolid.DimY() * Vector3d.Y_AX() - 0.5 * b3PrintSolid.DimZ() * Vector3d.Z_AX()
|
|
nMachStartId = EgtCreateGeoPoint(nMachStartLayerId, ptStart, GDB_RT.GLOB)
|
|
EgtSetName(nMachStartId, START_GEOM)
|
|
' coloro l'entita' di rosso
|
|
Dim c3Red As Color3d
|
|
c3Red.FromColor(System.Drawing.Color.Red)
|
|
EgtSetColor(nMachStartId, c3Red)
|
|
End If
|
|
Case ImportLayer.LayerType.RIBS
|
|
nRibsLayerId = EgtCreateGroup(nPartId)
|
|
EgtSetName(nRibsLayerId, LAY_RIBS)
|
|
For Each GeomEntity In ImportLayer.EntityList
|
|
EgtSetInfo(GeomEntity.nId, KEY_RIB_TYPE, RibEntity.RibTypes.FROMIMPORT)
|
|
EgtRelocateGlob(GeomEntity.nId, nRibsLayerId, GDB_POS.LAST_SON)
|
|
' coloro l'entita' di viola
|
|
Dim c3LightBlue As Color3d
|
|
c3LightBlue.FromColor(System.Drawing.Color.MediumOrchid)
|
|
EgtSetColor(GeomEntity.nId, c3LightBlue)
|
|
Next
|
|
Case ImportLayer.LayerType.SHELL_NUMBER
|
|
nShellNumberLayerId = EgtCreateGroup(nPartId)
|
|
EgtSetName(nShellNumberLayerId, LAY_SHELL_NBR)
|
|
For Each GeomEntity In ImportLayer.EntityList
|
|
EgtSetInfo(GeomEntity.nId, KEY_SHELLNBR_TYPE, ShellNumberEntity.ShellNumberTypes.FROMIMPORT)
|
|
EgtRelocateGlob(GeomEntity.nId, nShellNumberLayerId, GDB_POS.LAST_SON)
|
|
' coloro l'entita' di verde
|
|
Dim c3LightBlue As Color3d
|
|
c3LightBlue.FromColor(System.Drawing.Color.Lime)
|
|
EgtSetColor(GeomEntity.nId, c3LightBlue)
|
|
Next
|
|
Case ImportLayer.LayerType.AUX_SOLIDS
|
|
nAuxSolidsLayerId = EgtCreateGroup(nPartId)
|
|
EgtSetName(nAuxSolidsLayerId, LAY_AUX_SOLIDS)
|
|
For Each GeomEntity In ImportLayer.EntityList
|
|
EgtSetInfo(GeomEntity.nId, KEY_AUXSOLID_TYPE, RibEntity.RibTypes.FROMIMPORT)
|
|
EgtRelocateGlob(GeomEntity.nId, nAuxSolidsLayerId, GDB_POS.LAST_SON)
|
|
' coloro l'entita' di oro
|
|
Dim c3LightBlue As Color3d
|
|
c3LightBlue.FromColor(System.Drawing.Color.DarkGoldenrod)
|
|
EgtSetColor(GeomEntity.nId, c3LightBlue)
|
|
Next
|
|
Case ImportLayer.LayerType.OTHERS
|
|
nOthersLayerId = EgtCreateGroup(nPartId)
|
|
EgtSetName(nOthersLayerId, LAY_OTHERS)
|
|
For Each GeomEntity In ImportLayer.EntityList
|
|
EgtRelocateGlob(GeomEntity.nId, nOthersLayerId, GDB_POS.LAST_SON)
|
|
Next
|
|
If ImportPartIndex = 0 Then
|
|
For Each GeomEntity In ImportedEntityList
|
|
' se curva
|
|
Dim EntityType As GDB_TY = EgtGetType(GeomEntity.nId)
|
|
Select Case EntityType
|
|
Case GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_LINE
|
|
' la trasformo in curva compo
|
|
EgtCreateCurveCompo(nOthersLayerId, GeomEntity.nId, True)
|
|
Case Else
|
|
' altrimenti la sposto solamente
|
|
EgtRelocateGlob(GeomEntity.nId, nOthersLayerId, GDB_POS.LAST_SON)
|
|
End Select
|
|
Next
|
|
End If
|
|
End Select
|
|
Next
|
|
' aggiungo riferimento
|
|
Dim nReferenceLayerId As Integer = EgtCreateGroup(nPartId)
|
|
EgtSetName(nReferenceLayerId, LAY_REFERENCE)
|
|
' Creo riferimento
|
|
Dim ptOrig As New Point3d(b3PrintSolid.Min())
|
|
Select Case PrintSolidEntity.Reference
|
|
Case ChooseReferenceWndVM.References.TL
|
|
ptOrig += b3PrintSolid.DimY() * Vector3d.Y_AX
|
|
Case ChooseReferenceWndVM.References.TR
|
|
ptOrig += b3PrintSolid.DimY() * Vector3d.Y_AX + b3PrintSolid.DimX() * Vector3d.X_AX
|
|
Case ChooseReferenceWndVM.References.BL
|
|
Case ChooseReferenceWndVM.References.BR
|
|
ptOrig += b3PrintSolid.DimX() * Vector3d.X_AX
|
|
Case ChooseReferenceWndVM.References.TC
|
|
ptOrig += b3PrintSolid.DimY() * Vector3d.Y_AX + b3PrintSolid.DimX() / 2 * Vector3d.X_AX
|
|
Case ChooseReferenceWndVM.References.ML
|
|
ptOrig += b3PrintSolid.DimY() / 2 * Vector3d.Y_AX
|
|
Case ChooseReferenceWndVM.References.MR
|
|
ptOrig += b3PrintSolid.DimY() / 2 * Vector3d.Y_AX + b3PrintSolid.DimX() * Vector3d.X_AX
|
|
Case ChooseReferenceWndVM.References.TC
|
|
ptOrig += b3PrintSolid.DimY() * Vector3d.Y_AX + b3PrintSolid.DimX() / 2 * Vector3d.X_AX
|
|
Case ChooseReferenceWndVM.References.MR
|
|
ptOrig += b3PrintSolid.DimY() / 2 * Vector3d.Y_AX + b3PrintSolid.DimX() * Vector3d.X_AX
|
|
Case ChooseReferenceWndVM.References.BC
|
|
ptOrig += b3PrintSolid.DimX() / 2 * Vector3d.X_AX
|
|
Case ChooseReferenceWndVM.References.MC
|
|
ptOrig += b3PrintSolid.DimY() / 2 * Vector3d.Y_AX + b3PrintSolid.DimX() / 2 * Vector3d.X_AX
|
|
End Select
|
|
Dim frPrintSolid As New Frame3d(ptOrig)
|
|
nFrameId = EgtCreateGeoFrame(nReferenceLayerId, frPrintSolid, GDB_RT.GLOB)
|
|
If nFrameId Then
|
|
EgtSetName(nFrameId, FRAME_PART)
|
|
EgtSetMode(nFrameId, GDB_MD.LOCKED)
|
|
End If
|
|
EgtSetInfo(nReferenceLayerId, KEY_REFERENCE, PrintSolidEntity.Reference)
|
|
' appoggio il pezzo sulla tavola
|
|
EgtMove(nPartId, New Vector3d(0, 0, -b3PrintSolid.Min.z))
|
|
' lo aggiungo a lista pezzi
|
|
Dim sFilePath As String = ""
|
|
EgtGetInfo(m_nImportedPartId, FILE_PATH, sFilePath)
|
|
EgtSetInfo(nPartId, FILE_PATH, sFilePath)
|
|
EgtSetInfo(nPartId, "PartOnTable", 1)
|
|
Dim NewPart As New Print3dPartVM(nPartId, nPrintPartLayerId, PrintSolidEntity.nId, nOriginalPartLayerId, nReferenceLayerId, nFrameId, nMachStartLayerId, nRibsLayerId, nShellNumberLayerId, nAuxSolidsLayerId, nOthersLayerId, sFilePath)
|
|
Map.refTopPanelVM.PartList.Add(NewPart)
|
|
Next
|
|
End If
|
|
'EgtAddMachGroup("3dPrint")
|
|
'EgtSetTable("Tab")
|
|
|
|
'Dim nRawId As Integer = EgtAddRawPart(b3PrintSolid.Min, b3PrintSolid.DimX, b3PrintSolid.DimY, b3PrintSolid.DimZ, New Color3d(128, 128, 128, 30))
|
|
'EgtAddPartToRawPart(nPartId, b3PrintSolid.Min, nRawId)
|
|
'EgtMoveToCornerRawPart(nRawId, New Point3d(dPosX, dPosY, 0), MCH_CR.BL)
|
|
|
|
'EgtResetCurrMachGroup()
|
|
|
|
' seleziono ultimo pezzo aggiunto
|
|
Map.refTopPanelVM.SelLastPart()
|
|
' elimino vecchio pezzo d'importazione
|
|
EgtErase(m_nImportedPartId)
|
|
|
|
EgtDraw()
|
|
' ripristino modalita' standard
|
|
Map.refTopPanelVM.SelPage = Pages.MODIFY
|
|
End Sub
|
|
|
|
#End Region ' Ok
|
|
|
|
#Region "Cancel"
|
|
|
|
Public ReadOnly Property Cancel_Command As ICommand
|
|
Get
|
|
If m_cmdCancel Is Nothing Then
|
|
m_cmdCancel = New Command(AddressOf Cancel)
|
|
End If
|
|
Return m_cmdCancel
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Cancel()
|
|
' elimino pezzo importato
|
|
EgtErase(m_nImportedPartId)
|
|
EgtDraw()
|
|
' se ci sono pezzi
|
|
If Map.refTopPanelVM.PartList.Count > 0 Then
|
|
' ripristino modalita' standard
|
|
Map.refTopPanelVM.SelPage = Pages.MODIFY
|
|
Else
|
|
Map.refTopPanelVM.SelPage = Pages.NULL
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Cancel
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|