Files
icarus/Icarus/SceneHost/MySceneHostVM.vb
T
Dario Sassi 21ff4be8ec Icarus :
- aggiunta impostazione tolleranza di importazione da INI ( [Import] AdvToler=XXX) con default 0.1.
2026-05-12 10:18:39 +02:00

1822 lines
85 KiB
VB.net

Imports System.IO
Imports System.Windows.Forms.VisualStyles.VisualStyleElement
Imports EgtUILib
Imports EgtWPFLib5
Imports Microsoft.Win32
Public Class MySceneHostVM
Inherits EgtWPFLib5.SceneHostVM
Friend m_bIsFocused As Boolean
Friend Sub SetIsFocused(bValue As Boolean)
m_bIsFocused = bValue
End Sub
' Flag per distinguere tra Save a SaveAs
Private m_bIsSaveAs As Boolean = False
' Identificativi per pezzo da selezionare/deselezionare
Private m_nIdToSel As Integer = GDB_ID.NULL
Private m_nIdToDesel As Integer = GDB_ID.NULL
' Dati movimento
Private m_dMaxStep As Double = 0
' Dati per Drag
Private m_nRestRadius As Integer = 5
Private m_bDrag As Boolean = False
Private m_bDragToStart As Boolean = False
Private m_bVerify As Boolean = False
Private m_bFromParking As Boolean = False
Private m_bDragging As Boolean = False
Private m_locPrev As System.Drawing.Point
Private m_ptPrev As Point3d
Private m_vtTotMove As Vector3d
Private m_dSnapDist As Double = 0
Private bReducedCut As Boolean = False
Private m_bMagnetic As Boolean
' punto di snap per inizializzazione
Private m_SnapType As SP
Friend ReadOnly Property SnapType As SP
Get
Return m_SnapType
End Get
End Property
#Region "CONSTRUCTOR"
Sub New()
MyBase.New()
AddHandler MainController.OnNewProject, AddressOf OnNewProject
AddHandler MainController.OnOpenProject, AddressOf OnOpenProject
AddHandler MainController.OnSavingProject, AddressOf OnSavingProject
AddHandler MainController.OnSavedProject, AddressOf OnSavedProject
AddHandler MainController.OnInsertingProject, AddressOf OnInsertingProject
AddHandler MainController.OnInsertedProject, AddressOf OnInsertedProject
AddHandler MainController.PrepareInputBox, AddressOf PrepareInputBox
AddHandler MainController.SetInputBoxText, AddressOf SetInputBoxText
AddHandler MainController.SetInputBoxCheck, AddressOf SetInputBoxCheck
AddHandler MainController.AddInputBoxCombo, AddressOf AddInputBoxCombo
AddHandler MainController.UpdateUI, AddressOf UpdateUI
AddHandler MainController.OnExecCmdEnd, AddressOf OnExecCmdEnd
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Overrides Sub InitScene()
InitSceneEvents()
' Inizializzazione Scena
PreInitializeScene()
' Se tutto bene
If MainScene.Init() And Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.BASE) Then
PostInitializeScene()
' Non imposto automaticamente il focus sulla scena muovendo il mouse sopra di essa (necessario click)
MainScene.SetFocusOnMove( True, 0.3, 0.3, 0.1, 0.2)
' Imposto stato gestione mouse diretto della scena a nessuno
MainScene.SetStatusNull()
EgtSetCurrentContext(MainScene.GetCtx())
' inizializzo gestore lavorazioni
EgtInitMachMgr(Map.refMainWindowVM.MainWindowM.sMachinesRoot, Map.refMainWindowVM.MainWindowM.sToolMakersDir)
Return
End If
' Problemi
' Se manca la chiave
If Map.refMainWindowVM.MainWindowM.nKeyLevel = -1 Or Map.refMainWindowVM.MainWindowM.nKeyLevel = -2 Then
If Not EgtGetNetHwKey() Then
EgtOutLog("Missing Dongle")
' Box di avviso chiave mancante : "Chiave non presente. \n Inserirla e riavviare il programma." "Errore"
Dim sText As String = EgtMsg(10102) & vbCrLf & EgtMsg(10103)
Dim sTitle As String = EgtMsg(10101)
MessageBox.Show(sText, sTitle, MessageBoxButton.OK, MessageBoxImage.Error)
Else
EgtOutLog("NetDongle is full")
' Box di avviso slot chiave di rete occupato : "Chiave di Rete completamente occupata. \n Uscire dal programma su un altro PC." "Errore"
Dim sText As String = EgtMsg(10110) & vbCrLf & EgtMsg(10111)
Dim sTitle As String = EgtMsg(10101)
MessageBox.Show(sText, sTitle, MessageBoxButton.OK, MessageBoxImage.Error)
End If
' Se altrimenti manca il collegamento con la chiave di rete
ElseIf Map.refMainWindowVM.MainWindowM.nKeyLevel = -9 Then
EgtOutLog("Missing Link with Net Dongle")
' Box di avviso chiave mancante : "Collegamento con la Chiave di rete non riuscito. \n Verificare la connessione." "Errore"
Dim sText As String = EgtMsg(10108) & vbCrLf & EgtMsg(10109)
Dim sTitle As String = EgtMsg(10101)
MessageBox.Show(sText, sTitle, MessageBoxButton.OK, MessageBoxImage.Error)
' Altrimenti manca la licenza
Else
EgtOutLog("Problems with Licence")
' Box di avviso licenza con problemi : sKeyInfo \n "Programma senza licenza. \n Caricala e riavvia il programma." "Errore"
Dim sKeyInfo As String = "" : EgtGetKeyInfo(sKeyInfo)
Dim sText As String = sKeyInfo & vbCrLf & EgtMsg(10105) & vbCrLf & EgtMsg(10106)
Dim sTitle As String = EgtMsg(10101)
If MessageBox.Show(sText, sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.OK Then
' Apro dialogo per richiesta file licenza
Dim LicDlg As New Microsoft.Win32.OpenFileDialog() With {
.DefaultExt = ".lic",
.Filter = "Licences (.lic)|*.lic",
.CheckFileExists = True,
.ValidateNames = True
}
If LicDlg.ShowDialog() = True Then
' Recupero il direttorio del file
Dim sDir As String = Path.GetDirectoryName(LicDlg.FileName)
' Se il file non è già nel direttorio di configurazione lo copio
If Not String.Equals(Path.GetFullPath(sDir), Path.GetFullPath(Map.refMainWindowVM.MainWindowM.sConfigDir), StringComparison.OrdinalIgnoreCase) Then
Try
File.Copy(LicDlg.FileName, Path.Combine(Map.refMainWindowVM.MainWindowM.sConfigDir, LicDlg.SafeFileName), True)
Catch ex As Exception
End Try
End If
' Imposto il nuovo file di licenza nell'Ini
WriteMainPrivateProfileString(S_GENERAL, K_LICENCE, LicDlg.SafeFileName)
End If
End If
End If
' Chiudo il programma
End
End Sub
Public Overrides Sub InitSceneEvents()
AddHandler MainScene.OnCursorPos, AddressOf OnCursorPos
AddHandler MainScene.OnMouseSetObjFilterForSelect, AddressOf OnMouseSetObjFilterForSelect
AddHandler MainScene.OnMouseSelectedAll, AddressOf OnMouseSelectedAll
AddHandler MainScene.OnMouseDeselectedAll, AddressOf OnMouseDeselectedAll
AddHandler MainScene.OnMouseDownScene, AddressOf OnMouseDownScene
AddHandler MainScene.OnMouseMoveScene, AddressOf OnMouseMoveScene
AddHandler MainScene.OnMouseUpScene, AddressOf OnMouseUpScene
AddHandler MainScene.OnMouseSelectingObj, AddressOf OnMouseSelectingObj
AddHandler MainScene.OnMouseSelectedObj, AddressOf OnMouseSelectedObj
AddHandler MainScene.OnMouseSelectedPart, AddressOf OnMouseSelectedPart
AddHandler MainScene.OnMouseSelectedLayer, AddressOf OnMouseSelectedLayer
AddHandler MainScene.OnMouseSelectedPath, AddressOf OnMouseSelectedPath
AddHandler MainScene.OnMousePointFromSelection, AddressOf OnMousePointFromSelection
AddHandler MainScene.OnMouseDone, AddressOf OnMouseDone
AddHandler MainScene.OnMouseSelectedPoint, AddressOf OnMouseSelectedPoint
AddHandler MainScene.OnMouseSelectedDir, AddressOf OnMouseSelectedDir
AddHandler MainScene.OnMouseMoveSelPoint, AddressOf OnMouseMoveSelPoint
AddHandler MainScene.OnShowDistance, AddressOf OnShowDistance
AddHandler MainScene.KeyDown, AddressOf OnKeyDown
AddHandler MainScene.OnCloseGetDist, AddressOf OnCloseGetDist
AddHandler MainScene.OnChangedSnapPointType, AddressOf OnChangedSnapPointType
End Sub
Private Sub PreInitializeScene()
' imposto colore di default
Dim DefColor As New Color3d(0, 0, 0)
GetMainPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor)
MainScene.SetDefaultMaterial(DefColor)
' imposto colori sfondo
Dim BackTopColor As New Color3d(192, 192, 192)
GetMainPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor)
Dim BackBotColor As New Color3d(BackTopColor)
GetMainPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor)
MainScene.SetViewBackground(BackTopColor, BackBotColor)
' imposto spessore linee
Dim nLineWidth As Integer = 1
nLineWidth = GetMainPrivateProfileInt(S_SCENE, K_LINEWIDTH, nLineWidth)
MainScene.SetLineWidth(nLineWidth)
' imposto colore di evidenziazione
Dim MarkColor As New Color3d(255, 255, 0)
GetMainPrivateProfileColor(S_SCENE, K_MARK, MarkColor)
MainScene.SetMarkMaterial(MarkColor)
' imposto colore per superfici selezionate
Dim SelSurfColor As New Color3d(255, 255, 192)
GetMainPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor)
MainScene.SetSelSurfMaterial(SelSurfColor)
' imposto tipo e colore del rettangolo di zoom
Dim bOutline As Boolean = True
Dim ZwColor As New Color3d(0, 0, 0)
GetMainPrivateProfileZoomWin(S_SCENE, K_ZOOMWIN, bOutline, ZwColor)
MainScene.SetZoomWinAttribs(bOutline, ZwColor)
' imposto colore della linea di distanza
Dim DstLnColor As New Color3d(255, 0, 0)
GetMainPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor)
MainScene.SetDistLineMaterial(DstLnColor)
' imposto parametri OpenGL
Dim nDriver As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DRIVER, 3)
Dim b2Buff As Boolean = (GetMainPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1) <> 0)
Dim nColorBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_COLORBITS, 32)
Dim nDepthBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32)
MainScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits)
End Sub
Private Sub PostInitializeScene()
' Impostazioni Controller
MainController.SetScene(MainScene)
MainController.SetSurfTmTolerance(OptionModule.m_dGeometryTolerance)
MainController.SetAdvImpTolerance(OptionModule.m_dGeometryTolerance)
MainController.SetUseCustomColors(True, S_SCENE, K_CUSTOMCOLORS)
' imposto unità di misura per interfaccia utente
Dim bMmUnits As Boolean = GetMainPrivateProfileInt(S_SCENE, K_MMUNITS, 1) <> 0
EgtSetUiUnits(bMmUnits)
' imposto visualizzazione riferimento globale
EgtSetGlobFrameShow(True)
' imposto i dati della griglia
Dim MinLnColor As Color3d = New Color3d(160, 160, 160)
GetMainPrivateProfileColor(S_GRID, K_MINLNCOLOR, MinLnColor)
Dim MajLnColor As Color3d = New Color3d(160, 160, 160)
GetMainPrivateProfileColor(S_GRID, K_MAJLNCOLOR, MajLnColor)
EgtSetGridFrame(Frame3d.GLOB)
EgtSetGridGeo( If( bMmUnits, OptionModule.m_dSnapStepMm, OptionModule.m_dSnapStepInch),
OptionModule.m_nMinLineSStep, OptionModule.m_nMajLineSStep, OptionModule.m_nExtSStep)
EgtSetGridColor(MinLnColor, MajLnColor)
EgtSetGridShow(OptionModule.m_bGridVisibility, OptionModule.m_bGridVisibility)
' imposto tipo coordinate
MainScene.SetGridCursorPos(True)
' visualizzazione avanzata dei triangoli costituenti le superfici
Dim bShowTriaAdv As Boolean = (GetMainPrivateProfileInt(S_SCENE, K_SHOWTRIAADV, 1) <> 0)
EgtSetShowTriaAdv(bShowTriaAdv)
' visualizzazione direzione curve
Dim bShowCurveDirection As Boolean = (GetMainPrivateProfileInt(S_SCENE, K_CURVEDIR, 0) <> 0)
EgtSetShowCurveDirection(bShowCurveDirection)
' tipo visualizzazione per Zmap
Dim nShowZmap As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWZMAP, 1)
EgtSetShowZmap(DirectCast(nShowZmap, ZSM), False)
' dimensione lineare max in pixel delle textures
Dim nTxrMaxLinPix As Integer = GetMainPrivateProfileInt(S_SCENE, K_TEXMAXLINPIX, 4096)
EgtSetTextureMaxLinPixels(nTxrMaxLinPix)
' tipo snap point
MainScene.SetSnapPointType(SP.PT_GRID)
' nascondo input box
'Map.refFreeContourInputVM.ResetInputBox()
End Sub
Friend Sub EmitTitle()
' emissione del titolo
Map.refSecondaryWindowVM.SetTitle()
End Sub
#End Region ' METHODS
#Region "ProjectManager"
Public Overrides Function NewProject() As Boolean
EgtSetCurrentContext(MainScene.GetCtx())
Dim bOk As Boolean = MainController.NewProject()
MainScene.SetStatusNull()
Return bOk
End Function
Public Overrides Function OpenProject(sFilePath As String) As Boolean
EgtSetCurrentContext(MainScene.GetCtx())
Dim bOk As Boolean = False
If String.IsNullOrEmpty(sFilePath) Then
' Recupero cartella dell'ultimo progetto aperto
Dim sDir As String = MainController.GetCurrFile()
If String.IsNullOrWhiteSpace(sDir) Then
GetMainPrivateProfileString(S_MRUFILES, K_FILE & 1, "", sDir)
End If
If Not String.IsNullOrWhiteSpace(sDir) Then
sDir = Path.GetDirectoryName(sDir)
End If
Dim OpenFileDialog As New Windows.Forms.OpenFileDialog With {
.Title = "Open",
.Filter = "Icarus project(*.icrs)|*.icrs" &
"|New geometry EgalTech(*.nge)|*.nge",
.FilterIndex = 1,
.InitialDirectory = sDir
}
If Not OpenFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then Return False
sFilePath = OpenFileDialog.FileName
End If
bOk = MainController.OpenProject(sFilePath, False)
' Imposto stato gestione mouse diretto della scena a nessuno
MainScene.SetStatusNull()
Return bOk
End Function
Public Overrides Function SaveProject() As Boolean
' Se nome progetto non definito o con estensione non valida lo chiedo
Dim sCurrFile As String = ""
EgtGetCurrFilePath(sCurrFile)
Dim bOk As Boolean = False
If String.IsNullOrWhiteSpace(sCurrFile) Or EgtGetFileType(sCurrFile) <> FT.NGE Then
bOk = SaveAsProject()
Else
Dim bDeleteNgeFile As Boolean = ( Path.GetExtension(sCurrFile) = ".nge")
EgtSetCurrFilePath(Path.ChangeExtension(sCurrFile, "icrs"))
' Formato di salvataggio
Dim nSaveType As NGE = DirectCast( GetMainPrivateProfileInt(S_GEOMDB, K_SAVETYPE, NGE.CMPTEXT), NGE)
' Salvataggio standard
bOk = MainController.SaveProject(nSaveType)
If bOk AndAlso bDeleteNgeFile AndAlso File.Exists(sCurrFile) Then
Try
File.Delete(sCurrFile)
Catch ex As Exception
EgtOutLog("Delete nge file failed!")
End Try
End If
End If
' Imposto stato gestione mouse diretto della scena a nessuno
MainScene.SetStatusNull()
Return bOk
End Function
Public Overrides Function SaveAsProject() As Boolean
m_bIsSaveAs = True
Dim sFile As String = ""
EgtGetCurrFilePath(sFile)
Dim bOk As Boolean = False
' Se nome vuoto, assegno "New"
If String.IsNullOrWhiteSpace(sFile) Then sFile = "New.icrs"
' Eventuale sistemazione estensione
sFile = IO.Path.ChangeExtension(sFile, "icrs")
' Assegnazione nome file con dialogo
Dim SaveFileDialog As New Windows.Forms.SaveFileDialog With {
.Title = "Save",
.Filter = "Icarus Project(*.icrs)|*.icrs",
.FileName = sFile,
.InitialDirectory = IO.Path.GetDirectoryName(sFile)
}
If SaveFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim sFileName As String = SaveFileDialog.FileName
EgtSetCurrFilePath(sFileName)
' Formato di salvataggio
Dim nSaveType As NGE = DirectCast( GetMainPrivateProfileInt(S_GEOMDB, K_SAVETYPE, NGE.CMPTEXT), NGE)
' Salvataggio standard
bOk = MainController.SaveProject(nSaveType)
End If
m_bIsSaveAs = False
' Imposto stato gestione mouse diretto della scena a nessuno
MainScene.SetStatusNull()
Return bOk
End Function
Public Overrides Function InsertProject() As Boolean
' Recupero cartella dell'ultimo progetto aperto
Dim sDir As String = MainController.GetCurrFile()
If String.IsNullOrWhiteSpace(sDir) Then
GetMainPrivateProfileString(S_MRUIMPORTFILES, K_FILE & 1, "", sDir)
End If
If Not String.IsNullOrWhiteSpace(sDir) Then
sDir = Path.GetDirectoryName(sDir)
End If
If Not Directory.Exists(sDir) Then sDir = ""
Dim ExtIndex As Integer = GetMainPrivateProfileInt(S_PRINTING3D, K_IMPORTCURREXTENSION, 1)
Dim OpenFileDialog As New OpenFileDialog With {.Title = "Insert",
.Filter = "Stereolithography (*.stl)|*.stl" &
"|Iges files (*.igs;*.iges)|*.igs;*.iges" &
"|Step files (*.stp;*.step)|*.stp;*.step" &
"|3D Manufacturing format (*.3mf)|*.3mf" &
"|Rhino format (*.3dm)|*.3dm" &
"|New geometry EgalTech(*.nge)|*.nge" &
"|Imported Files (*.*)|*.stl;*.igs;*.iges;*.stp;*.step;*.3mf;*.nge" &
"|All Files (*.*)|*.*",
.FilterIndex = ExtIndex,
.InitialDirectory = sDir}
If Not OpenFileDialog.ShowDialog Then
Return False
End If
WriteMainPrivateProfileString(S_PRINTING3D, K_IMPORTCURREXTENSION, OpenFileDialog.FilterIndex)
Dim sFile As String = OpenFileDialog.FileName
' disabilito ProjManager, TopPanel, TFS, Slider, bottoni e uscita dal programma
Map.refProjManagerVM.SetProjCmdIsEnabled(False)
Map.refTopPanelVM.SetTopPanelIsEnabled(False)
Map.refViewLayerManagerVM.SetViewLayerManagerIsEnabled(False)
Map.refSliceManagerVM.SetButtonsIsEnabled(False)
Map.refSliderManagerVM.SetLayerIndexIsEnabled(False)
Map.refSliderManagerVM.SetLayerAdvancementIsEnabled(False)
Map.refInstrumentPanelVM.SetEdgeAnalysisIsEnabled(False)
Map.refSliderManagerVM.SetSliderVisibility(False)
' mostro finestra di caricamento
Dim ImportLoadingWnd As ImportLoadingWndV = New ImportLoadingWndV(Application.Current.MainWindow, New ImportLoadingWndVM)
ImportLoadingWnd.Show()
' importo la nuova geometria
Dim bOk As Boolean = MainController.InsertProject(sFile, False)
If bOk Then
Map.refViewLayerManagerVM.SetViewLayerManagerIsEnabled(True)
' la sposto in centro tavola
Dim nNewPartId As Integer = EgtGetLastPart()
Dim b3NewPart As New BBox3d
EgtGetBBoxGlob(nNewPartId, GDB_BB.STANDARD, b3NewPart)
EgtMove(nNewPartId, New Point3d((CurrentMachine.b3Tab.DimX / 2) - (b3NewPart.DimX / 2), (CurrentMachine.b3Tab.DimY / 2) - (b3NewPart.DimY / 2), 0) - b3NewPart.Min(), GDB_RT.GLOB)
' imposto modalita' import
Map.refTopPanelVM.SelPage = Pages.IMPORT
Else
Map.refProjManagerVM.SetProjCmdIsEnabled(True)
Map.refTopPanelVM.SetTopPanelIsEnabled(True)
Map.refSliceManagerVM.SetButtonsIsEnabled(True)
Map.refSliderManagerVM.SetLayerIndexIsEnabled(True)
Map.refSliderManagerVM.SetLayerAdvancementIsEnabled(True)
Map.refInstrumentPanelVM.SetEdgeAnalysisIsEnabled(True)
Map.refSliderManagerVM.SetSliderVisibility(True)
End If
' chiudo finestra di caricamento
ImportLoadingWnd.Close()
EgtDraw()
Return bOk
End Function
Public Function InsertRib() As Boolean
' Recupero cartella dell'ultimo progetto aperto
Dim sDir As String = MainController.GetCurrFile()
If String.IsNullOrWhiteSpace(sDir) Then
GetMainPrivateProfileString(S_MRUIMPORTFILES, K_FILE & 1, "", sDir)
End If
If Not String.IsNullOrWhiteSpace(sDir) Then
sDir = Path.GetDirectoryName(sDir)
End If
If Not Directory.Exists(sDir) Then sDir = ""
Dim OpenFileDialog As New OpenFileDialog With {.Title = "Insert",
.Filter = "Stereolithography (*.stl)|*.stl" &
"|Iges files (*.igs;*.iges)|*.igs;*.iges" &
"|Step files (*.stp;*.step)|*.stp;*.step" &
"|3D Manufacturing format (*.3mf)|*.3mf" &
"|Rhino format (*.3dm)|*.3dm" &
"|New geometry EgalTech(*.nge)|*.nge" &
"|Imported Files (*.*)|*.stl;*.igs;*.iges;*.stp;*.step;*.3mf;*.nge" &
"|All Files (*.*)|*.*",
.FilterIndex = 7,
.InitialDirectory = sDir}
If Not OpenFileDialog.ShowDialog Then
Return False
End If
Dim sFile As String = String.Empty
sFile = OpenFileDialog.FileName
' importo la nuova geometria
Dim bOk As Boolean = MainController.InsertProject(sFile, False)
If bOk Then
' sposto le nuove geometrie nel layer rib del pezzo
Dim nNewPartId As Integer = EgtGetLastPart()
Dim nNewLayerId As Integer = EgtGetFirstGroupInGroup(nNewPartId)
Dim frLayer As New Frame3d
EgtGetGroupGlobFrame( nNewLayerId, frLayer)
Dim nNewEntityId As Integer = EgtGetFirstInGroup(nNewLayerId)
While nNewEntityId <> GDB_ID.NULL
Dim EntityType As GDB_TY = EgtGetType(nNewEntityId)
Select Case EntityType
Case GDB_TY.CRV_COMPO, GDB_TY.CRV_LINE, GDB_TY.CRV_ARC
Dim nNewRib As Integer = GDB_ID.NULL
If EntityType = GDB_TY.CRV_LINE OrElse EntityType = GDB_TY.CRV_ARC Then
nNewRib = EgtCreateCurveCompo(nNewLayerId, nNewEntityId, False)
EgtRelocate( nNewRib, Map.refRibPanelVM.nRibLayerId, GDB_POS.LAST_SON)
Else
' lo copio nel layer dei rib
nNewRib = EgtCopy(nNewEntityId, Map.refRibPanelVM.nRibLayerId, GDB_POS.LAST_SON)
End If
EgtSetName(nNewRib, RIB_CURVE)
' elimino effetti di eventuale riferimento originale
EgtTransform( nNewRib, frLayer)
' elimino colore entita'
EgtResetColor(nNewEntityId)
' lo aggiungo alla lista
Dim NewEntity As RibEntity = New RibEntity(RibEntity.RibTypes.FROMIMPORT, nNewRib)
Map.refRibPanelVM.RibList.Add(NewEntity)
Case GDB_TY.SRF_MESH, GDB_TY.SRF_FRGN, GDB_TY.SRF_BEZ
' lo copio nel layer dei rib
Dim nNewRib As Integer = EgtCopy(nNewEntityId, Map.refRibPanelVM.nRibLayerId, GDB_POS.LAST_SON)
EgtSetName(nNewRib, RIB_EXTRUSION)
' elimino effetti di eventuale riferimento originale
EgtTransform( nNewRib, frLayer)
' elimino colore entita'
EgtResetColor(nNewEntityId)
' lo aggiungo alla lista
Dim NewEntity As RibEntity = New RibEntity(RibEntity.RibTypes.FROMIMPORT, nNewRib)
Map.refRibPanelVM.RibList.Add(NewEntity)
End Select
nNewEntityId = EgtGetNext(nNewEntityId)
End While
EgtErase(nNewPartId)
' seleziono ultima rib
Map.refRibPanelVM.SelLastRib()
EgtDraw()
' Imposto flag di ricalcolo slice
EgtSetInfo(Map.refTopPanelVM.SelPart.nPartId, MAC_TORECALC_SLICE, True)
End If
Return bOk
End Function
Public Function InsertPrint(MenuItem As ManagerLayer_MenuItem) As Boolean
' Recupero cartella dell'ultimo progetto aperto
Dim sDir As String = MainController.GetCurrFile()
If String.IsNullOrWhiteSpace(sDir) Then
GetMainPrivateProfileString(S_MRUIMPORTFILES, K_FILE & 1, "", sDir)
End If
If Not String.IsNullOrWhiteSpace(sDir) Then
sDir = Path.GetDirectoryName(sDir)
End If
If Not Directory.Exists(sDir) Then sDir = ""
Dim OpenFileDialog As New OpenFileDialog With {.Title = "Insert",
.Filter = "Stereolithography (*.stl)|*.stl" &
"|Iges files (*.igs;*.iges)|*.igs;*.iges" &
"|Step files (*.stp;*.step)|*.stp;*.step" &
"|3D Manufacturing format (*.3mf)|*.3mf" &
"|Rhino format (*.3dm)|*.3dm" &
"|New geometry EgalTech(*.nge)|*.nge" &
"|Imported Files (*.*)|*.stl;*.igs;*.iges;*.stp;*.step;*.3mf;*.nge" &
"|All Files (*.*)|*.*",
.FilterIndex = 7,
.InitialDirectory = sDir}
If Not OpenFileDialog.ShowDialog Then
Return False
End If
Dim sFile As String = OpenFileDialog.FileName
' importo la nuova geometria
Dim bOk As Boolean = MainController.InsertProject(sFile, False)
If bOk Then
' sposto le nuove geometrie nel layer rib del pezzo
Dim nNewPartId As Integer = EgtGetLastPart()
Dim nNewLayerId As Integer = EgtGetFirstGroupInGroup(nNewPartId)
Dim frLayer As New Frame3d
EgtGetGroupGlobFrame( nNewLayerId, frLayer)
' verifico che ci sia una sola entita'
If EgtGetGroupObjs(nNewLayerId) <> 1 Then
MessageBox.Show("Impossible importing file that contains more than one entity.", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
Else
' elimino eventuale entita' vecchia
If MenuItem.OrigLayer.EntityList.Count > 0 AndAlso MenuItem.OrigLayer.EntityList(0).nId <> GDB_ID.NULL Then EgtErase(MenuItem.OrigLayer.EntityList(0).nId)
Dim nNewEntityId As Integer = EgtGetFirstInGroup(nNewLayerId)
EgtRelocate(nNewEntityId, MenuItem.OrigLayer.nLayerId, GDB_POS.LAST_SON)
' elimino effetti di eventuale riferimento originale
EgtTransform( nNewEntityId, frLayer)
' elimino colore entita'
EgtResetColor(nNewEntityId)
' aggiorno riferimento pezzo
Map.refReferencePanelVM.UpdateFramePosition()
Map.refDispositionPanelVM.UpdateZPos()
Map.refSliceManagerVM.UpdateDimensions()
' elimino eventuale flag di spostamento a 45 gradi
EgtRemoveInfo(MenuItem.OrigLayer.OrigPart.PrintPart.nPartId, KEY_MOVEDPART)
' elimino vecchio elemento ed aggiungo nuovo
MenuItem.OrigLayer.EntityList.Clear()
MenuItem.OrigLayer.EntityList.Add(New PartManager_GeomEntity(MenuItem.OrigLayer, nNewEntityId))
' Imposto flag di ricalcolo slice
EgtSetInfo(Map.refTopPanelVM.SelPart.nPartId, MAC_TORECALC_SLICE, True)
End If
EgtErase(nNewPartId)
EgtDraw()
End If
Return bOk
End Function
Public Function InsertShellNumber() As Boolean
' Recupero cartella dell'ultimo progetto aperto
Dim sDir As String = MainController.GetCurrFile()
If String.IsNullOrWhiteSpace(sDir) Then
GetMainPrivateProfileString(S_MRUIMPORTFILES, K_FILE & 1, "", sDir)
End If
If Not String.IsNullOrWhiteSpace(sDir) Then
sDir = Path.GetDirectoryName(sDir)
End If
If Not Directory.Exists(sDir) Then sDir = ""
Dim OpenFileDialog As New OpenFileDialog With {.Title = "Insert",
.Filter = "Stereolithography (*.stl)|*.stl" &
"|Iges files (*.igs;*.iges)|*.igs;*.iges" &
"|Step files (*.stp;*.step)|*.stp;*.step" &
"|3D Manufacturing format (*.3mf)|*.3mf" &
"|Rhino format (*.3dm)|*.3dm" &
"|New geometry EgalTech(*.nge)|*.nge" &
"|Imported Files (*.*)|*.stl;*.igs;*.iges;*.stp;*.step;*.3mf;*.nge" &
"|All Files (*.*)|*.*",
.FilterIndex = 7,
.InitialDirectory = sDir}
If Not OpenFileDialog.ShowDialog Then
Return False
End If
Dim sFile As String = String.Empty
sFile = OpenFileDialog.FileName
' importo la nuova geometria
Dim bOk As Boolean = MainController.InsertProject(sFile, False)
If bOk Then
' sposto le nuove geometrie nel layer ShellNumber del pezzo
Dim nNewPartId As Integer = EgtGetLastPart()
Dim nNewLayerId As Integer = EgtGetFirstGroupInGroup(nNewPartId)
Dim frLayer As New Frame3d
EgtGetGroupGlobFrame( nNewLayerId, frLayer)
Dim nNewEntityId As Integer = EgtGetFirstInGroup(nNewLayerId)
While nNewEntityId <> GDB_ID.NULL
Dim EntityType As GDB_TY = EgtGetType(nNewEntityId)
Select Case EntityType
Case GDB_TY.CRV_COMPO, GDB_TY.CRV_LINE, GDB_TY.CRV_ARC
Dim nNewShellNumberId As Integer = GDB_ID.NULL
If EntityType = GDB_TY.CRV_LINE OrElse EntityType = GDB_TY.CRV_ARC Then
nNewShellNumberId = EgtCreateCurveCompo(nNewLayerId, nNewEntityId, False)
EgtRelocate( nNewShellNumberId, Map.refShellNumberPanelVM.nShellNumberLayerId, GDB_POS.LAST_SON)
Else
' lo copio nel layer dei shellnumber
nNewShellNumberId = EgtCopy(nNewEntityId, Map.refShellNumberPanelVM.nShellNumberLayerId, GDB_POS.LAST_SON)
End If
EgtSetName(nNewShellNumberId, RIB_CURVE)
' elimino effetti di eventuale riferimento originale
EgtTransform( nNewShellNumberId, frLayer)
' elimino colore entita'
EgtResetColor(nNewEntityId)
' lo aggiungo alla lista
Dim NewEntity As ShellNumberEntity = New ShellNumberEntity(ShellNumberEntity.ShellNumberTypes.FROMIMPORT, nNewShellNumberId)
Map.refShellNumberPanelVM.ShellNumberList.Add(NewEntity)
Case GDB_TY.SRF_MESH, GDB_TY.SRF_FRGN, GDB_TY.SRF_BEZ
' lo copio nel layer dei shellnumber
Dim nNewShellNumberId As Integer = EgtCopy(nNewEntityId, Map.refShellNumberPanelVM.nShellNumberLayerId, GDB_POS.LAST_SON)
EgtSetName(nNewShellNumberId, RIB_EXTRUSION)
' elimino effetti di eventuale riferimento originale
EgtTransform( nNewShellNumberId, frLayer)
' elimino colore entita'
EgtResetColor(nNewEntityId)
' lo aggiungo alla lista
Dim NewEntity As ShellNumberEntity = New ShellNumberEntity(ShellNumberEntity.ShellNumberTypes.FROMIMPORT, nNewShellNumberId)
Map.refShellNumberPanelVM.ShellNumberList.Add(NewEntity)
End Select
nNewEntityId = EgtGetNext(nNewEntityId)
End While
EgtErase(nNewPartId)
' seleziono ultima ShellNumber
Map.refShellNumberPanelVM.SelLastShellNumber()
EgtDraw()
' Imposto flag di ricalcolo slice
EgtSetInfo(Map.refTopPanelVM.SelPart.nPartId, MAC_TORECALC_SLICE, True)
End If
Return bOk
End Function
Public Function InsertFilledSolid() As Boolean
' Recupero cartella dell'ultimo progetto aperto
Dim sDir As String = MainController.GetCurrFile()
If String.IsNullOrWhiteSpace(sDir) Then
GetMainPrivateProfileString(S_MRUIMPORTFILES, K_FILE & 1, "", sDir)
End If
If Not String.IsNullOrWhiteSpace(sDir) Then
sDir = Path.GetDirectoryName(sDir)
End If
If Not Directory.Exists(sDir) Then sDir = ""
Dim OpenFileDialog As New OpenFileDialog With {.Title = "Insert",
.Filter = "Stereolithography (*.stl)|*.stl" &
"|Iges files (*.igs;*.iges)|*.igs;*.iges" &
"|Step files (*.stp;*.step)|*.stp;*.step" &
"|3D Manufacturing format (*.3mf)|*.3mf" &
"|Rhino format (*.3dm)|*.3dm" &
"|New geometry EgalTech(*.nge)|*.nge" &
"|Imported Files (*.*)|*.stl;*.igs;*.iges;*.stp;*.step;*.3mf;*.nge" &
"|All Files (*.*)|*.*",
.FilterIndex = 7,
.InitialDirectory = sDir}
If Not OpenFileDialog.ShowDialog Then
Return False
End If
Dim sFile As String = String.Empty
sFile = OpenFileDialog.FileName
' importo la nuova geometria
Dim bOk As Boolean = MainController.InsertProject(sFile, False)
If bOk Then
' sposto le nuove geometrie nel layer ShellNumber del pezzo
Dim nNewPartId As Integer = EgtGetLastPart()
Dim nNewLayerId As Integer = EgtGetFirstGroupInGroup(nNewPartId)
Dim frLayer As New Frame3d
EgtGetGroupGlobFrame( nNewLayerId, frLayer)
Dim nNewEntityId As Integer = EgtGetFirstInGroup(nNewLayerId)
While nNewEntityId <> GDB_ID.NULL
Dim EntityType As GDB_TY = EgtGetType(nNewEntityId)
Select Case EntityType
Case GDB_TY.CRV_COMPO, GDB_TY.CRV_LINE, GDB_TY.CRV_ARC
Dim nNewFilledSolidId As Integer = GDB_ID.NULL
If EntityType = GDB_TY.CRV_LINE OrElse EntityType = GDB_TY.CRV_ARC Then
nNewFilledSolidId = EgtCreateCurveCompo(nNewLayerId, nNewEntityId, False)
EgtRelocate( nNewFilledSolidId, Map.refFilledSolidPanelVM.nFilledSolidLayerId, GDB_POS.LAST_SON)
Else
' lo copio nel layer dei FilledSolid
nNewFilledSolidId = EgtCopy(nNewEntityId, Map.refFilledSolidPanelVM.nFilledSolidLayerId, GDB_POS.LAST_SON)
End If
EgtSetName(nNewFilledSolidId, RIB_CURVE)
' elimino effetti di eventuale riferimento originale
EgtTransform( nNewFilledSolidId, frLayer)
' elimino colore entita'
EgtResetColor(nNewEntityId)
' lo aggiungo alla lista
Dim NewEntity As FilledSolidEntity = New FilledSolidEntity(FilledSolidEntity.FilledSolidTypes.FROMIMPORT, nNewFilledSolidId)
Map.refFilledSolidPanelVM.FilledSolidList.Add(NewEntity)
Case GDB_TY.SRF_MESH, GDB_TY.SRF_FRGN, GDB_TY.SRF_BEZ
' lo copio nel layer dei FilledSolid
Dim nNewFilledSolidId As Integer = EgtCopy(nNewEntityId, Map.refFilledSolidPanelVM.nFilledSolidLayerId, GDB_POS.LAST_SON)
EgtSetName(nNewFilledSolidId, RIB_EXTRUSION)
' elimino effetti di eventuale riferimento originale
EgtTransform( nNewFilledSolidId, frLayer)
' elimino colore entita'
EgtResetColor(nNewEntityId)
' lo aggiungo alla lista
Dim NewEntity As FilledSolidEntity = New FilledSolidEntity(FilledSolidEntity.FilledSolidTypes.FROMIMPORT, nNewFilledSolidId)
Map.refFilledSolidPanelVM.FilledSolidList.Add(NewEntity)
End Select
nNewEntityId = EgtGetNext(nNewEntityId)
End While
EgtErase(nNewPartId)
' seleziono ultima FilledSolid
Map.refFilledSolidPanelVM.SelLastFilledSolid()
EgtDraw()
' Imposto flag di ricalcolo slice
EgtSetInfo(Map.refTopPanelVM.SelPart.nPartId, MAC_TORECALC_SLICE, True)
End If
Return bOk
End Function
Public Overrides Function ExportProject() As Boolean
' Reset controller e scena
MainController.ResetStatus()
'Assegnazione nome file con dialogo
Dim SaveFileDialog As New SaveFileDialog With {
.Title = "Export",
.Filter = "3D Manufacturing format (*.3mf)|*.3mf" &
"|Stereolithography (*.stl)|*.stl",
.FilterIndex = 1,
.FileName = Path.ChangeExtension(MainController.GetCurrFile(), "").TrimEnd("."c)
}
Dim DialogResult As Boolean? = SaveFileDialog.ShowDialog
If IsNothing(DialogResult) OrElse Not DialogResult Then Return False
MainController.SetDefaultFilterForExport(EEX_FLT.DEFAULT + EEX_FLT.LEV_TEMP)
Return MainController.ExportProject(SaveFileDialog.FileName, False)
End Function
Public Function ExportProjectForMachine(sFilePath As String) As Boolean
' Reset controller e scena
MainController.ResetStatus()
MainController.SetDefaultFilterForExport(EEX_FLT.MODE_HIDDEN + EEX_FLT.MODE_STD + EEX_FLT.STAT_ON + EEX_FLT.STAT_OFF + EEX_FLT.LEV_TEMP)
Return MainController.ExportGeomId(Map.refTopPanelVM.SelPart.nPartId, sFilePath, False)
End Function
Public Function ExportProjectForMachine(sDirPath As String, b3dm As Boolean, ByRef sFilePath As String) As Boolean
sFilePath = sDirPath & "\ProjectSlice" & If(b3dm, ".3dm", ".3mf")
' Reset controller e scena
MainController.ResetStatus()
MainController.SetDefaultFilterForExport(EEX_FLT.MODE_HIDDEN + EEX_FLT.MODE_STD + EEX_FLT.STAT_ON + EEX_FLT.STAT_OFF + EEX_FLT.LEV_TEMP)
Dim nExportGeomId As Integer = 0
If b3dm Then
If Not ExecPrepare3dmExport(nExportGeomId) Then Return False
Else
nExportGeomId = Map.refTopPanelVM.SelPart.nPartId
End If
Return MainController.ExportGeomId(nExportGeomId, sFilePath, False)
End Function
Public Overrides Function ExecScript(sFilePath As String) As Boolean
Dim bOk As Boolean = False
If String.IsNullOrEmpty(sFilePath) Then
Dim sDir As String = String.Empty
'GetMainPrivateProfileString(S_GENERAL, K_LASTLUADIR, "", sDir)
bOk = MainController.Exec(sDir)
Else
bOk = MainController.Exec(sFilePath, False)
End If
Dim bMachiningMode As Boolean = EgtGetCurrMachGroup() <> GDB_ID.NULL
If Not bMachiningMode And EgtGetCurrLayer() = GDB_ID.NULL Then
Dim nCurrPart As Integer = EgtGetCurrPart()
If nCurrPart = GDB_ID.NULL Or Not EgtSetCurrPartLayer(nCurrPart, EgtGetFirstLayer(nCurrPart, True)) Then
EgtResetCurrPartLayer()
End If
End If
Return bOk
End Function
#End Region ' ProjectManager
#Region "SCENE EVENTS"
Private Sub OnCursorPos(ByVal sender As Object, ByVal sCursorPos As String)
Map.refMyStatusBarVM.SetCurrPos(sCursorPos)
End Sub
Private Sub OnMouseSetObjFilterForSelect(sender As Object, bZeroDim As Boolean, bCurve As Boolean,
bSurf As Boolean, bVolume As Boolean, bExtra As Boolean)
' Se in modalità modifica e non seleziona pezzo
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
MainController.MouseSetObjFilterForSelect(bZeroDim, bCurve, bSurf, bVolume, bExtra)
End If
End Sub
Private Sub OnMouseSelectedAll(ByVal sender As Object, bOnlyVisble As Boolean)
' Se in modalità modifica e non seleziona pezzo
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
MainController.MouseSelectedAll(bOnlyVisble)
End If
End Sub
Private Sub OnMouseDeselectedAll(ByVal sender As Object)
' Se in modalità modifica e non seleziona pezzo
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
MainController.MouseDeselectedAll()
End If
End Sub
Private Sub OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs)
' se sto eseguendo comandi, esco
If MainController.GetStep() <> 0 Then Return
If e.Button = Forms.MouseButtons.Middle Then Return
If Map.refInstrumentPanelVM.GetDistIsChecked Then Return
' Se in modalità modifica
If Not IsNothing(Map.refTopPanelVM.SelPage) Then
If Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso Not IsNothing(Map.refTopPanelVM.SelModifyMode) Then
Select Case Map.refTopPanelVM.SelModifyMode.ModifyMode
Case ModifyModes.SELECT_
Part_OnMouseDownScene(sender, e)
Case ModifyModes.STARTMACH
StartMach_OnMouseDownScene(sender, e)
Case ModifyModes.RIBS
Rib_OnMouseDownScene(sender, e)
Case ModifyModes.SHELLNUMBER
ShellNumber_OnMouseDownScene(sender, e)
Case ModifyModes.AUXSOLIDS
FilledSolid_OnMouseDownScene(sender, e)
End Select
ElseIf Map.refTopPanelVM.SelPage = Pages.IMPORT Then
Import_OnMouseDownScene(sender, e)
End If
End If
'Select Case Map.refMainMenuVM.SelPage
' Case Pages.VIEW
' If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then
' If Map.refFreeContourManagerVM.bIsActive Then Return
' If Map.refShowBeamPanelVM.bShowAll Then
' View_Part_OnMouseDownScene(sender, e)
' Else
' View_Feature_OnMouseDownScene(sender, e)
' End If
' End If
' Case Pages.MACHINING
' If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then
' Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup
' If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return
' If SelectedMachGroup.nType = BWType.BEAM Then
' Beam_OnMouseDownScene(sender, e)
' ElseIf SelectedMachGroup.nType = BWType.WALL Then
' Wall_OnMouseDownScene(sender, e)
' End If
' End If
'End Select
End Sub
Private Sub OnMouseMoveScene(sender As Object, e As Forms.MouseEventArgs)
' se sto eseguendo comandi, esco
If MainController.GetStep() <> 0 Then Return
If e.Button = Forms.MouseButtons.Middle Then Return
If Map.refInstrumentPanelVM.GetDistIsChecked Then Return
' Se in modalità modifica
If Not IsNothing(Map.refTopPanelVM.SelPage) Then
If Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso Not IsNothing(Map.refTopPanelVM.SelModifyMode) Then
Select Case Map.refTopPanelVM.SelModifyMode.ModifyMode
Case ModifyModes.SELECT_
Part_OnMouseMoveScene(sender, e)
Case ModifyModes.STARTMACH
StartMach_OnMouseMoveScene(sender, e)
Case ModifyModes.RIBS
Rib_OnMouseMoveScene(sender, e)
Case ModifyModes.SHELLNUMBER
ShellNumber_OnMouseMoveScene(sender, e)
Case ModifyModes.AUXSOLIDS
FilledSolid_OnMouseMoveScene(sender, e)
End Select
ElseIf Map.refTopPanelVM.SelPage = Pages.IMPORT Then
Import_OnMouseMoveScene(sender, e)
End If
End If
'Select Case Map.refMainMenuVM.SelPage
' Case Pages.VIEW
' If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then
' If Map.refFreeContourManagerVM.bIsActive Then Return
' If Map.refShowBeamPanelVM.bShowAll Then
' View_Part_OnMouseMoveScene(sender, e)
' Else
' View_Feature_OnMouseMoveScene(sender, e)
' End If
' End If
' Case Pages.MACHINING
' If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then
' Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup
' If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return
' If SelectedMachGroup.nType = BWType.BEAM Then
' Beam_OnMouseMoveScene(sender, e)
' ElseIf SelectedMachGroup.nType = BWType.WALL Then
' Wall_OnMouseMoveScene(sender, e)
' End If
' End If
'End Select
End Sub
Private Sub OnMouseUpScene(sender As Object, e As Forms.MouseEventArgs)
' se sto eseguendo comandi, esco
If MainController.GetStep() <> 0 Then Return
If e.Button = Forms.MouseButtons.Middle Then Return
If Map.refInstrumentPanelVM.GetDistIsChecked Then Return
' Se in modalità modifica
If Not IsNothing(Map.refTopPanelVM.SelPage) Then
If Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso Not IsNothing(Map.refTopPanelVM.SelModifyMode) Then
Select Case Map.refTopPanelVM.SelModifyMode.ModifyMode
Case ModifyModes.SELECT_
Part_OnMouseUpScene(sender, e)
Case ModifyModes.STARTMACH
StartMach_OnMouseUpScene(sender, e)
Case ModifyModes.RIBS
Rib_OnMouseUpScene(sender, e)
Case ModifyModes.SHELLNUMBER
ShellNumber_OnMouseUpScene(sender, e)
Case ModifyModes.AUXSOLIDS
FilledSolid_OnMouseUpScene(sender, e)
End Select
ElseIf Map.refTopPanelVM.SelPage = Pages.IMPORT Then
Import_OnMouseUpScene(sender, e)
End If
End If
'Select Case Map.refMainMenuVM.SelPage
' Case Pages.VIEW
' If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then
' If Map.refFreeContourManagerVM.bIsActive Then Return
' If Map.refShowBeamPanelVM.bShowAll Then
' View_Part_OnMouseUpScene(sender, e)
' Else
' View_Feature_OnMouseUpScene(sender, e)
' End If
' End If
' Case Pages.MACHINING
' If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then
' Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup
' If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return
' If SelectedMachGroup.nType = BWType.BEAM Then
' Beam_OnMouseUpScene(sender, e)
' ElseIf SelectedMachGroup.nType = BWType.WALL Then
' Wall_OnMouseUpScene(sender, e)
' End If
' End If
'End Select
End Sub
Private Sub OnMouseSelectingObj(ByVal sender As Object, ByVal nId As Integer, ByRef bOk As Boolean)
' Se in modalità modifica e non seleziona pezzo
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
Select Case Map.refTopPanelVM.SelModifyMode.ModifyMode
'Case ModifyModes.SELECT_
Case ModifyModes.DISPOSITION
'bOk = Map.refDispositionPanelVM.OnMouseSelectingObj(nId)
Case ModifyModes.REFERENCE
Case ModifyModes.STARTMACH
bOk = Map.refStartMachPanelVM.OnMouseSelectingObj(nId)
Case ModifyModes.RIBS
bOk = Map.refRibPanelVM.OnMouseSelectingObj(nId)
Case ModifyModes.SHELLNUMBER
bOk = Map.refShellNumberPanelVM.OnMouseSelectingObj(nId)
Case ModifyModes.AUXSOLIDS
bOk = Map.refFilledSolidPanelVM.OnMouseSelectingObj(nId)
End Select
End If
End Sub
Private Sub OnMouseSelectedObj(ByVal sender As Object, ByVal nId As Integer, ByVal bLast As Boolean)
' Se in modalità modifica e non seleziona pezzo
'If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
' Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
' Select Case Map.refTopPanelVM.SelModifyMode.ModifyMode
' 'Case ModifyModes.SELECT_
' Case ModifyModes.DISPOSITION
' 'bOk = Map.refDispositionPanelVM.OnMouseSelectingObj(nId)
' Case ModifyModes.REFERENCE
' Case ModifyModes.STARTMACH
' Map.refStartMachPanelVM.OnMouseSelectedObj(nId)
' Case ModifyModes.RIBS
' Case ModifyModes.SHELLNUMBER
' Case ModifyModes.AUXSOLIDS
' End Select
'End If
MainController.MouseSelectedObj(nId, bLast)
End Sub
Private Sub OnMouseSelectedPart(ByVal sender As Object, ByVal nId As Integer)
' Se in modalità modifica e non seleziona pezzo
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
MainController.MouseSelectedPart(nId)
End If
End Sub
Private Sub OnMouseSelectedLayer(ByVal sender As Object, ByVal nId As Integer)
' Se in modalità modifica e non seleziona pezzo
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
MainController.MouseSelectedLayer(nId)
End If
End Sub
Private Sub OnMouseSelectedPath(ByVal sender As Object, ByVal nId As Integer, ByVal bHaltOnFork As Boolean)
' Se in modalità modifica e non seleziona pezzo
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
MainController.MouseSelectedPath(nId, bHaltOnFork)
End If
End Sub
Private Sub OnMousePointFromSelection(ByVal sender As Object, ByVal nId As Integer, ByVal PtP As Point3d, ByVal nAux As Integer)
' Se in modalità modifica e non seleziona pezzo
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
MainController.SetPointFromSelection(nId, PtP, nAux)
End If
End Sub
Private Sub OnMouseDone(ByVal sender As Object)
' Se in modalità modifica e non seleziona pezzo
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
MainController.Done(Map.refControllerInputPanelVM.Text)
End If
End Sub
Private Sub OnMouseSelectedPoint(ByVal sender As Object, ByVal PtP As Point3d, ByVal nSep As SEP, ByVal nId As Integer)
' Se in modalità modifica e non seleziona pezzo
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
Dim bDone As Boolean = (Keyboard.Modifiers And ModifierKeys.Control) <> ModifierKeys.Control
MainController.MouseSelectedPoint(PtP, nSep, nId, bDone)
End If
End Sub
Private Sub OnMouseSelectedDir(ByVal sender As Object, ByVal VtDir As Vector3d)
' Se in modalità modifica e non seleziona pezzo
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
MainController.SetLastVector3d(VtDir)
End If
End Sub
Private Sub OnMouseMoveSelPoint(ByVal sender As Object, ByVal PtP As Point3d)
' Se in modalità modifica e non seleziona pezzo
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso
Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode <> ModifyModes.SELECT_ Then
MainController.MouseMoveInSelectionPoint(PtP)
End If
End Sub
Private Sub OnShowDistance(ByVal sender As Object, ByVal sDistance As String)
Map.refMyStatusBarVM.SetOutputMessage(sDistance)
End Sub
Private Sub OnKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs)
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso Not IsNothing(Map.refTopPanelVM.SelModifyMode) Then
Select Case Map.refTopPanelVM.SelModifyMode.ModifyMode
'Case ModifyModes.SELECT_
Case ModifyModes.DISPOSITION
Map.refDispositionPanelVM.OnKeyDown(e.KeyData)
Case ModifyModes.REFERENCE
Case ModifyModes.STARTMACH
Map.refStartMachPanelVM.OnKeyDown(e.KeyData)
Case ModifyModes.RIBS
Map.refRibPanelVM.OnKeyDown(e.KeyData)
Case ModifyModes.SHELLNUMBER
Map.refShellNumberPanelVM.OnKeyDown(e.KeyData)
Case ModifyModes.AUXSOLIDS
Map.refFilledSolidPanelVM.OnKeyDown(e.KeyData)
End Select
End If
End Sub
Private Sub OnCloseGetDist(sender As System.Object)
Map.refInstrumentPanelVM.SetGetDistance_IsChecked(False)
End Sub
Friend Sub OnChangedSnapPointType(ByVal sender As Object, ByVal nSpType As SP, ByVal bUser As Boolean)
m_SnapType = nSpType
If Not IsNothing(Map.refMyStatusBarVM) Then Map.refMyStatusBarVM.SetSnapPointType(nSpType)
End Sub
#End Region ' SCENE EVENTS
#Region "CONTROLLER EVENTS"
Private Sub OnNewProject(sender As Object, bOk As Boolean)
EgtErase(EgtGetFirstPart())
CurrentMachine.CreateMachineTable()
If Not bOk Then
MessageBox.Show(Application.Current.MainWindow, EgtMsg(10002), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error on new file - Error
End If
Map.refTopPanelVM.PartList.Clear()
Map.refTopPanelVM.SetSelModifyMode(ModifyModes.NULL)
Map.refSliceManagerVM.UpdateTimeAndMass()
Map.refSliceManagerVM.UpdateDimensions()
Map.refSliderManagerVM.RefreshSlider(0, 0)
Map.refSliderManagerVM.SetLayerIndexToMax()
' resetto calcolo solidi
Map.refViewLayerManagerVM.ResetSolid()
EgtZoom(ZM.ALL)
MainScene.SetStatusNull()
End Sub
Private Sub OnOpenProject(sender As Object, sFile As String, bOk As Boolean)
WriteMainPrivateProfileString(S_GENERAL, K_LASTNGEDIR, Path.GetDirectoryName(sFile))
If bOk Then
Map.refProjManagerVM.MruFiles.Add(sFile)
Else
Map.refProjManagerVM.MruFiles.Remove(sFile)
Dim sMsg As String
If My.Computer.FileSystem.FileExists(sFile) Then
sMsg = EgtMsg(10003) & " '" & sFile & "'" 'Error opening file
Else
sMsg = EgtMsg(10009) & " '" & sFile & "'" 'Missing file
End If
MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error
End If
' leggo materiale e macchina
Dim nTabPartId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, TABLE)
If nTabPartId <> GDB_ID.NULL Then
Dim sMachineName As String = ""
If Not EgtGetInfo(nTabPartId, KEY_MACHINE_NAME, sMachineName) Then sMachineName = "Cms-Kreator"
Dim ProjectMachine As Machine = Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = sMachineName)
If Not IsNothing(ProjectMachine) Then
' imposto la macchina
Map.refMachinePanelVM.SelectedMachine = ProjectMachine
Else
MessageBox.Show("Project machine not found! Impossible to open the project.", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
Map.refProjManagerVM.NewProject(False)
Return
End If
Dim sMaterialGuid As String = ""
EgtGetInfo(nTabPartId, KEY_MATERIAL_GUID, sMaterialGuid)
Dim MaterialGuid As Guid
Dim ProjectMaterial As MaterialIndex = Nothing
If Guid.TryParse(sMaterialGuid, MaterialGuid) Then
' cerco materiale in lista
ProjectMaterial = Map.refTopPanelVM.MaterialList.FirstOrDefault(Function(x) x.sGUID = sMaterialGuid)
End If
If IsNothing(ProjectMaterial) Then
Dim sMaterialName As String = ""
EgtGetInfo(nTabPartId, KEY_MATERIAL_NAME, sMaterialName)
ProjectMaterial = Map.refTopPanelVM.MaterialList.FirstOrDefault(Function(x) x.sName = sMaterialName)
End If
If Not IsNothing(ProjectMaterial) Then
Map.refTopPanelVM.SetSelMaterial(ProjectMaterial, True)
Map.refTopPanelVM.NotifyPropertyChanged(NameOf(Map.refTopPanelVM.SelMaterial))
Else
Dim sMaterialName As String = ""
EgtGetInfo(nTabPartId, KEY_MATERIAL_NAME, sMaterialName)
MessageBox.Show("Project material (Guid:" & sMaterialGuid & " Name:""" & sMaterialName & """) not found!" & Environment.NewLine &
"Please select another material!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning)
End If
End If
' aggiorno punto di vista e griglia
EgtSetView( CurrentMachine.nStandardView, False)
EgtSetGridGeoAdv( -1, -1, -1, 0, CurrentMachine.b3Tab.DimX(), 0, CurrentMachine.b3Tab.DimY())
EgtZoom(ZM.ALL, False)
' leggo pezzi
Map.refTopPanelVM.PartList.Clear()
Dim bProjectToRecalc As Boolean = False
Dim nPartId As Integer = EgtGetFirstPart()
While nPartId <> GDB_ID.NULL
Dim nIsOnTable As Integer = 0
If Not EgtGetInfo(nPartId, "PartOnTable", nIsOnTable) OrElse nIsOnTable <> 1 Then
nPartId = EgtGetNextPart(nPartId)
Continue While
End If
Dim nPrintPartLayerId As Integer = EgtGetFirstNameInGroup(nPartId, PRINT_SOLID)
Dim nPrintPartId As Integer = EgtGetFirstInGroup(nPrintPartLayerId)
Dim nRibsLayerId As Integer = EgtGetFirstNameInGroup(nPartId, LAY_RIBS)
Dim nShellNumberLayerId As Integer = EgtGetFirstNameInGroup(nPartId, LAY_SHELL_NBR)
Dim nAuxSolidsLayerId As Integer = EgtGetFirstNameInGroup(nPartId, LAY_AUX_SOLIDS)
Dim nMachStartLayerId As Integer = EgtGetFirstNameInGroup(nPartId, LAY_MACH_START)
Dim nOthersLayerId As Integer = EgtGetFirstNameInGroup(nPartId, LAY_OTHERS)
Dim sFilePath As String = ""
EgtGetInfo(nPartId, FILE_PATH, sFilePath)
Dim nPartReferenceLayerId As Integer = EgtGetFirstNameInGroup(nPartId, LAY_PARTREFERENCE)
If nPartReferenceLayerId = GDB_ID.NULL Then
nPartReferenceLayerId = EgtCreateGroup(nPartId)
EgtSetName(nPartReferenceLayerId, LAY_PARTREFERENCE)
End If
Dim nReferenceLayerId As Integer = EgtGetFirstNameInGroup(nPartId, LAY_REFERENCE)
Dim nFrameId As Integer = EgtGetFirstInGroup(nReferenceLayerId)
Dim NewPart As New Print3dPartVM(nPartId, nPrintPartLayerId, nPartReferenceLayerId, nReferenceLayerId, nFrameId, nMachStartLayerId, nRibsLayerId, nShellNumberLayerId, nAuxSolidsLayerId, nOthersLayerId, sFilePath)
Map.refTopPanelVM.PartList.Add(NewPart)
Dim bPartToRecalc As Boolean = False
EgtGetInfo(nPartId, MAC_TORECALC_SLICE, bPartToRecalc)
If bPartToRecalc AndAlso Not bProjectToRecalc Then bProjectToRecalc = True
' Disabilito segnalazione modificato
Dim DisableMgr As New DisableModifiedMgr
' setto i solidi non calcolati
EgtSetInfo(nPartId, KEY_CALC_SOLIDS, 0)
EgtSetInfo(nPartId, KEY_HAS_SOLIDS, 0)
' Ripristino stato segnalazione modifica
DisableMgr.ReEnable()
nPartId = EgtGetNextPart(nPartId)
End While
' aggiorno colori entita'
GeomEntityColors.UpdateColors(LayerType.ALL)
' aggiorno tempo e massa
Map.refSliceManagerVM.UpdateTimeAndMass()
Map.refSliceManagerVM.UpdateDimensions()
Map.refSliderManagerVM.SetLayerIndexToMax()
' seleziono primo pezzo trovato
Map.refTopPanelVM.SelFirstPart()
' resetto calcolo solidi
Map.refViewLayerManagerVM.ResetSolid()
' imposto modalita' modifica
Map.refTopPanelVM.SelPage = Pages.MODIFY
EgtDraw()
MainScene.SetStatusNull()
End Sub
Private Sub OnSavingProject(ByVal sender As Object, sFile As String)
' Se in SaveAs, aggiorno nome CN da generare
If m_bIsSaveAs Then
Dim nTabPartId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, TABLE)
If nTabPartId <> GDB_ID.NULL Then
EgtRemoveInfo(nTabPartId, KEY_ISOFILE_PATH)
End If
End If
End Sub
Private Sub OnSavedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean)
WriteMainPrivateProfileString(S_GENERAL, K_LASTNGEDIR, Path.GetDirectoryName(sFile))
If bOk Then
Map.refProjManagerVM.MruFiles.Add(sFile)
Else
Map.refProjManagerVM.MruFiles.Remove(sFile)
Dim sMsg As String = EgtMsg(10004) & " '" & sFile & "'" 'Error saving file
MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error
End If
End Sub
Private Sub OnInsertingProject(sender As Object, nType As Integer, ByRef nFlag As Integer)
If nType = FT.OBJ Or nType = FT.IGES Or nType = FT.STEP_ Or nType = FT.ACIS Or
nType = FT.PARASOLID Or nType = FT.JT Or nType = FT.VRML Or nType = FT.C3D Then
nFlag = GetMainPrivateProfileInt(S_IMPORT, K_ADVFLAG, 0)
Dim dToler As Double = GetMainPrivateProfileDouble(S_IMPORT, K_ADVTOLER, 0.1)
MainController.SetAdvImpTolerance( dToler)
Else
nFlag = 0
End If
End Sub
Private Sub OnInsertedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean)
' Segnalo eventuale errore
If Not bOk Then
Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" 'Error importing file
MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error
End If
Map.refProjManagerVM.MruImportFiles.Add(sFile)
EgtSetInfo(EgtGetLastPart(), FILE_PATH, sFile)
EgtDraw()
MainScene.SetStatusNull()
End Sub
Private Sub PrepareInputBox(ByVal sTitle As String, ByVal sLabel As String, ByVal sCheckLabel As String,
ByVal bShowCombo As Boolean, ByVal bShowBtn As Boolean)
Map.refControllerInputPanelVM.PrepareInputBox(sTitle, sLabel, sCheckLabel, bShowCombo, bShowBtn)
End Sub
Private Sub SetInputBoxText(ByVal sText As String)
Map.refControllerInputPanelVM.SetInputBoxText(sText)
End Sub
Private Sub SetInputBoxCheck(ByVal bCheck As Boolean)
Map.refControllerInputPanelVM.SetInputBoxCheck(bCheck)
End Sub
Private Sub AddInputBoxCombo(ByVal sText As String, ByVal bSelected As Boolean)
Map.refControllerInputPanelVM.AddInputBoxCombo(sText, bSelected)
End Sub
Private Sub UpdateUI(ByVal sender As Object, ByVal bReloadUI As Boolean)
' pulisco input e relativi messaggi
Map.refControllerInputPanelVM.ResetInputBox()
If MainController.GetContinue() Then
Map.refMyStatusBarVM.SetOutputMessage(EgtMsg(399)) ' Continue : 'L' with line, 'A' with arc
Else
Map.refMyStatusBarVM.ClearOutputMessage()
End If
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso Not IsNothing(Map.refTopPanelVM.SelModifyMode) Then
Select Case Map.refTopPanelVM.SelModifyMode.ModifyMode
'Case ModifyModes.SELECT_
Case ModifyModes.DISPOSITION
Map.refDispositionPanelVM.UpdateUI()
Case ModifyModes.REFERENCE
Case ModifyModes.STARTMACH
Map.refStartMachPanelVM.UpdateUI()
Case ModifyModes.RIBS
Map.refRibPanelVM.UpdateUI()
Case ModifyModes.SHELLNUMBER
Map.refShellNumberPanelVM.UpdateUI()
Case ModifyModes.AUXSOLIDS
Map.refFilledSolidPanelVM.UpdateUI()
End Select
End If
' aggiorno titolo
EmitTitle()
End Sub
Private Sub OnExecCmdEnd(command As Controller.CMD)
If Not IsNothing(Map.refTopPanelVM.SelPage) AndAlso Map.refTopPanelVM.SelPage = Pages.MODIFY AndAlso Not IsNothing(Map.refTopPanelVM.SelModifyMode) Then
Select Case Map.refTopPanelVM.SelModifyMode.ModifyMode
'Case ModifyModes.SELECT_
Case ModifyModes.DISPOSITION
Case ModifyModes.REFERENCE
Case ModifyModes.STARTMACH
Map.refStartMachPanelVM.OnExecCmdEnd(command)
Case ModifyModes.RIBS
Map.refRibPanelVM.OnExecCmdEnd(command)
Case ModifyModes.SHELLNUMBER
Map.refShellNumberPanelVM.OnExecCmdEnd(command)
Case ModifyModes.AUXSOLIDS
Map.refFilledSolidPanelVM.OnExecCmdEnd(command)
End Select
End If
End Sub
#End Region ' CONTROLLER EVENTS
#Region "VIEW EVENTS"
#Region "Part"
Friend Sub Part_OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs)
' Verifico se selezionato indicativo di pezzo
EgtSetObjFilterForSelWin(True, True, True, True, True)
Dim nSel As Integer
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
Dim nId As Integer = EgtGetFirstObjInSelWin()
While nId <> GDB_ID.NULL
' Recupero l'identificativo del pezzo cui appartiene
Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
Dim bFound As Boolean = False
If EgtIsPart(nPartId) Then bFound = True
If Not bFound Then
nId = EgtGetNextObjInSelWin()
Continue While
End If
Dim nStat As Integer = GDB_ST.ON_
EgtGetStatus(nPartId, nStat)
' Se già selezionato
If nStat = GDB_ST.SEL Then
' Memorizzo Id da deselezionare
m_nIdToDesel = nPartId
Else
' Memorizzo Id da selezionare
m_nIdToSel = nPartId
End If
Exit While
nId = EgtGetNextObjInSelWin()
End While
' Dati per drag
m_bDragToStart = True
End Sub
Friend Sub Part_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se drag non abilitato o già in esecuzione, esco
If Not m_bDragToStart Then Return
' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel
If m_bDragToStart Then
If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And
Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then
Return
End If
m_bDragToStart = False
End If
End Sub
Friend Sub Part_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se eseguito drag
If Not m_bDragToStart Then
' Se selezione da eseguire
ElseIf m_nIdToSel <> GDB_ID.NULL Then
' Se pezzo da selezionare non è già selezionato
'If EgtIsSelectedObj(m_nIdToSel) Then
' Eseguo la selezione
Map.refTopPanelVM.SelPartFromId(m_nIdToSel)
'EgtDeselectAll()
'EgtSelectPartObjs(m_nIdToSel)
'EgtSelectObj(m_nIdToSel)
'EgtSetMark(m_nIdToSel)
'End If
'If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) OrElse Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId <> m_nIdToSel Then
' ' Eseguo la selezione
' For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList
' If BTLPart.nPartId = m_nIdToSel Then
' BTLPart.SetIsSelected(True)
' ElseIf BTLPart.IsSelected Then
' BTLPart.SetIsSelected(False)
' End If
' Next
' End If
End If
' Reset
m_bDrag = False
m_nIdToSel = GDB_ID.NULL
m_nIdToDesel = GDB_ID.NULL
EgtDraw()
End Sub
#End Region ' Part
#Region "Import"
Friend Sub Import_OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs)
' Verifico se selezionato indicativo di pezzo
EgtSetObjFilterForSelWin(True, True, True, True, True)
Dim nSel As Integer
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
Dim nId As Integer = EgtGetFirstObjInSelWin()
Dim nCurrIdToSel As Integer = GDB_ID.NULL
While nId <> GDB_ID.NULL
' Recupero l'identificativo del pezzo cui appartiene
Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
If nPartId = Map.refManagePartPanelVM.nImportedPartId Then
Dim EntityType As GDB_TY = EgtGetType(nId)
Select Case EntityType
Case GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO, GDB_TY.CRV_LINE
nCurrIdToSel = nId
Exit While
Case GDB_TY.SRF_BEZ, GDB_TY.SRF_FRGN, GDB_TY.SRF_MESH
If nCurrIdToSel = GDB_ID.NULL Then nCurrIdToSel = nId
End Select
End If
nId = EgtGetNextObjInSelWin()
End While
' Memorizzo Id da selezionare
m_nIdToSel = nCurrIdToSel
' Dati per drag
m_bDragToStart = True
End Sub
Friend Sub Import_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se drag non abilitato o già in esecuzione, esco
If Not m_bDragToStart Then Return
' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel
If m_bDragToStart Then
If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And
Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then
Return
End If
m_bDragToStart = False
End If
End Sub
Friend Sub Import_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se eseguito drag
If Not m_bDragToStart Then
' Se selezione da eseguire
ElseIf m_nIdToSel <> GDB_ID.NULL Then
Map.refManagePartPanelVM.SetSelImportedEntity(m_nIdToSel)
End If
' Reset
m_bDrag = False
m_nIdToSel = GDB_ID.NULL
m_nIdToDesel = GDB_ID.NULL
End Sub
#End Region ' Import
#Region "StartMach"
Friend Sub StartMach_OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs)
' Verifico se selezionato indicativo di pezzo
EgtSetObjFilterForSelWin(True, True, True, True, True)
Dim nSel As Integer
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
Dim nId As Integer = EgtGetFirstObjInSelWin()
While nId <> GDB_ID.NULL
' Se per Griglia da faccia di oggetto
If Map.refStartMachPanelVM.bCPlaneObj_IsActive Then
If EgtGetType(nId) = GDB_TY.SRF_MESH Then
m_nIdToSel = nId
Exit While
End If
Else
' Recupero l'identificativo del pezzo cui appartiene
Dim nStartMachLayerId As Integer = EgtGetParent(nId)
If nStartMachLayerId = Map.refStartMachPanelVM.nStartMachLayerId Then
m_nIdToSel = nId
Exit While
End If
End If
nId = EgtGetNextObjInSelWin()
End While
If Map.refStartMachPanelVM.bCPlaneObj_IsActive And m_nIdToSel <> GDB_ID.NULL Then
' recupero dati punto di selezione
Dim PtTemp As Point3d
Dim nAux As Integer
If EgtGetPointFromSelect(m_nIdToSel, e.Location, PtTemp, nAux) Then
' eseguo la selezione
EgtSelectObj(m_nIdToSel)
' dati ausiliari
EgtSetSelInfo(m_nIdToSel, nAux, PtTemp)
End If
End If
' Dati per drag
m_bDragToStart = True
End Sub
Friend Sub StartMach_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se drag non abilitato o già in esecuzione, esco
If Not m_bDragToStart Then Return
' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel
If m_bDragToStart Then
If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And
Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then
Return
End If
m_bDragToStart = False
End If
End Sub
Friend Sub StartMach_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se eseguito drag
If Not m_bDragToStart Then
' se in scelta piano da oggetto resetto eventuale selezione
If Map.refRibPanelVM.bCPlaneObj_IsActive Then
EgtDeselectAll()
End If
' Se selezione da eseguire
ElseIf m_nIdToSel <> GDB_ID.NULL Then
If Map.refStartMachPanelVM.bCPlaneObj_IsActive Then
' eseguo comando
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.GRID_OBJ)
Map.refStartMachPanelVM.ResetCPlaneObjIsActive()
' imposto dimensioni griglia standard (non tavola)
EgtSetGridGeo( -1, -1, -1, OptionModule.m_nExtSStep)
' ripristino selezioni precedenti
For Each Id In Map.refStartMachPanelVM.PrevSelObjs
EgtSelectObj(Id)
Next
Map.refControllerInputPanelVM.ResetInputBox()
Else
' Eseguo la selezione
Map.refStartMachPanelVM.SelStartFromId(m_nIdToSel)
End If
End If
' Reset
m_bDrag = False
m_nIdToSel = GDB_ID.NULL
m_nIdToDesel = GDB_ID.NULL
EgtDraw()
End Sub
#End Region ' StartMach
#Region "Rib"
Friend Sub Rib_OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs)
' Verifico se selezionato indicativo di pezzo
EgtSetObjFilterForSelWin(True, True, True, True, True)
Dim nSel As Integer
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
Dim nId As Integer = EgtGetFirstObjInSelWin()
While nId <> GDB_ID.NULL
' Se per Griglia da faccia di oggetto
If Map.refRibPanelVM.bCPlaneObj_IsActive Then
If EgtGetType(nId) = GDB_TY.SRF_MESH Then
m_nIdToSel = nId
Exit While
End If
Else
Dim nRibLayerId As Integer = EgtGetParent(nId)
If nRibLayerId = Map.refRibPanelVM.nRibLayerId Then
m_nIdToSel = nId
Exit While
End If
End If
nId = EgtGetNextObjInSelWin()
End While
If Map.refRibPanelVM.bCPlaneObj_IsActive And m_nIdToSel <> GDB_ID.NULL Then
' recupero dati punto di selezione
Dim PtTemp As Point3d
Dim nAux As Integer
If EgtGetPointFromSelect(m_nIdToSel, e.Location, PtTemp, nAux) Then
' eseguo la selezione
EgtSelectObj(m_nIdToSel)
' dati ausiliari
EgtSetSelInfo(m_nIdToSel, nAux, PtTemp)
End If
End If
' Dati per drag
m_bDragToStart = True
End Sub
Friend Sub Rib_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se drag non abilitato o già in esecuzione, esco
If Not m_bDragToStart Then Return
' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel
If m_bDragToStart Then
If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And
Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then
Return
End If
m_bDragToStart = False
End If
End Sub
Friend Sub Rib_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se eseguito drag
If Not m_bDragToStart Then
' se in scelta piano da oggetto resetto eventuale selezione
If Map.refRibPanelVM.bCPlaneObj_IsActive Then
EgtDeselectAll()
End If
' Se selezione da eseguire
ElseIf m_nIdToSel <> GDB_ID.NULL Then
If Map.refRibPanelVM.bCPlaneObj_IsActive Then
' eseguo comando
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.GRID_OBJ)
Map.refRibPanelVM.ResetCPlaneObjIsActive()
' imposto dimensioni griglia standard (non tavola)
EgtSetGridGeo( -1, -1, -1, OptionModule.m_nExtSStep)
' ripristino selezioni precedenti
For Each Id In Map.refRibPanelVM.PrevSelObjs
EgtSelectObj(Id)
Next
Map.refControllerInputPanelVM.ResetInputBox()
Else
' Eseguo la selezione
Map.refRibPanelVM.SelStartFromId(m_nIdToSel)
End If
End If
' Reset
m_bDrag = False
m_nIdToSel = GDB_ID.NULL
m_nIdToDesel = GDB_ID.NULL
EgtDraw()
End Sub
#End Region ' Rib
#Region "ShellNumber"
Friend Sub ShellNumber_OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs)
m_nIdToSel = GDB_ID.NULL
' Verifico se selezionato indicativo di pezzo
EgtSetObjFilterForSelWin(True, True, True, True, True)
Dim nSel As Integer
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
Dim nId As Integer = EgtGetFirstObjInSelWin()
While nId <> GDB_ID.NULL
' Se per Griglia da faccia di oggetto
If Map.refShellNumberPanelVM.bCPlaneObj_IsActive Then
If EgtGetType(nId) = GDB_TY.SRF_MESH Then
m_nIdToSel = nId
Exit While
End If
Else
Dim nShellNumberLayerId As Integer = EgtGetParent(nId)
If nShellNumberLayerId = Map.refShellNumberPanelVM.nShellNumberLayerId Then
m_nIdToSel = nId
Exit While
End If
End If
nId = EgtGetNextObjInSelWin()
End While
If Map.refShellNumberPanelVM.bCPlaneObj_IsActive And m_nIdToSel <> GDB_ID.NULL Then
' recupero dati punto di selezione
Dim PtTemp As Point3d
Dim nAux As Integer
If EgtGetPointFromSelect(m_nIdToSel, e.Location, PtTemp, nAux) Then
' eseguo la selezione
EgtSelectObj(m_nIdToSel)
' dati ausiliari
EgtSetSelInfo(m_nIdToSel, nAux, PtTemp)
End If
End If
' Dati per drag
m_bDragToStart = True
End Sub
Friend Sub ShellNumber_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se drag non abilitato o già in esecuzione, esco
If Not m_bDragToStart Then Return
' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel
If m_bDragToStart Then
If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And
Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then
Return
End If
m_bDragToStart = False
End If
End Sub
Friend Sub ShellNumber_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se eseguito drag
If Not m_bDragToStart Then
' se in scelta piano da oggetto resetto eventuale selezione
If Map.refRibPanelVM.bCPlaneObj_IsActive Then
EgtDeselectAll()
End If
' Se selezione da eseguire
ElseIf m_nIdToSel <> GDB_ID.NULL Then
If Map.refShellNumberPanelVM.bCPlaneObj_IsActive Then
' eseguo comando
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.GRID_OBJ)
Map.refShellNumberPanelVM.ResetCPlaneObjIsActive()
' imposto dimensioni griglia standard (non tavola)
EgtSetGridGeo( -1, -1, -1, OptionModule.m_nExtSStep)
' ripristino selezioni precedenti
For Each Id In Map.refShellNumberPanelVM.PrevSelObjs
EgtSelectObj(Id)
Next
Map.refControllerInputPanelVM.ResetInputBox()
Else
' eseguo la selezione
Map.refShellNumberPanelVM.SelStartFromId(m_nIdToSel)
End If
End If
' Reset
m_bDrag = False
m_nIdToSel = GDB_ID.NULL
m_nIdToDesel = GDB_ID.NULL
EgtDraw()
End Sub
#End Region ' ShellNumber
#Region "FilledSolid"
Friend Sub FilledSolid_OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs)
m_nIdToSel = GDB_ID.NULL
' Verifico se selezionato indicativo di pezzo
EgtSetObjFilterForSelWin(True, True, True, True, True)
Dim nSel As Integer
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
Dim nId As Integer = EgtGetFirstObjInSelWin()
While nId <> GDB_ID.NULL
' Se per Griglia da faccia di oggetto
If Map.refFilledSolidPanelVM.bCPlaneObj_IsActive Then
If EgtGetType(nId) = GDB_TY.SRF_MESH Then
m_nIdToSel = nId
Exit While
End If
Else
Dim nFilledSolidLayerId As Integer = EgtGetParent(nId)
If nFilledSolidLayerId = Map.refFilledSolidPanelVM.nFilledSolidLayerId Then
m_nIdToSel = nId
Exit While
End If
End If
nId = EgtGetNextObjInSelWin()
End While
If Map.refFilledSolidPanelVM.bCPlaneObj_IsActive And m_nIdToSel <> GDB_ID.NULL Then
' recupero dati punto di selezione
Dim PtTemp As Point3d
Dim nAux As Integer
If EgtGetPointFromSelect(m_nIdToSel, e.Location, PtTemp, nAux) Then
' eseguo la selezione
EgtSelectObj(m_nIdToSel)
' dati ausiliari
EgtSetSelInfo(m_nIdToSel, nAux, PtTemp)
End If
End If
' Dati per drag
m_bDragToStart = True
End Sub
Friend Sub FilledSolid_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se drag non abilitato o già in esecuzione, esco
If Not m_bDragToStart Then Return
' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel
If m_bDragToStart Then
If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And
Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then
Return
End If
m_bDragToStart = False
End If
End Sub
Friend Sub FilledSolid_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se eseguito drag
If Not m_bDragToStart Then
' se in scelta piano da oggetto resetto eventuale selezione
If Map.refRibPanelVM.bCPlaneObj_IsActive Then
EgtDeselectAll()
End If
' Se selezione da eseguire
ElseIf m_nIdToSel <> GDB_ID.NULL Then
If Map.refFilledSolidPanelVM.bCPlaneObj_IsActive Then
' eseguo comando
Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.GRID_OBJ)
Map.refFilledSolidPanelVM.ResetCPlaneObjIsActive()
' imposto dimensioni griglia standard (non tavola)
EgtSetGridGeo( -1, -1, -1, OptionModule.m_nExtSStep)
' ripristino selezioni precedenti
For Each Id In Map.refFilledSolidPanelVM.PrevSelObjs
EgtSelectObj(Id)
Next
Map.refControllerInputPanelVM.ResetInputBox()
Else
' eseguo la selezione
Map.refFilledSolidPanelVM.SelStartFromId(m_nIdToSel)
End If
End If
' Reset
m_bDrag = False
m_nIdToSel = GDB_ID.NULL
m_nIdToDesel = GDB_ID.NULL
EgtDraw()
End Sub
#End Region ' FilledSolid
#End Region ' VIEW EVENTS
End Class