OmagCUT 1.8h2 :

- aggiunta rotazione in registrazione 
- correzioni per gestione immagini.
This commit is contained in:
Dario Sassi
2017-08-07 18:34:14 +00:00
parent b77d3aa71f
commit 73d60f3f66
13 changed files with 309 additions and 129 deletions
+33 -41
View File
@@ -531,11 +531,10 @@ Friend Module CamAuto
Dim dReducedDepth As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_REDUCEDDEPTH, 1, m_MainWindow.GetMachIniFile())
Dim dHolesOffset As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_HOLES_OFFSET, 0, m_MainWindow.GetMachIniFile())
Dim dHolesOverlap As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_HOLES_OVERLAP, 0, m_MainWindow.GetMachIniFile())
Dim dCornerSafety As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_SAFE_LEN_INTCORNER, 1, m_MainWindow.GetMachIniFile())
Dim dCornerSafety As Double = Math.Max(GetPrivateProfileDouble(S_MACH_NEST, K_MACH_SAFE_LEN_INTCORNER, 1, m_MainWindow.GetMachIniFile()), 10 * EPS_SMALL)
Dim bOneHoleIntCorner As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_ONEHOLE_INTCORNER, 0, m_MainWindow.GetMachIniFile()) <> 0)
Dim bMillingOnCorners As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_MILLING_ON_CORNERS, 1, m_MainWindow.GetMachIniFile()) <> 0)
Dim bMillingOnSinks As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_MILLING_ON_SINKS, 0, m_MainWindow.GetMachIniFile()) <> 0)
dCornerSafety = Math.Max(dCornerSafety, 10 * EPS_SMALL)
EgtLuaSetGlobStringVar("CAM.SAWMCH", sSawMch)
EgtLuaSetGlobStringVar("CAM.MILLMCH", sMillMch)
EgtLuaSetGlobStringVar("CAM.DRILLMCH", sDrillMch)
@@ -548,50 +547,29 @@ Friend Module CamAuto
EgtLuaSetGlobBoolVar("CAM.MILLINGONCORNERS", bMillingOnCorners)
EgtLuaSetGlobBoolVar("CAM.MILLINGONSINKS", bMillingOnSinks)
EgtLuaSetGlobNumVar("CAM.RAWHEIGHT", GetRawHeight())
EgtLuaSetGlobNumVar("CAM.REGROT", GetRegistrationRotation())
Return True
End Function
Friend Function GetCurrentRaw() As Integer
' Recupero il grezzo (primo con fase 1)
Dim nRawId As Integer = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL And Not EgtVerifyRawPartPhase(nRawId, 1)
nRawId = EgtGetNextRawPart(nRawId)
End While
Return nRawId
End Function
Friend Function GetRawBox(ByRef ptRawMin As Point3d, ByRef ptRawMax As Point3d) As Boolean
' Recupero il grezzo (primo con fase 1)
Dim nRawId As Integer = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL And Not EgtVerifyRawPartPhase(nRawId, 1)
nRawId = EgtGetNextRawPart(nRawId)
End While
' eseguo
Return GetRawBox(nRawId, ptRawMin, ptRawMax)
Return EgtGetRawPartBBox(GetCurrentRaw(), ptRawMin, ptRawMax)
End Function
Friend Function GetRawBox(ByRef b3RawBox As BBox3d) As Boolean
' Recupero il grezzo (primo con fase 1)
Dim nRawId As Integer = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL And Not EgtVerifyRawPartPhase(nRawId, 1)
nRawId = EgtGetNextRawPart(nRawId)
End While
' eseguo
Return GetRawBox(nRawId, b3RawBox)
Return EgtGetRawPartBBox(GetCurrentRaw(), b3RawBox)
End Function
Friend Function GetRawBox(nRawId As Integer, ByRef ptRawMin As Point3d, ByRef ptRawMax As Point3d) As Boolean
' Recupero identificativo del grezzo e del suo solido
Dim nSolidRawId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_RAW_SOLID)
If nSolidRawId = GDB_ID.NULL Then Return False
' Ne recupero il box
EgtGetBBoxGlob(nSolidRawId, GDB_BB.STANDARD, ptRawMin, ptRawMax)
Return True
End Function
Friend Function GetRawBox(nRawId As Integer, ByRef b3RawBox As BBox3d) As Boolean
' Recupero identificativo del grezzo e del suo solido
Dim nSolidRawId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_RAW_SOLID)
If nSolidRawId = GDB_ID.NULL Then Return False
' Ne recupero il box
EgtGetBBoxGlob(nSolidRawId, GDB_BB.STANDARD, b3RawBox)
Return True
End Function
Friend Function GetRawCenter(nRawId As Integer, ByRef ptCent As Point3d) As Boolean
Dim nCentId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_RAW_CENTER)
Return EgtStartPoint(nCentId, GDB_ID.ROOT, ptCent)
Friend Function GetRawCenter(ByRef ptCent As Point3d) As Boolean
Return EgtGetRawPartCenter(GetCurrentRaw(), ptCent)
End Function
Friend Function GetRawHeight() As Double
@@ -603,6 +581,20 @@ Friend Module CamAuto
End If
End Function
Friend Function SetRegistrationRotation(dRegRot As Double) As Boolean
Return EgtSetInfo(GetCurrentRaw(), INFO_REGROT, dRegRot)
End Function
Friend Function ResetRegistrationRotation() As Boolean
Return EgtRemoveInfo(GetCurrentRaw(), INFO_REGROT)
End Function
Friend Function GetRegistrationRotation() As Double
Dim dRegRot As Double = 0
EgtGetInfo(GetCurrentRaw(), INFO_REGROT, dRegRot)
Return dRegRot
End Function
Friend Function UpdateAllRawsZ(dDeltaZ As Double) As Boolean
For i As Integer = 1 To EgtGetPhaseCount()
EgtSetCurrPhase(i)
@@ -648,7 +640,7 @@ Friend Module CamAuto
' Cancello tutte le lavorazioni
EgtRemoveAllOperations()
' Recupero il grezzo corrente
Dim nRawId As Integer = EgtGetFirstRawPart()
Dim nRawId As Integer = GetCurrentRaw()
If nRawId = GDB_ID.NULL Then Return False
' Se non ci sono pezzi, esco
If EgtGetPartInRawPartCount(nRawId) = 0 Then Return True
@@ -666,7 +658,7 @@ Friend Module CamAuto
Dim nId As Integer = EgtGetOperationId(NAME_FRAME_SAWROU)
EgtRemoveOperation(nId)
' Recupero il grezzo corrente
Dim nRawId As Integer = EgtGetFirstRawPart()
Dim nRawId As Integer = GetCurrentRaw()
If nRawId = GDB_ID.NULL Then Return False
' Se non ci sono pezzi, esco
If EgtGetPartInRawPartCount(nRawId) = 0 Then Return True
@@ -707,7 +699,7 @@ Friend Module CamAuto
Dim nId As Integer = EgtGetOperationId(NAME_FRAME_SAWFIN)
EgtRemoveOperation(nId)
' Recupero il grezzo corrente
Dim nRawId As Integer = EgtGetFirstRawPart()
Dim nRawId As Integer = GetCurrentRaw()
If nRawId = GDB_ID.NULL Then Return False
' Se non ci sono pezzi, esco
If EgtGetPartInRawPartCount(nRawId) = 0 Then Return True
@@ -758,7 +750,7 @@ Friend Module CamAuto
Dim nId As Integer = EgtGetOperationId(NAME_FRAME_SAWSIDEFIN)
EgtRemoveOperation(nId)
' Recupero il grezzo corrente
Dim nRawId As Integer = EgtGetFirstRawPart()
Dim nRawId As Integer = GetCurrentRaw()
If nRawId = GDB_ID.NULL Then Return False
' Se non ci sono pezzi, esco
If EgtGetPartInRawPartCount(nRawId) = 0 Then Return True
+4
View File
@@ -120,6 +120,10 @@ Module ConstGen
Public Const INFO_NCPROGSENT As String = "NcProgSent"
' Info per ingombro pezzi con gocciolatoio
Public Const INFO_DRIPBBOX As String = "DripBBox"
' Info per rotazione in registrazione grezzo
Public Const INFO_REGROT As String = "RegRot"
' Info con path carico progetto
Public Const INFO_LOADPATH As String = "LoadPath"
' Nome layer delle regioni
Public Const NAME_REGION As String = "Region"
+4
View File
@@ -130,6 +130,10 @@ Module ConstIni
Public Const K_RAWROTATION As String = "Rotation"
Public Const K_PERPENDICULAR As String = "Perpendicular"
Public Const S_REG As String = "Reg"
Public Const K_REGSTEP As String = "Step"
Public Const K_REGANGSTEP As String = "AngStep"
Public Const S_CAMERA As String = "Camera"
Public Const K_CAM_COUNT As String = "Count"
Public Const K_CAM_EXEPATH As String = "ExePath"
+3
View File
@@ -111,6 +111,9 @@
Public Const S_MACH_RAWMOVE As String = "RawMove"
Public Const K_MACH_RM_ROTATE As String = "Rotate"
Public Const S_MACH_REG As String = "Reg"
Public Const K_MACH_MAX_ROT_ANG As String = "MaxRotAng"
Public Const S_TOOLCHANGER As String = "ToolChanger"
Public Const K_NUMBER As String = "Number"
Public Const K_POS As String = "Pos"
+13 -8
View File
@@ -634,6 +634,11 @@ Public Class CurrentProjectPageUC
Return nNcSent
End Function
Friend Function SetLoadPath(sPath As String) As Boolean
Dim nMarkId As Integer = AddProjectMark()
Return EgtSetInfo(nMarkId, INFO_LOADPATH, sPath)
End Function
Friend Sub UpdateHeightTxBx()
HeightTxBx.Text = LenToString(m_dRawHeight, 3)
End Sub
@@ -811,15 +816,14 @@ Public Class CurrentProjectPageUC
If nPhotoId = GDB_ID.NULL Then Return False
' Verifico esistenza texture della foto
Dim sPath As String = String.Empty
EgtGetPhotoPath(nPhotoId, sPath)
If Not File.Exists(sPath) Then Return False
If Not EgtGetPhotoPath(nPhotoId, sPath) OrElse Not File.Exists(sPath) Then Return False
' Recupero i dati aggiuntivi della foto
Dim ptOri As New Point3d(0, 0, 0)
EgtGetPhotoOrigin(nPhotoId, ptOri)
If Not EgtGetPhotoOrigin(nPhotoId, ptOri) Then Return False
Dim ptCen As New Point3d(0, 0, 1)
EgtGetPhotoCenter(nPhotoId, ptCen)
Dim dMMxPixel As Double = 1
EgtGetPhotoMMxPixel(nPhotoId, dMMxPixel)
If Not EgtGetPhotoCenter(nPhotoId, ptCen) Then Return False
Dim dDimX, dDimY As Double
If Not EgtGetPhotoDimensions(nPhotoId, dDimX, dDimY) Then Return False
' Recupero origine della tavola
Dim ptTab As Point3d
If Not EgtGetTableRef(1, ptTab) Then Return False
@@ -830,7 +834,8 @@ Public Class CurrentProjectPageUC
Dim dAddTable As Double = m_MainWindow.m_CurrentMachine.dAdditionalTable
' Aggiusto dati per spessore grezzo (Coefficiente di scalatura)
Dim dFsca As Double = (ptCen.z - m_dRawHeight - dAddTable) / (ptCen.z - ptOri.z)
dMMxPixel *= dFsca
dDimX *= dFsca
dDimY *= dFsca
ptOri.x = ptCen.x + (ptOri.x - ptCen.x) * dFsca
ptOri.y = ptCen.y + (ptOri.y - ptCen.y) * dFsca
ptOri.z = m_dRawHeight + dAddTable
@@ -852,7 +857,7 @@ Public Class CurrentProjectPageUC
End If
EgtSetLevel(nPhGrpId, GDB_LV.SYSTEM)
' Carico la fotografia
Return EgtAddPhoto(PHOTO_NAME, sPath, ptOri, ptCen, dMMxPixel, nPhGrpId, ptMin, ptMax) <> GDB_ID.NULL
Return EgtAddPhoto2(PHOTO_NAME, sPath, ptOri, ptCen, dDimX, dDimY, nPhGrpId, ptMin, ptMax) <> GDB_ID.NULL
End Function
Friend Function UpdateContour() As Boolean
+4 -4
View File
@@ -206,7 +206,7 @@ Public Class MoveRawPartPage
If m_bByHand Then
' Recupero il centro del grezzo
Dim ptRawCen As Point3d
GetRawCenter(nRawId, ptRawCen)
EgtGetRawPartCenter(nRawId, ptRawCen)
' Calcolo la distanza di movimento
Dim dMove As Double = m_dStep
If m_dCurrDist < EPS_SMALL Then
@@ -243,7 +243,7 @@ Public Class MoveRawPartPage
If m_dCurrDist < EPS_SMALL Then Return
' Recupero il centro del grezzo
Dim ptRawCen As Point3d
GetRawCenter(nRawId, ptRawCen)
EgtGetRawPartCenter(nRawId, ptRawCen)
' Calcolo la distanza di movimento
Dim dMove As Double = m_dStep
If m_dCurrDist < m_dStep Then
@@ -319,7 +319,7 @@ Public Class MoveRawPartPage
If EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAng) Then
' Recupero il centro del grezzo
Dim ptRawCen As Point3d
GetRawCenter(nRawId, ptRawCen)
EgtGetRawPartCenter(nRawId, ptRawCen)
EgtRotate(GetVacuumId(), ptRawCen, Vector3d.Z_AX(), dAng, GDB_RT.GLOB)
AddRawMoveData(nRawId, dAng, m_RawMoveDataList)
End If
@@ -341,7 +341,7 @@ Public Class MoveRawPartPage
If EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAng) Then
' Recupero il centro del grezzo
Dim ptRawCen As Point3d
GetRawCenter(nRawId, ptRawCen)
EgtGetRawPartCenter(nRawId, ptRawCen)
EgtRotate(GetVacuumId(), ptRawCen, Vector3d.Z_AX(), dAng, GDB_RT.GLOB)
AddRawMoveData(nRawId, dAng, m_RawMoveDataList)
End If
+2 -2
View File
@@ -60,5 +60,5 @@ Imports System.Windows
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.8.7.3")>
<Assembly: AssemblyFileVersion("1.8.7.3")>
<Assembly: AssemblyVersion("1.8.8.2")>
<Assembly: AssemblyFileVersion("1.8.8.2")>
+215 -52
View File
@@ -22,8 +22,7 @@ Public Class NestPageUC
Private m_nIdToDesel As Integer = GDB_ID.NULL
' Dati del grezzo
Private m_nRawId As Integer = GDB_ID.NULL
Private m_ptRawMin As Point3d
Private m_ptRawMax As Point3d
Private m_b3Raw As New BBox3d
Private m_dKerf As Double
Private m_dMinDist As Double = 0
' Dati movimento
@@ -32,6 +31,10 @@ Public Class NestPageUC
Private m_bMaximizeMove As Boolean = False
Private m_dAngStep As Double = 0
Private m_bReducedCut As Boolean = False
' Dati movimento registrazione grezzo
Private m_dRegStep As Double = 0
Private m_dRegAngStep As Double = 0
Private m_dMaxRegAng As Double = 10
' Dati per Drag
Private m_nRestRadius As Integer = 3
Private m_bDrag As Boolean = False
@@ -71,12 +74,16 @@ Public Class NestPageUC
' carico e calcolo i parametri di movimento e drag
m_dStep = GetPrivateProfileDouble(S_NEST, K_STEP, 10, m_MainWindow.GetIniFile())
StepMoveTxBx.Text = LenToString(m_dStep, 3)
m_dMaxStep = Math.Max(m_ptRawMax.x - m_ptRawMin.x, m_ptRawMax.y - m_ptRawMin.y)
m_dMaxStep = Math.Max(m_b3Raw.DimX(), m_b3Raw.DimY())
m_dAngStep = GetPrivateProfileDouble(S_NEST, K_ANGSTEP, 15, m_MainWindow.GetIniFile())
RotationAngleTxBx.Text = DoubleToString(m_dAngStep, 2)
m_nRestRadius = GetPrivateProfileInt(S_NEST, K_RESTRADIUS, 3, m_MainWindow.GetIniFile())
m_dSnapDist = GetPrivateProfileDouble(S_NEST, K_SNAPDIST, 50, m_MainWindow.GetIniFile())
m_bReducedCut = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_REDUCEDCUT, 0, m_MainWindow.GetMachIniFile()) <> 0)
' carico i parametri di registrazione grezzo
m_dRegStep = GetPrivateProfileDouble(S_REG, K_REGSTEP, 10, m_MainWindow.GetIniFile())
m_dRegAngStep = GetPrivateProfileDouble(S_REG, K_REGANGSTEP, 1, m_MainWindow.GetIniFile())
m_dMaxRegAng = GetPrivateProfileDouble(S_MACH_REG, K_MACH_MAX_ROT_ANG, 10, m_MainWindow.GetMachIniFile())
' Garantisco visibilità pezzi parcheggiati
ShowParkedParts()
' Garantisco visibilità eventuale contorno da foto
@@ -86,20 +93,25 @@ Public Class NestPageUC
Public Sub CalcRawPart()
' determino il grezzo (è il primo con fase 1)
m_nRawId = EgtGetFirstRawPart()
While m_nRawId <> GDB_ID.NULL And Not EgtVerifyRawPartPhase(m_nRawId, 1)
m_nRawId = EgtGetNextRawPart(m_nRawId)
End While
m_nRawId = GetCurrentRaw()
' recupero dimensioni del grezzo e kerf
GetRawBox(m_ptRawMin, m_ptRawMax)
EgtGetRawPartBBox(m_nRawId, m_b3Raw)
EgtGetInfo(m_nRawId, KEY_KERF, m_dKerf)
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
Public Sub UpdateStepsOnUI()
If Not m_bRegister Then
StepMoveTxBx.Text = LenToString(m_dStep, 3)
RotationAngleTxBx.Text = DoubleToString(m_dAngStep, 2)
Else
StepMoveTxBx.Text = LenToString(m_dRegStep, 3)
RotationAngleTxBx.Text = DoubleToString(m_dRegAngStep, 2)
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 e non in modalità registrazione
If Not m_bActive Or m_bRegister 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
@@ -326,7 +338,7 @@ Public Class NestPageUC
nId = EgtGetNextSelectedObj()
End While
Else
MoveAllRawParts(New Vector3d(0, m_dStep, 0))
MoveAllRawParts(New Vector3d(0, m_dRegStep, 0))
EgtDraw()
End If
End Sub
@@ -360,7 +372,7 @@ Public Class NestPageUC
nId = EgtGetNextSelectedObj()
End While
Else
MoveAllRawParts(New Vector3d(0, -m_dStep, 0))
MoveAllRawParts(New Vector3d(0, -m_dRegStep, 0))
EgtDraw()
End If
End Sub
@@ -394,7 +406,7 @@ Public Class NestPageUC
nId = EgtGetNextSelectedObj()
End While
Else
MoveAllRawParts(New Vector3d(m_dStep, 0, 0))
MoveAllRawParts(New Vector3d(m_dRegStep, 0, 0))
EgtDraw()
End If
End Sub
@@ -428,7 +440,7 @@ Public Class NestPageUC
nId = EgtGetNextSelectedObj()
End While
Else
MoveAllRawParts(New Vector3d(-m_dStep, 0, 0))
MoveAllRawParts(New Vector3d(-m_dRegStep, 0, 0))
EgtDraw()
End If
End Sub
@@ -476,28 +488,38 @@ Public Class NestPageUC
Private Sub RotateCounterClockwiseBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateCounterClockwiseBtn.Click
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
RotateCluster(m_dAngStep)
m_CurrProjPage.ResetOrderMachiningFlag()
EgtDraw()
' Eventuale notifica al VeinMatching
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
VeinMatching.OnMovePartInRaw(nId)
nId = EgtGetNextSelectedObj()
End While
If Not m_bRegister Then
RotateCluster(m_dAngStep)
m_CurrProjPage.ResetOrderMachiningFlag()
EgtDraw()
' Eventuale notifica al VeinMatching
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
VeinMatching.OnMovePartInRaw(nId)
nId = EgtGetNextSelectedObj()
End While
Else
RotateAllRawParts(m_dRegAngStep)
EgtDraw()
End If
End Sub
Private Sub RotateClockwiseBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateClockwiseBtn.Click
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
RotateCluster(-m_dAngStep)
m_CurrProjPage.ResetOrderMachiningFlag()
EgtDraw()
' Eventuale notifica al VeinMatching
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
VeinMatching.OnMovePartInRaw(nId)
nId = EgtGetNextSelectedObj()
End While
If Not m_bRegister Then
RotateCluster(-m_dAngStep)
m_CurrProjPage.ResetOrderMachiningFlag()
EgtDraw()
' Eventuale notifica al VeinMatching
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
VeinMatching.OnMovePartInRaw(nId)
nId = EgtGetNextSelectedObj()
End While
Else
RotateAllRawParts(-m_dRegAngStep)
EgtDraw()
End If
End Sub
Private Function RotateCluster(ByVal dAngRotDeg As Double) As Boolean
@@ -539,6 +561,142 @@ Public Class NestPageUC
End If
End Function
Private Sub RotateAllRawParts(dAngDeg As Double)
' Recupero rotazione totale
Dim dRegRot As Double = GetRegistrationRotation()
' Verifico se nuova rotazione totale ammissibile
m_CurrProjPage.ClearMessage()
If Math.Abs(dRegRot + dAngDeg) > m_dMaxRegAng Then
m_CurrProjPage.SetWarningMessage(EgtMsg(90338)) 'Angolo di registrazione oltre i limiti
Return
End If
' Recupero il centro del grezzo iniziale per usarlo come centro della rotazione
Dim ptCen As New Point3d
GetRawCenter(ptCen)
' Provo la rotazione
Dim bMoveOk As Boolean = True
Dim nPhase As Integer = 1
Dim nRawId As Integer = GDB_ID.NULL
While nPhase <= EgtGetPhaseCount()
EgtSetCurrPhase(nPhase)
nRawId = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL
If EgtVerifyRawPartPhase(nRawId, nPhase) Then
' Rotazione del centro come spostamento grezzo più rotazione grezzo attorno al suo centro
Dim ptRawCen As New Point3d
EgtGetRawPartCenter(nRawId, ptRawCen)
Dim ptMovCen As New Point3d(ptRawCen)
ptMovCen.Rotate(ptCen, Vector3d.Z_AX(), dAngDeg)
If Not EgtMoveRawPart(nRawId, ptMovCen - ptRawCen) Then
bMoveOk = False
Exit While
End If
If Not EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAngDeg) Then
EgtMoveRawPart(nRawId, -(ptMovCen - ptRawCen))
bMoveOk = False
Exit While
End If
End If
nRawId = EgtGetNextRawPart(nRawId)
End While
If Not bMoveOk Then Exit While
nPhase += 1
End While
' Se rotazione impossibile, ripristino posizione dei grezzi già spostati
If Not bMoveOk Then
m_CurrProjPage.SetWarningMessage(EgtMsg(90339)) 'Rotazione impossibile
Dim nRevPhase As Integer = 1
Dim nRevRawId As Integer = GDB_ID.NULL
While nRevPhase <= nPhase
EgtSetCurrPhase(nRevPhase)
nRevRawId = EgtGetFirstRawPart()
While nRevRawId <> GDB_ID.NULL And (nRevPhase < nPhase Or nRevRawId <> nRawId)
If EgtVerifyRawPartPhase(nRevRawId, nRevPhase) Then
' Eseguo al contrario
EgtRotateRawPart(nRevRawId, Vector3d.Z_AX(), -dAngDeg)
Dim ptRawCen As New Point3d
EgtGetRawPartCenter(nRevRawId, ptRawCen)
Dim ptMovCen As New Point3d(ptRawCen)
ptMovCen.Rotate(ptCen, Vector3d.Z_AX(), -dAngDeg)
EgtMoveRawPart(nRevRawId, (ptMovCen - ptRawCen))
End If
nRevRawId = EgtGetNextRawPart(nRevRawId)
End While
nRevPhase += 1
End While
' Altrimenti eseguo sistemazioni
Else
' Origine della tavola
Dim ptOri As Point3d
EgtGetTableRef(1, ptOri)
' Annullo rotazioni dei grezzi e le rifaccio sulle parti componenti
Dim nRevPhase As Integer = 1
Dim nRevRawId As Integer = GDB_ID.NULL
While nRevPhase <= EgtGetPhaseCount()
EgtSetCurrPhase(nRevPhase)
nRevRawId = EgtGetFirstRawPart()
While nRevRawId <> GDB_ID.NULL
If EgtVerifyRawPartPhase(nRevRawId, nRevPhase) Then
' Eseguo al contrario
EgtRotateRawPart(nRevRawId, Vector3d.Z_AX(), -dAngDeg)
Dim ptRawCen As New Point3d
EgtGetRawPartCenter(nRevRawId, ptRawCen)
Dim ptMovCen As New Point3d(ptRawCen)
ptMovCen.Rotate(ptCen, Vector3d.Z_AX(), -dAngDeg)
EgtMoveRawPart(nRevRawId, (ptMovCen - ptRawCen))
' Rifaccio sugli oggetti contenuti nel grezzo
Dim nId As Integer = EgtGetFirstInGroup(nRevRawId)
While nId <> GDB_ID.NULL
EgtRotate(nId, ptCen, Vector3d.Z_AX(), dAngDeg, GDB_RT.GLOB)
nId = EgtGetNext(nId)
End While
' Imposto posizione esatta del grezzo dopo rotazione
Dim b3Raw As New BBox3d
EgtGetRawPartBBox(nRevRawId, b3Raw)
EgtMoveToCornerRawPart(nRevRawId, (b3Raw.Min() - ptOri) + Point3d.ORIG(), MCH_CR.BL)
End If
nRevRawId = EgtGetNextRawPart(nRevRawId)
End While
nRevPhase += 1
End While
' Ruoto opportunamente anche i dati di movimento
Dim nOpeId As Integer = EgtGetFirstActiveOperation()
While nOpeId <> GDB_ID.NULL
If EgtGetOperationType(nOpeId) = MCH_OY.DISP Then
' Recupero i gruppi con i dati
Dim nRpmId As Integer = EgtGetFirstNameInGroup(nOpeId, "Rpm*")
While nRpmId <> GDB_ID.NULL
' Recupero le informazioni
Dim vtRawMove As New Vector3d
If EgtGetInfo(nRpmId, "Mv", vtRawMove) Then
vtRawMove.Rotate(Vector3d.Z_AX(), dAngDeg)
EgtSetInfo(nRpmId, "Mv", vtRawMove)
End If
Dim vtDelta As New Vector3d
If EgtGetInfo(nRpmId, "Dt", vtDelta) Then
vtDelta.Rotate(Vector3d.Z_AX(), dAngDeg)
EgtSetInfo(nRpmId, "Dt", vtDelta)
End If
Dim dAngRotDeg As Double = 0
If EgtGetInfo(nRpmId, "Ad", dAngRotDeg) Then
EgtSetInfo(nRpmId, "Ad", dAngRotDeg + dAngDeg)
End If
' Cerco un altro gruppo
nRpmId = EgtGetNextName(nRpmId, "Rpm*")
End While
End If
nOpeId = EgtGetNextActiveOperation(nOpeId)
End While
' Aggiorno rotazione totale
SetRegistrationRotation(dRegRot + dAngDeg)
' Dichiaro grezzo per punti
EgtSetInfo(GetCurrentRaw(), KEY_RAWBYPOINTS, 1)
End If
' Ripristino lo stato iniziale
EgtSetCurrPhase(1)
HideAllMachinings()
End Sub
Private Sub InsertPartBtn_Click(sender As Object, e As RoutedEventArgs) Handles InsertPartBtn.Click
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
' Ciclo di inserimento in tavola dei pezzi selezionati
@@ -568,20 +726,17 @@ Public Class NestPageUC
' Se esiste grezzo e pezzo in parcheggio, lo metto nella tavola
If m_nRawId <> GDB_ID.NULL AndAlso EgtIsPart(nId) Then
' Sistemazioni per eventuali lati esterni inclinati
EgtCalcFlatPartDownRegion(nId, m_ptRawMax.z - m_ptRawMin.z)
EgtCalcFlatPartDownRegion(nId, m_b3Raw.DimZ())
' Dimensioni del pezzo
Dim ptPartMin, ptPartMax As Point3d
If Not EgtGetBBoxGlob(nId, GDB_BB.IGNORE_DIM + GDB_BB.IGNORE_TEXT, ptPartMin, ptPartMax) Then Return False
Dim dPartLen As Double = ptPartMax.x - ptPartMin.x
Dim dPartHeight As Double = ptPartMax.y - ptPartMin.y
Dim b3Part As New BBox3d
If Not EgtGetBBoxGlob(nId, GDB_BB.IGNORE_DIM + GDB_BB.IGNORE_TEXT, b3Part) Then Return False
' Centro del grezzo
Dim nRawCenId = EgtGetFirstNameInGroup(m_nRawId, NAME_RAW_CENTER)
Dim ptRawCenter As Point3d
EgtStartPoint(nRawCenId, GDB_ID.ROOT, ptRawCenter)
Dim dRawCenX = ptRawCenter.x - m_ptRawMin.x
Dim dRawCenY = ptRawCenter.y - m_ptRawMin.y
If Not EgtGetRawPartCenter(m_nRawId, ptRawCenter) Then Return False
Dim dRawCenX = ptRawCenter.x - m_b3Raw.Min().x
Dim dRawCenY = ptRawCenter.y - m_b3Raw.Min().y
' Inserisco il pezzo nel grezzo, in centro in XY e in alto in Z
Dim ptP As New Point3d(dRawCenX - 0.5 * dPartLen, dRawCenY - 0.5 * dPartHeight, m_ptRawMax.z - m_ptRawMin.z)
Dim ptP As New Point3d(dRawCenX - 0.5 * b3Part.DimX(), dRawCenY - 0.5 * b3Part.DimY(), m_b3Raw.DimZ())
If EgtAddPartToRawPart(nId, ptP, m_nRawId) Then
' Aggiungo le lavorazioni standard
AddMachinings(nId, True, False)
@@ -649,7 +804,7 @@ Public Class NestPageUC
' Aggiusto la posizione in Z
Dim ptPartMin, ptPartMax As Point3d
If EgtGetBBoxGlob(nId, GDB_BB.IGNORE_DIM + GDB_BB.IGNORE_TEXT, ptPartMin, ptPartMax) Then
EgtMove(nId, New Vector3d(0, 0, m_ptRawMax.z - ptPartMax.z), GDB_RT.GLOB)
EgtMove(nId, New Vector3d(0, 0, m_b3Raw.Max().z - ptPartMax.z), GDB_RT.GLOB)
End If
Return True
End If
@@ -672,6 +827,7 @@ Public Class NestPageUC
End Function
Private Sub RemovePartBtn_Click(sender As Object, e As RoutedEventArgs) Handles RemovePartBtn.Click
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
' Se non ci sono pezzi selezionati, esco subito
If EgtGetFirstSelectedObj() = GDB_ID.NULL Then Return
' Chiedo conferma prima di procedere
@@ -679,7 +835,6 @@ Public Class NestPageUC
If RemovePartWnd.m_nPressedBtn = 0 Then
Return
End If
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
' Verifico se ci sono pezzi provenienti da liste Csv
Dim bCsvParts As Boolean = False
Dim nId As Integer = EgtGetFirstSelectedObj()
@@ -782,16 +937,24 @@ Public Class NestPageUC
End Sub
Private Sub StepMoveTxBx_EgtClosed(sender As Object, e As EventArgs) Handles StepMoveTxBx.EgtClosed
Dim dStep As Double
If StringToLen(StepMoveTxBx.Text, dStep) Then
m_dStep = Math.Max(dStep, 2 * EPS_SMALL)
Dim dVal As Double
If StringToLen(StepMoveTxBx.Text, dVal) Then
If Not m_bRegister Then
m_dStep = Math.Max(dVal, 2 * EPS_SMALL)
Else
m_dRegStep = Math.Max(dVal, 2 * EPS_SMALL)
End If
End If
End Sub
Private Sub RotationAngleTxBx_EgtClosed(sender As Object, e As EventArgs) Handles RotationAngleTxBx.EgtClosed
Dim dAngStep As Double
If StringToDouble(RotationAngleTxBx.Text, dAngStep) Then
m_dAngStep = Math.Max(dAngStep, 50 * EPS_ANG_SMALL)
Dim dVal As Double
If StringToDouble(RotationAngleTxBx.Text, dVal) Then
If Not m_bRegister Then
m_dAngStep = Math.Max(dVal, 50 * EPS_ANG_SMALL)
Else
m_dRegAngStep = Math.Max(dVal, 50 * EPS_ANG_SMALL)
End If
End If
End Sub
+8
View File
@@ -138,6 +138,8 @@ Public Class ProjectMgrUC
Else
WritePrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, String.Empty, m_MainWindow.GetIniFile())
End If
' Salvo path di carico del progetto
m_CurrProjPage.SetLoadPath(sCurrDir & "\" & sCurrFile)
End If
' Verifico se andare nel CadCut o nel FrameCut
Dim nPrjType As Integer = m_CurrProjPage.GetCurrentProjectType()
@@ -420,6 +422,8 @@ Public Class ProjectMgrUC
m_MainWindow.m_CadCutPageUC.m_NestPage.RemovePartBtn.Visibility = Windows.Visibility.Hidden
m_MainWindow.m_CadCutPageUC.m_NestPage.SelectAllBtn.Visibility = Windows.Visibility.Hidden
m_MainWindow.m_CadCutPageUC.m_NestPage.DeselectAllBtn.Visibility = Windows.Visibility.Hidden
' Deseleziono tutto
EgtDeselectAll()
' Se c'è la foto devo sistemare
If m_CurrProjPage.GetPhoto() <> GDB_ID.NULL Then
' Salvo il riferimento della texture originale di ogni grezzo
@@ -524,6 +528,10 @@ Public Class ProjectMgrUC
EgtDraw()
End If
End If
' Visualizzo step adatti alla scelta fatta
m_MainWindow.m_CadCutPageUC.m_NestPage.UpdateStepsOnUI()
' Cancello eventuali messaggi di errore/avvertimento
m_CurrProjPage.ClearMessage()
End Sub
End Class
+8 -8
View File
@@ -406,7 +406,7 @@ Public Class RawPartPageUC
OffsetXTxBx.Text = LenToString(m_RawOffsX, 2)
OffsetYTxBx.Text = LenToString(m_RawOffsY, 2)
End If
' se sposto lato sotto
' se sposto lato sotto
ElseIf m_nDragEnt = 1 Then
Dim dDelta = ptCurr.y - m_ptPrev.y
If m_RawWidth - dDelta > MIN_RAW_DIM And m_RawOffsY + dDelta > m_RawKerf Then
@@ -421,7 +421,7 @@ Public Class RawPartPageUC
WidthTxBx.Text = LenToString(m_RawWidth, 2)
OffsetYTxBx.Text = LenToString(m_RawOffsY, 2)
End If
' se sposto lato a destra
' se sposto lato a destra
ElseIf m_nDragEnt = 2 Then
Dim dDelta = ptCurr.x - m_ptPrev.x
If m_RawLength + dDelta > MIN_RAW_DIM And
@@ -433,7 +433,7 @@ Public Class RawPartPageUC
EgtDraw()
LengthTxBx.Text = LenToString(m_RawLength, 2)
End If
' se sposto lato sopra
' se sposto lato sopra
ElseIf m_nDragEnt = 3 Then
Dim dDelta = ptCurr.y - m_ptPrev.y
If m_RawWidth + dDelta > MIN_RAW_DIM And
@@ -445,7 +445,7 @@ Public Class RawPartPageUC
EgtDraw()
WidthTxBx.Text = LenToString(m_RawWidth, 2)
End If
' se sposto lato a sinistra
' se sposto lato a sinistra
ElseIf m_nDragEnt = 4 Then
Dim dDelta = ptCurr.x - m_ptPrev.x
If m_RawLength - dDelta > MIN_RAW_DIM And m_RawOffsX + dDelta > m_RawKerf Then
@@ -897,10 +897,7 @@ Public Class RawPartPageUC
' in presenza di foto rendo molto più trasparente
If m_CurrProjPage.GetPhoto() <> GDB_ID.NULL Then Col.A = 20
' Se non esiste già il grezzo (primo con fase 1) e richiesto, lo inserisco
Dim nRawId As Integer = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL And Not EgtVerifyRawPartPhase(nRawId, 1)
nRawId = EgtGetNextRawPart(nRawId)
End While
Dim nRawId As Integer = GetCurrentRaw()
If nRawId = GDB_ID.NULL And m_RawHeight > EPS_SMALL Then
m_CurrProjPage.m_nRawId = EgtAddRawPart(Point3d.ORIG(), m_RawLength + 2 * m_RawKerf,
m_RawWidth + 2 * m_RawKerf, m_RawHeight, Col)
@@ -983,6 +980,9 @@ Public Class RawPartPageUC
' Elimino il grezzo
EgtRemoveRawPart(m_CurrProjPage.m_nRawId)
m_CurrProjPage.m_nRawId = GDB_ID.NULL
' Imposto modalità rettangolo
RawModeCmBx.SelectedIndex = RAWMODE.RECTANGLE
PointsGpBx.Visibility = Windows.Visibility.Hidden
' altrimenti da aggiornare
Else
' Salvo vecchia altezza
+4 -4
View File
@@ -273,7 +273,7 @@ Public Module SplitAuto
EgtKeepRawPart(nRawId)
' Fisso posizione del grezzo
Dim ptMin, ptMax As Point3d
GetRawBox(nRawId, ptMin, ptMax)
EgtGetRawPartBBox(nRawId, ptMin, ptMax)
EgtMoveToCornerRawPart(nRawId, ptMin - vtOri, MCH_CR.BL)
End If
nRawId = EgtGetNextRawPart(nRawId)
@@ -291,7 +291,7 @@ Public Module SplitAuto
Dim nNewRawId = nRaw1Id
While nNewRawId <> GDB_ID.NULL
Dim ptMin, ptMax As Point3d
GetRawBox(nNewRawId, ptMin, ptMax)
EgtGetRawPartBBox(nNewRawId, ptMin, ptMax)
EgtMoveToCornerRawPart(nNewRawId, ptMin - vtOri, MCH_CR.BL)
nNewRawId = EgtGetNextRawPart(nNewRawId)
End While
@@ -600,9 +600,9 @@ Public Module SplitAuto
End If
' Centri dei primi 2 grezzi
Dim ptCen0 As Point3d
If Not GetRawCenter(vNewRaws(0), ptCen0) Then Return False
If Not EgtGetRawPartCenter(vNewRaws(0), ptCen0) Then Return False
Dim ptCen1 As Point3d
If Not GetRawCenter(vNewRaws(1), ptCen1) Then Return False
If Not EgtGetRawPartCenter(vNewRaws(1), ptCen1) Then Return False
' Direzione del taglio
EgtSetCurrMachining(nCutId)
Dim nEntId, nSub As Integer
+2 -2
View File
@@ -135,9 +135,9 @@ Module VacuumCups
ResetVacuumCups()
' Box e baricentro del grezzo (riportato sopra al grezzo)
Dim b3Raw As New BBox3d
GetRawBox(nRawId, b3Raw)
EgtGetRawPartBBox(nRawId, b3Raw)
Dim ptRawCen As Point3d
GetRawCenter(nRawId, ptRawCen)
EgtGetRawPartCenter(nRawId, ptRawCen)
ptRawCen.z += b3Raw.DimZ() / 2
' Se non esiste, creo la regione del kerf del grezzo
Dim nKerfId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_KERF)
+9 -8
View File
@@ -1,4 +1,5 @@
Imports System.Windows.Interop
Imports System.IO
Imports System.Windows.Interop
Imports System.Runtime.InteropServices
Imports EgtUILib
@@ -403,15 +404,15 @@ Friend Module VeinMatching
Dim nCurrCtx = EgtGetCurrentContext()
' Recupero i dati della fotografia
Dim sPath As String = String.Empty
EgtGetPhotoPath(nPhotoId, sPath)
If Not EgtGetPhotoPath(nPhotoId, sPath) OrElse Not File.Exists(sPath) Then Return False
Dim ptOri As Point3d
EgtGetPhotoOrigin(nPhotoId, ptOri)
If Not EgtGetPhotoOrigin(nPhotoId, ptOri) Then Return False
Dim ptCen As Point3d
EgtGetPhotoCenter(nPhotoId, ptCen)
Dim dMMxPixel As Double
EgtGetPhotoMMxPixel(nPhotoId, dMMxPixel)
If Not EgtGetPhotoCenter(nPhotoId, ptCen) Then Return False
Dim dDimX, dDimY As Double
If Not EgtGetPhotoDimensions(nPhotoId, dDimX, dDimY) Then Return False
Dim ptMin, ptMax As Point3d
EgtGetBBoxGlob(nPhotoId, GDB_BB.STANDARD, ptMin, ptMax)
If Not EgtGetBBoxGlob(nPhotoId, GDB_BB.STANDARD, ptMin, ptMax) Then Return False
' Passo al contesto del VeinMatching
EgtSetCurrentContext(m_nVeinCtx)
' Se non esiste il gruppo per le foto, lo creo
@@ -428,7 +429,7 @@ Friend Module VeinMatching
EgtSetStatus(nPhGrpId, GDB_ST.OFF)
' Carico la fotografia
m_nPhoto += 1
Dim nNewId As Integer = EgtAddPhoto(GetPhotoName(), sPath, ptOri, ptCen, dMMxPixel, nPhGrpId, ptMin, ptMax)
Dim nNewId As Integer = EgtAddPhoto2(GetPhotoName(), sPath, ptOri, ptCen, dDimX, dDimY, nPhGrpId, ptMin, ptMax)
' Ritorno al contesto corrente
EgtSetCurrentContext(nCurrCtx)
Return nNewId <> GDB_ID.NULL