1242 lines
56 KiB
VB.net
1242 lines
56 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtUILib.Controller
|
|
Imports EgtWPFLib5
|
|
Imports System.IO
|
|
Imports System.Windows.Forms
|
|
|
|
Public Class MySceneHostVM
|
|
Inherits SceneHostVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Public Event OnOpeningProject As OnOpeningProjectEventHandler
|
|
Public Event OnOpenProj As OnOpenProjectEventHandler
|
|
|
|
' variabili per la selezione in over
|
|
Public m_SelType As Integer = GDB_TY.CRV_LINE ' tipo di oggetti da evidenziare con il mouse over
|
|
Private m_nIdMouseOverSel As Integer = GDB_ID.NULL ' id dell'oggetto attualmente evidenziato dal mouse over
|
|
Public m_MarkedPartsList As New List(Of Integer) ' id degli oggetti da tenere selezionati
|
|
Public m_nAlphaTransparent As Integer = 0 ' trasparenza originale dell'oggetto evidenziato
|
|
Public m_nAlphaTransparent1 As Integer = 0 ' trasparenza dell'oggetto Marked3
|
|
Public m_nAlphaTransparent2 As Integer = 0 ' trasparenza dell'oggetto Marked4
|
|
|
|
' variabili per la selezione degli elementi e il drag
|
|
Private m_bEnableEdit As Boolean = False
|
|
Public m_nIdPart As Integer = GDB_ID.NULL
|
|
Private m_nIdToSel As Integer = GDB_ID.NULL
|
|
Private m_nIdToDesel As Integer = GDB_ID.NULL
|
|
Private m_bDrag As Boolean = False
|
|
Private m_bRotate As Boolean = False
|
|
Private m_bDragToStart As Boolean = False
|
|
Private m_bDragging As Boolean = False
|
|
Private m_locPrev As System.Drawing.Point
|
|
Private m_ptPrev As Point3d
|
|
Private m_ptCen As Point3d
|
|
' Gestione rotazione pezzi in fase di Drag
|
|
Private m_bKeyCtrlPressed As Boolean = False
|
|
Private m_bKeyLeftShiftPressed As Boolean = False
|
|
Private m_dAngTotal As Double = 0
|
|
Private m_dStartAng As Double = 0
|
|
Private m_bStartRot As Boolean = False
|
|
Private m_bStartMove As Boolean = False
|
|
Private m_ptBeforeTrasf As New Point3d ' punto da salvare per poter condensare le operazioni di drag e rotate con terna in un'unica operazione
|
|
Private m_nRestRadius As Integer = GetMainPrivateProfileInt(S_NEST, K_RESTRADIUS, 3)
|
|
' variabili aggiuntive per spostamenti e rotazioni
|
|
Public m_dAngRot As Double = 0 ' ultimo angolo che è stato usato con il comando Rotate
|
|
Public m_bRotated As Boolean = False
|
|
Private m_dCorrection As Double = 0 ' correzione da applicare all'ultima operazione di drag/rotate per poter andare in battuta senza creare intersezioni
|
|
Private m_bPreview As Boolean = False ' boolean per indicare se è stata visualizzata la preview per il valore inserito nel comando move
|
|
Private m_ptPair As New Point3d ' punto scelto per l'accoppiamento
|
|
Public m_bFlippedParal As Boolean = False ' flag che indica se il pezzo che si sta cercando di accoppiare è stato flippato
|
|
Public m_bFlippedPerp As Boolean = False ' flag che indica se il pezzo che si sta cercando di accoppiare è stato flippato
|
|
Public m_nTransfNum As Integer = 0 ' numero di operazioni che è stato effettuato dall'inzio del pairing
|
|
|
|
' lista dei part selezionati per la creazione di un fondello a partire da delle paretine
|
|
Public m_PanelPartList As New List(Of Integer)
|
|
|
|
' gestione del move con inserimento a mano
|
|
Public m_bPreviewShown As Boolean = False
|
|
|
|
' Flag per distinguere tra Save a SaveAs
|
|
Private m_bIsSaveAs As Boolean = False
|
|
|
|
Private m_GridPanelVM As GridPanelVM
|
|
Friend ReadOnly Property GridPanelVM As GridPanelVM
|
|
Get
|
|
Return m_GridPanelVM
|
|
End Get
|
|
End Property
|
|
|
|
Friend m_bIsFocused As Boolean
|
|
Friend Sub SetIsFocused(bValue As Boolean)
|
|
m_bIsFocused = bValue
|
|
End Sub
|
|
|
|
' gestione del tempo
|
|
Public m_MaxTime As Integer = 50
|
|
Private m_nTime As Integer = -1
|
|
Public Property nTime As Integer
|
|
Get
|
|
Return m_nTime
|
|
End Get
|
|
Set(value As Integer)
|
|
If value < -1 Then Return
|
|
If value >= m_MaxTime Then Return
|
|
m_nTime = value
|
|
End Set
|
|
End Property
|
|
|
|
Public m_MaxTempTime As Integer = 100
|
|
Private m_nTempTime As Integer = -1
|
|
Public Property nTempTime As Integer
|
|
Get
|
|
Return m_nTempTime
|
|
End Get
|
|
Set(value As Integer)
|
|
m_nTempTime = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#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.OnInsertedProject, AddressOf OnInsertedProject
|
|
AddHandler MainController.OnImportingProject, AddressOf OnImportingProject
|
|
AddHandler MainController.OnImportedProject, AddressOf OnImportedProject
|
|
AddHandler MainController.UpdateUI, AddressOf UpdateUI
|
|
|
|
AssLogM.InitAssLog()
|
|
|
|
Map.SetRefSceneHostVM(Me)
|
|
|
|
' Creo GridPanel
|
|
m_GridPanelVM = New GridPanelVM
|
|
|
|
' riempio di valori null la lista degli elementi da tenere selezionati
|
|
ResetMarkedPartsList()
|
|
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()
|
|
' modo di visualizzazione
|
|
EgtSetView(VT.ISO_SE)
|
|
' Imposto stato gestione mouse diretto della scena a nessuno
|
|
MainScene.SetStatusNull()
|
|
'MainScene.SetStatusAnalyze() ' debug
|
|
EgtSetCurrentContext(MainScene.GetCtx())
|
|
Return
|
|
End If
|
|
' Problemi
|
|
' Se manca la chiave
|
|
If Map.refMainWindowVM.MainWindowM.nKeyLevel = -1 Or Map.refMainWindowVM.MainWindowM.nKeyLevel = -2 Then
|
|
EgtOutLog("Missing Dongle")
|
|
' Box di avviso chiave mancante : "Chiave non presente. \n Inserirla e riavviare il programma."
|
|
Dim sText As String = EgtMsg(10102) & vbCrLf & EgtMsg(10103)
|
|
Dim sTitle As String = EgtMsg(10101) ' Errore
|
|
EgtStone3D.EgtMessageBoxV.Show(Application.Current.MainWindow, sText, sTitle, MessageBoxButton.OK, MessageBoxImage.Error)
|
|
' Altrimenti manca la licenza
|
|
Else
|
|
EgtOutLog("Problems with Licence")
|
|
' Box di avviso licenza con problemi : "Programma senza licenza. \n Caricala e riavvia il programma."
|
|
Dim sText As String = EgtMsg(10105) & vbCrLf & EgtMsg(10106)
|
|
Dim sTitle As String = EgtMsg(10101) ' Errore
|
|
If EgtStone3D.EgtMessageBoxV.Show(Application.Current.MainWindow, sText, sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.OK Then
|
|
' Apro dialogo per richiesta file licenza
|
|
Dim LicDlg As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With {
|
|
.Title = EgtMsg(110026), ' Licenza
|
|
.Filter = "Licences (.lic)|*.lic",
|
|
.CheckFileExists = True,
|
|
.ValidateNames = True
|
|
}
|
|
If LicDlg.ShowDialog() = Windows.Forms.DialogResult.OK 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.OnMouseMoveScene, AddressOf OnMouseMoveScene
|
|
AddHandler MainScene.OnMouseDownScene, AddressOf OnMouseDownScene
|
|
AddHandler MainScene.OnMouseUpScene, AddressOf OnMouseUpScene
|
|
AddHandler MainScene.KeyDown, AddressOf ShiftKey_Down
|
|
AddHandler MainScene.KeyUp, AddressOf ShiftKey_Up
|
|
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(0, 123, 167)
|
|
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(0.05)
|
|
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 bGridVisibility As Boolean = (GetMainPrivateProfileInt(S_GRID, K_SHOWGRID, 1) <> 0)
|
|
Dim dSnapStepMm As Double = GetMainPrivateProfileDouble(S_GRID, K_SNAPSTEP, 10)
|
|
Dim dSnapStepInch As Double = GetMainPrivateProfileDouble(S_GRID, K_SNAPSTEPINCH, 10)
|
|
Dim nMinLineSStep As Integer = GetMainPrivateProfileInt(S_GRID, K_MINLINESSTEP, 1)
|
|
Dim nMajLineSStep As Integer = GetMainPrivateProfileInt(S_GRID, K_MAJLINESSTEP, 10)
|
|
Dim nExtSStep As Integer = GetMainPrivateProfileInt(S_GRID, K_EXTSSTEP, 50)
|
|
Dim MinLnColor As New Color3d(160, 160, 160)
|
|
GetMainPrivateProfileColor(S_GRID, K_MINLNCOLOR, MinLnColor)
|
|
Dim MajLnColor As New Color3d(160, 160, 160)
|
|
GetMainPrivateProfileColor(S_GRID, K_MAJLNCOLOR, MajLnColor)
|
|
EgtSetGridFrame(Frame3d.GLOB)
|
|
If bMmUnits Then
|
|
EgtSetGridGeo(dSnapStepMm, nMinLineSStep, nMajLineSStep, nExtSStep)
|
|
Else
|
|
EgtSetGridGeo(dSnapStepInch, nMinLineSStep, nMajLineSStep, nExtSStep)
|
|
End If
|
|
EgtSetGridColor(MinLnColor, MajLnColor)
|
|
EgtSetGridShow(bGridVisibility, 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)
|
|
' visualizzazione griglia
|
|
OptionModule.m_bShowGridFrame = (GetMainPrivateProfileInt(S_GRID, K_SHOWFRAME, 1) <> 0)
|
|
OptionModule.m_bGridState = GetMainPrivateProfileInt(S_GENERAL, K_GRIDSTATE, 1)
|
|
Map.refGridPanelVM.UpdateStatusGrid(OptionModule.m_bGridState, OptionModule.m_bShowGridFrame)
|
|
' imposto unità di misura per interfaccia utente
|
|
OptionModule.m_bMmUnits = (GetMainPrivateProfileInt(S_SCENE, K_MMUNITS, 1) <> 0)
|
|
Map.refGridPanelVM.UpdateStatusUnits(OptionModule.m_bMmUnits)
|
|
End Sub
|
|
|
|
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 EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With {
|
|
.Title = EgtMsg(110015), ' Apri
|
|
.Filter = "nge files (*.nge)|*.nge" &
|
|
"|vme files (*.vme)|*.vme",
|
|
.FileName = "New.vme",
|
|
.FilterIndex = 2,
|
|
.InitialDirectory = sDir,
|
|
.Mode = 1
|
|
}
|
|
If Not OpenFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then Return False
|
|
sFilePath = OpenFileDialog.FileName
|
|
End If
|
|
bOk = OpenProj(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
|
|
If Path.GetExtension(sCurrFile) = ".wme" Then
|
|
EgtSetCurrFilePath(sCurrFile)
|
|
Else
|
|
EgtSetCurrFilePath(sCurrFile)
|
|
End If
|
|
' Salvataggio standard
|
|
bOk = MainController.SaveProject()
|
|
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 = ""
|
|
Dim sFileName As String = ""
|
|
EgtGetCurrFilePath(sFile)
|
|
Dim bOk As Boolean = False
|
|
' Se nome vuoto, assegno "New"
|
|
If String.IsNullOrWhiteSpace(sFile) Then sFile = "New.vme"
|
|
' Eventuale sistemazione estensione
|
|
sFile = IO.Path.ChangeExtension(sFile, "vme")
|
|
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
|
|
' Assegnazione nome file con dialogo
|
|
Dim SaveFileDialog As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With {
|
|
.Title = EgtMsg(110013), ' Salva
|
|
.Filter = "New geometry EgalTech(*.nge)|*.nge" &
|
|
"|vme files (*.vme)|*.vme",
|
|
.FileName = sFile,
|
|
.FilterIndex = 2,
|
|
.InitialDirectory = sDir,
|
|
.ValidateNames = False,
|
|
.OverwritePrompt = True,
|
|
.Mode = 1
|
|
}
|
|
If SaveFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
|
|
If Path.GetExtension(SaveFileDialog.SafeFileName).Equals(String.Empty) Then
|
|
sFileName = SaveFileDialog.InitialDirectory & "\" & SaveFileDialog.SafeFileName & SaveFileDialog.SelFilter.sExstension.Trim("*"c)
|
|
Else
|
|
sFileName = SaveFileDialog.InitialDirectory & "\" & SaveFileDialog.SafeFileName
|
|
End If
|
|
EgtSetCurrFilePath(sFileName)
|
|
' Salvataggio standard
|
|
bOk = MainController.SaveProject()
|
|
End If
|
|
m_bIsSaveAs = False
|
|
' Salvo nome ultimo file
|
|
WriteMainPrivateProfileString(S_GENERAL, K_LASTPROJ, sFile)
|
|
' Imposto stato gestione mouse diretto della scena a nessuno
|
|
MainScene.SetStatusNull()
|
|
Return bOk
|
|
End Function
|
|
|
|
Public Function ManageModified() As Boolean
|
|
' If not modified, proceed normally
|
|
If Not MainController.GetModified() Then
|
|
Return True
|
|
End If
|
|
|
|
' Ask what to do
|
|
Dim sMsg As String = "Save changes"
|
|
Dim sCurrFile As String = MainController.GetCurrFile()
|
|
If Not String.IsNullOrEmpty(sCurrFile) Then
|
|
sMsg += " to " & sCurrFile
|
|
End If
|
|
sMsg += " ?"
|
|
|
|
Dim nRes As DialogResult = EgtMessageBoxV.Show(Application.Current.MainWindow, sMsg, "", MessageBoxButtons.YesNoCancel, MessageBoxImage.Question)
|
|
Select Case nRes
|
|
Case DialogResult.Yes
|
|
SaveProject()
|
|
Return True
|
|
Case DialogResult.No
|
|
Return True
|
|
Case Else
|
|
Return False
|
|
End Select
|
|
End Function
|
|
|
|
Public Function OpenProj(Optional sDir As String = "", Optional bWithDlg As Boolean = True) As Boolean
|
|
' Manage current modified file
|
|
If Not ManageModified() Then Return False
|
|
' Reset controller and scene
|
|
MainController.ResetStatus(False)
|
|
' Execute
|
|
Dim sFile As String = sDir
|
|
' File selection with dialog
|
|
If bWithDlg Then
|
|
Dim OpenFileDialog As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With {
|
|
.Title = "Open",
|
|
.Filter = "New geometry EgalTech(.nge)|*.nge" &
|
|
"|New font EgalTech(.nfe)|*.nfe" &
|
|
"|All Files (*.*)|*.*",
|
|
.FilterIndex = 1,
|
|
.InitialDirectory = sDir
|
|
}
|
|
If Not OpenFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then Return False
|
|
sFile = OpenFileDialog.FileName
|
|
End If
|
|
' Before loading
|
|
RaiseEvent OnOpeningProject(Me)
|
|
' Project loading
|
|
Cursor.Current = Cursors.WaitCursor
|
|
EgtEnableCommandLogger()
|
|
Dim bOk As Boolean = EgtOpenFile(sFile)
|
|
EgtDisableCommandLogger()
|
|
' Update
|
|
UpdateUI(Me, True)
|
|
Cursor.Current = Cursors.Default
|
|
' Result handling
|
|
Map.refSceneHostVM.OnOpenProject(Me, sFile, bOk)
|
|
Return bOk
|
|
End Function
|
|
|
|
|
|
Public Function SaveProj(sCurrFile As String, Optional nType As NGE = NGE.CMPTEXT) As Boolean
|
|
If String.IsNullOrWhiteSpace(sCurrFile) Or EgtGetFileType(sCurrFile) <> FT.LUA Then
|
|
Return SaveAsProject()
|
|
Else
|
|
' Reset controller and scene
|
|
MainController.ResetStatus(False)
|
|
' Before saving
|
|
OnSavingProject(Me, sCurrFile)
|
|
' Project saving
|
|
Cursor.Current = Cursors.WaitCursor
|
|
EgtEnableCommandLogger()
|
|
Dim bOk As Boolean = EgtSaveFile(sCurrFile, nType)
|
|
EgtDisableCommandLogger()
|
|
' Update
|
|
UpdateUI(Me, False)
|
|
Cursor.Current = Cursors.Default
|
|
' Result handling
|
|
Map.refSceneHostVM.OnSavedProject(Me, sCurrFile, bOk)
|
|
Return bOk
|
|
End If
|
|
End Function
|
|
|
|
Friend Sub StatusUnitsCommand()
|
|
OptionModule.m_bMmUnits = Not OptionModule.m_bMmUnits
|
|
Map.refGridPanelVM.UpdateStatusUnits(OptionModule.m_bMmUnits)
|
|
UpdateGridData()
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub UpdateGridData()
|
|
If OptionModule.m_bMmUnits Then
|
|
EgtSetGridGeo(OptionModule.m_dSnapStepMm, OptionModule.m_nMinLineSStep, OptionModule.m_nMajLineSStep, OptionModule.m_nExtSStep)
|
|
Else
|
|
EgtSetGridGeo(OptionModule.m_dSnapStepInch, OptionModule.m_nMinLineSStep, OptionModule.m_nMajLineSStep, OptionModule.m_nExtSStep)
|
|
End If
|
|
EgtSetGridColor(OptionModule.m_MinLnColor, OptionModule.m_MajLnColor)
|
|
End Sub
|
|
|
|
Friend Sub ResetMarkedPartsList()
|
|
m_MarkedPartsList.Clear()
|
|
For i As Integer = 0 To 3
|
|
m_MarkedPartsList.Add(GDB_ID.NULL)
|
|
Next
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
#Region "EVENTS"
|
|
|
|
Private Sub OnNewProject(sender As Object, bOk As Boolean)
|
|
EgtErase(EgtGetFirstPart())
|
|
If Not bOk Then
|
|
' Errore nella creazione di un nuovo file Errore
|
|
EgtStone3D.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(10002), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
End If
|
|
EgtZoom(ZM.ALL)
|
|
MainScene.SetStatusNull()
|
|
End Sub
|
|
|
|
Private Sub OnOpenProject(sender As Object, sFile As String, bOk As Boolean)
|
|
EgtZoom(ZM.ALL)
|
|
WriteMainPrivateProfileString(S_GENERAL, K_LASTNGEDIR, Path.GetDirectoryName(sFile))
|
|
WriteMainPrivateProfileString(S_GENERAL, K_LASTPROJ, sFile)
|
|
If bOk Then
|
|
Map.refTopPanelVM.MruFiles.Add(sFile)
|
|
Else
|
|
Map.refTopPanelVM.MruFiles.Remove(sFile)
|
|
Dim sMsg As String
|
|
If My.Computer.FileSystem.FileExists(sFile) Then
|
|
sMsg = EgtMsg(10003) & " '" & sFile & "'" ' Errore nell'apertura del file
|
|
Else
|
|
sMsg = EgtMsg(10009) & " '" & sFile & "'" ' Non esiste il file
|
|
End If
|
|
' Errore
|
|
EgtStone3D.EgtMessageBoxV.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
End If
|
|
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.refTopPanelVM.MruFiles.Add(sFile)
|
|
Else
|
|
Map.refTopPanelVM.MruFiles.Remove(sFile)
|
|
Dim sMsg As String = EgtMsg(10004) & " '" & sFile & "'" ' Errore nel salvataggio del file
|
|
' Errore
|
|
EgtStone3D.EgtMessageBoxV.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
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 & "'" ' Errore nell'importazione del file
|
|
' Errore
|
|
EgtStone3D.EgtMessageBoxV.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
End If
|
|
Map.refTopPanelVM.MruImportFiles.Add(sFile)
|
|
EgtSetInfo(EgtGetLastPart(), FILE_PATH, sFile)
|
|
EgtDraw()
|
|
MainScene.SetStatusNull()
|
|
End Sub
|
|
|
|
Private Sub OnImportingProject(sender As Object, nType As Integer, ByRef nFlag As Integer)
|
|
If nType <> FT.NULL Then
|
|
If nType = FT.CNC Then
|
|
nFlag = GetMainPrivateProfileInt(S_IMPORT, K_CNCFLAG, EIC_FL.NONE)
|
|
Else
|
|
nFlag = 0
|
|
End If
|
|
Else
|
|
' Tipo di file sconosciuto Errore
|
|
EgtStone3D.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(10005), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' File type unknown - Error
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnImportedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean)
|
|
EgtZoom(ZM.ALL)
|
|
' Salvo path
|
|
WriteMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, Path.GetDirectoryName(sFile))
|
|
' Segnalo eventuale errore
|
|
If Not bOk Then
|
|
Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" ' Errore nell'importazione del file
|
|
' Errore
|
|
EgtStone3D.EgtMessageBoxV.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error
|
|
End If
|
|
MainScene.SetStatusNull()
|
|
End Sub
|
|
|
|
Private Sub UpdateUI(ByVal sender As Object, ByVal bReloadUI As Boolean)
|
|
Map.refSecondaryWindowVM.UpdateTitle()
|
|
Map.refOptionWindowVM.UpdateAllMessages()
|
|
End Sub
|
|
|
|
Private Sub OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
|
|
OnMouseOver(sender, e, m_SelType)
|
|
' Se drag non abilitato o già in esecuzione, esco
|
|
If Not m_bDrag Or m_bDragging Then Return
|
|
' Determino cosa muovere
|
|
'Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL)
|
|
Dim PartSolidSel As PartSolidM = GetPartSolid(m_nIdPart)
|
|
If IsNothing(PartSolidSel) Then Return
|
|
Dim nMoveId = PartSolidSel.SolidId
|
|
' 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
|
|
'If m_bRotate Then
|
|
' 'If Not EgtGetPartPartClusterCenterGlob(nMoveId, m_ptCen) Then Return
|
|
'End If
|
|
m_bDragToStart = False
|
|
End If
|
|
' Inizio esecuzione di drag
|
|
m_bDragging = True
|
|
' Ricavo il punto corrente in coordinate mondo
|
|
Dim ptCurr As Point3d
|
|
EgtUnProjectPoint(e.Location, ptCurr)
|
|
' Se traslazione
|
|
If Not m_bRotate Then
|
|
' Ricavo il vettore di movimento
|
|
Dim vtMove As Vector3d = ptCurr - m_ptPrev
|
|
' Eseguo il movimento
|
|
If vtMove.SqLen() > EPS_SMALL * EPS_SMALL Then
|
|
Move(m_nIdPart, PartSolidSel.vtDrag * (PartSolidSel.vtDrag * vtMove), False, True)
|
|
'If TgBtn_Inters.IsChecked Then
|
|
' Dim vInters As ObservableCollection(Of PartSolidM) = CalcInters(PartSolidSel.PartSolidId)
|
|
' If vInters.Count() <> 1 Then
|
|
' m_bDrag = False
|
|
' Dim dCorr As Double = 0.0
|
|
' SolidManagerM.MaxApproach(PartSolidSel, dCorr, vInters)
|
|
' m_dCorrection = dCorr
|
|
' End If
|
|
'End If
|
|
'VeinMatching.SetProjectModified()
|
|
EgtDraw()
|
|
End If
|
|
' altrimenti rotazione
|
|
Else
|
|
' Ricavo l'angolo di movimento
|
|
m_ptCen = PartSolidSel.Center()
|
|
Dim vtPrev As Vector3d = m_ptPrev - m_ptCen
|
|
Dim vtCurr As Vector3d = ptCurr - m_ptCen
|
|
'MyMsgTxBl.Text = String.Format("{0:00.00}", vtCurr.z)
|
|
Dim dAngRotDeg As Double = Math.Atan2(Vector3d.CrossXY(vtPrev, vtCurr), Vector3d.ScalarXY(vtPrev, vtCurr)) * 180.0 / Math.PI
|
|
If Math.Abs(dAngRotDeg) > EPS_ANG_SMALL Then
|
|
Rotate(m_nIdPart, m_ptCen, PartSolidSel.vtDrag, dAngRotDeg, False)
|
|
' qui inserisco il controllo sull'intersezione ed eventulamente il passo indietro con MaxApproach
|
|
'If TgBtn_Inters.IsChecked Then
|
|
' Dim vInters As ObservableCollection(Of PartSolidM) = CalcInters(PartSolidSel.PartSolidId)
|
|
' If vInters.Count() <> 1 Then
|
|
' m_bDrag = False
|
|
' Dim dCorr As Double = 0.0
|
|
' MaxApproach(PartSolidSel, dCorr, vInters)
|
|
' m_dCorrection = dCorr
|
|
' End If
|
|
'End If
|
|
'VeinMatching.SetProjectModified()
|
|
EgtDraw()
|
|
End If
|
|
End If
|
|
' Aggiorno il punto precedente
|
|
m_ptPrev = ptCurr
|
|
' Terminata esecuzione di drag
|
|
m_bDragging = False
|
|
End Sub
|
|
|
|
Private Sub OnMouseOver(sender As Object, e As Windows.Forms.MouseEventArgs, Optional IdType As GDB_TY = GDB_TY.CRV_LINE)
|
|
' Eseguo selezione
|
|
EgtSetObjFilterForSelWin(True, True, True, True, True)
|
|
Dim nSel As Integer
|
|
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
|
|
' Ricavo la prima enità selezionata
|
|
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
|
While nId <> GDB_ID.NULL
|
|
' riconosco il tipo di entità
|
|
Dim bCanResetPreviousMark As Boolean = (m_MarkedPartsList.FirstOrDefault(Function(x) x = m_nIdMouseOverSel) = 0)
|
|
Dim sNameLay As String = String.Empty
|
|
EgtGetName(EgtGetParent(nId), sNameLay)
|
|
' se sono attivi i bottoni AddSplashTop o AddWaterfall, posso evidenziare solo i lati dell'OUTLOOP
|
|
Dim bParetinaApproved As Boolean = (Map.refSceneButtonVM.IsTgBtnChecked("AddPanel") And
|
|
(((IdType = GDB_TY.CRV_LINE And (sNameLay = OUTLOOP Or sNameLay = INLOOP)) Or IdType = GDB_TY.SRF_MESH))) Or
|
|
(Not Map.refSceneButtonVM.IsTgBtnChecked("AddPanel"))
|
|
If EgtGetType(nId) = IdType Then
|
|
If nId <> m_nIdMouseOverSel And
|
|
(m_MarkedPartsList.FirstOrDefault(Function(x) x = nId) = 0) And
|
|
((m_nIdMouseOverSel <> GDB_ID.NULL And bCanResetPreviousMark) Or m_nIdMouseOverSel = GDB_ID.NULL) And
|
|
bParetinaApproved Then
|
|
EgtResetMark(m_nIdMouseOverSel)
|
|
EgtSetAlpha(m_nIdMouseOverSel, m_nAlphaTransparent)
|
|
' recupero info colore/trasparenza oggetto
|
|
Dim Color3D_ As Color3d
|
|
EgtGetColor(nId, Color3D_)
|
|
' se prima selezione, allora salvo il valore di trasparenza
|
|
If m_nIdMouseOverSel <> nId Then m_nAlphaTransparent = Color3D_.A
|
|
' Selezione oggetto
|
|
EgtSetAlpha(nId, 100)
|
|
EgtSetMark(nId)
|
|
m_nIdMouseOverSel = nId
|
|
End If
|
|
Exit While
|
|
End If
|
|
' Passo al successivo
|
|
nId = EgtGetNextObjInSelWin()
|
|
End While
|
|
If nId = GDB_ID.NULL And m_nIdMouseOverSel <> GDB_ID.NULL Then
|
|
If (m_MarkedPartsList.FirstOrDefault(Function(x) x = m_nIdMouseOverSel) = 0) Then
|
|
EgtResetMark(m_nIdMouseOverSel)
|
|
EgtSetAlpha(m_nIdMouseOverSel, m_nAlphaTransparent)
|
|
End If
|
|
m_nIdMouseOverSel = GDB_ID.NULL
|
|
End If
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs)
|
|
If e.Button = Windows.Forms.MouseButtons.Right Then
|
|
Map.refSceneButtonV.MenuSelType.IsOpen = Not Map.refSceneButtonV.MenuSelType.IsOpen
|
|
Return
|
|
End If
|
|
If e.Button = Windows.Forms.MouseButtons.Left Then
|
|
Map.refSceneButtonV.MenuSelType.IsOpen = False
|
|
End If
|
|
' Per default no drag
|
|
m_bDrag = False
|
|
m_bRotate = False
|
|
' Si può selezionare solo con il tasto sinistro e se non stato NULL
|
|
If e.Button <> Windows.Forms.MouseButtons.Left Or Not MainScene.IsStatusNull() Then Return
|
|
' Eseguo selezione
|
|
EgtSetObjFilterForSelWin(True, True, True, True, True)
|
|
Dim nSel As Integer
|
|
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
|
|
' Ricavo nome dell'entità selezionata e identificativo
|
|
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
|
While nId <> GDB_ID.NULL
|
|
' Cerco l'identificativo del pezzo cui appartiene
|
|
Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
|
|
Dim sName As String = String.Empty
|
|
EgtGetName(nPartId, sName)
|
|
If sName = TERNA Then
|
|
Dim sNameAx As String = String.Empty
|
|
EgtGetName(EgtGetParent(nId), sNameAx)
|
|
Dim PartSolidIdTempSel As PartSolidM = GetPartSolid(m_nIdPart)
|
|
If IsNothing(PartSolidIdTempSel) Then Return
|
|
'PartSolidIdTempSel.Unpair()
|
|
Select Case sNameAx
|
|
Case EGT_X
|
|
Dim vtDir As New Vector3d
|
|
Dim nLay As Integer = EgtGetFirstNameInGroup(PartSolidIdTempSel.TernaId, "AxisX")
|
|
EgtStartVector(EgtGetFirstInGroup(nLay), GDB_RT.GLOB, vtDir)
|
|
PartSolidIdTempSel.vtDrag = vtDir
|
|
m_bDrag = True
|
|
'wnd_RotationInputDataV.Testo.Text = "α°"
|
|
Case EGT_Y
|
|
Dim vtDir As New Vector3d
|
|
Dim nLay As Integer = EgtGetFirstNameInGroup(PartSolidIdTempSel.TernaId, "AxisY")
|
|
EgtStartVector(EgtGetFirstInGroup(nLay), GDB_RT.GLOB, vtDir)
|
|
PartSolidIdTempSel.vtDrag = vtDir
|
|
m_bDrag = True
|
|
'wnd_RotationInputDataV.Testo.Text = "𝛃°"
|
|
Case EGT_Z
|
|
Dim vtDir As New Vector3d
|
|
Dim nLay As Integer = EgtGetFirstNameInGroup(PartSolidIdTempSel.TernaId, "AxisZ")
|
|
EgtStartVector(EgtGetFirstInGroup(nLay), GDB_RT.GLOB, vtDir)
|
|
PartSolidIdTempSel.vtDrag = vtDir
|
|
m_bDrag = True
|
|
'wnd_RotationInputDataV.Testo.Text = "𝛄°"
|
|
Case EGT_XY, EGT_YX
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) > 0 Then
|
|
PartSolidIdTempSel.vtDrag = Vector3d.Z_AX
|
|
m_bDrag = True
|
|
m_bRotate = True
|
|
'wnd_RotationInputDataV.Testo.Text = "𝛄°"
|
|
Else
|
|
' Passo al successivo
|
|
nId = EgtGetNextObjInSelWin()
|
|
Continue While
|
|
End If
|
|
Case EGT_YZ, EGT_ZY
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) > 0 Then
|
|
PartSolidIdTempSel.vtDrag = Vector3d.X_AX
|
|
m_bDrag = True
|
|
m_bRotate = True
|
|
'wnd_RotationInputDataV.Testo.Text = "α°"
|
|
Else
|
|
' Passo al successivo
|
|
nId = EgtGetNextObjInSelWin()
|
|
Continue While
|
|
End If
|
|
Case EGT_ZX, EGT_XZ
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) > 0 Then
|
|
PartSolidIdTempSel.vtDrag = Vector3d.Y_AX
|
|
m_bDrag = True
|
|
m_bRotate = True
|
|
'wnd_RotationInputDataV.Testo.Text = "𝛃°"
|
|
Else
|
|
' Passo al successivo
|
|
nId = EgtGetNextObjInSelWin()
|
|
Continue While
|
|
End If
|
|
' sennò procedo ad esseguire la rotazione attorno al segmento selezionato...
|
|
Case AXISX
|
|
'wnd_RotationInputDataV.Testo.Text = "α°"
|
|
GoTo Line1
|
|
Case AXISY
|
|
'wnd_RotationInputDataV.Testo.Text = "𝛃°"
|
|
GoTo Line1
|
|
Case AXISZ
|
|
'wnd_RotationInputDataV.Testo.Text = "𝛄°"
|
|
GoTo Line1
|
|
Case Else
|
|
|
|
End Select
|
|
m_bDragToStart = True
|
|
m_locPrev = e.Location
|
|
m_bDrag = m_bDrag AndAlso EgtUnProjectPoint(e.Location, m_ptPrev)
|
|
'salvo il punto di inizio del drag per poter salvare l'operazione di drag come un'unica operazione, al momento del mouseUp
|
|
If m_bDrag Then m_ptBeforeTrasf = m_ptPrev
|
|
Exit While
|
|
End If
|
|
|
|
If Not EgtIsPart(nPartId) Then
|
|
' Passo al successivo
|
|
nId = EgtGetNextObjInSelWin()
|
|
Continue While
|
|
End If
|
|
|
|
Line1:
|
|
' rotazione attiva
|
|
|
|
If Map.refSceneButtonVM.IsTgBtnChecked(EGT_ROTATE) Then
|
|
Dim RotateVM As RotateVM = DirectCast(Map.refSceneButtonVM.m_RotateUC.DataContext, RotateVM)
|
|
If RotateVM.AtStage() = RotateStage.SelectAxis Then
|
|
' se non identificato un part da ruotare aggiorno l'id
|
|
If m_nIdPart = -1 Then
|
|
m_nIdPart = nPartId
|
|
' se avevo identificato un part da ruotare, ma ne ho identificato uno nuovo e non ho selezioni attive allora cambio id
|
|
ElseIf m_nIdPart <> -1 And m_nIdPart <> nPartId And Not IsAPartSelected() Then
|
|
Dim PartSolidIdSel As PartSolidM = GetPartSolid(m_nIdPart)
|
|
If IsNothing(PartSolidIdSel) Then Return
|
|
PartSolidIdSel.ResetData()
|
|
m_nIdPart = nPartId
|
|
End If
|
|
Dim PartSolidIdTempSel As PartSolidM = GetPartSolid(m_nIdPart)
|
|
If IsNothing(PartSolidIdTempSel) Then Return
|
|
If EgtGetType(nId) = GDB_TY.CRV_LINE And PartSolidIdTempSel.nIdLineAxisRotate = -1 Then
|
|
PartSolidIdTempSel.nIdLineAxisRotate = nId
|
|
EgtSetMark(nId)
|
|
m_MarkedPartsList(0) = nId
|
|
' se trovo già un valore scritto nella casella di testo allora ruoto subito il part attorno all'asse indicato
|
|
RotateVM.bAxisSelected = True
|
|
RotateVM.AngText_Changed()
|
|
Return
|
|
ElseIf EgtGetType(nId) = GDB_TY.CRV_LINE And PartSolidIdTempSel.nIdLineAxisRotate <> -1 Then
|
|
EgtResetMark(PartSolidIdTempSel.nIdLineAxisRotate)
|
|
PartSolidIdTempSel.nIdLineAxisRotate = nId
|
|
EgtSetMark(nId)
|
|
m_MarkedPartsList(0) = nId
|
|
' se trovo già un valore scritto nella casella di testo allora ruoto subito il part attorno all'asse indicato
|
|
RotateVM.bAxisSelected = True
|
|
RotateVM.AngText_Changed()
|
|
End If
|
|
' Passo al successivo
|
|
nId = EgtGetNextObjInSelWin()
|
|
Continue While
|
|
End If
|
|
End If
|
|
|
|
''misura
|
|
'If TgBtn_Measure.IsChecked Then
|
|
' If m_nIdPart = GDB_ID.NULL Then
|
|
' m_nIdPart = nPartId
|
|
' End If
|
|
' If EgtGetType(nId) = GDB_TY.CRV_LINE Then
|
|
' Dim PartSolidIdTempSel As PartSolid = GetPartSolid(m_nIdPart)
|
|
' If IsNothing(PartSolidIdTempSel) Then Return
|
|
' If PartSolidIdTempSel.nIdLineFirst <> -1 Then
|
|
' EgtResetMark(PartSolidIdTempSel.nIdLineFirst)
|
|
' End If
|
|
' EgtSetMark(nId)
|
|
' m_nIdMarked1 = nId
|
|
' PartSolidIdTempSel.nIdLineFirst = nId
|
|
' MyMsgTxBl.Text = MeasureOption.SelectedItem.ToString & ": " & PartSolidIdTempSel.GetLineInfo(MeasureOption.SelectedIndex)
|
|
' Return
|
|
' End If
|
|
' nId = EgtGetNextObjInSelWin()
|
|
' Continue While
|
|
'End If
|
|
|
|
' kiss kiss
|
|
If Map.refSceneButtonVM.IsTgBtnChecked(EGT_PAIR) Then
|
|
If m_nIdPart = -1 Then
|
|
m_nIdPart = nPartId
|
|
End If
|
|
Dim PartSolidIdTempSel As PartSolidM = GetPartSolid(m_nIdPart)
|
|
If IsNothing(PartSolidIdTempSel) Then Return
|
|
Dim PartSolidIdTempSel2 As PartSolidM = GetPartSolid(EgtGetParent(EgtGetParent(PartSolidIdTempSel.nIdLineSecond)))
|
|
Dim PartSolidIdTempSelNew As PartSolidM = GetPartSolid(nPartId)
|
|
Dim PairUC As PairVM = DirectCast(Map.refSceneButtonVM.m_PairUC.DataContext, PairVM)
|
|
If EgtGetType(nId) = GDB_TY.CRV_LINE And PartSolidIdTempSel.nIdLineFirst = -1 Then
|
|
PartSolidIdTempSel.nIdLineFirst = nId
|
|
EgtSetMark(nId)
|
|
m_MarkedPartsList(0) = nId
|
|
PairUC.AdvanceStage()
|
|
Return
|
|
' impongo anche che il secondo lato appartenga ad un solid diverso dal primo selezionato
|
|
ElseIf EgtGetType(nId) = GDB_TY.CRV_LINE And PartSolidIdTempSel.nIdLineSecond = -1 And
|
|
nPartId <> PartSolidIdTempSel.PartId And nPartId <> PartSolidIdTempSel.PartSolidId Then
|
|
PairUC.AdvanceStage()
|
|
PartSolidIdTempSel.nIdLineSecond = nId
|
|
EgtSetMark(nId)
|
|
m_MarkedPartsList(1) = nId
|
|
PairUC.PairParts()
|
|
Return
|
|
' impongo anche che il secondo lato appartenga ad un solid diverso dal primo selezionato
|
|
ElseIf EgtGetType(nId) = GDB_TY.CRV_LINE And PartSolidIdTempSel.nIdLineSecond <> -1 And
|
|
nPartId <> PartSolidIdTempSel.PartId And nPartId <> PartSolidIdTempSel.PartSolidId Then
|
|
'MyMsgTxBl.Text = "Modifica le impostazioni di accoppiamento e conferma oppura annulla l'accoppiamento" & vbCrLf &
|
|
' "tenendo premuto SHIFT puoi anche selezionare per ogni Part una faccia adiacente ai due lati accoppiati, per farle coincidere"
|
|
EgtResetMark(PartSolidIdTempSel.nIdLineSecond)
|
|
EgtSetMark(nId)
|
|
m_MarkedPartsList(1) = nId
|
|
PartSolidIdTempSel.nIdLineSecond = nId
|
|
PairUC.PairParts()
|
|
Return
|
|
' impongo che la prima faccia appartenga al primo solido selezionato
|
|
ElseIf (ModifierKeys.Shift And Keyboard.Modifiers) > 0 And EgtGetType(nId) = GDB_TY.SRF_FRGN And
|
|
PartSolidIdTempSelNew.PartSolidId = PartSolidIdTempSel.PartSolidId Then
|
|
PartSolidIdTempSel.nIdSurfFirst = nId
|
|
If m_MarkedPartsList.Count > 2 Then
|
|
EgtResetMark(m_MarkedPartsList(2))
|
|
EgtSetAlpha(m_MarkedPartsList(2), m_nAlphaTransparent1)
|
|
End If
|
|
m_MarkedPartsList(2) = nId
|
|
' salvo il valore di trasparenza
|
|
m_nAlphaTransparent1 = m_nAlphaTransparent
|
|
'EgtSurfFrNormVersor(nId, GDB_ID.ROOT, PartSolidIdTempSel.vtNormFirst)
|
|
EgtSetMark(nId)
|
|
Return
|
|
' impongo che la seconda faccia appartenga ad un solido diverso dal primo selezionato
|
|
ElseIf (ModifierKeys.Shift And Keyboard.Modifiers) > 0 And EgtGetType(nId) = GDB_TY.SRF_FRGN And
|
|
PartSolidIdTempSel.nIdLineSecond <> GDB_ID.NULL And PartSolidIdTempSel.nIdSurfFirst <> GDB_ID.NULL Then
|
|
If PartSolidIdTempSel2.PartSolidId = PartSolidIdTempSel.PartSolidId Then
|
|
'MyMsgTxBl.Text = "Devi selezionare una faccia appartente ad un altro pezzo"
|
|
Return
|
|
End If
|
|
If PartSolidIdTempSelNew.PartSolidId <> PartSolidIdTempSel2.PartSolidId Then
|
|
'MyMsgTxBl.Text = "Devi selezionare una faccia appartente al pezzo del secondo edge selezionato"
|
|
Return
|
|
End If
|
|
'EgtSurfFrNormVersor(nId, GDB_ID.ROOT, PartSolidIdTempSel.vtNormSecond)
|
|
EgtResetMark(PartSolidIdTempSel.nIdSurfSecond)
|
|
PartSolidIdTempSel.nIdSurfSecond = nId
|
|
If m_MarkedPartsList.Count > 3 Then
|
|
EgtResetMark(m_MarkedPartsList(3))
|
|
EgtSetAlpha(m_MarkedPartsList(3), m_nAlphaTransparent2)
|
|
End If
|
|
m_MarkedPartsList(3) = nId
|
|
' salvo il valore di trasparenza
|
|
m_nAlphaTransparent2 = m_nAlphaTransparent
|
|
EgtSetMark(nId)
|
|
FacePair(m_nIdPart, m_nTransfNum)
|
|
Return
|
|
End If
|
|
' Passo al successivo
|
|
nId = EgtGetNextObjInSelWin()
|
|
Continue While
|
|
End If
|
|
|
|
If Map.refSceneButtonVM.IsTgBtnChecked(EGT_PANEL) Then
|
|
Dim sPanelType = DirectCast(Map.refSceneButtonVM.m_NewPanelUC.DataContext, NewPanelVM).GetPanelType()
|
|
If sPanelType = "Alzatina" Or sPanelType = "Frontalino" Or sPanelType = "Tappa Buca" Then
|
|
If EgtGetType(nId) = GDB_TY.CRV_LINE Then
|
|
Dim sLayName As String = String.Empty
|
|
EgtGetName(EgtGetParent(nId), sLayName)
|
|
If sPanelType = "Alzatina" Or sPanelType = "Frontalino" Or (sPanelType = "Tappa Buca" And sLayName = "InLoop") Then
|
|
Dim sEdgeName As String = String.Empty
|
|
EgtGetName(nId, sEdgeName)
|
|
If sEdgeName.Length > 0 Then
|
|
If sEdgeName(0) = "A" Then
|
|
SceneCmd.AddPanel(nId)
|
|
Return
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
ElseIf sPanelType = "SplitBottom" Then
|
|
Dim nPanelPart As Integer = nPartId
|
|
If sName = "SOLID" Then
|
|
EgtGetInfo(nPartId, "Parent", nPanelPart)
|
|
End If
|
|
If m_PanelPartList.FirstOrDefault(Function(x) x = nPanelPart) = 0 Then
|
|
m_PanelPartList.Add(nPanelPart)
|
|
Dim nChild As Integer = GDB_ID.NULL
|
|
EgtGetInfo(nPanelPart, "Child", nChild)
|
|
EgtSetMark(nChild)
|
|
m_MarkedPartsList.Add(nChild)
|
|
Else
|
|
m_PanelPartList.Remove(nPanelPart)
|
|
Dim nChild As Integer = GDB_ID.NULL
|
|
EgtGetInfo(nPanelPart, "Child", nChild)
|
|
EgtResetMark(nChild)
|
|
m_MarkedPartsList.Remove(nChild)
|
|
End If
|
|
End If
|
|
nId = EgtGetNextObjInSelWin()
|
|
Continue While
|
|
End If
|
|
|
|
If Map.refSceneButtonVM.IsTgBtnChecked(EGT_EDIT_PANEL) Then
|
|
Dim PartSolidId As Integer = nPartId
|
|
If sName = "SOLID" Then EgtGetInfo(nPartId, "Parent", PartSolidId)
|
|
DirectCast(Map.refSceneButtonVM.m_EditPanelUC.DataContext, EditPanelVM).nIdPart = PartSolidId
|
|
End If
|
|
|
|
' selezione semplice
|
|
If EgtIsPart(nPartId) Then
|
|
Dim nStat As Integer = GDB_ST.ON_
|
|
EgtGetStatus(nPartId, nStat)
|
|
' Se già selezionato o posizione oggetto incompatibile con flag posizione selezionati
|
|
If nStat = GDB_ST.SEL Then
|
|
' Memorizzo Id da deselezionare
|
|
m_nIdToDesel = nPartId
|
|
Else
|
|
' Memorizzo Id da selezionare
|
|
m_nIdToSel = nPartId
|
|
'm_nIdPart = nPartId
|
|
End If
|
|
If m_bEnableEdit Then m_bDrag = True
|
|
EgtDraw()
|
|
Exit While
|
|
End If
|
|
' Passo al successivo
|
|
nId = EgtGetNextObjInSelWin()
|
|
End While
|
|
End Sub
|
|
|
|
Private Sub OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
|
|
' Se abilitata modifica
|
|
If m_bEnableEdit Then
|
|
' Se eseguito drag
|
|
If Not m_bDragToStart Then
|
|
' Non serve fare alcunché
|
|
' Se selezione da eseguire
|
|
ElseIf m_nIdToSel <> GDB_ID.NULL Then
|
|
' Eseguo la selezione
|
|
Dim PartSolidIdToSel As PartSolidM = GetPartSolid(m_nIdToSel)
|
|
If IsNothing(PartSolidIdToSel) Then Return
|
|
PartSolidIdToSel.SelectPart()
|
|
' Se deselezione da eseguire
|
|
ElseIf m_nIdToDesel <> GDB_ID.NULL Then
|
|
Dim PartSolidIdToDesel As PartSolidM = GetPartSolid(m_nIdToDesel)
|
|
If IsNothing(PartSolidIdToDesel) Then Return
|
|
PartSolidIdToDesel.DeselectPart()
|
|
End If
|
|
' Altrimenti selezione/deselezione anche per nesting
|
|
Else
|
|
' Se selezione da eseguire
|
|
If m_nIdToSel <> GDB_ID.NULL Then
|
|
'' deseleziono tutto quello che c'era selezionato prima
|
|
'If Not TgBtn_MultiSel.IsChecked Then DeselectAll()
|
|
|
|
' Eseguo la selezione in Nesting
|
|
Dim PartSolidIdToSel As PartSolidM = GetPartSolid(m_nIdToSel)
|
|
If IsNothing(PartSolidIdToSel) Then
|
|
' il part selezionato non ha un PartSolid associato nella lista, quindi lo creo e lo aggiungo
|
|
Dim Part As New PartSolidM(m_nIdToSel)
|
|
m_PartSolidList.Add(Part)
|
|
PartSolidIdToSel = GetPartSolid(m_nIdToSel)
|
|
If IsNothing(PartSolidIdToSel) Then Return
|
|
End If
|
|
If m_nIdPart = GDB_ID.NULL Then
|
|
If Map.refSceneButtonVM.IsTgBtnChecked(EGT_MOVE) Then
|
|
' era attiva la modalità move ma non avevo selezionato un part
|
|
DirectCast(Map.refSceneButtonVM.m_MoveUC.DataContext, MoveVM).AdvanceStage()
|
|
End If
|
|
If Map.refSceneButtonVM.IsTgBtnChecked(EGT_ROTATE) Then
|
|
' era attiva la modalità rotate ma non avevo selezionato un part
|
|
m_nIdPart = PartSolidIdToSel.PartId
|
|
PartSolidIdToSel.SelectPart()
|
|
DirectCast(Map.refSceneButtonVM.m_RotateUC.DataContext, RotateVM).AdvanceStage()
|
|
End If
|
|
End If
|
|
|
|
m_nIdToSel = PartSolidIdToSel.PartId
|
|
m_nIdPart = PartSolidIdToSel.PartId
|
|
'' seleziono l'oggetto nel tree
|
|
'SelectInTree()
|
|
|
|
' attivo tutti i pulsanti che eseguono azioni sul pezzo
|
|
EnableActionButtons()
|
|
|
|
'' seleziono nel nesting
|
|
'Dim bSelected As Boolean = False
|
|
'Dim nOriId As Integer = GDB_ID.NULL
|
|
'EgtGetInfo(m_nIdToSel, KEY_ORI_ID, nOriId)
|
|
'If EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx()) AndAlso EgtExistsObj(nOriId) Then
|
|
' Dim nMachGrpId As Integer
|
|
' If (OmagOFFICEMap.refNestingTabVM.SelectPart(nOriId, False, nMachGrpId)) Then
|
|
' bSelected = True
|
|
' Else
|
|
' If nMachGrpId = GDB_ID.NULL Then
|
|
' ' "Attenzione" "Pezzo non selezionabile in questa condizione"
|
|
' MessageBox.Show(Me, EgtMsg(91606), EgtMsg(91122), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
' Else
|
|
' Dim sMachGrpName As String = String.Empty
|
|
' EgtGetMachGroupName(nMachGrpId, sMachGrpName)
|
|
' ' "Attenzione" "Pezzo non selezionabile perchè appartenente a gruppo di lavoro non corrente :" ...
|
|
' MessageBox.Show(Me, EgtMsg(91607) & " " & sMachGrpName, EgtMsg(91122), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
' End If
|
|
' End If
|
|
|
|
'End If
|
|
'EgtSetCurrentContext(VeinMatchingScene.GetCtx())
|
|
|
|
|
|
' Se selezione riuscita, la eseguo anche in VME
|
|
' WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
|
' WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
|
' WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
|
' WARNING WARNING WARNING WARNING WARNING WARNING ' questo controllo è stato tolto per poter selezionare gli oggetti importati nel vme e quindi non presenti nel nesting
|
|
'If bSelected Then
|
|
If Map.refSceneButtonVM.IsTgBtnChecked(EGT_EDIT_PANEL) Then
|
|
DirectCast(Map.refSceneButtonVM.m_EditPanelUC.DataContext, EditPanelVM).SelectPartOrPartsToEdit()
|
|
Else
|
|
PartSolidIdToSel.SelectPart()
|
|
End If
|
|
|
|
'End If
|
|
' Se deselezione da eseguire
|
|
ElseIf m_nIdToDesel <> GDB_ID.NULL Then
|
|
' disattivo i pulsanti che eseguono azioni sul pezzo
|
|
DisableActionButtons()
|
|
|
|
m_nIdPart = -1
|
|
'deseleziono
|
|
Dim PartSolidIdToDesel As PartSolidM = GetPartSolid(m_nIdToDesel)
|
|
If IsNothing(PartSolidIdToDesel) Then
|
|
' selezione di un Part che non ha un SOLID associato
|
|
EgtDeselectObj(m_nIdToDesel)
|
|
Return
|
|
End If
|
|
m_nIdToDesel = PartSolidIdToDesel.PartId
|
|
'' Eseguo la deselezione in Nesting
|
|
'Dim bDeselected As Boolean = False
|
|
'Dim nOriId As Integer = GDB_ID.NULL
|
|
'EgtGetInfo(m_nIdToDesel, KEY_ORI_ID, nOriId)
|
|
'If EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx()) AndAlso EgtExistsObj(nOriId) Then
|
|
' If (OmagOFFICEMap.refNestingTabVM.DeselectPart(nOriId, False)) Then
|
|
' bDeselected = True
|
|
' End If
|
|
'End If
|
|
'EgtSetCurrentContext(VeinMatchingScene.GetCtx())
|
|
'' Se deselezione riuscita, la eseguo anche in VME
|
|
'' WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
|
'' WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
|
'' WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
|
'' WARNING WARNING WARNING WARNING WARNING WARNING
|
|
|
|
|
|
'If bDeselected Then
|
|
PartSolidIdToDesel.DeselectPart()
|
|
'End If
|
|
End If
|
|
End If
|
|
' Reset e salvataggio
|
|
m_nIdToSel = GDB_ID.NULL
|
|
m_nIdToDesel = GDB_ID.NULL
|
|
|
|
' salvo la trasformazione
|
|
If m_bDrag Or m_bRotate Then
|
|
If m_nIdPart = GDB_ID.NULL Then Return
|
|
Dim ptCurr As Point3d
|
|
EgtUnProjectPoint(e.Location, ptCurr)
|
|
Dim PartSolidSel As PartSolidM = GetPartSolid(m_nIdPart)
|
|
If IsNothing(PartSolidSel) Then Return
|
|
If Not m_bRotate Then
|
|
Dim vtDir As Vector3d = ptCurr - m_ptBeforeTrasf
|
|
'If m_dCorrection > EPS_SMALL Then
|
|
' vtDir -= LastTempTransf().m_vtDir * m_dCorrection
|
|
'End If
|
|
' proietto il vettore di spostamento sul versore della terna che stavo usando
|
|
vtDir = PartSolidSel.vtDrag * (PartSolidSel.vtDrag * vtDir)
|
|
If EgtLuaSetGlobIntVar("ASS.nTypeTrf", 0) Then AssLog("ASS.nTypeTrf = 0 ")
|
|
If EgtLuaSetGlobIntVar("ASS.nPartId", m_nIdPart) Then AssLog("ASS.nPartId = " & m_nIdPart.ToString)
|
|
If EgtLuaSetGlobVectorVar("ASS.vtMove", vtDir) Then AssLog("ASS.vtMove = {" & vtDir.ToString & "}")
|
|
If EgtLuaCallFunction("ASS.AddEvent") Then AssLog("ASS.AddEvent()")
|
|
EgtLuaSetGlobIntVar("ASS.nTypeTrf", -1)
|
|
Else
|
|
m_ptCen = PartSolidSel.Center()
|
|
Dim vtPrev As Vector3d = m_ptBeforeTrasf - m_ptCen
|
|
Dim vtCurr As Vector3d = ptCurr - m_ptCen
|
|
Dim dAngRotDeg As Double = Math.Atan2(Vector3d.CrossXY(vtPrev, vtCurr), Vector3d.ScalarXY(vtPrev, vtCurr)) * 180.0 / Math.PI
|
|
'If m_dCorrection > EPS_SMALL Then
|
|
' dAngRotDeg -= LastTempTransf().m_dAngOrId * m_dCorrection
|
|
'End If
|
|
If EgtLuaSetGlobIntVar("ASS.nTypeTrf", 1) Then AssLog("ASS.nTypeTrf = 1 ")
|
|
If EgtLuaSetGlobIntVar("ASS.nPartId", m_nIdPart) Then AssLog("ASS.nPartId = " & m_nIdPart.ToString)
|
|
If EgtLuaSetGlobPointVar("ASS.ptAx", m_ptCen) Then AssLog("ASS.vtAx = {" & m_ptCen.ToString & "}")
|
|
If EgtLuaSetGlobVectorVar("ASS.vtAx", PartSolidSel.vtDrag) Then AssLog("ASS.vtAx = " & PartSolidSel.vtDrag.ToString)
|
|
If EgtLuaSetGlobNumVar("ASS.dAng", dAngRotDeg) Then AssLog("ASS.dAng = " & dAngRotDeg.ToString)
|
|
If Not EgtLuaCallFunction("ASS.AddEvent") Then
|
|
AssLog("fallita la chiamata a ASS.AddEvent")
|
|
Else
|
|
AssLog("ASS.AddEvent()")
|
|
End If
|
|
EgtLuaSetGlobIntVar("ASS.nTypeTrf", -1)
|
|
End If
|
|
' fattore di correzione dell'ultima operazione
|
|
m_dCorrection = 0
|
|
' aumento il contatore della storia
|
|
nTime += 1
|
|
SolidManagerM.ManageUndoRedo()
|
|
End If
|
|
m_bDrag = False
|
|
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub ShiftKey_Down(sender As Object, e As System.Windows.Forms.KeyEventArgs)
|
|
If e.Shift Then
|
|
Dim TgBtn As SceneBtn = Map.refSceneButtonVM.GetButton("Pair")
|
|
If TypeOf (TgBtn) Is _ToggleButton And DirectCast(TgBtn, _ToggleButton).IsChecked Then
|
|
m_SelType = GDB_TY.SRF_FRGN
|
|
End If
|
|
Return
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ShiftKey_Up(sender As Object, e As System.Windows.Forms.KeyEventArgs)
|
|
If Not e.Shift Then
|
|
Dim TgBtn As SceneBtn = Map.refSceneButtonVM.GetButton("Pair")
|
|
If TypeOf (TgBtn) Is _ToggleButton And DirectCast(TgBtn, _ToggleButton).IsChecked Then
|
|
m_SelType = GDB_TY.CRV_LINE
|
|
End If
|
|
Return
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Events
|
|
|
|
End Class
|