From da79a3dd69b4effe98c6e504ff6beaa133876ceb Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 1 Oct 2021 13:11:03 +0200 Subject: [PATCH] Option graphics limited to 45deg in creation: separate options for brd and fp editors. Add these options in PANEL_EDIT_OPTIONS. This option was previously living only in some context menus, not really visible. --- pcbnew/dialogs/panel_edit_options.cpp | 10 +- pcbnew/dialogs/panel_edit_options_base.cpp | 33 ++- pcbnew/dialogs/panel_edit_options_base.fbp | 258 +++++++++++++++++---- pcbnew/dialogs/panel_edit_options_base.h | 4 +- pcbnew/pcbnew_settings.cpp | 10 +- pcbnew/pcbnew_settings.h | 8 +- pcbnew/tools/convert_tool.cpp | 2 - pcbnew/tools/drawing_tool.cpp | 6 +- pcbnew/tools/pcb_editor_conditions.cpp | 5 +- pcbnew/tools/pcb_tool_base.cpp | 5 +- pcbnew/tools/pcb_viewer_tools.cpp | 7 +- 11 files changed, 280 insertions(+), 68 deletions(-) diff --git a/pcbnew/dialogs/panel_edit_options.cpp b/pcbnew/dialogs/panel_edit_options.cpp index acbb15239f..9a83a55a24 100644 --- a/pcbnew/dialogs/panel_edit_options.cpp +++ b/pcbnew/dialogs/panel_edit_options.cpp @@ -87,6 +87,8 @@ bool PANEL_EDIT_OPTIONS::TransferDataToWindow() m_showPageLimits->SetValue( m_frame->ShowPageLimits() ); m_autoRefillZones->SetValue( general_opts.m_AutoRefillZones ); m_allowFreePads->SetValue( general_opts.m_AllowFreePads ); + + m_cbPcbGraphic45Mode->SetValue( general_opts.m_PcbUse45DegreeLimit ); } else if( dynamic_cast( m_frame ) ) { @@ -94,9 +96,10 @@ bool PANEL_EDIT_OPTIONS::TransferDataToWindow() m_magneticPads->SetValue( mag_opts->pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS ); m_magneticGraphics->SetValue( mag_opts->graphics ); + m_cbFpGraphic45Mode->SetValue( general_opts.m_FpeditUse45DegreeLimit ); } - return true; + return true; } @@ -130,6 +133,8 @@ bool PANEL_EDIT_OPTIONS::TransferDataFromWindow() pcbnewSettings.m_TrackDragAction = TRACK_DRAG_ACTION::DRAG; else if( m_rbTrackDragFree->GetValue() ) pcbnewSettings.m_TrackDragAction = TRACK_DRAG_ACTION::DRAG_FREE_ANGLE; + + pcbnewSettings.m_PcbUse45DegreeLimit = m_cbPcbGraphic45Mode->GetValue(); } else if( dynamic_cast( m_frame ) ) { @@ -138,8 +143,11 @@ bool PANEL_EDIT_OPTIONS::TransferDataFromWindow() mag_opts->pads = m_magneticPads->GetValue() ? MAGNETIC_OPTIONS::CAPTURE_ALWAYS : MAGNETIC_OPTIONS::NO_EFFECT; mag_opts->graphics = m_magneticGraphics->GetValue(); + + m_frame->Settings().m_FpeditUse45DegreeLimit = m_cbFpGraphic45Mode->GetValue(); } + // Apply changes to the GAL KIGFX::VIEW* view = m_frame->GetCanvas()->GetView(); KIGFX::PCB_PAINTER* painter = static_cast( view->GetPainter() ); diff --git a/pcbnew/dialogs/panel_edit_options_base.cpp b/pcbnew/dialogs/panel_edit_options_base.cpp index ce5db3ef78..3ce0b3f449 100644 --- a/pcbnew/dialogs/panel_edit_options_base.cpp +++ b/pcbnew/dialogs/panel_edit_options_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.9.0 Apr 22 2021) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -234,9 +234,25 @@ PANEL_EDIT_OPTIONS_BASE::PANEL_EDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID i bMargins->Add( bMiddleLeftSizer, 1, wxEXPAND|wxRIGHT, 5 ); m_optionsBook = new wxSimplebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - wxPanel* emptyPage; - emptyPage = new wxPanel( m_optionsBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_optionsBook->AddPage( emptyPage, _("a page"), false ); + wxPanel* fpPage; + fpPage = new wxPanel( m_optionsBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer10; + bSizer10 = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* sbSizerFpGraphics; + sbSizerFpGraphics = new wxStaticBoxSizer( new wxStaticBox( fpPage, wxID_ANY, _("Graphics Editing") ), wxVERTICAL ); + + m_cbFpGraphic45Mode = new wxCheckBox( sbSizerFpGraphics->GetStaticBox(), wxID_ANY, _("Limit actions to 45 degrees from start"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerFpGraphics->Add( m_cbFpGraphic45Mode, 0, wxALL, 5 ); + + + bSizer10->Add( sbSizerFpGraphics, 1, wxEXPAND, 5 ); + + + fpPage->SetSizer( bSizer10 ); + fpPage->Layout(); + bSizer10->Fit( fpPage ); + m_optionsBook->AddPage( fpPage, _("a page"), false ); wxPanel* pcbPage; pcbPage = new wxPanel( m_optionsBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* pcbOptionsSizer; @@ -343,6 +359,15 @@ PANEL_EDIT_OPTIONS_BASE::PANEL_EDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID i pcbOptionsSizer->Add( sbSizer41, 0, wxEXPAND|wxTOP, 5 ); + wxStaticBoxSizer* sbSizerPcbGraphics; + sbSizerPcbGraphics = new wxStaticBoxSizer( new wxStaticBox( pcbPage, wxID_ANY, _("Graphics Editing") ), wxVERTICAL ); + + m_cbPcbGraphic45Mode = new wxCheckBox( sbSizerPcbGraphics->GetStaticBox(), wxID_ANY, _("Limit actions to 45 degrees from start"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizerPcbGraphics->Add( m_cbPcbGraphic45Mode, 0, wxALL, 5 ); + + + pcbOptionsSizer->Add( sbSizerPcbGraphics, 0, wxEXPAND|wxTOP, 5 ); + wxStaticBoxSizer* sbSizer4; sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( pcbPage, wxID_ANY, _("Miscellaneous") ), wxVERTICAL ); diff --git a/pcbnew/dialogs/panel_edit_options_base.fbp b/pcbnew/dialogs/panel_edit_options_base.fbp index ff71d47ea5..81f1d72e42 100644 --- a/pcbnew/dialogs/panel_edit_options_base.fbp +++ b/pcbnew/dialogs/panel_edit_options_base.fbp @@ -14,7 +14,6 @@ panel_edit_options_base 1000 none - 1 PanelEditOptions @@ -26,7 +25,6 @@ 1 1 UI - 0 1 0 @@ -709,7 +707,7 @@ 5 wxEXPAND 1 - + 2 wxBOTH @@ -721,11 +719,11 @@ none 0 0 - + 5 wxALL 0 - + 1 1 1 @@ -782,11 +780,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -843,11 +841,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -904,11 +902,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -965,11 +963,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1026,11 +1024,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1087,11 +1085,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1148,11 +1146,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1209,11 +1207,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1270,11 +1268,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1470,7 +1468,7 @@ 5 wxEXPAND 1 - + 2 wxBOTH @@ -1482,11 +1480,11 @@ none 0 0 - + 5 wxALL 0 - + 1 1 1 @@ -1543,11 +1541,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1604,11 +1602,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1665,11 +1663,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1726,11 +1724,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1787,11 +1785,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1848,11 +1846,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1909,11 +1907,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -1970,11 +1968,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -2031,11 +2029,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -2092,11 +2090,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -2153,11 +2151,11 @@ -1 - + 5 wxALL 0 - + 1 1 1 @@ -2313,7 +2311,7 @@ 0 1 - emptyPage + fpPage 1 @@ -2329,6 +2327,90 @@ wxTAB_TRAVERSAL + + + bSizer10 + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + wxID_ANY + Graphics Editing + + sbSizerFpGraphics + 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 + Limit actions to 45 degrees from start + + 0 + + + 0 + + 1 + m_cbFpGraphic45Mode + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + @@ -3217,6 +3299,84 @@ + + 5 + wxEXPAND|wxTOP + 0 + + wxID_ANY + Graphics Editing + + sbSizerPcbGraphics + 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 + Limit actions to 45 degrees from start + + 0 + + + 0 + + 1 + m_cbPcbGraphic45Mode + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 wxEXPAND|wxTOP diff --git a/pcbnew/dialogs/panel_edit_options_base.h b/pcbnew/dialogs/panel_edit_options_base.h index 1aa36a5f36..93db3a1f40 100644 --- a/pcbnew/dialogs/panel_edit_options_base.h +++ b/pcbnew/dialogs/panel_edit_options_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.9.0 Apr 22 2021) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -48,6 +48,7 @@ class PANEL_EDIT_OPTIONS_BASE : public wxPanel wxStaticBoxSizer* m_mouseCmdsOSX; wxStaticText* m_staticText1811; wxSimplebook* m_optionsBook; + wxCheckBox* m_cbFpGraphic45Mode; wxStaticText* m_staticText2; wxChoice* m_magneticPadChoice; wxStaticText* m_staticText21; @@ -60,6 +61,7 @@ class PANEL_EDIT_OPTIONS_BASE : public wxPanel wxRadioButton* m_rbTrackDragMove; wxRadioButton* m_rbTrackDrag45; wxRadioButton* m_rbTrackDragFree; + wxCheckBox* m_cbPcbGraphic45Mode; wxCheckBox* m_showPageLimits; wxCheckBox* m_autoRefillZones; diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index c5f232a383..cc2e59a27b 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -67,7 +67,8 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_FootprintWizard(), m_Display(), m_TrackDragAction( TRACK_DRAG_ACTION::DRAG ), - m_Use45DegreeLimit( false ), + m_PcbUse45DegreeLimit( false ), + m_FpeditUse45DegreeLimit( false ), m_FlipLeftRight( false ), m_PolarCoords( false ), m_RotationAngle( 900 ), @@ -123,8 +124,11 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() reinterpret_cast( &m_TrackDragAction ), static_cast( TRACK_DRAG_ACTION::DRAG ) ) ); - m_params.emplace_back( new PARAM( "editing.use_45_degree_limit", - &m_Use45DegreeLimit, false ) ); + m_params.emplace_back( new PARAM( "editing.pcb_use_45_degree_limit", + &m_PcbUse45DegreeLimit, false ) ); + + m_params.emplace_back( new PARAM( "editing.fp_use_45_degree_limit", + &m_FpeditUse45DegreeLimit, false ) ); m_params.emplace_back( new PARAM( "editing.auto_fill_zones", &m_AutoRefillZones, true ) ); diff --git a/pcbnew/pcbnew_settings.h b/pcbnew/pcbnew_settings.h index 578df6181d..d56e586f62 100644 --- a/pcbnew/pcbnew_settings.h +++ b/pcbnew/pcbnew_settings.h @@ -274,9 +274,11 @@ public: TRACK_DRAG_ACTION m_TrackDragAction; - bool m_Use45DegreeLimit; // True to constrain tool actions to horizontal, - // vertical and 45ยบ - bool m_FlipLeftRight; // True: Flip footprints across Y axis + bool m_PcbUse45DegreeLimit; // True to constrain tool actions to horizontal, + // vertical and 45deg in board editor + bool m_FpeditUse45DegreeLimit; // True to constrain tool actions to horizontal, + // vertical and 45deg in footprint editor + bool m_FlipLeftRight; // True: Flip footprints across Y axis // False: Flip footprints across X axis bool m_PolarCoords; diff --git a/pcbnew/tools/convert_tool.cpp b/pcbnew/tools/convert_tool.cpp index 94d5f118b7..d3fadb3291 100644 --- a/pcbnew/tools/convert_tool.cpp +++ b/pcbnew/tools/convert_tool.cpp @@ -513,8 +513,6 @@ SHAPE_POLY_SET CONVERT_TOOL::extractPolygons( const std::deque& aItem int CONVERT_TOOL::CreateLines( const TOOL_EVENT& aEvent ) { - bool createTracks = aEvent.IsAction( &PCB_ACTIONS::convertToTracks ); - auto& selection = m_selectionTool->RequestSelection( []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool ) { diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 7bcab6b6e7..71e8c83b94 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1376,8 +1376,10 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent ) int DRAWING_TOOL::ToggleLine45degMode( const TOOL_EVENT& toolEvent ) { - m_frame->Settings().m_Use45DegreeLimit = - !m_frame->Settings().m_Use45DegreeLimit; + if( m_frame->IsType( FRAME_PCB_EDITOR ) ) + m_frame->Settings().m_PcbUse45DegreeLimit = !m_frame->Settings().m_PcbUse45DegreeLimit; + else + m_frame->Settings().m_FpeditUse45DegreeLimit = !m_frame->Settings().m_FpeditUse45DegreeLimit; return 0; } diff --git a/pcbnew/tools/pcb_editor_conditions.cpp b/pcbnew/tools/pcb_editor_conditions.cpp index 7b882095e5..38a539a862 100644 --- a/pcbnew/tools/pcb_editor_conditions.cpp +++ b/pcbnew/tools/pcb_editor_conditions.cpp @@ -185,5 +185,8 @@ bool PCB_EDITOR_CONDITIONS::zoneDisplayModeFunc( const SELECTION& aSelection, PC bool PCB_EDITOR_CONDITIONS::get45degModeFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame ) { - return aFrame->Settings().m_Use45DegreeLimit; + if( aFrame->IsType( FRAME_PCB_EDITOR ) ) + return aFrame->Settings().m_PcbUse45DegreeLimit; + else + return aFrame->Settings().m_FpeditUse45DegreeLimit; } diff --git a/pcbnew/tools/pcb_tool_base.cpp b/pcbnew/tools/pcb_tool_base.cpp index e28110014d..220036effe 100644 --- a/pcbnew/tools/pcb_tool_base.cpp +++ b/pcbnew/tools/pcb_tool_base.cpp @@ -328,7 +328,10 @@ PCB_SELECTION& PCB_TOOL_BASE::selection() bool PCB_TOOL_BASE::Is45Limited() const { - return frame()->Settings().m_Use45DegreeLimit; + if( frame()->IsType( FRAME_PCB_EDITOR ) ) + return frame()->Settings().m_PcbUse45DegreeLimit; + else + return frame()->Settings().m_FpeditUse45DegreeLimit; } diff --git a/pcbnew/tools/pcb_viewer_tools.cpp b/pcbnew/tools/pcb_viewer_tools.cpp index 9af5ee420f..93d1de3e9a 100644 --- a/pcbnew/tools/pcb_viewer_tools.cpp +++ b/pcbnew/tools/pcb_viewer_tools.cpp @@ -293,7 +293,12 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent ) // move or drag when origin set updates rules else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) ) { - twoPtMgr.SetAngleSnap( frame()->Settings().m_Use45DegreeLimit ); + bool force45Deg = frame()->Settings().m_PcbUse45DegreeLimit; + + if( !frame()->IsType( FRAME_PCB_EDITOR ) ) + force45Deg = frame()->Settings().m_FpeditUse45DegreeLimit; + + twoPtMgr.SetAngleSnap( force45Deg ); twoPtMgr.SetEnd( cursorPos ); view.SetVisible( &ruler, true );