e537861ca5
- aggiunta la scelta del tipo di giunzione alla creazione delle paretine - ricreazione dei vicini alla cancellazione di una paretina.
426 lines
16 KiB
VB.net
426 lines
16 KiB
VB.net
Imports EgtUILib
|
|
|
|
Public Class EditPanelVM
|
|
Inherits SceneUserControlVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private ReadOnly m_MsgList As New List(Of String)({TopBar_Msg_Stg0, TopBar_Msg_Stg1, TopBar_Msg_Stg2, Msg_Paragraph1, Msg_Paragraph2})
|
|
Public ReadOnly Property MsgList As List(Of String)
|
|
Get
|
|
Return m_MsgList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_Stage As EditPanelStage = EditPanelStage.SelectPart
|
|
Private Property Stage As EditPanelStage
|
|
Get
|
|
Return m_Stage
|
|
End Get
|
|
Set(value As EditPanelStage)
|
|
m_Stage = value
|
|
DirectCast(ParamList(0), _TextBlockParam).MsgValue = MsgList(m_Stage)
|
|
End Set
|
|
End Property
|
|
|
|
Private m_PartType As PartType = PartType.Unknown
|
|
Friend Property PartType As PartType
|
|
Get
|
|
Return m_PartType
|
|
End Get
|
|
Set(value As PartType)
|
|
m_PartType = value
|
|
End Set
|
|
End Property
|
|
|
|
' id del part selezionato per essere modificato
|
|
Private m_nIdPart As Integer = GDB_ID.NULL
|
|
Public Property nIdPart As Integer
|
|
Get
|
|
Return m_nIdPart
|
|
End Get
|
|
Set(value As Integer)
|
|
If m_nIdPart <> GDB_ID.NULL Then SceneCmd.DeselectAll()
|
|
m_nIdPart = value
|
|
Stage = EditPanelStage.InsertNewParam
|
|
' devo capire che tipo di pezzo sto modificando
|
|
' se non ha info di accoppiamento è una base (piano cucina)
|
|
' se ha l'info "Sink" allora è un pezzo di una buca
|
|
' se ha info di accoppiamento generico è una paretina
|
|
PartType = GetPartType()
|
|
If ParamList.Count > 0 Then
|
|
Select Case PartType
|
|
Case PartType.Panel
|
|
UpdatePanelInfoFromPart(m_nIdPart)
|
|
Case PartType.Sink
|
|
Dim bIsBottom As Boolean = False
|
|
EgtGetInfo(m_nIdPart, "Bottom", bIsBottom)
|
|
If bIsBottom Then
|
|
Dim nParent As Integer = GDB_ID.NULL
|
|
EgtGetInfo(m_nIdPart, "Parent", nParent)
|
|
UpdatePanelInfoFromPart(nParent)
|
|
Else
|
|
UpdatePanelInfoFromPart(m_nIdPart)
|
|
End If
|
|
End Select
|
|
End If
|
|
UpdateParameterListShown()
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property TopBar_Msg_Stg0 As String
|
|
Get
|
|
Return EgtMsg(110040) ' Seleziona il Part che vuoi modificare
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property TopBar_Msg_Stg1 As String
|
|
Get
|
|
Return EgtMsg(110041) ' Inserisci i nuovi parametri
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property TopBar_Msg_Stg2 As String
|
|
Get
|
|
Return EgtMsg(110042) ' Conferma, modifica con altri parametri o annulla
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property Msg_Paragraph1 As String
|
|
Get
|
|
Return EgtMsg(110038) ' Frontalino
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property Msg_Paragraph2 As String
|
|
Get
|
|
Return EgtMsg(110039) ' Fondo
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Public Sub New()
|
|
MyBase.New()
|
|
Title = "Modifica Paretina".ToUpper()
|
|
If Map.refSceneHostVM.m_nIdPart <> GDB_ID.NULL Then
|
|
nIdPart = Map.refSceneHostVM.m_nIdPart
|
|
Stage = EditPanelStage.InsertNewParam
|
|
End If
|
|
|
|
LoadParamList()
|
|
UpdatePanelInfoFromPart(m_nIdPart)
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
Private Sub UpdatePanelInfoFromPart(nIdPart As Integer)
|
|
If nIdPart = GDB_ID.NULL Then Return
|
|
Dim dH As Double = 100
|
|
EgtGetInfo(nIdPart, "H", dH)
|
|
DirectCast(ParamList(2), _TextBoxParam).sValue = dH.ToString()
|
|
Dim dTh As Double = 10
|
|
EgtGetInfo(nIdPart, "Th", dTh)
|
|
DirectCast(ParamList(3), _TextBoxParam).sValue = dTh.ToString()
|
|
Dim nJunctionType As Integer
|
|
EgtGetInfo(nIdPart, "JunctionType", nJunctionType)
|
|
DirectCast(ParamList(4), _ComboBoxParam).IndexSelParamCmBx = nJunctionType - 1
|
|
End Sub
|
|
|
|
Private Sub UpdateParameterListShown()
|
|
'' dalle info leggo se l'oggetto è una paretina o una buca
|
|
If PartType = PartType.TopKitchen Then
|
|
'ParamList(3).nVisibility = Visibility.Collapsed
|
|
'ParamList(4).nVisibility = Visibility.Collapsed
|
|
|
|
'ParamList(5).nVisibility = Visibility.Visible
|
|
'ParamList(6).nVisibility = Visibility.Visible
|
|
'ParamList(7).nVisibility = Visibility.Visible
|
|
'ParamList(8).nVisibility = Visibility.Visible
|
|
'ParamList(9).nVisibility = Visibility.Visible
|
|
|
|
ElseIf PartType = PartType.Sink Then
|
|
ParamList(1).nVisibility = Visibility.Visible
|
|
ParamList(2).nVisibility = Visibility.Visible
|
|
ParamList(3).nVisibility = Visibility.Visible
|
|
ParamList(4).nVisibility = Visibility.Collapsed
|
|
|
|
ParamList(5).nVisibility = Visibility.Visible
|
|
ParamList(6).nVisibility = Visibility.Visible
|
|
ParamList(7).nVisibility = Visibility.Visible
|
|
ParamList(8).nVisibility = Visibility.Visible
|
|
|
|
ParamList(9).nVisibility = Visibility.Collapsed
|
|
ElseIf PartType = PartType.Panel Then
|
|
ParamList(1).nVisibility = Visibility.Collapsed
|
|
ParamList(2).nVisibility = Visibility.Visible
|
|
ParamList(3).nVisibility = Visibility.Visible
|
|
ParamList(4).nVisibility = Visibility.Visible
|
|
|
|
ParamList(5).nVisibility = Visibility.Collapsed
|
|
ParamList(6).nVisibility = Visibility.Collapsed
|
|
ParamList(7).nVisibility = Visibility.Collapsed
|
|
ParamList(8).nVisibility = Visibility.Collapsed
|
|
|
|
ParamList(9).nVisibility = Visibility.Visible
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides Sub LoadParamList()
|
|
AddGenericParam(New _TextBlockParam("Messaggio", MsgList(0), ParamType.STR, Visibility.Visible))
|
|
' sezione paretina
|
|
AddGenericParam(New _TextBlockParam("Messaggio", MsgList(3), ParamType.STR, Visibility.Collapsed))
|
|
Dim dH As Double = 200
|
|
AddGenericParam(New _TextBoxParam("Altezza", dH, ParamType.LEN, Visibility.Visible))
|
|
Dim dTh As Double = 20
|
|
AddGenericParam(New _TextBoxParam("Spessore", dTh, ParamType.LEN, Visibility.Visible))
|
|
Dim nJunctionType As Integer = 0
|
|
Dim JunctionTypeList As New List(Of ParamCmBx)({New ParamCmBx("Trim Start"), New ParamCmBx("Trim End"), New ParamCmBx("Angle"), New ParamCmBx("Trim Both")})
|
|
AddGenericParam(New _ComboBoxParam("Tipo Giunzione", JunctionTypeList, nJunctionType))
|
|
|
|
' sezione fondello
|
|
AddGenericParam(New _TextBlockParam("Messaggio", MsgList(4), ParamType.STR, Visibility.Collapsed))
|
|
AddGenericParam(New _TextBoxParam("Spessore", 10, ParamType.LEN, Visibility.Collapsed))
|
|
AddGenericParam(New _TextBoxParam("Inclinazione", 0.1, ParamType.DOUB, Visibility.Collapsed))
|
|
AddGenericParam(New _TextBoxParam("Diametro foro", 30, ParamType.LEN, Visibility.Collapsed))
|
|
|
|
' checkbox
|
|
AddGenericParam(New _CheckBoxParam("ModificaAdiacenti", "Modifica anche altre paretine dello stesso tipo", Visibility.Visible))
|
|
End Sub
|
|
|
|
Public Sub AdvanceStage()
|
|
Stage += 1
|
|
End Sub
|
|
|
|
Public Function AtStage()
|
|
Return Stage
|
|
End Function
|
|
|
|
Public Overrides Sub Conferma()
|
|
' in base al tipo di pezzo che sto modificando chiamo la funzione corrispondente
|
|
Select Case PartType
|
|
Case PartType.Sink
|
|
EditSinkWithSplitBottom()
|
|
Case PartType.Panel
|
|
EditPanel(nIdPart)
|
|
Case PartType.TopKitchen
|
|
'EditTopKitchen()
|
|
End Select
|
|
' aggiorno la lista dei partSolid
|
|
SolidManagerM.CreatePartSolid()
|
|
' chiudo lo user control
|
|
Close()
|
|
End Sub
|
|
|
|
Public Overrides Sub Annulla()
|
|
Map.refSceneHostVM.m_nIdPart = GDB_ID.NULL
|
|
SceneCmd.DeselectAll()
|
|
' chiudo lo user control
|
|
Close()
|
|
End Sub
|
|
|
|
Private Sub Close()
|
|
SolidManagerM.ResetOperationMarks(Map.refSceneHostVM.m_nIdPart)
|
|
EgtDraw()
|
|
Dim Btn As SceneBtn = Map.refSceneButtonVM.GetButton(EGT_EDIT_PANEL)
|
|
If TypeOf (Btn) Is _ToggleButton Then
|
|
DirectCast(Btn, _ToggleButton).IsChecked = False
|
|
Else
|
|
EgtOutLog("CONFIG ERR: Il pulsante di Edit Panel è stato definito come Button anziché ToggleButton")
|
|
End If
|
|
' rimuovo lo UC dalla griglia
|
|
Map.refSceneButtonVM.RemoveUC(Map.refSceneButtonVM.m_EditPanelUC)
|
|
SolidManagerM.ManageUndoRedo()
|
|
End Sub
|
|
|
|
Public Function GetPartType()
|
|
Dim bIsSink As Boolean = False
|
|
EgtGetInfo(m_nIdPart, "Sink", bIsSink)
|
|
If bIsSink Then
|
|
Return PartType.Sink
|
|
End If
|
|
Dim sPair As String = String.Empty
|
|
EgtGetInfo(m_nIdPart, "PairMyRef", sPair)
|
|
Dim bIsPanel As Boolean = sPair <> String.Empty
|
|
If bIsPanel Then
|
|
Return PartType.Panel
|
|
End If
|
|
' altrimenti è un piano cucina
|
|
Return PartType.TopKitchen
|
|
End Function
|
|
|
|
Private Sub SetVariablesAndRecreate(nEdgeId As Integer)
|
|
If EgtLuaSetGlobIntVar("TOOL.nEdgeId", nEdgeId) Then AssLog("TOOL.nEdgeId = " & nEdgeId.ToString())
|
|
Dim nJunctionType = DirectCast(ParamList(4), _ComboBoxParam).IndexSelParamCmBx + 1 ' in Lua l'enum è 1-based
|
|
If EgtLuaSetGlobIntVar("TOOL.nJunctionType", nJunctionType) Then AssLog("TOOL.nJunctionType = " & nJunctionType.ToString())
|
|
Dim dTh As Double = DirectCast(ParamList(3), _TextBoxParam).GetValue()
|
|
If EgtLuaSetGlobNumVar("TOOL.dTh", dTh) Then AssLog("TOOL.dTh = " & dTh.ToString())
|
|
Dim dH As Double = DirectCast(ParamList(2), _TextBoxParam).GetValue()
|
|
If EgtLuaSetGlobNumVar("TOOL.dH", dH) Then AssLog("TOOL.dH = " & dH.ToString())
|
|
Dim bPrev As Boolean = True
|
|
If EgtLuaSetGlobBoolVar("TOOL.bPrev", bPrev) Then AssLog("TOOL.bPrev = true")
|
|
Dim bNext As Boolean = True
|
|
If EgtLuaSetGlobBoolVar("TOOL.bNext", bNext) Then AssLog("TOOL.bNext = true")
|
|
If EgtLuaCallFunction("TOOL.CreateParetinaFull") Then AssLog("TOOL.CreateParetinaFull()")
|
|
End Sub
|
|
|
|
Private Sub EditPanel(nId)
|
|
' recupero le info salvate nel Part
|
|
EgtLuaExecLine("TOOL.FillInfoTableFromPart(" & nId.ToString() & ")")
|
|
' recupero l'id dell'edge che ha generato la paretina
|
|
Dim nParent As Integer = GDB_ID.NULL
|
|
EgtGetInfo(nId, "Parent", nParent)
|
|
Dim nIn As Integer = 0
|
|
EgtGetInfo(nId, "nInLoop", nIn)
|
|
Dim sLayName As String = "OutLoop"
|
|
Dim nLayId As Integer = GDB_ID.NULL
|
|
If nIn = 0 Then
|
|
nLayId = EgtGetFirstNameInGroup(nParent, sLayName)
|
|
Else
|
|
sLayName = "InLoop"
|
|
nLayId = EgtGetFirstNameInGroup(nParent, sLayName)
|
|
Dim nInLays = 1
|
|
While nInLays <> nIn
|
|
nLayId = EgtGetNextName(nLayId, sLayName)
|
|
nInLays += 1
|
|
End While
|
|
End If
|
|
Dim nEdge As Integer = 0
|
|
EgtGetInfo(nId, "ParentEdge", nEdge)
|
|
Dim sEdgeName As String = "A" & nEdge.ToString()
|
|
Dim nEdgeId As Integer = EgtGetFirstNameInGroup(nLayId, sEdgeName)
|
|
' setto i parametri che ha scelto l'utente
|
|
SetVariablesAndRecreate(nEdgeId)
|
|
' se la checkbox per la modifica delle paretine dello stesso tipo, sullo stesso loop, è checkata allora scorro il loop e continuo a chiamare la ricreazione
|
|
If DirectCast(ParamList(9), _CheckBoxParam).IsChecked Then
|
|
' scorro i next e prev modificando anche le paretine adiacenti con le stesse modifiche
|
|
' facendo attenzione a non entrare in un loop
|
|
Dim sCurrPartName As String = String.Empty
|
|
EgtGetName(nId, sCurrPartName)
|
|
Dim sNamePrev As String = String.Empty
|
|
EgtGetInfo(nId, "Prev", sNamePrev)
|
|
Dim nLastPrev As Integer = GDB_ID.NULL
|
|
While sNamePrev <> String.Empty And sNamePrev <> sCurrPartName
|
|
Dim nPrev As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, sNamePrev)
|
|
' recupero l'edge del parent e ricreo la paretina
|
|
EgtGetInfo(nPrev, "ParentEdge", nEdge)
|
|
' recupero le info salvate nel Part
|
|
EgtLuaExecLine("TOOL.FillInfoTableFromPart(" & nPrev.ToString() & ")")
|
|
sEdgeName = "A" & nEdge.ToString()
|
|
nEdgeId = EgtGetFirstNameInGroup(nLayId, sEdgeName)
|
|
SetVariablesAndRecreate(nEdgeId)
|
|
EgtGetInfo(nPrev, "Prev", sNamePrev)
|
|
nLastPrev = nPrev
|
|
End While
|
|
Dim sNameNext As String = String.Empty
|
|
EgtGetInfo(nId, "Next", sNameNext)
|
|
While sNameNext <> String.Empty
|
|
Dim nNext As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, sNameNext)
|
|
' recupero l'edge del parent e ricreo la paretina
|
|
If nNext = nLastPrev Then Exit While
|
|
' recupero le info salvate nel Part
|
|
EgtLuaExecLine("TOOL.FillInfoTableFromPart(" & nNext.ToString() & ")")
|
|
EgtGetInfo(nNext, "ParentEdge", nEdge)
|
|
sEdgeName = "A" & nEdge.ToString()
|
|
nEdgeId = EgtGetFirstNameInGroup(nLayId, sEdgeName)
|
|
SetVariablesAndRecreate(nEdgeId)
|
|
EgtGetInfo(nNext, "Next", sNameNext)
|
|
End While
|
|
End If
|
|
End Sub
|
|
|
|
Private Function GetNeighbours(nId As Integer)
|
|
Dim NeighList As New List(Of Integer)
|
|
If nId = GDB_ID.NULL Then Return NeighList
|
|
Dim nNextId As Integer = nId
|
|
While nNextId <> GDB_ID.NULL
|
|
NeighList.Add(nNextId)
|
|
Dim sNextName As String = String.Empty
|
|
EgtGetInfo(nNextId, "Next", sNextName)
|
|
nNextId = EgtGetFirstNameInGroup(GDB_ID.ROOT, sNextName)
|
|
If nNextId = nId Then Exit While
|
|
End While
|
|
|
|
Return NeighList
|
|
End Function
|
|
|
|
Private Sub EditSinkBottom(PartList As List(Of Integer))
|
|
Dim lEdgeList As New List(Of Integer)
|
|
For Each nPart As Integer In PartList
|
|
Dim nOutLay As Integer = EgtGetFirstNameInGroup(nPart, "OutLoop")
|
|
Dim nEdge As Integer = EgtGetFirstNameInGroup(nOutLay, "A3")
|
|
lEdgeList.Add(nEdge)
|
|
Next
|
|
|
|
For i As Integer = 1 To lEdgeList.Count
|
|
EgtLuaSetGlobIntVar("TOOL.tbIdEdges." & i.ToString(), lEdgeList(i - 1).ToString())
|
|
Next
|
|
Dim dTh As Double = DirectCast(ParamList(6), _TextBoxParam).GetValue()
|
|
EgtLuaSetGlobNumVar("TOOL.dTh", dTh)
|
|
Dim dDiam As Double = DirectCast(ParamList(8), _TextBoxParam).GetValue()
|
|
EgtLuaSetGlobNumVar("TOOL.dDiamBore", dDiam)
|
|
Dim dAng As Double = DirectCast(ParamList(7), _TextBoxParam).GetValue()
|
|
EgtLuaSetGlobNumVar("TOOL.dSlopeAng", dAng)
|
|
EgtLuaCallFunction("TOOL.CreateSplitBottom")
|
|
End Sub
|
|
|
|
Private Sub EditSinkWithSplitBottom()
|
|
' risalgo ai frontalini
|
|
Dim bBottom As Boolean = False
|
|
EgtGetInfo(nIdPart, "Bottom", bBottom)
|
|
Dim nWaterfallId As Integer = nIdPart
|
|
If bBottom Then
|
|
Dim sInfoPartDest As String = String.Empty
|
|
EgtGetInfo(nIdPart, "PairToRef", sInfoPartDest)
|
|
Dim sInfoPartDestSplit As Array = sInfoPartDest.Split(","c)
|
|
Dim sPartDest As String = sInfoPartDestSplit(0)
|
|
nWaterfallId = EgtGetFirstNameInGroup(GDB_ID.ROOT, sPartDest)
|
|
End If
|
|
' modifico i frontalini
|
|
DirectCast(ParamList(9), _CheckBoxParam).IsChecked = True
|
|
EditPanel(nWaterfallId)
|
|
' recupero la lista degli id dei frontalini
|
|
Dim WaterfallList As List(Of Integer) = GetNeighbours(nWaterfallId)
|
|
' modifico i pezzi dello split bottom
|
|
EditSinkBottom(WaterfallList)
|
|
End Sub
|
|
|
|
Public Sub SelectPartOrPartsToEdit()
|
|
If PartType = PartType.Sink Then
|
|
Dim bBottom As Boolean = False
|
|
EgtGetInfo(nIdPart, "Bottom", bBottom)
|
|
Dim BottomList As List(Of Integer)
|
|
Dim WaterFallList As List(Of Integer)
|
|
If bBottom Then
|
|
BottomList = GetNeighbours(nIdPart)
|
|
Dim nWaterfallId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(nIdPart, "Parent", nWaterfallId)
|
|
WaterFallList = GetNeighbours(nWaterfallId)
|
|
Else
|
|
WaterFallList = GetNeighbours(nIdPart)
|
|
Dim sBottomName As String = String.Empty
|
|
EgtGetInfo(nIdPart, "A3", sBottomName)
|
|
Dim nBottomId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, sBottomName)
|
|
BottomList = GetNeighbours(nBottomId)
|
|
End If
|
|
For Each nPartId In BottomList
|
|
Dim PartSolidSel As PartSolidM = GetPartSolid(nPartId)
|
|
PartSolidSel.SelectSinglePart()
|
|
Next
|
|
For Each nPartId In WaterFallList
|
|
Dim PartSolidSel As PartSolidM = GetPartSolid(nPartId)
|
|
PartSolidSel.SelectSinglePart()
|
|
Next
|
|
Else
|
|
Dim PartSolidSel As PartSolidM = GetPartSolid(nIdPart)
|
|
PartSolidSel.SelectSinglePart()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
End Class
|