2011-10-13 19:56:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2016-02-24 19:53:02 +00:00
|
|
|
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-13 19:56:32 +00:00
|
|
|
*
|
|
|
|
* 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 2
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file dialog_general_options.cpp
|
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2008-12-21 16:54:27 +00:00
|
|
|
/* functions relatives to the dialogs opened from the main menu :
|
2009-11-14 22:15:22 +00:00
|
|
|
* Preferences/general
|
|
|
|
* Preferences/display
|
|
|
|
*/
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <class_board_design_settings.h>
|
2013-12-17 21:38:20 +00:00
|
|
|
#include <kicad_string.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <class_board.h>
|
2014-02-25 13:28:09 +00:00
|
|
|
#include <collectors.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_general_options.h>
|
2009-02-24 22:41:30 +00:00
|
|
|
|
2015-10-14 18:12:17 +00:00
|
|
|
|
2012-04-11 18:54:20 +00:00
|
|
|
DIALOG_GENERALOPTIONS::DIALOG_GENERALOPTIONS( PCB_EDIT_FRAME* parent ) :
|
|
|
|
DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE( parent )
|
2008-12-21 12:11:47 +00:00
|
|
|
{
|
2009-02-24 22:41:30 +00:00
|
|
|
init();
|
2010-01-20 12:43:05 +00:00
|
|
|
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
Center();
|
2008-12-21 12:11:47 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2012-04-11 18:54:20 +00:00
|
|
|
void DIALOG_GENERALOPTIONS::init()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-02-24 22:41:30 +00:00
|
|
|
SetFocus();
|
2012-04-11 18:54:20 +00:00
|
|
|
m_sdbSizerOK->SetDefault();
|
2008-04-29 03:18:02 +00:00
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
m_Board = GetParent()->GetBoard();
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetParent()->GetDisplayOptions();
|
2010-01-29 20:36:12 +00:00
|
|
|
|
2007-06-20 00:33:23 +00:00
|
|
|
/* Set display options */
|
2015-01-10 10:27:49 +00:00
|
|
|
m_PolarDisplay->SetSelection( displ_opts->m_DisplayPolarCood ? 1 : 0 );
|
2010-07-12 14:07:09 +00:00
|
|
|
m_UnitsSelection->SetSelection( g_UserUnit ? 1 : 0 );
|
2016-05-11 03:33:24 +00:00
|
|
|
|
2013-12-17 21:38:20 +00:00
|
|
|
wxString rotationAngle;
|
2014-01-10 20:12:36 +00:00
|
|
|
rotationAngle = AngleToStringDegrees( (double)GetParent()->GetRotationAngle() );
|
|
|
|
m_RotationAngle->SetValue( rotationAngle );
|
2011-09-07 09:27:02 +00:00
|
|
|
|
2008-04-29 03:18:02 +00:00
|
|
|
wxString timevalue;
|
2011-10-13 19:56:32 +00:00
|
|
|
timevalue << GetParent()->GetAutoSaveInterval() / 60;
|
2008-04-29 03:18:02 +00:00
|
|
|
m_SaveTime->SetValue( timevalue );
|
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
m_DrcOn->SetValue( GetParent()->Settings().m_legacyDrcOn );
|
2017-03-13 03:19:33 +00:00
|
|
|
m_ShowGlobalRatsnest->SetValue( m_Board->IsElementVisible( LAYER_RATSNEST ) );
|
2017-08-04 12:43:02 +00:00
|
|
|
m_TrackAutodel->SetValue( GetParent()->Settings().m_legacyAutoDeleteOldTrack );
|
|
|
|
m_Track_45_Only_Ctrl->SetValue( GetParent()->Settings().m_legacyUse45DegreeTracks );
|
|
|
|
m_Segments_45_Only_Ctrl->SetValue( GetParent()->Settings().m_use45DegreeGraphicSegments );
|
2015-08-06 18:40:22 +00:00
|
|
|
m_ZoomCenterOpt->SetValue( ! GetParent()->GetCanvas()->GetEnableZoomNoCenter() );
|
2016-02-24 19:53:02 +00:00
|
|
|
m_MousewheelPANOpt->SetValue( GetParent()->GetCanvas()->GetEnableMousewheelPan() );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_AutoPANOpt->SetValue( GetParent()->GetCanvas()->GetEnableAutoPan() );
|
2017-08-04 12:43:02 +00:00
|
|
|
m_Track_DoubleSegm_Ctrl->SetValue( GetParent()->Settings().m_legacyUseTwoSegmentTracks );
|
|
|
|
m_MagneticPadOptCtrl->SetSelection( GetParent()->Settings().m_magneticPads );
|
|
|
|
m_MagneticTrackOptCtrl->SetSelection( GetParent()->Settings().m_magneticTracks );
|
|
|
|
m_UseEditKeyForWidth->SetValue( GetParent()->Settings().m_editActionChangesTrackWidth );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-04-29 03:18:02 +00:00
|
|
|
|
2012-04-11 18:54:20 +00:00
|
|
|
void DIALOG_GENERALOPTIONS::OnCancelClick( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-06-05 12:10:51 +00:00
|
|
|
event.Skip();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2008-04-29 03:18:02 +00:00
|
|
|
|
|
|
|
|
2012-04-11 18:54:20 +00:00
|
|
|
void DIALOG_GENERALOPTIONS::OnOkClick( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-09-06 19:42:46 +00:00
|
|
|
EDA_UNITS_T ii;
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetParent()->GetDisplayOptions();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_DisplayPolarCood = ( m_PolarDisplay->GetSelection() == 0 ) ? false : true;
|
2010-07-12 14:07:09 +00:00
|
|
|
ii = g_UserUnit;
|
|
|
|
g_UserUnit = ( m_UnitsSelection->GetSelection() == 0 ) ? INCHES : MILLIMETRES;
|
2011-09-06 19:42:46 +00:00
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
if( ii != g_UserUnit )
|
2011-09-26 20:32:56 +00:00
|
|
|
GetParent()->ReCreateAuxiliaryToolbar();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
GetParent()->SetAutoSaveInterval( m_SaveTime->GetValue() * 60 );
|
2013-12-17 21:38:20 +00:00
|
|
|
GetParent()->SetRotationAngle( wxRound( 10.0 * wxAtof( m_RotationAngle->GetValue() ) ) );
|
2011-09-07 09:27:02 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Updating the combobox to display the active layer. */
|
2017-08-04 12:43:02 +00:00
|
|
|
GetParent()->Settings().m_legacyDrcOn = m_DrcOn->GetValue();
|
2011-09-06 19:42:46 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
if( m_Board->IsElementVisible( LAYER_RATSNEST ) != m_ShowGlobalRatsnest->GetValue() )
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
GetParent()->SetElementVisibility( LAYER_RATSNEST, m_ShowGlobalRatsnest->GetValue() );
|
2015-10-14 18:12:17 +00:00
|
|
|
GetParent()->GetCanvas()->Refresh();
|
|
|
|
GetParent()->OnModify();
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
2011-09-06 19:42:46 +00:00
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
GetParent()->Settings().m_legacyAutoDeleteOldTrack = m_TrackAutodel->GetValue();
|
|
|
|
GetParent()->Settings().m_use45DegreeGraphicSegments = m_Segments_45_Only_Ctrl->GetValue();
|
|
|
|
GetParent()->Settings().m_legacyUse45DegreeTracks = m_Track_45_Only_Ctrl->GetValue();
|
2012-04-11 18:54:20 +00:00
|
|
|
|
2015-08-06 18:40:22 +00:00
|
|
|
GetParent()->GetCanvas()->SetEnableZoomNoCenter( ! m_ZoomCenterOpt->GetValue() );
|
2016-02-24 19:53:02 +00:00
|
|
|
GetParent()->GetCanvas()->SetEnableMousewheelPan( m_MousewheelPANOpt->GetValue() );
|
2011-12-29 20:11:42 +00:00
|
|
|
GetParent()->GetCanvas()->SetEnableAutoPan( m_AutoPANOpt->GetValue() );
|
2016-02-24 19:53:02 +00:00
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
GetParent()->Settings().m_legacyUseTwoSegmentTracks = m_Track_DoubleSegm_Ctrl->GetValue();
|
|
|
|
GetParent()->Settings().m_magneticPads = (MAGNETIC_PAD_OPTION_VALUES) m_MagneticPadOptCtrl->GetSelection();
|
|
|
|
GetParent()->Settings().m_magneticTracks = (MAGNETIC_PAD_OPTION_VALUES) m_MagneticTrackOptCtrl->GetSelection();
|
|
|
|
GetParent()->Settings().m_editActionChangesTrackWidth = m_UseEditKeyForWidth->GetValue();
|
2009-02-24 22:41:30 +00:00
|
|
|
|
2010-04-23 14:46:00 +00:00
|
|
|
EndModal( wxID_OK );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|