Commit 061660e9 authored by Tomasz Włostowski's avatar Tomasz Włostowski
Browse files

Long-awaited new version of the P&S router

parent e9afb10a
Loading
Loading
Loading
Loading
+75 −0
Original line number Diff line number Diff line
/*
 * KiRouter - a push-and-(sometimes-)shove PCB router
 *
 * Copyright (C) 2014  CERN
 * Author: Maciej Suminski <maciej.suminski@cern.ch>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.or/licenses/>.
 */

/**
 * Push and Shove router settings dialog.
 */

#include "dialog_pns_settings.h"
#include <router/pns_routing_settings.h>

DIALOG_PNS_SETTINGS::DIALOG_PNS_SETTINGS( wxWindow* aParent, PNS_ROUTING_SETTINGS& aSettings ) :
    DIALOG_PNS_SETTINGS_BASE( aParent ), m_settings( aSettings )
{
    // "Figure out what's best" is not available yet
    m_mode->Enable( RM_Smart, false );

    // Load widgets' values from settings
    m_mode->SetSelection( m_settings.Mode() );
    m_shoveVias->SetValue( m_settings.ShoveVias() );
    m_backPressure->SetValue( m_settings.JumpOverObstacles() );
    m_removeLoops->SetValue( m_settings.RemoveLoops() );
    m_suggestEnding->SetValue( m_settings.SuggestFinish() );
    m_autoNeckdown->SetValue( m_settings.SmartPads() );
    m_effort->SetValue( m_settings.OptimizerEffort() );
    m_smoothDragged->SetValue( m_settings.SmoothDraggedSegments() );
    m_violateDrc->SetValue( m_settings.CanViolateDRC() );
}


void DIALOG_PNS_SETTINGS::OnClose( wxCloseEvent& aEvent )
{
    // Do nothing, it is result of ESC pressing
    EndModal( 0 );
}


void DIALOG_PNS_SETTINGS::OnOkClick( wxCommandEvent& aEvent )
{
    // Save widgets' values to settings
    m_settings.SetMode( (PNS_MODE) m_mode->GetSelection() );
    m_settings.SetShoveVias( m_shoveVias->GetValue() );
    m_settings.SetJumpOverObstacles( m_backPressure->GetValue() );
    m_settings.SetRemoveLoops( m_removeLoops->GetValue() );
    m_settings.SetSuggestFinish ( m_suggestEnding->GetValue() );
    m_settings.SetSmartPads( m_autoNeckdown->GetValue() );
    m_settings.SetOptimizerEffort( (PNS_OPTIMIZATION_EFFORT) m_effort->GetValue() );
    m_settings.SetSmoothDraggedSegments( m_smoothDragged->GetValue() );
    m_settings.SetCanViolateDRC( m_violateDrc->GetValue() );

    EndModal( 1 );
}


void DIALOG_PNS_SETTINGS::OnCancelClick( wxCommandEvent& aEvent )
{
    // Do nothing
    EndModal( 0 );
}
+45 −0
Original line number Diff line number Diff line
/*
 * KiRouter - a push-and-(sometimes-)shove PCB router
 *
 * Copyright (C) 2014  CERN
 * Author: Maciej Suminski <maciej.suminski@cern.ch>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.or/licenses/>.
 */

/**
 * Push and Shove router settings dialog.
 */

#ifndef __dialog_pns_settings__
#define __dialog_pns_settings__

#include "dialog_pns_settings_base.h"

class PNS_ROUTING_SETTINGS;

class DIALOG_PNS_SETTINGS : public DIALOG_PNS_SETTINGS_BASE
{
	public:
		DIALOG_PNS_SETTINGS( wxWindow* aParent, PNS_ROUTING_SETTINGS& aSettings );

        virtual void OnClose( wxCloseEvent& aEvent );
        virtual void OnOkClick( wxCommandEvent& aEvent );
        virtual void OnCancelClick( wxCommandEvent& aEvent );
	
	private:
		PNS_ROUTING_SETTINGS& m_settings;
};

#endif // __dialog_pns_settings__
+127 −0
Original line number Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#include "dialog_pns_settings_base.h"

///////////////////////////////////////////////////////////////////////////

