<commit_before>/*******************************************************/
/* Dialog frame to choose gerber layers and pcb layers */
/*******************************************************/

/**
 * @file select_layers_to_pcb.cpp
 */

#include "fctsys.h"
#include "common.h"
#include "appl_wxstruct.h"
#include "gerbview.h"
#include "gerbview_id.h"
#include "class_board_design_settings.h"
#include "class_GERBER.h"
#include "wx/statline.h"

#include "select_layers_to_pcb.h"

#define LAYER_UNSELECTED NB_LAYERS

enum swap_layer_id {
    ID_LAYERS_MAP_DIALOG = ID_GERBER_END_LIST,
    ID_BUTTON_0,
    ID_TEXT_0 = ID_BUTTON_0 + 32
};

/*
 * This dialog shows the gerber files loaded, and allows user to choose:
 *   what gerber file and what board layer are used
 *   the number of copper layers
 */

BEGIN_EVENT_TABLE( LAYERS_MAP_DIALOG, LAYERS_MAP_DIALOG_BASE )
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + 31,
                   wxEVT_COMMAND_BUTTON_CLICKED,
                   LAYERS_MAP_DIALOG::OnSelectLayer )
END_EVENT_TABLE()


LAYERS_MAP_DIALOG::LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent ) :
    LAYERS_MAP_DIALOG_BASE( parent )
{
    m_Parent = parent;
    initDialog();

    // Resize the dialog
    GetSizer()->SetSizeHints( this );
    Centre();
}


void LAYERS_MAP_DIALOG::initDialog()
{
    wxStaticText* label;
    wxStaticText* text;
    int           item_ID;
    wxString      msg;
    wxSize        goodSize;

    m_flexRightColumnBoxSizer = NULL;

    // Experimentation has shown that buttons in the Windows version can be 20
    // pixels wide and 20 pixels high, but that they need to be 26 pixels wide
    // and 26 pixels high in the Linux version. (And although the dimensions
    // of those buttons could be set to 26 pixels wide and 26 pixels high in
    // both of those versions, that would result in a dialog box which would
    // be excessively high in the Windows version.)
#ifdef __WINDOWS__
    int w = 20;
    int h = 20;
#else
    int w = 26;
    int h = 26;
#endif

    // As currently implemented, the dimensions of the buttons in the Mac
    // 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.

    // Compute a reasonable number of copper layers
    m_exportBoardCopperLayersCount = 0;
    for( int ii = 0; ii < 32; ii++ )
    {
        if( g_GERBER_List[ii] != NULL )
            m_exportBoardCopperLayersCount++;

        // Specify the default value for each member of these arrays.
        m_buttonTable[ii] = -1;
        m_layersLookUpTable[ii] = LAYER_UNSELECTED;
    }

    // Ensure we have:
    //    at least 2 copper layers and NB_COPPER_LAYERS copper layers max
    //    an even layers count because board *must* have even layers count
    //    and maxi NB_COPPER_LAYERS copper layers count
    normalizeBrdLayersCount();

    int idx = ( m_exportBoardCopperLayersCount / 2 ) - 1;
    m_comboCopperLayersCount->SetSelection( idx );

    int pcb_layer_num = 0;
    m_itemsCount = 0;
    for( int ii = 0; ii < 32; ii++ )
    {
        if( g_GERBER_List[ii] == NULL )
            continue;

        if( (pcb_layer_num == m_exportBoardCopperLayersCount - 1)
           && (m_exportBoardCopperLayersCount > 1) )
            pcb_layer_num = LAYER_N_FRONT;

        m_buttonTable[m_itemsCount] = ii;
        m_layersLookUpTable[ii]  = pcb_layer_num;
        m_itemsCount++;
        pcb_layer_num++;
    }

    if( m_itemsCount <= 16 )    // Only one list is enough
    {
        m_staticlineSep->Hide();
    }
    else        // Add the second list of gerber files
    {
        m_flexRightColumnBoxSizer = new wxFlexGridSizer( 16, 4, 0, 0 );
        for( int ii = 0; ii < 4; ii++ )
            m_flexRightColumnBoxSizer->AddGrowableCol( ii );
        m_flexRightColumnBoxSizer->SetFlexibleDirection( wxBOTH );
        m_flexRightColumnBoxSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
    }

    wxFlexGridSizer* flexColumnBoxSizer = m_flexLeftColumnBoxSizer;<commit_msg>Gerbview: export to pcbnew enhancements and fixes.<commit_after>/*******************************************************/
/* Dialog frame to choose gerber layers and pcb layers */
/*******************************************************/

/**
 * @file select_layers_to_pcb.cpp
 */

#include "fctsys.h"
#include "common.h"
#include "appl_wxstruct.h"
#include "gerbview.h"
#include "gerbview_id.h"
#include "class_board_design_settings.h"
#include "class_GERBER.h"
#include "wx/statline.h"

#include "select_layers_to_pcb.h"

#define LAYER_UNSELECTED NB_LAYERS

enum swap_layer_id {
    ID_LAYERS_MAP_DIALOG = ID_GERBER_END_LIST,
    ID_BUTTON_0,
    ID_TEXT_0 = ID_BUTTON_0 + 32
};

/*
 * This dialog shows the gerber files loaded, and allows user to choose:
 *   what gerber file and what board layer are used
 *   the number of copper layers
 */

BEGIN_EVENT_TABLE( LAYERS_MAP_DIALOG, LAYERS_MAP_DIALOG_BASE )
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + 31,
                   wxEVT_COMMAND_BUTTON_CLICKED,
                   LAYERS_MAP_DIALOG::OnSelectLayer )
