5278c1d2e0
- Aggiunta finestra disegno Compo. - Migliorie varie.
485 lines
17 KiB
VB.net
485 lines
17 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class MoveRawModeVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Fase corrente
|
|
Private m_nCurrPhase As Integer = 0
|
|
' Gestione movimento manuale perpendicolare
|
|
Private m_vtDir As New Vector3d ' direzione di movimento
|
|
Private m_ptMid As New Point3d ' punto medio del taglio
|
|
Private m_dOrigDist As Double = 0 ' distanza iniziale (spessore taglio)
|
|
Private m_dCurrDist As Double = 0 ' distanza corrente
|
|
' Gestione movimento con ventose
|
|
Private m_bRemovedRaw As Boolean = False ' flag per rimozione manuale pezzi
|
|
Private m_RawMoveDataList As New List(Of RawMoveData) ' dati di movimento
|
|
Private m_bRawWithCups As Boolean = False ' flag per pezzo corrente con ventose
|
|
|
|
Private m_dStepMove As Double
|
|
Public Property StepMove As String
|
|
Get
|
|
Return LenToString(m_dStepMove, 2)
|
|
End Get
|
|
Set(value As String)
|
|
StringToLen(value, m_dStepMove)
|
|
End Set
|
|
End Property
|
|
|
|
Private m_MoveRawModeIsEnabled As Boolean
|
|
Public Property MoveRawModeIsEnabled As Boolean
|
|
Get
|
|
Return m_MoveRawModeIsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_MoveRawModeIsEnabled = value
|
|
NotifyPropertyChanged("MoveRawModeIsEnabled")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_LRArrowVisibility As Visibility
|
|
Public Property LRArrowVisibility As Visibility
|
|
Get
|
|
Return m_LRArrowVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
If value <> m_LRArrowVisibility Then
|
|
m_LRArrowVisibility = value
|
|
NotifyPropertyChanged("LRArrowVisibility")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property RemoveMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_MOVERAWPAGEUC + 1) ' Rimuovi
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
' Definizione comandi
|
|
Private m_cmdUp As ICommand
|
|
Private m_cmdLeft As ICommand
|
|
Private m_cmdRight As ICommand
|
|
Private m_cmdDown As ICommand
|
|
Private m_cmdRemovePart As ICommand
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in OmagOFFICEMap
|
|
OmagOFFICEMap.SetRefMoveRawModeVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Function InitMoveRaw() As Boolean
|
|
' Deseleziono tutto
|
|
EgtDeselectAll()
|
|
' Recupero i tagli allungati prima definiti
|
|
Dim Cuts(0) As Integer
|
|
OmagOFFICEMap.refSplitModeVM.GetEnabledCuts(Cuts)
|
|
' Fase precedente
|
|
Dim nPrevPhase As Integer = EgtGetCurrPhase()
|
|
If Not OmagOFFICEMap.refMachiningTabVM.IsShow Then
|
|
' Creo nuova fase, eseguo spezzatura grezzi e vi sposto le lavorazioni
|
|
Dim vNewRaws As New List(Of Integer)
|
|
SplitRawParts(nPrevPhase, Cuts, vNewRaws)
|
|
Else
|
|
EgtSetCurrPhase(nPrevPhase + 1)
|
|
End If
|
|
m_nCurrPhase = EgtGetCurrPhase()
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
' Carico i parametri di movimento
|
|
m_dStepMove = GetMainPrivateProfileDouble(S_RAWMOVE, K_RAWSTEP, 50)
|
|
NotifyPropertyChanged("StepMove")
|
|
' Se movimento manuale perpendicolare
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
' Se esiste taglio passante determino direzione di movimento
|
|
If Cuts.Length() > 0 Then
|
|
' recupero taglio di separazione
|
|
Dim nCutId As Integer = Cuts(0)
|
|
' recupero linea di base del taglio
|
|
EgtSetCurrMachining(nCutId)
|
|
' Recupero la prima entità geometrica della lavorazione
|
|
Dim nEntId, nSub As Integer
|
|
If EgtGetMachiningGeometry(0, nEntId, nSub) Then
|
|
' Direzione perpendicolare al taglio
|
|
EgtStartVector(nEntId, GDB_ID.ROOT, m_vtDir)
|
|
m_vtDir.Rotate(Vector3d.Z_AX(), 90)
|
|
' Punto medio del taglio
|
|
EgtMidPoint(nEntId, GDB_ID.ROOT, m_ptMid)
|
|
' Recupero il preview della lavorazione
|
|
Dim nPvId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(EgtGetFirstNameInGroup(nCutId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId)
|
|
' Recupero la larghezza del taglio
|
|
Dim nGrpId As Integer = EgtGetFirstGroupInGroup(nPvId)
|
|
If Not EgtGetInfo(nGrpId, "WT", m_dOrigDist) Then
|
|
m_dOrigDist = 4
|
|
End If
|
|
' Distanza iniziale
|
|
m_dCurrDist = 0
|
|
End If
|
|
' Non dovrebbe mai accadere, ma inizializzo con default
|
|
Else
|
|
m_vtDir = Vector3d.Y_AX()
|
|
m_ptMid = Point3d.ORIG()
|
|
m_dOrigDist = 0
|
|
m_dCurrDist = 0
|
|
End If
|
|
' Altrimenti movimento con ventose
|
|
Else
|
|
m_bRemovedRaw = False
|
|
m_bRawWithCups = False
|
|
' Pulisco lista info per grezzi
|
|
m_RawMoveDataList.Clear()
|
|
m_RawMoveDataList.Capacity() = 10
|
|
' Se solo visualizzazione carico i movimenti già fatti nella fase
|
|
If Not OmagOFFICEMap.refMachiningTabVM.IsShow Then
|
|
Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
GetMoveInfoInDisposition(nDispId, m_RawMoveDataList)
|
|
End If
|
|
End If
|
|
' Aggiorno interfaccia per taglio perpendicolare
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
LRArrowVisibility = Visibility.Hidden
|
|
' Altrimenti per movimento con ventose
|
|
Else
|
|
LRArrowVisibility = Visibility.Visible
|
|
End If
|
|
' Ritorno a precedente sempre abilitato
|
|
OmagOFFICEMap.refMachiningTabVM.PrevIsEnabled = True
|
|
' Gestione abilitazione altri bottoni
|
|
EnableButtons()
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function ExitMoveRaw() As Boolean
|
|
' Deseleziono tutto
|
|
EgtDeselectAll()
|
|
' Se movimento con ventose
|
|
If Not OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
' nascondo le ventose
|
|
EgtDisableModified()
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
EgtEnableModified()
|
|
' se non solo visualizzazione
|
|
If Not OmagOFFICEMap.refMachiningTabVM.IsShow Then
|
|
' recupero disposizione fase corrente
|
|
Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
' aggiungo al gruppo disposizione dei sottogruppi con i dati di movimento dei grezzi spostati
|
|
SaveMoveInfoInDisposition(nDispId, m_RawMoveDataList)
|
|
' imposto presenza operazioni manuali
|
|
SaveRemoveByHandInDisposition(nDispId, m_bRemovedRaw)
|
|
' Eseguo calcolo speciale dei movimenti
|
|
SpecialApplyDisposition(nDispId, True)
|
|
End If
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Friend Sub ChangeToModify()
|
|
' Elimino le fasi successive alla corrente
|
|
While EgtGetPhaseCount() > m_nCurrPhase
|
|
RemoveLastPhase()
|
|
End While
|
|
' Svuoto gruppo disposizione
|
|
Dim nDispId = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
EgtEmptyGroup(nDispId)
|
|
' Disabilito le lavorazioni della fase corrente e ne nascondo i percorsi utensile
|
|
Dim nOpeId As Integer = EgtGetNextOperation(nDispId)
|
|
While nOpeId <> GDB_ID.NULL
|
|
EgtSetOperationMode(nOpeId, False)
|
|
EgtSetInfo(nOpeId, INFO_MCH_USER_OFF, True)
|
|
EgtSetOperationStatus(nOpeId, False)
|
|
nOpeId = EgtGetNextOperation(nOpeId)
|
|
End While
|
|
' Aggiono abilitazione bottoni
|
|
EnableButtons()
|
|
End Sub
|
|
|
|
Private Sub EnableButtons()
|
|
' Per bottone MODIFY
|
|
OmagOFFICEMap.refMachiningTabVM.ModifyIsEnabled = OmagOFFICEMap.refMachiningTabVM.IsShow
|
|
' Altri bottoni
|
|
MoveRawModeIsEnabled = Not OmagOFFICEMap.refMachiningTabVM.IsShow
|
|
End Sub
|
|
|
|
Friend Sub Refresh(PrevMeasureUnit As MeasureUnitOpt)
|
|
NotifyPropertyChanged("StepMove")
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "UpCommand"
|
|
|
|
Public ReadOnly Property UpCommand As ICommand
|
|
Get
|
|
If m_cmdUp Is Nothing Then
|
|
m_cmdUp = New Command(AddressOf Up)
|
|
End If
|
|
Return m_cmdUp
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Up(ByVal param As Object)
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
' Se movimento perpendicolare, è allontanamento
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
' Recupero il centro del grezzo
|
|
Dim ptRawCen As Point3d
|
|
GetRawCenter(nRawId, ptRawCen)
|
|
' Calcolo la distanza di movimento
|
|
Dim dMove As Double = m_dStepMove
|
|
If m_dCurrDist < EPS_SMALL Then
|
|
dMove -= m_dOrigDist
|
|
End If
|
|
If (m_vtDir * (ptRawCen - m_ptMid) < 0) Then dMove *= -1
|
|
' Eseguo il movimento
|
|
If EgtMoveRawPart(nRawId, dMove * m_vtDir) Then
|
|
m_dCurrDist += Math.Abs(dMove)
|
|
End If
|
|
' Altrimenti movimento Y +
|
|
Else
|
|
If m_bRawWithCups Then
|
|
Dim vtMove As New Vector3d(0, m_dStepMove, 0)
|
|
If EgtMoveRawPart(nRawId, vtMove) Then
|
|
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
End If
|
|
Else
|
|
' Pezzo troppo piccolo : non si può muovere
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' UpCommand
|
|
|
|
#Region "LeftCommand"
|
|
|
|
Public ReadOnly Property LeftCommand As ICommand
|
|
Get
|
|
If m_cmdLeft Is Nothing Then
|
|
m_cmdLeft = New Command(AddressOf Left)
|
|
End If
|
|
Return m_cmdLeft
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Left(ByVal param As Object)
|
|
' Solo movimento con ventose
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then Return
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
If m_bRawWithCups Then
|
|
Dim vtMove As New Vector3d(-m_dStepMove, 0, 0)
|
|
If EgtMoveRawPart(nRawId, vtMove) Then
|
|
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
End If
|
|
Else
|
|
' Pezzo troppo piccolo : non si può muovere
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' LeftCommand
|
|
|
|
#Region "RightCommand"
|
|
|
|
Public ReadOnly Property RightCommand As ICommand
|
|
Get
|
|
If m_cmdRight Is Nothing Then
|
|
m_cmdRight = New Command(AddressOf Right)
|
|
End If
|
|
Return m_cmdRight
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Right(ByVal param As Object)
|
|
' Solo movimento con ventose
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then Return
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
If m_bRawWithCups Then
|
|
Dim vtMove As New Vector3d(m_dStepMove, 0, 0)
|
|
If EgtMoveRawPart(nRawId, vtMove) Then
|
|
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
End If
|
|
Else
|
|
' Pezzo troppo piccolo : non si può muovere
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' RightCommand
|
|
|
|
#Region "DownCommand"
|
|
|
|
Public ReadOnly Property DownCommand As ICommand
|
|
Get
|
|
If m_cmdDown Is Nothing Then
|
|
m_cmdDown = New Command(AddressOf Down)
|
|
End If
|
|
Return m_cmdDown
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Down(ByVal param As Object)
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
' Se movimento perpendicolare, è avvicinamento
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
' Se sono già a contatto, non devo fare alcunché
|
|
If m_dCurrDist < EPS_SMALL Then Return
|
|
' Recupero il centro del grezzo
|
|
Dim ptRawCen As Point3d
|
|
GetRawCenter(nRawId, ptRawCen)
|
|
' Calcolo la distanza di movimento
|
|
Dim dMove As Double = m_dStepMove
|
|
If m_dCurrDist < m_dStepMove Then
|
|
dMove -= m_dOrigDist
|
|
End If
|
|
If (m_vtDir * (ptRawCen - m_ptMid) > 0) Then dMove *= -1
|
|
' Eseguo il movimento
|
|
If EgtMoveRawPart(nRawId, dMove * m_vtDir) Then
|
|
m_dCurrDist -= Math.Abs(dMove)
|
|
End If
|
|
' Altrimenti movimento Y -
|
|
Else
|
|
If m_bRawWithCups Then
|
|
Dim vtMove As New Vector3d(0, -m_dStepMove, 0)
|
|
If EgtMoveRawPart(nRawId, vtMove) Then
|
|
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
End If
|
|
Else
|
|
' Pezzo troppo piccolo : non si può muovere
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' DownCommand
|
|
|
|
#Region "RemovePartCommand"
|
|
|
|
Public ReadOnly Property RemovePartCommand As ICommand
|
|
Get
|
|
If m_cmdRemovePart Is Nothing Then
|
|
m_cmdRemovePart = New Command(AddressOf RemovePart)
|
|
End If
|
|
Return m_cmdRemovePart
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub RemovePart(ByVal param As Object)
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
EgtRemoveRawPartFromCurrPhase(nRawId)
|
|
' Se con ventose
|
|
If Not OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
m_bRemovedRaw = True
|
|
' rimuovo eventuali indicazioni di movimento
|
|
RemoveRawMoveData(nRawId, m_RawMoveDataList)
|
|
' nascondo le ventose
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
' Reset eventuale messaggio
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
End If
|
|
nRawId = EgtGetFirstSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' RemovePartCommand
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
#Region "EVENTS"
|
|
|
|
Friend Sub OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs)
|
|
' Verifico di non essere in modalità solo visualizzazione
|
|
If OmagOFFICEMap.refMachiningTabVM.IsShow Then Return
|
|
' Gruppo dei grezzi
|
|
Dim nRawGroupId = EgtGetParent(EgtGetFirstRawPart())
|
|
' Verifico se selezionato indicativo di grezzo attivo
|
|
EgtSetObjFilterForSelWin(True, True, True, True, True)
|
|
Dim nSel As Integer
|
|
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
|
|
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
|
While nId <> GDB_ID.NULL
|
|
' Cerco l'identificativo del grezzo cui appartiene
|
|
Dim nParentId = EgtGetParent(nId)
|
|
While nParentId <> GDB_ID.NULL And nParentId <> nRawGroupId
|
|
nId = nParentId
|
|
nParentId = EgtGetParent(nId)
|
|
End While
|
|
' Se trovato il grezzo
|
|
If nParentId = nRawGroupId Then
|
|
Dim nStat As Integer = GDB_ST.ON_
|
|
EgtGetStatus(nId, nStat)
|
|
If nStat = GDB_ST.SEL Then
|
|
EgtSetStatus(nId, GDB_ST.ON_)
|
|
' Se con ventose, le nascondo
|
|
If Not OmagOFFICEMap.refMachiningTabVM.ByHand Then EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
Else
|
|
EgtDeselectAll()
|
|
EgtSetStatus(nId, GDB_ST.SEL)
|
|
' Se con ventose, le posiziono sul grezzo
|
|
If Not OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
Dim rmData As New RawMoveData
|
|
If PutVacuumCupsOnRaw(nId, rmData) Then
|
|
' Visualizzo le ventose
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.ON_)
|
|
' Aggiorno i dati
|
|
AddRawMoveData(rmData, m_RawMoveDataList)
|
|
m_bRawWithCups = True
|
|
' Reset eventuale messaggio
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
Else
|
|
' Aggiorno i dati
|
|
m_bRawWithCups = False
|
|
' Messaggio di avvertimento (Pezzo troppo piccolo : non si può muovere)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
End If
|
|
End If
|
|
EgtDraw()
|
|
Exit While
|
|
End If
|
|
nId = EgtGetNextObjInSelWin()
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' EVENTS
|
|
|
|
End Class
|