174 lines
6.9 KiB
VB.net
174 lines
6.9 KiB
VB.net
Imports System.Windows.Interop
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class SceneShowBuldingVM
|
|
Inherits EgtWPFLib5.SceneHostVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private nOldPartId As Integer = -1
|
|
|
|
Private m_SceneShowBulding As New Scene
|
|
Public ReadOnly Property SceneShowBulding As Scene
|
|
Get
|
|
Return m_SceneShowBulding
|
|
End Get
|
|
End Property
|
|
|
|
Private m_MapInfo As New Dictionary(Of Integer, Integer)()
|
|
Public Property MapInfo As Dictionary(Of Integer, Integer)
|
|
Get
|
|
Return m_MapInfo
|
|
End Get
|
|
Set(value As Dictionary(Of Integer, Integer))
|
|
m_MapInfo = value
|
|
NotifyPropertyChanged(NameOf(MapInfo))
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
MyBase.New()
|
|
' Creo Riferimento
|
|
Map.SetRefSceneShowBuldingVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Public Overrides Sub InitScene()
|
|
'InitSceneEvents()
|
|
' Inizializzazione Scena
|
|
PreInitializeScene()
|
|
If SceneShowBulding.Init() And Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.BEAM Or KEY_OPT.WALL) Then
|
|
PostInitializeScene()
|
|
' Imposto stato gestione mouse diretto della scena a nessuno
|
|
SceneShowBulding.SetStatusNull()
|
|
' Imposto focus pulsante su false
|
|
SceneShowBulding.SetFocusOnMove(False)
|
|
' Recupero e imposto handle finestra principale
|
|
Dim hMainWnd As IntPtr = New WindowInteropHelper(Application.Current.MainWindow).Handle
|
|
EgtSetMainWindowHandle(hMainWnd)
|
|
EgtSetCurrentContext(SceneShowBulding.GetCtx())
|
|
' Imposto direttorio ausiliario per import/gestione BTL
|
|
Dim sBtlAuxDir As String = String.Empty
|
|
GetMainPrivateProfileString(S_IMPORT, K_BTLAUXDIR, "", sBtlAuxDir)
|
|
EgtSetBtlAuxDir(sBtlAuxDir)
|
|
' inizializzo gestore travi e pareti
|
|
EgtInitBeamMgr(EIB_FL.TS3_POS + EIB_FL.USEUATTR)
|
|
' inizializzo gestore lavorazioni
|
|
EgtInitMachMgr(Map.refMainWindowVM.MainWindowM.sMachinesRoot, Map.refMainWindowVM.MainWindowM.sToolMakersDir)
|
|
Return
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides Sub InitSceneEvents()
|
|
AddHandler SceneShowBulding.OnMouseDownScene, AddressOf OnMouseDownScene
|
|
End Sub
|
|
|
|
Private Sub PreInitializeScene()
|
|
' imposto colore di default
|
|
Dim DefColor As New Color3d(0, 0, 0)
|
|
GetMainPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor)
|
|
SceneShowBulding.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)
|
|
SceneShowBulding.SetViewBackground(BackTopColor, BackBotColor)
|
|
' imposto colore di evidenziazione
|
|
Dim MarkColor As New Color3d(255, 255, 0)
|
|
GetMainPrivateProfileColor(S_SCENE, K_MARK, MarkColor)
|
|
SceneShowBulding.SetMarkMaterial(MarkColor)
|
|
' imposto colore per superfici selezionate
|
|
Dim SelSurfColor As New Color3d(255, 255, 192)
|
|
GetMainPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor)
|
|
SceneShowBulding.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)
|
|
SceneShowBulding.SetZoomWinAttribs(bOutline, ZwColor)
|
|
' imposto colore della linea di distanza
|
|
Dim DstLnColor As New Color3d(255, 0, 0)
|
|
GetMainPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor)
|
|
SceneShowBulding.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)
|
|
SceneShowBulding.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits)
|
|
End Sub
|
|
|
|
Private Sub PostInitializeScene()
|
|
' Impostazioni Controller
|
|
MainController.SetScene(SceneShowBulding)
|
|
' imposto tipo coordinate
|
|
SceneShowBulding.SetGridCursorPos(True)
|
|
' modo di visualizzazione
|
|
Dim nShowMode As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWMODE, SM.SHADING)
|
|
'Map.refShowPanelVM.SetShowMode(DirectCast(nShowMode, SM))
|
|
EgtSetShowMode(DirectCast(nShowMode, SM))
|
|
' visualizzazione avanzata dei triangoli costituenti le superfici
|
|
Dim bShowTriaAdv As Boolean = (GetMainPrivateProfileInt(S_SCENE, K_SHOWTRIAADV, 1) <> 0)
|
|
EgtSetShowTriaAdv(bShowTriaAdv)
|
|
' 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
|
|
SceneShowBulding.SetSnapPointType(SP.PT_SKETCH)
|
|
' imposto parametri geometrici griglia
|
|
EgtSetGridGeo(100, 1, 10, 100)
|
|
End Sub
|
|
|
|
Friend Overloads Sub SetMainScene(Scene As Scene)
|
|
m_SceneShowBulding = Scene
|
|
InitScene()
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
#Region "EVENTS"
|
|
|
|
Private Sub OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs)
|
|
EgtSetStatus(nOldPartId, GDB_ST.ON_)
|
|
' Verifico se selezionato indicativo di pezzo
|
|
EgtSetObjFilterForSelWin(True, True, True, True, True)
|
|
Dim nSel As Integer = 0
|
|
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
|
|
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
|
' Recupero l'identificativo del pezzo cui appartiene
|
|
Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
|
|
Dim nOrigPartId As Integer = nPartId
|
|
nOldPartId = nOrigPartId
|
|
Dim nCopId As Integer = 0
|
|
If EgtGetInfo(nPartId, "!COP", nCopId) Then
|
|
nPartId = nCopId
|
|
End If
|
|
Dim nOrIdKey As KeyValuePair(Of Integer, Integer) = Map.refSceneShowBuldingVM.MapInfo.FirstOrDefault(Function(x) x.Value = nPartId)
|
|
Dim nOrdId As Integer = nOrIdKey.Key
|
|
Dim BTLPartVM As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(y) y.nPartId = nOrdId)
|
|
' Ritorno al contesto corrente
|
|
EgtSetCurrentContext(Map.refSceneHostVM.MainScene.GetCtx())
|
|
Map.refProjectVM.BTLStructureVM.SetSelBTLPart(BTLPartVM, True)
|
|
Map.refProjectVM.BTLStructureVM.SelectBTLPartScene(BTLPartVM, True)
|
|
' Setto il nuovo contesto
|
|
EgtSetCurrentContext(SceneShowBulding.GetCtx())
|
|
EgtSetStatus(nOrigPartId, GDB_ST.SEL)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' Events
|
|
|
|
End Class |