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
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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>
|
2014-04-04 09:56:04 +00:00
|
|
|
#include <class_draw_panel_gal.h>
|
2013-04-08 08:50:47 +00:00
|
|
|
#include <view/view.h>
|
|
|
|
#include <pcb_painter.h>
|
2014-01-10 20:12:36 +00:00
|
|
|
#include <base_units.h>
|
2009-02-24 22:41:30 +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();
|
2010-01-29 20:36:12 +00:00
|
|
|
|
2007-06-20 00:33:23 +00:00
|
|
|
/* Set display options */
|
2008-04-29 03:18:02 +00:00
|
|
|
m_PolarDisplay->SetSelection( DisplayOpt.DisplayPolarCood ? 1 : 0 );
|
2010-07-12 14:07:09 +00:00
|
|
|
m_UnitsSelection->SetSelection( g_UserUnit ? 1 : 0 );
|
2011-12-14 20:03:15 +00:00
|
|
|
m_CursorShape->SetSelection( GetParent()->GetCursorShape() ? 1 : 0 );
|
2008-04-29 03:18:02 +00:00
|
|
|
|
2011-09-07 09:27:02 +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 );
|
|
|
|
m_MaxShowLinks->SetValue( g_MaxLinksShowed );
|
|
|
|
|
2013-03-27 18:32:12 +00:00
|
|
|
m_DrcOn->SetValue( g_Drc_On );
|
2008-04-29 03:18:02 +00:00
|
|
|
m_ShowModuleRatsnest->SetValue( g_Show_Module_Ratsnest );
|
2011-09-26 20:32:56 +00:00
|
|
|
m_ShowGlobalRatsnest->SetValue( m_Board->IsElementVisible( RATSNEST_VISIBLE ) );
|
2008-04-29 03:18:02 +00:00
|
|
|
m_TrackAutodel->SetValue( g_AutoDeleteOldTrack );
|
2010-05-01 09:22:12 +00:00
|
|
|
m_Track_45_Only_Ctrl->SetValue( g_Track_45_Only_Allowed );
|
2013-03-27 18:32:12 +00:00
|
|
|
m_Segments_45_Only_Ctrl->SetValue( g_Segments_45_Only );
|
2013-02-02 19:10:48 +00:00
|
|
|
m_ZoomNoCenterOpt->SetValue( GetParent()->GetCanvas()->GetEnableZoomNoCenter() );
|
2012-04-11 18:54:20 +00:00
|
|
|
m_MiddleButtonPANOpt->SetValue( GetParent()->GetCanvas()->GetEnableMiddleButtonPan() );
|
|
|
|
m_OptMiddleButtonPanLimited->SetValue( GetParent()->GetCanvas()->GetMiddleButtonPanLimited() );
|
|
|
|
m_OptMiddleButtonPanLimited->Enable( m_MiddleButtonPANOpt->GetValue() );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_AutoPANOpt->SetValue( GetParent()->GetCanvas()->GetEnableAutoPan() );
|
2008-04-29 03:18:02 +00:00
|
|
|
m_Track_DoubleSegm_Ctrl->SetValue( g_TwoSegmentTrackBuild );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-12-21 12:11:47 +00:00
|
|
|
m_MagneticPadOptCtrl->SetSelection( g_MagneticPadOption );
|
|
|
|
m_MagneticTrackOptCtrl->SetSelection( g_MagneticTrackOption );
|
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;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
DisplayOpt.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-12-14 20:03:15 +00:00
|
|
|
GetParent()->SetCursorShape( m_CursorShape->GetSelection() );
|
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. */
|
2007-06-20 00:33:23 +00:00
|
|
|
g_MaxLinksShowed = m_MaxShowLinks->GetValue();
|
2013-03-27 18:32:12 +00:00
|
|
|
g_Drc_On = m_DrcOn->GetValue();
|
2011-09-06 19:42:46 +00:00
|
|
|
|
2010-01-29 20:36:12 +00:00
|
|
|
if( m_Board->IsElementVisible(RATSNEST_VISIBLE) != m_ShowGlobalRatsnest->GetValue() )
|
2007-06-20 00:33:23 +00:00
|
|
|
{
|
2011-09-26 20:32:56 +00:00
|
|
|
GetParent()->SetElementVisibility(RATSNEST_VISIBLE, m_ShowGlobalRatsnest->GetValue() );
|
2011-12-22 13:28:11 +00:00
|
|
|
GetParent()->GetCanvas()->Refresh( );
|
2007-06-20 00:33:23 +00:00
|
|
|
}
|
2011-09-06 19:42:46 +00:00
|
|
|
|
2007-06-20 00:33:23 +00:00
|
|
|
g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue();
|
2008-04-29 03:18:02 +00:00
|
|
|
g_AutoDeleteOldTrack = m_TrackAutodel->GetValue();
|
2013-03-27 18:32:12 +00:00
|
|
|
g_Segments_45_Only = m_Segments_45_Only_Ctrl->GetValue();
|
2010-05-01 09:22:12 +00:00
|
|
|
g_Track_45_Only_Allowed = m_Track_45_Only_Ctrl->GetValue();
|
2012-04-11 18:54:20 +00:00
|
|
|
|
2013-02-02 19:10:48 +00:00
|
|
|
GetParent()->GetCanvas()->SetEnableZoomNoCenter( m_ZoomNoCenterOpt->GetValue() );
|
2012-04-11 18:54:20 +00:00
|
|
|
GetParent()->GetCanvas()->SetEnableMiddleButtonPan( m_MiddleButtonPANOpt->GetValue() );
|
|
|
|
GetParent()->GetCanvas()->SetMiddleButtonPanLimited( m_OptMiddleButtonPanLimited->GetValue() );
|
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
GetParent()->GetCanvas()->SetEnableAutoPan( m_AutoPANOpt->GetValue() );
|
2007-05-06 16:03:28 +00:00
|
|
|
g_TwoSegmentTrackBuild = m_Track_DoubleSegm_Ctrl->GetValue();
|
2009-11-14 22:15:22 +00:00
|
|
|
g_MagneticPadOption = m_MagneticPadOptCtrl->GetSelection();
|
2009-02-24 22:41:30 +00:00
|
|
|
g_MagneticTrackOption = m_MagneticTrackOptCtrl->GetSelection();
|
|
|
|
|
2010-04-23 14:46:00 +00:00
|
|
|
EndModal( wxID_OK );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-21 16:54:27 +00:00
|
|
|
/* Must be called on a click on the left toolbar (options toolbar
|
2010-01-29 20:36:12 +00:00
|
|
|
* Update variables according to tools states
|
2008-12-21 16:54:27 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
|
2008-12-21 16:54:27 +00:00
|
|
|
{
|
|
|
|
int id = event.GetId();
|
2013-01-19 09:58:25 +00:00
|
|
|
bool state = event.IsChecked();
|
2008-12-21 16:54:27 +00:00
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_TB_OPTIONS_DRC_OFF:
|
2013-03-27 18:32:12 +00:00
|
|
|
g_Drc_On = !state;
|
2011-09-26 20:32:56 +00:00
|
|
|
|
2011-03-04 19:16:00 +00:00
|
|
|
if( GetToolId() == ID_TRACK_BUTT )
|
|
|
|
{
|
2013-03-27 18:32:12 +00:00
|
|
|
if( g_Drc_On )
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetCursor( wxCURSOR_PENCIL );
|
2011-03-04 19:16:00 +00:00
|
|
|
else
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetCursor( wxCURSOR_QUESTION_ARROW );
|
2011-03-04 19:16:00 +00:00
|
|
|
}
|
2008-12-21 16:54:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TB_OPTIONS_SHOW_RATSNEST:
|
2011-02-21 13:54:29 +00:00
|
|
|
SetElementVisibility( RATSNEST_VISIBLE, state );
|
2011-09-26 20:32:56 +00:00
|
|
|
|
2011-03-10 08:31:07 +00:00
|
|
|
if( state && (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
|
|
|
|
Compile_Ratsnest( NULL, true );
|
2011-09-26 20:32:56 +00:00
|
|
|
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2008-12-21 16:54:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST:
|
2010-01-30 14:46:26 +00:00
|
|
|
g_Show_Module_Ratsnest = state; // TODO: use the visibility list
|
2008-12-21 16:54:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TB_OPTIONS_AUTO_DEL_TRACK:
|
2010-01-30 14:46:26 +00:00
|
|
|
g_AutoDeleteOldTrack = state;
|
2008-12-21 16:54:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TB_OPTIONS_SHOW_ZONES:
|
|
|
|
DisplayOpt.DisplayZonesMode = 0;
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2008-12-21 16:54:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
|
|
|
|
DisplayOpt.DisplayZonesMode = 1;
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2008-12-21 16:54:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
|
|
|
|
DisplayOpt.DisplayZonesMode = 2;
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2008-12-21 16:54:27 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-29 04:44:35 +00:00
|
|
|
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
|
2011-02-21 13:54:29 +00:00
|
|
|
m_DisplayViaFill = DisplayOpt.DisplayViaFill = !state;
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2009-09-29 04:44:35 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-21 16:54:27 +00:00
|
|
|
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
|
2010-01-30 14:46:26 +00:00
|
|
|
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = !state;
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2008-12-21 16:54:27 +00:00
|
|
|
break;
|
|
|
|
|
2009-06-19 20:13:22 +00:00
|
|
|
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
|
2013-07-16 07:26:29 +00:00
|
|
|
{
|
2010-01-30 14:46:26 +00:00
|
|
|
DisplayOpt.ContrastModeDisplay = state;
|
2013-09-20 15:29:32 +00:00
|
|
|
m_canvas->Refresh();
|
2008-12-21 16:54:27 +00:00
|
|
|
break;
|
2013-07-16 07:26:29 +00:00
|
|
|
}
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2011-03-04 19:16:00 +00:00
|
|
|
case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE:
|
2010-01-30 14:46:26 +00:00
|
|
|
m_show_microwave_tools = state;
|
2011-12-14 20:03:15 +00:00
|
|
|
m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).Show( m_show_microwave_tools );
|
2010-01-21 20:36:48 +00:00
|
|
|
m_auimgr.Update();
|
2014-02-27 18:48:18 +00:00
|
|
|
|
|
|
|
GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR,
|
|
|
|
m_show_microwave_tools ?
|
|
|
|
_( "Hide Microwave Toolbar" ): _( "Show Microwave Toolbar" ));
|
2010-01-21 20:36:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-02-03 14:44:12 +00:00
|
|
|
case ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR:
|
2010-01-21 20:36:48 +00:00
|
|
|
// show auxiliary Vertical layers and visibility manager toolbar
|
2010-01-30 14:46:26 +00:00
|
|
|
m_show_layer_manager_tools = state;
|
2010-01-21 20:36:48 +00:00
|
|
|
m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.Update();
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2011-03-03 19:08:13 +00:00
|
|
|
GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
|
|
|
|
m_show_layer_manager_tools ?
|
2011-09-26 20:32:56 +00:00
|
|
|
_( "Hide &Layers Manager" ) : _( "Show &Layers Manager" ) );
|
2008-12-21 16:54:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this,
|
2011-03-01 19:26:17 +00:00
|
|
|
wxT( "PCB_EDIT_FRAME::OnSelectOptionToolbar error \n (event not handled!)" ) );
|
2008-12-21 16:54:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|