297 lines
14 KiB
VB.net
297 lines
14 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class DxfImportSceneHostV
|
|
|
|
' Indentificativo del pezzo selezionato
|
|
Private m_nSelectedPart As Integer = GDB_ID.NULL
|
|
Friend Property SelectedPart As Integer
|
|
Get
|
|
Return m_nSelectedPart
|
|
End Get
|
|
Set(value As Integer)
|
|
m_nSelectedPart = value
|
|
End Set
|
|
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
|
|
DxfImportWindowMap.SetRefDxfImportSceneHostV(Me)
|
|
' Inizializzazione Scena
|
|
PreInitializeScene()
|
|
ImportDxfScene.Init()
|
|
PostInitializeScene()
|
|
' Imposto stato gestione mouse diretto della scena a nessuno
|
|
ImportDxfScene.SetStatusNull()
|
|
EgtNewFile()
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub PreInitializeScene()
|
|
' imposto colore di default
|
|
Dim DefColor As New Color3d(0, 0, 0)
|
|
GetMainPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor)
|
|
ImportDxfScene.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)
|
|
ImportDxfScene.SetViewBackground(BackTopColor, BackBotColor)
|
|
' imposto colore di evidenziazione
|
|
Dim MarkColor As New Color3d(255, 255, 0)
|
|
GetMainPrivateProfileColor(S_SCENE, K_MARK, MarkColor)
|
|
ImportDxfScene.SetMarkMaterial(MarkColor)
|
|
' imposto colore per superfici selezionate
|
|
Dim SelSurfColor As New Color3d(255, 255, 192)
|
|
GetMainPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor)
|
|
ImportDxfScene.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)
|
|
ImportDxfScene.SetZoomWinAttribs(bOutline, ZwColor)
|
|
' imposto colore della linea di distanza
|
|
Dim DstLnColor As New Color3d(255, 0, 0)
|
|
GetMainPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor)
|
|
ImportDxfScene.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)
|
|
ImportDxfScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits)
|
|
End Sub
|
|
|
|
Private Sub PostInitializeScene()
|
|
' imposto tipo coordinate
|
|
ImportDxfScene.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 ImportDxfScene.OnMouseDownScene
|
|
' Solo se in modalità angoli o gocciolatoio su lati esterni
|
|
If DxfImportWindowMap.refDxfImportWindowVM.SideAngle_IsChecked Or DxfImportWindowMap.refDxfImportWindowVM.Drip_IsChecked Or DxfImportWindowMap.refDxfImportWindowVM.Engrave_IsChecked Then
|
|
OnMouseDownSceneSideAngle(e)
|
|
ElseIf DxfImportWindowMap.refDxfImportWindowVM.FiloTop_IsChecked Then
|
|
OnMouseDownSceneFiloTop(e)
|
|
ElseIf DxfImportWindowMap.refDxfImportWindowVM.UnderDrill_IsChecked Then
|
|
OnMouseDownSceneUnderDrill(e)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnMouseDownSceneSideAngle(e As System.Windows.Forms.MouseEventArgs)
|
|
' Solo con il tasto sinistro e se stato NULL
|
|
If e.Button <> Windows.Forms.MouseButtons.Left Or Not ImportDxfScene.IsStatusNull() 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_nSelectedPart = GDB_ID.NULL
|
|
m_nSelectedLayer = GDB_ID.NULL
|
|
SideEntityControlVM.WriteSideAngleForNest(ImportDxfScene.GetCtx())
|
|
' Messaggio di selezione da effettuare
|
|
DxfImportWindowMap.refDxfImportWindowVM.SetOutputMessage(EgtMsg(MSG_DRAWPAGEUC + 6), MSG_TYPE.INFO) ' Selezionare un contorno
|
|
Else
|
|
Dim nLayId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_OUTLOOP)
|
|
EgtGetInfo(nId, "ID", nLayId)
|
|
' prima deseleziono eventuale pezzo già selezionato
|
|
EgtDeselectAll()
|
|
m_nSelectedPart = GDB_ID.NULL
|
|
m_nSelectedLayer = GDB_ID.NULL
|
|
SideEntityControlVM.WriteSideAngleForNest(ImportDxfScene.GetCtx())
|
|
' seleziono pezzo cliccato
|
|
EgtSelectObj(nId)
|
|
EgtSelectObj(nLayId)
|
|
m_nSelectedPart = nPartId
|
|
m_nSelectedLayer = nLayId
|
|
' Pulisco area messaggi
|
|
DxfImportWindowMap.refDxfImportWindowVM.ClearOutputMessage()
|
|
End If
|
|
DxfImportWindowMap.refDxfImportWindowVM.SelectedPartChanged()
|
|
EgtDraw()
|
|
Exit While
|
|
End If
|
|
End If
|
|
nId = EgtGetNextObjInSelWin()
|
|
End While
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub OnMouseDownSceneUnderDrill(e As System.Windows.Forms.MouseEventArgs)
|
|
' Solo con il tasto sinistro e se stato NULL
|
|
If e.Button <> Windows.Forms.MouseButtons.Left Or Not ImportDxfScene.IsStatusNull() 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
|
|
Dim nLayId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(nId, "ID", nLayId)
|
|
EgtDeselectObj(nId)
|
|
EgtDeselectObj(nLayId)
|
|
Dim sLayName As String = ""
|
|
If EgtGetName(nLayId, sLayName) And sLayName = NAME_UNDERDRILL Then
|
|
EgtSetName(nLayId, NAME_INLOOP)
|
|
Dim nEntId As Integer = EgtGetFirstInGroup(nLayId)
|
|
EgtRemoveInfo(nEntId, INFO_DEPTH)
|
|
EgtSetColor(nEntId, New Color3d(0, 0, 0))
|
|
End If
|
|
Else
|
|
Dim nLayId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(nId, "ID", nLayId)
|
|
Dim sLayName As String = ""
|
|
If EgtGetName(nLayId, sLayName) And (sLayName = NAME_INLOOP) Then
|
|
EgtSelectObj(nId)
|
|
EgtSelectObj(nLayId)
|
|
EgtSetName(nLayId, NAME_UNDERDRILL)
|
|
Dim nEntId As Integer = EgtGetFirstInGroup(nLayId)
|
|
EgtSetInfo(nEntId, INFO_DEPTH, DxfImportWindowMap.refUnderDrillControlVM.dDrillDepth)
|
|
EgtSetColor(nEntId, New Color3d(255, 255, 255))
|
|
End If
|
|
End If
|
|
EgtDraw()
|
|
End If
|
|
End If
|
|
nId = EgtGetNextObjInSelWin()
|
|
End While
|
|
End Sub
|
|
|
|
Private Sub OnMouseDownSceneFiloTop(e As System.Windows.Forms.MouseEventArgs)
|
|
' Solo con il tasto sinistro e se stato NULL
|
|
If e.Button <> Windows.Forms.MouseButtons.Left Or Not ImportDxfScene.IsStatusNull() 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
|
|
Dim nLayId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(nId, "ID", nLayId)
|
|
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)
|
|
Dim nEntId As Integer = EgtGetFirstInGroup(nLayId)
|
|
While nEntId <> GDB_ID.NULL
|
|
EgtSetColor(nEntId, New Color3d(127, 63, 0))
|
|
nEntId = EgtGetNext(nEntId)
|
|
End While
|
|
End If
|
|
Else
|
|
Dim nLayId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(nId, "ID", nLayId)
|
|
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)
|
|
Dim nEntId As Integer = EgtGetFirstInGroup(nLayId)
|
|
While nEntId <> GDB_ID.NULL
|
|
EgtSetColor(nEntId, New Color3d(255, 255, 255))
|
|
nEntId = EgtGetNext(nEntId)
|
|
End While
|
|
End If
|
|
End If
|
|
EgtDraw()
|
|
End If
|
|
End If
|
|
nId = EgtGetNextObjInSelWin()
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' EVENTS
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub Deselect()
|
|
EgtDeselectAll()
|
|
m_nSelectedPart = GDB_ID.NULL
|
|
m_nSelectedLayer = GDB_ID.NULL
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
End Class
|