2011-04-23 19:01:41 +00:00
|
|
|
/**
|
2012-12-18 13:54:44 +00:00
|
|
|
* @file select_layers_to_pcb.cpp
|
2012-05-04 17:44:42 +00:00
|
|
|
* @brief Dialog to choose equivalence between gerber layers and pcb layers
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-09-12 17:28:55 +00:00
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
|
2012-05-04 17:44:42 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2011-04-23 19:01:41 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
//#include <pgm_base.h>
|
|
|
|
#include <kiface_i.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview.h>
|
|
|
|
#include <gerbview_id.h>
|
|
|
|
#include <class_GERBER.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <select_layers_to_pcb.h>
|
2011-04-23 19:01:41 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
// Imported function
|
2013-03-31 13:27:46 +00:00
|
|
|
extern const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
enum swap_layer_id {
|
2011-04-26 08:30:16 +00:00
|
|
|
ID_LAYERS_MAP_DIALOG = ID_GERBER_END_LIST,
|
2007-11-02 05:33:31 +00:00
|
|
|
ID_BUTTON_0,
|
2013-03-31 13:27:46 +00:00
|
|
|
ID_TEXT_0 = ID_BUTTON_0 + NB_GERBER_LAYERS
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2012-12-18 13:54:44 +00:00
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-12-18 13:54:44 +00:00
|
|
|
int LAYERS_MAP_DIALOG::m_exportBoardCopperLayersCount = 2;
|
|
|
|
|
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
BEGIN_EVENT_TABLE( LAYERS_MAP_DIALOG, LAYERS_MAP_DIALOG_BASE )
|
2013-03-31 13:27:46 +00:00
|
|
|
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + NB_GERBER_LAYERS-1,
|
2012-12-18 13:54:44 +00:00
|
|
|
wxEVT_COMMAND_BUTTON_CLICKED,
|
|
|
|
LAYERS_MAP_DIALOG::OnSelectLayer )
|
2007-06-05 12:10:51 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
LAYERS_MAP_DIALOG::LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent ) :
|
|
|
|
LAYERS_MAP_DIALOG_BASE( parent )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-11-02 05:33:31 +00:00
|
|
|
m_Parent = parent;
|
2011-04-24 18:26:42 +00:00
|
|
|
initDialog();
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2011-04-24 18:26:42 +00:00
|
|
|
// Resize the dialog
|
2011-04-26 11:07:37 +00:00
|
|
|
Layout();
|
2011-04-24 18:26:42 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
void LAYERS_MAP_DIALOG::initDialog()
|
2011-04-24 18:26:42 +00:00
|
|
|
{
|
|
|
|
wxStaticText* label;
|
|
|
|
wxStaticText* text;
|
2011-04-26 08:30:16 +00:00
|
|
|
int item_ID;
|
2011-04-24 18:26:42 +00:00
|
|
|
wxString msg;
|
|
|
|
wxSize goodSize;
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
m_flexRightColumnBoxSizer = NULL;
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
// Experimentation has shown that buttons in the Windows version can be 20
|
|
|
|
// pixels wide and 20 pixels high, but that they need to be 26 pixels wide
|
|
|
|
// and 26 pixels high in the Linux version. (And although the dimensions
|
|
|
|
// of those buttons could be set to 26 pixels wide and 26 pixels high in
|
|
|
|
// both of those versions, that would result in a dialog box which would
|
|
|
|
// be excessively high in the Windows version.)
|
2007-11-02 05:33:31 +00:00
|
|
|
#ifdef __WINDOWS__
|
|
|
|
int w = 20;
|
|
|
|
int h = 20;
|
|
|
|
#else
|
|
|
|
int w = 26;
|
|
|
|
int h = 26;
|
|
|
|
#endif
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
// As currently implemented, the dimensions of the buttons in the Mac
|
|
|
|
// version are also 26 pixels wide and 26 pixels high. If appropriate,
|
|
|
|
// the above code should be modified as required in the event that those
|
|
|
|
// buttons should be some other size in that version.
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
|
|
|
// Specify the default value for each member of these arrays.
|
2011-04-26 08:30:16 +00:00
|
|
|
m_buttonTable[ii] = -1;
|
2013-03-31 13:27:46 +00:00
|
|
|
m_layersLookUpTable[ii] = UNSELECTED_LAYER;
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
// Ensure we have:
|
2012-05-04 17:44:42 +00:00
|
|
|
// at least 2 copper layers and BOARD_COPPER_LAYERS_MAX_COUNT copper layers max
|
2011-11-24 19:57:41 +00:00
|
|
|
// and even layers count because a board *must* have even layers count
|
2012-05-04 17:44:42 +00:00
|
|
|
// and maxi BOARD_COPPER_LAYERS_MAX_COUNT copper layers count
|
2011-04-26 08:30:16 +00:00
|
|
|
normalizeBrdLayersCount();
|
|
|
|
|
|
|
|
int idx = ( m_exportBoardCopperLayersCount / 2 ) - 1;
|
|
|
|
m_comboCopperLayersCount->SetSelection( idx );
|
2011-04-23 19:01:41 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM pcb_layer_num = FIRST_LAYER;
|
2011-04-24 18:26:42 +00:00
|
|
|
m_itemsCount = 0;
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2008-11-08 06:44:07 +00:00
|
|
|
if( g_GERBER_List[ii] == NULL )
|
2007-11-02 05:33:31 +00:00
|
|
|
continue;
|
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
if( (pcb_layer_num == m_exportBoardCopperLayersCount - 1)
|
|
|
|
&& (m_exportBoardCopperLayersCount > 1) )
|
2014-06-24 16:17:18 +00:00
|
|
|
pcb_layer_num = F_Cu;
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
m_buttonTable[m_itemsCount] = ii;
|
|
|
|
m_layersLookUpTable[ii] = pcb_layer_num;
|
2011-04-24 18:26:42 +00:00
|
|
|
m_itemsCount++;
|
2013-03-31 13:27:46 +00:00
|
|
|
++pcb_layer_num;
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
if( m_itemsCount <= NB_GERBER_LAYERS/2 ) // Only one list is enough
|
2011-04-24 18:26:42 +00:00
|
|
|
{
|
2011-04-23 19:01:41 +00:00
|
|
|
m_staticlineSep->Hide();
|
2011-04-24 18:26:42 +00:00
|
|
|
}
|
2011-04-26 08:30:16 +00:00
|
|
|
else // Add the second list of gerber files
|
|
|
|
{
|
|
|
|
m_flexRightColumnBoxSizer = new wxFlexGridSizer( 16, 4, 0, 0 );
|
|
|
|
for( int ii = 0; ii < 4; ii++ )
|
|
|
|
m_flexRightColumnBoxSizer->AddGrowableCol( ii );
|
|
|
|
m_flexRightColumnBoxSizer->SetFlexibleDirection( wxBOTH );
|
|
|
|
m_flexRightColumnBoxSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
2011-04-26 11:07:37 +00:00
|
|
|
sbSizerLayersTable->Add( m_flexRightColumnBoxSizer, 1, wxEXPAND, 5 );
|
2011-04-26 08:30:16 +00:00
|
|
|
}
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2011-04-23 19:01:41 +00:00
|
|
|
wxFlexGridSizer* flexColumnBoxSizer = m_flexLeftColumnBoxSizer;
|
2011-04-26 08:30:16 +00:00
|
|
|
for( int ii = 0; ii < m_itemsCount; ii++ )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2011-04-23 19:01:41 +00:00
|
|
|
// Each Gerber layer has an associated static text string (to
|
|
|
|
// identify that layer), a button (for invoking a child dialog
|
2011-09-30 18:15:37 +00:00
|
|
|
// box to change which Pcbnew layer that the Gerber layer is
|
2011-04-23 19:01:41 +00:00
|
|
|
// mapped to), and a second static text string (to depict which
|
2011-09-30 18:15:37 +00:00
|
|
|
// Pcbnew layer that the Gerber layer has been mapped to). Each
|
2011-04-23 19:01:41 +00:00
|
|
|
// of those items are placed into the left hand column, middle
|
|
|
|
// column, and right hand column (respectively) of the Flexgrid
|
|
|
|
// sizer, and the color of the second text string is set to
|
|
|
|
// fuchsia or blue (to respectively indicate whether the Gerber
|
2011-09-30 18:15:37 +00:00
|
|
|
// layer has been mapped to a Pcbnew layer or is not being
|
2011-04-23 19:01:41 +00:00
|
|
|
// exported at all). (Experimentation has shown that if a text
|
2011-09-30 18:15:37 +00:00
|
|
|
// control is used to depict which Pcbnew layer that each Gerber
|
2011-04-23 19:01:41 +00:00
|
|
|
// layer is mapped to (instead of a static text string), then
|
|
|
|
// those controls do not behave in a fully satisfactory manner
|
|
|
|
// in the Linux version. Even when the read-only attribute is
|
|
|
|
// specified for all of those controls, they can still be selected
|
|
|
|
// when the arrow keys or Tab key is used to step through all of
|
|
|
|
// the controls within the dialog box, and directives to set the
|
|
|
|
// foreground color of the text of each such control to blue (to
|
|
|
|
// indicate that the text is of a read-only nature) are disregarded.
|
|
|
|
// Specify a FlexGrid sizer with an appropriate number of rows
|
|
|
|
// and three columns. If nb_items < 16, then the number of rows
|
|
|
|
// is nb_items; otherwise, the number of rows is 16 (with two
|
|
|
|
// separate columns of controls being used if nb_items > 16).
|
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
if( ii == NB_GERBER_LAYERS/2 )
|
2011-04-23 19:01:41 +00:00
|
|
|
flexColumnBoxSizer = m_flexRightColumnBoxSizer;
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
// Provide a text string to identify the Gerber layer
|
2011-04-26 08:30:16 +00:00
|
|
|
msg.Printf( _( "Layer %d" ), m_buttonTable[ii] + 1 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
label = new wxStaticText( this, wxID_STATIC, msg, wxDefaultPosition,
|
|
|
|
wxDefaultSize, wxALIGN_RIGHT );
|
2011-04-23 19:01:41 +00:00
|
|
|
flexColumnBoxSizer->Add( label, 0,
|
2009-04-29 17:09:00 +00:00
|
|
|
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL |
|
2011-04-24 18:26:42 +00:00
|
|
|
wxRIGHT | wxLEFT, 5 );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
/* 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 );
|
2011-04-23 19:01:41 +00:00
|
|
|
flexColumnBoxSizer->Add( label, 0,
|
2009-04-29 17:09:00 +00:00
|
|
|
wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL |
|
2011-04-24 18:26:42 +00:00
|
|
|
wxRIGHT | wxLEFT, 5 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
|
|
|
// Provide a button for this layer (which will invoke a child dialog box)
|
|
|
|
item_ID = ID_BUTTON_0 + ii;
|
2011-04-24 18:26:42 +00:00
|
|
|
wxButton * Button = new wxButton( this, item_ID, wxT( "..." ),
|
|
|
|
wxDefaultPosition, wxSize( w, h ), 0 );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2011-04-23 19:01:41 +00:00
|
|
|
flexColumnBoxSizer->Add( Button, 0,
|
2011-04-24 18:26:42 +00:00
|
|
|
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// Provide another text string to specify which Pcbnew layer that this
|
2007-11-02 05:33:31 +00:00
|
|
|
// Gerber layer is initially mapped to, and set the initial text to
|
2011-09-30 18:15:37 +00:00
|
|
|
// specify the appropriate Pcbnew layer, and set the foreground color
|
2009-11-09 14:00:22 +00:00
|
|
|
// of the text to fuchsia (to indicate that the layer is being exported).
|
2007-11-02 05:33:31 +00:00
|
|
|
item_ID = ID_TEXT_0 + ii;
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
// When the first of these text strings is being added, determine what
|
|
|
|
// size is necessary to to be able to display any possible string
|
|
|
|
// without it being truncated. Then specify that size as the minimum
|
|
|
|
// size for all of these text strings. (If this minimum size is not
|
|
|
|
// determined in this fashion, then it is possible for the display of
|
2011-09-30 18:15:37 +00:00
|
|
|
// one or more of these strings to be truncated after different Pcbnew
|
2009-04-29 17:09:00 +00:00
|
|
|
// layers are selected.)
|
2007-11-02 05:33:31 +00:00
|
|
|
if( ii == 0 )
|
|
|
|
{
|
2011-04-24 18:26:42 +00:00
|
|
|
msg = _( "Do not export" );
|
2009-04-29 17:09:00 +00:00
|
|
|
text = new wxStaticText( this, item_ID, msg, wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
2007-11-02 05:33:31 +00:00
|
|
|
goodSize = text->GetSize();
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM jj = FIRST_LAYER; jj < NB_LAYERS; ++jj )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
text->SetLabel( GetPCBDefaultLayerName( jj ) );
|
2007-11-02 05:33:31 +00:00
|
|
|
if( goodSize.x < text->GetSize().x )
|
|
|
|
goodSize.x = text->GetSize().x;
|
|
|
|
}
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
msg = GetPCBDefaultLayerName( m_layersLookUpTable[m_buttonTable[ii]] );
|
2007-11-02 05:33:31 +00:00
|
|
|
text->SetLabel( msg );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
msg = GetPCBDefaultLayerName( m_layersLookUpTable[m_buttonTable[ii]] );
|
2009-04-29 17:09:00 +00:00
|
|
|
text = new wxStaticText( this, item_ID, msg, wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
|
|
|
text->SetMinSize( goodSize );
|
2011-04-23 19:01:41 +00:00
|
|
|
flexColumnBoxSizer->Add( text, 1,
|
2011-04-24 18:26:42 +00:00
|
|
|
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT,
|
2009-04-29 17:09:00 +00:00
|
|
|
5 );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
m_layersList[ii] = text;
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
2011-04-24 18:26:42 +00:00
|
|
|
}
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
/* Ensure m_exportBoardCopperLayersCount = 2 to BOARD_COPPER_LAYERS_MAX_COUNT
|
2011-04-26 08:30:16 +00:00
|
|
|
* 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++;
|
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
if( m_exportBoardCopperLayersCount > NB_LAYERS )
|
|
|
|
m_exportBoardCopperLayersCount = NB_LAYERS;
|
2011-04-26 08:30:16 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2011-04-24 18:26:42 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* reset pcb layers selection to the default value
|
|
|
|
*/
|
2011-04-26 08:30:16 +00:00
|
|
|
void LAYERS_MAP_DIALOG::OnResetClick( wxCommandEvent& event )
|
2011-04-24 18:26:42 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2013-03-31 13:27:46 +00:00
|
|
|
int ii;
|
|
|
|
LAYER_NUM layer;
|
|
|
|
for( ii = 0, layer = FIRST_LAYER; ii < m_itemsCount; ii++, ++layer )
|
2011-04-24 18:26:42 +00:00
|
|
|
{
|
2011-04-26 08:30:16 +00:00
|
|
|
if( (layer == m_exportBoardCopperLayersCount - 1)
|
|
|
|
&& (m_exportBoardCopperLayersCount > 1) )
|
2014-06-24 16:17:18 +00:00
|
|
|
layer = F_Cu;
|
2011-04-26 08:30:16 +00:00
|
|
|
m_layersLookUpTable[ii] = layer;
|
2012-05-04 17:44:42 +00:00
|
|
|
msg = GetPCBDefaultLayerName( layer );
|
2011-04-26 08:30:16 +00:00
|
|
|
m_layersList[ii]->SetLabel( msg );
|
|
|
|
m_layersList[ii]->SetForegroundColour( wxNullColour );
|
|
|
|
m_buttonTable[ii] = ii;
|
2011-04-24 18:26:42 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-24 19:57:41 +00:00
|
|
|
/* Stores the current layers selection in config
|
2011-04-24 18:26:42 +00:00
|
|
|
*/
|
2011-04-26 08:30:16 +00:00
|
|
|
void LAYERS_MAP_DIALOG::OnStoreSetup( wxCommandEvent& event )
|
2011-04-24 18:26:42 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxConfigBase* config = Kiface().KifaceSettings();
|
2012-05-04 17:44:42 +00:00
|
|
|
config->Write( wxT("BrdLayersCount"), m_exportBoardCopperLayersCount );
|
2011-04-24 18:26:42 +00:00
|
|
|
|
|
|
|
wxString key;
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
|
2011-04-24 18:26:42 +00:00
|
|
|
{
|
|
|
|
key.Printf( wxT("GbrLyr%dToPcb"), ii );
|
2011-04-26 08:30:16 +00:00
|
|
|
config->Write( key, m_layersLookUpTable[ii] );
|
2011-04-24 18:26:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
|
2011-04-24 18:26:42 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxConfigBase* config = Kiface().KifaceSettings();
|
2011-04-26 08:30:16 +00:00
|
|
|
|
|
|
|
config->Read( wxT("BrdLayersCount"), &m_exportBoardCopperLayersCount );
|
|
|
|
normalizeBrdLayersCount();
|
|
|
|
|
|
|
|
int idx = ( m_exportBoardCopperLayersCount / 2 ) - 1;
|
|
|
|
m_comboCopperLayersCount->SetSelection( idx );
|
|
|
|
|
2011-04-24 18:26:42 +00:00
|
|
|
wxString key;
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
|
2011-04-24 18:26:42 +00:00
|
|
|
{
|
|
|
|
key.Printf( wxT("GbrLyr%dToPcb"), ii );
|
2013-03-31 13:27:46 +00:00
|
|
|
int ilayer;
|
|
|
|
config->Read( key, &ilayer);
|
|
|
|
m_layersLookUpTable[ii] = ilayer;
|
2011-04-24 18:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( int ii = 0; ii < m_itemsCount; ii++ )
|
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM layer = m_layersLookUpTable[ii];
|
|
|
|
if( layer == UNSELECTED_LAYER )
|
2011-04-24 18:26:42 +00:00
|
|
|
{
|
2011-04-26 08:30:16 +00:00
|
|
|
m_layersList[ii]->SetLabel( _( "Do not export" ) );
|
|
|
|
m_layersList[ii]->SetForegroundColour( *wxBLUE );
|
2011-04-24 18:26:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
m_layersList[ii]->SetLabel( GetPCBDefaultLayerName( layer ) );
|
2011-04-26 08:30:16 +00:00
|
|
|
m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
|
2011-04-24 18:26:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
int ii;
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
ii = event.GetId() - ID_BUTTON_0;
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
if( (ii < FIRST_LAYER) || (ii >= NB_GERBER_LAYERS) )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
|
|
|
wxFAIL_MSG( wxT("Bad layer id") );
|
2007-11-02 05:33:31 +00:00
|
|
|
return;
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM jj = m_layersLookUpTable[m_buttonTable[ii]];
|
2013-04-09 16:00:46 +00:00
|
|
|
if( !IsValidLayer( jj ) )
|
2014-06-24 16:17:18 +00:00
|
|
|
jj = B_Cu; // (Defaults to "Copper" layer.)
|
2011-04-26 08:30:16 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
jj = m_Parent->SelectPCBLayer( jj, m_exportBoardCopperLayersCount, true );
|
2007-11-02 05:33:31 +00:00
|
|
|
|
2013-04-09 16:00:46 +00:00
|
|
|
if( !IsValidLayer( jj ) )
|
2007-11-02 05:33:31 +00:00
|
|
|
return;
|
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
if( jj != m_layersLookUpTable[m_buttonTable[ii]] )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2011-04-26 08:30:16 +00:00
|
|
|
m_layersLookUpTable[m_buttonTable[ii]] = jj;
|
2013-03-31 13:27:46 +00:00
|
|
|
if( jj == UNSELECTED_LAYER )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
2011-04-26 08:30:16 +00:00
|
|
|
m_layersList[ii]->SetLabel( _( "Do not export" ) );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
// Change the text color to blue (to highlight
|
|
|
|
// that this layer is *not* being exported)
|
2011-04-26 08:30:16 +00:00
|
|
|
m_layersList[ii]->SetForegroundColour( *wxBLUE );
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
2007-11-02 05:33:31 +00:00
|
|
|
else
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
m_layersList[ii]->SetLabel( GetPCBDefaultLayerName( jj ) );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
// Change the text color to fuchsia (to highlight
|
2007-11-05 06:14:55 +00:00
|
|
|
// that this layer *is* being exported)
|
2011-04-26 08:30:16 +00:00
|
|
|
m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
void LAYERS_MAP_DIALOG::OnCancelClick( wxCommandEvent& event )
|
2009-10-28 11:48:47 +00:00
|
|
|
{
|
2011-04-23 19:01:41 +00:00
|
|
|
EndModal( wxID_CANCEL );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-07 03:08:24 +00:00
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
void LAYERS_MAP_DIALOG::OnOkClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-04-26 08:30:16 +00:00
|
|
|
/* Make some test about copper layers:
|
|
|
|
* Board must have enough copper layers to handle selected internal layers
|
2007-11-02 05:33:31 +00:00
|
|
|
*/
|
2011-04-26 08:30:16 +00:00
|
|
|
normalizeBrdLayersCount();
|
2011-04-24 18:26:42 +00:00
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
int inner_layer_max = 0;
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM ii = FIRST_LAYER; ii < NB_GERBER_LAYERS; ++ii )
|
2007-11-02 05:33:31 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( m_layersLookUpTable[ii] < F_Cu )
|
2011-04-26 08:30:16 +00:00
|
|
|
{
|
|
|
|
if( m_layersLookUpTable[ii ] > inner_layer_max )
|
|
|
|
inner_layer_max = m_layersLookUpTable[ii];
|
|
|
|
}
|
2007-11-02 05:33:31 +00:00
|
|
|
}
|
|
|
|
|
2011-04-26 08:30:16 +00:00
|
|
|
// 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;
|
|
|
|
}
|
2011-04-23 19:01:41 +00:00
|
|
|
EndModal( wxID_OK );
|
2007-10-07 03:08:24 +00:00
|
|
|
}
|