DIALOG_PNS_SETTINGS_BASE::DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
	wxBoxSizer* bMainSizer;
	bMainSizer = new wxBoxSizer( wxVERTICAL );
	
	wxString m_modeChoices[] = { _("Highlight collisions"), _("Shove"), _("Walk around"), _("Figure out what's best") };
	int m_modeNChoices = sizeof( m_modeChoices ) / sizeof( wxString );
	m_mode = new wxRadioBox( this, wxID_ANY, _("Mode"), wxDefaultPosition, wxDefaultSize, m_modeNChoices, m_modeChoices, 1, wxRA_SPECIFY_COLS );
	m_mode->SetSelection( 1 );
	bMainSizer->Add( m_mode, 0, wxALL, 5 );
	
	wxStaticBoxSizer* bOptions;
	bOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL );
	
	m_shoveVias = new wxCheckBox( this, wxID_ANY, _("Shove vias"), wxDefaultPosition, wxDefaultSize, 0 );
	bOptions->Add( m_shoveVias, 0, wxALL, 5 );
	
	m_backPressure = new wxCheckBox( this, wxID_ANY, _("Jump over obstacles"), wxDefaultPosition, wxDefaultSize, 0 );
	bOptions->Add( m_backPressure, 0, wxALL, 5 );
	
	m_removeLoops = new wxCheckBox( this, wxID_ANY, _("Remove redundant tracks"), wxDefaultPosition, wxDefaultSize, 0 );
	bOptions->Add( m_removeLoops, 0, wxALL, 5 );
	
	m_autoNeckdown = new wxCheckBox( this, wxID_ANY, _("Automatic neckdown"), wxDefaultPosition, wxDefaultSize, 0 );
	bOptions->Add( m_autoNeckdown, 0, wxALL, 5 );
	
	m_smoothDragged = new wxCheckBox( this, wxID_ANY, _("Smooth dragged segments"), wxDefaultPosition, wxDefaultSize, 0 );
	bOptions->Add( m_smoothDragged, 0, wxALL, 5 );
	
	m_violateDrc = new wxCheckBox( this, wxID_ANY, _("Allow DRC violations"), wxDefaultPosition, wxDefaultSize, 0 );
	bOptions->Add( m_violateDrc, 0, wxALL, 5 );
	
	m_suggestEnding = new wxCheckBox( this, wxID_ANY, _("Suggest track finish"), wxDefaultPosition, wxDefaultSize, 0 );
	m_suggestEnding->Enable( false );
	
	bOptions->Add( m_suggestEnding, 0, wxALL, 5 );
	
	wxBoxSizer* bEffort;
	bEffort = new wxBoxSizer( wxHORIZONTAL );
	
	m_effortLabel = new wxStaticText( this, wxID_ANY, _("Optimizer effort"), wxDefaultPosition, wxDefaultSize, 0 );
	m_effortLabel->Wrap( -1 );
	bEffort->Add( m_effortLabel, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
	
	
	bEffort->Add( 0, 0, 0, wxEXPAND, 5 );
	
	wxBoxSizer* bSlider;
	bSlider = new wxBoxSizer( wxVERTICAL );
	
	m_effort = new wxSlider( this, wxID_ANY, 1, 0, 2, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_BOTTOM|wxSL_HORIZONTAL|wxSL_TOP );
	bSlider->Add( m_effort, 1, wxEXPAND, 5 );
	
	wxBoxSizer* bSliderLabels;
	bSliderLabels = new wxBoxSizer( wxHORIZONTAL );
	
	m_lowLabel = new wxStaticText( this, wxID_ANY, _("low"), wxDefaultPosition, wxDefaultSize, 0 );
	m_lowLabel->Wrap( -1 );
	m_lowLabel->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
	
	bSliderLabels->Add( m_lowLabel, 0, 0, 5 );
	
	
	bSliderLabels->Add( 0, 0, 1, wxEXPAND, 5 );
	
	m_highLabel = new wxStaticText( this, wxID_ANY, _("high"), wxDefaultPosition, wxDefaultSize, 0 );
	m_highLabel->Wrap( -1 );
	m_highLabel->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
	
	bSliderLabels->Add( m_highLabel, 0, 0, 5 );
	
	
	bSlider->Add( bSliderLabels, 1, wxEXPAND, 5 );
	
	
	bEffort->Add( bSlider, 1, wxEXPAND, 5 );
	
	
	bOptions->Add( bEffort, 1, wxALL|wxEXPAND, 5 );
	
	wxBoxSizer* bButtons;
	bButtons = new wxBoxSizer( wxHORIZONTAL );
	
	m_ok = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
	m_ok->SetDefault(); 
	bButtons->Add( m_ok, 1, wxALL, 5 );
	
	m_cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
	bButtons->Add( m_cancel, 1, wxALL, 5 );
	
	
	bOptions->Add( bButtons, 1, wxEXPAND, 5 );
	
	
	bMainSizer->Add( bOptions, 1, wxEXPAND, 5 );
	
	
	this->SetSizer( bMainSizer );
	this->Layout();
	
	// Connect Events
	this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PNS_SETTINGS_BASE::OnClose ) );
	m_ok->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::OnOkClick ), NULL, this );
	m_cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::OnCancelClick ), NULL, this );
}

DIALOG_PNS_SETTINGS_BASE::~DIALOG_PNS_SETTINGS_BASE()
{
	// Disconnect Events
	this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PNS_SETTINGS_BASE::OnClose ) );
	m_ok->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::OnOkClick ), NULL, this );
	m_cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_SETTINGS_BASE::OnCancelClick ), NULL, this );
	
}
+1414 −0

File added.

Preview size limit exceeded, changes collapsed.

+67 −0
Original line number Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#ifndef __DIALOG_PNS_SETTINGS_BASE_H__
#define __DIALOG_PNS_SETTINGS_BASE_H__

#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/radiobox.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/checkbox.h>
#include <wx/stattext.h>
#include <wx/slider.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/statbox.h>
#include <wx/dialog.h>

///////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_PNS_SETTINGS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_PNS_SETTINGS_BASE : public wxDialog 
{
	private:
	
	protected:
		wxRadioBox* m_mode;
		wxCheckBox* m_shoveVias;
		wxCheckBox* m_backPressure;
		wxCheckBox* m_removeLoops;
		wxCheckBox* m_autoNeckdown;
		wxCheckBox* m_smoothDragged;
		wxCheckBox* m_violateDrc;
		wxCheckBox* m_suggestEnding;
		wxStaticText* m_effortLabel;
		wxSlider* m_effort;
		wxStaticText* m_lowLabel;
		wxStaticText* m_highLabel;
		wxButton* m_ok;
		wxButton* m_cancel;
		
		// Virtual event handlers, overide them in your derived class
		virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
		virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
		virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
		
	
	public:
		
		DIALOG_PNS_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Interactive Router settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 289,504 ), long style = wxDEFAULT_DIALOG_STYLE ); 
		~DIALOG_PNS_SETTINGS_BASE();
	
};

#endif //__DIALOG_PNS_SETTINGS_BASE_H__
Loading