Increase GervView layers to 51.

This also makes its use of LSET consistent with PCBNew.

Fixes: lp:1809019
* https://bugs.launchpad.net/kicad/+bug/1809019
This commit is contained in:
Jeff Young 2019-04-10 14:40:01 +01:00
parent 2144c6c97d
commit b7c12b238f
5 changed files with 39 additions and 106 deletions

View File

@ -1,7 +1,3 @@
/**
* @file gerbview/files.cpp
*/
/* /*
* 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.
* *
@ -50,6 +46,7 @@
_( "<b>No more available free graphic layer</b> in Gerbview to load files" ) _( "<b>No more available free graphic layer</b> in Gerbview to load files" )
#define MSG_NOT_LOADED _( "\n<b>Not loaded:</b> <i>%s</i>" ) #define MSG_NOT_LOADED _( "\n<b>Not loaded:</b> <i>%s</i>" )
void GERBVIEW_FRAME::OnGbrFileHistory( wxCommandEvent& event ) void GERBVIEW_FRAME::OnGbrFileHistory( wxCommandEvent& event )
{ {
wxString fn; wxString fn;
@ -93,13 +90,10 @@ void GERBVIEW_FRAME::OnZipFileHistory( wxCommandEvent& event )
void GERBVIEW_FRAME::OnJobFileHistory( wxCommandEvent& event ) void GERBVIEW_FRAME::OnJobFileHistory( wxCommandEvent& event )
{ {
wxString filename; wxString filename = GetFileFromHistory( event.GetId(), _( "Job files" ), &m_jobFileHistory );
filename = GetFileFromHistory( event.GetId(), _( "Job files" ), &m_jobFileHistory );
if( !filename.IsEmpty() ) if( !filename.IsEmpty() )
{
LoadGerberJobFile( filename ); LoadGerberJobFile( filename );
}
} }
@ -135,8 +129,7 @@ void GERBVIEW_FRAME::Files_io( wxCommandEvent& event )
if( !GetImagesList()->GetGbrImage( i )->m_InUse ) if( !GetImagesList()->GetGbrImage( i )->m_InUse )
continue; continue;
EXCELLON_IMAGE* drill_file = auto* drill_file = dynamic_cast<EXCELLON_IMAGE*>( GetImagesList()->GetGbrImage( i ) );
dynamic_cast<EXCELLON_IMAGE*>( GetImagesList()->GetGbrImage( i ) );
if( drill_file ) if( drill_file )
fileType.push_back( 1 ); fileType.push_back( 1 );
@ -273,7 +266,7 @@ bool GERBVIEW_FRAME::loadListOfGerberAndDrillFiles( const wxString& aPath,
// Read gerber files: each file is loaded on a new GerbView layer // Read gerber files: each file is loaded on a new GerbView layer
bool success = true; bool success = true;
int layer = GetActiveLayer(); int layer = GetActiveLayer();
int visibility = GetVisibleLayers(); LSET visibility = GetVisibleLayers();
// Manage errors when loading files // Manage errors when loading files
wxString msg; wxString msg;
@ -287,7 +280,6 @@ bool GERBVIEW_FRAME::loadListOfGerberAndDrillFiles( const wxString& aPath,
for( unsigned ii = 0; ii < aFilenameList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aFilenameList.GetCount(); ii++ )
{ {
filename = aFilenameList[ii]; filename = aFilenameList[ii];
if( !filename.IsAbsolute() ) if( !filename.IsAbsolute() )
@ -321,7 +313,7 @@ bool GERBVIEW_FRAME::loadListOfGerberAndDrillFiles( const wxString& aPath,
SetActiveLayer( layer, false ); SetActiveLayer( layer, false );
visibility |= ( 1 << layer ); visibility[ layer ] = true;
if( aFileType && (*aFileType)[ii] == 1 ) if( aFileType && (*aFileType)[ii] == 1 )
{ {
@ -346,9 +338,7 @@ bool GERBVIEW_FRAME::loadListOfGerberAndDrillFiles( const wxString& aPath,
while( ii < aFilenameList.GetCount() ) while( ii < aFilenameList.GetCount() )
{ {
filename = aFilenameList[ii++]; filename = aFilenameList[ii++];
wxString txt; wxString txt = wxString::Format( MSG_NOT_LOADED, filename.GetFullName() );
txt.Printf( MSG_NOT_LOADED,
GetChars( filename.GetFullName() ) );
reporter.Report( txt, REPORTER::RPT_ERROR ); reporter.Report( txt, REPORTER::RPT_ERROR );
} }
break; break;
@ -469,9 +459,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName )
while( ii < filenamesList.GetCount() ) while( ii < filenamesList.GetCount() )
{ {
filename = filenamesList[ii++]; filename = filenamesList[ii++];
wxString txt; wxString txt = wxString::Format( MSG_NOT_LOADED, filename.GetFullName() );
txt.Printf( MSG_NOT_LOADED,
GetChars( filename.GetFullName() ) );
reporter.Report( txt, REPORTER::RPT_ERROR ); reporter.Report( txt, REPORTER::RPT_ERROR );
} }
break; break;

View File

@ -2,7 +2,7 @@
* 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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@ -18,10 +18,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/**
* @file gerbview_frame.cpp
*/
#include <fctsys.h> #include <fctsys.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <pgm_base.h> #include <pgm_base.h>
@ -120,7 +116,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
SetLayout( new GBR_LAYOUT() ); SetLayout( new GBR_LAYOUT() );
SetVisibleLayers( -1 ); // All draw layers visible. SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) ); SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) );
@ -661,8 +657,8 @@ void GERBVIEW_FRAME::UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions )
if( update_flashed ) if( update_flashed )
{ {
view->UpdateAllItemsConditionally( KIGFX::REPAINT, view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
[]( KIGFX::VIEW_ITEM* aItem ) { {
auto item = static_cast<GERBER_DRAW_ITEM*>( aItem ); auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
switch( item->m_Shape ) switch( item->m_Shape )
@ -681,8 +677,8 @@ void GERBVIEW_FRAME::UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions )
} }
else if( update_lines ) else if( update_lines )
{ {
view->UpdateAllItemsConditionally( KIGFX::REPAINT, view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
[]( KIGFX::VIEW_ITEM* aItem ) { {
auto item = static_cast<GERBER_DRAW_ITEM*>( aItem ); auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
switch( item->m_Shape ) switch( item->m_Shape )
@ -699,8 +695,8 @@ void GERBVIEW_FRAME::UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions )
} }
else if( update_polygons ) else if( update_polygons )
{ {
view->UpdateAllItemsConditionally( KIGFX::REPAINT, view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
[]( KIGFX::VIEW_ITEM* aItem ) { {
auto item = static_cast<GERBER_DRAW_ITEM*>( aItem ); auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
return ( item->m_Shape == GBR_POLYGON ); return ( item->m_Shape == GBR_POLYGON );
@ -800,36 +796,27 @@ bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
} }
long GERBVIEW_FRAME::GetVisibleLayers() const LSET GERBVIEW_FRAME::GetVisibleLayers() const
{ {
long layerMask = 0; LSET visible = LSET::AllLayersMask();
if( auto canvas = GetGalCanvas() ) if( auto canvas = GetGalCanvas() )
{ {
// NOTE: This assumes max 32 drawlayers!
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ ) for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
{ visible[i] = canvas->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
if( canvas->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) ) }
layerMask |= ( 1 << i );
}
return layerMask; return visible;
}
else
{
return -1;
}
} }
void GERBVIEW_FRAME::SetVisibleLayers( long aLayerMask ) void GERBVIEW_FRAME::SetVisibleLayers( LSET aLayerMask )
{ {
if( auto canvas = GetGalCanvas() ) if( auto canvas = GetGalCanvas() )
{ {
// NOTE: This assumes max 32 drawlayers!
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ ) for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
{ {
bool v = ( aLayerMask & ( 1 << i ) ); bool v = aLayerMask[i];
int layer = GERBER_DRAW_LAYER( i ); int layer = GERBER_DRAW_LAYER( i );
canvas->GetView()->SetLayerVisible( layer, v ); canvas->GetView()->SetLayerVisible( layer, v );
canvas->GetView()->SetLayerVisible( GERBER_DCODE_LAYER( layer ), canvas->GetView()->SetLayerVisible( GERBER_DCODE_LAYER( layer ),
@ -1051,13 +1038,6 @@ void GERBVIEW_FRAME::SetGridColor( COLOR4D aColor )
} }
EDA_RECT GERBVIEW_FRAME::GetGerberLayoutBoundingBox()
{
GetGerberLayout()->ComputeBoundingBox();
return GetGerberLayout()->GetBoundingBox();
}
void GERBVIEW_FRAME::UpdateStatusBar() void GERBVIEW_FRAME::UpdateStatusBar()
{ {
EDA_DRAW_FRAME::UpdateStatusBar(); EDA_DRAW_FRAME::UpdateStatusBar();

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@ -19,10 +19,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/**
* @file gerbview_frame.h
*/
#ifndef WX_GERBER_STRUCT_H #ifndef WX_GERBER_STRUCT_H
#define WX_GERBER_STRUCT_H #define WX_GERBER_STRUCT_H
@ -99,13 +95,6 @@ public:
unsigned ImagesMaxCount() const; ///< The max number of file images unsigned ImagesMaxCount() const; ///< The max number of file images
/**
* Function GetGerberLayoutBoundingBox
* calculates the bounding box containing all gerber items.
* @return EDA_RECT - the items bounding box
*/
EDA_RECT GetGerberLayoutBoundingBox();
void SetPageSettings( const PAGE_INFO& aPageSettings ) override; void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
const PAGE_INFO& GetPageSettings() const override; const PAGE_INFO& GetPageSettings() const override;
const wxSize GetPageSizeIU() const override; const wxSize GetPageSizeIU() const override;
@ -114,10 +103,7 @@ public:
void SetAuxOrigin( const wxPoint& aPoint ) override; void SetAuxOrigin( const wxPoint& aPoint ) override;
const wxPoint& GetGridOrigin() const override { return m_grid_origin; } const wxPoint& GetGridOrigin() const override { return m_grid_origin; }
void SetGridOrigin( const wxPoint& aPoint ) override void SetGridOrigin( const wxPoint& aPoint ) override { m_grid_origin = aPoint; }
{
m_grid_origin = aPoint;
}
const TITLE_BLOCK& GetTitleBlock() const override; const TITLE_BLOCK& GetTitleBlock() const override;
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override; void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
@ -157,17 +143,11 @@ public:
protected: protected:
GERBER_LAYER_WIDGET* m_LayersManager; GERBER_LAYER_WIDGET* m_LayersManager;
// Auxiliary file history used to store zip files history.
FILE_HISTORY m_zipFileHistory; FILE_HISTORY m_zipFileHistory;
// Auxiliary file history used to store drill files history.
FILE_HISTORY m_drillFileHistory; FILE_HISTORY m_drillFileHistory;
// Auxiliary file history used to store job files history.
FILE_HISTORY m_jobFileHistory; FILE_HISTORY m_jobFileHistory;
/// The last filename chosen to be proposed to the user wxString m_lastFileName; // The last filename chosen to be proposed to the user
wxString m_lastFileName;
public: public:
wxChoice* m_SelComponentBox; // a choice box to display and highlight component graphic items wxChoice* m_SelComponentBox; // a choice box to display and highlight component graphic items
@ -310,18 +290,16 @@ public:
/** /**
* Function GetVisibleLayers * Function GetVisibleLayers
* is a proxy function that calls the correspondent function in m_BoardSettings * is a proxy function that calls the correspondent function in m_BoardSettings
* Returns a bit-mask of all the layers that are visible * @return LSET of the visible layers
* @return long - the visible layers in bit-mapped form.
*/ */
long GetVisibleLayers() const; LSET GetVisibleLayers() const;
/** /**
* Function SetVisibleLayers * Function SetVisibleLayers
* is a proxy function that calls the correspondent function in m_BoardSettings * is a proxy function that calls the correspondent function in m_BoardSettings
* changes the bit-mask of visible layers * @param aLayerMask = The new set of visible layers
* @param aLayerMask = The new bit-mask of visible layers
*/ */
void SetVisibleLayers( long aLayerMask ); void SetVisibleLayers( LSET aLayerMask );
/** /**
* Function IsLayerVisible * Function IsLayerVisible

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2004-2010 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2004-2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.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
@ -24,11 +24,6 @@
*/ */
/**
* @file class_gerbview_layer_widget.cpp
* @brief GerbView layers manager.
*/
#include <fctsys.h> #include <fctsys.h>
#include <common.h> #include <common.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
@ -172,7 +167,7 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
int rowCount; int rowCount;
int menuId = event.GetId(); int menuId = event.GetId();
bool visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false; bool visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false;
long visibleLayers = 0; LSET visibleLayers;
bool force_active_layer_visible; bool force_active_layer_visible;
switch( menuId ) switch( menuId )
@ -185,26 +180,21 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
m_alwaysShowActiveLayer = ( menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE ); m_alwaysShowActiveLayer = ( menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
force_active_layer_visible = ( menuId == ID_SHOW_NO_LAYERS_BUT_ACTIVE || force_active_layer_visible = ( menuId == ID_SHOW_NO_LAYERS_BUT_ACTIVE ||
menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE ); menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
// Update icons and check boxes // Update icons and check boxes
rowCount = GetLayerRowCount(); rowCount = GetLayerRowCount();
for( int row=0; row < rowCount; ++row )
for( int row = 0; row < rowCount; ++row )
{ {
wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB ); wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
int layer = getDecodedId( cb->GetId() ); int layer = getDecodedId( cb->GetId() );
bool loc_visible = visible; bool loc_visible = visible;
if( force_active_layer_visible && if( force_active_layer_visible && (layer == myframe->GetActiveLayer() ) )
(layer == myframe->GetActiveLayer() ) )
{
loc_visible = true; loc_visible = true;
}
cb->SetValue( loc_visible ); cb->SetValue( loc_visible );
visibleLayers[ row ] = loc_visible;
if( loc_visible )
visibleLayers |= 1 << row;
else
visibleLayers &= ~( 1 << row );
} }
myframe->SetVisibleLayers( visibleLayers ); myframe->SetVisibleLayers( visibleLayers );
@ -309,12 +299,9 @@ bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer )
void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
{ {
long visibleLayers = myframe->GetVisibleLayers(); LSET visibleLayers = myframe->GetVisibleLayers();
if( isVisible ) visibleLayers[ aLayer ] = isVisible;
visibleLayers |= 1 << aLayer ;
else
visibleLayers &= ~( 1 << aLayer );
myframe->SetVisibleLayers( visibleLayers ); myframe->SetVisibleLayers( visibleLayers );

View File

@ -277,7 +277,7 @@ inline SCH_LAYER_ID operator++( SCH_LAYER_ID& a )
} }
// number of draw layers in Gerbview // number of draw layers in Gerbview
#define GERBER_DRAWLAYERS_COUNT 32 #define GERBER_DRAWLAYERS_COUNT PCB_LAYER_ID_COUNT
/// GerbView draw layers /// GerbView draw layers
enum GERBVIEW_LAYER_ID: int enum GERBVIEW_LAYER_ID: int