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.

407 lines
12 KiB

  1. /********************************************/
  2. /* GERBVIEW - Gestion des Options et Reglages */
  3. /********************************************/
  4. /* File options.cpp */
  5. /*
  6. * Set the display options for Gerbview
  7. */
  8. #include "fctsys.h"
  9. #include "common.h"
  10. #include "gerbview.h"
  11. #include "pcbplot.h"
  12. #include "id.h"
  13. #include "protos.h"
  14. #include <wx/spinctrl.h>
  15. /*****************************************************************/
  16. void WinEDA_GerberFrame::OnSelectOptionToolbar(wxCommandEvent& event)
  17. /*****************************************************************/
  18. /** Function OnSelectOptionToolbar
  19. * called to validate current choices
  20. */
  21. {
  22. int id = event.GetId();
  23. switch ( id )
  24. {
  25. case ID_TB_OPTIONS_SHOW_GRID:
  26. m_Draw_Grid = g_ShowGrid = m_OptionsToolBar->GetToolState(id);
  27. DrawPanel->Refresh(TRUE);
  28. break;
  29. case ID_TB_OPTIONS_SELECT_UNIT_MM:
  30. g_UnitMetric = MILLIMETRE;
  31. Affiche_Status_Box();
  32. break;
  33. case ID_TB_OPTIONS_SELECT_UNIT_INCH:
  34. g_UnitMetric = INCHES;
  35. Affiche_Status_Box();
  36. break;
  37. case ID_TB_OPTIONS_SHOW_POLAR_COORD:
  38. Affiche_Message(wxEmptyString);
  39. DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState(id);
  40. Affiche_Status_Box();
  41. break;
  42. case ID_TB_OPTIONS_SELECT_CURSOR:
  43. g_CursorShape = m_OptionsToolBar->GetToolState(id);
  44. DrawPanel->Refresh(TRUE);
  45. break;
  46. case ID_TB_OPTIONS_SHOW_PADS_SKETCH:
  47. if ( m_OptionsToolBar->GetToolState(id) )
  48. {
  49. m_DisplayPadFill = FALSE;
  50. DisplayOpt.DisplayPadFill = FALSE;
  51. }
  52. else
  53. {
  54. m_DisplayPadFill = TRUE;
  55. DisplayOpt.DisplayPadFill = TRUE;
  56. }
  57. DrawPanel->Refresh(TRUE);
  58. break;
  59. case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
  60. if( m_OptionsToolBar->GetToolState(id) )
  61. {
  62. m_DisplayPcbTrackFill = FALSE;
  63. DisplayOpt.DisplayPcbTrackFill = FALSE;
  64. }
  65. else
  66. {
  67. m_DisplayPcbTrackFill = TRUE;
  68. DisplayOpt.DisplayPcbTrackFill = TRUE;
  69. }
  70. DrawPanel->Refresh(TRUE);
  71. break;
  72. case ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH:
  73. if ( m_OptionsToolBar->GetToolState(id) ) // Polygons filled asked
  74. g_DisplayPolygonsModeSketch = 1;
  75. else g_DisplayPolygonsModeSketch = 0;
  76. DrawPanel->Refresh(TRUE);
  77. break;
  78. case ID_TB_OPTIONS_SHOW_DCODES:
  79. DisplayOpt.DisplayPadNum = m_OptionsToolBar->GetToolState(id);
  80. DrawPanel->Refresh(TRUE);
  81. break;
  82. default:
  83. DisplayError(this, wxT("WinEDA_PcbFrame::OnSelectOptionToolbar error"));
  84. break;
  85. }
  86. SetToolbars();
  87. }
  88. /******************************************************/
  89. class WinEDA_GerberGeneralOptionsFrame: public wxDialog
  90. /******************************************************/
  91. {
  92. private:
  93. WinEDA_BasePcbFrame * m_Parent;
  94. wxRadioBox * m_PolarDisplay;
  95. wxRadioBox * m_BoxUnits;
  96. wxRadioBox * m_CursorShape;
  97. wxRadioBox * m_GerberDefaultScale;
  98. // Constructor and destructor
  99. public:
  100. WinEDA_GerberGeneralOptionsFrame(WinEDA_BasePcbFrame *parent,const wxPoint& pos);
  101. ~WinEDA_GerberGeneralOptionsFrame() {};
  102. private:
  103. void OnOkClick(wxCommandEvent& event);
  104. void OnCancelClick(wxCommandEvent & event);
  105. DECLARE_EVENT_TABLE()
  106. };
  107. /* Events table for WinEDA_GerberGeneralOptionsFrame */
  108. BEGIN_EVENT_TABLE(WinEDA_GerberGeneralOptionsFrame, wxDialog)
  109. EVT_BUTTON(wxID_OK, WinEDA_GerberGeneralOptionsFrame::OnOkClick)
  110. EVT_BUTTON(wxID_CANCEL, WinEDA_GerberGeneralOptionsFrame::OnCancelClick)
  111. END_EVENT_TABLE()
  112. /**********************************************************************************************/
  113. WinEDA_GerberGeneralOptionsFrame::WinEDA_GerberGeneralOptionsFrame(WinEDA_BasePcbFrame *parent,
  114. const wxPoint& framepos):
  115. wxDialog(parent, -1, _("Gerbview Options"),
  116. framepos, wxSize(300, 240),
  117. wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT )
  118. /**********************************************************************************************/
  119. /** WinEDA_GerberGeneralOptionsFrame Constructor
  120. */
  121. {
  122. m_Parent = parent;
  123. SetFont(*g_DialogFont);
  124. wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
  125. SetSizer(MainBoxSizer);
  126. wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL);
  127. wxBoxSizer * MiddleBoxSizer = new wxBoxSizer(wxVERTICAL);
  128. wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL);
  129. MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5);
  130. MainBoxSizer->Add(MiddleBoxSizer, 0, wxGROW|wxALL, 5);
  131. MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
  132. wxButton * Button = new wxButton(this, wxID_OK, _("OK"));
  133. Button->SetForegroundColour(*wxRED);
  134. RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5);
  135. Button = new wxButton(this, wxID_CANCEL, _("Cancel"));
  136. Button->SetForegroundColour(*wxBLUE);
  137. RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5);
  138. /* Display / not display polar coordinates: */
  139. wxString list_coord[2] =
  140. { _("No Display"),
  141. _("Display") };
  142. m_PolarDisplay = new wxRadioBox(this, -1, _("Display Polar Coord"),
  143. wxDefaultPosition, wxDefaultSize,
  144. 2, list_coord, 1);
  145. m_PolarDisplay->SetSelection(DisplayOpt.DisplayPolarCood ? 1 : 0);
  146. LeftBoxSizer->Add(m_PolarDisplay, 0, wxGROW|wxALL, 5);
  147. /* Selection of units */
  148. wxString list_units[2] = {
  149. _("Inches"),
  150. _("millimeters") };
  151. m_BoxUnits = new wxRadioBox(this, -1, _("Units"), wxDefaultPosition, wxDefaultSize,
  152. 2, list_units, 1);
  153. m_BoxUnits->SetSelection( g_UnitMetric ? 1 : 0);
  154. LeftBoxSizer->Add(m_BoxUnits, 0, wxGROW|wxALL, 5);
  155. /* Selection of cursor shape */
  156. wxString list_cursors[2] = { _("Small"), _("Big") };
  157. m_CursorShape = new wxRadioBox(this, -1, _("Cursor"), wxDefaultPosition, wxDefaultSize,
  158. 2, list_cursors, 1);
  159. m_CursorShape->SetSelection( g_CursorShape ? 1 : 0);
  160. MiddleBoxSizer->Add(m_CursorShape, 0, wxGROW|wxALL, 5);
  161. /* Selection Default Scale (i.e. format 2.3 ou 3.4) */
  162. wxString list_scales[2] = { _("format: 2.3"), _("format 3.4") };
  163. m_GerberDefaultScale = new wxRadioBox(this, -1, _("Default format"),
  164. wxDefaultPosition, wxDefaultSize,
  165. 2, list_scales, 1);
  166. m_GerberDefaultScale->SetSelection( (g_Default_GERBER_Format == 23) ? 0 : 1);
  167. MiddleBoxSizer->Add(m_GerberDefaultScale, 0, wxGROW|wxALL, 5);
  168. GetSizer()->Fit(this);
  169. GetSizer()->SetSizeHints(this);
  170. }
  171. /************************************************************************/
  172. void WinEDA_GerberGeneralOptionsFrame::OnCancelClick(wxCommandEvent& WXUNUSED(event))
  173. /************************************************************************/
  174. {
  175. EndModal( -1 );
  176. }
  177. /*****************************************************************************/
  178. void WinEDA_GerberGeneralOptionsFrame::OnOkClick(wxCommandEvent& event)
  179. /*****************************************************************************/
  180. {
  181. DisplayOpt.DisplayPolarCood =
  182. (m_PolarDisplay->GetSelection() == 0) ? FALSE : TRUE;
  183. g_UnitMetric = (m_BoxUnits->GetSelection() == 0) ? 0 : 1;
  184. g_CursorShape = m_CursorShape->GetSelection();
  185. g_Default_GERBER_Format =
  186. (m_GerberDefaultScale->GetSelection() == 0) ? 23 : 34;
  187. EndModal( 1 );
  188. }
  189. /*******************************************/
  190. /* Dialog frame to select deisplay options */
  191. /*******************************************/
  192. class WinEDA_LookFrame: public wxDialog
  193. {
  194. private:
  195. WinEDA_BasePcbFrame * m_Parent;
  196. wxRadioBox * m_OptDisplayLines;
  197. wxRadioBox * m_OptDisplayFlashes;
  198. wxRadioBox * m_OptDisplayPolygons;
  199. wxCheckBox * m_OptDisplayDCodes;
  200. wxRadioBox * m_OptDisplayDrawings;
  201. public:
  202. // Constructor and destructor
  203. WinEDA_LookFrame(WinEDA_BasePcbFrame *parent,const wxPoint& pos);
  204. ~WinEDA_LookFrame() {};
  205. private:
  206. void OnOkClick(wxCommandEvent& event);
  207. void OnCancelClick(wxCommandEvent & event);
  208. DECLARE_EVENT_TABLE()
  209. };
  210. /* Construction de la table des evenements pour WinEDA_LookFrame */
  211. BEGIN_EVENT_TABLE(WinEDA_LookFrame, wxDialog)
  212. EVT_BUTTON(wxID_OK, WinEDA_LookFrame::OnOkClick)
  213. EVT_BUTTON(wxID_CANCEL, WinEDA_LookFrame::OnCancelClick)
  214. END_EVENT_TABLE()
  215. /*******************************************************************************/
  216. WinEDA_LookFrame::WinEDA_LookFrame(WinEDA_BasePcbFrame *parent,
  217. const wxPoint& framepos):
  218. wxDialog(parent, -1, _("Gerbview Draw Options"), framepos, wxSize(350, 200),
  219. wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT )
  220. /*******************************************************************************/
  221. {
  222. m_Parent = parent;
  223. SetFont(*g_DialogFont);
  224. wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
  225. SetSizer(MainBoxSizer);
  226. wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL);
  227. wxBoxSizer * MiddleBoxSizer = new wxBoxSizer(wxVERTICAL);
  228. wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL);
  229. MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5);
  230. MainBoxSizer->Add(MiddleBoxSizer, 0, wxGROW|wxALL, 5);
  231. MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
  232. wxButton * Button = new wxButton(this, wxID_OK, _("OK"));
  233. Button->SetForegroundColour(*wxRED);
  234. RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5);
  235. Button = new wxButton(this, wxID_CANCEL, _("Cancel"));
  236. Button->SetForegroundColour(*wxBLUE);
  237. RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5);
  238. // Show Option Draw Tracks
  239. wxString list_opt2[2] = { _("Sketch"), _("Filled") };
  240. m_OptDisplayLines = new wxRadioBox(this, -1, _("Lines:"),
  241. wxDefaultPosition, wxDefaultSize,
  242. 2, list_opt2, 1);
  243. if ( DisplayOpt.DisplayPcbTrackFill )
  244. m_OptDisplayLines->SetSelection(1);
  245. LeftBoxSizer->Add(m_OptDisplayLines, 0, wxGROW|wxALL, 5);
  246. m_OptDisplayFlashes = new wxRadioBox(this, -1, _("Spots:"),
  247. wxDefaultPosition, wxDefaultSize,
  248. 2, list_opt2, 1);
  249. if ( DisplayOpt.DisplayPadFill )
  250. m_OptDisplayFlashes->SetSelection(1);
  251. LeftBoxSizer->Add(m_OptDisplayFlashes, 0, wxGROW|wxALL, 5);
  252. // Show Option Draw polygons
  253. m_OptDisplayPolygons = new wxRadioBox(this, -1, _("Polygons:"),
  254. wxDefaultPosition, wxDefaultSize,
  255. 2, list_opt2, 1);
  256. if ( g_DisplayPolygonsModeSketch == 0)
  257. m_OptDisplayPolygons->SetSelection(1);
  258. LeftBoxSizer->Add(m_OptDisplayPolygons, 0, wxGROW|wxALL, 5);
  259. wxString list_opt3[3] = { _("Sketch"), _("Filled"), _("Line") };
  260. m_OptDisplayDrawings = new wxRadioBox(this, -1, _("Display other items:"),
  261. wxDefaultPosition, wxDefaultSize,
  262. 3, list_opt3, 1);
  263. m_OptDisplayDrawings->SetSelection(DisplayOpt.DisplayDrawItems);
  264. MiddleBoxSizer->Add(m_OptDisplayDrawings, 0, wxGROW|wxALL, 5);
  265. m_OptDisplayDCodes = new wxCheckBox(this, -1, _("Show D codes"));
  266. if ( DisplayOpt.DisplayPadNum )
  267. m_OptDisplayDCodes->SetValue(TRUE);
  268. MiddleBoxSizer->Add(m_OptDisplayDCodes, 0, wxGROW|wxALL, 5);
  269. GetSizer()->Fit(this);
  270. GetSizer()->SetSizeHints(this);
  271. }
  272. /**************************************************************/
  273. void WinEDA_LookFrame::OnCancelClick(wxCommandEvent& WXUNUSED(event))
  274. /**************************************************************/
  275. {
  276. EndModal( -1 );
  277. }
  278. /*************************************************************/
  279. void WinEDA_LookFrame::OnOkClick(wxCommandEvent& event)
  280. /*************************************************************/
  281. /* Met a jour les options
  282. */
  283. {
  284. if ( m_OptDisplayLines->GetSelection() == 1 )
  285. DisplayOpt.DisplayPcbTrackFill = TRUE;
  286. else
  287. DisplayOpt.DisplayPcbTrackFill = FALSE;
  288. if ( m_OptDisplayFlashes->GetSelection() == 1 )
  289. DisplayOpt.DisplayPadFill = TRUE;
  290. else
  291. DisplayOpt.DisplayPadFill = FALSE;
  292. if ( m_OptDisplayPolygons->GetSelection() == 0 )
  293. g_DisplayPolygonsModeSketch = 1;
  294. else
  295. g_DisplayPolygonsModeSketch = 0;
  296. DisplayOpt.DisplayPadNum = m_OptDisplayDCodes->GetValue();
  297. DisplayOpt.DisplayDrawItems = m_OptDisplayDrawings->GetSelection();
  298. m_Parent->m_DisplayPadFill = DisplayOpt.DisplayPadFill;
  299. m_Parent->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
  300. m_Parent->GetScreen()->SetRefreshReq();
  301. EndModal( 1 );
  302. }
  303. /***************************************************************************/
  304. void WinEDA_GerberFrame::InstallPcbOptionsFrame(const wxPoint & pos, int id)
  305. /***************************************************************************/
  306. {
  307. switch ( id )
  308. {
  309. case ID_PCB_LOOK_SETUP:
  310. {
  311. WinEDA_LookFrame * OptionsFrame =
  312. new WinEDA_LookFrame(this, pos);
  313. OptionsFrame->ShowModal();
  314. OptionsFrame->Destroy();
  315. }
  316. break;
  317. case ID_OPTIONS_SETUP:
  318. {
  319. WinEDA_GerberGeneralOptionsFrame * OptionsFrame =
  320. new WinEDA_GerberGeneralOptionsFrame(this, pos);
  321. OptionsFrame->ShowModal();
  322. OptionsFrame->Destroy();
  323. }
  324. break;
  325. }
  326. }