← Back to team overview

kicad-developers team mailing list archive

Re: [FEATURE] Partial selection in pcbnew

 

Three further patch files attached:

- Different color select box based on direction
- Fixed HitTest for EDA_TEXT
- Control modifier unselects anything in rectangle.

The major piece of feedback I need right now is how to perfect the
behaviour of the tool in PCBNEW and MODEDIT:

a) PCBNEW

Selecting part of a MODULE (right to left) will select both the entire
module and also any parts of the module that you touched (lines, pads,
etc). Then, when you move the module, the doubly-selected items are moved
twice! It is hard to describe properly but if you try this you will see
what I mean.

b) MODEDIT

Selecting any item in the footprint selects the entire footprint, which is
highly undesirable. In this case I think the best approach is to filter the
MODULE from the selection entirely. But I am not sure how to do this.

Feedback welcome :)

Regards,
Oliver

On Tue, May 2, 2017 at 5:25 PM, Oliver Walters <
oliver.henry.walters@xxxxxxxxx> wrote:

> I have attached a patch-set that implements "partial selection" of objects
> when the selection box is dragged right-to-left.
>
> L -> R = Objects must be completely enclosed to be selected
> R -> L = Objects that intersect the selection rectangle will be selected.
>
> To achieve this I had to fix a lot of the HitTest implementations as this
> was broken for most shapes, under a variety of edge cases (some HitTest
> code did not work at all).
>
> There are two issues I see as outstanding, and am unsure how to proceed:
>
> 1. When editing a PCB, selecting part of a footprint (e.g. a line of the
> courtyard) selects both that line and the entire footprint. This causes
> some issues when the footprint is dragged around the PCB. I believe that
> the line should not be selected separately, but the entire footprint should.
>
> 2. The inverse of 1. In the footprint editor, selecting a single graphical
> item selects the entire footprint. Somehow I would like to filter the
> selection such that individual items are selected but NOT the entire
> footprint.
>
> Feedback please! :)
>
> I have fixed hit testing (both for wxPoint and EDA_RECT comparison) for:
>
> - Pads (all shapes)
> - Lines
> - Circles
> - Arcs
> - Text items
> - Zones
> - Footprints
>
> Cheers,
> Oliver
>
>
>
From fd1e30e1afa92f83b59ee169fddf2195c5788454 Mon Sep 17 00:00:00 2001
From: Oliver Walters <oliver.henry.walters@xxxxxxxxx>
Date: Fri, 5 May 2017 15:04:29 +1000
Subject: [PATCH 13/15] Alter selection area colours based on selection mode

- Left to Right is slightly blue (as current)
- Right to left is slightly green
---
 common/preview_items/selection_area.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/common/preview_items/selection_area.cpp b/common/preview_items/selection_area.cpp
index f66cb1d..a1a4813 100644
--- a/common/preview_items/selection_area.cpp
+++ b/common/preview_items/selection_area.cpp
@@ -29,6 +29,10 @@
 
 using namespace KIGFX::PREVIEW;
 
