kicad/pcbnew/dialog_general_options.cpp

410 lines
13 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 :
Prefernces/general
Prefernces/display
*/
2007-05-06 16:03:28 +00:00
#include "fctsys.h"
2007-05-06 16:03:28 +00:00
#include "common.h"
#include "pcbnew.h"
#include "id.h"
#include "dialog_general_options_BoardEditor_base.h"
#include "dialog_display_options_base.h"
#include "dialog_general_options.h"
2007-05-06 16:03:28 +00:00
/***********************************************************************************/
Dialog_GeneralOptions::Dialog_GeneralOptions( WinEDA_PcbFrame* parent, wxDC* DC ) :
DialogGeneralOptionsBoardEditor_base( parent )
/***********************************************************************************/
{
m_Parent = parent;
m_DC = DC;
}
2007-05-06 16:03:28 +00:00
/********************************************************************/
void Dialog_GeneralOptions::OnInitDialog( wxInitDialogEvent& event )
/********************************************************************/
2007-05-06 16:03:28 +00:00
{
SetFont( *g_DialogFont );
SetFocus();
2007-05-06 16:03:28 +00:00
2008-04-29 03:18:02 +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 );
m_UnitsSelection->SetSelection( g_UnitMetric ? 1 : 0 );
2008-04-29 03:18:02 +00:00
m_CursorShape->SetSelection( g_CursorShape ? 1 : 0 );
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 );
int layer_count[] = {1,2,4,6,8,10,12,14,16};
m_LayerNumber->SetSelection(1);
for ( unsigned ii = 0; ii < sizeof(layer_count); ii++ )
{
if ( g_DesignSettings.m_CopperLayerCount != layer_count[ii] )
continue;
m_LayerNumber->SetSelection(ii);
break;
}
2008-04-29 03:18:02 +00:00
m_MaxShowLinks->SetValue( g_MaxLinksShowed );
m_DrcOn->SetValue( Drc_On );
m_ShowModuleRatsnest->SetValue( g_Show_Module_Ratsnest );
m_ShowGlobalRatsnest->SetValue( g_Show_Ratsnest );
m_TrackAutodel->SetValue( g_AutoDeleteOldTrack );
m_Track_45_Only_Ctrl->SetValue( Track_45_Only );
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 );
2008-04-29 03:18:02 +00:00
if( GetSizer() )
{
2008-04-29 03:18:02 +00:00
GetSizer()->SetSizeHints( this );
}
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
2007-05-06 16:03:28 +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;
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
2007-06-20 00:33:23 +00:00
g_CursorShape = m_CursorShape->GetSelection();
g_TimeOut = 60 * m_SaveTime->GetValue();
2007-05-06 16:03:28 +00:00
2007-06-20 00:33:23 +00:00
/* Mise a jour de la combobox d'affichage de la couche active */
int layer_count[] = {1,2,4,6,8,10,12,14,16};
g_DesignSettings.m_CopperLayerCount = layer_count[m_LayerNumber->GetSelection()];
2008-04-29 03:18:02 +00:00
m_Parent->ReCreateLayerBox( NULL );
2007-05-06 16:03:28 +00:00
2007-06-20 00:33:23 +00:00
g_MaxLinksShowed = m_MaxShowLinks->GetValue();
Drc_On = m_DrcOn->GetValue();
2008-04-29 03:18:02 +00:00
if( g_Show_Ratsnest != m_ShowGlobalRatsnest->GetValue() )
2007-06-20 00:33:23 +00:00
{
g_Show_Ratsnest = m_ShowGlobalRatsnest->GetValue();
2008-04-29 03:18:02 +00:00
m_Parent->Ratsnest_On_Off( m_DC );
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();
2008-04-29 03:18:02 +00:00
Track_45_Only = 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();
2008-04-29 03:18:02 +00:00
EndModal( 1 );
2007-05-06 16:03:28 +00:00
}
/*******************************************************************************/
Dialog_Display_Options::Dialog_Display_Options( WinEDA_BasePcbFrame* parent ) :
DialogDisplayOptions_base(parent)
/*******************************************************************************/
{
m_Parent = parent;
}
/****************************************************************/
void Dialog_Display_Options::OnInitDialog( wxInitDialogEvent& event )
/****************************************************************/
{
SetFocus();
if ( DisplayOpt.DisplayPcbTrackFill )
m_OptDisplayTracks->SetSelection(1);
if ( DisplayOpt.DisplayTrackIsol )
m_OptDisplayTracksClearance->SetSelection(0);
else if ( g_ShowIsolDuringCreateTrack )
m_OptDisplayTracksClearance->SetSelection(1);
else m_OptDisplayTracksClearance->SetSelection(2);
if ( DisplayOpt.DisplayPadFill )
m_OptDisplayPads->SetSelection(1);
m_Show_Page_Limits->SetSelection( g_ShowPageLimits ? 0 : 1);
m_OptDisplayViaHole->SetSelection( DisplayOpt.m_DisplayViaMode );
m_OptDisplayModTexts->SetSelection( DisplayOpt.DisplayModText );
m_OptDisplayModEdges->SetSelection( DisplayOpt.DisplayModEdge );
m_OptDisplayPadClearence->SetValue( DisplayOpt.DisplayPadIsol );
m_OptDisplayPadNumber->SetValue( DisplayOpt.DisplayPadNum );
m_OptDisplayPadNoConn->SetValue( DisplayOpt.DisplayPadNoConn );
m_OptDisplayDrawings->SetSelection( DisplayOpt.DisplayDrawItems );
if( GetSizer() )
{
GetSizer()->SetSizeHints( this );
}
}
/*****************************************************************/
void Dialog_Display_Options::OnCancelClick( wxCommandEvent& event )
/*****************************************************************/
{
event.Skip();
}
/*************************************************************************/
void Dialog_Display_Options::OnOkClick(wxCommandEvent& event)
/*************************************************************************/
/* Update variables with new options
*/
{
if ( m_Show_Page_Limits->GetSelection() == 0 ) g_ShowPageLimits = TRUE;
else g_ShowPageLimits = FALSE;
if ( m_OptDisplayTracks->GetSelection() == 1)
DisplayOpt.DisplayPcbTrackFill = TRUE;
else DisplayOpt.DisplayPcbTrackFill = FALSE;
m_Parent->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
DisplayOpt.m_DisplayViaMode = m_OptDisplayViaHole->GetSelection();
switch ( m_OptDisplayTracksClearance->GetSelection() )
{
case 0:
DisplayOpt.DisplayTrackIsol = TRUE;
g_ShowIsolDuringCreateTrack = TRUE;
break;
case 1:
DisplayOpt.DisplayTrackIsol = FALSE;
g_ShowIsolDuringCreateTrack = TRUE;
break;
case 2:
DisplayOpt.DisplayTrackIsol = FALSE;
g_ShowIsolDuringCreateTrack = FALSE;
break;
}
m_Parent->m_DisplayModText = DisplayOpt.DisplayModText =
m_OptDisplayModTexts->GetSelection();
m_Parent->m_DisplayModEdge = DisplayOpt.DisplayModEdge =
m_OptDisplayModEdges->GetSelection();
if (m_OptDisplayPads->GetSelection() == 1 )
DisplayOpt.DisplayPadFill = TRUE;
else DisplayOpt.DisplayPadFill = FALSE;
m_Parent->m_DisplayPadFill = DisplayOpt.DisplayPadFill;
DisplayOpt.DisplayPadIsol = m_OptDisplayPadClearence->GetValue();
m_Parent->m_DisplayPadNum = DisplayOpt.DisplayPadNum = m_OptDisplayPadNumber->GetValue();
DisplayOpt.DisplayPadNoConn = m_OptDisplayPadNoConn->GetValue();
DisplayOpt.DisplayDrawItems = m_OptDisplayDrawings->GetSelection();
m_Parent->DrawPanel->Refresh(TRUE);
EndModal(1);
}
2007-05-06 16:03:28 +00:00
#include "dialog_track_options.cpp"
#include "dialog_graphic_items_options.cpp"
/*****************************************************************/
2008-04-29 03:18:02 +00:00
void WinEDA_PcbFrame::InstallPcbOptionsFrame( const wxPoint& pos,
wxDC* DC, int id )
2007-05-06 16:03:28 +00:00
/*****************************************************************/
{
2008-04-29 03:18:02 +00:00
switch( id )
2007-06-20 00:33:23 +00:00
{
case ID_PCB_TRACK_SIZE_SETUP:
{
2008-04-29 03:18:02 +00:00
WinEDA_PcbTracksDialog* OptionsFrame =
new WinEDA_PcbTracksDialog( this );
OptionsFrame->ShowModal();
OptionsFrame->Destroy();
2007-06-20 00:33:23 +00:00
}
break;
case ID_PCB_DRAWINGS_WIDTHS_SETUP:
{
2008-04-29 03:18:02 +00:00
WinEDA_GraphicItemsOptionsDialog* OptionsFrame =
new WinEDA_GraphicItemsOptionsDialog( this );
OptionsFrame->ShowModal();
OptionsFrame->Destroy();
2007-06-20 00:33:23 +00:00
}
break;
case ID_PCB_LOOK_SETUP:
{
Dialog_Display_Options* DisplayOptionsDialog =
new Dialog_Display_Options( this );
2008-04-29 03:18:02 +00:00
DisplayOptionsDialog->ShowModal();
DisplayOptionsDialog->Destroy();
2007-06-20 00:33:23 +00:00
}
break;
case ID_OPTIONS_SETUP:
{
Dialog_GeneralOptions* OptionsFrame =
new Dialog_GeneralOptions( this, DC );
2008-04-29 03:18:02 +00:00
OptionsFrame->ShowModal();
OptionsFrame->Destroy();
2007-06-20 00:33:23 +00:00
}
break;
}
2007-05-06 16:03:28 +00:00
}
/*******************************************************************/
2008-04-29 03:18:02 +00:00
void WinEDA_ModuleEditFrame::InstallOptionsFrame( const wxPoint& pos )
2007-05-06 16:03:28 +00:00
/*******************************************************************/
{
2008-04-29 03:18:02 +00:00
WinEDA_GraphicItemsOptionsDialog OptionsFrame( this );
2007-06-20 00:33:23 +00:00
OptionsFrame.ShowModal();
2007-05-06 16:03:28 +00:00
}
/*****************************************************************/
void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
/*****************************************************************/
/* Must be called on a click on the left toolbar (options toolbar
* Update variables according to the tools states
*/
{
int id = event.GetId();
switch( id )
{
case ID_TB_OPTIONS_DRC_OFF:
Drc_On = m_OptionsToolBar->GetToolState( id ) ? FALSE : TRUE;
break;
case ID_TB_OPTIONS_SHOW_GRID:
m_Draw_Grid = g_ShowGrid = m_OptionsToolBar->GetToolState( id );
DrawPanel->Refresh( );
break;
case ID_TB_OPTIONS_SHOW_RATSNEST:
g_Show_Ratsnest = m_OptionsToolBar->GetToolState( id );
{
wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext( &dc );
Ratsnest_On_Off( &dc );
}
break;
case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST:
g_Show_Module_Ratsnest = m_OptionsToolBar->GetToolState( id );
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_SelTrackWidthBox_Changed = TRUE;
Affiche_Status_Box(); /* Reaffichage des coord curseur */
ReCreateAuxiliaryToolbar();
DisplayUnitsMsg();
break;
case ID_TB_OPTIONS_SHOW_POLAR_COORD:
Affiche_Message( wxEmptyString );
DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState( id );
Affiche_Status_Box(); /* Reaffichage des coord curseur */
break;
case ID_TB_OPTIONS_SELECT_CURSOR:
g_CursorShape = m_OptionsToolBar->GetToolState( id );
break;
case ID_TB_OPTIONS_AUTO_DEL_TRACK:
g_AutoDeleteOldTrack = m_OptionsToolBar->GetToolState( id );
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:
m_DisplayPadFill = DisplayOpt.DisplayPadFill =
!m_OptionsToolBar->GetToolState( id );
DrawPanel->Refresh( );
break;
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill =
!m_OptionsToolBar->GetToolState( id );
DrawPanel->Refresh( );
break;
case ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE:
DisplayOpt.ContrastModeDisplay =
m_OptionsToolBar->GetToolState( id );
DrawPanel->Refresh( );
break;
case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1:
if( m_OptionsToolBar->GetToolState( id ) ) // show aux V toolbar (Microwave tool)
ReCreateAuxVToolbar();
else
{
delete m_AuxVToolBar;
m_AuxVToolBar = NULL;
}
{
wxSizeEvent SizeEv( GetSize() );
OnSize( SizeEv );
}
break;
default:
DisplayError( this,
wxT( "WinEDA_PcbFrame::OnSelectOptionToolbar error \n (event not handled!)" ) );
break;
}
SetToolbars();
}