Files
Dario Sassi ab283a3efa OmagCUT 3.1e2 :
- correzioni al polishing (oar si notifica che è un taglio diretto e si controlla meglio l'utensile)
- varie migliorie nei tagli diretti.
2026-05-10 11:12:38 +02:00

1109 lines
49 KiB
VB.net

Imports EgtUILib
Imports System.Collections.ObjectModel
Public Class GridCut
' Riferimenti a pagine
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
Private WithEvents m_CurrProjPage As CurrentProjectPageUC
' Flag di pagina attiva
Private m_bActive As Boolean = False
' Flag di simulazione in corso
Private m_bSimul 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
' Parametri della lavorazione
Private m_bCutOk As Boolean = False
Private m_dDepth As Double = 0
Private m_dAngO As Double = 180
Private m_dAngV As Double = 0
Private m_nNumX As Integer = 0
Private m_dDimX As Double = 0
Private m_nNumY As Integer = 0
Private m_dDimY As Double = 0
Private m_bHeadSide As Boolean = False
' 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 = GDB_ID.NULL
' Gestione spessore lama
Private m_bSawTh As Boolean = False
' Gestione griglia Custom
Dim m_bCustomGrid As Boolean = False
Public m_ListOfCut_X As New ObservableCollection(Of Cut_Axis)
Public m_ListOfCut_Y As New ObservableCollection(Of Cut_Axis)
Friend m_CustomGrid As CustomGridUC
' Costanti
Private Const MAX_TAB_DEPTH As Double = 10.0
Private Const MIN_CUT_LEN As Double = 10.0
Private Const MAX_SIDE_ANG As Double = 60.0
' 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 GridCut_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
' Creo lista modalità di acquisizione punto
m_PointsModeArray(PT_MODE.SAW) = EgtMsg(90224) ' Lama
m_PointsModeArray(PT_MODE.LASER) = EgtMsg(90212) ' Laser
m_PointsModeArray(PT_MODE.DRAW) = EgtMsg(90225) ' Disegno
' la associo alla combobox
PointModeCmBx.ItemsSource = m_PointsModeArray
' assegno messaggi
Point1Btn.ToolTip = EgtMsg(90210) ' Acquisisci P1
Point2Btn.ToolTip = EgtMsg(90211) ' Acquisisci P2
DepthTxBl.Text = EgtMsg(90213) ' Affondamento
DirectionTxBl.Text = EgtMsg(90215) ' Direzione
SideAngleTxBl.Text = EgtMsg(90216) ' Inclinazione
NumPzXTxBl.Text = EgtMsg(90219) ' Numero X
DimPzXTxBl.Text = EgtMsg(90220) ' Dimensioni X
NumPzYTxBl.Text = EgtMsg(90221) ' Numero Y
DimPzYTxBl.Text = EgtMsg(90222) ' Dimensioni Y
SideTxBl.Text = EgtMsg(90223) ' Taglia lato motore
SimulBtn.ToolTip = EgtMsg(90301) ' Simula
OkBtn.ToolTip = EgtMsg(90230) ' Esegui
GridCutTxt.Text = EgtMsg(90264) ' Custom Grid
' Carico i dati dell'ultimo taglio
m_dDepth = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_GRID_DEPTH, m_dDepth, m_MainWindow.GetIniFile())
m_dAngO = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_GRID_ANGH, m_dAngO, m_MainWindow.GetIniFile())
m_dAngV = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_GRID_ANGV, m_dAngV, m_MainWindow.GetIniFile())
m_nNumX = GetPrivateProfileInt(S_DIRECTCUTS, K_DC_GRID_NUMX, m_nNumX, m_MainWindow.GetIniFile())
m_dDimX = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_GRID_DIMX, m_dDimX, m_MainWindow.GetIniFile())
m_nNumY = GetPrivateProfileInt(S_DIRECTCUTS, K_DC_GRID_NUMY, m_nNumY, m_MainWindow.GetIniFile())
m_dDepth = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_GRID_DEPTH, m_dDepth, m_MainWindow.GetIniFile())
m_dAngO = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_GRID_ANGH, m_dAngO, m_MainWindow.GetIniFile())
m_dAngV = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_GRID_ANGV, m_dAngV, m_MainWindow.GetIniFile())
m_nNumX = GetPrivateProfileInt(S_DIRECTCUTS, K_DC_GRID_NUMX, m_nNumX, m_MainWindow.GetIniFile())
m_dDimX = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_GRID_DIMX, m_dDimX, m_MainWindow.GetIniFile())
m_nNumY = GetPrivateProfileInt(S_DIRECTCUTS, K_DC_GRID_NUMY, m_nNumY, m_MainWindow.GetIniFile())
m_dDimY = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_GRID_DIMY, m_dDimY, m_MainWindow.GetIniFile())
' Carico i dati per i tagli di griglia Custom
m_bCustomGrid = (GetPrivateProfileInt(S_DIRECTCUTS, K_ENABLECUSTOMGRID, 0, m_MainWindow.GetIniFile()) <> 0)
If m_bCustomGrid Then
LoadCustomData(K_GRIDNUMDIMXCUSTOM, m_ListOfCut_X)
LoadCustomData(K_GRIDNUMDIMYCUSTOM, m_ListOfCut_Y)
End If
' --- INIZIO GESTIONE SPECIALE --- per macchina sinistrorsa
m_bSawTh = (GetPrivateProfileInt(S_DIRECTCUTS, K_DC_SING_SAWTH, 0, m_MainWindow.GetIniFile()) <> 0)
' --- FINE GESTIONE SPECIALE --- per macchina sinistrorsa
m_bHeadSide = (GetPrivateProfileInt(S_DIRECTCUTS, K_DC_GRID_HEADSIDE, 0, m_MainWindow.GetIniFile()) <> 0)
m_ptTipP1.x = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_GRID_POSX, m_ptTipP1.x, m_MainWindow.GetIniFile())
m_ptTipP1.y = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_GRID_POSY, m_ptTipP1.y, m_MainWindow.GetIniFile())
End Sub
' Lettura dei dati della griglia Custom
Private Sub LoadCustomData(sIpKeyName As String, LocalList As ObservableCollection(Of Cut_Axis))
Dim dVal As Double = 0
Dim nVal As Integer = 0
Dim sVal As String = String.Empty
GetPrivateProfileString(S_DIRECTCUTS, sIpKeyName, sVal, sVal, m_MainWindow.GetIniFile())
Dim sItems As String() = sVal.Split(";"c)
If sItems.Count > 0 Then
For Each Item As String In sItems
Dim sSubItems As String() = Item.Split(",")
If sSubItems.Count = 2 Then
If IsNumeric(sSubItems(0)) And IsNumeric(sSubItems(1)) Then
nVal = CInt(sSubItems(0))
StringToDouble(sSubItems(1), dVal)
LocalList.Add(New Cut_Axis(nVal, dVal))
End If
End If
Next
End If
End Sub
Private Sub GridCut_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
' Attivo la pagina
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
m_bActive = True
' Se rientro da simulazione
If m_bSimul Then
m_bSimul = False
' Disabilito registrazione progetto modificato
EgtDisableModified()
' Aggiorno visualizzazione
SetMachineInCurrPos()
m_MainWindow.m_DirectCutPageUC.m_bShowMachine = True
EgtSetMachineLook(m_MainWindow.m_DirectCutPageUC.m_nMachLook)
EgtDraw()
Return
End If
' Disabilito registrazione progetto modificato
EgtDisableModified()
' Creo layer temporaneo per crocette
m_nTempLay = EgtCreateGroup(GDB_ID.ROOT)
EgtSetLevel(m_nTempLay, GDB_LV.TEMP)
' 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 punto acquisito
m_bPointP1Ok = False
m_bPointP2Ok = False
' Inizializzo primo punto acquisito dal disegno
m_ptPrev = m_ptTipP1 + (m_ptTabOri - Point3d.ORIG())
m_ptPrev = m_ptTipP1 + (m_ptTabOri - Point3d.ORIG())
m_ptPrev.z = m_ptRawMax.z
' Disegno crocetta che indica il punto acquisito
CreateCross(m_nTempLay, m_ptPrev)
' Imposto modalità di acquisizione punti
PointModeCmBx.SelectedIndex = PT_MODE.DRAW
SetCoordVisibility(True)
ShowCoord()
' Assegno parametri di lavorazione
DepthTxBx.Text = LenToString(m_dDepth, 1)
DirectionTxBx.Text = DoubleToString(m_dAngO - m_MainWindow.m_CurrentMachine.dDeltaC, 2)
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
DepthTxBx.Text = LenToString(m_dDepth, 1)
DirectionTxBx.Text = DoubleToString(m_dAngO - m_MainWindow.m_CurrentMachine.dDeltaC, 2)
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
NumPzXTxBx.Text = m_nNumX.ToString()
DimPzXTxBx.Text = LenToString(m_dDimX, 1)
DimPzXTxBx.Text = LenToString(m_dDimX, 1)
NumPzYTxBx.Text = m_nNumY.ToString()
DimPzYTxBx.Text = LenToString(m_dDimY, 1)
DimPzYTxBx.Text = LenToString(m_dDimY, 1)
SideChBx.IsChecked = m_bHeadSide
' --- INIZIO GESTIONE SPECIALE --- per macchina sinistrorsa
m_bSawTh = (GetPrivateProfileInt(S_DIRECTCUTS, K_DC_SING_SAWTH, 0, m_MainWindow.GetIniFile()) <> 0)
' --- FINE GESTIONE SPECIALE --- per macchina sinistrorsa
' Reset taglio e disabilito bottone esecuzione
m_bCutOk = False
UpdateSimulOkBtn()
' Disabilito bottone secondo punto
Point2Btn.IsEnabled = False
' Deseleziono bottone primo punto
Point1Btn.IsChecked = False
' Aggiorno visualizzazione
EgtDraw()
If m_bCustomGrid Then
StandardGrid.Visibility = Visibility.Hidden
CustomGridBtn.Visibility = Visibility.Visible
m_CustomGrid = New CustomGridUC(Me)
'CustomGrid.Visibility = Visibility.Visible
'Cut_XTgBtn.IsChecked = True
'CustomGridLstBx.ItemsSource = m_ListOfCut_X
Else
StandardGrid.Visibility = Visibility.Visible
CustomGridBtn.Visibility = Visibility.Hidden
'CustomGrid.Visibility = Visibility.Hidden
End If
End Sub
Friend Sub GridCut_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded
' Salvo i dati correnti
WritePrivateProfileString(S_DIRECTCUTS, K_DC_GRID_DEPTH, DoubleToString(m_dDepth, 2), m_MainWindow.GetIniFile())
WritePrivateProfileString(S_DIRECTCUTS, K_DC_GRID_ANGH, DoubleToString(m_dAngO, 2), m_MainWindow.GetIniFile())
WritePrivateProfileString(S_DIRECTCUTS, K_DC_GRID_ANGV, DoubleToString(m_dAngV, 2), m_MainWindow.GetIniFile())
WritePrivateProfileString(S_DIRECTCUTS, K_DC_GRID_NUMX, m_nNumX.ToString(), m_MainWindow.GetIniFile())
WritePrivateProfileString(S_DIRECTCUTS, K_DC_GRID_DIMX, DoubleToString(m_dDimX, 2), m_MainWindow.GetIniFile())
WritePrivateProfileString(S_DIRECTCUTS, K_DC_GRID_NUMY, m_nNumY.ToString(), m_MainWindow.GetIniFile())
WritePrivateProfileString(S_DIRECTCUTS, K_DC_GRID_DIMY, DoubleToString(m_dDimY, 2), m_MainWindow.GetIniFile())
WritePrivateProfileString(S_DIRECTCUTS, K_DC_GRID_HEADSIDE, If(m_bHeadSide, "1", "0"), m_MainWindow.GetIniFile())
WritePrivateProfileString(S_DIRECTCUTS, K_DC_GRID_POSX, DoubleToString(m_ptTipP1.x, 2), m_MainWindow.GetIniFile())
WritePrivateProfileString(S_DIRECTCUTS, K_DC_GRID_POSY, DoubleToString(m_ptTipP1.y, 2), m_MainWindow.GetIniFile())
If m_bCustomGrid Then
Dim sGridNumDimXCustom As String = ""
For Index_X As Integer = 0 To m_ListOfCut_X.Count - 1
sGridNumDimXCustom &= m_ListOfCut_X(Index_X).sNumber & "," & DoubleToString(m_ListOfCut_X(Index_X).dInteraxis, 2) & ";"
Next
If sGridNumDimXCustom <> "" Then sGridNumDimXCustom = sGridNumDimXCustom.Remove(sGridNumDimXCustom.Count - 1)
WritePrivateProfileString(S_DIRECTCUTS, "GridNumDimXCustom", sGridNumDimXCustom, m_MainWindow.GetIniFile())
Dim sGridNumDimYCustom As String = ""
For Index_Y As Integer = 0 To m_ListOfCut_Y.Count - 1
sGridNumDimYCustom &= m_ListOfCut_Y(Index_Y).sNumber & "," & DoubleToString(m_ListOfCut_Y(Index_Y).dInteraxis, 2) & ";"
Next
If sGridNumDimYCustom <> "" Then sGridNumDimYCustom = sGridNumDimYCustom.Remove(sGridNumDimYCustom.Count - 1)
WritePrivateProfileString(S_DIRECTCUTS, "GridNumDimYCustom", sGridNumDimYCustom, m_MainWindow.GetIniFile())
End If
' Se non vado in simulazione
If Not m_bSimul Then
' Dichiaro sottopagina da non riattivare
m_MainWindow.m_DirectCutPageUC.m_ControlsDirectCutUC.m_ActiveDirectCutPage = ControlsDirectCutUC.DirectCutPages.DirectCut
' Rimuovo layer temporaneo per crocette
EgtErase(m_nTempLay)
' Rimuovo eventuale pezzo per taglio diretto
EraseDirectCutPart()
' Riattivo eventuali lavorazioni presenti
ActivateAllMachinings()
EgtSetCurrPhase(1)
' Abilito registrazione progetto modificato
EgtEnableModified()
' Nascondo la macchina
m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False
EgtSetMachineLook(MCH_LOOK.TAB)
EgtDraw()
End If
' Dichiaro pagina non attiva
m_bActive = False
End Sub
Public Sub SetEnableParam(ByVal bIsSaw As Boolean)
' se macchina solo WaterJet Disabilito/Nascondo parametri della lama
DepthTxBx.IsEnabled = bIsSaw
End Sub
Private Sub UpdateSimulOkBtn()
If m_bCutOk Then
SimulBtn.IsEnabled = True
SimulBtn.Foreground = Brushes.Black
OkBtn.IsEnabled = True
OkBtn.Foreground = Brushes.Black
Else
SimulBtn.IsEnabled = False
SimulBtn.Foreground = Brushes.DarkGray
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
' 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
' Visualizzo coordinate (rispetto a 0 tavola)
ShowCoord()
' Disegno crocetta che indica il punto acquisito
CreateCross(m_nTempLay, m_ptPrev)
EgtDraw()
End Sub
Private Sub PointModeCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles PointModeCmBx.SelectionChanged
SetCoordVisibility(PointModeCmBx.SelectedIndex = PT_MODE.DRAW)
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
' forzo utilizzo testa H1 solo per macchina con 2 teste
Dim bIsMultiCut As Boolean = (EgtGetHeadId("H101") <> GDB_ID.NULL)
If bIsMultiCut Then
m_MainWindow.m_DirectCutPageUC.ReloadParam()
End If
' Recupero dati utensile e testa corrente
Dim sTool As String = ""
Dim sHead As String = ""
Dim nExit As Integer = 0
EgtGetCalcTool(sTool, sHead, nExit)
' 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
' Se macchina multicut il primo asse rotante restituito è quello della tavola
Dim vAng() As Double = {dR1, dR2, 0}
If bIsMultiCut Then
vAng(0) = 0
vAng(1) = dR1
vAng(2) = dR2
End If
' Ricavo dati lama corrente
Dim sSaw As String = m_MainWindow.m_CurrentMachine.sCurrSaw
' 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
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, vAng, True, m_ptTipP1) Then Return
' Reimposto eventuale precedente utensile
EgtSetCalcTool(sTool, sHead, nExit)
' Altrimenti da lama
Else
' Reimposto eventuale precedente utensile
EgtSetCalcTool(sTool, sHead, nExit)
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, vAng, True, m_ptTipP1) Then Return
End If
' Calcolo direzione asse lama
If Not EgtGetCalcToolDirFromAngles(vAng, m_vtToolP1) Then Return
' Porto il tip nell'origine tavola
m_ptTipP1.ToLoc(New Frame3d(m_ptTabOri))
m_bPointP1Ok = True
' 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)
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
' Altrimenti punto da click di mouse
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
' Reimposto eventuale precedente utensile
EgtSetCalcTool(sTool, sHead, nExit)
End If
' Disegno il taglio
CreateGridCut()
' Disegno la macchina nella sua posizione reale
SetMachineInCurrPos()
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
' forzo utilizzo testa H1 solo per macchina con 2 teste
Dim bIsMultiCut As Boolean = (EgtGetHeadId("H101") <> GDB_ID.NULL)
If bIsMultiCut Then
m_MainWindow.m_DirectCutPageUC.ReloadParam()
End If
' Recupero dati utensile e testa corrente
Dim sTool As String = ""
Dim sHead As String = ""
Dim nExit As Integer = 0
EgtGetCalcTool(sTool, sHead, nExit)
' 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
' Se macchina multicut il primo asse rotante restituito è quello della tavola
Dim vAng() As Double = {dR1, dR2, 0}
If bIsMultiCut Then
vAng(0) = 0
vAng(1) = dR1
vAng(2) = dR2
End If
' Ricavo dati lama corrente
Dim sSaw As String = m_MainWindow.m_CurrentMachine.sCurrSaw
' 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
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, vAng, True, m_ptTipP2) Then Return
' Reimposto eventuale precedente utensile
EgtSetCalcTool(sTool, sHead, nExit)
' Altrimenti da lama
Else
' Reimposto eventuale precedente utensile
EgtSetCalcTool(sTool, sHead, nExit)
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, vAng, True, m_ptTipP2) Then Return
End If
' Calcolo direzione asse lama
If Not EgtGetCalcToolDirFromAngles(vAng, m_vtToolP2) Then Return
' Porto il tip nell'origine tavola
m_ptTipP2.ToLoc(New Frame3d(m_ptTabOri))
m_bPointP2Ok = True
' Assegno angolo verticale da direzione utensile
Dim dTLen, dTAngV, dTAngO As Double
m_vtToolP2.ToSpherical(dTLen, dTAngV, dTAngO)
m_dAngV = 90 - dTAngV
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
' Altrimenti punto da click di mouse
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
' Reimposto eventuale precedente utensile
EgtSetCalcTool(sTool, sHead, nExit)
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_dAngO = dAngOrizzDeg
DirectionTxBx.Text = DoubleToString(m_dAngO - m_MainWindow.m_CurrentMachine.dDeltaC, 2)
CreateGridCut()
' Disegno la macchina nella sua posizione reale
SetMachineInCurrPos()
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 + m_MainWindow.m_CurrentMachine.MaxTabDepth
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
CreateGridCut()
SetMachineInCurrPos()
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
' Dichiaro non più usato P2
m_bPointP2Ok = False
Point2Btn.IsChecked = False
' Disegno il taglio
CreateGridCut()
SetMachineInCurrPos()
EgtDraw()
End Sub
Private Sub SideAngleTxBx_EgtClosed(sender As Object, e As EventArgs) Handles SideAngleTxBx.EgtClosed
' Verifico che l'inclinazione del taglio impostata non sia superiore a quella massima
Dim dSideAngle As Double = 0
StringToDouble(SideAngleTxBx.Text, dSideAngle)
If dSideAngle < 0 Then
m_dAngV = 0
ElseIf dSideAngle > MAX_SIDE_ANG Then
m_dAngV = MAX_SIDE_ANG
Else
m_dAngV = dSideAngle
End If
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
' Disegno il taglio
CreateGridCut()
SetMachineInCurrPos()
EgtDraw()
End Sub
Private Sub XcoordTxBx_EgtClosed(sender As Object, e As EventArgs) Handles XcoordTxBx.EgtClosed
' Recupero il valore della coordinata (in 0 Tab)
Dim dXcoord As Double = 0
StringToLen(XcoordTxBx.Text, dXcoord)
XcoordTxBx.Text = LenToString(dXcoord, 2)
' lo assegno al punto corrente (in 0 Macc)
m_ptPrev.x = dXcoord + m_ptTabOri.x
' Rimuovo eventuali crocette create acquisendo i punti nel disegno
EgtEmptyGroup(m_nTempLay)
' Disegno crocetta che indica il punto acquisito
CreateCross(m_nTempLay, m_ptPrev)
EgtDraw()
End Sub
Private Sub YcoordTxBx_EgtClosed(sender As Object, e As EventArgs) Handles YcoordTxBx.EgtClosed
' Recupero il valore della coordinata (in 0 Tab)
Dim dYcoord As Double = 0
StringToLen(YcoordTxBx.Text, dYcoord)
YcoordTxBx.Text = LenToString(dYcoord, 2)
' lo assegno al punto corrente (in 0 Macc)
m_ptPrev.y = dYcoord + m_ptTabOri.y
' Rimuovo eventuali crocette create acquisendo i punti nel disegno
EgtEmptyGroup(m_nTempLay)
' Disegno crocetta che indica il punto acquisito
CreateCross(m_nTempLay, m_ptPrev)
EgtDraw()
End Sub
Private Sub CustomGridBtn_Click(sender As Object, e As RoutedEventArgs) Handles CustomGridBtn.Click
m_CustomGrid.SetValue(Grid.RowProperty, 1)
m_CustomGrid.SetValue(Grid.RowSpanProperty, 6)
m_CustomGrid.SetValue(Grid.ColumnSpanProperty, 2)
SingleCutGrid.Children.Add(m_CustomGrid)
End Sub
'#Region "CUSTOM LIST GRID"
' Private Sub CutX_Selected() Handles Cut_XTgBtn.Click
' If Cut_XTgBtn.IsChecked Then
' Cut_YTgBtn.IsChecked = False
' CustomGridLstBx.ItemsSource = m_ListOfCut_X
' CustomGridLstBx.UpdateLayout()
' End If
' End Sub
' Private Sub CutY_Selected() Handles Cut_YTgBtn.Click
' If Cut_YTgBtn.IsChecked Then
' Cut_XTgBtn.IsChecked = False
' CustomGridLstBx.ItemsSource = m_ListOfCut_Y
' CustomGridLstBx.UpdateLayout()
' End If
' End Sub
' Private Sub AddCut_Click(sender As Object, e As EventArgs) Handles AddCutBtn.Click
' If Cut_XTgBtn.IsChecked Then
' m_ListOfCut_X.Add(New Cut_Axis(0, 0))
' ElseIf Cut_YTgBtn.IsChecked Then
' m_ListOfCut_Y.Add(New Cut_Axis(0, 0))
' End If
' CustomGridLstBx.UpdateLayout()
' End Sub
' Private Sub RemoveCut_Click(sender As Object, e As EventArgs) Handles RemoveCutBtn.Click
' Dim CurrIndexListSelected As Integer = -1
' CurrIndexListSelected = CustomGridLstBx.SelectedIndex
' If Cut_XTgBtn.IsChecked Then
' If CurrIndexListSelected < 0 Or CurrIndexListSelected > m_ListOfCut_X.Count - 1 Then
' CurrIndexListSelected = m_ListOfCut_X.Count - 1
' End If
' m_ListOfCut_X.RemoveAt(CurrIndexListSelected)
' ElseIf Cut_YTgBtn.IsChecked Then
' If CurrIndexListSelected < 0 Or CurrIndexListSelected > m_ListOfCut_Y.Count - 1 Then
' CurrIndexListSelected = m_ListOfCut_Y.Count - 1
' End If
' m_ListOfCut_Y.RemoveAt(CurrIndexListSelected)
' End If
' CustomGridLstBx.UpdateLayout()
' End Sub
' Public Sub Update_Click() Handles UpdateBtn.Click
' CreateGridCut()
' EgtDraw()
' End Sub
'#End Region ' Custom Grid
Private Sub SimulBtn_Click(sender As Object, e As RoutedEventArgs) Handles SimulBtn.Click
' Verifico ci sia un taglio valido
If Not m_bCutOk Then Return
' Salvo il progetto con le lavorazioni
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
Dim sMchPath As String = m_MainWindow.GetTempDir() & "\" & "DirectProj.nge"
m_MainWindow.m_CurrentProjectPageUC.SaveFile(sMchPath, False)
' Predispongo passaggio a simulazione
m_bSimul = True
m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False
m_CurrProjPage.CurrProjGrid.Visibility = Windows.Visibility.Hidden
m_MainWindow.m_DirectCutPageUC.m_ControlsDirectCutUC.LeftButtonGrid.Children.Remove(Me)
m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_DirectCutPageUC)
m_MainWindow.m_PrevActivePage = MainWindow.Pages.DirectCut
m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_SimulationPage)
m_MainWindow.m_ActivePage = MainWindow.Pages.Simulation
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
#If TRIAL Then
m_CurrProjPage.SetWarningMessage("Trial Version")
#Else
' Verifico non sia versione Ufficio
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.OFFICE_TYPE) Then
m_CurrProjPage.SetWarningMessage("Office Version")
Return
End If
' Verifico ci sia un taglio valido
If Not m_bCutOk Then Return
' Salvo il progetto con le lavorazioni
Dim sMchPath As String = m_MainWindow.GetTempDir() & "\" & "DirectProj.nge"
m_MainWindow.m_CurrentProjectPageUC.SaveFile(sMchPath, False)
' Genero file CNC (lancio anche se errore in precedenza)
Dim sCncPath As String = m_MainWindow.GetCncDir() & "\DirectCut" & m_MainWindow.m_CurrentMachine.sIsoFileExt
Dim bOk As Boolean = EgtGenerate(sCncPath, "OmagCut ver." & m_MainWindow.GetVersion())
' 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
Dim sNameProg As Integer = 900
sNameProg = GetPrivateProfileInt(S_PARTPROGRAM, "NameProg", sNameProg, m_MainWindow.GetMachIniFile)
' Download programma (eventuali errori sono segnalati dalla funzione)
If m_MainWindow.m_CNCommunication.SendProgram(sCncPath, sNameProg) 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)
' lancio eventuale lua post-trasmissione
m_MainWindow.ExecSentProgScript(True)
End If
#End If
End Sub
Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click
m_MainWindow.m_DirectCutPageUC.m_ControlsDirectCutUC.LeftButtonGrid.Children.Remove(Me)
End Sub
Friend Function CreateGridCut() 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 As Integer = CreateDirectCutPart()
Dim nLayerId As Integer = EgtCreateGroup(nPartId)
EgtSetName(nLayerId, NAME_OUTLOOP)
' Creo il taglio parallelo alla lama
Dim ptStart As Point3d = m_ptTipP1
ptStart.z = 0
' Funzione che crea i tagli successivi al primo
MultiplyCut(nLayerId)
' Creo layer per crocetta di riferimento
Dim nCrossLayerId = EgtCreateGroup(nPartId)
' Aggiungo crocetta/e
If m_bPointP1Ok Then
CreateCross(nCrossLayerId, ptStart)
End If
If m_bPointP2Ok Then
Dim ptEnd As Point3d = m_ptTipP2
ptEnd.z = 0
CreateCross(nCrossLayerId, ptEnd)
End If
' 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) AndAlso UpdateAllMachiningsToolpaths()
EgtSetCurrPhase(1)
' Eventuale eliminazione Home finale
If Not m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome Then
RemoveFinalHome()
End If
' Se richiesta gestione tagli finali
OrderFinalSawCuts()
' Aggiorno stato bottoni
UpdateSimulOkBtn()
Return m_bCutOk
End Function
Private Function OrderFinalSawCuts() As Boolean
' Se gestione tagli finali non richiesta, esco
If Not m_MainWindow.m_CurrentMachine.bEnableFinalSawCut Then Return False
' Sposto i tagli finali alla fine, conservando l'ordine relativo
Dim nFirstMovedId As Integer = GDB_ID.NULL
Dim nRefId As Integer = EgtGetLastActiveOperation()
Dim nOpeId As Integer = EgtGetFirstActiveOperation()
While nOpeId <> GDB_ID.NULL
If nOpeId = nFirstMovedId Then Exit While
Dim nNextOpeId As Integer = EgtGetNextActiveOperation( nOpeId)
If EgtGetOperationType( nOpeId) = MCH_OY.SAWING Then
Dim bFinalCut As Boolean = False
IF EgtGetInfo( nOpeId, "FinalCut", bFinalCut) AndAlso bFinalCut Then
EgtRelocateGlob( nOpeId, nRefId, GDB_POS.AFTER)
nRefId = nOpeId
If nFirstMovedId = GDB_ID.NULL Then nFirstMovedId = nOpeId
End If
End If
nOpeId = nNextOpeId
End While
' Esco
Return True
End Function
Private Function MultiplyCut(nLayerId As Integer) As Boolean
If m_bCustomGrid Then
Return MultiplyCut_1(nLayerId)
End If
Return MultiplyCut_0(nLayerId)
End Function
Private Function MultiplyCut_0(nLayerId As Integer) As Boolean
' Recupero lo spessore del taglio della lama o del waterjet correntemente attiva
Dim nType As Integer = 0
EgtTdbGetCurrToolParam(MCH_TP.TYPE, nType)
Dim dThick As Double = 0
EgtTdbGetCurrToolParam(If(nType = MCH_TY.SAW_STD, MCH_TP.THICK, MCH_TP.DIAM), dThick)
' Ricalcolo lo spessore in base all'inclinazione
dThick = dThick / Math.Cos(m_dAngV * Math.PI / 180)
' Imposto angolo di rotazione a seconda del lato dei tagli paralleli
Dim dRotAngOX As Double = If(SideChBx.IsChecked(), -90, 90)
' Recupero dati da interfaccia
Dim dDimPzX As Double = 0
Dim nNumPzX As Integer = 0
StringToLen(DimPzXTxBx.Text, dDimPzX)
StringToInt(NumPzXTxBx.Text, nNumPzX)
Dim dDimPzY As Double = 0
Dim nNumPzY As Integer = 0
StringToLen(DimPzYTxBx.Text, dDimPzY)
StringToInt(NumPzYTxBx.Text, nNumPzY)
' Definisco vettore di spostamento
Dim vtDelta As Vector3d
' Calcolo primo taglio parallelo
Dim ptStart As Point3d = m_ptTipP1
ptStart.z = 0
If dDimPzY <> 0 And nNumPzY > 0 And dDimPzX <> 0 And nNumPzX > 0 Then
Dim dLenX As Double = dThick + (dDimPzX + dThick) * nNumPzX
Dim nCutParaId = EgtCreateLinePDL(nLayerId, ptStart, m_dAngO, dLenX + 0.1)
' Inidico che è un taglio Diretto di tipo GridCut
EgtSetInfo(nCutParaId, INFO_DIRECTCUT, MainWindow.FlagDirectCuts.GridCut)
' --- INIZIO GESTIONE SPECIALE --- per macchina sinistrorsa
' Recupero spessore lama corrente
Dim sSawing As String = m_MainWindow.m_CurrentMachine.sCurrSawing
If m_bSawTh And Not String.IsNullOrEmpty(sSawing) Then
EgtOffsetCurve(nCutParaId, -dThick, OFF_TYPE.EXTEND)
End If
' --- FINE GESTIONE SPECIALE --- per macchina sinistrorsa
' Imposto affondamento e angolo di fianco sul taglio
EgtSetInfo(nCutParaId, INFO_DEPTH, m_dDepth)
EgtSetInfo(nCutParaId, INFO_SIDE_ANGLE, m_dAngV)
' Calcolo vettore di spostamento
vtDelta = Vector3d.FromPolar((dDimPzY + dThick), m_dAngO)
' Ruoto il vettore di traslazione
vtDelta.Rotate(Vector3d.Z_AX, dRotAngOX)
For Index As Integer = 1 To nNumPzY
Dim vtPerpMove As Vector3d = Index * vtDelta
' Creo copie
Dim nCut2Id = EgtCopyGlob(nCutParaId, nLayerId)
EgtMove(nCut2Id, vtPerpMove, GDB_RT.GLOB)
Next
' Calcolo primo taglio perpendicolare
Dim dLenY As Double = dThick + (dDimPzY + dThick) * nNumPzY
' Arretro il punto di partenza di uno spessore lama
Dim vtDeltaPos As Vector3d = Vector3d.FromPolar(dThick + 0.1, m_dAngO - 90)
Dim nCutPerpId = EgtCreateLinePDL(nLayerId, ptStart + vtDeltaPos, m_dAngO + 90, dLenY + 0.2)
' Inidico che è un taglio Diretto di tipo GridCut
EgtSetInfo(nCutPerpId, INFO_DIRECTCUT, MainWindow.FlagDirectCuts.GridCut)
' --- INIZIO GESTIONE SPECIALE --- per macchina sinistrorsa
If m_bSawTh And Not String.IsNullOrEmpty(sSawing) Then
EgtOffsetCurve(nCutPerpId, -dThick, OFF_TYPE.EXTEND)
End If
' --- FINE GESTIONE SPECIALE --- per macchina sinistrorsa
' Specchio se è attivo il flag che cambia lato di disegno
If SideChBx.IsChecked() Then
Dim vtRot As Vector3d = Vector3d.FromPolar(1, m_dAngO + 90)
EgtMirror(nCutPerpId, ptStart + Vector3d.FromPolar(dThick / 2, m_dAngO - 90), vtRot, GDB_RT.GLOB)
EgtInvertCurve(nCutPerpId)
End If
' Imposto affondamento e angolo di fianco sul taglio
EgtSetInfo(nCutPerpId, INFO_DEPTH, m_dDepth)
EgtSetInfo(nCutPerpId, INFO_SIDE_ANGLE, m_dAngV)
' Calcolo secondo vettore di spostamento
vtDelta = Vector3d.FromPolar((dDimPzX + dThick), m_dAngO)
For Index As Integer = 1 To nNumPzX
Dim vtPerpMove As Vector3d = vtDelta * Index
' Creo copie
Dim nCut3Id = EgtCopyGlob(nCutPerpId, nLayerId)
EgtMove(nCut3Id, vtPerpMove, GDB_RT.GLOB)
Next
End If
Return True
End Function
Private Function MultiplyCut_1(nLayerId As Integer) As Boolean
' Recupero lo spessore del taglio della lama o del waterjet correntemente attiva
Dim nType As Integer = 0
EgtTdbGetCurrToolParam(MCH_TP.TYPE, nType)
Dim dThick As Double = 0
EgtTdbGetCurrToolParam(If(nType = MCH_TY.SAW_STD, MCH_TP.THICK, MCH_TP.DIAM), dThick)
' Ricalcolo lo spessore in base all'inclinazione
dThick = dThick / Math.Cos(m_dAngV * Math.PI / 180)
' Imposto angolo di rotazione a seconda del lato dei tagli paralleli
Dim dRotAngOX As Double = If(SideChBx.IsChecked(), -90, 90)
' Recupero dati da interfaccia
Dim dDimPzX As Double = If(m_ListOfCut_X.Count = 0, 0.0, m_ListOfCut_X(0).dInteraxis)
Dim nNumPzX As Integer = If(m_ListOfCut_X.Count = 0, 0, m_ListOfCut_X(0).nNumber)
Dim dDimPzY As Double = If(m_ListOfCut_Y.Count = 0, 0.0, m_ListOfCut_Y(0).dInteraxis)
Dim nNumPzY As Integer = If(m_ListOfCut_Y.Count = 0, 0, m_ListOfCut_Y(0).nNumber)
Dim TotLenX As Double = 0
For Ind_X As Integer = 0 To m_ListOfCut_X.Count - 1
TotLenX = TotLenX + (m_ListOfCut_X(Ind_X).dInteraxis + dThick) * m_ListOfCut_X(Ind_X).nNumber
Next
Dim TotLenY As Double = 0
For Ind_Y As Integer = 0 To m_ListOfCut_Y.Count - 1
TotLenY = TotLenY + (m_ListOfCut_Y(Ind_Y).dInteraxis + dThick) * m_ListOfCut_Y(Ind_Y).nNumber
Next
' Definisco vettore di spostamento
Dim vtDelta As Vector3d
' Calcolo primo taglio parallelo
Dim ptStart As Point3d = m_ptTipP1
ptStart.z = 0
If dDimPzY <> 0 And nNumPzY > 0 And dDimPzX <> 0 And nNumPzX > 0 Then
' -------------- TAGLI PARALLELI ASSE Y --------------
Dim dLenX As Double = dThick + TotLenX
Dim nCutParaId = EgtCreateLinePDL(nLayerId, ptStart, m_dAngO, dLenX + 0.1)
' --- INIZIO GESTIONE SPECIALE --- per macchina sinistrorsa
' Recupero spessore lama corrente
Dim sSawing As String = m_MainWindow.m_CurrentMachine.sCurrSawing
If m_bSawTh And Not String.IsNullOrEmpty(sSawing) Then
EgtOffsetCurve(nCutParaId, -dThick, OFF_TYPE.EXTEND)
End If
' --- FINE GESTIONE SPECIALE --- per macchina sinistrorsa
' Imposto affondamento e angolo di fianco sul taglio
EgtSetInfo(nCutParaId, INFO_DEPTH, m_dDepth)
EgtSetInfo(nCutParaId, INFO_SIDE_ANGLE, m_dAngV)
For IndexList_Y As Integer = 0 To m_ListOfCut_Y.Count - 1
Dim nCut2Id As Integer = GDB_ID.NULL
dDimPzY = m_ListOfCut_Y(IndexList_Y).dInteraxis
nNumPzY = m_ListOfCut_Y(IndexList_Y).nNumber
' Calcolo vettore di spostamento
vtDelta = Vector3d.FromPolar((dDimPzY + dThick), m_dAngO)
' Ruoto il vettore di traslazione
vtDelta.Rotate(Vector3d.Z_AX, dRotAngOX)
For Index As Integer = 1 To nNumPzY
Dim vtPerpMove As Vector3d = Index * vtDelta
' Creo copie
nCut2Id = EgtCopyGlob(nCutParaId, nLayerId)
EgtMove(nCut2Id, vtPerpMove, GDB_RT.GLOB)
Next
nCutParaId = nCut2Id
Next
' -------------- TAGLI PARALLELI ASSE X --------------
' Calcolo primo taglio perpendicolare
Dim dLenY As Double = dThick + TotLenY
' Arretro il punto di partenza di uno spessore lama
Dim vtDeltaPos As Vector3d = Vector3d.FromPolar(dThick + 0.1, m_dAngO - 90)
Dim nCutPerpId = EgtCreateLinePDL(nLayerId, ptStart + vtDeltaPos, m_dAngO + 90, dLenY + 0.2)
' --- INIZIO GESTIONE SPECIALE --- per macchina sinistrorsa
If m_bSawTh And Not String.IsNullOrEmpty(sSawing) Then
EgtOffsetCurve(nCutPerpId, -dThick, OFF_TYPE.EXTEND)
End If
' --- FINE GESTIONE SPECIALE --- per macchina sinistrorsa
' Specchio se è attivo il flag che cambia lato di disegno
If SideChBx.IsChecked() Then
Dim vtRot As Vector3d = Vector3d.FromPolar(1, m_dAngO + 90)
EgtMirror(nCutPerpId, ptStart + Vector3d.FromPolar(dThick / 2, m_dAngO - 90), vtRot, GDB_RT.GLOB)
EgtInvertCurve(nCutPerpId)
End If
' Imposto affondamento e angolo di fianco sul taglio
EgtSetInfo(nCutPerpId, INFO_DEPTH, m_dDepth)
EgtSetInfo(nCutPerpId, INFO_SIDE_ANGLE, m_dAngV)
For IndexList_X As Integer = 0 To m_ListOfCut_X.Count - 1
Dim nCut3Id As Integer = GDB_ID.NULL
dDimPzX = m_ListOfCut_X(IndexList_X).dInteraxis
nNumPzX = m_ListOfCut_X(IndexList_X).nNumber
' Calcolo secondo vettore di spostamento
vtDelta = Vector3d.FromPolar((dDimPzX + dThick), m_dAngO)
For Index As Integer = 1 To nNumPzX
Dim vtPerpMove As Vector3d = vtDelta * Index
' Creo copie
nCut3Id = EgtCopyGlob(nCutPerpId, nLayerId)
EgtMove(nCut3Id, vtPerpMove, GDB_RT.GLOB)
Next
nCutPerpId = nCut3Id
Next
End If
Return True
End Function
Private Function CreateCross(nLayerId As Integer, ptP As Point3d) As Boolean
ptP += New Vector3d(0, 0, 0.15)
' 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
Private Sub NumPzsTxBx_EgtClosed(sender As Object, e As EventArgs) Handles NumPzXTxBx.EgtClosed, NumPzYTxBx.EgtClosed,
DimPzXTxBx.EgtClosed, DimPzYTxBx.EgtClosed, SideChBx.Click
StringToInt(NumPzXTxBx.Text, m_nNumX)
StringToLen(DimPzXTxBx.Text, m_dDimX)
StringToInt(NumPzYTxBx.Text, m_nNumY)
StringToLen(DimPzYTxBx.Text, m_dDimY)
m_bHeadSide = SideChBx.IsChecked
' Disegno il taglio
CreateGridCut()
SetMachineInCurrPos()
EgtDraw()
End Sub
Private Sub SetCoordVisibility(bShow As Boolean)
XcoordTxBl.Visibility = If(bShow, Windows.Visibility.Visible, Windows.Visibility.Hidden)
XcoordTxBx.Visibility = If(bShow, Windows.Visibility.Visible, Windows.Visibility.Hidden)
YcoordTxBl.Visibility = If(bShow, Windows.Visibility.Visible, Windows.Visibility.Hidden)
YcoordTxBx.Visibility = If(bShow, Windows.Visibility.Visible, Windows.Visibility.Hidden)
End Sub
Private Sub ShowCoord()
Dim ptText As Point3d = m_ptPrev
ptText.ToLoc(New Frame3d(m_ptTabOri))
XcoordTxBx.Text = LenToString(ptText.x, 2)
YcoordTxBx.Text = LenToString(ptText.y, 2)
End Sub
Private Function SetMachineInCurrPos() As Boolean
' 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 False
' 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
If Not m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2) Then Return False
' Visualizzo macchina in posizione
EgtSetAxisPos(sL1, dL1)
EgtSetAxisPos(sL2, dL2)
EgtSetAxisPos(sL3, dL3)
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
Return True
End Function
End Class
Public Class Cut_Axis
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
' Numero di tagli con questo interasse
Private m_nNumber As Integer = 0
Public Property sNumber As String
Get
Return m_nNumber.ToString
End Get
Set(value As String)
If IsNumeric(value) Then
m_nNumber = CInt(value)
End If
End Set
End Property
Public ReadOnly Property nNumber As Double
Get
Return m_nNumber
End Get
End Property
' Distanza dal taglio precedente
Private m_dInteraxis As Double = 0.0
Public Property sInteraxis As String
Get
Return LenToString(m_dInteraxis, 2)
End Get
Set(value As String)
Dim PrevValue As Double = m_dInteraxis
If Not StringToLen(value, m_dInteraxis) Then m_dInteraxis = PrevValue
End Set
End Property
Public ReadOnly Property dInteraxis As Double
Get
Return m_dInteraxis
End Get
End Property
'Public ReadOnly Property UpdateSub As Boolean
' Get
' m_MainWindow.m_DirectCutPageUC.m_ControlsDirectCutUC.m_CustomGrid.Update_Click()
' Return True
' End Get
'End Property
Sub New(nNumb As Integer, dInter As Double)
m_nNumber = nNumb
m_dInteraxis = dInter
End Sub
End Class