2527 lines
99 KiB
VB.net
2527 lines
99 KiB
VB.net
Imports EgtWPFLib5
|
|
Imports EgtUILib
|
|
|
|
Public Class NestingTabVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' 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
|
|
' Identificativi per pezzo da selezionare/deselezionare
|
|
Private m_nIdToSel As Integer = GDB_ID.NULL
|
|
Private m_nIdToDesel As Integer = GDB_ID.NULL
|
|
' Dati del grezzo
|
|
Private m_dMinDist As Double = 0
|
|
' Dati movimento
|
|
Private m_dMaxStep As Double = 0
|
|
' Dati per Drag
|
|
Private m_nRestRadius As Integer = 3
|
|
Private m_bDrag As Boolean = False
|
|
Private m_bDragToStart As Boolean = False
|
|
Private m_bVerify As Boolean = False
|
|
Private m_bFromParking As Boolean = False
|
|
Private m_bDragging As Boolean = False
|
|
Private m_locPrev As System.Drawing.Point
|
|
Private m_ptPrev As Point3d
|
|
Private m_vtTotMove As Vector3d
|
|
Private m_dSnapDist As Double = 0
|
|
' Gestione rotazione pezzi in fase di Drag
|
|
Private m_bKeyCtrlPressed As Boolean = False
|
|
Private m_bKeyLeftShiftPressed As Boolean = False
|
|
Private m_dAngTotal As Double = 0
|
|
Private m_dStartAng As Double = 0
|
|
Private m_bStartRot As Boolean = False
|
|
Private m_bStartMove As Boolean = False
|
|
' Abilitazioni TrfData e CsvData
|
|
Private m_bTrfData As Boolean = False
|
|
Private m_bCsvData As Boolean = False
|
|
|
|
' Id del rettangolo, del traglio e della curva da modificare tramite Drag
|
|
Private m_nIdSelectedOutLoopRectangle As Integer = GDB_ID.NULL
|
|
Private m_nIdSelectedRegionRectangle As Integer = GDB_ID.NULL
|
|
Private m_nIdSelectedSawRectangle As Integer = GDB_ID.NULL
|
|
Private m_nIdSelectedCurvRectangle As Integer = GDB_ID.NULL
|
|
Private m_nIdSelectedTextRectangle As Integer = GDB_ID.NULL
|
|
Private m_nIdSelectedTextTopRectangle As Integer = GDB_ID.NULL
|
|
Private m_nIdSelectedFlatSurfRectangle As Integer = GDB_ID.NULL
|
|
Private m_SideListRectangle(4) As Integer
|
|
Private m_sTextContent As String = String.Empty
|
|
|
|
' Id dei lato WJ da separare tramite comando ON_OFF
|
|
Private m_nIdSelectedSideWJ As Integer = GDB_ID.NULL
|
|
Private m_nIdSelectedWaterJet As Integer = GDB_ID.NULL
|
|
|
|
Private m_CsvImportWindow As CsvWindowV
|
|
Friend ReadOnly Property CsvImportWindow As CsvWindowV
|
|
Get
|
|
Return m_CsvImportWindow
|
|
End Get
|
|
End Property
|
|
|
|
Private m_CsvImport_IsChecked As Boolean
|
|
Public Property CsvImport_IsChecked As Boolean
|
|
Get
|
|
Return m_CsvImport_IsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_CsvImport_IsChecked Then
|
|
m_CsvImport_IsChecked = value
|
|
If m_CsvImport_IsChecked Then
|
|
m_CsvImportWindow = New CsvWindowV(Application.Current.MainWindow, New CsvWindowVM)
|
|
m_CsvImportWindow.Show()
|
|
Else
|
|
m_CsvImportWindow.Close()
|
|
m_CsvImportWindow = Nothing
|
|
End If
|
|
NotifyPropertyChanged("CsvImport_IsChecked")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_MaxMoveIsChecked As Boolean
|
|
Public Property MaxMoveIsChecked As Boolean
|
|
Get
|
|
Return m_MaxMoveIsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_MaxMoveIsChecked Then
|
|
m_MaxMoveIsChecked = value
|
|
NotifyPropertyChanged("MaxMoveIsChecked")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_dStepMove As Double
|
|
Public Property StepMove As String
|
|
Get
|
|
Return LenToString(m_dStepMove, 2)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dValue As Double
|
|
'StringToLen(value, m_dStepMove)
|
|
If StringToLen(value, dValue) Then
|
|
If dValue < 0 Then
|
|
dValue = 0
|
|
ElseIf dValue > 1000 Then
|
|
dValue = 1000
|
|
End If
|
|
m_dStepMove = dValue
|
|
WriteMainPrivateProfileString(S_NEST, K_STEP, DoubleToString(m_dStepMove, 2))
|
|
End If
|
|
NotifyPropertyChanged("StepMove")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_dRotationAngle As Double
|
|
Public Property RotationAngle As String
|
|
Get
|
|
Return DoubleToString(m_dRotationAngle, 2)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dValue As Double
|
|
If StringToDouble(value, dValue) Then
|
|
If dValue < 0 Then
|
|
dValue = 0
|
|
ElseIf dValue > 180 Then
|
|
dValue = 180
|
|
End If
|
|
m_dRotationAngle = dValue
|
|
WriteMainPrivateProfileString(S_NEST, K_ANGSTEP, DoubleToString(m_dRotationAngle, 2))
|
|
End If
|
|
NotifyPropertyChanged("RotationAngle")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_bMagnetic As Boolean
|
|
Public Property MagneticIsChecked As Boolean
|
|
Get
|
|
Return m_bMagnetic
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_bMagnetic Then
|
|
m_bMagnetic = value
|
|
NotifyPropertyChanged("MagneticIsChecked")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_CsvData_Visibility As Visibility = Visibility.Collapsed
|
|
Public Property CsvData_Visibility As Visibility
|
|
Get
|
|
Return m_CsvData_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_CsvData_Visibility = value
|
|
NotifyPropertyChanged("CsvData_Visibility")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_CountColumn As Integer = 2
|
|
Public ReadOnly Property CountColumn As Integer
|
|
Get
|
|
Return m_CountColumn
|
|
End Get
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property InsertPartMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_NESTPAGEUC + 1)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StorePartMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_NESTPAGEUC + 2)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RemovePartMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_NESTPAGEUC + 3)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DragRectangleMsg As String
|
|
Get
|
|
Return "Drag Rectangle"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SplitCurvWJMsg As String
|
|
Get
|
|
'91133=Separa
|
|
Return EgtMsg(91133)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StartCurvWJMsg As String
|
|
Get
|
|
'91132=Start
|
|
Return EgtMsg(91132)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SelectAllMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_NESTPAGEUC + 4)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DeselectAllMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_NESTPAGEUC + 5)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ResetMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_NESTPAGEUC + 6)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CsvDataMsg As String
|
|
Get
|
|
Return EgtMsg(90398) 'Dati Csv
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
' Definizione comandi
|
|
Private m_cmdDraw As ICommand
|
|
Private m_cmdImportDxf As ICommand
|
|
Private m_cmdPartRotOn As ICommand
|
|
Private m_cmdPartRotOff As ICommand
|
|
Private m_cmdUp As ICommand
|
|
Private m_cmdLeft As ICommand
|
|
Private m_cmdRight As ICommand
|
|
Private m_cmdDown As ICommand
|
|
Private m_cmdCClockwiseRot As ICommand
|
|
Private m_cmdClockwiseRot As ICommand
|
|
Private m_cmdInsertPart As ICommand
|
|
Private m_cmdStorePart As ICommand
|
|
Private m_cmdRemovePart As ICommand
|
|
Private m_cmdSelectAll As ICommand
|
|
Private m_cmdDeselectAll As ICommand
|
|
Private m_cmdReset As ICommand
|
|
Private m_cmdCsvData As ICommand
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
If GetMainPrivateProfileInt(S_NEST, K_DRAGRECTANGLE, 1) <> 0 Then
|
|
m_DragRectangle_Visibility = Visibility.Visible
|
|
m_CountColumn += 1
|
|
Else
|
|
m_DragRectangle_Visibility = Visibility.Collapsed
|
|
End If
|
|
NotifyPropertyChanged("DragRectangle_Visibility")
|
|
NotifyPropertyChanged("CountColumn")
|
|
' Creo riferimento a questa classe in OmagOFFICEMap
|
|
OmagOFFICEMap.SetRefNestingTabVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Function InitNesting() As Boolean
|
|
' Se previsto, abilito bottone VeinMatching
|
|
If Not IsNothing(OmagOFFICEMap.refMainWindowVM.VeinMatchingWnd) Then
|
|
OmagOFFICEMap.refVeinMatchPanelVM.VeinMatchIsEnabled = True
|
|
End If
|
|
' Abilitazione TrfData
|
|
m_bTrfData = OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.TRF_IMPORT) And
|
|
(GetMainPrivateProfileInt(S_COMPO, K_TRFDATA, 0) <> 0)
|
|
' Abilitazione CsvData
|
|
m_bCsvData = Not m_bTrfData And
|
|
(GetMainPrivateProfileInt(S_COMPO, K_CSVDATA, 0) <> 0)
|
|
' Se previsto, abilito bottone CsvData
|
|
CsvData_Visibility = If(m_bCsvData, Visibility.Visible, Visibility.Collapsed)
|
|
' Imposto il corretto contesto
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' aggiorno dati del grezzo
|
|
EstCalc.UpdateRawPart()
|
|
' calcolo valore di minima distanza (da spessore lama corrente)
|
|
Dim dSawThick As Double = 0
|
|
If EgtTdbSetCurrTool(CurrentMachine.sCurrSaw) AndAlso
|
|
EgtTdbGetCurrToolParam(MCH_TP.THICK, dSawThick) Then
|
|
m_dMinDist = dSawThick
|
|
Else
|
|
EgtOutLog("Not found current saw for nesting mindist")
|
|
m_dMinDist = 0
|
|
End If
|
|
' carico e calcolo i parametri di movimento e drag
|
|
m_dStepMove = GetMainPrivateProfileDouble(S_NEST, K_STEP, 10)
|
|
NotifyPropertyChanged("StepMove")
|
|
Dim ptRawDiag As Vector3d = GetRawPtMax() - GetRawPtMin()
|
|
m_dMaxStep = Math.Max(ptRawDiag.x, ptRawDiag.y)
|
|
m_dRotationAngle = GetMainPrivateProfileDouble(S_NEST, K_ANGSTEP, 15)
|
|
NotifyPropertyChanged("RotationAngle")
|
|
m_nRestRadius = GetMainPrivateProfileInt(S_NEST, K_RESTRADIUS, 3)
|
|
m_dSnapDist = GetMainPrivateProfileDouble(S_NEST, K_SNAPDIST, 50)
|
|
' Garantisco visibilità pezzi parcheggiati
|
|
EstCalc.ShowParkedParts()
|
|
' Garantisco visibilità eventuale contorno da foto
|
|
EstPhoto.ShowContour(True)
|
|
' Se abilitato CSV ne visualizzo la finestra
|
|
If m_CsvImport_IsChecked Then
|
|
m_CsvImportWindow = New CsvWindowV(Application.Current.MainWindow, New CsvWindowVM)
|
|
m_CsvImportWindow.Show()
|
|
End If
|
|
EgtZoom(ZM.ALL)
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub StandardInsert()
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
Dim bWrongTrf As Boolean = False
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
' Ciclo di inserimento in tavola dei pezzi selezionati
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
' Recupero successivo selezionato
|
|
Dim nNextId = EgtGetNextSelectedObj()
|
|
' Se pezzo da Trf, verifico compatibilità
|
|
If Not VerifyTrfData(nId) Then
|
|
bWrongTrf = True
|
|
EgtSetStatus(nId, GDB_ST.ON_)
|
|
' Passo al successivo selezionato
|
|
nId = nNextId
|
|
Continue While
|
|
End If
|
|
' Lo metto in tavola, se possibile
|
|
If EstCalc.InsertOnePart(nId, CurrentMachine.bAligned, CurrentMachine.bReducedCut) Then
|
|
' Eventuale notifica al VeinMatching
|
|
VeinMatching.OnInsertPartInRaw(nId)
|
|
Else
|
|
VeinMatching.OnDeselectPart(nId)
|
|
End If
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Passo al successivo selezionato
|
|
nId = nNextId
|
|
End While
|
|
' Aggiorno flag selezionati
|
|
m_nPartPos = If(EgtGetSelectedObjCount() > 0, PART_POS.IN_TABLE, PART_POS.NONE_TABLE)
|
|
' Aggiorno vista
|
|
EgtZoom(ZM.ALL)
|
|
' Eventuale segnalazione di pezzi Trf non adatti
|
|
If bWrongTrf Then
|
|
' Pezzi con spessore, materiale o finitura non compatibili
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_NESTPAGEUC + 7), MSG_TYPE.WARNING)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub AutomaticInsert()
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90340)) ' Nesting Automatico in corso
|
|
Dim bWrongTrf As Boolean = False
|
|
Dim vParts As New List(Of Integer)
|
|
' Ciclo di pre-inserimento in tavola dei pezzi selezionati
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
' Recupero successivo selezionato
|
|
Dim nNextId = EgtGetNextSelectedObj()
|
|
' Se pezzo da Trf, verifico compatibilità
|
|
If Not VerifyTrfData(nId) Then
|
|
bWrongTrf = True
|
|
EgtSetStatus(nId, GDB_ST.ON_)
|
|
' Passo al successivo selezionato
|
|
nId = nNextId
|
|
Continue While
|
|
End If
|
|
' Lo preparo in tavola, se possibile
|
|
If PreInsertOnePart(nId) Then
|
|
vParts.Add(nId)
|
|
Else
|
|
EgtSetStatus(nId, GDB_ST.ON_)
|
|
VeinMatching.OnDeselectPart(nId)
|
|
End If
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Passo al successivo selezionato
|
|
nId = nNextId
|
|
End While
|
|
' Aggiorno le regioni per il nesting
|
|
UpdateNestRegions()
|
|
Dim bAligned As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_NEST_ALIGNED, 0, CurrentMachine.sMachIniFile) <> 0)
|
|
EnableReferenceRegion(bAligned)
|
|
' Eseguo nesting automatico
|
|
Dim bOpimizeOnX As Boolean = (GetMainPrivateProfileInt(S_NEST, K_AUTOMATICOPTIMIZE, 2) = 1)
|
|
Dim bGuillotineMode As Boolean = bAligned
|
|
Dim nAutomaticMaxTime As Integer = GetMainPrivateProfileInt(S_NEST, K_AUTOMATICMAXTIME, 20)
|
|
Dim dPartTime As Double = If(bGuillotineMode, 1.0, 0.5)
|
|
Dim nMaxTime As Integer = Math.Min(CInt(2 + dPartTime * vParts.Count()), nAutomaticMaxTime)
|
|
EgtAutomaticPackParts(vParts, bOpimizeOnX, CurrentMachine.bReducedCut, bGuillotineMode, nMaxTime)
|
|
' Sistemo i pezzi
|
|
For Each nPartId As Integer In vParts
|
|
' se pezzo inserito
|
|
If nPartId > 0 Then
|
|
VeinMatching.OnInsertPartInRaw(nPartId)
|
|
' Eventuale aggiunta solido per taglio da sotto
|
|
UpdateSolidForDrip(nPartId)
|
|
' altrimenti rifiutato
|
|
Else
|
|
' Ripristino lo stato originale
|
|
PreRemoveOnePart(Math.Abs(nPartId))
|
|
VeinMatching.OnDeselectPart(Math.Abs(nPartId))
|
|
End If
|
|
Next
|
|
' Aggiorno flag selezionati
|
|
m_nPartPos = If(EgtGetSelectedObjCount() > 0, PART_POS.IN_TABLE, PART_POS.NONE_TABLE)
|
|
' Aggiorno vista
|
|
EgtZoom(ZM.ALL)
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
' Eventuale segnalazione di pezzi Trf non adatti
|
|
If bWrongTrf Then
|
|
' Pezzi con spessore, materiale o finitura non compatibili
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_NESTPAGEUC + 7), MSG_TYPE.WARNING)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub VerifyMove()
|
|
If m_bVerify Then
|
|
' Determino cosa verificare
|
|
Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL)
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' Eseguo verifica
|
|
If VerifyTrfData(nMoveId) And EgtVerifyPart(nMoveId, CurrentMachine.bReducedCut) Then
|
|
EstCalc.ResetOrderMachiningFlag()
|
|
' Non superata riporto alla posizione iniziale
|
|
Else
|
|
If m_bFromParking Then
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
PreRemoveOnePart(nMoveId)
|
|
VeinMatching.OnRemovePartFromRaw(nMoveId)
|
|
Else
|
|
EgtMove(nMoveId, -m_vtTotMove)
|
|
' Eventuale notifica al VeinMatching
|
|
If nMoveId = GDB_ID.SEL Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Else
|
|
VeinMatching.OnMovePartInRaw(nMoveId)
|
|
End If
|
|
End If
|
|
'---------------------- COUNTER PART ----------------------
|
|
' solo se pezzo disposto in tavola
|
|
If m_bFromParking Then
|
|
Dim sRefGroup As String = String.Empty
|
|
If EgtGetInfo(nMoveId, INFO_REFGROUP, sRefGroup) Then
|
|
' accendo il layer che contiene il contatore (spento in fase di Drag)
|
|
Dim nCounterLayer As Integer = EgtGetFirstNameInGroup(nMoveId, INFO_COUNTERLY)
|
|
EgtSetStatus(nCounterLayer, GDB_ST.ON_)
|
|
' aggiorno il layer che indica il numero di pezzi in parcheggio
|
|
CountPartInFamily(sRefGroup)
|
|
End If
|
|
End If
|
|
'---------------------- COUNTER PART ----------------------
|
|
End If
|
|
m_bFromParking = False
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub VerifyRot()
|
|
' se comando Shift è stato attivato
|
|
If m_bKeyLeftShiftPressed Then
|
|
' Determino cosa verificare
|
|
Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL)
|
|
If Not EgtVerifyPart(nMoveId, CurrentMachine.bReducedCut) Then
|
|
Dim ptCen As Point3d
|
|
If Not EgtGetPartPartClusterCenterGlob(nMoveId, ptCen) Then Return
|
|
EgtRotate(nMoveId, ptCen, Vector3d.Z_AX(), -m_dAngTotal, GDB_RT.GLOB)
|
|
End If
|
|
End If
|
|
' resetto i valori
|
|
m_dStartAng = 0
|
|
m_dAngTotal = 0
|
|
m_bStartRot = False
|
|
End Sub
|
|
|
|
' verifica che la rotazione sia ammessa
|
|
Private Function RotatePartInsideBond(dAngRotDeg As Double, nIdMove As Integer) As Boolean
|
|
' Verifico se ci sono dei pezzi bloccati in rotazione
|
|
Dim bLockedRot As Boolean = GetLockOnRotation(nIdMove)
|
|
' Se tutti i pezzi possono ruotare
|
|
If Not bLockedRot Then
|
|
' Calcolo il centro di rotazione come centro del cluster
|
|
Dim ptCen As Point3d
|
|
If Not EgtGetPartPartClusterCenterGlob(nIdMove, ptCen) Then Return False
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' Verifico rotazione complessiva
|
|
EgtRotate(nIdMove, ptCen, Vector3d.Z_AX(), dAngRotDeg, GDB_RT.GLOB)
|
|
If EgtVerifyPart(nIdMove, CurrentMachine.bReducedCut) Then Return True
|
|
' Provo rotazione parziale (dopo aver annullato la complessiva)
|
|
EgtRotate(nIdMove, ptCen, Vector3d.Z_AX(), -dAngRotDeg, GDB_RT.GLOB)
|
|
Return EgtRotatePart(nIdMove, CurrentMachine.bReducedCut, ptCen, dAngRotDeg)
|
|
Else
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
Private Function RotateCluster(ByVal dAngRotDeg As Double) As Boolean
|
|
' Se non ci sono pezzi selezionati, esco
|
|
If EgtGetSelectedObjCount() = 0 Then Return True
|
|
|
|
' Se pezzi in parcheggio, li ruoto liberamente e li risistemo (sempre possibile)
|
|
If m_nPartPos <> PART_POS.IN_TABLE Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
' Se pezzo con rotazione libera
|
|
If Not EgtExistsInfo(nId, INFO_PARTROT) Then
|
|
' Calcolo il centro di rotazione come centro del pezzo
|
|
Dim ptCen As Point3d
|
|
If Not EgtGetPartPartClusterCenterGlob(nId, ptCen) Then Return False
|
|
' Rotazione del pezzo attorno al suo centro
|
|
EgtRotate(nId, ptCen, Vector3d.Z_AX(), dAngRotDeg, GDB_RT.GLOB)
|
|
|
|
'---------------------- COUNTER PART ----------------------
|
|
' Aggiorno il Guid assegnando la nuova rotazione
|
|
Dim sRefGroup As String = String.Empty
|
|
If EgtGetInfo(nId, INFO_REFGROUP, sRefGroup) Then
|
|
Dim sCurrRefGroup As String = sRefGroup
|
|
If UppDateGuidCode(sRefGroup, CreatePreGuidCode(nId)) Then
|
|
EgtSetInfo(nId, INFO_REFGROUP, sRefGroup)
|
|
End If
|
|
' aggiorno il layer che indica il numero di pezzi in parcheggio
|
|
CountPartInFamily(sCurrRefGroup)
|
|
End If
|
|
' se esiste almento un pezzo del gruppo in parcheggio esco
|
|
If Not ParkInGroupFamily(nId) Then
|
|
PackPartInStore(nId)
|
|
End If
|
|
' ricarico l'lelenco dei pezzi in parcheggio
|
|
GetFamilyGroupInPark()
|
|
'---------------------- COUNTER PART ----------------------
|
|
|
|
|
|
'' Sistemazione nel parcheggio
|
|
'PackPartInStore(nId)
|
|
End If
|
|
' Passo al successivo selezionato
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Return True
|
|
' Altrimenti li ruoto tenendo conto delle collisioni
|
|
Else
|
|
Return RotatePartInsideBond(dAngRotDeg, GDB_ID.SEL)
|
|
End If
|
|
End Function
|
|
|
|
Private Function GetLockOnRotation(nPartId As Integer) As Boolean
|
|
' Se singolo pezzo
|
|
If nPartId <> GDB_ID.SEL Then
|
|
Return EgtExistsInfo(nPartId, INFO_PARTROT)
|
|
' Altrimenti tutti i selezionati
|
|
Else
|
|
Dim bLockedRot As Boolean = False
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
If EgtExistsInfo(nId, INFO_PARTROT) Then
|
|
bLockedRot = True
|
|
Exit While
|
|
End If
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Return bLockedRot
|
|
End If
|
|
End Function
|
|
|
|
Friend Sub Refresh(PrevMeasureUnit As MeasureUnitOpt)
|
|
NotifyPropertyChanged("StepMove")
|
|
End Sub
|
|
|
|
Friend Function SelectPart(nPartId As Integer, bNotifyVM As Boolean, ByRef nOtherMgrpId As Integer) As Boolean
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Determino se pezzo in tavola, in parcheggio o in altro gruppo
|
|
Dim bPartInTable As Boolean = (EgtGetParent(nPartId) = EstCalc.GetRawId())
|
|
Dim bPartFree As Boolean = PartIsFree(nPartId)
|
|
' Se ci sono pezzi già selezionati nella posizione opposta, restituisco selezione non possibile
|
|
If (bPartInTable And m_nPartPos = PART_POS.OUT_TABLE) Or
|
|
(bPartFree And m_nPartPos = PART_POS.IN_TABLE) Then
|
|
nOtherMgrpId = GDB_ID.NULL
|
|
Return False
|
|
End If
|
|
' Se il pezzo appartiene ad un altro gruppo di lavoro, restituisco selezione non possibile
|
|
If Not bPartInTable And Not bPartFree Then
|
|
nOtherMgrpId = EstCalc.GetPartMachGroup(nPartId)
|
|
Return False
|
|
End If
|
|
' Eseguo la selezione
|
|
EgtSelectObj(nPartId)
|
|
' Eventuale aggiornamento VeinMatching
|
|
If bNotifyVM Then VeinMatching.OnSelectPart(nPartId)
|
|
' Set flag posizione selezionati
|
|
m_nPartPos = If(bPartInTable, PART_POS.IN_TABLE, PART_POS.OUT_TABLE)
|
|
' Selezione effettuata
|
|
EgtDraw()
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function DeselectPart(nPartId As Integer, bNotifyVM As Boolean) As Boolean
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Eseguo la deselezione
|
|
EgtDeselectObj(nPartId)
|
|
' Eventuale aggiornamento VeinMatching
|
|
If bNotifyVM Then VeinMatching.OnDeselectPart(nPartId)
|
|
' Se nessun pezzo selezionato, reset flag posizione selezionati
|
|
If EgtGetSelectedObjCount() = 0 Then m_nPartPos = PART_POS.NONE_TABLE
|
|
' Deselezione effettuata
|
|
EgtDraw()
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function DeselectAllParts(bNotifyVM As Boolean) As Boolean
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Eseguo
|
|
EgtDeselectAll()
|
|
' Eventuale notifica al VeinMatching
|
|
If bNotifyVM Then VeinMatching.OnDeselectAll()
|
|
' Imposto flag posizione pezzi
|
|
m_nPartPos = PART_POS.NONE_TABLE
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function ExitNesting(bChange As Boolean) As Boolean
|
|
If m_CsvImport_IsChecked Then
|
|
m_CsvImportWindow.Close()
|
|
m_CsvImportWindow = Nothing
|
|
End If
|
|
If bChange Then
|
|
OmagOFFICEMap.refVeinMatchPanelVM.SetVeinMatchIsChecked(False)
|
|
OmagOFFICEMap.refVeinMatchPanelVM.VeinMatchIsEnabled = False
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
#Region "DRAG RECTANGLE"
|
|
|
|
' funzione chiamata da OnMyMouseMoveScene: verifica che la selezione sia corretta (deve essere il lato di una figura rettangolare)
|
|
Private Sub OnMyMouseDownSceneSelSideRectangle(sender As Object, e As System.Windows.Forms.MouseEventArgs)
|
|
' Si può selezionare solo con il tasto sinistro
|
|
If e.Button <> Windows.Forms.MouseButtons.Left Then Return
|
|
' 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_nIdSelectedOutLoopRectangle = nIdParent
|
|
If Not IsRectangle(m_SideListRectangle) 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, NAME_PREVIEW)
|
|
' 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 EgtGetGroupObjs(nIdSaw) <> 0 Then
|
|
m_nIdSelectedSawRectangle = nIdSaw
|
|
m_nIdSelectedCurvRectangle = nIdMy
|
|
|
|
m_nIdSelectedRegionRectangle = EgtGetFirstNameInGroup(nIdParentPart, NAME_REGION)
|
|
' recupero i testi contenuti nel layer Region
|
|
If m_nIdSelectedRegionRectangle <> GDB_ID.NULL Then
|
|
Dim nCurrId As Integer = EgtGetFirstInGroup(m_nIdSelectedRegionRectangle)
|
|
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_nIdSelectedTextTopRectangle = nCurrId
|
|
Else
|
|
m_nIdSelectedTextRectangle = nCurrId
|
|
m_sTextContent = GetMyRectangleText(sVal)
|
|
End If
|
|
ElseIf EgtGetType(nCurrId) = GDB_TY.SRF_FRGN Then
|
|
m_nIdSelectedFlatSurfRectangle = 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 l'elemento corrente non è una linea
|
|
End If
|
|
' se l'elemento 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 GetMyRectangleText(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
|
|
sText = sInfo(0) & " " & sInfo(1) & " "
|
|
Return sText
|
|
End If
|
|
End If
|
|
Return sText
|
|
End Function
|
|
|
|
' verifico che la figura selezionata sia realmente un rettangolo
|
|
Private Function IsRectangle(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 IdSideRectangle As Integer = EgtGetFirstInGroup(m_nIdSelectedOutLoopRectangle)
|
|
While IdSideRectangle <> GDB_ID.NULL And nCounter < 4
|
|
Dim sVal As String = String.Empty
|
|
Dim dPrevAng As Double = 0
|
|
EgtGetInfo(IdSideRectangle, "PrevAng", sVal)
|
|
StringToDouble(sVal, dPrevAng)
|
|
Dim dNextAng As Double = 0
|
|
EgtGetInfo(IdSideRectangle, "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) = IdSideRectangle
|
|
nCounter += 1
|
|
IdSideRectangle = EgtGetNext(IdSideRectangle)
|
|
End While
|
|
' verifico che siano solo quattro lati
|
|
If IdSideRectangle = GDB_ID.NULL And nCounter = 4 Then
|
|
' solo se la figura ha 4 lati ortogonali
|
|
Return True
|
|
End If
|
|
|
|
m_nIdSelectedOutLoopRectangle = 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 GetRectangleInfoScale(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_nIdSelectedCurvRectangle, 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_SideListRectangle(Ind) = m_nIdSelectedCurvRectangle 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_SideListRectangle(Index), MaxLen)
|
|
EgtCurveLength(m_nIdSelectedCurvRectangle, 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_SideListRectangle(Index), GDB_ID.ROOT, vtDir)
|
|
vtDir.Normalize()
|
|
Dim dProjectionBaseX As Double = vtDir * Vector3d.X_AX
|
|
Dim ptFixed As New Point3d
|
|
EgtStartPoint(m_SideListRectangle(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 OnMyMouseMoveSawRectangle(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 = GetRectangleInfoScale(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_nIdSelectedOutLoopRectangle, frFixed, dScalefactor, 1, 1, GDB_RT.GLOB)
|
|
EgtScale(m_nIdSelectedFlatSurfRectangle, frFixed, dScalefactor, 1, 1, GDB_RT.GLOB)
|
|
Dim ptCen As Point3d
|
|
EgtCenterPoint(m_nIdSelectedTextRectangle, ptCen)
|
|
EgtModifyText(m_nIdSelectedTextRectangle, m_sTextContent & LenToString(MaxLen + dProjection, 2) & " x " & LenToString(MinLen, 2))
|
|
EgtMove(m_nIdSelectedTextRectangle, vtMove * 0.5, GDB_RT.GLOB)
|
|
If m_nIdSelectedTextTopRectangle <> GDB_ID.NULL Then
|
|
EgtMove(m_nIdSelectedTextTopRectangle, vtMove * 0.5, GDB_RT.GLOB)
|
|
End If
|
|
End If
|
|
|
|
' verifico che il il lato maggiore rimanga semore il lato maggiore
|
|
Dim bRectangleCorrect As Boolean = False
|
|
If (MaxLen + dProjection - MinLen) > EPS_SMALL Then bRectangleCorrect = True
|
|
|
|
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_nIdSelectedOutLoopRectangle), True) Or Not bRectangleCorrect Then
|
|
EgtScale(m_nIdSelectedOutLoopRectangle, frFixed, 1 / dScalefactor, 1, 1, GDB_RT.GLOB)
|
|
EgtScale(m_nIdSelectedFlatSurfRectangle, frFixed, 1 / dScalefactor, 1, 1, GDB_RT.GLOB)
|
|
Dim ptCen As Point3d
|
|
EgtCenterPoint(m_nIdSelectedTextRectangle, ptCen)
|
|
EgtModifyText(m_nIdSelectedTextRectangle, m_sTextContent & LenToString(MaxLen, 2) & " x " & LenToString(MinLen, 2))
|
|
EgtMove(m_nIdSelectedTextRectangle, -vtMove * 0.5, GDB_RT.GLOB)
|
|
If m_nIdSelectedTextTopRectangle <> GDB_ID.NULL Then
|
|
EgtMove(m_nIdSelectedTextTopRectangle, -vtMove * 0.5, GDB_RT.GLOB)
|
|
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 ResetDragRectangleParam()
|
|
' deseleziono l'elemento corrente
|
|
EgtDeselectObj(m_nIdSelectedSawRectangle)
|
|
EgtDeselectObj(m_nIdSelectedCurvRectangle)
|
|
EgtResetMark(m_nIdSelectedSawRectangle)
|
|
' resetto gli indici
|
|
m_nIdSelectedOutLoopRectangle = GDB_ID.NULL
|
|
m_nIdSelectedRegionRectangle = GDB_ID.NULL
|
|
m_nIdSelectedSawRectangle = GDB_ID.NULL
|
|
m_nIdSelectedCurvRectangle = GDB_ID.NULL
|
|
m_nIdSelectedTextRectangle = GDB_ID.NULL
|
|
m_nIdSelectedTextTopRectangle = GDB_ID.NULL
|
|
m_nIdSelectedFlatSurfRectangle = GDB_ID.NULL
|
|
m_SideListRectangle = {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
|
|
|
|
Private m_bDragRectangle As Boolean
|
|
Public Property bDragRectangle As Boolean
|
|
Get
|
|
Return m_bDragRectangle
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bDragRectangle = value
|
|
m_bSplitCurvWJ = False
|
|
ResetSplitCurvWJParam(True)
|
|
m_bStartCurvWJ = False
|
|
ResetStartCurvWJParam(True)
|
|
NotifyPropertyChanged("bSplitCurvWJ")
|
|
NotifyPropertyChanged("bStartCurvWJ")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_DragRectangle_Visibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property DragRectangle_Visibility As Visibility
|
|
Get
|
|
Return m_DragRectangle_Visibility
|
|
End Get
|
|
End Property
|
|
|
|
#Region "WATERJET SPLIT CURVE"
|
|
|
|
' funzione per la selezione dei lati su cui operare la separazione del tagli waterjet
|
|
Private Sub OnMyMouseDownSceneSplitCurv(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 Or
|
|
Not m_bSplitCurvWJ Then
|
|
Return
|
|
End If
|
|
' Se esiste un elemento selezionato
|
|
EgtResetMark(m_nIdSelectedWaterJet)
|
|
' 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_ARC OrElse EgtGetType(nIdMy) = GDB_TY.CRV_COMPO OrElse EgtGetType(nIdMy) = GDB_TY.CRV_LINE Then
|
|
If m_nIdSelectedSideWJ <> GDB_ID.NULL Or m_nIdSelectedSideWJ = nIdMy Then
|
|
EgtDeselectObj(m_nIdSelectedSideWJ)
|
|
End If
|
|
' recupero il gruppo della lavorazione associata
|
|
Dim nIdParentPart As Integer = EgtGetParent(nIdParent)
|
|
Dim nIdPV As Integer = EgtGetFirstNameInGroup(nIdParentPart, NAME_PREVIEW)
|
|
' VERIFICA: recupero l'elenco delle Preview di Tipo WaterJet associate a questo Part
|
|
Dim ListGroup As List(Of Integer) = ResearchGropuWJ(nIdParent, nIdPV)
|
|
' VERIFICA: se esistono delle lavorazioni associate al percorso OutLoop di tipo Saw allora non procedo
|
|
Dim ListGroupSaw As List(Of Integer) = ResearchGropuSaw(nIdParent, nIdPV)
|
|
' se non esiste almeno 1 Preview di tipo WaterJet
|
|
If ListGroup.Count > 0 And ListGroupSaw.Count = 0 Then
|
|
m_nIdSelectedSideWJ = nIdMy
|
|
Dim nValInfo As Integer = 1
|
|
Dim nNewValInfo As Integer = nValInfo
|
|
If EgtGetInfo(nIdMy, INFO_JOINTENTITY, nValInfo) Then
|
|
If nValInfo = 1 Then
|
|
nNewValInfo = 0
|
|
Else
|
|
nNewValInfo = 1
|
|
End If
|
|
Else
|
|
' se manca l'info allora il taglio sValInfo = "1" quindi separo il taglio
|
|
nNewValInfo = 0
|
|
End If
|
|
EgtSetInfo(nIdMy, INFO_JOINTENTITY, nNewValInfo)
|
|
' Ricalcolo tutte le lavorazioni
|
|
Dim nWarn As Integer = 0
|
|
ResetAllMachinings(nWarn)
|
|
' recupero l'indice del PreView che deve essere acceso per indicare la selezione
|
|
ListGroup = ResearchGropuWJ(nIdParent, nIdPV)
|
|
Dim nIdWJ As Integer = GetPVIdFromIdSide(ListGroup, nIdMy)
|
|
GetCurrentPVFromIdSide(ListGroup, nIdMy, nIdWJ, nIdParent)
|
|
' assegno un identificativo grafico per inidcare che è un taglio separato
|
|
If nNewValInfo = 0 Then
|
|
AssignFlagOnGraphic(nIdMy, nIdParentPart)
|
|
Else
|
|
EraseFlagOnGraphic(nIdMy, nIdParentPart)
|
|
End If
|
|
' salvo il valore del PreView evidenziato
|
|
m_nIdSelectedWaterJet = nIdWJ
|
|
EgtSetMark(nIdWJ)
|
|
EgtSelectObj(nIdMy)
|
|
EgtDraw()
|
|
Exit While
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
nIdMy = EgtGetNextObjInSelWin()
|
|
End While
|
|
Return
|
|
End Sub
|
|
|
|
' restituisce l'elenco dei Gruppi Waterjet associati al contorno indicato
|
|
Public Function ResearchGropuWJ(nIdOutLoop As Integer, nIdPV As Integer) As List(Of Integer)
|
|
Dim ListOfGroupPV As New List(Of Integer)
|
|
Dim nIdGroup As Integer = GDB_ID.NULL
|
|
Dim nIdMy As Integer = GDB_ID.NULL
|
|
' recupero il primo lato dall'elenco dei lati della figura
|
|
nIdMy = EgtGetFirstInGroup(nIdOutLoop)
|
|
' altrimenti cerco all'interno del layer OutLoop per ogni lato la lavorazione associata
|
|
While nIdMy <> GDB_ID.NULL
|
|
' verifico se esiste una Preview associata al lato
|
|
nIdGroup = EgtGetFirstNameInGroup(nIdPV, "Waterjet" & nIdMy.ToString & "S")
|
|
If nIdGroup <> GDB_ID.NULL Then
|
|
ListOfGroupPV.Add(nIdGroup)
|
|
End If
|
|
nIdMy = EgtGetNext(nIdMy)
|
|
End While
|
|
Return ListOfGroupPV
|
|
End Function
|
|
|
|
' restituisce l'elenco dei Gruppi Saw associati al contorno indicato
|
|
Public Function ResearchGropuSaw(nIdOutLoop As Integer, nIdPV As Integer) As List(Of Integer)
|
|
Dim ListOfGroupPV As New List(Of Integer)
|
|
Dim nIdGroup As Integer = GDB_ID.NULL
|
|
Dim nIdMy As Integer = GDB_ID.NULL
|
|
' recupero il primo lato dall'elenco dei lati della figura
|
|
nIdMy = EgtGetFirstInGroup(nIdOutLoop)
|
|
' altrimenti cerco all'interno del layer OutLoop per ogni lato la lavorazione associata
|
|
While nIdMy <> GDB_ID.NULL
|
|
' verifico se esiste una Preview associata al lato
|
|
nIdGroup = EgtGetFirstNameInGroup(nIdPV, "Saw" & nIdMy.ToString)
|
|
If nIdGroup <> GDB_ID.NULL Then
|
|
ListOfGroupPV.Add(nIdGroup)
|
|
End If
|
|
nIdMy = EgtGetNext(nIdMy)
|
|
End While
|
|
Return ListOfGroupPV
|
|
End Function
|
|
|
|
Public Function GetPVIdFromIdSide(ListGroup As List(Of Integer), nIdMy As Integer) As Integer
|
|
Dim IdWaterjetPV As Integer = GDB_ID.NULL
|
|
For Each nIdItem As Integer In ListGroup
|
|
Dim sName As String = String.Empty
|
|
If EgtGetName(nIdItem, sName) Then
|
|
If sName.Contains(nIdMy.ToString) Then
|
|
IdWaterjetPV = nIdItem
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
Return IdWaterjetPV
|
|
End Function
|
|
|
|
Public Sub GetCurrentPVFromIdSide(ListGroup As List(Of Integer), nIdMy As Integer, ByRef nIdWj As Integer, nIdParent As Integer)
|
|
Dim nObjInGroup As Integer = EgtGetGroupObjs(nIdParent)
|
|
Dim nCount As Integer = 0
|
|
GetNextSideJoint(ListGroup, nIdMy, nIdWj, nCount, nObjInGroup)
|
|
If nIdWj <> GDB_ID.NULL Then Return
|
|
GetPrevSideJoint(ListGroup, nIdMy, nIdWj, nCount, nObjInGroup)
|
|
End Sub
|
|
|
|
' funzione ricorsiva per la ricerca del lato al quale è associata la PreView
|
|
Private Sub GetNextSideJoint(ListGroup As List(Of Integer), nIdMy As Integer, ByRef nIdWj As Integer, ByRef nCount As Integer, nObjInGroup As Integer)
|
|
Dim nValInfo As Integer = 1
|
|
' espressione di controllo per evitare di generare Loop infinito
|
|
If nCount > nObjInGroup Then Return
|
|
If nIdWj = GDB_ID.NULL Then
|
|
Dim nIdWJNext As Integer = EgtGetNext(nIdMy)
|
|
If nIdWJNext = GDB_ID.NULL Then nIdWJNext = EgtGetFirstInGroup(EgtGetParent(nIdMy))
|
|
nCount += 1
|
|
EgtGetInfo(nIdWJNext, "JoinEntity", nValInfo)
|
|
If nValInfo = 1 Then
|
|
nIdWj = GetPVIdFromIdSide(ListGroup, nIdWJNext)
|
|
If nIdWj <> GDB_ID.NULL Then Return
|
|
Else
|
|
Return
|
|
End If
|
|
'nIdWJNext = EgtGetNext(nIdWJNext)
|
|
GetNextSideJoint(ListGroup, nIdWJNext, nIdWj, nCount, nObjInGroup)
|
|
If nIdWj <> GDB_ID.NULL Then Return
|
|
End If
|
|
End Sub
|
|
|
|
' funzione ricorsiva per la ricerca del lato al quale è associata la PreView
|
|
Private Sub GetPrevSideJoint(ListGroup As List(Of Integer), nIdMy As Integer, ByRef nIdWj As Integer, ByRef nCount As Integer, nObjInGroup As Integer)
|
|
Dim nValInfo As Integer = 1
|
|
' espressione di controllo per evitare di generare Loop infinito
|
|
If nCount > nObjInGroup Then Return
|
|
If nIdWj = GDB_ID.NULL Then
|
|
Dim nIdWJPrev As Integer = EgtGetPrev(nIdMy)
|
|
' se arrivato al primo valore allora continuo la ricerca dall'ultimo
|
|
If nIdWJPrev = GDB_ID.NULL Then nIdWJPrev = EgtGetLastInGroup(EgtGetParent(nIdMy))
|
|
nCount += 1
|
|
EgtGetInfo(nIdWJPrev, INFO_JOINTENTITY, nValInfo)
|
|
If nValInfo = 1 Then
|
|
nIdWj = GetPVIdFromIdSide(ListGroup, nIdWJPrev)
|
|
If nIdWj <> GDB_ID.NULL Then Return
|
|
Else
|
|
Return
|
|
End If
|
|
'nIdWJPrev = EgtGetPrev(nIdWJPrev)
|
|
GetPrevSideJoint(ListGroup, nIdWJPrev, nIdWj, nCount, nObjInGroup)
|
|
If nIdWj <> GDB_ID.NULL Then Return
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub ResetSplitCurvWJParam(Optional bAllParam As Boolean = True)
|
|
If bAllParam Then
|
|
EgtDeselectObj(m_nIdSelectedSideWJ)
|
|
EgtResetMark(m_nIdSelectedWaterJet)
|
|
End If
|
|
m_nIdSelectedSideWJ = GDB_ID.NULL
|
|
m_nIdSelectedWaterJet = GDB_ID.NULL
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
' ricevo l'ID del percorso di lavorazione WJ al quale associo una etichetta grafica con scritto "S"
|
|
Private Sub AssignFlagOnGraphic(nIdMy As Integer, IdParentPart As Integer)
|
|
' cerco se esiste già un layer nominato "AUX_SPLIT_WJ", altrimenti lo creo
|
|
Dim IdAuxLayer As Integer = EgtGetFirstNameInGroup(IdParentPart, INFO_AUX_SPLIT_WJ)
|
|
If IdAuxLayer = GDB_ID.NULL Then
|
|
IdAuxLayer = EgtCreateGroup(IdParentPart)
|
|
EgtSetName(IdAuxLayer, INFO_AUX_SPLIT_WJ)
|
|
End If
|
|
' recupero il punto medio del segmento selezionato
|
|
Dim MidPoint As Point3d
|
|
EgtMidPoint(nIdMy, GDB_RT.GLOB, MidPoint)
|
|
'Dim nIdTextFlag As Integer = EgtCreateText(IdAuxLayer, MidPoint, "*", 20, GDB_RT.GLOB)
|
|
Dim nIdTextFlag As Integer = GetCreateFlagText(nIdMy, IdAuxLayer)
|
|
EgtSetColor(nIdTextFlag, New Color3d(255, 0, 0))
|
|
EgtSetName(nIdTextFlag, "RefSide_" & nIdMy.ToString)
|
|
End Sub
|
|
|
|
Private Function GetCreateFlagText(nId As Integer, nIdLayer As Integer, Optional sText As String = "*") As Integer
|
|
' recupero il punto medio
|
|
Dim MidPoint As Point3d
|
|
EgtMidPoint(nId, GDB_RT.GLOB, MidPoint)
|
|
' recupero la direzione del vettore nel punto medio
|
|
Dim vVers As Vector3d
|
|
EgtMidVector(nId, GDB_RT.GLOB, vVers)
|
|
vVers.Normalize()
|
|
vVers.Rotate(Vector3d.Z_AX, 90)
|
|
' Ingombro complessivo della lavorazione
|
|
Dim ptMin, ptMax As Point3d
|
|
EgtStartPoint(nId, GDB_RT.GLOB, ptMin)
|
|
EgtEndPoint(nId, GDB_RT.GLOB, ptMax)
|
|
' Metto il numero nel centro
|
|
Dim dRadXY = Point3d.DistXY(ptMin, ptMax)
|
|
Dim dHtxt As Double = 50
|
|
Dim dRat As Double = 0.75
|
|
If dRadXY < 200 Then
|
|
dHtxt = 40
|
|
dRat = 0.6
|
|
ElseIf dRadXY < 25 Then
|
|
dHtxt = 25
|
|
dRat = 0.5
|
|
End If
|
|
' determino la posizione del flag
|
|
MidPoint.x += vVers.x * dHtxt / 2
|
|
MidPoint.y += vVers.y * dHtxt / 2
|
|
|
|
Return EgtCreateTextAdv(nIdLayer, MidPoint, 0, sText, "", 300, False, dHtxt, dRat, 0, INS_POS.MC, GDB_RT.GLOB)
|
|
End Function
|
|
|
|
Private Sub EraseFlagOnGraphic(nIdMy As Integer, IdParentPart As Integer)
|
|
' cerco se esiste già un layer nominato "AUX_SPLIT_WJ", altrimenti lo creo
|
|
Dim IdAuxLayer As Integer = EgtGetFirstNameInGroup(IdParentPart, INFO_AUX_SPLIT_WJ)
|
|
If IdAuxLayer = GDB_ID.NULL Then Return
|
|
Dim nIdTextFlag As Integer = EgtGetFirstNameInGroup(IdAuxLayer, "RefSide_" & nIdMy.ToString)
|
|
EgtErase(nIdTextFlag)
|
|
End Sub
|
|
|
|
#End Region ' WaterJet Section and StartPoint
|
|
|
|
Private m_bSplitCurvWJ As Boolean
|
|
Public Property bSplitCurvWJ As Boolean
|
|
Get
|
|
Return m_bSplitCurvWJ
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bSplitCurvWJ = value
|
|
If Not m_bSplitCurvWJ Then
|
|
' resetto i parametri di selezione dei lati
|
|
ResetSplitCurvWJParam(True)
|
|
End If
|
|
m_bDragRectangle = False
|
|
m_bStartCurvWJ = False
|
|
ResetStartCurvWJParam(True)
|
|
NotifyPropertyChanged("bDragRectangle")
|
|
NotifyPropertyChanged("bStartCurvWJ")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_WJ_Cmd_Visibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property WJ_Cmd_Visibility As Visibility
|
|
Get
|
|
Return m_WJ_Cmd_Visibility
|
|
End Get
|
|
End Property
|
|
|
|
' in funzione della macchinata attiva predispone la visualizzazione del bottone SplitCurv (abilitato solo per WaterJet Machine)
|
|
Public Sub Set_WJ_Cmd_Visibility()
|
|
' gestisco la visualizzazione del comando ON_OFF (per i tagli waterjet)
|
|
If CurrentMachine.WaterJettingActive Then
|
|
m_WJ_Cmd_Visibility = Visibility.Visible
|
|
Else
|
|
m_WJ_Cmd_Visibility = Visibility.Collapsed
|
|
End If
|
|
NotifyPropertyChanged("WJ_Cmd_Visibility")
|
|
End Sub
|
|
|
|
#Region "WATERJET START POINT"
|
|
|
|
' funzione per la selezione del punto di inizio tagli waterjet (percorso chiuso)
|
|
Private Sub OnMyMouseDownSceneStartCurv(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 Or
|
|
Not m_bStartCurvWJ Then
|
|
Return
|
|
End If
|
|
|
|
' Acquisisco punto da disegno
|
|
Dim ptStartCurv As New Point3d
|
|
EgtUnProjectPoint(e.Location, ptStartCurv)
|
|
' Aggiusto Z punto acquisito (è in globale)
|
|
Dim ptRawMax As New Point3d
|
|
Dim ptRawMin As New Point3d
|
|
If GetRawBox(ptRawMin, ptRawMax) Then
|
|
ptStartCurv.z = ptRawMax.z
|
|
End If
|
|
|
|
' Se esiste un elemento selezionato
|
|
EgtResetMark(m_nIdSelectedWaterJet)
|
|
' 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 Or sLayer = NAME_INLOOP Then
|
|
If EgtGetType(nIdMy) = GDB_TY.CRV_ARC OrElse EgtGetType(nIdMy) = GDB_TY.CRV_COMPO OrElse EgtGetType(nIdMy) = GDB_TY.CRV_LINE Then
|
|
' verifico che il contorno sia chiuso, altrimenti esco
|
|
If Not VerifyOutLoopIsClosed(nIdParent) Then
|
|
'91131=Il contorno non è chiuso
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(91131), MSG_TYPE.WARNING)
|
|
Exit While
|
|
End If
|
|
' recupero il gruppo della lavorazione associata
|
|
Dim nIdParentPart As Integer = EgtGetParent(nIdParent)
|
|
Dim nIdPV As Integer = EgtGetFirstNameInGroup(nIdParentPart, NAME_PREVIEW)
|
|
' VERIFICA: recupero l'elenco delle Preview di Tipo WaterJet_n_S associate a questo Part
|
|
Dim ListGroup As List(Of Integer) = ResearchGropuWJ(nIdParent, nIdPV)
|
|
' VERIFICA: se esistono delle lavorazioni associate al percorso OutLoop di tipo Saw allora non procedo
|
|
Dim ListGroupSaw As List(Of Integer) = ResearchGropuSaw(nIdParent, nIdPV)
|
|
' se non esiste almeno 1 Preview di tipo WaterJet
|
|
If ListGroup.Count = 1 And ListGroupSaw.Count = 0 Then
|
|
EgtSetInfo(nIdParent, INFO_START, ptStartCurv)
|
|
' Ricalcolo tutte le lavorazioni
|
|
Dim nWarn As Integer = 0
|
|
ResetAllMachinings(nWarn)
|
|
' recupero l'indice del PreView che deve essere acceso per indicare la selezione
|
|
ListGroup = ResearchGropuWJ(nIdParent, nIdPV)
|
|
Dim nIdWJ As Integer = GetPVIdFromIdSide(ListGroup, nIdMy)
|
|
GetCurrentPVFromIdSide(ListGroup, nIdMy, nIdWJ, nIdParent)
|
|
m_nIdSelectedWaterJet = nIdWJ
|
|
EgtSetMark(nIdWJ)
|
|
EgtDraw()
|
|
Exit While
|
|
Else
|
|
'91131=Il contorno non è chiuso
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(91131), MSG_TYPE.WARNING)
|
|
Exit While
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
nIdMy = EgtGetNextObjInSelWin()
|
|
End While
|
|
Return
|
|
End Sub
|
|
|
|
#End Region ' Water Start Point
|
|
|
|
Private m_bStartCurvWJ As Boolean
|
|
Public Property bStartCurvWJ As Boolean
|
|
Get
|
|
Return m_bStartCurvWJ
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bStartCurvWJ = value
|
|
If Not m_bStartCurvWJ Then
|
|
ResetStartCurvWJParam(True)
|
|
End If
|
|
m_bDragRectangle = False
|
|
m_bSplitCurvWJ = False
|
|
ResetSplitCurvWJParam(True)
|
|
NotifyPropertyChanged("bDragRectangle")
|
|
NotifyPropertyChanged("bSplitCurvWJ")
|
|
End Set
|
|
End Property
|
|
|
|
Public Sub ResetStartCurvWJParam(Optional bAllParam As Boolean = True)
|
|
If bAllParam Then
|
|
EgtDeselectObj(m_nIdSelectedSideWJ)
|
|
EgtResetMark(m_nIdSelectedWaterJet)
|
|
End If
|
|
m_nIdSelectedSideWJ = GDB_ID.NULL
|
|
m_nIdSelectedWaterJet = GDB_ID.NULL
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "DrawCommand"
|
|
|
|
Public ReadOnly Property DrawCommand As ICommand
|
|
Get
|
|
If m_cmdDraw Is Nothing Then
|
|
m_cmdDraw = New Command(AddressOf Draw)
|
|
End If
|
|
Return m_cmdDraw
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Draw(ByVal param As Object)
|
|
Dim CompoWindow As New CompoWindowV(Application.Current.MainWindow, New CompoWindowVM)
|
|
CompoWindow.Height = 700
|
|
CompoWindow.ShowDialog()
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
End Sub
|
|
|
|
#End Region ' DrawCommand
|
|
|
|
#Region "ImportDxfCommand"
|
|
|
|
Public ReadOnly Property ImportDxfCommand As ICommand
|
|
Get
|
|
If m_cmdImportDxf Is Nothing Then
|
|
m_cmdImportDxf = New Command(AddressOf ImportDxf)
|
|
End If
|
|
Return m_cmdImportDxf
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ImportDxf(ByVal param As Object)
|
|
Dim DxfImportWindow As New DxfImportWindowV(Application.Current.MainWindow, New DxfImportWindowVM)
|
|
DxfImportWindow.ShowDialog()
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
End Sub
|
|
|
|
#End Region ' ImportDxfCommand
|
|
|
|
#Region "PartRotOnCommand"
|
|
|
|
Public ReadOnly Property PartRotOnCommand As ICommand
|
|
Get
|
|
If m_cmdPartRotOn Is Nothing Then
|
|
m_cmdPartRotOn = New Command(AddressOf PartRotOn)
|
|
End If
|
|
Return m_cmdPartRotOn
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub PartRotOn(ByVal param As Object)
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Se non ci sono pezzi selezionati o non sono in parcheggio, esco
|
|
If EgtGetSelectedObjCount() = 0 OrElse m_nPartPos <> PART_POS.OUT_TABLE Then Return
|
|
' Tolgo blocco rotazione sui pezzi selezionati
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
' Se rotazione bloccata, tolgo blocco e aggiorno info
|
|
If EgtExistsInfo(nId, INFO_PARTROT) Then
|
|
' Rimuovo flag di rotazione bloccata
|
|
EgtRemoveInfo(nId, INFO_PARTROT)
|
|
' Tolgo da info sul pezzo Codice
|
|
Dim nTextId As Integer = EgtGetFirstInGroup(EgtGetFirstNameInGroup(nId, NAME_REGION))
|
|
While nTextId <> GDB_ID.NULL
|
|
If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then
|
|
Dim sText As String = ""
|
|
EgtTextGetContent(nTextId, sText)
|
|
sText = sText.Replace("<br/>(X)", "")
|
|
EgtModifyText(nTextId, sText)
|
|
Exit While
|
|
End If
|
|
nTextId = EgtGetNext(nTextId)
|
|
End While
|
|
End If
|
|
' Passo al successivo selezionato
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' PartRotOnCommand
|
|
|
|
#Region "PartRotOffCommand"
|
|
|
|
Public ReadOnly Property PartRotOffCommand As ICommand
|
|
Get
|
|
If m_cmdPartRotOff Is Nothing Then
|
|
m_cmdPartRotOff = New Command(AddressOf PartRotOff)
|
|
End If
|
|
Return m_cmdPartRotOff
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub PartRotOff(ByVal param As Object)
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Se non ci sono pezzi selezionati o non sono in parcheggio, esco
|
|
If EgtGetSelectedObjCount() = 0 OrElse m_nPartPos <> PART_POS.OUT_TABLE Then Return
|
|
' Metto blocco rotazione sui pezzi selezionati
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
' Se rotazione libera, applico blocco e aggiorno info
|
|
If Not EgtExistsInfo(nId, INFO_PARTROT) Then
|
|
' Imposto flag di rotazione bloccata
|
|
EgtSetInfo(nId, INFO_PARTROT, 0)
|
|
' Inserisco in info sul pezzo Codice
|
|
Dim nTextId As Integer = EgtGetFirstInGroup(EgtGetFirstNameInGroup(nId, NAME_REGION))
|
|
While nTextId <> GDB_ID.NULL
|
|
If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then
|
|
Dim sText As String = ""
|
|
EgtTextGetContent(nTextId, sText)
|
|
sText &= "<br/>(X)"
|
|
EgtModifyText(nTextId, sText)
|
|
Exit While
|
|
End If
|
|
nTextId = EgtGetNext(nTextId)
|
|
End While
|
|
End If
|
|
' Passo al successivo selezionato
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' PartRotOffCommand
|
|
|
|
#Region "UpCommand"
|
|
|
|
Public ReadOnly Property UpCommand As ICommand
|
|
Get
|
|
If m_cmdUp Is Nothing Then
|
|
m_cmdUp = New Command(AddressOf Up)
|
|
End If
|
|
Return m_cmdUp
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Up(ByVal param As Object)
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' eseguo movimento
|
|
Dim dStep As Double = If(m_MaxMoveIsChecked, m_dMaxStep, m_dStepMove)
|
|
EgtMovePart(GDB_ID.SEL, CurrentMachine.bReducedCut, New Vector3d(0, dStep, 0))
|
|
EgtSaveCollInfo()
|
|
' se abilitato magnetico (allineamento + snap), lo provo
|
|
Dim bAlignMoved As Boolean = False
|
|
Dim bSnapMoved As Boolean = False
|
|
If m_bMagnetic Then
|
|
If Not GetLockOnRotation(GDB_ID.SEL) Then
|
|
EgtAlignPartOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, bAlignMoved)
|
|
End If
|
|
If m_dSnapDist > EPS_SMALL Then
|
|
EgtRestoreCollInfo()
|
|
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, m_dSnapDist, bSnapMoved)
|
|
End If
|
|
End If
|
|
EstCalc.ResetOrderMachiningFlag()
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' UpCommand
|
|
|
|
#Region "LeftCommand"
|
|
|
|
Public ReadOnly Property LeftCommand As ICommand
|
|
Get
|
|
If m_cmdLeft Is Nothing Then
|
|
m_cmdLeft = New Command(AddressOf Left)
|
|
End If
|
|
Return m_cmdLeft
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Left(ByVal param As Object)
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' eseguo movimento
|
|
Dim dStep As Double = If(m_MaxMoveIsChecked, m_dMaxStep, m_dStepMove)
|
|
EgtMovePart(GDB_ID.SEL, CurrentMachine.bReducedCut, New Vector3d(-dStep, 0, 0))
|
|
EgtSaveCollInfo()
|
|
' se abilitato magnetico (allineamento + snap), lo provo
|
|
Dim bAlignMoved As Boolean = False
|
|
Dim bSnapMoved As Boolean = False
|
|
If m_bMagnetic Then
|
|
If Not GetLockOnRotation(GDB_ID.SEL) Then
|
|
EgtAlignPartOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, bAlignMoved)
|
|
End If
|
|
If m_dSnapDist > EPS_SMALL Then
|
|
EgtRestoreCollInfo()
|
|
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, m_dSnapDist, bSnapMoved)
|
|
End If
|
|
End If
|
|
EstCalc.ResetOrderMachiningFlag()
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' LeftCommand
|
|
|
|
#Region "RightCommand"
|
|
|
|
Public ReadOnly Property RightCommand As ICommand
|
|
Get
|
|
If m_cmdRight Is Nothing Then
|
|
m_cmdRight = New Command(AddressOf Right)
|
|
End If
|
|
Return m_cmdRight
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Right(ByVal param As Object)
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' eseguo movimento
|
|
Dim dStep As Double = If(m_MaxMoveIsChecked, m_dMaxStep, m_dStepMove)
|
|
EgtMovePart(GDB_ID.SEL, CurrentMachine.bReducedCut, New Vector3d(dStep, 0, 0))
|
|
EgtSaveCollInfo()
|
|
' se abilitato magnetico (allineamento + snap), lo provo
|
|
Dim bAlignMoved As Boolean = False
|
|
Dim bSnapMoved As Boolean = False
|
|
If m_bMagnetic Then
|
|
If Not GetLockOnRotation(GDB_ID.SEL) Then
|
|
EgtAlignPartOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, bAlignMoved)
|
|
End If
|
|
If m_dSnapDist > EPS_SMALL Then
|
|
EgtRestoreCollInfo()
|
|
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, m_dSnapDist, bSnapMoved)
|
|
End If
|
|
End If
|
|
EstCalc.ResetOrderMachiningFlag()
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' RightCommand
|
|
|
|
#Region "DownCommand"
|
|
|
|
Public ReadOnly Property DownCommand As ICommand
|
|
Get
|
|
If m_cmdDown Is Nothing Then
|
|
m_cmdDown = New Command(AddressOf Down)
|
|
End If
|
|
Return m_cmdDown
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Down(ByVal param As Object)
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' eseguo movimento
|
|
Dim dStep As Double = If(m_MaxMoveIsChecked, m_dMaxStep, m_dStepMove)
|
|
EgtMovePart(GDB_ID.SEL, CurrentMachine.bReducedCut, New Vector3d(0, -dStep, 0))
|
|
EgtSaveCollInfo()
|
|
' se abilitato magnetico (allineamento + snap), lo provo
|
|
Dim bAlignMoved As Boolean = False
|
|
Dim bSnapMoved As Boolean = False
|
|
If m_bMagnetic Then
|
|
If Not GetLockOnRotation(GDB_ID.SEL) Then
|
|
EgtAlignPartOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, bAlignMoved)
|
|
End If
|
|
If m_dSnapDist > EPS_SMALL Then
|
|
EgtRestoreCollInfo()
|
|
EgtMovePartToSnapPointOnCollision(GDB_ID.SEL, CurrentMachine.bReducedCut, m_dSnapDist, bSnapMoved)
|
|
End If
|
|
End If
|
|
EstCalc.ResetOrderMachiningFlag()
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' DownCommand
|
|
|
|
#Region "CClockwiseRotCommand"
|
|
|
|
Public ReadOnly Property CClockwiseRotCommand As ICommand
|
|
Get
|
|
If m_cmdCClockwiseRot Is Nothing Then
|
|
m_cmdCClockwiseRot = New Command(AddressOf CClockwiseRot)
|
|
End If
|
|
Return m_cmdCClockwiseRot
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub CClockwiseRot(ByVal param As Object)
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
RotateCluster(m_dRotationAngle)
|
|
EstCalc.ResetOrderMachiningFlag()
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' CClockwiseRotCommand
|
|
|
|
#Region "ClockwiseRotCommand"
|
|
|
|
Public ReadOnly Property ClockwiseRotCommand As ICommand
|
|
Get
|
|
If m_cmdClockwiseRot Is Nothing Then
|
|
m_cmdClockwiseRot = New Command(AddressOf ClockwiseRot)
|
|
End If
|
|
Return m_cmdClockwiseRot
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ClockwiseRot(ByVal param As Object)
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
RotateCluster(-m_dRotationAngle)
|
|
EstCalc.ResetOrderMachiningFlag()
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' ClockwiseRotCommand
|
|
|
|
#Region "InsertPartCommand"
|
|
|
|
Public ReadOnly Property InsertPartCommand As ICommand
|
|
Get
|
|
If m_cmdInsertPart Is Nothing Then
|
|
m_cmdInsertPart = New Command(AddressOf InsertPart)
|
|
End If
|
|
Return m_cmdInsertPart
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub InsertPart(ByVal param As Object)
|
|
' Se inserimento automatico
|
|
If CurrentMachine.bAutomatic And
|
|
OmagOFFICEMap.refMainWindowVM.MainWindowM.AutoNestOption() Then
|
|
AutomaticInsert()
|
|
' altrimenti inserimento standard
|
|
Else
|
|
StandardInsert()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' InsertPartCommand
|
|
|
|
#Region "StorePartCommand"
|
|
|
|
Public ReadOnly Property StorePartCommand As ICommand
|
|
Get
|
|
If m_cmdStorePart Is Nothing Then
|
|
m_cmdStorePart = New Command(AddressOf StorePart)
|
|
End If
|
|
Return m_cmdStorePart
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub StorePart(ByVal param As Object)
|
|
' creo la lista delle famiglie di pezzi presenti in parcheggio
|
|
GetFamilyGroupInPark()
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Ciclo di parcheggio dei pezzi selezionati
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
' Recupero indice del successivo
|
|
Dim nNextId As Integer = EgtGetNextSelectedObj()
|
|
' Metto in parcheggio, se in grezzo
|
|
EstCalc.StoreOnePart(nId)
|
|
' Eventuale notifica al VeinMatching
|
|
VeinMatching.OnRemovePartFromRaw(nId)
|
|
' 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
|
|
|
|
#End Region ' StorePartCommand
|
|
|
|
#Region "RemovePartCommand"
|
|
|
|
Public ReadOnly Property RemovePartCommand As ICommand
|
|
Get
|
|
If m_cmdRemovePart Is Nothing Then
|
|
m_cmdRemovePart = New Command(AddressOf RemovePart)
|
|
End If
|
|
Return m_cmdRemovePart
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub RemovePart()
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Se non ci sono pezzi selezionati, esco subito
|
|
If EgtGetFirstSelectedObj() = GDB_ID.NULL Then Return
|
|
' Chiedo conferma prima di procedere
|
|
If MessageBox.Show(EgtMsg(MSG_EGTMSGBOX + 21), "", MessageBoxButton.OKCancel, MessageBoxImage.Question) = MessageBoxResult.Cancel Then Return
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Verifico se ci sono pezzi provenienti da liste Csv
|
|
Dim bCsvParts As Boolean = False
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
If EgtExistsInfo(nId, INFO_CSV_PATH) Then
|
|
bCsvParts = True
|
|
Exit While
|
|
End If
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
' Chiedo se si vogliono cancellare anche questi pezzi
|
|
Dim bEraseCsvParts As Boolean = False
|
|
If bCsvParts Then
|
|
' Vuoi cancellare anche i pezzi da lista Csv ?
|
|
Select Case MessageBox.Show(EgtMsg(MSG_EGTMSGBOX + 12), "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question)
|
|
Case MessageBoxResult.Cancel
|
|
Return
|
|
Case MessageBoxResult.Yes
|
|
bEraseCsvParts = True
|
|
Case MessageBoxResult.No
|
|
bEraseCsvParts = False
|
|
End Select
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
End If
|
|
' Ciclo di cancellazione dei pezzi selezionati
|
|
nId = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
'' elimino eventuali ponticelli associati al pezzo: non è gestito il movimento del pezzo
|
|
'DeleteBridgeAssociated(nId)
|
|
' se è stato eseguito il Drag allora cancello tutti i ponticelli
|
|
ResetAllBridges()
|
|
' Recupero indice del successivo
|
|
Dim nNextId = EgtGetNextSelectedObj()
|
|
' Se abilitata cancellazione in ogni caso o pezzo non da Csv
|
|
If bEraseCsvParts OrElse Not EgtExistsInfo(nId, INFO_CSV_PATH) Then
|
|
' Se pezzo in parcheggio cancello direttamente
|
|
If EgtIsPart(nId) Then
|
|
'---------------------- COUNTER PART ----------------------
|
|
Dim sRefGroup As String = String.Empty
|
|
' recupero l'GUID del gruppo
|
|
EgtGetInfo(nId, INFO_REFGROUP, sRefGroup)
|
|
'---------------------- COUNTER PART ----------------------
|
|
' Eventuale notifica al VeinMatching
|
|
VeinMatching.OnRemovePart(nId, False)
|
|
' Rimuovo le lavorazioni
|
|
EraseMachinings(nId)
|
|
' Cancello
|
|
EgtErase(nId)
|
|
' aggiorno il layer che indica il numero di pezzi in parcheggio (se sRefGroup<>"")
|
|
CountPartInFamily(sRefGroup)
|
|
' Altrimenti pezzo nel grezzo
|
|
ElseIf EgtGetParent(nId) = EstCalc.GetRawId() Then
|
|
If EgtRemovePartFromRawPart(nId) Then
|
|
' Eventuale notifica al VeinMatching
|
|
VeinMatching.OnRemovePart(nId, False)
|
|
' Rimuovo le lavorazioni
|
|
EraseMachinings(nId)
|
|
'Cancello
|
|
EgtErase(nId)
|
|
End If
|
|
End If
|
|
End If
|
|
' Passo al successivo selezionato
|
|
nId = nNextId
|
|
End While
|
|
' Imposto flag posizione pezzi
|
|
m_nPartPos = PART_POS.NONE_TABLE
|
|
' Aggiorno viste
|
|
EgtZoom(ZM.ALL)
|
|
VeinMatching.Draw()
|
|
End Sub
|
|
|
|
Private Sub DeleteBridgeAssociated(nMyId As Integer)
|
|
' verifico se esistono dei ponticelli associati al pezzo indicato
|
|
' recuoero il gruppo di lavorazione corrente
|
|
Dim nIdCurrMachGroup As Integer = EgtGetCurrMachGroup()
|
|
' creo il gruppo per i ponticelli
|
|
Dim sNameGroup As String = NAME_BRIDGES
|
|
Dim nIdBridgesGroup As Integer = EgtGetFirstNameInGroup(nIdCurrMachGroup, sNameGroup)
|
|
If nIdBridgesGroup <> GDB_ID.NULL Then
|
|
' carico la prima entità del gruppo BRIDGES
|
|
Dim nIdBridgeLine As Integer = GDB_ID.NULL
|
|
nIdBridgeLine = EgtGetFirstNameInGroup(nIdBridgesGroup, NAME_BRIDGESLINE)
|
|
' ciclo su tutte le entità
|
|
While nIdBridgeLine <> GDB_ID.NULL
|
|
Dim nNextBridgeLine As Integer = GDB_ID.NULL
|
|
Dim nIdPart As Integer = GDB_ID.NULL
|
|
If EgtGetInfo(nIdBridgeLine, "PartStart", nIdPart) Then
|
|
If nIdPart = nMyId Then
|
|
nNextBridgeLine = EgtGetNext(nIdBridgeLine)
|
|
' il ponticello deve essere eliminato
|
|
EgtErase(nIdBridgeLine)
|
|
nIdBridgeLine = nNextBridgeLine
|
|
' riparto dall'inizio del ciclo
|
|
Continue While
|
|
End If
|
|
End If
|
|
If EgtGetInfo(nIdBridgeLine, "PartEnd", nIdPart) Then
|
|
If nIdPart = nMyId Then
|
|
nNextBridgeLine = EgtGetNext(nIdBridgeLine)
|
|
' il ponticello deve essere eliminato
|
|
EgtErase(nIdBridgeLine)
|
|
nIdBridgeLine = nNextBridgeLine
|
|
' riparto dall'inizio del ciclo
|
|
Continue While
|
|
End If
|
|
End If
|
|
' il BridgeLine corrente non contiene riferimeti al pezzo da eliminare
|
|
nIdBridgeLine = EgtGetNext(nIdBridgeLine)
|
|
End While
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' RemovePartCommand
|
|
|
|
#Region "SelectAllCommand"
|
|
|
|
Public ReadOnly Property SelectAllCommand As ICommand
|
|
Get
|
|
If m_cmdSelectAll Is Nothing Then
|
|
m_cmdSelectAll = New Command(AddressOf SelectAll)
|
|
End If
|
|
Return m_cmdSelectAll
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub SelectAll(ByVal param As Object)
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Numero dei pezzi in tavola
|
|
Dim nPartTab As Integer = EgtGetPartInRawPartCount(GetRawId())
|
|
' Se già selezionati in tavola o non ci sono selezionati e pezzi in tavola
|
|
If m_nPartPos = PART_POS.IN_TABLE Or
|
|
(m_nPartPos = PART_POS.NONE_TABLE And nPartTab > 0) Then
|
|
' Seleziono tutti i pezzi in tavola
|
|
Dim nPartId As Integer = EgtGetFirstGroupInGroup(GetRawId())
|
|
While nPartId <> GDB_ID.NULL
|
|
EgtSelectObj(nPartId)
|
|
VeinMatching.OnSelectPart(nPartId, False)
|
|
nPartId = EgtGetNextGroup(nPartId)
|
|
End While
|
|
' Aggiorno flag
|
|
m_nPartPos = If(EgtGetSelectedObjCount() > 0, PART_POS.IN_TABLE, PART_POS.NONE_TABLE)
|
|
' Altrimenti
|
|
Else
|
|
' Seleziono tutti i pezzi in parcheggio
|
|
Dim nPartId As Integer = EgtGetFirstPart()
|
|
While nPartId <> GDB_ID.NULL
|
|
If PartIsFree(nPartId) Then
|
|
EgtSelectObj(nPartId)
|
|
VeinMatching.OnSelectPart(nPartId, False)
|
|
End If
|
|
nPartId = EgtGetNextPart(nPartId)
|
|
End While
|
|
End If
|
|
' Aggiorno viste
|
|
EgtDraw()
|
|
VeinMatching.Draw()
|
|
End Sub
|
|
|
|
#End Region ' SelectAllCommand
|
|
|
|
#Region "DeselectAllCommand"
|
|
|
|
Public ReadOnly Property DeselectAllCommand As ICommand
|
|
Get
|
|
If m_cmdDeselectAll Is Nothing Then
|
|
m_cmdDeselectAll = New Command(AddressOf DeselectAll)
|
|
End If
|
|
Return m_cmdDeselectAll
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub DeselectAll(ByVal param As Object)
|
|
DeselectAllParts(True)
|
|
' Aggiorno vista
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' DeselectAllCommand
|
|
|
|
#Region "ResetCommand"
|
|
|
|
Public ReadOnly Property ResetCommand As ICommand
|
|
Get
|
|
If m_cmdReset Is Nothing Then
|
|
m_cmdReset = New Command(AddressOf Reset)
|
|
End If
|
|
Return m_cmdReset
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Reset(ByVal param As Object)
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Cancello eventuali messaggi
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
' cancello tutti i tagli di separazione
|
|
ResetAllSplitCurv()
|
|
' cancello tutti i punti di inizio (Waterjet)
|
|
ResetAllStartCurv()
|
|
' cancello tutti i ponticelli disegnati
|
|
ResetAllBridges()
|
|
' cancello tutti i tagli di separazione disegnati
|
|
ResetAllSplitCut()
|
|
' Cancello tutte le lavorazioni
|
|
CamAuto.EraseMachinings(GDB_ID.NULL)
|
|
' Reinserisco tutte le lavorazioni piane
|
|
CamAuto.AddMachinings(GDB_ID.NULL)
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' ResetCommand
|
|
|
|
#Region "CsvDataCommand"
|
|
|
|
Public ReadOnly Property CsvDataCommand As ICommand
|
|
Get
|
|
If m_cmdCsvData Is Nothing Then
|
|
m_cmdCsvData = New Command(AddressOf CsvData)
|
|
End If
|
|
Return m_cmdCsvData
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub CsvData(ByVal param As Object)
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Cancello eventuali messaggi
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
' Cerco il primo pezzo selezionato
|
|
Dim nPartId As Integer = EgtGetFirstSelectedObj()
|
|
If nPartId = GDB_ID.NULL Then Return
|
|
' Deseleziono eventuali altri
|
|
If EgtGetNextSelectedObj() <> GDB_ID.NULL Then
|
|
EgtDeselectAll()
|
|
EgtSelectObj(nPartId)
|
|
EgtDraw()
|
|
End If
|
|
' Recupero dati del pezzo
|
|
Dim sCsvOrder As String = "" : EgtGetInfo(nPartId, INFO_CSV_ORD, sCsvOrder)
|
|
Dim sCsvList As String = "" : EgtGetInfo(nPartId, INFO_CSV_DIST, sCsvList)
|
|
Dim sCsvName As String = "" : EgtGetInfo(nPartId, INFO_CSV_PART, sCsvName)
|
|
' Avvio dialogo modifica
|
|
Dim DlgCsvDataVM As New CompoCsvDataWindowVM()
|
|
Dim DlgCsvDataV As New CompoCsvDataWindowV(Application.Current.MainWindow, DlgCsvDataVM)
|
|
DlgCsvDataVM.SetData(sCsvOrder, sCsvList, sCsvName)
|
|
If DlgCsvDataV.ShowDialog() Then
|
|
' Recupero i nuovi dati
|
|
Dim sNewOrder As String = ""
|
|
Dim sNewList As String = ""
|
|
Dim sNewName As String = ""
|
|
DlgCsvDataVM.GetData(sNewOrder, sNewList, sNewName)
|
|
' Assegno i nuovi dati
|
|
EgtSetInfo(nPartId, INFO_CSV_ORD, sNewOrder)
|
|
EgtSetInfo(nPartId, INFO_CSV_DIST, sNewList)
|
|
EgtSetInfo(nPartId, INFO_CSV_PART, sNewName)
|
|
' Se necessario, modifico la scritta
|
|
If sNewName <> sCsvName Then
|
|
Dim nRegLayId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_REGION)
|
|
Dim nTextId = EgtGetFirstInGroup(nRegLayId)
|
|
While nTextId <> GDB_ID.NULL
|
|
If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then
|
|
Dim sText As String = String.Empty
|
|
EgtTextGetContent(nTextId, sText)
|
|
Dim nPos As Integer = sText.IndexOf(sCsvName)
|
|
Dim sNewText As String
|
|
If nPos < 0 Then
|
|
sNewText = sNewName & "<br/>" & sText
|
|
Else
|
|
sNewText = sText.Remove(nPos, sCsvName.Length()).Insert(nPos, sNewName)
|
|
End If
|
|
EgtModifyText(nTextId, sNewText)
|
|
VeinMatching.ModifyPartText(nPartId, sNewText)
|
|
Exit While
|
|
End If
|
|
nTextId = EgtGetNext(nTextId)
|
|
End While
|
|
End If
|
|
End If
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' CsvDataCommand
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
#Region "EVENTS"
|
|
|
|
Friend Sub OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs)
|
|
' se in modalità DragRectangle (deformazione delle componenti rettangolari)
|
|
If m_bDragRectangle Then
|
|
OnMyMouseDownSceneSelSideRectangle(sender, e)
|
|
' Dati per drag (abilito il Drag)
|
|
m_locPrev = e.Location
|
|
m_bDrag = EgtUnProjectPoint(e.Location, m_ptPrev) And m_nIdSelectedCurvRectangle <> 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
|
|
' se in modalità separazione curve WaterJet
|
|
If m_bSplitCurvWJ Then
|
|
OnMyMouseDownSceneSplitCurv(sender, e)
|
|
Return
|
|
End If
|
|
' se in modalità punto inizio curve WaterJet
|
|
If m_bStartCurvWJ Then
|
|
OnMyMouseDownSceneStartCurv(sender, e)
|
|
Return
|
|
End If
|
|
|
|
' Per default no drag
|
|
m_bDrag = False
|
|
' Verifico se selezionato indicativo di pezzo
|
|
EgtSetObjFilterForSelWin(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) = GetRawId())
|
|
If EgtIsPart(nPartId) Or bPartInTable Then
|
|
Dim nStat As Integer = GDB_ST.ON_
|
|
EgtGetStatus(nPartId, nStat)
|
|
|
|
' verifico se l'lemento selezionato è il numero di pezzi
|
|
If EgtGetType(nId) = GDB_TY.EXT_TEXT Then
|
|
Dim NameLayer As String = String.Empty
|
|
EgtGetName(EgtGetParent(nId), NameLayer)
|
|
If NameLayer = INFO_COUNTERLY Then
|
|
Dim sText As String = String.Empty
|
|
If EgtTextGetContent(nId, sText) Then
|
|
Dim sItems() As String = sText.Split("#"c)
|
|
If sItems.Count > 1 Then
|
|
m_nCurrNubrOfParts = 0
|
|
If StringToInt(sItems(1), m_nCurrNubrOfParts) Then
|
|
m_bIsCounterLy = True
|
|
m_nIdToSel = nPartId
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If Not m_bIsCounterLy Then
|
|
' Se già selezionato o posizione oggetto incompatibile con flag posizione selezionati
|
|
If nStat = GDB_ST.SEL Then
|
|
' Memorizzo Id da deselezionare
|
|
m_nIdToDesel = nPartId
|
|
Else
|
|
' Memorizzo Id da selezionare
|
|
m_nIdToSel = nPartId
|
|
End If
|
|
End If
|
|
' Drag possibile
|
|
m_bDrag = True
|
|
Exit While
|
|
End If
|
|
nId = EgtGetNextObjInSelWin()
|
|
End While
|
|
' Dati per drag
|
|
m_locPrev = e.Location
|
|
m_bDrag = m_bDrag AndAlso EgtUnProjectPoint(e.Location, m_ptPrev)
|
|
m_bDragToStart = m_bDrag
|
|
m_bVerify = m_bDrag AndAlso (Keyboard.Modifiers And ModifierKeys.Shift) > 0
|
|
m_bKeyLeftShiftPressed = m_bVerify
|
|
m_vtTotMove = Vector3d.NULL()
|
|
End Sub
|
|
|
|
Friend Sub OnMouseMoveScene(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
|
|
|
|
' se devo muovere un lato del rettangolo
|
|
If m_bDragRectangle Then
|
|
OnMyMouseMoveSawRectangle(sender, e)
|
|
Return
|
|
End If
|
|
|
|
' Determino cosa muovere
|
|
Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL)
|
|
' Verifico se in tavola o in parcheggio
|
|
Dim nTestId = If(nMoveId <> GDB_ID.SEL, nMoveId, EgtGetFirstSelectedObj())
|
|
If EgtGetParent(nTestId) <> GetRawId() Then
|
|
' Dal parcheggio ammesso drag di un singolo pezzo
|
|
If nMoveId = GDB_ID.SEL Then Return
|
|
' Se pezzo Trf, verifico compatibilità
|
|
If Not VerifyTrfData(nTestId) Then
|
|
' Pezzi con spessore, materiale o finitura non compatibili
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_NESTPAGEUC + 7), MSG_TYPE.WARNING)
|
|
End If
|
|
' Applico le lavorazioni al pezzo
|
|
Dim b3Curr As New BBox3d
|
|
EgtGetBBoxGlob(EgtGetFirstNameInGroup(nTestId, NAME_REGION), BBFLAG, b3Curr)
|
|
If Not EstCalc.PreInsertOnePart(nTestId) Then Return
|
|
Dim b3Ins As New BBox3d
|
|
EgtGetBBoxGlob(EgtGetFirstNameInGroup(nTestId, NAME_REGION), BBFLAG, b3Ins)
|
|
Dim vtDiff As New Vector3d(b3Curr.Min().x - b3Ins.Min().x, b3Curr.Min().y - b3Ins.Min().y, 0)
|
|
EgtMove(nMoveId, vtDiff)
|
|
|
|
'---------------------- COUNTER PART ----------------------
|
|
' aggiorno contatore pezzi
|
|
Dim sRefGroup As String = String.Empty
|
|
If EgtGetInfo(nMoveId, INFO_REFGROUP, sRefGroup) Then
|
|
' spengo il layer che contiene il contatore
|
|
Dim nCounterLayer As Integer = EgtGetFirstNameInGroup(nMoveId, INFO_COUNTERLY)
|
|
EgtSetStatus(nCounterLayer, GDB_ST.OFF)
|
|
' aggiorno il layer che indica il numero di pezzi in parcheggio
|
|
CountPartInFamily(sRefGroup)
|
|
End If
|
|
'---------------------- COUNTER PART ----------------------
|
|
|
|
' Gestione VeinMatching
|
|
VeinMatching.OnInsertPartInRaw(nMoveId)
|
|
' Imposto stato
|
|
m_bVerify = True
|
|
m_bFromParking = True
|
|
End If
|
|
' Inizio esecuzione di drag
|
|
m_bDragging = True
|
|
' Ricavo il punto corrente in coordinate mondo
|
|
Dim ptCurr As Point3d
|
|
EgtUnProjectPoint(e.Location, ptCurr)
|
|
|
|
' la rotazione è attivabile solo se premuto il tasto Ctrl (e non sono in parheggio)
|
|
m_bKeyCtrlPressed = m_bDrag AndAlso (Keyboard.Modifiers And ModifierKeys.Control) > 0
|
|
|
|
'-------------Inizio ROTAZIONE ----------------
|
|
If m_bKeyCtrlPressed AndAlso (Not m_bFromParking OrElse m_bKeyLeftShiftPressed) Then
|
|
' Calcolo il centro di rotazione come centro del cluster
|
|
Dim ptCen As Point3d
|
|
If Not EgtGetPartPartClusterCenterGlob(nMoveId, ptCen) Then Return
|
|
' definisco il vettore dal centro del pezzo alla posizione del cursore
|
|
Dim vtCurr As Vector3d = ptCurr - ptCen
|
|
Dim dLen, dHAng, dVAng As Double
|
|
' recupero l'angolo orizzontale del vettore
|
|
vtCurr.ToSpherical(dLen, dHAng, dVAng)
|
|
If Not m_bStartRot Then
|
|
m_dAngTotal = 0
|
|
' notifico una rotazione
|
|
m_bStartRot = True
|
|
m_dStartAng = dVAng
|
|
End If
|
|
Dim dDeltaAng As Double = dVAng - m_dStartAng
|
|
' gestione del passaggio da 0° → 360° evitando mantenendo la visualizzazione fluida
|
|
If Math.Abs(dDeltaAng) > 90 Then
|
|
If m_dStartAng < 180 And dVAng > 180 Then
|
|
dDeltaAng = dVAng - 360 - m_dStartAng
|
|
ElseIf m_dStartAng > 180 And dVAng < 180 Then
|
|
dDeltaAng = dVAng - m_dStartAng + 360
|
|
End If
|
|
End If
|
|
' Rotazione del pezzo attorno al suo centro
|
|
If Math.Abs(dDeltaAng) > EPS_ANG_SMALL Then
|
|
' se il tasto Shift è premuto (disabilitato il controllo collisioni durante il Drag)
|
|
If m_bKeyLeftShiftPressed Then
|
|
EgtRotate(nMoveId, ptCen, Vector3d.Z_AX(), dDeltaAng, GDB_RT.GLOB)
|
|
m_dAngTotal += dDeltaAng
|
|
Else
|
|
' esegue la rotazione fino ad incontrare un altro pezzo
|
|
RotatePartInsideBond(dDeltaAng, nMoveId)
|
|
EstCalc.ResetOrderMachiningFlag()
|
|
' Eventuale notifica al VeinMatching
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
End If
|
|
m_dStartAng = dVAng
|
|
End If
|
|
'-------------Fine ROTAZIONE ----------------
|
|
|
|
Else
|
|
' -------------Inizio TRASLAZIONE ---------------
|
|
' Ricavo il vettore di movimento
|
|
Dim vtMove As Vector3d = ptCurr - m_ptPrev
|
|
' Muovo i pezzi selezionati di quanto possibile
|
|
If vtMove.SqLen() > EPS_SMALL * EPS_SMALL Then
|
|
' notifico una traslazione
|
|
If Not m_bStartMove Then
|
|
m_bStartMove = True
|
|
End If
|
|
|
|
' Se movimento con sola verifica finale (disabilitato il controllo collisioni durante il Drag)
|
|
If m_bVerify Then
|
|
EgtMove(nMoveId, vtMove)
|
|
m_vtTotMove += vtMove
|
|
' altrimenti caso con verifica durante il movimento
|
|
Else
|
|
' Aggiorno regioni per nesting
|
|
UpdateNestRegions()
|
|
EnableReferenceRegion(False)
|
|
' muovo il pezzo
|
|
EgtMovePart(nMoveId, CurrentMachine.bReducedCut, vtMove)
|
|
EgtSaveCollInfo()
|
|
' se movimento risultante nullo, provo con movimento tangente
|
|
Dim bTgMoved As Boolean = False
|
|
If vtMove.IsSmall() Then
|
|
' riprovo con movimento tangente
|
|
Dim vtTgMove As Vector3d = ptCurr - m_ptPrev
|
|
EgtTgMovePartOnCollision(nMoveId, CurrentMachine.bReducedCut, vtTgMove)
|
|
bTgMoved = (Not vtTgMove.IsSmall())
|
|
End If
|
|
' se abilitato magnetico (allineamento + snap), lo provo
|
|
Dim bAlignMoved As Boolean = False
|
|
Dim bSnapMoved As Boolean = False
|
|
If m_bMagnetic Then
|
|
If Not GetLockOnRotation(nMoveId) Then
|
|
EgtAlignPartOnCollision(nMoveId, CurrentMachine.bReducedCut, bAlignMoved)
|
|
End If
|
|
If m_dSnapDist > EPS_SMALL Then
|
|
EgtRestoreCollInfo()
|
|
EgtMovePartToSnapPointOnCollision(nMoveId, CurrentMachine.bReducedCut, m_dSnapDist, bSnapMoved)
|
|
End If
|
|
End If
|
|
EstCalc.ResetOrderMachiningFlag()
|
|
End If
|
|
' -------------Fine TRASLAZIONE ---------------
|
|
End If
|
|
End If
|
|
|
|
EgtDraw()
|
|
' Eventuale notifica al VeinMatching
|
|
If m_bStartMove OrElse m_bStartRot Then
|
|
If nMoveId = GDB_ID.SEL Then
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
VeinMatching.OnMovePartInRaw(nId)
|
|
nId = EgtGetNextSelectedObj()
|
|
End While
|
|
Else
|
|
VeinMatching.OnMovePartInRaw(nMoveId)
|
|
End If
|
|
End If
|
|
' Aggiorno il punto precedente
|
|
m_ptPrev = ptCurr
|
|
' Terminata esecuzione di drag
|
|
m_bDragging = False
|
|
' se è stato eseguito il Drag allora cancello tutti i ponticelli
|
|
ResetAllBridges()
|
|
' non è gestito il movimento della lavorazione!
|
|
'DeleteBridgeAssociated(nMoveId)
|
|
End Sub
|
|
|
|
Friend Sub OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
|
|
If m_bDragRectangle Then
|
|
' deseleziono gli oggeti, resetto le variabili usate, aggiorno il disegno
|
|
ResetDragRectangleParam()
|
|
Return
|
|
End If
|
|
' verifico che sia attivo il comando di modifica tagli waterjet
|
|
If m_bSplitCurvWJ Then
|
|
' deseleziono gli oggeti, resetto le variabili usate, aggiorno il disegno
|
|
' ResetSplitCurvWJParam(False)
|
|
Return
|
|
End If
|
|
If m_bStartCurvWJ Then
|
|
' ResetStartCurvWJParam(False)
|
|
Return
|
|
End If
|
|
|
|
' Se eseguito drag
|
|
If Not m_bDragToStart Then
|
|
' Se movimento con sola verifica finale ----- TRASLAZIONE
|
|
If Not m_bStartRot And m_bStartMove Then
|
|
VerifyMove()
|
|
' Se movimento con sola verifica finale ----- TRASLAZIONE + ROTAZIONE
|
|
ElseIf m_bStartRot And m_bStartMove Then
|
|
If Not m_bFromParking Then
|
|
VerifyRot()
|
|
Else
|
|
' forzo il reset delle info di rotazione
|
|
m_dStartAng = 0
|
|
m_dAngTotal = 0
|
|
m_bStartRot = False
|
|
End If
|
|
VerifyMove()
|
|
' verifico se la posizione finale della rotazione è corretta ----- ROTAZIONE
|
|
ElseIf m_bStartRot And Not m_bStartMove Then
|
|
If m_bFromParking Then
|
|
VerifyMove()
|
|
' forzo il reset delle info di rotazione
|
|
m_dStartAng = 0
|
|
m_dAngTotal = 0
|
|
m_bStartRot = False
|
|
Else
|
|
VerifyRot()
|
|
End If
|
|
Else
|
|
' Basta reset alla fine
|
|
End If
|
|
|
|
' se è stato selezionato il layer del contatore mostro la finsetra
|
|
ElseIf m_bIsCounterLy Then
|
|
' devo csotruire la finestra per la selezione del numero di pezzi da muovere
|
|
' apro una finestra di dialogo per chiedere se inserire tutti i pezzi della famiglia
|
|
Dim sRefGroup As String = String.Empty
|
|
EgtGetInfo(m_nIdToSel, INFO_REFGROUP, sRefGroup)
|
|
Dim DataContextSlectWD As New MultiSelectionVM(m_nCurrNubrOfParts, sRefGroup)
|
|
Dim SelectWD As MultiSelectionV = New MultiSelectionV(Application.Current.MainWindow, DataContextSlectWD)
|
|
DataContextSlectWD.SetMultiSelectionV(SelectWD)
|
|
m_bIsCounterLy = False
|
|
|
|
' Se selezione da eseguire
|
|
ElseIf m_nIdToSel <> GDB_ID.NULL Then
|
|
' Determino se pezzo in tavola o in parcheggio
|
|
Dim bPartInTable As Boolean = (EgtGetParent(m_nIdToSel) = GetRawId())
|
|
' Se ci sono pezzi già selezionati nella posizione opposta, li deseleziono
|
|
If (bPartInTable And m_nPartPos = PART_POS.OUT_TABLE) Or
|
|
(Not bPartInTable And m_nPartPos = PART_POS.IN_TABLE) Then
|
|
EgtDeselectAll()
|
|
' Aggiornamento eventuale VeinMatching
|
|
VeinMatching.OnDeselectAll()
|
|
End If
|
|
' Eseguo la selezione
|
|
EgtSelectObj(m_nIdToSel)
|
|
' Eventuale aggiornamento VeinMatching
|
|
VeinMatching.OnSelectPart(m_nIdToSel)
|
|
' Set flag posizione selezionati
|
|
m_nPartPos = If(bPartInTable, PART_POS.IN_TABLE, PART_POS.OUT_TABLE)
|
|
' Se deselezione da eseguire
|
|
ElseIf m_nIdToDesel <> GDB_ID.NULL Then
|
|
EgtDeselectObj(m_nIdToDesel)
|
|
' Eventuale aggiornamento VeinMatching
|
|
VeinMatching.OnDeselectPart(m_nIdToDesel)
|
|
End If
|
|
' Reset
|
|
GetFamilyGroupInPark()
|
|
m_bDrag = False
|
|
m_nIdToSel = GDB_ID.NULL
|
|
m_nIdToDesel = GDB_ID.NULL
|
|
' Se nessun pezzo selezionato, reset flag posizione selezionati
|
|
If EgtGetSelectedObjCount() = 0 Then
|
|
m_nPartPos = PART_POS.NONE_TABLE
|
|
End If
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Friend Sub OnKeyDownScene(sender As Object, e As System.Windows.Forms.KeyEventArgs)
|
|
' Con CANC cancello i pezzi selezionati
|
|
If e.KeyData = System.Windows.Forms.Keys.Delete Then
|
|
RemovePart()
|
|
' Con INS eseguo inserimento dei pezzi selezionati in VeinMatching
|
|
ElseIf e.KeyData = System.Windows.Forms.Keys.Insert Then
|
|
' Vettore dei pezzi selezionati (l'inserimento di un pezzo in VM cancella la selezione)
|
|
Dim vSel As New List(Of Integer)
|
|
Dim nTmp As Integer = EgtGetFirstSelectedObj()
|
|
While nTmp <> GDB_ID.NULL
|
|
vSel.Add(nTmp)
|
|
nTmp = EgtGetNextSelectedObj()
|
|
End While
|
|
' Ciclo di inserimento in VM dei pezzi selezionati
|
|
For Each nId As Integer In vSel
|
|
' Se non è già inserito
|
|
If Not VeinMatching.IsPartIn(nId) Then
|
|
' Lo copio in VM
|
|
VeinMatching.SetRefOnPart(nId)
|
|
VeinMatching.AddPart(nId, True)
|
|
' Se pezzo in lastra (ovvero non è un pezzo standard in parcheggio)
|
|
If Not EgtIsPart(nId) Then
|
|
VeinMatching.OnInsertPartInRaw(nId, False)
|
|
End If
|
|
' Dichiaro progetto modificato
|
|
EgtSetModified()
|
|
End If
|
|
Next
|
|
' Ripristino lo stato di selezione
|
|
For Each nId As Integer In vSel
|
|
EgtSelectObj(nId)
|
|
VeinMatching.OnSelectPart(nId)
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' EVENTS
|
|
|
|
End Class
|
|
|
|
Class FamilyPart
|
|
|
|
Private PtMinStoraged As Point3d
|
|
Private PtMaxStoraged As Point3d
|
|
|
|
Private m_nHText As Integer = 40
|
|
Public ReadOnly Property nHText As Double
|
|
Get
|
|
Return m_nHText
|
|
End Get
|
|
End Property
|
|
|
|
Private m_sRefGuid As String = String.Empty
|
|
Public ReadOnly Property sRefGuid As String
|
|
Get
|
|
Return m_sRefGuid
|
|
End Get
|
|
End Property
|
|
|
|
Private m_nIdPart As Integer = -1
|
|
Public ReadOnly Property nIdPart As Integer
|
|
Get
|
|
Return m_nIdPart
|
|
End Get
|
|
End Property
|
|
|
|
Private m_IdCounterText As Integer
|
|
Public ReadOnly Property IdCounterText As Integer
|
|
Get
|
|
Return m_IdCounterText
|
|
End Get
|
|
End Property
|
|
|
|
Public Function PtStorage() As Point3d
|
|
EgtGetBBoxGlob(m_nIdPart, GDB_BB.STANDARD, PtMinStoraged, PtMaxStoraged)
|
|
Return PtMinStoraged
|
|
End Function
|
|
|
|
Sub New(Guid As String, IdPart As Integer)
|
|
m_sRefGuid = Guid
|
|
m_nIdPart = IdPart
|
|
End Sub
|
|
|
|
End Class |