From b0ec70e41b4bead341ebf2332f28acfb07610e38 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 15 Dec 2025 16:55:10 +0100 Subject: [PATCH] EgtUILib 2.7l2 : - aggiunta gestione selezione per colore. --- Controller.vb | 34 ++++++++++++++++++++++++++++++++++ EgtInterface.vb | 6 ++++++ My Project/AssemblyInfo.vb | 4 ++-- Scene.Designer.vb | 13 ++++++++++--- Scene.vb | 21 ++++++++++++++++----- 5 files changed, 68 insertions(+), 10 deletions(-) diff --git a/Controller.vb b/Controller.vb index 62c2d62..0321127 100644 --- a/Controller.vb +++ b/Controller.vb @@ -846,6 +846,40 @@ Public Class Controller End If End Sub + Public Sub MouseSelectedColor(nId As Integer) + ' recupero stato e colore + Dim nStat As Integer = GDB_ST.ON_ + EgtGetStatus(nId, nStat) + Dim colRef As Color3d + EgtGetCalcColor( nId, colRef) + ' eseguo selezione o deselezione ed aggiorno + EnableCommandLog() + Dim nPartId As Integer = EgtGetFirstPart( True) + While nPartId <> GDB_ID.NULL + Dim nLayerId As Integer = EgtGetFirstLayer( nPartId, True) + While nLayerId <> GDB_ID.NULL + Dim nEntId As Integer = EgtGetFirstInGroup( nLayerId) + While nEntId <> GDB_ID.NULL + Dim nEntStat As GDB_ST = GDB_ST.ON_ + Dim colEnt As Color3d + If EgtGetCalcStatus( nEntId, nEntStat) AndAlso nEntStat <> GDB_ST.OFF AndAlso + EgtGetCalcColor( nEntId, colEnt) AndAlso Color3d.Similar( colEnt, colRef, 10) Then + If nStat <> GDB_ST.SEL Then + EgtSelectObj(nEntId) + Else + EgtDeselectObj(nEntId) + End If + End If + nEntId = EgtGetNext( nEntId) + End While + nLayerId = EgtGetNextLayer( nLayerId, True) + End While + nPartId = EgtGetNextPart( nPartId, True) + End While + DisableCommandLog() + EgtDraw() + End Sub + Public Sub MouseSelectedPart(nId As Integer) ' recupero il pezzo Dim nPartId = EgtGetParent(EgtGetParent(nId)) diff --git a/EgtInterface.vb b/EgtInterface.vb index 0976849..2946aca 100644 --- a/EgtInterface.vb +++ b/EgtInterface.vb @@ -977,6 +977,12 @@ Structure Color3d If nVal > nMax Then Return nMax Return nVal End Function + ' Conronto di colori con tolleranza + Shared Function Similar( ByRef colOne As Color3d, ByRef colTwo As Color3d, nTol As Integer) As Boolean + return Math.Abs( colOne.R - colTwo.R) < nTol AndAlso + Math.Abs( colOne.G - colTwo.G) < nTol AndAlso + Math.Abs( colOne.B - colTwo.B) < nTol + End Function End Structure Structure FlagPar diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index c8377a1..3359765 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -35,5 +35,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/Scene.Designer.vb b/Scene.Designer.vb index 761c818..72e1422 100644 --- a/Scene.Designer.vb +++ b/Scene.Designer.vb @@ -29,6 +29,7 @@ Partial Class Scene Me.cmdDeselectAll = New System.Windows.Forms.ToolStripMenuItem() Me.sepSel1 = New System.Windows.Forms.ToolStripSeparator() Me.cmdWinSelect = New System.Windows.Forms.ToolStripMenuItem() + Me.cmdColorSelect = New System.Windows.Forms.ToolStripMenuItem() Me.cmdSelectPart = New System.Windows.Forms.ToolStripMenuItem() Me.cmdSelectLayer = New System.Windows.Forms.ToolStripMenuItem() Me.cmdSelectPath = New System.Windows.Forms.ToolStripMenuItem() @@ -56,12 +57,12 @@ Partial Class Scene ' 'MenuScene ' - Me.MenuScene.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.cmdSelectAllVisible, Me.cmdSelectAll, Me.cmdDeselectAll, Me.sepSel1, Me.cmdWinSelect, Me.cmdSelectPart, Me.cmdSelectLayer, Me.cmdSelectPath, Me.cmdSelectPathAuto, Me.cmdSelectEntity, Me.cmdRestartDrag, Me.cmdSketchPoint, Me.cmdGridPoint, Me.cmdEndPoint, Me.cmdMidPoint, Me.cmdCenterPoint, Me.cmdCentroid, Me.cmdNearPoint, Me.cmdIntersectionPoint, Me.cmdTangentPoint, Me.cmdPerpendicularPoint, Me.cmdMinDistPoint, Me.sepSelPnt1, Me.cmdExcludeSurfFromSel, Me.cmdExcludeSurfFromSnap, Me.sepSelPnt2, Me.cmdStopDrag}) + Me.MenuScene.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.cmdSelectAllVisible, Me.cmdSelectAll, Me.cmdDeselectAll, Me.sepSel1, Me.cmdWinSelect, Me.cmdSelectPart, Me.cmdSelectLayer, Me.cmdSelectPath, Me.cmdSelectPathAuto, Me.cmdColorSelect, Me.cmdSelectEntity, Me.cmdRestartDrag, Me.cmdSketchPoint, Me.cmdGridPoint, Me.cmdEndPoint, Me.cmdMidPoint, Me.cmdCenterPoint, Me.cmdCentroid, Me.cmdNearPoint, Me.cmdIntersectionPoint, Me.cmdTangentPoint, Me.cmdPerpendicularPoint, Me.cmdMinDistPoint, Me.sepSelPnt1, Me.cmdExcludeSurfFromSel, Me.cmdExcludeSurfFromSnap, Me.sepSelPnt2, Me.cmdStopDrag}) Me.MenuScene.Name = "ContextMenuStrip1" Me.MenuScene.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional Me.MenuScene.ShowCheckMargin = true Me.MenuScene.ShowImageMargin = false - Me.MenuScene.Size = New System.Drawing.Size(193, 572) + Me.MenuScene.Size = New System.Drawing.Size(193, 594) ' 'cmdSelectAllVisible ' @@ -94,6 +95,12 @@ Partial Class Scene Me.cmdWinSelect.Size = New System.Drawing.Size(192, 22) Me.cmdWinSelect.Text = "Select Window" ' + 'cmdColorSelect + ' + Me.cmdColorSelect.Name = "cmdColorSelect" + Me.cmdColorSelect.Size = New System.Drawing.Size(192, 22) + Me.cmdColorSelect.Text = "Select Color" + ' 'cmdSelectPart ' Me.cmdSelectPart.Name = "cmdSelectPart" @@ -278,5 +285,5 @@ End Sub Friend WithEvents cmdExcludeSurfFromSel As System.Windows.Forms.ToolStripMenuItem Friend WithEvents cmdSelectEntity As System.Windows.Forms.ToolStripMenuItem Friend WithEvents cmdSelectAllVisible As System.Windows.Forms.ToolStripMenuItem - + Friend WithEvents cmdColorSelect As ToolStripMenuItem End Class diff --git a/Scene.vb b/Scene.vb index ceb40b5..085f63d 100644 --- a/Scene.vb +++ b/Scene.vb @@ -41,6 +41,7 @@ Public Class Scene GETDIST2 SELPOINT SELPOINTZ + SELCOLOR End Enum Private m_nSnapType As SP = SP.PT_GRID ' tipo di snap in selezione punto Private m_bAlsoSelDir As Boolean = False ' abilita anche selezione direzione quando selezione punto @@ -266,6 +267,7 @@ Public Class Scene Public Event OnMouseSelectedAll(sender As Object, bOnlyVisible As Boolean) Public Event OnMouseDeselectedAll(sender As Object) Public Event OnMouseSelectedObj(sender As Object, nId As Integer, bLast As Boolean) + Public Event OnMouseSelectedColor(sender As Object, nId As Integer) Public Event OnMouseSelectedPart(sender As Object, nId As Integer) Public Event OnMouseSelectedLayer(sender As Object, nId As Integer) Public Event OnMouseSelectedPath(sender As Object, nId As Integer, bHaltOnFork As Boolean) @@ -344,8 +346,8 @@ Public Class Scene End If m_nStatus = ST.SEL End If - ' se stato SEL, SELPART, SELLAYER - ElseIf m_nStatus = ST.SEL Or m_nStatus = ST.SELPART Or m_nStatus = ST.SELLAYER Then + ' se stato SEL, SELCOLOR, SELPART, SELLAYER + ElseIf m_nStatus = ST.SEL Or m_nStatus = ST.SELCOLOR Or m_nStatus = ST.SELPART Or m_nStatus = ST.SELLAYER Then ' SEL + Ctrl + Alt --> SELLAYER If m_nStatus = ST.SEL And (ModifierKeys And Keys.Control) = Keys.Control And (ModifierKeys And Keys.Alt) = Keys.Alt Then m_nStatus = ST.SELLAYER ' SEL + Alt --> SELPART @@ -357,6 +359,8 @@ Public Class Scene Select Case m_nStatus Case ST.SEL RaiseEvent OnMouseSelectedObj(Me, nId, True) + Case ST.SELCOLOR + RaiseEvent OnMouseSelectedColor(Me, nId) Case ST.SELPART RaiseEvent OnMouseSelectedPart(Me, nId) Case ST.SELLAYER @@ -946,7 +950,8 @@ Public Class Scene Private Sub PrepareMenuScene() ' per selezione oggetti - If m_nStatus = ST.SEL Or m_nStatus = ST.WINSEL Or m_nStatus = ST.SELPART Or m_nStatus = ST.SELLAYER Or m_nStatus = ST.SELPATH Or m_nStatus = ST.SELPATHAUTO Then + If m_nStatus = ST.SEL Or m_nStatus = ST.WINSEL Or m_nStatus = ST.SELCOLOR Or + m_nStatus = ST.SELPART Or m_nStatus = ST.SELLAYER Or m_nStatus = ST.SELPATH Or m_nStatus = ST.SELPATHAUTO Then For Each i As ToolStripItem In MenuScene.Items Select Case i.Name Case "cmdSelectAllVisible" @@ -964,6 +969,10 @@ Public Class Scene i.Text = EgtMsg(1005) ' Select Window i.Visible = True DirectCast(i, ToolStripMenuItem).Checked = (m_nStatus = ST.WINSEL) + Case "cmdColorSelect" + i.Text = EgtMsg(1006) ' Select Color + i.Visible = True + DirectCast(i, ToolStripMenuItem).Checked = (m_nStatus = ST.SELCOLOR) Case "cmdSelectPart" i.Text = EgtMsg(1007) ' Select Part i.Visible = True @@ -1104,6 +1113,8 @@ Public Class Scene RaiseEvent OnMouseDeselectedAll(Me) ElseIf e.ClickedItem.Name = "cmdWinSelect" Then m_nStatus = ST.WINSEL + ElseIf e.ClickedItem.Name = "cmdColorSelect" Then + m_nStatus = ST.SELCOLOR ElseIf e.ClickedItem.Name = "cmdSelectPart" Then m_nStatus = ST.SELPART ElseIf e.ClickedItem.Name = "cmdSelectLayer" Then @@ -1244,7 +1255,7 @@ Public Class Scene Private Function IsRestorableCurrStatus() As Boolean Select Case m_nStatus Case ST.NULL, ST.SEL, ST.ANALYZE, ST.SELPART, ST.SELLAYER, - ST.SELPATH, ST.SELPATHAUTO, ST.GETDIST, ST.GETDIST2, ST.SELPOINT, ST.SELPOINTZ + ST.SELPATH, ST.SELPATHAUTO, ST.GETDIST, ST.GETDIST2, ST.SELPOINT, ST.SELPOINTZ, ST.SELCOLOR Return True Case Else Return False @@ -1264,7 +1275,7 @@ Public Class Scene Cursor = Cursors.Default Return True ElseIf m_nOldStatus = ST.SEL Or m_nOldStatus = ST.SELPART Or m_nOldStatus = ST.SELLAYER Or - m_nOldStatus = ST.SELPATH Or m_nOldStatus = ST.SELPATHAUTO Then + m_nOldStatus = ST.SELPATH Or m_nOldStatus = ST.SELPATHAUTO Or m_nOldStatus = ST.SELCOLOR Then m_nStatus = m_nOldStatus Cursor = New Cursor(Me.GetType(), "Select.cur") Return True