241 lines
9.6 KiB
VB.net
241 lines
9.6 KiB
VB.net
Imports EgtUILib
|
|
|
|
Public Class MoveVM
|
|
Inherits SceneUserControlVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_MsgList As New List(Of String)({TopBar_Msg_Stg0, TopBar_Msg_Stg1})
|
|
Public ReadOnly Property MsgList As List(Of String)
|
|
Get
|
|
Return m_MsgList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_Stage As MoveStage = MoveStage.SelectPart
|
|
Private Property Stage As MoveStage
|
|
Get
|
|
Return m_Stage
|
|
End Get
|
|
Set(value As MoveStage)
|
|
m_Stage = value
|
|
DirectCast(ParamList(0), _TextBlockParam).MsgValue = MsgList(m_Stage)
|
|
ChangeTextColor()
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property TopBar_Msg_Stg0 As String
|
|
Get
|
|
Return EgtMsg(110023) ' Seleziona il pezzo da spostare
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TopBar_Msg_Stg1 As String
|
|
Get
|
|
Return EgtMsg(110025) ' Inserisci il vettore di spostamento
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
#End Region ' Fields & properties
|
|
|
|
#Region "CONTRUCTOR"
|
|
|
|
Public Sub New()
|
|
MyBase.New()
|
|
Title = EGT_MOVE.ToUpper()
|
|
LoadParamList()
|
|
Stage = If(Map.refSceneHostVM.m_nIdPart = GDB_ID.NULL, MoveStage.SelectPart, MoveStage.InsertMovement)
|
|
ActivateButton()
|
|
RemoveAllUC()
|
|
End Sub
|
|
|
|
#End Region ' Contructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Public Overrides Sub LoadParamList()
|
|
ParamList.Add(New _TextBlockParam(EGT_MESSAGE, MsgList(Stage), ParamType.STR, Visibility.Visible))
|
|
ParamList.Add(New _TextBoxParam("X", "0", ParamType.LEN, Visibility.Visible))
|
|
ParamList.Add(New _TextBoxParam("Y", "0", ParamType.LEN, Visibility.Visible))
|
|
ParamList.Add(New _TextBoxParam("Z", "0", ParamType.LEN, Visibility.Visible))
|
|
End Sub
|
|
|
|
Public Sub AdvanceStage()
|
|
Stage += 1
|
|
End Sub
|
|
|
|
Public Function AtStage()
|
|
Return Stage
|
|
End Function
|
|
|
|
Private Function ReadMoveInput()
|
|
' recupero i valori nelle box
|
|
Dim x_TextBox As _TextBoxParam = DirectCast(ParamList(1), _TextBoxParam)
|
|
Dim y_TextBox As _TextBoxParam = DirectCast(ParamList(2), _TextBoxParam)
|
|
Dim z_TextBox As _TextBoxParam = DirectCast(ParamList(3), _TextBoxParam)
|
|
' verifico che siano validi
|
|
If String.IsNullOrEmpty(x_TextBox.sValue) Then x_TextBox.sValue = "0"
|
|
If String.IsNullOrEmpty(y_TextBox.sValue) Then y_TextBox.sValue = "0"
|
|
If String.IsNullOrEmpty(z_TextBox.sValue) Then z_TextBox.sValue = "0"
|
|
' restituisco il vettore
|
|
Return New Vector3d(CDbl(x_TextBox.sValue),
|
|
CDbl(y_TextBox.sValue),
|
|
CDbl(z_TextBox.sValue))
|
|
End Function
|
|
|
|
Public Overrides Sub Conferma()
|
|
' se non avevo visualizzato la preview allora sposto il/i pezzo/i
|
|
If Not Map.refSceneHostVM.m_bPreviewShown Then
|
|
Dim vtMove As Vector3d = ReadMoveInput()
|
|
'''' gestione dell'opzione 'AllSelected
|
|
'If Not AreSameVectorExact(vtMove, New Vector3d) Then
|
|
' If Not AllOption_Move.IsChecked Then
|
|
' Move(m_nIdPart, vtMove, True, False)
|
|
' Else
|
|
' Dim ListSelected As List(Of PartSolid)
|
|
' ListSelected = GetAllSelected()
|
|
' For Each PartSolidInSel As PartSolid In ListSelected
|
|
' Move(PartSolidInSel.PartId, vtMove, True, False)
|
|
' Next
|
|
' End If
|
|
' m_bPreview = True
|
|
'End If
|
|
|
|
If Map.refSceneHostVM.m_nIdPart <> GDB_ID.NULL And Not AreSameVectorExact(vtMove, New Vector3d) Then
|
|
SolidManagerM.Move(Map.refSceneHostVM.m_nIdPart, vtMove, False, True)
|
|
End If
|
|
End If
|
|
|
|
''''' gestione dell'opzione 'AllSelected
|
|
'If Not AllOption_Move.IsChecked Then
|
|
' ' AddEvent(New ObjectEvent(m_nIdPart, LastTempTransf()))
|
|
' If EgtLuaSetGlobIntVar("ASS.nTempToSave", -1) Then AssLog("ASS.nTempToSave = -1")
|
|
' If EgtLuaCallFunction("ASS.AddEventFromTemp") Then AssLog("ASS.AddEventFromTemp()")
|
|
'Else
|
|
' Dim ListSelected As List(Of PartSolid)
|
|
' ListSelected = GetAllSelected()
|
|
' 'For Each PartSolidInSel As PartSolid In ListSelected
|
|
' 'AddEvent(New ObjectEvent(PartSolidInSel.PartId, LastTempTransf()))
|
|
' For nTrasf As Integer = -ListSelected.Count() To 0 Step +1
|
|
' If EgtLuaSetGlobIntVar("ASS.nTempToSave", nTrasf) Then AssLog("ASS.nTempToSave = " & nTrasf.ToString)
|
|
' If EgtLuaCallFunction("ASS.AddEventFromTemp") Then AssLog("ASS.AddEventFromTemp()")
|
|
' Next
|
|
'End If
|
|
|
|
'' devo salvare le operazioni svolte durante l'accoppiamento come parte della storia globale
|
|
'For nItTime As Integer = -Map.refSceneHostV.m_nTransfNum To -1 Step 1
|
|
' '' scorro le ultime trasformazioni temporanee
|
|
' If EgtLuaSetGlobIntVar("ASS.nTempToSave", nItTime) Then AssLog("ASS.nTempToSave = " & nItTime.ToString)
|
|
' If EgtLuaCallFunction("ASS.AddEventFromTemp") Then AssLog("ASS.AddEventFromTemp()")
|
|
'Next
|
|
If EgtLuaSetGlobIntVar("ASS.nTempToSave", Map.refSceneHostVM.m_nTransfNum + 1) Then AssLog("ASS.nTempToSave = " & (Map.refSceneHostVM.m_nTransfNum + 1).ToString)
|
|
If EgtLuaCallFunction("ASS.AddLastestEventsFromTemp") Then AssLog("ASS.AddLastestEventsFromTemp()")
|
|
|
|
DeselectAll()
|
|
Map.refSceneHostVM.m_bPreviewShown = False
|
|
' gestisco le attivazioni di undo/redo
|
|
SolidManagerM.ManageUndoRedo()
|
|
Close()
|
|
End Sub
|
|
|
|
Public Overrides Sub Annulla()
|
|
' faccio il reset del pairing
|
|
If Map.refSceneHostVM.m_nTransfNum > Map.refSceneHostVM.m_MaxTempTime Then
|
|
Map.refSceneHostVM.m_nTransfNum = Map.refSceneHostVM.m_MaxTempTime
|
|
End If
|
|
For op As Integer = Map.refSceneHostVM.m_nTransfNum To 0 Step -1
|
|
If EgtLuaCallFunction("ASS.UndoTemp") Then AssLog("ASS.UndoTemp()")
|
|
Next
|
|
Close()
|
|
End Sub
|
|
|
|
Public Overrides Sub ShowPreview()
|
|
Dim Btn As SceneBtn = DirectCast(Map.refSceneButtonV.DataContext, SceneButtonVM).GetButton(EGT_MOVE)
|
|
If TypeOf (Btn) Is _ToggleButton Then
|
|
If Not DirectCast(Btn, _ToggleButton).IsChecked Then Return
|
|
Else
|
|
EgtOutLog("CONFIG ERR: Il pulsante di Move è stato definito come Button anziché ToggleButton")
|
|
Return
|
|
End If
|
|
|
|
Dim vtMove As Vector3d = ReadMoveInput()
|
|
If Map.refSceneHostVM.m_nIdPart <> GDB_ID.NULL And Not AreSameVectorExact(vtMove, New Vector3d) Then
|
|
If Map.refSceneHostVM.m_bPreviewShown = True Then
|
|
' resetto il movimento precedente
|
|
If EgtLuaCallFunction("ASS.UndoTemp") Then AssLog("ASS.UndoTemp()")
|
|
End If
|
|
|
|
'''' eventuale gestione di un'opzione 'All Selected
|
|
'If Not AllOption_Move.IsChecked And m_nIdPart <> -1 Then
|
|
' Dim PartSolidSelected As PartSolid = GetPartSolid(m_nIdPart)
|
|
' If IsNothing(PartSolidSelected) Then Return
|
|
' Move(m_nIdPart, vtMove, False, True)
|
|
'Else
|
|
' Dim ListSelected As List(Of PartSolid)
|
|
' ListSelected = GetAllSelected()
|
|
' For Each PartSolidInSel As PartSolid In ListSelected
|
|
' If IsNothing(PartSolidInSel) Then Return
|
|
' Move(PartSolidInSel.PartId, vtMove, False, True)
|
|
' Next
|
|
'End If
|
|
|
|
SolidManagerM.Move(Map.refSceneHostVM.m_nIdPart, vtMove, False, True)
|
|
|
|
Map.refSceneHostVM.m_bPreviewShown = True
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Close()
|
|
SolidManagerM.ResetOperationMarks(Map.refSceneHostVM.m_nIdPart)
|
|
EgtDraw()
|
|
Dim Btn As SceneBtn = Map.refSceneButtonVM.GetButton(EGT_MOVE)
|
|
If TypeOf (Btn) Is _ToggleButton Then
|
|
DirectCast(Btn, _ToggleButton).IsChecked = False
|
|
Else
|
|
EgtOutLog("CONFIG ERR: Il pulsante di Move è stato definito come Button anziché ToggleButton")
|
|
End If
|
|
' resetto la storia temporanea
|
|
If EgtLuaCallFunction("ASS.ResetTempStory") Then AssLog("ASS.ResetTempStory()")
|
|
' resetto il contatore per le operazioni temporanee e la variabile che indica se è stata visualizzata la preview
|
|
Map.refSceneHostVM.m_nTransfNum = 0
|
|
Map.refSceneHostVM.m_bPreviewShown = False
|
|
' setto le variabili per il salvataggio della storia normale
|
|
Dim bSave As Boolean = True
|
|
If EgtLuaSetGlobBoolVar("ASS.bSaveHist", bSave) Then AssLog("ASS.bSaveHist = " & bSave.ToString)
|
|
Dim bSaveTemp As Boolean = False
|
|
If EgtLuaSetGlobBoolVar("ASS.bSaveTemp", bSaveTemp) Then AssLog("ASS.bSaveTemp = " & bSaveTemp.ToString)
|
|
' rimuovo lo UC dalla griglia
|
|
Map.refSceneButtonVM.RemoveUC(Map.refSceneButtonVM.m_MoveUC)
|
|
SolidManagerM.ManageUndoRedo()
|
|
End Sub
|
|
|
|
Private Sub ActivateButton()
|
|
' Disattivo pulsante Rotate
|
|
DirectCast(Map.refSceneButtonVM.GetButton(EGT_ROTATE), _ToggleButton).IsChecked = False
|
|
' Disattivo pulsante Pair
|
|
DirectCast(Map.refSceneButtonVM.GetButton(EGT_PAIR), _ToggleButton).IsChecked = False
|
|
' Attivo pulsante Move
|
|
DirectCast(Map.refSceneButtonVM.GetButton(EGT_MOVE), _ToggleButton).IsChecked = True
|
|
End Sub
|
|
|
|
Private Sub RemoveAllUC()
|
|
Map.refSceneButtonVM.RemoveUC(Map.refSceneButtonVM.m_AngleUC)
|
|
Map.refSceneButtonVM.RemoveUC(Map.refSceneButtonVM.m_EditPanelUC)
|
|
Map.refSceneButtonVM.RemoveUC(Map.refSceneButtonVM.m_EditParametricUC)
|
|
Map.refSceneButtonVM.RemoveUC(Map.refSceneButtonVM.m_ExtremityUC)
|
|
Map.refSceneButtonVM.RemoveUC(Map.refSceneButtonVM.m_LengthUC)
|
|
Map.refSceneButtonVM.RemoveUC(Map.refSceneButtonVM.m_NewPanelUC)
|
|
Map.refSceneButtonVM.RemoveUC(Map.refSceneButtonVM.m_PairUC)
|
|
Map.refSceneButtonVM.RemoveUC(Map.refSceneButtonVM.m_ParametricCompoUC)
|
|
Map.refSceneButtonVM.RemoveUC(Map.refSceneButtonVM.m_RotateUC)
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|