From c0175c48af3efcb4c5956284f6a23477fcc4faa1 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 21 Jun 2020 15:39:27 -0400 Subject: [PATCH] ADDED: Setting to control track mouse drag behavior Default is now to perform a 45-degree drag --- pcbnew/dialogs/panel_edit_options.cpp | 19 ++ pcbnew/dialogs/panel_edit_options_base.cpp | 27 +++ pcbnew/dialogs/panel_edit_options_base.fbp | 267 +++++++++++++++++++++ pcbnew/dialogs/panel_edit_options_base.h | 5 + pcbnew/pcbnew_settings.cpp | 4 + pcbnew/pcbnew_settings.h | 9 + pcbnew/tools/selection_tool.cpp | 11 +- 7 files changed, 341 insertions(+), 1 deletion(-) diff --git a/pcbnew/dialogs/panel_edit_options.cpp b/pcbnew/dialogs/panel_edit_options.cpp index 4e732e8d8c..0c13a5b2a1 100644 --- a/pcbnew/dialogs/panel_edit_options.cpp +++ b/pcbnew/dialogs/panel_edit_options.cpp @@ -73,6 +73,13 @@ bool PANEL_EDIT_OPTIONS::TransferDataToWindow() m_FlipLeftRight->SetValue( general_opts.m_FlipLeftRight ); m_Show_Page_Limits->SetValue( m_Frame->ShowPageLimits() ); + + switch( general_opts.m_TrackDragAction ) + { + case TRACK_DRAG_ACTION::MOVE: m_rbTrackDragMove->SetValue( true ); break; + case TRACK_DRAG_ACTION::DRAG: m_rbTrackDrag45->SetValue( true ); break; + case TRACK_DRAG_ACTION::DRAG_FREE_ANGLE: m_rbTrackDragFree->SetValue( true ); break; + } } else if( dynamic_cast( m_Frame ) ) { @@ -104,6 +111,18 @@ bool PANEL_EDIT_OPTIONS::TransferDataFromWindow() m_Frame->SetShowPageLimits( m_Show_Page_Limits->GetValue() ); + if( dynamic_cast( m_Frame ) ) + { + PCBNEW_SETTINGS& settings = m_Frame->Settings(); + + if( m_rbTrackDragMove->GetValue() ) + settings.m_TrackDragAction = TRACK_DRAG_ACTION::MOVE; + else if( m_rbTrackDrag45->GetValue() ) + settings.m_TrackDragAction = TRACK_DRAG_ACTION::DRAG; + else if( m_rbTrackDragFree->GetValue() ) + settings.m_TrackDragAction = TRACK_DRAG_ACTION::DRAG_FREE_ANGLE; + } + // Apply changes to the GAL PCB_DISPLAY_OPTIONS displ_opts = m_Frame->GetDisplayOptions(); KIGFX::VIEW* view = m_Frame->GetCanvas()->GetView(); diff --git a/pcbnew/dialogs/panel_edit_options_base.cpp b/pcbnew/dialogs/panel_edit_options_base.cpp index b46c931e53..3c3cab307a 100644 --- a/pcbnew/dialogs/panel_edit_options_base.cpp +++ b/pcbnew/dialogs/panel_edit_options_base.cpp @@ -164,6 +164,33 @@ PANEL_EDIT_OPTIONS_BASE::PANEL_EDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID i pcbOptionsSizer->Add( sbSizer4, 0, wxEXPAND|wxTOP, 5 ); + wxStaticBoxSizer* sbSizer41; + sbSizer41 = new wxStaticBoxSizer( new wxStaticBox( pcbPage, wxID_ANY, _("Track Editing") ), wxVERTICAL ); + + m_staticText5 = new wxStaticText( sbSizer41->GetStaticBox(), wxID_ANY, _("Track mouse drag behavior:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText5->Wrap( -1 ); + m_staticText5->SetToolTip( _("Choose the action to perform when dragging a track segment with the mouse") ); + + sbSizer41->Add( m_staticText5, 0, wxALL, 5 ); + + m_rbTrackDragMove = new wxRadioButton( sbSizer41->GetStaticBox(), wxID_ANY, _("Move"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); + m_rbTrackDragMove->SetToolTip( _("Moves the track segment without moving connected tracks") ); + + sbSizer41->Add( m_rbTrackDragMove, 0, wxALL, 5 ); + + m_rbTrackDrag45 = new wxRadioButton( sbSizer41->GetStaticBox(), wxID_ANY, _("Drag (45 degree mode)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_rbTrackDrag45->SetToolTip( _("Drags the track segment while keeping connected tracks at 45 degrees.") ); + + sbSizer41->Add( m_rbTrackDrag45, 0, wxALL, 5 ); + + m_rbTrackDragFree = new wxRadioButton( sbSizer41->GetStaticBox(), wxID_ANY, _("Drag (free angle)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_rbTrackDragFree->SetToolTip( _("Drags the nearest joint in the track without restricting the track angle.") ); + + sbSizer41->Add( m_rbTrackDragFree, 0, wxALL, 5 ); + + + pcbOptionsSizer->Add( sbSizer41, 1, wxEXPAND|wxTOP, 5 ); + pcbPage->SetSizer( pcbOptionsSizer ); pcbPage->Layout(); diff --git a/pcbnew/dialogs/panel_edit_options_base.fbp b/pcbnew/dialogs/panel_edit_options_base.fbp index 0b0636fa67..79957c31ed 100644 --- a/pcbnew/dialogs/panel_edit_options_base.fbp +++ b/pcbnew/dialogs/panel_edit_options_base.fbp @@ -1416,6 +1416,273 @@ + + 5 + wxEXPAND|wxTOP + 1 + + wxID_ANY + Track Editing + + sbSizer41 + wxVERTICAL + 1 + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Track mouse drag behavior: + 0 + + 0 + + + 0 + + 1 + m_staticText5 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Choose the action to perform when dragging a track segment with the mouse + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Move + + 0 + + + 0 + + 1 + m_rbTrackDragMove + 1 + + + protected + 1 + + Resizable + 1 + + wxRB_GROUP + ; ; forward_declare + 0 + Moves the track segment without moving connected tracks + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Drag (45 degree mode) + + 0 + + + 0 + + 1 + m_rbTrackDrag45 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Drags the track segment while keeping connected tracks at 45 degrees. + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Drag (free angle) + + 0 + + + 0 + + 1 + m_rbTrackDragFree + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + Drags the nearest joint in the track without restricting the track angle. + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + diff --git a/pcbnew/dialogs/panel_edit_options_base.h b/pcbnew/dialogs/panel_edit_options_base.h index fac95c0466..5e9028223f 100644 --- a/pcbnew/dialogs/panel_edit_options_base.h +++ b/pcbnew/dialogs/panel_edit_options_base.h @@ -23,6 +23,7 @@ #include #include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -60,6 +61,10 @@ class PANEL_EDIT_OPTIONS_BASE : public wxPanel wxCheckBox* m_showSelectedRatsnest; wxCheckBox* m_OptDisplayCurvedRatsnestLines; wxCheckBox* m_Show_Page_Limits; + wxStaticText* m_staticText5; + wxRadioButton* m_rbTrackDragMove; + wxRadioButton* m_rbTrackDrag45; + wxRadioButton* m_rbTrackDragFree; public: diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index 42482edd2c..b965eb474e 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -111,6 +111,10 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_params.emplace_back( new PARAM( "editing.polar_coords", &m_PolarCoords, false ) ); + m_params.emplace_back( new PARAM( "editing.track_drag_action", + reinterpret_cast( &m_TrackDragAction ), + static_cast( TRACK_DRAG_ACTION::DRAG ) ) ); + m_params.emplace_back( new PARAM( "editing.use_45_degree_graphic_segments", &m_Use45DegreeGraphicSegments, false ) ); diff --git a/pcbnew/pcbnew_settings.h b/pcbnew/pcbnew_settings.h index b9b5881401..96bc073d96 100644 --- a/pcbnew/pcbnew_settings.h +++ b/pcbnew/pcbnew_settings.h @@ -50,6 +50,13 @@ struct MAGNETIC_SETTINGS } }; +enum class TRACK_DRAG_ACTION +{ + MOVE, + DRAG, + DRAG_FREE_ANGLE +}; + #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU) typedef std::vector> ACTION_PLUGIN_SETTINGS_LIST; #endif @@ -242,6 +249,8 @@ public: MAGNETIC_SETTINGS m_MagneticItems; + TRACK_DRAG_ACTION m_TrackDragAction; + bool m_Use45DegreeGraphicSegments; // True to constraint graphic lines to horizontal, // vertical and 45ยบ bool m_FlipLeftRight; // True: Flip footprints across Y axis diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 8488f5b2c2..6d7bb9f942 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -43,6 +43,7 @@ using namespace std::placeholders; #include #include #include +#include #include #include #include @@ -191,6 +192,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); bool dragAlwaysSelects = getEditFrame()->GetDragSelects(); + TRACK_DRAG_ACTION dragAction = getEditFrame()->Settings().m_TrackDragAction; m_additive = m_subtractive = m_exclusive_or = false; // OSX uses CTRL for context menu, and SHIFT is exclusive-or @@ -266,7 +268,14 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( selectionContains( evt->Position() ) ) { // Yes -> run the move tool and wait till it finishes - m_toolMgr->RunAction( PCB_ACTIONS::drag, true ); + TRACK* track = dynamic_cast( m_selection.GetItem( 0 ) ); + + if( track && dragAction == TRACK_DRAG_ACTION::DRAG ) + m_toolMgr->RunAction( PCB_ACTIONS::drag45Degree, true ); + else if( track && dragAction == TRACK_DRAG_ACTION::DRAG_FREE_ANGLE ) + m_toolMgr->RunAction( PCB_ACTIONS::dragFreeAngle, true ); + else + m_toolMgr->RunAction( PCB_ACTIONS::drag, true ); } else {