OmagOFFICE 1.9b2 :

- aggiunto import TRF (da Cut)
- aggiunta gestione doppia pendenza su bordo (da Cut)
- tolta visualizzazione iniziale inappropriata.
This commit is contained in:
Dario Sassi
2018-02-08 10:43:23 +00:00
parent e03180a40b
commit 69313d5f6d
14 changed files with 264 additions and 121 deletions
+57 -40
View File
@@ -538,67 +538,84 @@ Public Class SideEntityControlVM
End Sub
' Funzione che dato un segmento e una distanza, scrive il testo centrato alla sua destra
Friend Shared Function AddTextToLine(sText As String, TextLayer As Integer, CurrLine As Integer, dDistance As Double, dBBoxRad As Double, bTextExt As Boolean) As Integer
Friend Shared Function AddTextToLine(sText As String, TextLayer As Integer, CurrLine As Integer, dDistance As Double,
dBBoxRad As Double, bTextExt As Boolean, Optional bRot As Boolean = False) As Integer
' Calcolo altezza testo
Dim dH As Double = 0.075 * dBBoxRad
' Creo testo
Dim nText As Integer = EgtCreateTextAdv(TextLayer, New Point3d(0, 0, 0), 0, sText, "", 500, False, dH, 1, 0, INS_POS.MC)
' Calcolo punto in cui posizionare il testo
' calcolo BBox del testo
' Calcolo posizionamento
' BBox del testo e suo centro
Dim ptMinBBox As Point3d
Dim ptMaxBBox As Point3d
EgtGetBBox(nText, GDB_BB.STANDARD, ptMinBBox, ptMaxBBox)
' calcolo centro del BBox
Dim ptMidBBox As Point3d
ptMidBBox = Point3d.Media(ptMinBBox, ptMaxBBox)
' calcolo vettore della CurrLine
' estremi della CurrLine
Dim ptLineStart As Point3d
EgtStartPoint(CurrLine, nText, ptLineStart)
Dim ptLineEnd As Point3d
EgtEndPoint(CurrLine, nText, ptLineEnd)
' versore della CurrLine
Dim vtCurrLine As Vector3d = ptLineEnd - ptLineStart
' lo normalizzo per ottenerne il versore
vtCurrLine.Normalize()
' calcolo vettore dal centro del BBox all'estremo più vicino se testo esterno alla figura
Dim vtptExtptMC As Vector3d
' versore perpendicolare alla CurrLine che punta verso il testo
Dim vtOrtoLine As New Vector3d(vtCurrLine)
If bTextExt Then
If vtCurrLine.x > 0 Then
If vtCurrLine.y > 0 Then
vtptExtptMC = ptMidBBox - New Point3d(ptMinBBox.x, ptMaxBBox.y, 0)
Else
vtptExtptMC = ptMidBBox - ptMaxBBox
End If
Else
If vtCurrLine.y > 0 Then
vtptExtptMC = ptMidBBox - ptMinBBox
Else
vtptExtptMC = ptMidBBox - New Point3d(ptMaxBBox.x, ptMinBBox.y, 0)
End If
End If
vtOrtoLine.Rotate(Vector3d.Z_AX(), -90)
Else
If vtCurrLine.x > 0 Then
If vtCurrLine.y > 0 Then
vtptExtptMC = ptMidBBox - New Point3d(ptMaxBBox.x, ptMinBBox.y, 0)
Else
vtptExtptMC = ptMidBBox - ptMinBBox
End If
Else
If vtCurrLine.y > 0 Then
vtptExtptMC = ptMidBBox - ptMaxBBox
Else
vtptExtptMC = ptMidBBox - New Point3d(ptMinBBox.x, ptMaxBBox.y, 0)
End If
End If
vtOrtoLine.Rotate(Vector3d.Z_AX(), 90)
End If
' ruoto il vettore della CurrLine per ottenerne il perpendicolare
If bTextExt Then
vtCurrLine.Rotate(Vector3d.Z_AX, -90)
' eventuale rotazione del testo
Dim dRotAng As Double = 0
If bRot Then
dRotAng = Math.Atan2(vtCurrLine.y, vtCurrLine.x) * 180 / Math.PI
Dim dSpecRotAng = dRotAng
If dSpecRotAng > 91 Then
dSpecRotAng -= 180
ElseIf dSpecRotAng < -89 Then
dSpecRotAng += 180
End If
EgtRotate(nText, Point3d.ORIG(), Vector3d.Z_AX(), dSpecRotAng)
End If
' vettore dal centro del BBox all'estremo più vicino
Dim vtptExtptMC As Vector3d
If bRot Then
vtptExtptMC = New Vector3d(0, ptMidBBox.y - ptMinBBox.y, 0)
vtptExtptMC.Rotate(Vector3d.Z_AX(), dRotAng)
Else
vtCurrLine.Rotate(Vector3d.Z_AX, 90)
If bTextExt Then
If vtCurrLine.x > 0 Then
If vtCurrLine.y > 0 Then
vtptExtptMC = ptMidBBox - New Point3d(ptMinBBox.x, ptMaxBBox.y, 0)
Else
vtptExtptMC = ptMidBBox - ptMaxBBox
End If
Else
If vtCurrLine.y > 0 Then
vtptExtptMC = ptMidBBox - ptMinBBox
Else
vtptExtptMC = ptMidBBox - New Point3d(ptMaxBBox.x, ptMinBBox.y, 0)
End If
End If
Else
If vtCurrLine.x > 0 Then
If vtCurrLine.y > 0 Then
vtptExtptMC = ptMidBBox - New Point3d(ptMaxBBox.x, ptMinBBox.y, 0)
Else
vtptExtptMC = ptMidBBox - ptMinBBox
End If
Else
If vtCurrLine.y > 0 Then
vtptExtptMC = ptMidBBox - ptMaxBBox
Else
vtptExtptMC = ptMidBBox - New Point3d(ptMinBBox.x, ptMaxBBox.y, 0)
End If
End If
End If
End If
' Calcolo il centro del testo
Dim ptTextMC As Point3d = Point3d.Media(ptLineStart, ptLineEnd) + vtCurrLine * (dDistance + (vtCurrLine * vtptExtptMC))
Dim ptTextMC As Point3d = Point3d.Media(ptLineStart, ptLineEnd) + vtOrtoLine * (dDistance + (vtOrtoLine * vtptExtptMC))
EgtMove(nText, (ptTextMC - Point3d.ORIG))
Return nText
End Function