204216c05e
- piccolo adattamento.
193 lines
7.8 KiB
VB.net
193 lines
7.8 KiB
VB.net
Imports System.Text
|
|
Imports EgtUILib
|
|
|
|
Public Class Form1
|
|
|
|
Private m_sIniFile As String = String.Empty
|
|
Private WithEvents m_Controller1 As New Controller
|
|
Private WithEvents m_Controller2 As New Controller
|
|
|
|
Private Sub MainForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
|
|
m_sIniFile = Application.StartupPath & "\EgtDemo1.ini"
|
|
' Leggo e imposto chiave di protezione
|
|
Dim sLicFile As String = Application.StartupPath & "\" & "EgtDemo1.lic"
|
|
Dim sKey As String = String.Empty
|
|
GetPrivateProfileString("Licence", "Key", "", sKey, sLicFile)
|
|
EgtSetKey(sKey)
|
|
'Inizializzazione generale di EgtInterface
|
|
Dim sLogMsg As String = My.Application.Info.Description.ToString() & " ver. " & My.Application.Info.Version.ToString()
|
|
EgtInit(0, "TestEngine.log", sLogMsg)
|
|
' Leggo file messaggi
|
|
Dim sMsgFile As String = String.Empty
|
|
GetPrivateProfileString("General", "Messages", "", sMsgFile, m_sIniFile)
|
|
Dim sMsgFilePath As String = Application.StartupPath & "\" & sMsgFile
|
|
If Not EgtLoadMessages(sMsgFilePath) Then
|
|
EgtOutLog("Error in EgtLoadMessages")
|
|
End If
|
|
' imposto dir font Nfe e font default
|
|
Dim sNfeDir As String = String.Empty
|
|
GetPrivateProfileString("GeomDB", "NfeFontDir", "", sNfeDir, m_sIniFile)
|
|
Dim sDefFont As String = String.Empty
|
|
GetPrivateProfileString("GeomDB", "DefaultFont", "", sDefFont, m_sIniFile)
|
|
EgtSetFont(sNfeDir, sDefFont)
|
|
' imposto direttorio di default per libreria Lua
|
|
Dim sLuaLibsDir As String = String.Empty
|
|
GetPrivateProfileString("Lua", "LibsDir", "", sLuaLibsDir, m_sIniFile)
|
|
EgtSetLuaLibs(sLuaLibsDir)
|
|
'Impostazioni particolari vista 2
|
|
Dim DefColor As New Color3d(128, 128, 0)
|
|
Scene2.SetDefaultMaterial(DefColor)
|
|
Scene2.SetViewAttributes(2, True, 16, 16)
|
|
Dim BackTopColor As New Color3d(255, 255, 255)
|
|
Dim BackBotColor As New Color3d(168, 168, 168)
|
|
Scene2.SetViewBackground(BackTopColor, BackBotColor)
|
|
'Inizializzazione delle viste
|
|
Scene1.Init()
|
|
'Eventuali impostazioni modificabili vista 1 (vanno fatte dopo Init)
|
|
Scene2.Init()
|
|
'Impostazioni modificabili vista 2 (vanno fatte dopo Init)
|
|
EgtSetMarkAttribs(New Color3d(128, 255, 255))
|
|
EgtSetGeoLineAttribs(New Color3d(0, 255, 0))
|
|
EgtSetWinRectAttribs(False, New Color3d(255, 128, 128, 30))
|
|
EgtSetGridShow(True, True)
|
|
' Impostazione dei controller
|
|
m_Controller1.SetScene(Scene1)
|
|
m_Controller2.SetScene(Scene2)
|
|
'Attiva scena 1
|
|
OnMouseDownScene(Scene1, Nothing)
|
|
'Posizione e dimensioni del Form
|
|
If ModifierKeys <> Keys.Shift Then
|
|
Dim nFlag As Integer
|
|
Dim nLeft As Integer
|
|
Dim nTop As Integer
|
|
Dim nWidth As Integer
|
|
Dim nHeight As Integer
|
|
GetPrivateProfileWinPos("General", "WinPlace", nFlag, nLeft, nTop, nWidth, nHeight, m_sIniFile)
|
|
Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
|
|
Me.Location = New Point(nLeft, nTop)
|
|
Me.Size = New Size(nWidth, nHeight)
|
|
WindowState = IIf(nFlag = 1, FormWindowState.Maximized, FormWindowState.Normal)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub MainForm_FormClosing(sender As System.Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
|
|
'Salvo posizione Form
|
|
Dim nFlag As Integer = IIf(Me.WindowState = FormWindowState.Maximized, 1, 0)
|
|
WritePrivateProfileWinPos("General", "WinPlace", nFlag, Me.Left, Me.Top, Me.Width, Me.Height, m_sIniFile)
|
|
'Terminazione generale di EgtInterface
|
|
EgtExit()
|
|
End Sub
|
|
|
|
Private Sub OnMouseSelectedAll(ByVal sender As Object) Handles Scene1.OnMouseSelectedAll, Scene2.OnMouseSelectedAll
|
|
If sender.GetCtx() = 1 Then
|
|
m_Controller1.MouseSelectedAll()
|
|
Else
|
|
m_Controller2.MouseSelectedAll()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnMouseDeselectedAll(ByVal sender As Object) Handles Scene1.OnMouseDeselectedAll, Scene2.OnMouseDeselectedAll
|
|
If sender.GetCtx() = 1 Then
|
|
m_Controller1.MouseDeselectedAll()
|
|
Else
|
|
m_Controller2.MouseDeselectedAll()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnMouseSelectedObj(ByVal sender As Object, ByVal nId As Integer, ByVal bLast As Boolean) Handles Scene1.OnMouseSelectedObj, Scene2.OnMouseSelectedObj
|
|
If sender.GetCtx() = 1 Then
|
|
m_Controller1.MouseSelectedObj(nId, bLast)
|
|
Else
|
|
m_Controller2.MouseSelectedObj(nId, bLast)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnMouseSelectedPart(ByVal sender As Object, ByVal nId As Integer) Handles Scene1.OnMouseSelectedPart, Scene2.OnMouseSelectedPart
|
|
If sender.GetCtx() = 1 Then
|
|
m_Controller1.MouseSelectedPart(nId)
|
|
Else
|
|
m_Controller2.MouseSelectedPart(nId)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnMouseSelectedLayer(ByVal sender As Object, ByVal nId As Integer) Handles Scene1.OnMouseSelectedLayer, Scene2.OnMouseSelectedLayer
|
|
If sender.GetCtx() = 1 Then
|
|
m_Controller1.MouseSelectedLayer(nId)
|
|
Else
|
|
m_Controller2.MouseSelectedLayer(nId)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnMouseAnalyzed(ByVal sender As Object, ByVal nId As Integer) Handles Scene1.OnMouseAnalyzed, Scene2.OnMouseAnalyzed
|
|
Dim sOut As String = String.Empty
|
|
If (EgtGeoObjDump(nId, sOut)) Then
|
|
EgtSetMark(nId)
|
|
EgtDraw()
|
|
Dim AnalDlg As New AnalyzeDlg
|
|
AnalDlg.SetText(sOut)
|
|
AnalDlg.ShowDialog()
|
|
End If
|
|
EgtResetMark(nId)
|
|
EgtDraw()
|
|
TsInfo1.btnAnalyze.Checked = False
|
|
sender.ResetStatusAnalyze()
|
|
End Sub
|
|
|
|
Private Sub OnMouseDownScene(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Scene1.OnMouseDownScene, Scene2.OnMouseDownScene
|
|
If sender.GetCtx() = 1 Then
|
|
RadioButton1.Checked = True
|
|
Else
|
|
RadioButton2.Checked = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnCursorPos(ByVal sender As Object, ByVal sCursorPos As String) Handles Scene1.OnCursorPos, Scene2.OnCursorPos
|
|
If sender.GetCtx() = 1 Then
|
|
StatusCoord1.Text = sCursorPos
|
|
Else
|
|
StatusCoord2.Text = sCursorPos
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnShowDistance(ByVal sender As Object, ByVal sDistance As String) Handles Scene1.OnShowDistance, Scene2.OnShowDistance
|
|
If sender.GetCtx() = 1 Then
|
|
StatusOutput1.Text = sDistance
|
|
Else
|
|
StatusOutput2.Text = sDistance
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnCloseGetDist1(ByVal sender As Object) Handles Scene1.OnCloseGetDist, Scene2.OnCloseGetDist
|
|
If sender.GetCtx() = 1 Then
|
|
StatusOutput1.Text = " "
|
|
Else
|
|
StatusOutput2.Text = " "
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged
|
|
TsInfo1.btnGetDist.Checked = False
|
|
TsInfo1.btnAnalyze.Checked = False
|
|
If RadioButton1.Checked Then
|
|
EnableView(Scene1, m_Controller1)
|
|
Else
|
|
EnableView(Scene2, m_Controller2)
|
|
End If
|
|
Dim nShowMode As Integer = EgtGetShowMode()
|
|
TsRendering1.btnWireframe.Checked = (nShowMode = SM.WIREFRAME)
|
|
TsRendering1.btnHiddenLine.Checked = (nShowMode = SM.HIDDENLINE)
|
|
TsRendering1.btnShading.Checked = (nShowMode = SM.SHADING)
|
|
End Sub
|
|
|
|
Private Sub EnableView(ByRef scene As EgtUILib.Scene, ByRef controller As EgtUILib.Controller)
|
|
EgtSetCurrentContext(scene.GetCtx())
|
|
TsMain1.SetController(controller)
|
|
TsRendering1.SetScene(scene)
|
|
TsLookFrom1.SetScene(scene)
|
|
TsZoom1.SetScene(scene)
|
|
TsExec1.SetController(controller)
|
|
TsInfo1.SetScene(scene)
|
|
End Sub
|
|
|
|
End Class
|