From f77d2f8cb84c78f51adff830b3b1edc48498cbb8 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Thu, 27 Feb 2020 22:02:45 +0100 Subject: [PATCH] router: option to enable optimization of the track being dragged --- pcbnew/dialogs/dialog_pns_settings.cpp | 3 +- pcbnew/dialogs/dialog_pns_settings_base.cpp | 7 +- pcbnew/dialogs/dialog_pns_settings_base.fbp | 663 +++++++++++++++++++- pcbnew/dialogs/dialog_pns_settings_base.h | 3 +- pcbnew/router/pns_dragger.cpp | 24 +- pcbnew/router/pns_routing_settings.cpp | 2 + pcbnew/router/pns_routing_settings.h | 4 + 7 files changed, 689 insertions(+), 17 deletions(-) diff --git a/pcbnew/dialogs/dialog_pns_settings.cpp b/pcbnew/dialogs/dialog_pns_settings.cpp index b2191962bc..15ceeed38e 100644 --- a/pcbnew/dialogs/dialog_pns_settings.cpp +++ b/pcbnew/dialogs/dialog_pns_settings.cpp @@ -47,6 +47,7 @@ DIALOG_PNS_SETTINGS::DIALOG_PNS_SETTINGS( wxWindow* aParent, PNS::ROUTING_SETTIN m_violateDrc->SetValue( m_settings.CanViolateDRC() ); m_freeAngleMode->SetValue( m_settings.GetFreeAngleMode() ); m_dragToolMode->SetSelection ( m_settings.InlineDragEnabled() ? 1 : 0 ); + m_optimizeDraggedTrack->SetValue( m_settings.GetOptimizeDraggedTrack() ); // Enable/disable some options wxCommandEvent event; onModeChange( event ); @@ -75,7 +76,7 @@ void DIALOG_PNS_SETTINGS::OnOkClick( wxCommandEvent& aEvent ) m_settings.SetCanViolateDRC( m_violateDrc->GetValue() ); m_settings.SetFreeAngleMode( m_freeAngleMode->GetValue() ); m_settings.SetInlineDragEnabled( m_dragToolMode->GetSelection () ? true : false ); - + m_settings.SetOptimizeDraggedTrack( m_optimizeDraggedTrack->GetValue() ); m_settings.SaveToFile(); aEvent.Skip(); // ends returning wxID_OK (default behavior) diff --git a/pcbnew/dialogs/dialog_pns_settings_base.cpp b/pcbnew/dialogs/dialog_pns_settings_base.cpp index 01e51a6ac1..c4589b60d1 100644 --- a/pcbnew/dialogs/dialog_pns_settings_base.cpp +++ b/pcbnew/dialogs/dialog_pns_settings_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Oct 17 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -74,7 +74,7 @@ DIALOG_PNS_SETTINGS_BASE::DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID bOptions->Add( m_smoothDragged, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_violateDrc = new wxCheckBox( bOptions->GetStaticBox(), wxID_ANY, _("Allow DRC violations"), wxDefaultPosition, wxDefaultSize, 0 ); - m_violateDrc->SetToolTip( _("(Highlight collisions mode only) - allows to establish a track even if is violating the DRC rules.") ); + m_violateDrc->SetToolTip( _("(Highlight collisions mode only) - allows one to establish a track even if is violating the DRC rules.") ); bOptions->Add( m_violateDrc, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -83,6 +83,9 @@ DIALOG_PNS_SETTINGS_BASE::DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID bOptions->Add( m_suggestEnding, 0, wxALL, 5 ); + m_optimizeDraggedTrack = new wxCheckBox( bOptions->GetStaticBox(), wxID_ANY, _("Optimize track being dragged"), wxDefaultPosition, wxDefaultSize, 0 ); + bOptions->Add( m_optimizeDraggedTrack, 0, wxALL, 5 ); + m_staticline1 = new wxStaticLine( bOptions->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bOptions->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); diff --git a/pcbnew/dialogs/dialog_pns_settings_base.fbp b/pcbnew/dialogs/dialog_pns_settings_base.fbp index 3050dc7f9f..7e71a78fed 100644 --- a/pcbnew/dialogs/dialog_pns_settings_base.fbp +++ b/pcbnew/dialogs/dialog_pns_settings_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -53,6 +53,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bMainSizer @@ -122,7 +171,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + onModeChange + + + + + + @@ -137,6 +216,7 @@ wxVERTICAL 1 none + 5 wxEXPAND @@ -212,6 +292,36 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -276,6 +386,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -342,7 +483,37 @@ + + + + + + + + onFreeAngleModeChange + + + + + + + + + + + + + + + + + + + + + + @@ -407,6 +578,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -471,6 +673,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -535,6 +768,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -599,6 +863,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -663,6 +958,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -727,6 +1053,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -791,6 +1148,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Optimize track being dragged + + 0 + + + 0 + + 1 + m_optimizeDraggedTrack + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -849,6 +1332,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -919,6 +1432,36 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1003,6 +1546,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1073,6 +1667,36 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1144,6 +1768,36 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1170,7 +1824,14 @@ m_stdButtons protected + + + + + OnOkClick + + diff --git a/pcbnew/dialogs/dialog_pns_settings_base.h b/pcbnew/dialogs/dialog_pns_settings_base.h index 4f05ccadc7..fe904770d5 100644 --- a/pcbnew/dialogs/dialog_pns_settings_base.h +++ b/pcbnew/dialogs/dialog_pns_settings_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Oct 17 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -50,6 +50,7 @@ class DIALOG_PNS_SETTINGS_BASE : public DIALOG_SHIM wxCheckBox* m_smoothDragged; wxCheckBox* m_violateDrc; wxCheckBox* m_suggestEnding; + wxCheckBox* m_optimizeDraggedTrack; wxStaticLine* m_staticline1; wxStaticText* m_effortLabel; wxSlider* m_effort; diff --git a/pcbnew/router/pns_dragger.cpp b/pcbnew/router/pns_dragger.cpp index e03bd694b2..144d93902b 100644 --- a/pcbnew/router/pns_dragger.cpp +++ b/pcbnew/router/pns_dragger.cpp @@ -325,14 +325,14 @@ void DRAGGER::optimizeAndUpdateDraggedLine( LINE& dragged, const VECTOR2I& aP ) dragged.ClearSegmentLinks(); dragged.Unmark(); - Dbg()->AddLine( dragged.CLine(), 5, 100000 ); - lockV = dragged.CLine().NearestPoint( aP ); - Dbg()->AddPoint( lockV, 4 ); - OPTIMIZER::Optimize( &dragged, - OPTIMIZER::MERGE_SEGMENTS | OPTIMIZER::KEEP_TOPOLOGY | OPTIMIZER::PRESERVE_VERTEX, - m_lastNode, lockV ); + if( Settings().GetOptimizeDraggedTrack() ) + { + OPTIMIZER::Optimize( &dragged, + OPTIMIZER::MERGE_SEGMENTS | OPTIMIZER::KEEP_TOPOLOGY | OPTIMIZER::PRESERVE_VERTEX, + m_lastNode, lockV ); + } m_lastNode->Add( dragged ); m_draggedItems.Clear(); @@ -465,14 +465,14 @@ bool DRAGGER::dragShove( const VECTOR2I& aP ) dragged.ClearSegmentLinks(); dragged.Unmark(); - Dbg()->AddLine(dragged.CLine(), 5, 100000 ); - lockV = dragged.CLine().NearestPoint( aP ); - Dbg()->AddPoint(lockV, 4 ); - OPTIMIZER::Optimize( &dragged, OPTIMIZER::MERGE_SEGMENTS - | OPTIMIZER::KEEP_TOPOLOGY - | OPTIMIZER::PRESERVE_VERTEX, m_lastNode, lockV ); + if( Settings().GetOptimizeDraggedTrack() ) + { + OPTIMIZER::Optimize( &dragged, OPTIMIZER::MERGE_SEGMENTS + | OPTIMIZER::KEEP_TOPOLOGY + | OPTIMIZER::PRESERVE_VERTEX, m_lastNode, lockV ); + } m_lastNode->Add( dragged ); m_draggedItems.Clear(); diff --git a/pcbnew/router/pns_routing_settings.cpp b/pcbnew/router/pns_routing_settings.cpp index 981a3374fc..fc041ca437 100644 --- a/pcbnew/router/pns_routing_settings.cpp +++ b/pcbnew/router/pns_routing_settings.cpp @@ -50,6 +50,7 @@ ROUTING_SETTINGS::ROUTING_SETTINGS( JSON_SETTINGS* aParent, const std::string& a m_inlineDragEnabled = false; m_snapToTracks = false; m_snapToPads = false; + m_optimizeDraggedTrack = true; m_minRadius = 0; m_maxRadius = 1000000; m_roundedCorners = false; @@ -86,6 +87,7 @@ ROUTING_SETTINGS::ROUTING_SETTINGS( JSON_SETTINGS* aParent, const std::string& a m_params.emplace_back( new PARAM( "inline_drag", &m_inlineDragEnabled, false ) ); m_params.emplace_back( new PARAM( "snap_to_tracks", &m_snapToTracks, false ) ); m_params.emplace_back( new PARAM( "snap_to_pads", &m_snapToPads, false ) ); + m_params.emplace_back( new PARAM( "optimize_dragged_track", &m_optimizeDraggedTrack, true ) ); m_params.emplace_back( new PARAM( "min_radius", &m_minRadius, 0 ) ); m_params.emplace_back( new PARAM( "max_radius", &m_maxRadius, 1000000 ) ); diff --git a/pcbnew/router/pns_routing_settings.h b/pcbnew/router/pns_routing_settings.h index 6e4c29570f..491500999c 100644 --- a/pcbnew/router/pns_routing_settings.h +++ b/pcbnew/router/pns_routing_settings.h @@ -144,6 +144,9 @@ public: bool GetRounded() const { return m_roundedCorners; } void SetRounded( bool aRound ) { m_roundedCorners = aRound; } + bool GetOptimizeDraggedTrack() const { return m_optimizeDraggedTrack; } + void SetOptimizeDraggedTrack( bool aEnable ) { m_optimizeDraggedTrack = aEnable; } + void SetMinRadius( int aRadius ) { m_minRadius = aRadius; @@ -178,6 +181,7 @@ private: bool m_snapToTracks; bool m_snapToPads; bool m_roundedCorners; + bool m_optimizeDraggedTrack; int m_minRadius; int m_maxRadius;