Gerbview: code cleanup (mainly remove g_GERBER_List global variable)
This commit is contained in:
parent
0862ac28d0
commit
a907e50424
|
@ -36,9 +36,9 @@
|
||||||
#include <class_gerber_file_image.h>
|
#include <class_gerber_file_image.h>
|
||||||
#include <class_gerber_file_image_list.h>
|
#include <class_gerber_file_image_list.h>
|
||||||
|
|
||||||
|
// Call back function used in block command
|
||||||
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
||||||
bool erase );
|
const wxPoint& aPosition, bool erase );
|
||||||
|
|
||||||
|
|
||||||
int GERBVIEW_FRAME::BlockCommand( EDA_KEY key )
|
int GERBVIEW_FRAME::BlockCommand( EDA_KEY key )
|
||||||
|
@ -82,7 +82,7 @@ void GERBVIEW_FRAME::HandleBlockPlace( wxDC* DC )
|
||||||
if( m_canvas->IsMouseCaptured() )
|
if( m_canvas->IsMouseCaptured() )
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
||||||
|
|
||||||
Block_Move( DC );
|
Block_Move();
|
||||||
GetScreen()->m_BlockLocate.ClearItemsList();
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -177,16 +177,14 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
|
||||||
|
|
||||||
if( screen->m_BlockLocate.GetMoveVector().x || screen->m_BlockLocate.GetMoveVector().y )
|
if( screen->m_BlockLocate.GetMoveVector().x || screen->m_BlockLocate.GetMoveVector().y )
|
||||||
{
|
{
|
||||||
screen->m_BlockLocate.Draw( aPanel,
|
screen->m_BlockLocate.Draw( aPanel, aDC,
|
||||||
aDC,
|
|
||||||
screen->m_BlockLocate.GetMoveVector(),
|
screen->m_BlockLocate.GetMoveVector(),
|
||||||
g_XorMode,
|
g_XorMode, Color );
|
||||||
Color );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GERBVIEW_FRAME::Block_Move( wxDC* DC )
|
void GERBVIEW_FRAME::Block_Move()
|
||||||
{
|
{
|
||||||
wxPoint delta;
|
wxPoint delta;
|
||||||
wxPoint oldpos;
|
wxPoint oldpos;
|
||||||
|
@ -201,10 +199,11 @@ void GERBVIEW_FRAME::Block_Move( wxDC* DC )
|
||||||
|
|
||||||
/* Calculate displacement vectors. */
|
/* Calculate displacement vectors. */
|
||||||
delta = GetScreen()->m_BlockLocate.GetMoveVector();
|
delta = GetScreen()->m_BlockLocate.GetMoveVector();
|
||||||
|
GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList();
|
||||||
|
|
||||||
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
|
||||||
{
|
{
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
|
||||||
|
|
||||||
if( gerber == NULL ) // Graphic layer not yet used
|
if( gerber == NULL ) // Graphic layer not yet used
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1992-2012 Jean-Pierre Charras <jean-pierre.charras@ujf-grenoble.fr>
|
* Copyright (C) 1992-2016 Jean-Pierre Charras <jp.charras at wanadoo.fr>
|
||||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
|
* Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -42,7 +42,9 @@ void GBR_LAYER_BOX_SELECTOR::Resync()
|
||||||
Freeze();
|
Freeze();
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
for( int layerid = 0; layerid < GERBER_DRAWLAYERS_COUNT; ++layerid )
|
GERBER_FILE_IMAGE_LIST& images = GERBER_FILE_IMAGE_LIST::GetImagesList();
|
||||||
|
|
||||||
|
for( unsigned layerid = 0; layerid < images.ImagesMaxCount(); ++layerid )
|
||||||
{
|
{
|
||||||
wxBitmap layerbmp( BM_SIZE, BM_SIZE );
|
wxBitmap layerbmp( BM_SIZE, BM_SIZE );
|
||||||
wxString layername;
|
wxString layername;
|
||||||
|
@ -79,7 +81,8 @@ EDA_COLOR_T GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayer ) const
|
||||||
// Returns the name of the layer id
|
// Returns the name of the layer id
|
||||||
wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( int aLayer ) const
|
wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( int aLayer ) const
|
||||||
{
|
{
|
||||||
wxString name = g_GERBER_List.GetDisplayName( aLayer );
|
GERBER_FILE_IMAGE_LIST& images = GERBER_FILE_IMAGE_LIST::GetImagesList();
|
||||||
|
wxString name = images.GetDisplayName( aLayer );
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,13 @@ GBR_LAYOUT::~GBR_LAYOUT()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Accessor to the list of gerber files (and drill files) images
|
||||||
|
GERBER_FILE_IMAGE_LIST* GBR_LAYOUT::GetImagesList()
|
||||||
|
{
|
||||||
|
return &GERBER_FILE_IMAGE_LIST::GetImagesList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GBR_LAYOUT::IsLayerPrintable( int aLayer ) const
|
bool GBR_LAYOUT::IsLayerPrintable( int aLayer ) const
|
||||||
{
|
{
|
||||||
for( unsigned ii = 0; ii < m_printLayersList.size(); ++ii )
|
for( unsigned ii = 0; ii < m_printLayersList.size(); ++ii )
|
||||||
|
@ -56,14 +63,15 @@ bool GBR_LAYOUT::IsLayerPrintable( int aLayer ) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EDA_RECT GBR_LAYOUT::ComputeBoundingBox()
|
EDA_RECT GBR_LAYOUT::ComputeBoundingBox()
|
||||||
{
|
{
|
||||||
EDA_RECT bbox;
|
EDA_RECT bbox;
|
||||||
bool first_item = true;
|
bool first_item = true;
|
||||||
|
|
||||||
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
|
||||||
{
|
{
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
|
||||||
|
|
||||||
if( gerber == NULL ) // Graphic layer not yet used
|
if( gerber == NULL ) // Graphic layer not yet used
|
||||||
continue;
|
continue;
|
||||||
|
@ -171,7 +179,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
||||||
layer = active_layer;
|
layer = active_layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
|
||||||
|
|
||||||
if( gerber == NULL ) // Graphic layer not yet used
|
if( gerber == NULL ) // Graphic layer not yet used
|
||||||
continue;
|
continue;
|
||||||
|
@ -335,9 +343,9 @@ void GBR_LAYOUT::DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
||||||
|
|
||||||
GRSetDrawMode( aDC, aDrawMode );
|
GRSetDrawMode( aDC, aDrawMode );
|
||||||
|
|
||||||
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
|
||||||
{
|
{
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
|
||||||
|
|
||||||
if( gerber == NULL ) // Graphic layer not yet used
|
if( gerber == NULL ) // Graphic layer not yet used
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -43,6 +43,8 @@
|
||||||
|
|
||||||
#include <gr_basic.h>
|
#include <gr_basic.h>
|
||||||
|
|
||||||
|
class GERBER_FILE_IMAGE_LIST;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GBR_LAYOUT
|
* Class GBR_LAYOUT
|
||||||
* holds list of GERBER_DRAW_ITEM currently loaded.
|
* holds list of GERBER_DRAW_ITEM currently loaded.
|
||||||
|
@ -60,6 +62,10 @@ public:
|
||||||
GBR_LAYOUT();
|
GBR_LAYOUT();
|
||||||
~GBR_LAYOUT();
|
~GBR_LAYOUT();
|
||||||
|
|
||||||
|
// Accessor to the GERBER_FILE_IMAGE_LIST,
|
||||||
|
// which handles the list of gerber files (and drill files) images loaded
|
||||||
|
GERBER_FILE_IMAGE_LIST* GetImagesList();
|
||||||
|
|
||||||
const wxPoint& GetAuxOrigin() const
|
const wxPoint& GetAuxOrigin() const
|
||||||
{
|
{
|
||||||
return m_originAxisPosition;
|
return m_originAxisPosition;
|
||||||
|
|
|
@ -38,6 +38,10 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
|
// The global image list:
|
||||||
|
GERBER_FILE_IMAGE_LIST s_GERBER_List;
|
||||||
|
|
||||||
|
|
||||||
// GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files
|
// GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files
|
||||||
GERBER_FILE_IMAGE_LIST::GERBER_FILE_IMAGE_LIST()
|
GERBER_FILE_IMAGE_LIST::GERBER_FILE_IMAGE_LIST()
|
||||||
{
|
{
|
||||||
|
@ -54,6 +58,12 @@ GERBER_FILE_IMAGE_LIST::~GERBER_FILE_IMAGE_LIST()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GERBER_FILE_IMAGE_LIST& GERBER_FILE_IMAGE_LIST::GetImagesList()
|
||||||
|
{
|
||||||
|
return s_GERBER_List;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GERBER_FILE_IMAGE* GERBER_FILE_IMAGE_LIST::GetGbrImage( int aIdx )
|
GERBER_FILE_IMAGE* GERBER_FILE_IMAGE_LIST::GetGbrImage( int aIdx )
|
||||||
{
|
{
|
||||||
if( (unsigned)aIdx < m_GERBER_List.size() )
|
if( (unsigned)aIdx < m_GERBER_List.size() )
|
||||||
|
@ -217,6 +227,3 @@ void GERBER_FILE_IMAGE_LIST::SortImagesByZOrder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// The global image list:
|
|
||||||
GERBER_FILE_IMAGE_LIST g_GERBER_List;
|
|
||||||
|
|
|
@ -69,8 +69,11 @@ public:
|
||||||
~GERBER_FILE_IMAGE_LIST();
|
~GERBER_FILE_IMAGE_LIST();
|
||||||
|
|
||||||
//Accessor
|
//Accessor
|
||||||
|
static GERBER_FILE_IMAGE_LIST& GetImagesList();
|
||||||
GERBER_FILE_IMAGE* GetGbrImage( int aIdx );
|
GERBER_FILE_IMAGE* GetGbrImage( int aIdx );
|
||||||
|
|
||||||
|
unsigned ImagesMaxCount() { return m_GERBER_List.size(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a GERBER_FILE_IMAGE* at index aIdx
|
* Add a GERBER_FILE_IMAGE* at index aIdx
|
||||||
* or at the first free location if aIdx < 0
|
* or at the first free location if aIdx < 0
|
||||||
|
@ -112,7 +115,4 @@ public:
|
||||||
void SortImagesByZOrder();
|
void SortImagesByZOrder();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern GERBER_FILE_IMAGE_LIST g_GERBER_List;
|
|
||||||
|
|
||||||
#endif // ifndef CLASS_GERBER_FILE_IMAGE_LIST_H
|
#endif // ifndef CLASS_GERBER_FILE_IMAGE_LIST_H
|
||||||
|
|
|
@ -77,11 +77,12 @@ GERBER_LAYER_WIDGET::GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFo
|
||||||
// using installRightLayerClickHandler
|
// using installRightLayerClickHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
GERBER_FILE_IMAGE_LIST* GERBER_LAYER_WIDGET::GetImagesList()
|
||||||
* Function SetLayersManagerTabsText
|
{
|
||||||
* Update the layer manager tabs labels
|
return &GERBER_FILE_IMAGE_LIST::GetImagesList();
|
||||||
* Useful when changing Language or to set labels to a non default value
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
void GERBER_LAYER_WIDGET::SetLayersManagerTabsText( )
|
void GERBER_LAYER_WIDGET::SetLayersManagerTabsText( )
|
||||||
{
|
{
|
||||||
m_notebook->SetPageText(0, _("Layer") );
|
m_notebook->SetPageText(0, _("Layer") );
|
||||||
|
@ -208,7 +209,7 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_SORT_GBR_LAYERS:
|
case ID_SORT_GBR_LAYERS:
|
||||||
g_GERBER_List.SortImagesByZOrder();
|
GetImagesList()->SortImagesByZOrder();
|
||||||
myframe->ReFillLayerWidget();
|
myframe->ReFillLayerWidget();
|
||||||
myframe->syncLayerBox( true );
|
myframe->syncLayerBox( true );
|
||||||
myframe->GetCanvas()->Refresh();
|
myframe->GetCanvas()->Refresh();
|
||||||
|
@ -238,7 +239,7 @@ void GERBER_LAYER_WIDGET::ReFill()
|
||||||
|
|
||||||
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
||||||
{
|
{
|
||||||
wxString msg = g_GERBER_List.GetDisplayName( layer );
|
wxString msg = GetImagesList()->GetDisplayName( layer );
|
||||||
|
|
||||||
AppendLayerRow( LAYER_WIDGET::ROW( msg, layer,
|
AppendLayerRow( LAYER_WIDGET::ROW( msg, layer,
|
||||||
myframe->GetLayerColor( layer ), wxEmptyString, true ) );
|
myframe->GetLayerColor( layer ), wxEmptyString, true ) );
|
||||||
|
@ -311,7 +312,7 @@ void GERBER_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
|
||||||
*/
|
*/
|
||||||
bool GERBER_LAYER_WIDGET::useAlternateBitmap(int aRow)
|
bool GERBER_LAYER_WIDGET::useAlternateBitmap(int aRow)
|
||||||
{
|
{
|
||||||
return g_GERBER_List.GetGbrImage( aRow ) != NULL;
|
return GetImagesList()->GetGbrImage( aRow ) != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -77,6 +77,8 @@ class GERBER_LAYER_WIDGET : public LAYER_WIDGET
|
||||||
*/
|
*/
|
||||||
virtual bool useAlternateBitmap(int aRow);
|
virtual bool useAlternateBitmap(int aRow);
|
||||||
|
|
||||||
|
GERBER_FILE_IMAGE_LIST* GetImagesList();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,6 +105,7 @@ public:
|
||||||
void OnLayerVisible( int aLayer, bool isVisible, bool isFinal );
|
void OnLayerVisible( int aLayer, bool isVisible, bool isFinal );
|
||||||
void OnRenderColorChange( int aId, EDA_COLOR_T aColor );
|
void OnRenderColorChange( int aId, EDA_COLOR_T aColor );
|
||||||
void OnRenderEnable( int aId, bool isEnabled );
|
void OnRenderEnable( int aId, bool isEnabled );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SetLayersManagerTabsText
|
* Function SetLayersManagerTabsText
|
||||||
* Update the layer manager tabs labels
|
* Update the layer manager tabs labels
|
||||||
|
|
|
@ -47,7 +47,7 @@ bool GERBVIEW_FRAME::Clear_DrawLayers( bool query )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_GERBER_List.DeleteAllImages();
|
GetGerberLayout()->GetImagesList()->DeleteAllImages();
|
||||||
|
|
||||||
GetGerberLayout()->SetBoundingBox( EDA_RECT() );
|
GetGerberLayout()->SetBoundingBox( EDA_RECT() );
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ void GERBVIEW_FRAME::Erase_Current_DrawLayer( bool query )
|
||||||
|
|
||||||
SetCurItem( NULL );
|
SetCurItem( NULL );
|
||||||
|
|
||||||
g_GERBER_List.DeleteImage( layer );
|
GetGerberLayout()->GetImagesList()->DeleteImage( layer );
|
||||||
|
|
||||||
m_LayersManager->UpdateLayerIcons();
|
m_LayersManager->UpdateLayerIcons();
|
||||||
syncLayerBox();
|
syncLayerBox();
|
||||||
|
|
|
@ -155,15 +155,16 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
|
||||||
}
|
}
|
||||||
|
|
||||||
s_Parameters.m_PageSetupData = s_pageSetupData;
|
s_Parameters.m_PageSetupData = s_pageSetupData;
|
||||||
|
GERBER_FILE_IMAGE_LIST* images = m_Parent->GetGerberLayout()->GetImagesList();
|
||||||
|
|
||||||
// Create layer list
|
// Create layer list
|
||||||
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
|
for( unsigned ii = 0; ii < images->ImagesMaxCount(); ++ii )
|
||||||
{
|
{
|
||||||
msg = _( "Layer" );
|
msg = _( "Layer" );
|
||||||
msg << wxT( " " ) << ii + 1;
|
msg << wxT( " " ) << ii + 1;
|
||||||
m_BoxSelectLayer[ii] = new wxCheckBox( this, -1, msg );
|
m_BoxSelectLayer[ii] = new wxCheckBox( this, -1, msg );
|
||||||
|
|
||||||
if( g_GERBER_List.GetGbrImage( ii ) == NULL ) // Nothing loaded on this draw layer
|
if( images->GetGbrImage( ii ) == NULL ) // Nothing loaded on this draw layer
|
||||||
m_BoxSelectLayer[ii]->Enable( false );
|
m_BoxSelectLayer[ii]->Enable( false );
|
||||||
|
|
||||||
if( ii < 16 )
|
if( ii < 16 )
|
||||||
|
|
|
@ -229,7 +229,7 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
|
|
||||||
void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
|
void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
GERBER_FILE_IMAGE* gerber_image = g_GERBER_List.GetGbrImage( getActiveLayer() );
|
GERBER_FILE_IMAGE* gerber_image = GetGbrImage( getActiveLayer() );
|
||||||
|
|
||||||
if( gerber_image )
|
if( gerber_image )
|
||||||
{
|
{
|
||||||
|
@ -261,7 +261,7 @@ void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
|
||||||
void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event )
|
void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
int layer = getActiveLayer();
|
int layer = getActiveLayer();
|
||||||
GERBER_FILE_IMAGE* gerber_layer = g_GERBER_List.GetGbrImage( layer );
|
GERBER_FILE_IMAGE* gerber_layer = GetGbrImage( layer );
|
||||||
|
|
||||||
if( gerber_layer )
|
if( gerber_layer )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,3 @@
|
||||||
/**
|
|
||||||
* @file excellon_read_drill_file.cpp
|
|
||||||
* Functions to read drill files (EXCELLON format) created by Pcbnew
|
|
||||||
* These files use only a subset of EXCELLON commands.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
|
@ -62,6 +55,13 @@
|
||||||
* Feed Rate and Spindle Speed are just skipped because they are not used in a viewer
|
* Feed Rate and Spindle Speed are just skipped because they are not used in a viewer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file excellon_read_drill_file.cpp
|
||||||
|
* Functions to read drill files (EXCELLON format) created by Pcbnew
|
||||||
|
* These files use only a subset of EXCELLON commands.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
|
@ -161,12 +161,13 @@ bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName )
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg;
|
||||||
int layerId = getActiveLayer(); // current layer used in GerbView
|
int layerId = getActiveLayer(); // current layer used in GerbView
|
||||||
EXCELLON_IMAGE* drill_Layer = (EXCELLON_IMAGE*) g_GERBER_List.GetGbrImage( layerId );
|
GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList();
|
||||||
|
EXCELLON_IMAGE* drill_Layer = (EXCELLON_IMAGE*) images->GetGbrImage( layerId );
|
||||||
|
|
||||||
if( drill_Layer == NULL )
|
if( drill_Layer == NULL )
|
||||||
{
|
{
|
||||||
drill_Layer = new EXCELLON_IMAGE( layerId );
|
drill_Layer = new EXCELLON_IMAGE( layerId );
|
||||||
layerId = g_GERBER_List.AddGbrImage( drill_Layer, layerId );
|
layerId = images->AddGbrImage( drill_Layer, layerId );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( layerId < 0 )
|
if( layerId < 0 )
|
||||||
|
|
|
@ -156,10 +156,11 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
int layercount = 0;
|
int layercount = 0;
|
||||||
|
|
||||||
|
GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList();
|
||||||
// Count the Gerber layers which are actually currently used
|
// Count the Gerber layers which are actually currently used
|
||||||
for( LAYER_NUM ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
|
for( LAYER_NUM ii = 0; ii < (LAYER_NUM)images->ImagesMaxCount(); ++ii )
|
||||||
{
|
{
|
||||||
if( g_GERBER_List.GetGbrImage( ii ) )
|
if( images->GetGbrImage( ii ) )
|
||||||
layercount++;
|
layercount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,10 +222,11 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* aLayerLookUpTable, int aCopperLa
|
||||||
// create an image of gerber data
|
// create an image of gerber data
|
||||||
// First: non copper layers:
|
// First: non copper layers:
|
||||||
const int pcbCopperLayerMax = 31;
|
const int pcbCopperLayerMax = 31;
|
||||||
|
GERBER_FILE_IMAGE_LIST* images = m_gerbview_frame->GetGerberLayout()->GetImagesList();
|
||||||
|
|
||||||
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
|
||||||
{
|
{
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
|
||||||
|
|
||||||
if( gerber == NULL ) // Graphic layer not yet used
|
if( gerber == NULL ) // Graphic layer not yet used
|
||||||
continue;
|
continue;
|
||||||
|
@ -244,9 +246,9 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* aLayerLookUpTable, int aCopperLa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copper layers
|
// Copper layers
|
||||||
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
|
||||||
{
|
{
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
|
||||||
|
|
||||||
if( gerber == NULL ) // Graphic layer not yet used
|
if( gerber == NULL ) // Graphic layer not yet used
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -369,16 +369,16 @@ int GERBVIEW_FRAME::getNextAvailableLayer( int aLayer ) const
|
||||||
{
|
{
|
||||||
int layer = aLayer;
|
int layer = aLayer;
|
||||||
|
|
||||||
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; ++i )
|
for( unsigned i = 0; i < ImagesMaxCount(); ++i )
|
||||||
{
|
{
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
|
||||||
|
|
||||||
if( gerber == NULL ) // this graphic layer is available: use it
|
if( gerber == NULL ) // this graphic layer is available: use it
|
||||||
return layer;
|
return layer;
|
||||||
|
|
||||||
++layer; // try next graphic layer
|
++layer; // try next graphic layer
|
||||||
|
|
||||||
if( layer >= GERBER_DRAWLAYERS_COUNT )
|
if( layer >= (int)ImagesMaxCount() )
|
||||||
layer = 0;
|
layer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,8 +400,8 @@ void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
|
||||||
|
|
||||||
m_SelLayerBox->SetSelection( getActiveLayer() );
|
m_SelLayerBox->SetSelection( getActiveLayer() );
|
||||||
|
|
||||||
int dcodeSelected = -1;
|
int dcodeSelected = -1;
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( getActiveLayer() );
|
GERBER_FILE_IMAGE* gerber = GetGbrImage( getActiveLayer() );
|
||||||
|
|
||||||
if( gerber )
|
if( gerber )
|
||||||
dcodeSelected = gerber->m_Selected_Tool;
|
dcodeSelected = gerber->m_Selected_Tool;
|
||||||
|
@ -422,13 +422,12 @@ void GERBVIEW_FRAME::Liste_D_Codes()
|
||||||
D_CODE* pt_D_code;
|
D_CODE* pt_D_code;
|
||||||
wxString Line;
|
wxString Line;
|
||||||
wxArrayString list;
|
wxArrayString list;
|
||||||
double scale = g_UserUnit == INCHES ? IU_PER_MILS * 1000 :
|
double scale = g_UserUnit == INCHES ? IU_PER_MILS * 1000 : IU_PER_MM;
|
||||||
IU_PER_MM;
|
|
||||||
int curr_layer = getActiveLayer();
|
int curr_layer = getActiveLayer();
|
||||||
|
|
||||||
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
for( int layer = 0; layer < (int)ImagesMaxCount(); ++layer )
|
||||||
{
|
{
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
|
||||||
|
|
||||||
if( gerber == NULL )
|
if( gerber == NULL )
|
||||||
continue;
|
continue;
|
||||||
|
@ -444,6 +443,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
|
||||||
list.Add( Line );
|
list.Add( Line );
|
||||||
|
|
||||||
const char* units = g_UserUnit == INCHES ? "\"" : "mm";
|
const char* units = g_UserUnit == INCHES ? "\"" : "mm";
|
||||||
|
|
||||||
for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
|
for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
|
||||||
{
|
{
|
||||||
pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE, false );
|
pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE, false );
|
||||||
|
@ -483,7 +483,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
|
||||||
|
|
||||||
void GERBVIEW_FRAME::UpdateTitleAndInfo()
|
void GERBVIEW_FRAME::UpdateTitleAndInfo()
|
||||||
{
|
{
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( getActiveLayer() );
|
GERBER_FILE_IMAGE* gerber = GetGbrImage( getActiveLayer() );
|
||||||
wxString text;
|
wxString text;
|
||||||
|
|
||||||
// Display the gerber filename
|
// Display the gerber filename
|
||||||
|
@ -848,3 +848,14 @@ const wxString GERBVIEW_FRAME::GetZoomLevelIndicator() const
|
||||||
{
|
{
|
||||||
return EDA_DRAW_FRAME::GetZoomLevelIndicator();
|
return EDA_DRAW_FRAME::GetZoomLevelIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GERBER_FILE_IMAGE* GERBVIEW_FRAME::GetGbrImage( int aIdx ) const
|
||||||
|
{
|
||||||
|
return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned GERBVIEW_FRAME::ImagesMaxCount() const
|
||||||
|
{
|
||||||
|
return m_gerberLayout->GetImagesList()->ImagesMaxCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,8 @@ class DCODE_SELECTION_BOX;
|
||||||
class GERBER_LAYER_WIDGET;
|
class GERBER_LAYER_WIDGET;
|
||||||
class GBR_LAYER_BOX_SELECTOR;
|
class GBR_LAYER_BOX_SELECTOR;
|
||||||
class GERBER_DRAW_ITEM;
|
class GERBER_DRAW_ITEM;
|
||||||
|
class GERBER_FILE_IMAGE;
|
||||||
|
class GERBER_FILE_IMAGE_LIST;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,6 +84,18 @@ public:
|
||||||
return m_gerberLayout;
|
return m_gerberLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data
|
||||||
|
*/
|
||||||
|
GERBER_FILE_IMAGE_LIST* GetImagesList() const
|
||||||
|
{
|
||||||
|
return m_gerberLayout->GetImagesList();
|
||||||
|
}
|
||||||
|
|
||||||
|
GERBER_FILE_IMAGE* GetGbrImage( int aIdx ) const;
|
||||||
|
|
||||||
|
unsigned ImagesMaxCount() const; ///< The max number of file images
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetGerberLayoutBoundingBox
|
* Function GetGerberLayoutBoundingBox
|
||||||
|
@ -165,7 +179,7 @@ private:
|
||||||
|
|
||||||
bool m_show_layer_manager_tools;
|
bool m_show_layer_manager_tools;
|
||||||
|
|
||||||
// An array sting to store warning messages when reaging a gerber file.
|
// An array sting to store warning messages when reading a gerber file.
|
||||||
wxArrayString m_Messages;
|
wxArrayString m_Messages;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -535,11 +549,8 @@ public:
|
||||||
* moves all tracks and segments within the selected block.
|
* moves all tracks and segments within the selected block.
|
||||||
* New location is determined by the current offset from the selected
|
* New location is determined by the current offset from the selected
|
||||||
* block's original location.
|
* block's original location.
|
||||||
* Defined separately in Pcbnew and GerbView
|
|
||||||
*
|
|
||||||
* @param DC A device context to draw on.
|
|
||||||
*/
|
*/
|
||||||
void Block_Move( wxDC* DC );
|
void Block_Move();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ToPrinter
|
* Function ToPrinter
|
||||||
|
|
|
@ -49,7 +49,8 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc
|
||||||
ref = GetNearestGridPosition( ref );
|
ref = GetNearestGridPosition( ref );
|
||||||
|
|
||||||
int layer = getActiveLayer();
|
int layer = getActiveLayer();
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList();
|
||||||
|
GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
|
||||||
|
|
||||||
// Search first on active layer
|
// Search first on active layer
|
||||||
GERBER_DRAW_ITEM* gerb_item = NULL;
|
GERBER_DRAW_ITEM* gerb_item = NULL;
|
||||||
|
@ -68,9 +69,9 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc
|
||||||
|
|
||||||
if( !found ) // Search on all layers
|
if( !found ) // Search on all layers
|
||||||
{
|
{
|
||||||
for( layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
for( layer = 0; layer < (int)images->ImagesMaxCount(); ++layer )
|
||||||
{
|
{
|
||||||
gerber = g_GERBER_List.GetGbrImage( layer );
|
gerber = images->GetGbrImage( layer );
|
||||||
|
|
||||||
if( gerber == NULL ) // Graphic layer not yet used
|
if( gerber == NULL ) // Graphic layer not yet used
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -42,7 +42,8 @@ void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
|
||||||
|
|
||||||
if( DrawStruct == NULL )
|
if( DrawStruct == NULL )
|
||||||
{
|
{
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( getActiveLayer() );
|
GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList();
|
||||||
|
GERBER_FILE_IMAGE* gerber = images->GetGbrImage( getActiveLayer() );
|
||||||
|
|
||||||
if( gerber )
|
if( gerber )
|
||||||
gerber->DisplayImageInfo( this );
|
gerber->DisplayImageInfo( this );
|
||||||
|
|
|
@ -41,12 +41,13 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName )
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
||||||
int layer = getActiveLayer();
|
int layer = getActiveLayer();
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList();
|
||||||
|
GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
|
||||||
|
|
||||||
if( gerber == NULL )
|
if( gerber == NULL )
|
||||||
{
|
{
|
||||||
gerber = new GERBER_FILE_IMAGE( layer );
|
gerber = new GERBER_FILE_IMAGE( layer );
|
||||||
g_GERBER_List.AddGbrImage( gerber, layer );
|
images->AddGbrImage( gerber, layer );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the gerber file */
|
/* Read the gerber file */
|
||||||
|
|
|
@ -120,9 +120,11 @@ void LAYERS_MAP_DIALOG::initDialog()
|
||||||
|
|
||||||
LAYER_NUM pcb_layer_num = 0;
|
LAYER_NUM pcb_layer_num = 0;
|
||||||
m_gerberActiveLayersCount = 0;
|
m_gerberActiveLayersCount = 0;
|
||||||
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
|
GERBER_FILE_IMAGE_LIST* images = m_Parent->GetGerberLayout()->GetImagesList();
|
||||||
|
|
||||||
|
for( unsigned ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
|
||||||
{
|
{
|
||||||
if( g_GERBER_List.GetGbrImage( ii ) == NULL )
|
if( images->GetGbrImage( ii ) == NULL )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if( (pcb_layer_num == m_exportBoardCopperLayersCount - 1)
|
if( (pcb_layer_num == m_exportBoardCopperLayersCount - 1)
|
||||||
|
@ -190,7 +192,7 @@ void LAYERS_MAP_DIALOG::initDialog()
|
||||||
wxRIGHT | wxLEFT, 5 );
|
wxRIGHT | wxLEFT, 5 );
|
||||||
|
|
||||||
/* Add file name and extension without path. */
|
/* Add file name and extension without path. */
|
||||||
wxFileName fn( g_GERBER_List.GetGbrImage( ii )->m_FileName );
|
wxFileName fn( images->GetGbrImage( ii )->m_FileName );
|
||||||
label = new wxStaticText( this, wxID_STATIC, fn.GetFullName(),
|
label = new wxStaticText( this, wxID_STATIC, fn.GetFullName(),
|
||||||
wxDefaultPosition, wxDefaultSize );
|
wxDefaultPosition, wxDefaultSize );
|
||||||
flexColumnBoxSizer->Add( label, 0,
|
flexColumnBoxSizer->Add( label, 0,
|
||||||
|
|
|
@ -307,7 +307,8 @@ void GERBVIEW_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent )
|
||||||
void GERBVIEW_FRAME::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent )
|
void GERBVIEW_FRAME::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent )
|
||||||
{
|
{
|
||||||
int layer = getActiveLayer();
|
int layer = getActiveLayer();
|
||||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList();
|
||||||
|
GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
|
||||||
int selected = ( gerber ) ? gerber->m_Selected_Tool : 0;
|
int selected = ( gerber ) ? gerber->m_Selected_Tool : 0;
|
||||||
|
|
||||||
if( m_DCodeSelector && m_DCodeSelector->GetSelectedDCodeId() != selected )
|
if( m_DCodeSelector && m_DCodeSelector->GetSelectedDCodeId() != selected )
|
||||||
|
|
Loading…
Reference in New Issue