+// Selection area colours
+const COLOR4D SELECT_COLOR_L2R( 0.3, 0.3, 0.5, 0.3 );  // Slight blue
+const COLOR4D SELECT_COLOR_R2L( 0.3, 0.5, 0.3, 0.3 );  // Slight green
+
 
 SELECTION_AREA::SELECTION_AREA()
 {
@@ -50,6 +54,9 @@ const BOX2I SELECTION_AREA::ViewBBox() const
 
 void SELECTION_AREA::drawPreviewShape( KIGFX::GAL& aGal ) const
 {
+    // Set the fill color based on the direction of selection
+    aGal.SetFillColor( ( m_origin.x <= m_end.x ) ? SELECT_COLOR_L2R : SELECT_COLOR_R2L );
+
     aGal.DrawRectangle( m_origin, m_end );
 }
 
-- 
2.7.4

From 87d505b559ffcd7f2140f5f561db8d3097c0432a Mon Sep 17 00:00:00 2001
From: Oliver Walters <oliver.henry.walters@xxxxxxxxx>
Date: Fri, 5 May 2017 15:04:46 +1000
Subject: [PATCH 14/15] Use CTRL modifier to deselect items

---
 common/preview_items/selection_area.cpp |  4 ++--
 pcbnew/tools/selection_tool.cpp         | 20 ++++++++++++++++----
 pcbnew/tools/selection_tool.h           |  3 +++
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/common/preview_items/selection_area.cpp b/common/preview_items/selection_area.cpp
index a1a4813..001e6df 100644
--- a/common/preview_items/selection_area.cpp
+++ b/common/preview_items/selection_area.cpp
@@ -30,8 +30,8 @@
 using namespace KIGFX::PREVIEW;
 
 // Selection area colours
-const COLOR4D SELECT_COLOR_L2R( 0.3, 0.3, 0.5, 0.3 );  // Slight blue
-const COLOR4D SELECT_COLOR_R2L( 0.3, 0.5, 0.3, 0.3 );  // Slight green
+const COLOR4D SELECT_COLOR_L2R( 0.3, 0.3, 0.6, 0.3 );  // Slight blue
+const COLOR4D SELECT_COLOR_R2L( 0.3, 0.6, 0.3, 0.3 );  // Slight green
 
 
 SELECTION_AREA::SELECTION_AREA()
diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp
index 0ea9529..a77e53e 100644
--- a/pcbnew/tools/selection_tool.cpp
+++ b/pcbnew/tools/selection_tool.cpp
@@ -230,6 +230,10 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
         // become the new selection (discarding previously selected items)
         m_additive = evt->Modifier( MD_SHIFT );
 
+        // Should selected items be REMOVED from the current selection?
+        // This will be ignored if the SHIFT modifier is pressed
+        m_subtractive = !m_additive && evt->Modifier( MD_CTRL );
+
         // single click? Select single object
         if( evt->IsClick( BUT_LEFT ) )
         {
@@ -269,7 +273,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
         // drag with LMB? Select multiple objects (or at least draw a selection box) or drag them
         else if( evt->IsDrag( BUT_LEFT ) )
         {
-            if( m_additive )
+            if( m_additive || m_subtractive )
             {
                 selectMultiple();
             }
@@ -483,8 +487,10 @@ bool SELECTION_TOOL::selectMultiple()
 
         if( evt->IsDrag( BUT_LEFT ) )
         {
-            if( !m_additive )
+            if( !m_additive && !m_subtractive )
+            {
                 clearSelection();
+            }
 
             // Start drawing a selection box
             area.SetOrigin( evt->DragOrigin() );
@@ -529,14 +535,20 @@ bool SELECTION_TOOL::selectMultiple()
                 {
                     if( selectionBox.Contains( item->ViewBBox() ) )
                     {
-                        select( item );
+                        if( m_subtractive )
+                            unselect( item );
+                        else
+                            select( item );
                     }
                 }
                 else
                 {
                     if( item->HitTest( selectionRect, false ) )
                     {
-                        select( item );
+                        if( m_subtractive )
+                            unselect( item );
+                        else
+                            select( item );
                     }
 
                 }
diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h
index a285370..642842d 100644
--- a/pcbnew/tools/selection_tool.h
+++ b/pcbnew/tools/selection_tool.h
@@ -323,6 +323,9 @@ private:
     /// Flag saying if items should be added to the current selection or rather replace it.
     bool m_additive;
 
+    /// Flag saying if items should be removed from the current selection
+    bool m_subtractive;
+
     /// Flag saying if multiple selection mode is active.
     bool m_multiple;
 
-- 
2.7.4

From e9225dbb981fc75b15eae397443c6d3a0ceae392 Mon Sep 17 00:00:00 2001
From: Oliver Walters <oliver.henry.walters@xxxxxxxxx>
Date: Sat, 6 May 2017 17:05:05 +1000
Subject: [PATCH 15/15] HitTest improvement for EDA_TEXT

---
 common/eda_text.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/eda_text.cpp b/common/eda_text.cpp
index 8c57c60..70a3ce3 100644
--- a/common/eda_text.cpp
+++ b/common/eda_text.cpp
@@ -285,7 +285,7 @@ bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy
     if( aContains )
         return rect.Contains( GetTextBox( -1 ) );
 
-    return rect.Intersects( GetTextBox( -1 ) );
+    return rect.Intersects( GetTextBox( -1 ), GetTextAngle() );
 }
 
 
-- 
2.7.4


Follow ups

References