Files
omagoffice/EgtStoneLib/EstPhoto.vb
T
Dario Sassi 7494e86397 OmagOFFICE :
- modifiche per libreria EgtSTONELib rinominata in EgtPHOTOLib.
2020-08-19 15:41:08 +00:00

510 lines
22 KiB
VB.net

'----------------------------------------------------------------------------
' EgalTech 2015-2017
'----------------------------------------------------------------------------
' File : GenPhoto.vb Data : 12.04.17 Versione : 1.8d1
' Contenuto : Modulo gestione fotografie.
' Ogni gruppo di lavoro può avere una sua foto della lastra.
'
'
' Modifiche : 12.04.17 DS Creazione modulo.
'
'
'----------------------------------------------------------------------------
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Module EstPhoto
Friend Function LoadPhoto(sPath As String,
ByRef nSlabId As Integer, ByRef sSlabName As String, ByRef sMat As String) As Boolean
' Verifico esistenza file immagine
If Not File.Exists(sPath) Then Return False
' Leggo eventuale file dati aggiuntivi
Dim ptOri As New Point3d(0, 0, 0)
Dim ptCen As New Point3d(0, 0, INFINITO)
Dim dMMxPixel As Double = 1
Dim dCoeff As Double = 1
If Not ReadAuxData(sPath, nSlabId, sSlabName, sMat, ptOri, ptCen, dMMxPixel, dCoeff) Then Return False
' Aggiungo eventuali offset
ptOri += CurrentMachine.PhotoOffset
ptCen += CurrentMachine.PhotoOffset
' Altezza eventuale tavola aggiuntiva
Dim dAddTable As Double = CurrentMachine.dAdditionalTable
' Aggiusto dati per spessore grezzo
If Math.Abs(EstCalc.GetRawHeight() + dAddTable) > EPS_SMALL Then
' Coefficiente di scalatura
Dim dFsca As Double = (ptCen.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptOri.z)
dMMxPixel *= dFsca
ptOri.x = ptCen.x + (ptOri.x - ptCen.x) * dFsca
ptOri.y = ptCen.y + (ptOri.y - ptCen.y) * dFsca
ptOri.z = EstCalc.GetRawHeight() + dAddTable
End If
' Recupero origine della tavola e porto i punti in globale
Dim ptTab As Point3d
If Not EgtGetTableRef(1, ptTab) Then Return False
ptOri.ToGlob(New Frame3d(ptTab))
ptCen.ToGlob(New Frame3d(ptTab))
' Recupero le dimensioni della tavola
Dim b3Tab As New BBox3d
If Not EgtGetTableArea(1, b3Tab) Then Return False
b3Tab.Expand(100, 100, 0)
' Elimino eventuale precedente foto
Dim nOldPhotoId = GetPhoto()
If nOldPhotoId <> GDB_ID.NULL Then EgtErase(nOldPhotoId)
' 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 Return False
EgtSetName(nPhGrpId, PHOTO_GRP)
End If
EgtSetLevel(nPhGrpId, GDB_LV.SYSTEM)
' Carico la fotografia
Return EgtAddPhoto(GetPhotoName(), sPath, ptOri, ptCen, dMMxPixel, nPhGrpId, b3Tab.Min(), b3Tab.Max()) <> GDB_ID.NULL
End Function
Friend Function LoadContour(sPath As String) As Boolean
' Elimino eventuale vecchio contorno
RemoveContour()
' Leggo eventuale file dati aggiuntivi
Dim nSlabId As Integer = 0
Dim sSlabName As String = String.Empty
Dim sMat As String = String.Empty
Dim ptOri As New Point3d(0, 0, 0)
Dim ptCen As New Point3d(0, 0, INFINITO)
Dim dMMxPixel As Double = 1
Dim dCoeff As Double = 1
If Not ReadAuxData(sPath, nSlabId, sSlabName, sMat, ptOri, ptCen, dMMxPixel, dCoeff) Then Return False
' Aggiungo eventuali offset
ptOri += CurrentMachine.PhotoOffset
ptCen += CurrentMachine.PhotoOffset
' Recupero dimensione della immagine originale della fotografia
Dim nPixelX As Integer = 0
Dim nPixelY As Integer = 0
If Not EgtGetPhotoImagePixels(GetPhoto(), nPixelX, nPixelY) Then Return False
' Altezza eventuale tavola aggiuntiva
Dim dAddTable As Double = CurrentMachine.dAdditionalTable
' Aggiusto dati per spessore grezzo
If Math.Abs(EstCalc.GetRawHeight() + dAddTable) > EPS_SMALL Then
' Coefficiente di scalatura
Dim dFsca As Double = (ptCen.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptOri.z)
dMMxPixel *= dFsca
ptOri.x = ptCen.x + (ptOri.x - ptCen.x) * dFsca
ptOri.y = ptCen.y + (ptOri.y - ptCen.y) * dFsca
ptOri.z = EstCalc.GetRawHeight() + dAddTable
End If
' Recupero origine della tavola e porto i punti in globale
Dim ptTab As Point3d
If Not EgtGetTableRef(1, ptTab) Then Return False
ptOri.ToGlob(New Frame3d(ptTab))
ptCen.ToGlob(New Frame3d(ptTab))
' Verifico coefficiente scalatura Pixel (per MapaScan, normalmente 1)
If dCoeff < EPS_SMALL Then
EgtOutLog("ReadContour : coefficiente di scalatura pixel nullo")
Return False
End If
' Se esiste file dxf lancio lettore standard, altrimenti quello personalizzato
Dim nCrvId As Integer = GDB_ID.NULL
Dim sCntPath As String = Path.ChangeExtension(sPath, ".dxf")
If My.Computer.FileSystem.FileExists(sCntPath) Then
nCrvId = LoadStandardContour(sCntPath, ptOri, dMMxPixel, nPixelY, dCoeff)
Else
nCrvId = LoadCustomContour(sPath, ptOri, dMMxPixel, nPixelY, dCoeff)
End If
' Eseguo le semplificazioni
Dim nApprType As Integer = APP_TYPE.LEFT_LINES
Dim dTol As Double = GetMainPrivateProfileDouble(S_CAMERA, K_CAM_TOLERANCE, 5)
EgtApproxCurve(nCrvId, nApprType, dTol)
Dim ptNew As Point3d
EgtMidPoint(nCrvId, ptNew)
EgtChangeClosedCurveStartPoint(nCrvId, ptNew)
EgtApproxCurve(nCrvId, nApprType, dTol)
Return True
End Function
Private Function LoadStandardContour(sPath As String, ptOri As Point3d, dMMxPixel As Double, nPixelY As Integer, dCoeff As Double) As Integer
' Carico Dxf del contorno
If Not EgtImportDxf(sPath, 1) Then Return GDB_ID.NULL
Dim nPartId As Integer = EgtGetLastPart()
Dim nLayerId As Integer = EgtGetFirstLayer(nPartId)
EgtSetName(nPartId, NAME_RAW_PHOTO_OUTLINE)
EgtSetLevel(nPartId, GDB_LV.SYSTEM)
If nPartId = GDB_ID.NULL Or nLayerId = GDB_ID.NULL Then Return GDB_ID.NULL
' Ribalto rispetto a YZ locale (i contorni da CW diventano CCW)
EgtMirror(nLayerId, New Point3d(0, nPixelY * dCoeff / 2, 0), Vector3d.Y_AX(), GDB_RT.GLOB)
' Eseguo scalatura
Dim dScaCoeff As Double = dMMxPixel / dCoeff
EgtScale(nLayerId, New Frame3d(), dScaCoeff, dScaCoeff, dScaCoeff, GDB_RT.GLOB)
' Eseguo spostamento
EgtMove(nLayerId, (ptOri - Point3d.ORIG()), GDB_RT.GLOB)
' Eseguo concatenamento
EgtSelectGroupObjs(nLayerId)
EgtCreateCurveCompoByReorder(nLayerId, 1, {GDB_ID.SEL}, New Point3d(), True)
' Conservo la curva chiusa di area massima
Dim dAreaMax As Double = 0
Dim nCrvId As Integer = GDB_ID.NULL
Dim nCurrCrvId As Integer = EgtGetFirstInGroup(nLayerId)
While nCurrCrvId <> GDB_ID.NULL
Dim dArea As Double = 0
If Not EgtCurveAreaXY(nCurrCrvId, dArea) OrElse dArea <= dAreaMax Then
Dim nToEraseId = nCurrCrvId
nCurrCrvId = EgtGetNext(nCurrCrvId)
EgtErase(nToEraseId)
Else
dAreaMax = dArea
EgtErase(nCrvId)
nCrvId = nCurrCrvId
nCurrCrvId = EgtGetNext(nCurrCrvId)
End If
End While
EgtSetColor(nCrvId, New Color3d(0, 255, 0))
Return nCrvId
End Function
Private Function LoadCustomContour(sPath As String, ptOri As Point3d, dMMxPixel As Double, nPixelY As Integer, dCoeff As Double) As Integer
' Definizione variabili
EgtLuaCreateGlobTable("RCT")
EgtLuaSetGlobStringVar("RCT.FILE", sPath)
' Esecuzione
Dim nErr As Integer = 999
If EgtLuaExecFile(OmagOFFICEMap.refMainWindowVM.MainWindowM.sImgAutoDir & "\ReadContour.lua") AndAlso
EgtLuaCallFunction("RCT.ReadContour") Then
' Verifica stato di errore
EgtLuaGetGlobIntVar("RCT.ERR", nErr)
End If
If nErr <> 0 Then
EgtOutLog("Error in ReadContour : " & nErr.ToString())
Return GDB_ID.NULL
End If
' Leggo i risultati
Dim nPartId As Integer = GDB_ID.NULL
EgtLuaGetGlobIntVar("RCT.PARTID", nPartId)
If nPartId = GDB_ID.NULL Then Return GDB_ID.NULL
EgtSetName(nPartId, NAME_RAW_PHOTO_OUTLINE)
EgtSetLevel(nPartId, GDB_LV.SYSTEM)
Dim nCrvId As Integer = GDB_ID.NULL
EgtLuaGetGlobIntVar("RCT.CRVID", nCrvId)
EgtLuaResetGlobVar("RCT")
If nCrvId = GDB_ID.NULL Then Return GDB_ID.NULL
EgtSetColor(nCrvId, New Color3d(0, 255, 0))
' Ribalto rispetto a YZ locale (i contorni da CW diventano CCW)
EgtMirror(nCrvId, New Point3d(0, nPixelY * dCoeff / 2, 0), Vector3d.Y_AX(), GDB_RT.GLOB)
' Eseguo scalatura
Dim dScaCoeff As Double = dMMxPixel / dCoeff
EgtScale(nCrvId, New Frame3d(), dScaCoeff, dScaCoeff, dScaCoeff, GDB_RT.GLOB)
' Eseguo spostamento
EgtMove(nCrvId, (ptOri - Point3d.ORIG()), GDB_RT.GLOB)
' Deve essere CCW
Dim dArea As Double = 0
If EgtCurveAreaXY(nCrvId, dArea) AndAlso dArea < 0 Then
EgtInvertCurve(nCrvId)
End If
Return nCrvId
End Function
Private Function ReadAuxData(sPath As String,
ByRef nSlabId As Integer, ByRef sSlabName As String, ByRef sMat As String,
ByRef ptOri As Point3d, ByRef ptCen As Point3d, ByRef dMMxPixel As Double, ByRef dCoeff As Double) As Boolean
' Se esiste file txt lancio lettore standard, altrimenti quello personalizzato
Dim sAuxPath As String = Path.ChangeExtension(sPath, ".txt")
If My.Computer.FileSystem.FileExists(sAuxPath) Then
Return ReadStandardAuxData(sAuxPath, nSlabId, sSlabName, sMat, ptOri, ptCen, dMMxPixel, dCoeff)
Else
Return ReadCustomAuxData(sPath, nSlabId, sSlabName, sMat, ptOri, ptCen, dMMxPixel, dCoeff)
End If
End Function
Private Function ReadStandardAuxData(sAuxPath As String,
ByRef nSlabId As Integer, ByRef sSlabName As String, ByRef sMat As String,
ByRef ptOri As Point3d, ByRef ptCen As Point3d, ByRef dMMxPixel As Double, ByRef dCoeff As Double) As Boolean
nSlabId = 0
sSlabName = String.Empty
sMat = String.Empty
dCoeff = 1
Try
Dim sLine As String = String.Empty
Dim sr As StreamReader = New StreamReader(sAuxPath)
Do While sr.Peek() > -1
sLine = sr.ReadLine()
sLine = sLine.Replace(" ", "")
If sLine.StartsWith("X=") Then
StringToDouble(sLine.Substring(2), ptOri.x)
ElseIf sLine.StartsWith("Y=") Then
StringToDouble(sLine.Substring(2), ptOri.y)
ElseIf sLine.StartsWith("Z_Lastra=") Then
StringToDouble(sLine.Substring(9), ptOri.z)
ElseIf sLine.StartsWith("X_ScaleCenter=") Then
StringToDouble(sLine.Substring(14), ptCen.x)
ElseIf sLine.StartsWith("Y_ScaleCenter=") Then
StringToDouble(sLine.Substring(14), ptCen.y)
ElseIf sLine.StartsWith("Z_ScaleCenter=") Then
StringToDouble(sLine.Substring(14), ptCen.z)
ElseIf sLine.StartsWith("Pixelxmm=") Then
Dim dTmp As Double
StringToDouble(sLine.Substring(9), dTmp)
If dTmp > EPS_SMALL Then
dMMxPixel = 1 / dTmp
End If
End If
Loop
sr.Close()
Return True
Catch ex As Exception
EgtOutLog("LoadPhoto Error on auxfile : " & sAuxPath)
Return False
End Try
End Function
Private Function ReadCustomAuxData(sPath As String,
ByRef nSlabId As Integer, ByRef sSlabName As String, ByRef sMat As String,
ByRef ptOri As Point3d, ByRef ptCen As Point3d, ByRef dMMxPixel As Double, ByRef dCoeff As Double) As Boolean
' Definizione variabili
EgtLuaCreateGlobTable("RDT")
EgtLuaSetGlobStringVar("RDT.FILE", sPath)
' Esecuzione
Dim nErr As Integer = 999
If EgtLuaExecFile(OmagOFFICEMap.refMainWindowVM.MainWindowM.sImgAutoDir & "\ReadData.lua") AndAlso
EgtLuaCallFunction("RDT.ReadData") Then
' Verifica stato di errore
EgtLuaGetGlobIntVar("RDT.ERR", nErr)
End If
If nErr <> 0 Then
EgtOutLog("Error in ReadData : " & nErr.ToString())
Return False
End If
' Leggo i risultati
If Not EgtLuaGetGlobIntVar("RDT.SLABID", nSlabId) Then nSlabId = 0
If Not EgtLuaGetGlobStringVar("RDT.SLABNAME", sSlabName) Then sSlabName = String.Empty
If Not EgtLuaGetGlobStringVar("RDT.MATERIAL", sMat) Then sMat = String.Empty
Dim dThick As Double = 0
EgtLuaGetGlobNumVar("RDT.TH", dThick)
EgtLuaGetGlobPointVar("RDT.ORI", ptOri)
EgtLuaGetGlobPointVar("RDT.CEN", ptCen)
EgtLuaGetGlobNumVar("RDT.COEFF", dCoeff)
EgtLuaGetGlobNumVar("RDT.MMXPIXEL", dMMxPixel)
EgtLuaResetGlobVar("RDT")
Return True
End Function
Public Function GetPhotoName() As String
' Recupero il nome del gruppo di lavoro corrente
Dim sMGrp As String = String.Empty
If Not EgtGetMachGroupName(EgtGetCurrMachGroup(), sMGrp) Then Return ""
' Creo il nome della foto
Return PHOTO_NAME & sMGrp
End Function
Public Function GetPhoto() As Integer
' Recupero Id del gruppo delle foto
Dim nPhGrpId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP)
' Recupero Id della foto
Return EgtGetFirstNameInGroup(nPhGrpId, GetPhotoName())
End Function
Public Function GetPhotoTexturePath() As String
' Recupero la foto
Dim nId As Integer = GetPhoto()
If nId = GDB_ID.NULL Then Return ""
' Recupero la path della texture
Dim sPath As String = String.Empty
If EgtGetPhotoPath(nId, sPath) Then
Return sPath
Else
Return ""
End If
End Function
Public Function GetPhotoTextureRef(ByRef refTxr As Frame3d) As Boolean
' Recupero la foto
Dim nId As Integer = GetPhoto()
If nId = GDB_ID.NULL Then Return False
' Recupero il riferimento in globale
Return EgtGetTextureFrame(nId, GDB_ID.ROOT, refTxr)
End Function
Public Function ShowPhoto(ByVal bShow As Boolean, Optional bDisableModified As Boolean = True) As Boolean
' Recupero la foto
Dim nId As Integer = GetPhoto()
If nId = GDB_ID.NULL Then Return False
' Se richiesto, disabilito impostazione modificato
Dim bOldEnMod As Boolean = False
If bDisableModified Then
bOldEnMod = EgtGetEnableModified()
If bOldEnMod Then EgtDisableModified()
End If
' Ne cambio lo stato
Dim bOk As Boolean = EgtSetStatus(nId, If(bShow, GDB_ST.ON_, GDB_ST.OFF))
' Se necessario, ripristino precedente impostazione modificato
If bOldEnMod Then EgtEnableModified()
Return bOk
End Function
Public Function GetPhotoOffsetRot(ByRef dOffsetX As Double, ByRef dOffsetY As Double, ByRef dRot As Double) As Boolean
' Verifico esistenza oggetto foto
Dim nPhotoId As Integer = GetPhoto()
If nPhotoId = GDB_ID.NULL Then Return False
' Recupero valori
If Not EgtGetInfo(nPhotoId, "OffsX", dOffsetX) Then dOffsetX = 0
If Not EgtGetInfo(nPhotoId, "OffsY", dOffsetY) Then dOffsetY = 0
If Not EgtGetInfo(nPhotoId, "Rot", dRot) Then dRot = 0
Return True
End Function
Public Function UpdatePhoto() As Boolean
' Verifico esistenza oggetto foto
Dim nPhotoId As Integer = GetPhoto()
If nPhotoId = GDB_ID.NULL Then Return False
' Verifico esistenza texture della foto
Dim sPath As String = String.Empty
If Not EgtGetPhotoPath(nPhotoId, sPath) OrElse Not File.Exists(sPath) Then Return False
' Recupero i dati aggiuntivi della foto
Dim ptOri As New Point3d(0, 0, 0)
If Not EgtGetPhotoOrigin(nPhotoId, ptOri) Then Return False
Dim ptCen As New Point3d(0, 0, 1)
If Not EgtGetPhotoCenter(nPhotoId, ptCen) Then Return False
Dim dDimX, dDimY As Double
If Not EgtGetPhotoDimensions(nPhotoId, dDimX, dDimY) Then Return False
' Recupero origine della tavola
Dim ptTab As Point3d
If Not EgtGetTableRef(1, ptTab) Then Return False
' Porto i punti in locale
ptOri.ToLoc(New Frame3d(ptTab))
ptCen.ToLoc(New Frame3d(ptTab))
' Altezza eventuale tavola aggiuntiva
Dim dAddTable As Double = CurrentMachine.dAdditionalTable
' Aggiusto dati per spessore grezzo (Coefficiente di scalatura)
Dim dFsca As Double = (ptCen.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptOri.z)
dDimX *= dFsca
dDimY *= dFsca
ptOri.x = ptCen.x + (ptOri.x - ptCen.x) * dFsca
ptOri.y = ptCen.y + (ptOri.y - ptCen.y) * dFsca
ptOri.z = EstCalc.GetRawHeight() + dAddTable
' Porto i punti in globale
ptOri.ToGlob(New Frame3d(ptTab))
ptCen.ToGlob(New Frame3d(ptTab))
' Carico gli offset
Dim dOffsetX As Double = 0
EgtGetInfo(nPhotoId, "OffsX", dOffsetX)
Dim dOffsetY As Double = 0
EgtGetInfo(nPhotoId, "OffsY", dOffsetY)
Dim dRot As Double = 0
EgtGetInfo(nPhotoId, "Rot", dRot)
' Recupero le dimensioni della tavola
Dim ptMin, ptMax As Point3d
If Not EgtGetTableArea(1, ptMin, ptMax) Then Return False
' Elimino precedente foto
EgtErase(nPhotoId)
' 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 Return False
EgtSetName(nPhGrpId, PHOTO_GRP)
End If
EgtSetLevel(nPhGrpId, GDB_LV.SYSTEM)
' Carico la fotografia
Dim nNewPhotoId As Integer = EgtAddPhoto2(GetPhotoName(), sPath, ptOri, ptCen, dDimX, dDimY, nPhGrpId, ptMin, ptMax)
If nNewPhotoId = GDB_ID.NULL Then Return False
' Eseguo eventuale rotazione attorno all'origine
EgtRotatePhoto(nNewPhotoId, ptOri, Vector3d.Z_AX(), dRot)
' Salvo gli offset
EgtSetInfo(nNewPhotoId, "OffsX", dOffsetX)
EgtSetInfo(nNewPhotoId, "OffsY", dOffsetY)
EgtSetInfo(nNewPhotoId, "Rot", dRot)
Return True
End Function
Public Function ChangeOffsetPhoto(dOffsetX As Double, dOffsetY As Double) As Boolean
' Verifico esistenza oggetto foto
Dim nPhotoId As Integer = GetPhoto()
If nPhotoId = GDB_ID.NULL Then Return False
' Verifico esistenza texture della foto
Dim sPath As String = String.Empty
EgtGetPhotoPath(nPhotoId, sPath)
If Not File.Exists(sPath) Then Return False
' Recupero offset corrente
Dim dOldOffsX As Double = 0
EgtGetInfo(nPhotoId, "OffsX", dOldOffsX)
Dim dOldOffsY As Double = 0
EgtGetInfo(nPhotoId, "OffsY", dOldOffsY)
' Eseguo traslazione
Dim vtMove As New Vector3d(dOffsetX - dOldOffsX, dOffsetY - dOldOffsY, 0)
EgtMovePhoto(nPhotoId, vtMove)
' Aggiorno valori di offset
EgtSetInfo(nPhotoId, "OffsX", dOffsetX)
EgtSetInfo(nPhotoId, "OffsY", dOffsetY)
Return True
End Function
Public Function ChangeRotationPhoto(ptAx As Point3d, dRot As Double) As Boolean
' Verifico esistenza oggetto foto
Dim nPhotoId As Integer = GetPhoto()
If nPhotoId = GDB_ID.NULL Then Return False
' Verifico esistenza texture della foto
Dim sPath As String = String.Empty
EgtGetPhotoPath(nPhotoId, sPath)
If Not File.Exists(sPath) Then Return False
' Recupero rotazione corrente
Dim dOldRot As Double = 0
EgtGetInfo(nPhotoId, "Rot", dOldRot)
' Eseguo rotazione
EgtRotatePhoto(nPhotoId, ptAx, Vector3d.Z_AX(), dRot - dOldRot)
' Aggiorno valore di rotazione
EgtSetInfo(nPhotoId, "Rot", dRot)
Return True
End Function
Public Function UpdateContour() As Boolean
' Verifico esistenza oggetto contorno
Dim nCrvId As Integer = GetContour()
If nCrvId = GDB_ID.NULL Then Return False
' Verifico esistenza oggetto foto
Dim nPhotoId As Integer = GetPhoto()
If nPhotoId = GDB_ID.NULL Then Return False
' Recupero centro della foto
Dim ptCen As New Point3d(0, 0, 1)
EgtGetPhotoCenter(nPhotoId, ptCen)
' Recupero origine della tavola
Dim ptTab As Point3d
If Not EgtGetTableRef(1, ptTab) Then Return False
' Altezza eventuale tavola aggiuntiva
Dim dAddTable As Double = CurrentMachine.dAdditionalTable
' Recupero inizio contorno
Dim ptStart As Point3d
EgtStartPoint(nCrvId, GDB_ID.ROOT, ptStart)
' Calcolo coefficiente di scalatura
Dim dFsca As Double = (ptCen.z - ptTab.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptStart.z)
' Scalo opportunamente
EgtScale(nCrvId, New Frame3d(ptCen), dFsca, dFsca, 1, GDB_RT.GLOB)
' Sposto in Z
Dim vtMove As New Vector3d(0, 0, ptTab.z + EstCalc.GetRawHeight() + dAddTable - ptStart.z)
EgtMove(nCrvId, vtMove, GDB_RT.GLOB)
Return True
End Function
Public Function GetContour() As Integer
Dim nPartId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE)
Dim nLayerId As Integer = EgtGetFirstGroupInGroup(nPartId)
Dim nCrvId As Integer = EgtGetFirstInGroup(nLayerId)
Return nCrvId
End Function
Friend Sub RemoveContour()
EgtErase(EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE))
End Sub
Public Sub ShowContour(bShow As Boolean)
' Disabilito impostazione modificato
Dim bOldEnMod As Boolean = EgtGetEnableModified()
If bOldEnMod Then EgtDisableModified()
' Cambio stato di visualizzazione
EgtSetStatus(EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE), If(bShow, GDB_ST.ON_, GDB_ST.OFF))
' Se necessario, ripristino precedente impostazione modificato
If bOldEnMod Then EgtEnableModified()
End Sub
End Module