dffe9de64e
- Migliorie SetUp. - Migliorie simulazione.
1593 lines
57 KiB
VB.net
1593 lines
57 KiB
VB.net
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports System.Text.RegularExpressions
|
|
Imports EgtUILib
|
|
|
|
Public Class FamilyToolTreeViewItem
|
|
Inherits InheritableTreeViewItem
|
|
|
|
Public Overrides Property IsSelected As Boolean
|
|
Get
|
|
Return m_IsSelected
|
|
End Get
|
|
Set(value As Boolean)
|
|
If (value <> m_IsSelected) Then
|
|
m_IsSelected = value
|
|
If value Then
|
|
' The function that I want to call When Parent item is selected in the tree
|
|
If EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
|
EgtNewFile()
|
|
EgtSetView(VT.TOP, False)
|
|
EgtZoom(ZM.ALL)
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
End If
|
|
End If
|
|
NotifyPropertyChanged("IsSelected")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ToolType As MCH_TF
|
|
''' <summary>
|
|
''' Property that determines the tool type of the family
|
|
''' </summary>
|
|
Public Property ToolType As MCH_TF
|
|
Get
|
|
Return m_ToolType
|
|
End Get
|
|
Set(value As MCH_TF)
|
|
m_ToolType = value
|
|
End Set
|
|
End Property
|
|
|
|
' Proprietà che permette di nascondere tutti i parametri utensile grazie al binding ed al converter
|
|
Public ReadOnly Property Type As Integer
|
|
Get
|
|
Return MCH_TY.NONE
|
|
End Get
|
|
End Property
|
|
|
|
Sub New(Name As String, ToolFamily As MCH_TF)
|
|
MyBase.New(Name)
|
|
Me.PictureString = "/Resources/TreeView/Folder.png"
|
|
Me.m_ToolType = ToolFamily
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class ToolTreeViewItem
|
|
Inherits InheritableTreeViewItem
|
|
Implements IDataErrorInfo
|
|
|
|
#Region "Tool Property"
|
|
|
|
' Variabile che indica quando non lanciare l'update del disegno utensile
|
|
' (utile per evitare di rifare il disegno più volte quando vengono caricati i parametri alla selezione di un utensile)
|
|
Private m_SuspendToolDrawUpdate As Boolean = False
|
|
|
|
Private m_ErrorOnTool As Boolean
|
|
Public Property ErrorOnTool As Boolean
|
|
Get
|
|
Return m_ErrorOnTool
|
|
End Get
|
|
Set(value As Boolean)
|
|
If IsValid Then
|
|
m_ErrorOnTool = False
|
|
Application.Msn.NotifyColleagues(Application.ERRORONTOOL, Nothing)
|
|
Else
|
|
m_ErrorOnTool = True
|
|
Application.Msn.NotifyColleagues(Application.ERRORONTOOL, Me)
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
' Variabile che indica se l'utensile è appena stato creato
|
|
Dim m_NewTool As Boolean = False
|
|
Public Property NewTool As Boolean
|
|
Get
|
|
Return m_NewTool
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_NewTool = value
|
|
End Set
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Property that determines if the Tool is selected or not
|
|
''' </summary>
|
|
Public Overrides Property IsSelected As Boolean
|
|
Get
|
|
Return m_IsSelected
|
|
End Get
|
|
Set(value As Boolean)
|
|
If (value <> m_IsSelected) Then
|
|
m_IsSelected = value
|
|
If value Then
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbSetCurrTool(Me.Name)
|
|
ReadToolParam()
|
|
IsModifiedReset()
|
|
NotifyPropertyChanged("Type")
|
|
Else
|
|
WriteToolParam()
|
|
If EgtTdbIsCurrToolModified() Or m_IsModifiedName Or Me.NewTool Then
|
|
Select Case MsgBox(EgtMsg(MSG_TOOLSERRORS), MsgBoxStyle.YesNo, EgtMsg(MSG_TOOLSERRORS + 1))
|
|
Case MsgBoxResult.Yes
|
|
m_NewTool = False
|
|
m_Name = m_Name.Trim()
|
|
WriteToolName()
|
|
If IsUUID(Path.GetFileNameWithoutExtension(m_Draw)) Then
|
|
SaveToolDraw()
|
|
End If
|
|
EgtTdbSaveCurrTool()
|
|
EgtTdbSave()
|
|
Case MsgBoxResult.No
|
|
If m_NewTool Then
|
|
Application.Msn.NotifyColleagues(Application.REMOVETOOL, Me)
|
|
ElseIf m_IsModifiedName Then
|
|
Dim DbName As String = String.Empty
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.NAME, DbName)
|
|
NamePar = DbName
|
|
End If
|
|
End Select
|
|
End If
|
|
End If
|
|
NotifyPropertyChanged("IsSelected")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedCorr As Boolean = False
|
|
Private m_Corr As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Corrector
|
|
''' </summary>
|
|
Public Property Corr As String
|
|
Get
|
|
Return m_Corr
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_Corr Then
|
|
m_Corr = value
|
|
Dim DbCorr As Integer = 0
|
|
Dim nValue As Integer = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.CORR, DbCorr)
|
|
Int32.TryParse(value, nValue)
|
|
m_IsModifiedCorr = If(nValue <> DbCorr, True, False)
|
|
NotifyPropertyChanged("Corr")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedExit As Boolean = False
|
|
Private m_Exit As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Exit
|
|
''' </summary>
|
|
Public Property ExitPar As String
|
|
Get
|
|
Return m_Exit
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_Exit Then
|
|
m_Exit = value
|
|
Dim DbExit As Integer = 0
|
|
Dim nValue As Integer = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.EXIT_, DbExit)
|
|
Int32.TryParse(value, nValue)
|
|
m_IsModifiedExit = If(nValue <> DbExit, True, False)
|
|
If Not m_SuspendToolDrawUpdate Then
|
|
UpdateSceneToolDraw(DrawUpdateSource.EXIT_)
|
|
End If
|
|
NotifyPropertyChanged("ExitPar")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Type As Integer
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Type
|
|
''' </summary>
|
|
Public Property Type As Integer
|
|
Get
|
|
Return m_Type
|
|
End Get
|
|
Set(value As Integer)
|
|
If value <> m_Type Then
|
|
m_Type = value
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedCoolant As Boolean = False
|
|
Private m_Coolant As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Coolant
|
|
''' </summary>
|
|
Public Property Coolant As String
|
|
Get
|
|
Return m_Coolant
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_Coolant Then
|
|
m_Coolant = value
|
|
Dim DbCoolant As Integer = 0
|
|
Dim nValue As Integer = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.COOLANT, DbCoolant)
|
|
Int32.TryParse(value, nValue)
|
|
m_IsModifiedCoolant = If(nValue <> DbCoolant, True, False)
|
|
NotifyPropertyChanged("Coolant")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedCornRad As Boolean = False
|
|
Private m_CornRad As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Corner Radius
|
|
''' </summary>
|
|
Public Property CornRad As String
|
|
Get
|
|
Return m_CornRad
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_CornRad Then
|
|
m_CornRad = value
|
|
Dim DbCornRad As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.CORNRAD, DbCornRad)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedCornRad = Math.Abs(dValue - DbCornRad) > 10 * EPS_ANG_SMALL
|
|
NotifyPropertyChanged("CornRad")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedDiam As Boolean = False
|
|
Private m_Diam As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Diameter
|
|
''' </summary>
|
|
Public Property Diam As String
|
|
Get
|
|
Return m_Diam
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_Diam Then
|
|
m_Diam = value
|
|
Dim DbDiam As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.DIAM, DbDiam)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedDiam = Math.Abs(dValue - DbDiam) > 10 * EPS_ANG_SMALL
|
|
If Not m_SuspendToolDrawUpdate Then
|
|
UpdateSceneToolDraw(DrawUpdateSource.DIAM)
|
|
End If
|
|
NotifyPropertyChanged("Diam")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedTotDiam As Boolean = False
|
|
Private m_TotDiam As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Total Diameter
|
|
''' </summary>
|
|
Public Property TotDiam As String
|
|
Get
|
|
Return m_TotDiam
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_TotDiam Then
|
|
m_TotDiam = value
|
|
Dim DbTotDiam As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.TOTDIAM, DbTotDiam)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedTotDiam = Math.Abs(dValue - DbTotDiam) > 10 * EPS_SMALL
|
|
NotifyPropertyChanged("TotDiam")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedFeed As Boolean = False
|
|
Private m_Feed As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Feed
|
|
''' </summary>
|
|
Public Property Feed As String
|
|
Get
|
|
Return m_Feed
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_Feed Then
|
|
m_Feed = value
|
|
Dim DbFeed As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.FEED, DbFeed)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedFeed = Math.Abs(dValue - DbFeed) > 10 * EPS_SMALL
|
|
NotifyPropertyChanged("Feed")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedEndFeed As Boolean = False
|
|
Private m_EndFeed As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the End Feed
|
|
''' </summary>
|
|
Public Property EndFeed As String
|
|
Get
|
|
Return m_EndFeed
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_EndFeed Then
|
|
m_EndFeed = value
|
|
Dim DbEndFeed As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.ENDFEED, DbEndFeed)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedEndFeed = Math.Abs(dValue - DbEndFeed) > 10 * EPS_SMALL
|
|
NotifyPropertyChanged("EndFeed")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedStartFeed As Boolean = False
|
|
Private m_StartFeed As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Start Feed
|
|
''' </summary>
|
|
Public Property StartFeed As String
|
|
Get
|
|
Return m_StartFeed
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_StartFeed Then
|
|
m_StartFeed = value
|
|
Dim DbStartFeed As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.STARTFEED, DbStartFeed)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedStartFeed = Math.Abs(dValue - DbStartFeed) > 10 * EPS_SMALL
|
|
NotifyPropertyChanged("StartFeed")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedTipFeed As Boolean = False
|
|
Private m_TipFeed As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Tip Feed
|
|
''' </summary>
|
|
Public Property TipFeed As String
|
|
Get
|
|
Return m_TipFeed
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_TipFeed Then
|
|
m_TipFeed = value
|
|
Dim DbTipFeed As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.TIPFEED, DbTipFeed)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedTipFeed = Math.Abs(dValue - DbTipFeed) > 10 * EPS_SMALL
|
|
NotifyPropertyChanged("TipFeed")
|
|
' Se fresa e 0 non può lavorare di testa
|
|
If (Type And MCH_TF.MILL) <> 0 Then
|
|
If dValue > EPS_SMALL Then
|
|
Type = MCH_TY.MILL_STD
|
|
Else
|
|
Type = MCH_TY.MILL_NOTIP
|
|
End If
|
|
End If
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedLen As Boolean = False
|
|
Private m_Len As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Len
|
|
''' </summary>
|
|
Public Property Len As String
|
|
Get
|
|
Return m_Len
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_Len Then
|
|
m_Len = value
|
|
Dim DbLen As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.LEN, DbLen)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedLen = Math.Abs(dValue - DbLen) > 10 * EPS_SMALL
|
|
If Not m_SuspendToolDrawUpdate Then
|
|
UpdateSceneToolDraw(DrawUpdateSource.LEN)
|
|
End If
|
|
NotifyPropertyChanged("Len")
|
|
' Se lama
|
|
If (Type And MCH_TF.SAWBLADE) <> 0 Then
|
|
Dim CurrTotLen As Double = 0
|
|
If Not IsNothing(TotLen) Then
|
|
StringToLen(TotLen, CurrTotLen)
|
|
' se len e totlen coincidono tipo piatto
|
|
If (CurrTotLen - dValue) > 10 * EPS_SMALL Then
|
|
Type = MCH_TY.SAW_STD
|
|
Else
|
|
Type = MCH_TY.SAW_FLAT
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedTotLen As Boolean = False
|
|
Private m_TotLen As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Total Len
|
|
''' </summary>
|
|
Public Property TotLen As String
|
|
Get
|
|
Return m_TotLen
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_TotLen Then
|
|
m_TotLen = value
|
|
Dim DbTotLen As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.TOTLEN, DbTotLen)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedTotLen = Math.Abs(dValue - DbTotLen) > 10 * EPS_SMALL
|
|
If Not m_SuspendToolDrawUpdate Then
|
|
UpdateSceneToolDraw(DrawUpdateSource.TOTLEN)
|
|
End If
|
|
NotifyPropertyChanged("TotLen")
|
|
' Se lama e len e totlen coincidono tipo piatto
|
|
If (Type And MCH_TF.SAWBLADE) <> 0 Then
|
|
If Not IsNothing(Len) Then
|
|
Dim CurrLen As Double = 0
|
|
StringToLen(Len, CurrLen)
|
|
If (dValue - CurrLen) > 10 * EPS_SMALL Then
|
|
Type = MCH_TY.SAW_STD
|
|
Else
|
|
Type = MCH_TY.SAW_FLAT
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedMaxMat As Boolean = False
|
|
Private m_MaxMat As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Max Material
|
|
''' </summary>
|
|
Public Property MaxMat As String
|
|
Get
|
|
Return m_MaxMat
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_MaxMat Then
|
|
m_MaxMat = value
|
|
Dim DbMaxMat As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, DbMaxMat)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedMaxMat = Math.Abs(dValue - DbMaxMat) > 10 * EPS_SMALL
|
|
If Not m_SuspendToolDrawUpdate Then
|
|
UpdateSceneToolDraw(DrawUpdateSource.MAXMAT)
|
|
End If
|
|
NotifyPropertyChanged("MaxMat")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedLonOffset As Boolean = False
|
|
Private m_LonOffset As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Lon Offset
|
|
''' </summary>
|
|
Public Property LonOffset As String
|
|
Get
|
|
Return m_LonOffset
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_LonOffset Then
|
|
m_LonOffset = value
|
|
Dim DbLonOffset As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.LONOFFSET, DbLonOffset)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedLonOffset = Math.Abs(dValue - DbLonOffset) > 10 * EPS_SMALL
|
|
NotifyPropertyChanged("LonOffset")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedRadOffset As Boolean = False
|
|
Private m_RadOffset As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Rad Offset
|
|
''' </summary>
|
|
Public Property RadOffset As String
|
|
Get
|
|
Return m_RadOffset
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_RadOffset Then
|
|
m_RadOffset = value
|
|
Dim DbRadOffset As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.RADOFFSET, DbRadOffset)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedRadOffset = Math.Abs(dValue - DbRadOffset) > 10 * EPS_SMALL
|
|
NotifyPropertyChanged("RadOffset")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedSpeed As Boolean = False
|
|
Private m_Speed As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Speed
|
|
''' </summary>
|
|
Public Property Speed As String
|
|
Get
|
|
Return m_Speed
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_Speed Then
|
|
m_Speed = value
|
|
Dim DbSpeed As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.SPEED, DbSpeed)
|
|
StringToDouble(value, dValue)
|
|
m_IsModifiedSpeed = Math.Abs(dValue - DbSpeed) > 10 * EPS_ANG_SMALL
|
|
NotifyPropertyChanged("Speed")
|
|
NotifyPropertyChanged("MaxSpeed")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedSideAng As Boolean = False
|
|
Private m_SideAng As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Side Angle
|
|
''' </summary>
|
|
Public Property SideAng As String
|
|
Get
|
|
Return m_SideAng
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_SideAng Then
|
|
m_SideAng = value
|
|
Dim DbSideAng As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.SIDEANG, DbSideAng)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedSideAng = Math.Abs(dValue - DbSideAng) > 10 * EPS_ANG_SMALL
|
|
NotifyPropertyChanged("SideAng")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedMaxSpeed As Boolean = False
|
|
Private m_MaxSpeed As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Max Speed
|
|
''' </summary>
|
|
Public Property MaxSpeed As String
|
|
Get
|
|
Return m_MaxSpeed
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_MaxSpeed Then
|
|
m_MaxSpeed = value
|
|
Dim DbMaxSpeed As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.MAXSPEED, DbMaxSpeed)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedMaxSpeed = Math.Abs(dValue - DbMaxSpeed) > 10 * EPS_ANG_SMALL
|
|
NotifyPropertyChanged("Speed")
|
|
NotifyPropertyChanged("MaxSpeed")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedThick As Boolean = False
|
|
Private m_Thick As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Thick
|
|
''' </summary>
|
|
Public Property Thick As String
|
|
Get
|
|
Return m_Thick
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_Thick Then
|
|
m_Thick = value
|
|
Dim DbThick As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.THICK, DbThick)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedThick = Math.Abs(dValue - DbThick) > 10 * EPS_SMALL
|
|
If Not m_SuspendToolDrawUpdate Then
|
|
UpdateSceneToolDraw(DrawUpdateSource.THICK)
|
|
End If
|
|
NotifyPropertyChanged("Thick")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedMaxAbsorption As Boolean = False
|
|
Private m_MaxAbsorption As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Max Absorption
|
|
''' </summary>
|
|
Public Property MaxAbsorption As String
|
|
Get
|
|
Return m_MaxAbsorption
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_MaxAbsorption Then
|
|
m_MaxAbsorption = value
|
|
Dim DbMaxAbsorption As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.MAXABSORPTION, DbMaxAbsorption)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedMaxAbsorption = Math.Abs(dValue - DbMaxAbsorption) > 10 * EPS_SMALL
|
|
NotifyPropertyChanged("MaxAbsorption")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedMinFeed As Boolean = False
|
|
Private m_MinFeed As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Min Feed
|
|
''' </summary>
|
|
Public Property MinFeed As String
|
|
Get
|
|
Return m_MinFeed
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_MinFeed Then
|
|
m_MinFeed = value
|
|
Dim DbMinFeed As Double = 0
|
|
Dim dValue As Double = 0
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.MINFEED, DbMinFeed)
|
|
StringToLen(value, dValue)
|
|
m_IsModifiedMinFeed = Math.Abs(dValue - DbMinFeed) > 10 * EPS_SMALL
|
|
NotifyPropertyChanged("MinFeed")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedDraw As Boolean = False
|
|
Friend m_Draw As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Draw
|
|
''' </summary>
|
|
Public Property Draw As String
|
|
Get
|
|
Return m_Draw
|
|
End Get
|
|
Set(value As String)
|
|
If value = String.Empty Or value <> m_Draw Then
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
If value = ToolDrawUUIDName Then
|
|
value = m_Draw
|
|
ElseIf value = ToolDrawUUIDName.Substring(0, ToolDrawUUIDName.Length - 1) Then
|
|
value = String.Empty
|
|
End If
|
|
m_Draw = value
|
|
Dim DbDraw As String = String.Empty
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.DRAW, DbDraw)
|
|
m_IsModifiedDraw = If(value <> DbDraw, True, False)
|
|
If Not m_SuspendToolDrawUpdate Then
|
|
UpdateSceneToolDraw(DrawUpdateSource.DRAW)
|
|
End If
|
|
NotifyPropertyChanged("Draw")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedHead As Boolean = False
|
|
Private m_Head As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Head
|
|
''' </summary>
|
|
Public Property Head As String
|
|
Get
|
|
Return m_Head
|
|
End Get
|
|
Set(value As String)
|
|
If value = String.Empty Or value <> m_Head Then
|
|
m_Head = value
|
|
Dim DbHead As String = String.Empty
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.HEAD, DbHead)
|
|
m_IsModifiedHead = If(value <> DbHead, True, False)
|
|
If Not m_SuspendToolDrawUpdate Then
|
|
UpdateSceneToolDraw(DrawUpdateSource.HEAD)
|
|
End If
|
|
NotifyPropertyChanged("Head")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
' Variabile che indica se c'è un errore nel nome dell'utensile (ad esempio nome già utilizzato)
|
|
Dim nErrorToolName As Integer = 0
|
|
' Array dei caratteri vietati
|
|
Dim cForbiddenCharacter() As Char = {"\"c, "/"c, ":"c, "*"c, "?"c, """"c, "<"c, ">"c, "|"c}
|
|
Friend m_IsModifiedName As Boolean = False
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Name
|
|
''' </summary>
|
|
Public Property NamePar As String
|
|
Get
|
|
Return m_Name
|
|
End Get
|
|
Set(value As String)
|
|
If value = String.Empty Or value <> m_Name Then
|
|
nErrorToolName = 0
|
|
m_Name = value
|
|
' Verifico se il nome contiene uno dei caratteri vietati
|
|
For Each cForbidden In cForbiddenCharacter
|
|
If m_Name.Contains(cForbidden) Then
|
|
nErrorToolName = 2
|
|
Exit For
|
|
End If
|
|
Next
|
|
' Verifico se il nome è diverso da quello nel database e imposto l'apposito flag
|
|
Dim DbName As String = String.Empty
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.NAME, DbName)
|
|
m_IsModifiedName = If(value <> DbName, True, False)
|
|
' Verifico che il nuovo nome sia valido
|
|
Dim sTempName As String = value
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetToolNewName(sTempName)
|
|
If m_IsModifiedName And Not value = sTempName Then
|
|
nErrorToolName = 1
|
|
End If
|
|
NotifyPropertyChanged("NamePar")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedUserNotes As Boolean = False
|
|
Private m_UserNotes As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the User Notes
|
|
''' </summary>
|
|
Public Property UserNotes As String
|
|
Get
|
|
Return m_UserNotes
|
|
End Get
|
|
Set(value As String)
|
|
If value = String.Empty Or value <> m_UserNotes Then
|
|
Dim DbUserNotes As String = String.Empty
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.USERNOTES, DbUserNotes)
|
|
m_IsModifiedUserNotes = If(value <> DbUserNotes, True, False)
|
|
m_UserNotes = value
|
|
NotifyPropertyChanged("UserNotes")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Friend Shared m_TcPosList As New List(Of String)
|
|
Public ReadOnly Property TcPosList As List(Of String)
|
|
Get
|
|
Return m_TcPosList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_IsModifiedTcPos As Boolean = False
|
|
Private m_SelectedTcPos As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Tc Pos
|
|
''' </summary>
|
|
Public Property SelectedTcPos As String
|
|
Get
|
|
Return m_SelectedTcPos
|
|
End Get
|
|
Set(value As String)
|
|
If value = String.Empty Or value <> m_SelectedTcPos Then
|
|
Dim DbTcPos As String = String.Empty
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetCurrToolParam(MCH_TP.TCPOS, DbTcPos)
|
|
m_IsModifiedTcPos = If(value <> DbTcPos, True, False)
|
|
m_SelectedTcPos = value
|
|
NotifyPropertyChanged("SelectedTcPos")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Uuid As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Uuid
|
|
''' </summary>
|
|
Public ReadOnly Property Uuid As String
|
|
Get
|
|
Return m_Uuid
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Tool Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdOpenDrawFile As ICommand
|
|
|
|
#Region "Constructors"
|
|
|
|
Sub New(Name As String)
|
|
MyBase.New(Name)
|
|
End Sub
|
|
|
|
#End Region ' Constructors
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub ReadToolParam()
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
' sospendo l'aggiornamento del disegno per evitare di rifarlo al cambio di ogni parametro inerente
|
|
m_SuspendToolDrawUpdate = True
|
|
Dim nValue As Integer = 0
|
|
Dim dValue As Double = 0
|
|
Dim sValue As String = String.Empty
|
|
EgtTdbGetCurrToolParam(MCH_TP.CORR, nValue)
|
|
Corr = nValue.ToString()
|
|
EgtTdbGetCurrToolParam(MCH_TP.EXIT_, nValue)
|
|
ExitPar = nValue.ToString()
|
|
EgtTdbGetCurrToolParam(MCH_TP.TYPE, nValue)
|
|
Type = nValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.COOLANT, nValue)
|
|
Coolant = nValue.ToString()
|
|
EgtTdbGetCurrToolParam(MCH_TP.CORNRAD, dValue)
|
|
CornRad = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.DIAM, dValue)
|
|
Diam = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.TOTDIAM, dValue)
|
|
TotDiam = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.FEED, dValue)
|
|
Feed = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.ENDFEED, dValue)
|
|
EndFeed = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.STARTFEED, dValue)
|
|
StartFeed = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.TIPFEED, dValue)
|
|
TipFeed = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.LEN, dValue)
|
|
Len = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.TOTLEN, dValue)
|
|
TotLen = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, dValue)
|
|
MaxMat = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.LONOFFSET, dValue)
|
|
LonOffset = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.RADOFFSET, dValue)
|
|
RadOffset = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.SPEED, dValue)
|
|
Speed = DoubleToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.SIDEANG, dValue)
|
|
SideAng = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.MAXSPEED, dValue)
|
|
MaxSpeed = DoubleToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.THICK, dValue)
|
|
Thick = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.MAXABSORPTION, dValue)
|
|
MaxAbsorption = DoubleToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.MINFEED, dValue)
|
|
MinFeed = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.DRAW, sValue)
|
|
Draw = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.HEAD, sValue)
|
|
Head = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.NAME, sValue)
|
|
NamePar = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.USERNOTES, sValue)
|
|
UserNotes = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sValue)
|
|
SelectedTcPos = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.UUID, sValue)
|
|
m_Uuid = sValue
|
|
' Ora che tutti i parametri sono aggiornati, aggiorno il disegno
|
|
m_SuspendToolDrawUpdate = False
|
|
UpdateSceneToolDraw(DrawUpdateSource.LEN)
|
|
NotifyPropertyChanged("Draw")
|
|
NotifyPropertyChanged("MaxMat")
|
|
NotifyPropertyChanged("Thick")
|
|
NotifyPropertyChanged("Diam")
|
|
NotifyPropertyChanged("Len")
|
|
NotifyPropertyChanged("TotLen")
|
|
End Sub
|
|
|
|
Friend Sub WriteToolParam()
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
Dim nValue As Integer = 0
|
|
Dim dValue As Double = 0
|
|
Int32.TryParse(Corr, nValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.CORR, nValue)
|
|
Int32.TryParse(ExitPar, nValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.EXIT_, nValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.TYPE, Type)
|
|
Int32.TryParse(Coolant, nValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.COOLANT, nValue)
|
|
StringToLen(CornRad, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.CORNRAD, dValue)
|
|
StringToLen(Diam, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.DIAM, dValue)
|
|
StringToLen(TotDiam, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dValue)
|
|
StringToLen(Feed, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.FEED, dValue)
|
|
StringToLen(EndFeed, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.ENDFEED, dValue)
|
|
StringToLen(StartFeed, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.STARTFEED, dValue)
|
|
StringToLen(TipFeed, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.TIPFEED, dValue)
|
|
StringToLen(Len, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.LEN, dValue)
|
|
StringToLen(TotLen, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dValue)
|
|
StringToLen(MaxMat, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, dValue)
|
|
StringToLen(LonOffset, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.LONOFFSET, dValue)
|
|
StringToLen(RadOffset, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.RADOFFSET, dValue)
|
|
StringToDouble(Speed, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.SPEED, dValue)
|
|
StringToLen(SideAng, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.SIDEANG, dValue)
|
|
StringToDouble(MaxSpeed, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.MAXSPEED, dValue)
|
|
StringToLen(Thick, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.THICK, dValue)
|
|
StringToDouble(MaxAbsorption, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.MAXABSORPTION, dValue)
|
|
StringToLen(MinFeed, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.MINFEED, dValue)
|
|
EgtTdbSetCurrToolParam(MCH_TP.DRAW, Draw)
|
|
EgtTdbSetCurrToolParam(MCH_TP.HEAD, Head)
|
|
EgtTdbSetCurrToolParam(MCH_TP.USERNOTES, UserNotes)
|
|
EgtTdbSetCurrToolParam(MCH_TP.TCPOS, SelectedTcPos)
|
|
End Sub
|
|
|
|
Public Sub WriteToolName()
|
|
EgtTdbSetCurrToolParam(MCH_TP.NAME, NamePar)
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
#Region "ToolSceneUpdate"
|
|
|
|
' Enum che indica le proprietà di disegno dell'utensile
|
|
Friend Enum DrawUpdateSource
|
|
DIAM = 0
|
|
LEN = 1
|
|
MAXMAT = 2
|
|
THICK = 3
|
|
DRAW = 4
|
|
TOTLEN = 5
|
|
HEAD = 6
|
|
EXIT_ = 7
|
|
End Enum
|
|
|
|
' Variabili che segnalano errori nel disegno dell'utensile
|
|
Dim m_bToolMakerError As Boolean = False
|
|
Dim m_bDrawNameExistError As Boolean = False
|
|
Dim m_bDrawNameError As Boolean = False
|
|
Dim m_nDrawingError As Integer = 0
|
|
|
|
Private Sub UpdateSceneToolDraw(UpdateSource As DrawUpdateSource)
|
|
' Azzero errori
|
|
m_bToolMakerError = False
|
|
m_bDrawNameError = False
|
|
m_bDrawNameExistError = False
|
|
m_nDrawingError = 0
|
|
|
|
' Verifico proprietà draw
|
|
If String.IsNullOrEmpty(m_Draw) OrElse IsUUID(Path.GetFileNameWithoutExtension(m_Draw)) Then
|
|
CreateToolDraw(UpdateSource)
|
|
Else
|
|
EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
|
If IsNgeFile(m_Draw) Then
|
|
If EgtOpenFile(IniFile.m_sCurrMachToolsDirPath & "\" & m_Draw) Then
|
|
EgtSetView(VT.TOP, False)
|
|
EgtZoom(ZM.ALL)
|
|
Else
|
|
' Errore
|
|
m_bDrawNameExistError = True
|
|
EgtNewFile()
|
|
EgtSetView(VT.TOP, False)
|
|
EgtZoom(ZM.ALL)
|
|
End If
|
|
Else
|
|
' Errore
|
|
m_bDrawNameError = True
|
|
EgtNewFile()
|
|
EgtSetView(VT.TOP, False)
|
|
EgtZoom(ZM.ALL)
|
|
End If
|
|
End If
|
|
NotifyPropertyChanged("Draw")
|
|
If UpdateSource = DrawUpdateSource.TOTLEN Or UpdateSource = DrawUpdateSource.LEN Or UpdateSource = DrawUpdateSource.MAXMAT Then
|
|
NotifyPropertyChanged("TotLen")
|
|
NotifyPropertyChanged("Len")
|
|
NotifyPropertyChanged("MaxMat")
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CreateToolDraw(UpdateSource As DrawUpdateSource)
|
|
' Carico il relativo ToolHolder
|
|
Dim ToolHolder As String = String.Empty
|
|
ToolHolder = LoadToolHolder()
|
|
If Not LoadToolMaker() OrElse Not CreateToolDraw(ToolHolder, UpdateSource) Then
|
|
EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
|
EgtNewFile()
|
|
End If
|
|
EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
|
' Aggiorno visualizzazione
|
|
EgtSetView(VT.TOP, False)
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Mathod that load the toolholder for the current tool (based on his head), or return an empty string
|
|
''' </summary>
|
|
Private Function LoadToolHolder() As String
|
|
Dim sHolder As String = String.Empty
|
|
If Type = MCH_TY.SAW_STD Then
|
|
EgtUILib.GetPrivateProfileString(S_TOOLHOLDER, Head & "." & ExitPar.ToString() & ":SAW_STD", "", sHolder, IniFile.m_sCurrMachIniFilePath)
|
|
ElseIf Type = MCH_TY.SAW_FLAT Then
|
|
EgtUILib.GetPrivateProfileString(S_TOOLHOLDER, Head & "." & ExitPar.ToString() & ":SAW_FLAT", "", sHolder, IniFile.m_sCurrMachIniFilePath)
|
|
End If
|
|
If String.IsNullOrEmpty(sHolder) Then
|
|
EgtUILib.GetPrivateProfileString(S_TOOLHOLDER, Head & "." & ExitPar.ToString(), "", sHolder, IniFile.m_sCurrMachIniFilePath)
|
|
End If
|
|
If String.IsNullOrWhiteSpace(sHolder) Then
|
|
Return String.Empty
|
|
Else
|
|
Dim sHolderPath As String = String.Empty
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbGetToolHolderDir(sHolderPath)
|
|
sHolderPath += "\" & sHolder
|
|
Return sHolderPath
|
|
End If
|
|
End Function
|
|
|
|
Private Function LoadToolMaker() As Boolean
|
|
Dim sMaker As String = String.Empty
|
|
EgtUILib.GetPrivateProfileString(S_TOOLS, ConvertTypeToString(Type), "", sMaker, IniFile.m_sCurrMachIniFilePath)
|
|
If String.IsNullOrWhiteSpace(sMaker) Then m_bToolMakerError = True
|
|
' Acquisisce solo il file lua, ma meglio impostare contesto disegno utensili (se ci sono chiamate...)
|
|
EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
|
Return EgtLuaExecFile(IniFile.m_sToolMakersDir & "\" & sMaker)
|
|
End Function
|
|
|
|
Private Function ConvertTypeToString(Type As Integer) As String
|
|
Select Case Type
|
|
Case MCH_TY.DRILL_STD, MCH_TY.DRILL_LONG
|
|
Return K_DRILLMAKER
|
|
Case MCH_TY.SAW_STD, MCH_TY.SAW_FLAT
|
|
Return K_SAWBLADEMAKER
|
|
Case MCH_TY.MILL_STD, MCH_TY.MILL_NOTIP
|
|
Return K_MILLMAKER
|
|
Case MCH_TY.MORTISE_STD
|
|
Return "MortiseMaker"
|
|
Case MCH_TY.COMPO
|
|
Return "CompoMaker"
|
|
End Select
|
|
Return Nothing
|
|
End Function
|
|
|
|
Private Function CreateToolDraw(ToolHolder As String, UpdateSource As DrawUpdateSource) As Boolean
|
|
Dim dTotLen As Double = 0
|
|
Dim dLen As Double = 0
|
|
Dim dDiam As Double = 0
|
|
Dim dThick As Double = 0
|
|
Dim dMaxMat As Double = 0
|
|
StringToLen(m_TotLen, dTotLen)
|
|
StringToLen(m_Len, dLen)
|
|
StringToLen(m_Diam, dDiam)
|
|
StringToLen(m_Thick, dThick)
|
|
StringToLen(m_MaxMat, dMaxMat)
|
|
Select Case Type
|
|
Case MCH_TY.DRILL_STD, MCH_TY.DRILL_LONG
|
|
' imposto dati utensile
|
|
EgtLuaSetGlobStringVar("TOOL.TOOLHOLDER", ToolHolder)
|
|
EgtLuaSetGlobNumVar("TOOL.TOTLEN", dTotLen)
|
|
EgtLuaSetGlobNumVar("TOOL.LEN", dLen)
|
|
EgtLuaSetGlobNumVar("TOOL.DIAM", dDiam)
|
|
EgtLuaSetGlobNumVar("TOOL.MAXMAT", dMaxMat)
|
|
Case MCH_TY.SAW_STD, MCH_TY.SAW_FLAT
|
|
' imposto dati utensile
|
|
EgtLuaSetGlobStringVar("TOOL.TOOLHOLDER", ToolHolder)
|
|
EgtLuaSetGlobNumVar("TOOL.LEN", dLen)
|
|
EgtLuaSetGlobNumVar("TOOL.DIAM", dDiam)
|
|
Dim dCore As Double = If(dLen >= dThick, dThick - 1, 2 * dLen - dThick)
|
|
EgtLuaSetGlobNumVar("TOOL.CORE", dCore)
|
|
EgtLuaSetGlobNumVar("TOOL.THICK", dThick)
|
|
EgtLuaSetGlobNumVar("TOOL.MAXMAT", dMaxMat)
|
|
Case MCH_TY.MILL_STD, MCH_TY.MILL_NOTIP
|
|
' imposto dati utensile
|
|
EgtLuaSetGlobStringVar("TOOL.TOOLHOLDER", ToolHolder)
|
|
EgtLuaSetGlobNumVar("TOOL.LEN", dLen)
|
|
EgtLuaSetGlobNumVar("TOOL.DIAM", dDiam)
|
|
EgtLuaSetGlobNumVar("TOOL.MAXMAT", dMaxMat)
|
|
Case Else
|
|
m_nDrawingError = 999
|
|
Draw = String.Empty
|
|
Return False
|
|
End Select
|
|
' passo all'ambiente di disegno dell'utensile
|
|
EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
|
' eseguo creazione utensile
|
|
EgtLuaCallFunction("CreateTool")
|
|
' recupero errore
|
|
Dim nErr As Integer = 999
|
|
EgtLuaGetGlobIntVar("TOOL.ERR", nErr)
|
|
m_nDrawingError = nErr
|
|
If m_nDrawingError <> 0 And UpdateSource <> DrawUpdateSource.DRAW Then Draw = String.Empty
|
|
If m_nDrawingError = 0 Then m_Draw = m_Uuid & ".nge"
|
|
Return (nErr = 0)
|
|
End Function
|
|
|
|
Friend Function SaveToolDraw() As Boolean
|
|
If m_Type = MCH_TY.DRILL_STD Or m_Type = MCH_TY.DRILL_LONG Or
|
|
m_Type = MCH_TY.SAW_STD Or m_Type = MCH_TY.SAW_FLAT Or
|
|
m_Type = MCH_TY.MILL_STD Or m_Type = MCH_TY.MILL_NOTIP Then
|
|
' nome e direttorio del file da salvare
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
Dim sDrawName As String = Uuid
|
|
sDrawName = sDrawName & ".nge"
|
|
Dim sPath As String = String.Empty
|
|
EgtTdbGetToolDir(sPath)
|
|
sPath = sPath & "\" & sDrawName
|
|
' passo all'ambiente di disegno dell'utensile
|
|
EgtSetCurrentContext(IniFile.m_ToolsDbSceneContext)
|
|
' nascondo layer ausiliario
|
|
Dim nAuxId As Integer = GDB_ID.NULL
|
|
nAuxId = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(GDB_ID.ROOT), "AUX")
|
|
EgtSetStatus(nAuxId, GDB_ST.OFF)
|
|
' se lama devo ruotare -90 deg attorno a Z+
|
|
If m_Type = MCH_TY.SAW_STD Or m_Type = MCH_TY.SAW_FLAT Then
|
|
EgtRotate(EgtGetFirstGroupInGroup(GDB_ID.ROOT), Point3d.ORIG(), Vector3d.Z_AX(), -90, GDB_RT.GLOB)
|
|
End If
|
|
' salvo il modello
|
|
Dim z = EgtGetCurrentContext()
|
|
Dim bOk As Boolean = EgtSaveFile(sPath, NGE.CMPTEXT)
|
|
Dim e = EgtGetCurrentContext()
|
|
' eseguo controrotazione per lama
|
|
If m_Type = MCH_TY.SAW_STD Or m_Type = MCH_TY.SAW_FLAT Then
|
|
EgtRotate(EgtGetFirstGroupInGroup(GDB_ID.ROOT), Point3d.ORIG(), Vector3d.Z_AX(), 90, GDB_RT.GLOB)
|
|
End If
|
|
' ripristino visualizzazione layer aux
|
|
EgtSetStatus(nAuxId, GDB_ST.ON_)
|
|
' salvo nome del disegno utensile
|
|
EgtSetCurrentContext(IniFile.m_ProjectSceneContext)
|
|
EgtTdbSetCurrToolParam(MCH_TP.DRAW, sDrawName)
|
|
EgtTdbSaveCurrTool()
|
|
Return bOk
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
#End Region ' ToolSceneUpdate
|
|
|
|
#Region "IDataErrorInfo Members"
|
|
|
|
Private ReadOnly Property IDataErrorInfo_Error() As String Implements IDataErrorInfo.Error
|
|
Get
|
|
Return Nothing
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property IDataErrorInfo_Item(ByVal propertyName As String) As String Implements IDataErrorInfo.Item
|
|
Get
|
|
ErrorOnTool = True
|
|
Return Me.GetValidationError(propertyName)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' IDataErrorInfo Members
|
|
|
|
#Region "Validation"
|
|
|
|
''' <summary>
|
|
''' Returns true if this object has no validation errors.
|
|
''' </summary>
|
|
Public ReadOnly Property IsValid() As Boolean
|
|
Get
|
|
For Each [property] As String In ValidatedProperties
|
|
If GetValidationError([property]) IsNot Nothing Then
|
|
Return False
|
|
End If
|
|
Next [property]
|
|
|
|
Return True
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property IsModified() As Boolean
|
|
Get
|
|
Return m_IsModifiedCorr OrElse m_IsModifiedExit OrElse m_IsModifiedCornRad OrElse m_IsModifiedDiam OrElse m_IsModifiedTotDiam OrElse m_IsModifiedFeed OrElse m_IsModifiedEndFeed _
|
|
OrElse m_IsModifiedStartFeed OrElse m_IsModifiedTipFeed OrElse m_IsModifiedLen OrElse m_IsModifiedTotLen OrElse m_IsModifiedMaxMat OrElse m_IsModifiedLonOffset _
|
|
OrElse m_IsModifiedRadOffset OrElse m_IsModifiedSpeed OrElse m_IsModifiedSideAng OrElse m_IsModifiedMaxSpeed OrElse m_IsModifiedThick OrElse m_IsModifiedMaxAbsorption _
|
|
OrElse m_IsModifiedMinFeed OrElse m_IsModifiedDraw OrElse m_IsModifiedHead OrElse m_IsModifiedName OrElse m_IsModifiedUserNotes OrElse m_IsModifiedTcPos
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub IsModifiedReset()
|
|
m_IsModifiedCorr = False
|
|
m_IsModifiedExit = False
|
|
m_IsModifiedCornRad = False
|
|
m_IsModifiedDiam = False
|
|
m_IsModifiedTotDiam = False
|
|
m_IsModifiedFeed = False
|
|
m_IsModifiedEndFeed = False
|
|
m_IsModifiedStartFeed = False
|
|
m_IsModifiedTipFeed = False
|
|
m_IsModifiedLen = False
|
|
m_IsModifiedTotLen = False
|
|
m_IsModifiedMaxMat = False
|
|
m_IsModifiedLonOffset = False
|
|
m_IsModifiedRadOffset = False
|
|
m_IsModifiedSpeed = False
|
|
m_IsModifiedSideAng = False
|
|
m_IsModifiedMaxSpeed = False
|
|
m_IsModifiedThick = False
|
|
m_IsModifiedMaxAbsorption = False
|
|
m_IsModifiedMinFeed = False
|
|
m_IsModifiedDraw = False
|
|
m_IsModifiedHead = False
|
|
m_IsModifiedName = False
|
|
m_IsModifiedUserNotes = False
|
|
m_IsModifiedTcPos = False
|
|
End Sub
|
|
|
|
Private Shared ReadOnly ValidatedProperties() As String = {"Draw", "MaxMat", "Thick", "Diam", "Len", "TotLen", "Speed", "NamePar"}
|
|
|
|
Private Function GetValidationError(ByVal propertyName As String) As String
|
|
|
|
If Not EgtCAM5.ToolsDbViewModel.m_bActive Then
|
|
Return Nothing
|
|
End If
|
|
If Array.IndexOf(ValidatedProperties, propertyName) < 0 Then
|
|
Return Nothing
|
|
End If
|
|
|
|
Dim [error] As String = Nothing
|
|
|
|
Select Case propertyName
|
|
Case "Draw"
|
|
[error] = Me.ValidateDraw()
|
|
Case "MaxMat"
|
|
[error] = Me.ValidateMaxMat()
|
|
Case "Diam"
|
|
[error] = Me.ValidateDiam()
|
|
Case "Thick"
|
|
[error] = Me.ValidateThick()
|
|
Case "Len"
|
|
[error] = Me.ValidateLen()
|
|
Case "TotLen"
|
|
[error] = Me.ValidateTotLen()
|
|
Case "Speed"
|
|
[error] = Me.ValidateSpeed()
|
|
Case "NamePar"
|
|
[error] = Me.ValidateName()
|
|
|
|
Case Else
|
|
'Debug.Fail("Unexpected property being validated on Tool: " & propertyName)
|
|
End Select
|
|
Return [error]
|
|
End Function
|
|
|
|
Private Function ValidateDraw() As String
|
|
If m_bDrawNameError Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 2)
|
|
End If
|
|
If m_bDrawNameExistError Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 3)
|
|
End If
|
|
If m_bToolMakerError Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 4)
|
|
End If
|
|
If m_nDrawingError = 12 Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 21) ' Utensile troppo corto con il portautensile
|
|
ElseIf m_nDrawingError <> 0 Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 5)
|
|
End If
|
|
Return Nothing
|
|
End Function
|
|
|
|
Private Function ValidateMaxMat() As String
|
|
If Not IsNothing(m_MaxMat) Then
|
|
Dim dMaxMat As Double = 0
|
|
StringToLen(m_MaxMat, dMaxMat)
|
|
If dMaxMat < EPS_SMALL Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 6)
|
|
End If
|
|
If (Type And MCH_TF.SAWBLADE) = 0 Then
|
|
If Not IsNothing(m_Len) Then
|
|
Dim dLen As Double = 0
|
|
StringToLen(m_Len, dLen)
|
|
If dMaxMat > dLen + EPS_SMALL Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 7)
|
|
End If
|
|
End If
|
|
Else
|
|
If Not IsNothing(m_Diam) Then
|
|
Dim dDiam As Double = 0
|
|
StringToLen(m_Diam, dDiam)
|
|
If dMaxMat > (dDiam / 3) + EPS_SMALL Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 17)
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
Return Nothing
|
|
End Function
|
|
|
|
Private Function ValidateThick() As String
|
|
If Not IsNothing(m_Thick) Then
|
|
Dim dThick As Double = 0
|
|
StringToLen(m_Thick, dThick)
|
|
If (m_Type = MCH_TY.SAW_FLAT Or m_Type = MCH_TY.SAW_STD Or m_Type = MCH_TY.MORTISE_STD) And dThick < EPS_SMALL Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 8)
|
|
End If
|
|
End If
|
|
Return Nothing
|
|
End Function
|
|
|
|
Private Function ValidateDiam() As String
|
|
If Not IsNothing(m_Diam) Then
|
|
Dim dDiam As Double = 0
|
|
StringToLen(m_Diam, dDiam)
|
|
If dDiam < EPS_SMALL Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 9)
|
|
End If
|
|
If Not IsNothing(m_TotDiam) Then
|
|
Dim dTotDiam As Double = 0
|
|
StringToLen(m_TotDiam, dTotDiam)
|
|
If dDiam > dTotDiam + EPS_SMALL Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 18)
|
|
End If
|
|
End If
|
|
If (Type And MCH_TF.SAWBLADE) <> 0 Then
|
|
If Not IsNothing(m_MaxMat) Then
|
|
Dim dMaxMat As Double = 0
|
|
StringToLen(m_MaxMat, dMaxMat)
|
|
If (dDiam / 3) + EPS_SMALL < dMaxMat Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 19)
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
Return Nothing
|
|
End Function
|
|
|
|
Private Function ValidateTotDiam() As String
|
|
If Not IsNothing(m_TotDiam) Then
|
|
Dim dTotDiam As Double = 0
|
|
StringToLen(m_TotDiam, dTotDiam)
|
|
If dTotDiam < EPS_SMALL Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 20)
|
|
End If
|
|
End If
|
|
Return Nothing
|
|
End Function
|
|
|
|
Private Function ValidateLen() As String
|
|
If Not IsNothing(m_Len) Then
|
|
Dim dLen As Double = 0
|
|
StringToLen(m_Len, dLen)
|
|
If dLen < EPS_SMALL Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 10)
|
|
End If
|
|
If Not IsNothing(m_TotLen) Then
|
|
Dim dTotLen As Double = 0
|
|
StringToLen(m_TotLen, dTotLen)
|
|
If dLen > dTotLen + EPS_SMALL Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 13)
|
|
End If
|
|
End If
|
|
If (Type And MCH_TF.SAWBLADE) = 0 Then
|
|
If Not IsNothing(m_MaxMat) Then
|
|
Dim dMaxMat As Double = 0
|
|
StringToLen(m_MaxMat, dMaxMat)
|
|
If dLen < dMaxMat Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 14)
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
Return Nothing
|
|
End Function
|
|
|
|
Private Function ValidateTotLen() As String
|
|
If Not IsNothing(m_TotLen) Then
|
|
Dim dTotLen As Double = 0
|
|
StringToLen(m_TotLen, dTotLen)
|
|
If dTotLen < EPS_SMALL Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 15)
|
|
End If
|
|
If Not IsNothing(m_Len) Then
|
|
Dim dLen As Double = 0
|
|
StringToLen(m_Len, dLen)
|
|
If dTotLen < dLen - EPS_SMALL Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 16)
|
|
End If
|
|
End If
|
|
End If
|
|
Return Nothing
|
|
End Function
|
|
|
|
Private Function ValidateSpeed() As String
|
|
If Not IsNothing(m_Speed) And Not IsNothing(m_MaxSpeed) Then
|
|
Dim dSpeed As Double = 0
|
|
StringToDouble(m_Speed, dSpeed)
|
|
Dim dMaxSpeed As Double = 0
|
|
StringToDouble(m_MaxSpeed, dMaxSpeed)
|
|
If Math.Abs(dSpeed) > dMaxSpeed + EPS_ZERO Then
|
|
Return EgtMsg(MSG_TOOLSERRORS + 11)
|
|
End If
|
|
End If
|
|
Return Nothing
|
|
End Function
|
|
|
|
Private Function ValidateName() As String
|
|
Select Case nErrorToolName
|
|
Case 1
|
|
Return EgtMsg(MSG_TOOLSERRORS + 12)
|
|
Case 2
|
|
Return EgtMsg(MSG_MACHININGSERRORS + 3)
|
|
End Select
|
|
Return Nothing
|
|
End Function
|
|
|
|
Private Shared Function IsStringMissing(ByVal value As String) As Boolean
|
|
Return String.IsNullOrEmpty(value) OrElse value.Trim() = String.Empty
|
|
End Function
|
|
|
|
Private Shared Function IsNgeFile(FileName As String) As Boolean
|
|
If IsStringMissing(FileName) Then
|
|
Return False
|
|
End If
|
|
|
|
Dim pattern As String = "^.+\.(?:[nN][gG][eE])$"
|
|
|
|
Return Regex.IsMatch(FileName, pattern, RegexOptions.IgnoreCase)
|
|
End Function
|
|
|
|
#End Region ' Validation
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "OpenDrawFileCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property OpenDrawFileCommand As ICommand
|
|
Get
|
|
If m_cmdOpenDrawFile Is Nothing Then
|
|
m_cmdOpenDrawFile = New Command(AddressOf OpenDrawFile)
|
|
End If
|
|
Return m_cmdOpenDrawFile
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub OpenDrawFile(ByVal param As Object)
|
|
Dim OpenFileDialog As New EgtWPFLib5.EgtOpenFileDialog
|
|
OpenFileDialog.Title = "Open draw file"
|
|
OpenFileDialog.Filter = "*.nge"
|
|
OpenFileDialog.Directory = IniFile.m_sCurrMachToolsDirPath
|
|
OpenFileDialog.FileName = m_Draw
|
|
If OpenFileDialog.ShowDialog <> True Then
|
|
Return
|
|
End If
|
|
Draw = Path.GetFileName(OpenFileDialog.FileName)
|
|
End Sub
|
|
|
|
#End Region ' OpenDrawFileCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
End Class
|
|
|
|
''' <summary>
|
|
''' Class that represent a Converter that use tool type and param type, to set the visibility state of the param type.
|
|
''' </summary>
|
|
Public Class ToolParamVisibilityConverter
|
|
Implements IValueConverter
|
|
|
|
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
|
|
Select Case CInt(value)
|
|
Case MCH_TY.NONE
|
|
Return Visibility.Hidden
|
|
Case MCH_TY.DRILL_STD
|
|
Return SharedFieldsClass.Drill_Std(CInt(parameter))
|
|
Case MCH_TY.DRILL_LONG
|
|
Return SharedFieldsClass.Drill_Long(CInt(parameter))
|
|
Case MCH_TY.SAW_STD
|
|
Return SharedFieldsClass.Saw_Std(CInt(parameter))
|
|
Case MCH_TY.SAW_FLAT
|
|
Return SharedFieldsClass.Saw_Flat(CInt(parameter))
|
|
Case MCH_TY.MILL_STD
|
|
Return SharedFieldsClass.Mill_Std(CInt(parameter))
|
|
Case MCH_TY.MILL_NOTIP
|
|
Return SharedFieldsClass.Mill_NoTip(CInt(parameter))
|
|
Case MCH_TY.MORTISE_STD
|
|
Return SharedFieldsClass.Mortise_Std(CInt(parameter))
|
|
Case MCH_TY.COMPO
|
|
Return SharedFieldsClass.Compo(CInt(parameter))
|
|
Case Else
|
|
Return Visibility.Hidden
|
|
End Select
|
|
End Function
|
|
|
|
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
|
|
Throw New NotImplementedException
|
|
End Function
|
|
|
|
End Class
|
|
|
|
''' <summary>
|
|
''' Class that represent a Converter that convert UUID to ***** in Draw param
|
|
''' </summary>
|
|
Public Class ToolDrawUUIDConverter
|
|
Implements IValueConverter
|
|
|
|
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
|
|
If Not IsNothing(value) Then
|
|
If IsUUID(Path.GetFileNameWithoutExtension(value.ToString)) Then
|
|
Return ToolDrawUUIDName
|
|
Else
|
|
Return value.ToString
|
|
End If
|
|
Else
|
|
Return Nothing
|
|
End If
|
|
End Function
|
|
|
|
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
|
|
Return value.ToString
|
|
End Function
|
|
End Class
|