Gerbview: export to pcbnew enhancements and fixes.

This commit is contained in:
jean-pierre charras 2011-04-26 11:18:17 +02:00
commit cfb354cb9f
13 changed files with 1601 additions and 429 deletions

View File

@ -6,7 +6,7 @@
#endif
#ifndef KICAD_BUILD_VERSION
#define KICAD_BUILD_VERSION "(2011-04-17)"
#define KICAD_BUILD_VERSION "(2011-04-24)"
#endif

View File

@ -17,6 +17,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
set(DIALOGS_SRCS
dialogs/gerbview_dialog_display_options_frame_base.cpp
dialogs/gerbview_dialog_display_options_frame.cpp
dialogs/dialog_layers_select_to_pcb_base.cpp
dialogs/dialog_print_using_printer.cpp
dialogs/dialog_print_using_printer_base.cpp
)

View File

@ -419,7 +419,7 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode,
break;
case GBR_ARC:
// Currently, arcs plotted witha rectangular aperture are not supported.
// Currently, arcs plotted with a rectangular aperture are not supported.
// a round pen only is expected.
#if 0 // for arc debug only
GRLine( &aPanel->m_ClipBox, aDC, GetABPosition( m_Start ),

View File

@ -0,0 +1,111 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 17 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_layers_select_to_pcb_base.h"
///////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE( LAYERS_MAP_DIALOG_BASE, wxDialog )
EVT_COMBOBOX( ID_M_COMBOCOPPERLAYERSCOUNT, LAYERS_MAP_DIALOG_BASE::_wxFB_OnBrdLayersCountSelection )
EVT_BUTTON( ID_STORE_CHOICE, LAYERS_MAP_DIALOG_BASE::_wxFB_OnStoreSetup )
EVT_BUTTON( ID_GET_PREVIOUS_CHOICE, LAYERS_MAP_DIALOG_BASE::_wxFB_OnGetSetup )
EVT_BUTTON( ID_RESET_CHOICE, LAYERS_MAP_DIALOG_BASE::_wxFB_OnResetClick )
EVT_BUTTON( wxID_CANCEL, LAYERS_MAP_DIALOG_BASE::_wxFB_OnCancelClick )
EVT_BUTTON( wxID_OK, LAYERS_MAP_DIALOG_BASE::_wxFB_OnOkClick )
END_EVENT_TABLE()
LAYERS_MAP_DIALOG_BASE::LAYERS_MAP_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* sbUpperSizer;
sbUpperSizer = new wxBoxSizer( wxHORIZONTAL );
sbSizerLayersTable = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Layers selection:") ), wxHORIZONTAL );
m_flexLeftColumnBoxSizer = new wxFlexGridSizer( 16, 4, 0, 0 );
m_flexLeftColumnBoxSizer->AddGrowableCol( 0 );
m_flexLeftColumnBoxSizer->AddGrowableCol( 1 );
m_flexLeftColumnBoxSizer->AddGrowableCol( 2 );
m_flexLeftColumnBoxSizer->AddGrowableCol( 3 );
m_flexLeftColumnBoxSizer->SetFlexibleDirection( wxBOTH );
m_flexLeftColumnBoxSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
sbSizerLayersTable->Add( m_flexLeftColumnBoxSizer, 1, wxEXPAND, 5 );
m_staticlineSep = new wxStaticLine( this, ID_M_STATICLINESEP, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
sbSizerLayersTable->Add( m_staticlineSep, 0, wxEXPAND | wxALL, 5 );
sbUpperSizer->Add( sbSizerLayersTable, 1, wxEXPAND, 5 );
wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerLyrCnt;
bSizerLyrCnt = new wxBoxSizer( wxVERTICAL );
m_staticTextCopperlayerCount = new wxStaticText( this, ID_M_STATICTEXTCOPPERLAYERCOUNT, _("Copper layers count:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextCopperlayerCount->Wrap( -1 );
bSizerLyrCnt->Add( m_staticTextCopperlayerCount, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_comboCopperLayersCount = new wxComboBox( this, ID_M_COMBOCOPPERLAYERSCOUNT, _("2 Layers"), wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_comboCopperLayersCount->Append( _("2 Layers") );
m_comboCopperLayersCount->Append( _("4 Layers") );
m_comboCopperLayersCount->Append( _("6 Layers") );
m_comboCopperLayersCount->Append( _("8 Layers") );
m_comboCopperLayersCount->Append( _("10 Layers") );
m_comboCopperLayersCount->Append( _("12 Layers") );
m_comboCopperLayersCount->Append( _("14 Layers") );
m_comboCopperLayersCount->Append( _("16 Layers") );
bSizerLyrCnt->Add( m_comboCopperLayersCount, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bRightSizer->Add( bSizerLyrCnt, 0, wxEXPAND, 5 );
bRightSizer->Add( 5, 15, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerButtons;
bSizerButtons = new wxBoxSizer( wxVERTICAL );
m_buttonStore = new wxButton( this, ID_STORE_CHOICE, _("Store Choice"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_buttonStore, 0, wxALL|wxEXPAND, 5 );
m_buttonRetrieve = new wxButton( this, ID_GET_PREVIOUS_CHOICE, _("Get Stored Choice"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_buttonRetrieve, 0, wxALL|wxEXPAND, 5 );
m_buttonReset = new wxButton( this, ID_RESET_CHOICE, _("Reset"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_buttonReset, 0, wxALL|wxEXPAND, 5 );
bRightSizer->Add( bSizerButtons, 0, wxEXPAND, 5 );
sbUpperSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain->Add( sbUpperSizer, 1, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_sdbSizerButtons = new wxStdDialogButtonSizer();
m_sdbSizerButtonsOK = new wxButton( this, wxID_OK );
m_sdbSizerButtons->AddButton( m_sdbSizerButtonsOK );
m_sdbSizerButtonsCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizerButtons->AddButton( m_sdbSizerButtonsCancel );
m_sdbSizerButtons->Realize();
bSizerMain->Add( m_sdbSizerButtons, 0, wxALIGN_RIGHT|wxALL, 5 );
this->SetSizer( bSizerMain );
this->Layout();
this->Centre( wxBOTH );
}
LAYERS_MAP_DIALOG_BASE::~LAYERS_MAP_DIALOG_BASE()
{
}

View File

@ -0,0 +1,821 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="10" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_python_events">0</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">table</property>
<property name="file">dialog_layers_select_to_pcb_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="internationalize">1</property>
<property name="name">dialog_layers_select_to_pcb_base</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_python_events">1</property>
<property name="use_enum">1</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_managed">0</property>
<property name="aui_name"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center">wxBOTH</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">ID_LAYERS_MAP_DIALOG_BASE</property>
<property name="layer"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">LAYERS_MAP_DIALOG_BASE</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size">400,286</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="title">Layer selection:</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnActivate"></event>
<event name="OnActivateApp"></event>
<event name="OnChar"></event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
<event name="OnIconize"></event>
<event name="OnIdle"></event>
<event name="OnInitDialog"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerMain</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">sbUpperSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Layers selection:</property>
<property name="minimum_size"></property>
<property name="name">sbSizerLayersTable</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">protected</property>
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">4</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">0,1,2,3</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">m_flexLeftColumnBoxSizer</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">protected</property>
<property name="rows">16</property>
<property name="vgap">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_name"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">ID_M_STATICLINESEP</property>
<property name="layer"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticlineSep</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxLI_VERTICAL</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bRightSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerLyrCnt</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_name"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">ID_M_STATICTEXTCOPPERLAYERCOUNT</property>
<property name="label">Copper layers count:</property>
<property name="layer"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticTextCopperlayerCount</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxComboBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_name"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;2 Layers&quot; &quot;4 Layers&quot; &quot;6 Layers&quot; &quot;8 Layers&quot; &quot;10 Layers&quot; &quot;12 Layers&quot; &quot;14 Layers&quot; &quot;16 Layers&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">ID_M_COMBOCOPPERLAYERSCOUNT</property>
<property name="layer"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_comboCopperLayersCount</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value">2 Layers</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCombobox">OnBrdLayersCountSelection</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">15</property>
<property name="permission">protected</property>
<property name="width">5</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerButtons</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_name"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">ID_STORE_CHOICE</property>
<property name="label">Store Choice</property>
<property name="layer"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_buttonStore</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnStoreSetup</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_name"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">ID_GET_PREVIOUS_CHOICE</property>
<property name="label">Get Stored Choice</property>
<property name="layer"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_buttonRetrieve</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnGetSetup</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_name"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">ID_RESET_CHOICE</property>
<property name="label">Reset</property>
<property name="layer"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_buttonReset</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnResetClick</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_name"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="layer"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticline1</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="resize">Resizable</property>
<property name="row"></property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxLI_HORIZONTAL</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_RIGHT|wxALL</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizerButtons</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick">OnCancelClick</event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick">OnOkClick</event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -0,0 +1,87 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 17 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_layers_select_to_pcb_base__
#define __dialog_layers_select_to_pcb_base__
#include <wx/intl.h>
#include <wx/sizer.h>
#include <wx/gdicmn.h>
#include <wx/statline.h>
#include <wx/string.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/statbox.h>
#include <wx/stattext.h>
#include <wx/combobox.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class LAYERS_MAP_DIALOG_BASE
///////////////////////////////////////////////////////////////////////////////
class LAYERS_MAP_DIALOG_BASE : public wxDialog
{
DECLARE_EVENT_TABLE()
private:
// Private event handlers
void _wxFB_OnBrdLayersCountSelection( wxCommandEvent& event ){ OnBrdLayersCountSelection( event ); }
void _wxFB_OnStoreSetup( wxCommandEvent& event ){ OnStoreSetup( event ); }
void _wxFB_OnGetSetup( wxCommandEvent& event ){ OnGetSetup( event ); }
void _wxFB_OnResetClick( wxCommandEvent& event ){ OnResetClick( event ); }
void _wxFB_OnCancelClick( wxCommandEvent& event ){ OnCancelClick( event ); }
void _wxFB_OnOkClick( wxCommandEvent& event ){ OnOkClick( event ); }
protected:
enum
{
ID_LAYERS_MAP_DIALOG_BASE = 1000,
ID_M_STATICLINESEP,
ID_M_STATICTEXTCOPPERLAYERCOUNT,
ID_M_COMBOCOPPERLAYERSCOUNT,
ID_STORE_CHOICE,
ID_GET_PREVIOUS_CHOICE,
ID_RESET_CHOICE,
};
wxStaticBoxSizer* sbSizerLayersTable;
wxFlexGridSizer* m_flexLeftColumnBoxSizer;
wxStaticLine* m_staticlineSep;
wxStaticText* m_staticTextCopperlayerCount;
wxComboBox* m_comboCopperLayersCount;
wxButton* m_buttonStore;
wxButton* m_buttonRetrieve;
wxButton* m_buttonReset;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizerButtons;
wxButton* m_sdbSizerButtonsOK;
wxButton* m_sdbSizerButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnBrdLayersCountSelection( wxCommandEvent& event ) { event.Skip(); }
virtual void OnStoreSetup( wxCommandEvent& event ) { event.Skip(); }
virtual void OnGetSetup( wxCommandEvent& event ) { event.Skip(); }
virtual void OnResetClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:
LAYERS_MAP_DIALOG_BASE( wxWindow* parent, wxWindowID id = ID_LAYERS_MAP_DIALOG_BASE, const wxString& title = _("Layer selection:"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 400,286 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~LAYERS_MAP_DIALOG_BASE();
};
#endif //__dialog_layers_select_to_pcb_base__

View File

@ -10,13 +10,50 @@
#include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "trigo.h"
#include "gerbview.h"
#include "class_board_design_settings.h"
#include "class_gerber_draw_item.h"
#include "select_layers_to_pcb.h"
/* A helper class to export a Gerber set of files to Pcbnew
*/
class GBR_TO_PCB_EXPORTER
{
GERBVIEW_FRAME* m_gerbview_frame; // the maint gerber frame
FILE * m_file; // .brd file to write to
BOARD* m_pcb; // the board to populate and export
public:
GBR_TO_PCB_EXPORTER(GERBVIEW_FRAME * aFrame, FILE * aFile );
~GBR_TO_PCB_EXPORTER();
bool ExportPcb( int* LayerLookUpTable );
BOARD* GetBoard() { return m_pcb; }
private:
bool WriteSetup( ); // Write the SETUP section data file
bool WriteGeneralDescrPcb( );
void export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
void export_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
void export_flashed_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
void export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
void export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer );
void cleanBoard();
};
GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME * aFrame, FILE * aFile )
{
m_gerbview_frame = aFrame;
m_file = aFile;
m_pcb = new BOARD( NULL, m_gerbview_frame );
}
GBR_TO_PCB_EXPORTER::~GBR_TO_PCB_EXPORTER()
{
delete m_pcb;
}
static int SavePcbFormatAscii( GERBVIEW_FRAME* frame,
FILE* File, int* LayerLookUpTable );
/* Export data in pcbnew format
@ -45,8 +82,6 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
wxString PcbExt( wxT( ".brd" ) );
FILE* dest;
msg = wxT( "*" ) + PcbExt;
FullFileName = EDA_FileSelector( _( "Board file name:" ),
wxEmptyString,
@ -60,151 +95,37 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event )
if( FullFileName == wxEmptyString )
return;
int* LayerLookUpTable;
if( ( LayerLookUpTable = InstallDialogLayerPairChoice( ) ) != NULL )
{
/* Install a dialog frame to choose the mapping
* between gerber layers and pcbnew layers
*/
LAYERS_MAP_DIALOG* dlg = new LAYERS_MAP_DIALOG( this );
int ok = dlg->ShowModal();
dlg->Destroy();
if( ok != wxID_OK )
return;
if( wxFileExists( FullFileName ) )
{
if( !IsOK( this, _( "Ok to change the existing file ?" ) ) )
return;
}
dest = wxFopen( FullFileName, wxT( "wt" ) );
if( dest == 0 )
FILE * file = wxFopen( FullFileName, wxT( "wt" ) );
if( file == NULL )
{
msg = _( "Unable to create " ) + FullFileName;
DisplayError( this, msg );
return;
}
GetScreen()->SetFileName( FullFileName );
SavePcbFormatAscii( this, dest, LayerLookUpTable );
fclose( dest );
}
GBR_TO_PCB_EXPORTER gbr_exporter( this, file );
gbr_exporter.ExportPcb( dlg->GetLayersLookUpTable() );
fclose( file );
}
static int WriteSetup( FILE* File, BOARD* Pcb )
void GBR_TO_PCB_EXPORTER::cleanBoard()
{
char text[1024];
fprintf( File, "$SETUP\n" );
sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
fprintf( File, "%s", text );
fprintf( File, "Layers %d\n", Pcb->GetCopperLayerCount() );
fprintf( File, "$EndSETUP\n\n" );
return 1;
}
static bool WriteGeneralDescrPcb( BOARD* Pcb, FILE* File )
{
int NbLayers;
/* Print the copper layer count */
NbLayers = Pcb->GetCopperLayerCount();
fprintf( File, "$GENERAL\n" );
fprintf( File, "LayerCount %d\n", NbLayers );
/* Compute and print the board bounding box */
Pcb->ComputeBoundingBox();
fprintf( File, "Di %d %d %d %d\n",
Pcb->m_BoundaryBox.GetX(), Pcb->m_BoundaryBox.GetY(),
Pcb->m_BoundaryBox.GetRight(),
Pcb->m_BoundaryBox.GetBottom() );
fprintf( File, "$EndGENERAL\n\n" );
return TRUE;
}
/* Routine to save the board
* @param frame = pointer to the main frame
* @param File = FILE * pointer to an already opened file
* @param LayerLookUpTable = look up table: pcbnew layer for each gerber layer
* @return 1 if OK, 0 if fail
*/
static int SavePcbFormatAscii( GERBVIEW_FRAME* frame, FILE* aFile,
int* LayerLookUpTable )
{
char line[256];
BOARD* gerberPcb = frame->GetBoard();
BOARD* pcb;
wxBeginBusyCursor();
// create an image of gerber data
pcb = new BOARD( NULL, frame );
BOARD_ITEM* item = gerberPcb->m_Drawings;
for( ; item; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
int layer = gerb_item->GetLayer();
int pcb_layer_number = LayerLookUpTable[layer];
if( pcb_layer_number < 0 || pcb_layer_number > LAST_NO_COPPER_LAYER )
continue;
if( pcb_layer_number > LAST_COPPER_LAYER )
{
DRAWSEGMENT* drawitem = new DRAWSEGMENT( pcb, TYPE_DRAWSEGMENT );
drawitem->SetLayer( pcb_layer_number );
drawitem->m_Start = gerb_item->m_Start;
drawitem->m_End = gerb_item->m_End;
drawitem->m_Width = gerb_item->m_Size.x;
if( gerb_item->m_Shape == GBR_ARC )
{
double cx = gerb_item->m_ArcCentre.x;
double cy = gerb_item->m_ArcCentre.y;
double a = atan2( gerb_item->m_Start.y - cy,
gerb_item->m_Start.x - cx );
double b = atan2( gerb_item->m_End.y - cy, gerb_item->m_End.x - cx );
drawitem->m_Shape = S_ARC;
drawitem->m_Angle = (int) fmod(
(a - b) / M_PI * 1800.0 + 3600.0, 3600.0 );
drawitem->m_Start.x = (int) cx;
drawitem->m_Start.y = (int) cy;
}
pcb->Add( drawitem );
}
else
{
TRACK* newtrack;
// replace spots with vias when possible
if( gerb_item->m_Shape == GBR_SPOT_CIRCLE
|| gerb_item->m_Shape == GBR_SPOT_RECT
|| gerb_item->m_Shape == GBR_SPOT_OVAL )
{
newtrack = new SEGVIA( pcb );
// A spot is found, and can be a via: change it to via, and
// delete other
// spots at same location
newtrack->m_Shape = VIA_THROUGH;
newtrack->SetLayer( 0x0F ); // Layers are 0 to 15 (Cu/Cmp)
newtrack->SetDrillDefault();
newtrack->m_Start = newtrack->m_End = gerb_item->m_Start;
newtrack->m_Width = (gerb_item->m_Size.x + gerb_item->m_Size.y) / 2;
}
else // a true TRACK
{
newtrack = new TRACK( pcb );
newtrack->SetLayer( pcb_layer_number );
newtrack->m_Start = gerb_item->m_Start;
newtrack->m_End = gerb_item->m_End;
newtrack->m_Width = gerb_item->m_Size.x;
}
pcb->Add( newtrack );
}
}
// delete redundant vias
for( TRACK * track = pcb->m_Track; track; track = track->Next() )
for( TRACK * track = m_pcb->m_Track; track; track = track->Next() )
{
if( track->m_Shape != VIA_THROUGH )
continue;
@ -226,24 +147,210 @@ static int SavePcbFormatAscii( GERBVIEW_FRAME* frame, FILE* aFile,
delete alt_track;
}
}
}
// Switch the locale to standard C (needed to print floating point numbers
// like 1.3)
bool GBR_TO_PCB_EXPORTER::WriteSetup( )
{
fprintf( m_file, "$SETUP\n" );
fprintf( m_file, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
fprintf( m_file, "Layers %d\n", m_pcb->GetCopperLayerCount() );
fprintf( m_file, "$EndSETUP\n\n" );
return true;
}
bool GBR_TO_PCB_EXPORTER::WriteGeneralDescrPcb( )
{
int nbLayers;
/* Print the copper layer count */
nbLayers = m_pcb->GetCopperLayerCount();
if( nbLayers <= 1 ) // Minimal layers count in Pcbnew is 2
{
nbLayers = 2;
m_pcb->SetCopperLayerCount(2);
}
fprintf( m_file, "$GENERAL\n" );
fprintf( m_file, "encoding utf-8\n");
fprintf( m_file, "LayerCount %d\n", nbLayers );
/* Compute and print the board bounding box */
m_pcb->ComputeBoundingBox();
fprintf( m_file, "Di %d %d %d %d\n",
m_pcb->m_BoundaryBox.GetX(), m_pcb->m_BoundaryBox.GetY(),
m_pcb->m_BoundaryBox.GetRight(),
m_pcb->m_BoundaryBox.GetBottom() );
fprintf( m_file, "$EndGENERAL\n\n" );
return true;
}
/* Routine to save the board
* @param frame = pointer to the main frame
* @param File = FILE * pointer to an already opened file
* @param LayerLookUpTable = look up table: pcbnew layer for each gerber layer
* @return 1 if OK, 0 if fail
*/
bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
{
char line[256];
BOARD* gerberPcb = m_gerbview_frame->GetBoard();
// create an image of gerber data
BOARD_ITEM* item = gerberPcb->m_Drawings;
for( ; item; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
int layer = gerb_item->GetLayer();
int pcb_layer_number = LayerLookUpTable[layer];
if( pcb_layer_number < 0 || pcb_layer_number > LAST_NO_COPPER_LAYER )
continue;
if( pcb_layer_number > LAST_COPPER_LAYER )
export_non_copper_item( gerb_item, pcb_layer_number );
else
export_copper_item( gerb_item, pcb_layer_number );
}
cleanBoard();
// Switch the locale to standard C (needed to print floating point numbers)
SetLocaleTo_C_standard();
// write the PCB heading
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
// write PCB header
fprintf( m_file, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
DateAndTime( line ) );
WriteGeneralDescrPcb( pcb, aFile );
WriteSetup( aFile, pcb );
WriteGeneralDescrPcb( );
WriteSetup( );
// write the useful part of the pcb
pcb->Save( aFile );
// the destructor should destroy all owned sub-objects
delete pcb;
// write items on file
m_pcb->Save( m_file );
SetLocaleTo_Default(); // revert to the current locale
wxEndBusyCursor();
return 1;
return true;
}
void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
{
DRAWSEGMENT* drawitem = new DRAWSEGMENT( m_pcb, TYPE_DRAWSEGMENT );
drawitem->SetLayer( aLayer );
drawitem->m_Start = aGbrItem->m_Start;
drawitem->m_End = aGbrItem->m_End;
drawitem->m_Width = aGbrItem->m_Size.x;
if( aGbrItem->m_Shape == GBR_ARC )
{
double a = atan2( (double)( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y),
(double)( aGbrItem->m_Start.x - aGbrItem->m_ArcCentre.x ) );
double b = atan2( (double)( aGbrItem->m_End.y - aGbrItem->m_ArcCentre.y ),
(double)( aGbrItem->m_End.x - aGbrItem->m_ArcCentre.x ) );
drawitem->m_Shape = S_ARC;
drawitem->m_Angle = wxRound( (a - b) / M_PI * 1800.0 );
drawitem->m_Start = aGbrItem->m_ArcCentre;
if( drawitem->m_Angle < 0 )
{
NEGATE( drawitem->m_Angle );
drawitem->m_End = aGbrItem->m_Start;
}
}
m_pcb->Add( drawitem );
}
void GBR_TO_PCB_EXPORTER::export_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
{
switch( aGbrItem->m_Shape )
{
case GBR_SPOT_CIRCLE:
case GBR_SPOT_RECT:
case GBR_SPOT_OVAL:
// replace spots with vias when possible
export_flashed_copper_item( aGbrItem, aLayer );
break;
case GBR_ARC:
// export_segarc_copper_item( aGbrItem, aLayer );
break;
default:
export_segline_copper_item( aGbrItem, aLayer );
break;
}
}
void GBR_TO_PCB_EXPORTER::export_segline_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
{
TRACK * newtrack = new TRACK( m_pcb );
newtrack->SetLayer( aLayer );
newtrack->m_Start = aGbrItem->m_Start;
newtrack->m_End = aGbrItem->m_End;
newtrack->m_Width = aGbrItem->m_Size.x;
m_pcb->Add( newtrack );
}
void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
{
double a = atan2( (double)( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y ),
(double)( aGbrItem->m_Start.x - aGbrItem->m_ArcCentre.x ) );
double b = atan2( (double)( aGbrItem->m_End.y - aGbrItem->m_ArcCentre.y ),
(double)( aGbrItem->m_End.x - aGbrItem->m_ArcCentre.x ) );
int arc_angle = wxRound( ( (a - b) / M_PI * 1800.0 ) );
wxPoint start = aGbrItem->m_Start;
wxPoint end = aGbrItem->m_End;
/* Because Pcbnew does not know arcs in tracks,
* approximate arc by segments (16 segment per 360 deg)
*/
#define DELTA 3600/16
if( arc_angle < 0 )
{
NEGATE( arc_angle );
EXCHG( start, end );
}
wxPoint curr_start = start;
for( int rot = DELTA; rot < (arc_angle - DELTA); rot += DELTA )
{
TRACK * newtrack = new TRACK( m_pcb );
newtrack->SetLayer( aLayer );
newtrack->m_Start = curr_start;
wxPoint curr_end = start;
RotatePoint( &curr_end, aGbrItem->m_ArcCentre, rot );
newtrack->m_End = curr_end;
newtrack->m_Width = aGbrItem->m_Size.x;
m_pcb->Add( newtrack );
curr_start = curr_end;
}
if( end != curr_start )
{
TRACK * newtrack = new TRACK( m_pcb );
newtrack->SetLayer( aLayer );
newtrack->m_Start = curr_start;
newtrack->m_End = end;
newtrack->m_Width = aGbrItem->m_Size.x;
m_pcb->Add( newtrack );
}
}
/*
* creates a via from a flashed gerber item.
* Flashed items are usually pads or vias, so we try to export all of them
* using vias
*/
void GBR_TO_PCB_EXPORTER::export_flashed_copper_item( GERBER_DRAW_ITEM* aGbrItem, int aLayer )
{
SEGVIA * newtrack = new SEGVIA( m_pcb );
newtrack->m_Shape = VIA_THROUGH;
newtrack->SetLayer( 0x0F ); // Layers are 0 to 15 (Cu/Cmp)
newtrack->SetDrillDefault();
newtrack->m_Start = newtrack->m_End = aGbrItem->m_Start;
newtrack->m_Width = (aGbrItem->m_Size.x + aGbrItem->m_Size.y) / 2;
m_pcb->Add( newtrack );
}

View File

@ -509,14 +509,6 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
virtual void PrintPage( wxDC* aDC, int aPrintMasklayer, bool aPrintMirrorMode,
void* aData = NULL );
/**
* Function InstallDialogLayerPairChoice
* Install a dialog frame to choose the equivalence
* between gerber layers and pcbnew layers
* @return the "lookup table" if ok, or NULL
*/
int* InstallDialogLayerPairChoice();
/**
* Function DrawItemsDCodeID
* Draw the DCode value (if exists) corresponding to gerber item

View File

@ -2,102 +2,64 @@
/* Dialog frame to choose gerber layers and pcb layers */
/*******************************************************/
/* select_layers_to_pcb.cpp */
/**
* @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
static int ButtonTable[32]; // Indexes buttons to Gerber layers
static int LayerLookUpTable[32]; // Indexes Gerber layers to PCB file layers
wxStaticText* layer_list[32]; // Indexes text strings to buttons
enum swap_layer_id {
ID_WINEDA_SWAPLAYERFRAME = 1800,
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
*/
class SWAP_LAYERS_DIALOG : public wxDialog
{
private:
GERBVIEW_FRAME* m_Parent;
wxBoxSizer* OuterBoxSizer;
wxBoxSizer* MainBoxSizer;
wxFlexGridSizer* FlexColumnBoxSizer;
wxStaticText* label;
wxButton* Button;
wxStaticText* text;
wxStaticLine* Line;
wxStdDialogButtonSizer* StdDialogButtonSizer;
public:
SWAP_LAYERS_DIALOG( GERBVIEW_FRAME* parent );
~SWAP_LAYERS_DIALOG() {};
private:
void OnSelectLayer( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE( SWAP_LAYERS_DIALOG, wxDialog )
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + 31,
BEGIN_EVENT_TABLE( LAYERS_MAP_DIALOG, LAYERS_MAP_DIALOG_BASE )
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + 31,
wxEVT_COMMAND_BUTTON_CLICKED,
SWAP_LAYERS_DIALOG::OnSelectLayer )
EVT_BUTTON( wxID_OK, SWAP_LAYERS_DIALOG::OnOkClick )
EVT_BUTTON( wxID_CANCEL, SWAP_LAYERS_DIALOG::OnCancelClick )
LAYERS_MAP_DIALOG::OnSelectLayer )
END_EVENT_TABLE()
/* Install a dialog frame to choose the equivalence
* between gerber layers and pcbnew layers
* return the "lookup table" if ok, or NULL
*/
int* GERBVIEW_FRAME::InstallDialogLayerPairChoice( )
LAYERS_MAP_DIALOG::LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent ) :
LAYERS_MAP_DIALOG_BASE( parent )
{
SWAP_LAYERS_DIALOG* frame = new SWAP_LAYERS_DIALOG( this );
m_Parent = parent;
initDialog();
int ii = frame->ShowModal();
frame->Destroy();
if( ii >= 0 )
return LayerLookUpTable;
else
return NULL;
// Resize the dialog
GetSizer()->SetSizeHints( this );
Centre();
}
SWAP_LAYERS_DIALOG::SWAP_LAYERS_DIALOG( GERBVIEW_FRAME* parent ) :
wxDialog( parent, -1, _( "Layer selection:" ), wxPoint( -1, -1 ),
wxDefaultSize, wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER )
void LAYERS_MAP_DIALOG::initDialog()
{
OuterBoxSizer = NULL;
MainBoxSizer = NULL;
FlexColumnBoxSizer = NULL;
label = NULL;
Button = NULL;
text = NULL;
Line = NULL;
StdDialogButtonSizer = NULL;
m_Parent = parent;
int item_ID, ii, nb_items;
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
@ -118,53 +80,58 @@ SWAP_LAYERS_DIALOG::SWAP_LAYERS_DIALOG( GERBVIEW_FRAME* parent ) :
// buttons should be some other size in that version.
// Compute a reasonable number of copper layers
int pcb_layer_number = 0;
for( ii = 0; ii < 32; ii++ )
m_exportBoardCopperLayersCount = 0;
for( int ii = 0; ii < 32; ii++ )
{
if( g_GERBER_List[ii] != NULL )
pcb_layer_number++;
m_exportBoardCopperLayersCount++;
// Specify the default value for each member of these arrays.
ButtonTable[ii] = -1;
LayerLookUpTable[ii] = LAYER_UNSELECTED;
m_buttonTable[ii] = -1;
m_layersLookUpTable[ii] = LAYER_UNSELECTED;
}
m_Parent->GetBoard()->SetCopperLayerCount(pcb_layer_number);
pcb_layer_number = 0;
for( nb_items = 0, ii = 0; ii < 32; ii++ )
// 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_number == m_Parent->GetBoard()->GetCopperLayerCount() - 1)
&& (m_Parent->GetBoard()->GetCopperLayerCount() > 1) )
pcb_layer_number = LAYER_N_FRONT;
if( (pcb_layer_num == m_exportBoardCopperLayersCount - 1)
&& (m_exportBoardCopperLayersCount > 1) )
pcb_layer_num = LAYER_N_FRONT;
ButtonTable[nb_items] = ii;
LayerLookUpTable[ii] = pcb_layer_number;
nb_items++;
pcb_layer_number++;
m_buttonTable[m_itemsCount] = ii;
m_layersLookUpTable[ii] = pcb_layer_num;
m_itemsCount++;
pcb_layer_num++;
}
OuterBoxSizer = new wxBoxSizer( wxVERTICAL );
SetSizer( OuterBoxSizer );
MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
for( ii = 0; ii < nb_items; ii++ )
if( m_itemsCount <= 16 ) // Only one list is enough
{
// If more than 16 Gerber layers are used, provide a vertical line to
// separate the two FlexGrid sizers
if( (nb_items > 16) && (ii == 16) )
m_staticlineSep->Hide();
}
else // Add the second list of gerber files
{
Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize,
wxLI_VERTICAL );
MainBoxSizer->Add( Line, 0, wxGROW | wxLEFT | wxRIGHT, 5 );
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 );
}
// Provide a separate FlexGrid sizer for every sixteen sets of controls
if( ii % 16 == 0 )
wxFlexGridSizer* flexColumnBoxSizer = m_flexLeftColumnBoxSizer;
for( int ii = 0; ii < m_itemsCount; ii++ )
{
// Each Gerber layer has an associated static text string (to
// identify that layer), a button (for invoking a child dialog
@ -191,50 +158,33 @@ SWAP_LAYERS_DIALOG::SWAP_LAYERS_DIALOG( GERBVIEW_FRAME* parent ) :
// is nb_items; otherwise, the number of rows is 16 (with two
// separate columns of controls being used if nb_items > 16).
if( nb_items < 16 )
FlexColumnBoxSizer = new wxFlexGridSizer( nb_items, 4, 0, 0 );
else
FlexColumnBoxSizer = new wxFlexGridSizer( 16, 4, 0, 0 );
// Specify that all of the rows can be expanded.
for( int jj = 0; jj < MIN( nb_items, 16 ); jj++ )
{
FlexColumnBoxSizer->AddGrowableRow( jj );
}
// Specify that (just) the right-hand column can be expanded.
FlexColumnBoxSizer->AddGrowableCol( 2 );
MainBoxSizer->Add( FlexColumnBoxSizer, 1, wxGROW | wxTOP, 5 );
}
if( ii == 16 )
flexColumnBoxSizer = m_flexRightColumnBoxSizer;
// Provide a text string to identify the Gerber layer
msg = _( "Layer " );
msg << ButtonTable[ii] + 1;
msg.Printf( _( "Layer %d" ), m_buttonTable[ii] + 1 );
label = new wxStaticText( this, wxID_STATIC, msg, wxDefaultPosition,
wxDefaultSize, wxALIGN_RIGHT );
FlexColumnBoxSizer->Add( label, 0,
flexColumnBoxSizer->Add( label, 0,
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL |
wxALL, 5 );
wxRIGHT | wxLEFT, 5 );
/* Add file name and extension without path. */
wxFileName fn( g_GERBER_List[ii]->m_FileName );
label = new wxStaticText( this, wxID_STATIC, fn.GetFullName(),
wxDefaultPosition, wxDefaultSize );
FlexColumnBoxSizer->Add( label, 0,
flexColumnBoxSizer->Add( label, 0,
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL |
wxALL, 5 );
wxRIGHT | wxLEFT, 5 );
// Provide a button for this layer (which will invoke a child dialog box)
item_ID = ID_BUTTON_0 + ii;
Button = new wxButton( this, item_ID, wxT( "..." ),
wxButton * Button = new wxButton( this, item_ID, wxT( "..." ),
wxDefaultPosition, wxSize( w, h ), 0 );
FlexColumnBoxSizer->Add( Button, 0,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
wxALL, 5 );
flexColumnBoxSizer->Add( Button, 0,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
// Provide another text string to specify which pcbnew layer that this
// Gerber layer is initially mapped to, and set the initial text to
@ -263,67 +213,119 @@ SWAP_LAYERS_DIALOG::SWAP_LAYERS_DIALOG( GERBVIEW_FRAME* parent ) :
goodSize.x = text->GetSize().x;
}
msg = BOARD::GetDefaultLayerName( LayerLookUpTable[ButtonTable[ii]] );
msg = BOARD::GetDefaultLayerName( m_layersLookUpTable[m_buttonTable[ii]] );
text->SetLabel( msg );
}
else
{
msg = BOARD::GetDefaultLayerName( LayerLookUpTable[ButtonTable[ii]] );
msg = BOARD::GetDefaultLayerName( m_layersLookUpTable[m_buttonTable[ii]] );
text = new wxStaticText( this, item_ID, msg, wxDefaultPosition,
wxDefaultSize, 0 );
}
text->SetMinSize( goodSize );
FlexColumnBoxSizer->Add( text, 1,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,
flexColumnBoxSizer->Add( text, 1,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT,
5 );
layer_list[ii] = text;
m_layersList[ii] = text;
}
}
// If required, provide spacers to occupy otherwise blank cells within the
// second FlexGrid sizer. (As it incorporates three columns, three spacers
// are thus required for each otherwise unused row.)
if( 16 < nb_items && nb_items < 32 )
/* Ensure m_exportBoardCopperLayersCount = 2 to NB_COPPER_LAYERS
* and it is an even value because Boards have always an even layer count
*/
void LAYERS_MAP_DIALOG::normalizeBrdLayersCount()
{
if( ( m_exportBoardCopperLayersCount & 1 ) )
m_exportBoardCopperLayersCount++;
if( m_exportBoardCopperLayersCount > NB_COPPER_LAYERS )
m_exportBoardCopperLayersCount = NB_COPPER_LAYERS;
if( m_exportBoardCopperLayersCount < 2 )
m_exportBoardCopperLayersCount = 2;
}
/*
* Called when user change the current board copper layers count
*/
void LAYERS_MAP_DIALOG::OnBrdLayersCountSelection( wxCommandEvent& event )
{
int id = event.GetSelection();
m_exportBoardCopperLayersCount = (id+1) * 2;
}
/*
* reset pcb layers selection to the default value
*/
void LAYERS_MAP_DIALOG::OnResetClick( wxCommandEvent& event )
{
wxString msg;
int ii, layer;
for( ii = 0, layer = 0; ii < m_itemsCount; ii++, layer++ )
{
for( ii = 4 * nb_items; ii < 96; ii++ )
{
FlexColumnBoxSizer->Add( 5, h, 0,
wxALIGN_CENTER_HORIZONTAL |
wxALIGN_CENTER_VERTICAL | wxLEFT |
wxRIGHT | wxBOTTOM, 5 );
}
}
// Provide a line to separate the controls which have been provided so far
// from the OK and Cancel buttons (which will be provided after this line)
Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize,
wxLI_HORIZONTAL );
OuterBoxSizer->Add( Line, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
// Provide a StdDialogButtonSizer to accommodate the OK and Cancel buttons;
// using that type of sizer results in those buttons being automatically
// located in positions appropriate for each (OS) version of KiCad.
StdDialogButtonSizer = new wxStdDialogButtonSizer;
OuterBoxSizer->Add( StdDialogButtonSizer, 0, wxGROW | wxALL, 10 );
Button = new wxButton( this, wxID_OK, _( "&OK" ), wxDefaultPosition,
wxDefaultSize, 0 );
StdDialogButtonSizer->AddButton( Button );
Button = new wxButton( this, wxID_CANCEL, _( "&Cancel" ),
wxDefaultPosition, wxDefaultSize, 0 );
StdDialogButtonSizer->AddButton( Button );
StdDialogButtonSizer->Realize();
// Resize the dialog
if( GetSizer() )
{
GetSizer()->SetSizeHints( this );
if( (layer == m_exportBoardCopperLayersCount - 1)
&& (m_exportBoardCopperLayersCount > 1) )
layer = LAYER_N_FRONT;
m_layersLookUpTable[ii] = layer;
msg = BOARD::GetDefaultLayerName( layer );
m_layersList[ii]->SetLabel( msg );
m_layersList[ii]->SetForegroundColour( wxNullColour );
m_buttonTable[ii] = ii;
}
}
void SWAP_LAYERS_DIALOG::OnSelectLayer( wxCommandEvent& event )
/* Stores the current mayers selection in config
*/
void LAYERS_MAP_DIALOG::OnStoreSetup( wxCommandEvent& event )
{
wxConfig* config = wxGetApp().m_EDA_Config;
config->Write( wxT("BrdLayersCount"), m_itemsCount );
wxString key;
for( int ii = 0; ii < 32; ii++ )
{
key.Printf( wxT("GbrLyr%dToPcb"), ii );
config->Write( key, m_layersLookUpTable[ii] );
}
}
void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
{
wxConfig* config = wxGetApp().m_EDA_Config;
config->Read( wxT("BrdLayersCount"), &m_exportBoardCopperLayersCount );
normalizeBrdLayersCount();
int idx = ( m_exportBoardCopperLayersCount / 2 ) - 1;
m_comboCopperLayersCount->SetSelection( idx );
wxString key;
for( int ii = 0; ii < 32; ii++ )
{
key.Printf( wxT("GbrLyr%dToPcb"), ii );
config->Read( key, &m_layersLookUpTable[ii] );
}
for( int ii = 0; ii < m_itemsCount; ii++ )
{
int layer = m_layersLookUpTable[ii];
if( layer == LAYER_UNSELECTED )
{
m_layersList[ii]->SetLabel( _( "Do not export" ) );
m_layersList[ii]->SetForegroundColour( *wxBLUE );
}
else
{
m_layersList[ii]->SetLabel( BOARD::GetDefaultLayerName( layer ) );
m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
}
}
}
void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event )
{
int ii, jj;
@ -334,71 +336,70 @@ void SWAP_LAYERS_DIALOG::OnSelectLayer( wxCommandEvent& event )
ii = event.GetId() - ID_BUTTON_0;
jj = LayerLookUpTable[ButtonTable[ii]];
jj = m_layersLookUpTable[m_buttonTable[ii]];
if( ( jj < 0 ) || ( jj > LAYER_UNSELECTED ) )
jj = 0; // (Defaults to "Copper" layer.)
jj = LAYER_N_BACK; // (Defaults to "Copper" layer.)
jj = m_Parent->SelectLayer( jj, -1, -1, true );
if( ( jj < 0 ) || ( jj > LAYER_UNSELECTED ) )
return;
if( jj != LayerLookUpTable[ButtonTable[ii]] )
if( jj != m_layersLookUpTable[m_buttonTable[ii]] )
{
LayerLookUpTable[ButtonTable[ii]] = jj;
m_layersLookUpTable[m_buttonTable[ii]] = jj;
if( jj == LAYER_UNSELECTED )
{
layer_list[ii]->SetLabel( _( "Do not export" ) );
m_layersList[ii]->SetLabel( _( "Do not export" ) );
// Change the text color to blue (to highlight
// that this layer is *not* being exported)
layer_list[ii]->SetForegroundColour( *wxBLUE );
m_layersList[ii]->SetForegroundColour( *wxBLUE );
}
else
{
layer_list[ii]->SetLabel( BOARD::GetDefaultLayerName( jj ) );
m_layersList[ii]->SetLabel( BOARD::GetDefaultLayerName( jj ) );
// Change the text color to fuchsia (to highlight
// that this layer *is* being exported)
layer_list[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
}
}
}
void SWAP_LAYERS_DIALOG::OnCancelClick( wxCommandEvent& event )
void LAYERS_MAP_DIALOG::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
EndModal( wxID_CANCEL );
}
void SWAP_LAYERS_DIALOG::OnOkClick( wxCommandEvent& event )
void LAYERS_MAP_DIALOG::OnOkClick( wxCommandEvent& event )
{
int ii;
bool AsCmpLayer = false;
/* Compute the number of copper layers
* this is the max layer number + 1 (if some internal layers exist)
/* Make some test about copper layers:
* Board must have enough copper layers to handle selected internal layers
*/
int layers_count = 1;
for( ii = 0; ii < 32; ii++ )
normalizeBrdLayersCount();
int inner_layer_max = 0;
for( int ii = 0; ii < 32; ii++ )
{
if( LayerLookUpTable[ii] == LAYER_N_FRONT )
AsCmpLayer = true;
else
if( m_layersLookUpTable[ii] < LAYER_N_FRONT )
{
if( LayerLookUpTable[ii] >= LAST_COPPER_LAYER )
continue; // not a copper layer
if( LayerLookUpTable[ii] >= layers_count )
layers_count++;
if( m_layersLookUpTable[ii ] > inner_layer_max )
inner_layer_max = m_layersLookUpTable[ii];
}
}
if( AsCmpLayer )
layers_count++;
if( layers_count > NB_COPPER_LAYERS ) // should not occur.
layers_count = NB_COPPER_LAYERS;
m_Parent->GetBoard()->SetCopperLayerCount( layers_count );
EndModal( 1 );
// inner_layer_max must be less than (or equal to) the number of
// internal copper layers
// internal copper layers = m_exportBoardCopperLayersCount-2
if( inner_layer_max > m_exportBoardCopperLayersCount-2 )
{
wxMessageBox(
_("The exported board has not enough copper layers to handle selected inner layers") );
return;
}
m_layersLookUpTable[32] = m_exportBoardCopperLayersCount;
EndModal( wxID_OK );
}

View File

@ -0,0 +1,57 @@
/*******************************************************/
/* Dialog frame to choose gerber layers and pcb layers */
/*******************************************************/
/**
* @file select_layers_to_pcb.h
*/
#ifndef _SELECT_LAYERS_TO_PCB_H_
#define _SELECT_LAYERS_TO_PCB_H_
#include "wx/statline.h"
#include "dialogs/dialog_layers_select_to_pcb_base.h"
#define LAYER_UNSELECTED NB_LAYERS
/*
* 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
*/
class LAYERS_MAP_DIALOG : public LAYERS_MAP_DIALOG_BASE
{
private:
GERBVIEW_FRAME* m_Parent;
int m_itemsCount;
int m_exportBoardCopperLayersCount;
wxFlexGridSizer* m_flexRightColumnBoxSizer; // An extra wxFlexGridSizer used
// when we have more than 16 gerber files loaded
int m_layersLookUpTable[32+1]; // Indexes Gerber layers to PCB file layers
// the last value in table is the number of copper layers
int m_buttonTable[32]; // Indexes buttons to Gerber layers
wxStaticText* m_layersList[32]; // Indexes text strings to buttons
public: LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent );
~LAYERS_MAP_DIALOG() {};
int * GetLayersLookUpTable() { return m_layersLookUpTable; }
int GetCopperLayersCount() { return m_exportBoardCopperLayersCount; }
private:
void initDialog();
void normalizeBrdLayersCount();
void OnBrdLayersCountSelection( wxCommandEvent& event );
void OnSelectLayer( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnStoreSetup( wxCommandEvent& event );
void OnGetSetup( wxCommandEvent& event );
void OnResetClick( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
};
#endif // _SELECT_LAYERS_TO_PCB_H_

View File

@ -17,7 +17,7 @@
; General Product Description Definitions
!define PRODUCT_NAME "KiCad"
!define PRODUCT_VERSION "2011.04.17"
!define PRODUCT_VERSION "2011.04.24"
!define PRODUCT_WEB_SITE "http://iut-tice.ujf-grenoble.fr/kicad/"
!define SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/"
!define COMPANY_NAME ""

View File

@ -1,14 +1,12 @@
/* Set up the basic primitives for Layer control */
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "pcbnew.h"
#include "class_board_design_settings.h"
#include "protos.h"
enum layer_sel_id {
@ -18,7 +16,7 @@ enum layer_sel_id {
};
class WinEDA_SelLayerFrame : public wxDialog
class SELECT_LAYER_DIALOG : public wxDialog
{
private:
PCB_BASE_FRAME* m_Parent;
@ -28,9 +26,9 @@ private:
public:
// Constructor and destructor
WinEDA_SelLayerFrame( PCB_BASE_FRAME* parent, int default_layer,
SELECT_LAYER_DIALOG( PCB_BASE_FRAME* parent, int default_layer,
int min_layer, int max_layer, bool null_layer );
~WinEDA_SelLayerFrame() { };
~SELECT_LAYER_DIALOG() { };
private:
void Sel_Layer( wxCommandEvent& event );
@ -40,10 +38,10 @@ private:
};
BEGIN_EVENT_TABLE( WinEDA_SelLayerFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_SelLayerFrame::Sel_Layer )
EVT_BUTTON( wxID_CANCEL, WinEDA_SelLayerFrame::OnCancelClick )
EVT_RADIOBOX( ID_LAYER_SELECT, WinEDA_SelLayerFrame::Sel_Layer )
BEGIN_EVENT_TABLE( SELECT_LAYER_DIALOG, wxDialog )
EVT_BUTTON( wxID_OK, SELECT_LAYER_DIALOG::Sel_Layer )
EVT_BUTTON( wxID_CANCEL, SELECT_LAYER_DIALOG::OnCancelClick )
EVT_RADIOBOX( ID_LAYER_SELECT, SELECT_LAYER_DIALOG::Sel_Layer )
END_EVENT_TABLE()
@ -70,7 +68,7 @@ int PCB_BASE_FRAME::SelectLayer( int default_layer,
bool null_layer )
{
int layer;
WinEDA_SelLayerFrame* frame = new WinEDA_SelLayerFrame( this,
SELECT_LAYER_DIALOG* frame = new SELECT_LAYER_DIALOG( this,
default_layer,
min_layer,
max_layer,
@ -88,7 +86,7 @@ int PCB_BASE_FRAME::SelectLayer( int default_layer,
* radiobuttons, in which case they are positioned (in a vertical line)
* to the right of that radiobox.
*/
WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( PCB_BASE_FRAME* parent,
SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( PCB_BASE_FRAME* parent,
int default_layer, int min_layer,
int max_layer, bool null_layer ) :
wxDialog( parent, -1, _( "Select Layer:" ), wxPoint( -1, -1 ),
@ -165,14 +163,11 @@ WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( PCB_BASE_FRAME* parent,
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
ButtonBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
if( GetSizer() )
{
GetSizer()->SetSizeHints( this );
}
}
void WinEDA_SelLayerFrame::Sel_Layer( wxCommandEvent& event )
void SELECT_LAYER_DIALOG::Sel_Layer( wxCommandEvent& event )
{
int ii = m_LayerId[m_LayerList->GetSelection()];
@ -180,7 +175,7 @@ void WinEDA_SelLayerFrame::Sel_Layer( wxCommandEvent& event )
}
void WinEDA_SelLayerFrame::OnCancelClick( wxCommandEvent& event )
void SELECT_LAYER_DIALOG::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
}
@ -190,7 +185,7 @@ void WinEDA_SelLayerFrame::OnCancelClick( wxCommandEvent& event )
/* Dialog for the selecting pairs of layers. */
/*********************************************/
class WinEDA_SelLayerPairFrame : public wxDialog
class SELECT_LAYERS_PAIR_DIALOG : public wxDialog
{
private:
PCB_BASE_FRAME* m_Parent;
@ -198,8 +193,8 @@ private:
wxRadioBox* m_LayerListBOTTOM;
int m_LayerId[NB_COPPER_LAYERS];
public: WinEDA_SelLayerPairFrame( PCB_BASE_FRAME* parent );
~WinEDA_SelLayerPairFrame() { };
public: SELECT_LAYERS_PAIR_DIALOG( PCB_BASE_FRAME* parent );
~SELECT_LAYERS_PAIR_DIALOG() { };
private:
void OnOkClick( wxCommandEvent& event );
@ -209,9 +204,9 @@ private:
};
BEGIN_EVENT_TABLE( WinEDA_SelLayerPairFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_SelLayerPairFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_SelLayerPairFrame::OnCancelClick )
BEGIN_EVENT_TABLE( SELECT_LAYERS_PAIR_DIALOG, wxDialog )
EVT_BUTTON( wxID_OK, SELECT_LAYERS_PAIR_DIALOG::OnOkClick )
EVT_BUTTON( wxID_CANCEL, SELECT_LAYERS_PAIR_DIALOG::OnCancelClick )
END_EVENT_TABLE()
@ -232,8 +227,8 @@ void PCB_BASE_FRAME::SelectLayerPair()
return;
}
WinEDA_SelLayerPairFrame* frame =
new WinEDA_SelLayerPairFrame( this );
SELECT_LAYERS_PAIR_DIALOG* frame =
new SELECT_LAYERS_PAIR_DIALOG( this );
int result = frame->ShowModal();
frame->Destroy();
@ -248,7 +243,7 @@ void PCB_BASE_FRAME::SelectLayerPair()
}
WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame( PCB_BASE_FRAME* parent ) :
SELECT_LAYERS_PAIR_DIALOG::SELECT_LAYERS_PAIR_DIALOG( PCB_BASE_FRAME* parent ) :
wxDialog( parent, -1, _( "Select Layer Pair:" ), wxPoint( -1, -1 ),
wxSize( 470, 250 ), DIALOG_STYLE )
{
@ -325,7 +320,7 @@ WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame( PCB_BASE_FRAME* parent ) :
}
void WinEDA_SelLayerPairFrame::OnOkClick( wxCommandEvent& event )
void SELECT_LAYERS_PAIR_DIALOG::OnOkClick( wxCommandEvent& event )
{
// select the same layer for top and bottom is allowed (normal in some
// boards)
@ -343,7 +338,7 @@ void WinEDA_SelLayerPairFrame::OnOkClick( wxCommandEvent& event )
}
void WinEDA_SelLayerPairFrame::OnCancelClick( wxCommandEvent& event )
void SELECT_LAYERS_PAIR_DIALOG::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
}

View File

@ -1,4 +1,4 @@
release version:
2011 apr 17
2011 apr 24
files (.zip,.tgz):
kicad-2011-04-17
kicad-2011-04-24