From 013296cb1a89daf2dc4d53c6d09595eeef21a1db Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 27 Jun 2014 19:07:42 +0200 Subject: [PATCH] Make gerbview compilable and working (does not use now layers and layer masks from Pcbnew). Export to Pcbnew is broken, but it is a very rarely used feature. It will be fixed later. --- common/copy_to_clipboard.cpp | 3 +- gerbview/block.cpp | 1 + gerbview/class_DCodeSelectionbox.cpp | 1 + gerbview/class_GERBER.cpp | 1 + gerbview/class_excellon.h | 2 +- gerbview/class_gbr_layer_box_selector.cpp | 8 +- gerbview/class_gbr_layer_box_selector.h | 7 +- gerbview/class_gbr_layout.cpp | 12 +- gerbview/class_gbr_layout.h | 36 ++-- gerbview/class_gerber_draw_item.cpp | 3 +- gerbview/class_gerber_draw_item.h | 11 +- gerbview/class_gerbview_layer_widget.cpp | 29 ++-- gerbview/controle.cpp | 1 + gerbview/dcode.cpp | 1 + .../dialogs/dialog_print_using_printer.cpp | 158 ++++++++---------- .../dialogs/dialog_select_one_pcb_layer.cpp | 59 ++++--- gerbview/dialogs/dialog_show_page_borders.cpp | 1 + .../gerbview_dialog_display_options_frame.cpp | 1 + gerbview/draw_gerber_screen.cpp | 17 +- gerbview/events_called_functions.cpp | 5 +- gerbview/excellon_read_drill_file.cpp | 7 +- gerbview/export_to_pcbnew.cpp | 19 +-- gerbview/files.cpp | 5 +- gerbview/gerbview.cpp | 1 + gerbview/gerbview.h | 17 +- gerbview/gerbview_config.cpp | 3 +- gerbview/gerbview_frame.cpp | 43 ++--- gerbview/gerbview_frame.h | 21 ++- gerbview/hotkeys.cpp | 1 + gerbview/initpcb.cpp | 9 +- gerbview/locate.cpp | 3 +- gerbview/menubar.cpp | 1 + gerbview/onleftclick.cpp | 1 + gerbview/onrightclick.cpp | 1 + gerbview/pcbplot.cpp | 1 + gerbview/readgerb.cpp | 3 +- gerbview/rs274d.cpp | 12 +- gerbview/rs274x.cpp | 1 + gerbview/select_layers_to_pcb.cpp | 48 +++--- gerbview/select_layers_to_pcb.h | 11 +- gerbview/toolbars_gerber.cpp | 3 +- pcbnew/class_board.cpp | 1 + pcbnew/printout_controler.cpp | 8 +- 43 files changed, 284 insertions(+), 293 deletions(-) diff --git a/common/copy_to_clipboard.cpp b/common/copy_to_clipboard.cpp index 5e710d81a7..fef6bb90cc 100644 --- a/common/copy_to_clipboard.cpp +++ b/common/copy_to_clipboard.cpp @@ -109,7 +109,8 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame ) dc.SetClippingRegion( DrawArea ); } - aFrame->PrintPage( &dc, FULL_LAYERS, false ); + const LSET allLayersMask = LSET().set(); + aFrame->PrintPage( &dc, allLayersMask, false ); screen->m_IsPrinting = false; aFrame->GetCanvas()->SetClipBox( tmp ); wxMetafile* mf = dc.Close(); diff --git a/gerbview/block.cpp b/gerbview/block.cpp index 912113538a..1218322b54 100644 --- a/gerbview/block.cpp +++ b/gerbview/block.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include diff --git a/gerbview/class_DCodeSelectionbox.cpp b/gerbview/class_DCodeSelectionbox.cpp index 84cf9cdc54..fc98ae6b55 100644 --- a/gerbview/class_DCodeSelectionbox.cpp +++ b/gerbview/class_DCodeSelectionbox.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include diff --git a/gerbview/class_GERBER.cpp b/gerbview/class_GERBER.cpp index 5ae04d5083..eeb10ff0e8 100644 --- a/gerbview/class_GERBER.cpp +++ b/gerbview/class_GERBER.cpp @@ -34,6 +34,7 @@ #include #include +#include #include diff --git a/gerbview/class_excellon.h b/gerbview/class_excellon.h index 07d2800b0d..555d2a310e 100644 --- a/gerbview/class_excellon.h +++ b/gerbview/class_excellon.h @@ -76,7 +76,7 @@ private: excellon_state m_State; // state of excellon file analysis bool m_SlotOn; // true during an oval driil definition -public: EXCELLON_IMAGE( GERBVIEW_FRAME* aParent, LAYER_NUM layer ) : +public: EXCELLON_IMAGE( GERBVIEW_FRAME* aParent, int layer ) : GERBER_IMAGE( aParent, layer ) { m_State = READ_HEADER_STATE; diff --git a/gerbview/class_gbr_layer_box_selector.cpp b/gerbview/class_gbr_layer_box_selector.cpp index cd598482b2..11d2b9fa5f 100644 --- a/gerbview/class_gbr_layer_box_selector.cpp +++ b/gerbview/class_gbr_layer_box_selector.cpp @@ -40,7 +40,7 @@ void GBR_LAYER_BOX_SELECTOR::Resync() { Clear(); - for( LAYER_NUM layerid = FIRST_LAYER; layerid < NB_LAYERS; ++layerid ) + for( int layerid = 0; layerid < GERBER_DRAWLAYERS_COUNT; ++layerid ) { wxBitmap layerbmp( 14, 14 ); wxString layername; @@ -49,7 +49,7 @@ void GBR_LAYER_BOX_SELECTOR::Resync() continue; // Prepare Bitmap - SetBitmapLayer( layerbmp, layerid ); + SetBitmapLayer( layerbmp, (LAYER_ID)layerid ); layername = GetLayerName( layerid ); @@ -59,7 +59,7 @@ void GBR_LAYER_BOX_SELECTOR::Resync() // Returns a color index from the layer id -EDA_COLOR_T GBR_LAYER_BOX_SELECTOR::GetLayerColor( LAYER_NUM aLayer ) const +EDA_COLOR_T GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayer ) const { GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent(); @@ -68,7 +68,7 @@ EDA_COLOR_T GBR_LAYER_BOX_SELECTOR::GetLayerColor( LAYER_NUM aLayer ) const // Returns the name of the layer id -wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( LAYER_NUM aLayer ) const +wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( int aLayer ) const { wxString name; name.Printf( _( "Layer %d" ), aLayer + 1 ); diff --git a/gerbview/class_gbr_layer_box_selector.h b/gerbview/class_gbr_layer_box_selector.h index ff7878ae09..f404566ebc 100644 --- a/gerbview/class_gbr_layer_box_selector.h +++ b/gerbview/class_gbr_layer_box_selector.h @@ -22,15 +22,14 @@ public: // Returns a color index from the layer id // Virtual function - EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const; + EDA_COLOR_T GetLayerColor( int aLayer ) const; // Returns true if the layer id is enabled (i.e. is it should be displayed) // Virtual function - bool IsLayerEnabled( LAYER_NUM aLayer ) const { return true; }; + bool IsLayerEnabled( int aLayer ) const { return true; }; // Returns the name of the layer id - // Virtual function - wxString GetLayerName( LAYER_NUM aLayer ) const; + wxString GetLayerName( int aLayer ) const; }; #endif //CLASS_GBR_LAYER_BOX_SELECTOR_H diff --git a/gerbview/class_gbr_layout.cpp b/gerbview/class_gbr_layout.cpp index ad475e07f6..2d96bf8f40 100644 --- a/gerbview/class_gbr_layout.cpp +++ b/gerbview/class_gbr_layout.cpp @@ -14,7 +14,7 @@ GBR_LAYOUT::GBR_LAYOUT() { PAGE_INFO pageInfo( wxT( "GERBER" ) ); SetPageSettings( pageInfo ); - m_printLayersMask = FULL_LAYERS; + m_printLayersMask = -1; } @@ -22,16 +22,6 @@ GBR_LAYOUT::~GBR_LAYOUT() { } -/* Function IsLayerVisible - * tests whether a given layer is visible - * param aLayer = The layer to be tested - * return bool - true if the layer is visible. - */ -bool GBR_LAYOUT::IsLayerVisible( LAYER_NUM aLayer ) const -{ - return m_printLayersMask & GetLayerMask( aLayer ); -} - EDA_RECT GBR_LAYOUT::ComputeBoundingBox() { diff --git a/gerbview/class_gbr_layout.h b/gerbview/class_gbr_layout.h index 62397de9c7..2bce7de431 100644 --- a/gerbview/class_gbr_layout.h +++ b/gerbview/class_gbr_layout.h @@ -11,6 +11,7 @@ #include #include // PAGE_INFO +#include // GERBER_DRAWLAYERS_COUNT #include #include @@ -23,11 +24,11 @@ class GBR_LAYOUT { private: - EDA_RECT m_BoundingBox; - PAGE_INFO m_paper; - TITLE_BLOCK m_titles; - wxPoint m_originAxisPosition; - LSET m_printLayersMask; // When printing: the list of layers to print + EDA_RECT m_BoundingBox; + PAGE_INFO m_paper; + TITLE_BLOCK m_titles; + wxPoint m_originAxisPosition; + std::bitset m_printLayersMask; // When printing: the list of layers to print public: DLIST m_Drawings; // linked list of Gerber Items @@ -87,24 +88,35 @@ public: void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset, bool aPrintBlackAndWhite = false ); - /** - * Function SetVisibleLayers - * changes the bit-mask of visible layers - * @param aLayerMask = The new bit-mask of visible layers + * Function SetPrintableLayers + * changes the list of printable layers + * @param aLayerMask = The new bit-mask of printable layers */ - void SetVisibleLayers( LSET aLayerMask ) + void SetPrintableLayers( const std::bitset & aLayerMask ) { m_printLayersMask = aLayerMask; } /** - * Function IsLayerVisible + * Function GetPrintableLayers + * @return the bit-mask of printable layers + */ + std::bitset GetPrintableLayers() + { + return m_printLayersMask; + } + + /** + * Function IsLayerPrintable * tests whether a given layer is visible * @param aLayer = The layer to be tested * @return bool - true if the layer is visible. */ - bool IsLayerVisible( LAYER_NUM aLayer ) const; + bool IsLayerPrintable( int aLayer ) const + { + return m_printLayersMask[ aLayer ]; + } #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const; // overload diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp index f01f3d5d55..e7e2341f8c 100644 --- a/gerbview/class_gerber_draw_item.cpp +++ b/gerbview/class_gerber_draw_item.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -44,7 +45,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GBR_LAYOUT* aParent, GERBER_IMAGE* aGerberpa EDA_ITEM( (EDA_ITEM*)aParent, TYPE_GERBER_DRAW_ITEM ) { m_imageParams = aGerberparams; - m_Layer = FIRST_LAYER; + m_Layer = 0; m_Shape = GBR_SEGMENT; m_Flashed = false; m_DCode = 0; diff --git a/gerbview/class_gerber_draw_item.h b/gerbview/class_gerber_draw_item.h index 13d15e62e6..49e3340c6c 100644 --- a/gerbview/class_gerber_draw_item.h +++ b/gerbview/class_gerber_draw_item.h @@ -90,7 +90,7 @@ public: * redundancy for these parameters */ private: - LAYER_NUM m_Layer; + int m_Layer; // These values are used to draw this item, according to gerber layers parameters // Because they can change inside a gerber image, they are stored here @@ -123,7 +123,7 @@ public: * Function GetLayer * returns the layer this item is on. */ - LAYER_NUM GetLayer() const { return m_Layer; } + int GetLayer() const { return m_Layer; } /** * Function SetLayer @@ -132,12 +132,7 @@ public: * is virtual because some items (in fact: class DIMENSION) * have a slightly different initialization */ - void SetLayer( LAYER_NUM aLayer ) { m_Layer = aLayer; } - - LSET GetLayerMask() - { - return ::GetLayerMask( m_Layer ); - } + void SetLayer( int aLayer ) { m_Layer = aLayer; } bool GetLayerPolarity() { diff --git a/gerbview/class_gerbview_layer_widget.cpp b/gerbview/class_gerbview_layer_widget.cpp index 533232fd41..6101db824d 100644 --- a/gerbview/class_gerbview_layer_widget.cpp +++ b/gerbview/class_gerbview_layer_widget.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -166,10 +167,10 @@ void GERBER_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event ) void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) { - int rowCount; - int menuId = event.GetId(); - bool visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false;; - LSET visibleLayers = NO_LAYERS; + int rowCount; + int menuId = event.GetId(); + bool visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false;; + long visibleLayers = 0; bool force_active_layer_visible; m_alwaysShowActiveLayer = ( menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE ); @@ -186,7 +187,7 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) for( int row=0; row < rowCount; ++row ) { wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 ); - LAYER_NUM layer = getDecodedId( cb->GetId() ); + int layer = getDecodedId( cb->GetId() ); bool loc_visible = visible; if( force_active_layer_visible && (layer == myframe->getActiveLayer() ) ) @@ -195,9 +196,9 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) cb->SetValue( loc_visible ); if( loc_visible ) - visibleLayers |= GetLayerSet( row ); + visibleLayers |= 1 << row; else - visibleLayers &= ~GetLayerSet( row ); + visibleLayers &= ~( 1 << row ); } myframe->SetVisibleLayers( visibleLayers ); @@ -224,7 +225,7 @@ void GERBER_LAYER_WIDGET::ReFill() { ClearLayerRows(); - for( LAYER_NUM layer = FIRST_LAYER; layer < NB_GERBER_LAYERS; ++layer ) + for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer ) { wxString msg; msg.Printf( _("Layer %d"), layer+1 ); @@ -244,11 +245,11 @@ void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor ) myframe->GetCanvas()->Refresh(); } -bool GERBER_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer ) +bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer ) { // the layer change from the GERBER_LAYER_WIDGET can be denied by returning // false from this function. - LAYER_NUM layer = myframe->getActiveLayer( ); + int layer = myframe->getActiveLayer( ); myframe->setActiveLayer( aLayer, false ); myframe->syncLayerBox(); @@ -261,14 +262,14 @@ bool GERBER_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer ) return true; } -void GERBER_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool isFinal ) +void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) { - LSET visibleLayers = myframe->GetVisibleLayers(); + long visibleLayers = myframe->GetVisibleLayers(); if( isVisible ) - visibleLayers |= GetLayerSet( aLayer ); + visibleLayers |= 1 << aLayer; else - visibleLayers &= ~GetLayerSet( aLayer ); + visibleLayers &= ~( 1 << aLayer ); myframe->SetVisibleLayers( visibleLayers ); diff --git a/gerbview/controle.cpp b/gerbview/controle.cpp index fedb66b381..86999c5df0 100644 --- a/gerbview/controle.cpp +++ b/gerbview/controle.cpp @@ -30,6 +30,7 @@ #include #include #include +#include void GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index 5e1dc793c3..8063b81b0c 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -38,6 +38,7 @@ #include #include +#include #include #include diff --git a/gerbview/dialogs/dialog_print_using_printer.cpp b/gerbview/dialogs/dialog_print_using_printer.cpp index 1bd58a195e..95e938282a 100644 --- a/gerbview/dialogs/dialog_print_using_printer.cpp +++ b/gerbview/dialogs/dialog_print_using_printer.cpp @@ -6,7 +6,7 @@ #define wxTEST_POSTSCRIPT_IN_MSW 1 #include -//#include + #include #include #include @@ -16,9 +16,9 @@ #include #include +#include #include -static long s_SelectedLayers; static double s_ScaleList[] = { 0, 0.5, 0.7, 0.999, 1.0, 1.4, 2.0, 3.0, 4.0 }; @@ -27,8 +27,8 @@ static double s_ScaleList[] = #define MAX_SCALE 100.0 // static print data and page setup data, to remember settings during the session -static wxPrintData* g_PrintData; -static wxPageSetupDialogData* g_pageSetupData = (wxPageSetupDialogData*) NULL; +static wxPrintData* s_printData; +static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL; // Variables locales static PRINT_PARAMETERS s_Parameters; @@ -41,8 +41,8 @@ class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_BASE { private: GERBVIEW_FRAME* m_Parent; - wxConfigBase* m_Config; - wxCheckBox* m_BoxSelectLayer[32]; + wxConfigBase* m_Config; + wxCheckBox* m_BoxSelectLayer[32]; public: DIALOG_PRINT_USING_PRINTER( GERBVIEW_FRAME* parent ); @@ -63,7 +63,10 @@ private: public: bool IsMirrored() { return m_Print_Mirror->IsChecked(); } bool PrintUsingSinglePage() { return true; } - int SetLayerSetFromListSelection(); + int SetLayerSetFromListSelection(); + // Prepare print parameters. return true if OK, + // false if there is an issue (mainly no printable layers) + bool PreparePrintPrms(); }; @@ -75,17 +78,17 @@ void GERBVIEW_FRAME::ToPrinter( wxCommandEvent& event ) * Display the print dialog */ { - if( g_PrintData == NULL ) // First print - g_PrintData = new wxPrintData(); + if( s_printData == NULL ) // First print + s_printData = new wxPrintData(); - if( !g_PrintData->Ok() ) + if( !s_printData->Ok() ) { DisplayError( this, _( "Error Init Printer info" ) ); return; } - g_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); - g_PrintData->SetOrientation( GetPageSettings().IsPortrait() ? + s_printData->SetQuality( wxPRINT_QUALITY_HIGH ); + s_printData->SetOrientation( GetPageSettings().IsPortrait() ? wxPORTRAIT : wxLANDSCAPE ); DIALOG_PRINT_USING_PRINTER* frame = new DIALOG_PRINT_USING_PRINTER( this ); @@ -118,31 +121,29 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) /************************************************************************/ { SetFocus(); - LAYER_NUM layer_max = NB_GERBER_LAYERS; wxString msg; - if( g_pageSetupData == NULL ) + if( s_pageSetupData == NULL ) { - g_pageSetupData = new wxPageSetupDialogData; + s_pageSetupData = new wxPageSetupDialogData; // Set initial page margins. - // Margins are already set in Pcbnew, so we can use 0 - g_pageSetupData->SetMarginTopLeft(wxPoint(0, 0)); - g_pageSetupData->SetMarginBottomRight(wxPoint(0, 0)); + // Margins are already set in Gerbview, so we can use 0 + s_pageSetupData->SetMarginTopLeft(wxPoint(0, 0)); + s_pageSetupData->SetMarginBottomRight(wxPoint(0, 0)); } - s_Parameters.m_PageSetupData = g_pageSetupData; + s_Parameters.m_PageSetupData = s_pageSetupData; - layer_max = NB_LAYERS; // Create layer list - for( LAYER_NUM ii = FIRST_LAYER; ii < layer_max; ++ii ) + for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii ) { - LSET mask = GetLayerSet( ii ); msg = _( "Layer" ); msg << wxT( " " ) << ii + 1; m_BoxSelectLayer[ii] = new wxCheckBox( this, -1, msg ); - if( mask & s_SelectedLayers ) - m_BoxSelectLayer[ii]->SetValue( true ); + if( g_GERBER_List[ii] == NULL ) // Nothing loaded on this draw layer + m_BoxSelectLayer[ii]->Enable( false ); + if( ii < 16 ) m_leftLayersBoxSizer->Add( m_BoxSelectLayer[ii], wxGROW | wxLEFT | wxRIGHT | wxTOP ); @@ -170,21 +171,14 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) s_Parameters.m_YScaleAdjust > MAX_SCALE ) s_Parameters.m_XScaleAdjust = s_Parameters.m_YScaleAdjust = 1.0; - s_SelectedLayers = 0; - for( LAYER_NUM layer = FIRST_LAYER; layer < layer_max; ++layer ) + for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer ) { wxString layerKey; bool option; layerKey.Printf( OPTKEY_LAYERBASE, layer ); - - option = false; - if( m_Config->Read( layerKey, &option ) ) - { - m_BoxSelectLayer[layer]->SetValue( option ); - if( option ) - s_SelectedLayers |= GetLayerSet( layer ); - } + m_Config->Read( layerKey, &option, false ); + m_BoxSelectLayer[layer]->SetValue( option ); } } @@ -214,30 +208,29 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) m_FineAdjustYscaleOpt->Enable(enable); } -/**************************************************************/ int DIALOG_PRINT_USING_PRINTER::SetLayerSetFromListSelection() -/**************************************************************/ { int page_count = 0; - s_Parameters.m_PrintMaskLayer = NO_LAYERS; - for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii ) + std::bitset layerMask; + for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii ) { - if( m_BoxSelectLayer[ii]->IsChecked() ) + if( m_BoxSelectLayer[ii]->IsChecked() && m_BoxSelectLayer[ii]->IsEnabled() ) { page_count++; - s_Parameters.m_PrintMaskLayer |= GetLayerSet( ii ); + layerMask[ii] = true; } + else + layerMask[ii] = false; } + m_Parent->GetGerberLayout()->SetPrintableLayers( layerMask ); s_Parameters.m_PageCount = page_count; return page_count; } -/********************************************************************/ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event ) -/********************************************************************/ { SetPrintParameters(); @@ -249,19 +242,18 @@ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event ) m_Config->Write( OPTKEY_PRINT_PAGE_FRAME, s_Parameters.m_Print_Sheet_Ref); m_Config->Write( OPTKEY_PRINT_MONOCHROME_MODE, s_Parameters.m_Print_Black_and_White); wxString layerKey; - for( LAYER_NUM layer = FIRST_LAYER; layer < NB_GERBER_LAYERS; ++layer ) + for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer ) { layerKey.Printf( OPTKEY_LAYERBASE, layer ); m_Config->Write( layerKey, m_BoxSelectLayer[layer]->IsChecked() ); } } + EndModal( 0 ); } -/******************************************************************/ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( ) -/******************************************************************/ { s_Parameters.m_PrintMirror = m_Print_Mirror->GetValue(); s_Parameters.m_Print_Black_and_White = @@ -303,38 +295,45 @@ void DIALOG_PRINT_USING_PRINTER::OnScaleSelectionClick( wxCommandEvent& event ) m_FineAdjustYscaleOpt->Enable(enable); } -/**********************************************************/ +// Open a dialog box for printer setup (printer options, page size ...) void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event ) -/**********************************************************/ - -/* Open a dialog box for printer setup (printer options, page size ...) - */ { - *g_pageSetupData = *g_PrintData; + *s_pageSetupData = *s_printData; - wxPageSetupDialog pageSetupDialog(this, g_pageSetupData); + wxPageSetupDialog pageSetupDialog(this, s_pageSetupData); pageSetupDialog.ShowModal(); - (*g_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData(); - (*g_pageSetupData) = pageSetupDialog.GetPageSetupDialogData(); + (*s_printData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData(); + (*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData(); } - -/************************************************************/ -void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) -/************************************************************/ - -/* Open and display a previewer frame for printing - */ +bool DIALOG_PRINT_USING_PRINTER::PreparePrintPrms() { SetPrintParameters( ); + // If no layer selected, we have no plot. prompt user if it happens + // because he could think there is a bug in Pcbnew: + if( m_Parent->GetGerberLayout()->GetPrintableLayers().none() ) + { + DisplayError( this, _( "No layer selected" ) ); + return false; + } + + return true; +} + +// Open and display a previewer frame for printing +void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) +{ + if( !PreparePrintPrms() ) + return; + // Pass two printout objects: for preview, and possible printing. wxString title = _( "Print Preview" ); wxPrintPreview* preview = new wxPrintPreview( new BOARD_PRINTOUT_CONTROLLER( s_Parameters, m_Parent, title ), new BOARD_PRINTOUT_CONTROLLER( s_Parameters, m_Parent, title ), - g_PrintData ); + s_printData ); if( preview == NULL ) { @@ -342,16 +341,6 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) return; } - SetLayerSetFromListSelection(); - - // If no layer selected, we have no plot. prompt user if it happens - // because he could think there is a bug in Pcbnew: - if( s_Parameters.m_PrintMaskLayer == 0 ) - { - DisplayError( this, _( "No layer selected" ) ); - return; - } - // Uses the parent position and size. // @todo uses last position and size ans store them when exit in m_Config @@ -365,29 +354,16 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) } -/***************************************************************************/ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event ) -/***************************************************************************/ - -/* Called on activate Print button - */ { - SetPrintParameters( ); - - // If no layer selected, we have no plot. prompt user if it happens - // because he could think there is a bug in Pcbnew: - if( s_Parameters.m_PrintMaskLayer == 0 ) - { - DisplayError( this, _( "No layer selected" ) ); + if( !PreparePrintPrms() ) return; - } - wxPrintDialogData printDialogData( *g_PrintData ); + wxPrintDialogData printDialogData( *s_printData ); - wxPrinter printer( &printDialogData ); - - wxString title = _( "Print" ); - BOARD_PRINTOUT_CONTROLLER printout( s_Parameters, m_Parent, title ); + wxPrinter printer( &printDialogData ); + wxString title = _( "Print" ); + BOARD_PRINTOUT_CONTROLLER printout( s_Parameters, m_Parent, title ); #if !defined(__WINDOWS__) && !wxCHECK_VERSION(2,9,0) wxDC* dc = printout.GetDC(); @@ -402,7 +378,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event ) } else { - *g_PrintData = printer.GetPrintDialogData().GetPrintData(); + *s_printData = printer.GetPrintDialogData().GetPrintData(); } } diff --git a/gerbview/dialogs/dialog_select_one_pcb_layer.cpp b/gerbview/dialogs/dialog_select_one_pcb_layer.cpp index cfadefe3ea..00dcc9b657 100644 --- a/gerbview/dialogs/dialog_select_one_pcb_layer.cpp +++ b/gerbview/dialogs/dialog_select_one_pcb_layer.cpp @@ -8,7 +8,7 @@ #include // Exported function -const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber ); +const wxString GetPCBDefaultLayerName( int aLayerNumber ); enum layer_sel_id { @@ -23,11 +23,11 @@ class SELECT_LAYER_DIALOG : public wxDialog private: GERBVIEW_FRAME* m_Parent; wxRadioBox* m_LayerList; - LAYER_NUM m_LayerId[int(NB_LAYERS) + 1]; // One extra element for "(Deselect)" radiobutton + int m_LayerId[int(GERBER_DRAWLAYERS_COUNT) + 1]; // One extra element for "(Deselect)" radiobutton public: // Constructor and destructor - SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, LAYER_NUM aDefaultLayer, + SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLayer, int aCopperLayerCount, bool aShowDeselectOption ); ~SELECT_LAYER_DIALOG() { }; @@ -47,10 +47,10 @@ END_EVENT_TABLE() /** Install the dialog box for layer selection - * @param aDefaultLayer = Preselection (NB_LAYERS for "(Deselect)" layer) + * @param aDefaultLayer = Preselection (GERBER_DRAWLAYERS_COUNT for "(Deselect)" layer) * @param aCopperLayerCount = number of copper layers * @param aShowDeselectOption = display a "(Deselect)" radiobutton (when set to true) - * @return new layer value (NB_LAYERS when "(Deselect)" radiobutton selected), + * @return new layer value (GERBER_DRAWLAYERS_COUNT when "(Deselect)" radiobutton selected), * or -1 if canceled * * Providing the option to also display a "(Deselect)" radiobutton makes the @@ -61,10 +61,10 @@ END_EVENT_TABLE() * different radiobutton is clicked on) prior to then clicking on the "Deselect" * button provided within the "Layer selection:" dialog box). */ -LAYER_NUM GERBVIEW_FRAME::SelectPCBLayer( LAYER_NUM aDefaultLayer, int aCopperLayerCount, +int GERBVIEW_FRAME::SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount, bool aShowDeselectOption ) { - LAYER_NUM layer; + int layer; SELECT_LAYER_DIALOG* frame = new SELECT_LAYER_DIALOG( this, aDefaultLayer, aCopperLayerCount, aShowDeselectOption ); @@ -82,14 +82,17 @@ LAYER_NUM GERBVIEW_FRAME::SelectPCBLayer( LAYER_NUM aDefaultLayer, int aCopperLa * to the right of that radiobox. */ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, - LAYER_NUM aDefaultLayer, int aCopperLayerCount, + int aDefaultLayer, int aCopperLayerCount, bool aShowDeselectOption ) : wxDialog( parent, -1, _( "Select Layer:" ), wxPoint( -1, -1 ), wxSize( 470, 250 ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) { + #define NB_PCB_LAYERS 64 + #define FIRST_COPPER_LAYER 0 + #define LAST_COPPER_LAYER 31 wxButton* Button; - LAYER_NUM ii; + int ii; wxString LayerList[NB_PCB_LAYERS + 1]; // One extra element for "(Deselect)" // radiobutton int LayerCount, LayerSelect = -1; @@ -98,9 +101,10 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, // Build the layer list; first build copper layers list LayerCount = 0; - for( ii = FIRST_COPPER_LAYER; ii < NB_COPPER_LAYERS; ++ii ) + + for( ii = FIRST_COPPER_LAYER; ii <= LAST_COPPER_LAYER; ++ii ) { - m_LayerId[ii] = FIRST_LAYER; + m_LayerId[ii] = 0; if( ii == FIRST_COPPER_LAYER || ii == LAST_COPPER_LAYER || ii < aCopperLayerCount-1 ) { @@ -113,10 +117,11 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, LayerCount++; } } + // Build the layer list; build non copper layers list for( ; ii < NB_PCB_LAYERS; ++ii ) { - m_LayerId[ii] = FIRST_LAYER; + m_LayerId[ii] = 0; LayerList[LayerCount] = GetPCBDefaultLayerName( ii ); @@ -182,7 +187,7 @@ void SELECT_LAYER_DIALOG::OnCancelClick( wxCommandEvent& event ) EndModal( -1 ); } -const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber ) +const wxString GetPCBDefaultLayerName( int aLayerNumber ) { const wxChar* txt; @@ -190,20 +195,20 @@ const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber ) switch( aLayerNumber ) { case F_Cu: txt = wxT( "F.Cu" ); break; - case LAYER_N_2: txt = wxT( "Inner1.Cu" ); break; - case LAYER_N_3: txt = wxT( "Inner2.Cu" ); break; - case LAYER_N_4: txt = wxT( "Inner3.Cu" ); break; - case LAYER_N_5: txt = wxT( "Inner4.Cu" ); break; - case LAYER_N_6: txt = wxT( "Inner5.Cu" ); break; - case LAYER_N_7: txt = wxT( "Inner6.Cu" ); break; - case LAYER_N_8: txt = wxT( "Inner7.Cu" ); break; - case LAYER_N_9: txt = wxT( "Inner8.Cu" ); break; - case LAYER_N_10: txt = wxT( "Inner9.Cu" ); break; - case LAYER_N_11: txt = wxT( "Inner10.Cu" ); break; - case LAYER_N_12: txt = wxT( "Inner11.Cu" ); break; - case LAYER_N_13: txt = wxT( "Inner12.Cu" ); break; - case LAYER_N_14: txt = wxT( "Inner13.Cu" ); break; - case LAYER_N_15: txt = wxT( "Inner14.Cu" ); break; + case In1_Cu: txt = wxT( "In1.Cu" ); break; + case In2_Cu: txt = wxT( "In2.Cu" ); break; + case In3_Cu: txt = wxT( "In3.Cu" ); break; + case In4_Cu: txt = wxT( "In4.Cu" ); break; + case In5_Cu: txt = wxT( "In5.Cu" ); break; + case In6_Cu: txt = wxT( "In6.Cu" ); break; + case In7_Cu: txt = wxT( "In7.Cu" ); break; + case In8_Cu: txt = wxT( "In8.Cu" ); break; + case In9_Cu: txt = wxT( "In9.Cu" ); break; + case In10_Cu: txt = wxT( "In10.Cu" ); break; + case In11_Cu: txt = wxT( "In11.Cu" ); break; + case In12_Cu: txt = wxT( "In12.Cu" ); break; + case In13_Cu: txt = wxT( "In13.Cu" ); break; + case In14_Cu: txt = wxT( "In14.Cu" ); break; case B_Cu: txt = wxT( "B.Cu" ); break; case B_Adhes: txt = wxT( "B.Adhes" ); break; case F_Adhes: txt = wxT( "F.Adhes" ); break; diff --git a/gerbview/dialogs/dialog_show_page_borders.cpp b/gerbview/dialogs/dialog_show_page_borders.cpp index 210291792a..7c2dcfd7ea 100644 --- a/gerbview/dialogs/dialog_show_page_borders.cpp +++ b/gerbview/dialogs/dialog_show_page_borders.cpp @@ -32,6 +32,7 @@ #include #include +#include #include diff --git a/gerbview/dialogs/gerbview_dialog_display_options_frame.cpp b/gerbview/dialogs/gerbview_dialog_display_options_frame.cpp index 24928c9f75..b2d52c851a 100644 --- a/gerbview/dialogs/gerbview_dialog_display_options_frame.cpp +++ b/gerbview/dialogs/gerbview_dialog_display_options_frame.cpp @@ -11,6 +11,7 @@ #include #include +#include #include diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp index da9e793679..8da86a78aa 100644 --- a/gerbview/draw_gerber_screen.cpp +++ b/gerbview/draw_gerber_screen.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -46,11 +47,10 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer, bool aPrintMirrorMode, void* aData ) { // Save current draw options, because print mode has specific options: - LSET visiblemask = GetVisibleLayers(); GBR_DISPLAY_OPTIONS imgDisplayOptions = m_DisplayOptions; + std::bitset printLayersMask = GetGerberLayout()->GetPrintableLayers(); // Set draw options for printing: - SetVisibleLayers( aPrintMasklayer ); m_DisplayOptions.m_DisplayFlashedItemsFill = true; m_DisplayOptions.m_DisplayLinesFill = true; m_DisplayOptions.m_DisplayPolygonsFill = true; @@ -58,7 +58,10 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer, m_DisplayOptions.m_IsPrinting = true; PRINT_PARAMETERS* printParameters = (PRINT_PARAMETERS*)aData; - + std::bitset printCurrLayerMask; + printCurrLayerMask.reset(); + printCurrLayerMask.set(printParameters->m_Flags); // m_Flags contains the draw layer number + GetGerberLayout()->SetPrintableLayers( printCurrLayerMask ); m_canvas->SetPrintMirrored( aPrintMirrorMode ); bool printBlackAndWhite = printParameters && printParameters->m_Print_Black_and_White; @@ -68,7 +71,7 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer, m_canvas->SetPrintMirrored( false ); // Restore draw options: - SetVisibleLayers( visiblemask ); + GetGerberLayout()->SetPrintableLayers( printLayersMask ); m_DisplayOptions = imgDisplayOptions; } @@ -202,14 +205,14 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, bool end = false; - for( LAYER_NUM layer = FIRST_LAYER; !end; ++layer ) + for( int layer = 0; !end; ++layer ) { - LAYER_NUM active_layer = gerbFrame->getActiveLayer(); + int active_layer = gerbFrame->getActiveLayer(); if( layer == active_layer ) // active layer will be drawn after other layers continue; - if( layer == NB_GERBER_LAYERS ) // last loop: draw active layer + if( layer == GERBER_DRAWLAYERS_COUNT ) // last loop: draw active layer { end = true; layer = active_layer; diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index 6f258ab2b8..bfbff86459 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -226,7 +227,7 @@ void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event ) void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event ) { - LAYER_NUM layer = getActiveLayer(); + int layer = getActiveLayer(); setActiveLayer( event.GetSelection() ); @@ -240,7 +241,7 @@ void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event ) void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event ) { - LAYER_NUM layer = getActiveLayer(); + int layer = getActiveLayer(); GERBER_IMAGE* gerber_layer = g_GERBER_List[layer]; if( gerber_layer ) diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index 952d89c8d3..7c9726d2b0 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -67,6 +67,7 @@ #include #include +#include #include #include #include @@ -92,13 +93,13 @@ extern double ReadDouble( char*& text, bool aSkipSeparator = true ); extern void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem, APERTURE_T aAperture, int Dcode_index, - LAYER_NUM aLayer, + int aLayer, const wxPoint& aPos, wxSize aSize, bool aLayerNegative ); void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, - LAYER_NUM aLayer, + int aLayer, const wxPoint& aStart, const wxPoint& aEnd, wxSize aPenSize, @@ -167,7 +168,7 @@ static EXCELLON_CMD excellon_G_CmdList[] = bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) { wxString msg; - LAYER_NUM layer = getActiveLayer(); // current layer used in GerbView + int layer = getActiveLayer(); // current layer used in GerbView if( g_GERBER_List[layer] == NULL ) { diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index 1594f5d7af..f770256667 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -7,13 +7,13 @@ #include #include -// #include #include #include #include #include #include #include +#include #include #include #include @@ -123,7 +123,7 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event ) int layercount = 0; // Count the Gerber layers which are actually currently used - for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii ) + for( LAYER_NUM ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii ) { if( g_GERBER_List[ii] != NULL ) layercount++; @@ -190,16 +190,17 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* LayerLookUpTable, int aCopperLay // create an image of gerber data // First: non copper layers: GERBER_DRAW_ITEM* gerb_item = m_gerbview_frame->GetItemsList(); + int pcbCopperLayerMax = 31; for( ; gerb_item; gerb_item = gerb_item->Next() ) { - LAYER_NUM layer = gerb_item->GetLayer(); + int layer = gerb_item->GetLayer(); LAYER_NUM pcb_layer_number = LayerLookUpTable[layer]; if( !IsPcbLayer( pcb_layer_number ) ) continue; - if( pcb_layer_number > LAST_COPPER_LAYER ) + if( pcb_layer_number > pcbCopperLayerMax ) export_non_copper_item( gerb_item, pcb_layer_number ); } @@ -209,10 +210,10 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* LayerLookUpTable, int aCopperLay for( ; gerb_item; gerb_item = gerb_item->Next() ) { - LAYER_NUM layer = gerb_item->GetLayer(); + int layer = gerb_item->GetLayer(); LAYER_NUM pcb_layer_number = LayerLookUpTable[layer]; - if( pcb_layer_number < 0 || pcb_layer_number > LAST_COPPER_LAYER ) + if( pcb_layer_number < 0 || pcb_layer_number > pcbCopperLayerMax ) continue; else @@ -398,13 +399,7 @@ void GBR_TO_PCB_EXPORTER::writePcbHeader() // Write copper layer count fprintf( m_fp, "LayerCount %d\n", m_pcbCopperLayersCount ); - // Write enabled layer mask: - int lmask = ALL_NO_CU_LAYERS | EXTERNAL_CU_LAYERS; - for( int ii = 0; ii < m_pcbCopperLayersCount - 2; ii++ ) - lmask |= 2 << ii; - - fprintf( m_fp, "EnabledLayers %08X\n", lmask ); fprintf( m_fp, "$EndGENERAL\n\n" ); // Creates void setup diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 6d219cd131..5b016e87a9 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -163,7 +164,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) } // Read gerber files: each file is loaded on a new GerbView layer - LAYER_NUM layer = getActiveLayer(); + int layer = getActiveLayer(); for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ ) { @@ -244,7 +245,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) } // Read gerber files: each file is loaded on a new GerbView layer - LAYER_NUM layer = getActiveLayer(); + int layer = getActiveLayer(); for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ ) { diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index fbdc0288bc..6e30d8a7c2 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include diff --git a/gerbview/gerbview.h b/gerbview/gerbview.h index 42a469a631..89385344f1 100644 --- a/gerbview/gerbview.h +++ b/gerbview/gerbview.h @@ -8,9 +8,6 @@ #include #include -#include -#include -#include #define CURSEUR_ON_GRILLE 0 #define CURSEUR_OFF_GRILLE 1 @@ -32,6 +29,8 @@ extern const wxChar* g_GerberPageSizeList[8]; #define GERB_STOP_DRAW 2 // Extinguish light (lift pen) #define GERB_FLASH 3 // Flash +// number fo draw layers in Gerbview +#define GERBER_DRAWLAYERS_COUNT 32 /** * Enum GERBER_VISIBLE_ID @@ -47,9 +46,6 @@ enum GERBER_VISIBLE_ID END_GERBER_VISIBLE_LIST // sentinel }; -extern const wxString GerbviewProjectFileExt; -extern const wxString GerbviewProjectFileWildcard; - // Interpolation type enum Gerb_Interpolation { @@ -93,13 +89,6 @@ enum Gerb_Analyse_Cmd ENTER_RS274X_CMD }; - -/**************/ -/* rs274x.cpp */ -/**************/ -bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file ); -extern GERBER_IMAGE* g_GERBER_List[32]; - -#include +extern GERBER_IMAGE* g_GERBER_List[GERBER_DRAWLAYERS_COUNT]; #endif // ifndef GERBVIEW_H diff --git a/gerbview/gerbview_config.cpp b/gerbview/gerbview_config.cpp index db1ed29f3e..4202284555 100644 --- a/gerbview/gerbview_config.cpp +++ b/gerbview/gerbview_config.cpp @@ -38,14 +38,13 @@ #include #include +#include #include #include #define GROUP wxT("/gerbview") -#define INSETUP true - void GERBVIEW_FRAME::Process_Config( wxCommandEvent& event ) { diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 632ce929c6..a26c5c378a 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -27,7 +27,6 @@ */ #include -//#include #include #include #include @@ -40,6 +39,7 @@ #include #include +#include #include #include #include @@ -92,7 +92,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): SetLayout( new GBR_LAYOUT() ); - SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible. + SetVisibleLayers( -1 ); // All draw layers visible. SetScreen( new GBR_SCREEN( GetGerberLayout()->GetPageSettings().GetSizeIU() ) ); @@ -167,6 +167,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): m_LayersManager->ReFillRender(); // Update colors in Render after the config is read m_auimgr.Update(); + setActiveLayer( 0, true ); Zoom_Automatique( true ); // Gives a default zoom value } @@ -184,9 +185,9 @@ void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector& aFileSet, int aCtl ) { - const unsigned limit = std::min( unsigned( aFileSet.size() ), unsigned( NB_GERBER_LAYERS ) ); + const unsigned limit = std::min( unsigned( aFileSet.size() ), unsigned( GERBER_DRAWLAYERS_COUNT ) ); - LAYER_NUM layer = FIRST_LAYER; + int layer = 0; for( unsigned i=0; i= NB_GERBER_LAYERS ) - layer = FIRST_LAYER; + if( layer >= GERBER_DRAWLAYERS_COUNT ) + layer = 0; } return NO_AVAILABLE_LAYERS; @@ -398,9 +399,9 @@ void GERBVIEW_FRAME::Liste_D_Codes() wxArrayString list; double scale = g_UserUnit == INCHES ? IU_PER_MILS * 1000 : IU_PER_MM; - LAYER_NUM curr_layer = getActiveLayer(); + int curr_layer = getActiveLayer(); - for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer ) + for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer ) { GERBER_IMAGE* gerber = g_GERBER_List[layer]; @@ -551,9 +552,9 @@ void GERBVIEW_FRAME::SetVisibleAlls() * Returns a bit-mask of all the layers that are visible * @return int - the visible layers in bit-mapped form. */ -LSET GERBVIEW_FRAME::GetVisibleLayers() const +long GERBVIEW_FRAME::GetVisibleLayers() const { - return FULL_LAYERS; // TODO + return -1; // TODO } @@ -563,9 +564,9 @@ LSET GERBVIEW_FRAME::GetVisibleLayers() const * changes the bit-mask of visible layers * @param aLayerMask = The new bit-mask of visible layers */ -void GERBVIEW_FRAME::SetVisibleLayers( LSET aLayerMask ) +void GERBVIEW_FRAME::SetVisibleLayers( long aLayerMask ) { - GetGerberLayout()->SetVisibleLayers( aLayerMask ); +// GetGerberLayout()->SetVisibleLayers( aLayerMask ); } @@ -575,12 +576,12 @@ void GERBVIEW_FRAME::SetVisibleLayers( LSET aLayerMask ) * @param aLayer = The layer to be tested * @return bool - true if the layer is visible. */ -bool GERBVIEW_FRAME::IsLayerVisible( LAYER_NUM aLayer ) const +bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const { if( ! m_DisplayOptions.m_IsPrinting ) return m_LayersManager->IsLayerVisible( aLayer ); else - return GetGerberLayout()->IsLayerVisible( aLayer ); + return GetGerberLayout()->IsLayerPrintable( aLayer ); } @@ -664,7 +665,7 @@ EDA_COLOR_T GERBVIEW_FRAME::GetNegativeItemsColor() const * Function GetLayerColor * gets a layer color for any valid layer. */ -EDA_COLOR_T GERBVIEW_FRAME::GetLayerColor( LAYER_NUM aLayer ) const +EDA_COLOR_T GERBVIEW_FRAME::GetLayerColor( int aLayer ) const { return m_colorsSettings->GetLayerColor( aLayer ); } @@ -674,7 +675,7 @@ EDA_COLOR_T GERBVIEW_FRAME::GetLayerColor( LAYER_NUM aLayer ) const * Function SetLayerColor * changes a layer color for any valid layer. */ -void GERBVIEW_FRAME::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor ) +void GERBVIEW_FRAME::SetLayerColor( int aLayer, EDA_COLOR_T aColor ) { m_colorsSettings->SetLayerColor( aLayer, aColor ); } @@ -684,7 +685,7 @@ void GERBVIEW_FRAME::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor ) * Function getActiveLayer * returns the active layer */ -LAYER_NUM GERBVIEW_FRAME::getActiveLayer() +int GERBVIEW_FRAME::getActiveLayer() { return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer; } @@ -695,7 +696,7 @@ LAYER_NUM GERBVIEW_FRAME::getActiveLayer() * will change the currently active layer to \a aLayer and also * update the PCB_LAYER_WIDGET. */ -void GERBVIEW_FRAME::setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate ) +void GERBVIEW_FRAME::setActiveLayer( int aLayer, bool doLayerWidgetUpdate ) { ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer; diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 81a076e361..fc35c3d4a5 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -37,7 +37,6 @@ #include #include #include -#include #define NO_AVAILABLE_LAYERS UNDEFINED_LAYER @@ -167,7 +166,7 @@ public: * different radiobutton is clicked on) prior to then clicking on the "Deselect" * button provided within the "Layer selection:" dialog box). */ - LAYER_NUM SelectPCBLayer( LAYER_NUM aDefaultLayer, int aOpperLayerCount, bool aNullLayer = false ); + int SelectPCBLayer( int aDefaultLayer, int aOpperLayerCount, bool aNullLayer = false ); protected: GERBER_LAYER_WIDGET* m_LayersManager; @@ -306,9 +305,9 @@ 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 int - the visible layers in bit-mapped form. + * @return long - the visible layers in bit-mapped form. */ - LSET GetVisibleLayers() const; + long GetVisibleLayers() const; /** * Function SetVisibleLayers @@ -316,7 +315,7 @@ public: * changes the bit-mask of visible layers * @param aLayerMask = The new bit-mask of visible layers */ - void SetVisibleLayers( LSET aLayerMask ); + void SetVisibleLayers( long aLayerMask ); /** * Function IsLayerVisible @@ -324,7 +323,7 @@ public: * @param aLayer = The layer to be tested * @return bool - true if the layer is visible. */ - bool IsLayerVisible( LAYER_NUM aLayer ) const; + bool IsLayerVisible( int aLayer ) const; /** * Function GetVisibleElementColor @@ -338,13 +337,13 @@ public: * Function GetLayerColor * gets a layer color for any valid layer. */ - EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const; + EDA_COLOR_T GetLayerColor( int aLayer ) const; /** * Function SetLayerColor * changes a layer color for any valid layer. */ - void SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor ); + void SetLayerColor( int aLayer, EDA_COLOR_T aColor ); /** * Function GetNegativeItemsColor @@ -396,13 +395,13 @@ public: * will change the currently active layer to \a aLayer and also * update the GERBER_LAYER_WIDGET. */ - void setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate = true ); + void setActiveLayer( int aLayer, bool doLayerWidgetUpdate = true ); /** * Function getActiveLayer * returns the active layer */ - LAYER_NUM getActiveLayer(); + int getActiveLayer(); /** * Function getNextAvailableLayer @@ -411,7 +410,7 @@ public: * @param aLayer The first layer to search. * @return The first empty layer found or NO_AVAILABLE_LAYERS. */ - LAYER_NUM getNextAvailableLayer( LAYER_NUM aLayer = FIRST_LAYER ) const; + int getNextAvailableLayer( int aLayer = 0 ) const; bool hasAvailableLayers() const { diff --git a/gerbview/hotkeys.cpp b/gerbview/hotkeys.cpp index 29082a6349..76bae66e51 100644 --- a/gerbview/hotkeys.cpp +++ b/gerbview/hotkeys.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/gerbview/initpcb.cpp b/gerbview/initpcb.cpp index 1ae5090a3c..f428dd9a54 100644 --- a/gerbview/initpcb.cpp +++ b/gerbview/initpcb.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -39,7 +40,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query ) { - LAYER_NUM layer; + int layer; if( GetGerberLayout() == NULL ) return false; @@ -52,7 +53,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query ) GetGerberLayout()->m_Drawings.DeleteAll(); - for( layer = FIRST_LAYER; layer < NB_GERBER_LAYERS; ++layer ) + for( layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer ) { if( g_GERBER_List[layer] ) { @@ -65,7 +66,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query ) SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) ); - setActiveLayer( FIRST_LAYER ); + setActiveLayer( 0 ); m_LayersManager->UpdateLayerIcons(); syncLayerBox(); return true; @@ -74,7 +75,7 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query ) void GERBVIEW_FRAME::Erase_Current_Layer( bool query ) { - LAYER_NUM layer = getActiveLayer(); + int layer = getActiveLayer(); wxString msg; msg.Printf( _( "Clear layer %d?" ), layer + 1 ); diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp index 7e6ba30737..f2fb2a4d50 100644 --- a/gerbview/locate.cpp +++ b/gerbview/locate.cpp @@ -31,6 +31,7 @@ #include #include +#include #include @@ -46,7 +47,7 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc if( aTypeloc == CURSEUR_ON_GRILLE ) ref = GetNearestGridPosition( ref ); - LAYER_NUM layer = getActiveLayer(); + int layer = getActiveLayer(); // Search first on active layer GERBER_DRAW_ITEM* gerb_item = GetItemsList(); diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index fd2b6c0abf..4703b6da66 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/gerbview/onleftclick.cpp b/gerbview/onleftclick.cpp index dc73fbac08..ceedc7f39b 100644 --- a/gerbview/onleftclick.cpp +++ b/gerbview/onleftclick.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include diff --git a/gerbview/onrightclick.cpp b/gerbview/onrightclick.cpp index aefc0e006b..ca9224b5a4 100644 --- a/gerbview/onrightclick.cpp +++ b/gerbview/onrightclick.cpp @@ -8,6 +8,7 @@ #include #include +#include #include diff --git a/gerbview/pcbplot.cpp b/gerbview/pcbplot.cpp index e13b1de974..0e39eb48bb 100644 --- a/gerbview/pcbplot.cpp +++ b/gerbview/pcbplot.cpp @@ -6,6 +6,7 @@ #include #include +#include #include /** TODO */ diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp index ac374bb5c7..cb932db050 100644 --- a/gerbview/readgerb.cpp +++ b/gerbview/readgerb.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -25,7 +26,7 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName, wxString msg; char* text; - LAYER_NUM layer; // current layer used in GerbView + int layer; // current layer used in GerbView layer = getActiveLayer(); diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index 7023d63930..74cb464cb9 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -107,7 +108,7 @@ void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem, APERTURE_T aAperture, int Dcode_index, - LAYER_NUM aLayer, + int aLayer, const wxPoint& aPos, wxSize aSize, bool aLayerNegative ) @@ -159,7 +160,7 @@ void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem, */ void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, - LAYER_NUM aLayer, + int aLayer, const wxPoint& aStart, const wxPoint& aEnd, wxSize aPenSize, @@ -208,7 +209,7 @@ void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem, * false when arc is inside one quadrant * @param aLayerNegative = true if the current layer is negative */ -static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, LAYER_NUM aLayer, +static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, int aLayer, const wxPoint& aStart, const wxPoint& aEnd, const wxPoint& aRelCenter, wxSize aPenSize, bool aClockwise, bool aMultiquadrant, @@ -344,10 +345,11 @@ static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem, * so we muse create a dummy track and use its geometric parameters */ static GERBER_DRAW_ITEM dummyGbrItem( NULL, NULL ); + static const int drawlayer = 0; aGbrItem->SetLayerPolarity( aLayerNegative ); - fillArcGBRITEM( &dummyGbrItem, 0, FIRST_LAYER, + fillArcGBRITEM( &dummyGbrItem, 0, drawlayer, aStart, aEnd, rel_center, wxSize(0, 0), aClockwise, aMultiquadrant, aLayerNegative ); @@ -568,7 +570,7 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) GERBER_DRAW_ITEM* gbritem; GBR_LAYOUT* layout = m_Parent->GetGerberLayout(); - LAYER_NUM activeLayer = m_Parent->getActiveLayer(); + int activeLayer = m_Parent->getActiveLayer(); int dcode = 0; D_CODE* tool = NULL; diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp index e35c94bd2e..aeb7871429 100644 --- a/gerbview/rs274x.cpp +++ b/gerbview/rs274x.cpp @@ -12,6 +12,7 @@ extern int ReadInt( char*& text, bool aSkipSeparator = true ); extern double ReadDouble( char*& text, bool aSkipSeparator = true ); +extern bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file ); #define CODE( x, y ) ( ( (x) << 8 ) + (y) ) diff --git a/gerbview/select_layers_to_pcb.cpp b/gerbview/select_layers_to_pcb.cpp index b6f1cf8f15..03e48aa3c9 100644 --- a/gerbview/select_layers_to_pcb.cpp +++ b/gerbview/select_layers_to_pcb.cpp @@ -27,9 +27,9 @@ */ #include -//#include #include #include +#include #include #include @@ -41,7 +41,7 @@ extern const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber ); enum swap_layer_id { ID_LAYERS_MAP_DIALOG = ID_GERBER_END_LIST, ID_BUTTON_0, - ID_TEXT_0 = ID_BUTTON_0 + NB_GERBER_LAYERS + ID_TEXT_0 = ID_BUTTON_0 + GERBER_DRAWLAYERS_COUNT }; @@ -55,7 +55,7 @@ int LAYERS_MAP_DIALOG::m_exportBoardCopperLayersCount = 2; BEGIN_EVENT_TABLE( LAYERS_MAP_DIALOG, LAYERS_MAP_DIALOG_BASE ) - EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + NB_GERBER_LAYERS-1, + EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + GERBER_DRAWLAYERS_COUNT-1, wxEVT_COMMAND_BUTTON_CLICKED, LAYERS_MAP_DIALOG::OnSelectLayer ) END_EVENT_TABLE() @@ -102,8 +102,7 @@ void LAYERS_MAP_DIALOG::initDialog() // version are also 26 pixels wide and 26 pixels high. If appropriate, // the above code should be modified as required in the event that those // buttons should be some other size in that version. - - for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii ) + for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii ) { // Specify the default value for each member of these arrays. m_buttonTable[ii] = -1; @@ -111,32 +110,31 @@ void LAYERS_MAP_DIALOG::initDialog() } // Ensure we have: - // at least 2 copper layers and BOARD_COPPER_LAYERS_MAX_COUNT copper layers max + // at least 2 copper layers and less than max pacb copper layers count // and even layers count because a board *must* have even layers count - // and maxi BOARD_COPPER_LAYERS_MAX_COUNT copper layers count normalizeBrdLayersCount(); int idx = ( m_exportBoardCopperLayersCount / 2 ) - 1; m_comboCopperLayersCount->SetSelection( idx ); - LAYER_NUM pcb_layer_num = FIRST_LAYER; - m_itemsCount = 0; - for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii ) + LAYER_NUM pcb_layer_num = 0; + m_gerberActiveLayersCount = 0; + for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii ) { if( g_GERBER_List[ii] == NULL ) - continue; + break; if( (pcb_layer_num == m_exportBoardCopperLayersCount - 1) && (m_exportBoardCopperLayersCount > 1) ) pcb_layer_num = F_Cu; - m_buttonTable[m_itemsCount] = ii; + m_buttonTable[m_gerberActiveLayersCount] = ii; m_layersLookUpTable[ii] = pcb_layer_num; - m_itemsCount++; + m_gerberActiveLayersCount++; ++pcb_layer_num; } - if( m_itemsCount <= NB_GERBER_LAYERS/2 ) // Only one list is enough + if( m_gerberActiveLayersCount <= GERBER_DRAWLAYERS_COUNT/2 ) // Only one list is enough { m_staticlineSep->Hide(); } @@ -151,7 +149,7 @@ void LAYERS_MAP_DIALOG::initDialog() } wxFlexGridSizer* flexColumnBoxSizer = m_flexLeftColumnBoxSizer; - for( int ii = 0; ii < m_itemsCount; ii++ ) + for( int ii = 0; ii < m_gerberActiveLayersCount; ii++ ) { // Each Gerber layer has an associated static text string (to // identify that layer), a button (for invoking a child dialog @@ -178,7 +176,7 @@ void LAYERS_MAP_DIALOG::initDialog() // is nb_items; otherwise, the number of rows is 16 (with two // separate columns of controls being used if nb_items > 16). - if( ii == NB_GERBER_LAYERS/2 ) + if( ii == GERBER_DRAWLAYERS_COUNT/2 ) flexColumnBoxSizer = m_flexRightColumnBoxSizer; // Provide a text string to identify the Gerber layer @@ -226,7 +224,7 @@ void LAYERS_MAP_DIALOG::initDialog() wxDefaultSize, 0 ); goodSize = text->GetSize(); - for( LAYER_NUM jj = FIRST_LAYER; jj < NB_LAYERS; ++jj ) + for( LAYER_NUM jj = 0; jj < GERBER_DRAWLAYERS_COUNT; ++jj ) { text->SetLabel( GetPCBDefaultLayerName( jj ) ); if( goodSize.x < text->GetSize().x ) @@ -259,8 +257,8 @@ void LAYERS_MAP_DIALOG::normalizeBrdLayersCount() if( ( m_exportBoardCopperLayersCount & 1 ) ) m_exportBoardCopperLayersCount++; - if( m_exportBoardCopperLayersCount > NB_LAYERS ) - m_exportBoardCopperLayersCount = NB_LAYERS; + if( m_exportBoardCopperLayersCount > GERBER_DRAWLAYERS_COUNT ) + m_exportBoardCopperLayersCount = GERBER_DRAWLAYERS_COUNT; if( m_exportBoardCopperLayersCount < 2 ) m_exportBoardCopperLayersCount = 2; @@ -284,7 +282,7 @@ void LAYERS_MAP_DIALOG::OnResetClick( wxCommandEvent& event ) wxString msg; int ii; LAYER_NUM layer; - for( ii = 0, layer = FIRST_LAYER; ii < m_itemsCount; ii++, ++layer ) + for( ii = 0, layer = 0; ii < m_gerberActiveLayersCount; ii++, ++layer ) { if( (layer == m_exportBoardCopperLayersCount - 1) && (m_exportBoardCopperLayersCount > 1) ) @@ -306,7 +304,7 @@ void LAYERS_MAP_DIALOG::OnStoreSetup( wxCommandEvent& event ) config->Write( wxT("BrdLayersCount"), m_exportBoardCopperLayersCount ); wxString key; - for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii ) + for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii ) { key.Printf( wxT("GbrLyr%dToPcb"), ii ); config->Write( key, m_layersLookUpTable[ii] ); @@ -324,7 +322,7 @@ void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event ) m_comboCopperLayersCount->SetSelection( idx ); wxString key; - for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii ) + for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii ) { key.Printf( wxT("GbrLyr%dToPcb"), ii ); int ilayer; @@ -332,7 +330,7 @@ void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event ) m_layersLookUpTable[ii] = ilayer; } - for( int ii = 0; ii < m_itemsCount; ii++ ) + for( int ii = 0; ii < m_gerberActiveLayersCount; ii++ ) { LAYER_NUM layer = m_layersLookUpTable[ii]; if( layer == UNSELECTED_LAYER ) @@ -354,7 +352,7 @@ void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event ) ii = event.GetId() - ID_BUTTON_0; - if( (ii < FIRST_LAYER) || (ii >= NB_GERBER_LAYERS) ) + if( (ii < 0) || (ii >= GERBER_DRAWLAYERS_COUNT) ) { wxFAIL_MSG( wxT("Bad layer id") ); return; @@ -406,7 +404,7 @@ void LAYERS_MAP_DIALOG::OnOkClick( wxCommandEvent& event ) normalizeBrdLayersCount(); int inner_layer_max = 0; - for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii ) + for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii ) { if( m_layersLookUpTable[ii] < F_Cu ) { diff --git a/gerbview/select_layers_to_pcb.h b/gerbview/select_layers_to_pcb.h index dd27ee28ea..08dd56326b 100644 --- a/gerbview/select_layers_to_pcb.h +++ b/gerbview/select_layers_to_pcb.h @@ -6,24 +6,23 @@ #define _SELECT_LAYERS_TO_PCB_H_ #include -#include /* * This dialog shows the gerber files loaded, and allows user to choose - * equivalence tbetween gerber layers and pcb layers + * equivalence between gerber layers and pcb layers */ class LAYERS_MAP_DIALOG : public LAYERS_MAP_DIALOG_BASE { private: GERBVIEW_FRAME* m_Parent; - int m_itemsCount; + int m_gerberActiveLayersCount; // Number of initialized gerber layers static int m_exportBoardCopperLayersCount; wxFlexGridSizer* m_flexRightColumnBoxSizer; // An extra wxFlexGridSizer used // when we have more than 16 gerber files loaded - LAYER_NUM m_layersLookUpTable[NB_GERBER_LAYERS]; // Indexes Gerber layers to PCB file layers + LAYER_NUM m_layersLookUpTable[GERBER_DRAWLAYERS_COUNT]; // Indexes Gerber layers to PCB file layers // the last value in table is the number of copper layers - int m_buttonTable[int(NB_GERBER_LAYERS)+1]; // Indexes buttons to Gerber layers - wxStaticText* m_layersList[int(NB_GERBER_LAYERS)+1]; // Indexes text strings to buttons + int m_buttonTable[int(GERBER_DRAWLAYERS_COUNT)+1]; // Indexes buttons to Gerber layers + wxStaticText* m_layersList[int(GERBER_DRAWLAYERS_COUNT)+1]; // Indexes text strings to buttons public: LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent ); ~LAYERS_MAP_DIALOG() {}; diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index bc878db1d4..7ad3b5e7b2 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -292,7 +293,7 @@ void GERBVIEW_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent ) void GERBVIEW_FRAME::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent ) { - LAYER_NUM layer = getActiveLayer(); + int layer = getActiveLayer(); GERBER_IMAGE* gerber = g_GERBER_List[layer]; int selected = ( gerber ) ? gerber->m_Selected_Tool : 0; diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index cb34bb3ce6..86e404330e 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -375,6 +375,7 @@ bool BOARD::SetLayerName( LAYER_ID aLayer, const wxString& aLayerName ) // veto changing the name if it exists elsewhere. if( id != aLayer && nameTemp == m_Layer[id].m_name ) +// if( id != aLayer && nameTemp == wxString( m_Layer[id].m_name ) ) return false; } #endif diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index b7e503c2c1..88509163e0 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -89,6 +89,7 @@ BOARD_PRINTOUT_CONTROLLER::BOARD_PRINTOUT_CONTROLLER( const PRINT_PARAMETERS& aP bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage ) { +#ifdef PCBNEW LSET lset = m_PrintParams.m_PrintMaskLayer; // compute layer mask from page number if we want one page per layer @@ -106,15 +107,18 @@ bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage ) if( !m_PrintParams.m_PrintMaskLayer.any() ) return false; -#ifdef PCBNEW // In Pcbnew we can want the layer EDGE always printed if( m_PrintParams.m_Flags == 1 ) m_PrintParams.m_PrintMaskLayer.set( Edge_Cuts ); -#endif DrawPage(); m_PrintParams.m_PrintMaskLayer = lset; +#else // GERBVIEW + // in gerbview, draw layers are printed on separate pages + m_PrintParams.m_Flags = aPage-1; // = gerber draw layer id + DrawPage(); +#endif return true; }