From b7c12b238fe29e7cf2eefc56910fca4c1c211688 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 10 Apr 2019 14:40:01 +0100 Subject: [PATCH] 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 --- gerbview/files.cpp | 26 ++++-------- gerbview/gerbview_frame.cpp | 50 +++++++---------------- gerbview/gerbview_frame.h | 36 ++++------------ gerbview/gerbview_layer_widget.cpp | 31 ++++---------- include/layers_id_colors_and_visibility.h | 2 +- 5 files changed, 39 insertions(+), 106 deletions(-) diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 1c4675e0b9..7d185ab408 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -1,7 +1,3 @@ -/** - * @file gerbview/files.cpp - */ - /* * This program source code file is part of KiCad, a free EDA CAD application. * @@ -50,6 +46,7 @@ _( "No more available free graphic layer in Gerbview to load files" ) #define MSG_NOT_LOADED _( "\nNot loaded: %s" ) + void GERBVIEW_FRAME::OnGbrFileHistory( wxCommandEvent& event ) { wxString fn; @@ -93,13 +90,10 @@ void GERBVIEW_FRAME::OnZipFileHistory( wxCommandEvent& event ) void GERBVIEW_FRAME::OnJobFileHistory( wxCommandEvent& event ) { - wxString filename; - filename = GetFileFromHistory( event.GetId(), _( "Job files" ), &m_jobFileHistory ); + wxString filename = GetFileFromHistory( event.GetId(), _( "Job files" ), &m_jobFileHistory ); if( !filename.IsEmpty() ) - { LoadGerberJobFile( filename ); - } } @@ -135,8 +129,7 @@ void GERBVIEW_FRAME::Files_io( wxCommandEvent& event ) if( !GetImagesList()->GetGbrImage( i )->m_InUse ) continue; - EXCELLON_IMAGE* drill_file = - dynamic_cast( GetImagesList()->GetGbrImage( i ) ); + auto* drill_file = dynamic_cast( GetImagesList()->GetGbrImage( i ) ); if( drill_file ) 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 bool success = true; int layer = GetActiveLayer(); - int visibility = GetVisibleLayers(); + LSET visibility = GetVisibleLayers(); // Manage errors when loading files wxString msg; @@ -287,7 +280,6 @@ bool GERBVIEW_FRAME::loadListOfGerberAndDrillFiles( const wxString& aPath, for( unsigned ii = 0; ii < aFilenameList.GetCount(); ii++ ) { - filename = aFilenameList[ii]; if( !filename.IsAbsolute() ) @@ -321,7 +313,7 @@ bool GERBVIEW_FRAME::loadListOfGerberAndDrillFiles( const wxString& aPath, SetActiveLayer( layer, false ); - visibility |= ( 1 << layer ); + visibility[ layer ] = true; if( aFileType && (*aFileType)[ii] == 1 ) { @@ -346,9 +338,7 @@ bool GERBVIEW_FRAME::loadListOfGerberAndDrillFiles( const wxString& aPath, while( ii < aFilenameList.GetCount() ) { filename = aFilenameList[ii++]; - wxString txt; - txt.Printf( MSG_NOT_LOADED, - GetChars( filename.GetFullName() ) ); + wxString txt = wxString::Format( MSG_NOT_LOADED, filename.GetFullName() ); reporter.Report( txt, REPORTER::RPT_ERROR ); } break; @@ -469,9 +459,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) while( ii < filenamesList.GetCount() ) { filename = filenamesList[ii++]; - wxString txt; - txt.Printf( MSG_NOT_LOADED, - GetChars( filename.GetFullName() ) ); + wxString txt = wxString::Format( MSG_NOT_LOADED, filename.GetFullName() ); reporter.Report( txt, REPORTER::RPT_ERROR ); } break; diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 31280fcf0d..8f6cee4042 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -2,7 +2,7 @@ * 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) 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 * under the terms of the GNU General Public License as published by the @@ -18,10 +18,6 @@ * with this program. If not, see . */ -/** - * @file gerbview_frame.cpp - */ - #include #include #include @@ -120,7 +116,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): SetLayout( new GBR_LAYOUT() ); - SetVisibleLayers( -1 ); // All draw layers visible. + SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible. SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) ); @@ -661,8 +657,8 @@ void GERBVIEW_FRAME::UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions ) if( update_flashed ) { - view->UpdateAllItemsConditionally( KIGFX::REPAINT, - []( KIGFX::VIEW_ITEM* aItem ) { + view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem ) + { auto item = static_cast( aItem ); switch( item->m_Shape ) @@ -681,8 +677,8 @@ void GERBVIEW_FRAME::UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions ) } else if( update_lines ) { - view->UpdateAllItemsConditionally( KIGFX::REPAINT, - []( KIGFX::VIEW_ITEM* aItem ) { + view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem ) + { auto item = static_cast( aItem ); switch( item->m_Shape ) @@ -699,8 +695,8 @@ void GERBVIEW_FRAME::UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions ) } else if( update_polygons ) { - view->UpdateAllItemsConditionally( KIGFX::REPAINT, - []( KIGFX::VIEW_ITEM* aItem ) { + view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem ) + { auto item = static_cast( aItem ); 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() ) { - // NOTE: This assumes max 32 drawlayers! for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ ) - { - if( canvas->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) ) - layerMask |= ( 1 << i ); - } + visible[i] = canvas->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) ); + } - return layerMask; - } - else - { - return -1; - } + return visible; } -void GERBVIEW_FRAME::SetVisibleLayers( long aLayerMask ) +void GERBVIEW_FRAME::SetVisibleLayers( LSET aLayerMask ) { if( auto canvas = GetGalCanvas() ) { - // NOTE: This assumes max 32 drawlayers! for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ ) { - bool v = ( aLayerMask & ( 1 << i ) ); + bool v = aLayerMask[i]; int layer = GERBER_DRAW_LAYER( i ); canvas->GetView()->SetLayerVisible( layer, v ); 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() { EDA_DRAW_FRAME::UpdateStatusBar(); diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 0d0f172f1e..3c291ef29b 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -3,7 +3,7 @@ * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 Wayne Stambaugh - * 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 * under the terms of the GNU General Public License as published by the @@ -19,10 +19,6 @@ * with this program. If not, see . */ -/** - * @file gerbview_frame.h - */ - #ifndef WX_GERBER_STRUCT_H #define WX_GERBER_STRUCT_H @@ -99,13 +95,6 @@ public: 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; const PAGE_INFO& GetPageSettings() const override; const wxSize GetPageSizeIU() const override; @@ -114,10 +103,7 @@ public: void SetAuxOrigin( const wxPoint& aPoint ) override; const wxPoint& GetGridOrigin() const override { return m_grid_origin; } - void SetGridOrigin( const wxPoint& aPoint ) override - { - m_grid_origin = aPoint; - } + void SetGridOrigin( const wxPoint& aPoint ) override { m_grid_origin = aPoint; } const TITLE_BLOCK& GetTitleBlock() const override; void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override; @@ -157,17 +143,11 @@ public: protected: GERBER_LAYER_WIDGET* m_LayersManager; - // Auxiliary file history used to store zip files history. FILE_HISTORY m_zipFileHistory; - - // Auxiliary file history used to store drill files history. FILE_HISTORY m_drillFileHistory; - - // Auxiliary file history used to store job files history. FILE_HISTORY m_jobFileHistory; - /// The last filename chosen to be proposed to the user - wxString m_lastFileName; + wxString m_lastFileName; // The last filename chosen to be proposed to the user public: wxChoice* m_SelComponentBox; // a choice box to display and highlight component graphic items @@ -310,18 +290,16 @@ public: /** * Function GetVisibleLayers * is a proxy function that calls the correspondent function in m_BoardSettings - * Returns a bit-mask of all the layers that are visible - * @return long - the visible layers in bit-mapped form. + * @return LSET of the visible layers */ - long GetVisibleLayers() const; + LSET GetVisibleLayers() const; /** * Function SetVisibleLayers * is a proxy function that calls the correspondent function in m_BoardSettings - * changes the bit-mask of visible layers - * @param aLayerMask = The new bit-mask of visible layers + * @param aLayerMask = The new set of visible layers */ - void SetVisibleLayers( long aLayerMask ); + void SetVisibleLayers( LSET aLayerMask ); /** * Function IsLayerVisible diff --git a/gerbview/gerbview_layer_widget.cpp b/gerbview/gerbview_layer_widget.cpp index 2fda30193c..8188bba605 100644 --- a/gerbview/gerbview_layer_widget.cpp +++ b/gerbview/gerbview_layer_widget.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2004-2010 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck - * 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 * 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 #include #include @@ -172,7 +167,7 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) int rowCount; int menuId = event.GetId(); bool visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false; - long visibleLayers = 0; + LSET visibleLayers; bool force_active_layer_visible; switch( menuId ) @@ -185,26 +180,21 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) m_alwaysShowActiveLayer = ( menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE ); force_active_layer_visible = ( menuId == ID_SHOW_NO_LAYERS_BUT_ACTIVE || menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE ); + // Update icons and check boxes 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 ); int layer = getDecodedId( cb->GetId() ); bool loc_visible = visible; - if( force_active_layer_visible && - (layer == myframe->GetActiveLayer() ) ) - { + if( force_active_layer_visible && (layer == myframe->GetActiveLayer() ) ) loc_visible = true; - } cb->SetValue( loc_visible ); - - if( loc_visible ) - visibleLayers |= 1 << row; - else - visibleLayers &= ~( 1 << row ); + visibleLayers[ row ] = loc_visible; } 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 ) { - long visibleLayers = myframe->GetVisibleLayers(); + LSET visibleLayers = myframe->GetVisibleLayers(); - if( isVisible ) - visibleLayers |= 1 << aLayer ; - else - visibleLayers &= ~( 1 << aLayer ); + visibleLayers[ aLayer ] = isVisible; myframe->SetVisibleLayers( visibleLayers ); diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index d6e1f79ceb..0467c9a086 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -277,7 +277,7 @@ inline SCH_LAYER_ID operator++( SCH_LAYER_ID& a ) } // number of draw layers in Gerbview -#define GERBER_DRAWLAYERS_COUNT 32 +#define GERBER_DRAWLAYERS_COUNT PCB_LAYER_ID_COUNT /// GerbView draw layers enum GERBVIEW_LAYER_ID: int