KiCad PCB EDA Suite
dialog_pns_settings.cpp
Go to the documentation of this file.
1 /*
2  * KiRouter - a push-and-(sometimes-)shove PCB router
3  *
4  * Copyright (C) 2014 CERN
5  * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
6  * Author: Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program. If not, see <http://www.gnu.or/licenses/>.
20  */
21 
26 #include "dialog_pns_settings.h"
28 
30  DIALOG_PNS_SETTINGS_BASE( aParent ), m_settings( aSettings )
31 {
32  // Add tool tip to the mode radio box, one by option
33  // (cannot be made with wxFormBuilder for each item )
34  m_mode->SetItemToolTip( 0, _( "DRC violation: highlight obstacles" ) );
35  m_mode->SetItemToolTip( 1, _( "DRC violation: shove tracks and vias" ) );
36  m_mode->SetItemToolTip( 2, _( "DRC violation: walk around obstacles" ) );
37 
38  // Load widgets' values from settings
39  m_mode->SetSelection( m_settings.Mode() );
40  m_shoveVias->SetValue( m_settings.ShoveVias() );
42  m_removeLoops->SetValue( m_settings.RemoveLoops() );
44  m_smartPads->SetValue( m_settings.SmartPads() );
45  m_effort->SetValue( m_settings.OptimizerEffort() );
47  m_violateDrc->SetValue( m_settings.CanViolateDRC() );
49  m_dragToolMode->SetSelection ( m_settings.InlineDragEnabled() ? 1 : 0 );
53 
54  // Enable/disable some options
55  wxCommandEvent event;
56  onModeChange( event );
57 
58  // Don't show options that are not implemented
59  m_suggestEnding->Hide();
60  m_shoveVias->Hide();
61 
62  SetDefaultItem( m_stdButtonsOK );
63  GetSizer()->Fit( this );
64  GetSizer()->SetSizeHints( this );
65 }
66 
67 
68 void DIALOG_PNS_SETTINGS::OnOkClick( wxCommandEvent& aEvent )
69 {
70  // Save widgets' values to settings
71  m_settings.SetMode( (PNS::PNS_MODE) m_mode->GetSelection() );
72  m_settings.SetShoveVias( m_shoveVias->GetValue() );
76  m_settings.SetSmartPads( m_smartPads->GetValue() );
79  m_settings.SetInlineDragEnabled( m_dragToolMode->GetSelection () ? true : false );
83 
84  if( m_mode->GetSelection() == PNS::RM_MarkObstacles )
85  {
88  }
89 
90  aEvent.Skip(); // ends returning wxID_OK (default behavior)
91 }
92 
93 
94 void DIALOG_PNS_SETTINGS::onModeChange( wxCommandEvent& aEvent )
95 {
96  if( m_mode->GetSelection() == PNS::RM_MarkObstacles )
97  {
99  m_freeAngleMode->Enable();
100 
101  m_violateDrc->SetValue( m_settings.CanViolateDRC() );
102  m_violateDrc->Enable();
103  }
104  else
105  {
106  if( m_freeAngleMode->IsEnabled() )
108 
109  m_freeAngleMode->SetValue( false );
110  m_freeAngleMode->Enable( false );
111 
112  if( m_violateDrc->IsEnabled() )
114 
115  m_violateDrc->SetValue( false );
116  m_violateDrc->Enable( false );
117  }
118 }
void SetOptimizerEffort(PNS_OPTIMIZATION_EFFORT aEffort)
Return true if shoving vias is enabled.
Contain all persistent settings of the router, such as the mode, optimization effort,...
bool SmartPads() const
Enable/disable Smart Pads (optimized connections).
void SetMode(PNS_MODE aMode)
Return the optimizer effort. Bigger means cleaner traces, but slower routing.
void SetFreeAngleMode(bool aEnable)
PNS_MODE
< Routing modes
void SetSuggestFinish(bool aSuggestFinish)
Return true if Smart Pads (optimized connections) is enabled.
void SetRemoveLoops(bool aRemoveLoops)
Return true if suggesting the finish of currently placed track is on.
void SetInlineDragEnabled(bool aEnable)
void SetSmartPads(bool aSmartPads)
Return true if follow mouse mode is active (permanently on for the moment).
Class DIALOG_PNS_SETTINGS_BASE.
void SetOptimizeDraggedTrack(bool aEnable)
bool RemoveLoops() const
Enable/disable loop (redundant track) removal.
void SetAutoPosture(bool aEnable)
DIALOG_PNS_SETTINGS(wxWindow *aParent, PNS::ROUTING_SETTINGS &aSettings)
Push and Shove router settings dialog.
PNS_OPTIMIZATION_EFFORT OptimizerEffort() const
Set the optimizer effort. Bigger means cleaner traces, but slower routing.
void SetShoveVias(bool aShoveVias)
Return true if loop (redundant track) removal is on.
bool SmoothDraggedSegments() const
Enable/disable smoothing segments during dragging.
PNS_MODE Mode() const
Set the routing mode.
virtual void OnOkClick(wxCommandEvent &aEvent) override
void SetCanViolateDRC(bool aViolate)
PNS::ROUTING_SETTINGS & m_settings
Ignore collisions, mark obstacles.
bool SuggestFinish()
Enable displaying suggestions for finishing the currently placed track.
#define _(s)
Definition: 3d_actions.cpp:33
bool JumpOverObstacles() const
Enable/disable jumping over unmovable obstacles.
virtual void onModeChange(wxCommandEvent &aEvent) override
bool ShoveVias() const
Enable/disable shoving vias.
bool GetOptimizeDraggedTrack() const
void SetSmoothDraggedSegments(bool aSmooth)
Return true if jumping over unmovable obstacles is on.
void SetJumpOverObstacles(bool aJumpOverObstacles)
void SetFixAllSegments(bool aEnable)