Commit 81947a4f authored by jean-pierre charras's avatar jean-pierre charras

Gerbview: export_to_pcbnew enhancements.

parent a7a4dab4
......@@ -10,6 +10,9 @@
///////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE( LAYERS_TABLE_DIALOG_BASE, wxDialog )
EVT_BUTTON( ID_STORE_CHOICE, LAYERS_TABLE_DIALOG_BASE::_wxFB_OnStoreSetup )
EVT_BUTTON( ID_GET_PREVIOUS_CHOICE, LAYERS_TABLE_DIALOG_BASE::_wxFB_OnGetSetup )
EVT_BUTTON( ID_RESET_CHOICE, LAYERS_TABLE_DIALOG_BASE::_wxFB_OnResetClick )
EVT_BUTTON( wxID_CANCEL, LAYERS_TABLE_DIALOG_BASE::_wxFB_OnCancelClick )
EVT_BUTTON( wxID_OK, LAYERS_TABLE_DIALOG_BASE::_wxFB_OnOkClick )
END_EVENT_TABLE()
......@@ -54,12 +57,15 @@ LAYERS_TABLE_DIALOG_BASE::LAYERS_TABLE_DIALOG_BASE( wxWindow* parent, wxWindowID
wxBoxSizer* bSizerButtons;
bSizerButtons = new wxBoxSizer( wxVERTICAL );
m_buttonStore = new wxButton( this, wxID_ANY, _("Store Choice"), wxDefaultPosition, wxDefaultSize, 0 );
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, wxID_ANY, _("Get Stored Choice"), wxDefaultPosition, wxDefaultSize, 0 );
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 );
sbUpperSizer->Add( bSizerButtons, 0, wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain->Add( sbUpperSizer, 1, wxEXPAND, 5 );
......
......@@ -291,7 +291,7 @@
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="id">ID_STORE_CHOICE</property>
<property name="label">Store Choice</property>
<property name="layer"></property>
<property name="maximize_button">0</property>
......@@ -322,7 +322,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick"></event>
<event name="OnButtonClick">OnStoreSetup</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
......@@ -376,7 +376,7 @@
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</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>
......@@ -407,7 +407,92 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick"></event>
<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>
......
......@@ -32,6 +32,9 @@ class LAYERS_TABLE_DIALOG_BASE : public wxDialog
private:
// Private event handlers
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 ); }
......@@ -40,6 +43,9 @@ class LAYERS_TABLE_DIALOG_BASE : public wxDialog
enum
{
ID_M_STATICLINESEP = 1000,
ID_STORE_CHOICE,
ID_GET_PREVIOUS_CHOICE,
ID_RESET_CHOICE,
};
wxStaticBoxSizer* sbSizerLayersTable;
......@@ -48,12 +54,16 @@ class LAYERS_TABLE_DIALOG_BASE : public wxDialog
wxFlexGridSizer* m_flexRightColumnBoxSizer;
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 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(); }
......
......@@ -8,6 +8,7 @@
#include "fctsys.h"
#include "common.h"
#include "appl_wxstruct.h"
#include "gerbview.h"
#include "class_board_design_settings.h"
#include "class_GERBER.h"
......@@ -17,12 +18,12 @@
#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
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_TABLE_DIALOG = 1800,
ID_BUTTON_0,
ID_TEXT_0 = ID_BUTTON_0 + 32
};
......@@ -31,29 +32,30 @@ enum swap_layer_id {
class LAYERS_TABLE_DIALOG : public LAYERS_TABLE_DIALOG_BASE
{
private:
GERBVIEW_FRAME* m_Parent;
wxStaticText* label;
wxButton* Button;
wxStaticText* text;
GERBVIEW_FRAME* m_Parent;
int m_itemsCount;
public:
LAYERS_TABLE_DIALOG( GERBVIEW_FRAME* parent );
public: LAYERS_TABLE_DIALOG( GERBVIEW_FRAME* parent );
~LAYERS_TABLE_DIALOG() {};
private:
void initDialog();
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()
};
BEGIN_EVENT_TABLE( LAYERS_TABLE_DIALOG, wxDialog )
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + 31,
wxEVT_COMMAND_BUTTON_CLICKED,
LAYERS_TABLE_DIALOG::OnSelectLayer )
BEGIN_EVENT_TABLE( LAYERS_TABLE_DIALOG, LAYERS_TABLE_DIALOG_BASE )
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + 31,
wxEVT_COMMAND_BUTTON_CLICKED,
LAYERS_TABLE_DIALOG::OnSelectLayer )
END_EVENT_TABLE()
......@@ -61,8 +63,7 @@ END_EVENT_TABLE()
* between gerber layers and pcbnew layers
* return the "lookup table" if ok, or NULL
*/
int* GERBVIEW_FRAME::InstallDialogLayerPairChoice( )
{
int* GERBVIEW_FRAME::InstallDialogLayerPairChoice() {
LAYERS_TABLE_DIALOG* frame = new LAYERS_TABLE_DIALOG( this );
int ii = frame->ShowModal();
......@@ -78,15 +79,22 @@ int* GERBVIEW_FRAME::InstallDialogLayerPairChoice( )
LAYERS_TABLE_DIALOG::LAYERS_TABLE_DIALOG( GERBVIEW_FRAME* parent ) :
LAYERS_TABLE_DIALOG_BASE( parent )
{
label = NULL;
Button = NULL;
text = NULL;
m_Parent = parent;
initDialog();
int item_ID, ii, nb_items;
wxString msg;
wxSize goodSize;
// Resize the dialog
GetSizer()->SetSizeHints( this );
Centre();
}
void LAYERS_TABLE_DIALOG::initDialog()
{
wxStaticText* label;
wxStaticText* text;
int item_ID, ii;
wxString msg;
wxSize goodSize;
// 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
......@@ -124,10 +132,11 @@ LAYERS_TABLE_DIALOG::LAYERS_TABLE_DIALOG( GERBVIEW_FRAME* parent ) :
pcb_copper_layer_count = 2;
if( pcb_copper_layer_count > NB_COPPER_LAYERS )
pcb_copper_layer_count = NB_COPPER_LAYERS;
m_Parent->GetBoard()->SetCopperLayerCount(pcb_copper_layer_count);
m_Parent->GetBoard()->SetCopperLayerCount( pcb_copper_layer_count );
int pcb_layer_num = 0;
for( nb_items = 0, ii = 0; ii < 32; ii++ )
m_itemsCount = 0;
for( ii = 0; ii < 32; ii++ )
{
if( g_GERBER_List[ii] == NULL )
continue;
......@@ -136,17 +145,19 @@ LAYERS_TABLE_DIALOG::LAYERS_TABLE_DIALOG( GERBVIEW_FRAME* parent ) :
&& (m_Parent->GetBoard()->GetCopperLayerCount() > 1) )
pcb_layer_num = LAYER_N_FRONT;
ButtonTable[nb_items] = ii;
ButtonTable[m_itemsCount] = ii;
LayerLookUpTable[ii] = pcb_layer_num;
nb_items++;
m_itemsCount++;
pcb_layer_num++;
}
if( nb_items <= 16 )
if( m_itemsCount <= 16 ) // Only one list is enough
{
m_staticlineSep->Hide();
}
wxFlexGridSizer* flexColumnBoxSizer = m_flexLeftColumnBoxSizer;
for( ii = 0; ii < nb_items; ii++ )
for( 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
......@@ -183,7 +194,7 @@ LAYERS_TABLE_DIALOG::LAYERS_TABLE_DIALOG( GERBVIEW_FRAME* parent ) :
wxDefaultSize, wxALIGN_RIGHT );
flexColumnBoxSizer->Add( label, 0,
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL |
wxRIGHT|wxLEFT, 5 );
wxRIGHT | wxLEFT, 5 );
/* Add file name and extension without path. */
wxFileName fn( g_GERBER_List[ii]->m_FileName );
......@@ -191,17 +202,15 @@ LAYERS_TABLE_DIALOG::LAYERS_TABLE_DIALOG( GERBVIEW_FRAME* parent ) :
wxDefaultPosition, wxDefaultSize );
flexColumnBoxSizer->Add( label, 0,
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL |
wxRIGHT|wxLEFT, 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( "..." ),
wxDefaultPosition, wxSize( w, h ), 0 );
wxButton * Button = new wxButton( this, item_ID, wxT( "..." ),
wxDefaultPosition, wxSize( w, h ), 0 );
flexColumnBoxSizer->Add( Button, 0,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
wxRIGHT|wxLEFT, 5 );
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
......@@ -218,7 +227,7 @@ LAYERS_TABLE_DIALOG::LAYERS_TABLE_DIALOG( GERBVIEW_FRAME* parent ) :
// layers are selected.)
if( ii == 0 )
{
msg = _( "Do not export" );
msg = _( "Do not export" );
text = new wxStaticText( this, item_ID, msg, wxDefaultPosition,
wxDefaultSize, 0 );
goodSize = text->GetSize();
......@@ -241,18 +250,86 @@ LAYERS_TABLE_DIALOG::LAYERS_TABLE_DIALOG( GERBVIEW_FRAME* parent ) :
}
text->SetMinSize( goodSize );
flexColumnBoxSizer->Add( text, 1,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxRIGHT| wxLEFT,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT,
5 );
layer_list[ii] = text;
}
}
// Resize the dialog
GetSizer()->SetSizeHints( this );
Centre();
/*
* reset pcb layers selection to the default value
*/
void LAYERS_TABLE_DIALOG::OnResetClick( wxCommandEvent& event )
{
wxString msg;
int ii, layer;
for( ii = 0, layer = 0; ii < m_itemsCount; ii++, layer++ )
{
if( (layer == m_Parent->GetBoard()->GetCopperLayerCount() - 1)
&& (m_Parent->GetBoard()->GetCopperLayerCount() > 1) )
layer = LAYER_N_FRONT;
LayerLookUpTable[ii] = layer;
msg = BOARD::GetDefaultLayerName( layer );
layer_list[ii]->SetLabel( msg );
layer_list[ii]->SetForegroundColour( wxNullColour );
ButtonTable[ii] = ii;
}
}
/* Stores the current mayers selection in config
*/
void LAYERS_TABLE_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, LayerLookUpTable[ii] );
}
}
void LAYERS_TABLE_DIALOG::OnGetSetup( wxCommandEvent& event )
{
wxConfig* config = wxGetApp().m_EDA_Config;
int lyrcnt = 0;
config->Read( wxT("BrdLayersCount"), &lyrcnt );
if( lyrcnt == 0 || lyrcnt != m_itemsCount )
{
wxString msg;
msg.Printf( _("Previous stored setup as %d layers, and there are %d loaded layers"),
lyrcnt, m_itemsCount );
wxMessageBox( msg );
return;
}
wxString key;
for( int ii = 0; ii < 32; ii++ )
{
key.Printf( wxT("GbrLyr%dToPcb"), ii );
config->Read( key, &LayerLookUpTable[ii] );
}
for( int ii = 0; ii < m_itemsCount; ii++ )
{
int layer = LayerLookUpTable[ii];
if( layer == LAYER_UNSELECTED )
{
layer_list[ii]->SetLabel( _( "Do not export" ) );
layer_list[ii]->SetForegroundColour( *wxBLUE );
}
else
{
layer_list[ii]->SetLabel( BOARD::GetDefaultLayerName( layer ) );
layer_list[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
}
}
}
void LAYERS_TABLE_DIALOG::OnSelectLayer( wxCommandEvent& event )
{
int ii, jj;
......@@ -266,7 +343,7 @@ void LAYERS_TABLE_DIALOG::OnSelectLayer( wxCommandEvent& event )
jj = LayerLookUpTable[ButtonTable[ii]];
if( ( jj < 0 ) || ( jj > LAYER_UNSELECTED ) )
jj = 0; // (Defaults to "Copper" layer.)
jj = 0; // (Defaults to "Copper" layer.)
jj = m_Parent->SelectLayer( jj, -1, -1, true );
if( ( jj < 0 ) || ( jj > LAYER_UNSELECTED ) )
......@@ -310,6 +387,7 @@ void LAYERS_TABLE_DIALOG::OnOkClick( wxCommandEvent& event )
* this is the max layer number + 1 (if some internal layers exist)
*/
int layers_count = 1;
for( ii = 0; ii < 32; ii++ )
{
if( LayerLookUpTable[ii] == LAYER_N_FRONT )
......@@ -317,7 +395,7 @@ void LAYERS_TABLE_DIALOG::OnOkClick( wxCommandEvent& event )
else
{
if( LayerLookUpTable[ii] >= LAST_COPPER_LAYER )
continue; // not a copper layer
continue; // not a copper layer
if( LayerLookUpTable[ii] >= layers_count )
layers_count++;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment