2014-10-21 18:36:45 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
|
2022-02-17 17:17:53 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-10-21 18:36:45 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview.h>
|
2014-06-27 17:07:42 +00:00
|
|
|
#include <gerbview_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview_id.h>
|
2018-01-29 12:26:58 +00:00
|
|
|
#include <gerber_file_image.h>
|
|
|
|
#include <gerber_file_image_list.h>
|
2018-03-13 21:59:46 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2017-09-17 22:43:20 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2019-05-28 23:23:58 +00:00
|
|
|
#include <tool/selection.h>
|
|
|
|
#include <tools/gerbview_selection_tool.h>
|
2017-09-17 22:43:20 +00:00
|
|
|
#include <gerbview_painter.h>
|
|
|
|
#include <view/view.h>
|
2020-11-16 12:13:08 +00:00
|
|
|
#include "widgets/gerbview_layer_widget.h"
|
|
|
|
#include "widgets/dcode_selection_box.h"
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
// Event table:
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
|
2011-09-23 20:00:30 +00:00
|
|
|
EVT_CLOSE( GERBVIEW_FRAME::OnCloseWindow )
|
|
|
|
EVT_SIZE( GERBVIEW_FRAME::OnSize )
|
|
|
|
|
|
|
|
// Menu Files:
|
2018-08-20 13:46:38 +00:00
|
|
|
EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, GERBVIEW_FRAME::OnGbrFileHistory )
|
2020-02-25 15:46:56 +00:00
|
|
|
EVT_MENU( ID_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearGbrFileHistory )
|
2017-01-26 09:45:28 +00:00
|
|
|
|
2018-08-20 13:46:38 +00:00
|
|
|
EVT_MENU_RANGE( ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX,
|
2011-09-23 20:00:30 +00:00
|
|
|
GERBVIEW_FRAME::OnDrlFileHistory )
|
2020-02-25 15:46:56 +00:00
|
|
|
EVT_MENU( ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearDrlFileHistory )
|
2011-09-23 20:00:30 +00:00
|
|
|
|
2018-08-20 13:46:38 +00:00
|
|
|
EVT_MENU_RANGE( ID_GERBVIEW_ZIP_FILE1, ID_GERBVIEW_ZIP_FILEMAX,
|
2017-01-26 09:45:28 +00:00
|
|
|
GERBVIEW_FRAME::OnZipFileHistory )
|
2020-02-25 15:46:56 +00:00
|
|
|
EVT_MENU( ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearZipFileHistory )
|
2017-01-26 09:45:28 +00:00
|
|
|
|
2018-08-20 13:46:38 +00:00
|
|
|
EVT_MENU_RANGE( ID_GERBVIEW_JOB_FILE1, ID_GERBVIEW_JOB_FILEMAX,
|
2017-08-19 16:28:11 +00:00
|
|
|
GERBVIEW_FRAME::OnJobFileHistory )
|
2020-02-25 15:46:56 +00:00
|
|
|
EVT_MENU( ID_GERBVIEW_JOB_FILE_LIST_CLEAR, GERBVIEW_FRAME::OnClearJobFileHistory )
|
2017-08-19 16:28:11 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
EVT_MENU( wxID_EXIT, GERBVIEW_FRAME::OnQuit )
|
|
|
|
|
2019-05-15 22:49:48 +00:00
|
|
|
EVT_COMBOBOX( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, GERBVIEW_FRAME::OnSelectActiveLayer )
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnSelectActiveDCode )
|
|
|
|
|
|
|
|
// Option toolbar
|
|
|
|
EVT_TOOL_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2,
|
|
|
|
GERBVIEW_FRAME::OnSelectDisplayMode )
|
|
|
|
|
2016-08-16 10:56:20 +00:00
|
|
|
// Auxiliary horizontal toolbar
|
2019-01-28 14:15:32 +00:00
|
|
|
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice )
|
|
|
|
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice )
|
|
|
|
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE,
|
2018-03-13 21:59:46 +00:00
|
|
|
GERBVIEW_FRAME::OnSelectHighlightChoice )
|
2019-01-28 14:15:32 +00:00
|
|
|
EVT_CHOICE( ID_ON_ZOOM_SELECT, GERBVIEW_FRAME::OnSelectZoom )
|
|
|
|
EVT_CHOICE( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnSelectGrid )
|
2022-02-17 17:17:53 +00:00
|
|
|
EVT_MENU( ID_GRID_SETTINGS, GERBVIEW_FRAME::OnGridSettings )
|
2016-08-16 10:56:20 +00:00
|
|
|
|
2018-07-11 12:56:05 +00:00
|
|
|
EVT_UPDATE_UI( ID_ON_GRID_SELECT, GERBVIEW_FRAME::OnUpdateSelectGrid )
|
2011-09-23 20:00:30 +00:00
|
|
|
EVT_UPDATE_UI( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnUpdateSelectDCode )
|
|
|
|
EVT_UPDATE_UI( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER,
|
|
|
|
GERBVIEW_FRAME::OnUpdateLayerSelectBox )
|
|
|
|
EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2,
|
|
|
|
GERBVIEW_FRAME::OnUpdateDrawMode )
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
void GERBVIEW_FRAME::OnSelectHighlightChoice( wxCommandEvent& event )
|
|
|
|
{
|
2019-06-13 17:28:55 +00:00
|
|
|
auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() )->GetSettings();
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
switch( event.GetId() )
|
|
|
|
{
|
|
|
|
case ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE:
|
|
|
|
settings->m_componentHighlightString = m_SelComponentBox->GetStringSelection();
|
|
|
|
break;
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
case ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE:
|
|
|
|
settings->m_netHighlightString = m_SelNetnameBox->GetStringSelection();
|
|
|
|
break;
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
case ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE:
|
|
|
|
settings->m_attributeHighlightString = m_SelAperAttributesBox->GetStringSelection();
|
|
|
|
break;
|
2017-09-17 22:43:20 +00:00
|
|
|
|
|
|
|
}
|
2019-05-27 16:16:54 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
|
|
|
|
GetCanvas()->Refresh();
|
2017-09-17 22:43:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
|
|
|
|
{
|
2017-09-17 22:43:20 +00:00
|
|
|
GERBER_FILE_IMAGE* gerber_image = GetGbrImage( GetActiveLayer() );
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
if( gerber_image )
|
|
|
|
{
|
2021-03-13 17:45:33 +00:00
|
|
|
int d_code = m_DCodeSelector->GetSelectedDCodeId();
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2021-03-13 17:45:33 +00:00
|
|
|
auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>(
|
|
|
|
GetCanvas()->GetView()->GetPainter() )->GetSettings();
|
|
|
|
gerber_image->m_Selected_Tool = d_code;
|
|
|
|
settings->m_dcodeHighlightValue = d_code;
|
|
|
|
|
|
|
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
|
|
|
|
GetCanvas()->Refresh();
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
2014-05-03 17:40:19 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
|
|
|
|
{
|
2018-03-04 04:43:16 +00:00
|
|
|
SetActiveLayer( event.GetSelection(), true );
|
2019-05-15 14:11:04 +00:00
|
|
|
|
|
|
|
// Rebuild the DCode list in toolbar (but not the Layer Box) after change
|
|
|
|
syncLayerBox( false );
|
2021-03-13 17:45:33 +00:00
|
|
|
|
|
|
|
// Reinit highlighted dcode
|
|
|
|
auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>
|
|
|
|
( GetCanvas()->GetView()->GetPainter() )->GetSettings();
|
|
|
|
int dcodeSelected = m_DCodeSelector->GetSelectedDCodeId();
|
|
|
|
settings->m_dcodeHighlightValue = dcodeSelected;
|
|
|
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
|
|
|
|
GetCanvas()->Refresh();
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
switch( event.GetId() )
|
|
|
|
{
|
2019-05-30 12:25:08 +00:00
|
|
|
case ID_TB_OPTIONS_SHOW_GBR_MODE_0: SetDisplayMode( 0 ); break;
|
|
|
|
case ID_TB_OPTIONS_SHOW_GBR_MODE_1: SetDisplayMode( 1 ); break;
|
|
|
|
case ID_TB_OPTIONS_SHOW_GBR_MODE_2: SetDisplayMode( 2 ); break;
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->Refresh();
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
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.
2014-05-03 17:40:19 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
void GERBVIEW_FRAME::OnQuit( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
Close( true );
|
|
|
|
}
|
|
|
|
|
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.
2014-05-03 17:40:19 +00:00
|
|
|
|
|
|
|
void GERBVIEW_FRAME::ShowChangedLanguage()
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
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.
2014-05-03 17:40:19 +00:00
|
|
|
// call my base class
|
|
|
|
EDA_DRAW_FRAME::ShowChangedLanguage();
|
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
m_LayersManager->SetLayersManagerTabsText();
|
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.
2014-05-03 17:40:19 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
|
2021-06-10 01:24:15 +00:00
|
|
|
pane_info.Caption( _( "Layers Manager" ) );
|
2011-09-23 20:00:30 +00:00
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
ReFillLayerWidget();
|
|
|
|
}
|