Files
egtstone3d/Panel/EditParametricVM.vb
Demetrio Cassarino 6043e8bf16 -pulizia codice
2025-02-25 09:15:59 +01:00

301 lines
8.3 KiB
VB.net

Imports EgtUILib
Imports EgtWPFLib5
Public Class EditParametricVM
Inherits SceneUserControlVM
#Region "FIELDS & PROPERTIES"
Private Enum ParamEnum As Integer
TOP_MSG = 0
CHK_PNT = 1
CHK_LEN = 2
CHK_DIR = 3
End Enum
Private bReadyForLinks As Boolean = False
Private ReadOnly m_MsgList As New List(Of String)({TopBar_Msg_Stg0, TopBar_Msg_Stg1, TopBar_Msg_Stg2})
Public ReadOnly Property MsgList As List(Of String)
Get
Return m_MsgList
End Get
End Property
Private m_Stage As EditParametricStage = EditParametricStage.SelectPart
Private Property Stage As EditParametricStage
Get
Return m_Stage
End Get
Set(value As EditParametricStage)
m_Stage = value
DirectCast(ParamList(0), _TextBlockParam).MsgValue = MsgList(m_Stage)
ChangeTextColor()
End Set
End Property
' id del part selezionato per essere modificato
Private m_nId1 As Integer = GDB_ID.NULL
Public Property nId1 As Integer
Get
Return m_nId1
End Get
Set(value As Integer)
If m_nId1 <> GDB_ID.NULL Then SceneCmd.DeselectAll()
m_nId1 = value
End Set
End Property
' punto selezionato sulla prima linea
Private m_FirstPoint As New Point3d
Public Property FirstPoint As Point3d
Get
Return m_FirstPoint
End Get
Set(value As Point3d)
m_FirstPoint = value
End Set
End Property
' parametro del punto sulla prima linea
Private m_dUFirst As Double
Public Property dUFirst As Double
Get
Return m_dUFirst
End Get
Set(value As Double)
m_dUFirst = value
End Set
End Property
' id del secondo part, a cui voglio vincolare il primo
Private m_nId2 As Integer = GDB_ID.NULL
Public Property nId2 As Integer
Get
Return m_nId2
End Get
Set(value As Integer)
If m_nId2 <> GDB_ID.NULL Then SceneCmd.DeselectAll()
m_nId2 = value
End Set
End Property
' punto selezionato sulla seconda linea
Private m_SecondPoint As New Point3d
Public Property SecondPoint As Point3d
Get
Return m_SecondPoint
End Get
Set(value As Point3d)
m_SecondPoint = value
End Set
End Property
' parametro del punto sulla seconda linea
Private m_dUSecond As Double
Public Property dUSecond As Double
Get
Return m_dUSecond
End Get
Set(value As Double)
m_dUSecond = value
End Set
End Property
' sottocurva sulla prima curva selezionata
Private m_nSubCrv1 As Integer
Public Property nSubCrv1 As Integer
Get
Return m_nSubCrv1
End Get
Set(value As Integer)
m_nSubCrv1 = value
End Set
End Property
' sottocurva sull'ultima curva selezionata
Private m_nSubCrv2 As Integer
Public Property nSubCrv2 As Integer
Get
Return m_nSubCrv2
End Get
Set(value As Integer)
m_nSubCrv2 = value
End Set
End Property
#Region "Messages"
Public ReadOnly Property TopBar_Msg_Stg0 As String
Get
Return EgtMsg(110040) ' Seleziona l'oggetto di cui vuoi modificare il vincolo
End Get
End Property
Public ReadOnly Property TopBar_Msg_Stg1 As String
Get
Return EgtMsg(110041) ' Seleziona l'oggetto a cui vuoi vincolare il precedente
End Get
End Property
Public ReadOnly Property TopBar_Msg_Stg2 As String
Get
Return EgtMsg(110042) '
End Get
End Property
#End Region ' Messages
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
Public Sub New()
MyBase.New()
Title = "Modifica Contorno Pezzo".ToUpper()
Dim Dir_Vein3D As String = String.Empty
Dim Path_Parametric As String = String.Empty
' carico il file LUA con tutte le funzioni di gestione parametrico
GetMainPrivateProfileString(K_VEIND3D, VEIND3D_DIR, "", Dir_Vein3D)
' Path del lua da utilizzare
GetMainPrivateProfileString(K_VEIND3D, "Parametric2D", "", Path_Parametric)
' avvio il file OperationOnSolid.lua
Dim sLuaPath As String = Dir_Vein3D & Path_Parametric
EgtLuaExecFile(sLuaPath)
LoadParamList()
Map.refSceneHostVM.m_SelType = GDB_TY.CRV_LINE
EgtSetView(VT.TOP)
End Sub
#End Region ' Constructor
#Region "METHODS"
Public Overrides Sub LoadParamList()
AddGenericParam(New _TextBlockParam(EGT_MESSAGE, MsgList(0), ParamType.STR, Visibility.Visible))
' checkbox
AddGenericParam(New _CheckBoxParam("Vincolo Punto", "Punto Start Vincolato", Visibility.Visible))
AddGenericParam(New _CheckBoxParam("Vincolo Lunghezza", "Lunghezza Vincolata", Visibility.Visible))
AddGenericParam(New _CheckBoxParam("Vincolo Direzione", "Direzione Vincolata", Visibility.Visible))
End Sub
Public Overrides Sub Conferma()
' Eseguo la giunzione di due pezzi
LinksEnt()
' Unisco in una compo
EgtLuaExecLine("PAR.JointLine()")
' chiudo lo user control
Close()
End Sub
Public Overrides Sub Annulla()
' Ripristino il primo stato
UndoLinksEnt()
' chiudo lo user control
Close()
End Sub
Public Overrides Sub ShowPreview()
LinksEnt()
End Sub
Private Sub Close()
SolidManagerM.ResetOperationMarks(Map.refSceneHostVM.m_nIdPart)
EgtDraw()
Dim Btn As SceneBtn = Map.refSceneButtonVM.GetButton(EGT_EDIT_PARAMETRIC)
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_EditParametricUC)
SolidManagerM.ManageUndoRedo()
' resetto la tabella globale del parametric
EgtLuaResetGlobVar("PAR")
End Sub
Private Sub LinksEnt()
' Unisco le due entità ricevute
If bReadyForLinks Then
EgtLuaExecLine("PAR.LinksLine()")
Else
EgtOutLog("Errore nella definizione dei pezzi da unire")
End If
End Sub
Private Sub UndoLinksEnt()
' Riposiziono prima entità
EgtLuaExecLine("PAR.UndoLinksLine()")
End Sub
Private Sub ResetEnt()
' Ripulisco la tabelle e il disegno
EgtLuaExecLine("PAR.Reset()")
End Sub
Public Sub ShowFirstCurrPoint()
' Info primo punto
EgtLuaSetGlobIntVar("PAR.nId1", m_nId1)
EgtLuaSetGlobPointVar("PAR.Pt1", m_FirstPoint)
EgtLuaSetGlobNumVar("PAR.dU1", m_dUFirst)
EgtLuaSetGlobNumVar("PAR.nSubCrv1", m_nSubCrv1)
' Disegno l'entità selezionata
bReadyForLinks = EgtLuaExecLine("PAR.DrawFirstPoint()")
End Sub
Public Sub ShowSecondCurrPoint()
' Info secondo punto
EgtLuaSetGlobIntVar("PAR.nId2", m_nId2)
EgtLuaSetGlobPointVar("PAR.Pt2", m_SecondPoint)
EgtLuaSetGlobNumVar("PAR.dU2", m_dUSecond)
EgtLuaSetGlobNumVar("PAR.nSubCrv2", m_nSubCrv2)
' Disegno l'entità selezionata
bReadyForLinks = bReadyForLinks And EgtLuaExecLine("PAR.DrawSecondPoint()")
End Sub
Private Sub ConstraintLenght()
' Lunghezza segmento
EgtLuaSetGlobNumVar("PAR.Len", 450.25)
' Fisso la lunghezza del segmento
EgtLuaExecLine("PAR.LinearDimension()")
' Rappresento la quotatura
EgtLuaExecLine("PAR.DrawLinearDimension()")
End Sub
Private Sub ConstraintDirection()
' Lunghezza segmento
EgtLuaSetGlobNumVar("PAR.Ang", 45.5)
' Fisso la lunghezza del segmento
EgtLuaExecLine("PAR.AngularDimension()")
' Rappresento la quotatura
EgtLuaExecLine("PAR.DrawAngularDimension()")
End Sub
#End Region ' Methods
#Region "EVENTS"
Public Overrides Sub OnCheckboxCheckedChanged(sender As Object, checkedState As Boolean)
Dim CheckBox As _CheckBoxParam = DirectCast(sender, _CheckBoxParam)
Select Case CheckBox.Name
Case "Vincolo Punto"
'LinksEnt()
Case "Vincolo Lunghezza"
ConstraintLenght()
Reset()
Case "Vincolo Direzione"
ConstraintDirection()
End Select
End Sub
Public Overrides Sub OnComboboxSelectionChanged(sender As Object, Selection As ParamCmBx)
End Sub
#End Region ' Events
End Class