OmagCUT :

- Aggiunta spianatura.
- Aggiunta verifica nome già presente in salva con nome.
This commit is contained in:
Emmanuele Sassi
2016-03-09 18:44:19 +00:00
parent ef59927203
commit 1f33c844b7
8 changed files with 826 additions and 4 deletions
+2
View File
@@ -64,6 +64,8 @@
Style="{StaticResource OmagCut_YellowTextButton}"/>
<Button Name="GridCutBtn" Grid.Row="3"
Style="{StaticResource OmagCut_YellowTextButton}"/>
<Button Name="FlatteningCutBtn" Grid.Row="4"
Style="{StaticResource OmagCut_YellowTextButton}"/>
<Button Name="SawTestBtn" Grid.Row="5"
Style="{StaticResource OmagCut_YellowTextButton}"/>
</Grid>
+10 -1
View File
@@ -10,6 +10,7 @@ Public Class DirectCutPageUC
Friend m_SingleCut As SingleCutUC
Friend m_MultipleCut As MultipleCut
Friend m_GridCut As GridCut
Friend m_FlatteningCut As FlatteningCut
Friend m_SawTest As SawTestUC
' Stato di visualizzazione della macchina
Friend m_bShowMachine As Boolean = False
@@ -25,6 +26,7 @@ Public Class DirectCutPageUC
SingleCut
MultipleCut
GridCut
FlatteningCut
SawTest
End Enum
@@ -36,6 +38,7 @@ Public Class DirectCutPageUC
m_SingleCut = New SingleCutUC
m_MultipleCut = New MultipleCut
m_GridCut = New GridCut
m_FlatteningCut = New FlatteningCut
m_SawTest = New SawTestUC
'Posizionemento nella griglia delle Page UserControl
@@ -44,6 +47,7 @@ Public Class DirectCutPageUC
m_SingleCut.SetValue(Grid.RowProperty, 1)
m_MultipleCut.SetValue(Grid.RowProperty, 1)
m_GridCut.SetValue(Grid.RowProperty, 1)
m_FlatteningCut.SetValue(Grid.RowProperty, 1)
m_SawTest.SetValue(Grid.RowProperty, 1)
'Assegno MachineButtons alla pagina
@@ -53,7 +57,7 @@ Public Class DirectCutPageUC
SingleCutBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 2)
MultipleCutBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 3)
GridCutBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 4)
'MachViewModeBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 5)
FlatteningCutBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 6)
SawTestBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 7)
End Sub
@@ -80,6 +84,11 @@ Public Class DirectCutPageUC
m_ActiveDirectCutPage = DirectCutPages.GridCut
End Sub
Private Sub FlatteningCutBtn_Click(sender As Object, e As RoutedEventArgs) Handles FlatteningCutBtn.Click
LeftButtonGrid.Children.Add(m_FlatteningCut)
m_ActiveDirectCutPage = DirectCutPages.FlatteningCut
End Sub
Private Sub SawTestBtn_Click(sender As Object, e As RoutedEventArgs) Handles SawTestBtn.Click
LeftButtonGrid.Children.Add(m_SawTest)
m_ActiveDirectCutPage = DirectCutPages.SawTest
+95
View File
@@ -0,0 +1,95 @@
<UserControl x:Class="FlatteningCut"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:EgtWPFLib="clr-namespace:EgtWPFLib;assembly=EgtWPFLib"
mc:Ignorable="d"
d:DesignHeight="597.3" d:DesignWidth="256">
<!-- Chiamata al Dictionary -->
<UserControl.Resources>
<ResourceDictionary Source="OmagCutDictionary.xaml"/>
</UserControl.Resources>
<Border CornerRadius="{StaticResource Page_CornerRadius}" Background="{StaticResource OmagCut_LightGray}">
<!-- Definizione della Grid MultipleCut -->
<Grid Name="SingleCutGrid" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<ToggleButton Name="Point1Btn" Grid.Column="0"
Style="{StaticResource OmagCut_YellowToggleButton}"/>
<ToggleButton Name="Point2Btn" Grid.Column="1"
Style="{StaticResource OmagCut_YellowToggleButton}"/>
</Grid>
<ComboBox Name="PointModeCmBx" Grid.Row="1" Grid.ColumnSpan="2" Height="38" Width="200"
MaxDropDownHeight="300">
<ComboBox.ItemTemplate>
<DataTemplate>
<Label Content="{Binding}" FontSize="20" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Name="DepthTxBl" Grid.Column="0" Grid.Row="2"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}"/>
<EgtWPFLib:EgtTextBox Name="DepthTxBx" Grid.Column="1" Grid.Row="2" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<TextBlock Name="DirectionTxBl" Grid.Column="0" Grid.Row="3"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}"/>
<EgtWPFLib:EgtTextBox Name="DirectionTxBx" Grid.Column="1" Grid.Row="3" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<TextBlock Name="LenghtTxBl" Grid.Column="0" Grid.Row="4"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}"/>
<EgtWPFLib:EgtTextBox Name="LenghtTxBx" Grid.Column="1" Grid.Row="4" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<TextBlock Name="WidthTxBl" Grid.Column="0" Grid.Row="5"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}"/>
<EgtWPFLib:EgtTextBox Name="WidthTxBx" Grid.Column="1" Grid.Row="5" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<TextBlock Name="OverlapTxBl" Grid.Column="0" Grid.Row="6"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}"/>
<EgtWPFLib:EgtTextBox Name="OverlapTxBx" Grid.Column="1" Grid.Row="6" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<CheckBox Name="SideChBx" Grid.Row="7" Grid.ColumnSpan="2" Height="40" Width="220" FontSize="20"/>
<Button Name="OkBtn" Grid.Column="0" Grid.Row="11" Style="{StaticResource OmagCut_GradientBlueTextButton}"/>
<Button Name="ExitBtn" Grid.Column="2" Grid.Row="11" Style="{StaticResource OmagCut_YellowIconButton}">
<Image Source="Resources/X.png" Style="{StaticResource OmagCut_ButtonIcon}"/>
</Button>
</Grid>
</Border>
</UserControl>
+694
View File
@@ -0,0 +1,694 @@
Imports EgtUILib
Public Class FlatteningCut
' Riferimenti a pagine
Private m_MainWindow As MainWindow = Application.Current.MainWindow
Private WithEvents m_CurrProjPage As CurrentProjectPageUC
' Flag di pagina attiva
Private m_bActive As Boolean = False
' Origine tavola e dati grezzo
Private m_bRawOk As Boolean = False
Private m_ptTabOri As Point3d
Private m_ptRawMin As Point3d
Private m_ptRawMax As Point3d
' Parametri P1 acquisito
Private m_bPointP1Ok As Boolean = False
Private m_ptTipP1 As Point3d
Private m_vtToolP1 As Vector3d
' Parametri P2 acquisito
Private m_bPointP2Ok As Boolean = False
Private m_ptTipP2 As Point3d
Private m_vtToolP2 As Vector3d
' Lato di creazione dei tagli
Private m_bCutSide As CutSide = CutSide.Left
' Parametri della lavorazione
Private m_bCutOk As Boolean = False
Private m_dDepth As Double = 0
Private m_dLen As Double = 500
Private m_dWid As Double = 500
Private m_dAngO As Double = 180
Private m_dAngV As Double = 0
Private m_dOverlap As Double = 1
' Array delle modalità di acquisizione dei punti
Private m_PointsModeArray(2) As String
' Punto selezionato nel disegno
Private m_ptPrev As Point3d
' Layer per crocette temporanee
Private m_nTempLay As Integer
' Costanti
Private Const MAX_TAB_DEPTH As Double = 10.0
Private Const MIN_CUT_LEN As Double = 10.0
Private Const MIN_CUT_WID As Double = 10.0
Private Const MAX_SIDE_ANG As Double = 60.0
Private Const DIRECTCUT As String = "DirectCut"
Private Const RAW_CENTER As String = "RawCenter"
' Costanti che indicano la modalità di acquisizione dei punti
Private Enum PT_MODE As Integer
SAW = 0
LASER = 1
DRAW = 2
End Enum
'Costante che indica il lato in cui posizionare i tagli
Private Enum CutSide As Integer
Left
Right
End Enum
Private Sub FlatteningCut_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
' Creo lista modalità di acquisizione punto
m_PointsModeArray(PT_MODE.SAW) = EgtMsg(MSG_DIRECTCUTPAGEUC + 24)
m_PointsModeArray(PT_MODE.LASER) = EgtMsg(MSG_DIRECTCUTPAGEUC + 12)
m_PointsModeArray(PT_MODE.DRAW) = EgtMsg(MSG_DIRECTCUTPAGEUC + 25)
' la associo alla combobox
PointModeCmBx.ItemsSource = m_PointsModeArray
Point1Btn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 10)
Point2Btn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 11)
DepthTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 13)
LenghtTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 14)
DirectionTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 15)
WidthTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 26)
OverlapTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 27)
SideChBx.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 23)
OkBtn.Content = EgtMsg(MSG_DIRECTCUTPAGEUC + 30)
End Sub
Private Sub FlatteningCut_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
m_bActive = True
' Creo layer temporaneo per crocette
m_nTempLay = EgtCreateGroup(GDB_ID.ROOT)
EgtSetLevel(m_nTempLay, GDB_LV.TEMP)
' Reset punto acquisito
m_bPointP1Ok = False
' Inizializzo primo punto acquisito dal disegno come centro del grezzo
Dim nRawPartCenter As Integer = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, RAW_CENTER)
EgtStartPoint(nRawPartCenter, GDB_ID.ROOT, m_ptPrev)
' Imposto modalità di acquisizione punti
PointModeCmBx.SelectedIndex = PT_MODE.DRAW
' Assegno parametri di lavorazione già definiti
DepthTxBx.Text = LenToString(m_dDepth, 1)
LenghtTxBx.Text = LenToString(m_dLen, 1)
' Inizializzo valori non ancora definiti
DirectionTxBx.Text = DoubleToString(m_dAngO - m_MainWindow.m_CurrentMachine.dDeltaC, 2)
WidthTxBx.Text = DoubleToString(m_dWid, 2)
OverlapTxBx.Text = DoubleToString(m_dOverlap, 2)
' Origine tavola
m_bRawOk = True
If Not EgtGetTableRef(1, m_ptTabOri) Then
m_bRawOk = False
EgtOutLog("Error on TableRef1")
End If
' Dati del grezzo
If Not GetRawBox(m_ptRawMin, m_ptRawMax) Then
m_bRawOk = False
EgtOutLog("Error on RawBox")
End If
' Reset taglio e disabilito bottone esecuzione
m_bCutOk = False
UpdateOkBtn()
' Disabilito bottone secondo punto
Point2Btn.IsEnabled = False
' Deseleziono bottone primo punto
Point1Btn.IsChecked = False
' Disabilito registrazione progetto modificato
EgtDisableModified()
End Sub
Friend Sub MultipleCut_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded
' Rimuovo layer temporaneo per crocette
EgtErase(m_nTempLay)
' Rimuovo eventuale pezzo per taglio diretto
EraseDirectCutPart()
' Riattivo eventuali lavorazioni presenti
ActivateAllMachinings()
' Abilito registrazione progetto modificato
EgtEnableModified()
' Nascondo la macchina
m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False
EgtSetMachineLook(MCH_LOOK.TAB)
EgtDraw()
End Sub
Private Sub UpdateOkBtn()
If m_bCutOk Then
OkBtn.IsEnabled = True
OkBtn.Foreground = Brushes.Black
Else
OkBtn.IsEnabled = False
OkBtn.Foreground = Brushes.DarkGray
End If
End Sub
Private Sub OnMyMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_CurrProjPage.OnMouseDownScene
' Verifico di essere il gestore attivo
If Not m_bActive Then
Return
End If
' Si può selezionare solo con il tasto sinistro e se stato NULL
If e.Button <> Windows.Forms.MouseButtons.Left Or
Not m_CurrProjPage.CurrentProjectScene.IsStatusNull() Then
Return
End If
' Rimuovo eventuali crocette create acquisendo i punti nel disegno
EgtEmptyGroup(m_nTempLay)
' Acquisisco punto da disegno
EgtUnProjectPoint(e.Location, m_ptPrev)
' Aggiusto Z punto acquisito (è in globale)
Dim dPtPrevZ As Double = m_ptPrev.z
m_ptPrev.z = m_ptRawMax.z
' Se direzione di vista calcolabile e da sopra posso aggiustare anche XY
Dim dAngVertDeg, dAngHorizDeg As Double
If EgtGetGenericView(dAngVertDeg, dAngHorizDeg) Then
Dim vtDir As Vector3d = Vector3d.FromSpherical(1, dAngVertDeg, dAngHorizDeg)
If vtDir.z > EPS_SMALL Then
m_ptPrev.z = dPtPrevZ
m_ptPrev += vtDir * (m_ptRawMax.z - m_ptPrev.z) / vtDir.z
End If
End If
' Disegno crocetta che indica il punto acquisito
CreateCross(m_nTempLay, m_ptPrev)
EgtDraw()
End Sub
Private Sub Point1Btn_Click(sender As Object, e As RoutedEventArgs) Handles Point1Btn.Click
' Rimuovo eventuali crocette create acquisendo i punti nel disegno
EgtEmptyGroup(m_nTempLay)
' Reset punto non acquisito
m_bPointP1Ok = False
' Verifico configurazione tavola e grezzo
If Not m_bRawOk Then
Return
End If
' Se acquisizone lama o laser
If PointModeCmBx.SelectedIndex = PT_MODE.SAW Or PointModeCmBx.SelectedIndex = PT_MODE.LASER Then
' Recupero la posizione macchina
Dim dL1, dL2, dL3, dR1, dR2 As Double
If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then
Return
End If
' Ricavo dati lama corrente
Dim sSaw As String = String.Empty
GetPrivateProfileString(S_MACH_MACH, K_CURRSAW, "", sSaw, m_MainWindow.GetMachIniFile())
' Se punto da laser
If PointModeCmBx.SelectedIndex = PT_MODE.LASER Then
' Imposto come testa corrente il laser (senza utensile ovviamente)
If Not EgtSetCalcTool("", "H3", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP1) Then
Return
End If
' Ora imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Altrimenti da lama
Else
' Imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP1) Then
Return
End If
End If
' Calcolo direzione asse lama
If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtToolP1) Then
Return
End If
' Porto il tip nell'origine tavola
m_ptTipP1.ToLoc(New Frame3d(m_ptTabOri))
m_bPointP1Ok = True
' Recupero il nome degli assi macchina
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
' Visualizzo macchina in posizione
EgtSetAxisPos(sL1, dL1)
EgtSetAxisPos(sL2, dL2)
EgtSetAxisPos(sL3, dL3)
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
' Visualizzo quote
Dim sSawTip As String = "X" & LenToString(m_ptTipP1.x, 0) & " Y" & LenToString(m_ptTipP1.y, 0) &
" Z" & LenToString(m_ptTipP1.z, 0) & " C" & DoubleToString(dR1, 0) &
" B" & DoubleToString(dR2, 0)
'SawTipTxBl.Text = sSawTip
' Assegno angoli
Dim dTLen, dTAngV, dTAngO As Double
m_vtToolP1.ToSpherical(dTLen, dTAngV, dTAngO)
m_dAngO = dTAngO + 90
m_dAngV = 90 - dTAngV
DirectionTxBx.Text = DoubleToString(m_dAngO - m_MainWindow.m_CurrentMachine.dDeltaC, 2)
Else
' Assegno punto selezionato nel disegno a m_ptTipP1
m_ptTipP1 = m_ptPrev
' Porto il tip nell'origine tavola
m_ptTipP1.ToLoc(New Frame3d(m_ptTabOri))
m_bPointP1Ok = True
' Ricavo dati lama corrente
Dim sSaw As String = m_MainWindow.m_CurrentMachine.sCurrSaw
' Imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
'Disegno macchina nella sua posizione reale
Dim dL1, dL2, dL3, dR1, dR2 As Double
m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2)
' Recupero il nome degli assi macchina
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
' Visualizzo macchina in posizione
EgtSetAxisPos(sL1, dL1)
EgtSetAxisPos(sL2, dL2)
EgtSetAxisPos(sL3, dL3)
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
End If
' Disegno il taglio
CreateFlatteringCut()
m_MainWindow.m_DirectCutPageUC.m_bShowMachine = True
EgtSetMachineLook(m_MainWindow.m_DirectCutPageUC.m_nMachLook)
EgtDraw()
' Seleziono il bottone per indicare che il primo punto è stato acquisito
Point1Btn.IsChecked = True
' Abilito e deseleziono secondo punto
Point2Btn.IsEnabled = True
Point2Btn.IsChecked = False
' Annullo secondo punto selezionato
m_bPointP2Ok = False
End Sub
Private Sub Point2Btn_Click(sender As Object, e As RoutedEventArgs) Handles Point2Btn.Click
' Rimuovo eventuali crocette create acquisendo i punti nel disegno
EgtEmptyGroup(m_nTempLay)
' Deseleziono il bottone (poichè si seleziona automaticamente) cos' nel caso ci sia un errore rimane deselezionato
Point2Btn.IsChecked = False
' Reset punto non acquisito
m_bPointP2Ok = False
' Verifico configurazione tavola e grezzo
If Not m_bRawOk Then
Return
End If
' Se acquisizone lama o laser
If PointModeCmBx.SelectedIndex = PT_MODE.SAW Or PointModeCmBx.SelectedIndex = PT_MODE.LASER Then
' Recupero la posizione macchina
Dim dL1, dL2, dL3, dR1, dR2 As Double
If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then
Return
End If
' Ricavo dati lama corrente
Dim sSaw As String = String.Empty
GetPrivateProfileString(S_MACH_MACH, K_CURRSAW, "", sSaw, m_MainWindow.GetMachIniFile())
' Se punto da laser
If PointModeCmBx.SelectedIndex = PT_MODE.LASER Then
' Imposto come testa corrente il laser (senza utensile ovviamente)
If Not EgtSetCalcTool("", "H3", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP2) Then
Return
End If
' Ora imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Altrimenti da lama
Else
' Imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP2) Then
Return
End If
End If
' Calcolo direzione asse lama
If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtToolP2) Then
Return
End If
' Porto il tip nell'origine tavola
m_ptTipP2.ToLoc(New Frame3d(m_ptTabOri))
m_bPointP2Ok = True
' Recupero il nome degli assi macchina
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
' Visualizzo macchina in posizione
EgtSetAxisPos(sL1, dL1)
EgtSetAxisPos(sL2, dL2)
EgtSetAxisPos(sL3, dL3)
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
' Visualizzo quote
Dim sSawTip As String = "X" & LenToString(m_ptTipP2.x, 0) & " Y" & LenToString(m_ptTipP2.y, 0) &
" Z" & LenToString(m_ptTipP2.z, 0) & " C" & DoubleToString(dR1, 0) &
" B" & DoubleToString(dR2, 0)
'SawTipTxBl.Text = sSawTip
' Assegno angolo verticale da direzione utensile
Dim dTLen, dTAngV, dTAngO As Double
m_vtToolP2.ToSpherical(dTLen, dTAngV, dTAngO)
m_dAngV = 90 - dTAngV
Else
' Assegno punto selezionato nel disegno a m_ptTipP2
m_ptTipP2 = m_ptPrev
' Porto il tip nell'origine tavola
m_ptTipP2.ToLoc(New Frame3d(m_ptTabOri))
m_bPointP2Ok = True
' Ricavo dati lama corrente
Dim sSaw As String = m_MainWindow.m_CurrentMachine.sCurrSaw
' Imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
'Disegno macchina nella sua posizione reale
Dim dL1, dL2, dL3, dR1, dR2 As Double
m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2)
' Recupero il nome degli assi macchina
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
' Visualizzo macchina in posizione
EgtSetAxisPos(sL1, dL1)
EgtSetAxisPos(sL2, dL2)
EgtSetAxisPos(sL3, dL3)
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
End If
' Se il secondo punto non coincide con il primo, disegno il taglio
Dim vtDiff As Vector3d = m_ptTipP2 - m_ptTipP1
vtDiff.z = 0
Dim dLen As Double
Dim dAngVertDeg As Double
Dim dAngOrizzDeg As Double
vtDiff.ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg)
If dLen > EPS_SMALL Then
m_dLen = dLen
LenghtTxBx.Text = LenToString(dLen, 1)
m_dAngO = dAngOrizzDeg
DirectionTxBx.Text = DoubleToString(m_dAngO - m_MainWindow.m_CurrentMachine.dDeltaC, 2)
Create2PointsFlatteringCut()
m_MainWindow.m_DirectCutPageUC.m_bShowMachine = True
EgtSetMachineLook(m_MainWindow.m_DirectCutPageUC.m_nMachLook)
EgtDraw()
' Seleziono il bottone per indicare che il secondo punto è stato acquisito
Point2Btn.IsChecked = True
Else
Point1Btn_Click(sender, e)
' Deseleziono il bottone per indicare che il secondo punto non è stato acquisito perchè uguale al primo
Point2Btn.IsChecked = False
End If
End Sub
Private Sub DepthTxBx_EgtClosed(sender As Object, e As EventArgs) Handles DepthTxBx.EgtClosed
' Verifico che l'affondamento impostato non sia superiore a quello massimo
Dim dMaxDepth = m_ptRawMax.z - m_ptRawMin.z + MAX_TAB_DEPTH
Dim dDepth As Double = 0
StringToLen(DepthTxBx.Text, dDepth)
If dDepth < 0 Then
m_dDepth = 0
ElseIf dDepth > dMaxDepth Then
m_dDepth = dMaxDepth
Else
m_dDepth = dDepth
End If
DepthTxBx.Text = LenToString(m_dDepth, 2)
' Disegno il taglio
CreateFlatteringCut()
EgtDraw()
End Sub
Private Sub LenghtTxBx_EgtClosed(sender As Object, e As EventArgs) Handles LenghtTxBx.EgtClosed
' Verifico che la lunghezza del taglio impostata non sia inferiore a quella minima
Dim dLenght As Double = 0
StringToLen(LenghtTxBx.Text, dLenght)
If dLenght < MIN_CUT_LEN Then
m_dLen = MIN_CUT_LEN
Else
m_dLen = dLenght
End If
LenghtTxBx.Text = LenToString(m_dLen, 2)
' Disegno il taglio
CreateFlatteringCut()
EgtDraw()
End Sub
Private Sub WidthTxBx_EgtClosed(sender As Object, e As EventArgs) Handles WidthTxBx.EgtClosed
' Verifico che la larghezza del taglio impostata non sia inferiore a quella minima
Dim dWidth As Double = 0
StringToLen(WidthTxBx.Text, dWidth)
If dWidth < MIN_CUT_WID Then
m_dWid = MIN_CUT_WID
Else
m_dWid = dWidth
End If
WidthTxBx.Text = LenToString(m_dWid, 2)
' Disegno il taglio
CreateFlatteringCut()
EgtDraw()
End Sub
Private Sub DirectionTxBx_EgtClosed(sender As Object, e As EventArgs) Handles DirectionTxBx.EgtClosed
' Assegno il nuovo valore di direzione
Dim dDirection As Double = 0
StringToDouble(DirectionTxBx.Text, dDirection)
dDirection += m_MainWindow.m_CurrentMachine.dDeltaC
m_dAngO = dDirection
' Disegno il taglio
CreateFlatteringCut()
EgtDraw()
End Sub
Private Sub OverlapTxBx_EgtClosed(sender As Object, e As EventArgs) Handles OverlapTxBx.EgtClosed
' Recupero spessore della lama correntemente attiva
Dim dThick As Double = 0
EgtTdbGetCurrToolParam(MCH_TP.THICK, dThick)
' Verifico che la sovrapposizione non sia superiore allo spessore della lama
Dim dOverlap As Double = 0
StringToDouble(OverlapTxBx.Text, dOverlap)
If dOverlap < 0 Then
m_dOverlap = 0
ElseIf dOverlap > dThick Then
m_dOverlap = dThick
Else
m_dOverlap = dOverlap
End If
OverlapTxBx.Text = DoubleToString(m_dOverlap, 2)
' Disegno il taglio
CreateFlatteringCut()
EgtDraw()
End Sub
Private Sub SideChBx_Click(sender As Object, e As EventArgs) Handles SideChBx.Click
' Disegno il taglio
If m_bPointP2Ok Then
Create2PointsFlatteringCut()
Else
CreateFlatteringCut()
End If
EgtDraw()
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
' Verifico ci sia un taglio valido
If Not m_bCutOk Then
Return
End If
' Salvo il progetto con le lavorazioni
Dim sMchPath As String = m_MainWindow.GetTempDir() & "\" & "DirectProj.nge"
m_MainWindow.m_CurrentProjectPageUC.SaveFile(sMchPath)
' Genero file CNC (lancio anche se errore in precedenza)
Dim sCncPath As String = m_MainWindow.GetCncDir() & "\DirectCut.xpi"
Dim bOk As Boolean = EgtGenerate(sCncPath, "OmagCut")
' Se errore in generazione, segnalo l'errore ed esco
If Not bOk Then
m_CurrProjPage.SetErrorMessage(EgtMsg(90314)) 'Errore nella generazione del programma CN
Return
End If
' Download programma (eventuali errori sono segnalati dalla funzione)
If m_MainWindow.m_CNCommunication.SendProgram(sCncPath, 900) Then
' copio il progetto corrente come progetto in lavorazione
Dim sWrkPath As String = m_MainWindow.GetTempDir() & "\" & "WorkProj.nge"
My.Computer.FileSystem.CopyFile(sMchPath, sWrkPath, True)
End If
End Sub
Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click
m_MainWindow.m_DirectCutPageUC.LeftButtonGrid.Children.Remove(Me)
m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut
End Sub
Private Function CreateFlatteringCut() As Boolean
' Verifico sia definito il punto iniziale e il grezzo
If Not m_bPointP1Ok Or Not m_bRawOk Then
m_bCutOk = False
Return False
End If
' Spessore grezzo
Dim dRawHeight As Double = m_ptRawMax.z - m_ptRawMin.z
' Rimuovo eventuale vecchio pezzo per taglio diretto
EraseDirectCutPart()
' Disattivo eventuali lavorazioni presenti
DeactivateAllMachinings()
' Creo nuovo pezzo per il taglio diretto
Dim nPartId = EgtCreateGroup(GDB_ID.ROOT)
EgtSetName(nPartId, DIRECTCUT)
Dim nLayerId = EgtCreateGroup(nPartId)
EgtSetName(nLayerId, "OutLoop")
' Creo il taglio
Dim ptStart As Point3d = m_ptTipP1
ptStart.z = 0
Dim nCutId = EgtCreateLinePDL(nLayerId, ptStart, m_dAngO, m_dLen)
' Imposto affondamento e angolo di fianco sul taglio
EgtSetInfo(nCutId, "Depth", DoubleToString(m_dDepth, 3))
EgtSetInfo(nCutId, "SideAng", DoubleToString(m_dAngV, 3))
' Funzione che crea i tagli successivi al primo
MultiplyCut(nLayerId, nCutId)
' Creo layer per crocetta di riferimento
Dim nCrossLayerId = EgtCreateGroup(nPartId)
' Aggiungo crocetta
CreateCross(nCrossLayerId, ptStart)
' Calcolo punto di inserimento nel grezzo
Dim ptMin, ptMax As Point3d
EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, ptMin, ptMax)
Dim ptIns As Point3d = ptMin + (m_ptTabOri - m_ptRawMin)
ptIns.z = dRawHeight
' Inserisco il pezzo nel grezzo
EgtAddPartToRawPart(nPartId, ptIns, m_MainWindow.m_CurrentProjectPageUC.m_nRawId)
' Inserisco la lavorazione
m_bCutOk = AddMachinings(nPartId, True, True)
UpdateOkBtn()
EgtSaveFile("C:\Temp\qqq.nge", NGE.TEXT)
Return m_bCutOk
End Function
Private Function Create2PointsFlatteringCut() As Boolean
' Verifico siano definiti punto iniziale punto finale e grezzo
If Not m_bPointP1Ok Or Not m_bPointP2Ok Or Not m_bRawOk Then
m_bCutOk = False
Return False
End If
' Spessore grezzo
Dim dRawHeight As Double = m_ptRawMax.z - m_ptRawMin.z
' Rimuovo eventuale vecchio pezzo per taglio diretto
EraseDirectCutPart()
' Disattivo eventuali lavorazioni presenti
DeactivateAllMachinings()
' Creo nuovo pezzo per il taglio diretto
Dim nPartId = EgtCreateGroup(GDB_ID.ROOT)
EgtSetName(nPartId, DIRECTCUT)
' Creo layer di taglio
Dim nLayerId = EgtCreateGroup(nPartId)
EgtSetName(nLayerId, "OutLoop")
' Creo il taglio
Dim ptStart As Point3d = m_ptTipP1
Dim ptEnd As Point3d = m_ptTipP2
ptStart.z = 0
ptEnd.z = 0
Dim nCutId = EgtCreateLine(nLayerId, ptStart, ptEnd)
' Imposto affondamento e angolo di fianco sul taglio
EgtSetInfo(nCutId, "Depth", DoubleToString(m_dDepth, 3))
EgtSetInfo(nCutId, "SideAng", DoubleToString(m_dAngV, 3))
' Funzione che crea i tagli successivi al primo
MultiplyCut(nLayerId, nCutId)
' Creo layer per crocette di riferimento
Dim nCrossLayerId = EgtCreateGroup(nPartId)
' Aggiungo crocette
CreateCross(nCrossLayerId, ptStart)
CreateCross(nCrossLayerId, ptEnd)
' Calcolo punto di inserimento nel grezzo
Dim ptMin, ptMax As Point3d
EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, ptMin, ptMax)
Dim ptIns As Point3d = ptMin + (m_ptTabOri - m_ptRawMin)
ptIns.z = dRawHeight
' Inserisco il pezzo nel grezzo
EgtAddPartToRawPart(nPartId, ptIns, m_MainWindow.m_CurrentProjectPageUC.m_nRawId)
' Inserisco la lavorazione
m_bCutOk = AddMachinings(nPartId, True, True)
UpdateOkBtn()
Return m_bCutOk
End Function
Private Function MultiplyCut(nLayerId As Integer, nCutId As Integer)
' Recupero spessore della lama correntemente attiva
Dim dThick As Double = 0
EgtTdbGetCurrToolParam(MCH_TP.THICK, dThick)
' Imposto angolo di rotazione a seconda del lato dei tagli
Dim dRotAngO As Double = If(SideChBx.IsChecked, -90, 90)
' Definisco vettore di spostamento
Dim vtDelta As Vector3d
vtDelta = Vector3d.FromPolar(1, m_dAngO)
vtDelta.Rotate(Vector3d.Z_AX, dRotAngO)
' Calcolo numero di iterazioni necessarie a coprire l'area impostata e lunghezza vettore delta
Dim nStepNum As Integer
Dim dDelta As Double
Dim dWidth As Double = m_dWid
dDelta = dThick - m_dOverlap
dWidth -= dThick
nStepNum = Math.Ceiling(dWidth / dDelta) + 1
If nStepNum > 1 Then
dDelta = dWidth / (nStepNum - 1)
End If
' Creo vettore delta
vtDelta *= dDelta
For Index As Integer = 1 To nStepNum - 1
Dim vtPerpMove As Vector3d = Index * vtDelta
' Creo copie
Dim nCut2Id = EgtCopyGlob(nCutId, nLayerId)
EgtMove(nCut2Id, vtPerpMove, GDB_RT.GLOB)
Next
Return True
End Function
Private Function EraseDirectCutPart()
' Recupero identificativo del pezzo
Dim nDirPartId As Integer = EgtGetFirstNameInGroup(m_MainWindow.m_CurrentProjectPageUC.m_nRawId, DIRECTCUT)
If nDirPartId = GDB_ID.NULL Then
Return True
End If
' Cancello le lavorazioni
EraseMachinings(nDirPartId)
' Tolgo il pezzo dal grezzo
EgtRemovePartFromRawPart(nDirPartId)
' Cancello il pezzo
EgtErase(nDirPartId)
Return True
End Function
Private Function CreateCross(nLayerId As Integer, ptP As Point3d) As Boolean
' Aggiungo crocette
Dim vtCrossX As New Vector3d(20, 0, 0)
Dim vtCrossY As New Vector3d(0, 20, 0)
Dim nCrossId1 = EgtCreateLine(nLayerId, ptP + (-vtCrossX), ptP + vtCrossX)
EgtSetColor(nCrossId1, New Color3d(255, 0, 0))
Dim nCrossId2 = EgtCreateLine(nLayerId, ptP + (-vtCrossY), ptP + vtCrossY)
EgtSetColor(nCrossId2, New Color3d(255, 0, 0))
Return True
End Function
End Class
+2
View File
@@ -407,6 +407,8 @@ Public Class MultipleCut
Dim dAngOrizzDeg As Double
vtDiff.ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg)
If dLen > EPS_SMALL Then
m_dLen = dLen
m_dAngO = dAngOrizzDeg
LenghtTxBx.Text = LenToString(dLen, 1)
m_dAngO = dAngOrizzDeg
DirectionTxBx.Text = DoubleToString(m_dAngO - m_MainWindow.m_CurrentMachine.dDeltaC, 2)
+7
View File
@@ -156,6 +156,9 @@
<Compile Include="EgtDictionary.xaml.vb">
<DependentUpon>EgtDictionary.xaml</DependentUpon>
</Compile>
<Compile Include="FlatteningCut.xaml.vb">
<DependentUpon>FlatteningCut.xaml</DependentUpon>
</Compile>
<Compile Include="FrameCutPageUC.xaml.vb">
<DependentUpon>FrameCutPageUC.xaml</DependentUpon>
</Compile>
@@ -288,6 +291,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="FlatteningCut.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="FrameCutPageUC.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
+1 -2
View File
@@ -36,8 +36,7 @@
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<Button Name="OkBtn" Grid.Column="1" Style="{StaticResource OmagCut_GradientBlueIconButton}"
IsCancel="True">
<Button Name="OkBtn" Grid.Column="1" Style="{StaticResource OmagCut_GradientBlueIconButton}">
<Image Source="Resources/V.png" Style="{StaticResource OmagCut_ButtonIcon}"/>
</Button>
<Button Name="ExitBtn" Grid.Column="3" Style="{StaticResource OmagCut_GradientBlueIconButton}"
+15 -1
View File
@@ -1,4 +1,6 @@
Imports EgtUILib
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib
Public Class SaveNameWD
@@ -18,12 +20,24 @@ Public Class SaveNameWD
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
' Creo path completa con nome inserito
Dim sPath As String = m_MainWindow.GetSaveNameDir() & "\" & SaveNameTxBx.Text & ".nge"
' Verifico se il nome inserito è già utilizzato
If File.Exists(sPath) Then
Dim ConfirmWD As New EgtMsgBox(m_MainWindow, "", EgtMsg(MSG_EGTMSGBOX + 6), EgtMsgBox.Buttons.OK_CANCEL, EgtMsgBox.Icons.NULL)
Select Case ConfirmWD.DialogResult
Case 0 'Cancel
' Esco
Return
End Select
End If
' Aggiorno file Ini
WritePrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, SaveNameTxBx.Text, m_MainWindow.GetIniFile())
' Eseguo salvataggio
m_MainWindow.m_CurrentProjectPageUC.SaveNameProject()
m_MainWindow.m_CurrentProjectPageUC.SaveProject()
EgtDraw()
Close()
End Sub
End Class