e4044e0670
- riportate migliorie per VeinMatching - riportate migliorie per gocciolatoio - riportate migliorie in gestione Next di Split.
1513 lines
54 KiB
VB.net
1513 lines
54 KiB
VB.net
Imports System.IO
|
|
Imports System.Collections.ObjectModel
|
|
Imports EgtWPFLib5
|
|
Imports EgtUILib
|
|
|
|
Public Class RawPartTabVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Colori standard
|
|
Private m_RawCol As New Color3d(64, 192, 255, 40)
|
|
Private m_KerfCol As New Color3d(255, 0, 0, 100)
|
|
' Dati tavola
|
|
Private m_ptTableMin As Point3d
|
|
Private m_dTableLength As Double = 0
|
|
Private m_dTableWidth As Double = 0
|
|
' Dati per Drag
|
|
Private m_bDrag As Boolean = False
|
|
Private m_ptPrev As Point3d
|
|
Private m_nDragEnt As Integer = -1
|
|
Private m_dDragPar As Double = 0
|
|
' Modalità operazione su punti grezzo
|
|
Private m_nPtMode As PTMODE = PTMODE.MOVE
|
|
' Modalità operazione su punti aree danneggiate
|
|
Private m_nPtDmgMode As DMGMODE = DMGMODE.NONE
|
|
' Variabile che indica la zona danneggiata selezionata
|
|
Private m_nSelDmg As Integer
|
|
' Layer per crocette temporanee
|
|
Private m_nTempLay As Integer = GDB_ID.NULL
|
|
|
|
' Costante minima dimensione del grezzo
|
|
Private Const MIN_RAW_DIM As Double = 10
|
|
' Costante distanza di sicurezza del grezzo dal bordo
|
|
Private Const SAFE_RAW_DIST As Double = 5
|
|
' Costante raggio cerchietto
|
|
Private Const RAD_CIRCLE As Double = 30
|
|
' Stati dialogo tipo contorno
|
|
Enum Type As Integer
|
|
RECTANGLE = 0
|
|
BY_POINTS = 1
|
|
FROM_PHOTO = 2
|
|
End Enum
|
|
' Costanti modalità di creazione grezzo
|
|
Private Enum RAWMODE As Integer
|
|
RECTANGLE = 0
|
|
BY_POINTS = 1
|
|
FROM_PHOTO = 2
|
|
DAMAGED = 3
|
|
End Enum
|
|
' Costanti modo operazione punti
|
|
Private Enum PTMODE
|
|
MOVE = 0
|
|
ADD = 1
|
|
REMOVE = 2
|
|
End Enum
|
|
' Costanti modo operazione zone danneggiate
|
|
Private Enum DMGMODE
|
|
NONE = 0
|
|
ADD = 1
|
|
REMOVE = 2
|
|
End Enum
|
|
|
|
Private m_OutlineIsChecked As Boolean
|
|
Public Property OutlineIsChecked As Boolean
|
|
Get
|
|
Return m_OutlineIsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_OutlineIsChecked Then
|
|
m_OutlineIsChecked = value
|
|
RawModeView()
|
|
If m_OutlineIsChecked Then
|
|
UpdateCircles()
|
|
Else
|
|
m_SelType = Type.BY_POINTS
|
|
NotifyPropertyChanged("SelType")
|
|
RemoveCircles()
|
|
End If
|
|
EgtDraw()
|
|
NotifyPropertyChanged("OutlineIsChecked")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TypeList As New List(Of String)
|
|
Public ReadOnly Property TypeList As List(Of String)
|
|
Get
|
|
Return m_TypeList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelType As Integer
|
|
Public Property SelType As Integer
|
|
Get
|
|
Return m_SelType
|
|
End Get
|
|
Set(value As Integer)
|
|
m_SelType = value
|
|
Select Case m_SelType
|
|
Case Type.RECTANGLE
|
|
RawModeView()
|
|
RemoveCircles()
|
|
UpdateRawPart()
|
|
Case Type.BY_POINTS
|
|
RawModeView()
|
|
UpdateCircles()
|
|
EgtDraw()
|
|
Case Type.FROM_PHOTO
|
|
RawModeView()
|
|
RemoveCircles()
|
|
' CreateRawFromPhotoContour()
|
|
EgtDraw()
|
|
End Select
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TypeIsEnabled As Boolean
|
|
Public Property TypeIsEnabled As Boolean
|
|
Get
|
|
Return m_TypeIsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_TypeIsEnabled Then
|
|
m_TypeIsEnabled = value
|
|
NotifyPropertyChanged("TypeIsEnabled")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_dLength As Double
|
|
Public Property Length As String
|
|
Get
|
|
Return LenToString(m_dLength, -2)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dLength As Double = 0
|
|
Dim dMaxLen As Double = m_dTableLength - m_dOffsetX - m_dKerf
|
|
If StringToLen(value, dLength) And dLength > EPS_SMALL And dLength < dMaxLen + EPS_SMALL Then
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
m_dLength = dLength
|
|
UpdateRawPart()
|
|
ElseIf dLength <= EPS_SMALL Then
|
|
NotifyPropertyChanged("Length")
|
|
Else
|
|
NotifyPropertyChanged("Length")
|
|
' Massima lunghezza =
|
|
Dim sMsg As String = EgtMsg(MSG_RAWPARTPAGEUC + 16) & " " & LenToString(dMaxLen, 2)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, MSG_TYPE.ERROR_)
|
|
|
|
End If
|
|
End Set
|
|
End Property
|
|
Private Sub SetLength(value As Double)
|
|
m_dLength = value
|
|
NotifyPropertyChanged("Length")
|
|
End Sub
|
|
|
|
Private m_LengthIsEnabled As Boolean
|
|
Public Property LengthIsEnabled As Boolean
|
|
Get
|
|
Return m_LengthIsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_LengthIsEnabled Then
|
|
m_LengthIsEnabled = value
|
|
NotifyPropertyChanged("LengthIsEnabled")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_dWidth As Double
|
|
Public Property Width As String
|
|
Get
|
|
Return LenToString(m_dWidth, -2)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dWidth As Double = 0
|
|
Dim dMaxWidth As Double = m_dTableWidth - m_dOffsetY - m_dKerf
|
|
If StringToLen(value, dWidth) And dWidth > EPS_SMALL And dWidth < dMaxWidth + EPS_SMALL Then
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
m_dWidth = dWidth
|
|
UpdateRawPart()
|
|
ElseIf dWidth <= EPS_SMALL Then
|
|
NotifyPropertyChanged("Width")
|
|
Else
|
|
NotifyPropertyChanged("Width")
|
|
' Massima larghezza =
|
|
Dim sMsg As String = EgtMsg(MSG_RAWPARTPAGEUC + 17) & " " & LenToString(dMaxWidth, 2)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, MSG_TYPE.ERROR_)
|
|
End If
|
|
End Set
|
|
End Property
|
|
Private Sub SetWidth(value As Double)
|
|
m_dWidth = value
|
|
NotifyPropertyChanged("Width")
|
|
End Sub
|
|
|
|
Private m_WidthIsEnabled As Boolean
|
|
Public Property WidthIsEnabled As Boolean
|
|
Get
|
|
Return m_WidthIsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_WidthIsEnabled Then
|
|
m_WidthIsEnabled = value
|
|
NotifyPropertyChanged("WidthIsEnabled")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_dHeight As Double
|
|
Public Property Height As String
|
|
Get
|
|
Return LenToString(m_dHeight, -2)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dHeight As Double = 0
|
|
If StringToLen(value, dHeight) And dHeight > -EPS_ZERO Then
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
m_dHeight = dHeight
|
|
UpdateRawPartHeight()
|
|
Else
|
|
NotifyPropertyChanged("Height")
|
|
' Non sono ammessi spessori negativi
|
|
Dim sMsg As String = EgtMsg(MSG_RAWPARTPAGEUC + 18)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, MSG_TYPE.ERROR_)
|
|
End If
|
|
End Set
|
|
End Property
|
|
Private Sub SetHeight(value As Double)
|
|
m_dHeight = value
|
|
NotifyPropertyChanged("Height")
|
|
End Sub
|
|
|
|
Private m_HeightIsEnabled As Boolean
|
|
Public Property HeightIsEnabled As Boolean
|
|
Get
|
|
Return m_HeightIsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_HeightIsEnabled Then
|
|
m_HeightIsEnabled = value
|
|
NotifyPropertyChanged("HeightIsEnabled")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_dOffsetX As Double
|
|
Public Property OffsetX As String
|
|
Get
|
|
Return LenToString(m_dOffsetX, -2)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dOffsetX As Double = 0
|
|
Dim dMinOffsetX As Double = m_dKerf
|
|
Dim dMaxOffsetX As Double = m_dTableLength - m_dLength - m_dKerf
|
|
If StringToLen(value, dOffsetX) And dOffsetX > dMinOffsetX - EPS_SMALL And dOffsetX < dMaxOffsetX + EPS_SMALL Then
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
m_dOffsetX = dOffsetX
|
|
UpdateRawPart()
|
|
ElseIf dOffsetX < dMinOffsetX Then
|
|
NotifyPropertyChanged("OffsetX")
|
|
' Minimo offset X =
|
|
Dim sMsg As String = EgtMsg(MSG_RAWPARTPAGEUC + 19) & " " & LenToString(dMinOffsetX, 2)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, MSG_TYPE.ERROR_)
|
|
Else
|
|
NotifyPropertyChanged("OffsetX")
|
|
' Massimo offset X =
|
|
Dim sMsg As String = EgtMsg(MSG_RAWPARTPAGEUC + 48) & " " & LenToString(dMaxOffsetX, 2)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, MSG_TYPE.ERROR_)
|
|
End If
|
|
End Set
|
|
End Property
|
|
Private Sub SetOffsetX(value As Double)
|
|
m_dOffsetX = value
|
|
NotifyPropertyChanged("OffsetX")
|
|
End Sub
|
|
|
|
Private m_OffsetXIsEnabled As Boolean
|
|
Public Property OffsetXIsEnabled As Boolean
|
|
Get
|
|
Return m_OffsetXIsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_OffsetXIsEnabled Then
|
|
m_OffsetXIsEnabled = value
|
|
NotifyPropertyChanged("OffsetXIsEnabled")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_dOffsetY As Double
|
|
Public Property OffsetY As String
|
|
Get
|
|
Return LenToString(m_dOffsetY, -2)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dOffsetY As Double = 0
|
|
Dim dMinOffsetY As Double = m_dKerf
|
|
Dim dMaxOffsetY As Double = m_dTableWidth - m_dWidth - m_dKerf
|
|
If StringToLen(value, dOffsetY) And dOffsetY > dMinOffsetY - EPS_SMALL And dOffsetY < dMaxOffsetY + EPS_SMALL Then
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
m_dOffsetY = dOffsetY
|
|
UpdateRawPart()
|
|
ElseIf dOffsetY < dMinOffsetY Then
|
|
NotifyPropertyChanged("OffsetY")
|
|
' Minimo offset Y =
|
|
Dim sMsg As String = EgtMsg(MSG_RAWPARTPAGEUC + 20) & " " & LenToString(dMinOffsetY, 2)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, MSG_TYPE.ERROR_)
|
|
Else
|
|
NotifyPropertyChanged("OffsetY")
|
|
' Massimo offset Y =
|
|
Dim sMsg As String = EgtMsg(MSG_RAWPARTPAGEUC + 49) & " " & LenToString(dMaxOffsetY, 2)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, MSG_TYPE.ERROR_)
|
|
End If
|
|
End Set
|
|
End Property
|
|
Private Sub SetOffsetY(value As Double)
|
|
m_dOffsetY = value
|
|
NotifyPropertyChanged("OffsetY")
|
|
End Sub
|
|
|
|
Private m_OffsetYIsEnabled As Boolean
|
|
Public Property OffsetYIsEnabled As Boolean
|
|
Get
|
|
Return m_OffsetYIsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_OffsetYIsEnabled Then
|
|
m_OffsetYIsEnabled = value
|
|
NotifyPropertyChanged("OffsetYIsEnabled")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_dKerf As Double
|
|
Public Property Kerf As String
|
|
Get
|
|
Return LenToString(m_dKerf, -2)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dKerf As Double = -1
|
|
Dim dMinKerf As Double = 0
|
|
Dim dMaxKerf As Double = Math.Min(Math.Min(m_dOffsetX, m_dOffsetY),
|
|
Math.Min(m_dTableLength - m_dLength - m_dOffsetX, m_dTableWidth - m_dWidth - m_dOffsetY))
|
|
If StringToLen(value, dKerf) And dKerf > dMinKerf - EPS_SMALL And dKerf < dMaxKerf + EPS_SMALL Then
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
m_dKerf = dKerf
|
|
UpdateRawPartKerf()
|
|
ElseIf dKerf < dMinKerf Then
|
|
NotifyPropertyChanged("Kerf")
|
|
' Minimo kerf =
|
|
Dim sMsg As String = EgtMsg(MSG_RAWPARTPAGEUC + 21) & " " & LenToString(dMinKerf, 2)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, MSG_TYPE.ERROR_)
|
|
Else
|
|
NotifyPropertyChanged("Kerf")
|
|
' Massimo kerf =
|
|
Dim sMsg As String = EgtMsg(MSG_RAWPARTPAGEUC + 22) & " " & LenToString(dMaxKerf, 2)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, MSG_TYPE.ERROR_)
|
|
End If
|
|
End Set
|
|
End Property
|
|
Private Sub SetKerf(value As Double)
|
|
m_dKerf = value
|
|
NotifyPropertyChanged("Kerf")
|
|
End Sub
|
|
|
|
Private m_KerfIsEnabled As Boolean
|
|
Public Property KerfIsEnabled As Boolean
|
|
Get
|
|
Return m_KerfIsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_KerfIsEnabled Then
|
|
m_KerfIsEnabled = value
|
|
NotifyPropertyChanged("KerfIsEnabled")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property MaterialList As ObservableCollection(Of Material)
|
|
Get
|
|
Return CurrentMachine.Materials
|
|
End Get
|
|
End Property
|
|
|
|
Public Property SelMaterial As Material
|
|
Get
|
|
Return CurrentMachine.CurrMat
|
|
End Get
|
|
Set(value As Material)
|
|
CurrentMachine.CurrMat = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_AddPoint As Boolean
|
|
Public Property AddPoint As Boolean
|
|
Get
|
|
Return m_AddPoint
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_AddPoint Then
|
|
m_AddPoint = value
|
|
Select Case GetRawMode()
|
|
Case RAWMODE.BY_POINTS
|
|
m_RemovePoint = False
|
|
NotifyPropertyChanged("RemovePoint")
|
|
m_nPtMode = If(m_AddPoint, PTMODE.ADD, PTMODE.MOVE)
|
|
Case RAWMODE.DAMAGED
|
|
' Verifico ci sia almeno una zona rovinata
|
|
If EgtGetFirstNameInGroup(GetRawId(), NAME_DAMAGED) = GDB_ID.NULL Then
|
|
m_AddPoint = False
|
|
End If
|
|
m_RemovePoint = False
|
|
NotifyPropertyChanged("RemovePoint")
|
|
m_NewDA = False
|
|
NotifyPropertyChanged("NewDA")
|
|
m_DeleteDA = False
|
|
NotifyPropertyChanged("DeleteDA")
|
|
m_nPtMode = If(m_AddPoint, PTMODE.ADD, PTMODE.MOVE)
|
|
m_nPtDmgMode = DMGMODE.NONE
|
|
End Select
|
|
NotifyPropertyChanged("AddPoint")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_RemovePoint As Boolean
|
|
Public Property RemovePoint As Boolean
|
|
Get
|
|
Return m_RemovePoint
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_RemovePoint Then
|
|
m_RemovePoint = value
|
|
Select GetRawMode()
|
|
Case RAWMODE.BY_POINTS
|
|
m_AddPoint = False
|
|
NotifyPropertyChanged("AddPoint")
|
|
m_nPtMode = If(m_RemovePoint, PTMODE.REMOVE, PTMODE.MOVE)
|
|
Case RAWMODE.DAMAGED
|
|
' Verifico ci sia almeno una zona rovinata
|
|
If EgtGetFirstNameInGroup(GetRawId(), NAME_DAMAGED) = GDB_ID.NULL Then
|
|
m_RemovePoint = False
|
|
End If
|
|
m_AddPoint = False
|
|
NotifyPropertyChanged("AddPoint")
|
|
m_NewDA = False
|
|
NotifyPropertyChanged("NewDA")
|
|
m_DeleteDA = False
|
|
NotifyPropertyChanged("DeleteDA")
|
|
m_nPtMode = If(m_RemovePoint, PTMODE.REMOVE, PTMODE.MOVE)
|
|
m_nPtDmgMode = DMGMODE.NONE
|
|
End Select
|
|
NotifyPropertyChanged("RemovePoint")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_PointsVisibility As Visibility
|
|
Public Property PointsVisibility As Visibility
|
|
Get
|
|
Return m_PointsVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
If value <> m_PointsVisibility Then
|
|
m_PointsVisibility = value
|
|
NotifyPropertyChanged("PointsVisibility")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_NewDA As Boolean
|
|
Public Property NewDA As Boolean
|
|
Get
|
|
Return m_NewDA
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_NewDA Then
|
|
m_NewDA = value
|
|
NotifyPropertyChanged("NewDA")
|
|
m_nPtDmgMode = If(m_NewDA, DMGMODE.ADD, DMGMODE.NONE)
|
|
m_DeleteDA = False
|
|
NotifyPropertyChanged("DeleteDA")
|
|
m_AddPoint = False
|
|
NotifyPropertyChanged("AddPoint")
|
|
m_RemovePoint = False
|
|
NotifyPropertyChanged("RemovePoint")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_DeleteDA As Boolean
|
|
Public Property DeleteDA As Boolean
|
|
Get
|
|
Return m_DeleteDA
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_DeleteDA Then
|
|
m_DeleteDA = value
|
|
' Verifico ci sia almeno una zona rovinata
|
|
If EgtGetFirstNameInGroup(GetRawId(), NAME_DAMAGED) = GDB_ID.NULL Then
|
|
m_DeleteDA = False
|
|
End If
|
|
NotifyPropertyChanged("DeleteDA")
|
|
m_nPtDmgMode = If(m_DeleteDA, DMGMODE.REMOVE, DMGMODE.NONE)
|
|
m_NewDA = False
|
|
NotifyPropertyChanged("NewDA")
|
|
m_AddPoint = False
|
|
NotifyPropertyChanged("AddPoint")
|
|
m_RemovePoint = False
|
|
NotifyPropertyChanged("RemovePoint")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_DAVisibility As Visibility
|
|
Public Property DAVisibility As Visibility
|
|
Get
|
|
Return m_DAVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
If value <> m_DAVisibility Then
|
|
m_DAVisibility = value
|
|
NotifyPropertyChanged("DAVisibility")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ConfirmPhotoVisibility As Visibility
|
|
Public Property ConfirmPhotoVisibility As Visibility
|
|
Get
|
|
Return m_ConfirmPhotoVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
If value <> m_ConfirmPhotoVisibility Then
|
|
m_ConfirmPhotoVisibility = value
|
|
NotifyPropertyChanged("ConfirmPhotoVisibility")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property OutlineMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 33)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DamagedAreaMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 10)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property LengthMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 3)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property WidthMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 4)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property HeightMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 5)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property OffsetXMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 6)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property OffsetYMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 7)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property KerfMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 8)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MaterialMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 9)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PointsMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 13)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property AddMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 14)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RemoveMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 15)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NewMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 11)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DeleteMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 12)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ConfirmPhotoMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_RAWPARTPAGEUC + 24)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
#Region "ToolTip"
|
|
|
|
Public ReadOnly Property PhotoToolTip As String
|
|
Get
|
|
Return "Importa fotografia"
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' ToolTip
|
|
|
|
' Definizione comandi
|
|
Private m_cmdClosePath As ICommand
|
|
Private m_cmdPhoto As ICommand
|
|
Private m_cmdConfirmPhoto As ICommand
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in OmagOFFICEMap
|
|
OmagOFFICEMap.SetRefRawPartTabVM(Me)
|
|
' Aggiungo voci alla lista di tipi di definizione grezzo
|
|
m_TypeList.Add(EgtMsg(MSG_RAWPARTPAGEUC + 1))
|
|
m_TypeList.Add(EgtMsg(MSG_RAWPARTPAGEUC + 2))
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Function InitRawPart() As Boolean
|
|
' Colori standard
|
|
GetMainPrivateProfileColor(S_RAWPART, K_RAWCOLOR, m_RawCol)
|
|
GetMainPrivateProfileColor(S_RAWPART, K_KERFCOLOR, m_KerfCol)
|
|
' Dimensioni tavola
|
|
Dim ptMin, ptMax As Point3d
|
|
If EgtGetTableArea(1, ptMin, ptMax) Then
|
|
m_ptTableMin = ptMin
|
|
m_dTableLength = ptMax.x - ptMin.x
|
|
m_dTableWidth = ptMax.y - ptMin.y
|
|
End If
|
|
' Origine tavola
|
|
Dim ptRef1 As Point3d
|
|
If EgtGetTableRef(1, ptRef1) Then
|
|
If Not Point3d.SameApprox(m_ptTableMin, ptRef1) Then
|
|
EgtOutLog("Error : TableMin e TableRef1 are different")
|
|
End If
|
|
End If
|
|
' Assegno identificativo del grezzo
|
|
EstCalc.UpdateRawPart()
|
|
' Parcheggio pezzi presenti nel grezzo
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(GetRawId())
|
|
While nPartId <> GDB_ID.NULL
|
|
' Recupero identificativo del successivo
|
|
Dim nNextPartId As Integer = EgtGetNextPartInRawPart(nPartId)
|
|
' Metto in parcheggio
|
|
StoreOnePart(nPartId)
|
|
' Eventuale notifica al VeinMatching
|
|
VeinMatching.OnRemovePartFromRaw(nPartId)
|
|
' Passo al successivo
|
|
nPartId = nNextPartId
|
|
End While
|
|
' Nascondo eventuali pezzi in parcheggio
|
|
HideParkedParts()
|
|
' Deseleziono pezzi
|
|
EgtDeselectAll()
|
|
VeinMatching.OnDeselectAll()
|
|
' Cancello tutte le lavorazioni
|
|
EraseMachinings(GDB_ID.NULL)
|
|
' Visualizzo eventuale foto
|
|
ShowPhoto(True)
|
|
Dim bHeightModified As Boolean = False
|
|
' Se esiste già il grezzo...
|
|
If GetRawId() <> GDB_ID.NULL Then
|
|
' dimensioni del grezzo
|
|
Dim ptRawMin As Point3d = GetRawPtMin()
|
|
Dim ptRawMax As Point3d = GetRawPtMax()
|
|
' kerf
|
|
Dim dTmp As Double = 0
|
|
EgtGetInfo(EgtGetFirstRawPart(), KEY_KERF, dTmp)
|
|
SetKerf(dTmp)
|
|
' aggiorno dati grezzo
|
|
SetLength(ptRawMax.x - ptRawMin.x - 2 * m_dKerf)
|
|
SetWidth(ptRawMax.y - ptRawMin.y - 2 * m_dKerf)
|
|
SetHeight(ptRawMax.z - ptRawMin.z)
|
|
SetOffsetX(ptRawMin.x - m_ptTableMin.x + m_dKerf)
|
|
SetOffsetY(ptRawMin.y - m_ptTableMin.y + m_dKerf)
|
|
' aggiorno l'apparenza del grezzo
|
|
AdjustRawPartOnStart()
|
|
' Altrimenti lo definisco
|
|
Else
|
|
' Leggo da Ini gli ultimi valori
|
|
SetLength(GetMainPrivateProfileDouble(S_RAWPART, K_RAWLENGTH, 2500))
|
|
SetWidth(GetMainPrivateProfileDouble(S_RAWPART, K_RAWWIDTH, 1500))
|
|
SetHeight(GetMainPrivateProfileDouble(S_RAWPART, K_RAWHEIGHT, 30))
|
|
SetOffsetX(GetMainPrivateProfileDouble(S_RAWPART, K_RAWOFFSX, 100))
|
|
SetOffsetY(GetMainPrivateProfileDouble(S_RAWPART, K_RAWOFFSY, 100))
|
|
SetKerf(GetMainPrivateProfileDouble(S_RAWPART, K_RAWKERF, 50))
|
|
' Richiedo ricalcolo quota eventuale foto
|
|
bHeightModified = True
|
|
End If
|
|
' Creo layer temporaneo per crocette
|
|
m_nTempLay = EgtCreateGroup(GDB_ID.ROOT)
|
|
EgtSetLevel(m_nTempLay, GDB_LV.TEMP)
|
|
' Determino modalità di definizione
|
|
OutlineIsChecked = True
|
|
If EgtExistsInfo(GetRawId(), KEY_RAWBYPOINTS) Then
|
|
SelType = Type.BY_POINTS
|
|
NotifyPropertyChanged("SelType")
|
|
PointsVisibility = Visibility.Visible
|
|
' Visualizzo crocette
|
|
UpdateCircles()
|
|
EgtZoom(ZM.ALL)
|
|
Else
|
|
m_SelType = Type.RECTANGLE
|
|
NotifyPropertyChanged("SelType")
|
|
PointsVisibility = Visibility.Collapsed
|
|
UpdateRawPart(bHeightModified)
|
|
End If
|
|
DAVisibility = Visibility.Collapsed
|
|
' Imposto il materiale corrente nella combobox
|
|
NotifyPropertyChanged("SelMaterial")
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function ExitRawPart() As Boolean
|
|
|
|
|
|
' Sistemo il grezzo
|
|
AdjustRawPartOnExit()
|
|
' Rimuovo layer temporaneo per crocette
|
|
EgtErase(m_nTempLay)
|
|
' Salvo nel file Ini le dimensioni del grezzo (sempre in mm)
|
|
WriteMainPrivateProfileString(S_RAWPART, K_RAWLENGTH, DoubleToString(m_dLength, 2))
|
|
WriteMainPrivateProfileString(S_RAWPART, K_RAWWIDTH, DoubleToString(m_dWidth, 2))
|
|
WriteMainPrivateProfileString(S_RAWPART, K_RAWHEIGHT, DoubleToString(m_dHeight, 2))
|
|
WriteMainPrivateProfileString(S_RAWPART, K_RAWOFFSX, DoubleToString(m_dOffsetX, 2))
|
|
WriteMainPrivateProfileString(S_RAWPART, K_RAWOFFSY, DoubleToString(m_dOffsetY, 2))
|
|
WriteMainPrivateProfileString(S_RAWPART, K_RAWKERF, DoubleToString(m_dKerf, 2))
|
|
Return True
|
|
End Function
|
|
|
|
Private Function GetRawMode() As RAWMODE
|
|
Select Case m_SelType
|
|
Case Type.RECTANGLE
|
|
Return RAWMODE.RECTANGLE
|
|
Case Type.BY_POINTS
|
|
If m_OutlineIsChecked Then
|
|
Return RAWMODE.BY_POINTS
|
|
Else
|
|
Return RAWMODE.DAMAGED
|
|
End If
|
|
Case Type.FROM_PHOTO
|
|
Return RAWMODE.FROM_PHOTO
|
|
End Select
|
|
Return RAWMODE.RECTANGLE
|
|
End Function
|
|
|
|
Private Sub RawModeView()
|
|
Select Case GetRawMode()
|
|
Case RAWMODE.RECTANGLE
|
|
TypeIsEnabled = True
|
|
LengthIsEnabled = True
|
|
WidthIsEnabled = True
|
|
HeightIsEnabled = True
|
|
OffsetXIsEnabled = True
|
|
OffsetYIsEnabled = True
|
|
KerfIsEnabled = True
|
|
' Nascondo bottoni per disegno
|
|
PointsVisibility = Visibility.Collapsed
|
|
' Disattivo bottoni zone rovinate e conferma contorno da foto
|
|
DAVisibility = Visibility.Collapsed
|
|
ConfirmPhotoVisibility = Visibility.Collapsed
|
|
Case RAWMODE.BY_POINTS
|
|
TypeIsEnabled = True
|
|
LengthIsEnabled = False
|
|
WidthIsEnabled = False
|
|
HeightIsEnabled = True
|
|
OffsetXIsEnabled = False
|
|
OffsetYIsEnabled = False
|
|
KerfIsEnabled = True
|
|
' Visualizzo bottoni per disegno
|
|
PointsVisibility = Visibility.Visible
|
|
' Disattivo bottoni zone rovinate e conferma contorno da foto
|
|
DAVisibility = Visibility.Collapsed
|
|
ConfirmPhotoVisibility = Visibility.Collapsed
|
|
Case RAWMODE.DAMAGED
|
|
TypeIsEnabled = False
|
|
LengthIsEnabled = False
|
|
WidthIsEnabled = False
|
|
HeightIsEnabled = False
|
|
OffsetXIsEnabled = False
|
|
OffsetYIsEnabled = False
|
|
KerfIsEnabled = False
|
|
' Visualizzo bottoni per disegno
|
|
PointsVisibility = Visibility.Visible
|
|
' Attivo bottoni zone rovinate
|
|
DAVisibility = Visibility.Visible
|
|
' Disattivo bottone conferma contorno da foto
|
|
ConfirmPhotoVisibility = Visibility.Collapsed
|
|
Case RAWMODE.FROM_PHOTO
|
|
TypeIsEnabled = True
|
|
LengthIsEnabled = False
|
|
WidthIsEnabled = False
|
|
HeightIsEnabled = True
|
|
OffsetXIsEnabled = False
|
|
OffsetYIsEnabled = False
|
|
KerfIsEnabled = True
|
|
' Nascondo bottoni per punti e zone rovinate
|
|
PointsVisibility = Visibility.Collapsed
|
|
DAVisibility = Visibility.Collapsed
|
|
' Visualizzo bottone conferma contorno da foto
|
|
ConfirmPhotoVisibility = Visibility.Visible
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub UpdateRawPart(Optional bHeightModified As Boolean = False)
|
|
' Se cambiato spessore e c'è foto, aggiorno quota fotografia
|
|
If bHeightModified And GetPhoto() <> GDB_ID.NULL Then
|
|
' Ricarico fotografia
|
|
UpdatePhoto()
|
|
' Aggiorno eventuale contorno da foto
|
|
UpdateContour()
|
|
End If
|
|
' Recupero il colore (con la foto lo rendo molto più trasparente)
|
|
Dim Col = m_RawCol
|
|
' in presenza di foto rendo molto più trasparente
|
|
If GetPhoto() <> GDB_ID.NULL Then Col.A = 20
|
|
' Se non esiste già il grezzo e richiesto, lo inserisco
|
|
Dim nRawId As Integer = GetRawId()
|
|
If nRawId = GDB_ID.NULL And m_dHeight > EPS_SMALL Then
|
|
EgtAddRawPart(Point3d.ORIG(), m_dLength + 2 * m_dKerf, m_dWidth + 2 * m_dKerf, m_dHeight, Col)
|
|
' se esiste e da cancellare
|
|
ElseIf m_dHeight < EPS_SMALL Then
|
|
EgtRemoveRawPart(nRawId)
|
|
' Altrimenti lo modifico
|
|
Else
|
|
EgtModifyRawPart(nRawId, Point3d.ORIG(), m_dLength + 2 * m_dKerf, m_dWidth + 2 * m_dKerf, m_dHeight, Col)
|
|
End If
|
|
EstCalc.UpdateRawPart()
|
|
' Se non cancellato
|
|
If m_dHeight > EPS_SMALL Then
|
|
AdjustRawPartKerf()
|
|
' Sistemo la posizione
|
|
Dim ptRef As New Point3d(m_dOffsetX - m_dKerf, m_dOffsetY - m_dKerf, CurrentMachine.dAdditionalTable)
|
|
If EgtMoveToCornerRawPart(GetRawId(), ptRef, MCH_CR.BL) Then
|
|
EstCalc.UpdateRawPart()
|
|
'OkBtn.IsEnabled = True
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
Else
|
|
'OkBtn.IsEnabled = False
|
|
Dim sMsg As String = "Errore nella posizione o dimensione del grezzo"
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, MSG_TYPE.ERROR_)
|
|
End If
|
|
End If
|
|
' Aggiorno visualizzazione
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Private Function AdjustRawPartKerf() As Boolean
|
|
' Se non c'è il grezzo, esco
|
|
If GetRawId() = GDB_ID.NULL Then Return False
|
|
' Cancello eventuale vecchio contorno di kerf
|
|
Dim nKerfId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
|
|
EgtErase(nKerfId)
|
|
' box grezzo
|
|
Dim ptMin As Point3d = GetRawPtMin()
|
|
Dim ptMax As Point3d = GetRawPtMax()
|
|
ptMin.x += m_dKerf
|
|
ptMin.y += m_dKerf
|
|
ptMin.z = ptMax.z
|
|
ptMax.x -= m_dKerf
|
|
ptMax.y -= m_dKerf
|
|
' Creo il nuovo contorno del kerf
|
|
nKerfId = EgtCreateRectangle2P(GetRawId(), ptMin, ptMax, GDB_RT.GLOB)
|
|
EgtSetName(nKerfId, NAME_KERF)
|
|
EgtSetColor(nKerfId, m_KerfCol)
|
|
' Salvo il valore del kerf (sempre in mm)
|
|
EgtSetInfo(GetRawId(), KEY_KERF, m_dKerf)
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub UpdateRawPartHeight()
|
|
' Se da creare
|
|
If GetRawId() = GDB_ID.NULL Then
|
|
UpdateRawPart(True)
|
|
Return
|
|
' se da cancellare
|
|
ElseIf m_dHeight < EPS_SMALL Then
|
|
EgtRemoveRawPart(GetRawId())
|
|
' altrimenti da aggiornare
|
|
Else
|
|
' Aggiorno solido
|
|
EgtModifyRawPartHeight(GetRawId(), m_dHeight)
|
|
' Aggiorno quota kerf
|
|
Dim nKerfId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
|
|
If nKerfId <> GDB_ID.NULL Then
|
|
Dim ptStart As Point3d
|
|
EgtStartPoint(nKerfId, GDB_ID.ROOT, ptStart)
|
|
Dim dKerfHeight = ptStart.z - m_ptTableMin.z - CurrentMachine.dAdditionalTable
|
|
EgtMove(nKerfId, New Vector3d(0, 0, m_dHeight - dKerfHeight))
|
|
End If
|
|
End If
|
|
EstCalc.UpdateRawPart()
|
|
' Se c'è foto, aggiorno quota fotografia
|
|
If GetPhoto() <> GDB_ID.NULL Then
|
|
' Ricarico fotografia
|
|
UpdatePhoto()
|
|
' Aggiorno eventuale contorno da foto
|
|
UpdateContour()
|
|
End If
|
|
' Aggiorno visualizzazione
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Private Sub UpdateRawPartKerf()
|
|
' Se non c'è il grezzo, esco
|
|
If GetRawId() = GDB_ID.NULL Then Return
|
|
' Recupero percorso di contorno kerf
|
|
Dim nKerfId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
|
|
' Recupero colore grezzo ( in presenza di foto rendo molto più trasparente)
|
|
Dim Col = m_RawCol
|
|
If GetPhoto() <> GDB_ID.NULL Then Col.A = 20
|
|
' Aggiorno il grezzo
|
|
EgtModifyRawPart(GetRawId(), nKerfId, m_dKerf, m_ptTableMin.z, m_dHeight, Col)
|
|
' Salvo il nuovo valore (sempre in mm)
|
|
EgtSetInfo(GetRawId(), KEY_KERF, m_dKerf)
|
|
' Aggiorno dimensioni e posizione grezzo
|
|
UpdateRawXYData()
|
|
' Aggiorno visualizzazione
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Private Sub UpdateRawXYData()
|
|
' Aggiorno i dati del grezzo
|
|
EstCalc.UpdateRawPart()
|
|
' Aggiorno dimensioni grezzo nel piano XY
|
|
If GetRawId() <> GDB_ID.NULL Then
|
|
' aggiorno dati grezzo
|
|
m_dLength = EstCalc.GetRawLength() - 2 * m_dKerf
|
|
m_dWidth = EstCalc.GetRawWidth() - 2 * m_dKerf
|
|
m_dOffsetX = EstCalc.GetRawPtMin().x + m_dKerf - m_ptTableMin.x
|
|
m_dOffsetY = EstCalc.GetRawPtMin().y + m_dKerf - m_ptTableMin.y
|
|
' Assegno dati grezzo rettangolare ai textbox
|
|
NotifyPropertyChanged("Length")
|
|
NotifyPropertyChanged("Width")
|
|
NotifyPropertyChanged("OffsetX")
|
|
NotifyPropertyChanged("OffsetY")
|
|
End If
|
|
' Aggiorno la posizione del grezzo
|
|
Dim ptRef As New Point3d(m_dOffsetX - m_dKerf, m_dOffsetY - m_dKerf, CurrentMachine.dAdditionalTable)
|
|
If EgtMoveToCornerRawPart(GetRawId(), ptRef, MCH_CR.BL) Then
|
|
EstCalc.UpdateRawPart()
|
|
'OkBtn.IsEnabled = True
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
Else
|
|
'OkBtn.IsEnabled = False
|
|
Dim sMsg As String = "Errore nella posizione o dimensione del grezzo"
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sMsg, MSG_TYPE.ERROR_)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub AdjustRawPartOnStart()
|
|
' Se non c'è la foto va già bene così
|
|
If GetPhoto() = GDB_ID.NULL Then Return
|
|
|
|
' Disabilito impostazione modificato
|
|
Dim bOldEnMod = EgtGetEnableModified()
|
|
If bOldEnMod Then EgtDisableModified()
|
|
' Disabilito la texture sul grezzo
|
|
Dim nSolidId = EgtGetFirstNameInGroup(GetRawId(), NAME_RAW_SOLID)
|
|
EgtRemoveTextureData(nSolidId)
|
|
' Sistemo il colore
|
|
Dim Col = m_RawCol
|
|
Col.A = 20
|
|
EgtSetColor(nSolidId, Col, True)
|
|
' Ripristino precedente impostazione modificato
|
|
If bOldEnMod Then EgtEnableModified()
|
|
End Sub
|
|
|
|
Private Sub AdjustRawPartOnExit()
|
|
' Se non c'è il grezzo, esco
|
|
If GetRawId() = GDB_ID.NULL Then Return
|
|
|
|
' Disabilito impostazione modificato
|
|
Dim bOldEnMod = EgtGetEnableModified()
|
|
If bOldEnMod Then EgtDisableModified()
|
|
' Salvo la modalità di definizione
|
|
If SelType = Type.RECTANGLE Then
|
|
EgtRemoveInfo(GetRawId(), KEY_RAWBYPOINTS)
|
|
Else
|
|
EgtSetInfo(GetRawId(), KEY_RAWBYPOINTS, 1)
|
|
End If
|
|
' Verifico senso antiorario della curva di kerf
|
|
Dim nKerfId = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
|
|
Dim dArea As Double
|
|
If EgtCurveAreaXY(nKerfId, dArea) AndAlso dArea < 0 Then
|
|
EgtInvertCurve(nKerfId)
|
|
End If
|
|
' Elimino regioni per nesting
|
|
RemoveNestRegions()
|
|
' Se c'è la foto devo sistemare
|
|
If GetPhoto() <> GDB_ID.NULL Then
|
|
' Carico la texture della foto sul grezzo
|
|
Dim nSolidId = EgtGetFirstNameInGroup(GetRawId(), NAME_RAW_SOLID)
|
|
EgtSetTextureName(nSolidId, EstPhoto.GetPhotoName())
|
|
' Sistemo il riferimento della texture
|
|
Dim refTxr As New Frame3d
|
|
GetPhotoTextureRef(refTxr)
|
|
EgtSetTextureFrame(nSolidId, refTxr, GDB_RT.GLOB)
|
|
' Sistemo il colore
|
|
Dim colWhite As New Color3d(255, 255, 255, 100)
|
|
EgtSetColor(nSolidId, colWhite)
|
|
' Anche per il contorno
|
|
Dim nOutlineId = EgtGetFirstNameInGroup(GetRawId(), NAME_RAW_OUTLINE)
|
|
EgtSetColor(nOutlineId, colWhite)
|
|
EgtSetStatus(nOutlineId, GDB_ST.OFF)
|
|
' Nascondo la foto
|
|
ShowPhoto(False)
|
|
End If
|
|
' Ripristino precedente impostazione modificato
|
|
If bOldEnMod Then EgtEnableModified()
|
|
End Sub
|
|
|
|
Private Function RemoveNestRegions() As Boolean
|
|
' Cancello eventuale vecchia regione fuori kerf per nesting
|
|
EgtErase(EgtGetFirstNameInGroup(GetRawId(), NAME_OUTKERF_REG))
|
|
' Cancello eventuale vecchia regione di riferimento per nesting
|
|
EgtErase(EgtGetFirstNameInGroup(GetRawId(), NAME_REF_REG))
|
|
' Cancello eventuali vecchie regioni aree rovinate per nesting
|
|
Dim nId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_DAMAGED_REG)
|
|
While nId <> GDB_ID.NULL
|
|
EgtErase(nId)
|
|
nId = EgtGetFirstNameInGroup(GetRawId(), NAME_DAMAGED_REG)
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub AddNewDamagedArea()
|
|
' Creo triangolo che abbia il punto selezionato come centro (lato 100mm)
|
|
' calcolo punto in basso a sinistra
|
|
Dim ptBottomLeft As Point3d = New Point3d(m_ptPrev.x - 50,
|
|
m_ptPrev.y - (100 / 6 * Math.Sqrt(3)),
|
|
m_ptTableMin.z + CurrentMachine.dAdditionalTable + m_dHeight)
|
|
Dim vtRight As Vector3d = New Vector3d(100, 0, 0)
|
|
' creo lato base
|
|
Dim nBaseId As Integer = EgtCreateLine(GetRawId(), ptBottomLeft, ptBottomLeft + vtRight, GDB_RT.GLOB)
|
|
' calcolo vertice superiore del triangolo
|
|
Dim vtTop As New Vector3d(vtRight)
|
|
vtTop.Rotate(Vector3d.Z_AX, 60)
|
|
' creo lati inclinati
|
|
Dim nCat1 As Integer = EgtCreateLine(GetRawId(), ptBottomLeft + vtRight, ptBottomLeft + vtTop, GDB_RT.GLOB)
|
|
Dim nCAt2 As Integer = EgtCreateLine(GetRawId(), ptBottomLeft + vtTop, ptBottomLeft, GDB_RT.GLOB)
|
|
' Creo contorno zona rovinata
|
|
Dim nDmgId As Integer = EgtCreateCurveCompoByChain(GetRawId(), 3, {nBaseId, nCat1, nCAt2}, ptBottomLeft, True)
|
|
' Assegno il nome alla CCompo creata
|
|
EgtSetName(nDmgId, NAME_DAMAGED)
|
|
' e il colore
|
|
EgtSetColor(nDmgId, m_KerfCol)
|
|
' Imposto come area danneggiata corrente
|
|
m_nSelDmg = nDmgId
|
|
' Disabilito modalità aggiungi zona rovinata
|
|
m_nPtDmgMode = DMGMODE.NONE
|
|
End Sub
|
|
|
|
Private Sub RemoveDamagedArea()
|
|
' Elimino area rovinata selezionata
|
|
EgtErase(m_nSelDmg)
|
|
' Dichiaro zona danneggiata non selezionata
|
|
m_nSelDmg = GDB_ID.NULL
|
|
' Disabilito modalità rimuovi zona rovinata
|
|
m_nPtDmgMode = DMGMODE.NONE
|
|
End Sub
|
|
|
|
Private Sub UpdateCircles()
|
|
' Elimino vecchi punti finali
|
|
EgtEmptyGroup(m_nTempLay)
|
|
' Identificativo curva
|
|
Dim nId As Integer = GDB_ID.NULL
|
|
If GetRawMode() = RAWMODE.BY_POINTS Then
|
|
nId = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
|
|
ElseIf GetRawMode() = RAWMODE.DAMAGED Then
|
|
nId = m_nSelDmg
|
|
End If
|
|
' Verifico validità curva
|
|
If nId = GDB_ID.NULL Then Return
|
|
' riferimento globale della stessa
|
|
Dim frRef As New Frame3d
|
|
EgtGetGlobFrame(nId, frRef)
|
|
' Recupero i punti finali delle diverse entità componenti
|
|
Dim dU As Double = 1
|
|
Dim ptP As Point3d
|
|
While EgtAtParamPoint(nId, dU, ptP)
|
|
ptP.ToGlob(frRef)
|
|
CreateCircle(m_nTempLay, ptP)
|
|
dU += 1
|
|
End While
|
|
End Sub
|
|
|
|
Private Sub RemoveCircles()
|
|
EgtEmptyGroup(m_nTempLay)
|
|
End Sub
|
|
|
|
Private Function CreateCircle(nLayerId As Integer, ptP As Point3d) As Boolean
|
|
' Aggiungo cerchio
|
|
Dim nCircId As Integer = EgtCreateCircle(nLayerId, ptP, RAD_CIRCLE)
|
|
EgtSetColor(nCircId, New Color3d(255, 0, 0))
|
|
Return True
|
|
End Function
|
|
|
|
Friend Sub Refresh(PrevMeasureUnit As MeasureUnitOpt)
|
|
NotifyPropertyChanged("Length")
|
|
NotifyPropertyChanged("Width")
|
|
NotifyPropertyChanged("Height")
|
|
NotifyPropertyChanged("OffsetX")
|
|
NotifyPropertyChanged("OffsetY")
|
|
NotifyPropertyChanged("Kerf")
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "PhotoCommand"
|
|
|
|
Public ReadOnly Property PhotoCommand As ICommand
|
|
Get
|
|
If m_cmdPhoto Is Nothing Then
|
|
m_cmdPhoto = New Command(AddressOf Photo)
|
|
End If
|
|
Return m_cmdPhoto
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Photo(ByVal param As Object)
|
|
' Apro dialogo per scelta immagine
|
|
Dim PhotoDlg As New Microsoft.Win32.OpenFileDialog
|
|
PhotoDlg.Title = "Open"
|
|
PhotoDlg.Filter = "Image file(*.jpg;*.png;*.bmp)|*.jpg;*.png;*.bmp"
|
|
PhotoDlg.FilterIndex = 1
|
|
GetMainPrivateProfileString(S_GENERAL, K_IMAGEDIR, "", PhotoDlg.InitialDirectory)
|
|
If Not PhotoDlg.ShowDialog Then Return
|
|
Dim sPhoto As String = PhotoDlg.FileName
|
|
' Salvo nuovo direttorio corrente per immagini
|
|
WriteMainPrivateProfileString(S_GENERAL, K_IMAGEDIR, Path.GetDirectoryName(sPhoto))
|
|
' Carico immagine
|
|
EstPhoto.LoadPhoto(sPhoto)
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
#End Region ' PhotoCommand
|
|
|
|
#Region "ConfirmPhotoCommand"
|
|
|
|
Public ReadOnly Property ConfirmPhotoCommand As ICommand
|
|
Get
|
|
If m_cmdConfirmPhoto Is Nothing Then
|
|
m_cmdConfirmPhoto = New Command(AddressOf ConfirmPhoto)
|
|
End If
|
|
Return m_cmdConfirmPhoto
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ConfirmPhoto(ByVal param As Object)
|
|
|
|
End Sub
|
|
|
|
#End Region ' ConfirmPhotoCommand
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
#Region "EVENTS"
|
|
|
|
Friend Sub OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs)
|
|
' Verifico cosa selezionato
|
|
Dim nSolidId = EgtGetFirstNameInGroup(GetRawId(), NAME_RAW_SOLID)
|
|
Dim nKerfId = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
|
|
EgtSetObjFilterForSelWin(True, True, True, True, True)
|
|
Dim nSel As Integer
|
|
EgtSelect(e.Location, 2 * Scene.DIM_SEL, 2 * Scene.DIM_SEL, nSel)
|
|
' Ricavo nome dell'entità selezionata e identificativo
|
|
Dim nSelId As Integer = EgtGetFirstObjInSelWin()
|
|
Dim sName As String = String.Empty
|
|
While nSelId <> GDB_ID.NULL
|
|
sName = String.Empty
|
|
EgtGetName(nSelId, sName)
|
|
If sName = NAME_RAW_SOLID Then
|
|
m_bDrag = EgtUnProjectPoint(e.Location, m_ptPrev)
|
|
m_nDragEnt = -1
|
|
m_dDragPar = -1
|
|
ElseIf sName = NAME_KERF And
|
|
(GetRawMode() = RAWMODE.RECTANGLE Or GetRawMode() = RAWMODE.BY_POINTS) Then
|
|
m_bDrag = EgtUnProjectPoint(e.Location, m_ptPrev)
|
|
Dim dDist, dU As Double
|
|
If Not EgtGetMinDistPointCurve(m_ptPrev.Loc(nKerfId), nKerfId, dDist, dU) Then
|
|
m_bDrag = False
|
|
End If
|
|
m_nDragEnt = CInt(Math.Ceiling(dU))
|
|
m_dDragPar = dU
|
|
' Privilegio il kerf, pertanto esco
|
|
Exit While
|
|
ElseIf sName = NAME_DAMAGED And GetRawMode() = RAWMODE.DAMAGED Then
|
|
m_bDrag = EgtUnProjectPoint(e.Location, m_ptPrev)
|
|
Dim dDist, dU As Double
|
|
If Not EgtGetMinDistPointCurve(m_ptPrev.Loc(nSelId), nSelId, dDist, dU) Then
|
|
m_bDrag = False
|
|
End If
|
|
m_nDragEnt = CInt(Math.Ceiling(dU))
|
|
m_dDragPar = dU
|
|
m_nSelDmg = nSelId
|
|
' Aggiorno cerchi
|
|
UpdateCircles()
|
|
EgtDraw()
|
|
' Privilegio l'area danneggiata, pertanto esco
|
|
Exit While
|
|
End If
|
|
nSelId = EgtGetNextObjInSelWin()
|
|
End While
|
|
' se drag e modalità punti
|
|
If m_bDrag And GetRawMode() = RAWMODE.BY_POINTS Then
|
|
' se aggiungi punto
|
|
If m_nPtMode = PTMODE.ADD Then
|
|
If EgtAddCurveCompoJoint(nKerfId, m_dDragPar) Then m_dDragPar = Math.Ceiling(m_dDragPar)
|
|
' il grezzo non è cambiato, perchè il nuovo punto è sulla vecchia linea
|
|
m_AddPoint = False
|
|
NotifyPropertyChanged("AddPoint")
|
|
m_nPtMode = PTMODE.MOVE
|
|
' Aggiorno cerchi
|
|
UpdateCircles()
|
|
EgtDraw()
|
|
' altrimenti
|
|
Else
|
|
' verifico di essere abbastanza vicino ad un estremo
|
|
Dim ptJoint As Point3d
|
|
If Not EgtAtParamPoint(nKerfId, Math.Round(m_dDragPar), GDB_ID.ROOT, ptJoint) OrElse
|
|
Point3d.SqDistXY(ptJoint, m_ptPrev) > RAD_CIRCLE * RAD_CIRCLE Then
|
|
m_bDrag = False
|
|
End If
|
|
' se rimuovi
|
|
If m_bDrag And m_nPtMode = PTMODE.REMOVE Then
|
|
' ci devono essere almeno 4 punti
|
|
If EgtGetCurveCompoJointCount(nKerfId) >= 4 Then
|
|
EgtRemoveCurveCompoJoint(nKerfId, CInt(m_dDragPar))
|
|
' Aggiorno il solido del grezzo, l'ingombro e la posizione
|
|
UpdateRawPartKerf()
|
|
' Aggiorno cerchi
|
|
UpdateCircles()
|
|
EgtDraw()
|
|
End If
|
|
m_RemovePoint = False
|
|
NotifyPropertyChanged("RemovePoint")
|
|
m_nPtMode = PTMODE.MOVE
|
|
m_bDrag = False
|
|
End If
|
|
End If
|
|
' se drag e modalità zona danneggiata
|
|
ElseIf m_bDrag And GetRawMode() = RAWMODE.DAMAGED Then
|
|
' se aggiungi zona rovinata
|
|
If m_nPtDmgMode = DMGMODE.ADD Then
|
|
AddNewDamagedArea()
|
|
' Aggiorno
|
|
m_NewDA = False
|
|
NotifyPropertyChanged("NewDA")
|
|
UpdateCircles()
|
|
EgtDraw()
|
|
' se rimuovi zona rovinata
|
|
ElseIf m_nPtDmgMode = DMGMODE.REMOVE Then
|
|
' Verifico di essere sulla zona danneggiata
|
|
Dim ptNear As Point3d
|
|
If EgtAtParamPoint(m_nSelDmg, m_dDragPar, GDB_ID.ROOT, ptNear) And
|
|
Point3d.SqDistXY(ptNear, m_ptPrev) <= RAD_CIRCLE * RAD_CIRCLE Then
|
|
RemoveDamagedArea()
|
|
' Aggiorno
|
|
m_DeleteDA = False
|
|
NotifyPropertyChanged("DeleteDA")
|
|
End If
|
|
' Aggiorno cerchi
|
|
UpdateCircles()
|
|
EgtDraw()
|
|
' altrimenti eventuali operazioni di punto
|
|
Else
|
|
' se aggiungi punto
|
|
If m_nPtMode = PTMODE.ADD Then
|
|
If EgtAddCurveCompoJoint(m_nSelDmg, m_dDragPar) Then m_dDragPar = Math.Ceiling(m_dDragPar)
|
|
' il grezzo non è cambiato, perchè il nuovo punto è sulla vecchia linea
|
|
m_AddPoint = False
|
|
NotifyPropertyChanged("AddPoint")
|
|
m_nPtMode = PTMODE.MOVE
|
|
' Aggiorno cerchi
|
|
UpdateCircles()
|
|
EgtDraw()
|
|
' altrimenti
|
|
Else
|
|
' verifico di essere abbastanza vicino ad un estremo
|
|
Dim ptJoint As Point3d
|
|
If Not EgtAtParamPoint(m_nSelDmg, Math.Round(m_dDragPar), GDB_ID.ROOT, ptJoint) OrElse
|
|
Point3d.SqDistXY(ptJoint, m_ptPrev) > RAD_CIRCLE * RAD_CIRCLE Then
|
|
m_bDrag = False
|
|
End If
|
|
' se rimuovi
|
|
If m_bDrag And m_nPtMode = PTMODE.REMOVE Then
|
|
' ci devono essere almeno 4 punti
|
|
If EgtGetCurveCompoJointCount(m_nSelDmg) >= 4 Then
|
|
EgtRemoveCurveCompoJoint(m_nSelDmg, CInt(m_dDragPar))
|
|
' aggiorno il solido del grezzo, l'ingombro e la posizione
|
|
UpdateRawPartKerf()
|
|
' Aggiorno cerchi
|
|
UpdateCircles()
|
|
EgtDraw()
|
|
End If
|
|
m_RemovePoint = False
|
|
NotifyPropertyChanged("RemovePoint")
|
|
m_nPtMode = PTMODE.MOVE
|
|
m_bDrag = False
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
|
|
' Verifico di essere in modalità drag
|
|
If Not m_bDrag Then Return
|
|
' Ricavo il punto corrente in coordinate mondo
|
|
Dim ptCurr As Point3d
|
|
EgtUnProjectPoint(e.Location, ptCurr)
|
|
' Eseguo modifica
|
|
Select GetRawMode()
|
|
Case RAWMODE.RECTANGLE
|
|
ModifyRectangle(ptCurr)
|
|
Case RAWMODE.BY_POINTS
|
|
ModifyGeneric(ptCurr)
|
|
Case RAWMODE.DAMAGED
|
|
ModifyDamaged(ptCurr)
|
|
End Select
|
|
' Aggiorno il punto precedente
|
|
m_ptPrev = ptCurr
|
|
End Sub
|
|
|
|
Private Sub ModifyRectangle(ptCurr As Point3d)
|
|
' Se movimento del grezzo
|
|
If m_nDragEnt = -1 Then
|
|
' Ricavo il vettore di movimento (tengo solo XY)
|
|
Dim vtMove As Vector3d = ptCurr - m_ptPrev
|
|
vtMove.z = 0
|
|
' Muovo il grezzo
|
|
If EgtMoveRawPart(GetRawId(), vtMove) Then
|
|
EstCalc.UpdateRawPart()
|
|
EgtDraw()
|
|
' Aggiorno gli offset
|
|
m_dOffsetX += vtMove.x
|
|
m_dOffsetY += vtMove.y
|
|
NotifyPropertyChanged("OffsetX")
|
|
NotifyPropertyChanged("OffsetY")
|
|
End If
|
|
' se sposto lato sotto
|
|
ElseIf m_nDragEnt = 1 Then
|
|
Dim dDelta = ptCurr.y - m_ptPrev.y
|
|
If m_dWidth - dDelta > MIN_RAW_DIM And m_dOffsetY + dDelta > m_dKerf Then
|
|
m_dWidth -= dDelta
|
|
m_dOffsetY += dDelta
|
|
EgtModifyRawPartSize(GetRawId(), m_dLength + 2 * m_dKerf, m_dWidth + 2 * m_dKerf, m_dHeight)
|
|
EstCalc.UpdateRawPart()
|
|
AdjustRawPartKerf()
|
|
Dim vtMove As New Vector3d(0, dDelta, 0)
|
|
EgtMoveRawPart(GetRawId(), vtMove)
|
|
EstCalc.UpdateRawPart()
|
|
EgtDraw()
|
|
NotifyPropertyChanged("Width")
|
|
NotifyPropertyChanged("OffsetY")
|
|
End If
|
|
' se sposto lato a destra
|
|
ElseIf m_nDragEnt = 2 Then
|
|
Dim dDelta = ptCurr.x - m_ptPrev.x
|
|
If m_dLength + dDelta > MIN_RAW_DIM And
|
|
m_dOffsetX + m_dLength + dDelta + m_dKerf < m_dTableLength Then
|
|
m_dLength += dDelta
|
|
EgtModifyRawPartSize(GetRawId(), m_dLength + 2 * m_dKerf, m_dWidth + 2 * m_dKerf, m_dHeight)
|
|
EstCalc.UpdateRawPart()
|
|
AdjustRawPartKerf()
|
|
EgtDraw()
|
|
NotifyPropertyChanged("Length")
|
|
End If
|
|
' se sposto lato sopra
|
|
ElseIf m_nDragEnt = 3 Then
|
|
Dim dDelta = ptCurr.y - m_ptPrev.y
|
|
If m_dWidth + dDelta > MIN_RAW_DIM And
|
|
m_dOffsetY + m_dWidth + dDelta + m_dKerf < m_dTableWidth Then
|
|
m_dWidth += dDelta
|
|
EgtModifyRawPartSize(GetRawId(), m_dLength + 2 * m_dKerf, m_dWidth + 2 * m_dKerf, m_dHeight)
|
|
EstCalc.UpdateRawPart()
|
|
AdjustRawPartKerf()
|
|
EgtDraw()
|
|
NotifyPropertyChanged("Width")
|
|
End If
|
|
' se sposto lato a sinistra
|
|
ElseIf m_nDragEnt = 4 Then
|
|
Dim dDelta = ptCurr.x - m_ptPrev.x
|
|
If m_dLength - dDelta > MIN_RAW_DIM And m_dOffsetX + dDelta > m_dKerf Then
|
|
m_dLength -= dDelta
|
|
m_dOffsetX += dDelta
|
|
EgtModifyRawPartSize(GetRawId(), m_dLength + 2 * m_dKerf, m_dWidth + 2 * m_dKerf, m_dHeight)
|
|
EstCalc.UpdateRawPart()
|
|
AdjustRawPartKerf()
|
|
Dim vtMove As New Vector3d(dDelta, 0, 0)
|
|
EgtMoveRawPart(GetRawId(), vtMove)
|
|
EstCalc.UpdateRawPart()
|
|
EgtDraw()
|
|
NotifyPropertyChanged("Length")
|
|
NotifyPropertyChanged("OffsetX")
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ModifyGeneric(ptCurr As Point3d)
|
|
' Se non selezionata entità del kerf, esco
|
|
If m_nDragEnt = -1 Then Return
|
|
' Limito il punto a stare nella tavola con franco pari al kerf
|
|
If ptCurr.x < m_ptTableMin.x + m_dKerf Then ptCurr.x = m_ptTableMin.x + m_dKerf + SAFE_RAW_DIST
|
|
If ptCurr.y < m_ptTableMin.y + m_dKerf Then ptCurr.y = m_ptTableMin.y + m_dKerf + SAFE_RAW_DIST
|
|
If ptCurr.x > m_ptTableMin.x + m_dTableLength - m_dKerf Then ptCurr.x = m_ptTableMin.x + m_dTableLength - m_dKerf - SAFE_RAW_DIST
|
|
If ptCurr.y > m_ptTableMin.y + m_dTableWidth - m_dKerf Then ptCurr.y = m_ptTableMin.y + m_dTableWidth - m_dKerf - SAFE_RAW_DIST
|
|
' Identificativo curva di kerf
|
|
Dim nKerfId = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
|
|
' Identifico il punto
|
|
Dim nU As Integer = CInt(m_dDragPar)
|
|
' Aggiusto Z punto movimentato (è in globale)
|
|
ptCurr.z = m_ptTableMin.z + CurrentMachine.dAdditionalTable + m_dHeight
|
|
' Sposto il punto
|
|
If Not EgtModifyCurveCompoJoint(nKerfId, nU, ptCurr, GDB_RT.GLOB) Then Return
|
|
' Aggiorno il grezzo, l'ingombro e la posizione
|
|
UpdateRawPartKerf()
|
|
' Salvo il valore del kerf (sempre in mm)
|
|
EgtSetInfo(GetRawId(), KEY_KERF, m_dKerf)
|
|
' Aggiorno cerchi
|
|
UpdateCircles()
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub ModifyDamaged(ptCurr As Point3d)
|
|
' Se non selezionata entità, esco
|
|
If m_nDragEnt = -1 Then Return
|
|
' Recupero Id kerf
|
|
Dim nKerfId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
|
|
' Limito il punto a stare nel kerf
|
|
Dim ptLocCurr As Point3d = ptCurr.Loc(nKerfId)
|
|
Dim dMinDist As Double
|
|
Dim ptLocMin As Point3d
|
|
Dim nSide As Integer
|
|
If EgtGetMinDistPntSidePointCurve(ptLocCurr, nKerfId, Vector3d.Z_AX, dMinDist, ptLocMin, nSide) And nSide = +1 Then
|
|
ptCurr = ptLocMin.Glob(nKerfId)
|
|
End If
|
|
' Identifico il punto
|
|
Dim nU As Integer = CInt(m_dDragPar)
|
|
' Aggiusto Z punto movimentato (è in globale)
|
|
ptCurr.z = m_ptTableMin.z + CurrentMachine.dAdditionalTable + m_dHeight
|
|
' Sposto il punto
|
|
If Not EgtModifyCurveCompoJoint(m_nSelDmg, nU, ptCurr, GDB_RT.GLOB) Then Return
|
|
' Aggiorno cerchi
|
|
UpdateCircles()
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Friend Sub OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
|
|
' Disabilito modalità drag
|
|
m_bDrag = False
|
|
End Sub
|
|
|
|
#End Region ' EVENTS
|
|
|
|
End Class
|