d950fc1060
-> nuova definizione dei pezzi (classe Part) -> nuova gestione dei magazzini -> aggiunta pagina per la selezione dei pezzi manuali -> nuova configurazione delle variabili.
1172 lines
49 KiB
VB.net
1172 lines
49 KiB
VB.net
Imports System.IO
|
|
Imports System.Windows.Interop
|
|
Imports System.Runtime.InteropServices
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class VeinMatchingWindow
|
|
|
|
' Dichiarazione Scene
|
|
Friend WithEvents VeinMatchingScene As New Scene
|
|
Private VeinMatchingSceneHost As New System.Windows.Forms.Integration.WindowsFormsHost
|
|
' Gestione finestra
|
|
Private m_bFirst As Boolean = True
|
|
Private m_bPositioned As Boolean = False
|
|
' Selezione e modifica
|
|
Private m_nRestRadius As Integer = 3
|
|
Private m_dSnapDist As Double = 0
|
|
Private m_nIdToSel As Integer = GDB_ID.NULL
|
|
Private m_nIdToDesel As Integer = GDB_ID.NULL
|
|
Private m_bEnableEdit As Boolean = False
|
|
Private m_bVerify As Boolean = True
|
|
Private m_bCurrVerify As Boolean = True
|
|
Private m_bMagnetic As Boolean = False
|
|
Private m_bDrag As Boolean = False
|
|
Private m_bRotate As Boolean = False
|
|
Private m_bDragToStart As Boolean = False
|
|
Private m_bDragging As Boolean = False
|
|
Private m_locPrev As System.Drawing.Point
|
|
Private m_ptPrev As Point3d
|
|
Private m_ptCen As Point3d
|
|
|
|
Private Sub Window_Initialized(sender As Object, e As EventArgs)
|
|
' Assegnazione scena all'host e posizionamento nella PlacePageGrid
|
|
VeinMatchingSceneHost.Child = VeinMatchingScene
|
|
VeinMatchingSceneHost.SetValue(Grid.ColumnProperty, 1)
|
|
Me.VeinMatchingGrid.Children.Add(VeinMatchingSceneHost)
|
|
' Per non farla visualizzare alla creazione
|
|
Me.Left = 32000
|
|
' Assegno messaggi
|
|
ExportBtn.Content = EgtMsg(MSG_VEINMATCHING + 1) ' Esporta
|
|
ShowTextBtn.Content = EgtMsg(MSG_VEINMATCHING + 2) ' Mostra Info
|
|
EditBtn.Content = EgtMsg(MSG_VEINMATCHING + 3) ' Modifica
|
|
VerifyBtn.Content = EgtMsg(MSG_VEINMATCHING + 4) ' Verifica
|
|
MagneticBtn.Content = EgtMsg(MSG_VEINMATCHING + 5) ' Magnetico
|
|
End Sub
|
|
|
|
Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
' Inizializzazioni da eseguire appena prima della prima visualizzazione
|
|
If m_bFirst Then
|
|
' Imposto finestra senza SystemMenu
|
|
Dim hwnd As IntPtr = New WindowInteropHelper(Me).Handle
|
|
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) And Not WS_SYSMENU)
|
|
' imposto colore di default
|
|
Dim DefColor As New Color3d(0, 0, 0)
|
|
GetMainPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor)
|
|
VeinMatchingScene.SetDefaultMaterial(DefColor)
|
|
' imposto colori sfondo
|
|
Dim BackTopColor As New Color3d(211, 211, 211)
|
|
GetMainPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor)
|
|
Dim BackBotColor As New Color3d(211, 211, 211)
|
|
GetMainPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor)
|
|
VeinMatchingScene.SetViewBackground(BackTopColor, BackBotColor)
|
|
' imposto colore di evidenziazione
|
|
Dim MarkColor As New Color3d(255, 255, 0)
|
|
GetMainPrivateProfileColor(S_SCENE, K_MARK, MarkColor)
|
|
VeinMatchingScene.SetMarkMaterial(MarkColor)
|
|
' imposto colore per superfici selezionate
|
|
Dim SelSurfColor As New Color3d(255, 255, 192)
|
|
GetMainPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor)
|
|
VeinMatchingScene.SetSelSurfMaterial(SelSurfColor)
|
|
' imposto tipo e colore del rettangolo di zoom
|
|
Dim bOutline As Boolean = True
|
|
Dim ZwColor As New Color3d(0, 0, 0)
|
|
GetMainPrivateProfileZoomWin(S_SCENE, K_ZOOMWIN, bOutline, ZwColor)
|
|
VeinMatchingScene.SetZoomWinAttribs(bOutline, ZwColor)
|
|
' imposto colore della linea di distanza
|
|
Dim DstLnColor As New Color3d(255, 0, 0)
|
|
GetMainPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor)
|
|
VeinMatchingScene.SetDistLineMaterial(DstLnColor)
|
|
' imposto parametri OpenGL
|
|
Dim nDriver As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DRIVER, 3)
|
|
Dim b2Buff As Boolean = (GetMainPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1) <> 0)
|
|
Dim nColorBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_COLORBITS, 32)
|
|
Dim nDepthBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32)
|
|
VeinMatchingScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits)
|
|
' inizializzo la scena (DB geometrico + visualizzazione) e verifico presenza chiave
|
|
If Not VeinMatchingScene.Init() Then
|
|
Me.Close()
|
|
End If
|
|
' modo di visualizzazione
|
|
Dim nShowMode As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWMODE, SM.SHADING)
|
|
EgtSetShowMode(DirectCast(nShowMode, SM))
|
|
' visualizzazione avanzata dei triangoli costituenti le superfici
|
|
Dim bShowTriaAdv As Boolean = (GetMainPrivateProfileInt(S_SCENE, K_SHOWTRIAADV, 1) <> 0)
|
|
EgtSetShowTriaAdv(bShowTriaAdv)
|
|
' tipo visualizzazione per Zmap
|
|
Dim nShowZmap As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWZMAP, 1)
|
|
EgtSetShowZmap(DirectCast(nShowZmap, ZSM), False)
|
|
' dimensione lineare max in pixel delle textures
|
|
Dim nTxrMaxLinPix As Integer = GetMainPrivateProfileInt(S_SCENE, K_TEXMAXLINPIX, 4096)
|
|
EgtSetTextureMaxLinPixels(nTxrMaxLinPix)
|
|
' massimo movimento mouse considerato nullo
|
|
m_nRestRadius = GetMainPrivateProfileInt(S_NEST, K_RESTRADIUS, 3)
|
|
m_dSnapDist = GetMainPrivateProfileDouble(S_NEST, K_SNAPDIST, 50)
|
|
' imposto stato bottone ShowText
|
|
ShowTextBtn.IsChecked = VeinMatching.bShowText
|
|
' imposto stato bottoni Edit e Verify
|
|
EditBtn.IsChecked = m_bEnableEdit
|
|
VerifyBtn.IsEnabled = m_bEnableEdit
|
|
VerifyBtn.IsChecked = m_bVerify
|
|
MagneticBtn.IsEnabled = m_bEnableEdit And m_bVerify
|
|
MagneticBtn.IsChecked = m_bMagnetic
|
|
' dichiaro inizializzazioni eseguite
|
|
m_bFirst = False
|
|
End If
|
|
' inibisco selezione diretta da Scene
|
|
VeinMatchingScene.SetStatusNull()
|
|
End Sub
|
|
|
|
Private Sub Window_Closed(sender As Object, e As EventArgs) Handles Me.Closed
|
|
' Salvo posizione Window (se posizionata e non minimizzata)
|
|
If m_bPositioned And Me.WindowState <> WindowState.Minimized Then
|
|
Dim nFlag As Integer = If(Me.WindowState = WindowState.Maximized, 1, 0)
|
|
WriteMainPrivateProfileWinPos(S_VEINMATCHING, K_VEINMA_PLACE, nFlag, CInt(Me.Left), CInt(Me.Top), CInt(Me.Width), CInt(Me.Height))
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub AdjustPosition()
|
|
' Se già posizionata, esco subito
|
|
If m_bPositioned Then Return
|
|
' Imposto posizione e dimensioni della MainWindow da INI
|
|
Dim nFlag, nLeft, nTop, nWidth, nHeight As Integer
|
|
If GetMainPrivateProfileWinPos(S_VEINMATCHING, K_VEINMA_PLACE, nFlag, nLeft, nTop, nWidth, nHeight) Then
|
|
Dim PtTL = New System.Drawing.Point(nLeft, nTop)
|
|
Dim s As System.Windows.Forms.Screen = System.Windows.Forms.Screen.FromPoint(PtTL)
|
|
If s.Bounds.Contains(PtTL) Then
|
|
Me.WindowStartupLocation = Windows.WindowStartupLocation.Manual
|
|
Me.Top = nTop
|
|
Me.Left = nLeft
|
|
Me.Height = nHeight
|
|
Me.Width = nWidth
|
|
Me.WindowState = If(nFlag = 1, WindowState.Maximized, WindowState.Normal)
|
|
m_bPositioned = True
|
|
VeinMatching.ZoomAll()
|
|
Return
|
|
End If
|
|
End If
|
|
' Imposto in posizione standard
|
|
Me.WindowStartupLocation = Windows.WindowStartupLocation.Manual
|
|
Me.Top = Application.Current.MainWindow.Top
|
|
Me.Left = Application.Current.MainWindow.Left
|
|
Me.Height = nHeight
|
|
Me.Width = nWidth
|
|
Me.WindowState = If(nFlag = 1, WindowState.Maximized, WindowState.Normal)
|
|
m_bPositioned = True
|
|
VeinMatching.ZoomAll()
|
|
End Sub
|
|
|
|
Private Sub OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs) Handles VeinMatchingScene.OnMouseDownScene
|
|
' Per default no drag
|
|
m_bDrag = False
|
|
' Si può selezionare solo con il tasto sinistro e se stato NULL
|
|
If e.Button <> Windows.Forms.MouseButtons.Left Or Not VeinMatchingScene.IsStatusNull() Then Return
|
|
' Eseguo selezione
|
|
EgtSetObjFilterForSelWin(True, True, True, True, True)
|
|
Dim nSel As Integer
|
|
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
|
|
' Ricavo nome dell'entità selezionata e identificativo
|
|
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
|
While nId <> GDB_ID.NULL
|
|
' Cerco l'identificativo del pezzo cui appartiene
|
|
Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
|
|
If EgtIsPart(nPartId) Then
|
|
Dim nStat As Integer = GDB_ST.ON_
|
|
EgtGetStatus(nPartId, nStat)
|
|
' 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
|
|
If m_bEnableEdit Then m_bDrag = True
|
|
EgtDraw()
|
|
Exit While
|
|
End If
|
|
' Passo al successivo
|
|
nId = EgtGetNextObjInSelWin()
|
|
End While
|
|
' Se abilitata modifica, dati per drag
|
|
If m_bEnableEdit Then
|
|
m_locPrev = e.Location
|
|
m_bDrag = m_bDrag AndAlso EgtUnProjectPoint(e.Location, m_ptPrev)
|
|
m_bCurrVerify = m_bVerify And (Keyboard.Modifiers And ModifierKeys.Shift) = 0
|
|
m_bRotate = m_bDrag AndAlso (Keyboard.Modifiers And ModifierKeys.Control) > 0
|
|
m_bDragToStart = m_bDrag
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles VeinMatchingScene.OnMouseMoveScene
|
|
' Se drag non abilitato o già in esecuzione, esco
|
|
If Not m_bDrag Or m_bDragging Then Return
|
|
' Determino cosa muovere
|
|
Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL)
|
|
' 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
|
|
If m_bRotate Then
|
|
If Not EgtGetPartPartClusterCenterGlob(nMoveId, m_ptCen) Then Return
|
|
End If
|
|
m_bDragToStart = False
|
|
End If
|
|
' Inizio esecuzione di drag
|
|
m_bDragging = True
|
|
' Ricavo il punto corrente in coordinate mondo
|
|
Dim ptCurr As Point3d
|
|
EgtUnProjectPoint(e.Location, ptCurr)
|
|
' Se traslazione
|
|
If Not m_bRotate Then
|
|
' Ricavo il vettore di movimento
|
|
Dim vtMove As Vector3d = ptCurr - m_ptPrev
|
|
' Eseguo il movimento
|
|
If vtMove.SqLen() > EPS_SMALL * EPS_SMALL Then
|
|
' Con verifica di collisione
|
|
If m_bCurrVerify Then
|
|
EgtMovePart(nMoveId, True, 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, True, 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
|
|
EgtAlignPartOnCollision(nMoveId, True, bAlignMoved)
|
|
If m_dSnapDist > EPS_SMALL Then
|
|
EgtRestoreCollInfo()
|
|
' !!! Questa funzione usa i tagli, bisogna modificarla per farla funzionare in questo caso !!!
|
|
EgtMovePartToSnapPointOnCollision(nMoveId, True, m_dSnapDist, bSnapMoved)
|
|
End If
|
|
End If
|
|
' Standard
|
|
Else
|
|
EgtMove(nMoveId, vtMove)
|
|
End If
|
|
VeinMatching.SetProjectModified()
|
|
EgtDraw()
|
|
End If
|
|
' altrimenti rotazione
|
|
Else
|
|
' Ricavo l'angolo di movimento
|
|
Dim vtPrev As Vector3d = m_ptPrev - m_ptCen
|
|
Dim vtCurr As Vector3d = ptCurr - m_ptCen
|
|
Dim dAngRotDeg As Double = Math.Atan2(Vector3d.CrossXY(vtPrev, vtCurr), Vector3d.ScalarXY(vtPrev, vtCurr)) * 180.0 / Math.PI
|
|
If Math.Abs(dAngRotDeg) > EPS_ANG_SMALL Then
|
|
' Con verifica di collisione
|
|
If m_bCurrVerify Then
|
|
EgtRotatePart(nMoveId, True, m_ptCen, dAngRotDeg)
|
|
' Standard
|
|
Else
|
|
EgtRotate(nMoveId, m_ptCen, Vector3d.Z_AX(), dAngRotDeg, GDB_RT.GLOB)
|
|
End If
|
|
VeinMatching.SetProjectModified()
|
|
EgtDraw()
|
|
End If
|
|
End If
|
|
' Aggiorno il punto precedente
|
|
m_ptPrev = ptCurr
|
|
' Terminata esecuzione di drag
|
|
m_bDragging = False
|
|
End Sub
|
|
|
|
Private Sub OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles VeinMatchingScene.OnMouseUpScene
|
|
' Se abilitata modifica
|
|
If m_bEnableEdit Then
|
|
' Se eseguito drag
|
|
If Not m_bDragToStart Then
|
|
' Non serve fare alcunché
|
|
' Se selezione da eseguire
|
|
ElseIf m_nIdToSel <> GDB_ID.NULL Then
|
|
' Eseguo la selezione
|
|
EgtSelectObj(m_nIdToSel)
|
|
' Se deselezione da eseguire
|
|
ElseIf m_nIdToDesel <> GDB_ID.NULL Then
|
|
EgtDeselectObj(m_nIdToDesel)
|
|
End If
|
|
' Altrimenti selezione/deselezione anche per nesting
|
|
Else
|
|
' Se selezione da eseguire
|
|
If m_nIdToSel <> GDB_ID.NULL Then
|
|
' Eseguo la selezione in Nesting
|
|
Dim bSelected As Boolean = False
|
|
Dim nOriId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(m_nIdToSel, KEY_ORI_ID, nOriId)
|
|
If EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx()) AndAlso EgtExistsObj(nOriId) Then
|
|
Dim nMachGrpId As Integer
|
|
If (OmagOFFICEMap.refNestingTabVM.SelectPart(nOriId, False, nMachGrpId)) Then
|
|
bSelected = True
|
|
Else
|
|
If nMachGrpId = GDB_ID.NULL Then
|
|
' "Attenzione" "Pezzo non selezionabile in questa condizione"
|
|
MessageBox.Show(Me, EgtMsg(91606), EgtMsg(91122), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
Else
|
|
Dim sMachGrpName As String = String.Empty
|
|
EgtGetMachGroupName(nMachGrpId, sMachGrpName)
|
|
' "Attenzione" "Pezzo non selezionabile perchè appartenente a gruppo di lavoro non corrente :" ...
|
|
MessageBox.Show(Me, EgtMsg(91607) & " " & sMachGrpName, EgtMsg(91122), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
End If
|
|
End If
|
|
End If
|
|
EgtSetCurrentContext(VeinMatchingScene.GetCtx())
|
|
' Se selezione riuscita, la eseguo anche in VME
|
|
If bSelected Then EgtSelectObj(m_nIdToSel)
|
|
' Se deselezione da eseguire
|
|
ElseIf m_nIdToDesel <> GDB_ID.NULL Then
|
|
' Eseguo la deselezione in Nesting
|
|
Dim bDeselected As Boolean = False
|
|
Dim nOriId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(m_nIdToDesel, KEY_ORI_ID, nOriId)
|
|
If EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx()) AndAlso EgtExistsObj(nOriId) Then
|
|
If (OmagOFFICEMap.refNestingTabVM.DeselectPart(nOriId, False)) Then
|
|
bDeselected = True
|
|
End If
|
|
End If
|
|
EgtSetCurrentContext(VeinMatchingScene.GetCtx())
|
|
' Se deselezione riuscita, la eseguo anche in VME
|
|
If bDeselected Then EgtDeselectObj(m_nIdToDesel)
|
|
End If
|
|
End If
|
|
' Reset
|
|
m_bDrag = False
|
|
m_nIdToSel = GDB_ID.NULL
|
|
m_nIdToDesel = GDB_ID.NULL
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub ShowTextBtn_Click(sender As Object, e As RoutedEventArgs) Handles ShowTextBtn.Click
|
|
VeinMatching.SetShowText(If(ShowTextBtn.IsChecked, False))
|
|
End Sub
|
|
|
|
Private Sub EditBtn_Click(sender As Object, e As RoutedEventArgs) Handles EditBtn.Click
|
|
' Impostazione stato di modifica
|
|
m_bEnableEdit = If(EditBtn.IsChecked, False)
|
|
If Not m_bEnableEdit Then
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
End If
|
|
VerifyBtn.IsEnabled = m_bEnableEdit
|
|
MagneticBtn.IsEnabled = m_bEnableEdit And m_bVerify
|
|
End Sub
|
|
|
|
Private Sub VerifyBtn_Click(sender As Object, e As RoutedEventArgs) Handles VerifyBtn.Click
|
|
m_bVerify = If(VerifyBtn.IsChecked, False)
|
|
MagneticBtn.IsEnabled = m_bEnableEdit And m_bVerify
|
|
End Sub
|
|
|
|
Private Sub MagneticBtn_Click(sender As Object, e As RoutedEventArgs) Handles MagneticBtn.Click
|
|
m_bMagnetic = If(MagneticBtn.IsChecked, False)
|
|
End Sub
|
|
|
|
Private Sub ExportBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExportBtn.Click
|
|
Dim SaveFileDialog As New Microsoft.Win32.SaveFileDialog
|
|
SaveFileDialog.Title = "Export"
|
|
SaveFileDialog.Filter = "Images Png (*.png)|*.png" &
|
|
"|Images Jpeg (*.jpg;*.jpeg)|*.jpg;*.jpeg" &
|
|
"|Images Bitmap (*.bmp)|*.bmp"
|
|
SaveFileDialog.FilterIndex = 2
|
|
If Not SaveFileDialog.ShowDialog Then Return
|
|
VeinMatching.Export(SaveFileDialog.FileName)
|
|
End Sub
|
|
|
|
Private Sub Scene_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles VeinMatchingScene.KeyDown
|
|
' Con DEL eseguo cancellazione dei pezzi selezionati
|
|
If e.KeyData = System.Windows.Forms.Keys.Delete Then
|
|
' Se non ci sono oggetti selezionati, esco
|
|
If Not VeinMatching.SelectedObjects() Then Return
|
|
' Sei sicuro di voler cancellare i pezzi selezionati ?
|
|
If MessageBox.Show(EgtMsg(MSG_EGTMSGBOX + 21), "", MessageBoxButton.OKCancel, MessageBoxImage.Question) = MessageBoxResult.Cancel Then Return
|
|
VeinMatching.RemoveAllSelectedParts()
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Friend Module VeinMatching
|
|
|
|
' Contesto del VeinMatching
|
|
Friend m_nVeinCtx As Integer = 0
|
|
' Nome fotografia
|
|
Private m_nPhoto As Integer = 0
|
|
' Dimensioni immagine da esportare
|
|
Private m_nImgWidth As Integer = 1600
|
|
Private m_nImgHeight As Integer = 1200
|
|
' Flag visualizzazione testi
|
|
Private m_bShowText As Boolean = True
|
|
Friend ReadOnly Property bShowText As Boolean
|
|
Get
|
|
Return m_bShowText
|
|
End Get
|
|
End Property
|
|
|
|
' Costanti
|
|
Const REF_NAME As String = "Ref"
|
|
Const KEY_ORI_REF As String = "OriRef"
|
|
Const DIM_REG As Double = 20000
|
|
Const WIDTH_ADD_REG As Double = 4000
|
|
|
|
Friend Function SetExportImageDim(nImgWidth As Integer, nImgHeight As Integer) As Boolean
|
|
m_nImgWidth = nImgWidth
|
|
m_nImgHeight = nImgHeight
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function SetRefOnAllParts() As Boolean
|
|
' Si opera nel contesto corrente
|
|
Dim nId As Integer = EgtGetFirstPart()
|
|
While nId <> GDB_ID.NULL
|
|
' Gruppo regione
|
|
Dim nRegLayId As Integer = EgtGetFirstNameInGroup(nId, NAME_REGION)
|
|
' Entità superficie regione piatta
|
|
Dim nRegId As Integer = EgtGetFirstInGroup(nRegLayId)
|
|
While nRegId <> GDB_ID.NULL
|
|
If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then
|
|
Exit While
|
|
End If
|
|
nRegId = EgtGetNext(nRegId)
|
|
End While
|
|
' Ne recupero il centroide
|
|
Dim ptCen As Point3d
|
|
EgtCentroid(nRegId, GDB_ID.ROOT, ptCen)
|
|
' Inserisco il riferimento
|
|
Dim frRef As New Frame3d(ptCen)
|
|
Dim nRefId As Integer = EgtCreateGeoFrame(nRegLayId, frRef, GDB_RT.GLOB)
|
|
EgtSetName(nRefId, REF_NAME)
|
|
' salvo nelle info il riferimento originale
|
|
EgtSetInfo(nRefId, KEY_ORI_REF, frRef)
|
|
' nascondo l'oggetto appena inserito
|
|
EgtSetMode(nRefId, GDB_MD.HIDDEN)
|
|
' Passo al pezzo successivo
|
|
nId = EgtGetNextPart(nId)
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function SetRefOnPart(nId As Integer) As Boolean
|
|
' Si opera nel contesto corrente
|
|
' Verifico validità identificativo oggetto
|
|
If nId = GDB_ID.NULL Then Return False
|
|
' Recupero gruppo regione
|
|
Dim nRegLayId As Integer = EgtGetFirstNameInGroup(nId, NAME_REGION)
|
|
' Se c'è già il riferimento, esco
|
|
If EgtGetFirstNameInGroup(nRegLayId, REF_NAME) <> GDB_ID.NULL Then Return True
|
|
' Entità superficie regione piatta
|
|
Dim nRegId As Integer = EgtGetFirstInGroup(nRegLayId)
|
|
While nRegId <> GDB_ID.NULL
|
|
If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then
|
|
Exit While
|
|
End If
|
|
nRegId = EgtGetNext(nRegId)
|
|
End While
|
|
' Ne recupero il centroide
|
|
Dim ptCen As Point3d
|
|
EgtCentroid(nRegId, GDB_ID.ROOT, ptCen)
|
|
' Inserisco il riferimento
|
|
Dim frRef As New Frame3d(ptCen)
|
|
Dim nRefId As Integer = EgtCreateGeoFrame(nRegLayId, frRef, GDB_RT.GLOB)
|
|
EgtSetName(nRefId, REF_NAME)
|
|
' salvo nelle info il riferimento originale
|
|
EgtSetInfo(nRefId, KEY_ORI_REF, frRef)
|
|
' nascondo l'oggetto appena inserito
|
|
EgtSetMode(nRefId, GDB_MD.HIDDEN)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function AddPart(nPartId As Integer, Optional bPack As Boolean = False) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Se esiste già il pezzo nel VM, esco
|
|
If GetVeinPartId(nPartId) <> GDB_ID.NULL Then Return True
|
|
' Verifico validità pezzo
|
|
If nPartId = GDB_ID.NULL Then Return False
|
|
' Salvo il pezzo su file temporaneo
|
|
Dim sTmpDir As String = String.Empty
|
|
If Not EgtGetTempDir(sTmpDir) Then Return False
|
|
Dim sTmpFile As String = sTmpDir & "\FlatPartVme.Nge"
|
|
EgtSaveObjToFile(nPartId, sTmpFile, NGE.BIN)
|
|
ShowParkedParts()
|
|
' Carico il file nel VM
|
|
Dim bOk As Boolean = My.Computer.FileSystem.FileExists(sTmpFile)
|
|
If bOk Then
|
|
bOk = AddPart(sTmpFile, nPartId, bPack)
|
|
' Ne aggiorno la visualizzazione
|
|
ZoomAll()
|
|
' Cancello il file
|
|
My.Computer.FileSystem.DeleteFile(sTmpFile)
|
|
End If
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function AddPart(sPartFile As String, nPartId As Integer, Optional bPack As Boolean = False) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Se esiste già il pezzo nel VM, esco
|
|
If GetVeinPartId(nPartId) <> GDB_ID.NULL Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nMainCtx = SetVeinContext()
|
|
If nMainCtx = 0 Then Return False
|
|
' Inserisco il pezzo
|
|
EgtInsertFile(sPartFile)
|
|
' Ne recupero l'Id
|
|
Dim nVeinId2 As Integer = EgtGetLastPart()
|
|
' Elimino eventuali preview delle lavorazioni
|
|
EgtErase(EgtGetFirstNameInGroup(nVeinId2, NAME_PREVIEW))
|
|
' Assegno Id originale
|
|
EgtSetInfo(nVeinId2, KEY_ORI_ID, nPartId)
|
|
' Se impostato, nascondo scritte, sono nel layer "Region"
|
|
If Not m_bShowText Then
|
|
Dim nVeinRegId As Integer = EgtGetFirstNameInGroup(nVeinId2, NAME_REGION)
|
|
Dim nCurrId As Integer = EgtGetFirstInGroup(nVeinRegId)
|
|
While nCurrId <> GDB_ID.NULL
|
|
If EgtGetType(nCurrId) = GDB_TY.EXT_TEXT Then EgtSetStatus(nCurrId, GDB_ST.OFF)
|
|
nCurrId = EgtGetNext(nCurrId)
|
|
End While
|
|
End If
|
|
' Nascondo layer con valori angoli dei lati
|
|
Dim nLayAngId As Integer = EgtGetFirstNameInGroup(nVeinId2, SIDE_ANGLE_LAYER)
|
|
EgtSetStatus(nLayAngId, GDB_ST.OFF)
|
|
' Se richiesto, eseguo pack
|
|
If bPack Then EgtPackBox(nVeinId2, 0, 0, WIDTH_ADD_REG, DIM_REG, 0, True)
|
|
' Se necessario, ripristino il contesto originale
|
|
If nMainCtx > 0 Then EgtSetCurrentContext(nMainCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function AddParts(sPartFile As String, nFirstPartId As Integer, Optional bPack As Boolean = False) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nMainCtx = SetVeinContext()
|
|
If nMainCtx = 0 Then Return False
|
|
' Inserisco i pezzi e recupero Id primo pezzo inserito
|
|
Dim nFirstVeinId As Integer = EgtGetLastPart()
|
|
EgtInsertFile(sPartFile)
|
|
nFirstVeinId = If(nFirstVeinId <> GDB_ID.NULL, EgtGetNextPart(nFirstVeinId), EgtGetFirstPart())
|
|
' Ciclo sui pezzi inseriti
|
|
Dim nVeinId As Integer = nFirstVeinId
|
|
While nVeinId <> GDB_ID.NULL
|
|
' Calcolo Id originale
|
|
Dim nOrigId As Integer = nFirstPartId + nVeinId - nFirstVeinId
|
|
' Se già presente un pezzo con questo Id originale, elimino nuovo pezzo e vado al successivo
|
|
If GetVeinPartId(nOrigId) <> GDB_ID.NULL Then
|
|
Dim nToEraseId As Integer = nVeinId
|
|
nVeinId = EgtGetNextPart(nVeinId)
|
|
EgtErase(nToEraseId)
|
|
Continue While
|
|
End If
|
|
' Assegno Id originale
|
|
EgtSetInfo(nVeinId, KEY_ORI_ID, nOrigId)
|
|
' Nascondo scritte, sono nel layer "Region"
|
|
Dim nVeinRegId As Integer = EgtGetFirstNameInGroup(nVeinId, NAME_REGION)
|
|
Dim nCurrId As Integer = EgtGetFirstInGroup(nVeinRegId)
|
|
While nCurrId <> GDB_ID.NULL
|
|
If EgtGetType(nCurrId) = GDB_TY.EXT_TEXT Then EgtSetStatus(nCurrId, GDB_ST.OFF)
|
|
nCurrId = EgtGetNext(nCurrId)
|
|
End While
|
|
' Nascondo layer con valori angoli dei lati
|
|
nCurrId = EgtGetFirstNameInGroup(nVeinId, SIDE_ANGLE_LAYER)
|
|
EgtSetStatus(nCurrId, GDB_ST.OFF)
|
|
' Se richiesto, eseguo pack
|
|
If bPack Then EgtPackBox(nVeinId, 0, 0, WIDTH_ADD_REG, DIM_REG, 0, True)
|
|
' Passo al pezzo successivo
|
|
nVeinId = EgtGetNextPart(nVeinId)
|
|
End While
|
|
' Se necessario, ripristino il contesto originale
|
|
If nMainCtx > 0 Then EgtSetCurrentContext(nMainCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function OnInsertPartInRaw(nPartId As Integer, Optional bDeselect As Boolean = True) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Se non c'è la fotografia, esco
|
|
Dim nPhotoId As Integer = EstPhoto.GetPhoto()
|
|
If nPhotoId = GDB_ID.NULL Then Return If(bDeselect, OnDeselectPart(nPartId), True)
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Recupero la path originale della foto
|
|
Dim sPhoto As String = String.Empty
|
|
EgtGetPhotoPath(nPhotoId, sPhoto)
|
|
' Verifico se esiste già questa foto nel VeinMatching
|
|
Dim sVeinPhoto As String = String.Empty
|
|
Dim nInd As Integer = 1
|
|
While nInd <= m_nPhoto
|
|
If GetVeinPhotoPath(nInd, sVeinPhoto) AndAlso
|
|
String.Compare(sPhoto, sVeinPhoto, True) = 0 Then
|
|
Exit While
|
|
End If
|
|
nInd += 1
|
|
End While
|
|
' Se necessario, copio la foto
|
|
If nInd > m_nPhoto Then
|
|
If Not CopyPhoto(nPhotoId) Then Return False
|
|
nInd = m_nPhoto
|
|
End If
|
|
' Recupero il pezzo nel VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId = GetVeinPartId(nOriId)
|
|
If nId <> GDB_ID.NULL Then
|
|
' Recupero la regione del pezzo
|
|
Dim nRegId As Integer = GetVeinPartRegionId(nId)
|
|
' Gli assegno la texture della foto
|
|
EgtSetTextureName(nRegId, GetVeinPhotoName(nInd))
|
|
' Sistemo il riferimento della texture
|
|
Dim refTxr As New Frame3d
|
|
GetVeinRefPhoto(nMainCtx, nPartId, nId, refTxr)
|
|
EgtSetTextureFrame(nRegId, refTxr, GDB_RT.GLOB)
|
|
' Sistemo il colore
|
|
Dim colWhite As New Color3d(255, 255, 255, 100)
|
|
EgtSetColor(nRegId, colWhite)
|
|
' Se richiesto, eseguo deselezione
|
|
If bDeselect Then EgtDeselectObj(nId)
|
|
End If
|
|
EgtDraw()
|
|
EgtSetCurrentContext(nMainCtx)
|
|
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function OnMovePartInRaw(nPartId As Integer) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Se non c'è la fotografia, esco
|
|
Dim nPhotoId As Integer = EstPhoto.GetPhoto()
|
|
If nPhotoId = GDB_ID.NULL Then Return True
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Recupero il pezzo nel VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId = GetVeinPartId(nOriId)
|
|
If nId <> GDB_ID.NULL Then
|
|
' Recupero la regione del pezzo
|
|
Dim nRegId As Integer = GetVeinPartRegionId(nId)
|
|
' Sistemo il riferimento della texture
|
|
Dim refTxr As New Frame3d
|
|
GetVeinRefPhoto(nMainCtx, nPartId, nId, refTxr)
|
|
EgtSetTextureFrame(nRegId, refTxr, GDB_RT.GLOB)
|
|
EgtDraw()
|
|
End If
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function OnRemovePartFromRaw(nPartId As Integer, Optional bDeselect As Boolean = True) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Se non c'è la fotografia, esco
|
|
Dim nPhotoId As Integer = EstPhoto.GetPhoto()
|
|
If nPhotoId = GDB_ID.NULL Then Return If(bDeselect, OnDeselectPart(nPartId), True)
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Tolgo la texture dal pezzo
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId As Integer = GetVeinPartId(nOriId)
|
|
If nId <> GDB_ID.NULL Then
|
|
' Recupero la regione del pezzo
|
|
Dim nRegId As Integer = GetVeinPartRegionId(nId)
|
|
' Gli tolgo la texture
|
|
EgtRemoveTextureData(nRegId)
|
|
' Sistemo il colore
|
|
Dim colAqua As New Color3d(0, 255, 255, 25)
|
|
EgtSetColor(nRegId, colAqua)
|
|
' Se richiesto, eseguo deselezione
|
|
If bDeselect Then EgtDeselectObj(nId)
|
|
EgtDraw()
|
|
End If
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function OnRemovePart(nPartId As Integer, Optional bDraw As Boolean = True) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Recupero il pezzo nel VeinMatching e lo cancello
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId = GetVeinPartId(nOriId)
|
|
If nId <> GDB_ID.NULL Then
|
|
EgtErase(nId)
|
|
If bDraw Then EgtDraw()
|
|
End If
|
|
' Ritorno al contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function OnSelectPart(nPartId As Integer, Optional bDraw As Boolean = True) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Recupero il pezzo nel VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId = GetVeinPartId(nOriId)
|
|
Dim bFound As Boolean = nId <> GDB_ID.NULL
|
|
' Lo seleziono e aggiorno visualizzazione
|
|
If bFound Then
|
|
EgtSelectObj(nId)
|
|
If bDraw Then EgtDraw()
|
|
End If
|
|
' Ritorno al contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return bFound
|
|
End Function
|
|
|
|
Friend Function OnDeselectPart(nPartId As Integer) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Recupero il pezzo nel VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId = GetVeinPartId(nOriId)
|
|
Dim bFound As Boolean = nId <> GDB_ID.NULL
|
|
' Lo seleziono
|
|
If bFound Then EgtDeselectObj(nId)
|
|
' Aggiorno visualizzazione e ritorno al contesto originale
|
|
EgtDraw()
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return bFound
|
|
End Function
|
|
|
|
Friend Function OnSelectAll() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Eseguo selezione di tutti i pezzi
|
|
EgtSelectAll()
|
|
EgtDraw()
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function OnDeselectAll() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Eseguo deselezione di tutti i pezzi
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function SelectedObjects() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return False
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
Dim bFound As Boolean = (EgtGetFirstSelectedObj() <> GDB_ID.NULL)
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return bFound
|
|
End Function
|
|
|
|
Friend Function RemoveAllSelectedParts() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Eseguo la cancellazione di tutti i pezzi selezionati
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
Dim nNextId As Integer = EgtGetNextSelectedObj()
|
|
EgtErase(nId)
|
|
nId = nNextId
|
|
End While
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function Draw() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Eseguo Zoom
|
|
EgtDraw()
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function ZoomAll() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Eseguo Zoom
|
|
EgtZoom(ZM.ALL)
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function Clear() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Pulisco il DB
|
|
EgtNewFile()
|
|
EgtDraw()
|
|
' Reset contatore foto
|
|
m_nPhoto = 0
|
|
' creo regione valida per i pezzi
|
|
EgtCreateOutRegionRectangle(GDB_ID.ROOT, -DIM_REG, -DIM_REG, DIM_REG, DIM_REG, 0)
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function Open(sFilePath As String) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Apro il file
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim bOk As Boolean = EgtOpenFile(sFilePath)
|
|
' Aggiorno contatore foto
|
|
Dim nPhId As Integer = EgtGetFirstInGroup(EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP))
|
|
While nPhId <> GDB_ID.NULL
|
|
Dim sName As String = String.Empty
|
|
EgtGetName(nPhId, sName)
|
|
Dim nVal As Integer = 0
|
|
If StringToInt(sName.Replace(PHOTO_NAME, ""), nVal) Then m_nPhoto = Math.Max(m_nPhoto, nVal)
|
|
nPhId = EgtGetNext(nPhId)
|
|
End While
|
|
' Se non presente, aggiungo regione valida per i pezzi
|
|
EgtCreateOutRegionRectangle(GDB_ID.ROOT, -DIM_REG, -DIM_REG, DIM_REG, DIM_REG, 0)
|
|
' Aggiorno visualizzazione testi
|
|
UpdateShowText(False)
|
|
' Eseguo zoom all
|
|
EgtZoom(ZM.ALL)
|
|
' Ripristino il contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function Save(sFilePath As String) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx As Integer = EgtGetCurrentContext()
|
|
' Elimino foto inutilizzate
|
|
RemoveUnusedPhotos()
|
|
' Salvo il file
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim bOk As Boolean = EgtSaveFile(sFilePath, NGE.CMPTEXT)
|
|
' Ripristino il contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function Export(sFilePath As String) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Esporto il file come immagine
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim bOk As Boolean = (EgtGetFileType(sFilePath) = FT.IMG)
|
|
bOk = bOk AndAlso EgtGetImage(EgtGetShowMode(), New Color3d(255, 255, 255), New Color3d(255, 255, 255),
|
|
m_nImgWidth, m_nImgHeight, sFilePath)
|
|
' Ripristino il contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function ChangePhotoPath(sOldPath As String, sNewPath As String) As Boolean
|
|
' Cerco nel VeinMatching una foto con la path originale
|
|
Dim sVeinPhoto As String = String.Empty
|
|
Dim nInd As Integer = 1
|
|
While nInd <= m_nPhoto
|
|
If GetVeinPhotoPath(nInd, sVeinPhoto) AndAlso
|
|
String.Compare(sOldPath, sVeinPhoto, True) = 0 Then
|
|
Exit While
|
|
End If
|
|
nInd += 1
|
|
End While
|
|
' Se trovata, cambio il path
|
|
If nInd <= m_nPhoto Then
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Eseguo
|
|
Dim nPhotoId As Integer = GetVeinPhotoId(nInd)
|
|
EgtChangePhotoPath(nPhotoId, sNewPath)
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
Friend Function RemoveUnusedPhotos() As Boolean
|
|
' Recupero il contesto corrente
|
|
Dim nMainCtx As Integer = EgtGetCurrentContext()
|
|
' Riempio array con path delle foto caricate
|
|
Dim vsPath As New List(Of String)
|
|
Dim nPhId As Integer = EgtGetFirstInGroup(EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP))
|
|
While nPhId <> GDB_ID.NULL
|
|
Dim sPath As String = String.Empty
|
|
If EgtGetPhotoPath(nPhId, sPath) Then
|
|
vsPath.Add(sPath)
|
|
End If
|
|
nPhId = EgtGetNext(nPhId)
|
|
End While
|
|
' Passo al contesto del VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
' Elimino foto di VeinMatching in eccesso
|
|
Dim nVmPhId As Integer = EgtGetFirstInGroup(EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP))
|
|
While nVmPhId <> GDB_ID.NULL
|
|
Dim sPath As String = String.Empty
|
|
Dim bErase As Boolean = Not EgtGetPhotoPath(nVmPhId, sPath)
|
|
If Not bErase Then
|
|
Dim bFound As Boolean = False
|
|
For Each sVal As String In vsPath
|
|
If String.Compare(sVal, sPath, True) = 0 Then
|
|
bFound = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
bErase = Not bFound
|
|
End If
|
|
If bErase Then
|
|
Dim nEraseId As Integer = nVmPhId
|
|
nVmPhId = EgtGetNext(nVmPhId)
|
|
EgtErase(nEraseId)
|
|
Else
|
|
nVmPhId = EgtGetNext(nVmPhId)
|
|
End If
|
|
End While
|
|
' Ritorno al contesto corrente
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function SetShowText(bShow As Boolean) As Boolean
|
|
If bShow <> m_bShowText Then
|
|
m_bShowText = bShow
|
|
UpdateShowText()
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function IsPartIn(nPartId As Integer) As Boolean
|
|
Return (GetVeinPartId(nPartId) <> GDB_ID.NULL)
|
|
End Function
|
|
|
|
Friend Sub UpdateShowText(Optional bDraw As Boolean = True)
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx As Integer = EgtGetCurrentContext()
|
|
' Ciclo sui pezzi
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nPartId As Integer = EgtGetFirstPart()
|
|
While nPartId <> GDB_ID.NULL
|
|
Dim nVeinRegId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_REGION)
|
|
Dim nCurrId As Integer = EgtGetFirstInGroup(nVeinRegId)
|
|
While nCurrId <> GDB_ID.NULL
|
|
If EgtGetType(nCurrId) = GDB_TY.EXT_TEXT Then EgtSetStatus(nCurrId, If(m_bShowText, GDB_ST.ON_, GDB_ST.OFF))
|
|
nCurrId = EgtGetNext(nCurrId)
|
|
End While
|
|
nPartId = EgtGetNextPart(nPartId)
|
|
End While
|
|
If bDraw Then EgtDraw()
|
|
' Ripristino il contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
End Sub
|
|
|
|
Friend Sub SetProjectModified()
|
|
' Salvo il contesto corrente
|
|
Dim nCurrCtx As Integer = EgtGetCurrentContext()
|
|
' Recupero il contesto principale
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Imposto flag di modificato sul progetto principale
|
|
EgtSetModified()
|
|
' Ripristino il contesto originale
|
|
EgtSetCurrentContext(nCurrCtx)
|
|
End Sub
|
|
|
|
Private Function CopyPhoto(nPhotoId As Integer) As Boolean
|
|
' Recupero il contesto corrente
|
|
Dim nCurrCtx = EgtGetCurrentContext()
|
|
' Recupero i dati della fotografia
|
|
Dim sPath As String = String.Empty
|
|
If Not EgtGetPhotoPath(nPhotoId, sPath) OrElse Not File.Exists(sPath) Then Return False
|
|
Dim ptOri As Point3d
|
|
If Not EgtGetPhotoOrigin(nPhotoId, ptOri) Then Return False
|
|
Dim ptCen As Point3d
|
|
If Not EgtGetPhotoCenter(nPhotoId, ptCen) Then Return False
|
|
Dim dDimX, dDimY As Double
|
|
If Not EgtGetPhotoDimensions(nPhotoId, dDimX, dDimY) Then Return False
|
|
Dim ptMin, ptMax As Point3d
|
|
If Not EgtGetBBoxGlob(nPhotoId, GDB_BB.STANDARD, ptMin, ptMax) Then Return False
|
|
' Passo al contesto del VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
' Se non esiste il gruppo per le foto, lo creo
|
|
Dim nPhGrpId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP)
|
|
If nPhGrpId = GDB_ID.NULL Then
|
|
nPhGrpId = EgtCreateGroup(GDB_ID.ROOT)
|
|
If nPhGrpId = GDB_ID.NULL Then
|
|
EgtSetCurrentContext(nCurrCtx)
|
|
Return False
|
|
End If
|
|
EgtSetName(nPhGrpId, PHOTO_GRP)
|
|
End If
|
|
EgtSetLevel(nPhGrpId, GDB_LV.SYSTEM)
|
|
EgtSetStatus(nPhGrpId, GDB_ST.OFF)
|
|
' Carico la fotografia
|
|
m_nPhoto += 1
|
|
Dim nNewId As Integer = EgtAddPhoto2(GetVeinPhotoName(m_nPhoto), sPath, ptOri, ptCen, dDimX, dDimY, nPhGrpId, ptMin, ptMax)
|
|
' Ritorno al contesto corrente
|
|
EgtSetCurrentContext(nCurrCtx)
|
|
Return nNewId <> GDB_ID.NULL
|
|
End Function
|
|
|
|
Private Function SetVeinContext() As Integer
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return 0
|
|
' Recupero il contesto corrente
|
|
Dim nCurrCtx = EgtGetCurrentContext()
|
|
' Se necessario, cambio contesto
|
|
If m_nVeinCtx <> nCurrCtx Then
|
|
If EgtSetCurrentContext(m_nVeinCtx) Then
|
|
Return nCurrCtx
|
|
Else
|
|
Return 0
|
|
End If
|
|
Else
|
|
Return -1
|
|
End If
|
|
End Function
|
|
|
|
Private Function GetVeinPhotoName(nInd As Integer) As String
|
|
Return PHOTO_NAME & nInd.ToString()
|
|
End Function
|
|
|
|
Private Function GetVeinPhotoId(nInd As Integer) As Integer
|
|
Return EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP), GetVeinPhotoName(nInd))
|
|
End Function
|
|
|
|
Private Function GetVeinPhotoPath(nInd As Integer, ByRef sPath As String) As Boolean
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Recupero path dell'immagine della foto
|
|
Dim nId As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP), GetVeinPhotoName(nInd))
|
|
Dim bOk As Boolean = EgtGetPhotoPath(nId, sPath)
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return bOk
|
|
End Function
|
|
|
|
Private Function GetVeinRefPhoto(nMainCtx As Integer, nPartId As Integer, nVePartId As Integer, ByRef refPhoto As Frame3d) As Boolean
|
|
' Riferimento della foto rispetto al riferimento del pezzo nel contesto principale
|
|
If Not EgtSetCurrentContext(nMainCtx) Then Return False
|
|
' riferimento della foto in globale
|
|
If Not EstPhoto.GetPhotoTextureRef(refPhoto) Then
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Return False
|
|
End If
|
|
' riferimento del pezzo in globale
|
|
Dim nRefId As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(nPartId, NAME_REGION), REF_NAME)
|
|
Dim refPart As New Frame3d
|
|
If Not EgtFrame(nRefId, GDB_ID.ROOT, refPart) Then
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Return False
|
|
End If
|
|
' porto il riferimento della foto in quello del pezzo
|
|
refPhoto.ToLoc(refPart)
|
|
' Riferimento della foto rispetto al riferimento del pezzo in VeinMatching
|
|
If Not EgtSetCurrentContext(m_nVeinCtx) Then Return False
|
|
' riferimento del pezzo in globale
|
|
Dim nVeRefId As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(nVePartId, NAME_REGION), REF_NAME)
|
|
Dim refVePart As New Frame3d
|
|
If Not EgtFrame(nVeRefId, GDB_ID.ROOT, refVePart) Then Return False
|
|
refPhoto.ToGlob(refVePart)
|
|
Return True
|
|
End Function
|
|
|
|
Private Function GetVeinPartId(nPartId As Integer) As Integer
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return GDB_ID.NULL
|
|
' Cerco il pezzo in Vein che corrisponde al pezzo desiderato
|
|
Dim nId As Integer = EgtGetFirstPart()
|
|
While nId <> GDB_ID.NULL
|
|
Dim nOriId As Integer
|
|
If EgtGetInfo(nId, KEY_ORI_ID, nOriId) AndAlso nOriId = nPartId Then
|
|
Exit While
|
|
End If
|
|
nId = EgtGetNextPart(nId)
|
|
End While
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return nId
|
|
End Function
|
|
|
|
Private Function GetVeinPartRegionId(nVeinPartId As Integer) As Integer
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return GDB_ID.NULL
|
|
' Gruppo regione
|
|
Dim nRegLayId As Integer = EgtGetFirstNameInGroup(nVeinPartId, NAME_REGION)
|
|
' Entità superficie regione piatta
|
|
Dim nRegId As Integer = EgtGetFirstInGroup(nRegLayId)
|
|
While nRegId <> GDB_ID.NULL
|
|
If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then
|
|
Exit While
|
|
End If
|
|
nRegId = EgtGetNext(nRegId)
|
|
End While
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return nRegId
|
|
End Function
|
|
|
|
End Module
|