From eff9746f349a68726cc6b9202dd2087d445b953c Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 29 May 2021 11:53:55 -0400 Subject: [PATCH] CHANGED: Net highlight in PcbNew is now persistent to match Eeschema CHANGED: Highlight net tool changed to highlight display toggle; moved to left toolbar CHANGED: Multi-net highlight is now accessible when using the highlight net action ADDED: Highlight Net and Clear Highlight actions to Net Tools context menu ADDED: Default hotkey (Ctrl+`) for toggling net highlighting The current and previous net highlight state are now stored and can be toggled on or off with an action (no hotkey by default). Highlight is now treated as a persistent state rather than a tool that is entered, meaning there is no longer a special tool to enter in order to highlight nets. Highlighting can be controlled while any other tool is active using the hotkeys or context menu on a net object. Tweak the icons for highlight net and layer display mode to better disambiguate them. Fixes https://gitlab.com/kicad/code/kicad/-/issues/8250 --- bitmaps_png/png/contrast_mode_24.png | Bin 721 -> 420 bytes bitmaps_png/png/contrast_mode_dark_24.png | Bin 725 -> 415 bytes bitmaps_png/png/net_highlight_24.png | Bin 351 -> 307 bytes bitmaps_png/png/net_highlight_dark_24.png | Bin 361 -> 305 bytes bitmaps_png/sources/dark/contrast_mode.svg | 78 ++++++--------- bitmaps_png/sources/dark/net_highlight.svg | 50 +++++----- bitmaps_png/sources/light/contrast_mode.svg | 84 +++++++---------- bitmaps_png/sources/light/net_highlight.svg | 62 ++++++------ include/render_settings.h | 15 +++ pcbnew/pcb_edit_frame.cpp | 18 +++- pcbnew/toolbars_pcb_editor.cpp | 6 +- pcbnew/tools/board_inspection_tool.cpp | 99 +++++++++++++------- pcbnew/tools/board_inspection_tool.h | 11 ++- pcbnew/tools/pcb_actions.cpp | 12 +-- pcbnew/tools/pcb_actions.h | 13 ++- pcbnew/tools/pcb_selection_tool.cpp | 3 - 16 files changed, 237 insertions(+), 214 deletions(-) mode change 100755 => 100644 bitmaps_png/sources/light/contrast_mode.svg mode change 100755 => 100644 bitmaps_png/sources/light/net_highlight.svg diff --git a/bitmaps_png/png/contrast_mode_24.png b/bitmaps_png/png/contrast_mode_24.png index 314d0e9fa573ea8e6c074e4b277edd855e713e85..a57de94b26cf9fe47ac94b77562505741bf40475 100644 GIT binary patch delta 395 zcmV;60d)S+1*8LzBYy#FNklNwmBO2_J z%K_@()U!{`@h{N8p8pICj98O3kj7e65VGJ(pgMX|or22}oJ9pFLcw7U3>J{V-*-e| z1kqj>iSCo;q%tHEapQE4CK+D{W0Qb8D3a$*3&Ry44WOh;tR>hI2eMDdt_cYRDa*c z0Fo!}k!Cp5C#ue_3}lpwc*7i+7-k~{)x}i|q0GdY-0+_%C@jp5P=xMOb`t{{{t4j= zr$iJ5QjJId;>w{R5z*LkC=B0kZf;hE_`;zc$rn#|>bY?vS%58vuJ|7S%tQqhwfHg- z2(JT~aeqw4k`rk7BY26d=2(Z*0?o3O|AK*KOKC+FA;UrVUu$ct0XPq-J0>AT_~%2K zwvr6wW+I@WYhjjv*x)E*Xka>^?syg{sAiI#LxG0sKub%oFPfT~z;!mTPIp7{#h-mD zj@o2re{8;hmS@}HmH_K}vdb2bt3j@ZTJi-Zelt+hP8FI_?}0Kc$bze&CI$l;0GLeM gfQEku(YVwA0MPcGCUcwn(f|Me07*qoM6N<$g7WP?_5c6? diff --git a/bitmaps_png/png/contrast_mode_dark_24.png b/bitmaps_png/png/contrast_mode_dark_24.png index 06ce0f474dc23a9982d4de20a6aad081289ef2a9..9fec1dc5c80c32179d01234766d66d87c564b052 100644 GIT binary patch delta 389 zcmV;00eb$`1)l?uBYy#ANklD@8x0)LjDN|3G~GYg&~g10~?#!GmXx z9z7~XGfNH}IPf2cFVoBtkl{47`!tc^KNNre zG>IXBDwaH2;%xe163f3&lbHU0-x&kOpC&SbE%`8+L6KrhKtTd>HOOEX_`V|=;*(Mz zSnBx;#6ABR7#MLR>&sY+3W64t`Jg1zk12Iia9M)0r~pMMILv{;0y6mfjwp;E`jFJ% z1~lXw*rMdRS$^o2fbtIBq5>455KE9Ec_KqRibL>NLR8uZx%SfphEx#76}c2!LJSxj zmVn{_DNcyNr_tl>V``l{(1P!<)P>;+kOolFCBYKR6o}*#vTH&@K??H;MfEu`mM~BX jsF64b0<^?&3Rw;S?X}U=1tAs`00000NkvXXu0mjf zyB|DuNjC4z_r7_P<*I?vQ#Ap}6!f0c>gr7CBrmCpy^^}>m48a-IfqruEqLUdoabsj zF$m;@!H=Hl5AaguK0mE)d8KlLm&z$8D>)HUelhGTNQ)&vwbZ4%!Y0_oBi z5dQ|dz@|#d6@NJs@Zr-y-q1w0!M1KEHtkBT7Z86oZ9+q>HhI(KP0g+*418E2xlDm1 z6G;+{My=QZJT?UCe(|1V*q;o6X?3hus%+bl56vu*x!D4FGWn{N+z_$abPR}pnX|xW z=;xky%iUm4-frcTJn?*@9XZ8Bt4(ip0T?{)G|zJbu&;7~>=V{jlyww~Y>b zs7SZ4tAVyF8ZsI-%Pg9(ik_0iuX$2=INti5tXtZ#=yBnYT<>^lPXbyd6i4J5ssg&^ z*tSld*Mv~gB9bM2ef#%Bj4|n&pHr@M8fbkG9|z)^MdWVN1F)xe+9!10E}=S#kw~P6 zi3liU5r0@(xf48W6|hZcc2*|ilP`A*5yfk^`$k3%L2kYqM~zQJZ3PD3FE?_T1xVpm(kx<$vf$GM z1|J|k{b?e@7a%_MX%d4kvB5#m0+3-qL;qvJfy4v{VGAHG|9}7Ubld-bzrOtcd8!p` z!O=d=|5A-d$ik==Ol0^3GVtH8&;LQ--_K8A3!YEpqLKwL9{^nrvgGHf7V7%o<0J-e zY;o{$GJ_|s3`%k;`Z$rn>v^le(vH$>-Z4&qOxHgWF00000NkvXXu0mjfJzRIX delta 325 zcmV-L0lNOP0^b6VBYy!VNklXTG|3Lh#wY61;f!d&LijY$U@@4UNs}hA16{u!D)+vvt<9QJ3qbfXvL!$^TXS>sN~qjd zAlr?sAOX5g6llODs6p3(E|-MKty;B;87MXvD)$43{i$xr|9}7g8G-x>P`S@!M=m}~ zkb|1i6eI?U3s}UHZNaB03~C?x8IF!$3G_Wz%!a{d22kzoS9lt;1! zpC>VBeVWSo|KFFV|Nnh{@*l)DZC?Ffs__U4h8adk41_T(0J;3%=g0s5etP)-(-gM< z=FKaqX8|~fCO$FD0=XO{FUWEKwGGn!w-# z#HT+^WcUKar#?+$@Fg}l2wDI#3~1-P#O42go_}up|L@nA|36Q)f-N{V z)9}C3j@M*iR0}3Dd;%Hx@7L%5An@<}au{0{&C002ovPDHLkV1l!gc*p<% delta 335 zcmV-V0kHnD0_g&fBYy!fNkl-!l#cOJt_v%vu)cpcA(gLsNDN~`}SE=Y5@peMz-YY)vIhk zv6WD{uRve9krgDsAP@x_a0zPAbs%37Cbw$UDrTVAT&Ua+pnp&Nscy;t|Nj|*@iGA_ z_nGX-#b*g}P*aqGKyd(y3s}UHZNaB03~C?x8IF!$3G_Wz%!a{d22 zkzoS9lt;1!pC>VBeVWSo|KFFV|Nnh{@*l*G*nIB4(~j3D7-kqDF%ZVE0Oaz2pCAAK z`|08TPgB_bM@VfxO+5?1K{SbB7Rcq`V4B1*nW{kqw @@ -55,15 +55,15 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1920" - inkscape:window-height="995" + inkscape:window-width="2560" + inkscape:window-height="1371" id="namedview3143" showgrid="true" - inkscape:zoom="24.408623" - inkscape:cx="11.458471" - inkscape:cy="13.139804" - inkscape:window-x="1280" - inkscape:window-y="23" + inkscape:zoom="45.254834" + inkscape:cx="7.8087159" + inkscape:cy="9.3949822" + inkscape:window-x="0" + inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="Слой_1" inkscape:document-rotation="0"> @@ -74,7 +74,8 @@ spacingy="0.5" color="#c1c1ff" opacity="0.1254902" - empspacing="2" /> + empspacing="2" + enabled="true" /> @@ -126,47 +127,30 @@ contrast_mode - - + sodipodi:nodetypes="ccc" + transform="translate(-1,-1.4946319)" /> + id="polyline3132-3" + style="fill:none;stroke:#f2647e;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 5,-1 6,6 m 0,0 h 5 l 8,8" + sodipodi:nodetypes="ccccc" /> - + id="polyline3132-3-6" + style="fill:none;stroke:#c0c0c0;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 0,13 6,6 m 0,0 h 9 l 5,5" + sodipodi:nodetypes="ccccc" /> + diff --git a/bitmaps_png/sources/dark/net_highlight.svg b/bitmaps_png/sources/dark/net_highlight.svg index 8d1fd503db..5da8ebd947 100644 --- a/bitmaps_png/sources/dark/net_highlight.svg +++ b/bitmaps_png/sources/dark/net_highlight.svg @@ -30,8 +30,8 @@ id="namedview34" showgrid="true" inkscape:zoom="37.889139" - inkscape:cx="2.5768824" - inkscape:cy="10.805587" + inkscape:cx="2.8153171" + inkscape:cy="12.582575" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" @@ -117,39 +117,33 @@ net_highlight - - - + + diff --git a/bitmaps_png/sources/light/contrast_mode.svg b/bitmaps_png/sources/light/contrast_mode.svg old mode 100755 new mode 100644 index a713c2d5f4..deec97e57b --- a/bitmaps_png/sources/light/contrast_mode.svg +++ b/bitmaps_png/sources/light/contrast_mode.svg @@ -13,7 +13,7 @@ viewBox="0 0 24 24" version="1.1" sodipodi:docname="contrast_mode.svg" - inkscape:version="1.0.1 (c497b03c, 2020-09-10)" + inkscape:version="1.0.2 (1.0.2+r75+1)" inkscape:export-filename="/home/seth/code/kicad/kicad_bitmaps/bitmaps_png/sources/contrast_mode.png" inkscape:export-xdpi="1890.4615" inkscape:export-ydpi="1890.4615"> @@ -55,15 +55,15 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1920" - inkscape:window-height="995" + inkscape:window-width="2560" + inkscape:window-height="1371" id="namedview3143" showgrid="true" - inkscape:zoom="24.408623" - inkscape:cx="11.458471" - inkscape:cy="13.139804" - inkscape:window-x="1280" - inkscape:window-y="23" + inkscape:zoom="45.254834" + inkscape:cx="7.8087159" + inkscape:cy="9.3949822" + inkscape:window-x="0" + inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="Слой_1" inkscape:document-rotation="0"> @@ -74,7 +74,8 @@ spacingy="0.5" color="#c1c1ff" opacity="0.1254902" - empspacing="2" /> + empspacing="2" + enabled="true" /> @@ -93,10 +94,10 @@ offset="1" stop-color="#c6c6c5" id="stop6191" - style="stop-color:#545454;stop-opacity:1" /> + style="stop-color:#DED3DD;stop-opacity:1" /> + id="style3116">.cls-1,.cls-2,.cls-3,.cls-5{fill:none;stroke-linecap:round;stroke-linejoin:round;}.cls-1,.cls-2,.cls-3{stroke-width:2px;}.cls-1{stroke:url(#Безымянный_градиент_19);}.cls-2{stroke:#42B8EB;}.cls-3{stroke:url(#Безымянный_градиент_19-2);}.cls-4{fill:#f2647e;}.cls-5{stroke:#DED3DD;} + style="stop-color:#DED3DD;stop-opacity:1" /> contrast_mode - - + sodipodi:nodetypes="ccc" + transform="translate(-1,-1.4946319)" /> + id="polyline3132-3" + style="fill:none;stroke:#bf2641;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 5,-1 6,6 m 0,0 h 5 l 8,8" + sodipodi:nodetypes="ccccc" /> - + id="polyline3132-3-6" + style="fill:none;stroke:#545454;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 0,13 6,6 m 0,0 h 9 l 5,5" + sodipodi:nodetypes="ccccc" /> + diff --git a/bitmaps_png/sources/light/net_highlight.svg b/bitmaps_png/sources/light/net_highlight.svg old mode 100755 new mode 100644 index 34eda92fd8..f3414fbf0d --- a/bitmaps_png/sources/light/net_highlight.svg +++ b/bitmaps_png/sources/light/net_highlight.svg @@ -12,7 +12,7 @@ viewBox="0 0 24 24" version="1.1" sodipodi:docname="net_highlight.svg" - inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)" + inkscape:version="1.0.2 (1.0.2+r75+1)" inkscape:export-filename="/Users/jeff/kicad_dev/kicad/bitmaps_png/png_26/net_highlight.png" inkscape:export-xdpi="96" inkscape:export-ydpi="96"> @@ -25,16 +25,16 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="2478" - inkscape:window-height="1573" + inkscape:window-width="2560" + inkscape:window-height="1371" id="namedview34" showgrid="true" inkscape:zoom="37.889139" - inkscape:cx="8.4228849" - inkscape:cy="10.805587" + inkscape:cx="2.8153171" + inkscape:cy="12.582575" inkscape:window-x="0" - inkscape:window-y="37" - inkscape:window-maximized="0" + inkscape:window-y="0" + inkscape:window-maximized="1" inkscape:current-layer="Слой_1" inkscape:document-rotation="0" inkscape:measure-start="0,0" @@ -80,7 +80,7 @@ + id="style3">.cls-1,.cls-2,.cls-5,.cls-6{fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:2px;}.cls-1{stroke:#42B8EB;}.cls-2{stroke:#f2647e;}.cls-3{fill:#8f8f8f;}.cls-4{fill:#f29100;}.cls-5{stroke:url(#Безымянный_градиент_19);}.cls-6{stroke:url(#Безымянный_градиент_3);} net_highlight - - - + + diff --git a/include/render_settings.h b/include/render_settings.h index 00088f4d7f..688790850e 100644 --- a/include/render_settings.h +++ b/include/render_settings.h @@ -164,6 +164,21 @@ public: m_highlightNetcodes.clear(); } + /** + * Turns on highlighting and highlights multiple nets + * @param aHighlight is a set of netcodes to highlight + * @param aEnabled tells if highlighting should be enabled. + */ + inline void SetHighlight( std::set& aHighlight, bool aEnabled = true ) + { + m_highlightEnabled = aEnabled; + + if( aEnabled ) + m_highlightNetcodes = aHighlight; + else + m_highlightNetcodes.clear(); + } + /** * Turns on/off high contrast display mode. */ diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index eb0c3b58a7..c3742d0c71 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -624,11 +625,27 @@ void PCB_EDIT_FRAME::setupUIConditions() return GetDisplayOptions().m_DisplayRatsnestLinesCurved; }; + auto netHighlightCond = + [this]( const SELECTION& ) + { + KIGFX::RENDER_SETTINGS* settings = GetCanvas()->GetView()->GetPainter()->GetSettings(); + return !settings->GetHighlightNetCodes().empty(); + }; + + auto enableNetHighlightCond = + [this]( const SELECTION& ) + { + BOARD_INSPECTION_TOOL* tool = m_toolManager->GetTool(); + return tool->IsNetHighlightSet(); + }; + mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastCond ) ); mgr->SetConditions( PCB_ACTIONS::flipBoard, CHECK( boardFlippedCond ) ); mgr->SetConditions( PCB_ACTIONS::showLayersManager, CHECK( layerManagerCond ) ); mgr->SetConditions( PCB_ACTIONS::showRatsnest, CHECK( globalRatsnestCond ) ); mgr->SetConditions( PCB_ACTIONS::ratsnestLineMode, CHECK( curvedRatsnestCond ) ); + mgr->SetConditions( PCB_ACTIONS::toggleNetHighlight, + CHECK( netHighlightCond ).Enable( enableNetHighlightCond ) ); mgr->SetConditions( PCB_ACTIONS::boardSetup , ENABLE( enableBoardSetupCondition ) ); @@ -706,7 +723,6 @@ void PCB_EDIT_FRAME::setupUIConditions() CURRENT_TOOL( ACTIONS::zoomTool ); CURRENT_TOOL( ACTIONS::measureTool ); CURRENT_TOOL( ACTIONS::selectionTool ); - CURRENT_TOOL( PCB_ACTIONS::highlightNetTool ); CURRENT_TOOL( PCB_ACTIONS::localRatsnestTool ); diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 1c3105c906..ad24e34802 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -352,6 +352,10 @@ void PCB_EDIT_FRAME::ReCreateOptToolbar() m_optionsToolBar->Add( PCB_ACTIONS::showRatsnest, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( PCB_ACTIONS::ratsnestLineMode, ACTION_TOOLBAR::TOGGLE ); + m_optionsToolBar->AddScaledSeparator( this ); + m_optionsToolBar->Add( ACTIONS::highContrastMode, ACTION_TOOLBAR::TOGGLE ); + m_optionsToolBar->Add( PCB_ACTIONS::toggleNetHighlight, ACTION_TOOLBAR::TOGGLE ); + m_optionsToolBar->AddScaledSeparator( this ); m_optionsToolBar->Add( PCB_ACTIONS::zoneDisplayEnable, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( PCB_ACTIONS::zoneDisplayDisable, ACTION_TOOLBAR::TOGGLE ); @@ -361,7 +365,6 @@ void PCB_EDIT_FRAME::ReCreateOptToolbar() m_optionsToolBar->Add( PCB_ACTIONS::padDisplayMode, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( PCB_ACTIONS::viaDisplayMode, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( PCB_ACTIONS::trackDisplayMode, ACTION_TOOLBAR::TOGGLE ); - m_optionsToolBar->Add( ACTIONS::highContrastMode, ACTION_TOOLBAR::TOGGLE ); // Tools to show/hide toolbars: m_optionsToolBar->AddScaledSeparator( this ); @@ -429,7 +432,6 @@ void PCB_EDIT_FRAME::ReCreateVToolbar() } m_drawToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( PCB_ACTIONS::highlightNetTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::localRatsnestTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->AddScaledSeparator( this ); diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index 6b170621f4..65099baa82 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -54,8 +54,7 @@ BOARD_INSPECTION_TOOL::BOARD_INSPECTION_TOOL() : m_frame( nullptr ) { m_probingSchToPcb = false; - m_lastNetcode = -1; - m_dynamicData = nullptr; + m_dynamicData = nullptr; } @@ -69,7 +68,8 @@ public: Add( PCB_ACTIONS::showNet ); Add( PCB_ACTIONS::hideNet ); - // Add( PCB_ACTIONS::highlightNet ); + Add( PCB_ACTIONS::highlightNetSelection ); + Add( PCB_ACTIONS::clearHighlight ); } private: @@ -844,21 +844,35 @@ int BOARD_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent ) if( aUseSelection ) { const PCB_SELECTION& selection = selectionTool->GetSelection(); + std::set netcodes; for( auto item : selection ) { if( auto ci = dyn_cast( item ) ) - { - int item_net = ci->GetNetCode(); - - if( net < 0 ) - net = item_net; - else if( net != item_net ) // more than one net selected: do nothing - return false; - } + netcodes.insert( ci->GetNetCode() ); } - enableHighlight = ( net >= 0 && !settings->GetHighlightNetCodes().count( net ) ); + enableHighlight = !netcodes.empty(); + + if( enableHighlight && netcodes.size() > 1 ) + { + // If we are doing a multi-highlight, cross-probing back and other stuff is not + // yet supported + settings->SetHighlight( netcodes ); + board->ResetNetHighLight(); + + for( int multiNet : netcodes ) + board->SetHighLightNet( multiNet, true ); + + board->HighLightON(); + m_toolMgr->GetView()->UpdateAllLayersColor(); + m_currentlyHighlighted = netcodes; + return true; + } + else if( enableHighlight ) + { + net = *netcodes.begin(); + } } // If we didn't get a net to highlight from the selection, use the cursor @@ -928,7 +942,7 @@ int BOARD_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent ) if( enableHighlight != settings->IsHighlightEnabled() || !netcodes.count( net ) ) { if( !netcodes.empty() ) - m_lastNetcode = *netcodes.begin(); + m_lastHighlighted = netcodes; settings->SetHighlight( enableHighlight, net ); m_toolMgr->GetView()->UpdateAllLayersColor(); @@ -937,6 +951,7 @@ int BOARD_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent ) // Store the highlighted netcode in the current board (for dialogs for instance) if( enableHighlight && net >= 0 ) { + m_currentlyHighlighted = netcodes; board->SetHighLightNet( net ); board->HighLightON(); @@ -952,6 +967,7 @@ int BOARD_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent ) } else { + m_currentlyHighlighted.clear(); board->ResetNetHighLight(); m_frame->SetMsgPanel( board ); m_frame->SendCrossProbeNetName( "" ); @@ -969,16 +985,30 @@ int BOARD_INSPECTION_TOOL::HighlightNet( const TOOL_EVENT& aEvent ) if( netcode > 0 ) { - m_lastNetcode = highlighted.empty() ? -1 : *highlighted.begin(); + m_lastHighlighted = highlighted; settings->SetHighlight( true, netcode ); m_toolMgr->GetView()->UpdateAllLayersColor(); + m_currentlyHighlighted.clear(); + m_currentlyHighlighted.insert( netcode ); + } + else if( aEvent.IsAction( &PCB_ACTIONS::highlightNetSelection ) ) + { + // Highlight selection (cursor position will be ignored) + highlightNet( getViewControls()->GetMousePosition(), true ); } else if( aEvent.IsAction( &PCB_ACTIONS::toggleLastNetHighlight ) ) { - int temp = highlighted.empty() ? -1 : *highlighted.begin(); - settings->SetHighlight( true, m_lastNetcode ); + std::set temp = highlighted; + settings->SetHighlight( m_lastHighlighted ); + m_toolMgr->GetView()->UpdateAllLayersColor(); + m_currentlyHighlighted = m_lastHighlighted; + m_lastHighlighted = temp; + } + else if( aEvent.IsAction( &PCB_ACTIONS::toggleNetHighlight ) ) + { + bool turnOn = highlighted.empty() && !m_currentlyHighlighted.empty(); + settings->SetHighlight( m_currentlyHighlighted, turnOn ); m_toolMgr->GetView()->UpdateAllLayersColor(); - m_lastNetcode = temp; } else // Highlight the net belonging to the item under the cursor { @@ -994,6 +1024,9 @@ int BOARD_INSPECTION_TOOL::ClearHighlight( const TOOL_EVENT& aEvent ) BOARD* board = static_cast( m_toolMgr->GetModel() ); KIGFX::RENDER_SETTINGS* settings = m_toolMgr->GetView()->GetPainter()->GetSettings(); + m_currentlyHighlighted.clear(); + m_lastHighlighted.clear(); + board->ResetNetHighLight(); settings->SetHighlight( false ); m_toolMgr->GetView()->UpdateAllLayersColor(); @@ -1002,7 +1035,7 @@ int BOARD_INSPECTION_TOOL::ClearHighlight( const TOOL_EVENT& aEvent ) return 0; } - +#if 0 int BOARD_INSPECTION_TOOL::HighlightNetTool( const TOOL_EVENT& aEvent ) { std::string tool = aEvent.GetCommandStr().get(); @@ -1034,7 +1067,7 @@ int BOARD_INSPECTION_TOOL::HighlightNetTool( const TOOL_EVENT& aEvent ) return 0; } - +#endif int BOARD_INSPECTION_TOOL::LocalRatsnestTool( const TOOL_EVENT& aEvent ) { @@ -1347,22 +1380,18 @@ void BOARD_INSPECTION_TOOL::setTransitions() Go( &BOARD_INSPECTION_TOOL::UpdateSelectionRatsnest, PCB_ACTIONS::updateLocalRatsnest.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::ListNets, PCB_ACTIONS::listNets.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::ShowStatisticsDialog, PCB_ACTIONS::boardStatistics.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::InspectClearance, PCB_ACTIONS::inspectClearance.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::InspectConstraints, - PCB_ACTIONS::inspectConstraints.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::ListNets, PCB_ACTIONS::listNets.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::ShowStatisticsDialog, PCB_ACTIONS::boardStatistics.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::InspectClearance, PCB_ACTIONS::inspectClearance.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::InspectConstraints, PCB_ACTIONS::inspectConstraints.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::HighlightNet, PCB_ACTIONS::highlightNet.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::HighlightNet, - PCB_ACTIONS::highlightNetSelection.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::HighlightNet, - PCB_ACTIONS::toggleLastNetHighlight.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::ClearHighlight, PCB_ACTIONS::clearHighlight.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::HighlightNetTool, PCB_ACTIONS::highlightNetTool.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::ClearHighlight, ACTIONS::cancelInteractive.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::HighlightItem, PCB_ACTIONS::highlightItem.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::HighlightNet, PCB_ACTIONS::highlightNet.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::HighlightNet, PCB_ACTIONS::highlightNetSelection.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::HighlightNet, PCB_ACTIONS::toggleLastNetHighlight.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::ClearHighlight, PCB_ACTIONS::clearHighlight.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::HighlightNet, PCB_ACTIONS::toggleNetHighlight.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::HighlightItem, PCB_ACTIONS::highlightItem.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::HideNet, PCB_ACTIONS::hideNet.MakeEvent() ); - Go( &BOARD_INSPECTION_TOOL::ShowNet, PCB_ACTIONS::showNet.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::HideNet, PCB_ACTIONS::hideNet.MakeEvent() ); + Go( &BOARD_INSPECTION_TOOL::ShowNet, PCB_ACTIONS::showNet.MakeEvent() ); } diff --git a/pcbnew/tools/board_inspection_tool.h b/pcbnew/tools/board_inspection_tool.h index 689f364541..bd48f5ebab 100644 --- a/pcbnew/tools/board_inspection_tool.h +++ b/pcbnew/tools/board_inspection_tool.h @@ -119,6 +119,14 @@ public: int InspectConstraints( const TOOL_EVENT& aEvent ); + /** + * @return true if a net or nets to highlight have been set + */ + bool IsNetHighlightSet() const + { + return !m_currentlyHighlighted.empty(); + } + private: ///< Event handler to recalculate dynamic ratsnest. void ratsnestTimer( wxTimerEvent& aEvent ); @@ -155,7 +163,8 @@ private: PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame. bool m_probingSchToPcb; // Recursion guard when cross-probing to Eeschema - int m_lastNetcode; // Used for toggling between last two highlighted nets + std::set m_currentlyHighlighted; // Active net being highlighted, or -1 when off + std::set m_lastHighlighted; // Used for toggling between last two highlighted nets CONNECTIVITY_DATA* m_dynamicData; // Cached connectivity data from the selection diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index 66bc6c6abb..bb492a226f 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -701,19 +701,19 @@ TOOL_ACTION PCB_ACTIONS::toggleLastNetHighlight( "pcbnew.EditorControl.toggleLas _( "Toggle Last Net Highlight" ), _( "Toggle between last two highlighted nets" ) ); TOOL_ACTION PCB_ACTIONS::clearHighlight( "pcbnew.EditorControl.clearHighlight", - AS_GLOBAL, 0, "", + AS_GLOBAL, '~', "", _( "Clear Net Highlighting" ), _( "Clear any existing net highlighting" ) ); -TOOL_ACTION PCB_ACTIONS::highlightNetTool( "pcbnew.EditorControl.highlightNetTool", - AS_GLOBAL, 0, "", - _( "Highlight Nets" ), _( "Highlight all copper items of a net" ), - BITMAPS::net_highlight, AF_ACTIVATE ); +TOOL_ACTION PCB_ACTIONS::toggleNetHighlight( "pcbnew.EditorControl.toggleNetHighlight", + AS_GLOBAL, MD_CTRL + '`', "", + _( "Toggle Net Highlight" ), _( "Toggle net highlighting" ), + BITMAPS::net_highlight ); TOOL_ACTION PCB_ACTIONS::highlightNetSelection( "pcbnew.EditorControl.highlightNetSelection", AS_GLOBAL, // Don't be tempted to remove "Modern Toolset only". It's in the legacy property name. '`', LEGACY_HK_NAME( "Toggle Highlight of Selected Net (Modern Toolset only)" ), - _( "Highlight Net" ), _( "Highlight all copper items of a net" ), + _( "Highlight Net" ), _( "Highlight all copper items on the selected net(s)" ), BITMAPS::net_highlight ); TOOL_ACTION PCB_ACTIONS::highlightItem( "pcbnew.EditorControl.highlightItem", diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 65ff6f55f4..304358bf8f 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -445,14 +445,13 @@ public: static TOOL_ACTION inspectClearance; static TOOL_ACTION inspectConstraints; - // Appearance controls - static TOOL_ACTION clearHighlight; - static TOOL_ACTION highlightNet; - static TOOL_ACTION toggleLastNetHighlight; - static TOOL_ACTION highlightNetTool; - static TOOL_ACTION highlightNetSelection; - static TOOL_ACTION highlightItem; + static TOOL_ACTION clearHighlight; // Turns off highlight and resets previous highlight + static TOOL_ACTION highlightNet; // Highlights a net by code (cross-probe highlight) + static TOOL_ACTION toggleLastNetHighlight; // Toggles between current and previous highlight + static TOOL_ACTION toggleNetHighlight; // Toggles between highlight off and highlight on + static TOOL_ACTION highlightNetSelection; // Turns on highlight and takes net from selection + static TOOL_ACTION highlightItem; // Select component via cross-probe static TOOL_ACTION hideNet; static TOOL_ACTION showNet; diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 95e22b7fc0..c5ae5f8019 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -440,9 +440,6 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) ExitGroup(); ClearSelection(); - - if( evt->FirstResponder() == this ) - m_toolMgr->RunAction( PCB_ACTIONS::clearHighlight ); } else {