EgtCAM5 :

- Cambiati nomi classi e file.
This commit is contained in:
Emmanuele Sassi
2018-04-10 17:08:35 +00:00
parent 4e2801a1c4
commit a4b5cd4834
144 changed files with 517 additions and 521 deletions
@@ -0,0 +1,106 @@
<UserControl x:Class="DispositionParameterExpanderView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<UserControl.Resources>
<sys:Int32 x:Key="TL">1</sys:Int32>
<sys:Int32 x:Key="TR">2</sys:Int32>
<sys:Int32 x:Key="BL">3</sys:Int32>
<sys:Int32 x:Key="BR">4</sys:Int32>
</UserControl.Resources>
<StackPanel>
<Expander Header="RawPart" IsExpanded="{Binding RawPartIsExpanded}"
Style="{StaticResource ExpanderStyle}" Margin="0,1,0,1">
<StackPanel>
<!--<CheckBox Content="Move with Fixture" IsChecked="{Binding MoveWithFixture, Mode=TwoWay}"/>-->
<!--ContentPresenter that contains the RawPart options -->
<ContentPresenter Name="RawPartOptions" Content="{Binding RawPartOptions ,Mode=OneWay}"/>
</StackPanel>
</Expander>
<Expander Header="Part" IsExpanded="{Binding PartIsExpanded}"
Style="{StaticResource ExpanderStyle}" Margin="0,1,0,1">
</Expander>
<Expander Header="Fixture" IsExpanded="{Binding FixtureIsExpanded}"
Style="{StaticResource ExpanderStyle}" Margin="0,1,0,1">
<!--ContentPresenter that contains the Fixture options -->
<ContentPresenter Name="FixtureParameters" Content="{Binding FixtureParameters ,Mode=OneWay}"/>
</Expander>
<UniformGrid Columns="2">
<RadioButton Content="Move" IsChecked="{Binding MoveIsChecked}"
Style="{StaticResource {x:Type ToggleButton}}" Height="30"/>
<RadioButton Content="Rotate"
Style="{StaticResource {x:Type ToggleButton}}" Height="30"/>
</UniformGrid>
<Grid Margin="0,5,0,5" Visibility="{Binding RawRefGroupVisibility}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.ColumnSpan="4" Text="Move Raw Reference"/>
<RadioButton Grid.Column="1" Grid.Row="1" Command="{Binding CheckedRawRefCommand}"
CommandParameter="{StaticResource TL}"
Style="{StaticResource {x:Type ToggleButton}}" Height="40" Width="40">
<Border BorderBrush="{StaticResource EgaltechBlue1}" BorderThickness="5,5,0,0"
Height="30" Width="30"/>
</RadioButton>
<RadioButton Grid.Column="2" Grid.Row="1" Command="{Binding CheckedRawRefCommand}"
CommandParameter="{StaticResource TR}"
Style="{StaticResource {x:Type ToggleButton}}" Height="40" Width="40">
<Border BorderBrush="{StaticResource EgaltechBlue1}" BorderThickness="0,5,5,0"
Height="30" Width="30"/>
</RadioButton>
<RadioButton Grid.Column="1" Grid.Row="2" Command="{Binding CheckedRawRefCommand}"
CommandParameter="{StaticResource BL}" IsChecked="{Binding BLIsChecked,Mode=OneWay}"
Style="{StaticResource {x:Type ToggleButton}}" Height="40" Width="40">
<Border BorderBrush="{StaticResource EgaltechBlue1}" BorderThickness="5,0,0,5"
Height="30" Width="30"/>
</RadioButton>
<RadioButton Grid.Column="2" Grid.Row="2" Command="{Binding CheckedRawRefCommand}"
CommandParameter="{StaticResource BR}"
Style="{StaticResource {x:Type ToggleButton}}" Height="40" Width="40">
<Border BorderBrush="{StaticResource EgaltechBlue1}" BorderThickness="0,0,5,5"
Height="30" Width="30"/>
</RadioButton>
</Grid>
<TextBlock Text="{Binding InputMsg,Mode=OneWay}" Margin="5,5,0,5"/>
<TextBox Text="{Binding InputValue,UpdateSourceTrigger=PropertyChanged}" Margin="5,0,5,5">
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding DoneCommand}"/>
<!--<KeyBinding Key="S" Modifiers="Control" Command="{Binding ShowCommand}"/>-->
</TextBox.InputBindings>
</TextBox>
<TextBlock Text="{Binding InputErrorMsg,Mode=OneWay}" Margin="5,5,5,5"
Style="{StaticResource ValidationErrorTextBlock}"/>
<Grid Margin="5,0,5,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<!--<Button Command="{Binding ShowCommand}" Visibility="{Binding ShowBtnVisibility}"
Content="{Binding ShowMsg}" Style="{StaticResource EgtCAM5_InputButton}"/>-->
<Button Command="{Binding DoneCommand}" Grid.Column="1"
Content="{Binding OkMsg}" Style="{StaticResource EgtCAM5_InputButton}"/>
</Grid>
</StackPanel>
</UserControl>
@@ -0,0 +1,3 @@
Public Class DispositionParameterExpanderView
End Class
@@ -0,0 +1,464 @@
Imports EgtUILib
Namespace EgtCAM5
Public Class DispositionParameterExpanderViewModel
Inherits ViewModelBase
Public Enum ObjectType As Integer
RAWPART = 1
PART = 2
FIXTURE = 3
End Enum
Private m_ActiveObject As ObjectType
Public Property ActiveObject As ObjectType
Get
Return m_ActiveObject
End Get
Set(value As ObjectType)
If value <> m_ActiveObject Then
Select Case value
Case ObjectType.RAWPART
RawPartIsExpanded = True
Case ObjectType.PART
PartIsExpanded = True
Case ObjectType.FIXTURE
FixtureIsExpanded = True
End Select
m_ActiveObject = value
End If
m_ActiveObject = value
End Set
End Property
Friend m_Id As Integer
Public ReadOnly Property Id As Integer
Get
Return m_Id
End Get
End Property
Private m_Name As String
Public Property Name As String
Get
Return m_Name
End Get
Set(value As String)
m_Name = value
End Set
End Property
Private m_RawPartIsExpanded As Boolean
Public Property RawPartIsExpanded As Boolean
Get
Return m_RawPartIsExpanded
End Get
Set(value As Boolean)
If value <> m_RawPartIsExpanded Then
If value Then
' Chiudo Part e Fixture
PartIsExpanded = False
FixtureIsExpanded = False
' verifico se è attiva l'opzione muovi con ventose
If m_MoveWithFixture Then
' Abilito la selezione dei RawPart con ventose
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.RAWPARTWITHFIXTURE)
Else
' Abilito la selezione dei RawPart
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.RAWPART)
End If
If m_MoveIsChecked Then
m_RawRefGroupVisibility = Visibility.Visible
OnPropertyChanged("RawRefGroupVisibility")
End If
Else
' Nascondo i bottoni per impostare la posizione di riferimento del grezzo
m_RawRefGroupVisibility = Visibility.Collapsed
OnPropertyChanged("RawRefGroupVisibility")
' smarco la prima entità selezionata
EgtResetMark(EgtGetFirstSelectedObj)
EgtDeselectAll()
EgtDraw()
End If
m_RawPartIsExpanded = value
ActiveObject = ObjectType.RAWPART
OnPropertyChanged("RawPartIsExpanded")
End If
End Set
End Property
Private m_PartIsExpanded As Boolean
Public Property PartIsExpanded As Boolean
Get
Return m_PartIsExpanded
End Get
Set(value As Boolean)
If value <> m_PartIsExpanded Then
If value Then
' Chiudo RawPart e Fixture
RawPartIsExpanded = False
FixtureIsExpanded = False
Else
' smarco la prima entità selezionata
EgtResetMark(EgtGetFirstSelectedObj)
EgtDeselectAll()
EgtDraw()
End If
m_PartIsExpanded = value
ActiveObject = ObjectType.PART
OnPropertyChanged("PartIsExpanded")
End If
End Set
End Property
Private m_FixtureIsExpanded As Boolean
Public Property FixtureIsExpanded As Boolean
Get
Return m_FixtureIsExpanded
End Get
Set(value As Boolean)
If value <> m_FixtureIsExpanded Then
If value Then
' Chiudo RawPart e Part
RawPartIsExpanded = False
PartIsExpanded = False
' Abilito la selezione delle Fixture
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.FIXTURE)
m_ExpandFixtureFunction()
Else
' smarco la prima entità selezionata
EgtResetMark(EgtGetFirstSelectedObj)
' deseleziono tutto ed aggiorno la visualizzazione
EgtDeselectAll()
EgtDraw()
End If
m_FixtureIsExpanded = value
ActiveObject = ObjectType.FIXTURE
OnPropertyChanged("FixtureIsExpanded")
End If
End Set
End Property
Private m_MoveIsChecked As Boolean
Public Property MoveIsChecked As Boolean
Get
Return m_MoveIsChecked
End Get
Set(value As Boolean)
If value <> m_MoveIsChecked Then
Application.Msn.NotifyColleagues(Application.SETMOVEINDISPOSITION, value)
InputValue = String.Empty
OnPropertyChanged("InputValue")
If value Then
If m_RawPartIsExpanded Then
m_RawRefGroupVisibility = Visibility.Visible
OnPropertyChanged("RawRefGroupVisibility")
Else
m_RawRefGroupVisibility = Visibility.Collapsed
OnPropertyChanged("RawRefGroupVisibility")
End If
m_InputMsg = "Move to:"
Else
m_RawRefGroupVisibility = Visibility.Collapsed
OnPropertyChanged("RawRefGroupVisibility")
m_InputMsg = "Rotate of:"
End If
OnPropertyChanged("InputMsg")
m_MoveIsChecked = value
End If
End Set
End Property
Private m_MoveWithFixture As Boolean = False
Public Property MoveWithFixture As Boolean
Get
Return m_MoveWithFixture
End Get
Set(value As Boolean)
If value <> m_MoveWithFixture Then
If value Then
' Abilito la selezione di RawPart con autoselezione delle sue ventose
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.RAWPARTWITHFIXTURE)
' Seleziono le ventose associate ad uno dei grezzi selezionati
' ciclo sui grezzi selezionati
Dim nSelRawPartId As Integer = EgtGetFirstSelectedObj()
While nSelRawPartId <> GDB_ID.NULL
' seleziono i sottopezzi del grezzo
DispositionUtility.SelectRawPartFixture(nSelRawPartId)
nSelRawPartId = EgtGetNextSelectedObj()
End While
Else
' Abilito la selezione di RawPart
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.RAWPART)
' ciclo sui grezzi selezionati
Dim nSelRawPartId As Integer = EgtGetFirstSelectedObj()
While nSelRawPartId <> GDB_ID.NULL
' deseleziono i sottopezzi del grezzo
DispositionUtility.DeselectRawPartFixture(nSelRawPartId)
nSelRawPartId = EgtGetNextSelectedObj()
End While
End If
EgtDraw()
m_MoveWithFixture = value
OnPropertyChanged("MoveWithFixture")
End If
End Set
End Property
Private m_InputValue As String
Public Property InputValue As String
Get
Return m_InputValue
End Get
Set(value As String)
If Not String.IsNullOrEmpty(m_InputErrorMsg) Then
m_InputErrorMsg = String.Empty
OnPropertyChanged("InputErrorMsg")
End If
m_InputValue = value
End Set
End Property
Private m_BLIsChecked As Boolean = True
Public ReadOnly Property BLIsChecked As Boolean
Get
Return m_BLIsChecked
End Get
End Property
Private m_RawRefPosition As MCH_CR = MCH_CR.BL
Private m_RawRefGroupVisibility As Visibility
Public ReadOnly Property RawRefGroupVisibility As Visibility
Get
Return m_RawRefGroupVisibility
End Get
End Property
' Actions
Private m_ExpandFixtureFunction As Action
Private m_FixtureParameters As FixtureParametersView
Public ReadOnly Property FixtureParameters As ContentControl
Get
If IsNothing(m_FixtureParameters) Then
m_FixtureParameters = New FixtureParametersView
m_FixtureParameters.DataContext = New FixtureParametersViewModel(m_ExpandFixtureFunction)
End If
Return m_FixtureParameters
End Get
End Property
Private m_RawPartOptions As RawPartOptionView
Public ReadOnly Property RawPartOptions As ContentControl
Get
If IsNothing(m_RawPartOptions) Then
m_RawPartOptions = New RawPartOptionView
m_RawPartOptions.DataContext = New RawPartOptionViewModel
End If
Return m_RawPartOptions
End Get
End Property
#Region "Messages"
Private m_InputMsg As String
Public ReadOnly Property InputMsg As String
Get
Return m_InputMsg
End Get
End Property
Private m_InputErrorMsg As String
Public ReadOnly Property InputErrorMsg As String
Get
Return m_InputErrorMsg
End Get
End Property
Public ReadOnly Property OkMsg As String
Get
Return EgtMsg(MSG_DISPOSITION + 1)
End Get
End Property
#End Region ' Messages
' Definizione comandi
Private m_cmdDone As ICommand
Private m_cmdCheckedRawRef As ICommand
#Region "CONSTRUCTOR"
Sub New(ByRef OpenDispositionFunction As Action(Of Boolean))
OpenDispositionFunction = AddressOf OpenDispositionParameters
MoveIsChecked = True
m_BLIsChecked = True
OnPropertyChanged("BLIsChecked")
m_RawRefPosition = MCH_CR.BL
End Sub
#End Region
#Region "METHODS"
Public Sub OpenDispositionParameters(bFirst As Boolean)
If bFirst Then
ActiveObject = ObjectType.RAWPART
Else
ActiveObject = ObjectType.FIXTURE
End If
Select Case m_ActiveObject
Case ObjectType.RAWPART
' Abilito la selezione delle Fixture
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.RAWPART)
Case ObjectType.FIXTURE
' Abilito la selezione delle Fixture
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.FIXTURE)
End Select
m_MoveWithFixture = False
OnPropertyChanged("MoveWithFixture")
End Sub
#End Region ' METHODS
#Region "COMMANDS"
#Region "DoneCommand"
''' <summary>
''' Returns a command that do Done.
''' </summary>
Public ReadOnly Property DoneCommand As ICommand
Get
If m_cmdDone Is Nothing Then
m_cmdDone = New RelayCommand(AddressOf Done)
End If
Return m_cmdDone
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the DoneCommand.
''' </summary>
Public Sub Done(ByVal param As Object)
' Verifico la validità del punto in Input
If Not String.IsNullOrEmpty(m_InputValue) Then
' se movimento di traslazione
If m_MoveIsChecked Then
Dim InputPoint As New Point3d(0, 0, 0)
Dim Values() As String = m_InputValue.Split(","c)
If Values.Count = 2 Then
StringToLen(Values(0), InputPoint.x)
StringToLen(Values(1), InputPoint.y)
Else
m_InputErrorMsg = "Il valore non è una cordinata XY"
OnPropertyChanged("InputErrorMsg")
Return
End If
' Vettore di movimento
Dim vtMove As Vector3d
' lo imposto a seconda del tipo del primo elemento selezionato
Dim nFirstSelectedId As Integer = EgtGetFirstSelectedObj()
' se è un grezzo
If EgtVerifyRawPartCurrPhase(nFirstSelectedId) Then
' imposto il riferimento della tavola
Dim ptTableRef As Point3d
EgtGetTableRef(1, ptTableRef)
' calcolo il punto del grezzo da posizionar nelle coordinate di input
Dim ptRawRefPoint As Point3d = DispositionUtility.GetRawPartRefPoint(nFirstSelectedId, m_RawRefPosition)
' creo un punto con le coordinate di input espresse rispetto alla tavola
Dim TableRefInputPoint As New Point3d(InputPoint)
TableRefInputPoint.LocToLoc(EgtGetGridFrame(), New Frame3d(ptTableRef))
' calcolo il vettore di spostamento del grezzo
vtMove = TableRefInputPoint - ptRawRefPoint
' se è una ventosa
ElseIf EgtVerifyFixture(nFirstSelectedId) Then
Dim SelObjFrame3d As New Frame3d(Frame3d.GLOB)
EgtGetGroupGlobFrame(nFirstSelectedId, SelObjFrame3d)
SelObjFrame3d.ToLoc(EgtGetGridFrame())
Dim FixturePoint As New Point3d(SelObjFrame3d.Orig)
' Ricavo il vettore di movimento (tengo solo XY)
vtMove = InputPoint - FixturePoint
vtMove.z = 0
End If
' Muovo tutti gli oggetti selezionati
DispositionUtility.MoveRawPartPartAndFixture(GDB_ID.SEL, vtMove)
' se è un grezzo
If EgtVerifyRawPartCurrPhase(nFirstSelectedId) Then
Dim ptRawRefPoint As Point3d = DispositionUtility.GetRawPartRefPoint(nFirstSelectedId, m_RawRefPosition)
' verifico se lo spostamento effettuato differisce da quello richiesto
Dim vtRemainingMove As Vector3d = InputPoint - ptRawRefPoint
' se differisce
If Not vtRemainingMove.IsSmall() Then
' eseguo lo spostamento rimanente sull'asse x
DispositionUtility.MoveRawPartPartAndFixture(GDB_ID.SEL, New Vector3d(vtRemainingMove.x, 0, 0))
' eseguo lo spostamento rimanente sull'asse y
DispositionUtility.MoveRawPartPartAndFixture(GDB_ID.SEL, New Vector3d(0, vtRemainingMove.y, 0))
End If
End If
' se rotazione
Else
Dim InputAngle As Double = 0
If Not StringToDouble(m_InputValue, InputAngle) Then
m_InputErrorMsg = "Il valore non è un angolo valido"
OnPropertyChanged("InputErrorMsg")
Return
End If
Dim nSelId As Integer = EgtGetFirstSelectedObj()
While nSelId <> GDB_ID.NULL
Select Case m_ActiveObject
Case ObjectType.RAWPART
If Not EgtRotateRawPart(nSelId, Vector3d.Z_AX, InputAngle) Then
m_InputErrorMsg = "Impossibile ruotare il grezzo."
OnPropertyChanged("InputErrorMsg")
End If
Case ObjectType.PART
'EgtMove...
Case ObjectType.FIXTURE
If Not EgtRotateFixture(nSelId, InputAngle) Then
m_InputErrorMsg = "Impossibile ruotare la ventosa"
OnPropertyChanged("InputErrorMsg")
End If
End Select
nSelId = EgtGetNextSelectedObj()
End While
End If
EgtDraw()
End If
End Sub
#End Region ' DoneCommand
#Region "CheckedRawRefCommand"
''' <summary>
''' Returns a command that do Done.
''' </summary>
Public ReadOnly Property CheckedRawRefCommand As ICommand
Get
If m_cmdCheckedRawRef Is Nothing Then
m_cmdCheckedRawRef = New RelayCommand(AddressOf CheckedRawRef)
End If
Return m_cmdCheckedRawRef
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the DoneCommand.
''' </summary>
Public Sub CheckedRawRef(ByVal param As Object)
Dim nRawRef As MCH_CR = DirectCast(param, MCH_CR)
m_RawRefPosition = nRawRef
End Sub
#End Region ' CheckedRawRefCommand
#End Region
End Class
End Namespace
@@ -0,0 +1,594 @@
Imports EgtUILib
Public NotInheritable Class DispositionUtility
Friend Shared Function GetRawPartRefPoint(nRawPartId As Integer, RawRefPosition As MCH_CR) As Point3d
Dim bboxRawPart As New BBox3d
' recupero il solido del grezzo dal primo elemento selezionato
Dim nRawSolidId As Integer = EgtGetFirstNameInGroup(nRawPartId, RAWSOLID)
' ne calcolo il BBox
EgtGetBBoxGlob(nRawSolidId, GDB_BB.ONLY_VISIBLE, bboxRawPart)
' imposto il riferimento della tavola
Dim ptTableRef As Point3d
EgtGetTableRef(1, ptTableRef)
' calcolo i punti min e max del bbox riferiti alla tavola
Dim ptBBoxRawPartMin As New Point3d(bboxRawPart.Min)
Dim ptBBoxRawPartMax As New Point3d(bboxRawPart.Max)
ptBBoxRawPartMin.ToLoc(New Frame3d(ptTableRef))
ptBBoxRawPartMax.ToLoc(New Frame3d(ptTableRef))
' dal box e dal tipo di punto di riferimento selezionato ricavo le coordinate del punto di riferimento
Dim ptRawRefPoint As Point3d
Select Case RawRefPosition
Case MCH_CR.TL
ptRawRefPoint.x = ptBBoxRawPartMin.x
ptRawRefPoint.y = ptBBoxRawPartMax.y
Case MCH_CR.TR
ptRawRefPoint.x = ptBBoxRawPartMax.x
ptRawRefPoint.y = ptBBoxRawPartMax.y
Case MCH_CR.BL
ptRawRefPoint.x = ptBBoxRawPartMin.x
ptRawRefPoint.y = ptBBoxRawPartMin.y
Case MCH_CR.BR
ptRawRefPoint.x = ptBBoxRawPartMax.x
ptRawRefPoint.y = ptBBoxRawPartMin.y
End Select
ptRawRefPoint.z = ptBBoxRawPartMin.z
Return ptRawRefPoint
End Function
Public Shared Function MoveRawPartPartAndFixture(nMoveId As Integer, vtMove As Vector3d, Optional nCount As Integer = 1) As Boolean
Dim bErrorMoving As Boolean = False
' Muovo gli oggetti selezionati se consentito
If nMoveId = GDB_ID.SEL Then
Dim nSelObjId As Integer = EgtGetFirstSelectedObj()
While nSelObjId <> GDB_ID.NULL
If EgtVerifyFixture(nSelObjId) Then
If Not EgtMoveFixture(nSelObjId, vtMove) Then
bErrorMoving = True
nSelObjId = EgtGetPrevSelectedObj()
While nSelObjId <> GDB_ID.NULL
If EgtVerifyFixture(nSelObjId) Then
EgtMoveFixture(nSelObjId, -vtMove)
Else
EgtMoveRawPart(nSelObjId, -vtMove)
End If
nSelObjId = EgtGetPrevSelectedObj()
End While
Exit While
End If
nSelObjId = EgtGetNextSelectedObj()
Else
If Not EgtMoveRawPart(nSelObjId, vtMove) Then
bErrorMoving = True
nSelObjId = EgtGetPrevSelectedObj()
While nSelObjId <> GDB_ID.NULL
If EgtVerifyFixture(nSelObjId) Then
EgtMoveFixture(nSelObjId, -vtMove)
Else
EgtMoveRawPart(nSelObjId, -vtMove)
End If
nSelObjId = EgtGetPrevSelectedObj()
End While
Exit While
End If
nSelObjId = EgtGetNextSelectedObj()
End If
End While
Else
If EgtVerifyFixture(nMoveId) Then
If Not EgtMoveFixture(nMoveId, vtMove) Then
bErrorMoving = True
End If
Else
If Not EgtMoveRawPart(nMoveId, vtMove) Then
bErrorMoving = True
End If
End If
End If
' Variabile che contiene l'eventuale spostamento correttivo per interferenza con riferimenti
Dim vtRefMove As New Vector3d(Vector3d.NULL)
' Se non ci sono stati errori nel movimento
Dim bErrorVerify As Boolean = False
If Not bErrorMoving Then
' Verifico che gli spostamenti effettuati siano validi
If nMoveId = GDB_ID.SEL Then
Dim nSelObjId As Integer = EgtGetFirstSelectedObj()
While nSelObjId <> GDB_ID.NULL
If Not VerifyRawPartFixturePos(nSelObjId, vtMove, vtRefMove) Then
bErrorVerify = True
Exit While
End If
nSelObjId = EgtGetNextSelectedObj()
End While
Else
If Not VerifyRawPartFixturePos(nMoveId, vtMove, vtRefMove) Then
bErrorVerify = True
End If
'Dim sOut As String = "VerifyRaw : Count=" & nCount & " Err=" & If(bErrorVerify, "1", "0") &
' " Move=" & LenToString(vtMove.x, 3) & "," & LenToString(vtMove.y, 3) &
' " RefMove=" & LenToString(vtRefMove.x, 3) & "," & LenToString(vtRefMove.y, 3)
'EgtOutLog(sOut)
End If
End If
' Se non c'è errore ma necessaria correzione riferimento
If Not bErrorVerify AndAlso Not vtRefMove.IsSmall() Then
' provo a correggere (max 1 prova)
If nCount < 2 Then
bErrorVerify = Not MoveRawPartPartAndFixture(nMoveId, vtRefMove, nCount + 1)
End If
End If
' Se c'è almeno uno spostamento non valido
If bErrorVerify Then
' ripristino la situazione iniziale annullando tutti i movimenti
If nMoveId = GDB_ID.SEL Then
Dim nSelObjId As Integer = EgtGetFirstSelectedObj()
While nSelObjId <> GDB_ID.NULL
If EgtVerifyFixture(nSelObjId) Then
EgtMoveFixture(nSelObjId, -vtMove)
Else
EgtMoveRawPart(nSelObjId, -vtMove)
End If
nSelObjId = EgtGetNextSelectedObj()
End While
Else
If EgtVerifyFixture(nMoveId) Then
EgtMoveFixture(nMoveId, -vtMove)
Else
EgtMoveRawPart(nMoveId, -vtMove)
End If
End If
' ritorno falso
Return False
End If
Return True
End Function
Public Shared Function VerifyRawPartFixturePos(nMovedObjId As Integer, ByRef vtOrigMove As Vector3d, ByRef vtRefMove As Vector3d) As Boolean
' Verifico quale sia il tipo dell'oggetto mosso
If EgtVerifyFixture(nMovedObjId) Then
Return VerifyFixturePosition(nMovedObjId, vtRefMove)
ElseIf EgtVerifyRawPartCurrPhase(nMovedObjId) Then
Return VerifyRawPosition(nMovedObjId, vtOrigMove, vtRefMove)
Else
Return False
End If
End Function
Friend Shared Function VerifyFixturePosition(nMovedFixtureId As Integer, ByRef vtRefMove As Vector3d) As Boolean
' Definisco il box della ventosa mossa
Dim bboxMovedFixture As New BBox3d
EgtGetBBoxGlob(nMovedFixtureId, GDB_BB.ONLY_VISIBLE, bboxMovedFixture)
Dim bboxFixture As New BBox3d
' Ciclo sui sottopezzi correnti per verificare le collisioni con il sottopezzo spostato
Dim nFixtureId As Integer = EgtGetFirstFixture()
While nFixtureId <> GDB_ID.NULL
If EgtVerifyFixture(nFixtureId) AndAlso nFixtureId <> nMovedFixtureId Then
' ne calcolo il BBox
EgtGetBBoxGlob(nFixtureId, GDB_BB.ONLY_VISIBLE, bboxFixture)
' verifico se c'è sovrapposizione
If bboxMovedFixture.OverlapsXY(bboxFixture) Then
' se c'è restituisco falso perchè i sottopezzi non si possono sovrapporre
Return False
End If
End If
nFixtureId = EgtGetNextFixture(nFixtureId)
End While
Return VerifyFixtureWithRaw(nMovedFixtureId, vtRefMove)
End Function
Private Shared Function VerifyFixtureWithRaw(nFixtureId As Integer, ByRef vtRefMove As Vector3d) As Boolean
' Tengo da parte il riferimento della tavola
Dim ptTableRef As Point3d
EgtGetTableRef(1, ptTableRef)
Dim TableFrame As New Frame3d(ptTableRef)
' Definisco il box del sottopezzo mosso
Dim bboxFixture As New BBox3d
EgtGetBBoxGlob(nFixtureId, GDB_BB.ONLY_VISIBLE, bboxFixture)
Dim bboxRawPart As New BBox3d
' Variabile che indica se il riferimento non è in battuta su nessun grezzo
Dim bRefAttachedToRaw As Boolean = False
' Ciclo sui grezzi della fase corrente per verificare le collisioni con il sottopezzo mosso
Dim nRawPartId As Integer = EgtGetFirstRawPart()
While nRawPartId <> GDB_ID.NULL
If EgtVerifyRawPartCurrPhase(nRawPartId) Then
' recupero il solido del grezzo
Dim nRawSolidId As Integer = EgtGetFirstNameInGroup(nRawPartId, RAWSOLID)
' ne calcolo il BBox
EgtGetBBoxGlob(nRawSolidId, GDB_BB.ONLY_VISIBLE, bboxRawPart)
' verifico il tipo di sottopezzo
Select Case FixtureType(nFixtureId)
' se il sottopezzo è una ventosa
Case FIX_TYPE.VACUUM
' verifico se c'è sovrapposizione
If bboxFixture.OverlapsXY(bboxRawPart) Then
' se c'è devo verificare che l'altezza del grezzo sia uguale a quella della ventosa
' recupero altezza ventosa
Dim dFixtureHeight As Double = 0
EgtGetInfo(nFixtureId, "H", dFixtureHeight)
' recupero altezza grezzo riferita alla tavola
Dim dRawPartMin As Point3d = bboxRawPart.Min
dRawPartMin.ToLoc(TableFrame)
' se l'altezza grezzo è minore di quella della ventosa, lo sposto alla stessa altezza
If dRawPartMin.z < dFixtureHeight - EPS_SMALL Then
Dim vtMove As New Vector3d(0, 0, dFixtureHeight - dRawPartMin.z)
EgtMoveRawPart(nRawPartId, vtMove)
' ricalcolo il BBox del solido del grezzo per averlo aggiornato con la nuova Z
EgtGetBBoxGlob(nRawSolidId, GDB_BB.ONLY_VISIBLE, bboxRawPart)
End If
' se non c'è sovrapposizione devo verificare il grezzo con tutti gli altri sottopezzi per sapere se ho tolto l'ultimo e quindi devo abbassarlo
Else
' variabile che contiene la massima altezza delle ventose sottostanti
Dim dMaxFixtureHeight As Double = 0
' Variabile che dice se c'è almeno una ventosa sotto il grezzo
Dim bIsFixtureUnderRawPart As Boolean = False
Dim nOtherFixtureId As Integer = EgtGetFirstFixture()
While nOtherFixtureId <> GDB_ID.NULL
' evito di rifare la verifica sul sottopezzo mosso
If nOtherFixtureId <> nFixtureId Then
' calcolo il BBox del sottopezzo
Dim bboxOtherFixture As New BBox3d
EgtGetBBoxGlob(nOtherFixtureId, GDB_BB.ONLY_VISIBLE, bboxOtherFixture)
If bboxRawPart.OverlapsXY(bboxOtherFixture) Then
bIsFixtureUnderRawPart = True
' recupero altezza ventosa
Dim dOtherFixtureHeight As Double = 0
EgtGetInfo(nFixtureId, "H", dOtherFixtureHeight)
' la confronto con quella massima
If dOtherFixtureHeight > dMaxFixtureHeight Then
dMaxFixtureHeight = dOtherFixtureHeight
End If
End If
End If
nOtherFixtureId = EgtGetNextFixture(nOtherFixtureId)
End While
' recupero altezza grezzo riferita alla tavola
Dim dRawPartMin As Point3d = bboxRawPart.Min
dRawPartMin.ToLoc(TableFrame)
' se non ci sono ventose sotto il grezzo
If Not bIsFixtureUnderRawPart Then
' verifico che il grezzo sia ad altezza tavola
If dRawPartMin.z <> 0 Then
Dim vtMove As New Vector3d(0, 0, -dRawPartMin.z)
EgtMoveRawPart(nRawPartId, vtMove)
End If
Else
' se ci sono verifico che l'altezza del grezzo sia quella della ventosa più alta
If Math.Abs(dRawPartMin.z - dMaxFixtureHeight) > EPS_SMALL Then
Dim vtMove As New Vector3d(0, 0, dMaxFixtureHeight - dRawPartMin.z)
EgtMoveRawPart(nRawPartId, vtMove)
End If
End If
End If
' se il sottopezzo è un riferimento
Case FIX_TYPE.REFERENCE
' verifico se c'è sovrapposizione
If bboxFixture.OverlapsXY(bboxRawPart) Then
' recupero arco del riferimento
Dim arcRefId As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(nFixtureId, SOLID), REF_ARC)
' calcolo bbox dell'arco di riferimento
Dim bboxArcRef As New BBox3d
EgtGetBBoxGlob(arcRefId, GDB_BB.STANDARD, bboxArcRef)
' ne faccio l'offset ??
'bboxArcRef.Expand(10)
If bboxRawPart.OverlapsXY(bboxArcRef) Then
' recupero contorno del grezzo
Dim ccompoRawPartOutlineId As Integer = EgtGetFirstNameInGroup(nRawPartId, RAWOUTLINE)
'recupero il raggio dell'arco di riferimento
Dim dArcRadius As Double
EgtArcRadius(arcRefId, dArcRadius)
' faccio copia e offset del contorno grezzo
Dim ccompoRawPartOutlineOffsetId As Integer = EgtCopyGlob(ccompoRawPartOutlineId, ccompoRawPartOutlineId, GDB_POS.AFTER)
EgtOffsetCurve(ccompoRawPartOutlineOffsetId, dArcRadius, OFF_TYPE.FILLET)
' recupero centro dell'arco di riferimento
Dim ptArcCenter As Point3d
EgtCenterPoint(arcRefId, ccompoRawPartOutlineOffsetId, ptArcCenter)
' verifico quale è il punto dell'offset vicino al centro dell'arco di riferimento
Dim dDist As Double
Dim ptMin As Point3d
Dim nSide As Integer
EgtGetMinDistPntSidePointCurve(ptArcCenter, ccompoRawPartOutlineOffsetId, Vector3d.Z_AX, dDist, ptMin, nSide)
' cancello offset
EgtErase(ccompoRawPartOutlineOffsetId)
' calcolo il vettore di spostamento necessario ad allinearli
Dim vtDelta As Vector3d = ptArcCenter - ptMin
vtDelta.z = 0
' se i punti coincidono, esco
If vtDelta.IsSmall() Then
' il grezzo è in battuta sul riferimento
Dim nContactColDisk As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(nFixtureId, SOLID), REF_DISK)
EgtSetColor(nContactColDisk, ReferenceContactColGreen)
bRefAttachedToRaw = True
Else
' altrimenti riporto il vettore di correzione
vtRefMove = -vtDelta.Glob(ccompoRawPartOutlineId)
End If
Else
' il grezzo non è in battuta sul riferimento
Dim nContactColDisk As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(nFixtureId, SOLID), REF_DISK)
EgtSetColor(nContactColDisk, ReferenceContactColRed)
End If
End If
End Select
End If
nRawPartId = EgtGetNextRawPart(nRawPartId)
End While
' se è un riferimento e non è in battuta sul nessun grezzo
If FixtureType(nFixtureId) = FIX_TYPE.REFERENCE AndAlso Not bRefAttachedToRaw Then
' lo segnalo
Dim nContactColDisk As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(nFixtureId, SOLID), REF_DISK)
EgtSetColor(nContactColDisk, ReferenceContactColRed)
End If
Return True
End Function
Private Shared Function VerifyRawPosition(nMovedRawId As Integer, ByRef vtOrigMove As Vector3d, ByRef vtRefMove As Vector3d) As Boolean
' Recupero il solido del grezzo
Dim nMovedRawSolidId As Integer = EgtGetFirstNameInGroup(nMovedRawId, RAWSOLID)
' definisco il box del solido del grezzo
Dim bboxMovedRawPart As New BBox3d
EgtGetBBoxGlob(nMovedRawSolidId, GDB_BB.ONLY_VISIBLE, bboxMovedRawPart)
Dim bboxRawPart As New BBox3d
' Ciclo sui grezzi della fase corrente per verificare le collisioni con il grezzo spostato
Dim nRawPartId As Integer = EgtGetFirstRawPart()
While nRawPartId <> GDB_ID.NULL
If EgtVerifyRawPartCurrPhase(nRawPartId) AndAlso nRawPartId <> nMovedRawId Then
' recupero il solido del grezzo
Dim nRawSolidId As Integer = EgtGetFirstNameInGroup(nRawPartId, RAWSOLID)
' ne calcolo il BBox
EgtGetBBoxGlob(nRawSolidId, GDB_BB.ONLY_VISIBLE, bboxRawPart)
' verifico se c'è sovrapposizione
If bboxMovedRawPart.OverlapsXY(bboxRawPart) Then
' se c'è restituisco falso perchè i grezzi non si possono sovrapporre
Return False
End If
End If
nRawPartId = EgtGetNextRawPart(nRawPartId)
End While
' verifico le interferenze tra il grezzo spostato e le ventose
Return VerifyRawWithFixture(nMovedRawId, vtOrigMove, vtRefMove)
End Function
Private Shared Function VerifyRawWithFixture(nRawId As Integer, ByRef vtOrigMove As Vector3d, ByRef vtRefMove As Vector3d) As Boolean
' Tengo da parte il riferimento della tavola
Dim ptTableRef As Point3d
EgtGetTableRef(1, ptTableRef)
Dim TableFrame As New Frame3d(ptTableRef)
' Recupero il solido del grezzo
Dim nMovedRawSolidId As Integer = EgtGetFirstNameInGroup(nRawId, RAWSOLID)
' definisco il box del solido del grezzo
Dim bboxRawPartId As New BBox3d
EgtGetBBoxGlob(nMovedRawSolidId, GDB_BB.ONLY_VISIBLE, bboxRawPartId)
' Variabile che dice se c'è almeno una ventosa sotto il grezzo
Dim bIsFixtureUnderRawPart As Boolean = False
Dim bboxFixture As New BBox3d
' variabile che contiene la massima altezza delle ventose sottostanti
Dim dMaxFixtureHeight As Double = 0
' recupero altezza grezzo riferita alla tavola
Dim dRawPartMin As Point3d = bboxRawPartId.Min
dRawPartMin.ToLoc(TableFrame)
' Ciclo sui sottopezzi presenti per verificare le collisioni con il grezzo
Dim nFixtureId As Integer = EgtGetFirstFixture()
While nFixtureId <> GDB_ID.NULL
' calcolo il BBox del sottopezzo
EgtGetBBoxGlob(nFixtureId, GDB_BB.ONLY_VISIBLE, bboxFixture)
' verifico se c'è sovrapposizione
If bboxRawPartId.OverlapsXY(bboxFixture) Then
Select Case FixtureType(nFixtureId)
' se il sottopezzo è una ventosa
Case FIX_TYPE.VACUUM
' recupero altezza ventosa
Dim dFixtureHeight As Double = 0
EgtGetInfo(nFixtureId, "H", dFixtureHeight)
' la confronto con quella massima
If dFixtureHeight > dMaxFixtureHeight Then
dMaxFixtureHeight = dFixtureHeight
End If
' se l'altezza grezzo è diversa da quella della ventosa, lo sposto alla stessa altezza
If dRawPartMin.z < dFixtureHeight - EPS_SMALL Then
Dim vtMove As New Vector3d(0, 0, dFixtureHeight - dRawPartMin.z)
EgtMoveRawPart(nRawId, vtMove)
' recupero il solido del grezzo
Dim nRawSolidId As Integer = EgtGetFirstNameInGroup(nRawId, RAWSOLID)
' ricalcolo il BBox del solido del grezzo per averlo aggiornato con la nuova Z
EgtGetBBoxGlob(nRawSolidId, GDB_BB.ONLY_VISIBLE, bboxRawPartId)
dRawPartMin = bboxRawPartId.Min
dRawPartMin.ToLoc(TableFrame)
End If
bIsFixtureUnderRawPart = True
' se il sottopezzo è un riferimento
Case FIX_TYPE.REFERENCE
' recupero arco del riferimento
Dim arcRefId As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(nFixtureId, SOLID), REF_ARC)
' calcolo bbox dell'arco di riferimento
Dim bboxArcRef As New BBox3d
EgtGetBBoxGlob(arcRefId, GDB_BB.STANDARD, bboxArcRef)
' ne faccio l'offset ??
'bboxArcRef.Expand(10)
If bboxRawPartId.OverlapsXY(bboxArcRef) Then
' recupero contorno del grezzo
Dim ccompoRawPartOutlineId As Integer = EgtGetFirstNameInGroup(nRawId, RAWOUTLINE)
'recupero il raggio dell'arco di riferimento
Dim dArcRadius As Double
EgtArcRadius(arcRefId, dArcRadius)
' faccio copia e offset del contorno grezzo
Dim ccompoRawPartOutlineOffsetId As Integer = EgtCopyGlob(ccompoRawPartOutlineId, ccompoRawPartOutlineId, GDB_POS.AFTER)
EgtOffsetCurve(ccompoRawPartOutlineOffsetId, dArcRadius, OFF_TYPE.FILLET)
' recupero centro dell'arco di riferimento
Dim ptArcCenter As Point3d
EgtCenterPoint(arcRefId, ccompoRawPartOutlineId, ptArcCenter)
' Creo un segmento avente origine nel centro dell'arco e direzione opposta a quella del movimento
Dim nDistLine As Integer = EgtCreateLinePVL(EgtGetParent(ccompoRawPartOutlineId), ptArcCenter, vtOrigMove.Loc(ccompoRawPartOutlineId), 10000)
' cerco punto di intersezione tra il segmento e l'offset
Dim ptDist As Point3d
If EgtIntersectionPoint(nDistLine, ccompoRawPartOutlineOffsetId, ptArcCenter, ptDist) Then
' calcolo il vettore di spostamento necessario ad allinearli
Dim vtDelta As Vector3d = -(ptDist - ptArcCenter)
vtDelta.z = 0
' se il vettore non è nullo
If vtDelta.IsSmall() Then
' il grezzo è in battuta sul riferimento
Dim nContactColDisk As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(nFixtureId, SOLID), REF_DISK)
EgtSetColor(nContactColDisk, ReferenceContactColGreen)
Else
vtDelta = vtDelta.Glob(ccompoRawPartOutlineId)
' il vettore da restituire è nullo, quindi lo inizializzo
If vtRefMove.IsSmall() Then
vtRefMove = vtDelta
' altrimenti lo confronto
Else
' per ogni coordinata devo prendere il massimo in direzione opposta allo spostamento originale
' calcolo il versore nella direzione del movimento
Dim vtMoveVers As New Vector3d(vtOrigMove)
vtMoveVers.Normalize()
If (vtDelta * vtMoveVers) < (vtRefMove * vtMoveVers) Then
vtRefMove = vtDelta
End If
End If
End If
End If
' cancello segmento e offset
EgtErase(nDistLine)
EgtErase(ccompoRawPartOutlineOffsetId)
Else
' il grezzo non è in battuta sul riferimento
Dim nContactColDisk As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(nFixtureId, SOLID), REF_DISK)
EgtSetColor(nContactColDisk, ReferenceContactColRed)
End If
End Select
' se non c'è sovrapposizione
ElseIf FixtureType(nFixtureId) = FIX_TYPE.REFERENCE Then
' il grezzo non è in battuta sul riferimento
Dim nContactColDisk As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(nFixtureId, SOLID), REF_DISK)
EgtSetColor(nContactColDisk, ReferenceContactColRed)
End If
nFixtureId = EgtGetNextFixture(nFixtureId)
End While
' se non ci sono ventose sotto il grezzo
If Not bIsFixtureUnderRawPart Then
' verifico che il grezzo sia ad altezza tavola
If dRawPartMin.z <> 0 Then
Dim vtMove As New Vector3d(0, 0, -dRawPartMin.z)
EgtMoveRawPart(nRawId, vtMove)
End If
Else
' se ci sono verifico che l'altezza del grezzo sia quella della ventosa più alta
If Math.Abs(dRawPartMin.z - dMaxFixtureHeight) > EPS_SMALL Then
Dim vtMove As New Vector3d(0, 0, dMaxFixtureHeight - dRawPartMin.z)
EgtMoveRawPart(nRawId, vtMove)
End If
End If
Return True
End Function
' Funzione che restituisce il tipo di sottopezzo passatogli
Friend Shared Function FixtureType(nFixtureId As Integer) As FIX_TYPE
Dim sFixtureType As String = String.Empty
EgtGetInfo(nFixtureId, EgtUILib.FIX_TYPE, sFixtureType)
Select Case sFixtureType
Case FIX_VAC
Return FIX_TYPE.VACUUM
Case FIX_REF
Return FIX_TYPE.REFERENCE
Case FIX_VIS
Return FIX_TYPE.VISE
End Select
Return FIX_TYPE.NULL
End Function
Public Enum FIX_TYPE As Integer
NULL = 0
VACUUM = 1
REFERENCE = 2
VISE = 3
End Enum
' Funzione che seleziona i sottopezzi del grezzo passatogli
Friend Shared Sub SelectRawPartFixture(nRawPartId As Integer)
Dim bboxRawPart As New BBox3d
Dim bboxFixture As New BBox3d
' ricavo solido del grezzo
Dim nRawPartSolid As Integer = EgtGetFirstNameInGroup(nRawPartId, RAWSOLID)
' ne ricavo il bbox
EgtGetBBoxGlob(nRawPartSolid, GDB_BB.ONLY_VISIBLE, bboxRawPart)
Dim nFixtureId As Integer = EgtGetFirstFixture()
While nFixtureId <> GDB_ID.NULL
' ricavo il bbox del sottopezzo
EgtGetBBoxGlob(nFixtureId, GDB_BB.ONLY_VISIBLE, bboxFixture)
' verifico se si sovrappongono
If bboxRawPart.OverlapsXY(bboxFixture) Then
' seleziono il sottopezzo
EgtSelectObj(nFixtureId)
End If
nFixtureId = EgtGetNextFixture(nFixtureId)
End While
End Sub
' Funzione che deseleziona i sottopezzi del grezzo passatogli
Friend Shared Sub DeselectRawPartFixture(nRawPartId As Integer)
Dim bboxRawPart As New BBox3d
Dim bboxFixture As New BBox3d
' ricavo solido del grezzo
Dim nRawPartSolid As Integer = EgtGetFirstNameInGroup(nRawPartId, RAWSOLID)
' ne ricavo il bbox
EgtGetBBoxGlob(nRawPartSolid, GDB_BB.ONLY_VISIBLE, bboxRawPart)
Dim nFixtureId As Integer = EgtGetFirstFixture()
While nFixtureId <> GDB_ID.NULL
' ricavo il bbox del sottopezzo
EgtGetBBoxGlob(nFixtureId, GDB_BB.ONLY_VISIBLE, bboxFixture)
' verifico se si sovrappongono
If bboxRawPart.OverlapsXY(bboxFixture) Then
' deseleziono il pezzo
EgtDeselectObj(nFixtureId)
End If
nFixtureId = EgtGetNextFixture(nFixtureId)
End While
End Sub
' Costante che identifica l'informazione contenente il Frame3d originale del pezzo
Private Const ORIG_FRAME As String = "ORIGFRAME"
' Funzione che visualizza i pezzi disponibili e li sposta sotto il grezzo
Friend Shared Sub ShowParts()
' prendo riferimento tavola
' ciclo sui pezzi
Dim nPartId As Integer = EgtGetFirstPart()
While nPartId <> GDB_ID.NULL
' mi faccio dare il riferimento del pezzo prima si spostarlo
Dim frOrigPart As New Frame3d
EgtGetGroupGlobFrame(nPartId, frOrigPart)
' salvo il riferimento originale
EgtSetInfo(nPartId, ORIG_FRAME, frOrigPart)
'
' Attivo la visualizzazione del pezzo mettendolo in modalità standard
EgtSetStatus(nPartId, GDB_ST.ON_)
' prendo il pezzo successivo
nPartId = EgtGetNextPart(nPartId)
End While
EgtDraw()
End Sub
' Funzione che rimette a posto i pezzi
Friend Shared Sub HideParts()
' ciclo sui pezzi
Dim nPartId As Integer = EgtGetFirstPart()
While nPartId <> GDB_ID.NULL
' recupero il riferimento originale
Dim frOrigPart As New Frame3d
EgtGetInfo(nPartId, ORIG_FRAME, frOrigPart)
' lo ripristino
EgtChangeGroupFrame(nPartId, frOrigPart)
' Attivo la visualizzazione del pezzo mettendolo in modalità standard
EgtSetStatus(nPartId, GDB_ST.OFF)
' prendo il pezzo successivo
nPartId = EgtGetNextPart(nPartId)
End While
End Sub
End Class
@@ -0,0 +1,52 @@
<UserControl x:Class="FixtureParametersView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:EgtCAM5="clr-namespace:EgtCAM5">
<StackPanel>
<ListBox Name="FixtureListBox" ItemsSource="{Binding FixtureTypeList}"
Height="150" IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding SelectedFixtureType}">
<ListBox.Resources>
<DataTemplate DataType="{x:Type EgtCAM5:FixtureType}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Image Source="{Binding Image}" Height="15" Margin="0,0,5,0"/>
<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="0,0,5,0"/>
<TextBlock Grid.Column="2" Text="{Binding UsedTotalRatio}" TextAlignment="Right"/>
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type EgtCAM5:FixtureListItem}">
<Border CornerRadius="1" Background="{StaticResource EgaltechBlue3}" FocusVisualStyle="{x:Null}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" Foreground="White" Margin="5,0,0,0"
FontSize="15" FontWeight="SemiBold"/>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.Resources>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource FixtureTypeListBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="IsEnabled" Value="{Binding IsEnabled, Mode=OneWay}"/>
<Setter Property="IsSelected" Value="{Binding IsSelected}"/>
<Setter Property="Focusable" Value="{Binding Focusable, Mode=OneWay}"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<TextBlock Text="{Binding FixtureErrorMsg,Mode=OneWay}" Margin="5,5,5,5"
Style="{StaticResource ValidationErrorTextBlock}"/>
<UniformGrid Columns="2">
<Button Content="Add" Height="30" Command="{Binding AddCommand}" CommandParameter="{Binding Path=SelectedItem, ElementName=FixtureListBox}"/>
<Button Content="Remove" Height="30" Command="{Binding RemoveCommand}" CommandParameter="{Binding Path=SelectedItem, ElementName=FixtureListBox}"/>
</UniformGrid>
</StackPanel>
</UserControl>
@@ -0,0 +1,3 @@
Public Class FixtureParametersView
End Class
@@ -0,0 +1,410 @@
Imports System.ComponentModel
Imports System.Collections.ObjectModel
Imports EgtUILib
Namespace EgtCAM5
Public Class FixtureParametersViewModel
Inherits ViewModelBase
Private m_FixtureTypeList As ObservableCollection(Of FixtureListItem)
Public ReadOnly Property FixtureTypeList As ObservableCollection(Of FixtureListItem)
Get
If IsNothing(m_FixtureTypeList) Then
m_FixtureTypeList = New ObservableCollection(Of FixtureListItem)(FixtureType.ReadFixtureTypeFromMachIni())
End If
Return m_FixtureTypeList
End Get
End Property
Private m_SelectedFixtureType As FixtureListItem
Public Property SelectedFixtureType As FixtureListItem
Get
Return m_SelectedFixtureType
End Get
Set(value As FixtureListItem)
m_SelectedFixtureType = value
End Set
End Property
#Region "Messages"
Private m_FixtureErrorMsg As String
Public ReadOnly Property FixtureErrorMsg As String
Get
Return m_FixtureErrorMsg
End Get
End Property
Public ReadOnly Property OkMsg As String
Get
Return EgtMsg(MSG_DISPOSITION + 1)
End Get
End Property
#End Region ' Messages
Sub New(ByRef ExpandFixtureFunction As Action)
ExpandFixtureFunction = AddressOf UpdateFixtureCount
' seleziono secondo elemento se presente perchè primo è categoria
SelectedFixtureType = Nothing
End Sub
Private Sub UpdateFixtureCount()
' resetto tutto
For Index = 0 To m_FixtureTypeList.Count - 1
If TypeOf m_FixtureTypeList(Index) Is FixtureType Then
Dim CurrFixtureType As FixtureType = DirectCast(m_FixtureTypeList(Index), FixtureType)
CurrFixtureType.UsedNumber = 0
End If
Next
' calcolo i sottopezzi utilizzati in questa fase
Dim nUsedFixtureId As Integer = EgtGetFirstFixture()
While nUsedFixtureId <> GDB_ID.NULL
Dim sUsedFixtureName As String = String.Empty
For Index = 0 To m_FixtureTypeList.Count - 1
EgtGetName(nUsedFixtureId, sUsedFixtureName)
If sUsedFixtureName = m_FixtureTypeList(Index).Name Then
Dim CurrFixtureType As FixtureType = DirectCast(m_FixtureTypeList(Index), FixtureType)
CurrFixtureType.UsedNumber += 1
Exit For
End If
Next
nUsedFixtureId = EgtGetNextFixture(nUsedFixtureId)
End While
End Sub
' Definizione comandi
Private m_cmdAdd As ICommand
Private m_cmdRemove As ICommand
#Region "COMMANDS"
#Region "AddCommand"
''' <summary>
''' Returns a command that do Done.
''' </summary>
Public ReadOnly Property AddCommand As ICommand
Get
If m_cmdAdd Is Nothing Then
m_cmdAdd = New RelayCommand(AddressOf Add)
End If
Return m_cmdAdd
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the DoneCommand.
''' </summary>
Public Sub Add(ByVal param As Object)
' resetto il messaggio di errore
m_FixtureErrorMsg = String.Empty
' verifico se è stato selezionato un sottopezzo nella lista
Dim SelectedFixture As FixtureType
If TypeOf param Is FixtureType Then
SelectedFixture = DirectCast(param, FixtureType)
Else
Return
End If
' recupero area della tavola
Dim ptTableMin As Point3d
Dim ptTableMax As Point3d
EgtGetTableArea(1, ptTableMin, ptTableMax)
' calcolo il centro della tavola
Dim ptTableMid As New Point3d((ptTableMax.x - ptTableMin.x) / 2, (ptTableMax.y - ptTableMin.y) / 2, (ptTableMax.z - ptTableMin.z) / 2)
' posiziono il nuovo sottopezzo al centro della tavola
Dim nAddedFixtureId As Integer = EgtAddFixture(SelectedFixture.Name, ptTableMid, 0, 0)
' verifico se è in una posizione valida
If Not DispositionUtility.VerifyFixturePosition(nAddedFixtureId, New Vector3d) Then
' creo un gruppo temporaneo
Dim nTempGroupId As Integer = EgtCreateGroup(GDB_ID.ROOT)
EgtSetLevel(nTempGroupId, GDB_LV.USER)
EgtSetMode(nTempGroupId, GDB_MD.STD)
' calcolo ingombro sottopezzo aggiunto
Dim bboxAddedFixture As New BBox3d
EgtGetBBoxGlob(nAddedFixtureId, GDB_BB.STANDARD, bboxAddedFixture)
' calcolo bbox tavolo
Dim bboxTableArea As New BBox3d(ptTableMin, ptTableMax)
bboxTableArea.Expand(-bboxAddedFixture.DimX / 2, -bboxAddedFixture.DimY / 2, 0)
' creo superficie delle misure della tavola
Dim nTableFrId As Integer = EgtCreateSurfFrRectangle(nTempGroupId, bboxTableArea.Min, bboxTableArea.Max)
' ciclo su tutti i pezzi di questa fase
Dim nFixtureId As Integer = EgtGetFirstFixture()
While nFixtureId <> GDB_ID.NULL
' creo il bbox del sottopezzo
Dim bboxFixture As New BBox3d
EgtGetBBoxGlob(nFixtureId, GDB_BB.STANDARD, bboxFixture)
' faccio offset del bbox del sottopezzo per includere metà del sottopezzo da aggiungere
bboxFixture.Expand(bboxAddedFixture.DimX / 2, bboxAddedFixture.DimY / 2, 0)
' lo porto all'altezza della tavola
Dim ptMinFixtureFr As New Point3d(bboxFixture.Min)
Dim ptMaxFixtureFr As New Point3d(bboxFixture.Max)
ptMinFixtureFr.z = ptTableMin.z
ptMaxFixtureFr.z = ptTableMin.z
' creo la regione occupata dal bbox del sottopezzo
Dim nFixtureFrId As Integer = EgtCreateSurfFrRectangle(nTempGroupId, ptMinFixtureFr, ptMaxFixtureFr)
' sottraggo la regione del sottopezzo da quella della tavola
Dim x = EgtSurfFrSubtract(nTableFrId, nFixtureFrId)
nFixtureId = EgtGetNextFixture(nFixtureId)
End While
' creo gruppo con i bordi della regione di tavola avanzata
Dim TableFrBorderGroupId As Integer = EgtCreateGroup(nTempGroupId)
Dim nTableFrBorderCount As Integer = 0
Dim nChunk As Integer=EgtSurfFrChunkCount(nTableFrId)
For Index = 0 To nChunk - 1
EgtExtractSurfFrChunkLoops(nTableFrId, Index, TableFrBorderGroupId, nTableFrBorderCount)
Next
' verifico se c'è almeno un bordo
If nTableFrBorderCount = 0 Then
m_FixtureErrorMsg = "Impossibile posizionare la ventosa sulla tavola"
OnPropertyChanged("FixtureErrorMsg")
Return
End If
' converto il punto medio della tavola in coordinate globali
Dim PtTableRef As Point3d
EgtGetTableRef(1, PtTableRef)
Dim frTableRef As New Frame3d(PtTableRef)
ptTableMid.ToGlob(frTableRef)
' ciclo sui bordi per trovare il punto più vicino
Dim dMinDist As Double = (bboxTableArea.Max - bboxTableArea.Min).SqLenXY
Dim ptMinAbs As Point3d
Dim BorderId As Integer = EgtGetFirstInGroup(TableFrBorderGroupId)
While BorderId <> GDB_ID.NULL
Dim dDist As Double = 0
Dim ptMinRel As Point3d
Dim nSide As Integer = 0
EgtGetMinDistPntSidePointCurve(ptTableMid, BorderId, Vector3d.Z_AX, dDist, ptMinRel, nSide)
If dDist < dMinDist Then
dMinDist = dDist
ptMinAbs = ptMinRel
End If
BorderId = EgtGetNext(BorderId)
End While
' sposto il sottopezzo nel punto trovato
Dim vtFixtureMove As Vector3d = ptMinAbs - ptTableMid
vtFixtureMove.z = 0
EgtMoveFixture(nAddedFixtureId, vtFixtureMove)
' cancello il gruppo temporaneo
EgtErase(nTempGroupId)
End If
' sottraggo la ventosa aggiunta dal conto di quelle disponibili
SelectedFixture.UsedNumber += 1
EgtDraw()
OnPropertyChanged("FixtureErrorMsg")
End Sub
#End Region ' AddCommand
#Region "RemoveCommand"
''' <summary>
''' Returns a command that do Done.
''' </summary>
Public ReadOnly Property RemoveCommand As ICommand
Get
If m_cmdRemove Is Nothing Then
m_cmdRemove = New RelayCommand(AddressOf Remove)
End If
Return m_cmdRemove
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the DoneCommand.
''' </summary>
Public Sub Remove()
Dim SelectedFixtureId As Integer = EgtGetFirstSelectedObj()
While SelectedFixtureId <> GDB_ID.NULL
Dim NextSelectedId As Integer = EgtGetNextSelectedObj()
If EgtVerifyFixture(SelectedFixtureId) Then
EgtRemoveFixture(SelectedFixtureId)
For Index = 0 To FixtureTypeList.Count - 1
Dim SelFixtureName As String = String.Empty
EgtGetName(SelectedFixtureId, SelFixtureName)
If SelFixtureName = FixtureTypeList(Index).Name Then
Dim CurrFixtureType As FixtureType = DirectCast(FixtureTypeList(Index), FixtureType)
CurrFixtureType.UsedNumber -= 1
End If
Next
End If
SelectedFixtureId = NextSelectedId
End While
EgtDraw()
End Sub
#End Region ' RemoveCommand
#End Region
End Class
End Namespace
Public Class FixtureType
Inherits FixtureListItem
Private m_TotalNumber As Integer
Private m_UsedNumber As Integer
Private m_IsEnabled As Boolean = True
Private m_IsSelected As Boolean = False
Public Property TotalNumber As Integer
Get
Return m_TotalNumber
End Get
Set(value As Integer)
If value <> m_TotalNumber Then
m_TotalNumber = value
NotifyPropertyChanged("UsedTotalRatio")
End If
End Set
End Property
Public Property UsedNumber As Integer
Get
Return m_UsedNumber
End Get
Set(value As Integer)
If value <> m_UsedNumber Then
m_UsedNumber = value
NotifyPropertyChanged("UsedTotalRatio")
If UsedNumber >= TotalNumber Then
m_IsEnabled = False
m_IsSelected = False
NotifyPropertyChanged("IsSelected")
Else
m_IsEnabled = True
End If
NotifyPropertyChanged("IsEnabled")
End If
End Set
End Property
Public ReadOnly Property UsedTotalRatio As String
Get
Return (TotalNumber - UsedNumber).ToString & " / " & TotalNumber.ToString
End Get
End Property
Public ReadOnly Property IsEnabled As Boolean
Get
Return m_IsEnabled
End Get
End Property
Public Property IsSelected As Boolean
Get
Return m_IsSelected
End Get
Set(value As Boolean)
m_IsSelected = value
End Set
End Property
Sub New(sName As String, sCat As DispositionUtility.FIX_TYPE, nTot As Integer)
MyBase.New(sName, sCat)
TotalNumber = nTot
m_IsEnabled = True
End Sub
Public Shared Function ReadFixtureTypeFromMachIni() As List(Of FixtureListItem)
' creo la lista locale
Dim FixtureTypeList As New List(Of FixtureListItem)
' aggiungo le ventose se presenti
Dim sName As String = String.Empty
Dim nTot As Integer = 0
Dim bFirst As Boolean = True
Dim nIndex As Integer = 1
While GetPrivateProfileFixture(S_FIXTURES, System.Globalization.CultureInfo.InvariantCulture.TextInfo.ToTitleCase(FIX_VAC) & nIndex, sName, nTot)
If bFirst Then
FixtureTypeList.Add(New FixtureListItem(FIX_VAC, DispositionUtility.FIX_TYPE.VACUUM))
bFirst = False
End If
FixtureTypeList.Add(New FixtureType(sName, DispositionUtility.FIX_TYPE.VACUUM, nTot))
nIndex += 1
End While
' aggiungo i riferimenti se presenti
bFirst = True
nIndex = 1
While GetPrivateProfileFixture(S_FIXTURES, FIX_REF & nIndex, sName, nTot)
If bFirst Then
FixtureTypeList.Add(New FixtureListItem(FIX_REF, DispositionUtility.FIX_TYPE.REFERENCE))
bFirst = False
End If
FixtureTypeList.Add(New FixtureType(sName, DispositionUtility.FIX_TYPE.REFERENCE, nTot))
nIndex += 1
End While
' aggiungo le morse se presenti
bFirst = True
nIndex = 1
While GetPrivateProfileFixture(S_FIXTURES, FIX_VIS & nIndex, sName, nTot)
If bFirst Then
FixtureTypeList.Add(New FixtureListItem(FIX_VIS, DispositionUtility.FIX_TYPE.VISE))
bFirst = False
End If
FixtureTypeList.Add(New FixtureType(sName, DispositionUtility.FIX_TYPE.VISE, nTot))
nIndex += 1
End While
Return FixtureTypeList
End Function
End Class
Public Class FixtureListItem
Implements INotifyPropertyChanged
Private m_Name As String
Private m_Cathegory As DispositionUtility.FIX_TYPE
Private m_Focusable As Boolean
Public Property Name As String
Get
Return m_Name
End Get
Set(value As String)
m_Name = value
End Set
End Property
Public Property Cathegory As DispositionUtility.FIX_TYPE
Get
Return m_Cathegory
End Get
Set(value As DispositionUtility.FIX_TYPE)
m_Cathegory = value
End Set
End Property
Public ReadOnly Property Focusable As Boolean
Get
Return m_Focusable
End Get
End Property
Public ReadOnly Property CathegoryName As String
Get
Select Case Cathegory
Case DispositionUtility.FIX_TYPE.VACUUM
Return "Vacuum"
Case DispositionUtility.FIX_TYPE.REFERENCE
Return "Reference"
Case DispositionUtility.FIX_TYPE.VISE
Return "Vise"
Case Else
Return String.Empty
End Select
End Get
End Property
Sub New(sName As String, Cathegory As DispositionUtility.FIX_TYPE)
Me.Name = sName
Me.Cathegory = Cathegory
If TypeOf Me Is FixtureType Then
m_Focusable = True
Else
m_Focusable = False
End If
End Sub
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class
@@ -0,0 +1,40 @@
<UserControl x:Class="RawPartOptionView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<CheckBox Content="Move with Fixture" IsChecked="{Binding MoveWithFixture, Mode=TwoWay}"/>
<UniformGrid Columns="2" Margin="0,5,0,0">
<Button Content="New" Command="{Binding NewRawPartCommand}"/>
<Button Content="Remove" Command="{Binding RemoveRawPartCommand}"/>
</UniformGrid>
<Grid Visibility="{Binding RawPartParamVisibility, Mode=OneWay}">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<UniformGrid Grid.Row="0" Columns="2">
<TextBlock Text="{Binding LenghtMsg}"/>
<TextBox Text="{Binding Lenght}"/>
</UniformGrid>
<UniformGrid Grid.Row="1" Columns="2">
<TextBlock Text="{Binding WidthMsg}"/>
<TextBox Text="{Binding Width}"/>
</UniformGrid>
<UniformGrid Grid.Row="2" Columns="2">
<TextBlock Text="{Binding HeightMsg}"/>
<TextBox Text="{Binding Height}"/>
</UniformGrid>
<UniformGrid Grid.Row="3" Columns="2">
<TextBlock Text="{Binding PositionMsg}"/>
<TextBox Text="{Binding Position}"/>
</UniformGrid>
<Button Grid.Row="4" Content="Ok" Command="{Binding OkCommand}"/>
</Grid>
</StackPanel>
</UserControl>
@@ -0,0 +1,3 @@
Public Class RawPartOptionView
End Class
@@ -0,0 +1,129 @@
Imports EgtUILib
Namespace EgtCAM5
Public Class RawPartOptionViewModel
Inherits ViewModelBase
Private m_MoveWithFixture As Boolean = False
Public Property MoveWithFixture As Boolean
Get
Return m_MoveWithFixture
End Get
Set(value As Boolean)
If value <> m_MoveWithFixture Then
If value Then
' Abilito la selezione di RawPart con autoselezione delle sue ventose
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.RAWPARTWITHFIXTURE)
' Seleziono le ventose associate ad uno dei grezzi selezionati
' ciclo sui grezzi selezionati
Dim nSelRawPartId As Integer = EgtGetFirstSelectedObj()
While nSelRawPartId <> GDB_ID.NULL
' seleziono i sottopezzi del grezzo
DispositionUtility.SelectRawPartFixture(nSelRawPartId)
nSelRawPartId = EgtGetNextSelectedObj()
End While
Else
' Abilito la selezione di RawPart
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.RAWPART)
' ciclo sui grezzi selezionati
Dim nSelRawPartId As Integer = EgtGetFirstSelectedObj()
While nSelRawPartId <> GDB_ID.NULL
' deseleziono i sottopezzi del grezzo
DispositionUtility.DeselectRawPartFixture(nSelRawPartId)
nSelRawPartId = EgtGetNextSelectedObj()
End While
End If
EgtDraw()
m_MoveWithFixture = value
OnPropertyChanged("MoveWithFixture")
End If
End Set
End Property
Private m_bRawPartParamVisibility As Visibility
Public ReadOnly Property RawPartParamVisibility As Visibility
Get
Return m_bRawPartParamVisibility
End Get
End Property
#Region "Messages"
Public ReadOnly Property NewMsg As String
Get
Return EgtMsg(MSG_DISPOSITION + 3)
End Get
End Property
Public ReadOnly Property RemoveMsg As String
Get
Return EgtMsg(MSG_DISPOSITION + 4)
End Get
End Property
Public ReadOnly Property LenghtMsg As String
Get
Return EgtMsg(MSG_DISPOSITION + 5)
End Get
End Property
Public ReadOnly Property WidthMsg As String
Get
Return EgtMsg(MSG_DISPOSITION + 6)
End Get
End Property
Public ReadOnly Property HeightMsg As String
Get
Return EgtMsg(MSG_DISPOSITION + 7)
End Get
End Property
Public ReadOnly Property PositionMsg As String
Get
Return EgtMsg(MSG_DISPOSITION + 8)
End Get
End Property
#End Region ' Messages
' Definizione comandi
Private m_cmdNewRawPart As ICommand
Private m_cmdRemoveRawPart As ICommand
Sub New()
If EgtGetFirstSelectedObj() <> GDB_ID.NULL Then
m_bRawPartParamVisibility = Visibility.Visible
Else
m_bRawPartParamVisibility = Visibility.Collapsed
End If
End Sub
#Region "COMMANDS"
#Region "NewRawPartCommand"
''' <summary>
''' Returns a command that do Done.
''' </summary>
Public ReadOnly Property NewRawPartCommand As ICommand
Get
If m_cmdNewRawPart Is Nothing Then
m_cmdNewRawPart = New RelayCommand(AddressOf NewRawPart)
End If
Return m_cmdNewRawPart
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the DoneCommand.
''' </summary>
Public Sub NewRawPart()
DispositionUtility.ShowParts()
m_bRawPartParamVisibility = Visibility.Visible
OnPropertyChanged("RawPartParamVisibility")
End Sub
#End Region ' NewRawPartCommand
#End Region ' Commands
End Class
End Namespace
@@ -0,0 +1,499 @@
<UserControl x:Class="MachiningParameterExpanderView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:EgtCAM5="clr-namespace:EgtCAM5"
xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5">
<UserControl.Resources>
<EgtCAM5:OperationParamVisibilityConverter x:Key="OperationParamVisibilityConverter"/>
<EgtCAM5:DepthUnitConverter x:Key="DepthUnitConverter"/>
<sys:Int32 x:Key="Invert">0</sys:Int32>
<sys:Int32 x:Key="LeaveTab">1</sys:Int32>
<sys:Int32 x:Key="WorkSide">2</sys:Int32>
<sys:Int32 x:Key="HeadSide">3</sys:Int32>
<sys:Int32 x:Key="LeadInType">4</sys:Int32>
<sys:Int32 x:Key="ExtLinkType">5</sys:Int32>
<sys:Int32 x:Key="LeadOutType">6</sys:Int32>
<sys:Int32 x:Key="CurveUse">7</sys:Int32>
<sys:Int32 x:Key="StepType">8</sys:Int32>
<sys:Int32 x:Key="LeadLinkType">9</sys:Int32>
<sys:Int32 x:Key="Speed">10</sys:Int32>
<sys:Int32 x:Key="Feed">11</sys:Int32>
<sys:Int32 x:Key="StartFeed">12</sys:Int32>
<sys:Int32 x:Key="EndFeed">13</sys:Int32>
<sys:Int32 x:Key="TipFeed">14</sys:Int32>
<sys:Int32 x:Key="OffSr">15</sys:Int32>
<sys:Int32 x:Key="OffSl">16</sys:Int32>
<sys:Int32 x:Key="SideAngle">17</sys:Int32>
<sys:Int32 x:Key="Approx">18</sys:Int32>
<sys:Int32 x:Key="StartPos">19</sys:Int32>
<sys:Int32 x:Key="StartSlowLen">20</sys:Int32>
<sys:Int32 x:Key="EndSlowLen">21</sys:Int32>
<sys:Int32 x:Key="ThrouAddLen">22</sys:Int32>
<sys:Int32 x:Key="StepPar">23</sys:Int32>
<sys:Int32 x:Key="ReturnPos">24</sys:Int32>
<sys:Int32 x:Key="TabLen">25</sys:Int32>
<sys:Int32 x:Key="TabDist">26</sys:Int32>
<sys:Int32 x:Key="TabHeight">27</sys:Int32>
<sys:Int32 x:Key="TabAngle">28</sys:Int32>
<sys:Int32 x:Key="LiTang">29</sys:Int32>
<sys:Int32 x:Key="LiPerp">30</sys:Int32>
<sys:Int32 x:Key="LiElev">31</sys:Int32>
<sys:Int32 x:Key="LiCompLen">32</sys:Int32>
<sys:Int32 x:Key="LoTang">33</sys:Int32>
<sys:Int32 x:Key="LoPerp">34</sys:Int32>
<sys:Int32 x:Key="LoElev">35</sys:Int32>
<sys:Int32 x:Key="LoCompLen">36</sys:Int32>
<sys:Int32 x:Key="StartAddLen">37</sys:Int32>
<sys:Int32 x:Key="EndAddLen">38</sys:Int32>
<sys:Int32 x:Key="StepExtArc">39</sys:Int32>
<sys:Int32 x:Key="StepIntArc">40</sys:Int32>
<sys:Int32 x:Key="SideStep">41</sys:Int32>
<sys:Int32 x:Key="VertFeed">42</sys:Int32>
<sys:Int32 x:Key="NamePar">43</sys:Int32>
<sys:Int32 x:Key="Tool">44</sys:Int32>
<sys:Int32 x:Key="DepthStr">45</sys:Int32>
<sys:Int32 x:Key="UserNotes">46</sys:Int32>
<sys:Int32 x:Key="OverLapStr">47</sys:Int32>
<sys:Int32 x:Key="OffsetStr">48</sys:Int32>
<sys:Int32 x:Key="SubType">49</sys:Int32>
<sys:Int32 x:Key="SolChoiceType">50</sys:Int32>
<sys:Int32 x:Key="AxRotRef">51</sys:Int32>
<sys:Int32 x:Key="BlockedAxesRef">52</sys:Int32>
<sys:Int32 x:Key="FaceUseType">53</sys:Int32>
<sys:Int32 x:Key="InvertToolDir">54</sys:Int32>
<sys:Int32 x:Key="ExpanderLeadIn">55</sys:Int32>
<sys:Int32 x:Key="ExpanderLeadOut">56</sys:Int32>
</UserControl.Resources>
<StackPanel Name="OperationParametersStackPanel">
<StackPanel Name="OperationFirstParametersStackPanel">
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource DepthStr}}">
<TextBlock Text="{Binding DepthMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding DepthStr, UpdateSourceTrigger=PropertyChanged,
Converter={StaticResource DepthUnitConverter}}"/>
</UniformGrid>
<UniformGrid Columns="2" Height="20" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource Invert}}">
<TextBlock Text="{Binding InvertMsg}"/>
<CheckBox HorizontalAlignment="Center" VerticalAlignment="Center"
IsChecked="{Binding Invert}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource HeadSide}}">
<TextBlock Text="{Binding HeadSideMsg}"/>
<ComboBox ItemsSource="{Binding HeadSideList, Mode=OneWay}"
SelectedIndex="{Binding SelectedHeadSide}"
IsSynchronizedWithCurrentItem="True">
</ComboBox>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource WorkSide}}">
<TextBlock Text="{Binding WorkSideMsg}"/>
<ComboBox ItemsSource="{Binding WorkSideList, Mode=OneWay}"
SelectedIndex="{Binding SelectedWorkSide}"
IsSynchronizedWithCurrentItem="True">
</ComboBox>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource UserNotes}}">
<TextBlock Text="{Binding UserNotesMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding UserNotes, UpdateSourceTrigger=PropertyChanged}">
<EgtWPFLib5:EgtTextBox.ToolTip>
<TextBlock Text="{Binding UserNotesTooltip}"/>
</EgtWPFLib5:EgtTextBox.ToolTip>
</EgtWPFLib5:EgtTextBox>
</UniformGrid>
</StackPanel>
<StackPanel Name="AutomaticCloseExpanderStackPanel">
<Expander Header="{Binding GenericExpanderHeader}" Name="GenericExpander"
Style="{StaticResource ExpanderStyle}" Margin="0,1,0,1">
<StackPanel>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource StartPos}}">
<TextBlock Text="{Binding StartPosMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding StartPos, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource ReturnPos}}">
<TextBlock Text="{Binding ReturnPosMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding ReturnPos, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource OverLapStr}}">
<TextBlock Text="{Binding OverLapMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding OverLap, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource ThrouAddLen}}">
<TextBlock Text="{Binding ThrouAddLenMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding ThrouAddLen, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource StepType}}">
<TextBlock Text="{Binding StepTypeMsg}"/>
<ComboBox ItemsSource="{Binding StepTypeList, Mode=OneWay}"
SelectedIndex="{Binding SelectedStepType}"
IsSynchronizedWithCurrentItem="True">
</ComboBox>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource SubType}}">
<TextBlock Text="{Binding SubTypeMsg}"/>
<ComboBox ItemsSource="{Binding SubTypeList, Mode=OneWay}"
SelectedIndex="{Binding SelectedSubType}"
IsSynchronizedWithCurrentItem="True">
</ComboBox>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource StepPar}}">
<TextBlock Text="{Binding StepParMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding StepPar, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource SideStep}}">
<TextBlock Text="{Binding SideStepMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding SideStep, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource StartSlowLen}}">
<TextBlock Text="{Binding StartSlowLenMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding StartSlowLen, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource EndSlowLen}}">
<TextBlock Text="{Binding EndSlowLenMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding EndSlowLen, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource SideAngle}}">
<TextBlock Text="{Binding SideAngleMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding SideAngle, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource OffSr}}">
<TextBlock Text="{Binding OffsetSrMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding OffSr, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource OffSl}}">
<TextBlock Text="{Binding OffsetSlMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding OffSl, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
</StackPanel>
</Expander>
<Expander Header="{Binding AdvancedParamMsg}" Name="AdvancedParam"
Style="{StaticResource ExpanderStyle}" Margin="0,1,0,1"
Visibility="{Binding Type, Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource AxRotRef}}">
<StackPanel>
<UniformGrid Columns="2" Height="20" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource InvertToolDir}}">
<TextBlock Text="{Binding InvertToolDirMsg}"/>
<CheckBox HorizontalAlignment="Center" VerticalAlignment="Center"
IsChecked="{Binding ToolInvert}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource FaceUseType}}">
<TextBlock Text="{Binding FaceUseTypeMsg}"/>
<ComboBox ItemsSource="{Binding FaceUseTypeList, Mode=OneWay}"
SelectedIndex="{Binding SelectedFaceUseType}"
IsSynchronizedWithCurrentItem="True">
</ComboBox>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource AxRotRef}}">
<TextBlock Text="{Binding InitAngsMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding InitAngs, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource BlockedAxesRef}}">
<TextBlock Text="{Binding BlockedAxisMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding BlockedAxis, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource SolChoiceType}}">
<TextBlock Text="{Binding SolChoiceTypeMsg}"/>
<ComboBox ItemsSource="{Binding SolChoiceTypeList, Mode=OneWay}"
SelectedIndex="{Binding SelectedSolChoiceType}"
IsSynchronizedWithCurrentItem="True">
</ComboBox>
</UniformGrid>
</StackPanel>
</Expander>
<Expander Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource ExpanderLeadIn}}"
Style="{StaticResource ExpanderStyle}">
<Expander.Header>
<UniformGrid Columns="2">
<TextBlock Text="{Binding LeadInTypeMsg}" Margin="0,0,5,0"/>
<ComboBox ItemsSource="{Binding LeadInTypeList, Mode=OneWay}"
SelectedIndex="{Binding SelectedLeadInType,Mode=TwoWay}"
IsSynchronizedWithCurrentItem="True"
Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource LeadInType}}">
</ComboBox>
</UniformGrid>
</Expander.Header>
<StackPanel>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource StartAddLen}}">
<TextBlock Text="{Binding StartAddLenMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding StartAddLen, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource LiTang}}">
<TextBlock Text="{Binding LiTangMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding LiTang, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource LiPerp}}">
<TextBlock Text="{Binding LiPerpMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding LiPerp, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource LiElev}}">
<TextBlock Text="{Binding LiElevMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding LiElev, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource LiCompLen}}">
<TextBlock Text="{Binding LiCompLenMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding LiCompLen, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
</StackPanel>
</Expander>
<Expander Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource ExpanderLeadOut}}"
Style="{StaticResource ExpanderStyle}">
<Expander.Header>
<UniformGrid Columns="2">
<TextBlock Text="{Binding LeadOutTypeMsg}" Margin="0,0,5,0"
VerticalAlignment="Center"/>
<ComboBox ItemsSource="{Binding LeadOutTypeList, Mode=OneWay}"
SelectedIndex="{Binding SelectedLeadOutType}"
IsSynchronizedWithCurrentItem="True"
Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource LeadOutType}}">
</ComboBox>
</UniformGrid>
</Expander.Header>
<StackPanel Margin="2">
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource EndAddLen}}">
<TextBlock Text="{Binding EndAddLenMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding EndAddLen, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource LoTang}}">
<TextBlock Text="{Binding LoTangMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding LoTang, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource LoPerp}}">
<TextBlock Text="{Binding LoPerpMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding LoPerp, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource LoElev}}">
<TextBlock Text="{Binding LoElevMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding LoElev, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource LoCompLen}}">
<TextBlock Text="{Binding LoCompLenMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding LoCompLen, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
</StackPanel>
</Expander>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource ExtLinkType}}">
<TextBlock Text="{Binding ExtLinkTypeMsg}"/>
<ComboBox ItemsSource="{Binding ExtLinkTypeList, Mode=OneWay}"
SelectedIndex="{Binding SelectedExtLinkType}"
IsSynchronizedWithCurrentItem="True">
</ComboBox>
</UniformGrid>
<Expander Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource CurveUse}}"
Style="{StaticResource ExpanderStyle}">
<Expander.Header>
<UniformGrid Columns="2">
<TextBlock Text="{Binding CurveUseMsg}" Margin="0,0,5,0"
VerticalAlignment="Center"/>
<ComboBox ItemsSource="{Binding CurveUseList, Mode=OneWay}"
SelectedIndex="{Binding SelectedCurveUse}"
IsSynchronizedWithCurrentItem="True">
</ComboBox>
</UniformGrid>
</Expander.Header>
<StackPanel Margin="2">
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource Approx}}">
<TextBlock Text="{Binding ApproxMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding Approx, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource StepExtArc}}">
<TextBlock Text="{Binding StepExtArcMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding StepExtArc, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource StepIntArc}}">
<TextBlock Text="{Binding StepIntArcMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding StepIntArc, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
</StackPanel>
</Expander>
<Expander Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource LeaveTab}}"
Style="{StaticResource ExpanderStyle}">
<Expander.Header>
<UniformGrid Columns="2">
<TextBlock Text="{Binding LeaveTabMsg}"/>
<CheckBox HorizontalAlignment="Center" IsChecked="{Binding LeaveTab}" />
</UniformGrid>
</Expander.Header>
<StackPanel>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource TabLen}}">
<TextBlock Text="{Binding TabLenMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding TabLen, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource TabHeight}}">
<TextBlock Text="{Binding TabHeightMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding TabHeight, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource TabAngle}}">
<TextBlock Text="{Binding TabAngleMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding TabAngle, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2" Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource TabDist}}">
<TextBlock Text="{Binding TabDistMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding TabDist, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
</StackPanel>
</Expander>
<Expander Style="{StaticResource ExpanderStyle}">
<Expander.Header>
<TextBlock Text="{Binding ToolExpanderHeader}"/>
</Expander.Header>
<StackPanel>
<UniformGrid Columns="2"
Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource Speed}}">
<TextBlock Text="{Binding SpeedMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding Speed, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2"
Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource Feed}}">
<TextBlock Text="{Binding FeedMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding Feed, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2"
Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource TipFeed}}">
<TextBlock Text="{Binding TipFeedMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding TipFeed, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2"
Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource StartFeed}}">
<TextBlock Text="{Binding StartFeedMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding StartFeed, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<UniformGrid Columns="2"
Visibility="{Binding Type,
Converter={StaticResource OperationParamVisibilityConverter},
ConverterParameter={StaticResource EndFeed}}">
<TextBlock Text="{Binding EndFeedMsg}"/>
<EgtWPFLib5:EgtTextBox Text="{Binding EndFeed, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
</StackPanel>
</Expander>
<Interactivity:Interaction.Behaviors>
<EgtCAM5:AutomaticCloseExpander/>
</Interactivity:Interaction.Behaviors>
</StackPanel>
<Button Name="ApplyMachBtn" Height="30" Content="{Binding UpdateMachiningBtnMsg}"
Command="{Binding UpdateMachiningCommand}" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<ToggleButton Name="ViewToolBtn" Grid.Column="0" Height="30" Content="{Binding ViewToolBtnMsg}"
IsChecked="{Binding ViewTool}" />
<Button Name="NextStepToolBtn" Grid.Column="1" Height="30" Content="{Binding NextStepToolBtnMsg}"
Command="{Binding NextStepToolCommand}" IsEnabled="{Binding IsChecked, ElementName=ViewToolBtn}"/>
<Button Name="PrevStepToolBtn" Grid.Column="2" Height="30" Content="{Binding PrevStepToolBtnMsg}"
Command="{Binding PrevStepToolCommand}" IsEnabled="{Binding IsChecked, ElementName=ViewToolBtn}"/>
</Grid>
</StackPanel>
</UserControl>
@@ -0,0 +1,83 @@
Imports EgtWPFLib5
Imports EgtWPFLib5.EgtFloating
Public Class MachiningParameterExpanderView
Private EgtFloatingTray As EgtFloatingTray
Private EgtFloatingPanel As EgtFloatingPanel
Private m_bFirst As Boolean = True
Private Sub OperationExpanderView_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
If m_bFirst Then
EgtFloatingTray = FindAncestor(Of EgtFloatingTray)(Me)
EgtFloatingPanel = FindAncestor(Of EgtFloatingPanel)(Me)
AddHandler EgtFloatingTray.SizeChanged, AddressOf EgtFloatingTray_SizeChanged
PanelHeight = EgtFloatingPanel.ActualHeight
Me.AutomaticCloseExpanderStackPanelHeight = AutomaticCloseExpanderStackPanel.ActualHeight
m_bFirst = False
End If
CalculateOperationParametersStackPanelMaxHeight()
End Sub
Dim m_bSizeChanging As Boolean = False
Private Sub EgtFloatingTray_SizeChanged(sender As Object, e As System.Windows.SizeChangedEventArgs)
If m_bSizeChanging Then Return
m_bSizeChanging = True
CalculateOperationParametersStackPanelMaxHeight()
m_bSizeChanging = False
End Sub
Dim PanelHeight As Double = 0
Dim AutomaticCloseExpanderStackPanelHeight As Double = 0
Private Sub CalculateOperationParametersStackPanelMaxHeight()
Dim AutomaticCloseExpanderStackPanelHeight As Double = 0
Dim OpenedExpanderList As New List(Of Boolean)
For Index = 0 To AutomaticCloseExpanderStackPanel.Children.Count - 1
If TypeOf AutomaticCloseExpanderStackPanel.Children(Index) Is Expander Then
Dim IndexedExpander As Expander = DirectCast(AutomaticCloseExpanderStackPanel.Children(Index), Expander)
If IndexedExpander.IsExpanded Then
OpenedExpanderList.Add(True)
IndexedExpander.IsExpanded = False
Dim CurrExpanderContent As FrameworkElement = DirectCast(IndexedExpander.Content, FrameworkElement)
CurrExpanderContent.Measure(New Size(Double.PositiveInfinity, Double.PositiveInfinity))
AutomaticCloseExpanderStackPanelHeight -= CurrExpanderContent.DesiredSize.Height
' Sottraggo anche i padding
AutomaticCloseExpanderStackPanelHeight -= (IndexedExpander.Padding.Top + IndexedExpander.Padding.Bottom)
Else
OpenedExpanderList.Add(False)
End If
Else
OpenedExpanderList.Add(False)
End If
Next
Dim RemainingHeight As Double = EgtFloatingTray.ActualHeight - PanelHeight
AutomaticCloseExpanderStackPanel.MaxHeight = Me.AutomaticCloseExpanderStackPanelHeight + RemainingHeight
For Index = AutomaticCloseExpanderStackPanel.Children.Count - 1 To 0 Step -1
If TypeOf AutomaticCloseExpanderStackPanel.Children(Index) Is Expander Then
Dim IndexedExpander As Expander = DirectCast(AutomaticCloseExpanderStackPanel.Children(Index), Expander)
If OpenedExpanderList(Index) Then
IndexedExpander.IsExpanded = True
End If
End If
Next
End Sub
' Funzione che permette di trovare il primo contenitore di tipo T di un elemento grafico dependencyObject
Public Function FindAncestor(Of T As Class)(dependencyObject As DependencyObject) As T
Dim target As DependencyObject = dependencyObject
Do
target = LogicalTreeHelper.GetParent(target)
Loop While target IsNot Nothing AndAlso Not (TypeOf target Is T)
If IsNothing(target) Then
target = dependencyObject
Do
target = VisualTreeHelper.GetParent(target)
Loop While target IsNot Nothing AndAlso Not (TypeOf target Is T)
End If
Return TryCast(target, T)
End Function
End Class
@@ -0,0 +1,92 @@
<UserControl x:Class="OperationExpanderView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:EgtCAM5="clr-namespace:EgtCAM5"
xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5">
<StackPanel Name="OperationExpanderViewStackPanel" IsEnabled="{Binding OperViewIsEnabled}">
<Expander Header="{Binding OperationListHeader}" IsExpanded="{Binding ListIsExpanded}" Name="OperationsListExpander"
Style="{StaticResource ExpanderStyle}">
<Expander.InputBindings>
<KeyBinding Key="Escape" Command="{Binding CancelOperationCommand}" CommandParameter="Escape"/>
</Expander.InputBindings>
<StackPanel>
<UniformGrid Rows="1">
<Button Content="{Binding NewMachiningBtnContent}" Command="{Binding NewMachiningCommand}" Height="30"/>
<Button Content="{Binding NewPositioningBtnContent}" Command="{Binding NewPositioningCommand}" Height="30"/>
<Button Content="{Binding CancelOperationBtnContent}" Command="{Binding CancelOperationCommand}" Height="30"/>
</UniformGrid>
<ListBox IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding OperationList}" SelectedItem="{Binding SelectedOperation}"
Height="200" x:Name="OperationList" IsEnabled="{Binding IsEnabledOperationList}">
<ListBox.Resources>
<DataTemplate DataType="{x:Type EgtCAM5:MachiningOpListBoxItem}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding Status}" Margin="0,0,5,0"/>
<Image Source="{Binding Image}" Height="15" Margin="0,0,5,0"/>
<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="0,0,5,0"/>
<TextBlock Grid.Column="2" Text="{Binding Info}"/>
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type EgtCAM5:DispositionOpListBoxItem}">
<Border CornerRadius="1" Background="{StaticResource EgaltechBlue3}">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Image}" Height="15" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Name}" Foreground="White"
FontSize="15" FontWeight="SemiBold"/>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.Resources>
<Interactivity:Interaction.Triggers>
<Interactivity:EventTrigger EventName="MouseDoubleClick">
<Interactivity:InvokeCommandAction Command="{Binding OperationListDoubleClickCommand}"/>
</Interactivity:EventTrigger>
</Interactivity:Interaction.Triggers>
<Interactivity:Interaction.Behaviors>
<EgtCAM5:ScrollIntoViewForListBox/>
</Interactivity:Interaction.Behaviors>
<ListBox.InputBindings>
<KeyBinding Key="Delete" Command="{Binding CancelOperationCommand}"/>
</ListBox.InputBindings>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<UniformGrid Rows="1">
<Button Content="{Binding MoveUpMsg}" Command="{Binding MoveUpCommand}" Height="30"/>
<Button Content="{Binding MoveDownMsg}" Command="{Binding MoveDownCommand}" Height="30"/>
<Button Content="{Binding UpdateMsg}" Command="{Binding UpdateCommand}" Height="30"/>
<Button Content="{Binding SetUpMsg}" Command="{Binding SetUpCommand}" Height="30"/>
</UniformGrid>
</StackPanel>
</Expander>
<Expander IsExpanded="{Binding ParametersIsExpanded}" Name="OperationParametersExpander"
Style="{StaticResource ExpanderStyle}" Padding="3">
<Expander.Header>
<TextBlock Text="{Binding ParametersExpanderName}"/>
</Expander.Header>
<!--ContentPresenter that contains the OperationParameters-->
<ContentPresenter Name="OperationParameters" Content="{Binding OperationParameters,Mode=OneWay}"/>
</Expander>
</StackPanel>
</UserControl>
@@ -0,0 +1,109 @@
Imports EgtWPFLib5
Imports EgtWPFLib5.EgtFloating
Public Class OperationExpanderView
Private EgtFloatingTray As EgtFloatingTray
Private OptionPanelView As UserControl
Private OptionPanelViewStackPanel As StackPanel
'Private OperationParameters As ContentPresenter
Private MachiningTreeContentPresenter As ContentPresenter
Private MachiningTreeUserControl As UserControl
Private MachiningTreeExpander As Expander
Private SimulationContentPresenter As ContentPresenter
Private SimulationUserControl As UserControl
Private SimulationExpanderStackPanel As StackPanel
Private SimulationExpander As Expander
Private GenerateButton As Button
Private m_bFirst As Boolean = True
Private Sub OperationExpanderView_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
If m_bFirst Then
EgtFloatingTray = FindAncestor(Of EgtFloatingTray)(Me)
OptionPanelView = FindAncestor(Of UserControl)(Me)
OptionPanelViewStackPanel = DirectCast(OptionPanelView.Content, StackPanel)
MachiningTreeContentPresenter = DirectCast(OptionPanelViewStackPanel.Children(1), ContentPresenter)
MachiningTreeUserControl = DirectCast(MachiningTreeContentPresenter.Content, UserControl)
MachiningTreeExpander = DirectCast(MachiningTreeUserControl.Content, Expander)
SimulationContentPresenter = DirectCast(OptionPanelViewStackPanel.Children(2), ContentPresenter)
SimulationUserControl = DirectCast(SimulationContentPresenter.Content, UserControl)
SimulationExpanderStackPanel = DirectCast(SimulationUserControl.Content, StackPanel)
SimulationExpander = DirectCast(SimulationExpanderStackPanel.Children(0), Expander)
GenerateButton = DirectCast(SimulationExpanderStackPanel.Children(1), Button)
' Gestisco l'evento SizeChanged della Tray
AddHandler EgtFloatingTray.SizeChanged, AddressOf OperationExpanderTray_SizeChanged
m_bFirst = False
End If
CalculateOperationParametersStackPanelMaxHeight()
End Sub
Private Sub OperationExpanderTray_SizeChanged(sender As Object, e As System.Windows.SizeChangedEventArgs)
CalculateOperationParametersStackPanelMaxHeight()
'For Each Expander In OperationParametersStackPanel.Children
' If TypeOf Expander Is Expander Then
' Dim CurrExpander As Expander = DirectCast(Expander, Expander)
' CurrExpander.IsExpanded = False
' End If
'Next
End Sub
Private Sub CalculateOperationParametersStackPanelMaxHeight()
Dim OccupiedHeight As Double = 0
If Not MachiningTreeExpander.IsExpanded Then
OccupiedHeight += MachiningTreeExpander.ActualHeight
Else
Dim MachiningTreeExpanderContent As FrameworkElement = DirectCast(MachiningTreeExpander.Content, FrameworkElement)
MachiningTreeExpanderContent.Measure(New Size(Double.PositiveInfinity, Double.PositiveInfinity))
OccupiedHeight += (MachiningTreeExpander.ActualHeight - MachiningTreeExpanderContent.DesiredSize.Height)
End If
If Not SimulationExpander.IsExpanded Then
OccupiedHeight += SimulationExpander.ActualHeight
Else
Dim SimulationExpanderContent As FrameworkElement = DirectCast(SimulationExpander.Content, FrameworkElement)
SimulationExpanderContent.Measure(New Size(Double.PositiveInfinity, Double.PositiveInfinity))
OccupiedHeight += (SimulationExpander.ActualHeight - SimulationExpanderContent.DesiredSize.Height)
End If
OccupiedHeight += GenerateButton.ActualHeight
'Aggiungo altezza OperationsList header Expander
If Not OperationsListExpander.IsExpanded Then
OccupiedHeight += OperationsListExpander.ActualHeight
Else
Dim OperationsListExpanderContent As FrameworkElement = DirectCast(OperationsListExpander.Content, FrameworkElement)
OperationsListExpanderContent.Measure(New Size(Double.PositiveInfinity, Double.PositiveInfinity))
OccupiedHeight += (OperationsListExpander.ActualHeight - OperationsListExpanderContent.DesiredSize.Height)
End If
If Not OperationParametersExpander.IsExpanded Then
OccupiedHeight += OperationParametersExpander.ActualHeight
Else
Dim OperationParametersExpanderContent As FrameworkElement = DirectCast(OperationParametersExpander.Content, FrameworkElement)
OperationParametersExpanderContent.Measure(New Size(Double.PositiveInfinity, Double.PositiveInfinity))
OccupiedHeight += (OperationParametersExpander.ActualHeight - OperationParametersExpanderContent.DesiredSize.Height)
End If
'' Aggiungo altezza contenuto OperationParameters che però è fuori dallo Stackpanel
'OperationFirstParametersStackPanel.Measure(New Size(Double.PositiveInfinity, Double.PositiveInfinity))
'If OperationFirstParametersStackPanel.DesiredSize.Height <> 0 Then
' OccupiedHeight += OperationFirstParametersStackPanel.DesiredSize.Height
'Else
' ' aggiungo il valore calcolato provando se non viene calcolato dal sistema al momento
' OccupiedHeight += 10
'End If
'OperationParametersStackPanel.MaxHeight = OptionPanelViewStackPanel.MaxHeight - OccupiedHeight
End Sub
' Funzione che permette di trovare il primo contenitore di tipo T di un elemento grafico dependencyObject
Public Function FindAncestor(Of T As Class)(dependencyObject As DependencyObject) As T
Dim target As DependencyObject = dependencyObject
Do
target = LogicalTreeHelper.GetParent(target)
Loop While target IsNot Nothing AndAlso Not (TypeOf target Is T)
If IsNothing(target) Then
target = dependencyObject
Do
target = VisualTreeHelper.GetParent(target)
Loop While target IsNot Nothing AndAlso Not (TypeOf target Is T)
End If
Return TryCast(target, T)
End Function
End Class
@@ -0,0 +1,857 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Namespace EgtCAM5
Public Class OperationExpanderViewModel
Inherits ViewModelBase
' Modalità di aggiunta attiva/disattiva
Private m_NewMachining As Boolean = False
Private Sub StartNewMachining()
m_NewMachining = True
' Smarco la geometria eventualmente marcata
If Not IsNothing(m_LastMarkedOperationId) Then EgtResetMark(EgtGetFirstNameInGroup(m_LastMarkedOperationId, MCH_MGR_CL))
' Deseleziono eventuali geometrie selezionate
EgtDeselectAll()
EgtDraw()
' Blocco la lista operazioni
IsEnabledOperationList = False
' Abilito la selezione delle geometrie da lavorare
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.MACHINING)
' Abilito la selezione di curve e superfici
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, SceneSelModeOpt.PARTCURVESANDSURFACES)
' Abilito ed apro l'expander con l'albero delle lavorazioni
Application.Msn.NotifyColleagues(Application.MACHININGTREEVIEWEXPANDERISENABLED, True)
End Sub
Private Sub EndNewMachining(SelOpId As Integer)
' Deseleziono eventuali geometrie selezionate
EgtDeselectAll()
EgtDraw()
' Sblocco la lista operazioni
IsEnabledOperationList = True
' Disabilito e chiudo l'expander con l'albero delle lavorazioni
Application.Msn.NotifyColleagues(Application.MACHININGTREEVIEWEXPANDERISENABLED, False)
' Disabilito la selezione
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.NULL)
' Disabilito la selezione di curve e superfici del pezzo
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, SceneSelModeOpt.NULL)
' Apro i parametri della lavorazione aggiunta
If SelOpId <> GDB_ID.NULL Then
For Index = 0 To OperationList.Count - 1
If OperationList(Index).Id = SelOpId Then
SelectedOperation = OperationList(Index)
End If
Next
End If
ParametersIsExpanded = True
m_NewMachining = False
End Sub
Private m_NewPositioning As Boolean = False
' Ultima lavorazione evidenziata
Private m_LastMarkedOperationId As Integer = GDB_ID.NULL
'Expander aperto tra quelli presenti nel MachiningOptionPanel
Private m_CurrExpandedExpander As MachiningOptionPanelExpander = MachiningOptionPanelExpander.OPERATIONLIST
Friend Enum MachiningOptionPanelExpander
OPERATIONLIST
OPERATIONPARAMETERS
SIMULATION
End Enum
Private m_OperViewIsEnabled As Boolean = True
Public Property OperViewIsEnabled As Boolean
Get
Return m_OperViewIsEnabled
End Get
Set(value As Boolean)
m_OperViewIsEnabled = value
OnPropertyChanged("OperViewIsEnabled")
End Set
End Property
Private m_ListIsExpanded As Boolean
Public Property ListIsExpanded As Boolean
Get
Return m_ListIsExpanded
End Get
Set(value As Boolean)
If value <> m_ListIsExpanded Then
m_ListIsExpanded = value
If value Then
If m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONPARAMETERS Then
ParametersIsExpanded = False
ElseIf m_CurrExpandedExpander = MachiningOptionPanelExpander.SIMULATION Then
Application.Msn.NotifyColleagues(Application.SIMULATIONEXPANDER_SET_ISEXPANDED, False)
End If
m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONLIST
End If
OnPropertyChanged("ListIsExpanded")
End If
End Set
End Property
Private m_ParametersIsExpanded As Boolean
Public Property ParametersIsExpanded As Boolean
Get
Return m_ParametersIsExpanded
End Get
Set(value As Boolean)
If value <> m_ParametersIsExpanded Then
m_ParametersIsExpanded = value
If value Then
If m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONLIST Then
ListIsExpanded = False
ElseIf m_CurrExpandedExpander = MachiningOptionPanelExpander.SIMULATION Then
m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONPARAMETERS
Application.Msn.NotifyColleagues(Application.SIMULATIONEXPANDER_SET_ISEXPANDED, False)
End If
m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONPARAMETERS
If IsValidDispositionType(SelectedOperation.m_Type) Then
ParametersExpanderName = m_SelectedOperation.Name
' Abilito la selezione di tutti i tipi di geometria
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, SceneSelModeOpt.ALL)
' Verifico se c'è un grezzo nella disposizione corrente
Dim bFirstRaw As Boolean = True
Dim nRawPartId As Integer = EgtGetFirstRawPart()
While nRawPartId <> GDB_ID.NULL
If EgtVerifyRawPartCurrPhase(nRawPartId) Then
bFirstRaw = False
Exit While
End If
nRawPartId = EgtGetNextRawPart(nRawPartId)
End While
' Lancio funzione che inizializza la disposizione
m_OpenDispositionFunction(bFirstRaw)
' Nascondo tutte le lavorazioni
Dim nOpId As Integer = EgtGetFirstOperation()
While nOpId <> GDB_ID.NULL
If IsValidMachiningType(EgtGetOperationType(nOpId)) Then
EgtSetOperationStatus(nOpId, False)
End If
nOpId = EgtGetNextOperation(nOpId)
End While
EgtDraw()
ElseIf IsValidMachiningType(SelectedOperation.m_Type) Then
' Leggo il tipo di operazione per impostare il tipo di selezione
EgtSetCurrMachining(SelectedOperation.m_Id)
Dim sOpMach As String = String.Empty
EgtGetMachiningParam(MCH_MP.NAME, sOpMach)
ParametersExpanderName = m_SelectedOperation.Name & " (" & sOpMach & ")"
Dim OperationType As Integer = -1
EgtGetMachiningParam(MCH_MP.TYPE, OperationType)
' Abilito la selezione delle lavorazioni
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.MACHINING)
' Abilito la selezione dei giusti tipi di geometria
Select Case OperationType
Case MCH_OY.SAWING
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomSawing)
Case MCH_OY.DRILLING
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomDrilling)
Case MCH_OY.MILLING
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomMilling)
Case MCH_OY.POCKETING
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomPocketing)
Case MCH_OY.MORTISING
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomMortising)
Case MCH_OY.SAWROUGHING
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomSawRoughing)
Case MCH_OY.SAWFINISHING
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomSawFinishing)
Case MCH_OY.GENMACHINING
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomGenMachining)
Case MCH_OY.CHISELING
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, OptionModule.m_SelGeomChiseling)
End Select
' Imposto visualizzazione utensile
DirectCast(m_MachiningParameterExpander.DataContext, MachiningParameterExpanderViewModel).ViewTool = True
End If
Else
If m_CurrExpandedExpander = MachiningOptionPanelExpander.OPERATIONLIST Then
ListIsExpanded = True
End If
If SelectedOperation.m_Type = MCH_OY.DISP Then
' Visualizzo tutte le lavorazioni della fase corrente
Dim nCurrPhase = EgtGetCurrPhase()
Dim nOpId As Integer = EgtGetFirstOperation()
While nOpId <> GDB_ID.NULL
If IsValidMachiningType(EgtGetOperationType(nOpId)) Then
EgtSetOperationStatus(nOpId, (EgtGetOperationPhase(nOpId) = nCurrPhase))
End If
nOpId = EgtGetNextOperation(nOpId)
End While
EgtDraw()
Else
' Nascondo visualizzazione utensile
DirectCast(m_MachiningParameterExpander.DataContext, MachiningParameterExpanderViewModel).ViewTool = False
End If
ParametersExpanderName = String.Empty
' Disabilito la selezione delle lavorazioni
Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.NULL)
' Resetto il tipo di selezione
Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, SceneSelModeOpt.NULL)
End If
OnPropertyChanged("ParametersIsExpanded")
End If
Application.Msn.NotifyColleagues(Application.EMITTITLE)
End Set
End Property
Private m_ParametersExpanderName As String
Public Property ParametersExpanderName As String
Get
If String.IsNullOrEmpty(m_ParametersExpanderName) Then
Return EgtMsg(MSG_OPERATION + 2)
Else
Return m_ParametersExpanderName
End If
End Get
Set(value As String)
If value <> m_ParametersExpanderName Then
m_ParametersExpanderName = value
End If
OnPropertyChanged("ParametersExpanderName")
End Set
End Property
Private m_IsEnabledOperationList As Boolean = True
Public Property IsEnabledOperationList As Boolean
Get
Return m_IsEnabledOperationList
End Get
Set(value As Boolean)
If value <> m_IsEnabledOperationList Then
m_IsEnabledOperationList = value
OnPropertyChanged("IsEnabledOperationList")
End If
End Set
End Property
Private m_OperationList As New ObservableCollection(Of OperationListBoxItem)
Public Property OperationList As ObservableCollection(Of OperationListBoxItem)
Get
Return m_OperationList
End Get
Set(value As ObservableCollection(Of OperationListBoxItem))
m_OperationList = value
End Set
End Property
Private m_SelectedOperation As OperationListBoxItem
Public Property SelectedOperation As OperationListBoxItem
Get
Return m_SelectedOperation
End Get
Set(value As OperationListBoxItem)
If Not IsNothing(value) Then
' Verifico se c'è l'operazione precedente
If m_LastMarkedOperationId <> GDB_ID.NULL Then
' La de-evidenzio
Dim bEnabModif As Boolean = EgtGetEnableModified()
EgtDisableModified()
EgtResetMark(EgtGetFirstNameInGroup(m_LastMarkedOperationId, MCH_MGR_CL))
If bEnabModif Then EgtEnableModified()
' Ne deseleziono la geometria
EgtDeselectAll()
End If
' Imposto la fase di lavorazione corrente
EgtSetCurrPhase(EgtGetOperationPhase(value.Id))
' Verifico se l'operazione è una disposizione
If EgtGetOperationType(value.Id) = MCH_OY.DISP Then
'' Abilito la selezione delle Fixture
'Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.FIXTURE)
'' Abilito la selezione di tutti i tipi di geometria
'Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, SceneSelModeOpt.ALL)
' L'operazione è una lavorazione
Else
'' Disabilito la selezione di qualunque cosa
'Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.NULL)
' Imposto come corrente la lavorazione(operazione) selezionata
EgtSetCurrMachining(value.Id)
' Evidenzio la lavorazione(operazione) selezionata
'EgtSetMark(value.Id)
Dim bEnabModif As Boolean = EgtGetEnableModified()
EgtDisableModified()
EgtSetMark(EgtGetFirstNameInGroup(value.Id, MCH_MGR_CL))
If bEnabModif Then EgtEnableModified()
' Seleziono la geometria della lavorazione
Dim CountIndex = 0
Dim EntityIndex As Integer = 0
Dim SubEntityIndex As Integer = 0 ' Nell'interfaccia non si usa ma devo comunque definirla perchè la funzione la restituisce obbligatoriamente
While EgtGetMachiningGeometry(CountIndex, EntityIndex, SubEntityIndex)
EgtSelectObj(EntityIndex)
IniFile.m_LastSubEntityId = SubEntityIndex
CountIndex += 1
End While
' La salvo come ultima operazione selezionata
m_LastMarkedOperationId = value.Id
End If
m_SelectedOperation = value
' Notifico al contentcontrol OperationParameter di aggiornarsi
OnPropertyChanged("OperationParameters")
' Notifico l'operazione selezionata all'expander con l'albero delle lavorazioni aggiungibili
Application.Msn.NotifyColleagues(Application.SELECTEDOPERATION, value)
' Aggiorno visualizzazione
EgtDraw()
End If
'OnPropertyChanged("ToolExpanderHeader")
OnPropertyChanged("SelectedOperation")
End Set
End Property
' Actions
Private m_UpdateParamValues As Action
Private m_OpenDispositionFunction As Action(Of Boolean)
Private m_MachiningParameterExpander As MachiningParameterExpanderView
Private m_DispositionParameterExpander As DispositionParameterExpanderView
Public ReadOnly Property OperationParameters As ContentControl
Get
If m_SelectedOperation.m_Type = MCH_OY.DISP Then
If IsNothing(m_DispositionParameterExpander) Then
m_DispositionParameterExpander = New DispositionParameterExpanderView
m_DispositionParameterExpander.DataContext = New DispositionParameterExpanderViewModel(m_OpenDispositionFunction)
End If
Return m_DispositionParameterExpander
Else
If IsNothing(m_MachiningParameterExpander) Then
m_MachiningParameterExpander = New MachiningParameterExpanderView
m_MachiningParameterExpander.DataContext = New MachiningParameterExpanderViewModel(m_UpdateParamValues)
End If
m_UpdateParamValues()
Return m_MachiningParameterExpander
End If
End Get
End Property
#Region "Messages"
Public ReadOnly Property OperationListHeader As String
Get
Return EgtMsg(MSG_OPERATION + 1)
End Get
End Property
Public ReadOnly Property NewMachiningBtnContent As String
Get
Return EgtMsg(MSG_OPERATION + 4)
End Get
End Property
Public ReadOnly Property NewPositioningBtnContent As String
Get
Return EgtMsg(MSG_OPERATION + 5)
End Get
End Property
Public ReadOnly Property CancelOperationBtnContent As String
Get
Return EgtMsg(MSG_OPERATION + 6)
End Get
End Property
Public ReadOnly Property MoveUpMsg As String
Get
Return EgtMsg(MSG_OPERATION + 8)
End Get
End Property
Public ReadOnly Property MoveDownMsg As String
Get
Return EgtMsg(MSG_OPERATION + 9)
End Get
End Property
Public ReadOnly Property UpdateMsg As String
Get
Return EgtMsg(MSG_OPERATION + 10)
End Get
End Property
Public ReadOnly Property SetUpMsg As String
Get
Return EgtMsg(MSG_SETUP + 1)
End Get
End Property
#End Region ' Messages
' Definizione comandi
Private m_cmdNewMachining As ICommand
Private m_cmdNewPositioning As ICommand
Private m_cmdCancelOperation As ICommand
Private m_cmdOperationListDoubleClick As ICommand
Private m_cmdMoveUp As ICommand
Private m_cmdMoveDown As ICommand
Private m_cmdUpdate As ICommand
Private m_cmdSetUp As ICommand
Sub New()
Me.ListIsExpanded = True
Application.Msn.Register(Application.LOADOPERATIONLIST, Sub(nSelectedOperation As Integer)
LoadOperationList()
SelectOperation(nSelectedOperation)
ListIsExpanded = True
End Sub)
Application.Msn.Register(Application.REMOVEMARKFROMLASTOPERATION, Sub()
EgtResetMark(EgtGetFirstNameInGroup(m_LastMarkedOperationId, MCH_MGR_CL))
End Sub)
Application.Msn.Register(Application.NEWMACHININGMODEISACTIVE, Sub(Params As NewMachOpParam)
If Params.bActive Then
StartNewMachining()
Else
EndNewMachining(Params.SelMachOpId)
End If
End Sub)
Application.Msn.Register(Application.OPERATIONVIEWEXPANDERISENABLED, Sub(bEnable As Boolean)
OperViewIsEnabled = bEnable
End Sub)
Application.Msn.Register(Application.SIMULATIONEXPANDER_GET_ISEXPANDED, Sub(bValue As Boolean)
If m_CurrExpandedExpander = MachiningOptionPanelExpander.SIMULATION Then
ListIsExpanded = True
End If
If bValue Then
If m_NewMachining Then EndNewMachining(GDB_ID.NULL)
ListIsExpanded = False
ParametersIsExpanded = False
m_CurrExpandedExpander = MachiningOptionPanelExpander.SIMULATION
Else
' Deseleziono e riseleziono la lavorazione corrente per fargli riselezionare la geometria
' di lavorazione che è stata deselezionata dalla simulazione
Dim CurrSelectedOperation As OperationListBoxItem
CurrSelectedOperation = SelectedOperation
SelectedOperation = Nothing
SelectedOperation = CurrSelectedOperation
End If
End Sub)
Application.Msn.Register(Application.DRAWMODE_ISCHECKED, Sub()
' Annullo creazione nuova lavorazione
If m_NewMachining Then EndNewMachining(GDB_ID.NULL)
' Disabilito visualizzazione utensile
If Not IsNothing(m_MachiningParameterExpander) Then
DirectCast(m_MachiningParameterExpander.DataContext, MachiningParameterExpanderViewModel).ViewTool = False
End If
End Sub)
Application.Msn.Register(Application.CANCELOPERATIONCOMMAND, Sub()
CancelOperation(String.Empty)
End Sub)
End Sub
#Region "COMMANDS"
#Region "NewMachiningCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property NewMachiningCommand As ICommand
Get
If m_cmdNewMachining Is Nothing Then
m_cmdNewMachining = New RelayCommand(AddressOf NewMachiningCmd)
End If
Return m_cmdNewMachining
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub NewMachiningCmd(ByVal param As Object)
StartNewMachining()
End Sub
#End Region ' NewMachiningCommand
#Region "NewPositioningCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property NewPositioningCommand As ICommand
Get
If m_cmdNewPositioning Is Nothing Then
m_cmdNewPositioning = New RelayCommand(AddressOf NewPositioning)
End If
Return m_cmdNewPositioning
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub NewPositioning(ByVal param As Object)
' Recupero grezzi e bloccaggi dell'ultima fase
Dim nLastPhase As Integer = EgtGetPhaseCount()
EgtSetCurrPhase(nLastPhase)
Dim vRawId As New List(Of Integer)
Dim nRawId As Integer = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL
If EgtVerifyRawPartPhase(nRawId, nLastPhase) Then
vRawId.Add(nRawId)
End If
nRawId = EgtGetNextRawPart(nRawId)
End While
Dim vFxtId As New List(Of Integer)
Dim nFxtId As Integer = EgtGetFirstFixture()
While nFxtId <> GDB_ID.NULL
vFxtId.Add(nFxtId)
nFxtId = EgtGetNextFixture(nFxtId)
End While
' Aggiungo la nuova fase
Dim nPhase As Integer = EgtAddPhase()
Dim nDispId As Integer = EgtGetPhaseDisposition(nPhase)
' Confermo grezzi e bloccaggi sopra salvati
For Each nId As Integer In vRawId
EgtKeepRawPart(nId, nLastPhase)
Next
For Each nId As Integer In vFxtId
EgtKeepFixture(nId, nLastPhase)
Next
' Ricarico la lista delle operazioni
Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, nDispId)
End Sub
#End Region ' NewPositioningCommand
#Region "CancelOperationCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property CancelOperationCommand As ICommand
Get
If m_cmdCancelOperation Is Nothing Then
m_cmdCancelOperation = New RelayCommand(AddressOf CancelOperation)
End If
Return m_cmdCancelOperation
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub CancelOperation(ByVal param As Object)
' Se viene premuto il tasto Esc
If DirectCast(param, String) = "Escape" Then
If m_NewMachining Then
EndNewMachining(GDB_ID.NULL)
ListIsExpanded = True
End If
Return
End If
' Se sto inserendo una nuova lavorazione
If m_NewMachining Then
EndNewMachining(GDB_ID.NULL)
ListIsExpanded = True
' altrimenti sto cancellandone una vecchia
Else
If Not IsNothing(SelectedOperation) Then
' Salvo indice operazione precedente a selezionata
Dim nPrevOperId As Integer = EgtGetPrevOperation(SelectedOperation.Id)
If SelectedOperation.Type = MCH_OY.DISP Then
' Posso cancellare solo l'ultima disposizione
If EgtGetOperationPhase(SelectedOperation.Id) = EgtGetPhaseCount() Then
EgtRemoveLastPhase()
Else
Return
End If
Else
' Smarco e deseleziono la geometria selezionata
EgtResetMark(EgtGetFirstNameInGroup(m_LastMarkedOperationId, MCH_MGR_CL))
EgtDeselectAll()
EgtDraw()
' Rimuovo l'operazione selezionata
EgtRemoveOperation(SelectedOperation.Id)
End If
' Ricarico la lista delle operazioni
Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, nPrevOperId)
End If
Application.Msn.NotifyColleagues(Application.EMITTITLE)
End If
End Sub
#End Region ' CancelOperationCommand
#Region "OperationListDoubleClickCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property OperationListDoubleClickCommand As ICommand
Get
If m_cmdOperationListDoubleClick Is Nothing Then
m_cmdOperationListDoubleClick = New RelayCommand(AddressOf OperationListDoubleClick)
End If
Return m_cmdOperationListDoubleClick
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub OperationListDoubleClick()
If EgtGetOperationMode(SelectedOperation.Id) Then
ParametersIsExpanded = True
End If
End Sub
#End Region ' OperationListDoubleClickCommand
#Region "MoveUpCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property MoveUpCommand As ICommand
Get
If m_cmdMoveUp Is Nothing Then
m_cmdMoveUp = New RelayCommand(AddressOf MoveUp)
End If
Return m_cmdMoveUp
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub MoveUp()
If Not IsNothing(SelectedOperation) Then
' Verifico se l'entità selezionata è una lavorazione o una disposizione,
' se è una disposizione esco perchè non si possono spostare
If SelectedOperation.Type = MCH_OY.DISP Then Return
' Trovo indice dell'entità selezionata
Dim SelectedIndex As Integer = OperationList.IndexOf(SelectedOperation)
' Posso spostare solo se la precedente non è una disposizione (per non cambiare fase)
If OperationList(SelectedIndex - 1).Type = MCH_OY.DISP Then Return
' Recupero Id entità selezionata e precedente a quella selezionata
Dim SelectedId As Integer = OperationList(SelectedIndex).Id
Dim PreviousId As Integer = OperationList(SelectedIndex - 1).Id
' Sposto l'operazione selezionata nell'ambiente Egt
If EgtRelocate(SelectedId, PreviousId, GDB_POS.BEFORE) Then
' Sposto l'operazione selezionata nella grafica
OperationList.Move(SelectedIndex, SelectedIndex - 1)
' Ricalcolo la lavorazione selezionata e la precedente
EgtSetCurrMachining(PreviousId)
EgtApplyMachining(False)
EgtSetCurrMachining(SelectedId)
EgtApplyMachining(False)
EgtDraw()
End If
Application.Msn.NotifyColleagues(Application.EMITTITLE)
End If
End Sub
#End Region ' MoveUpCommand
#Region "MoveDownCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property MoveDownCommand As ICommand
Get
If m_cmdMoveDown Is Nothing Then
m_cmdMoveDown = New RelayCommand(AddressOf MoveDown)
End If
Return m_cmdMoveDown
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub MoveDown()
If Not IsNothing(SelectedOperation) Then
' Verifico se l'entità selezionata è una lavorazione o una disposizione,
' se è una disposizione esco perchè non si possono spostare
If SelectedOperation.Type = MCH_OY.DISP Then Return
' Trovo indice dell'entità selezionata
Dim SelectedIndex As Integer = OperationList.IndexOf(SelectedOperation)
' Verifico che l'indice sia < della lunghezza della lista delle operazioni,altrimenti è già ultima e quindi non la posso spostare
If SelectedIndex > OperationList.Count - 2 Then Return
' Posso spostare solo se la successiva non è una disposizione (per non cambiare fase)
If OperationList(SelectedIndex + 1).Type = MCH_OY.DISP Then Return
' Recupero Id entitàselezionata e successiva a quella selezionata
Dim SelectedId As Integer = OperationList(SelectedIndex).Id
Dim PostId As Integer = OperationList(SelectedIndex + 1).Id
' Sposto l'operazione selezionata nell'ambiente Egt
If EgtRelocate(SelectedId, PostId, GDB_POS.AFTER) Then
' Sposto l'operazione selezionata nella grafica
OperationList.Move(SelectedIndex, SelectedIndex + 1)
' Ricalcolo la lavorazione selezionata e la successiva
EgtSetCurrMachining(SelectedId)
EgtApplyMachining(False)
EgtSetCurrMachining(PostId)
EgtApplyMachining(False)
EgtDraw()
End If
Application.Msn.NotifyColleagues(Application.EMITTITLE)
End If
End Sub
#End Region ' MoveDownCommand
#Region "UpdateCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property UpdateCommand As ICommand
Get
If m_cmdUpdate Is Nothing Then
m_cmdUpdate = New RelayCommand(AddressOf Update)
End If
Return m_cmdUpdate
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub Update()
' Cursore di attesa
Application.Current.MainWindow.ForceCursor = True
Application.Current.MainWindow.Cursor = Cursors.Wait
' Eseguo ricalcolo
Dim bRecalc As Boolean = ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift)
Dim sErr As String = String.Empty
Dim bOk As Boolean = EgtApplyAllMachinings(bRecalc, False, sErr)
EgtSetModified()
' Aggiorno visualizzazione e ritorno a cursore standard
EgtDraw()
Application.Current.MainWindow.ForceCursor = False
Application.Current.MainWindow.Cursor = Cursors.Arrow
' In caso di errori, li segnalo
If Not bOk Then
If Not String.IsNullOrEmpty(sErr) Then
MessageBox.Show(sErr, EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Exclamation)
Else
MessageBox.Show(EgtMsg(MSG_SIMULATION + 6), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Error)
End If
Else
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(MSG_OPERATION + 11))
End If
Application.Msn.NotifyColleagues(Application.EMITTITLE)
End Sub
#End Region ' UpdateCommand
#Region "SetUpCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property SetUpCommand As ICommand
Get
If m_cmdSetUp Is Nothing Then
m_cmdSetUp = New RelayCommand(AddressOf SetUp)
End If
Return m_cmdSetUp
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub SetUp()
' verifico che il file di configurazione attrezzaggio (lua) della macchina esista
If Not File.Exists(IniFile.m_sCurrMachScriptsDirPath & "\" & SETUP_LUA) Then
EgtOutLog("SetUp error: SetUp configuration file doesn't exist ")
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 7), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error)
Return
End If
' carico Lua che contiene le funzioni per ottenere le posizioni valide dell'utensile selezionato,
' e testa e uscita dell'utensile attrezzato
EgtLuaExecFile(IniFile.m_sCurrMachScriptsDirPath & "\" & SETUP_LUA)
' verifico che le teste riportate in configurazione esistano
Dim Index As Integer = 1
Dim nErr As Integer = 0
While nErr = 0
Dim sHead As String = String.Empty
nErr = 999
EgtLuaSetGlobIntVar("STU.INDEX", Index)
EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos")
' Leggo variabili
EgtLuaGetGlobStringVar("STU.HEAD", sHead)
EgtLuaGetGlobIntVar("STU.ERR", nErr)
If nErr = 0 Then
If EgtGetHeadExitCount(sHead) = 0 Then
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 8), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error)
Return
End If
End If
Index += 1
End While
' creo ed apro finestra SetUp
Dim SetUpWindow As New SetUpWindowV
SetUpWindow.Height = 614
SetUpWindow.Width = 1024
SetUpWindow.DataContext = New SetUpWindowVM
SetUpWindow.Owner = Application.Current.MainWindow
SetUpWindow.ShowDialog()
Application.Msn.NotifyColleagues(Application.EMITTITLE)
End Sub
#End Region ' SetUpCommand
#End Region ' Commands
#Region "METHODS"
Private Sub LoadOperationList()
OperationList.Clear()
Dim Id As Integer
Dim OpStatus As Boolean = True
Dim OpName As String = String.Empty
Dim OpType As Integer = 0
Dim OpTool As String = String.Empty
Dim OpMach As String = String.Empty
Id = EgtGetFirstOperation()
While Id <> GDB_ID.NULL
EgtGetOperationName(Id, OpName)
OpType = EgtGetOperationType(Id)
If IsValidMachiningType(OpType) Then
EgtSetCurrMachining(Id)
OpStatus = EgtGetOperationMode(Id)
EgtGetMachiningParam(MCH_MP.TOOL, OpTool)
EgtGetMachiningParam(MCH_MP.NAME, OpMach)
OperationList.Add(New MachiningOpListBoxItem(Id, OpStatus, OpName, OpType, OpTool, OpMach))
ElseIf IsValidDispositionType(OpType) Then
OpStatus = True
OpTool = String.Empty
OpMach = String.Empty
OperationList.Add(New DispositionOpListBoxItem(Id, OpName, OpType))
End If
Id = EgtGetNextOperation(Id)
End While
End Sub
Private Sub SelectOperation(nSelectedOperation As Integer)
If nSelectedOperation < 0 Then
SelectedOperation = OperationList(0)
Else
Dim OperationFound = False
For Each Operation In OperationList
If Operation.Id = nSelectedOperation Then
OperationFound = True
SelectedOperation = Operation
Exit For
End If
Next
If Not OperationFound Then
SelectedOperation = OperationList(0)
End If
End If
End Sub
#End Region ' Methods
End Class
End Namespace
@@ -0,0 +1,20 @@
Public Class DispositionOpListBoxItem
Inherits OperationListBoxItem
Private m_Image As String = String.Empty
Public Property Image As String
Get
Return m_Image
End Get
Set(value As String)
m_Image = value
End Set
End Property
Sub New(nId As Integer, sName As String, nType As Integer)
m_Id = nId
Me.Name = sName
m_Type = nType
End Sub
End Class
@@ -0,0 +1,99 @@
Imports System.ComponentModel
Imports System.Collections.ObjectModel
Imports EgtUILib
Public Class MachiningOpListBoxItem
Inherits OperationListBoxItem
Private m_Status As Boolean
Public Property Status As Boolean
Get
Return m_Status
End Get
Set(value As Boolean)
If value <> m_Status Then
If m_Type = MCH_OY.NONE Or m_Type = MCH_OY.DISP Then
m_Status = True
Else
m_Status = value
EgtSetOperationMode(Id, m_Status)
EgtDraw()
End If
End If
End Set
End Property
Private m_Image As String
Public Property Image As String
Get
Return m_Image
End Get
Set(value As String)
m_Image = value
End Set
End Property
Private m_Info As String
Public Property Info As String
Get
Return m_Info
End Get
Set(value As String)
m_Info = value
End Set
End Property
Private m_Tool As String
Public Property Tool As String
Get
Return m_Tool
End Get
Set(value As String)
m_Tool = value
End Set
End Property
Sub New(nId As Integer, bStatus As Boolean, sName As String, nType As Integer, sTool As String, sMach As String)
m_Id = nId
Me.Status = bStatus
Me.Name = sName
m_Type = nType
Me.Image = ConvertTypeToImage(Type)
If Type = MCH_OY.DISP Then
Me.Info = String.Empty
Me.Tool = String.Empty
Else
Me.Info = "(" & If(Not String.IsNullOrEmpty(sTool), sTool, String.Empty) & ", " &
If(Not String.IsNullOrEmpty(sMach), sMach, String.Empty) & ")"
Me.Tool = If(Not String.IsNullOrEmpty(sTool), "(" & sTool & ")", String.Empty)
End If
End Sub
Private Function ConvertTypeToImage(Type As Integer) As String
Select Case Type
Case MCH_OY.DISP
Return ""
Case MCH_OY.DRILLING
Return ""
Case MCH_OY.SAWING
Return ""
Case MCH_OY.MILLING
Return ""
Case MCH_OY.POCKETING
Return ""
Case MCH_OY.MORTISING
Return ""
Case MCH_OY.SAWROUGHING
Return ""
Case MCH_OY.SAWFINISHING
Return ""
Case MCH_OY.GENMACHINING
Return ""
Case MCH_OY.CHISELING
Return ""
Case Else
Return String.Empty
End Select
End Function
End Class
@@ -0,0 +1,36 @@
Imports System.ComponentModel
Public Class OperationListBoxItem
Implements INotifyPropertyChanged
Friend m_Type As Integer
Public ReadOnly Property Type As Integer
Get
Return m_Type
End Get
End Property
Friend m_Id As Integer
Public ReadOnly Property Id As Integer
Get
Return m_Id
End Get
End Property
Private m_Name As String
Public Property Name As String
Get
Return m_Name
End Get
Set(value As String)
m_Name = value
End Set
End Property
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class