2017-09-17 22:44:30 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
|
2023-02-10 09:04:52 +00:00
|
|
|
* Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-09-17 22:44:30 +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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-10-08 22:59:16 +00:00
|
|
|
#include <confirm.h>
|
2023-03-12 14:49:57 +00:00
|
|
|
#include <common.h>
|
2020-10-08 22:59:16 +00:00
|
|
|
#include <dialogs/dialog_layers_select_to_pcb.h>
|
|
|
|
#include <export_to_pcbnew.h>
|
2020-10-08 23:51:05 +00:00
|
|
|
#include <gerber_file_image.h>
|
2020-10-08 22:59:16 +00:00
|
|
|
#include <gerber_file_image_list.h>
|
2017-09-17 22:44:30 +00:00
|
|
|
#include <gerbview_painter.h>
|
|
|
|
#include <gerbview_frame.h>
|
2021-09-07 20:34:10 +00:00
|
|
|
#include <gerbview_settings.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2020-10-08 23:51:05 +00:00
|
|
|
#include <excellon_image.h>
|
2020-10-08 22:59:16 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2021-06-06 22:56:20 +00:00
|
|
|
#include <project.h>
|
2020-10-08 22:59:16 +00:00
|
|
|
#include <view/view.h>
|
|
|
|
#include <wildcards_and_files_ext.h>
|
2021-05-01 07:50:29 +00:00
|
|
|
#include <wx/filedlg.h>
|
2020-10-08 22:59:16 +00:00
|
|
|
|
2017-09-17 22:44:30 +00:00
|
|
|
#include "gerbview_actions.h"
|
|
|
|
#include "gerbview_control.h"
|
2019-04-28 19:04:28 +00:00
|
|
|
#include "gerbview_selection_tool.h"
|
2017-09-17 22:44:30 +00:00
|
|
|
|
2019-06-02 18:58:09 +00:00
|
|
|
|
2020-07-26 04:20:07 +00:00
|
|
|
GERBVIEW_CONTROL::GERBVIEW_CONTROL() : TOOL_INTERACTIVE( "gerbview.Control" ), m_frame( nullptr )
|
2017-09-17 22:44:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_CONTROL::Reset( RESET_REASON aReason )
|
|
|
|
{
|
|
|
|
m_frame = getEditFrame<GERBVIEW_FRAME>();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-16 18:42:46 +00:00
|
|
|
int GERBVIEW_CONTROL::OpenAutodetected( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->LoadAutodetectedFiles( wxEmptyString );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-03 22:02:07 +00:00
|
|
|
int GERBVIEW_CONTROL::OpenGerber( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->LoadGerberFiles( wxEmptyString );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_CONTROL::OpenDrillFile( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->LoadExcellonFiles( wxEmptyString );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_CONTROL::OpenJobFile( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->LoadGerberJobFile( wxEmptyString );
|
2020-10-08 23:51:05 +00:00
|
|
|
canvas()->Refresh();
|
2020-05-03 22:02:07 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_CONTROL::OpenZipFile( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->LoadZipArchiveFile( wxEmptyString );
|
2020-10-08 23:51:05 +00:00
|
|
|
canvas()->Refresh();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_CONTROL::ToggleLayerManager( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->ToggleLayerManager();
|
2020-05-03 22:02:07 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-08 22:59:16 +00:00
|
|
|
int GERBVIEW_CONTROL::ExportToPcbnew( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
int layercount = 0;
|
|
|
|
|
|
|
|
GERBER_FILE_IMAGE_LIST* images = m_frame->GetGerberLayout()->GetImagesList();
|
|
|
|
|
|
|
|
// Count the Gerber layers which are actually currently used
|
2021-07-21 23:14:56 +00:00
|
|
|
for( int ii = 0; ii < (int) images->ImagesMaxCount(); ++ii )
|
2020-10-08 22:59:16 +00:00
|
|
|
{
|
|
|
|
if( images->GetGbrImage( ii ) )
|
|
|
|
layercount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( layercount == 0 )
|
|
|
|
{
|
|
|
|
DisplayInfoMessage( m_frame, _( "None of the Gerber layers contain any data" ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-05-27 23:39:41 +00:00
|
|
|
wxString fileDialogName( NAMELESS_PROJECT + wxT( "." ) + KiCadPcbFileExtension );
|
2020-12-25 23:37:17 +00:00
|
|
|
wxString path = m_frame->GetMruPath();
|
2020-10-08 22:59:16 +00:00
|
|
|
|
2020-12-25 23:37:17 +00:00
|
|
|
wxFileDialog filedlg( m_frame, _( "Board File Name" ), path, fileDialogName, PcbFileWildcard(),
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
2020-10-08 22:59:16 +00:00
|
|
|
|
|
|
|
if( filedlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return 0;
|
|
|
|
|
2023-03-12 14:49:57 +00:00
|
|
|
wxFileName fileName = EnsureFileExtension( filedlg.GetPath(), KiCadPcbFileExtension );
|
2020-10-08 22:59:16 +00:00
|
|
|
|
|
|
|
/* Install a dialog frame to choose the mapping
|
|
|
|
* between gerber layers and Pcbnew layers
|
|
|
|
*/
|
|
|
|
LAYERS_MAP_DIALOG* layerdlg = new LAYERS_MAP_DIALOG( m_frame );
|
|
|
|
int ok = layerdlg->ShowModal();
|
|
|
|
layerdlg->Destroy();
|
|
|
|
|
|
|
|
if( ok != wxID_OK )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
m_frame->SetMruPath( fileName.GetPath() );
|
|
|
|
|
|
|
|
GBR_TO_PCB_EXPORTER gbr_exporter( m_frame, fileName.GetFullPath() );
|
|
|
|
|
|
|
|
gbr_exporter.ExportPcb( layerdlg->GetLayersLookUpTable(), layerdlg->GetCopperLayersCount() );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-17 22:44:30 +00:00
|
|
|
int GERBVIEW_CONTROL::HighlightControl( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( getView()->GetPainter() )->GetSettings();
|
|
|
|
const auto& selection = m_toolMgr->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection();
|
2019-06-09 21:57:23 +00:00
|
|
|
GERBER_DRAW_ITEM* item = nullptr;
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
if( selection.Size() == 1 )
|
|
|
|
{
|
|
|
|
item = static_cast<GERBER_DRAW_ITEM*>( selection[0] );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aEvent.IsAction( &GERBVIEW_ACTIONS::highlightClear ) )
|
|
|
|
{
|
|
|
|
m_frame->m_SelComponentBox->SetSelection( 0 );
|
|
|
|
m_frame->m_SelNetnameBox->SetSelection( 0 );
|
|
|
|
m_frame->m_SelAperAttributesBox->SetSelection( 0 );
|
|
|
|
|
2021-07-30 13:52:28 +00:00
|
|
|
settings->ClearHighlightSelections();
|
2021-03-13 17:45:33 +00:00
|
|
|
|
|
|
|
GERBER_FILE_IMAGE* gerber = m_frame->GetGbrImage( m_frame->GetActiveLayer() );
|
|
|
|
|
|
|
|
if( gerber )
|
|
|
|
gerber->m_Selected_Tool = settings->m_dcodeHighlightValue;
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
else if( item && aEvent.IsAction( &GERBVIEW_ACTIONS::highlightNet ) )
|
|
|
|
{
|
2021-03-13 17:45:33 +00:00
|
|
|
wxString net_name = item->GetNetAttributes().m_Netname;
|
|
|
|
settings->m_netHighlightString = net_name;
|
|
|
|
m_frame->m_SelNetnameBox->SetStringSelection( UnescapeString( net_name ) );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
else if( item && aEvent.IsAction( &GERBVIEW_ACTIONS::highlightComponent ) )
|
|
|
|
{
|
2021-03-13 17:45:33 +00:00
|
|
|
wxString net_attr = item->GetNetAttributes().m_Cmpref;
|
|
|
|
settings->m_componentHighlightString = net_attr;
|
|
|
|
m_frame->m_SelComponentBox->SetStringSelection( net_attr );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
else if( item && aEvent.IsAction( &GERBVIEW_ACTIONS::highlightAttribute ) )
|
|
|
|
{
|
|
|
|
D_CODE* apertDescr = item->GetDcodeDescr();
|
2020-12-25 23:37:17 +00:00
|
|
|
|
2017-09-17 22:44:30 +00:00
|
|
|
if( apertDescr )
|
|
|
|
{
|
2021-03-13 17:45:33 +00:00
|
|
|
wxString ap_name = apertDescr->m_AperFunction;
|
|
|
|
settings->m_attributeHighlightString = ap_name;
|
|
|
|
m_frame->m_SelAperAttributesBox->SetStringSelection( ap_name );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( item && aEvent.IsAction( &GERBVIEW_ACTIONS::highlightDCode ) )
|
|
|
|
{
|
|
|
|
D_CODE* apertDescr = item->GetDcodeDescr();
|
|
|
|
|
|
|
|
if( apertDescr )
|
|
|
|
{
|
|
|
|
int dcodeSelected = -1;
|
|
|
|
GERBER_FILE_IMAGE* gerber = m_frame->GetGbrImage( m_frame->GetActiveLayer() );
|
|
|
|
|
|
|
|
if( gerber )
|
|
|
|
dcodeSelected = apertDescr->m_Num_Dcode;
|
|
|
|
|
|
|
|
if( dcodeSelected > 0 )
|
|
|
|
{
|
|
|
|
settings->m_dcodeHighlightValue = dcodeSelected;
|
|
|
|
gerber->m_Selected_Tool = dcodeSelected;
|
|
|
|
m_frame->syncLayerBox( false );
|
|
|
|
}
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-08 23:51:05 +00:00
|
|
|
canvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
|
|
|
|
canvas()->Refresh();
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-04 21:59:12 +00:00
|
|
|
int GERBVIEW_CONTROL::DisplayControl( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
GERBVIEW_SETTINGS* cfg = m_frame->gvconfig();
|
|
|
|
KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
|
2018-03-04 21:59:12 +00:00
|
|
|
|
|
|
|
if( aEvent.IsAction( &GERBVIEW_ACTIONS::linesDisplayOutlines ) )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
cfg->m_Display.m_DisplayLinesFill = !cfg->m_Display.m_DisplayLinesFill;
|
|
|
|
|
|
|
|
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
|
|
|
[]( KIGFX::VIEW_ITEM* aItem )
|
|
|
|
{
|
|
|
|
GERBER_DRAW_ITEM* item = static_cast<GERBER_DRAW_ITEM*>( aItem );
|
|
|
|
|
2023-02-10 09:04:52 +00:00
|
|
|
switch( item->m_ShapeType )
|
2021-09-07 20:34:10 +00:00
|
|
|
{
|
|
|
|
case GBR_CIRCLE:
|
|
|
|
case GBR_ARC:
|
|
|
|
case GBR_SEGMENT:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} );
|
2018-03-04 21:59:12 +00:00
|
|
|
}
|
|
|
|
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::flashedDisplayOutlines ) )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
cfg->m_Display.m_DisplayFlashedItemsFill = !cfg->m_Display.m_DisplayFlashedItemsFill;
|
|
|
|
|
|
|
|
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
|
|
|
[]( KIGFX::VIEW_ITEM* aItem )
|
|
|
|
{
|
|
|
|
GERBER_DRAW_ITEM* item = static_cast<GERBER_DRAW_ITEM*>( aItem );
|
|
|
|
|
2023-02-10 09:04:52 +00:00
|
|
|
switch( item->m_ShapeType )
|
2021-09-07 20:34:10 +00:00
|
|
|
{
|
|
|
|
case GBR_SPOT_CIRCLE:
|
|
|
|
case GBR_SPOT_RECT:
|
|
|
|
case GBR_SPOT_OVAL:
|
|
|
|
case GBR_SPOT_POLY:
|
|
|
|
case GBR_SPOT_MACRO:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} );
|
2018-03-04 21:59:12 +00:00
|
|
|
}
|
|
|
|
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::polygonsDisplayOutlines ) )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
cfg->m_Display.m_DisplayPolygonsFill = !cfg->m_Display.m_DisplayPolygonsFill;
|
|
|
|
|
|
|
|
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
|
|
|
[]( KIGFX::VIEW_ITEM* aItem )
|
|
|
|
{
|
|
|
|
GERBER_DRAW_ITEM* item = static_cast<GERBER_DRAW_ITEM*>( aItem );
|
|
|
|
|
2023-02-10 09:04:52 +00:00
|
|
|
return ( item->m_ShapeType == GBR_POLYGON );
|
2021-09-07 20:34:10 +00:00
|
|
|
} );
|
2018-03-04 21:59:12 +00:00
|
|
|
}
|
|
|
|
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::negativeObjectDisplay ) )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
m_frame->SetElementVisibility( LAYER_NEGATIVE_OBJECTS, !cfg->m_Appearance.show_negative_objects );
|
2018-03-04 21:59:12 +00:00
|
|
|
}
|
|
|
|
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::dcodeDisplay ) )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
m_frame->SetElementVisibility( LAYER_DCODES, !cfg->m_Appearance.show_dcodes );
|
2018-03-04 21:59:12 +00:00
|
|
|
}
|
2022-07-25 19:43:11 +00:00
|
|
|
else if( aEvent.IsAction( &ACTIONS::highContrastMode )
|
|
|
|
|| aEvent.IsAction( &ACTIONS::highContrastModeCycle ) )
|
2019-06-02 18:58:09 +00:00
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
cfg->m_Display.m_HighContrastMode = !cfg->m_Display.m_HighContrastMode;
|
2019-06-02 18:58:09 +00:00
|
|
|
}
|
|
|
|
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::toggleDiffMode ) )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
cfg->m_Display.m_DiffMode = !cfg->m_Display.m_DiffMode;
|
2022-11-17 15:42:12 +00:00
|
|
|
|
|
|
|
if( cfg->m_Display.m_DiffMode && cfg->m_Display.m_XORMode )
|
|
|
|
cfg->m_Display.m_XORMode = false;
|
2022-12-19 15:58:40 +00:00
|
|
|
|
|
|
|
m_frame->UpdateXORLayers();
|
2022-11-17 15:42:12 +00:00
|
|
|
}
|
|
|
|
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::toggleXORMode ) )
|
|
|
|
{
|
|
|
|
cfg->m_Display.m_XORMode = !cfg->m_Display.m_XORMode;
|
|
|
|
|
|
|
|
if( cfg->m_Display.m_XORMode && cfg->m_Display.m_DiffMode )
|
|
|
|
cfg->m_Display.m_DiffMode = false;
|
|
|
|
|
|
|
|
m_frame->UpdateXORLayers();
|
2019-06-02 18:58:09 +00:00
|
|
|
}
|
2020-07-26 04:20:07 +00:00
|
|
|
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::flipGerberView ) )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
cfg->m_Display.m_FlipGerberView = !cfg->m_Display.m_FlipGerberView;
|
|
|
|
view->SetMirror( cfg->m_Display.m_FlipGerberView, false );
|
2020-07-26 04:20:07 +00:00
|
|
|
}
|
2018-03-04 21:59:12 +00:00
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
m_frame->ApplyDisplaySettingsToGAL();
|
|
|
|
|
|
|
|
view->UpdateAllItems( KIGFX::COLOR );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
2018-03-04 21:59:12 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_CONTROL::LayerNext( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
int layer = m_frame->GetActiveLayer();
|
|
|
|
|
2022-07-25 16:59:28 +00:00
|
|
|
if( layer < ( (int) GERBER_FILE_IMAGE_LIST::GetImagesList().GetLoadedImageCount() - 1 ) )
|
2018-03-04 21:59:12 +00:00
|
|
|
m_frame->SetActiveLayer( layer + 1, true );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
int layer = m_frame->GetActiveLayer();
|
|
|
|
|
|
|
|
if( layer > 0 )
|
|
|
|
m_frame->SetActiveLayer( layer - 1, true );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-25 14:02:17 +00:00
|
|
|
int GERBVIEW_CONTROL::MoveLayerUp( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
int layer = m_frame->GetActiveLayer();
|
|
|
|
|
|
|
|
if( layer > 0 )
|
|
|
|
{
|
|
|
|
m_frame->RemapLayers(
|
|
|
|
GERBER_FILE_IMAGE_LIST::GetImagesList().SwapImages( layer, layer - 1 ) );
|
|
|
|
m_frame->SetActiveLayer( layer - 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_CONTROL::MoveLayerDown( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
int layer = m_frame->GetActiveLayer();
|
|
|
|
GERBER_FILE_IMAGE_LIST& list = GERBER_FILE_IMAGE_LIST::GetImagesList();
|
|
|
|
|
|
|
|
if( layer < ( (int) list.GetLoadedImageCount() - 1 ) )
|
|
|
|
{
|
|
|
|
m_frame->RemapLayers( list.SwapImages( layer, layer + 1 ) );
|
|
|
|
m_frame->SetActiveLayer( layer + 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-08 23:51:05 +00:00
|
|
|
int GERBVIEW_CONTROL::ClearLayer( const TOOL_EVENT& aEvent )
|
2020-10-08 22:59:16 +00:00
|
|
|
{
|
|
|
|
m_frame->Erase_Current_DrawLayer( true );
|
|
|
|
m_frame->ClearMsgPanel();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-08 23:51:05 +00:00
|
|
|
int GERBVIEW_CONTROL::ClearAllLayers( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->Clear_DrawLayers( false );
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::zoomFitScreen );
|
2020-10-08 23:51:05 +00:00
|
|
|
canvas()->Refresh();
|
|
|
|
m_frame->ClearMsgPanel();
|
|
|
|
|
2021-07-30 13:52:28 +00:00
|
|
|
// Clear pending highlight selections, now outdated
|
|
|
|
KIGFX::GERBVIEW_RENDER_SETTINGS* settings =
|
|
|
|
static_cast<KIGFX::GERBVIEW_PAINTER*>( getView()->GetPainter() )->GetSettings();
|
|
|
|
settings->ClearHighlightSelections();
|
|
|
|
|
2020-10-08 23:51:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_CONTROL::ReloadAllLayers( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
// Store filenames
|
2020-12-25 23:37:17 +00:00
|
|
|
wxArrayString listOfGerberFiles;
|
|
|
|
std::vector<int> fileType;
|
2020-10-08 23:51:05 +00:00
|
|
|
GERBER_FILE_IMAGE_LIST* list = m_frame->GetImagesList();
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < list->ImagesMaxCount(); i++ )
|
|
|
|
{
|
|
|
|
if( list->GetGbrImage( i ) == nullptr )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( !list->GetGbrImage( i )->m_InUse )
|
|
|
|
continue;
|
|
|
|
|
2020-12-25 23:37:17 +00:00
|
|
|
EXCELLON_IMAGE* drill_file = dynamic_cast<EXCELLON_IMAGE*>( list->GetGbrImage( i ) );
|
2020-10-08 23:51:05 +00:00
|
|
|
|
|
|
|
if( drill_file )
|
|
|
|
fileType.push_back( 1 );
|
|
|
|
else
|
|
|
|
fileType.push_back( 0 );
|
|
|
|
|
|
|
|
listOfGerberFiles.Add( list->GetGbrImage( i )->m_FileName );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear all layers
|
2021-01-29 10:10:26 +00:00
|
|
|
m_frame->Clear_DrawLayers( false );
|
|
|
|
m_frame->ClearMsgPanel();
|
2020-10-08 23:51:05 +00:00
|
|
|
|
|
|
|
// Load the layers from stored paths
|
|
|
|
wxBusyCursor wait;
|
|
|
|
m_frame->LoadListOfGerberAndDrillFiles( wxEmptyString, listOfGerberFiles, &fileType );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
int GERBVIEW_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
GERBVIEW_SELECTION_TOOL* selTool = m_toolMgr->GetTool<GERBVIEW_SELECTION_TOOL>();
|
2019-06-08 21:48:22 +00:00
|
|
|
GERBVIEW_SELECTION& selection = selTool->GetSelection();
|
2019-05-28 23:23:58 +00:00
|
|
|
|
|
|
|
if( selection.GetSize() == 1 )
|
|
|
|
{
|
|
|
|
EDA_ITEM* item = (EDA_ITEM*) selection.Front();
|
|
|
|
|
2021-09-26 23:22:32 +00:00
|
|
|
std::vector<MSG_PANEL_ITEM> msgItems;
|
2020-04-24 13:36:10 +00:00
|
|
|
item->GetMsgPanelInfo( m_frame, msgItems );
|
2019-05-28 23:23:58 +00:00
|
|
|
m_frame->SetMsgPanel( msgItems );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_frame->EraseMsgBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-14 22:28:09 +00:00
|
|
|
int GERBVIEW_CONTROL::LoadZipfile( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->LoadZipArchiveFile( *aEvent.Parameter<wxString*>() );
|
|
|
|
canvas()->Refresh();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_CONTROL::LoadGerbFiles( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
// The event parameter is a string containing names of dropped files.
|
|
|
|
// Each file name has been enclosed with "", so file names with space character are allowed.
|
|
|
|
wxString files = *aEvent.Parameter<wxString*>();
|
|
|
|
// ie : files = "file1""another file""file3"...
|
|
|
|
|
|
|
|
std::vector<wxString> aFileNameList;
|
|
|
|
|
|
|
|
// Isolate each file name, deletting ""
|
|
|
|
files = files.AfterFirst( '"' );
|
|
|
|
|
|
|
|
// Gerber files are enclosed with "".
|
|
|
|
// Load files names in array.
|
|
|
|
while( !files.empty() )
|
|
|
|
{
|
|
|
|
wxString fileName = files.BeforeFirst( '"' );
|
|
|
|
// Check if file exists. If not, keep on and ignore fileName
|
|
|
|
if( wxFileName( fileName ).Exists() )
|
|
|
|
aFileNameList.push_back( fileName );
|
|
|
|
files = files.AfterFirst( '"' );
|
|
|
|
files = files.AfterFirst( '"' );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !aFileNameList.empty() )
|
|
|
|
m_frame->OpenProjectFiles( aFileNameList, KICTL_CREATE );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-17 22:44:30 +00:00
|
|
|
void GERBVIEW_CONTROL::setTransitions()
|
|
|
|
{
|
2021-08-16 18:42:46 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::OpenAutodetected, GERBVIEW_ACTIONS::openAutodetected.MakeEvent() );
|
2020-05-03 22:02:07 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::OpenGerber, GERBVIEW_ACTIONS::openGerber.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::OpenDrillFile, GERBVIEW_ACTIONS::openDrillFile.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::OpenJobFile, GERBVIEW_ACTIONS::openJobFile.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::OpenZipFile, GERBVIEW_ACTIONS::openZipFile.MakeEvent() );
|
2020-10-08 23:51:05 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::ToggleLayerManager, GERBVIEW_ACTIONS::toggleLayerManager.MakeEvent() );
|
2020-10-08 22:59:16 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::ExportToPcbnew, GERBVIEW_ACTIONS::exportToPcbnew.MakeEvent() );
|
2019-06-02 18:58:09 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::Print, ACTIONS::print.MakeEvent() );
|
|
|
|
|
2017-09-17 22:44:30 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightClear.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightNet.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightComponent.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightAttribute.MakeEvent() );
|
2021-03-13 17:45:33 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightDCode.MakeEvent() );
|
2018-03-04 21:59:12 +00:00
|
|
|
|
|
|
|
Go( &GERBVIEW_CONTROL::LayerNext, GERBVIEW_ACTIONS::layerNext.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::LayerPrev, GERBVIEW_ACTIONS::layerPrev.MakeEvent() );
|
2022-07-25 14:02:17 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::MoveLayerUp, GERBVIEW_ACTIONS::moveLayerUp.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::MoveLayerDown, GERBVIEW_ACTIONS::moveLayerDown.MakeEvent() );
|
2020-10-08 23:51:05 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::ClearLayer, GERBVIEW_ACTIONS::clearLayer.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::ClearAllLayers, GERBVIEW_ACTIONS::clearAllLayers.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::ReloadAllLayers, GERBVIEW_ACTIONS::reloadAllLayers.MakeEvent() );
|
2018-03-04 21:59:12 +00:00
|
|
|
|
|
|
|
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::linesDisplayOutlines.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::flashedDisplayOutlines.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::polygonsDisplayOutlines.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::negativeObjectDisplay.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::dcodeDisplay.MakeEvent() );
|
2019-06-02 18:58:09 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::DisplayControl, ACTIONS::highContrastMode.MakeEvent() );
|
2022-07-25 19:43:11 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::DisplayControl, ACTIONS::highContrastModeCycle.MakeEvent() );
|
2019-06-02 18:58:09 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::toggleDiffMode.MakeEvent() );
|
2022-11-17 15:42:12 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::toggleXORMode.MakeEvent() );
|
2020-07-26 04:20:07 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::DisplayControl, GERBVIEW_ACTIONS::flipGerberView.MakeEvent() );
|
2018-03-04 21:59:12 +00:00
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::UpdateMessagePanel, EVENTS::SelectedEvent );
|
|
|
|
Go( &GERBVIEW_CONTROL::UpdateMessagePanel, EVENTS::UnselectedEvent );
|
|
|
|
Go( &GERBVIEW_CONTROL::UpdateMessagePanel, EVENTS::ClearedEvent );
|
2021-08-16 20:15:13 +00:00
|
|
|
Go( &GERBVIEW_CONTROL::UpdateMessagePanel, ACTIONS::updateUnits.MakeEvent() );
|
2022-09-14 22:28:09 +00:00
|
|
|
|
|
|
|
Go( &GERBVIEW_CONTROL::LoadZipfile, GERBVIEW_ACTIONS::loadZipFile.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_CONTROL::LoadGerbFiles, GERBVIEW_ACTIONS::loadGerbFiles.MakeEvent() );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|