From e7d32c54b90297554c0193e71c620f5ee78e5164 Mon Sep 17 00:00:00 2001 From: MaPePeR Date: Mon, 30 Apr 2018 09:52:49 +0200 Subject: [PATCH] pcbnew: Draw Ratsnest with arcs to avoid overlap Adds a toggle button that allows switching between straight lines and curves for the ratsnest lines. Fixes: lp:1766597 * https://bugs.launchpad.net/kicad/+bug/1766597 --- bitmaps_png/CMakeLists.txt | 1 + bitmaps_png/cpp_26/curved_ratsnest.cpp | 45 +++++ .../include/bitmaps_png/bitmaps_list.h | 1 + bitmaps_png/sources/curved_ratsnest.svg | 189 ++++++++++++++++++ include/pcb_display_options.h | 1 + pcbnew/pcb_display_options.cpp | 1 + pcbnew/pcb_edit_frame.cpp | 3 + pcbnew/pcb_edit_frame.h | 1 + pcbnew/pcb_painter.cpp | 1 + pcbnew/pcb_painter.h | 8 + pcbnew/pcbnew_config.cpp | 2 + pcbnew/pcbnew_id.h | 1 + pcbnew/ratsnest.cpp | 17 +- pcbnew/ratsnest_viewitem.cpp | 17 +- pcbnew/tool_pcb_editor.cpp | 11 + pcbnew/toolbars_update_user_interface.cpp | 10 + pcbnew/tools/pcb_actions.cpp | 3 + pcbnew/tools/pcb_actions.h | 1 + pcbnew/tools/pcbnew_control.cpp | 17 ++ pcbnew/tools/pcbnew_control.h | 1 + 20 files changed, 327 insertions(+), 4 deletions(-) create mode 100644 bitmaps_png/cpp_26/curved_ratsnest.cpp create mode 100644 bitmaps_png/sources/curved_ratsnest.svg diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index 53d4e286ba..b291835977 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -173,6 +173,7 @@ set( BMAPS_MID cancel change_entry_orient contrast_mode + curved_ratsnest create_cmp_file checked_ok color_materials diff --git a/bitmaps_png/cpp_26/curved_ratsnest.cpp b/bitmaps_png/cpp_26/curved_ratsnest.cpp new file mode 100644 index 0000000000..8323489494 --- /dev/null +++ b/bitmaps_png/cpp_26/curved_ratsnest.cpp @@ -0,0 +1,45 @@ + +/* Do not modify this file, it was automatically generated by the + * PNG2cpp CMake script, using a *.png file as input. + */ + +#include + +static const unsigned char png[] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x04, 0x00, 0x00, 0x00, 0x03, 0x43, 0x84, + 0x45, 0x00, 0x00, 0x01, 0xc7, 0x49, 0x44, 0x41, 0x54, 0x38, 0xcb, 0x95, 0x94, 0xbb, 0x4f, 0xc2, + 0x50, 0x14, 0xc6, 0xbf, 0x2a, 0x21, 0x91, 0xd5, 0x8d, 0x38, 0x34, 0xba, 0xa1, 0xb8, 0xd0, 0xc1, + 0x41, 0x01, 0x11, 0x16, 0xf1, 0x1f, 0x70, 0x70, 0xd1, 0x89, 0x38, 0xaa, 0x69, 0xe2, 0xa4, 0x4e, + 0x1a, 0x07, 0x56, 0xcb, 0x66, 0x34, 0xf2, 0x1a, 0x1c, 0xd4, 0xc1, 0x18, 0x12, 0x17, 0x9c, 0x40, + 0x37, 0x95, 0x89, 0xc6, 0xc4, 0x26, 0xb2, 0xc0, 0x40, 0x4c, 0x0c, 0x31, 0xf5, 0xf6, 0x45, 0xef, + 0x6d, 0x0b, 0xea, 0x39, 0xcb, 0xbd, 0x3d, 0xfd, 0xf5, 0x9e, 0x47, 0xbf, 0x0b, 0xfc, 0xd3, 0x4e, + 0x42, 0xf4, 0x6e, 0x04, 0xdc, 0xd0, 0xb7, 0xf5, 0xb8, 0x94, 0x95, 0x54, 0x29, 0xac, 0xef, 0x83, + 0x81, 0x48, 0x29, 0x29, 0x27, 0xe5, 0x48, 0x31, 0x18, 0x20, 0x5b, 0x1e, 0xeb, 0xc8, 0xe1, 0x8a, + 0x78, 0x8e, 0xac, 0x78, 0x3b, 0x2e, 0x36, 0x08, 0x92, 0x35, 0x3f, 0x12, 0x29, 0x96, 0x7b, 0x8a, + 0xaa, 0xa8, 0xe5, 0xde, 0x74, 0x0d, 0x55, 0xb4, 0x70, 0x86, 0x0c, 0x56, 0x88, 0x67, 0xc8, 0xaa, + 0x85, 0x6a, 0xa8, 0xae, 0xc5, 0x2b, 0xaa, 0xa4, 0x8a, 0xaf, 0xd6, 0xc1, 0xdc, 0x92, 0xac, 0x21, + 0x9a, 0x2f, 0x74, 0x91, 0x86, 0x8f, 0x49, 0xcb, 0x87, 0x74, 0xb4, 0x6b, 0x20, 0x77, 0x6a, 0xa2, + 0x69, 0x15, 0xc1, 0x25, 0xfa, 0xd0, 0xe2, 0x9b, 0x47, 0x65, 0x24, 0xae, 0x21, 0x47, 0x24, 0x6e, + 0x43, 0x10, 0x0a, 0x25, 0x3d, 0xbd, 0xc2, 0xf7, 0xd4, 0x17, 0x44, 0x8c, 0x3a, 0xa9, 0x9d, 0x67, + 0x0d, 0xd9, 0x52, 0x4b, 0x3d, 0xe1, 0xa2, 0xff, 0x30, 0x18, 0x08, 0xd5, 0x63, 0xdd, 0x54, 0x53, + 0xc8, 0xfb, 0x67, 0x70, 0x8b, 0x27, 0xcc, 0xd1, 0x48, 0xee, 0x90, 0xd4, 0xd2, 0xe0, 0xdb, 0x7c, + 0x5b, 0xc8, 0x4f, 0x8c, 0xd1, 0x91, 0x07, 0x2c, 0x9b, 0x07, 0x73, 0x58, 0x83, 0x82, 0x63, 0xf8, + 0x6d, 0x44, 0xef, 0xd8, 0x1e, 0x71, 0xc6, 0x78, 0x7c, 0x30, 0xe5, 0x8f, 0xe3, 0x12, 0x35, 0x4c, + 0x52, 0x88, 0x07, 0xb4, 0x81, 0x73, 0x57, 0xf9, 0x9b, 0x78, 0x3f, 0x38, 0xa5, 0xe6, 0xe2, 0x82, + 0x24, 0x32, 0x11, 0x97, 0xed, 0x96, 0x29, 0xc4, 0x03, 0xba, 0x21, 0xd3, 0x71, 0x18, 0x95, 0xd8, + 0x00, 0xe8, 0x9a, 0x4c, 0xdf, 0x85, 0xac, 0x7e, 0x22, 0x3e, 0x0c, 0x72, 0xa4, 0x67, 0x9e, 0x32, + 0x4f, 0xda, 0x93, 0x18, 0x0c, 0x31, 0x8d, 0xa0, 0x12, 0xa3, 0xb1, 0x61, 0x2d, 0x77, 0xd4, 0x62, + 0x63, 0x2e, 0xa8, 0x3f, 0x5c, 0x57, 0xf9, 0x36, 0xb6, 0xef, 0x80, 0xc8, 0x6f, 0xf4, 0x18, 0xeb, + 0x26, 0xe5, 0xed, 0x17, 0x17, 0xa2, 0x63, 0x5c, 0x2b, 0x7c, 0x1f, 0xef, 0xc4, 0x3b, 0xa6, 0xde, + 0x68, 0x3d, 0xb1, 0x7a, 0xa1, 0x6d, 0xb6, 0x52, 0x50, 0x0d, 0xbd, 0x09, 0x79, 0x46, 0x4f, 0x86, + 0x5e, 0xa2, 0x6d, 0x3d, 0x77, 0x87, 0xc7, 0xda, 0x96, 0x74, 0x18, 0x3d, 0x19, 0x88, 0x32, 0x00, + 0x8a, 0x7a, 0x40, 0xba, 0x5e, 0x34, 0x84, 0xd1, 0x0b, 0x65, 0x96, 0xde, 0xa8, 0xb8, 0x76, 0xc3, + 0x88, 0x8d, 0x54, 0x53, 0xd3, 0x13, 0xab, 0x17, 0xbb, 0x51, 0x42, 0x81, 0x89, 0x4b, 0x61, 0xb3, + 0x63, 0xdc, 0x2f, 0x57, 0x18, 0x1b, 0x67, 0xaf, 0xbf, 0xbf, 0xd8, 0x0f, 0x3c, 0x1e, 0x28, 0x8f, + 0xaa, 0xd6, 0xe8, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, +}; + +const BITMAP_OPAQUE curved_ratsnest_xpm[1] = {{ png, sizeof( png ), "curved_ratsnest_xpm" }}; + +//EOF diff --git a/bitmaps_png/include/bitmaps_png/bitmaps_list.h b/bitmaps_png/include/bitmaps_png/bitmaps_list.h index 2d5f33830b..bd514206a7 100644 --- a/bitmaps_png/include/bitmaps_png/bitmaps_list.h +++ b/bitmaps_png/include/bitmaps_png/bitmaps_list.h @@ -111,6 +111,7 @@ EXTERN_BITMAP( create_cmp_file_xpm ) EXTERN_BITMAP( cursor_shape_xpm ) EXTERN_BITMAP( custom_pad_to_primitives_xpm ) EXTERN_BITMAP( cursor_xpm ) +EXTERN_BITMAP( curved_ratsnest_xpm ) EXTERN_BITMAP( cut_xpm ) EXTERN_BITMAP( cvpcb_xpm ) EXTERN_BITMAP( dashline_xpm ) diff --git a/bitmaps_png/sources/curved_ratsnest.svg b/bitmaps_png/sources/curved_ratsnest.svg new file mode 100644 index 0000000000..78077b00f4 --- /dev/null +++ b/bitmaps_png/sources/curved_ratsnest.svg @@ -0,0 +1,189 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/pcb_display_options.h b/include/pcb_display_options.h index d39b10ce1c..340c3c78e7 100644 --- a/include/pcb_display_options.h +++ b/include/pcb_display_options.h @@ -84,6 +84,7 @@ public: bool m_ContrastModeDisplay; int m_MaxLinksShowed; // in track creation: number of hairwires shown bool m_Show_Module_Ratsnest; // When moving a footprint: allows displaying a ratsnest + bool m_DisplayRatsnestLinesCurved; public: diff --git a/pcbnew/pcb_display_options.cpp b/pcbnew/pcb_display_options.cpp index 95c7b77fec..a296963d88 100644 --- a/pcbnew/pcb_display_options.cpp +++ b/pcbnew/pcb_display_options.cpp @@ -56,4 +56,5 @@ PCB_DISPLAY_OPTIONS::PCB_DISPLAY_OPTIONS() m_ContrastModeDisplay = false; m_MaxLinksShowed = 3; // in track creation: number of hairwires shown m_Show_Module_Ratsnest = true; // When moving a footprint: allows displaying a ratsnest + m_DisplayRatsnestLinesCurved = true; } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 7b6a6c5456..b420abcad8 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -232,6 +232,8 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) PCB_EDIT_FRAME::OnSelectOptionToolbar ) EVT_TOOL( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE, PCB_EDIT_FRAME::OnSelectOptionToolbar ) + EVT_TOOL( ID_TB_OPTIONS_CURVED_RATSNEST_LINES, + PCB_EDIT_FRAME::OnSelectOptionToolbar ) EVT_TOOL( ID_UPDATE_PCB_FROM_SCH, PCB_EDIT_FRAME::OnUpdatePCBFromSch ) EVT_TOOL( ID_RUN_EESCHEMA, PCB_EDIT_FRAME::OnRunEeschema ) @@ -271,6 +273,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_UPDATE_UI( ID_TB_OPTIONS_DRC_OFF, PCB_EDIT_FRAME::OnUpdateDrcEnable ) EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_RATSNEST, PCB_EDIT_FRAME::OnUpdateShowBoardRatsnest ) EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, PCB_EDIT_FRAME::OnUpdateViaDrawMode ) + EVT_UPDATE_UI( ID_TB_OPTIONS_CURVED_RATSNEST_LINES, PCB_EDIT_FRAME::OnUpdateCurvedRatsnest ) EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, PCB_EDIT_FRAME::OnUpdateTraceDrawMode ) EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode ) diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index dc03d1638a..49d5cc59dd 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -363,6 +363,7 @@ public: void OnConfigurePaths( wxCommandEvent& aEvent ); void OnUpdatePCBFromSch( wxCommandEvent& event ); void OnRunEeschema( wxCommandEvent& event ); + void OnUpdateCurvedRatsnest( wxUpdateUIEvent& aEvent ); void UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox, const bool aEdit = true ); void UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, const bool aEdit = true ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 077c8151bf..596ab476b3 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -136,6 +136,7 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOption m_sketchBoardGfx = !aOptions->m_DisplayDrawItemsFill; m_sketchFpGfx = !aOptions->m_DisplayModEdgeFill; m_sketchFpTxtfx = !aOptions->m_DisplayModTextFill; + m_curvedRatsnestlines = aOptions->m_DisplayRatsnestLinesCurved; // Whether to draw tracks, vias & pads filled or as outlines m_sketchMode[LAYER_PADS_TH] = !aOptions->m_DisplayPadFill; diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index 879ae6c962..5073690214 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -162,6 +162,11 @@ public: const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_CURSOR ]; } + inline bool GetCurvedRatsnestLinesEnabled() const + { + return m_curvedRatsnestlines; + } + protected: ///> Flag determining if items on a given layer should be drawn as an outline or a filled item bool m_sketchMode[GAL_LAYER_ID_END]; @@ -190,6 +195,9 @@ protected: ///> Flag determining if zones should have outlines drawn bool m_zoneOutlines; + ///> Flag determining if ratsnest lines should be drawn curved + bool m_curvedRatsnestlines = true; + ///> Maximum font size for netnames (and other dynamically shown strings) static const double MAX_FONT_SIZE; diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index b6025a526d..898a18f48b 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -197,6 +197,8 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() &displ_opts->m_DisplayDrawItemsFill, FILLED ) ); m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "PcbShowZonesMode" ), &displ_opts->m_DisplayZonesMode, 0, 0, 2 ) ); + m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "CurvedRatsnestLines" ), + &displ_opts->m_DisplayRatsnestLinesCurved, true ) ); // Miscellaneous: m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 0d18e2e006..eedca2d9cc 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -311,6 +311,7 @@ enum pcbnew_ids ID_TB_OPTIONS_SHOW_VIAS_SKETCH, ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, + ID_TB_OPTIONS_CURVED_RATSNEST_LINES, ID_DEC_LAYER_ALPHA, ID_INC_LAYER_ALPHA, ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE, diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp index 89944af8bc..91f55760ac 100644 --- a/pcbnew/ratsnest.cpp +++ b/pcbnew/ratsnest.cpp @@ -104,6 +104,10 @@ void PCB_BASE_FRAME::DrawGeneralRatsnest( wxDC* aDC, int aNetcode ) COLOR4D color = Settings().Colors().GetItemColor( LAYER_RATSNEST ); + auto displ_opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions(); + + const bool curved_ratsnest = displ_opts->m_DisplayRatsnestLinesCurved; + for( int i = 1 /* skip "No Net" at [0] */; i < connectivity->GetNetCount(); ++i ) { RN_NET* net = connectivity->GetRatsnestForNet( i ); @@ -128,8 +132,17 @@ void PCB_BASE_FRAME::DrawGeneralRatsnest( wxDC* aDC, int aNetcode ) || dn->Parent()->GetLocalRatsnestVisible(); if( enable && show ) - GRLine( m_canvas->GetClipBox(), aDC, wxPoint( s.x, s.y ), wxPoint( d.x, - d.y ), 0, color ); + { + if (curved_ratsnest) { + auto dx = d.x - s.x; + auto dy = d.y - s.y; + auto cx = s.x + 0.5 * dx + 1.2 * dy; + auto cy = s.y + 0.5 * dy - 1.2 * dx; + GRArc1( m_canvas->GetClipBox(), aDC, s.x, s.y, d.x, d.y, cx, cy, 0, color); + } else { + GRLine( m_canvas->GetClipBox(), aDC, s.x, s.y, d.x, d.y, 0, color ); + } + } } } } diff --git a/pcbnew/ratsnest_viewitem.cpp b/pcbnew/ratsnest_viewitem.cpp index 0c07bdb341..90b2690de2 100644 --- a/pcbnew/ratsnest_viewitem.cpp +++ b/pcbnew/ratsnest_viewitem.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -71,13 +72,15 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const gal->SetIsStroke( true ); gal->SetIsFill( false ); gal->SetLineWidth( 1.0 ); - auto rs = aView->GetPainter()->GetSettings(); + auto rs = static_cast(aView->GetPainter()->GetSettings()); auto color = rs->GetColor( NULL, LAYER_RATSNEST ); int highlightedNet = rs->GetHighlightNetCode(); gal->SetStrokeColor( color.Brightened(0.5) ); + const bool curved_ratsnest = rs->GetCurvedRatsnestLinesEnabled(); + // Draw the "dynamic" ratsnest (i.e. for objects that may be currently being moved) for( const auto& l : m_data->GetDynamicRatsnest() ) { @@ -145,7 +148,17 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const } else { - gal->DrawLine( source, target ); + if (curved_ratsnest) { + auto dx = target.x - source.x; + auto dy = target.y - source.y; + const auto center = VECTOR2I( + source.x + 0.5 * dx - 0.1 * dy, + source.y + 0.5 * dy + 0.1 * dx + ); + gal->DrawCurve( source, center, center, target ); + } else { + gal->DrawLine( source, target ); + } } } } diff --git a/pcbnew/tool_pcb_editor.cpp b/pcbnew/tool_pcb_editor.cpp index 0df204579a..e950f58cca 100644 --- a/pcbnew/tool_pcb_editor.cpp +++ b/pcbnew/tool_pcb_editor.cpp @@ -416,6 +416,10 @@ void PCB_EDIT_FRAME::ReCreateOptToolbar() KiScaledBitmap( contrast_mode_xpm, this ), _( "Enable high contrast display mode" ), wxITEM_CHECK ); + m_optionsToolBar->AddTool( ID_TB_OPTIONS_CURVED_RATSNEST_LINES, wxEmptyString, + KiScaledBitmap( curved_ratsnest_xpm, this ), + _( "Show ratsnest lines with curved lines" ), + wxITEM_CHECK ); // Tools to show/hide toolbars: KiScaledSeparator( m_optionsToolBar, this ); @@ -837,6 +841,13 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) break; } + case ID_TB_OPTIONS_CURVED_RATSNEST_LINES: + { + displ_opts->m_DisplayRatsnestLinesCurved = !state; + m_canvas->Refresh(); + break; + } + case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE: m_show_microwave_tools = state; m_auimgr.GetPane( "MicrowaveToolbar" ).Show( m_show_microwave_tools ); diff --git a/pcbnew/toolbars_update_user_interface.cpp b/pcbnew/toolbars_update_user_interface.cpp index 28b9ca0524..e67265e5de 100644 --- a/pcbnew/toolbars_update_user_interface.cpp +++ b/pcbnew/toolbars_update_user_interface.cpp @@ -147,6 +147,16 @@ void PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode( wxUpdateUIEvent& aEvent ) _( "High contrast display mode" ) ); } +void PCB_EDIT_FRAME::OnUpdateCurvedRatsnest( wxUpdateUIEvent& aEvent ) +{ + auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions(); + aEvent.Check( !displ_opts->m_DisplayRatsnestLinesCurved ); + m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_CURVED_RATSNEST_LINES, + displ_opts->m_DisplayRatsnestLinesCurved ? + _( "Show ratlines as curves" ) : + _( "Show ratlines as straight lines" ) ); +} + void PCB_EDIT_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent ) { diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index 7c53917c0b..564f1fdc26 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -120,6 +120,9 @@ OPT PCB_ACTIONS::TranslateLegacyId( int aId ) case ID_VIEWER_ZOOM_PAGE: return ACTIONS::zoomFitScreen.MakeEvent(); + case ID_TB_OPTIONS_CURVED_RATSNEST_LINES: + return PCB_ACTIONS::ratsnestLineMode.MakeEvent(); + case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH: return PCB_ACTIONS::trackDisplayMode.MakeEvent(); diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index a70b4e89b2..34b3cd1056 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -262,6 +262,7 @@ public: static TOOL_ACTION selectpositionRelativeItem; // Display modes + static TOOL_ACTION ratsnestLineMode; static TOOL_ACTION trackDisplayMode; static TOOL_ACTION padDisplayMode; static TOOL_ACTION viaDisplayMode; diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index e4045d183f..3bc46bf94f 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -68,6 +68,10 @@ extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl ); // Display modes +TOOL_ACTION PCB_ACTIONS::ratsnestLineMode( "pcbnew.Control.ratsnestLineMode", + AS_GLOBAL, 0, + "", "" ); + TOOL_ACTION PCB_ACTIONS::trackDisplayMode( "pcbnew.Control.trackDisplayMode", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_TRACK_DISPLAY_MODE ), "", "" ); @@ -257,6 +261,18 @@ int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent ) return 0; } +int PCBNEW_CONTROL::RatsnestLineMode( const TOOL_EVENT& aEvent ) +{ + auto opts = displayOptions(); + + Flip( opts->m_DisplayRatsnestLinesCurved ); + view()->UpdateDisplayOptions( opts ); + canvas()->RedrawRatsnest(); + canvas()->Refresh(); + + return 0; +} + int PCBNEW_CONTROL::PadDisplayMode( const TOOL_EVENT& aEvent ) { auto opts = displayOptions(); @@ -996,6 +1012,7 @@ void PCBNEW_CONTROL::setTransitions() { // Display modes Go( &PCBNEW_CONTROL::TrackDisplayMode, PCB_ACTIONS::trackDisplayMode.MakeEvent() ); + Go( &PCBNEW_CONTROL::RatsnestLineMode, PCB_ACTIONS::ratsnestLineMode.MakeEvent() ); Go( &PCBNEW_CONTROL::PadDisplayMode, PCB_ACTIONS::padDisplayMode.MakeEvent() ); Go( &PCBNEW_CONTROL::ViaDisplayMode, PCB_ACTIONS::viaDisplayMode.MakeEvent() ); Go( &PCBNEW_CONTROL::GraphicDisplayMode, PCB_ACTIONS::graphicDisplayMode.MakeEvent() ); diff --git a/pcbnew/tools/pcbnew_control.h b/pcbnew/tools/pcbnew_control.h index 90451f4a36..42585caf69 100644 --- a/pcbnew/tools/pcbnew_control.h +++ b/pcbnew/tools/pcbnew_control.h @@ -51,6 +51,7 @@ public: void Reset( RESET_REASON aReason ) override; // Display modes + int RatsnestLineMode( const TOOL_EVENT& aEvent ); int ZoneDisplayMode( const TOOL_EVENT& aEvent ); int TrackDisplayMode( const TOOL_EVENT& aEvent ); int PadDisplayMode( const TOOL_EVENT& aEvent );