EgtCAM5 :

- Divisi parametri operazioni tra lavorazioni e disposizioni.
- Iniziata implementazione movimento ventose, riferimenti e grezzi nelle disposizioni.
This commit is contained in:
Emmanuele Sassi
2016-11-07 12:11:48 +00:00
parent e6bf2f633f
commit 2f0c121fc4
17 changed files with 2142 additions and 870 deletions
+211 -70
View File
@@ -22,6 +22,9 @@ Namespace EgtCAM5
Private m_bLoaded As Boolean = False
' Variabile che contiene il Frame di disegno per poterlo ripristinare dopo essere passato dalla lavorazioneù
Private m_GridDrawFrame3d As Frame3d = New Frame3d(New Point3d(0, 0, 0))
'PROJECT PAGE'S SCENE FIELDS AND PROPERTIES
' Reference to the ProjectScene
Private WithEvents m_ProjectScene As New Scene
@@ -78,10 +81,18 @@ Namespace EgtCAM5
RegisterStatusBarCommands()
' Cambio impostazioni griglia a seconda che sia in modalità Draw o Machining
Application.Msn.Register(Application.MACHININGMODE_ISCHECKED, Sub()
' Salvo il Frame3d di disegno
m_GridDrawFrame3d = EgtGetGridFrame()
' sposto la griglia sulla tavola di lavorazione
Dim TableRef As Point3d
EgtGetTableRef(1, TableRef)
EgtSetGridFrame(New Frame3d(TableRef))
m_ProjectScene.GetObjFilterForSel(m_bSelZeroDim, m_bSelCurve, m_bSelSurf, m_bSelVolume, m_bSelExtra)
Application.Msn.NotifyColleagues(Application.UPDATESTATUSGRID, New UpdateStatusGridParam(IniFile.m_bMachiningShowGrid, IniFile.m_bShowGridFrame))
End Sub)
Application.Msn.Register(Application.DRAWMODE_ISCHECKED, Sub()
' Ripristino il riferimento della griglia di disegno
EgtSetGridFrame(m_GridDrawFrame3d)
m_ProjectScene.SetObjFilterForSel(m_bSelZeroDim, m_bSelCurve, m_bSelSurf, m_bSelVolume, m_bSelExtra)
Application.Msn.NotifyColleagues(Application.UPDATESTATUSGRID, New UpdateStatusGridParam(IniFile.m_bDrawShowGrid, IniFile.m_bShowGridFrame))
End Sub)
@@ -91,6 +102,9 @@ Namespace EgtCAM5
Application.Msn.Register(Application.SETSCENESELTYPE, Sub(nSceneSelType As SceneSelTypeOpt)
Me.SceneSelType = nSceneSelType
End Sub)
Application.Msn.Register(Application.SETMOVEINDISPOSITION, Sub(bMoveInDisposition As Boolean)
Me.bMoveInDisposition = bMoveInDisposition
End Sub)
End Sub
#End Region
@@ -806,89 +820,216 @@ Namespace EgtCAM5
m_Controller.MouseDeselectedAll()
End Sub
Private m_bFixtureDrag As Boolean
' Identificativi per elemento da selezionare/deselezionare
Private m_nIdToSel As Integer = GDB_ID.NULL
Private m_nIdToDesel As Integer = GDB_ID.NULL
'Private m_nFirstRawPartId As Integer = GDB_ID.NULL
' Dati per Drag
Private m_nRestRadius As Integer = 3
Private m_bDrag As Boolean = False
Private m_bDragToStart As Boolean = False
Private m_bDragging As Boolean = False
Private m_locPrev As System.Drawing.Point
Private m_ptPrev As Point3d
Private Sub OnMouseDown(ByVal sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_ProjectScene.OnMouseDownScene
' Se in modalità Draw accetto tutto
' Se in modalità Draw esco
If IniFile.m_ProjectMode = ProjectModeOpt.DRAW Then Return
' Sono in modalità Machining
If e.Button = Forms.MouseButtons.Left Then
Dim nSel As Integer
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
Dim nId As Integer = EgtGetFirstObjInSelWin()
While nId <> GDB_ID.NULL
Select Case m_SceneSelType
Case SceneSelTypeOpt.FIXTURE
Dim nFixtureId As Integer = EgtGetParent(EgtGetParent(nId))
If IsPartInFixture(nFixtureId) Then
If EgtIsSelectedObj(nFixtureId) Then
EgtDeselectObj(nFixtureId)
Else
EgtSelectObj(nFixtureId)
If EgtUnProjectPoint(e.Location, m_ptPrev) Then
m_bFixtureDrag = True
End If
End If
EgtDraw()
Exit Sub
If m_SceneSelType = SceneSelTypeOpt.NULL Then Return
' Si può selezionare solo con il tasto sinistro se la selezione non è impostata a NULL
If e.Button <> Forms.MouseButtons.Left OrElse m_SceneSelType = SceneSelTypeOpt.NULL Then Return
' Per default no drag
m_bDrag = False
Dim nSel As Integer
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
Dim nId As Integer = EgtGetFirstObjInSelWin()
While nId <> GDB_ID.NULL
Select Case m_SceneSelType
Case SceneSelTypeOpt.FIXTURE
Dim nFixtureId As Integer = EgtGetParent(EgtGetParent(nId))
If EgtVerifyFixture(nFixtureId) Then
' Se già selezionato
If EgtIsSelectedObj(nFixtureId) Then
' Memorizzo Id da deselezionare
m_nIdToDesel = nFixtureId
Else
' Memorizzo Id da selezionare
m_nIdToSel = nFixtureId
End If
Case SceneSelTypeOpt.RAWPART
End Select
nId = EgtGetNextObjInSelWin()
End While
End If
' Drag possibile
m_bDrag = True
Exit While
End If
Case SceneSelTypeOpt.RAWPART, SceneSelTypeOpt.RAWPARTWITHFIXTURE
Dim nRawPartId As Integer = EgtGetParent(nId)
If EgtVerifyRawPartCurrPhase(nRawPartId) Then
' Se già selezionato
If EgtIsSelectedObj(nRawPartId) Then
' Memorizzo Id da deselezionare
m_nIdToDesel = nRawPartId
Else
' Memorizzo Id da selezionare
m_nIdToSel = nRawPartId
End If
' Drag possibile
m_bDrag = True
Exit While
End If
End Select
nId = EgtGetNextObjInSelWin()
End While
' Dati per drag
m_locPrev = e.Location
Dim TableRef As Point3d
EgtGetTableRef(1, TableRef)
m_bDrag = m_bDrag AndAlso EgtGetPlaneSnapPoint(e.Location, Vector3d.Z_AX, TableRef.z, m_ptPrev)
m_bDragToStart = m_bDrag
End Sub
Private Sub OnMyMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_ProjectScene.OnMouseMoveScene
' Se in modalità Draw accetto tutto
' Se in modalità Draw esco
If IniFile.m_ProjectMode = ProjectModeOpt.DRAW Then Return
' Sono in modalità Machining
' Verifico di essere in modalità drag
If Not m_bFixtureDrag Then Return
' Si può selezionare solo con il tasto sinistro se la selezione non è impostata a NULL
If e.Button <> Forms.MouseButtons.Left OrElse m_SceneSelType = SceneSelTypeOpt.NULL Then Return
' se non sono in modalità muovi esco
If Not m_bMoveInDisposition Then Return
' Se drag non abilitato o già in esecuzione, esco
If Not m_bDrag Or m_bDragging Then Return
' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel
If m_bDragToStart Then
If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And
Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then
Return
End If
m_bDragToStart = False
End If
' Determino cosa muovere
Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL)
' Inizio esecuzione di drag
m_bDragging = True
' Ricavo il punto corrente in coordinate mondo
Dim ptCurr As Point3d
EgtUnProjectPoint(e.Location, ptCurr)
Dim TableRef As Point3d
EgtGetTableRef(1, TableRef)
EgtGetPlaneSnapPoint(e.Location, Vector3d.Z_AX, TableRef.z, ptCurr)
' Ricavo il vettore di movimento (tengo solo XY)
Dim vtMove As Vector3d = ptCurr - m_ptPrev
vtMove.z = 0
' Eseguo modifica
' '' ''Dim nSelObjId As Integer = EgtGetFirstSelectedObj()
' '' ''While nSelObjId <> GDB_ID.NULL
' '' '' EgtMoveFixture(nSelObjId, vtMove)
' '' '' nSelObjId = EgtGetNextSelectedObj()
' '' ''End While
' '' ''EgtDraw()
'Select Case m_SceneSelType
' Case SceneSelTypeOpt.FIXTURE
' MoveFixture(ptCurr)
'End Select
' Muovo gli oggetti selezionati se consentito
DispositionParameterExpanderViewModel.MoveRawPartPartAndFixture(nMoveId, vtMove)
EgtDraw()
' Aggiorno il punto precedente
m_ptPrev = ptCurr
' Terminata esecuzione di drag
m_bDragging = False
End Sub
'Private Sub MoveFixture(ptCurr As Point3d)
' ' Muovo il grezzo
' If EgtMoveFixture(m_CurrProjPage.m_nRawId, vtMove) Then
' EgtDraw()
' '' Aggiorno gli offset
' 'm_RawOffsX += vtMove.x
' 'm_RawOffsY += vtMove.y
' 'OffsetXTxBx.Text = LenToString(m_RawOffsX, 2)
' 'OffsetYTxBx.Text = LenToString(m_RawOffsY, 2)
' End If
'End Sub
Private Sub OnMyMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_ProjectScene.OnMouseUpScene
' Se in modalità Draw accetto tutto
If IniFile.m_ProjectMode = ProjectModeOpt.DRAW Then Return
' Sono in modalità Machining
' Disabilito drag
m_bFixtureDrag = False
' Se eseguito drag
If Not m_bDragToStart Then
' Basta reset alla fine
' Se selezione da eseguire
ElseIf m_nIdToSel <> GDB_ID.NULL Then
' se sono in modalità sottopezzi
If m_SceneSelType = SceneSelTypeOpt.FIXTURE Then
' verifico se il sottopezzo da selezionare è un riferimento
If DispositionParameterExpanderViewModel.FixtureType(m_nIdToSel) = DispositionParameterExpanderViewModel.FIX_TYPE.REFERENCE _
AndAlso EgtGetSelectedObjCount() > 0 Then
' se ci sono altri oggetti selezionati resetto lo stato di selezione ed esco
m_bDrag = False
m_nIdToSel = GDB_ID.NULL
m_nIdToDesel = GDB_ID.NULL
EgtDraw()
Return
Else
' altrimenti verifico il tipo del primo oggetto selezionato
Dim nFirstSelId As Integer = EgtGetFirstSelectedObj()
If DispositionParameterExpanderViewModel.FixtureType(nFirstSelId) = DispositionParameterExpanderViewModel.FIX_TYPE.REFERENCE Then
' se è un riferimento resetto lo stato di selezione ed esco
m_bDrag = False
m_nIdToSel = GDB_ID.NULL
m_nIdToDesel = GDB_ID.NULL
EgtDraw()
Return
End If
End If
End If
' marco il primo elemento se questo è il secondo
If EgtGetSelectedObjCount() = 1 Then
' marco il primo tra i selezionati
Dim nFirstSelObj As Integer = EgtGetFirstSelectedObj()
EgtSetMark(nFirstSelObj)
End If
' se sono in modalità grezzo con relativi sottopezzi
If m_SceneSelType = SceneSelTypeOpt.RAWPARTWITHFIXTURE Then
' calcolo il BBox del grezzo
Dim bboxRawPart As New BBox3d
EgtGetBBoxGlob(m_nIdToSel, GDB_BB.STANDARD, bboxRawPart)
' ciclo sulle ventose
Dim bboxFixture As New BBox3d
Dim nFixtureId As Integer = EgtGetFirstFixture()
While nFixtureId <> GDB_ID.NULL
EgtGetBBoxGlob(nFixtureId, GDB_BB.STANDARD, bboxFixture)
' verifico quali sono sotto il grezzo selezionato
If bboxRawPart.OverlapsXY(bboxFixture) Then
' Eseguo la selezione
EgtSelectObj(nFixtureId)
End If
nFixtureId = EgtGetNextFixture(nFixtureId)
End While
End If
' Eseguo la selezione
EgtSelectObj(m_nIdToSel)
' Se deselezione da eseguire
ElseIf m_nIdToDesel <> GDB_ID.NULL Then
' se l'elemento da deselezionare è marcato
Dim bMarked As Boolean = False
EgtGetMark(m_nIdToDesel, bMarked)
If bMarked Then
' smarco l'oggetto deselezionato
EgtResetMark(m_nIdToDesel)
End If
' se sono in modalità ventose o grezzi
If m_SceneSelType = SceneSelTypeOpt.RAWPARTWITHFIXTURE Then
' calcolo il BBox del grezzo
Dim bboxRawPart As New BBox3d
EgtGetBBoxGlob(m_nIdToDesel, GDB_BB.STANDARD, bboxRawPart)
' ciclo sulle ventose
Dim bboxFixture As New BBox3d
Dim nFixtureId As Integer = EgtGetFirstFixture()
While nFixtureId <> GDB_ID.NULL
EgtGetBBoxGlob(nFixtureId, GDB_BB.STANDARD, bboxFixture)
' verifico quali sono sotto il grezzo selezionato
If bboxRawPart.OverlapsXY(bboxFixture) Then
' Eseguo la deselezione
EgtDeselectObj(nFixtureId)
End If
nFixtureId = EgtGetNextFixture(nFixtureId)
End While
End If
' Eseguo la deselezione
EgtDeselectObj(m_nIdToDesel)
If EgtGetSelectedObjCount() > 1 Then
' marco il primo
Dim nFirstSelObj As Integer = EgtGetFirstSelectedObj()
EgtSetMark(nFirstSelObj)
Else
' smarco il primo ed unico oggetto selezionato
Dim nFirstSelObj As Integer = EgtGetFirstSelectedObj()
EgtResetMark(nFirstSelObj)
End If
End If
' Reset
m_bDrag = False
m_nIdToSel = GDB_ID.NULL
m_nIdToDesel = GDB_ID.NULL
EgtDraw()
End Sub
Private Sub OnMouseSelectingObj(ByVal sender As Object, ByVal nId As Integer, ByRef bOk As Boolean) Handles m_ProjectScene.OnMouseSelectingObj
@@ -1241,6 +1382,17 @@ Namespace EgtCAM5
End Set
End Property
Private m_bMoveInDisposition As Boolean
Public Property bMoveInDisposition As Boolean
Get
Return m_bMoveInDisposition
End Get
Set(value As Boolean)
m_bMoveInDisposition = value
End Set
End Property
Friend Function IsPartInRaw(nSearchedPartId As Integer) As Boolean
Dim nRawId As Integer = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL
@@ -1256,17 +1408,6 @@ Namespace EgtCAM5
Return False
End Function
Friend Function IsPartInFixture(nSearchedPartId As Integer) As Boolean
Dim nFixtureId As Integer = EgtGetFirstFixture()
While nFixtureId <> GDB_ID.NULL
If nFixtureId = nSearchedPartId Then
Return True
End If
nFixtureId = EgtGetNextFixture(nFixtureId)
End While
Return False
End Function
#End Region ' Scene selection
End Class