You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

264 lines
7.6 KiB

16 years ago
16 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
16 years ago
18 years ago
18 years ago
18 years ago
16 years ago
18 years ago
18 years ago
16 years ago
16 years ago
16 years ago
16 years ago
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: dialog_general_options.cpp
  3. // Author: jean-pierre Charras
  4. /////////////////////////////////////////////////////////////////////////////
  5. /* functions relatives to the dialogs opened from the main menu :
  6. * Preferences/general
  7. * Preferences/display
  8. */
  9. #include "fctsys.h"
  10. #include "common.h"
  11. #include "class_drawpanel.h"
  12. #include "confirm.h"
  13. #include "pcbnew.h"
  14. #include "wxPcbStruct.h"
  15. #include "class_board_design_settings.h"
  16. #include "dialog_general_options.h"
  17. #include "pcbnew_id.h"
  18. Dialog_GeneralOptions::Dialog_GeneralOptions( WinEDA_PcbFrame* parent ) :
  19. DialogGeneralOptionsBoardEditor_base( parent )
  20. {
  21. m_Parent = parent;
  22. init();
  23. GetSizer()->SetSizeHints( this );
  24. Center();
  25. }
  26. void Dialog_GeneralOptions::init()
  27. {
  28. SetFocus();
  29. m_Board = m_Parent->GetBoard();
  30. /* Set display options */
  31. m_PolarDisplay->SetSelection( DisplayOpt.DisplayPolarCood ? 1 : 0 );
  32. m_UnitsSelection->SetSelection( g_UnitMetric ? 1 : 0 );
  33. m_CursorShape->SetSelection( m_Parent->m_CursorShape ? 1 : 0 );
  34. wxString timevalue;
  35. timevalue << g_TimeOut / 60;
  36. m_SaveTime->SetValue( timevalue );
  37. m_MaxShowLinks->SetValue( g_MaxLinksShowed );
  38. m_DrcOn->SetValue( Drc_On );
  39. m_ShowModuleRatsnest->SetValue( g_Show_Module_Ratsnest );
  40. m_ShowGlobalRatsnest->SetValue( m_Board->IsElementVisible(RATSNEST_VISIBLE) );
  41. m_TrackAutodel->SetValue( g_AutoDeleteOldTrack );
  42. m_Track_45_Only_Ctrl->SetValue( Track_45_Only );
  43. m_Segments_45_Only_Ctrl->SetValue( Segments_45_Only );
  44. m_AutoPANOpt->SetValue( m_Parent->DrawPanel->m_AutoPAN_Enable );
  45. m_Segments_45_Only_Ctrl->SetValue( Segments_45_Only );
  46. m_Track_DoubleSegm_Ctrl->SetValue( g_TwoSegmentTrackBuild );
  47. m_MagneticPadOptCtrl->SetSelection( g_MagneticPadOption );
  48. m_MagneticTrackOptCtrl->SetSelection( g_MagneticTrackOption );
  49. }
  50. void Dialog_GeneralOptions::OnCancelClick( wxCommandEvent& event )
  51. {
  52. event.Skip();
  53. }
  54. void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
  55. {
  56. int ii;
  57. DisplayOpt.DisplayPolarCood =
  58. ( m_PolarDisplay->GetSelection() == 0 ) ? FALSE : true;
  59. ii = g_UnitMetric;
  60. g_UnitMetric = ( m_UnitsSelection->GetSelection() == 0 ) ? 0 : 1;
  61. if( ii != g_UnitMetric )
  62. m_Parent->ReCreateAuxiliaryToolbar();
  63. m_Parent->m_CursorShape = m_CursorShape->GetSelection();
  64. g_TimeOut = 60 * m_SaveTime->GetValue();
  65. /* Updating the combobox to display the active layer. */
  66. g_MaxLinksShowed = m_MaxShowLinks->GetValue();
  67. Drc_On = m_DrcOn->GetValue();
  68. if( m_Board->IsElementVisible(RATSNEST_VISIBLE) != m_ShowGlobalRatsnest->GetValue() )
  69. {
  70. m_Parent->SetElementVisibility(RATSNEST_VISIBLE, m_ShowGlobalRatsnest->GetValue() );
  71. m_Parent->DrawPanel->Refresh( );
  72. }
  73. g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue();
  74. g_AutoDeleteOldTrack = m_TrackAutodel->GetValue();
  75. Segments_45_Only = m_Segments_45_Only_Ctrl->GetValue();
  76. Track_45_Only = m_Track_45_Only_Ctrl->GetValue();
  77. m_Parent->DrawPanel->m_AutoPAN_Enable = m_AutoPANOpt->GetValue();
  78. g_TwoSegmentTrackBuild = m_Track_DoubleSegm_Ctrl->GetValue();
  79. g_MagneticPadOption = m_MagneticPadOptCtrl->GetSelection();
  80. g_MagneticTrackOption = m_MagneticTrackOptCtrl->GetSelection();
  81. EndModal( 1 );
  82. }
  83. #include "dialog_graphic_items_options.cpp"
  84. void WinEDA_PcbFrame::InstallPcbOptionsFrame( int id )
  85. {
  86. switch( id )
  87. {
  88. case ID_PCB_DRAWINGS_WIDTHS_SETUP:
  89. {
  90. WinEDA_GraphicItemsOptionsDialog dlg( this );
  91. dlg.ShowModal();
  92. }
  93. break;
  94. default:
  95. wxMessageBox( wxT( "InstallPcbOptionsFrame() id error" ) );
  96. break;
  97. }
  98. }
  99. void WinEDA_ModuleEditFrame::InstallOptionsFrame( const wxPoint& pos )
  100. {
  101. WinEDA_GraphicItemsOptionsDialog dlg( this );
  102. dlg.ShowModal();
  103. }
  104. /* Must be called on a click on the left toolbar (options toolbar
  105. * Update variables according to tools states
  106. */
  107. void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
  108. {
  109. int id = event.GetId();
  110. bool state = m_OptionsToolBar->GetToolState( id );
  111. switch( id )
  112. {
  113. case ID_TB_OPTIONS_DRC_OFF:
  114. Drc_On = state ? FALSE : true;
  115. break;
  116. case ID_TB_OPTIONS_SHOW_GRID:
  117. SetElementVisibility(GRID_VISIBLE, state);
  118. DrawPanel->Refresh();
  119. break;
  120. case ID_TB_OPTIONS_SHOW_RATSNEST:
  121. SetElementVisibility(RATSNEST_VISIBLE, state);
  122. DrawPanel->Refresh( );
  123. break;
  124. case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST:
  125. g_Show_Module_Ratsnest = state; // TODO: use the visibility list
  126. break;
  127. case ID_TB_OPTIONS_SELECT_UNIT_MM:
  128. g_UnitMetric = MILLIMETRE;
  129. case ID_TB_OPTIONS_SELECT_UNIT_INCH:
  130. if( id == ID_TB_OPTIONS_SELECT_UNIT_INCH )
  131. g_UnitMetric = INCHES;
  132. m_TrackAndViasSizesList_Changed = true;
  133. UpdateStatusBar();
  134. ReCreateAuxiliaryToolbar();
  135. DisplayUnitsMsg();
  136. break;
  137. case ID_TB_OPTIONS_SHOW_POLAR_COORD:
  138. Affiche_Message( wxEmptyString );
  139. DisplayOpt.DisplayPolarCood = state;
  140. UpdateStatusBar();
  141. break;
  142. case ID_TB_OPTIONS_SELECT_CURSOR:
  143. m_CursorShape = state;
  144. break;
  145. case ID_TB_OPTIONS_AUTO_DEL_TRACK:
  146. g_AutoDeleteOldTrack = state;
  147. break;
  148. case ID_TB_OPTIONS_SHOW_ZONES:
  149. DisplayOpt.DisplayZonesMode = 0;
  150. DrawPanel->Refresh();
  151. break;
  152. case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
  153. DisplayOpt.DisplayZonesMode = 1;
  154. DrawPanel->Refresh();
  155. break;
  156. case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
  157. DisplayOpt.DisplayZonesMode = 2;
  158. DrawPanel->Refresh();
  159. break;
  160. case ID_TB_OPTIONS_SHOW_PADS_SKETCH:
  161. if( state )
  162. {
  163. m_DisplayPadFill = DisplayOpt.DisplayPadFill = false;
  164. }
  165. else
  166. {
  167. m_DisplayPadFill = DisplayOpt.DisplayPadFill = true;
  168. }
  169. DrawPanel->Refresh();
  170. break;
  171. case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
  172. if( state )
  173. {
  174. m_DisplayViaFill = DisplayOpt.DisplayViaFill = false;
  175. }
  176. else
  177. {
  178. m_DisplayViaFill = DisplayOpt.DisplayViaFill = true;
  179. }
  180. DrawPanel->Refresh();
  181. break;
  182. case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
  183. m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = !state;
  184. DrawPanel->Refresh();
  185. break;
  186. case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
  187. DisplayOpt.ContrastModeDisplay = state;
  188. DrawPanel->Refresh();
  189. break;
  190. case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1:
  191. m_show_microwave_tools = state;
  192. m_auimgr.GetPane( wxT( "m_AuxVToolBar" ) ).Show( m_show_microwave_tools );
  193. m_auimgr.Update();
  194. break;
  195. case ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR:
  196. // show auxiliary Vertical layers and visibility manager toolbar
  197. m_show_layer_manager_tools = state;
  198. m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
  199. m_auimgr.Update();
  200. if( m_show_layer_manager_tools )
  201. GetMenuBar()->SetLabel(ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
  202. _("Hide &Layers Manager" ) );
  203. else
  204. GetMenuBar()->SetLabel(ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
  205. _("Show &Layers Manager" ) );
  206. break;
  207. default:
  208. DisplayError( this,
  209. wxT( "WinEDA_PcbFrame::OnSelectOptionToolbar error \n (event not handled!)" ) );
  210. break;
  211. }
  212. SetToolbars();
  213. }