From daad58e511548029add1e99d125582077018fbd7 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 12 Jun 2019 17:32:47 -0700 Subject: [PATCH] pcbnew: Add option to show ratsnest while moving Re-works ratsnest display options in the configuration parameters rather than the board file. Moves ratsnest options to central preferences location. Fixes: lp:1826440 * https://bugs.launchpad.net/kicad/+bug/1826440 Fixes: lp:1821183 * https://bugs.launchpad.net/kicad/+bug/1821183 --- include/layers_id_colors_and_visibility.h | 3 +- include/pcb_display_options.h | 7 +- pcbnew/class_board.cpp | 9 - pcbnew/dialogs/dialog_exchange_footprints.cpp | 4 +- .../dialogs/panel_pcbnew_display_options.cpp | 7 +- .../panel_pcbnew_display_options_base.cpp | 65 +- .../panel_pcbnew_display_options_base.fbp | 268 +------- .../panel_pcbnew_display_options_base.h | 21 +- pcbnew/dialogs/panel_pcbnew_settings.cpp | 14 + pcbnew/dialogs/panel_pcbnew_settings_base.cpp | 119 ++-- pcbnew/dialogs/panel_pcbnew_settings_base.fbp | 610 +++++++----------- pcbnew/dialogs/panel_pcbnew_settings_base.h | 23 +- pcbnew/initpcb.cpp | 2 +- pcbnew/load_select_footprint.cpp | 3 +- pcbnew/menubar_pcb_editor.cpp | 37 +- pcbnew/pcb_display_options.cpp | 5 +- pcbnew/pcb_edit_frame.cpp | 14 +- pcbnew/pcb_general_settings.cpp | 1 - pcbnew/pcb_layer_widget.cpp | 18 +- pcbnew/pcb_painter.cpp | 1 + pcbnew/pcb_painter.h | 8 + pcbnew/pcbnew_config.cpp | 4 + pcbnew/ratsnest_viewitem.cpp | 6 +- pcbnew/toolbars_pcb_editor.cpp | 3 +- pcbnew/tools/edit_tool.cpp | 1 - pcbnew/tools/pcb_editor_control.cpp | 20 +- pcbnew/tools/pcbnew_control.cpp | 8 +- 27 files changed, 458 insertions(+), 823 deletions(-) diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index 3cb97fbfef..1d4933f8dd 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -317,7 +317,8 @@ enum GERBVIEW_LAYER_ID: int ( 1 << GAL_LAYER_INDEX( LAYER_VIAS_HOLES ) ) +\ ( 1 << GAL_LAYER_INDEX( LAYER_DRC ) ) +\ ( 1 << GAL_LAYER_INDEX( LAYER_SELECT_OVERLAY ) ) +\ - ( 1 << GAL_LAYER_INDEX( LAYER_GP_OVERLAY ) ) ) + ( 1 << GAL_LAYER_INDEX( LAYER_GP_OVERLAY ) ) +\ + ( 1 << GAL_LAYER_INDEX( LAYER_RATSNEST ) ) ) /// A sequence of layers, a sequence provides a certain order. diff --git a/include/pcb_display_options.h b/include/pcb_display_options.h index 76cc30f2c3..76e018c3ad 100644 --- a/include/pcb_display_options.h +++ b/include/pcb_display_options.h @@ -79,10 +79,11 @@ public: * 3 show netnames on tracks and pads */ - bool m_DisplayDrawItemsFill; // How to display graphic items on board ( sketch/ filled ) + bool m_DisplayDrawItemsFill; // How to display graphic items on board ( sketch/ filled ) 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 + int m_MaxLinksShowed; // in track creation: number of hairwires shown + bool m_ShowModuleRatsnest; // When moving a footprint: allows displaying a ratsnest + bool m_ShowGlobalRatsnest; // If true, show all bool m_DisplayRatsnestLinesCurved; // Airwires can be drawn as straight lines (false) // or curved lines (true) diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index aad7616c8b..9b28aeb330 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -486,18 +486,9 @@ void BOARD::SetElementVisibility( GAL_LAYER_ID aLayer, bool isEnabled ) { case LAYER_RATSNEST: { - bool visible = IsElementVisible( LAYER_RATSNEST ); - // we must clear or set the CH_VISIBLE flags to hide/show ratsnest // because we have a tool to show/hide ratsnest relative to a pad or a module // so the hide/show option is a per item selection - for( unsigned int net = 1 /* skip "No Net" at [0] */; net < GetNetCount(); net++ ) - { - auto rn = GetConnectivity()->GetRatsnestForNet( net ); - if( rn ) - rn->SetVisible( visible ); - } - for( auto track : Tracks() ) track->SetLocalRatsnestVisible( isEnabled ); diff --git a/pcbnew/dialogs/dialog_exchange_footprints.cpp b/pcbnew/dialogs/dialog_exchange_footprints.cpp index c6da11ae79..d60be885cd 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints.cpp +++ b/pcbnew/dialogs/dialog_exchange_footprints.cpp @@ -272,9 +272,7 @@ void DIALOG_EXCHANGE_FOOTPRINTS::OnApplyClicked( wxCommandEvent& event ) if( processMatchingModules() ) { - if( m_parent->GetBoard()->IsElementVisible( LAYER_RATSNEST ) ) - m_parent->Compile_Ratsnest( true ); - + m_parent->Compile_Ratsnest( true ); m_parent->GetGalCanvas()->Refresh(); } diff --git a/pcbnew/dialogs/panel_pcbnew_display_options.cpp b/pcbnew/dialogs/panel_pcbnew_display_options.cpp index 8bc14a83e5..08f86290cf 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_options.cpp +++ b/pcbnew/dialogs/panel_pcbnew_display_options.cpp @@ -65,7 +65,6 @@ bool PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataToWindow() m_OptDisplayPadNumber->SetValue( displ_opts->m_DisplayPadNum ); m_OptDisplayPadNoConn->SetValue( m_frame->IsElementVisible( LAYER_NO_CONNECTS ) ); m_ShowNetNamesOption->SetSelection( displ_opts->m_DisplayNetNamesMode ); - m_OptDisplayCurvedRatsnestLines->SetValue( displ_opts->m_DisplayRatsnestLinesCurved ); m_galOptsPanel->TransferDataToWindow(); @@ -89,7 +88,6 @@ bool PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow() m_frame->SetElementVisibility( LAYER_NO_CONNECTS, m_OptDisplayPadNoConn->GetValue() ); displ_opts->m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection(); - displ_opts->m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue(); m_galOptsPanel->TransferDataFromWindow(); @@ -97,12 +95,13 @@ bool PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow() KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView(); KIGFX::PCB_PAINTER* painter = static_cast( view->GetPainter() ); KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings(); + settings->LoadDisplayOptions( displ_opts, m_frame->ShowPageLimits() ); + m_frame->SetElementVisibility( LAYER_RATSNEST, displ_opts->m_ShowGlobalRatsnest ); + view->RecacheAllItems(); view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); - m_frame->GetGalCanvas()->Refresh(); - return true; } diff --git a/pcbnew/dialogs/panel_pcbnew_display_options_base.cpp b/pcbnew/dialogs/panel_pcbnew_display_options_base.cpp index 0e9004b94a..4d0d9ad9c5 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_options_base.cpp +++ b/pcbnew/dialogs/panel_pcbnew_display_options_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Apr 23 2019) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -9,77 +9,68 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_PCBNEW_DISPLAY_OPTIONS_BASE::PANEL_PCBNEW_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) +PANEL_PCBNEW_DISPLAY_OPTIONS_BASE::PANEL_PCBNEW_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) { wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); - + wxBoxSizer* bupperSizer; bupperSizer = new wxBoxSizer( wxHORIZONTAL ); - + m_galOptionsSizer = new wxBoxSizer( wxVERTICAL ); - - + + bupperSizer->Add( m_galOptionsSizer, 1, wxEXPAND, 5 ); - + wxBoxSizer* bRightSizer; bRightSizer = new wxBoxSizer( wxVERTICAL ); - + wxStaticBoxSizer* sbAnnotations; sbAnnotations = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Annotations") ), wxVERTICAL ); - + wxString m_ShowNetNamesOptionChoices[] = { _("Do not show"), _("Show on pads"), _("Show on tracks"), _("Show on pads and tracks") }; int m_ShowNetNamesOptionNChoices = sizeof( m_ShowNetNamesOptionChoices ) / sizeof( wxString ); m_ShowNetNamesOption = new wxRadioBox( sbAnnotations->GetStaticBox(), wxID_ANY, _("Net Names"), wxDefaultPosition, wxDefaultSize, m_ShowNetNamesOptionNChoices, m_ShowNetNamesOptionChoices, 1, wxRA_SPECIFY_COLS ); m_ShowNetNamesOption->SetSelection( 0 ); m_ShowNetNamesOption->SetToolTip( _("Show or hide net names on pads and/or tracks.") ); - + sbAnnotations->Add( m_ShowNetNamesOption, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + m_OptDisplayPadNumber = new wxCheckBox( sbAnnotations->GetStaticBox(), wxID_ANY, _("Show pad numbers"), wxDefaultPosition, wxDefaultSize, 0 ); - m_OptDisplayPadNumber->SetValue(true); + m_OptDisplayPadNumber->SetValue(true); sbAnnotations->Add( m_OptDisplayPadNumber, 0, wxALL, 6 ); - + m_OptDisplayPadNoConn = new wxCheckBox( sbAnnotations->GetStaticBox(), wxID_ANY, _("Show pad indicator"), wxDefaultPosition, wxDefaultSize, 0 ); - m_OptDisplayPadNoConn->SetValue(true); + m_OptDisplayPadNoConn->SetValue(true); sbAnnotations->Add( m_OptDisplayPadNoConn, 0, wxBOTTOM|wxLEFT|wxRIGHT, 6 ); - - + + bRightSizer->Add( sbAnnotations, 0, wxEXPAND|wxBOTTOM, 5 ); - + wxStaticBoxSizer* sbClearance; sbClearance = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Clearance Outlines") ), wxVERTICAL ); - + wxString m_OptDisplayTracksClearanceChoices[] = { _("Do not show"), _("Show when creating tracks"), _("Show with via clearance at end"), _("Show when creating and editing tracks"), _("Show always") }; int m_OptDisplayTracksClearanceNChoices = sizeof( m_OptDisplayTracksClearanceChoices ) / sizeof( wxString ); m_OptDisplayTracksClearance = new wxRadioBox( sbClearance->GetStaticBox(), ID_SHOW_CLEARANCE, _("Track Clearance"), wxDefaultPosition, wxDefaultSize, m_OptDisplayTracksClearanceNChoices, m_OptDisplayTracksClearanceChoices, 1, wxRA_SPECIFY_COLS ); m_OptDisplayTracksClearance->SetSelection( 2 ); m_OptDisplayTracksClearance->SetToolTip( _("Show or hide the track and via clearance area. If \"New track\" is selected, track clearance area is shown only when creating the track.") ); - + sbClearance->Add( m_OptDisplayTracksClearance, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + m_OptDisplayPadClearence = new wxCheckBox( sbClearance->GetStaticBox(), wxID_ANY, _("Show pad clearance"), wxDefaultPosition, wxDefaultSize, 0 ); sbClearance->Add( m_OptDisplayPadClearence, 0, wxALL, 6 ); - - + + bRightSizer->Add( sbClearance, 0, wxBOTTOM|wxEXPAND|wxTOP, 5 ); - - wxStaticBoxSizer* sbGeneral; - sbGeneral = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("General") ), wxVERTICAL ); - - m_OptDisplayCurvedRatsnestLines = new wxCheckBox( sbGeneral->GetStaticBox(), wxID_ANY, _("Show ratsnest with curved lines"), wxDefaultPosition, wxDefaultSize, 0 ); - sbGeneral->Add( m_OptDisplayCurvedRatsnestLines, 0, wxBOTTOM|wxRIGHT|wxLEFT, 6 ); - - - bRightSizer->Add( sbGeneral, 0, wxEXPAND|wxTOP, 5 ); - - + + bupperSizer->Add( bRightSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - + + bMainSizer->Add( bupperSizer, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - - + + this->SetSizer( bMainSizer ); this->Layout(); bMainSizer->Fit( this ); diff --git a/pcbnew/dialogs/panel_pcbnew_display_options_base.fbp b/pcbnew/dialogs/panel_pcbnew_display_options_base.fbp index a16a5c7eb6..5195c7ce34 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_options_base.fbp +++ b/pcbnew/dialogs/panel_pcbnew_display_options_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,8 @@ panel_pcbnew_display_options_base 1000 none + + 1 PanelPcbnewDisplayOptions @@ -24,6 +26,7 @@ 1 1 UI + 0 1 0 @@ -48,36 +51,6 @@ wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bMainSizer @@ -112,11 +85,11 @@ bRightSizer wxVERTICAL none - + 5 wxEXPAND|wxBOTTOM 0 - + wxID_ANY Annotations @@ -124,7 +97,6 @@ wxVERTICAL 1 none - 5 wxEXPAND|wxRIGHT|wxLEFT @@ -189,30 +161,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -277,30 +225,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -365,39 +289,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + 5 wxBOTTOM|wxEXPAND|wxTOP 0 - + wxID_ANY Clearance Outlines @@ -405,7 +305,6 @@ wxVERTICAL 1 none - 5 wxEXPAND|wxRIGHT|wxLEFT @@ -470,30 +369,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -558,133 +433,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP - 0 - - wxID_ANY - General - - sbGeneral - wxVERTICAL - 1 - none - - - 6 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Show ratsnest with curved lines - - 0 - - - 0 - - 1 - m_OptDisplayCurvedRatsnestLines - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pcbnew/dialogs/panel_pcbnew_display_options_base.h b/pcbnew/dialogs/panel_pcbnew_display_options_base.h index baeec049bf..33f91b1c23 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_options_base.h +++ b/pcbnew/dialogs/panel_pcbnew_display_options_base.h @@ -1,12 +1,11 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Apr 23 2019) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __PANEL_PCBNEW_DISPLAY_OPTIONS_BASE_H__ -#define __PANEL_PCBNEW_DISPLAY_OPTIONS_BASE_H__ +#pragma once #include #include @@ -27,29 +26,27 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_PCBNEW_DISPLAY_OPTIONS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_PCBNEW_DISPLAY_OPTIONS_BASE : public wxPanel +class PANEL_PCBNEW_DISPLAY_OPTIONS_BASE : public wxPanel { private: - + protected: enum { ID_SHOW_CLEARANCE = 1000 }; - + wxBoxSizer* m_galOptionsSizer; wxRadioBox* m_ShowNetNamesOption; wxCheckBox* m_OptDisplayPadNumber; wxCheckBox* m_OptDisplayPadNoConn; wxRadioBox* m_OptDisplayTracksClearance; wxCheckBox* m_OptDisplayPadClearence; - wxCheckBox* m_OptDisplayCurvedRatsnestLines; - + public: - - PANEL_PCBNEW_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL ); + + PANEL_PCBNEW_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); ~PANEL_PCBNEW_DISPLAY_OPTIONS_BASE(); - + }; -#endif //__PANEL_PCBNEW_DISPLAY_OPTIONS_BASE_H__ diff --git a/pcbnew/dialogs/panel_pcbnew_settings.cpp b/pcbnew/dialogs/panel_pcbnew_settings.cpp index 66f0ea45b9..35c06fe490 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings.cpp +++ b/pcbnew/dialogs/panel_pcbnew_settings.cpp @@ -41,9 +41,15 @@ PANEL_PCBNEW_SETTINGS::PANEL_PCBNEW_SETTINGS( PCB_EDIT_FRAME* aFrame, PAGED_DIAL bool PANEL_PCBNEW_SETTINGS::TransferDataToWindow() { + const PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) m_Frame->GetDisplayOptions(); + /* Set display options */ m_PolarDisplay->SetSelection( m_Frame->GetShowPolarCoords() ? 1 : 0 ); m_UnitsSelection->SetSelection( m_Frame->GetUserUnits() == INCHES ? 0 : 1 ); + m_OptDisplayCurvedRatsnestLines->SetValue( displ_opts->m_DisplayRatsnestLinesCurved ); + m_showGlobalRatsnest->SetValue( displ_opts->m_ShowGlobalRatsnest ); + m_showSelectedRatsnest->SetValue( displ_opts->m_ShowModuleRatsnest ); + m_OptDisplayCurvedRatsnestLines->SetValue( displ_opts->m_DisplayRatsnestLinesCurved ); wxString rotationAngle; rotationAngle = AngleToStringDegrees( (double)m_Frame->GetRotationAngle() ); @@ -86,7 +92,15 @@ bool PANEL_PCBNEW_SETTINGS::TransferDataFromWindow() KIGFX::PCB_PAINTER* painter = static_cast( view->GetPainter() ); KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings(); + displ_opts->m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue(); + displ_opts->m_ShowGlobalRatsnest = m_showGlobalRatsnest->GetValue(); + displ_opts->m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue(); + settings->LoadDisplayOptions( displ_opts, m_Frame->ShowPageLimits() ); + view->RecacheAllItems(); + view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); + + m_Frame->GetGalCanvas()->Refresh(); return true; } diff --git a/pcbnew/dialogs/panel_pcbnew_settings_base.cpp b/pcbnew/dialogs/panel_pcbnew_settings_base.cpp index ed421a25ef..f35cff29cf 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings_base.cpp +++ b/pcbnew/dialogs/panel_pcbnew_settings_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Apr 23 2019) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -9,145 +9,160 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_PCBNEW_SETTINGS_BASE::PANEL_PCBNEW_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) +PANEL_PCBNEW_SETTINGS_BASE::PANEL_PCBNEW_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) { wxBoxSizer* bPanelSizer; bPanelSizer = new wxBoxSizer( wxHORIZONTAL ); - + wxBoxSizer* bMargins; bMargins = new wxBoxSizer( wxHORIZONTAL ); - + wxBoxSizer* bMiddleLeftSizer; bMiddleLeftSizer = new wxBoxSizer( wxVERTICAL ); - + wxString m_PolarDisplayChoices[] = { _("Cartesian coordinates"), _("Polar coordinates") }; int m_PolarDisplayNChoices = sizeof( m_PolarDisplayChoices ) / sizeof( wxString ); m_PolarDisplay = new wxRadioBox( this, wxID_POLAR_CTRL, _("Coordinates"), wxDefaultPosition, wxDefaultSize, m_PolarDisplayNChoices, m_PolarDisplayChoices, 1, wxRA_SPECIFY_COLS ); m_PolarDisplay->SetSelection( 0 ); m_PolarDisplay->SetToolTip( _("Set display of relative (dx/dy) coordinates to Cartesian (rectangular) or polar (angle/distance).") ); - + bMiddleLeftSizer->Add( m_PolarDisplay, 0, wxALL|wxEXPAND, 5 ); - + wxString m_UnitsSelectionChoices[] = { _("Inches"), _("Millimeters") }; int m_UnitsSelectionNChoices = sizeof( m_UnitsSelectionChoices ) / sizeof( wxString ); m_UnitsSelection = new wxRadioBox( this, wxID_UNITS, _("Units"), wxDefaultPosition, wxDefaultSize, m_UnitsSelectionNChoices, m_UnitsSelectionChoices, 1, wxRA_SPECIFY_COLS ); m_UnitsSelection->SetSelection( 0 ); m_UnitsSelection->SetToolTip( _("Set units used to display dimensions and positions.") ); - + bMiddleLeftSizer->Add( m_UnitsSelection, 0, wxALL|wxEXPAND, 5 ); - + wxStaticBoxSizer* bOptionsSizer; bOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Editing Options") ), wxVERTICAL ); - + m_Show_Page_Limits = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_ANY, _("Show page limits"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Show_Page_Limits->SetValue(true); + m_Show_Page_Limits->SetValue(true); bOptionsSizer->Add( m_Show_Page_Limits, 0, wxALL, 5 ); - + m_Segments_45_Only_Ctrl = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_SEGMENTS45, _("L&imit graphic lines to H, V and 45 degrees"), wxDefaultPosition, wxDefaultSize, 0 ); m_Segments_45_Only_Ctrl->SetToolTip( _("Force line segment directions to H, V or 45 degrees when drawing on technical layers.") ); - + bOptionsSizer->Add( m_Segments_45_Only_Ctrl, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - + m_UseEditKeyForWidth = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_ANY, _("Edit hotkey changes track width"), wxDefaultPosition, wxDefaultSize, 0 ); m_UseEditKeyForWidth->SetToolTip( _("When active, hitting Edit hotkey or double-clicking on a track or via changes its width/diameter to the one selected in the main toolbar. ") ); - + bOptionsSizer->Add( m_UseEditKeyForWidth, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - + m_dragSelects = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_ANY, _("Prefer selection to dragging"), wxDefaultPosition, wxDefaultSize, 0 ); m_dragSelects->SetToolTip( _("When enabled and nothing is selected, drag gesture will draw a selection box, even if there are items under the cursor that could be immediately dragged.") ); - + bOptionsSizer->Add( m_dragSelects, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - + wxFlexGridSizer* fgSizer12; fgSizer12 = new wxFlexGridSizer( 0, 2, 0, 0 ); fgSizer12->AddGrowableCol( 1 ); fgSizer12->SetFlexibleDirection( wxBOTH ); fgSizer12->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_staticTextRotationAngle = new wxStaticText( bOptionsSizer->GetStaticBox(), wxID_ANY, _("&Rotation angle:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextRotationAngle->Wrap( -1 ); fgSizer12->Add( m_staticTextRotationAngle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - + m_RotationAngle = new wxTextCtrl( bOptionsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_RotationAngle->SetToolTip( _("Set increment (in degrees) for context menu and hotkey rotation.") ); - + fgSizer12->Add( m_RotationAngle, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); - - + + bOptionsSizer->Add( fgSizer12, 1, wxEXPAND, 5 ); - - + + bMiddleLeftSizer->Add( bOptionsSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - + + bMargins->Add( bMiddleLeftSizer, 1, wxEXPAND|wxRIGHT, 5 ); - + wxBoxSizer* bRightSizer; bRightSizer = new wxBoxSizer( wxVERTICAL ); - + wxStaticBoxSizer* sbMagnets; sbMagnets = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Magnetic Points") ), wxVERTICAL ); - + wxFlexGridSizer* fgSizer2; fgSizer2 = new wxFlexGridSizer( 0, 2, 3, 0 ); fgSizer2->SetFlexibleDirection( wxBOTH ); fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_staticText2 = new wxStaticText( sbMagnets->GetStaticBox(), wxID_ANY, _("Snap to pads:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText2->Wrap( -1 ); m_staticText2->SetToolTip( _("Capture cursor when the mouse enters a pad area") ); - + fgSizer2->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - + wxString m_magneticPadChoiceChoices[] = { _("Never"), _("When creating tracks"), _("Always") }; int m_magneticPadChoiceNChoices = sizeof( m_magneticPadChoiceChoices ) / sizeof( wxString ); m_magneticPadChoice = new wxChoice( sbMagnets->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_magneticPadChoiceNChoices, m_magneticPadChoiceChoices, 0 ); m_magneticPadChoice->SetSelection( 1 ); m_magneticPadChoice->SetToolTip( _("Capture cursor when the mouse enters a pad area") ); - + fgSizer2->Add( m_magneticPadChoice, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + m_staticText21 = new wxStaticText( sbMagnets->GetStaticBox(), wxID_ANY, _("Snap to tracks:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText21->Wrap( -1 ); m_staticText21->SetToolTip( _("Capture cursor when the mouse approaches a track") ); - + fgSizer2->Add( m_staticText21, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - + wxString m_magneticTrackChoiceChoices[] = { _("Never"), _("When creating tracks"), _("Always") }; int m_magneticTrackChoiceNChoices = sizeof( m_magneticTrackChoiceChoices ) / sizeof( wxString ); m_magneticTrackChoice = new wxChoice( sbMagnets->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_magneticTrackChoiceNChoices, m_magneticTrackChoiceChoices, 0 ); m_magneticTrackChoice->SetSelection( 1 ); m_magneticTrackChoice->SetToolTip( _("Capture cursor when the mouse approaches a track") ); - + fgSizer2->Add( m_magneticTrackChoice, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - + m_staticText211 = new wxStaticText( sbMagnets->GetStaticBox(), wxID_ANY, _("Snap to graphics:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText211->Wrap( -1 ); m_staticText211->SetToolTip( _("Capture cursor when the mouse approaches graphical control points") ); - + fgSizer2->Add( m_staticText211, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - + wxString m_magneticGraphicsChoiceChoices[] = { _("Always"), _("Never") }; int m_magneticGraphicsChoiceNChoices = sizeof( m_magneticGraphicsChoiceChoices ) / sizeof( wxString ); m_magneticGraphicsChoice = new wxChoice( sbMagnets->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_magneticGraphicsChoiceNChoices, m_magneticGraphicsChoiceChoices, 0 ); m_magneticGraphicsChoice->SetSelection( 0 ); m_magneticGraphicsChoice->SetToolTip( _("Capture cursor when the mouse approaches graphical control points") ); - + fgSizer2->Add( m_magneticGraphicsChoice, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - - + + sbMagnets->Add( fgSizer2, 1, wxEXPAND, 5 ); - - + + bRightSizer->Add( sbMagnets, 1, wxEXPAND, 5 ); - - + + wxStaticBoxSizer* sbSizer3; + sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Ratsnest") ), wxVERTICAL ); + + m_showGlobalRatsnest = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Show ratsnest"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizer3->Add( m_showGlobalRatsnest, 0, wxALL, 5 ); + + m_showSelectedRatsnest = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Always show selected ratsnest"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizer3->Add( m_showSelectedRatsnest, 0, wxALL, 5 ); + + m_OptDisplayCurvedRatsnestLines = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Show ratsnest with curved lines"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizer3->Add( m_OptDisplayCurvedRatsnestLines, 0, wxALL, 5 ); + + + bRightSizer->Add( sbSizer3, 1, wxEXPAND, 5 ); + + bMargins->Add( bRightSizer, 1, wxEXPAND|wxTOP|wxRIGHT, 5 ); - - + + bPanelSizer->Add( bMargins, 1, wxRIGHT, 5 ); - - + + this->SetSizer( bPanelSizer ); this->Layout(); bPanelSizer->Fit( this ); diff --git a/pcbnew/dialogs/panel_pcbnew_settings_base.fbp b/pcbnew/dialogs/panel_pcbnew_settings_base.fbp index 151b353d11..1f177f7057 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings_base.fbp +++ b/pcbnew/dialogs/panel_pcbnew_settings_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,8 @@ panel_pcbnew_settings_base 1000 none + + 1 PanelPcbnewSettings @@ -24,6 +26,7 @@ 1 1 UI + 0 1 0 @@ -48,36 +51,6 @@ wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bPanelSizer @@ -165,30 +138,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -255,30 +204,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -293,7 +218,6 @@ wxVERTICAL 1 none - 5 wxALL @@ -356,30 +280,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -444,30 +344,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -532,30 +408,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -599,7 +451,7 @@ 0 1 - g_DragSelects + m_dragSelects 1 @@ -620,30 +472,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -695,6 +523,7 @@ 0 wxID_ANY &Rotation angle: + 0 0 @@ -720,29 +549,6 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -807,33 +613,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -863,12 +642,11 @@ wxVERTICAL 1 none - 5 wxEXPAND 1 - + 2 wxBOTH @@ -880,11 +658,11 @@ none 0 3 - + 5 wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -913,6 +691,7 @@ 0 wxID_ANY Snap to pads: + 0 0 @@ -938,36 +717,13 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - - + 5 wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -1025,37 +781,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + 5 wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -1084,6 +816,7 @@ 0 wxID_ANY Snap to tracks: + 0 0 @@ -1109,36 +842,13 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - - + 5 wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT 0 - + 1 1 1 @@ -1196,37 +906,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + 5 wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -1255,6 +941,7 @@ 0 wxID_ANY Snap to graphics: + 0 0 @@ -1280,36 +967,13 @@ -1 - - - - - - - - - - - - - - - - - - - - - - - - + 5 wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT 0 - + 1 1 1 @@ -1367,36 +1031,218 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + 5 + wxEXPAND + 1 + + wxID_ANY + Ratsnest + + sbSizer3 + wxVERTICAL + 1 + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show ratsnest + + 0 + + + 0 + + 1 + m_showGlobalRatsnest + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Always show selected ratsnest + + 0 + + + 0 + + 1 + m_showSelectedRatsnest + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show ratsnest with curved lines + + 0 + + + 0 + + 1 + m_OptDisplayCurvedRatsnestLines + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + diff --git a/pcbnew/dialogs/panel_pcbnew_settings_base.h b/pcbnew/dialogs/panel_pcbnew_settings_base.h index 620908eff6..002e112b62 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings_base.h +++ b/pcbnew/dialogs/panel_pcbnew_settings_base.h @@ -1,12 +1,11 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Apr 23 2019) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __PANEL_PCBNEW_SETTINGS_BASE_H__ -#define __PANEL_PCBNEW_SETTINGS_BASE_H__ +#pragma once #include #include @@ -30,10 +29,10 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_PCBNEW_SETTINGS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_PCBNEW_SETTINGS_BASE : public wxPanel +class PANEL_PCBNEW_SETTINGS_BASE : public wxPanel { private: - + protected: enum { @@ -41,7 +40,7 @@ class PANEL_PCBNEW_SETTINGS_BASE : public wxPanel wxID_UNITS, wxID_SEGMENTS45 }; - + wxRadioBox* m_PolarDisplay; wxRadioBox* m_UnitsSelection; wxCheckBox* m_Show_Page_Limits; @@ -56,12 +55,14 @@ class PANEL_PCBNEW_SETTINGS_BASE : public wxPanel wxChoice* m_magneticTrackChoice; wxStaticText* m_staticText211; wxChoice* m_magneticGraphicsChoice; - + wxCheckBox* m_showGlobalRatsnest; + wxCheckBox* m_showSelectedRatsnest; + wxCheckBox* m_OptDisplayCurvedRatsnestLines; + public: - - PANEL_PCBNEW_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL ); + + PANEL_PCBNEW_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); ~PANEL_PCBNEW_SETTINGS_BASE(); - + }; -#endif //__PANEL_PCBNEW_SETTINGS_BASE_H__ diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index 03ad1a8959..7685463b10 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -58,7 +58,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery, bool aFinal ) // Items visibility flags will be set because a new board will be created. // Grid and ratsnest can be left to their previous state bool showGrid = IsElementVisible( LAYER_GRID ); - bool showRats = IsElementVisible( LAYER_RATSNEST ); + bool showRats = m_DisplayOptions.m_ShowGlobalRatsnest; if( !aFinal ) { diff --git a/pcbnew/load_select_footprint.cpp b/pcbnew/load_select_footprint.cpp index 5b4592e355..f1e4353c8b 100644 --- a/pcbnew/load_select_footprint.cpp +++ b/pcbnew/load_select_footprint.cpp @@ -509,8 +509,7 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, bool aRecreateRatsnest ) if( aRecreateRatsnest ) m_Pcb->GetConnectivity()->Update( aModule ); - if( ( GetBoard()->IsElementVisible( LAYER_RATSNEST ) || displ_opts->m_Show_Module_Ratsnest ) - && aRecreateRatsnest ) + if( aRecreateRatsnest ) Compile_Ratsnest( true ); SetMsgPanel( aModule ); diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 23aa94c99c..e3beb0a54e 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -59,6 +59,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() // CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool ); static ACTION_MENU* openRecentMenu; + auto disp_opt = static_cast( GetDisplayOptions() ); if( Kiface().IsSingle() ) // not when under a project mgr { @@ -266,35 +267,35 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() auto fullCrosshairCondition = [ this ] ( const SELECTION& aSel ) { return GetGalDisplayOptions().m_fullscreenCursor; }; - auto ratsnestShownCondition = [ this ] ( const SELECTION& aSel ) { - return GetBoard()->IsElementVisible( LAYER_RATSNEST ); + auto ratsnestShownCondition = [ this, disp_opt ] ( const SELECTION& aSel ) { + return disp_opt->m_ShowGlobalRatsnest; }; - auto curvedRatsnestCondition = [ this ] ( const SELECTION& aSel ) { - return ( (PCB_DISPLAY_OPTIONS*) GetDisplayOptions() )->m_DisplayRatsnestLinesCurved; + auto curvedRatsnestCondition = [ this, disp_opt ] ( const SELECTION& aSel ) { + return disp_opt->m_DisplayRatsnestLinesCurved; }; auto boardFlippedCondition = [ this ] ( const SELECTION& aSel ) { return GetGalCanvas()->GetView()->IsMirroredX(); }; - auto zonesFilledCondition = [ this ] ( const SELECTION& aSel ) { - return ( (PCB_DISPLAY_OPTIONS*) GetDisplayOptions() )->m_DisplayZonesMode == 0; + auto zonesFilledCondition = [ this, disp_opt ] ( const SELECTION& aSel ) { + return disp_opt->m_DisplayZonesMode == 0; }; - auto zonesWireframedCondition = [ this ] ( const SELECTION& aSel ) { - return ( (PCB_DISPLAY_OPTIONS*) GetDisplayOptions() )->m_DisplayZonesMode == 1; + auto zonesWireframedCondition = [ this, disp_opt ] ( const SELECTION& aSel ) { + return disp_opt->m_DisplayZonesMode == 1; }; - auto zonesOutlinedCondition = [ this ] ( const SELECTION& aSel ) { - return ( (PCB_DISPLAY_OPTIONS*) GetDisplayOptions() )->m_DisplayZonesMode == 2; + auto zonesOutlinedCondition = [ this, disp_opt ] ( const SELECTION& aSel ) { + return disp_opt->m_DisplayZonesMode == 2; }; - auto sketchTracksCondition = [ this ] ( const SELECTION& aSel ) { - return !( (PCB_DISPLAY_OPTIONS*) GetDisplayOptions() )->m_DisplayPcbTrackFill; + auto sketchTracksCondition = [ this, disp_opt ] ( const SELECTION& aSel ) { + return !disp_opt->m_DisplayPcbTrackFill; }; - auto sketchViasCondition = [ this ] ( const SELECTION& aSel ) { - return !( (PCB_DISPLAY_OPTIONS*) GetDisplayOptions() )->m_DisplayViaFill; + auto sketchViasCondition = [ this, disp_opt ] ( const SELECTION& aSel ) { + return !disp_opt->m_DisplayViaFill; }; - auto sketchPadsCondition = [ this ] ( const SELECTION& aSel ) { - return !( (PCB_DISPLAY_OPTIONS*) GetDisplayOptions() )->m_DisplayPadFill; + auto sketchPadsCondition = [ this, disp_opt ] ( const SELECTION& aSel ) { + return !disp_opt->m_DisplayPadFill; }; - auto contrastModeCondition = [ this ] ( const SELECTION& aSel ) { - return !( (PCB_DISPLAY_OPTIONS*) GetDisplayOptions() )->m_ContrastModeDisplay; + auto contrastModeCondition = [ this, disp_opt ] ( const SELECTION& aSel ) { + return !disp_opt->m_ContrastModeDisplay; }; viewMenu->AddCheckItem( PCB_ACTIONS::showLayersManager, layersPaletteShownCondition ); diff --git a/pcbnew/pcb_display_options.cpp b/pcbnew/pcb_display_options.cpp index 47241915d9..687585208a 100644 --- a/pcbnew/pcb_display_options.cpp +++ b/pcbnew/pcb_display_options.cpp @@ -52,7 +52,8 @@ PCB_DISPLAY_OPTIONS::PCB_DISPLAY_OPTIONS() * 3 show netnames on tracks and pads */ m_DisplayDrawItemsFill = FILLED; 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_MaxLinksShowed = 3; // in track creation: number of hairwires shown + m_ShowModuleRatsnest = true; // When moving a footprint: allows displaying a ratsnest m_DisplayRatsnestLinesCurved = false; + m_ShowGlobalRatsnest = true; } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index ec0fce4d72..54fa27cee2 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -661,14 +661,11 @@ void PCB_EDIT_FRAME::onBoardLoaded() syncLayerWidgetLayer(); syncRenderStates(); + SetElementVisibility( LAYER_RATSNEST, + static_cast( GetDisplayOptions() )->m_ShowGlobalRatsnest ); // Update the tracks / vias available sizes list: ReCreateAuxiliaryToolbar(); - // Update the RATSNEST items, which were not loaded at the time - // BOARD::SetVisibleElements() was called from within any PLUGIN. - // See case LAYER_RATSNEST: in BOARD::SetElementVisibility() - GetBoard()->SetVisibleElements( GetBoard()->GetVisibleElements() ); - // Display the loaded board: Zoom_Automatique( false ); @@ -713,7 +710,12 @@ bool PCB_EDIT_FRAME::IsElementVisible( GAL_LAYER_ID aElement ) const void PCB_EDIT_FRAME::SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState ) { - GetGalCanvas()->GetView()->SetLayerVisible( aElement , aNewState ); + // Force the RATSNEST visible + if( aElement == LAYER_RATSNEST ) + GetGalCanvas()->GetView()->SetLayerVisible( aElement, true ); + else + GetGalCanvas()->GetView()->SetLayerVisible( aElement , aNewState ); + GetBoard()->SetElementVisibility( aElement, aNewState ); m_Layers->SetRenderState( aElement, aNewState ); } diff --git a/pcbnew/pcb_general_settings.cpp b/pcbnew/pcb_general_settings.cpp index 5b01db662d..550157a96b 100644 --- a/pcbnew/pcb_general_settings.cpp +++ b/pcbnew/pcb_general_settings.cpp @@ -50,7 +50,6 @@ PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS( FRAME_T aFrameType ) case FRAME_PCB_MODULE_EDITOR: Add( "Use45DegreeGraphicSegments", &g_Use45DegreeGraphicSegments, false); Add( "MagneticPads", reinterpret_cast( &g_MagneticPads ), CAPTURE_CURSOR_IN_TRACK_TOOL ); - Add( "DragSelects", &g_DragSelects, true ); break; default: diff --git a/pcbnew/pcb_layer_widget.cpp b/pcbnew/pcb_layer_widget.cpp index cc4490ef58..d9b7a653ab 100644 --- a/pcbnew/pcb_layer_widget.cpp +++ b/pcbnew/pcb_layer_widget.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -406,10 +407,16 @@ void PCB_LAYER_WIDGET::ReFillRender() if( renderRow.color != COLOR4D::UNSPECIFIED ) // does this row show a color? { // this window frame must have an established BOARD, i.e. after SetBoard() - renderRow.color = myframe->Settings().Colors().GetItemColor( static_cast( renderRow.id ) ); + renderRow.color = myframe->Settings().Colors().GetItemColor( + static_cast( renderRow.id ) ); } - renderRow.state = board->IsElementVisible( static_cast( renderRow.id ) ); + if( renderRow.id == LAYER_RATSNEST ) + renderRow.state = + static_cast( myframe->GetDisplayOptions() )->m_ShowGlobalRatsnest; + else + renderRow.state = board->IsElementVisible( + static_cast( renderRow.id ) ); } AppendRenderRow( renderRow ); @@ -709,6 +716,13 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled ) // don't touch the layers. ratsnest is enabled on per-item basis. galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); galCanvas->GetView()->SetLayerVisible( aId, true ); + + if( myframe->IsType( FRAME_PCB ) ) + { + auto opt = static_cast( myframe->GetDisplayOptions() ); + opt->m_ShowGlobalRatsnest = isEnabled; + static_cast( galCanvas->GetView() )->UpdateDisplayOptions( opt ); + } } else galCanvas->GetView()->SetLayerVisible( aId, isEnabled ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 341299c812..2d34f573b9 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -139,6 +139,7 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOption m_sketchFpGfx = !aOptions->m_DisplayModEdgeFill; m_sketchFpTxtfx = !aOptions->m_DisplayModTextFill; m_curvedRatsnestlines = aOptions->m_DisplayRatsnestLinesCurved; + m_globalRatsnestlines = aOptions->m_ShowGlobalRatsnest; // 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 5844a60b23..5dc07194b9 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -166,6 +166,11 @@ public: return m_curvedRatsnestlines; } + inline bool GetGlobalRatsnestLinesEnabled() const + { + return m_globalRatsnestlines; + } + 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]; @@ -197,6 +202,9 @@ protected: ///> Flag determining if ratsnest lines should be drawn curved bool m_curvedRatsnestlines = true; + ///> Flag determining if ratsnest lines are shown by default + bool m_globalRatsnestlines = 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 15a2ee554a..ff1cb57420 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -177,6 +177,10 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() &displ_opts->m_DisplayZonesMode, 0, 0, 2 ) ); m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "CurvedRatsnestLines" ), &displ_opts->m_DisplayRatsnestLinesCurved, false ) ); + m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowRatsnestLines" ), + &displ_opts->m_ShowGlobalRatsnest, true) ); + m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowRatsnestModuleLines" ), + &displ_opts->m_ShowModuleRatsnest, true) ); // Miscellaneous: m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), diff --git a/pcbnew/ratsnest_viewitem.cpp b/pcbnew/ratsnest_viewitem.cpp index 90b2690de2..adf4a13dd9 100644 --- a/pcbnew/ratsnest_viewitem.cpp +++ b/pcbnew/ratsnest_viewitem.cpp @@ -126,11 +126,11 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const bool enable = !sourceNode->GetNoLine() && !targetNode->GetNoLine(); bool show; - // If the ratsnest layer is currently enabled, the local ratsnest + // If the global ratsnest is currently enabled, the local ratsnest // should be easy to turn off, so either element can disable it - // If the layer is off, the local ratsnest should be easy to turn on + // If the global ratsnest is disabled, the local ratsnest should be easy to turn on // so either element can enable it. - if( sourceNode->Parent()->GetBoard()->IsElementVisible( LAYER_RATSNEST ) ) + if( rs->GetGlobalRatsnestLinesEnabled() ) show = sourceNode->Parent()->GetLocalRatsnestVisible() && targetNode->Parent()->GetLocalRatsnestVisible(); else diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 9f5e51ac6f..82eb8b7742 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -699,7 +699,6 @@ void PCB_EDIT_FRAME::SyncToolbars() PCB_DISPLAY_OPTIONS* opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions(); KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions(); int zoneMode = opts->m_DisplayZonesMode; - bool ratsnestShown = GetBoard()->IsElementVisible( LAYER_RATSNEST ); m_mainToolBar->Toggle( ACTIONS::save, GetScreen() && GetScreen()->IsModify() ); m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 ); @@ -721,7 +720,7 @@ void PCB_EDIT_FRAME::SyncToolbars() m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == INCHES ); m_optionsToolBar->Toggle( ACTIONS::togglePolarCoords, GetShowPolarCoords() ); m_optionsToolBar->Toggle( ACTIONS::toggleCursorStyle, !galOpts.m_fullscreenCursor ); - m_optionsToolBar->Toggle( PCB_ACTIONS::showRatsnest, ratsnestShown ); + m_optionsToolBar->Toggle( PCB_ACTIONS::showRatsnest, opts->m_ShowGlobalRatsnest ); m_optionsToolBar->Toggle( PCB_ACTIONS::ratsnestLineMode, opts->m_DisplayRatsnestLinesCurved ); m_optionsToolBar->Toggle( PCB_ACTIONS::showLayersManager, LayerManagerShown() ); m_optionsToolBar->Toggle( PCB_ACTIONS::showMicrowaveToolbar, MicrowaveToolbarShown() ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 250da3a075..de52af1a50 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -633,7 +633,6 @@ bool EDIT_TOOL::changeTrackWidthOnClick( const PCBNEW_SELECTION& selection ) int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) { PCB_BASE_EDIT_FRAME* editFrame = getEditFrame(); - VECTOR2I originalCursorPos = getViewControls()->GetCursorPosition(); m_selectionTool->ClearIfOutside( getViewControls()->GetCursorPosition() ); diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 5fce16e817..e8fe4b4da5 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -1388,7 +1388,7 @@ int PCB_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent ) } -static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, BOARD* aBoard, const VECTOR2D& aPosition ) +static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, BOARD* aBoard, bool aShow, const VECTOR2D& aPosition ) { auto selectionTool = aToolMgr->GetTool(); @@ -1408,7 +1408,7 @@ static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, BOARD* aBoard, const VECT for( auto mod : aBoard->Modules() ) { for( auto pad : mod->Pads() ) - pad->SetLocalRatsnestVisible( aBoard->IsElementVisible( LAYER_RATSNEST ) ); + pad->SetLocalRatsnestVisible( aShow ); } } else @@ -1443,20 +1443,20 @@ int PCB_EDITOR_CONTROL::LocalRatsnestTool( const TOOL_EVENT& aEvent ) auto picker = m_toolMgr->GetTool(); auto board = getModel(); + auto opt = displayOptions(); wxASSERT( picker ); wxASSERT( board ); m_frame->SetToolID( ID_LOCAL_RATSNEST_BUTT, wxCURSOR_PENCIL, _( "Pick Components for Local Ratsnest" ) ); - picker->SetClickHandler( std::bind( showLocalRatsnest, m_toolMgr, board, _1 ) ); - picker->SetFinalizeHandler( [ board ]( int aCondition ){ - auto vis = board->IsElementVisible( LAYER_RATSNEST ); - + picker->SetClickHandler( std::bind( + showLocalRatsnest, m_toolMgr, board, opt->m_ShowGlobalRatsnest, _1 ) ); + picker->SetFinalizeHandler( [ board, opt ]( int aCondition ){ if( aCondition != PCBNEW_PICKER_TOOL::END_ACTIVATE ) { for( auto mod : board->Modules() ) for( auto pad : mod->Pads() ) - pad->SetLocalRatsnestVisible( vis ); + pad->SetLocalRatsnestVisible( opt->m_ShowGlobalRatsnest ); } } ); @@ -1533,7 +1533,9 @@ void PCB_EDITOR_CONTROL::calculateSelectionRatsnest() { auto board_item = static_cast( item ); - if( board_item->Type() != PCB_MODULE_T && board_item->GetLocalRatsnestVisible() ) + if( board_item->Type() != PCB_MODULE_T + && ( board_item->GetLocalRatsnestVisible() + || displayOptions()->m_ShowModuleRatsnest ) ) { items.push_back( board_item ); } @@ -1541,7 +1543,7 @@ void PCB_EDITOR_CONTROL::calculateSelectionRatsnest() { for( auto pad : static_cast( item )->Pads() ) { - if( pad->GetLocalRatsnestVisible() ) + if( pad->GetLocalRatsnestVisible() || displayOptions()->m_ShowModuleRatsnest ) items.push_back( pad ); } } diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 4e9ffb3dc4..bc410e4fe8 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -290,8 +290,12 @@ int PCBNEW_CONTROL::ToggleRatsnest( const TOOL_EVENT& aEvent ) if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) ) { - PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) m_frame; - frame->SetElementVisibility( LAYER_RATSNEST, !frame->IsElementVisible( LAYER_RATSNEST ) ); + // N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest + Flip( opts->m_ShowGlobalRatsnest ); + view()->UpdateDisplayOptions( opts ); + getEditFrame()->SetElementVisibility( LAYER_RATSNEST, + opts->m_ShowGlobalRatsnest ); + } else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) ) {