Imports EgtUILib Imports EgtWPFLib5 Public Class CompoSceneHostV Public m_SelListHole As New List(Of Integer) Public m_DeselectListHole As New List(Of Integer) Private m_refSideEntityControlVM As SideEntityControlVM Private m_SelFromScene As Boolean = False Friend ReadOnly Property SelFromScene As Boolean Get Return m_SelFromScene End Get End Property ' Indentificativo del layer selezionato Private m_nSelectedLayer As Integer = GDB_ID.NULL Friend Property SelectedLayer As Integer Get Return m_nSelectedLayer End Get Set(value As Integer) m_nSelectedLayer = value End Set End Property Sub New() ' This call is required by the designer. InitializeComponent() ' Creo riferimento a questa classe in CompoWindowMap CompoWindowMap.SetRefCompoSceneHostV(Me) ' Inizializzazione Scena PreInitializeScene() CompoScene.Init() PostInitializeScene() ' Imposto stato gestione mouse diretto della scena a nessuno CompoScene.SetStatusNull() EgtNewFile() EgtDraw() End Sub Public Sub SetRefSideEntityControlVM(refSideEntityControl As SideEntityControlVM) m_refSideEntityControlVM = refSideEntityControl End Sub Private Sub PreInitializeScene() ' imposto colore di default Dim DefColor As New Color3d(0, 0, 0) GetMainPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor) CompoScene.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) CompoScene.SetViewBackground(BackTopColor, BackBotColor) ' imposto colore di evidenziazione Dim MarkColor As New Color3d(255, 255, 0) GetMainPrivateProfileColor(S_SCENE, K_MARK, MarkColor) CompoScene.SetMarkMaterial(MarkColor) ' imposto colore per superfici selezionate Dim SelSurfColor As New Color3d(255, 255, 192) GetMainPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor) CompoScene.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) CompoScene.SetZoomWinAttribs(bOutline, ZwColor) ' imposto colore della linea di distanza Dim DstLnColor As New Color3d(255, 0, 0) GetMainPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor) CompoScene.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) CompoScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits) End Sub Private Sub PostInitializeScene() ' imposto tipo coordinate CompoScene.SetGridCursorPos(True) ' modo di visualizzazione Dim nShowMode As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWMODE, SM.SHADING) 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) ' dati di griglia Dim dSnapStep As Double = If(EgtUiUnitsAreMM(), GetMainPrivateProfileDouble(S_GRID, K_SNAPSTEP, 10), GetMainPrivateProfileDouble(S_GRID, K_SNAPSTEPINCH, 12.7)) 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) EgtSetGridGeo(dSnapStep, nMinLineSStep, nMajLineSStep, nExtSStep) EgtSetGridColor(MinLnColor, MajLnColor) Dim bShowGrid As Boolean = (GetMainPrivateProfileInt(S_GRID, K_SHOWGRID, 1) <> 0) EgtSetGridShow(bShowGrid, False) End Sub #Region "EVENTS" Private Sub OnMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles CompoScene.OnMouseDownScene ' Si può selezionare solo con il tasto sinistro e se stato NULL If e.Button <> Windows.Forms.MouseButtons.Left Or Not CompoScene.IsStatusNull() Then Return ' Si può selezionare solo se non si sta già editando un componente If CompoWindowMap.refCompoListPageVM.SideAngle_IsChecked Or CompoWindowMap.refCompoListPageVM.Drip_IsChecked Then OnMouseDownSceneSideAngle(e) ElseIf CompoWindowMap.refCompoListPageVM.FiloTop_IsChecked Or CompoWindowMap.refCompoListPageVM.Drip_IsChecked Then OnMouseDownSceneFiloTop(e) ElseIf CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.LIST And Not IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompoFamily) Then OnMouseDownSceneInternalComponent(e) End If End Sub Private Sub OnMouseDownSceneInternalComponent(e As System.Windows.Forms.MouseEventArgs) ' Verifico se selezionato indicativo di componente (wall, door o window) EgtSetObjFilterForSelWin(False, False, True, False, False) Dim nSel As Integer EgtSelect(e.Location, 2 * Scene.DIM_SEL, 2 * Scene.DIM_SEL, nSel) Dim sCompo As String = String.Empty Dim nId As Integer = EgtGetFirstObjInSelWin() While nId <> GDB_ID.NULL If EgtGetInfo(nId, CompoParamPageVM.INFO_CMP, sCompo) Then Exit While End If nId = EgtGetNextObjInSelWin() End While If String.IsNullOrWhiteSpace(sCompo) Then Return ' Attivo stato selezione da scena m_SelFromScene = True ' Salvo l'indice della superficie di selezione Dim nSurfSelId As Integer = nId ' Recupero l'indice del componente Dim sName As String = String.Empty If Not EgtGetName(nId, sName) Then Return Dim nCmp As Integer = -1 If Not StringToInt(sName, nCmp) Then Return CompoWindowMap.refCompoWindowVM.m_SelInternalCompo = CompoWindowMap.refCompoListPageVM.CompoList.First(Function(x) x.LuaPath = sCompo & ".lua") CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.PARAM CompoWindowMap.refCompoParamPageVM.ReadSelInternalVariables(nId) ' Imposto l'indice del componente If Not EgtLuaSetGlobIntVar(CompoParamPageVM.LUA_CMP_INDEX, nCmp) Then Return ' Evidenzio la sua regione di selezione EgtSelectObj(nSurfSelId) ' Rendo visibili le eventuali etichette del componente Dim nHLId As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(GDB_ID.ROOT), "HoleLabels") While nHLId <> GDB_ID.NULL Dim nCmpInfo As Integer = 0 If EgtGetInfo(nHLId, "ID", nCmpInfo) AndAlso nCmp = nCmpInfo Then EgtSetStatus(nHLId, GDB_ST.ON_) ' nascondo eventuali FiloTop CompoWindowMap.refCompoParamPageVM.SetStatusVisibilityInLoopReference(nCmp, GDB_ST.OFF) Exit While End If nHLId = EgtGetNextName(nHLId, "HoleLabels") End While CompoScene.ZoomAll() ' Disattivo stato selezione da scena m_SelFromScene = False End Sub Private Sub OnMouseDownSceneSideAngle(e As System.Windows.Forms.MouseEventArgs) ' Se non ci sono loop interni, selezione inutile If EgtGetFirstNameInGroup(EgtGetFirstPart(), NAME_INLOOP) = GDB_ID.NULL Then Return ' Verifico se selezionato indicativo di pezzo EgtSetObjFilterForSelWin(False, False, True, False, False) 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 layer e del pezzo cui appartiene Dim nRegLayId As Integer = EgtGetParent(nId) Dim nPartId As Integer = EgtGetParent(nRegLayId) If EgtIsPart(nPartId) Then Dim sRegLayName As String = String.Empty EgtGetName(nRegLayId, sRegLayName) If sRegLayName = NAME_REGION Or sRegLayName = SELECT_REGION_LAYER Then Dim nStat As Integer = GDB_ST.ON_ EgtGetStatus(nId, nStat) If nStat = GDB_ST.SEL Then EgtDeselectAll() m_nSelectedLayer = GDB_ID.NULL SideEntityControlVM.WriteSideAngleForNest(CompoScene.GetCtx()) ' Messaggio di selezione da effettuare CompoWindowMap.refCompoListPageVM.SetOutputMessage(EgtMsg(MSG_DRAWPAGEUC + 6), MSG_TYPE.INFO) ' Selezionare un contorno Else Dim nLayId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_OUTLOOP) Dim nInd As Integer = 0 EgtGetInfo(nId, "ID", nInd) ' questa condizione non è presente nell'OmagCUT If nInd <> 0 Then Dim nInLoopId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_INLOOP) While nInLoopId <> GDB_ID.NULL Dim nLoopInd As Integer = 0 EgtGetInfo(nInLoopId, "ID", nLoopInd) If nLoopInd = nInd And nInd <> 0 Then nLayId = nInLoopId Exit While End If nInLoopId = EgtGetNextName(nInLoopId, NAME_INLOOP) End While End If EgtDeselectAll() EgtSelectObj(nId) EgtSelectObj(nLayId) m_nSelectedLayer = nLayId ' Pulisco area messaggi CompoWindowMap.refCompoListPageVM.ClearOutputMessage() End If CompoWindowMap.refCompoListPageVM.SelectedPartChanged() Exit While End If End If nId = EgtGetNextObjInSelWin() End While End Sub Private Sub OnMouseDownSceneFiloTop(e As System.Windows.Forms.MouseEventArgs) ' Verifico se selezionato indicativo di pezzo EgtSetObjFilterForSelWin(False, False, True, False, False) 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 layer e del pezzo cui appartiene Dim nRegLayId As Integer = EgtGetParent(nId) Dim nPartId As Integer = EgtGetParent(nRegLayId) If EgtIsPart(nPartId) Then Dim sRegLayName As String = String.Empty EgtGetName(nRegLayId, sRegLayName) If sRegLayName = NAME_REGION Or sRegLayName = SELECT_REGION_LAYER Then Dim nStat As Integer = GDB_ST.ON_ EgtGetStatus(nId, nStat) Dim nLayId As Integer = GDB_ID.NULL Dim nInd As Integer = 0 EgtGetInfo(nId, "ID", nInd) If nInd <> 0 Then Dim nInLoopId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_INLOOP) While nInLoopId <> GDB_ID.NULL Dim nLoopInd As Integer = 0 EgtGetInfo(nInLoopId, "ID", nLoopInd) If nLoopInd = nInd And nInd <> 0 Then nLayId = nInLoopId Exit While End If nInLoopId = EgtGetNextName(nInLoopId, NAME_INLOOP) End While End If If nStat = GDB_ST.SEL Then EgtDeselectObj(nId) EgtDeselectObj(nLayId) Dim sLayName As String = "" If EgtGetName(nLayId, sLayName) AndAlso sLayName = NAME_INLOOP AndAlso EgtExistsInfo(nLayId, INFO_FILOTOP) Then EgtRemoveInfo(nLayId, INFO_FILOTOP) EgtRemoveInfo(nLayId, INFO_OFFSET) EgtRemoveInfo(nLayId, INFO_DEPTH) EgtResetColor(nLayId) End If m_DeselectListHole.Add(nLayId) m_SelListHole.Remove(nLayId) Else Dim sLayName As String = "" If EgtGetName(nLayId, sLayName) AndAlso sLayName = NAME_INLOOP Then EgtSelectObj(nId) EgtSelectObj(nLayId) EgtSetInfo(nLayId, INFO_FILOTOP, 1) EgtSetInfo(nLayId, INFO_OFFSET, SideAngleEntity.m_Parameter1) EgtSetInfo(nLayId, INFO_DEPTH, SideAngleEntity.m_Parameter2) EgtSetColor(nLayId, New Color3d(255, 255, 255)) End If m_SelListHole.Add(nLayId) m_DeselectListHole.Remove(nLayId) End If EgtDraw() End If End If nId = EgtGetNextObjInSelWin() End While If Not IsNothing(m_refSideEntityControlVM) Then m_refSideEntityControlVM.CreateFiloTopPreView(m_SelListHole) m_refSideEntityControlVM.EraseFiloTopPreview(m_DeselectListHole) End If End Sub #End Region ' Events End Class