OmagCut :
- inserito movimento manuale di pezzi (esatto solo per rettangolari).
This commit is contained in:
@@ -7,11 +7,11 @@ Public Class CadCutPageUC
|
||||
Private m_MainWindow As MainWindow = Application.Current.MainWindow
|
||||
|
||||
'Dichiarazione delle Page UserControl
|
||||
Friend m_NestPage As NestPageUC
|
||||
Friend WithEvents m_NestPage As NestPageUC
|
||||
Friend m_SplitPage As SplitPageUC
|
||||
|
||||
'Variabile che indica la modalità
|
||||
Private m_bNesting As Boolean = False
|
||||
Friend m_bNesting As Boolean = False
|
||||
|
||||
Private Sub CadCutPage_Initialized(sender As Object, e As EventArgs)
|
||||
|
||||
@@ -34,7 +34,6 @@ Public Class CadCutPageUC
|
||||
End Sub
|
||||
|
||||
Private Sub CadCutPage_Loaded(sender As Object, e As RoutedEventArgs)
|
||||
|
||||
'Seleziono UserControl di apertura
|
||||
CadCutPageGrid.Children.Add(m_NestPage)
|
||||
m_bNesting = True
|
||||
|
||||
@@ -81,10 +81,19 @@ Module ConstIni
|
||||
Public Const K_FLPWINPLACE As String = "WinPlace"
|
||||
Public Const K_FLPCURRDIR As String = "CurrDir"
|
||||
|
||||
Public Const S_NEST As String = "Nest"
|
||||
Public Const K_RAWCOLOR As String = "RawColor"
|
||||
Public Const K_DIRECT As String = "Direct"
|
||||
Public Const K_STEP As String = "Step"
|
||||
|
||||
Public Const S_MACH As String = "Mach"
|
||||
Public Const K_MACHINESDIR As String = "MachinesDir"
|
||||
Public Const K_CURRMACH As String = "CurrMach"
|
||||
|
||||
Public Const S_MATERIALS As String = "Materials"
|
||||
Public Const K_CURRMATERIAL As String = "CurrMaterial"
|
||||
Public Const K_MATERIAL As String = "Material"
|
||||
|
||||
Public Const S_MRUFILES As String = "MruFiles"
|
||||
Public Const S_MRUSCRIPTS As String = "MruScripts"
|
||||
Public Const K_FILE As String = "File"
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
Public Class CurrentProjectPageUC
|
||||
|
||||
' Dichiarazione eventi
|
||||
Friend Event OnMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
|
||||
Friend Event OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
|
||||
Friend Event OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
|
||||
|
||||
' Riferimento alla MainWindow
|
||||
Private m_MainWindow As MainWindow = Application.Current.MainWindow
|
||||
|
||||
@@ -118,34 +123,16 @@ Public Class CurrentProjectPageUC
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub OnMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles CurrentProjectScene.OnMouseDownScene
|
||||
' Si può selezionare solo con il tasto sinistro e se stato NULL
|
||||
If e.Button <> Windows.Forms.MouseButtons.Left Or Not CurrentProjectScene.IsStatusNull() Then
|
||||
Return
|
||||
End If
|
||||
' Verifico se selezionato indicativo di pezzo
|
||||
EgtSetObjFilterForSelect(True, True, True, True, True)
|
||||
Dim nSel As Integer
|
||||
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
|
||||
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
||||
While nId <> GDB_ID.NULL
|
||||
' Recupero l'identificativo del pezzo cui appartiene
|
||||
Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
|
||||
If EgtIsPart(nPartId) Or EgtGetParent(nPartId) = m_nRawId Then
|
||||
Dim nStat As Integer = GDB_ST.ON_
|
||||
EgtGetStatus(nPartId, nStat)
|
||||
' Se selezionato
|
||||
If nStat = GDB_ST.SEL Then
|
||||
' Deseleziono
|
||||
EgtDeselectObj(nPartId)
|
||||
Else
|
||||
EgtSelectObj(nPartId)
|
||||
End If
|
||||
EgtDraw()
|
||||
Exit While
|
||||
End If
|
||||
nId = EgtGetNextObjInSelWin()
|
||||
End While
|
||||
Private Sub OnMyMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles CurrentProjectScene.OnMouseDownScene
|
||||
RaiseEvent OnMouseDownScene(sender, e)
|
||||
End Sub
|
||||
|
||||
Private Sub OnMyMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles CurrentProjectScene.OnMouseMoveScene
|
||||
RaiseEvent OnMouseMoveScene(sender, e)
|
||||
End Sub
|
||||
|
||||
Private Sub OnMyMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles CurrentProjectScene.OnMouseUpScene
|
||||
RaiseEvent OnMouseUpScene(sender, e)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
+18
-13
@@ -303,7 +303,9 @@ Public Class DrawPageUC
|
||||
End Function
|
||||
|
||||
Private Function MakeInsert(ByVal nNbr As Integer) As Boolean
|
||||
' recupero dimensioni del grezzo
|
||||
' Recupero flag per inserimento diretto in grezzo o in parcheggio
|
||||
Dim bDirect As Boolean = GetPrivateProfileInt(S_NEST, K_DIRECT, 0, m_MainWindow.GetIniFile()) <> 0
|
||||
' Recupero dimensioni del grezzo
|
||||
Dim nRawId As Integer = EgtGetFirstRawPart()
|
||||
Dim ptMin, ptMax As Point3d
|
||||
Dim nFlag As Integer = GDB_BB.ONLY_VISIBLE + GDB_BB.IGNORE_TEXT + GDB_BB.IGNORE_DIM
|
||||
@@ -327,14 +329,19 @@ Public Class DrawPageUC
|
||||
End If
|
||||
' Ne recupero l'Id
|
||||
Dim nId2 As Integer = EgtGetLastPart()
|
||||
' Lo posiziono in ordine
|
||||
Dim ptPmin, ptPmax As Point3d
|
||||
EgtGetBBoxGlob(nId2, nFlag, ptPmin, ptPmax)
|
||||
ptPmin.z = ptMax.z
|
||||
EgtAddPartToRawPart(nId2, ptPmin, nRawId)
|
||||
If Not EgtPackPart(nId2, ptMin.x, ptMin.y, ptMax.x, ptMax.y, 4, True) Then
|
||||
EgtRemovePartFromRawPart(nId2)
|
||||
EgtSetStatus(nId2, GDB_ST.ON_)
|
||||
' Se richiesto posizionamento diretto nel grezzo
|
||||
If bDirect Then
|
||||
Dim ptPmin, ptPmax As Point3d
|
||||
EgtGetBBoxGlob(nId2, nFlag, ptPmin, ptPmax)
|
||||
ptPmin.z = ptMax.z
|
||||
EgtAddPartToRawPart(nId2, ptPmin, nRawId)
|
||||
If Not EgtPackPart(nId2, ptMin.x, ptMin.y, ptMax.x, ptMax.y, 4, True) Then
|
||||
EgtRemovePartFromRawPart(nId2)
|
||||
EgtSetStatus(nId2, GDB_ST.ON_)
|
||||
EgtPackPart(nId2, -5000, -INFINITO, 1000, -3000, 20, False)
|
||||
End If
|
||||
' Altrimenti lo posiziono in parcheggio
|
||||
Else
|
||||
EgtPackPart(nId2, -5000, -INFINITO, 1000, -3000, 20, False)
|
||||
End If
|
||||
Next
|
||||
@@ -402,20 +409,18 @@ Public Class DrawPageUC
|
||||
'End Sub
|
||||
|
||||
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
|
||||
|
||||
' se errore esco
|
||||
If Not m_bDrawOk Then
|
||||
Return
|
||||
End If
|
||||
' Leggo numero di pezzi da inserire
|
||||
'Dim InsNbr As Integer = tbNbr.Text
|
||||
Dim InsNbr As Integer = Int32.Parse(PartNumTxBx.Text)
|
||||
' Passo al contesto principale
|
||||
EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
|
||||
' Inserisco il componente nel DB geometrico principale
|
||||
MakeInsert(Int32.Parse(PartNumTxBx.Text))
|
||||
MakeInsert(InsNbr)
|
||||
' Aggiorno ambiente principale
|
||||
EgtZoom(ZM.ALL)
|
||||
|
||||
'Istruzioni per chiudere ImportPageUC e aprire CadCutPageUC
|
||||
m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_DrawPageUC)
|
||||
m_MainWindow.MainWindowGrid.Children.Add(m_MainWindow.m_CurrentProjectPageUC)
|
||||
|
||||
+15
-8
@@ -338,6 +338,8 @@ Public Class ImportPageUC
|
||||
End Sub
|
||||
|
||||
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
|
||||
' Recupero flag per inserimento diretto in grezzo o in parcheggio
|
||||
Dim bDirect As Boolean = GetPrivateProfileInt(S_NEST, K_DIRECT, 0, m_MainWindow.GetIniFile()) <> 0
|
||||
' Vettore nomi file temporanei
|
||||
Dim sTmpFiles As New ArrayList()
|
||||
' Ciclo di salvataggio dei pezzi
|
||||
@@ -368,14 +370,19 @@ Public Class ImportPageUC
|
||||
EgtInsertFile(sTmpfile)
|
||||
' Ne recupero l'Id
|
||||
Dim nId2 As Integer = EgtGetLastPart()
|
||||
' Lo posiziono in ordine
|
||||
Dim ptPmin, ptPmax As Point3d
|
||||
EgtGetBBoxGlob(nId2, nFlag, ptPmin, ptPmax)
|
||||
ptPmin.z = ptMax.z
|
||||
EgtAddPartToRawPart(nId2, ptPmin, nRawId)
|
||||
If Not EgtPackPart(nId2, ptMin.x, ptMin.y, ptMax.x, ptMax.y, 4, True) Then
|
||||
EgtRemovePartFromRawPart(nId2)
|
||||
EgtSetStatus(nId2, GDB_ST.ON_)
|
||||
' Se richiesto posizionamento diretto nel grezzo
|
||||
If bDirect Then
|
||||
Dim ptPmin, ptPmax As Point3d
|
||||
EgtGetBBoxGlob(nId2, nFlag, ptPmin, ptPmax)
|
||||
ptPmin.z = ptMax.z
|
||||
EgtAddPartToRawPart(nId2, ptPmin, nRawId)
|
||||
If Not EgtPackPart(nId2, ptMin.x, ptMin.y, ptMax.x, ptMax.y, 4, True) Then
|
||||
EgtRemovePartFromRawPart(nId2)
|
||||
EgtSetStatus(nId2, GDB_ST.ON_)
|
||||
EgtPackPart(nId2, -5000, -INFINITO, 1000, -3000, 20, False)
|
||||
End If
|
||||
' Altrimenti lo posiziono in parcheggio
|
||||
Else
|
||||
EgtPackPart(nId2, -5000, -INFINITO, 1000, -3000, 20, False)
|
||||
End If
|
||||
' Cancello il file
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
d:DesignHeight="85.3" d:DesignWidth="1280" Initialized="MachineStatus_Initialized">
|
||||
|
||||
<!-- ** Definizione della MachineStatusBar ** -->
|
||||
<Grid Name="MachineStatusGrid" Background="White">
|
||||
<Grid Name="MachineStatusGrid" Background="DarkGray">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="2"/>
|
||||
|
||||
+3
-3
@@ -192,7 +192,7 @@ Class MainWindow
|
||||
'Leggo lista materiali da file ini
|
||||
Dim index As Integer = 1
|
||||
Dim sMaterial As String = String.Empty
|
||||
While GetPrivateProfileString("Materials", "Material" & index, "", sMaterial, GetIniFile) > 0
|
||||
While GetPrivateProfileString(S_MATERIALS, K_MATERIAL & index, "", sMaterial, GetIniFile) > 0
|
||||
Dim cMaterial As New Material(sMaterial)
|
||||
m_MaterialsList.Add(cMaterial)
|
||||
index += 1
|
||||
@@ -200,7 +200,7 @@ Class MainWindow
|
||||
|
||||
'Leggo materiale corrent da file ini
|
||||
Dim sCurrentMaterial As String = String.Empty
|
||||
GetPrivateProfileString("Materials", "CurrMaterial", "", sCurrentMaterial, GetIniFile)
|
||||
GetPrivateProfileString(S_MATERIALS, K_CURRMATERIAL, "", sCurrentMaterial, GetIniFile)
|
||||
For i As Integer = 0 To m_MaterialsList.Count - 1
|
||||
If sCurrentMaterial = m_MaterialsList(i).Name Then
|
||||
m_nCurrentMaterial = i
|
||||
@@ -607,7 +607,7 @@ Class MainWindow
|
||||
|
||||
Private Sub MainWindow_Unloaded(sender As Object, e As RoutedEventArgs)
|
||||
If m_nCurrentMaterial >= 0 And m_nCurrentMaterial < m_MaterialsList.Count() Then
|
||||
WritePrivateProfileString("Materials", "CurrMaterial", m_MaterialsList(m_nCurrentMaterial).Name, GetIniFile())
|
||||
WritePrivateProfileString(S_MATERIALS, K_CURRMATERIAL, m_MaterialsList(m_nCurrentMaterial).Name, GetIniFile())
|
||||
End If
|
||||
' Terminazione generale di EgtInterface
|
||||
EgtExit()
|
||||
|
||||
+14
-5
@@ -4,7 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="853.3" d:DesignWidth="256" Initialized="NestPage_Initialized">
|
||||
d:DesignHeight="853.3" d:DesignWidth="256" Initialized="NestPage_Initialized" Loaded="NestPage_Loaded" Unloaded="NestPage_Unloaded">
|
||||
|
||||
<!-- Chiamata al Dictionary -->
|
||||
<UserControl.Resources>
|
||||
@@ -24,10 +24,9 @@
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="0.5*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="0.5*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
@@ -67,7 +66,17 @@
|
||||
VerticalAlignment="Center" />
|
||||
</Button>
|
||||
|
||||
<UniformGrid Grid.Column="0" Grid.Row="6" Grid.ColumnSpan="3" Columns="2" >
|
||||
<UniformGrid Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="3" Columns="2" >
|
||||
<Button Name="SelectAllBtn" FontSize="22" >
|
||||
<TextBlock Name="SelectAllTxt" TextWrapping="Wrap" TextAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Name="DeselectAllBtn" FontSize="22" >
|
||||
<TextBlock Name="DeselectAllTxt" TextWrapping="Wrap" TextAlignment="Center"/>
|
||||
</Button>
|
||||
</UniformGrid>
|
||||
|
||||
|
||||
<UniformGrid Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="3" Columns="2" >
|
||||
<Button Name="InsertPartBtn" FontSize="22" >
|
||||
<TextBlock Name="InsertPartTxt" TextWrapping="Wrap" TextAlignment="Center"/>
|
||||
</Button>
|
||||
@@ -76,7 +85,7 @@
|
||||
</Button>
|
||||
</UniformGrid>
|
||||
|
||||
<Button Name="RemovePartBtn" Grid.ColumnSpan="3" Grid.Row="7" FontSize="22" />
|
||||
<Button Name="RemovePartBtn" Grid.ColumnSpan="3" Grid.Row="6" FontSize="22" />
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
+313
-16
@@ -2,21 +2,275 @@
|
||||
|
||||
Public Class NestPageUC
|
||||
|
||||
Private Sub NestPage_Initialized(sender As Object, e As EventArgs)
|
||||
' Riferimento alla MainWindow
|
||||
Private m_MainWindow As MainWindow = Application.Current.MainWindow
|
||||
Private WithEvents m_CurrProjPage As CurrentProjectPageUC
|
||||
|
||||
'Imposto i messaggi letti dal file dei messaggi
|
||||
InsertPartTxt.Text = EgtMsg(MSG_NESTPAGEUC + 1) 'Insert part - Inserisci pezzo
|
||||
StorePartTxt.Text = EgtMsg(MSG_NESTPAGEUC + 2) 'Store part - Parcheggia pezzo
|
||||
RemovePartBtn.Content = EgtMsg(MSG_NESTPAGEUC + 3) 'Remove part - Elimina pezzo
|
||||
' Flag di pagina attiva
|
||||
Private m_bActive As Boolean = False
|
||||
|
||||
End Sub
|
||||
' Flag per pezzi selezionati in tavola o fuori
|
||||
Private m_nPartPos As Integer = PART_POS.NONE_TABLE
|
||||
Enum PART_POS As Integer
|
||||
IN_TABLE = -1
|
||||
NONE_TABLE = 0
|
||||
OUT_TABLE = 1
|
||||
End Enum
|
||||
|
||||
' Dati del grezzo
|
||||
Private m_nRawId As Integer = GDB_ID.NULL
|
||||
Private m_ptRawMin As Point3d
|
||||
Private m_ptRawMax As Point3d
|
||||
Private m_dMinDist As Double = 4
|
||||
|
||||
' Dati movimento
|
||||
Friend m_dStep As Double = 0
|
||||
Friend m_dMaxStep As Double = 0
|
||||
Private m_bMaximizeMove As Boolean = False
|
||||
|
||||
' Dati per Drag
|
||||
Private m_bDrag As Boolean = False
|
||||
Private m_ptPrev As Point3d
|
||||
|
||||
' Costante per flag di BBox
|
||||
Dim BBFLAG As Integer = GDB_BB.ONLY_VISIBLE + GDB_BB.IGNORE_TEXT + GDB_BB.IGNORE_DIM
|
||||
|
||||
|
||||
Private Sub NestPage_Initialized(sender As Object, e As EventArgs)
|
||||
' Imposto i messaggi letti dal file dei messaggi
|
||||
InsertPartTxt.Text = EgtMsg(MSG_NESTPAGEUC + 1) 'Insert part - Inserisci pezzo
|
||||
StorePartTxt.Text = EgtMsg(MSG_NESTPAGEUC + 2) 'Store part - Parcheggia pezzo
|
||||
RemovePartBtn.Content = EgtMsg(MSG_NESTPAGEUC + 3) 'Remove part - Elimina pezzo
|
||||
SelectAllTxt.Text = EgtMsg(MSG_NESTPAGEUC + 4) 'Select All - Seleziona Tutto
|
||||
DeselectAllTxt.Text = EgtMsg(MSG_NESTPAGEUC + 5) 'Deselect All - Deseleziona Tutto
|
||||
End Sub
|
||||
|
||||
Private Sub NestPage_Loaded(sender As Object, e As RoutedEventArgs)
|
||||
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
||||
m_bActive = True
|
||||
' recupero dimensioni del grezzo
|
||||
m_nRawId = EgtGetFirstRawPart()
|
||||
EgtGetBBoxGlob(m_nRawId, BBFLAG, m_ptRawMin, m_ptRawMax)
|
||||
' carico e calcolo i parametri di movimento
|
||||
m_dStep = GetPrivateProfileDouble(S_NEST, K_STEP, 10, m_MainWindow.GetIniFile())
|
||||
m_dMaxStep = Math.Max(m_ptRawMax.x - m_ptRawMin.x, m_ptRawMax.y - m_ptRawMin.y)
|
||||
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
|
||||
End If
|
||||
' 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
|
||||
' Verifico se selezionato indicativo di pezzo
|
||||
EgtSetObjFilterForSelect(True, True, True, True, True)
|
||||
Dim nSel As Integer
|
||||
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
|
||||
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
||||
While nId <> GDB_ID.NULL
|
||||
' Recupero l'identificativo del pezzo cui appartiene
|
||||
Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
|
||||
Dim bPartInTable As Boolean = EgtGetParent(nPartId) = m_CurrProjPage.m_nRawId
|
||||
If EgtIsPart(nPartId) Or bPartInTable Then
|
||||
Dim nStat As Integer = GDB_ST.ON_
|
||||
EgtGetStatus(nPartId, nStat)
|
||||
' Se selezionato o posizione oggetto incompatibile con flag posizione selezionati
|
||||
If nStat = GDB_ST.SEL Or
|
||||
(bPartInTable And m_nPartPos = PART_POS.OUT_TABLE) Or
|
||||
(Not bPartInTable And m_nPartPos = PART_POS.IN_TABLE) Then
|
||||
' Deseleziono
|
||||
EgtDeselectObj(nPartId)
|
||||
' Se nessun pezzo selezionato, reset flag posizione selezionati
|
||||
If EgtGetSelectedObjCount() = 0 Then
|
||||
m_nPartPos = PART_POS.NONE_TABLE
|
||||
End If
|
||||
Else
|
||||
EgtSelectObj(nPartId)
|
||||
' Set flag posizione selezionati
|
||||
m_nPartPos = IIf(bPartInTable, PART_POS.IN_TABLE, PART_POS.OUT_TABLE)
|
||||
End If
|
||||
EgtDraw()
|
||||
Exit While
|
||||
End If
|
||||
nId = EgtGetNextObjInSelWin()
|
||||
End While
|
||||
' Dati per drag
|
||||
m_bDrag = EgtUnProjectPoint(e.Location, m_ptPrev)
|
||||
End Sub
|
||||
|
||||
Private Sub OnMyMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_CurrProjPage.OnMouseMoveScene
|
||||
' Verifico di essere il gestore attivo
|
||||
If Not m_bActive Then
|
||||
Return
|
||||
End If
|
||||
If Not m_bDrag Or m_nPartPos <> PART_POS.IN_TABLE Then
|
||||
Return
|
||||
End If
|
||||
' 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
|
||||
' Muovo i pezzi selezionati di quanto possibile
|
||||
EgtMoveSelectedCluster(vtMove, m_ptRawMin.x, m_ptRawMin.y, m_ptRawMax.x, m_ptRawMax.y, m_dMinDist)
|
||||
EgtDraw()
|
||||
' Aggiorno il punto precedente
|
||||
'm_ptPrev += vtMove
|
||||
m_ptPrev = ptCurr
|
||||
End Sub
|
||||
|
||||
Private Sub OnMyMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_CurrProjPage.OnMouseUpScene
|
||||
' Verifico di essere il gestore attivo
|
||||
If Not m_bActive Then
|
||||
Return
|
||||
End If
|
||||
' Disabilito modalità drag
|
||||
m_bDrag = False
|
||||
End Sub
|
||||
|
||||
Private Sub MaximizeMoveBtn_Click(sender As Object, e As RoutedEventArgs) Handles MaximizeMoveBtn.Click
|
||||
If MaximizeMoveBtn.IsChecked Then
|
||||
m_bMaximizeMove = True
|
||||
Else
|
||||
m_bMaximizeMove = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub UpBtn_Click(sender As Object, e As RoutedEventArgs) Handles UpBtn.Click
|
||||
Dim dStep As Double = IIf(m_bMaximizeMove, m_dMaxStep, m_dStep)
|
||||
EgtMoveSelectedCluster(New Vector3d(0, dStep, 0), m_ptRawMin.x, m_ptRawMin.y, m_ptRawMax.x, m_ptRawMax.y, m_dMinDist)
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Sub DownBtn_Click(sender As Object, e As RoutedEventArgs) Handles DownBtn.Click
|
||||
Dim dStep As Double = IIf(m_bMaximizeMove, m_dMaxStep, m_dStep)
|
||||
EgtMoveSelectedCluster(New Vector3d(0, -dStep, 0), m_ptRawMin.x, m_ptRawMin.y, m_ptRawMax.x, m_ptRawMax.y, m_dMinDist)
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Sub RightBtn_Click(sender As Object, e As RoutedEventArgs) Handles RightBtn.Click
|
||||
Dim dStep As Double = IIf(m_bMaximizeMove, m_dMaxStep, m_dStep)
|
||||
EgtMoveSelectedCluster(New Vector3d(dStep, 0, 0), m_ptRawMin.x, m_ptRawMin.y, m_ptRawMax.x, m_ptRawMax.y, m_dMinDist)
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Sub LeftBtn_Click(sender As Object, e As RoutedEventArgs) Handles LeftBtn.Click
|
||||
Dim dStep As Double = IIf(m_bMaximizeMove, m_dMaxStep, m_dStep)
|
||||
EgtMoveSelectedCluster(New Vector3d(-dStep, 0, 0), m_ptRawMin.x, m_ptRawMin.y, m_ptRawMax.x, m_ptRawMax.y, m_dMinDist)
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Sub RotateCounterClockwiseBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateCounterClockwiseBtn.Click
|
||||
RotateCluster(90)
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Sub RotateClockwiseBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateClockwiseBtn.Click
|
||||
RotateCluster(-90)
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Sub RotateHalfTurnBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateHalfTurnBtn.Click
|
||||
' Se non ci sono pezzi selezionati, esco
|
||||
Dim nCount As Integer = EgtGetSelectedObjCount()
|
||||
If nCount = 0 Then
|
||||
Return
|
||||
End If
|
||||
' Se un solo pezzo, non sono necessarie verifiche
|
||||
If nCount = 1 Then
|
||||
' Recupero il box del cluster di pezzi
|
||||
Dim ptMin As Point3d
|
||||
Dim ptMax As Point3d
|
||||
If Not EgtGetSelectedClusterBBoxGlob(ptMin, ptMax) Then
|
||||
Return
|
||||
End If
|
||||
' Ne derivo il centro di rotazione come centro del cluster
|
||||
Dim ptCen As Point3d = Point3d.Media(ptMin, ptMax, 0.5)
|
||||
' Rotazione dei pezzi attorno al loro centro
|
||||
EgtRotate(GDB_ID.SEL, ptCen, Vector3d.Z_AX(), 180, GDB_RT.GLOB)
|
||||
EgtDraw()
|
||||
Return
|
||||
End If
|
||||
' Caso generale
|
||||
RotateCluster(180)
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Function RotateCluster(ByVal dAngRotDeg As Double) As Boolean
|
||||
' Se non ci sono pezzi selezionati, esco
|
||||
If EgtGetSelectedObjCount() = 0 Then
|
||||
Return True
|
||||
End If
|
||||
' Recupero il box del cluster di pezzi
|
||||
Dim ptMin As Point3d
|
||||
Dim ptMax As Point3d
|
||||
If Not EgtGetSelectedClusterBBoxGlob(ptMin, ptMax) Then
|
||||
Return False
|
||||
End If
|
||||
' Ne derivo il centro di rotazione come centro del cluster
|
||||
Dim ptCen As Point3d = Point3d.Media(ptMin, ptMax, 0.5)
|
||||
' Rotazione dei pezzi attorno al loro centro
|
||||
EgtRotate(GDB_ID.SEL, ptCen, Vector3d.Z_AX(), dAngRotDeg, GDB_RT.GLOB)
|
||||
|
||||
' Se pezzi in parcheggio, li risistemo qui (sempre possibile)
|
||||
If m_nPartPos <> PART_POS.IN_TABLE Then
|
||||
EgtPackSelectedCluster(-5000, -INFINITO, 1000, -3000, 20, False)
|
||||
Return True
|
||||
End If
|
||||
|
||||
' Se pezzi in tavola, cerco di sistemarli qui (se impossibile, annullo la rotazione)
|
||||
' Recupero nuovo box
|
||||
EgtGetSelectedClusterBBoxGlob(ptMin, ptMax)
|
||||
' Se non esce dalla tavola, provo un pack sul posto
|
||||
If ptMin.x > m_ptRawMin.x - EPS_SMALL And ptMin.y > m_ptRawMin.y - EPS_SMALL And
|
||||
ptMax.x < m_ptRawMax.x + EPS_SMALL And ptMax.y < m_ptRawMax.y + EPS_SMALL Then
|
||||
If EgtPackSelectedCluster(ptMin.x, ptMin.y, ptMax.x + 1, ptMax.y + 1, m_dMinDist, True) Then
|
||||
Return True
|
||||
End If
|
||||
End If
|
||||
' Provo un pack un poco più esteso
|
||||
Dim dDim As Double = Math.Max(ptMax.x - ptMin.x, ptMax.y - ptMin.y)
|
||||
ptMin.x = ptCen.x - 0.5 * dDim
|
||||
ptMin.y = ptCen.y - 0.5 * dDim
|
||||
ptMax.x = ptCen.x + 0.5 * dDim
|
||||
ptMax.y = ptCen.y + 0.5 * dDim
|
||||
If (ptMin.x < m_ptRawMin.x) Then
|
||||
ptMax.x += m_ptRawMin.x - ptMin.x
|
||||
ptMax.x = Math.Min(ptMax.x, m_ptRawMax.x)
|
||||
ptMin.x = m_ptRawMin.x
|
||||
End If
|
||||
If (ptMin.y < m_ptRawMin.y) Then
|
||||
ptMax.y += m_ptRawMin.y - ptMin.y
|
||||
ptMax.y = Math.Min(ptMax.y, m_ptRawMax.y)
|
||||
ptMin.y = m_ptRawMin.y
|
||||
End If
|
||||
If (ptMax.x > m_ptRawMax.x) Then
|
||||
ptMin.x += m_ptRawMax.x - ptMax.x
|
||||
ptMin.x = Math.Max(ptMin.x, m_ptRawMin.x)
|
||||
ptMax.x = m_ptRawMax.x
|
||||
End If
|
||||
If (ptMax.y > m_ptRawMax.y) Then
|
||||
ptMin.y += m_ptRawMax.y - ptMax.y
|
||||
ptMin.y = Math.Max(ptMin.y, m_ptRawMin.y)
|
||||
ptMax.y = m_ptRawMax.y
|
||||
End If
|
||||
If EgtPackSelectedCluster(ptMin.x, ptMin.y, ptMax.x + 1, ptMax.y + 1, m_dMinDist, True) Then
|
||||
Return True
|
||||
End If
|
||||
' Provo un pack sull'intera tavola
|
||||
If EgtPackSelectedCluster(m_ptRawMin.x, m_ptRawMin.y, m_ptRawMax.x, m_ptRawMax.y, m_dMinDist, True) Then
|
||||
Return True
|
||||
End If
|
||||
' Non è possibile ruotare rimanendo in tavola, annullo l'azione
|
||||
EgtRotate(GDB_ID.SEL, ptCen, Vector3d.Z_AX(), -dAngRotDeg, GDB_RT.GLOB)
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Private Sub InsertPartBtn_Click(sender As Object, e As RoutedEventArgs) Handles InsertPartBtn.Click
|
||||
' recupero dimensioni del grezzo
|
||||
Dim nRawId As Integer = EgtGetFirstRawPart()
|
||||
Dim ptMin, ptMax As Point3d
|
||||
Dim nFlag As Integer = GDB_BB.ONLY_VISIBLE + GDB_BB.IGNORE_TEXT + GDB_BB.IGNORE_DIM
|
||||
EgtGetBBoxGlob(nRawId, nFlag, ptMin, ptMax)
|
||||
' Ciclo di inserimento in tavola dei pezzi selezionati
|
||||
Dim nId As Integer = EgtGetFirstSelectedObj()
|
||||
While nId <> GDB_ID.NULL
|
||||
@@ -25,10 +279,10 @@ Public Class NestPageUC
|
||||
' Se pezzo in parcheggio, metto nella tavola
|
||||
If EgtIsPart(nId) Then
|
||||
Dim ptPmin, ptPmax As Point3d
|
||||
EgtGetBBoxGlob(nId, nFlag, ptPmin, ptPmax)
|
||||
ptPmin.z = ptMax.z
|
||||
EgtAddPartToRawPart(nId, ptPmin, nRawId)
|
||||
If Not EgtPackPart(nId, ptMin.x, ptMin.y, ptMax.x, ptMax.y, 4, True) Then
|
||||
EgtGetBBoxGlob(nId, BBFLAG, ptPmin, ptPmax)
|
||||
ptPmin.z = m_ptRawMax.z
|
||||
EgtAddPartToRawPart(nId, ptPmin, m_nRawId)
|
||||
If Not EgtPackPart(nId, m_ptRawMin.x, m_ptRawMin.y, m_ptRawMax.x, m_ptRawMax.y, m_dMinDist, True) Then
|
||||
EgtRemovePartFromRawPart(nId)
|
||||
EgtSetStatus(nId, GDB_ST.ON_)
|
||||
End If
|
||||
@@ -36,6 +290,8 @@ Public Class NestPageUC
|
||||
' Passo al successivo selezionato
|
||||
nId = nNextId
|
||||
End While
|
||||
' Aggiorno flag selezionati
|
||||
m_nPartPos = IIf(EgtGetSelectedObjCount() > 0, PART_POS.IN_TABLE, PART_POS.NONE_TABLE)
|
||||
' Aggiorno vista
|
||||
EgtZoom(ZM.ALL)
|
||||
End Sub
|
||||
@@ -47,7 +303,7 @@ Public Class NestPageUC
|
||||
' Recupero indice del successivo
|
||||
Dim nNextId = EgtGetNextSelectedObj()
|
||||
' Se pezzo in grezzo, metto in parcheggio (sempre possibile)
|
||||
If Not EgtIsPart(nId) Then
|
||||
If EgtGetParent(nId) = m_CurrProjPage.m_nRawId Then
|
||||
EgtRemovePartFromRawPart(nId)
|
||||
EgtSetStatus(nId, GDB_ST.ON_)
|
||||
EgtPackPart(nId, -5000, -INFINITO, 1000, -3000, 20, False)
|
||||
@@ -55,6 +311,8 @@ Public Class NestPageUC
|
||||
' Passo al successivo selezionato
|
||||
nId = nNextId
|
||||
End While
|
||||
' Imposto flag posizione pezzi su parcheggio
|
||||
m_nPartPos = PART_POS.OUT_TABLE
|
||||
' Aggiorno vista
|
||||
EgtZoom(ZM.ALL)
|
||||
End Sub
|
||||
@@ -76,8 +334,47 @@ Public Class NestPageUC
|
||||
' Passo al successivo selezionato
|
||||
nId = nNextId
|
||||
End While
|
||||
' Imposto flag posizione pezzi
|
||||
m_nPartPos = PART_POS.NONE_TABLE
|
||||
' Aggiorno vista
|
||||
EgtZoom(ZM.ALL)
|
||||
End Sub
|
||||
|
||||
Private Sub SelectAllBtn_Click(sender As Object, e As RoutedEventArgs) Handles SelectAllBtn.Click
|
||||
' Se già selezionati in tavola o non ci sono selezionati
|
||||
If m_nPartPos = PART_POS.IN_TABLE Or m_nPartPos = PART_POS.NONE_TABLE Then
|
||||
' Seleziono tutti i pezzi in tavola
|
||||
Dim nPartId As Integer = EgtGetFirstGroupInGroup(m_nRawId)
|
||||
While nPartId <> GDB_ID.NULL
|
||||
EgtSetStatus(nPartId, GDB_ST.SEL)
|
||||
nPartId = EgtGetNextGroup(nPartId)
|
||||
End While
|
||||
' Aggiorno flag
|
||||
m_nPartPos = IIf(EgtGetSelectedObjCount() > 0, PART_POS.IN_TABLE, PART_POS.NONE_TABLE)
|
||||
' Se già selezionati in parcheggio
|
||||
ElseIf m_nPartPos = PART_POS.OUT_TABLE Then
|
||||
' Seleziono tutti i pezzi in parcheggio
|
||||
Dim nPartId As Integer = EgtGetFirstPart()
|
||||
While nPartId <> GDB_ID.NULL
|
||||
EgtSetStatus(nPartId, GDB_ST.SEL)
|
||||
nPartId = EgtGetNextPart(nPartId)
|
||||
End While
|
||||
End If
|
||||
' Aggiorno vista
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Sub DeselectAllBtn_Click(sender As Object, e As RoutedEventArgs) Handles DeselectAllBtn.Click
|
||||
' Eseguo
|
||||
EgtDeselectAll()
|
||||
' Imposto flag posizione pezzi
|
||||
m_nPartPos = PART_POS.NONE_TABLE
|
||||
' Aggiorno vista
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Sub NestPage_Unloaded(sender As Object, e As RoutedEventArgs)
|
||||
m_bActive = False
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
+16
-6
@@ -43,6 +43,8 @@ Public Class RawPartPageUC
|
||||
|
||||
Private Sub RawPartPage_Loaded(sender As Object, e As RoutedEventArgs)
|
||||
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
||||
' Nascondo eventuali pezzi in parcheggio
|
||||
HideParkedParts()
|
||||
' Aggiorno dimensioni grezzo
|
||||
' Se non esiste già il grezzo lo inserisco
|
||||
Dim nRawId As Integer = EgtGetFirstRawPart()
|
||||
@@ -76,11 +78,12 @@ Public Class RawPartPageUC
|
||||
KerfTxBx.Text = "50"
|
||||
m_bShowVar = False
|
||||
End If
|
||||
|
||||
'Seleziono modalità rettangolo
|
||||
' Deseleziono pezzi
|
||||
EgtDeselectAll()
|
||||
' Seleziono modalità rettangolo
|
||||
RectangleBtn.IsChecked = True
|
||||
UpdateRawPart()
|
||||
'Imposto il materiale corrente nella combobox
|
||||
' Imposto il materiale corrente nella combobox
|
||||
MaterialsCmbx.SelectedIndex = m_MainWindow.m_nCurrentMaterial
|
||||
|
||||
End Sub
|
||||
@@ -91,8 +94,12 @@ Public Class RawPartPageUC
|
||||
End Sub
|
||||
|
||||
Private Sub ExitBtnUC_Click(sender As Object, e As RoutedEventArgs)
|
||||
' Ripristino visualizzazione di eventuali pezzi in parcheggio
|
||||
ShowParkedParts()
|
||||
' Imposto spessore del grezzo
|
||||
m_CurrProjPage.m_dRawHeight = GetRawHeight()
|
||||
m_CurrProjPage.HeightTxBx.Text = GetRawHeight()
|
||||
' Esco dalla pagina
|
||||
m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Remove(Me)
|
||||
m_CurrProjPage.CurrProjGrid.Visibility = Windows.Visibility.Visible
|
||||
m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_CadCutPageUC)
|
||||
@@ -150,8 +157,11 @@ Public Class RawPartPageUC
|
||||
' Se non esiste già il grezzo lo inserisco
|
||||
Dim nRawId As Integer = EgtGetFirstRawPart()
|
||||
If nRawId = GDB_ID.NULL Then
|
||||
m_CurrProjPage.m_nRawId = EgtAddRawPart(Point3d.ORIG(), dLength + 2 * dKerf, dWidth + 2 * dKerf, dHeight, New Color3d(128, 128, 255, 60))
|
||||
' Altrimenti lo modifico
|
||||
' recupero il colore
|
||||
Dim Col As New Color3d(64, 192, 255, 40)
|
||||
GetPrivateProfileColor(S_NEST, K_RAWCOLOR, Col, m_MainWindow.GetIniFile())
|
||||
m_CurrProjPage.m_nRawId = EgtAddRawPart(Point3d.ORIG(), dLength + 2 * dKerf, dWidth + 2 * dKerf, dHeight, Col)
|
||||
' Altrimenti lo modifico
|
||||
Else
|
||||
m_CurrProjPage.m_nRawId = nRawId
|
||||
EgtModifyRawPartSize(nRawId, dLength + 2 * dKerf, dWidth + 2 * dKerf, dHeight)
|
||||
@@ -160,7 +170,7 @@ Public Class RawPartPageUC
|
||||
' Sistemo la posizione
|
||||
EgtMoveToCornerRawPart(m_CurrProjPage.m_nRawId, New Point3d(dOffsetX, dOffsetY, 0), MCH_CR.BL)
|
||||
' Aggiorno visualizzazione
|
||||
EgtDraw()
|
||||
EgtZoom(ZM.ALL)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
@@ -27,11 +27,7 @@ Public Class SimulationPageUC
|
||||
Private Sub SimulationPage_Loaded(sender As Object, e As RoutedEventArgs)
|
||||
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
||||
' Nascondo eventuali pezzi in parcheggio
|
||||
Dim nPartId As Integer = EgtGetFirstPart()
|
||||
While nPartId <> GDB_ID.NULL
|
||||
EgtSetStatus(nPartId, GDB_ST.OFF)
|
||||
nPartId = EgtGetNextPart(nPartId)
|
||||
End While
|
||||
HideParkedParts()
|
||||
' Visualizzo tutta la macchina
|
||||
EgtShowOnlyTable(False)
|
||||
EgtSetView(VT.ISO_SE, False)
|
||||
@@ -52,11 +48,7 @@ Public Class SimulationPageUC
|
||||
|
||||
Private Sub ExitBtnUC_Click(sender As Object, e As RoutedEventArgs)
|
||||
' Ripristino visualizzazione di eventuali pezzi in parcheggio
|
||||
Dim nPartId As Integer = EgtGetFirstPart()
|
||||
While nPartId <> GDB_ID.NULL
|
||||
EgtSetStatus(nPartId, GDB_ST.ON_)
|
||||
nPartId = EgtGetNextPart(nPartId)
|
||||
End While
|
||||
ShowParkedParts()
|
||||
' Ripristino visualizzazione della sola tavola
|
||||
EgtShowOnlyTable(True)
|
||||
EgtSetView(VT.TOP, False)
|
||||
|
||||
+17
-1
@@ -13,7 +13,23 @@ Module Utility
|
||||
End Function
|
||||
|
||||
Friend Function StringToDouble(ByVal sVal As String, ByRef dVal As Double) As Boolean
|
||||
Return EgtLuaEvalNumExpr(sVal, dVal)
|
||||
Return EgtLuaEvalNumExpr(sVal, dVal)
|
||||
End Function
|
||||
|
||||
Friend Sub HideParkedParts()
|
||||
Dim nPartId As Integer = EgtGetFirstPart()
|
||||
While nPartId <> GDB_ID.NULL
|
||||
EgtSetStatus(nPartId, GDB_ST.OFF)
|
||||
nPartId = EgtGetNextPart(nPartId)
|
||||
End While
|
||||
End Sub
|
||||
|
||||
Friend Sub ShowParkedParts()
|
||||
Dim nPartId As Integer = EgtGetFirstPart()
|
||||
While nPartId <> GDB_ID.NULL
|
||||
EgtSetStatus(nPartId, GDB_ST.ON_)
|
||||
nPartId = EgtGetNextPart(nPartId)
|
||||
End While
|
||||
End Sub
|
||||
|
||||
End Module
|
||||
|
||||
Reference in New Issue
Block a user