Compare commits

...

2 Commits

Author SHA1 Message Date
NicolaP 601471482a Insrite funzioni per la gestione del DragRettangle 2022-02-15 19:14:47 +01:00
NicolaP 8e112dc210 Inserito comando DragRettangle (gestione da configurazione) 2022-02-07 18:42:01 +01:00
3 changed files with 380 additions and 8 deletions
+1
View File
@@ -121,6 +121,7 @@ Module ConstIni
Public Const K_TEXTCOLOR As String = "TextColor" Public Const K_TEXTCOLOR As String = "TextColor"
Public Const K_AUTOMATICOPTIMIZE As String = "AutomaticOptimize" Public Const K_AUTOMATICOPTIMIZE As String = "AutomaticOptimize"
Public Const K_AUTOMATICMAXTIME As String = "AutomaticMaxTime" Public Const K_AUTOMATICMAXTIME As String = "AutomaticMaxTime"
Public Const K_DRAGRETTANGLE As String = "DragRettangle"
Public Const S_SPLIT As String = "Split" Public Const S_SPLIT As String = "Split"
Public Const K_MOVE_LEV As String = "MoveLevel" Public Const K_MOVE_LEV As String = "MoveLevel"
+18 -5
View File
@@ -24,7 +24,7 @@
Command="{Binding ImportDxfCommand}"> Command="{Binding ImportDxfCommand}">
<Image Source="/Resources/NestingTab/ImportDxf.png" Stretch="Uniform"/> <Image Source="/Resources/NestingTab/ImportDxf.png" Stretch="Uniform"/>
</Button> </Button>
<ToggleButton Grid.Column="4" Grid.Row="0" <ToggleButton Grid.Column="4" Grid.Row="0"
Style="{StaticResource OptionPanel_NestingToggleButton}" Style="{StaticResource OptionPanel_NestingToggleButton}"
IsChecked="{Binding CsvImport_IsChecked}"> IsChecked="{Binding CsvImport_IsChecked}">
<Image Source="/Resources/NestingTab/ImportCsv.png" Stretch="Uniform"/> <Image Source="/Resources/NestingTab/ImportCsv.png" Stretch="Uniform"/>
@@ -148,11 +148,24 @@
Margin="2.5,0,0,0"/> Margin="2.5,0,0,0"/>
</UniformGrid> </UniformGrid>
<Button Content="{Binding RemovePartMsg}" <Grid Margin="0,0,-2.5,5">
Style="{StaticResource OptionPanel_TextButton}" <Grid.ColumnDefinitions>
Command="{Binding RemovePartCommand}" <ColumnDefinition Width="1*"/>
Margin="0,0,0,5"/> <ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Button Content="{Binding RemovePartMsg}"
Grid.ColumnSpan="{Binding DragRettangle_Cl_Span}"
Style="{StaticResource OptionPanel_TextButton}"
Command="{Binding RemovePartCommand}"
Margin="0,0,2.5,0"/>
<ToggleButton Content="{Binding DragRettangleMsg}" Grid.Column="1"
Visibility="{Binding DragRettangle_Visibility}"
Style="{StaticResource OptionPanel_ToggleButton}"
IsChecked="{Binding bDragRettangle}"
Margin="2.5,0,2.5,0"/>
</Grid>
<UniformGrid Columns="2" Margin="0,0,0,5"> <UniformGrid Columns="2" Margin="0,0,0,5">
<Button Content="{Binding SelectAllMsg}" <Button Content="{Binding SelectAllMsg}"
Style="{StaticResource OptionPanel_TextButton}" Style="{StaticResource OptionPanel_TextButton}"
+361 -3
View File
@@ -35,6 +35,18 @@ Public Class NestingTabVM
Private m_bTrfData As Boolean = False Private m_bTrfData As Boolean = False
Private m_bCsvData As Boolean = False Private m_bCsvData As Boolean = False
' Id del rettangolo, del traglio e della curva da modificare tramite Drag
Private m_nIdSelectedOutLoopRettangle As Integer = GDB_ID.NULL
Private m_nIdSelectedRegionRettangle As Integer = GDB_ID.NULL
Private m_nIdSelectedSawRettangle As Integer = GDB_ID.NULL
Private m_nIdSelectedCurvRettangle As Integer = GDB_ID.NULL
Private m_nIdSelectedTextRettangle As Integer = GDB_ID.NULL
Private m_nIdSelectedTextTopRettangle As Integer = GDB_ID.NULL
Private m_nIdSelectedFlatSurfRettangle As Integer = GDB_ID.NULL
Private m_SideListRettangle(4) As Integer
Private m_sTextContent As String = String.Empty
Private m_CsvImportWindow As CsvWindowV Private m_CsvImportWindow As CsvWindowV
Friend ReadOnly Property CsvImportWindow As CsvWindowV Friend ReadOnly Property CsvImportWindow As CsvWindowV
Get Get
@@ -161,6 +173,12 @@ Public Class NestingTabVM
End Get End Get
End Property End Property
Public ReadOnly Property DragRettangleMsg As String
Get
Return "Drag Rettangle"
End Get
End Property
Public ReadOnly Property SelectAllMsg As String Public ReadOnly Property SelectAllMsg As String
Get Get
Return EgtMsg(MSG_NESTPAGEUC + 4) Return EgtMsg(MSG_NESTPAGEUC + 4)
@@ -211,6 +229,13 @@ Public Class NestingTabVM
#Region "CONSTRUCTOR" #Region "CONSTRUCTOR"
Sub New() Sub New()
If (GetMainPrivateProfileInt(S_NEST, K_DRAGRETTANGLE, 1) <> 0) Then
m_DragRettangle_Visibility = Visibility.Visible
Else
m_DragRettangle_Visibility = Visibility.Collapsed
End If
NotifyPropertyChanged("DragRettangle_Visibility")
NotifyPropertyChanged("DragRettangle_Cl_Span")
' Creo riferimento a questa classe in OmagOFFICEMap ' Creo riferimento a questa classe in OmagOFFICEMap
OmagOFFICEMap.SetRefNestingTabVM(Me) OmagOFFICEMap.SetRefNestingTabVM(Me)
End Sub End Sub
@@ -506,8 +531,318 @@ Public Class NestingTabVM
Return True Return True
End Function End Function
#Region "DRAG RETTANGLE"
' funzione chiamata da OnMyMouseMoveScene: verifica che la selezione sia corretta (deve essere il lato di una figura rettangolare)
Private Sub OnMyMouseDownSceneSelSideRettangle(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Si può selezionare solo con il tasto sinistro e se il bottone TEST Attivo
If e.Button <> Windows.Forms.MouseButtons.Left Then
Return
End If
' Verifico se selezionato indicativo di pezzo
EgtSetObjFilterForSelWin(False, True, False, False, False)
Dim nSelMy As Integer
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSelMy)
Dim nIdMy As Integer = EgtGetFirstObjInSelWin()
While nIdMy <> GDB_ID.NULL
Dim sLayer As String = String.Empty
' layer di origine
Dim nIdParent As Integer = EgtGetParent(nIdMy)
' recupero il nome del Layer
EgtGetName(nIdParent, sLayer)
' solo se il nome del layer è quello associato ad un lato esterno allora procedo con l'evidenziazione
If sLayer = NAME_OUTLOOP Then
If EgtGetType(nIdMy) = GDB_TY.CRV_LINE Then
' -------------------------------- INIZIO VERIFICHE --------------------------------
m_nIdSelectedOutLoopRettangle = nIdParent
If Not IsRettangle(m_SideListRettangle) Then
'm_CurrProjPage.ClearMessage()
'm_CurrProjPage.SetWarningMessage("Non è un rettangolo (0)")
Return
End If
' recupero il gruppo della lavorazione associata
Dim nIdParentPart As Integer = EgtGetParent(nIdParent)
Dim nIdPV As Integer = EgtGetFirstNameInGroup(nIdParentPart, "PV")
' se non esiste un gruppo di lavorazione associato allora esco
If nIdPV = GDB_ID.NULL Then
'm_CurrProjPage.ClearMessage()
'm_CurrProjPage.SetWarningMessage("Pezzo in parcheggio (1)")
Return
End If
' se esiste ma è vuoto (pezzo scaricato da tavola)
If EgtGetFirstInGroup(nIdPV) = GDB_ID.NULL Then
'm_CurrProjPage.ClearMessage()
'm_CurrProjPage.SetWarningMessage("Pezzo in parcheggio (2)")
Return
End If
' Devo verificare che sia una lavorazione solo di lama?
Dim nIdSaw As Integer = EgtGetFirstNameInGroup(nIdPV, "Saw" & nIdMy.ToString)
' -------------------------------- FINE VERIFICHE --------------------------------
If Not EgtGetGroupObjs(nIdSaw) Then
m_nIdSelectedSawRettangle = nIdSaw
m_nIdSelectedCurvRettangle = nIdMy
m_nIdSelectedRegionRettangle = EgtGetFirstNameInGroup(nIdParentPart, NAME_REGION)
' recupero i testi cintenuti nel layer Region
If m_nIdSelectedRegionRettangle <> GDB_ID.NULL Then
Dim nCurrId As Integer = EgtGetFirstInGroup(m_nIdSelectedRegionRettangle)
While nCurrId <> GDB_ID.NULL
If EgtGetType(nCurrId) = GDB_TY.EXT_TEXT Then
Dim sVal As String = String.Empty
EgtTextGetContent(nCurrId, sVal)
If sVal = "*TOP*" Then
m_nIdSelectedTextTopRettangle = nCurrId
Else
m_nIdSelectedTextRettangle = nCurrId
m_sTextContent = GetMyRettangleText(sVal)
End If
ElseIf EgtGetType(nCurrId) = GDB_TY.SRF_FRGN Then
m_nIdSelectedFlatSurfRettangle = nCurrId
End If
nCurrId = EgtGetNext(nCurrId)
End While
End If
' seleziono ed evidenzio il lato selezionato
EgtSelectObj(nIdSaw)
EgtSetMark(nIdSaw)
EgtSelectObj(nIdMy)
EgtDraw()
Exit While
End If
End If
' se le'elemto corrente non è una linea
End If
' se le'elemto corrente non appartiene al layer OutLoop passo al prossimo elemento dell'elenco
nIdMy = EgtGetNextObjInSelWin()
End While
End Sub
' restituisce il valore del Text ripulito dalle dimensioni
Private Function GetMyRettangleText(sTextPz As String) As String
' da DrawPageUC.xaml.vb/MultipleInsert
Dim sText As String = String.Empty
If sTextPz.Contains("<br/>") Then
Dim nLastIndex As Integer = sTextPz.LastIndexOf(">")
sText = sTextPz.Remove(nLastIndex + 1)
Return sText
End If
If sTextPz.Contains(" ") Then
Dim sInfo() As String = sTextPz.Split(" "c)
If sInfo.Count > 3 Then
Return sText = sInfo(0) & " " & sInfo(1) & " "
End If
End If
Return sText
End Function
' verifico che la figura selezionata sia realmente un rettangolo
Private Function IsRettangle(ByRef IdSideList() As Integer) As Boolean
' creo una lista con i lati del rettangolo
Dim nCounter As Integer = 0
' recupero i lati dal leyer "OutLoop"
Dim IdSideRettangle As Integer = EgtGetFirstInGroup(m_nIdSelectedOutLoopRettangle)
While IdSideRettangle <> GDB_ID.NULL And nCounter < 4
Dim sVal As String = String.Empty
Dim dPrevAng As Double = 0
EgtGetInfo(IdSideRettangle, "PrevAng", sVal)
StringToDouble(sVal, dPrevAng)
Dim dNextAng As Double = 0
EgtGetInfo(IdSideRettangle, "NextAng", sVal)
StringToDouble(sVal, dNextAng)
' se gli angoli non sono retti allora esco senza caricare il lato corrente
If Math.Abs(dPrevAng - 90) > EPS_ANG_SMALL OrElse Math.Abs(dNextAng - 90) > EPS_ANG_SMALL Then
Exit While
End If
IdSideList(nCounter) = IdSideRettangle
nCounter += 1
IdSideRettangle = EgtGetNext(IdSideRettangle)
End While
' verifico che siano solo quattro lati
If IdSideRettangle = GDB_ID.NULL And nCounter = 4 Then
' solo se la figura ha 4 lati ortogonali
Return True
End If
m_nIdSelectedOutLoopRettangle = GDB_ID.NULL
' la figura presenta più/meno di 4 lati
Return False
End Function
' recupero le informazioni correnti per sapere se la figura è mdificabile
Private Function GetRettangleInfoScale(ByRef frFixed As Frame3d, ByRef MaxLen As Double, ByRef MinLen As Double) As Vector3d
' determino la direzione del lato selezionato
Dim vtDirSelectedCurv As New Vector3d
EgtStartVector(m_nIdSelectedCurvRettangle, GDB_ID.ROOT, vtDirSelectedCurv)
' recupero il lato successivo a quello selezionato
Dim Index As Integer = 0
Dim Len As Double = 0
For Ind As Integer = 0 To 3
If m_SideListRettangle(Ind) = m_nIdSelectedCurvRettangle Then
' verifico se esiste un lato Precedente altrimenti recupero l'ultimo della lista
If Ind = 0 Then
Index = 3
Else
Index = Ind - 1
End If
End If
Next
' recupero la dimensione del lato
EgtCurveLength(m_SideListRettangle(Index), MaxLen)
EgtCurveLength(m_nIdSelectedCurvRettangle, MinLen)
' verifico che il lato selezionato sia il maggiore
If MinLen > MaxLen Then Return Nothing
' determimo il versore dal lato appena calcolato
Dim vtDir As New Vector3d
EgtStartVector(m_SideListRettangle(Index), GDB_ID.ROOT, vtDir)
vtDir.Normalize()
Dim dProjectionBaseX As Double = vtDir * Vector3d.X_AX
Dim ptFixed As New Point3d
EgtStartPoint(m_SideListRettangle(Index), GDB_ID.ROOT, ptFixed)
Dim vtPerp As New Vector3d(vtDir.x, vtDir.y, vtDir.z)
vtPerp.Rotate(Vector3d.Z_AX, 90)
' determino il Frame corrente
frFixed = New Frame3d(ptFixed, vtDir, vtPerp, Vector3d.Z_AX)
Return vtDir
End Function
' funzione chiamata da OnMyMouseMoveScene: gestisce la modifica lungo una dimensione del rettangolo selezionato
Private Sub OnMyMouseMoveSawRettangle(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' 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
' riferiemento che deve rimanere fisso del rettangolo
Dim frFixed As Frame3d = Nothing
' lunghezza del lato da modificare
Dim MaxLen As Double = 0
Dim MinLen As Double = 0
' recupero info sul rettangolo selezionato
Dim vtDir As Vector3d = GetRettangleInfoScale(frFixed, MaxLen, MinLen)
If vtDir.Equals(Vector3d.NULL) Then
Return
End If
' Inizio esecuzione di drag
m_bDragging = True
' Ricavo il punto corrente in coordinate mondo
Dim ptCurr As Point3d
EgtUnProjectPoint(e.Location, ptCurr)
' Ricavo il vettore di movimento
Dim vtMove As Vector3d = ptCurr - m_ptPrev
' ricavo il valore efficace di allungamento (la proiezione)
Dim dProjection As Double = vtMove * vtDir
vtMove = vtDir * dProjection
' recupero il valore di scalatura
Dim dScalefactor = dProjection / MaxLen + 1
' Modifico dimensione figura
If Math.Abs(dScalefactor) > EPS_SMALL * EPS_SMALL Then
EgtScale(m_nIdSelectedOutLoopRettangle, frFixed, dScalefactor, 1, 1, GDB_ID.ROOT)
EgtScale(m_nIdSelectedFlatSurfRettangle, frFixed, dScalefactor, 1, 1, GDB_ID.ROOT)
Dim ptCen As Point3d
EgtCenterPoint(m_nIdSelectedTextRettangle, ptCen)
EgtModifyText(m_nIdSelectedTextRettangle, m_sTextContent & LenToString(MaxLen + dProjection, 2) & " x " & LenToString(MinLen, 2))
EgtMove(m_nIdSelectedTextRettangle, vtMove * 0.5)
If m_nIdSelectedTextTopRettangle <> GDB_ID.NULL Then
EgtMove(m_nIdSelectedTextTopRettangle, vtMove * 0.5)
End If
End If
Dim nWarn As Integer = 0
ResetAllMachinings(nWarn)
EnableReferenceRegion(False)
' se la modifica genera un errore allora ripristino la figura prima della defomrazione
If Not EgtVerifyPart(EgtGetParent(m_nIdSelectedOutLoopRettangle), True) Then
EgtScale(m_nIdSelectedOutLoopRettangle, frFixed, 1 / dScalefactor, 1, 1, GDB_ID.ROOT)
EgtScale(m_nIdSelectedFlatSurfRettangle, frFixed, 1 / dScalefactor, 1, 1, GDB_ID.ROOT)
Dim ptCen As Point3d
EgtCenterPoint(m_nIdSelectedTextRettangle, ptCen)
EgtModifyText(m_nIdSelectedTextRettangle, m_sTextContent & LenToString(MaxLen, 2) & " x " & LenToString(MinLen, 2))
EgtMove(m_nIdSelectedTextRettangle, -vtMove * 0.5)
If m_nIdSelectedTextTopRettangle <> GDB_ID.NULL Then
EgtMove(m_nIdSelectedTextTopRettangle, -vtMove * 0.5)
End If
End If
EgtDraw()
' Aggiorno il punto precedente
m_ptPrev = ptCurr
' Terminata esecuzione di drag
m_bDragging = False
End Sub
' funzione chiamata da OnMyMouseUp: gestisce il reset di tutti gli indici in uso
Public Sub ResetDragRettangleParam()
' deseleziono l'elemento corrente
EgtDeselectObj(m_nIdSelectedSawRettangle)
EgtDeselectObj(m_nIdSelectedCurvRettangle)
EgtResetMark(m_nIdSelectedSawRettangle)
' resetto gli indici
m_nIdSelectedOutLoopRettangle = GDB_ID.NULL
m_nIdSelectedRegionRettangle = GDB_ID.NULL
m_nIdSelectedSawRettangle = GDB_ID.NULL
m_nIdSelectedCurvRettangle = GDB_ID.NULL
m_nIdSelectedTextRettangle = GDB_ID.NULL
m_nIdSelectedTextTopRettangle = GDB_ID.NULL
m_nIdSelectedFlatSurfRettangle = GDB_ID.NULL
m_SideListRettangle = {GDB_ID.NULL, GDB_ID.NULL, GDB_ID.NULL, GDB_ID.NULL}
m_sTextContent = String.Empty
' disattivo il drag
m_bDrag = False
' aggiorno le lavorazioni
Dim nWarn As Integer = 0
ResetAllMachinings(nWarn)
EgtDraw()
End Sub
#End Region ' Drag Rettangolo
#End Region ' METHODS #End Region ' METHODS
Private m_bDragRettangle As Boolean
Public Property bDragRettangle As Boolean
Get
Return m_bDragRettangle
End Get
Set(value As Boolean)
m_bDragRettangle = value
End Set
End Property
Private m_DragRettangle_Visibility As Visibility = Visibility.Collapsed
Public ReadOnly Property DragRettangle_Visibility As Visibility
Get
Return m_DragRettangle_Visibility
End Get
End Property
Public ReadOnly Property DragRettangle_Cl_Span As Integer
Get
If m_DragRettangle_Visibility = Visibility.Visible Then
Return 1
End If
Return 2
End Get
End Property
#Region "COMMANDS" #Region "COMMANDS"
#Region "DrawCommand" #Region "DrawCommand"
@@ -1169,6 +1504,17 @@ Public Class NestingTabVM
#Region "EVENTS" #Region "EVENTS"
Friend Sub OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs) Friend Sub OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs)
' se in modalità DragRettangle (deformazione delle componenti rettangolari)
If m_bDragRettangle Then
OnMyMouseDownSceneSelSideRettangle(sender, e)
' Dati per drag (abilito il Drag)
m_locPrev = e.Location
m_bDrag = EgtUnProjectPoint(e.Location, m_ptPrev) And m_nIdSelectedCurvRettangle <> GDB_ID.NULL
m_bDragToStart = m_bDrag
m_bVerify = m_bDrag AndAlso (Keyboard.Modifiers And ModifierKeys.Shift) > 0
m_vtTotMove = Vector3d.NULL()
Return
End If
' Per default no drag ' Per default no drag
m_bDrag = False m_bDrag = False
' Verifico se selezionato indicativo di pezzo ' Verifico se selezionato indicativo di pezzo
@@ -1216,6 +1562,13 @@ Public Class NestingTabVM
End If End If
m_bDragToStart = False m_bDragToStart = False
End If End If
' se devo muovere un lato del rettangolo
If m_bDragRettangle Then
OnMyMouseMoveSawRettangle(sender, e)
Return
End If
' Determino cosa muovere ' Determino cosa muovere
Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL) Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL)
' Verifico se in tavola o in parcheggio ' Verifico se in tavola o in parcheggio
@@ -1304,6 +1657,11 @@ Public Class NestingTabVM
End Sub End Sub
Friend Sub OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Friend Sub OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
If m_bDragRettangle Then
' deseleziono gli oggeti, resetto le variabili usate, aggiorno il disegno
ResetDragRettangleParam()
Return
End If
' Se eseguito drag ' Se eseguito drag
If Not m_bDragToStart Then If Not m_bDragToStart Then
' Se movimento con sola verifica finale ' Se movimento con sola verifica finale
@@ -1337,11 +1695,11 @@ Public Class NestingTabVM
End If End If
End If End If
m_bFromParking = False m_bFromParking = False
' altrimenti caso con verifica durante il movimento ' altrimenti caso con verifica durante il movimento
Else Else
' Basta reset alla fine ' Basta reset alla fine
End If End If
' Se selezione da eseguire ' Se selezione da eseguire
ElseIf m_nIdToSel <> GDB_ID.NULL Then ElseIf m_nIdToSel <> GDB_ID.NULL Then
' Determino se pezzo in tavola o in parcheggio ' Determino se pezzo in tavola o in parcheggio
Dim bPartInTable As Boolean = (EgtGetParent(m_nIdToSel) = GetRawId()) Dim bPartInTable As Boolean = (EgtGetParent(m_nIdToSel) = GetRawId())
@@ -1358,7 +1716,7 @@ Public Class NestingTabVM
VeinMatching.OnSelectPart(m_nIdToSel) VeinMatching.OnSelectPart(m_nIdToSel)
' Set flag posizione selezionati ' Set flag posizione selezionati
m_nPartPos = If(bPartInTable, PART_POS.IN_TABLE, PART_POS.OUT_TABLE) m_nPartPos = If(bPartInTable, PART_POS.IN_TABLE, PART_POS.OUT_TABLE)
' Se deselezione da eseguire ' Se deselezione da eseguire
ElseIf m_nIdToDesel <> GDB_ID.NULL Then ElseIf m_nIdToDesel <> GDB_ID.NULL Then
EgtDeselectObj(m_nIdToDesel) EgtDeselectObj(m_nIdToDesel)
' Eventuale aggiornamento VeinMatching ' Eventuale aggiornamento VeinMatching