7abeca0815
- aggiunta gestione direzione di vista standard da ini macchina ([General] StandardView=SE (ammessi SW, SE, NE, NW con SW default).
318 lines
14 KiB
VB.net
318 lines
14 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Module CurrentMachine
|
|
|
|
Private m_Salt As String = "3,1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679"
|
|
|
|
' Nome macchina corrente
|
|
Private m_sMachineName As String = String.Empty
|
|
Friend ReadOnly Property sMachineName As String
|
|
Get
|
|
Return m_sMachineName
|
|
End Get
|
|
End Property
|
|
' Direttorio macchina corrente
|
|
Private m_sMachDir As String = String.Empty
|
|
Friend ReadOnly Property sMachDir As String
|
|
Get
|
|
Return m_sMachDir
|
|
End Get
|
|
End Property
|
|
' File ini della macchina
|
|
Private m_sMachIniFile As String = String.Empty
|
|
Friend ReadOnly Property sMachIniFile As String
|
|
Get
|
|
Return m_sMachIniFile
|
|
End Get
|
|
End Property
|
|
' File ini dei dati della macchina
|
|
Private m_sMachDataIniFile As String = String.Empty
|
|
Friend ReadOnly Property sMachDataIniFile As String
|
|
Get
|
|
Return m_sMachDataIniFile
|
|
End Get
|
|
End Property
|
|
' File script della macchina
|
|
Private m_sMachScriptDir As String = String.Empty
|
|
Friend ReadOnly Property sMachScriptDir As String
|
|
Get
|
|
Return m_sMachScriptDir
|
|
End Get
|
|
End Property
|
|
' Cartella delle lavorazioni
|
|
Private m_sMachiningFilePath As String = String.Empty
|
|
Friend ReadOnly Property sMachiningFilePath As String
|
|
Get
|
|
Return m_sMachiningFilePath
|
|
End Get
|
|
End Property
|
|
Friend Sub SetMachiningFilePath(sValue As String)
|
|
m_sMachiningFilePath = sValue
|
|
End Sub
|
|
' Cartella dei materiali
|
|
Private m_sMaterialFilePath As String = String.Empty
|
|
Friend ReadOnly Property sMaterialFilePath As String
|
|
Get
|
|
Return m_sMaterialFilePath
|
|
End Get
|
|
End Property
|
|
Friend Sub SetMaterialFilePath(sValue As String)
|
|
m_sMaterialFilePath = sValue
|
|
End Sub
|
|
|
|
' box della tavola macchina
|
|
Private m_b3Tab As New BBox3d
|
|
Friend ReadOnly Property b3Tab As BBox3d
|
|
Get
|
|
Return m_b3Tab
|
|
End Get
|
|
End Property
|
|
|
|
' box dell'area di estrusione
|
|
Private m_b3ExtrusionArea As New BBox3d
|
|
Friend ReadOnly Property b3ExtrusionArea As BBox3d
|
|
Get
|
|
Return m_b3ExtrusionArea
|
|
End Get
|
|
End Property
|
|
|
|
' altezza massima di estrusione impostata in file ini macchina
|
|
Private m_dSlicingMaxHeight As Double
|
|
Public ReadOnly Property dSlicingMaxHeight As Double
|
|
Get
|
|
Return m_dSlicingMaxHeight
|
|
End Get
|
|
End Property
|
|
|
|
' direzione di vista standard
|
|
Private m_nStandardView As VT = VT.ISO_SW
|
|
Public ReadOnly Property nStandardView As VT
|
|
Get
|
|
Return m_nStandardView
|
|
End Get
|
|
End Property
|
|
|
|
#Region "Init"
|
|
|
|
Sub InitCurrentMachine(sMachinesRootDir As String, sMachineName As String)
|
|
' Nome macchina corrente
|
|
m_sMachineName = sMachineName
|
|
' Impostazione direttorio macchina
|
|
m_sMachDir = sMachinesRootDir & "\" & sMachineName
|
|
' Impostazione path MachIni file
|
|
m_sMachIniFile = sMachinesRootDir & "\" & sMachineName & "\" & sMachineName & ".ini"
|
|
' Impostazione path MachData Ini file
|
|
m_sMachDataIniFile = sMachinesRootDir & "\" & sMachineName & "\" & "CustomData" & "\" & MACHDATA_INI_FILE_NAME
|
|
If Not File.Exists(m_sMachDataIniFile) Then m_sMachDataIniFile = ""
|
|
' impostazione cartella script
|
|
m_sMachScriptDir = sMachinesRootDir & "\" & sMachineName & "\Scripts"
|
|
' impostazione cartella lavorazioni
|
|
m_sMachiningFilePath = sMachinesRootDir & "\" & sMachineName & "\Machinings\Machinings.ini"
|
|
' impostazione cartella materiali
|
|
m_sMaterialFilePath = sMachinesRootDir & "\" & sMachineName & "\Materials\Materials.ini"
|
|
' leggo altezza massima estrusione impostata su macchina
|
|
m_dSlicingMaxHeight = GetPrivateProfileDouble(S_MACH_PRINTING3D, K_MAX_HEIGHT, 900, m_sMachIniFile)
|
|
' leggo direzione di vista standard
|
|
Dim sView As String = ""
|
|
GetPrivateProfileString( S_GENERAL, K_GEN_STD_VIEW, "", sView, m_sMachIniFile)
|
|
Select sView
|
|
Case "SW"
|
|
m_nStandardView = VT.ISO_SW
|
|
Case "SE"
|
|
m_nStandardView = VT.ISO_SE
|
|
Case "NE"
|
|
m_nStandardView = VT.ISO_NE
|
|
Case "NW"
|
|
m_nStandardView = VT.ISO_NW
|
|
Case Else
|
|
m_nStandardView = VT.ISO_SW
|
|
End Select
|
|
' Disabilito segnalazione modificato
|
|
Dim DisableMgr As New DisableModifiedMgr
|
|
' recupero box macchina
|
|
Dim nQqqId = EgtAddMachGroup("qqq")
|
|
EgtSetTable("Tab")
|
|
EgtGetTableArea(1, m_b3Tab)
|
|
EgtResetCurrMachGroup()
|
|
EgtRemoveMachGroup(nQqqId)
|
|
' carico materiali e lavorazioni
|
|
Map.refTopPanelVM.InitMaterialList()
|
|
Map.refMaterialDbVM.Init()
|
|
Map.refTopPanelVM.InitMachiningsList()
|
|
Map.refMachiningDbVM.Init()
|
|
' Ripristino stato segnalazione modifica
|
|
DisableMgr.ReEnable()
|
|
End Sub
|
|
|
|
#End Region 'Init
|
|
|
|
#Region "Methods"
|
|
|
|
Public Sub CreateMachineTable()
|
|
' Disabilito segnalazione modificato
|
|
Dim DisableMgr As New DisableModifiedMgr
|
|
Dim dTabX = b3Tab.DimX()
|
|
Dim dTabY = b3Tab.DimY()
|
|
' Disegno tavola
|
|
Dim nTabPartId As Integer = EgtCreateGroup(GDB_ID.ROOT)
|
|
EgtSetLevel(nTabPartId, GDB_LV.SYSTEM)
|
|
EgtSetMode(nTabPartId, GDB_MD.LOCKED)
|
|
EgtSetStatus(nTabPartId, GDB_ST.ON_)
|
|
EgtSetName(nTabPartId, TABLE)
|
|
Dim nTabLayerId As Integer = EgtCreateGroup(nTabPartId)
|
|
EgtSetName(nTabLayerId, TABLE)
|
|
Dim nTabOutlineId As Integer = EgtCreateRectangle2P(nTabLayerId, New Point3d(0, 0, 0), New Point3d(dTabX, dTabY, 0))
|
|
EgtSetName(nTabOutlineId, TABLE_OUTLINE)
|
|
' scrivo il nome macchina sulla tavola
|
|
EgtSetInfo(nTabPartId, KEY_MACHINE_NAME, CurrentMachine.sMachineName)
|
|
' scrivo materiale sulla tavola
|
|
If Not IsNothing(Map.refTopPanelVM.SelMaterial) Then
|
|
EgtSetInfo(nTabPartId, KEY_MATERIAL_GUID, Map.refTopPanelVM.SelMaterial.sGUID)
|
|
EgtSetInfo(nTabPartId, KEY_MATERIAL_NAME, Map.refTopPanelVM.SelMaterial.sName)
|
|
End If
|
|
' creo area di estrusione
|
|
UpdateExtrusionArea()
|
|
' imposto dati griglia (primi tre parametri -1 indica tieni i correnti)
|
|
EgtSetGridGeoAdv( -1, -1, -1, 0, dTabX, 0, dTabY)
|
|
' Ripristino stato segnalazione modifica
|
|
DisableMgr.ReEnable()
|
|
End Sub
|
|
|
|
Public Sub SetTableVisibility(IsVisible As Boolean)
|
|
Dim nTableLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, TABLE)
|
|
EgtSetStatus(nTableLayerId, If(IsVisible, GDB_ST.ON_, GDB_ST.OFF))
|
|
End Sub
|
|
|
|
Public Sub UpdateExtrusionArea()
|
|
Dim DisableMgr As New DisableModifiedMgr
|
|
' recupero eventuale vecchia area di estrusione
|
|
Dim nTabPartId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, TABLE)
|
|
Dim nTabLayerId As Integer = EgtGetFirstNameInGroup(nTabPartId, TABLE)
|
|
Dim nExtrusionAreaId As Integer = EgtGetFirstNameInGroup(nTabLayerId, EXTRUSION_AREA)
|
|
If nExtrusionAreaId <> GDB_ID.NULL Then EgtErase(nExtrusionAreaId)
|
|
Dim nExtrusionRectId As Integer = EgtGetFirstNameInGroup(nTabLayerId, EXTRUSION_RECT)
|
|
If nExtrusionRectId <> GDB_ID.NULL Then EgtErase(nExtrusionRectId)
|
|
' se lavorazione corrente nulla, esco
|
|
If IsNothing(Map.refTopPanelVM.CurrMachining) Then
|
|
DisableMgr.ReEnable()
|
|
Return
|
|
End If
|
|
' se non esiste file dati macchina, esco
|
|
If String.IsNullOrWhiteSpace(m_sMachDataIniFile) Then
|
|
DisableMgr.ReEnable()
|
|
Return
|
|
End If
|
|
' recupero tipo di slice
|
|
Dim sExtrusionType As String = S_VERTICAL
|
|
Dim GeneralCathegory As MachiningCathegory = Map.refTopPanelVM.CurrMachining.CathegoryList.FirstOrDefault(Function(x) x.Type = MachiningCathegory.Cathegories.GENERAL)
|
|
Dim SlicingTypeParam As ComboMachiningParam = GeneralCathegory.MachiningParamList.FirstOrDefault(Function(x) x.Type = MachiningParam.Params.SLICINGTYPE)
|
|
Dim SlicingTypeValue As Machining.MPAR_SLICINGTYPE = SlicingTypeParam.SelValue.Id
|
|
Select Case SlicingTypeValue
|
|
Case Machining.MPAR_SLICINGTYPE.VERTICAL
|
|
sExtrusionType = S_VERTICAL
|
|
Case Machining.MPAR_SLICINGTYPE.DEG45
|
|
sExtrusionType = S_45DEGX
|
|
Case Machining.MPAR_SLICINGTYPE.DEG45_Y
|
|
sExtrusionType = S_45DEGY
|
|
Case Machining.MPAR_SLICINGTYPE.HORIZONTAL
|
|
sExtrusionType = S_HORIZONTAL
|
|
End Select
|
|
Dim dExtrXMax = GetPrivateProfileDouble(sExtrusionType, K_MAXX, 0, m_sMachDataIniFile)
|
|
Dim dExtrXMin = GetPrivateProfileDouble(sExtrusionType, K_MINX, 0, m_sMachDataIniFile)
|
|
Dim dExtrYMax = GetPrivateProfileDouble(sExtrusionType, K_MAXY, 0, m_sMachDataIniFile)
|
|
Dim dExtrYMin = GetPrivateProfileDouble(sExtrusionType, K_MINY, 0, m_sMachDataIniFile)
|
|
Const AREA_WIDTH As Double = 10
|
|
Dim nAuxRectId As Integer = EgtCreateRectangle2P(nTabLayerId, New Point3d(dExtrXMin - AREA_WIDTH, dExtrYMin - AREA_WIDTH, 0), New Point3d(dExtrXMax + AREA_WIDTH, dExtrYMax + AREA_WIDTH, 0))
|
|
nExtrusionRectId = EgtCreateRectangle2P(nTabLayerId, New Point3d(dExtrXMin, dExtrYMin, 0), New Point3d(dExtrXMax, dExtrYMax, 0))
|
|
nExtrusionAreaId = EgtCreateSurfTmByRegion( nTabLayerId, { nAuxRectId, nExtrusionRectId}, EPS_STM)
|
|
EgtErase( nAuxRectId)
|
|
Dim c3Temp As New Color3d
|
|
c3Temp.FromColor(System.Drawing.Color.Lime)
|
|
EgtSetColor(nExtrusionAreaId, c3Temp)
|
|
EgtSetName(nExtrusionAreaId, EXTRUSION_AREA)
|
|
EgtSetColor(nExtrusionRectId, c3Temp)
|
|
EgtSetName(nExtrusionRectId, EXTRUSION_RECT)
|
|
m_b3ExtrusionArea = New BBox3d(New Point3d(dExtrXMin, dExtrYMin, 0), New Point3d(dExtrXMax, dExtrYMax, 0))
|
|
DisableMgr.ReEnable()
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Friend Function ReadMachiningParamString(lpAppName As String, lpKeyName As String, lpDefault As String, ByRef lpString As String, Optional sFilePath As String = "") As Integer
|
|
Dim nResult As Integer = GetPrivateProfileString(lpAppName, lpKeyName, "", lpString, If(Not String.IsNullOrWhiteSpace(sFilePath), sFilePath, m_sMachiningFilePath))
|
|
If Not String.IsNullOrWhiteSpace(lpString) Then
|
|
lpString = EgwCrypto.PowerDecryptString(lpString, m_Salt)
|
|
Else
|
|
lpString = lpDefault
|
|
End If
|
|
Return nResult
|
|
End Function
|
|
|
|
Friend Function ReadMachiningParamSplit(lpAppName As String, lpKeyName As String, lpDefault As String, ByRef lpString As String, Optional sFilePath As String = "") As Integer
|
|
Dim nResult As Integer = GetPrivateProfileString(lpAppName, lpKeyName, "", lpString, If(Not String.IsNullOrWhiteSpace(sFilePath), sFilePath, m_sMachiningFilePath))
|
|
If Not String.IsNullOrWhiteSpace(lpString) Then
|
|
Dim Values() As String = lpString.Split(";"c)
|
|
Dim sCryptoValues As String = ""
|
|
For ValueIndex = 0 To Values.Count - 1
|
|
sCryptoValues += EgwCrypto.PowerDecryptString(Values(ValueIndex), m_Salt) & If(ValueIndex < Values.Count - 1, ";", "")
|
|
Next
|
|
lpString = sCryptoValues
|
|
Else
|
|
lpString = lpDefault
|
|
End If
|
|
Return nResult
|
|
End Function
|
|
|
|
Friend Function ReadMachiningParamDouble(lpAppName As String, lpKeyName As String, dDefault As Double, Optional sFilePath As String = "") As Double
|
|
Dim sParam As String = ""
|
|
Dim dParam As Double = dDefault
|
|
ReadMachiningParamString(lpAppName, lpKeyName, dDefault, sParam, sFilePath)
|
|
StringToDouble(sParam, dParam)
|
|
Return dParam
|
|
End Function
|
|
|
|
Friend Function WriteMachiningParam(lpAppName As String, lpKeyName As String, lpString As String, Optional sFilePath As String = "") As Boolean
|
|
Return WritePrivateProfileString(lpAppName, lpKeyName, EgwCrypto.PowerEncryptString(lpString, m_Salt), If(Not String.IsNullOrWhiteSpace(sFilePath), sFilePath, m_sMachiningFilePath))
|
|
End Function
|
|
|
|
Friend Function WriteMachiningParamSplit(lpAppName As String, lpKeyName As String, lpString As String, Optional sFilePath As String = "") As Boolean
|
|
If Not String.IsNullOrWhiteSpace(lpString) Then
|
|
Dim Values() As String = lpString.Split(";"c)
|
|
Dim sCryptoValues As String = ""
|
|
For ValueIndex = 0 To Values.Count - 1
|
|
sCryptoValues += EgwCrypto.PowerEncryptString(Values(ValueIndex), m_Salt) & If(ValueIndex < Values.Count - 1, ";", "")
|
|
Next
|
|
Return WritePrivateProfileString(lpAppName, lpKeyName, sCryptoValues, If(Not String.IsNullOrWhiteSpace(sFilePath), sFilePath, m_sMachiningFilePath))
|
|
Else
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
Friend Function ReadMaterialParamString(lpAppName As String, lpKeyName As String, lpDefault As String, ByRef lpString As String, Optional sFilePath As String = "") As Integer
|
|
Dim nResult As Integer = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, lpString, If(Not String.IsNullOrWhiteSpace(sFilePath), sFilePath, m_sMaterialFilePath))
|
|
If Not String.IsNullOrWhiteSpace(lpString) Then
|
|
lpString = EgwCrypto.PowerDecryptString(lpString, m_Salt)
|
|
Else
|
|
lpString = ""
|
|
End If
|
|
Return nResult
|
|
End Function
|
|
|
|
Friend Function ReadMaterialParamDouble(lpAppName As String, lpKeyName As String, dDefault As Double, Optional sFilePath As String = "") As Double
|
|
Dim sParam As String = ""
|
|
Dim dParam As Double = dDefault
|
|
ReadMaterialParamString(lpAppName, lpKeyName, dDefault, sParam, sFilePath)
|
|
StringToDouble(sParam, dParam)
|
|
Return dParam
|
|
End Function
|
|
|
|
Friend Function WriteMaterialParam(lpAppName As String, lpKeyName As String, lpString As String, Optional sFilePath As String = "") As Boolean
|
|
Return WritePrivateProfileString(lpAppName, lpKeyName, EgwCrypto.PowerEncryptString(lpString, m_Salt), If(Not String.IsNullOrWhiteSpace(sFilePath), sFilePath, m_sMaterialFilePath))
|
|
End Function
|
|
|
|
#End Region 'Methods
|
|
|
|
End Module
|