OmagCUT :

- aggiunta creazione grezzo da riconoscimento contorno da fotografia.
This commit is contained in:
Dario Sassi
2017-01-14 18:50:40 +00:00
parent 90f5bdea7a
commit d6eee85a02
6 changed files with 128 additions and 33 deletions
+10 -1
View File
@@ -642,7 +642,6 @@ Public Class CurrentProjectPageUC
Friend Function LoadContour(sPath As String) As Boolean
' Elimino eventuale vecchio contorno
RemoveContour()
EgtErase(EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE))
' Verifico esistenza file contorno
If Not File.Exists(sPath) Then Return False
' Leggo eventuale file dati aggiuntivi
@@ -874,6 +873,16 @@ Public Class CurrentProjectPageUC
EgtErase(EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE))
End Sub
Friend Sub ShowContour(bShow As Boolean)
' Disabilito impostazione modificato
Dim bOldEnMod As Integer = EgtGetEnableModified()
If bOldEnMod Then EgtDisableModified()
' Cambio stato di visualizzazione
EgtSetStatus(EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE), If(bShow, GDB_ST.ON_, GDB_ST.OFF))
' Se necessario, ripristino precedente impostazione modificato
If bOldEnMod Then EgtEnableModified()
End Sub
' Gestione messaggi in interfaccia
Friend Sub SetInfoMessage(sMessage As String)
+2
View File
@@ -74,6 +74,8 @@ Public Class NestPageUC
m_bReducedCut = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_REDUCEDCUT, 0, m_MainWindow.GetMachIniFile()) <> 0)
' Garantisco visibilità pezzi parcheggiati
ShowParkedParts()
' Garantisco visibilità eventuale contorno da foto
m_CurrProjPage.ShowContour(True)
EgtZoom(ZM.ALL)
End Sub
+3
View File
@@ -148,6 +148,9 @@
</GroupBox>
<Button Name="ConfirmPhotoBtn" Grid.Row="4" Grid.ColumnSpan="2" Visibility="Hidden"
Style="{StaticResource OmagCut_YellowTextButton}"/>
</Grid>
<!-- Definizione della Grid Inferiore per i Button V e X -->
+109 -32
View File
@@ -43,6 +43,7 @@ Public Class RawPartPageUC
Private m_nTempLay As Integer = GDB_ID.NULL
' Definizione lista modalità di definizione grezzo per ComboBox
Private m_RawModeList(2) As String
Private m_RawModeListEx(3) As String
' Variabile che indica la zona danneggiata selezionata
Private m_nSelDmg As Integer
' Array per modalità per punti
@@ -80,7 +81,8 @@ Public Class RawPartPageUC
RECTANGLE = 0
BY_POINTS = 1
FROM_LASER = 2
DAMAGED = 3
FROM_PHOTO = 3
DAMAGED = 4
End Enum
Private Sub RawPartPage_Initialized(sender As Object, e As EventArgs)
@@ -102,9 +104,13 @@ Public Class RawPartPageUC
KerfTxBx.Tag = KerfTxBl
' Creo list modalità di definizione del grezzo
m_RawModeList(0) = EgtMsg(MSG_RAWPARTPAGEUC + 1)
m_RawModeList(1) = EgtMsg(MSG_RAWPARTPAGEUC + 2)
m_RawModeList(2) = EgtMsg(MSG_RAWPARTPAGEUC + 30)
m_RawModeList(0) = EgtMsg(MSG_RAWPARTPAGEUC + 1) 'Rettangolo
m_RawModeList(1) = EgtMsg(MSG_RAWPARTPAGEUC + 2) 'Per Punti
m_RawModeList(2) = EgtMsg(MSG_RAWPARTPAGEUC + 30) 'Da Laser
m_RawModeListEx(0) = EgtMsg(MSG_RAWPARTPAGEUC + 1) 'Rettangolo
m_RawModeListEx(1) = EgtMsg(MSG_RAWPARTPAGEUC + 2) 'Per Punti
m_RawModeListEx(2) = EgtMsg(MSG_RAWPARTPAGEUC + 30) 'Da Laser
m_RawModeListEx(3) = EgtMsg(MSG_RAWPARTPAGEUC + 35) 'Da Fotografia
RawModeCmBx.ItemsSource = m_RawModeList
' Imposto i messaggi letti dal file dei messaggi
@@ -123,14 +129,21 @@ Public Class RawPartPageUC
PointsGpBx.Header = EgtMsg(MSG_RAWPARTPAGEUC + 13) 'Points - Punti
AddBtn.Content = EgtMsg(MSG_RAWPARTPAGEUC + 14) 'Add - Aggiungi
RemoveBtn.Content = EgtMsg(MSG_RAWPARTPAGEUC + 15) 'Remove - Rimuovi
CloseBtn.Content = EgtMsg(MSG_RAWPARTPAGEUC + 31) 'Close - Chiudi
CloseBtn.Content = EgtMsg(MSG_RAWPARTPAGEUC + 31) 'Close - Chiudi
ConfirmPhotoBtn.Content = EgtMsg(MSG_RAWPARTPAGEUC + 24) 'Conferma
End Sub
Private Sub RawPartPage_Loaded(sender As Object, e As RoutedEventArgs)
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
m_bActive = True
' correggo differenza tra machinebuttons che ha 10 colonne e spazio disponibile solo per 9 facendolo sbordare(non si vede perchè la parte che avanza è vuota)
' Correggo differenza tra machinebuttons che ha 10 colonne e spazio disponibile solo per 9 facendolo sbordare(non si vede perchè la parte che avanza è vuota)
m_MachineButtons.Width = LowerButtonGrid.ActualWidth / 12 * 10
' Se disponibile, imposto possibilità di contorno da foto
If m_CurrProjPage.GetContour() = GDB_ID.NULL Then
RawModeCmBx.ItemsSource = m_RawModeList
Else
RawModeCmBx.ItemsSource = m_RawModeListEx
End If
' Colori standard
GetPrivateProfileColor(S_RAWPART, K_RAWCOLOR, m_RawCol, m_MainWindow.GetIniFile())
GetPrivateProfileColor(S_RAWPART, K_KERFCOLOR, m_KerfCol, m_MainWindow.GetIniFile())
@@ -201,16 +214,14 @@ Public Class RawPartPageUC
' Determino modalità di definizione
OutlineBtn.IsChecked = True
If EgtExistsInfo(m_CurrProjPage.m_nRawId, KEY_RAWBYPOINTS) Then
m_ActiveRawMode = RAWMODE.BY_POINTS
RawModeCmBx.SelectedIndex = m_ActiveRawMode
RawModeCmBx.SelectedIndex = RAWMODE.BY_POINTS
PointsGpBx.Visibility = Windows.Visibility.Visible
CloseBtn.Visibility = Windows.Visibility.Hidden
' Visualizzo crocette
UpdateCircles()
EgtZoom(ZM.ALL)
Else
m_ActiveRawMode = RAWMODE.RECTANGLE
RawModeCmBx.SelectedIndex = m_ActiveRawMode
RawModeCmBx.SelectedIndex = RAWMODE.RECTANGLE
PointsGpBx.Visibility = Windows.Visibility.Hidden
UpdateRawPart(bHeightModified)
End If
@@ -294,10 +305,8 @@ Public Class RawPartPageUC
' ci devono essere almeno 4 punti
If EgtGetCurveCompoJointCount(nKerfId) >= 4 Then
EgtRemoveCurveCompoJoint(nKerfId, CInt(m_dDragPar))
' aggiorno il solido del grezzo
' Aggiorno il solido del grezzo, l'ingombro e la posizione
UpdateRawPartKerf()
' aggiorno l'ingombro e la posizione del grezzo
UpdateRawXYData()
' Aggiorno cerchi
UpdateCircles()
EgtDraw()
@@ -350,10 +359,8 @@ Public Class RawPartPageUC
' ci devono essere almeno 4 punti
If EgtGetCurveCompoJointCount(m_nSelDmg) >= 4 Then
EgtRemoveCurveCompoJoint(m_nSelDmg, CInt(m_dDragPar))
' aggiorno il solido del grezzo
' aggiorno il solido del grezzo, l'ingombro e la posizione
UpdateRawPartKerf()
' aggiorno l'ingombro e la posizione del grezzo
UpdateRawXYData()
' Aggiorno cerchi
UpdateCircles()
EgtDraw()
@@ -476,10 +483,8 @@ Public Class RawPartPageUC
ptCurr.z = m_ptTableMin.z + m_CurrentMachine.dAdditionalTable + m_RawHeight
' Sposto il punto
If Not EgtModifyCurveCompoJoint(nKerfId, nU, ptCurr, GDB_RT.GLOB) Then Return
' Aggiorno il grezzo
' Aggiorno il grezzo, l'ingombro e la posizione
UpdateRawPartKerf()
' Aggiorno dimensioni e posizione grezzo
UpdateRawXYData()
' Salvo il valore del kerf (sempre in mm)
EgtSetInfo(m_CurrProjPage.m_nRawId, KEY_KERF, m_RawKerf)
' Aggiorno cerchi
@@ -583,6 +588,7 @@ Public Class RawPartPageUC
Case 0 ' Rettangolo
' Se ero in modalità da laser
VerifyLaserDefining()
' Imposto nuova modalità
m_ActiveRawMode = RAWMODE.RECTANGLE
' Riattivo i controlli in base a quale modalità di inserimento contorni è attiva
RawModeView()
@@ -591,12 +597,14 @@ Public Class RawPartPageUC
Case 1 ' Punti
' Se ero in modalità da laser
VerifyLaserDefining()
' Imposto nuova modalità
m_ActiveRawMode = RAWMODE.BY_POINTS
' Riattivo i controlli in base a quale modalità di inserimento contorni è attiva
RawModeView()
UpdateCircles()
EgtDraw()
Case 2 ' Da laser
' Imposto nuova modalità
m_ActiveRawMode = RAWMODE.FROM_LASER
RemoveCircles()
LoadFromMachine()
@@ -610,6 +618,17 @@ Public Class RawPartPageUC
' Disattivo il bottone
CloseBtn.IsEnabled = False
OkBtn.IsEnabled = False
Case 3 ' Da fotografia
' Se ero in modalità da laser
VerifyLaserDefining()
' Imposto nuova modalità
m_ActiveRawMode = RAWMODE.FROM_PHOTO
' Riattivo i controlli in base a quale modalità di inserimento contorni è attiva
RawModeView()
RemoveCircles()
' Creo il grezzo dal contorno riconosciuto nella fotografia
CreateRawFromPhotoContour()
EgtDraw()
End Select
End Sub
@@ -624,6 +643,7 @@ Public Class RawPartPageUC
PointsGpBx.Visibility = Windows.Visibility.Hidden
' Disattivo bottoni zone rovinate
DamagedAreaGpBx.Visibility = Windows.Visibility.Hidden
ConfirmPhotoBtn.Visibility = Windows.Visibility.Hidden
Case RAWMODE.BY_POINTS
RawModeCmBx.IsEnabled = True
LengthTxBx.IsEnabled = False
@@ -636,8 +656,9 @@ Public Class RawPartPageUC
AddBtn.SetValue(Grid.RowSpanProperty, 2)
RemoveBtn.SetValue(Grid.RowSpanProperty, 2)
CloseBtn.Visibility = Windows.Visibility.Hidden
' Disattivo bottoni zone rovinate
' Disattivo bottoni zone rovinate e foto
DamagedAreaGpBx.Visibility = Windows.Visibility.Hidden
ConfirmPhotoBtn.Visibility = Windows.Visibility.Hidden
Case RAWMODE.FROM_LASER
RawModeCmBx.IsEnabled = True
LengthTxBx.IsEnabled = False
@@ -650,8 +671,9 @@ Public Class RawPartPageUC
AddBtn.SetValue(Grid.RowSpanProperty, 1)
RemoveBtn.SetValue(Grid.RowSpanProperty, 1)
CloseBtn.Visibility = Windows.Visibility.Visible
' Disattivo bottoni zone rovinate
' Disattivo bottoni zone rovinate e foto
DamagedAreaGpBx.Visibility = Windows.Visibility.Hidden
ConfirmPhotoBtn.Visibility = Windows.Visibility.Hidden
Case RAWMODE.DAMAGED
RawModeCmBx.IsEnabled = False
LengthTxBx.IsEnabled = False
@@ -667,6 +689,19 @@ Public Class RawPartPageUC
CloseBtn.Visibility = Windows.Visibility.Hidden
' Attivo bottoni zone rovinate
DamagedAreaGpBx.Visibility = Windows.Visibility.Visible
' Disattivo bottoni foto
ConfirmPhotoBtn.Visibility = Windows.Visibility.Hidden
Case RAWMODE.FROM_PHOTO
RawModeCmBx.IsEnabled = True
LengthTxBx.IsEnabled = False
WidthTxBx.IsEnabled = False
OffsetXTxBx.IsEnabled = False
OffsetYTxBx.IsEnabled = False
' Nascondo bottoni per punti e zone rovinate
PointsGpBx.Visibility = Windows.Visibility.Hidden
DamagedAreaGpBx.Visibility = Windows.Visibility.Hidden
' Visualizzo bottoni foto
ConfirmPhotoBtn.Visibility = Windows.Visibility.Visible
End Select
End Sub
@@ -808,6 +843,15 @@ Public Class RawPartPageUC
End Select
End Sub
Private Sub ConfirmPhotoBtn_Click(sender As Object, e As RoutedEventArgs) Handles ConfirmPhotoBtn.Click
' Passo in modalità per punti
RawModeCmBx.SelectedIndex = RAWMODE.BY_POINTS
' Riattivo i controlli in base a quale modalità di inserimento contorni è attiva
RawModeView()
UpdateCircles()
EgtDraw()
End Sub
Private Sub UpdateRawPart(Optional bHeightModified As Boolean = False)
' Se cambiato spessore e c'è foto, aggiorno quota fotografia
If bHeightModified And m_CurrProjPage.GetPhoto() <> GDB_ID.NULL Then
@@ -888,11 +932,11 @@ Public Class RawPartPageUC
If m_CurrProjPage.m_nRawId = GDB_ID.NULL Then
UpdateRawPart(True)
Return
' se da cancellare
' se da cancellare
ElseIf m_RawHeight < EPS_SMALL Then
EgtRemoveRawPart(m_CurrProjPage.m_nRawId)
m_CurrProjPage.m_nRawId = GDB_ID.NULL
' altrimenti da aggiornare
' altrimenti da aggiornare
Else
' Aggiorno solido
EgtModifyRawPartHeight(m_CurrProjPage.m_nRawId, m_RawHeight)
@@ -918,9 +962,7 @@ Public Class RawPartPageUC
Private Sub UpdateRawPartKerf()
' Se non c'è il grezzo, esco
If m_CurrProjPage.m_nRawId = GDB_ID.NULL Then
Return
End If
If m_CurrProjPage.m_nRawId = GDB_ID.NULL Then Return
' Recupero percorso di contorno kerf
Dim nKerfId As Integer = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, NAME_KERF)
' Recupero colore grezzo ( in presenza di foto rendo molto più trasparente)
@@ -962,6 +1004,29 @@ Public Class RawPartPageUC
End If
End Sub
Private Function CreateRawFromPhotoContour() As Boolean
' Calcolo offset interno di kerf dal contorno riconosciuto nella fotografia
Dim nCount As Integer = 0
Dim nKerfId As Integer = EgtOffsetCurveAdv(m_CurrProjPage.GetContour(), -m_RawKerf, OFF_TYPE.EXTEND, nCount)
If nKerfId = GDB_ID.NULL Then
EgtOutLog("Error on RawPart from Photo Contour")
Return False
End If
' Cancello eventuali curve risultato dell'offset oltre la prima
For i = 1 To nCount - 1
EgtErase(nKerfId + i)
Next
' Cancello il vecchio kerf
EgtErase(EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, NAME_KERF))
' Sposto la curva di offset nel gruppo del grezzo e la rinomino come kerf
EgtRelocateGlob(nKerfId, m_CurrProjPage.m_nRawId)
EgtSetName(nKerfId, NAME_KERF)
EgtSetColor(nKerfId, m_KerfCol)
' Aggiorno il grezzo, l'ingombro e la posizione
UpdateRawPartKerf()
Return True
End Function
Private Sub AdjustRawPartOnStart()
' Se non c'è la foto va già bene così
If m_CurrProjPage.GetPhoto() = GDB_ID.NULL Then Return
@@ -1079,7 +1144,17 @@ Public Class RawPartPageUC
m_CurrProjPage.ClearMessage()
If Math.Abs(dHeight - m_RawHeight) > EPS_SMALL Then
m_RawHeight = dHeight
UpdateRawPartHeight()
If m_ActiveRawMode <> RAWMODE.FROM_PHOTO Or m_RawHeight < EPS_SMALL Then
UpdateRawPartHeight()
Else
' Aggiorno spessore in progetto corrente
m_CurrProjPage.m_dRawHeight = m_RawHeight
' Aggiorno quota fotografia e contorno
m_CurrProjPage.UpdatePhoto()
m_CurrProjPage.UpdateContour()
' Ricreo grezzo
CreateRawFromPhotoContour()
End If
' Ridisegno
EgtDraw()
End If
@@ -1129,7 +1204,11 @@ Public Class RawPartPageUC
Math.Min(m_dTableLength - m_RawLength - m_RawOffsX, m_dTableWidth - m_RawWidth - m_RawOffsY))
If dKerf >= dMinKerf And dKerf <= dMaxKerf Then
m_RawKerf = dKerf
UpdateRawPartKerf()
If m_ActiveRawMode <> RAWMODE.FROM_PHOTO Then
UpdateRawPartKerf()
Else
CreateRawFromPhotoContour()
End If
' Ridisegno
EgtDraw()
ElseIf dKerf < dMinKerf Then
@@ -1314,7 +1393,7 @@ Public Class RawPartPageUC
Next
' Azzero lista e punto di partenza
m_CurveXKerfList.Clear()
'Creo rettangolo
' Creo rettangolo
UpdateRawPart()
End If
m_bIsRawDefiningByLaser = False
@@ -1353,10 +1432,8 @@ Public Class RawPartPageUC
EgtSetColor(nKerfId, m_KerfCol)
' Pulisco lista entità del grezzo
m_CurveXKerfList.Clear()
' Aggiorno il grezzo
' Aggiorno il grezzo comprese dimensioni e posizione
UpdateRawPartKerf()
' Aggiorno dimensioni e posizione grezzo
UpdateRawXYData()
' Salvo il valore del kerf (sempre in mm)
EgtSetInfo(m_CurrProjPage.m_nRawId, KEY_KERF, m_RawKerf)
' Segno flag che indica fine della definizione
+2
View File
@@ -98,6 +98,8 @@ Public Class SimulationPageUC
m_CurrProjPage.SaveFile(sMchPath)
' Nascondo eventuali pezzi in parcheggio
HideParkedParts()
' Nascondo eventuale contorno da foto
m_CurrProjPage.ShowContour(False)
' Imposto prima fase
EgtSetCurrPhase(1)
ShowAllCurrPhaseMachinings()
+2
View File
@@ -46,6 +46,8 @@ Public Class SplitPageUC
End If
' Nascondo eventuali pezzi in parcheggio
HideParkedParts()
' Nascondo eventuale contorno da foto
m_MainWindow.m_CurrentProjectPageUC.ShowContour(False)
' Deseleziono pezzi
EgtDeselectAll()
EgtZoom(ZM.ALL)