END_EVENT_TABLE()


LAYERS_MAP_DIALOG::LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent ) :
    LAYERS_MAP_DIALOG_BASE( parent )
{
    m_Parent = parent;
    initDialog();

    // Resize the dialog
    Layout();
    GetSizer()->SetSizeHints( this );
    Centre();
}


void LAYERS_MAP_DIALOG::initDialog()
{
    wxStaticText* label;
    wxStaticText* text;
    int           item_ID;
    wxString      msg;
    wxSize        goodSize;

    m_flexRightColumnBoxSizer = NULL;

    // Experimentation has shown that buttons in the Windows version can be 20
    // pixels wide and 20 pixels high, but that they need to be 26 pixels wide
    // and 26 pixels high in the Linux version. (And although the dimensions
    // of those buttons could be set to 26 pixels wide and 26 pixels high in
    // both of those versions, that would result in a dialog box which would
    // be excessively high in the Windows version.)
#ifdef __WINDOWS__
    int w = 20;
    int h = 20;
#else
    int w = 26;
    int h = 26;
#endif

    // As currently implemented, the dimensions of the buttons in the Mac
    // 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.

    // Compute a reasonable number of copper layers
    m_exportBoardCopperLayersCount = 0;
    for( int ii = 0; ii < 32; ii++ )
    {
        if( g_GERBER_List[ii] != NULL )
            m_exportBoardCopperLayersCount++;

        // Specify the default value for each member of these arrays.
        m_buttonTable[ii] = -1;
        m_layersLookUpTable[ii] = LAYER_UNSELECTED;
    }

    // Ensure we have:
    //    at least 2 copper layers and NB_COPPER_LAYERS copper layers max
    //    an even layers count because board *must* have even layers count
    //    and maxi NB_COPPER_LAYERS copper layers count
    normalizeBrdLayersCount();

    int idx = ( m_exportBoardCopperLayersCount / 2 ) - 1;
    m_comboCopperLayersCount->SetSelection( idx );

    int pcb_layer_num = 0;
    m_itemsCount = 0;
    for( int ii = 0; ii < 32; ii++ )
    {
        if( g_GERBER_List[ii] == NULL )
            continue;

        if( (pcb_layer_num == m_exportBoardCopperLayersCount - 1)
           && (m_exportBoardCopperLayersCount > 1) )
            pcb_layer_num = LAYER_N_FRONT;

        m_buttonTable[m_itemsCount] = ii;
        m_layersLookUpTable[ii]  = pcb_layer_num;
        m_itemsCount++;
        pcb_layer_num++;
    }

    if( m_itemsCount <= 16 )    // Only one list is enough
    {
        m_staticlineSep->Hide();
    }
    else        // Add the second list of gerber files
    {
        m_flexRightColumnBoxSizer = new wxFlexGridSizer( 16, 4, 0, 0 );
        for( int ii = 0; ii < 4; ii++ )
            m_flexRightColumnBoxSizer->AddGrowableCol( ii );
        m_flexRightColumnBoxSizer->SetFlexibleDirection( wxBOTH );
        m_flexRightColumnBoxSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
        sbSizerLayersTable->Add( m_flexRightColumnBoxSizer, 1, wxEXPAND, 5 );
    }

    wxFlexGridSizer* flexColumnBoxSizer = m_flexLeftColumnBoxSizer;
{'fraction_non_alphanumeric': 0.10701817744071265, 'fraction_numerical': 0.013964126640182978, 'mean_word_length': 2.87138863000932, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4311891', 'n_tokens_mistral': 2852, 'n_tokens_neox': 2674, 'n_words': 775}