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.

164 lines
5.7 KiB

Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2011-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include <gerbview.h>
  25. #include <gerbview_frame.h>
  26. #include <gerbview_id.h>
  27. #include <gerber_file_image.h>
  28. #include <gerber_file_image_list.h>
  29. #include <gal/graphics_abstraction_layer.h>
  30. #include <tool/tool_manager.h>
  31. #include <tool/selection.h>
  32. #include <tools/gerbview_selection_tool.h>
  33. #include <gerbview_painter.h>
  34. #include <view/view.h>
  35. #include "widgets/gerbview_layer_widget.h"
  36. #include "widgets/dcode_selection_box.h"
  37. // Event table:
  38. BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
  39. EVT_CLOSE( GERBVIEW_FRAME::OnCloseWindow )
  40. EVT_SIZE( GERBVIEW_FRAME::OnSize )
  41. // Menu Files:
  42. EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, GERBVIEW_FRAME::OnGbrFileHistory )
  43. EVT_MENU( ID_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearGbrFileHistory )
  44. EVT_MENU_RANGE( ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX,
  45. GERBVIEW_FRAME::OnDrlFileHistory )
  46. EVT_MENU( ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearDrlFileHistory )
  47. EVT_MENU_RANGE( ID_GERBVIEW_ZIP_FILE1, ID_GERBVIEW_ZIP_FILEMAX,
  48. GERBVIEW_FRAME::OnZipFileHistory )
  49. EVT_MENU( ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearZipFileHistory )
  50. EVT_MENU_RANGE( ID_GERBVIEW_JOB_FILE1, ID_GERBVIEW_JOB_FILEMAX,
  51. GERBVIEW_FRAME::OnJobFileHistory )
  52. EVT_MENU( ID_GERBVIEW_JOB_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearJobFileHistory )
  53. EVT_MENU( wxID_EXIT, GERBVIEW_FRAME::OnQuit )
  54. EVT_COMBOBOX( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnSelectActiveLayer )
  55. EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnSelectActiveDCode )
  56. // Auxiliary horizontal toolbar
  57. EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice )
  58. EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice )
  59. EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE,
  60. GERBVIEW_FRAME::OnSelectHighlightChoice )
  61. EVT_CHOICE( ID_ON_ZOOM_SELECT, GERBVIEW_FRAME::OnSelectZoom )
  62. EVT_CHOICE( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnSelectGrid )
  63. EVT_UPDATE_UI( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnUpdateSelectGrid )
  64. EVT_UPDATE_UI( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnUpdateSelectDCode )
  65. // Drop files event
  66. EVT_DROP_FILES( GERBVIEW_FRAME::OnDropFiles )
  67. END_EVENT_TABLE()
  68. void GERBVIEW_FRAME::OnSelectHighlightChoice( wxCommandEvent& event )
  69. {
  70. auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() )->GetSettings();
  71. switch( event.GetId() )
  72. {
  73. case ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE:
  74. settings->m_componentHighlightString = m_SelComponentBox->GetStringSelection();
  75. break;
  76. case ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE:
  77. settings->m_netHighlightString = m_SelNetnameBox->GetStringSelection();
  78. break;
  79. case ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE:
  80. settings->m_attributeHighlightString = m_SelAperAttributesBox->GetStringSelection();
  81. break;
  82. }
  83. GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
  84. GetCanvas()->Refresh();
  85. }
  86. void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
  87. {
  88. GERBER_FILE_IMAGE* gerber_image = GetGbrImage( GetActiveLayer() );
  89. if( gerber_image )
  90. {
  91. int d_code = m_DCodeSelector->GetSelectedDCodeId();
  92. auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>(
  93. GetCanvas()->GetView()->GetPainter() )->GetSettings();
  94. gerber_image->m_Selected_Tool = d_code;
  95. settings->m_dcodeHighlightValue = d_code;
  96. GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
  97. GetCanvas()->Refresh();
  98. }
  99. }
  100. void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
  101. {
  102. SetActiveLayer( event.GetSelection(), true );
  103. // Rebuild the DCode list in toolbar (but not the Layer Box) after change
  104. syncLayerBox( false );
  105. // Reinit highlighted dcode
  106. auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>
  107. ( GetCanvas()->GetView()->GetPainter() )->GetSettings();
  108. int dcodeSelected = m_DCodeSelector->GetSelectedDCodeId();
  109. settings->m_dcodeHighlightValue = dcodeSelected;
  110. GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
  111. GetCanvas()->Refresh();
  112. }
  113. void GERBVIEW_FRAME::OnQuit( wxCommandEvent& event )
  114. {
  115. Close( true );
  116. }
  117. void GERBVIEW_FRAME::ShowChangedLanguage()
  118. {
  119. // call my base class
  120. EDA_DRAW_FRAME::ShowChangedLanguage();
  121. m_LayersManager->SetLayersManagerTabsText();
  122. wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
  123. pane_info.Caption( _( "Layers Manager" ) );
  124. m_auimgr.Update();
  125. ReFillLayerWidget();
  126. }