kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #32915
Re: [PATCH] Add bidirectional net highlight cross-probing
Hi Wayne,
Give this patch a try on top of my first one and see if it does what you
want.
-Jon
On Sat, Jan 6, 2018 at 8:58 PM, Chris Pavlina <pavlina.chris@xxxxxxxxx>
wrote:
> On Sun, Jan 07, 2018 at 01:48:34AM +0000, Jon Evans wrote:
> > Do I get a pass if I did this because I was browsing the bug list looking
> > for more things to fix? ;-)
>
> I suppose so, I disagree with it having been classified as a bug but
> that's not your fault ;)
>
> >
> > Wayne, I'll work on the recentering in PcbNew, it shouldn't be too much
> to
> > add.
> >
> > On Sat, Jan 6, 2018 at 7:45 PM, Chris Pavlina <pavlina.chris@xxxxxxxxx>
> > wrote:
> >
> > > I like it too, I just worry that by accepting even small features
> during
> > > freeze we're encouraging people to do things that aren't bugfixes and
> > > release cleanup...
> > >
> > > On Sun, Jan 07, 2018 at 12:35:58AM +0000, Wayne Stambaugh wrote:
> > > > Jon,
> > > >
> > > > I just tested this and I like it! It doesn't seem like a high risk
> > > > feature so if now one objects I'm going to merge it. If you have
> time,
> > > > I do have one minor request. When highlighting a net in the board
> > > > editor, if the net in the schematic editor is scrolled of the
> display,
> > > > the schematic editor centers the net so you can see it. The same
> thing
> > > > does not happen when a net is highlighted in the schematic editor and
> > > > the net on the board is scrolled off the display. Would you please
> fix
> > > > this so the net in the board editor is centered on the display when
> the
> > > > net in the schematic editor is selected.
> > > >
> > > > Thanks,
> > > >
> > > > Wayne
> > > >
> > > > On 01/06/2018 03:52 PM, Jon Evans wrote:
> > > > > I implemented this in response to a bug report:
> > > > > https://bugs.launchpad.net/kicad/+bug/1738875
> > > > >
> > > > > But it is kind of on a blurred line between bug fix and new
> feature.
> > > > > I'll leave it up to Wayne et. al. to decide on if to merge this
> for V5.
> > > > >
> > > > > Basically, beforehand, cross-probing highlighted nets only if you
> > > > > clicked on a component pad.
> > > > > Now there is a separate cross-probing message for a net name, so
> that
> > > if
> > > > > the highlight tool is selected in both eeschema and pcbnew,
> selecting
> > > > > any part of a net will cross-probe.
> > > > >
> > > > > -Jon
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > Mailing list: https://launchpad.net/~kicad-developers
> > > > > Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> > > > > Unsubscribe : https://launchpad.net/~kicad-developers
> > > > > More help : https://help.launchpad.net/ListHelp
> > > > >
> > > >
> > > > _______________________________________________
> > > > Mailing list: https://launchpad.net/~kicad-developers
> > > > Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> > > > Unsubscribe : https://launchpad.net/~kicad-developers
> > > > More help : https://help.launchpad.net/ListHelp
> > >
> > > _______________________________________________
> > > Mailing list: https://launchpad.net/~kicad-developers
> > > Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> > > Unsubscribe : https://launchpad.net/~kicad-developers
> > > More help : https://help.launchpad.net/ListHelp
> > >
>
From 6de7100dc46219ab33b2b47ea303842f70d30e64 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Sat, 6 Jan 2018 21:30:31 -0500
Subject: [PATCH] Scale and zoom view to fit when cross-probing a net on the
board
---
pcbnew/cross-probing.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp
index b914cd310..0f9474dc1 100644
--- a/pcbnew/cross-probing.cpp
+++ b/pcbnew/cross-probing.cpp
@@ -21,6 +21,8 @@
#include <pcbnew_id.h>
#include <class_board.h>
#include <class_module.h>
+#include <class_track.h>
+#include <class_zone.h>
#include <collectors.h>
#include <pcbnew.h>
@@ -76,9 +78,52 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
if( IsGalCanvasActive() )
{
- auto rs = m_toolManager->GetView()->GetPainter()->GetSettings();
+ auto view = m_toolManager->GetView();
+ auto rs = view->GetPainter()->GetSettings();
rs->SetHighlight( true, netcode );
- m_toolManager->GetView()->UpdateAllLayersColor();
+ view->UpdateAllLayersColor();
+
+ BOX2I bbox;
+ bool first = true;
+
+ auto merge_area = [netcode, &bbox, &first]( BOARD_CONNECTED_ITEM* aItem )
+ {
+ if( aItem->GetNetCode() == netcode )
+ {
+ if( first )
+ {
+ bbox = aItem->GetBoundingBox();
+ first = false;
+ }
+ else
+ {
+ bbox.Merge( aItem->GetBoundingBox() );
+ }
+ }
+ };
+
+ for( auto zone : pcb->Zones() )
+ merge_area( zone );
+
+ for( auto track : pcb->Tracks() )
+ merge_area( track );
+
+ for( auto mod : pcb->Modules() )
+ for ( auto mod_pad : mod->Pads() )
+ merge_area( mod_pad );
+
+ if( netcode > 0 && bbox.GetWidth() > 0 && bbox.GetHeight() > 0 )
+ {
+ auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
+ auto screenSize = view->ToWorld( GetGalCanvas()->GetClientSize(), false );
+ double ratio = std::max( fabs( bbSize.x / screenSize.x ),
+ fabs( bbSize.y / screenSize.y ) );
+ double scale = view->GetScale() / ratio;
+
+ view->SetScale( scale );
+ view->SetCenter( bbox.Centre() );
+ }
+
GetGalCanvas()->Refresh();
}
else
--
2.14.1
Follow ups
References