From 699879e2c54afe8e3a573846d912c14b0fcff4be Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 14 Oct 2014 06:55:29 +0000 Subject: [PATCH] EgtUILib 1.5j2 : - aggiunta gestione analisi - aggiunta gestione distanza tra punti notevoli. --- EgtInterface.vb | 38 ++++++- EgtUILib.vbproj | 22 +++++ My Project/AssemblyInfo.vb | 4 +- My Project/Resources.Designer.vb | 20 ++++ My Project/Resources.resx | 6 ++ Resources/Analyze.cur | Bin 0 -> 326 bytes Resources/Analyze.png | Bin 0 -> 270 bytes Resources/GetDist.cur | Bin 0 -> 326 bytes Resources/GetDist.png | Bin 0 -> 248 bytes Scene.Designer.vb | 54 +++++++++- Scene.vb | 164 ++++++++++++++++++++++++++++--- SelectMulti.Designer.vb | 28 +++--- SelectMulti.vb | 44 +++++++-- tsExec.Designer.vb | 29 ++++++ tsExec.vb | 48 +++++++++ tsInfo.Designer.vb | 29 ++++++ tsInfo.vb | 78 +++++++++++++++ tsMain.vb | 17 ---- tsRendering.vb | 9 +- 19 files changed, 530 insertions(+), 60 deletions(-) create mode 100644 Resources/Analyze.cur create mode 100644 Resources/Analyze.png create mode 100644 Resources/GetDist.cur create mode 100644 Resources/GetDist.png create mode 100644 tsExec.Designer.vb create mode 100644 tsExec.vb create mode 100644 tsInfo.Designer.vb create mode 100644 tsInfo.vb diff --git a/EgtInterface.vb b/EgtInterface.vb index 05fc2ff..dd5189d 100644 --- a/EgtInterface.vb +++ b/EgtInterface.vb @@ -296,6 +296,18 @@ Public Shared Function EgtSetBackground(ByVal nCtx As Integer, ByVal nTopRed As Optional ByVal bRedraw As Boolean = True) As Boolean End Function + +Public Shared Function EgtSetMarkAttribs(ByVal nCtx As Integer, ByVal nRed As Integer, ByVal nGreen As Integer, ByVal nBlue As Integer) As Boolean +End Function + + +Public Shared Function EgtSetGeoLineAttribs(ByVal nCtx As Integer, ByVal nRed As Integer, ByVal nGreen As Integer, ByVal nBlue As Integer) As Boolean +End Function + + +Public Shared Function EgtSetWinRectAttribs(ByVal nCtx As Integer, ByVal bOutline As Boolean, ByVal nRed As Integer, ByVal nGreen As Integer, ByVal nBlue As Integer, ByVal nAlpha As Integer) As Boolean +End Function + Public Shared Function EgtResize(ByVal nCtx As Integer, ByVal nW As Integer, ByVal nH As Integer) As Boolean End Function @@ -305,9 +317,11 @@ Public Shared Function EgtDraw(ByVal nCtx As Integer) As Boolean End Function -Private Shared Function EgtSelect(ByVal nCtx As Integer, ByVal nWinX As Integer, ByVal nWinY As Integer, ByVal nSelW As Integer, ByVal nSelH As Integer, ByRef nSel As Integer) As Boolean +Private Shared Function EgtSelect(ByVal nCtx As Integer, ByVal nWinX As Integer, ByVal nWinY As Integer, + ByVal nSelW As Integer, ByVal nSelH As Integer, ByRef nSel As Integer) As Boolean End Function -Public Shared Function EgtSelect(ByVal nCtx As Integer, ByVal Curr As Point, ByVal nSelW As Integer, ByVal nSelH As Integer, ByRef nSel As Integer) As Boolean +Public Shared Function EgtSelect(ByVal nCtx As Integer, ByVal Curr As Point, ByVal nSelW As Integer, ByVal nSelH As Integer, + ByRef nSel As Integer) As Boolean Return EgtSelect(nCtx, Curr.X, Curr.Y, nSelW, nSelH, nSel) End Function @@ -319,14 +333,28 @@ End Function Public Shared Function EgtGetNextSelectedObj(ByVal nGseCtx As Integer) As Integer End Function + +Public Shared Function EgtGetSelectedSnapPoint(ByVal nGseCtx As Integer, ByVal nSnap As Integer, + ByVal nWinX As Integer, ByVal nWinY As Integer, ByVal nSelW As Integer, ByVal nSelH As Integer, + ByRef ptP As Point3d) As Boolean +End Function + Public Shared Function EgtSetShowMode(ByVal nCtx As Integer, ByVal nShowMode As Integer, Optional ByVal bRedraw As Boolean = True) As Boolean End Function + +Public Shared Function EgtGetShowMode(ByVal nCtx As Integer) As Integer +End Function + Public Shared Function EgtSetShowCurveDirection(ByVal nCtx As Integer, ByVal bShow As Boolean, Optional ByVal bRedraw As Boolean = True) As Boolean End Function + +Public Shared Function EgtGetShowCurveDirection(ByVal nCtx As Integer) As Boolean +End Function + Public Shared Function EgtZoom(ByVal nCtx As Integer, ByVal nZoom As Integer, Optional ByVal bRedraw As Boolean = True) As Boolean End Function @@ -339,7 +367,7 @@ Public Shared Function EgtZoomOnPoint(ByVal nCtx As Integer, ByVal Curr As Point End Function -Public Shared Function EgtSetGeoLine(ByVal nCtx As Integer, ByVal ptP1 As Point3d, ByVal ptP2 As Point3d, Optional ByVal bRedraw As Boolean = True) As Boolean +Public Shared Function EgtSetGeoLine(ByVal nCtx As Integer, ByRef ptP1 As Point3d, ByRef ptP2 As Point3d, Optional ByVal bRedraw As Boolean = True) As Boolean End Function @@ -393,6 +421,10 @@ Public Shared Function EgtUnProjectPoint(ByVal nCtx As Integer, ByVal Curr As Po Return EgtUnProjectPoint(nCtx, Curr.X, Curr.Y, ptP) End Function + +Public Shared Function EgtProjectPoint(ByVal nCtx As Integer, ByRef ptP As Point3d, ByRef ptWin As Point3d) As Boolean +End Function + 'Tsc Executor diff --git a/EgtUILib.vbproj b/EgtUILib.vbproj index 3291592..ff38b12 100644 --- a/EgtUILib.vbproj +++ b/EgtUILib.vbproj @@ -294,6 +294,18 @@ Form + + tsExec.vb + + + Component + + + tsInfo.vb + + + Component + tsLookFrom.vb @@ -416,6 +428,16 @@ + + + + + + + + + + IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\Dll32\EgtUILib.dll diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 467ed73..e0df6c7 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -42,5 +42,5 @@ Imports System.Runtime.InteropServices ' È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build ' utilizzando l'asterisco (*) come descritto di seguito: - - + + diff --git a/My Project/Resources.Designer.vb b/My Project/Resources.Designer.vb index cc7ddfe..2fbe626 100644 --- a/My Project/Resources.Designer.vb +++ b/My Project/Resources.Designer.vb @@ -70,6 +70,16 @@ Namespace My.Resources End Get End Property + ''' + ''' Cerca una risorsa localizzata di tipo System.Drawing.Bitmap. + ''' + Friend ReadOnly Property Analyze() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("Analyze", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property + ''' ''' Cerca una risorsa localizzata di tipo System.Drawing.Bitmap. ''' @@ -90,6 +100,16 @@ Namespace My.Resources End Get End Property + ''' + ''' Cerca una risorsa localizzata di tipo System.Drawing.Bitmap. + ''' + Friend ReadOnly Property GetDist() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("GetDist", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property + ''' ''' Cerca una risorsa localizzata di tipo System.Drawing.Bitmap. ''' diff --git a/My Project/Resources.resx b/My Project/Resources.resx index fda7313..36d0cd4 100644 --- a/My Project/Resources.resx +++ b/My Project/Resources.resx @@ -175,4 +175,10 @@ ..\Resources\New.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\GetDist.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Analyze.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Resources/Analyze.cur b/Resources/Analyze.cur new file mode 100644 index 0000000000000000000000000000000000000000..55f1c4c76d2ad042f534b848749e2f435e5f6647 GIT binary patch literal 326 zcmZvWF%H5o3`KupBt|yo4h)PH2WUHTq;Bzm)N3Je0Pey>rKsjRp%O^7_55u|u?<87 zG!1Z|w*fc;I1{!okU)3S5^IPQ$IZ-Y0*ny7A{N@OdVL}s2< zYwu5&h0AmsVV}ku+$PIu<@u98m1MHRo`_jLoAz(f{aswWE`5J<_@$7OamF@W F`~h`Lc_07) literal 0 HcmV?d00001 diff --git a/Resources/Analyze.png b/Resources/Analyze.png new file mode 100644 index 0000000000000000000000000000000000000000..3836f12a080f3a9bf5e0f88e3d11be3b7b0d3c81 GIT binary patch literal 270 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sDEfH31!Z9ZwB;9^e~#}Etuy_31Qm=$?kCeQOezigiG`>SVv zaIWk1UU`9C=*&AGpMW~TK;&zQkuex?L*<3p_=d$Dj7ERT)HV6LuUXJ+99`*C3O2WM3GY+0* zc;lmExWoMVMj&Otdmzh*Cv2NI=V6h;`)_~VkCwPz@$`qG>^6rI#>G1 N;OXk;vd$@?2>?v;XjK3J literal 0 HcmV?d00001 diff --git a/Resources/GetDist.cur b/Resources/GetDist.cur new file mode 100644 index 0000000000000000000000000000000000000000..540dd3ce3040786aa672c9803ff23cc4a5b900c5 GIT binary patch literal 326 zcmZvYF%H5o3`M^kBt|yoj*Ogu_7a>YK3Xrq%r&SKYQEb>RU>S@|C2bjq5uj(*8vyi zU4Scq8{rWKBFqR|bQPrq5$;aSltGZ*U+C)z9R|*lKe_dvWalx3JNJir?Wr^VIX~bBoNRcc literal 0 HcmV?d00001 diff --git a/Resources/GetDist.png b/Resources/GetDist.png new file mode 100644 index 0000000000000000000000000000000000000000..952dddf6beaad127b5a1936d71272070aab85b61 GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBufiR<}hF1enu-DVYF~q`u?!=3{4F()83!Qf~Ew-E}ulK-D z??JowiV1PeE2Ca`^IUDIo_^{%FKa^DCT&fB@lAVj+Wj8z9oUrM9K(2xL*NomL*%^L zxu3%qWy*ZftJ4=u3t^8Cvy _ Private Sub InitializeComponent() - components = New System.ComponentModel.Container() - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.components = New System.ComponentModel.Container() + Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components) + Me.cmdEndPoint = New System.Windows.Forms.ToolStripMenuItem() + Me.cmdMidPoint = New System.Windows.Forms.ToolStripMenuItem() + Me.cmdCenterPoint = New System.Windows.Forms.ToolStripMenuItem() + Me.cmdNearPoint = New System.Windows.Forms.ToolStripMenuItem() + Me.ContextMenuStrip1.SuspendLayout() + Me.SuspendLayout() + ' + 'ContextMenuStrip1 + ' + Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.cmdEndPoint, Me.cmdMidPoint, Me.cmdCenterPoint, Me.cmdNearPoint}) + Me.ContextMenuStrip1.Name = "ContextMenuStrip1" + Me.ContextMenuStrip1.ShowCheckMargin = True + Me.ContextMenuStrip1.ShowImageMargin = False + Me.ContextMenuStrip1.Size = New System.Drawing.Size(153, 114) + ' + 'cmdEndPoint + ' + Me.cmdEndPoint.Name = "cmdEndPoint" + Me.cmdEndPoint.Size = New System.Drawing.Size(152, 22) + Me.cmdEndPoint.Text = "End Point" + ' + 'cmdMidPoint + ' + Me.cmdMidPoint.Name = "cmdMidPoint" + Me.cmdMidPoint.Size = New System.Drawing.Size(152, 22) + Me.cmdMidPoint.Text = "MidPoint" + ' + 'cmdCenterPoint + ' + Me.cmdCenterPoint.Name = "cmdCenterPoint" + Me.cmdCenterPoint.Size = New System.Drawing.Size(152, 22) + Me.cmdCenterPoint.Text = "Center" + ' + 'cmdNearPoint + ' + Me.cmdNearPoint.Name = "cmdNearPoint" + Me.cmdNearPoint.Size = New System.Drawing.Size(152, 22) + Me.cmdNearPoint.Text = "Near Point" + ' + 'Scene + ' + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ContextMenuStrip = Me.ContextMenuStrip1 + Me.ContextMenuStrip1.ResumeLayout(False) + Me.ResumeLayout(False) End Sub + Friend WithEvents ContextMenuStrip1 As System.Windows.Forms.ContextMenuStrip + Friend WithEvents cmdEndPoint As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents cmdMidPoint As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents cmdCenterPoint As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents cmdNearPoint As System.Windows.Forms.ToolStripMenuItem End Class diff --git a/Scene.vb b/Scene.vb index fff9df9..be8a899 100644 --- a/Scene.vb +++ b/Scene.vb @@ -5,16 +5,25 @@ Imports EgtUILib.EgtInterface Public Class Scene + '---- Constants ------- + Public Const DIM_SEL As Integer = 13 + '---- Members --------- Private m_nGseContext As Integer Private m_nStatus As Integer + Private m_nOldStatus As Integer Private Enum ST As Integer NULL = 0 PAN = 1 ROT = 2 ZOOMWIN = 3 + ANALYZE = 4 + GETDIST = 5 + GETDIST2 = 6 End Enum + Private m_nSnapType As Integer Private m_PrevPoint As Point + Private m_ptPrev As Point3d Private m_nDefMatRed As Integer Private m_nDefMatGreen As Integer Private m_nDefMatBlue As Integer @@ -40,6 +49,8 @@ Public Class Scene SetStyle(ControlStyles.AllPaintingInWmPaint, True) m_nGseContext = 0 m_nStatus = ST.NULL + m_nOldStatus = ST.NULL + m_nSnapType = SP_END m_PrevPoint = Point.Empty m_nDefMatRed = 255 m_nDefMatGreen = 165 @@ -54,7 +65,7 @@ Public Class Scene m_nBackBotRed = 40 m_nBackBotGreen = 44 m_nBackBotBlue = 48 - Cursor = New Cursor(Me.GetType(), "Select.cur") + Cursor = Cursors.Default End Sub '---- Initials -------- @@ -118,8 +129,11 @@ Public Class Scene '---- Events ---------- Public Event OnMouseSelected(ByVal sender As Object, ByVal nId As Integer) + Public Event OnMouseAnalyzed(ByVal sender As Object, ByVal nId As Integer) Public Event OnMouseDownScene(ByVal sender As Object) Public Event OnCursorPos(ByVal sender As Object, ByVal sCursorPos As String) + Public Event OnShowDistance(ByVal sender As Object, ByVal sDistance As String) + Public Event OnCloseGetDist(ByVal sender As Object) Public Event OnNewProject(ByVal sender As Object) Public Event OnOpeningProject(ByVal sender As Object) Public Event OnOpenProject(ByVal sender As Object, ByVal sFile As String) @@ -140,15 +154,17 @@ Public Class Scene Protected Overrides Sub OnMouseDown(e As System.Windows.Forms.MouseEventArgs) If e.Button = Windows.Forms.MouseButtons.Left Then - If m_nStatus = ST.NULL Then - Cursor = New Cursor(Me.GetType(), "Select.cur") + If m_nStatus = ST.NULL Or m_nStatus = ST.ANALYZE Then + If m_nStatus = ST.NULL Then + Cursor = New Cursor(Me.GetType(), "Select.cur") + Else + Cursor = New Cursor(Me.GetType(), "Analyze.cur") + End If + Dim nId As Integer = GDB_ID_NULL Dim nSel As Integer - EgtSelect(m_nGseContext, e.Location, 13, 13, nSel) + EgtSelect(m_nGseContext, e.Location, DIM_SEL, DIM_SEL, nSel) If nSel = 1 Then - Dim nId = EgtGetFirstSelectedObj(m_nGseContext) - If nId <> GDB_ID_NULL Then - RaiseEvent OnMouseSelected(Me, nId) - End If + nId = EgtGetFirstSelectedObj(m_nGseContext) ElseIf nSel > 1 Then Dim MselDlg As New SelectMulti MselDlg.SetContext(m_nGseContext) @@ -157,21 +173,59 @@ Public Class Scene ptScreen.Offset(10, 0) MselDlg.Location = ptScreen If MselDlg.ShowDialog() = System.Windows.Forms.DialogResult.OK Then - Dim nId = MselDlg.GetId() - If nId <> GDB_ID_NULL Then - RaiseEvent OnMouseSelected(Me, nId) - End If + nId = MselDlg.GetId() End If End If + If nId <> GDB_ID_NULL Then + If m_nStatus = ST.NULL Then + RaiseEvent OnMouseSelected(Me, nId) + Else + RaiseEvent OnMouseAnalyzed(Me, nId) + End If + End If + ElseIf m_nStatus = ST.GETDIST Then + If EgtGetSelectedSnapPoint(m_nGseContext, m_nSnapType, e.Location.X, e.Location.Y, DIM_SEL, DIM_SEL, m_ptPrev) Then + ' salvo il punto di riferimento + Dim ptWin As Point3d + EgtProjectPoint(m_nGseContext, m_ptPrev, ptWin) + m_PrevPoint = New Point(ptWin.x, ptWin.y) + m_nStatus = ST.GETDIST2 + End If + ElseIf m_nStatus = ST.GETDIST2 Then + Dim ptSel As Point3d + If EgtGetSelectedSnapPoint(m_nGseContext, m_nSnapType, e.Location.X, e.Location.Y, DIM_SEL, DIM_SEL, ptSel) Then + ' disegno la linea (coordinate geo globali) + EgtSetGeoLine(m_nGseContext, m_ptPrev, ptSel) + ' calcolo la distanza e il delta e li visualizzo + Dim dX As Double = ptSel.x - m_ptPrev.x + Dim dY As Double = ptSel.y - m_ptPrev.y + Dim dZ As Double = ptSel.z - m_ptPrev.z + Dim dDist As Double = Sqrt(dX * dX + dY * dY + dZ * dZ) + Dim sOut As New System.Text.StringBuilder + sOut.Append("Dist=") + sOut.Append(dDist.ToString("F4", CultureInfo.InvariantCulture)) + sOut.Append(" dX=") + sOut.Append(dX.ToString("F4", CultureInfo.InvariantCulture)) + sOut.Append(" dY=") + sOut.Append(dY.ToString("F4", CultureInfo.InvariantCulture)) + sOut.Append(" dZ=") + sOut.Append(dZ.ToString("F4", CultureInfo.InvariantCulture)) + ' lancio l'evento per visualizzare la distanza + RaiseEvent OnShowDistance(Me, sOut.ToString()) + m_nStatus = ST.NULL + End If End If ElseIf e.Button = Windows.Forms.MouseButtons.Middle Then If (Control.ModifierKeys And Keys.Shift) = Keys.Shift Then + m_nOldStatus = IIf(m_nStatus = ST.GETDIST2, ST.GETDIST2, ST.NULL) m_nStatus = ST.ZOOMWIN Cursor = New Cursor(Me.GetType(), "ZoomWin.cur") ElseIf (Control.ModifierKeys And Keys.Control) = Keys.Control Then + m_nOldStatus = IIf(m_nStatus = ST.GETDIST2, ST.GETDIST2, ST.NULL) m_nStatus = ST.ROT Cursor = New Cursor(Me.GetType(), "Rotate.cur") Else + m_nOldStatus = IIf(m_nStatus = ST.GETDIST2, ST.GETDIST2, ST.NULL) m_nStatus = ST.PAN Cursor = New Cursor(Me.GetType(), "Pan.cur") End If @@ -184,15 +238,40 @@ Public Class Scene End Sub Protected Overrides Sub OnMouseUp(e As System.Windows.Forms.MouseEventArgs) + ' rilascio tasto medio (rotella) If e.Button = Windows.Forms.MouseButtons.Middle Then If m_nStatus = ST.ZOOMWIN Then EgtResetWinRect(m_nGseContext, False) EgtZoomWin(m_nGseContext, m_PrevPoint, e.Location, True) End If - If m_nStatus <> ST.NULL Then + ' eventuale ripristino vecchio stato + If m_nOldStatus = ST.GETDIST2 Then + m_nStatus = ST.GETDIST2 + Cursor = New Cursor(Me.GetType(), "GetDist.cur") + ' reset dello stato se non NULL + ElseIf m_nStatus <> ST.NULL Then m_nStatus = ST.NULL Cursor = New Cursor(Me.GetType(), "Select.cur") End If + ' rilascio tasto destro + ElseIf e.Button = Windows.Forms.MouseButtons.Right Then + If m_nStatus = ST.GETDIST Or m_nStatus = ST.GETDIST2 Then + ContextMenuStrip1.Visible = True + For Each i As ToolStripMenuItem In ContextMenuStrip1.Items + If i.Name = "cmdEndPoint" Then + i.Checked = (m_nSnapType = SP_END) + ElseIf i.Name = "cmdMidPoint" Then + i.Checked = (m_nSnapType = SP_MID) + ElseIf i.Name = "cmdCenterPoint" Then + i.Checked = (m_nSnapType = SP_CENTER) + ElseIf i.Name = "cmdNearPoint" Then + i.Checked = (m_nSnapType = SP_NEAR) + End If + Next + Else + ContextMenuStrip1.Visible = False + End If + ' tutti gli altri casi Else MyBase.OnMouseUp(e) End If @@ -201,7 +280,7 @@ Public Class Scene Protected Overrides Sub OnMouseMove(e As System.Windows.Forms.MouseEventArgs) 'Visualizzo le coordinate del mouse ShowCursorPos(e.Location) - 'Secondo lo stato... + 'In base allo stato... If e.Button = Windows.Forms.MouseButtons.Middle Then If m_nStatus = ST.ZOOMWIN Then Cursor = New Cursor(Me.GetType(), "ZoomWin.cur") @@ -219,6 +298,15 @@ Public Class Scene m_nStatus = ST.NULL Cursor = New Cursor(Me.GetType(), "Select.cur") End If + ElseIf m_nStatus = ST.GETDIST Then + Cursor = New Cursor(Me.GetType(), "GetDist.cur") + ElseIf m_nStatus = ST.GETDIST2 Then + Cursor = New Cursor(Me.GetType(), "GetDist.cur") + Dim ptP As Point3d + EgtUnProjectPoint(m_nGseContext, e.Location, ptP) + EgtSetGeoLine(m_nGseContext, m_ptPrev, ptP) + ElseIf m_nStatus = ST.ANALYZE Then + Cursor = New Cursor(Me.GetType(), "Analyze.cur") Else MyBase.OnMouseMove(e) End If @@ -228,6 +316,11 @@ Public Class Scene End Sub Protected Overrides Sub OnMouseWheel(e As System.Windows.Forms.MouseEventArgs) + ' devo essere nello stato NULL o GETDIST + If m_nStatus <> ST.NULL And m_nStatus <> ST.GETDIST And m_nStatus <> ST.GETDIST2 Then + Return + End If + ' trascuro rotazioni molto piccole If Abs(e.Delta) < 30 Then Return End If @@ -273,7 +366,20 @@ Public Class Scene RaiseEvent OnCursorPos(Me, sCursorPos.ToString) End Sub - '---- Main Buttons ---- + Private Sub ContextMenuStrip1_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) Handles ContextMenuStrip1.ItemClicked + + If e.ClickedItem.Name = "cmdEndPoint" Then + m_nSnapType = SP_END + ElseIf e.ClickedItem.Name = "cmdMidPoint" Then + m_nSnapType = SP_MID + ElseIf e.ClickedItem.Name = "cmdCenterPoint" Then + m_nSnapType = SP_CENTER + ElseIf e.ClickedItem.Name = "cmdNearPoint" Then + m_nSnapType = SP_NEAR + End If + End Sub + + '---- Main Buttons ---- Public Function NewProject() As Boolean Dim bOk As Boolean = EgtNewFile(m_nGseContext) EgtZoom(m_nGseContext, ZM_ALL) @@ -457,6 +563,34 @@ Public Class Scene Return bOk End Function + '---- Distance Operations ------------- + Public Sub SetStatusGetDistance() + m_nStatus = ST.GETDIST + End Sub + + Public Sub ResetStatusGetDistance() + If m_nStatus = ST.GETDIST Or m_nStatus = ST.GETDIST2 Then + m_nStatus = ST.NULL + End If + End Sub + + Public Sub CloseGetDistance() + ResetStatusGetDistance() + EgtResetGeoLine(GetCtx()) + RaiseEvent OnCloseGetDist(Me) + End Sub + + '---- Analyze Operations ------------- + Public Sub SetStatusAnalyze() + m_nStatus = ST.ANALYZE + End Sub + + Public Sub ResetStatusAnalyze() + If m_nStatus = ST.ANALYZE Then + m_nStatus = ST.NULL + End If + End Sub + '---- Zoom Buttons ---- Public Sub ZoomAll() EgtZoom(m_nGseContext, ZM_ALL) diff --git a/SelectMulti.Designer.vb b/SelectMulti.Designer.vb index 9b7b9d3..1420005 100644 --- a/SelectMulti.Designer.vb +++ b/SelectMulti.Designer.vb @@ -28,36 +28,42 @@ Partial Class SelectMulti ' 'ListBox1 ' - Me.ListBox1.Dock = System.Windows.Forms.DockStyle.Top + Me.ListBox1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.ListBox1.FormattingEnabled = True Me.ListBox1.Location = New System.Drawing.Point(0, 0) + Me.ListBox1.Margin = New System.Windows.Forms.Padding(0) Me.ListBox1.Name = "ListBox1" - Me.ListBox1.Size = New System.Drawing.Size(88, 134) + Me.ListBox1.Size = New System.Drawing.Size(98, 108) Me.ListBox1.TabIndex = 1 ' 'OK_Button ' - Me.OK_Button.Location = New System.Drawing.Point(9, 141) + Me.OK_Button.Location = New System.Drawing.Point(23, 109) Me.OK_Button.Name = "OK_Button" - Me.OK_Button.Size = New System.Drawing.Size(72, 20) + Me.OK_Button.Size = New System.Drawing.Size(52, 20) Me.OK_Button.TabIndex = 2 - Me.OK_Button.Text = "Ok" + Me.OK_Button.Text = "OK" Me.OK_Button.UseVisualStyleBackColor = True ' 'SelectMulti ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(88, 165) + Me.AcceptButton = Me.OK_Button + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None + Me.ClientSize = New System.Drawing.Size(104, 131) + Me.ControlBox = False Me.Controls.Add(Me.OK_Button) Me.Controls.Add(Me.ListBox1) - Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow + Me.KeyPreview = True Me.MaximizeBox = False - Me.MaximumSize = New System.Drawing.Size(94, 194) + Me.MaximumSize = New System.Drawing.Size(110, 160) Me.MinimizeBox = False - Me.MinimumSize = New System.Drawing.Size(94, 194) + Me.MinimumSize = New System.Drawing.Size(110, 160) Me.Name = "SelectMulti" + Me.ShowIcon = False Me.ShowInTaskbar = False + Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent Me.Text = "MultiSel" Me.ResumeLayout(False) diff --git a/SelectMulti.vb b/SelectMulti.vb index 100e8b0..59eed71 100644 --- a/SelectMulti.vb +++ b/SelectMulti.vb @@ -1,6 +1,7 @@ Imports System.Windows.Forms Imports EgtUILib.EgtInterface + Public Class SelectMulti Dim m_nGseContext As Integer @@ -8,6 +9,7 @@ Public Class SelectMulti Private Sub SelectMulti_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load ListBox1.BeginUpdate() + 'Inserisco le entità nel mirino Dim nId = EgtGetFirstSelectedObj(m_nGseContext) While nId <> GDB_ID_NULL Dim sTitle As String = String.Empty @@ -16,9 +18,13 @@ Public Class SelectMulti sTitle += "*" End If sTitle += " (" & nId & ")" - ListBox1.Items.Add(sTitle) + Dim smItem As New SelMulItem(sTitle, nId) + ListBox1.Items.Add(smItem) nId = EgtGetNextSelectedObj(m_nGseContext) End While + 'Inserisco None per non selezionare alcunchè + Dim smNone As New SelMulItem("None", GDB_ID_NULL) + ListBox1.Items.Add(smNone) ListBox1.EndUpdate() m_nCurrEnt = GDB_ID_NULL ListBox1.SelectedIndex = 0 @@ -37,19 +43,43 @@ Public Class SelectMulti Return m_nCurrEnt End Function - Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click + Private Sub OK_Click(sender As System.Object, e As System.EventArgs) Handles OK_Button.Click Me.DialogResult = System.Windows.Forms.DialogResult.OK Me.Close() End Sub + Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick + Me.DialogResult = System.Windows.Forms.DialogResult.OK + Me.Close() + End Sub + + Private Sub ListBox1_KeyDown(ByVal sender As System.Object, ByVal e As KeyEventArgs) Handles Me.KeyDown + If e.KeyData = Keys.Escape Then + Me.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.Close() + End If + End Sub + Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged - Dim curItem As String = ListBox1.SelectedItem.ToString() - Dim nIni As Integer = curItem.LastIndexOf("(") - Dim nFin As Integer = curItem.LastIndexOf(")") - Dim sNbr As String = curItem.Substring(nIni + 1, nFin - nIni - 1) EgtResetMark(m_nGseContext, m_nCurrEnt) - m_nCurrEnt = CInt(sNbr) + m_nCurrEnt = ListBox1.SelectedItem.m_nId EgtSetMark(m_nGseContext, m_nCurrEnt) EgtDraw(m_nGseContext) End Sub + End Class + +Public Class SelMulItem + Public m_sTitle As String + Public m_nId As Integer + + Public Sub New(ByVal sTitle As String, ByVal nId As Integer) + Me.m_sTitle = sTitle + Me.m_nId = nId + End Sub + + Public Overrides Function ToString() As String + Return m_sTitle + End Function + +End Class \ No newline at end of file diff --git a/tsExec.Designer.vb b/tsExec.Designer.vb new file mode 100644 index 0000000..dcefd7f --- /dev/null +++ b/tsExec.Designer.vb @@ -0,0 +1,29 @@ + _ +Partial Class tsExec + Inherits System.Windows.Forms.ToolStrip + + 'Control esegue l'override del metodo Dispose per pulire l'elenco dei componenti. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Richiesto da Progettazione controlli + Private components As System.ComponentModel.IContainer + + ' NOTA: la procedura che segue è richiesta da Progettazione componenti + ' Può essere modificata in Progettazione componenti. Non modificarla + ' nell'editor del codice. + _ + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + End Sub + +End Class + diff --git a/tsExec.vb b/tsExec.vb new file mode 100644 index 0000000..d014162 --- /dev/null +++ b/tsExec.vb @@ -0,0 +1,48 @@ +Public Class tsExec + + Private m_scene As Scene + + 'Create button + Dim btnExec As New ToolStripButton + + Sub New() + + MyBase.New() + Me.Anchor = AnchorStyles.None + Me.Dock = DockStyle.None + ' Chiamata richiesta dalla finestra di progettazione. + InitializeComponent() + AddButtons() + ' Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent(). + + End Sub + + Public Sub SetScene(ByRef scene As Scene) + m_scene = scene + End Sub + + Public Sub AddButtons() + With btnExec + 'Set properties + .Name = "btnExec" + .AutoToolTip = True + .DisplayStyle = ToolStripItemDisplayStyle.Image + .Image = EgtUILib.My.Resources.Resources.Exec + .Text = "" + .ToolTipText = "Exec" + End With + + 'Create a Handle to a Click Event + AddHandler btnExec.Click, AddressOf btnExec_Click + + 'Add to toolstrip + MyClass.Items.Add(btnExec) + + End Sub + + 'The Click Events + Private Sub btnExec_Click(sender As Object, e As System.EventArgs) + m_scene.Exec() + End Sub + +End Class diff --git a/tsInfo.Designer.vb b/tsInfo.Designer.vb new file mode 100644 index 0000000..c61d743 --- /dev/null +++ b/tsInfo.Designer.vb @@ -0,0 +1,29 @@ + _ +Partial Class tsInfo + Inherits System.Windows.Forms.ToolStrip + + 'Control esegue l'override del metodo Dispose per pulire l'elenco dei componenti. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Richiesto da Progettazione controlli + Private components As System.ComponentModel.IContainer + + ' NOTA: la procedura che segue è richiesta da Progettazione componenti + ' Può essere modificata in Progettazione componenti. Non modificarla + ' nell'editor del codice. + _ + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + End Sub + +End Class + diff --git a/tsInfo.vb b/tsInfo.vb new file mode 100644 index 0000000..f532de5 --- /dev/null +++ b/tsInfo.vb @@ -0,0 +1,78 @@ +Imports EgtUILib.EgtInterface + +Public Class tsInfo + + Private m_scene As Scene + + 'Create button + Public btnGetDist As New ToolStripButton + Public btnAnalyze As New ToolStripButton + + Sub New() + + MyBase.New() + Me.Anchor = AnchorStyles.None + Me.Dock = DockStyle.None + ' Chiamata richiesta dalla finestra di progettazione. + InitializeComponent() + AddButtons() + ' Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent(). + + End Sub + + Public Sub SetScene(ByRef scene As Scene) + m_scene = scene + End Sub + + Public Sub AddButtons() + With btnGetDist + 'Set properties + .Name = "btnGetDist" + .AutoToolTip = True + .DisplayStyle = ToolStripItemDisplayStyle.Image + .Image = EgtUILib.My.Resources.Resources.GetDist + .Text = "" + .ToolTipText = "GetDist" + End With + + With btnAnalyze + 'Set properties + .Name = "btnAnalyze" + .AutoToolTip = True + .DisplayStyle = ToolStripItemDisplayStyle.Image + .Image = EgtUILib.My.Resources.Resources.Analyze + .Text = "" + .ToolTipText = "Analyze" + End With + + 'Create a Handle to a Click Event + AddHandler btnGetDist.Click, AddressOf btnGetDist_Click + AddHandler btnAnalyze.Click, AddressOf btnAnalyze_Click + + 'Add to toolstrip + MyClass.Items.Add(btnGetDist) + MyClass.Items.Add(btnAnalyze) + + End Sub + + 'The Click Events + Private Sub btnGetDist_Click(sender As Object, e As System.EventArgs) + If btnGetDist.Checked Then + btnGetDist.Checked = False + m_scene.CloseGetDistance() + Else + btnGetDist.Checked = True + m_scene.SetStatusGetDistance() + End If + End Sub + + Private Sub btnAnalyze_Click(sender As Object, e As System.EventArgs) + If btnAnalyze.Checked Then + btnAnalyze.Checked = False + m_scene.ResetStatusAnalyze() + Else + btnAnalyze.Checked = True + m_scene.SetStatusAnalyze() + End If + End Sub +End Class diff --git a/tsMain.vb b/tsMain.vb index 3c5f36b..671044c 100644 --- a/tsMain.vb +++ b/tsMain.vb @@ -8,7 +8,6 @@ Dim btnSave As New ToolStripButton Dim btnImport As New ToolStripButton Dim btnExport As New ToolStripButton - Dim btnExec As New ToolStripButton Sub New() @@ -78,23 +77,12 @@ .ToolTipText = "Export" End With - With btnExec - 'Set properties - .Name = "btnExec" - .AutoToolTip = True - .DisplayStyle = ToolStripItemDisplayStyle.Image - .Image = EgtUILib.My.Resources.Resources.Exec - .Text = "" - .ToolTipText = "Exec" - End With - 'Create a Handle to a Click Event AddHandler btnNew.Click, AddressOf btnNew_Click AddHandler btnOpen.Click, AddressOf btnOpen_Click AddHandler btnSave.Click, AddressOf btnSave_Click AddHandler btnImport.Click, AddressOf btnImport_Click AddHandler btnExport.Click, AddressOf btnExport_Click - AddHandler btnExec.Click, AddressOf btnExec_Click 'Add to toolstrip MyClass.Items.Add(btnNew) @@ -102,7 +90,6 @@ MyClass.Items.Add(btnSave) MyClass.Items.Add(btnImport) MyClass.Items.Add(btnExport) - MyClass.Items.Add(btnExec) End Sub @@ -127,8 +114,4 @@ m_scene.ExportProject() End Sub - Private Sub btnExec_Click(sender As Object, e As System.EventArgs) - m_scene.Exec() - End Sub - End Class diff --git a/tsRendering.vb b/tsRendering.vb index 3278f4c..043266c 100644 --- a/tsRendering.vb +++ b/tsRendering.vb @@ -5,9 +5,9 @@ Public Class tsRendering Private m_scene As Scene 'Create buttons - Dim btnWireframe As New ToolStripButton - Dim btnHiddenLine As New ToolStripButton - Dim btnShading As New ToolStripButton + Public btnWireframe As New ToolStripButton + Public btnHiddenLine As New ToolStripButton + Public btnShading As New ToolStripButton Sub New() @@ -71,6 +71,7 @@ Public Class tsRendering 'The Click Events Private Sub btnWireframe_Click(sender As Object, e As System.EventArgs) + btnWireframe.Checked = True btnHiddenLine.Checked = False btnShading.Checked = False m_scene.WireFrame() @@ -78,6 +79,7 @@ Public Class tsRendering Private Sub btnHiddenLine_Click(sender As Object, e As System.EventArgs) btnWireframe.Checked = False + btnHiddenLine.Checked = True btnShading.Checked = False m_scene.HiddenLine() End Sub @@ -85,6 +87,7 @@ Public Class tsRendering Private Sub btnShading_Click(sender As Object, e As System.EventArgs) btnWireframe.Checked = False btnHiddenLine.Checked = False + btnShading.Checked = True m_scene.Shading() End Sub