kicad/pcbnew/dialog_general_options.cpp

236 lines
7.1 KiB
C++
Raw Normal View History

2007-05-06 16:03:28 +00:00
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_general_options.cpp
// Author: jean-pierre Charras
/////////////////////////////////////////////////////////////////////////////
/* functions relatives to the dialogs opened from the main menu :
* Preferences/general
* Preferences/display
*/
2007-05-06 16:03:28 +00:00
#include "fctsys.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
2007-05-06 16:03:28 +00:00
#include "pcbnew.h"
2009-07-30 11:04:07 +00:00
#include "wxPcbStruct.h"
2009-10-28 11:48:47 +00:00
#include "class_board_design_settings.h"
#include "dialog_general_options.h"
2007-05-06 16:03:28 +00:00
#include "pcbnew_id.h"
2007-05-06 16:03:28 +00:00
2009-12-19 19:24:49 +00:00
Dialog_GeneralOptions::Dialog_GeneralOptions( WinEDA_PcbFrame* parent ) :
DialogGeneralOptionsBoardEditor_base( parent )
{
m_Parent = parent;
init();
GetSizer()->SetSizeHints( this );
Center();
}
2007-05-06 16:03:28 +00:00
void Dialog_GeneralOptions::init()
2007-05-06 16:03:28 +00:00
{
SetFocus();
2008-04-29 03:18:02 +00:00
m_Board = m_Parent->GetBoard();
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 );
m_UnitsSelection->SetSelection( g_UnitMetric ? 1 : 0 );
m_CursorShape->SetSelection( m_Parent->m_CursorShape ? 1 : 0 );
2008-04-29 03:18:02 +00:00
wxString timevalue;
2007-06-20 00:33:23 +00:00
timevalue << g_TimeOut / 60;
2008-04-29 03:18:02 +00:00
m_SaveTime->SetValue( timevalue );
m_MaxShowLinks->SetValue( g_MaxLinksShowed );
m_DrcOn->SetValue( Drc_On );
m_ShowModuleRatsnest->SetValue( g_Show_Module_Ratsnest );
m_ShowGlobalRatsnest->SetValue( m_Board->IsElementVisible(RATSNEST_VISIBLE) );
2008-04-29 03:18:02 +00:00
m_TrackAutodel->SetValue( g_AutoDeleteOldTrack );
m_Track_45_Only_Ctrl->SetValue( g_Track_45_Only_Allowed );
2008-04-29 03:18:02 +00:00
m_Segments_45_Only_Ctrl->SetValue( Segments_45_Only );
m_AutoPANOpt->SetValue( m_Parent->DrawPanel->m_AutoPAN_Enable );
m_Segments_45_Only_Ctrl->SetValue( Segments_45_Only );
m_Track_DoubleSegm_Ctrl->SetValue( g_TwoSegmentTrackBuild );
2007-05-06 16:03:28 +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
void Dialog_GeneralOptions::OnCancelClick( wxCommandEvent& event )
2007-05-06 16:03:28 +00:00
{
event.Skip();
2007-05-06 16:03:28 +00:00
}
2008-04-29 03:18:02 +00:00
void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
2007-05-06 16:03:28 +00:00
{
2008-04-29 03:18:02 +00:00
int ii;
2007-05-06 16:03:28 +00:00
2007-06-20 00:33:23 +00:00
DisplayOpt.DisplayPolarCood =
( m_PolarDisplay->GetSelection() == 0 ) ? FALSE : true;
2007-06-20 00:33:23 +00:00
ii = g_UnitMetric;
g_UnitMetric = ( m_UnitsSelection->GetSelection() == 0 ) ? 0 : 1;
2008-04-29 03:18:02 +00:00
if( ii != g_UnitMetric )
m_Parent->ReCreateAuxiliaryToolbar();
2007-05-06 16:03:28 +00:00
m_Parent->m_CursorShape = m_CursorShape->GetSelection();
2007-06-20 00:33:23 +00:00
g_TimeOut = 60 * m_SaveTime->GetValue();
2007-05-06 16:03:28 +00:00
/* Updating the combobox to display the active layer. */
2007-06-20 00:33:23 +00:00
g_MaxLinksShowed = m_MaxShowLinks->GetValue();
Drc_On = m_DrcOn->GetValue();
if( m_Board->IsElementVisible(RATSNEST_VISIBLE) != m_ShowGlobalRatsnest->GetValue() )
2007-06-20 00:33:23 +00:00
{
m_Parent->SetElementVisibility(RATSNEST_VISIBLE, m_ShowGlobalRatsnest->GetValue() );
2009-12-19 19:24:49 +00:00
m_Parent->DrawPanel->Refresh( );
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();
2007-06-20 00:33:23 +00:00
Segments_45_Only = m_Segments_45_Only_Ctrl->GetValue();
g_Track_45_Only_Allowed = m_Track_45_Only_Ctrl->GetValue();
2007-06-20 00:33:23 +00:00
m_Parent->DrawPanel->m_AutoPAN_Enable = m_AutoPANOpt->GetValue();
2007-05-06 16:03:28 +00:00
g_TwoSegmentTrackBuild = m_Track_DoubleSegm_Ctrl->GetValue();
g_MagneticPadOption = m_MagneticPadOptCtrl->GetSelection();
g_MagneticTrackOption = m_MagneticTrackOptCtrl->GetSelection();
EndModal( wxID_OK );
2007-05-06 16:03:28 +00:00
}
/* Must be called on a click on the left toolbar (options toolbar
* Update variables according to tools states
*/
void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
{
int id = event.GetId();
bool state = m_OptionsToolBar->GetToolState( id );
switch( id )
{
case ID_TB_OPTIONS_DRC_OFF:
Drc_On = state ? FALSE : true;
break;
case ID_TB_OPTIONS_SHOW_GRID:
SetElementVisibility(GRID_VISIBLE, state);
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_RATSNEST:
SetElementVisibility(RATSNEST_VISIBLE, state);
2009-12-19 16:10:25 +00:00
DrawPanel->Refresh( );
break;
case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST:
g_Show_Module_Ratsnest = state; // TODO: use the visibility list
break;
case ID_TB_OPTIONS_SELECT_UNIT_MM:
g_UnitMetric = MILLIMETRE;
case ID_TB_OPTIONS_SELECT_UNIT_INCH:
if( id == ID_TB_OPTIONS_SELECT_UNIT_INCH )
g_UnitMetric = INCHES;
m_TrackAndViasSizesList_Changed = true;
UpdateStatusBar();
ReCreateAuxiliaryToolbar();
DisplayUnitsMsg();
break;
case ID_TB_OPTIONS_SHOW_POLAR_COORD:
Affiche_Message( wxEmptyString );
DisplayOpt.DisplayPolarCood = state;
UpdateStatusBar();
break;
case ID_TB_OPTIONS_SELECT_CURSOR:
m_CursorShape = state;
break;
case ID_TB_OPTIONS_AUTO_DEL_TRACK:
g_AutoDeleteOldTrack = state;
break;
case ID_TB_OPTIONS_SHOW_ZONES:
DisplayOpt.DisplayZonesMode = 0;
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
DisplayOpt.DisplayZonesMode = 1;
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
DisplayOpt.DisplayZonesMode = 2;
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_PADS_SKETCH:
if( state )
{
m_DisplayPadFill = DisplayOpt.DisplayPadFill = false;
}
else
{
m_DisplayPadFill = DisplayOpt.DisplayPadFill = true;
}
DrawPanel->Refresh();
break;
2009-09-29 04:44:35 +00:00
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
if( state )
2009-09-29 04:44:35 +00:00
{
m_DisplayViaFill = DisplayOpt.DisplayViaFill = false;
}
else
{
m_DisplayViaFill = DisplayOpt.DisplayViaFill = true;
}
DrawPanel->Refresh();
2009-09-29 04:44:35 +00:00
break;
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = !state;
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
DisplayOpt.ContrastModeDisplay = state;
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1:
m_show_microwave_tools = state;
m_auimgr.GetPane( wxT( "m_AuxVToolBar" ) ).Show( m_show_microwave_tools );
m_auimgr.Update();
break;
case ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR:
// show auxiliary Vertical layers and visibility manager toolbar
m_show_layer_manager_tools = state;
m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
2009-11-02 22:24:55 +00:00
m_auimgr.Update();
if( m_show_layer_manager_tools )
GetMenuBar()->SetLabel(ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
_("Hide &Layers Manager" ) );
else
GetMenuBar()->SetLabel(ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
_("Show &Layers Manager" ) );
break;
default:
DisplayError( this,
wxT( "WinEDA_PcbFrame::OnSelectOptionToolbar error \n (event not handled!)" ) );
break;
}
SetToolbars();
}