* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
    having a BOARD being edited by more than one editor, it was a bad design.
    And this meant removing m_PcbFrame from BOARD.
  * removed BOARD::SetWindowFrame(), since BOARD::m_PcbFrame gone.
  * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
  * Added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
  * A couple of dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
    such as dialog_mask_clearance, dialog_drc, etc.
  * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
    with build_version.h's #define BOARD_FILE_VERSION, although there may be a
    better place for this constant.
  * Made the public functions in PARAM_CFG_ARRAY be type const.
    void SaveParam(..) const and void ReadParam(..) const
  * PARAM_CFG_BASE now has virtual destructor since we have various ways of
    destroying the derived classes and boost::ptr_vector must be told about this.
  * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
    an automatic PARAM_CFG_ARRAY which is on the stack.
  * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
    since it has to access the current BOARD and the BOARD can change.
    Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
  * Made the m_BoundingBox member private, this was a brutally hard task,
    and indicative of the lack of commitment to accessors and object oriented
    design on the part of KiCad developers.  We must do better.
    Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
  * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
This commit is contained in:
Dick Hollenbeck 2011-12-05 00:28:17 -06:00
commit 40ee72653e
75 changed files with 1106 additions and 995 deletions

View File

@ -156,12 +156,15 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
m_gllist = glGenLists( 1 ); m_gllist = glGenLists( 1 );
pcb->ComputeBoundingBox(); EDA_RECT bbbox = pcbframe->GetBoardBoundingBox();
g_Parm_3D_Visu.m_BoardSettings = pcb->GetBoardDesignSettings();
g_Parm_3D_Visu.m_BoardSize = pcb->m_BoundaryBox.GetSize(); g_Parm_3D_Visu.m_BoardSettings = &pcb->GetDesignSettings();
g_Parm_3D_Visu.m_BoardPos = pcb->m_BoundaryBox.Centre();
g_Parm_3D_Visu.m_BoardPos.y = -g_Parm_3D_Visu.m_BoardPos.y; g_Parm_3D_Visu.m_BoardSize = bbbox.GetSize();
g_Parm_3D_Visu.m_Layers = pcb->GetCopperLayerCount(); g_Parm_3D_Visu.m_BoardPos = bbbox.Centre();
g_Parm_3D_Visu.m_BoardPos.y = -g_Parm_3D_Visu.m_BoardPos.y;
g_Parm_3D_Visu.m_Layers = pcb->GetCopperLayerCount();
// Ensure the board has 2 sides for 3D views, because it is hard to find // Ensure the board has 2 sides for 3D views, because it is hard to find
// a *really* single side board in the true life... // a *really* single side board in the true life...
@ -175,7 +178,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
// because all boards thickness no not match with this setup: // because all boards thickness no not match with this setup:
// double epoxy_width = 1.6; // epoxy width in mm // double epoxy_width = 1.6; // epoxy width in mm
g_Parm_3D_Visu.m_Epoxy_Width = pcb->GetBoardDesignSettings()->m_BoardThickness g_Parm_3D_Visu.m_Epoxy_Width = pcb->GetDesignSettings().m_BoardThickness
* g_Parm_3D_Visu.m_BoardScale; * g_Parm_3D_Visu.m_BoardScale;
/* calculate z position for each layer */ /* calculate z position for each layer */

View File

@ -150,8 +150,10 @@ public:
wxPoint m_BoardPos; wxPoint m_BoardPos;
wxSize m_BoardSize; wxSize m_BoardSize;
int m_Layers; int m_Layers;
BOARD_DESIGN_SETTINGS* m_BoardSettings; // Link to current board design settings
double m_Epoxy_Width; // Epoxy thickness (normalized) const BOARD_DESIGN_SETTINGS* m_BoardSettings; // Link to current board design settings
double m_Epoxy_Width; // Epoxy thickness (normalized)
double m_BoardScale; /* Normalization scale for coordinates: double m_BoardScale; /* Normalization scale for coordinates:
* when scaled between -1.0 and +1.0 */ * when scaled between -1.0 and +1.0 */

View File

@ -4,6 +4,36 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2011-Dec-5 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), since BOARD::m_PcbFrame gone.
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* Added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* A couple of dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various ways of
destroying the derived classes and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-Dec-04, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> 2011-Dec-04, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
Pcbnew: Pcbnew:
@ -17,7 +47,7 @@ Pcbnew:
2011-Nov-27 UPDATE Dick Hollenbeck <dick@softplc.com> 2011-Nov-27 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
PCBNew ++PCBNew
* Add PLUGIN and IO_MGR classes. * Add PLUGIN and IO_MGR classes.
* Remove one argument from BOARD constructor, * Remove one argument from BOARD constructor,
* add BOARD::SetWindowFrame() * add BOARD::SetWindowFrame()

View File

@ -53,4 +53,7 @@ E6) Start initial work for changing component library file format to use Dick's
PCBNew PCBNew
------ ------
* Make the zone hit testing be done in screen coordinates, not internal units.
See the @todos in class_zone.cpp

View File

@ -85,8 +85,6 @@ const wxString ModuleFileExtension( wxT( "mod" ) );
/* PCB file name wild card definitions. */ /* PCB file name wild card definitions. */
const wxString ModuleFileWildcard( _( "KiCad footprint library files (*.mod)|*.mod" ) ); const wxString ModuleFileWildcard( _( "KiCad footprint library files (*.mod)|*.mod" ) );
int g_CurrentVersionPCB = 1;
int g_RotationAngle; int g_RotationAngle;
int g_AnchorColor = BLUE; int g_AnchorColor = BLUE;

View File

@ -169,7 +169,7 @@ void EDA_APP::WriteProjectConfig( const wxString& fileName,
void EDA_APP::WriteProjectConfig( const wxString& fileName, void EDA_APP::WriteProjectConfig( const wxString& fileName,
const wxString& GroupName, const wxString& GroupName,
PARAM_CFG_ARRAY& params ) const PARAM_CFG_ARRAY& params )
{ {
ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG ); ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG );
@ -189,7 +189,7 @@ void EDA_APP::WriteProjectConfig( const wxString& fileName,
m_ProjectConfig->Write( wxT( "version" ), CONFIG_VERSION ); m_ProjectConfig->Write( wxT( "version" ), CONFIG_VERSION );
m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR ); m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR );
BOOST_FOREACH( PARAM_CFG_BASE& param, params ) BOOST_FOREACH( const PARAM_CFG_BASE& param, params )
{ {
if( param.m_Group ) if( param.m_Group )
m_ProjectConfig->SetPath( param.m_Group ); m_ProjectConfig->SetPath( param.m_Group );
@ -248,12 +248,12 @@ void EDA_APP::SaveCurrentSetupValues( PARAM_CFG_BASE** aList )
} }
void EDA_APP::SaveCurrentSetupValues( PARAM_CFG_ARRAY& List ) void EDA_APP::SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List )
{ {
if( m_EDA_Config == NULL ) if( m_EDA_Config == NULL )
return; return;
BOOST_FOREACH( PARAM_CFG_BASE& param, List ) BOOST_FOREACH( const PARAM_CFG_BASE& param, List )
{ {
if( param.m_Setup == false ) if( param.m_Setup == false )
continue; continue;
@ -326,7 +326,7 @@ bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename, bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName, const wxString& GroupName,
PARAM_CFG_ARRAY& params, const PARAM_CFG_ARRAY& params,
bool Load_Only_if_New ) bool Load_Only_if_New )
{ {
wxString timestamp; wxString timestamp;
@ -356,7 +356,7 @@ bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
m_CurrentOptionFile = g_Prj_Config_LocalFilename; m_CurrentOptionFile = g_Prj_Config_LocalFilename;
} }
BOOST_FOREACH( PARAM_CFG_BASE& param, params ) BOOST_FOREACH( const PARAM_CFG_BASE& param, params )
{ {
if( param.m_Group ) if( param.m_Group )
m_ProjectConfig->SetPath( param.m_Group ); m_ProjectConfig->SetPath( param.m_Group );
@ -392,9 +392,9 @@ void EDA_APP::ReadCurrentSetupValues( PARAM_CFG_BASE** aList )
} }
void EDA_APP::ReadCurrentSetupValues( PARAM_CFG_ARRAY& List ) void EDA_APP::ReadCurrentSetupValues( const PARAM_CFG_ARRAY& List )
{ {
BOOST_FOREACH( PARAM_CFG_BASE& param, List ) BOOST_FOREACH( const PARAM_CFG_BASE& param, List )
{ {
if( param.m_Setup == false ) if( param.m_Setup == false )
continue; continue;
@ -443,7 +443,7 @@ PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
* read the value of parameter this stored in aConfig * read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter * @param aConfig = the wxConfigBase that store the parameter
*/ */
void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig ) void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -461,7 +461,7 @@ void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig )
* save the value of parameter this stored in aConfig * save the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter * @param aConfig = the wxConfigBase that can store the parameter
*/ */
void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig ) void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -497,7 +497,7 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
* read the value of parameter this stored in aConfig * read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter * @param aConfig = the wxConfigBase that store the parameter
*/ */
void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -513,7 +513,7 @@ void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig )
* save the the value of parameter this stored in aConfig * save the the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter * @param aConfig = the wxConfigBase that can store the parameter
*/ */
void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -555,7 +555,7 @@ PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup,
* read the value of parameter this stored in aConfig * read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter * @param aConfig = the wxConfigBase that store the parameter
*/ */
void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig ) void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -584,7 +584,7 @@ void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig )
* save the the value of parameter this stored in aConfig * save the the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter * @param aConfig = the wxConfigBase that can store the parameter
*/ */
void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -619,7 +619,7 @@ PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup,
* read the value of parameter this stored in aConfig * read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter * @param aConfig = the wxConfigBase that store the parameter
*/ */
void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig ) void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -634,7 +634,7 @@ void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig )
* save the the value of parameter this stored in aConfig * save the the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter * @param aConfig = the wxConfigBase that can store the parameter
*/ */
void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig ) void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -668,7 +668,7 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident,
* read the value of parameter this stored in aConfig * read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter * @param aConfig = the wxConfigBase that store the parameter
*/ */
void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig ) void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -680,7 +680,7 @@ void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig )
* save the value of parameter this stored in aConfig * save the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter * @param aConfig = the wxConfigBase that can store the parameter
*/ */
void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig ) void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -703,7 +703,7 @@ PARAM_CFG_FILENAME::PARAM_CFG_FILENAME( const wxChar* ident,
* read the value of parameter this stored in aConfig * read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter * @param aConfig = the wxConfigBase that store the parameter
*/ */
void PARAM_CFG_FILENAME::ReadParam( wxConfigBase* aConfig ) void PARAM_CFG_FILENAME::ReadParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -722,7 +722,7 @@ void PARAM_CFG_FILENAME::ReadParam( wxConfigBase* aConfig )
* save the value of parameter this stored in aConfig * save the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter * @param aConfig = the wxConfigBase that can store the parameter
*/ */
void PARAM_CFG_FILENAME::SaveParam( wxConfigBase* aConfig ) void PARAM_CFG_FILENAME::SaveParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -747,7 +747,7 @@ PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident,
* read the value of parameter this stored in aConfig * read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter * @param aConfig = the wxConfigBase that store the parameter
*/ */
void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
@ -780,7 +780,7 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig )
* save the value of parameter this in aConfig (list of parameters) * save the value of parameter this in aConfig (list of parameters)
* @param aConfig = the wxConfigBase that can store the parameter * @param aConfig = the wxConfigBase that can store the parameter
*/ */
void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig ) void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;

View File

@ -61,7 +61,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father,
icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) ); icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) );
SetIcon( icon ); SetIcon( icon );
SetBoard( new BOARD( this ) ); SetBoard( new BOARD() );
SetScreen( new PCB_SCREEN() ); SetScreen( new PCB_SCREEN() );
LoadSettings(); LoadSettings();

View File

@ -252,7 +252,7 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
} }
PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters( void ) PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters()
{ {
if( !m_projectFileParams.empty() ) if( !m_projectFileParams.empty() )
return m_projectFileParams; return m_projectFileParams;

View File

@ -134,6 +134,8 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
wxColour bgColor = MakeColour( g_DrawBgColor ); wxColour bgColor = MakeColour( g_DrawBgColor );
wxBrush bgBrush( bgColor, wxSOLID ); wxBrush bgBrush( bgColor, wxSOLID );
GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent();
int bitmapWidth, bitmapHeight; int bitmapWidth, bitmapHeight;
wxDC* plotDC = aDC; wxDC* plotDC = aDC;
@ -188,7 +190,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
for( int layer = 0; !end; layer++ ) for( int layer = 0; !end; layer++ )
{ {
int active_layer = ( (GERBVIEW_FRAME*) m_PcbFrame )->getActiveLayer(); int active_layer = gerbFrame->getActiveLayer();
if( layer == active_layer ) // active layer will be drawn after other layers if( layer == active_layer ) // active layer will be drawn after other layers
continue; continue;
@ -269,7 +271,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
int dcode_highlight = 0; int dcode_highlight = 0;
if( layer == ( (GERBVIEW_FRAME*) m_PcbFrame )->getActiveLayer() ) if( layer == gerbFrame->getActiveLayer() )
dcode_highlight = gerber->m_Selected_Tool; dcode_highlight = gerber->m_Selected_Tool;
int layerdrawMode = GR_COPY; int layerdrawMode = GR_COPY;

View File

@ -19,6 +19,7 @@
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
#include "class_gerber_draw_item.h" #include "class_gerber_draw_item.h"
#include "select_layers_to_pcb.h" #include "select_layers_to_pcb.h"
#include "build_version.h" // BOARD_FILE_VERSION
/* A helper class to export a Gerber set of files to Pcbnew /* A helper class to export a Gerber set of files to Pcbnew
@ -51,7 +52,7 @@ GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME * aFrame, FILE * aFile
{ {
m_gerbview_frame = aFrame; m_gerbview_frame = aFrame;
m_file = aFile; m_file = aFile;
m_pcb = new BOARD( m_gerbview_frame ); m_pcb = new BOARD();
} }
@ -177,7 +178,7 @@ bool GBR_TO_PCB_EXPORTER::WriteGeneralDescrPcb( )
{ {
int nbLayers; int nbLayers;
/* Print the copper layer count */ // Print the copper layer count
nbLayers = m_pcb->GetCopperLayerCount(); nbLayers = m_pcb->GetCopperLayerCount();
if( nbLayers <= 1 ) // Minimal layers count in Pcbnew is 2 if( nbLayers <= 1 ) // Minimal layers count in Pcbnew is 2
@ -190,12 +191,13 @@ bool GBR_TO_PCB_EXPORTER::WriteGeneralDescrPcb( )
fprintf( m_file, "encoding utf-8\n"); fprintf( m_file, "encoding utf-8\n");
fprintf( m_file, "LayerCount %d\n", nbLayers ); fprintf( m_file, "LayerCount %d\n", nbLayers );
/* Compute and print the board bounding box */ // Compute and print the board bounding box
m_pcb->ComputeBoundingBox(); EDA_RECT bbbox = m_pcb->ComputeBoundingBox();
fprintf( m_file, "Di %d %d %d %d\n", fprintf( m_file, "Di %d %d %d %d\n",
m_pcb->m_BoundaryBox.GetX(), m_pcb->m_BoundaryBox.GetY(), bbbox.GetX(), bbbox.GetY(),
m_pcb->m_BoundaryBox.GetRight(), bbbox.GetRight(),
m_pcb->m_BoundaryBox.GetBottom() ); bbbox.GetBottom() );
fprintf( m_file, "$EndGENERAL\n\n" ); fprintf( m_file, "$EndGENERAL\n\n" );
return true; return true;
@ -237,7 +239,7 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
SetLocaleTo_C_standard(); SetLocaleTo_C_standard();
// write PCB header // write PCB header
fprintf( m_file, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB, fprintf( m_file, "PCBNEW-BOARD Version %d date %s\n\n", BOARD_FILE_VERSION,
TO_UTF8( DateAndTime() ) ); TO_UTF8( DateAndTime() ) );
WriteGeneralDescrPcb( ); WriteGeneralDescrPcb( );
WriteSetup( ); WriteSetup( );

View File

@ -61,7 +61,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
SetScreen( new PCB_SCREEN() ); SetScreen( new PCB_SCREEN() );
GetScreen()->m_CurrentSheetDesc = &g_Sheet_GERBER; GetScreen()->m_CurrentSheetDesc = &g_Sheet_GERBER;
SetBoard( new BOARD( this ) ); SetBoard( new BOARD() );
GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first. GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first.
GetBoard()->SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible. GetBoard()->SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible.

View File

@ -62,8 +62,8 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query )
} }
} }
GetBoard()->m_BoundaryBox.SetOrigin( 0, 0 ); GetBoard()->SetBoundingBox( EDA_RECT() );
GetBoard()->m_BoundaryBox.SetSize( 0, 0 );
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
GetBoard()->m_NbNodes = 0; GetBoard()->m_NbNodes = 0;
GetBoard()->m_NbNoconnect = 0; GetBoard()->m_NbNoconnect = 0;

View File

@ -176,9 +176,10 @@ public: EDA_APP();
void WriteProjectConfig( const wxString& local_config_filename, void WriteProjectConfig( const wxString& local_config_filename,
const wxString& GroupName, const wxString& GroupName,
PARAM_CFG_BASE** List ); PARAM_CFG_BASE** List );
void WriteProjectConfig( const wxString& fileName, void WriteProjectConfig( const wxString& fileName,
const wxString& GroupName, const wxString& GroupName,
PARAM_CFG_ARRAY& params ); const PARAM_CFG_ARRAY& params );
/** /**
* Function SaveCurrentSetupValues * Function SaveCurrentSetupValues
@ -188,7 +189,7 @@ public: EDA_APP();
* @param aList = array of PARAM_CFG_BASE pointers * @param aList = array of PARAM_CFG_BASE pointers
*/ */
void SaveCurrentSetupValues( PARAM_CFG_BASE** aList ); void SaveCurrentSetupValues( PARAM_CFG_BASE** aList );
void SaveCurrentSetupValues( PARAM_CFG_ARRAY& List ); void SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List );
/** /**
* Function ReadCurrentSetupValues * Function ReadCurrentSetupValues
@ -198,7 +199,7 @@ public: EDA_APP();
* @param aList = array of PARAM_CFG_BASE pointers * @param aList = array of PARAM_CFG_BASE pointers
*/ */
void ReadCurrentSetupValues( PARAM_CFG_BASE** aList ); void ReadCurrentSetupValues( PARAM_CFG_BASE** aList );
void ReadCurrentSetupValues( PARAM_CFG_ARRAY& List ); void ReadCurrentSetupValues( const PARAM_CFG_ARRAY& List );
/** /**
* Function ReadProjectConfig * Function ReadProjectConfig
@ -220,7 +221,7 @@ public: EDA_APP();
bool Load_Only_if_New ); bool Load_Only_if_New );
bool ReadProjectConfig( const wxString& local_config_filename, bool ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName, const wxString& GroupName,
PARAM_CFG_ARRAY& List, const PARAM_CFG_ARRAY& List,
bool Load_Only_if_New ); bool Load_Only_if_New );
/** /**

View File

@ -12,4 +12,8 @@ class wxString;
*/ */
wxString GetBuildVersion(); wxString GetBuildVersion();
/// The file format revision of the *.brd file created by this build
#define BOARD_FILE_VERSION 1
#endif // KICAD_BUILD_VERSION_H #endif // KICAD_BUILD_VERSION_H

View File

@ -11,34 +11,33 @@
class BOARD_DESIGN_SETTINGS class BOARD_DESIGN_SETTINGS
{ {
protected: protected:
int m_CopperLayerCount; // Number of copper layers for this design int m_CopperLayerCount; ///< Number of copper layers for this design
public: int m_EnabledLayers; ///< Bit-mask for layer enabling
bool m_MicroViasAllowed; // true to allow micro vias int m_VisibleLayers; ///< Bit-mask for layer visibility
int m_CurrentViaType; // via type (VIA_BLIND_BURIED, VIA_TROUGHT VIA_MICROVIA) int m_VisibleElements; ///< Bit-mask for element category visibility
// if true, when creating a new track starting on an existing track, use this track width public:
bool m_MicroViasAllowed; ///< true to allow micro vias
int m_CurrentViaType; ///< via type (VIA_BLIND_BURIED, VIA_TROUGHT VIA_MICROVIA)
/// if true, when creating a new track starting on an existing track, use this track width
bool m_UseConnectedTrackWidth; bool m_UseConnectedTrackWidth;
int m_DrawSegmentWidth; // current graphic line width (not EDGE layer) int m_DrawSegmentWidth; ///< current graphic line width (not EDGE layer)
int m_EdgeSegmentWidth; // current graphic line width (EDGE layer only) int m_EdgeSegmentWidth; ///< current graphic line width (EDGE layer only)
int m_PcbTextWidth; // current Pcb (not module) Text width int m_PcbTextWidth; ///< current Pcb (not module) Text width
wxSize m_PcbTextSize; // current Pcb (not module) Text size wxSize m_PcbTextSize; ///< current Pcb (not module) Text size
int m_TrackMinWidth; // track min value for width ((min copper size value int m_TrackMinWidth; ///< track min value for width ((min copper size value
int m_ViasMinSize; // vias (not micro vias) min diameter int m_ViasMinSize; ///< vias (not micro vias) min diameter
int m_ViasMinDrill; // vias (not micro vias) min drill diameter int m_ViasMinDrill; ///< vias (not micro vias) min drill diameter
int m_MicroViasMinSize; // micro vias (not vias) min diameter int m_MicroViasMinSize; ///< micro vias (not vias) min diameter
int m_MicroViasMinDrill; // micro vias (not vias) min drill diameter int m_MicroViasMinDrill; ///< micro vias (not vias) min drill diameter
// Global mask margins: // Global mask margins:
int m_SolderMaskMargin; // Solder mask margin int m_SolderMaskMargin; ///< Solder mask margin
int m_SolderPasteMargin; // Solder paste margin absolute value int m_SolderPasteMargin; ///< Solder paste margin absolute value
double m_SolderPasteMarginRatio; // Solder pask margin ratio value of pad size double m_SolderPasteMarginRatio; ///< Solder pask margin ratio value of pad size
// The final margin is the sum of these 2 values ///< The final margin is the sum of these 2 values
int m_BoardThickness; // Board Thickness for 3D viewer int m_BoardThickness; ///< Board Thickness for 3D viewer
protected:
int m_EnabledLayers; // Bit-mask for layer enabling
int m_VisibleLayers; // Bit-mask for layer visibility
int m_VisibleElements; // Bit-mask for element category visibility
public: public:
BOARD_DESIGN_SETTINGS(); BOARD_DESIGN_SETTINGS();
@ -79,7 +78,6 @@ public:
return (bool) ( m_VisibleLayers & m_EnabledLayers & (1 << aLayerIndex) ); return (bool) ( m_VisibleLayers & m_EnabledLayers & (1 << aLayerIndex) );
} }
/** /**
* Function SetLayerVisibility * Function SetLayerVisibility
* changes the visibility of a given layer * changes the visibility of a given layer
@ -98,7 +96,6 @@ public:
return m_VisibleElements; return m_VisibleElements;
} }
/** /**
* Function SetVisibleElements * Function SetVisibleElements
* changes the bit-mask of visible element categories * changes the bit-mask of visible element categories
@ -159,7 +156,6 @@ public:
return bool( m_EnabledLayers & (1 << aLayerIndex) ); return bool( m_EnabledLayers & (1 << aLayerIndex) );
} }
/** /**
* Function GetCopperLayerCount * Function GetCopperLayerCount
* @return int - the number of neabled copper layers * @return int - the number of neabled copper layers
@ -169,7 +165,6 @@ public:
return m_CopperLayerCount; return m_CopperLayerCount;
} }
/** /**
* Function SetCopperLayerCount * Function SetCopperLayerCount
* do what its name says... * do what its name says...

View File

@ -48,7 +48,6 @@ class BOARD_ITEM : public EDA_ITEM
void SetNext( EDA_ITEM* aNext ) { Pnext = aNext; } void SetNext( EDA_ITEM* aNext ) { Pnext = aNext; }
void SetBack( EDA_ITEM* aBack ) { Pback = aBack; } void SetBack( EDA_ITEM* aBack ) { Pback = aBack; }
protected: protected:
int m_Layer; int m_Layer;
@ -60,7 +59,6 @@ public:
{ {
} }
BOARD_ITEM( const BOARD_ITEM& src ) : BOARD_ITEM( const BOARD_ITEM& src ) :
EDA_ITEM( src.m_Parent, src.Type() ) EDA_ITEM( src.m_Parent, src.Type() )
, m_Layer( src.m_Layer ) , m_Layer( src.m_Layer )
@ -68,7 +66,6 @@ public:
m_Flags = src.m_Flags; m_Flags = src.m_Flags;
} }
/** /**
* A value of wxPoint(0,0) which can be passed to the Draw() functions. * A value of wxPoint(0,0) which can be passed to the Draw() functions.
*/ */
@ -107,7 +104,6 @@ public:
*/ */
virtual void SetLayer( int aLayer ) { m_Layer = aLayer; } virtual void SetLayer( int aLayer ) { m_Layer = aLayer; }
/** /**
* Function Draw * Function Draw
* BOARD_ITEMs have their own color information. * BOARD_ITEMs have their own color information.
@ -115,7 +111,6 @@ public:
virtual void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, virtual void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
int aDrawMode, const wxPoint& offset = ZeroOffset ) = 0; int aDrawMode, const wxPoint& offset = ZeroOffset ) = 0;
/** /**
* Function IsOnLayer * Function IsOnLayer
* tests to see if this object is on the given layer. Is virtual so * tests to see if this object is on the given layer. Is virtual so
@ -214,7 +209,6 @@ public:
wxMessageBox( wxT( "virtual BOARD_ITEM::Flip used, should not occur" ), GetClass() ); wxMessageBox( wxT( "virtual BOARD_ITEM::Flip used, should not occur" ), GetClass() );
} }
/** /**
* Function GetBoard * Function GetBoard
* returns the BOARD in which this BOARD_ITEM resides, or NULL if none. * returns the BOARD in which this BOARD_ITEM resides, or NULL if none.

View File

@ -3,8 +3,8 @@
* @file param_config.h * @file param_config.h
*/ */
#ifndef __PARAM_CONFIG_H__ #ifndef PARAM_CONFIG_H_
#define __PARAM_CONFIG_H__ 1 #define PARAM_CONFIG_H_
#include "wx/confbase.h" #include "wx/confbase.h"
#include "wx/fileconf.h" #include "wx/fileconf.h"
@ -45,21 +45,23 @@ public:
const wxChar* m_Group; ///< Group name (this is like a path in the config data) const wxChar* m_Group; ///< Group name (this is like a path in the config data)
bool m_Setup; ///< Install or Project based parameter, true == install bool m_Setup; ///< Install or Project based parameter, true == install
public: PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type, const wxChar* group = NULL ); public:
PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type, const wxChar* group = NULL );
virtual ~PARAM_CFG_BASE() {}
/** /**
* Function ReadParam * Function ReadParam
* reads the value of the parameter stored in aConfig * reads the value of the parameter stored in aConfig
* @param aConfig = the wxConfigBase that holds the parameter * @param aConfig = the wxConfigBase that holds the parameter
*/ */
virtual void ReadParam( wxConfigBase* aConfig ) {}; virtual void ReadParam( wxConfigBase* aConfig ) const {};
/** /**
* Function SaveParam * Function SaveParam
* saves the value of the parameter stored in aConfig * saves the value of the parameter stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter * @param aConfig = the wxConfigBase that can store the parameter
*/ */
virtual void SaveParam( wxConfigBase* aConfig ) {}; virtual void SaveParam( wxConfigBase* aConfig ) const {};
}; };
@ -74,15 +76,16 @@ public:
int m_Min, m_Max; ///< Minimum and maximum values of the param type int m_Min, m_Max; ///< Minimum and maximum values of the param type
int m_Default; ///< The default value of the parameter int m_Default; ///< The default value of the parameter
public: PARAM_CFG_INT( const wxChar* ident, int* ptparam, public:
PARAM_CFG_INT( const wxChar* ident, int* ptparam,
int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL, int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL,
const wxChar* group = NULL ); const wxChar* group = NULL );
PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam, PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL, int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL,
const wxChar* group = NULL ); const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ); virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ); virtual void SaveParam( wxConfigBase* aConfig ) const;
}; };
@ -96,13 +99,14 @@ public:
int* m_Pt_param; ///< Pointer to the parameter value int* m_Pt_param; ///< Pointer to the parameter value
int m_Default; ///< The default value of the parameter int m_Default; ///< The default value of the parameter
public: PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam, public:
PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam,
int default_val, const wxChar* group = NULL ); int default_val, const wxChar* group = NULL );
PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, int* ptparam, PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, int* ptparam,
int default_val, const wxChar* group = NULL ); int default_val, const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ); virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ); virtual void SaveParam( wxConfigBase* aConfig ) const;
}; };
@ -117,15 +121,16 @@ public:
double m_Default; ///< The default value of the parameter double m_Default; ///< The default value of the parameter
double m_Min, m_Max; ///< Minimum and maximum values of the param type double m_Min, m_Max; ///< Minimum and maximum values of the param type
public: PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam, public:
PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam,
double default_val = 0.0, double min = 0.0, double max = 10000.0, double default_val = 0.0, double min = 0.0, double max = 10000.0,
const wxChar* group = NULL ); const wxChar* group = NULL );
PARAM_CFG_DOUBLE( bool Insetup, const wxChar* ident, double* ptparam, PARAM_CFG_DOUBLE( bool Insetup, const wxChar* ident, double* ptparam,
double default_val = 0.0, double min = 0.0, double max = 10000.0, double default_val = 0.0, double min = 0.0, double max = 10000.0,
const wxChar* group = NULL ); const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ); virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ); virtual void SaveParam( wxConfigBase* aConfig ) const;
}; };
@ -139,13 +144,14 @@ public:
bool* m_Pt_param; ///< Pointer to the parameter value bool* m_Pt_param; ///< Pointer to the parameter value
int m_Default; ///< The default value of the parameter int m_Default; ///< The default value of the parameter
public: PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam, public:
PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
int default_val = false, const wxChar* group = NULL ); int default_val = false, const wxChar* group = NULL );
PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam, PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam,
int default_val = false, const wxChar* group = NULL ); int default_val = false, const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ); virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ); virtual void SaveParam( wxConfigBase* aConfig ) const;
}; };
@ -167,12 +173,11 @@ public:
const wxString& default_val = wxEmptyString, const wxString& default_val = wxEmptyString,
const wxChar* group = NULL ); const wxChar* group = NULL );
virtual ~PARAM_CFG_WXSTRING() {} virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ) const;
virtual void ReadParam( wxConfigBase* aConfig );
virtual void SaveParam( wxConfigBase* aConfig );
}; };
/** /**
* Configuration parameter - PARAM_CFG_FILENAME Class * Configuration parameter - PARAM_CFG_FILENAME Class
* Same as PARAM_CFG_WXSTRING, but stores "\" as "/". * Same as PARAM_CFG_WXSTRING, but stores "\" as "/".
@ -184,9 +189,10 @@ class PARAM_CFG_FILENAME : public PARAM_CFG_BASE
public: public:
wxString* m_Pt_param; ///< Pointer to the parameter value wxString* m_Pt_param; ///< Pointer to the parameter value
public: PARAM_CFG_FILENAME( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL ); public:
virtual void ReadParam( wxConfigBase* aConfig ); PARAM_CFG_FILENAME( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL );
virtual void SaveParam( wxConfigBase* aConfig ); virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ) const;
}; };
@ -195,16 +201,17 @@ class PARAM_CFG_LIBNAME_LIST : public PARAM_CFG_BASE
public: public:
wxArrayString* m_Pt_param; ///< Pointer to the parameter value wxArrayString* m_Pt_param; ///< Pointer to the parameter value
public: PARAM_CFG_LIBNAME_LIST( const wxChar* ident, public:
PARAM_CFG_LIBNAME_LIST( const wxChar* ident,
wxArrayString* ptparam, wxArrayString* ptparam,
const wxChar* group = NULL ); const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig ); virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ); virtual void SaveParam( wxConfigBase* aConfig ) const;
}; };
/** A list of parameters type */ /** A list of parameters type */
typedef boost::ptr_vector<PARAM_CFG_BASE> PARAM_CFG_ARRAY; typedef boost::ptr_vector<PARAM_CFG_BASE> PARAM_CFG_ARRAY;
#endif /* __PARAM_CONFIG_H__ */ #endif // PARAM_CONFIG_H_

View File

@ -54,7 +54,7 @@ class TEXTE_MODULE;
class EDA_3D_FRAME; class EDA_3D_FRAME;
class GENERAL_COLLECTOR; class GENERAL_COLLECTOR;
class GENERAL_COLLECTORS_GUIDE; class GENERAL_COLLECTORS_GUIDE;
class BOARD_DESIGN_SETTINGS;
/** /**
* class PCB_BASE_FRAME * class PCB_BASE_FRAME
@ -80,13 +80,17 @@ public:
FOOTPRINT_EDIT_FRAME* m_ModuleEditFrame; FOOTPRINT_EDIT_FRAME* m_ModuleEditFrame;
protected: protected:
BOARD* m_Pcb; // EDA_RECT m_BoundaryBox; // Board size and position
GENERAL_COLLECTOR* m_Collector; BOARD* m_Pcb;
GENERAL_COLLECTOR* m_Collector;
void updateGridSelectBox(); void updateGridSelectBox();
void updateZoomSelectBox(); void updateZoomSelectBox();
virtual void unitsChangeRefresh(); virtual void unitsChangeRefresh();
public: public:
PCB_BASE_FRAME( wxWindow* father, int idtype, const wxString& title, PCB_BASE_FRAME( wxWindow* father, int idtype, const wxString& title,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
@ -94,6 +98,14 @@ public:
~PCB_BASE_FRAME(); ~PCB_BASE_FRAME();
/**
* Function GetBoardBoundingBox
* calculates the bounding box containing all board items (or board edge segments).
* @param aBoardEdgesOnly is true if we are interested in board edge segments only.
* @return EDA_RECT - the board's bounding box
*/
EDA_RECT GetBoardBoundingBox( bool aBoardEdgesOnly = false ) const;
/** /**
* Function SetBoard * Function SetBoard
* sets the m_Pcb member in such as way as to ensure deleting any previous * sets the m_Pcb member in such as way as to ensure deleting any previous
@ -108,6 +120,8 @@ public:
return m_Pcb; return m_Pcb;
} }
BOARD_DESIGN_SETTINGS* GetDesignSettings();
// General // General
virtual void OnCloseWindow( wxCloseEvent& Event ) = 0; virtual void OnCloseWindow( wxCloseEvent& Event ) = 0;
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) { } virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) { }

View File

@ -88,7 +88,6 @@ protected:
DRC* m_drc; ///< the DRC controller, see drc.cpp DRC* m_drc; ///< the DRC controller, see drc.cpp
PARAM_CFG_ARRAY m_projectFileParams; ///< List of Pcbnew project file settings.
PARAM_CFG_ARRAY m_configSettings; ///< List of Pcbnew configuration settings. PARAM_CFG_ARRAY m_configSettings; ///< List of Pcbnew configuration settings.
wxString m_lastNetListRead; ///< Last net list read with relative path. wxString m_lastNetListRead; ///< Last net list read with relative path.
@ -276,16 +275,17 @@ public:
/** /**
* Function GetProjectFileParameters * Function GetProjectFileParameters
* returns the project file parameter list for Pcbnew. * returns a project file parameter list for Pcbnew.
* <p> * <p>
* Populate the project file parameter array specific to Pcbnew if it hasn't * Populate a project file parameter array specific to Pcbnew.
* already been populated and return a reference to the array to the caller.
* Creating the parameter list at run time has the advantage of being able * Creating the parameter list at run time has the advantage of being able
* to define local variables. The old method of statically building the array * to define local variables. The old method of statically building the array
* at compile time requiring global variable definitions by design. * at compile time requiring global variable definitions by design.
* </p> * </p>
* @return PARAM_CFG_ARRAY - it is only good until SetBoard() is called, so
* don't keep it around past that event.
*/ */
PARAM_CFG_ARRAY& GetProjectFileParameters(); PARAM_CFG_ARRAY GetProjectFileParameters();
void SaveProjectSettings(); void SaveProjectSettings();
@ -302,13 +302,13 @@ public:
* Function GetConfigurationSettings * Function GetConfigurationSettings
* returns the Pcbnew applications settings list. * returns the Pcbnew applications settings list.
* *
* This replaces the old statically define list that had the project * This replaces the old statically defined list that had the project
* file settings and the application settings mixed together. This * file settings and the application settings mixed together. This
* was confusing and caused some settings to get saved and loaded * was confusing and caused some settings to get saved and loaded
* incorrectly. Currently, only the settings that are needed at start * incorrectly. Currently, only the settings that are needed at start
* up by the main window are defined here. There are other locally used * up by the main window are defined here. There are other locally used
* settings are scattered throughout the Pcbnew source code. If you need * settings that are scattered throughout the Pcbnew source code. If you need
* to define a configuration setting that need to be loaded at run time, * to define a configuration setting that needs to be loaded at run time,
* this is the place to define it. * this is the place to define it.
* *
* @todo: Define the configuration variables as member variables instead of * @todo: Define the configuration variables as member variables instead of

View File

@ -182,7 +182,6 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
wxPoint start, current; wxPoint start, current;
int Ymax_size, Xsize_allowed; int Ymax_size, Xsize_allowed;
int pas_grille = (int) GetScreen()->GetGridSize().x; int pas_grille = (int) GetScreen()->GetGridSize().x;
bool edgesExists;
double surface; double surface;
if( GetBoard()->m_Modules == NULL ) if( GetBoard()->m_Modules == NULL )
@ -195,9 +194,12 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( !IsOK( this, _( "Move modules?" ) ) ) if( !IsOK( this, _( "Move modules?" ) ) )
return; return;
edgesExists = GetBoard()->ComputeBoundingBox( true ); EDA_RECT bbbox = GetBoard()->ComputeBoundingBox( true );
if( PlaceModulesHorsPcb && !edgesExists ) bool edgesExist = ( bbbox.GetWidth() || bbbox.GetHeight() );
// no edges exist
if( PlaceModulesHorsPcb && !edgesExist )
{ {
DisplayError( this, DisplayError( this,
_( "Could not automatically place modules. No board outlines detected." ) ); _( "Could not automatically place modules. No board outlines detected." ) );
@ -218,12 +220,12 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
/* to move modules outside the board, the cursor is placed below /* to move modules outside the board, the cursor is placed below
* the current board, to avoid placing components in board area. * the current board, to avoid placing components in board area.
*/ */
if( PlaceModulesHorsPcb && edgesExists ) if( PlaceModulesHorsPcb && edgesExist )
{ {
if( GetScreen()->GetCrossHairPosition().y < (GetBoard()->m_BoundaryBox.GetBottom() + 2000) ) if( GetScreen()->GetCrossHairPosition().y < (bbbox.GetBottom() + 2000) )
{ {
wxPoint pos = GetScreen()->GetCrossHairPosition(); wxPoint pos = GetScreen()->GetCrossHairPosition();
pos.y = GetBoard()->m_BoundaryBox.GetBottom() + 2000; pos.y = bbbox.GetBottom() + 2000;
GetScreen()->SetCrossHairPosition( pos ); GetScreen()->SetCrossHairPosition( pos );
} }
} }
@ -235,9 +237,9 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
{ {
Module = moduleList[ii]; Module = moduleList[ii];
if( PlaceModulesHorsPcb && edgesExists ) if( PlaceModulesHorsPcb && edgesExist )
{ {
if( GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) ) if( bbbox.Contains( Module->m_Pos ) )
continue; continue;
} }
@ -256,9 +258,9 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( Module->IsLocked() ) if( Module->IsLocked() )
continue; continue;
if( PlaceModulesHorsPcb && edgesExists ) if( PlaceModulesHorsPcb && edgesExist )
{ {
if( GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) ) if( bbbox.Contains( Module->m_Pos ) )
continue; continue;
} }

View File

@ -75,6 +75,9 @@ static const float OrientPenality[11] =
#define OUT_OF_BOARD -2 #define OUT_OF_BOARD -2
#define OCCUPED_By_MODULE -1 #define OCCUPED_By_MODULE -1
static EDA_RECT bbbox; // boards bounding box
static wxPoint CurrPosition; // Current position of the current module placement static wxPoint CurrPosition; // Current position of the current module placement
static bool AutoPlaceShowAll = true; static bool AutoPlaceShowAll = true;
@ -182,7 +185,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
if( Module->m_ModuleStatus & MODULE_is_LOCKED ) if( Module->m_ModuleStatus & MODULE_is_LOCKED )
break; break;
if( !GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) ) if( !bbbox.Contains( Module->m_Pos ) )
Module->m_ModuleStatus |= MODULE_to_PLACE; Module->m_ModuleStatus |= MODULE_to_PLACE;
break; break;
@ -367,11 +370,11 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC )
for( ii = 0; ii < Board.m_Nrows; ii++ ) for( ii = 0; ii < Board.m_Nrows; ii++ )
{ {
oy = GetBoard()->m_BoundaryBox.m_Pos.y + ( ii * Board.m_GridRouting ); oy = bbbox.m_Pos.y + ( ii * Board.m_GridRouting );
for( jj = 0; jj < Board.m_Ncols; jj++ ) for( jj = 0; jj < Board.m_Ncols; jj++ )
{ {
ox = GetBoard()->m_BoundaryBox.m_Pos.x + (jj * Board.m_GridRouting); ox = bbbox.m_Pos.x + (jj * Board.m_GridRouting);
color = BLACK; color = BLACK;
top_state = GetCell( ii, jj, TOP ); top_state = GetCell( ii, jj, TOP );
@ -408,28 +411,28 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
Board.UnInitBoard(); Board.UnInitBoard();
if( !GetBoard()->ComputeBoundingBox( true ) ) bbbox = GetBoard()->ComputeBoundingBox( true );
if( bbbox.GetWidth() == 0 && bbbox.GetHeight() == 0 )
{ {
DisplayError( this, _( "No PCB edge found, unknown board size!" ) ); DisplayError( this, _( "No PCB edge found, unknown board size!" ) );
return 0; return 0;
} }
/* The boundary box must have its start point on placing grid: */ /* The boundary box must have its start point on placing grid: */
GetBoard()->m_BoundaryBox.m_Pos.x -= GetBoard()->m_BoundaryBox.m_Pos.x % bbbox.m_Pos.x -= bbbox.m_Pos.x % Board.m_GridRouting;
Board.m_GridRouting; bbbox.m_Pos.y -= bbbox.m_Pos.y % Board.m_GridRouting;
GetBoard()->m_BoundaryBox.m_Pos.y -= GetBoard()->m_BoundaryBox.m_Pos.y %
Board.m_GridRouting;
/* The boundary box must have its end point on placing grid: */ /* The boundary box must have its end point on placing grid: */
wxPoint end = GetBoard()->m_BoundaryBox.GetEnd(); wxPoint end = bbbox.GetEnd();
end.x -= end.x % Board.m_GridRouting; end.x -= end.x % Board.m_GridRouting;
end.x += Board.m_GridRouting; end.x += Board.m_GridRouting;
end.y -= end.y % Board.m_GridRouting; end.y -= end.y % Board.m_GridRouting;
end.y += Board.m_GridRouting; end.y += Board.m_GridRouting;
GetBoard()->m_BoundaryBox.SetEnd( end ); bbbox.SetEnd( end );
Nrows = GetBoard()->m_BoundaryBox.GetHeight() / Board.m_GridRouting; Nrows = bbbox.GetHeight() / Board.m_GridRouting;
Ncols = GetBoard()->m_BoundaryBox.GetWidth() / Board.m_GridRouting; Ncols = bbbox.GetWidth() / Board.m_GridRouting;
/* get a small margin for memory allocation: */ /* get a small margin for memory allocation: */
Ncols += 2; Nrows += 2; Ncols += 2; Nrows += 2;
NbCells = Ncols * Nrows; NbCells = Ncols * Nrows;
@ -533,29 +536,29 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
oy = Module->m_BoundaryBox.m_Pos.y - marge; oy = Module->m_BoundaryBox.m_Pos.y - marge;
fy = Module->m_BoundaryBox.GetBottom() + marge; fy = Module->m_BoundaryBox.GetBottom() + marge;
if( ox < GetBoard()->m_BoundaryBox.m_Pos.x ) if( ox < bbbox.m_Pos.x )
ox = GetBoard()->m_BoundaryBox.m_Pos.x; ox = bbbox.m_Pos.x;
if( ox > GetBoard()->m_BoundaryBox.GetRight() ) if( ox > bbbox.GetRight() )
ox = GetBoard()->m_BoundaryBox.GetRight(); ox = bbbox.GetRight();
if( fx < GetBoard()->m_BoundaryBox.m_Pos.x ) if( fx < bbbox.m_Pos.x )
fx = GetBoard()->m_BoundaryBox.m_Pos.x; fx = bbbox.m_Pos.x;
if( fx > GetBoard()->m_BoundaryBox.GetRight() ) if( fx > bbbox.GetRight() )
fx = GetBoard()->m_BoundaryBox.GetRight(); fx = bbbox.GetRight();
if( oy < GetBoard()->m_BoundaryBox.m_Pos.y ) if( oy < bbbox.m_Pos.y )
oy = GetBoard()->m_BoundaryBox.m_Pos.y; oy = bbbox.m_Pos.y;
if( oy > GetBoard()->m_BoundaryBox.GetBottom() ) if( oy > bbbox.GetBottom() )
oy = GetBoard()->m_BoundaryBox.GetBottom(); oy = bbbox.GetBottom();
if( fy < GetBoard()->m_BoundaryBox.m_Pos.y ) if( fy < bbbox.m_Pos.y )
fy = GetBoard()->m_BoundaryBox.m_Pos.y; fy = bbbox.m_Pos.y;
if( fy > GetBoard()->m_BoundaryBox.GetBottom() ) if( fy > bbbox.GetBottom() )
fy = GetBoard()->m_BoundaryBox.GetBottom(); fy = bbbox.GetBottom();
layerMask = 0; layerMask = 0;
@ -598,8 +601,8 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
aModule->DisplayInfo( this ); aModule->DisplayInfo( this );
LastPosOK.x = GetBoard()->m_BoundaryBox.m_Pos.x; LastPosOK.x = bbbox.m_Pos.x;
LastPosOK.y = GetBoard()->m_BoundaryBox.m_Pos.y; LastPosOK.y = bbbox.m_Pos.y;
cx = aModule->m_Pos.x; cy = aModule->m_Pos.y; cx = aModule->m_Pos.x; cy = aModule->m_Pos.y;
ox = aModule->m_BoundaryBox.m_Pos.x - cx; ox = aModule->m_BoundaryBox.m_Pos.x - cx;
@ -607,8 +610,8 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
oy = aModule->m_BoundaryBox.m_Pos.y - cy; oy = aModule->m_BoundaryBox.m_Pos.y - cy;
fy = aModule->m_BoundaryBox.m_Size.y + oy; fy = aModule->m_BoundaryBox.m_Size.y + oy;
CurrPosition.x = GetBoard()->m_BoundaryBox.m_Pos.x - ox; CurrPosition.x = bbbox.m_Pos.x - ox;
CurrPosition.y = GetBoard()->m_BoundaryBox.m_Pos.y - oy; CurrPosition.y = bbbox.m_Pos.y - oy;
/* Module placement on grid. */ /* Module placement on grid. */
CurrPosition.x -= CurrPosition.x % Board.m_GridRouting; CurrPosition.x -= CurrPosition.x % Board.m_GridRouting;
@ -647,7 +650,7 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
mincout = -1.0; mincout = -1.0;
SetStatusText( wxT( "Score ??, pos ??" ) ); SetStatusText( wxT( "Score ??, pos ??" ) );
for( ; CurrPosition.x < GetBoard()->m_BoundaryBox.GetRight() - fx; for( ; CurrPosition.x < bbbox.GetRight() - fx;
CurrPosition.x += Board.m_GridRouting ) CurrPosition.x += Board.m_GridRouting )
{ {
wxYield(); wxYield();
@ -667,14 +670,14 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
DrawModuleOutlines( DrawPanel, aDC, aModule ); DrawModuleOutlines( DrawPanel, aDC, aModule );
g_Offset_Module.x = cx - CurrPosition.x; g_Offset_Module.x = cx - CurrPosition.x;
CurrPosition.y = GetBoard()->m_BoundaryBox.m_Pos.y - oy; CurrPosition.y = bbbox.m_Pos.y - oy;
/* Placement on grid. */ /* Placement on grid. */
CurrPosition.y -= CurrPosition.y % Board.m_GridRouting; CurrPosition.y -= CurrPosition.y % Board.m_GridRouting;
DrawModuleOutlines( DrawPanel, aDC, aModule ); DrawModuleOutlines( DrawPanel, aDC, aModule );
for( ; CurrPosition.y < GetBoard()->m_BoundaryBox.GetBottom() - fy; for( ; CurrPosition.y < bbbox.GetBottom() - fy;
CurrPosition.y += Board.m_GridRouting ) CurrPosition.y += Board.m_GridRouting )
{ {
/* Erase traces. */ /* Erase traces. */
@ -748,10 +751,10 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
int row_min, row_max, col_min, col_max; int row_min, row_max, col_min, col_max;
unsigned int data; unsigned int data;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; ux0 -= Pcb->GetBoundingBox().m_Pos.x;
uy0 -= Pcb->m_BoundaryBox.m_Pos.y; uy0 -= Pcb->GetBoundingBox().m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; ux1 -= Pcb->GetBoundingBox().m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y; uy1 -= Pcb->GetBoundingBox().m_Pos.y;
row_max = uy1 / Board.m_GridRouting; row_max = uy1 / Board.m_GridRouting;
col_max = ux1 / Board.m_GridRouting; col_max = ux1 / Board.m_GridRouting;
@ -805,10 +808,10 @@ unsigned int CalculateKeepOutArea( BOARD* Pcb, int ux0, int uy0, int ux1, int uy
int row_min, row_max, col_min, col_max; int row_min, row_max, col_min, col_max;
unsigned int keepOut; unsigned int keepOut;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; ux0 -= Pcb->GetBoundingBox().m_Pos.x;
uy0 -= Pcb->m_BoundaryBox.m_Pos.y; uy0 -= Pcb->GetBoundingBox().m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; ux1 -= Pcb->GetBoundingBox().m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y; uy1 -= Pcb->GetBoundingBox().m_Pos.y;
row_max = uy1 / Board.m_GridRouting; row_max = uy1 / Board.m_GridRouting;
col_max = ux1 / Board.m_GridRouting; col_max = ux1 / Board.m_GridRouting;
@ -979,10 +982,10 @@ static void CreateKeepOutRectangle( BOARD* Pcb,
if( trace == 0 ) if( trace == 0 )
return; return;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; ux0 -= Pcb->GetBoundingBox().m_Pos.x;
uy0 -= Pcb->m_BoundaryBox.m_Pos.y; uy0 -= Pcb->GetBoundingBox().m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; ux1 -= Pcb->GetBoundingBox().m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y; uy1 -= Pcb->GetBoundingBox().m_Pos.y;
ux0 -= marge; ux1 += marge; ux0 -= marge; ux1 += marge;
uy0 -= marge; uy1 += marge; uy0 -= marge; uy1 += marge;

View File

@ -110,6 +110,8 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* father,
PCB_BASE_FRAME::~PCB_BASE_FRAME() PCB_BASE_FRAME::~PCB_BASE_FRAME()
{ {
delete m_Collector; delete m_Collector;
// delete m_Pcb;
} }
@ -122,19 +124,55 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
} }
EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
{
wxASSERT( m_Pcb );
EDA_RECT area = m_Pcb->ComputeBoundingBox( aBoardEdgesOnly );
if( area.GetWidth() == 0 && area.GetHeight() == 0 )
{
if( m_Draw_Sheet_Ref )
{
area.SetOrigin( 0, 0 );
area.SetEnd( GetScreen()->ReturnPageSize().x,
GetScreen()->ReturnPageSize().y );
}
else
{
area.SetOrigin( -GetScreen()->ReturnPageSize().x / 2,
-GetScreen()->ReturnPageSize().y / 2 );
area.SetEnd( GetScreen()->ReturnPageSize().x / 2,
GetScreen()->ReturnPageSize().y / 2 );
}
}
return area;
}
BOARD_DESIGN_SETTINGS* PCB_BASE_FRAME::GetDesignSettings()
{
wxASSERT( m_Pcb );
return m_Pcb ? &m_Pcb->GetDesignSettings() : NULL;
}
double PCB_BASE_FRAME::BestZoom( void ) double PCB_BASE_FRAME::BestZoom( void )
{ {
int dx, dy; int dx, dy;
double ii, jj; double ii, jj;
wxSize size; wxSize size;
if( m_Pcb == NULL ) if( m_Pcb == NULL )
return 32.0; return 32.0;
m_Pcb->ComputeBoundingBox(); EDA_RECT bbbox = GetBoardBoundingBox();
dx = bbbox.GetWidth();
dy = bbbox.GetHeight();
dx = m_Pcb->m_BoundaryBox.GetWidth();
dy = m_Pcb->m_BoundaryBox.GetHeight();
size = DrawPanel->GetClientSize(); size = DrawPanel->GetClientSize();
if( size.x ) if( size.x )
@ -149,7 +187,7 @@ double PCB_BASE_FRAME::BestZoom( void )
double bestzoom = MAX( ii, jj ); double bestzoom = MAX( ii, jj );
GetScreen()->SetScrollCenterPosition( m_Pcb->m_BoundaryBox.Centre() ); GetScreen()->SetScrollCenterPosition( bbbox.Centre() );
return bestzoom ; return bestzoom ;
} }

View File

@ -48,20 +48,25 @@ bool MATRIX_ROUTING_HEAD::ComputeMatrixSize( BOARD* aPcb )
{ {
aPcb->ComputeBoundingBox(); aPcb->ComputeBoundingBox();
/* The boundary box must have its start point on routing grid: */ // The boundary box must have its start point on routing grid:
aPcb->m_BoundaryBox.m_Pos.x -= aPcb->m_BoundaryBox.m_Pos.x % m_GridRouting; m_BrdBox = aPcb->GetBoundingBox();
aPcb->m_BoundaryBox.m_Pos.y -= aPcb->m_BoundaryBox.m_Pos.y % m_GridRouting;
m_BrdBox = aPcb->m_BoundaryBox;
/* The boundary box must have its end point on routing grid: */ m_BrdBox.m_Pos.x -= m_BrdBox.m_Pos.x % m_GridRouting;
m_BrdBox.m_Pos.y -= m_BrdBox.m_Pos.y % m_GridRouting;
// The boundary box must have its end point on routing grid:
wxPoint end = m_BrdBox.GetEnd(); wxPoint end = m_BrdBox.GetEnd();
end.x -= end.x % m_GridRouting; end.x -= end.x % m_GridRouting;
end.x += m_GridRouting; end.x += m_GridRouting;
end.y -= end.y % m_GridRouting; end.y -= end.y % m_GridRouting;
end.y += m_GridRouting; end.y += m_GridRouting;
aPcb->m_BoundaryBox.SetEnd( end );
m_BrdBox.SetEnd(end); m_BrdBox.SetEnd(end);
aPcb->SetBoundingBox( m_BrdBox );
m_Nrows = Nrows = m_BrdBox.m_Size.y / m_GridRouting; m_Nrows = Nrows = m_BrdBox.m_Size.y / m_GridRouting;
m_Ncols = Ncols = m_BrdBox.m_Size.x / m_GridRouting; m_Ncols = Ncols = m_BrdBox.m_Size.x / m_GridRouting;
@ -330,12 +335,14 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
int Build_Work( BOARD* Pcb ) int Build_Work( BOARD* Pcb )
{ {
RATSNEST_ITEM* pt_rats; RATSNEST_ITEM* pt_rats;
D_PAD* pt_pad; D_PAD* pt_pad;
int r1, r2, c1, c2, current_net_code; int r1, r2, c1, c2, current_net_code;
RATSNEST_ITEM* pt_ch; RATSNEST_ITEM* pt_ch;
int demi_pas = Board.m_GridRouting / 2; int demi_pas = Board.m_GridRouting / 2;
wxString msg; wxString msg;
EDA_RECT bbbox = Pcb->GetBoundingBox();
InitWork(); /* clear work list */ InitWork(); /* clear work list */
Ntotal = 0; Ntotal = 0;
@ -361,48 +368,48 @@ int Build_Work( BOARD* Pcb )
current_net_code = pt_pad->GetNet(); current_net_code = pt_pad->GetNet();
pt_ch = pt_rats; pt_ch = pt_rats;
r1 = ( pt_pad->GetPosition().y - Pcb->m_BoundaryBox.m_Pos.y r1 = ( pt_pad->GetPosition().y - bbbox.m_Pos.y
+ demi_pas ) / Board.m_GridRouting; + demi_pas ) / Board.m_GridRouting;
if( r1 < 0 || r1 >= Nrows ) if( r1 < 0 || r1 >= Nrows )
{ {
msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r1, msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r1,
pt_pad->GetPosition().y, Pcb->m_BoundaryBox.m_Pos.y ); pt_pad->GetPosition().y, bbbox.m_Pos.y );
wxMessageBox( msg ); wxMessageBox( msg );
return 0; return 0;
} }
c1 = ( pt_pad->GetPosition().x - Pcb->m_BoundaryBox.m_Pos.x c1 = ( pt_pad->GetPosition().x - bbbox.m_Pos.x
+ demi_pas ) / Board.m_GridRouting; + demi_pas ) / Board.m_GridRouting;
if( c1 < 0 || c1 >= Ncols ) if( c1 < 0 || c1 >= Ncols )
{ {
msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c1, msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c1,
pt_pad->GetPosition().x, Pcb->m_BoundaryBox.m_Pos.x ); pt_pad->GetPosition().x, bbbox.m_Pos.x );
wxMessageBox( msg ); wxMessageBox( msg );
return 0; return 0;
} }
pt_pad = pt_rats->m_PadEnd; pt_pad = pt_rats->m_PadEnd;
r2 = ( pt_pad->GetPosition().y - Pcb->m_BoundaryBox.m_Pos.y r2 = ( pt_pad->GetPosition().y - bbbox.m_Pos.y
+ demi_pas ) / Board.m_GridRouting; + demi_pas ) / Board.m_GridRouting;
if( r2 < 0 || r2 >= Nrows ) if( r2 < 0 || r2 >= Nrows )
{ {
msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r2, msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r2,
pt_pad->GetPosition().y, Pcb->m_BoundaryBox.m_Pos.y ); pt_pad->GetPosition().y, bbbox.m_Pos.y );
wxMessageBox( msg ); wxMessageBox( msg );
return 0; return 0;
} }
c2 = ( pt_pad->GetPosition().x - Pcb->m_BoundaryBox.m_Pos.x c2 = ( pt_pad->GetPosition().x - bbbox.m_Pos.x
+ demi_pas ) / Board.m_GridRouting; + demi_pas ) / Board.m_GridRouting;
if( c2 < 0 || c2 >= Ncols ) if( c2 < 0 || c2 >= Ncols )
{ {
msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c2, msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c2,
pt_pad->GetPosition().x, Pcb->m_BoundaryBox.m_Pos.x ); pt_pad->GetPosition().x, bbbox.m_Pos.x );
wxMessageBox( msg ); wxMessageBox( msg );
return 0; return 0;
} }

View File

@ -10,6 +10,7 @@
#include "common.h" #include "common.h"
#include "pcbcommon.h" #include "pcbcommon.h"
#include "wxBasePcbFrame.h" #include "wxBasePcbFrame.h"
#include "build_version.h" // BOARD_FILE_VERSION
#include "pcbnew.h" #include "pcbnew.h"
#include "colors_selection.h" #include "colors_selection.h"
@ -27,18 +28,14 @@
wxPoint BOARD_ITEM::ZeroOffset( 0, 0 ); wxPoint BOARD_ITEM::ZeroOffset( 0, 0 );
// Current design settings (used also to read configs): BOARD::BOARD() :
BOARD_DESIGN_SETTINGS boardDesignSettings;
BOARD::BOARD( PCB_BASE_FRAME* frame ) :
BOARD_ITEM( (BOARD_ITEM*) NULL, PCB_T ), BOARD_ITEM( (BOARD_ITEM*) NULL, PCB_T ),
m_NetClasses( this ) m_NetClasses( this )
{ {
m_PcbFrame = frame; // we have not loaded a board yet, assume latest until then.
m_fileFormatVersionAtLoad = BOARD_FILE_VERSION;
m_Status_Pcb = 0; // Status word: bit 1 = calculate. m_Status_Pcb = 0; // Status word: bit 1 = calculate.
SetBoardDesignSettings( &boardDesignSettings );
SetColorsSettings( &g_ColorsSettings ); SetColorsSettings( &g_ColorsSettings );
m_NbNodes = 0; // Number of connected pads. m_NbNodes = 0; // Number of connected pads.
m_NbNoconnect = 0; // Number of unconnected nets. m_NbNoconnect = 0; // Number of unconnected nets.
@ -69,8 +66,12 @@ BOARD::BOARD( PCB_BASE_FRAME* frame ) :
BOARD::~BOARD() BOARD::~BOARD()
{ {
/* @todo
NO! this has nothing to do with a BOARD
Do this in the UI, not in the storage container please.
if( m_PcbFrame && m_PcbFrame->GetScreen() ) if( m_PcbFrame && m_PcbFrame->GetScreen() )
m_PcbFrame->GetScreen()->ClearUndoRedoList(); m_PcbFrame->GetScreen()->ClearUndoRedoList();
*/
while( m_ZoneDescriptorList.size() ) while( m_ZoneDescriptorList.size() )
{ {
@ -92,6 +93,13 @@ BOARD::~BOARD()
} }
void BOARD::SetDesignSettings( const BOARD_DESIGN_SETTINGS& aDesignSettings )
{
// copy all members.
m_designSettings = aDesignSettings;
}
void BOARD::chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* aList ) void BOARD::chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* aList )
{ {
TRACK* segment; // The current segment being analyzed. TRACK* segment; // The current segment being analyzed.
@ -466,36 +474,36 @@ LAYER_T LAYER::ParseType( const char* aType )
int BOARD::GetCopperLayerCount() const int BOARD::GetCopperLayerCount() const
{ {
return GetBoardDesignSettings()->GetCopperLayerCount(); return m_designSettings.GetCopperLayerCount();
} }
void BOARD::SetCopperLayerCount( int aCount ) void BOARD::SetCopperLayerCount( int aCount )
{ {
GetBoardDesignSettings()->SetCopperLayerCount( aCount ); m_designSettings.SetCopperLayerCount( aCount );
} }
int BOARD::GetEnabledLayers() const int BOARD::GetEnabledLayers() const
{ {
return GetBoardDesignSettings()->GetEnabledLayers(); return m_designSettings.GetEnabledLayers();
} }
int BOARD::GetVisibleLayers() const int BOARD::GetVisibleLayers() const
{ {
return GetBoardDesignSettings()->GetVisibleLayers(); return m_designSettings.GetVisibleLayers();
} }
void BOARD::SetEnabledLayers( int aLayerMask ) void BOARD::SetEnabledLayers( int aLayerMask )
{ {
GetBoardDesignSettings()->SetEnabledLayers( aLayerMask ); m_designSettings.SetEnabledLayers( aLayerMask );
} }
void BOARD::SetVisibleLayers( int aLayerMask ) void BOARD::SetVisibleLayers( int aLayerMask )
{ {
GetBoardDesignSettings()->SetVisibleLayers( aLayerMask ); m_designSettings.SetVisibleLayers( aLayerMask );
} }
@ -529,13 +537,13 @@ void BOARD::SetVisibleAlls( )
int BOARD::GetVisibleElements() const int BOARD::GetVisibleElements() const
{ {
return GetBoardDesignSettings()->GetVisibleElements(); return m_designSettings.GetVisibleElements();
} }
bool BOARD::IsElementVisible( int aPCB_VISIBLE ) const bool BOARD::IsElementVisible( int aPCB_VISIBLE ) const
{ {
return GetBoardDesignSettings()->IsElementVisible( aPCB_VISIBLE ); return m_designSettings.IsElementVisible( aPCB_VISIBLE );
} }
@ -544,7 +552,7 @@ void BOARD::SetElementVisibility( int aPCB_VISIBLE, bool isEnabled )
switch( aPCB_VISIBLE ) switch( aPCB_VISIBLE )
{ {
case RATSNEST_VISIBLE: case RATSNEST_VISIBLE:
GetBoardDesignSettings()->SetElementVisibility( aPCB_VISIBLE, isEnabled ); m_designSettings.SetElementVisibility( aPCB_VISIBLE, isEnabled );
// we must clear or set the CH_VISIBLE flags to hide/show ratsnet // we must clear or set the CH_VISIBLE flags to hide/show ratsnet
// because we have a tool to show hide ratsnest relative to a pad or a module // because we have a tool to show hide ratsnest relative to a pad or a module
// so the hide/show option is a per item selection // so the hide/show option is a per item selection
@ -563,7 +571,7 @@ void BOARD::SetElementVisibility( int aPCB_VISIBLE, bool isEnabled )
default: default:
GetBoardDesignSettings()->SetElementVisibility( aPCB_VISIBLE, isEnabled ); m_designSettings.SetElementVisibility( aPCB_VISIBLE, isEnabled );
} }
} }
@ -829,7 +837,7 @@ unsigned BOARD::GetNodesCount()
} }
bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly )
{ {
bool hasItems = false; bool hasItems = false;
EDA_RECT area; EDA_RECT area;
@ -898,26 +906,9 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly )
} }
} }
if( !hasItems && m_PcbFrame ) m_BoundingBox = area; // save for BOARD::GetBoundingBox()
{
if( m_PcbFrame->m_Draw_Sheet_Ref )
{
area.SetOrigin( 0, 0 );
area.SetEnd( m_PcbFrame->GetScreen()->ReturnPageSize().x,
m_PcbFrame->GetScreen()->ReturnPageSize().y );
}
else
{
area.SetOrigin( -m_PcbFrame->GetScreen()->ReturnPageSize().x / 2,
-m_PcbFrame->GetScreen()->ReturnPageSize().y / 2 );
area.SetEnd( m_PcbFrame->GetScreen()->ReturnPageSize().x / 2,
m_PcbFrame->GetScreen()->ReturnPageSize().y / 2 );
}
}
m_BoundaryBox = area; return area;
return hasItems;
} }
@ -1782,7 +1773,7 @@ TRACK* BOARD::GetTrace( TRACK* aTrace, const wxPoint& aPosition, int aLayerMask
if( track->GetState( BUSY | IS_DELETED ) ) if( track->GetState( BUSY | IS_DELETED ) )
continue; continue;
if( GetBoardDesignSettings()->IsLayerVisible( layer ) == false ) if( m_designSettings.IsLayerVisible( layer ) == false )
continue; continue;
if( track->Type() == PCB_VIA_T ) /* VIA encountered. */ if( track->Type() == PCB_VIA_T ) /* VIA encountered. */

View File

@ -152,28 +152,24 @@ private:
typedef std::vector<MARKER_PCB*> MARKERS; typedef std::vector<MARKER_PCB*> MARKERS;
/// MARKER_PCBs for clearance problems, owned by pointer. /// MARKER_PCBs for clearance problems, owned by pointer.
MARKERS m_markers; MARKERS m_markers;
// @todo: switch to boost::ptr_vector, and change ~BOARD() // @todo: switch to boost::ptr_vector, and change ~BOARD()
typedef std::vector<ZONE_CONTAINER*> ZONE_CONTAINERS; typedef std::vector<ZONE_CONTAINER*> ZONE_CONTAINERS;
/// edge zone descriptors, owned by pointer. /// edge zone descriptors, owned by pointer.
ZONE_CONTAINERS m_ZoneDescriptorList; ZONE_CONTAINERS m_ZoneDescriptorList;
LAYER m_Layer[NB_COPPER_LAYERS]; LAYER m_Layer[NB_COPPER_LAYERS];
// if true m_hightLight_NetCode is used // if true m_hightLight_NetCode is used
HIGH_LIGHT_INFO m_hightLight; // current high light data HIGH_LIGHT_INFO m_hightLight; // current high light data
HIGH_LIGHT_INFO m_hightLightPrevious; // a previously stored high light data HIGH_LIGHT_INFO m_hightLightPrevious; // a previously stored high light data
int m_fileFormatVersionAtLoad; ///< the version in the *.brd header on first line
EDA_RECT m_BoundingBox;
public: public:
PCB_BASE_FRAME* m_PcbFrame; // Window of visualization
void SetWindowFrame( PCB_BASE_FRAME* aFrame )
{
m_PcbFrame = aFrame;
}
EDA_RECT m_BoundaryBox; // Board size and position
/// Flags used in ratsnest calculation and update. /// Flags used in ratsnest calculation and update.
int m_Status_Pcb; int m_Status_Pcb;
@ -184,29 +180,29 @@ public:
/// Active ratsnest count (ratsnests not already connected by tracks) /// Active ratsnest count (ratsnests not already connected by tracks)
int m_NbNoconnect; int m_NbNoconnect;
DLIST<BOARD_ITEM> m_Drawings; // linked list of lines & texts DLIST<BOARD_ITEM> m_Drawings; // linked list of lines & texts
DLIST<MODULE> m_Modules; // linked list of MODULEs DLIST<MODULE> m_Modules; // linked list of MODULEs
DLIST<TRACK> m_Track; // linked list of TRACKs and SEGVIAs DLIST<TRACK> m_Track; // linked list of TRACKs and SEGVIAs
DLIST<SEGZONE> m_Zone; // linked list of SEGZONEs DLIST<SEGZONE> m_Zone; // linked list of SEGZONEs
/// nets info list (name, design constraints .. /// nets info list (name, design constraints ..
NETINFO_LIST* m_NetInfo; NETINFO_LIST* m_NetInfo;
/// Ratsnest list for the BOARD /// Ratsnest list for the BOARD
std::vector<RATSNEST_ITEM> m_FullRatsnest; std::vector<RATSNEST_ITEM> m_FullRatsnest;
/// Ratsnest list relative to a given footprint (used while moving a footprint). /// Ratsnest list relative to a given footprint (used while moving a footprint).
std::vector<RATSNEST_ITEM> m_LocalRatsnest; std::vector<RATSNEST_ITEM> m_LocalRatsnest;
/// zone contour currently in progress /// zone contour currently in progress
ZONE_CONTAINER* m_CurrentZoneContour; ZONE_CONTAINER* m_CurrentZoneContour;
/// List of current netclasses. There is always the default netclass. /// List of current netclasses. There is always the default netclass.
NETCLASSES m_NetClasses; NETCLASSES m_NetClasses;
/// Current net class name used to display netclass info. /// Current net class name used to display netclass info.
/// This is also the last used netclass after starting a track. /// This is also the last used netclass after starting a track.
wxString m_CurrentNetClassName; wxString m_CurrentNetClassName;
// handling of vias and tracks size: // handling of vias and tracks size:
// the first value is always the value of the current NetClass // the first value is always the value of the current NetClass
@ -228,7 +224,7 @@ public:
unsigned m_TrackWidthSelector; unsigned m_TrackWidthSelector;
private: private:
BOARD_DESIGN_SETTINGS* m_boardDesignSettings; // Link to current design settings BOARD_DESIGN_SETTINGS m_designSettings;
COLORS_DESIGN_SETTINGS* m_colorsSettings; // Link to current colors settings COLORS_DESIGN_SETTINGS* m_colorsSettings; // Link to current colors settings
/** /**
@ -243,9 +239,13 @@ private:
void chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* aList ); void chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* aList );
public: public:
BOARD( PCB_BASE_FRAME* frame ); BOARD();
~BOARD(); ~BOARD();
void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
int GetFileFormatVersionAtLoad() const { return m_fileFormatVersionAtLoad; }
/** /**
* Function GetDefaultLayerName * Function GetDefaultLayerName
* returns a default name of a PCB layer when given \a aLayerNumber. This * returns a default name of a PCB layer when given \a aLayerNumber. This
@ -275,7 +275,6 @@ public:
#define ADD_APPEND 1 ///< aControl flag for Add( aControl ), appends not inserts #define ADD_APPEND 1 ///< aControl flag for Add( aControl ), appends not inserts
/** /**
* Function Delete * Function Delete
* removes the given single item from this BOARD and deletes its memory. * removes the given single item from this BOARD and deletes its memory.
@ -427,7 +426,7 @@ public:
*/ */
bool IsLayerEnabled( int aLayer ) const bool IsLayerEnabled( int aLayer ) const
{ {
return GetBoardDesignSettings()->IsLayerEnabled( aLayer ); return m_designSettings.IsLayerEnabled( aLayer );
} }
/** /**
@ -439,7 +438,7 @@ public:
*/ */
bool IsLayerVisible( int aLayerIndex ) const bool IsLayerVisible( int aLayerIndex ) const
{ {
return GetBoardDesignSettings()->IsLayerVisible( aLayerIndex ); return m_designSettings.IsLayerVisible( aLayerIndex );
} }
/** /**
@ -524,24 +523,20 @@ public:
void SetVisibleElementColor( int aPCB_VISIBLE, int aColor ); void SetVisibleElementColor( int aPCB_VISIBLE, int aColor );
/** /**
* Function GetBoardDesignSettings * Function GetDesignSettings
* @return the current BOARD_DESIGN_SETTINGS in use * @return the BOARD_DESIGN_SETTINGS for this BOARD
*/ */
BOARD_DESIGN_SETTINGS* GetBoardDesignSettings() const // const BOARD_DESIGN_SETTINGS& GetDesignSettings() const want to use this one
BOARD_DESIGN_SETTINGS& GetDesignSettings()
{ {
return m_boardDesignSettings; return m_designSettings;
} }
/** /**
* Function SetBoardDesignSettings * Function SetDesignSettings
* @param aDesignSettings = the new BOARD_DESIGN_SETTINGS to use * @param aDesignSettings the new BOARD_DESIGN_SETTINGS to use
*/ */
void SetBoardDesignSettings( BOARD_DESIGN_SETTINGS* aDesignSettings) void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aDesignSettings );
{
m_boardDesignSettings = aDesignSettings;
}
/** /**
* Function SetBoardSettings * Function SetBoardSettings
@ -652,9 +647,20 @@ public:
* Function ComputeBoundingBox * Function ComputeBoundingBox
* calculates the bounding box containing all board items (or board edge segments). * calculates the bounding box containing all board items (or board edge segments).
* @param aBoardEdgesOnly is true if we are interested in board edge segments only. * @param aBoardEdgesOnly is true if we are interested in board edge segments only.
* @return bool - True if items (or board edge segments) were found. * @return EDA_RECT - the board's bounding box
* @see PCB_BASE_FRAME::GetBoardBoundingBox() which calls this and doctors the result
*/ */
bool ComputeBoundingBox( bool aBoardEdgesOnly = false ); EDA_RECT ComputeBoundingBox( bool aBoardEdgesOnly = false );
/**
* Function GetBoundingBox
* may be called soon after ComputeBoundingBox() to return the same EDA_RECT,
* as long as the BOARD has not changed. Remember, ComputeBoundingBox()'s
* aBoardEdgesOnly argument is considered in this return value also.
*/
EDA_RECT GetBoundingBox() const { return m_BoundingBox; } // override
void SetBoundingBox( const EDA_RECT& aBox ) { m_BoundingBox = aBox; }
/** /**
* Function DisplayInfo * Function DisplayInfo

View File

@ -17,7 +17,7 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS()
{ {
m_EnabledLayers = ALL_LAYERS; // All layers enabled at first. m_EnabledLayers = ALL_LAYERS; // All layers enabled at first.
// SetCopperLayerCount() will adjust this. // SetCopperLayerCount() will adjust this.
SetVisibleAlls( ); // All layers and all elements visible at first. SetVisibleAlls(); // All layers and all elements visible at first.
SetCopperLayerCount( 2 ); // Default design is a double sided board SetCopperLayerCount( 2 ); // Default design is a double sided board
@ -47,7 +47,6 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS()
// Layer thickness for 3D viewer // Layer thickness for 3D viewer
m_BoardThickness = (int)(1.6 * PCB_INTERNAL_UNIT / 25.4); m_BoardThickness = (int)(1.6 * PCB_INTERNAL_UNIT / 25.4);
} }

View File

@ -35,11 +35,9 @@
#include "class_netclass.h" #include "class_netclass.h"
// Current design settings (used also to read configs):
extern BOARD_DESIGN_SETTINGS boardDesignSettings;
// This will get mapped to "kicad_default" in the specctra_export. // This will get mapped to "kicad_default" in the specctra_export.
const wxString NETCLASS::Default = wxT("Default"); const wxString NETCLASS::Default = wxT("Default");
// Initial values for netclass initialization // Initial values for netclass initialization
int NETCLASS::DEFAULT_CLEARANCE = 100; // track to track and track to pads clearance int NETCLASS::DEFAULT_CLEARANCE = 100; // track to track and track to pads clearance
int NETCLASS::DEFAULT_VIA_DRILL = 250; // default via drill int NETCLASS::DEFAULT_VIA_DRILL = 250; // default via drill
@ -68,16 +66,17 @@ void NETCLASS::SetParams( const NETCLASS* defaults )
SetuViaDrill( defaults->GetuViaDrill() ); SetuViaDrill( defaults->GetuViaDrill() );
} }
else else
{ // We should use m_Parent->GetBoardDesignSettings() { // We should use m_Parent->GetDesignSettings()
// But when the NETCLASSES constructor is called // But when the NETCLASSES constructor is called
// (it call NETCLASS constructor), the m_Parent constructor (see BOARD::BOARD) // (it call NETCLASS constructor), the m_Parent constructor (see BOARD::BOARD)
// is not run, and GetBoardDesignSettings() return a bad value // is not run, and GetDesignSettings() return a bad value
// TODO: see how change that. // TODO: see how change that.
const BOARD_DESIGN_SETTINGS& g = boardDesignSettings; const BOARD_DESIGN_SETTINGS& g = m_Parent->GetDesignSettings(); // like that?
SetTrackWidth( g.m_TrackMinWidth ); SetTrackWidth( g.m_TrackMinWidth );
SetViaDiameter( g.m_ViasMinSize ); SetViaDiameter( g.m_ViasMinSize );
SetuViaDiameter(g.m_MicroViasMinSize ); SetuViaDiameter(g.m_MicroViasMinSize );
// Use default values for next parameters: // Use default values for next parameters:
SetClearance( DEFAULT_CLEARANCE ); SetClearance( DEFAULT_CLEARANCE );
SetViaDrill( DEFAULT_VIA_DRILL ); SetViaDrill( DEFAULT_VIA_DRILL );
@ -410,27 +409,26 @@ bool NETCLASS::ReadDescr( LINE_READER* aReader )
int NETCLASS::GetTrackMinWidth() const int NETCLASS::GetTrackMinWidth() const
{ {
return m_Parent->GetBoardDesignSettings()->m_TrackMinWidth; return m_Parent->GetDesignSettings().m_TrackMinWidth;
} }
int NETCLASS::GetViaMinDiameter() const int NETCLASS::GetViaMinDiameter() const
{ {
return m_Parent->GetBoardDesignSettings()->m_ViasMinSize; return m_Parent->GetDesignSettings().m_ViasMinSize;
} }
int NETCLASS::GetViaMinDrill() const int NETCLASS::GetViaMinDrill() const
{ {
return m_Parent->GetBoardDesignSettings()->m_ViasMinDrill; return m_Parent->GetDesignSettings().m_ViasMinDrill;
} }
int NETCLASS::GetuViaMinDiameter() const int NETCLASS::GetuViaMinDiameter() const
{ {
return m_Parent->GetBoardDesignSettings()->m_MicroViasMinSize; return m_Parent->GetDesignSettings().m_MicroViasMinSize;
} }
int NETCLASS::GetuViaMinDrill() const int NETCLASS::GetuViaMinDrill() const
{ {
return m_Parent->GetBoardDesignSettings()->m_MicroViasMinDrill; return m_Parent->GetDesignSettings().m_MicroViasMinDrill;
} }

View File

@ -304,7 +304,7 @@ int D_PAD::GetSolderMaskMargin()
if( margin == 0 ) if( margin == 0 )
{ {
BOARD * brd = GetBoard(); BOARD * brd = GetBoard();
margin = brd->GetBoardDesignSettings()->m_SolderMaskMargin; margin = brd->GetDesignSettings().m_SolderMaskMargin;
} }
} }
@ -344,14 +344,14 @@ wxSize D_PAD::GetSolderPasteMargin()
BOARD * brd = GetBoard(); BOARD * brd = GetBoard();
if( margin == 0 ) if( margin == 0 )
margin = brd->GetBoardDesignSettings()->m_SolderPasteMargin; margin = brd->GetDesignSettings().m_SolderPasteMargin;
if( mratio == 0.0 ) if( mratio == 0.0 )
mratio = module->m_LocalSolderPasteMarginRatio; mratio = module->m_LocalSolderPasteMarginRatio;
if( mratio == 0.0 ) if( mratio == 0.0 )
{ {
mratio = brd->GetBoardDesignSettings()->m_SolderPasteMarginRatio; mratio = brd->GetDesignSettings().m_SolderPasteMarginRatio;
} }
} }

View File

@ -59,7 +59,7 @@ public:
} }
void SetVisible( bool isVisible ) { m_NoShow = !isVisible; } void SetVisible( bool isVisible ) { m_NoShow = !isVisible; }
void SetInvisible( bool isHidden ) { m_NoShow = isHidden; } bool IsVisible() const { return !m_NoShow; }
void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; } void SetPos0( const wxPoint& aPos ) { m_Pos0 = aPos; }

View File

@ -843,16 +843,22 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
m_CornerSelection = -1; // Set to not found m_CornerSelection = -1; // Set to not found
// distance (in internal units) to detect a corner in a zone outline. // distance (in internal units) to detect a corner in a zone outline.
// @todo use a scaling factor here of actual screen coordinates, so that
// when nanometers come, it still works.
#define CORNER_MIN_DIST 100 #define CORNER_MIN_DIST 100
int min_dist = CORNER_MIN_DIST + 1; int min_dist = CORNER_MIN_DIST + 1;
#if 0
// Dick: I don't see this as reasonable. The mouse distance from the zone is
// not a function of the grid, it is a fixed number of pixels, regardless of zoom.
if( GetBoard() && GetBoard()->m_PcbFrame ) if( GetBoard() && GetBoard()->m_PcbFrame )
{ {
// Use grid size because it is known // Use grid size because it is known
wxRealPoint grid = GetBoard()->m_PcbFrame->DrawPanel->GetGrid(); wxRealPoint grid = GetBoard()->m_PcbFrame->DrawPanel->GetGrid();
min_dist = wxRound( MIN( grid.x, grid.y ) ); min_dist = wxRound( MIN( grid.x, grid.y ) );
} }
#endif
wxPoint delta; wxPoint delta;
unsigned lim = m_Poly->corner.size(); unsigned lim = m_Poly->corner.size();
@ -861,6 +867,7 @@ bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
{ {
delta.x = refPos.x - m_Poly->corner[item_pos].x; delta.x = refPos.x - m_Poly->corner[item_pos].x;
delta.y = refPos.y - m_Poly->corner[item_pos].y; delta.y = refPos.y - m_Poly->corner[item_pos].y;
// Calculate a distance: // Calculate a distance:
int dist = MAX( abs( delta.x ), abs( delta.y ) ); int dist = MAX( abs( delta.x ), abs( delta.y ) );
@ -881,15 +888,23 @@ bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
m_CornerSelection = -1; // Set to not found m_CornerSelection = -1; // Set to not found
// @todo use a scaling factor here of actual screen coordinates, so that
// when nanometers come, it still works. This should be done in screen coordinates
// not internal units.
#define EDGE_MIN_DIST 200 // distance (in internal units) to detect a zone outline #define EDGE_MIN_DIST 200 // distance (in internal units) to detect a zone outline
int min_dist = EDGE_MIN_DIST+1; int min_dist = EDGE_MIN_DIST+1;
#if 0
// Dick: I don't see this as reasonable. The mouse distance from the zone is
// not a function of the grid, it is a fixed number of pixels, regardless of zoom.
if( GetBoard() && GetBoard()->m_PcbFrame ) if( GetBoard() && GetBoard()->m_PcbFrame )
{ {
// Use grid size because it is known // Use grid size because it is known
wxRealPoint grid = GetBoard()->m_PcbFrame->DrawPanel->GetGrid(); wxRealPoint grid = GetBoard()->m_PcbFrame->DrawPanel->GetGrid();
min_dist = wxRound( MIN( grid.x, grid.y ) ); min_dist = wxRound( MIN( grid.x, grid.y ) );
} }
#endif
unsigned first_corner_pos = 0; unsigned first_corner_pos = 0;

View File

@ -213,18 +213,18 @@ void DIALOG_DESIGN_RULES::PrintCurrentSettings()
// Display min values: // Display min values:
value = ReturnStringFromValue( g_UserUnit, value = ReturnStringFromValue( g_UserUnit,
m_BrdSettings->m_TrackMinWidth, m_BrdSettings.m_TrackMinWidth,
internal_units, internal_units,
true ); true );
msg.Printf( _( "Minimum value for tracks width: <b>%s</b><br>\n" ), GetChars( value ) ); msg.Printf( _( "Minimum value for tracks width: <b>%s</b><br>\n" ), GetChars( value ) );
m_MessagesList->AppendToPage( msg ); m_MessagesList->AppendToPage( msg );
value = ReturnStringFromValue( g_UserUnit, m_BrdSettings->m_ViasMinSize, internal_units, true ); value = ReturnStringFromValue( g_UserUnit, m_BrdSettings.m_ViasMinSize, internal_units, true );
msg.Printf( _( "Minimum value for vias diameter: <b>%s</b><br>\n" ), GetChars( value ) ); msg.Printf( _( "Minimum value for vias diameter: <b>%s</b><br>\n" ), GetChars( value ) );
m_MessagesList->AppendToPage( msg ); m_MessagesList->AppendToPage( msg );
value = ReturnStringFromValue( g_UserUnit, value = ReturnStringFromValue( g_UserUnit,
m_BrdSettings->m_MicroViasMinSize, m_BrdSettings.m_MicroViasMinSize,
internal_units, internal_units,
true ); true );
msg.Printf( _( "Minimum value for microvias diameter: <b>%s</b><br>\n" ), GetChars( value ) ); msg.Printf( _( "Minimum value for microvias diameter: <b>%s</b><br>\n" ), GetChars( value ) );
@ -240,7 +240,7 @@ void DIALOG_DESIGN_RULES::InitDialogRules()
SetReturnCode( 0 ); SetReturnCode( 0 );
m_Pcb = m_Parent->GetBoard(); m_Pcb = m_Parent->GetBoard();
m_BrdSettings = m_Pcb->GetBoardDesignSettings(); m_BrdSettings = m_Pcb->GetDesignSettings();
// Initialize the Rules List // Initialize the Rules List
InitRulesList(); InitRulesList();
@ -291,21 +291,21 @@ void DIALOG_DESIGN_RULES::InitGlobalRules()
AddUnitSymbol( *m_TrackMinWidthTitle ); AddUnitSymbol( *m_TrackMinWidthTitle );
int Internal_Unit = m_Parent->m_InternalUnits; int Internal_Unit = m_Parent->m_InternalUnits;
PutValueInLocalUnits( *m_SetViasMinSizeCtrl, m_BrdSettings->m_ViasMinSize, Internal_Unit ); PutValueInLocalUnits( *m_SetViasMinSizeCtrl, m_BrdSettings.m_ViasMinSize, Internal_Unit );
PutValueInLocalUnits( *m_SetViasMinDrillCtrl, m_BrdSettings->m_ViasMinDrill, Internal_Unit ); PutValueInLocalUnits( *m_SetViasMinDrillCtrl, m_BrdSettings.m_ViasMinDrill, Internal_Unit );
if( m_BrdSettings->m_CurrentViaType != VIA_THROUGH ) if( m_BrdSettings.m_CurrentViaType != VIA_THROUGH )
m_OptViaType->SetSelection( 1 ); m_OptViaType->SetSelection( 1 );
m_AllowMicroViaCtrl->SetSelection( m_BrdSettings->m_MicroViasAllowed ? 1 : 0 ); m_AllowMicroViaCtrl->SetSelection( m_BrdSettings.m_MicroViasAllowed ? 1 : 0 );
PutValueInLocalUnits( *m_SetMicroViasMinSizeCtrl, PutValueInLocalUnits( *m_SetMicroViasMinSizeCtrl,
m_BrdSettings->m_MicroViasMinSize, m_BrdSettings.m_MicroViasMinSize,
Internal_Unit ); Internal_Unit );
PutValueInLocalUnits( *m_SetMicroViasMinDrillCtrl, PutValueInLocalUnits( *m_SetMicroViasMinDrillCtrl,
m_BrdSettings->m_MicroViasMinDrill, m_BrdSettings.m_MicroViasMinDrill,
Internal_Unit ); Internal_Unit );
PutValueInLocalUnits( *m_SetTrackMinWidthCtrl, m_BrdSettings->m_TrackMinWidth, Internal_Unit ); PutValueInLocalUnits( *m_SetTrackMinWidthCtrl, m_BrdSettings.m_TrackMinWidth, Internal_Unit );
// Initialize Vias and Tracks sizes lists. // Initialize Vias and Tracks sizes lists.
// note we display only extra values, never the current netclass value. // note we display only extra values, never the current netclass value.
@ -605,26 +605,26 @@ void DIALOG_DESIGN_RULES::CopyRulesListToBoard()
void DIALOG_DESIGN_RULES::CopyGlobalRulesToBoard() void DIALOG_DESIGN_RULES::CopyGlobalRulesToBoard()
/*************************************************/ /*************************************************/
{ {
m_BrdSettings->m_CurrentViaType = VIA_THROUGH; m_BrdSettings.m_CurrentViaType = VIA_THROUGH;
if( m_OptViaType->GetSelection() > 0 ) if( m_OptViaType->GetSelection() > 0 )
m_BrdSettings->m_CurrentViaType = VIA_BLIND_BURIED; m_BrdSettings.m_CurrentViaType = VIA_BLIND_BURIED;
// Update vias minimum values for DRC // Update vias minimum values for DRC
m_BrdSettings->m_ViasMinSize = m_BrdSettings.m_ViasMinSize =
ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl, m_Parent->m_InternalUnits );
m_BrdSettings->m_ViasMinDrill = m_BrdSettings.m_ViasMinDrill =
ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl, m_Parent->m_InternalUnits );
m_BrdSettings->m_MicroViasAllowed = m_AllowMicroViaCtrl->GetSelection() == 1; m_BrdSettings.m_MicroViasAllowed = m_AllowMicroViaCtrl->GetSelection() == 1;
// Update microvias minimum values for DRC // Update microvias minimum values for DRC
m_BrdSettings->m_MicroViasMinSize = m_BrdSettings.m_MicroViasMinSize =
ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl, m_Parent->m_InternalUnits );
m_BrdSettings->m_MicroViasMinDrill = m_BrdSettings.m_MicroViasMinDrill =
ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl, m_Parent->m_InternalUnits );
// Update tracks minimum values for DRC // Update tracks minimum values for DRC
m_BrdSettings->m_TrackMinWidth = m_BrdSettings.m_TrackMinWidth =
ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->m_InternalUnits );
} }
@ -708,6 +708,8 @@ void DIALOG_DESIGN_RULES::OnOkButtonClick( wxCommandEvent& event )
return; return;
} }
m_Pcb->SetDesignSettings( m_BrdSettings );
CopyRulesListToBoard(); CopyRulesListToBoard();
CopyGlobalRulesToBoard(); CopyGlobalRulesToBoard();
CopyDimensionsListsToBoard(); CopyDimensionsListsToBoard();

View File

@ -40,7 +40,7 @@ private:
PCB_EDIT_FRAME* m_Parent; PCB_EDIT_FRAME* m_Parent;
BOARD* m_Pcb; BOARD* m_Pcb;
BOARD_DESIGN_SETTINGS* m_BrdSettings; BOARD_DESIGN_SETTINGS m_BrdSettings;
static int s_LastTabSelection; ///< which tab user had open last static int s_LastTabSelection; ///< which tab user had open last

View File

@ -46,7 +46,7 @@ DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* parent ) :
{ {
m_tester = aTester; m_tester = aTester;
m_Parent = parent; m_Parent = parent;
m_BrdSettings = m_Parent->GetBoard()->GetBoardDesignSettings(); m_BrdSettings = m_Parent->GetBoard()->GetDesignSettings();
InitValues(); InitValues();
if( GetSizer() ) if( GetSizer() )
@ -130,12 +130,14 @@ void DIALOG_DRC_CONTROL::InitValues()
*/ */
void DIALOG_DRC_CONTROL::SetDrcParmeters( ) void DIALOG_DRC_CONTROL::SetDrcParmeters( )
{ {
m_BrdSettings->m_TrackMinWidth = m_BrdSettings.m_TrackMinWidth =
ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->m_InternalUnits );
m_BrdSettings->m_ViasMinSize = m_BrdSettings.m_ViasMinSize =
ReturnValueFromTextCtrl( *m_SetViaMinSizeCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_SetViaMinSizeCtrl, m_Parent->m_InternalUnits );
m_BrdSettings->m_MicroViasMinSize = m_BrdSettings.m_MicroViasMinSize =
ReturnValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl, m_Parent->m_InternalUnits );
m_Parent->GetBoard()->SetDesignSettings( m_BrdSettings );
} }
@ -160,7 +162,7 @@ void DIALOG_DRC_CONTROL::OnStartdrcClick( wxCommandEvent& event )
reportName = m_RptFilenameCtrl->GetValue(); reportName = m_RptFilenameCtrl->GetValue();
} }
SetDrcParmeters( ); SetDrcParmeters();
m_tester->SetSettings( true, // Pad to pad DRC test enabled m_tester->SetSettings( true, // Pad to pad DRC test enabled
true, // unconnected pdas DRC test enabled true, // unconnected pdas DRC test enabled
@ -238,7 +240,7 @@ void DIALOG_DRC_CONTROL::OnListUnconnectedClick( wxCommandEvent& event )
reportName = m_RptFilenameCtrl->GetValue(); reportName = m_RptFilenameCtrl->GetValue();
} }
SetDrcParmeters( ); SetDrcParmeters();
m_tester->SetSettings( true, // Pad to pad DRC test enabled m_tester->SetSettings( true, // Pad to pad DRC test enabled
true, // unconnected pdas DRC test enabled true, // unconnected pdas DRC test enabled
@ -311,7 +313,7 @@ void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event )
void DIALOG_DRC_CONTROL::OnOkClick( wxCommandEvent& event ) void DIALOG_DRC_CONTROL::OnOkClick( wxCommandEvent& event )
{ {
SetReturnCode( wxID_OK ); SetReturnCode( wxID_OK );
SetDrcParmeters( ); SetDrcParmeters();
m_tester->DestroyDialog( wxID_OK ); m_tester->DestroyDialog( wxID_OK );
} }

View File

@ -44,7 +44,7 @@ class BOARD_DESIGN_SETTINGS;
class DIALOG_DRC_CONTROL: public DIALOG_DRC_CONTROL_BASE class DIALOG_DRC_CONTROL: public DIALOG_DRC_CONTROL_BASE
{ {
public: public:
BOARD_DESIGN_SETTINGS* m_BrdSettings; BOARD_DESIGN_SETTINGS m_BrdSettings;
/// Constructors /// Constructors
DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* parent ); DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* parent );

View File

@ -33,7 +33,7 @@ private:
PCB_EDIT_FRAME* m_Parent; PCB_EDIT_FRAME* m_Parent;
wxDC* m_DC; wxDC* m_DC;
DRAWSEGMENT* m_Item; DRAWSEGMENT* m_Item;
BOARD_DESIGN_SETTINGS* m_BrdSettings; BOARD_DESIGN_SETTINGS m_BrdSettings;
public: public:
DialogGraphicItemProperties( PCB_EDIT_FRAME* aParent, DRAWSEGMENT * aItem, wxDC * aDC); DialogGraphicItemProperties( PCB_EDIT_FRAME* aParent, DRAWSEGMENT * aItem, wxDC * aDC);
@ -53,7 +53,7 @@ DialogGraphicItemProperties::DialogGraphicItemProperties( PCB_EDIT_FRAME* aParen
m_Parent = aParent; m_Parent = aParent;
m_DC = aDC; m_DC = aDC;
m_Item = aItem; m_Item = aItem;
m_BrdSettings = m_Parent->GetBoard()->GetBoardDesignSettings(); m_BrdSettings = m_Parent->GetBoard()->GetDesignSettings();
initDlg(); initDlg();
Layout(); Layout();
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
@ -88,32 +88,34 @@ void DialogGraphicItemProperties::initDlg( )
SetFocus(); SetFocus();
wxString msg; wxString msg;
// Change texts according to the segment shape: // Change texts according to the segment shape:
switch ( m_Item->m_Shape ) switch ( m_Item->m_Shape )
{ {
case S_CIRCLE: case S_CIRCLE:
m_Start_Center_XText->SetLabel(_("Center X")); m_Start_Center_XText->SetLabel(_("Center X"));
m_Start_Center_YText->SetLabel(_("Center Y")); m_Start_Center_YText->SetLabel(_("Center Y"));
m_EndX_Radius_Text->SetLabel(_("Point X")); m_EndX_Radius_Text->SetLabel(_("Point X"));
m_EndY_Text->SetLabel(_("Point Y")); m_EndY_Text->SetLabel(_("Point Y"));
m_Angle_Text->Show(false); m_Angle_Text->Show(false);
m_Angle_Ctrl->Show(false); m_Angle_Ctrl->Show(false);
break; break;
case S_ARC: case S_ARC:
m_Start_Center_XText->SetLabel(_("Center X")); m_Start_Center_XText->SetLabel(_("Center X"));
m_Start_Center_YText->SetLabel(_("Center Y")); m_Start_Center_YText->SetLabel(_("Center Y"));
m_EndX_Radius_Text->SetLabel(_("Start Point X")); m_EndX_Radius_Text->SetLabel(_("Start Point X"));
m_EndY_Text->SetLabel(_("Start Point Y")); m_EndY_Text->SetLabel(_("Start Point Y"));
msg << m_Item->m_Angle; msg << m_Item->m_Angle;
m_Angle_Ctrl->SetValue(msg); m_Angle_Ctrl->SetValue(msg);
break; break;
default: default:
m_Angle_Text->Show(false); m_Angle_Text->Show(false);
m_Angle_Ctrl->Show(false); m_Angle_Ctrl->Show(false);
break; break;
} }
AddUnitSymbol( *m_Start_Center_XText ); AddUnitSymbol( *m_Start_Center_XText );
PutValueInLocalUnits( *m_Center_StartXCtrl, m_Item->m_Start.x, PutValueInLocalUnits( *m_Center_StartXCtrl, m_Item->m_Start.x,
@ -136,11 +138,14 @@ void DialogGraphicItemProperties::initDlg( )
m_Parent->m_InternalUnits ); m_Parent->m_InternalUnits );
AddUnitSymbol( *m_DefaultThicknessText ); AddUnitSymbol( *m_DefaultThicknessText );
int thickness; int thickness;
if( m_Item->GetLayer() == EDGE_N ) if( m_Item->GetLayer() == EDGE_N )
thickness = m_BrdSettings->m_EdgeSegmentWidth; thickness = m_BrdSettings.m_EdgeSegmentWidth;
else else
thickness = m_BrdSettings->m_DrawSegmentWidth; thickness = m_BrdSettings.m_DrawSegmentWidth;
PutValueInLocalUnits( *m_DefaultThicknessCtrl, thickness, PutValueInLocalUnits( *m_DefaultThicknessCtrl, thickness,
m_Parent->m_InternalUnits ); m_Parent->m_InternalUnits );
@ -156,8 +161,6 @@ void DialogGraphicItemProperties::initDlg( )
if ( layer > LAST_NO_COPPER_LAYER ) if ( layer > LAST_NO_COPPER_LAYER )
layer = LAST_NO_COPPER_LAYER; layer = LAST_NO_COPPER_LAYER;
m_LayerSelection->SetSelection( layer - FIRST_NO_COPPER_LAYER ); m_LayerSelection->SetSelection( layer - FIRST_NO_COPPER_LAYER );
} }
@ -166,10 +169,12 @@ void DialogGraphicItemProperties::OnLayerChoice( wxCommandEvent& event )
/*******************************************************************/ /*******************************************************************/
{ {
int thickness; int thickness;
if( (m_LayerSelection->GetCurrentSelection() + FIRST_NO_COPPER_LAYER) == EDGE_N ) if( (m_LayerSelection->GetCurrentSelection() + FIRST_NO_COPPER_LAYER) == EDGE_N )
thickness = m_BrdSettings->m_EdgeSegmentWidth; thickness = m_BrdSettings.m_EdgeSegmentWidth;
else else
thickness = m_BrdSettings->m_DrawSegmentWidth; thickness = m_BrdSettings.m_DrawSegmentWidth;
PutValueInLocalUnits( *m_DefaultThicknessCtrl, thickness, PutValueInLocalUnits( *m_DefaultThicknessCtrl, thickness,
m_Parent->m_InternalUnits ); m_Parent->m_InternalUnits );
} }
@ -183,7 +188,7 @@ void DialogGraphicItemProperties::OnOkClick( wxCommandEvent& event )
m_Parent->SaveCopyInUndoList( m_Item, UR_CHANGED ); m_Parent->SaveCopyInUndoList( m_Item, UR_CHANGED );
wxString msg; wxString msg;
if ( m_DC ) if( m_DC )
m_Item->Draw( m_Parent->DrawPanel, m_DC, GR_XOR ); m_Item->Draw( m_Parent->DrawPanel, m_DC, GR_XOR );
msg = m_Center_StartXCtrl->GetValue(); msg = m_Center_StartXCtrl->GetValue();
@ -213,11 +218,11 @@ void DialogGraphicItemProperties::OnOkClick( wxCommandEvent& event )
m_Item->SetLayer( m_LayerSelection->GetCurrentSelection() + FIRST_NO_COPPER_LAYER); m_Item->SetLayer( m_LayerSelection->GetCurrentSelection() + FIRST_NO_COPPER_LAYER);
if( m_Item->GetLayer() == EDGE_N ) if( m_Item->GetLayer() == EDGE_N )
m_BrdSettings->m_EdgeSegmentWidth = thickness; m_BrdSettings.m_EdgeSegmentWidth = thickness;
else else
m_BrdSettings->m_DrawSegmentWidth = thickness; m_BrdSettings.m_DrawSegmentWidth = thickness;
if ( m_Item->m_Shape == S_ARC ) if( m_Item->m_Shape == S_ARC )
{ {
long angle; long angle;
m_Angle_Ctrl->GetValue().ToLong(&angle); m_Angle_Ctrl->GetValue().ToLong(&angle);
@ -226,10 +231,12 @@ void DialogGraphicItemProperties::OnOkClick( wxCommandEvent& event )
} }
m_Parent->OnModify(); m_Parent->OnModify();
if ( m_DC ) if( m_DC )
m_Item->Draw( m_Parent->DrawPanel, m_DC, GR_OR ); m_Item->Draw( m_Parent->DrawPanel, m_DC, GR_OR );
m_Item->DisplayInfo( m_Parent ); m_Item->DisplayInfo( m_Parent );
m_Parent->GetBoard()->SetDesignSettings( m_BrdSettings );
Close( TRUE ); Close( TRUE );
} }

View File

@ -40,7 +40,7 @@ DIALOG_GRAPHIC_ITEMS_OPTIONS::DIALOG_GRAPHIC_ITEMS_OPTIONS( PCB_BASE_FRAME* pare
: DIALOG_GRAPHIC_ITEMS_OPTIONS_BASE( parent ) : DIALOG_GRAPHIC_ITEMS_OPTIONS_BASE( parent )
{ {
m_Parent = parent; m_Parent = parent;
m_BrdSettings = m_Parent->GetBoard()->GetBoardDesignSettings(); m_BrdSettings = m_Parent->GetBoard()->GetDesignSettings();
initValues( ); initValues( );
m_sdbSizer1OK->SetDefault(); m_sdbSizer1OK->SetDefault();
@ -49,7 +49,7 @@ DIALOG_GRAPHIC_ITEMS_OPTIONS::DIALOG_GRAPHIC_ITEMS_OPTIONS( PCB_BASE_FRAME* pare
Centre(); Centre();
} }
DIALOG_GRAPHIC_ITEMS_OPTIONS::~DIALOG_GRAPHIC_ITEMS_OPTIONS( ) DIALOG_GRAPHIC_ITEMS_OPTIONS::~DIALOG_GRAPHIC_ITEMS_OPTIONS()
{ {
} }
@ -61,26 +61,26 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::initValues()
/* Drawings width */ /* Drawings width */
AddUnitSymbol( *m_GraphicSegmWidthTitle ); AddUnitSymbol( *m_GraphicSegmWidthTitle );
PutValueInLocalUnits( *m_OptPcbSegmWidth, PutValueInLocalUnits( *m_OptPcbSegmWidth,
m_BrdSettings->m_DrawSegmentWidth, m_BrdSettings.m_DrawSegmentWidth,
PCB_INTERNAL_UNIT ); PCB_INTERNAL_UNIT );
/* Edges width */ /* Edges width */
AddUnitSymbol( *m_BoardEdgesWidthTitle ); AddUnitSymbol( *m_BoardEdgesWidthTitle );
PutValueInLocalUnits( *m_OptPcbEdgesWidth, PutValueInLocalUnits( *m_OptPcbEdgesWidth,
m_BrdSettings->m_EdgeSegmentWidth, m_BrdSettings.m_EdgeSegmentWidth,
PCB_INTERNAL_UNIT ); PCB_INTERNAL_UNIT );
/* Pcb Textes (Size & Width) */ /* Pcb Textes (Size & Width) */
AddUnitSymbol( *m_CopperTextWidthTitle ); AddUnitSymbol( *m_CopperTextWidthTitle );
PutValueInLocalUnits( *m_OptPcbTextWidth, PutValueInLocalUnits( *m_OptPcbTextWidth,
m_BrdSettings->m_PcbTextWidth, PCB_INTERNAL_UNIT ); m_BrdSettings.m_PcbTextWidth, PCB_INTERNAL_UNIT );
AddUnitSymbol( *m_TextSizeVTitle ); AddUnitSymbol( *m_TextSizeVTitle );
PutValueInLocalUnits( *m_OptPcbTextVSize, PutValueInLocalUnits( *m_OptPcbTextVSize,
m_BrdSettings->m_PcbTextSize.y, PCB_INTERNAL_UNIT ); m_BrdSettings.m_PcbTextSize.y, PCB_INTERNAL_UNIT );
AddUnitSymbol( *m_TextSizeHTitle ); AddUnitSymbol( *m_TextSizeHTitle );
PutValueInLocalUnits( *m_OptPcbTextHSize, PutValueInLocalUnits( *m_OptPcbTextHSize,
m_BrdSettings->m_PcbTextSize.x, PCB_INTERNAL_UNIT ); m_BrdSettings.m_PcbTextSize.x, PCB_INTERNAL_UNIT );
/* Modules: Edges width */ /* Modules: Edges width */
@ -109,17 +109,19 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::initValues()
void DIALOG_GRAPHIC_ITEMS_OPTIONS::OnOkClick( wxCommandEvent& event ) void DIALOG_GRAPHIC_ITEMS_OPTIONS::OnOkClick( wxCommandEvent& event )
{ {
m_BrdSettings->m_DrawSegmentWidth = m_BrdSettings.m_DrawSegmentWidth =
ReturnValueFromTextCtrl( *m_OptPcbSegmWidth, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptPcbSegmWidth, PCB_INTERNAL_UNIT );
m_BrdSettings->m_EdgeSegmentWidth = m_BrdSettings.m_EdgeSegmentWidth =
ReturnValueFromTextCtrl( *m_OptPcbEdgesWidth, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptPcbEdgesWidth, PCB_INTERNAL_UNIT );
m_BrdSettings->m_PcbTextWidth = m_BrdSettings.m_PcbTextWidth =
ReturnValueFromTextCtrl( *m_OptPcbTextWidth, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptPcbTextWidth, PCB_INTERNAL_UNIT );
m_BrdSettings->m_PcbTextSize.y = m_BrdSettings.m_PcbTextSize.y =
ReturnValueFromTextCtrl( *m_OptPcbTextVSize, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptPcbTextVSize, PCB_INTERNAL_UNIT );
m_BrdSettings->m_PcbTextSize.x = m_BrdSettings.m_PcbTextSize.x =
ReturnValueFromTextCtrl( *m_OptPcbTextHSize, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptPcbTextHSize, PCB_INTERNAL_UNIT );
m_Parent->GetBoard()->SetDesignSettings( m_BrdSettings );
g_ModuleSegmentWidth = g_ModuleSegmentWidth =
ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth, PCB_INTERNAL_UNIT ); ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth, PCB_INTERNAL_UNIT );
g_ModuleTextWidth = g_ModuleTextWidth =
@ -139,7 +141,6 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::OnOkClick( wxCommandEvent& event )
} }
/*! /*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/ */

View File

@ -38,8 +38,8 @@
class DIALOG_GRAPHIC_ITEMS_OPTIONS: public DIALOG_GRAPHIC_ITEMS_OPTIONS_BASE class DIALOG_GRAPHIC_ITEMS_OPTIONS: public DIALOG_GRAPHIC_ITEMS_OPTIONS_BASE
{ {
public: public:
BOARD_DESIGN_SETTINGS* m_BrdSettings; BOARD_DESIGN_SETTINGS m_BrdSettings;
PCB_BASE_FRAME * m_Parent; PCB_BASE_FRAME * m_Parent;
public: public:
DIALOG_GRAPHIC_ITEMS_OPTIONS( PCB_BASE_FRAME* parent ); DIALOG_GRAPHIC_ITEMS_OPTIONS( PCB_BASE_FRAME* parent );

View File

@ -26,7 +26,7 @@ DIALOG_PADS_MASK_CLEARANCE::DIALOG_PADS_MASK_CLEARANCE( PCB_EDIT_FRAME* parent )
DIALOG_PADS_MASK_CLEARANCE_BASE( parent ) DIALOG_PADS_MASK_CLEARANCE_BASE( parent )
{ {
m_Parent = parent; m_Parent = parent;
m_BrdSettings = m_Parent->GetBoard()->GetBoardDesignSettings(); m_BrdSettings = m_Parent->GetBoard()->GetDesignSettings();
MyInit(); MyInit();
m_sdbButtonsSizerOK->SetDefault(); m_sdbButtonsSizerOK->SetDefault();
@ -44,20 +44,20 @@ void DIALOG_PADS_MASK_CLEARANCE::MyInit()
int Internal_Unit = m_Parent->m_InternalUnits; int Internal_Unit = m_Parent->m_InternalUnits;
PutValueInLocalUnits( *m_SolderMaskMarginCtrl, PutValueInLocalUnits( *m_SolderMaskMarginCtrl,
m_BrdSettings->m_SolderMaskMargin, m_BrdSettings.m_SolderMaskMargin,
Internal_Unit ); Internal_Unit );
// These 2 parameters are usually < 0, so prepare entering a negative // These 2 parameters are usually < 0, so prepare entering a negative
// value, if current is 0 // value, if current is 0
PutValueInLocalUnits( *m_SolderPasteMarginCtrl, PutValueInLocalUnits( *m_SolderPasteMarginCtrl,
m_BrdSettings->m_SolderPasteMargin, m_BrdSettings.m_SolderPasteMargin,
Internal_Unit ); Internal_Unit );
if( m_BrdSettings->m_SolderPasteMargin == 0 ) if( m_BrdSettings.m_SolderPasteMargin == 0 )
m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) +
m_SolderPasteMarginCtrl->GetValue() ); m_SolderPasteMarginCtrl->GetValue() );
wxString msg; wxString msg;
msg.Printf( wxT( "%f" ), m_BrdSettings->m_SolderPasteMarginRatio * 100.0 ); msg.Printf( wxT( "%f" ), m_BrdSettings.m_SolderPasteMarginRatio * 100.0 );
if( m_BrdSettings->m_SolderPasteMarginRatio == 0.0 && if( m_BrdSettings.m_SolderPasteMarginRatio == 0.0 &&
msg[0] == '0') // Sometimes Printf add a sign if the value is small msg[0] == '0') // Sometimes Printf add a sign if the value is small
m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg ); m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg );
else else
@ -69,10 +69,12 @@ void DIALOG_PADS_MASK_CLEARANCE::MyInit()
void DIALOG_PADS_MASK_CLEARANCE::OnButtonOkClick( wxCommandEvent& event ) void DIALOG_PADS_MASK_CLEARANCE::OnButtonOkClick( wxCommandEvent& event )
/*******************************************************************/ /*******************************************************************/
{ {
m_BrdSettings->m_SolderMaskMargin = m_BrdSettings.m_SolderMaskMargin =
ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->m_InternalUnits );
m_BrdSettings->m_SolderPasteMargin =
m_BrdSettings.m_SolderPasteMargin =
ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->m_InternalUnits ); ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->m_InternalUnits );
double dtmp = 0; double dtmp = 0;
wxString msg = m_SolderPasteMarginRatioCtrl->GetValue(); wxString msg = m_SolderPasteMarginRatioCtrl->GetValue();
msg.ToDouble( &dtmp ); msg.ToDouble( &dtmp );
@ -82,7 +84,10 @@ void DIALOG_PADS_MASK_CLEARANCE::OnButtonOkClick( wxCommandEvent& event )
dtmp = -50; dtmp = -50;
if( dtmp > +100 ) if( dtmp > +100 )
dtmp = +100; dtmp = +100;
m_BrdSettings->m_SolderPasteMarginRatio = dtmp / 100;
m_BrdSettings.m_SolderPasteMarginRatio = dtmp / 100;
m_Parent->GetBoard()->SetDesignSettings( m_BrdSettings );
EndModal( 1 ); EndModal( 1 );
} }

View File

@ -20,7 +20,7 @@ class DIALOG_PADS_MASK_CLEARANCE : public DIALOG_PADS_MASK_CLEARANCE_BASE
{ {
private: private:
PCB_EDIT_FRAME* m_Parent; PCB_EDIT_FRAME* m_Parent;
BOARD_DESIGN_SETTINGS* m_BrdSettings; BOARD_DESIGN_SETTINGS m_BrdSettings;
public: public:
DIALOG_PADS_MASK_CLEARANCE( PCB_EDIT_FRAME* parent ); DIALOG_PADS_MASK_CLEARANCE( PCB_EDIT_FRAME* parent );

View File

@ -249,8 +249,8 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC )
aDimension->m_arrowD2Ox = aDimension->m_arrowD2Fx = pos.x; aDimension->m_arrowD2Ox = aDimension->m_arrowD2Fx = pos.x;
aDimension->m_arrowD2Oy = aDimension->m_arrowD2Fy = pos.y; aDimension->m_arrowD2Oy = aDimension->m_arrowD2Fy = pos.y;
aDimension->m_Text->m_Size = GetBoard()->GetBoardDesignSettings()->m_PcbTextSize; aDimension->m_Text->m_Size = GetBoard()->GetDesignSettings().m_PcbTextSize;
int width = GetBoard()->GetBoardDesignSettings()->m_PcbTextWidth; int width = GetBoard()->GetDesignSettings().m_PcbTextWidth;
int maxthickness = Clamp_Text_PenSize(width, aDimension->m_Text->m_Size ); int maxthickness = Clamp_Text_PenSize(width, aDimension->m_Text->m_Size );
if( width > maxthickness ) if( width > maxthickness )

View File

@ -55,13 +55,13 @@ void DRC::ShowDialog()
// copy data retained in this DRC object into the m_ui DrcPanel: // copy data retained in this DRC object into the m_ui DrcPanel:
PutValueInLocalUnits( *m_ui->m_SetTrackMinWidthCtrl, PutValueInLocalUnits( *m_ui->m_SetTrackMinWidthCtrl,
m_pcb->GetBoardDesignSettings()->m_TrackMinWidth, m_pcb->GetDesignSettings().m_TrackMinWidth,
m_mainWindow->m_InternalUnits ); m_mainWindow->m_InternalUnits );
PutValueInLocalUnits( *m_ui->m_SetViaMinSizeCtrl, PutValueInLocalUnits( *m_ui->m_SetViaMinSizeCtrl,
m_pcb->GetBoardDesignSettings()->m_ViasMinSize, m_pcb->GetDesignSettings().m_ViasMinSize,
m_mainWindow->m_InternalUnits ); m_mainWindow->m_InternalUnits );
PutValueInLocalUnits( *m_ui->m_SetMicroViakMinSizeCtrl, PutValueInLocalUnits( *m_ui->m_SetMicroViakMinSizeCtrl,
m_pcb->GetBoardDesignSettings()->m_MicroViasMinSize, m_pcb->GetDesignSettings().m_MicroViasMinSize,
m_mainWindow->m_InternalUnits ); m_mainWindow->m_InternalUnits );
m_ui->m_CreateRptCtrl->SetValue( m_doCreateRptFile ); m_ui->m_CreateRptCtrl->SetValue( m_doCreateRptFile );
@ -292,7 +292,7 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg )
{ {
bool ret = true; bool ret = true;
const BOARD_DESIGN_SETTINGS& g = *m_pcb->GetBoardDesignSettings(); const BOARD_DESIGN_SETTINGS& g = m_pcb->GetDesignSettings();
#define FmtVal( x ) GetChars( ReturnStringFromValue( g_UserUnit, x, PCB_INTERNAL_UNIT ) ) #define FmtVal( x ) GetChars( ReturnStringFromValue( g_UserUnit, x, PCB_INTERNAL_UNIT ) )

View File

@ -221,7 +221,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
if( layer1 == LAYER_N_BACK && layer2 == LAYER_N_2 ) if( layer1 == LAYER_N_BACK && layer2 == LAYER_N_2 )
err = false; err = false;
if( layer1 == (m_pcb->GetBoardDesignSettings()->GetCopperLayerCount() - 2 ) if( layer1 == (m_pcb->GetDesignSettings().GetCopperLayerCount() - 2 )
&& layer2 == LAYER_N_FRONT ) && layer2 == LAYER_N_FRONT )
err = false; err = false;

View File

@ -352,14 +352,14 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
} }
else else
{ {
int v_type = GetBoard()->GetBoardDesignSettings()->m_CurrentViaType; int v_type = GetBoard()->GetDesignSettings().m_CurrentViaType;
// place micro via and switch layer. // place micro via and switch layer.
if( id == ID_POPUP_PCB_PLACE_MICROVIA ) if( id == ID_POPUP_PCB_PLACE_MICROVIA )
GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = VIA_MICROVIA; GetBoard()->GetDesignSettings().m_CurrentViaType = VIA_MICROVIA;
Other_Layer_Route( (TRACK*) GetCurItem(), &dc ); Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = v_type; GetBoard()->GetDesignSettings().m_CurrentViaType = v_type;
if( DisplayOpt.ContrastModeDisplay ) if( DisplayOpt.ContrastModeDisplay )
DrawPanel->Refresh(); DrawPanel->Refresh();

View File

@ -166,9 +166,9 @@ TEXTE_PCB* PCB_EDIT_FRAME::Create_Texte_Pcb( wxDC* DC )
if( TextePcb->GetLayer() == LAYER_N_BACK ) if( TextePcb->GetLayer() == LAYER_N_BACK )
TextePcb->m_Mirror = true; TextePcb->m_Mirror = true;
TextePcb->m_Size = GetBoard()->GetBoardDesignSettings()->m_PcbTextSize; TextePcb->m_Size = GetBoard()->GetDesignSettings().m_PcbTextSize;
TextePcb->m_Pos = GetScreen()->GetCrossHairPosition(); TextePcb->m_Pos = GetScreen()->GetCrossHairPosition();
TextePcb->m_Thickness = GetBoard()->GetBoardDesignSettings()->m_PcbTextWidth; TextePcb->m_Thickness = GetBoard()->GetDesignSettings().m_PcbTextWidth;
InstallTextPCBOptionsFrame( TextePcb, DC ); InstallTextPCBOptionsFrame( TextePcb, DC );

View File

@ -209,11 +209,11 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, int shape,
int s_large; int s_large;
DRAWSEGMENT* DrawItem; DRAWSEGMENT* DrawItem;
s_large = GetBoard()->GetBoardDesignSettings()->m_DrawSegmentWidth; s_large = GetBoard()->GetDesignSettings().m_DrawSegmentWidth;
if( getActiveLayer() == EDGE_N ) if( getActiveLayer() == EDGE_N )
{ {
s_large = GetBoard()->GetBoardDesignSettings()->m_EdgeSegmentWidth; s_large = GetBoard()->GetDesignSettings().m_EdgeSegmentWidth;
} }
if( Segment == NULL ) /* Create new trace. */ if( Segment == NULL ) /* Create new trace. */

View File

@ -97,7 +97,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
/* create the via */ /* create the via */
SEGVIA* via = new SEGVIA( GetBoard() ); SEGVIA* via = new SEGVIA( GetBoard() );
via->m_Flags = IS_NEW; via->m_Flags = IS_NEW;
via->m_Shape = GetBoard()->GetBoardDesignSettings()->m_CurrentViaType; via->m_Shape = GetBoard()->GetDesignSettings().m_CurrentViaType;
via->m_Width = GetBoard()->GetCurrentViaSize(); via->m_Width = GetBoard()->GetCurrentViaSize();
via->SetNet( GetBoard()->GetHighLightNetCode() ); via->SetNet( GetBoard()->GetHighLightNetCode() );
via->m_Start = via->m_End = g_CurrentTrackSegment->m_End; via->m_Start = via->m_End = g_CurrentTrackSegment->m_End;

View File

@ -166,7 +166,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer ); g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer );
g_CurrentTrackSegment->m_Width = GetBoard()->GetCurrentTrackWidth(); g_CurrentTrackSegment->m_Width = GetBoard()->GetCurrentTrackWidth();
if( GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth ) if( GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth )
{ {
if( TrackOnStartPoint && TrackOnStartPoint->Type() == PCB_TRACE_T ) if( TrackOnStartPoint && TrackOnStartPoint->Type() == PCB_TRACE_T )
g_CurrentTrackSegment->m_Width = TrackOnStartPoint->m_Width; g_CurrentTrackSegment->m_Width = TrackOnStartPoint->m_Width;
@ -271,7 +271,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
newTrack->SetLayer( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer ); newTrack->SetLayer( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
if( !GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth ) if( !GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth )
newTrack->m_Width = GetBoard()->GetCurrentTrackWidth(); newTrack->m_Width = GetBoard()->GetCurrentTrackWidth();
D( g_CurrentTrackList.VerifyListIntegrity(); ); D( g_CurrentTrackList.VerifyListIntegrity(); );
@ -695,7 +695,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
// Set track parameters, that can be modified while creating the track // Set track parameters, that can be modified while creating the track
g_CurrentTrackSegment->SetLayer( screen->m_Active_Layer ); g_CurrentTrackSegment->SetLayer( screen->m_Active_Layer );
if( !frame->GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth ) if( !frame->GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth )
g_CurrentTrackSegment->m_Width = frame->GetBoard()->GetCurrentTrackWidth(); g_CurrentTrackSegment->m_Width = frame->GetBoard()->GetCurrentTrackWidth();
if( g_TwoSegmentTrackBuild ) if( g_TwoSegmentTrackBuild )
@ -706,7 +706,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
{ {
previous_track->SetLayer( screen->m_Active_Layer ); previous_track->SetLayer( screen->m_Active_Layer );
if( !frame->GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth ) if( !frame->GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth )
previous_track->m_Width = frame->GetBoard()->GetCurrentTrackWidth(); previous_track->m_Width = frame->GetBoard()->GetCurrentTrackWidth();
} }
} }

View File

@ -285,8 +285,8 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC )
switch( aItem->Type() ) switch( aItem->Type() )
{ {
case PCB_TEXT_T: case PCB_TEXT_T:
newSize = GetBoard()->GetBoardDesignSettings()->m_PcbTextSize; newSize = GetBoard()->GetDesignSettings().m_PcbTextSize;
newThickness = GetBoard()->GetBoardDesignSettings()->m_PcbTextWidth; newThickness = GetBoard()->GetDesignSettings().m_PcbTextWidth;
pcbText = (TEXTE_PCB*) aItem; pcbText = (TEXTE_PCB*) aItem;
text = (EDA_TEXT*) pcbText; text = (EDA_TEXT*) pcbText;
break; break;

View File

@ -35,19 +35,19 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event )
switch( id ) switch( id )
{ {
case ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH: case ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH:
GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth = GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth =
not GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth; not GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth;
break; break;
case ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES: case ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES:
GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth = false; GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth = false;
GetBoard()->m_TrackWidthSelector = 0; GetBoard()->m_TrackWidthSelector = 0;
GetBoard()->m_ViaSizeSelector = 0; GetBoard()->m_ViaSizeSelector = 0;
break; break;
case ID_POPUP_PCB_SELECT_AUTO_WIDTH: case ID_POPUP_PCB_SELECT_AUTO_WIDTH:
DrawPanel->MoveCursorToCrossHair(); DrawPanel->MoveCursorToCrossHair();
GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth = true; GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth = true;
break; break;
case ID_POPUP_PCB_SELECT_WIDTH1: // this is the default Netclass selection case ID_POPUP_PCB_SELECT_WIDTH1: // this is the default Netclass selection
@ -59,7 +59,7 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event )
case ID_POPUP_PCB_SELECT_WIDTH7: case ID_POPUP_PCB_SELECT_WIDTH7:
case ID_POPUP_PCB_SELECT_WIDTH8: case ID_POPUP_PCB_SELECT_WIDTH8:
DrawPanel->MoveCursorToCrossHair(); DrawPanel->MoveCursorToCrossHair();
GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth = false; GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth = false;
ii = id - ID_POPUP_PCB_SELECT_WIDTH1; ii = id - ID_POPUP_PCB_SELECT_WIDTH1;
GetBoard()->m_TrackWidthSelector = ii; GetBoard()->m_TrackWidthSelector = ii;
break; break;

View File

@ -95,7 +95,7 @@ static const wxString GenCADLayerNameFlipped[32] =
// These are the export origin (the auxiliary axis) // These are the export origin (the auxiliary axis)
static int GencadOffsetX, GencadOffsetY; static int GencadOffsetX, GencadOffsetY;
/* GerbTool chokes on units different than INCH so this is the conversion /* GerbTool chokes on units different than INCH so this is the conversion
factor */ factor */
const static double SCALE_FACTOR = 10000.0; const static double SCALE_FACTOR = 10000.0;
@ -186,7 +186,7 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
CreateComponentsSection( file, pcb ); CreateComponentsSection( file, pcb );
CreateDevicesSection( file, pcb ); CreateDevicesSection( file, pcb );
// In a similar way the netlist is split in net, track and route // In a similar way the netlist is split in net, track and route
CreateSignalsSection( file, pcb ); CreateSignalsSection( file, pcb );
CreateTracksInfoData( file, pcb ); CreateTracksInfoData( file, pcb );
CreateRoutesSection( file, pcb ); CreateRoutesSection( file, pcb );
@ -194,7 +194,7 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
fclose( file ); fclose( file );
SetLocaleTo_Default(); // revert to the current locale SetLocaleTo_Default(); // revert to the current locale
// Undo the footprints modifications (flipped footprints) // Undo the footprints modifications (flipped footprints)
for( module = pcb->m_Modules; module != NULL; module = module->Next() ) for( module = pcb->m_Modules; module != NULL; module = module->Next() )
{ {
if( module->flag ) if( module->flag )
@ -221,13 +221,13 @@ static int ViaSort(const void* aRefptr, const void* aObjptr )
TRACK* padcmp = *(TRACK**)aObjptr; TRACK* padcmp = *(TRACK**)aObjptr;
if( padref->m_Width != padcmp->m_Width ) if( padref->m_Width != padcmp->m_Width )
return padref->m_Width-padcmp->m_Width; return padref->m_Width-padcmp->m_Width;
if( padref->GetDrillValue() != padcmp->GetDrillValue() ) if( padref->GetDrillValue() != padcmp->GetDrillValue() )
return padref->GetDrillValue()-padcmp->GetDrillValue(); return padref->GetDrillValue()-padcmp->GetDrillValue();
if( padref->ReturnMaskLayer() != padcmp->ReturnMaskLayer() ) if( padref->ReturnMaskLayer() != padcmp->ReturnMaskLayer() )
return padref->ReturnMaskLayer()-padcmp->ReturnMaskLayer(); return padref->ReturnMaskLayer()-padcmp->ReturnMaskLayer();
return 0; return 0;
} }
@ -240,7 +240,7 @@ static void CreateArtworksSection( FILE* aFile )
fputs( "$ENDARTWORKS\n\n", aFile ); fputs( "$ENDARTWORKS\n\n", aFile );
} }
// Emit PADS and PADSTACKS. They are sorted and emitted uniquely. // Emit PADS and PADSTACKS. They are sorted and emitted uniquely.
// Via name is synthesized from their attributes, pads are numbered // Via name is synthesized from their attributes, pads are numbered
static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb ) static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
{ {
@ -251,7 +251,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
padstacks.resize(1); // We count pads from 1 padstacks.resize(1); // We count pads from 1
// The master layermask (i.e. the enabled layers) for padstack generation // The master layermask (i.e. the enabled layers) for padstack generation
unsigned master_layermask = aPcb->GetBoardDesignSettings()->GetEnabledLayers(); unsigned master_layermask = aPcb->GetDesignSettings().GetEnabledLayers();
fputs( "$PADS\n", aFile ); fputs( "$PADS\n", aFile );
@ -261,35 +261,35 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
pads.insert( pads.end(), pads.insert( pads.end(),
aPcb->m_NetInfo->m_PadsFullList.begin(), aPcb->m_NetInfo->m_PadsFullList.begin(),
aPcb->m_NetInfo->m_PadsFullList.end() ); aPcb->m_NetInfo->m_PadsFullList.end() );
qsort( &pads[0], aPcb->GetPadsCount(), sizeof( D_PAD* ), qsort( &pads[0], aPcb->GetPadsCount(), sizeof( D_PAD* ),
PadListSortByShape ); PadListSortByShape );
} }
// The same for vias // The same for vias
for( TRACK* track = aPcb->m_Track; track != NULL; track = track->Next() ) for( TRACK* track = aPcb->m_Track; track != NULL; track = track->Next() )
{ {
if( track->Type() == PCB_VIA_T ) if( track->Type() == PCB_VIA_T )
{ {
vias.push_back( track ); vias.push_back( track );
} }
} }
qsort( &vias[0], vias.size(), sizeof(TRACK*), ViaSort ); qsort( &vias[0], vias.size(), sizeof(TRACK*), ViaSort );
// Emit vias pads // Emit vias pads
TRACK* old_via = 0; TRACK* old_via = 0;
for( unsigned i = 0; i < vias.size(); i++ ) for( unsigned i = 0; i < vias.size(); i++ )
{ {
TRACK* via = vias[i]; TRACK* via = vias[i];
if (old_via && 0 == ViaSort(&old_via, &via)) if (old_via && 0 == ViaSort(&old_via, &via))
continue; continue;
old_via = via; old_via = via;
viastacks.push_back(via); viastacks.push_back(via);
fprintf( aFile, "PAD V%d.%d.%X ROUND %g\nCIRCLE 0 0 %g\n", fprintf( aFile, "PAD V%d.%d.%X ROUND %g\nCIRCLE 0 0 %g\n",
via->m_Width,via->GetDrillValue(), via->m_Width,via->GetDrillValue(),
via->ReturnMaskLayer(), via->ReturnMaskLayer(),
via->GetDrillValue()/SCALE_FACTOR, via->GetDrillValue()/SCALE_FACTOR,
via->m_Width/(SCALE_FACTOR*2) ); via->m_Width/(SCALE_FACTOR*2) );
} }
// Emit component pads // Emit component pads
@ -311,7 +311,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
fprintf( aFile, "PAD P%d", pad->GetSubRatsnest() ); fprintf( aFile, "PAD P%d", pad->GetSubRatsnest() );
padstacks.push_back(pad); // Will have its own padstack later padstacks.push_back(pad); // Will have its own padstack later
int dx = pad->m_Size.x / 2; int dx = pad->m_Size.x / 2;
int dy = pad->m_Size.y / 2; int dy = pad->m_Size.y / 2;
@ -319,29 +319,29 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
{ {
default: default:
case PAD_CIRCLE: case PAD_CIRCLE:
fprintf( aFile, " ROUND %g\n", fprintf( aFile, " ROUND %g\n",
pad->m_Drill.x / SCALE_FACTOR ); pad->m_Drill.x / SCALE_FACTOR );
/* Circle is center, radius */ /* Circle is center, radius */
fprintf( aFile, "CIRCLE %g %g %g\n", fprintf( aFile, "CIRCLE %g %g %g\n",
pad->m_Offset.x / SCALE_FACTOR, pad->m_Offset.x / SCALE_FACTOR,
-pad->m_Offset.y / SCALE_FACTOR, -pad->m_Offset.y / SCALE_FACTOR,
pad->m_Size.x / (SCALE_FACTOR*2) ); pad->m_Size.x / (SCALE_FACTOR*2) );
break; break;
case PAD_RECT: case PAD_RECT:
fprintf( aFile, " RECTANGULAR %g\n", fprintf( aFile, " RECTANGULAR %g\n",
pad->m_Drill.x / SCALE_FACTOR ); pad->m_Drill.x / SCALE_FACTOR );
// Rectangle is begin, size *not* begin, end! // Rectangle is begin, size *not* begin, end!
fprintf( aFile, "RECTANGLE %g %g %g %g\n", fprintf( aFile, "RECTANGLE %g %g %g %g\n",
(-dx + pad->m_Offset.x ) / SCALE_FACTOR, (-dx + pad->m_Offset.x ) / SCALE_FACTOR,
(-dy - pad->m_Offset.y ) / SCALE_FACTOR, (-dy - pad->m_Offset.y ) / SCALE_FACTOR,
dx / (SCALE_FACTOR/2) , dy / (SCALE_FACTOR/2) ); dx / (SCALE_FACTOR/2) , dy / (SCALE_FACTOR/2) );
break; break;
case PAD_OVAL: // Create outline by 2 lines and 2 arcs case PAD_OVAL: // Create outline by 2 lines and 2 arcs
{ {
// OrCAD Layout call them OVAL or OBLONG - GenCAD call them FINGERs // OrCAD Layout call them OVAL or OBLONG - GenCAD call them FINGERs
fprintf( aFile, " FINGER %g\n", fprintf( aFile, " FINGER %g\n",
pad->m_Drill.x / SCALE_FACTOR ); pad->m_Drill.x / SCALE_FACTOR );
int dr = dx - dy; int dr = dx - dy;
@ -349,30 +349,30 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
{ {
int radius = dy; int radius = dy;
fprintf( aFile, "LINE %g %g %g %g\n", fprintf( aFile, "LINE %g %g %g %g\n",
(-dr + pad->m_Offset.x) / SCALE_FACTOR, (-dr + pad->m_Offset.x) / SCALE_FACTOR,
(-pad->m_Offset.y - radius) / SCALE_FACTOR, (-pad->m_Offset.y - radius) / SCALE_FACTOR,
(dr + pad->m_Offset.x ) / SCALE_FACTOR, (dr + pad->m_Offset.x ) / SCALE_FACTOR,
(-pad->m_Offset.y - radius) / SCALE_FACTOR ); (-pad->m_Offset.y - radius) / SCALE_FACTOR );
// GenCAD arcs are (start, end, center) // GenCAD arcs are (start, end, center)
fprintf( aFile, "ARC %g %g %g %g %g %g\n", fprintf( aFile, "ARC %g %g %g %g %g %g\n",
(dr + pad->m_Offset.x) / SCALE_FACTOR, (dr + pad->m_Offset.x) / SCALE_FACTOR,
(-pad->m_Offset.y - radius) / SCALE_FACTOR, (-pad->m_Offset.y - radius) / SCALE_FACTOR,
(dr + pad->m_Offset.x) / SCALE_FACTOR, (dr + pad->m_Offset.x) / SCALE_FACTOR,
(-pad->m_Offset.y + radius) / SCALE_FACTOR, (-pad->m_Offset.y + radius) / SCALE_FACTOR,
(dr + pad->m_Offset.x) / SCALE_FACTOR, (dr + pad->m_Offset.x) / SCALE_FACTOR,
-pad->m_Offset.y / SCALE_FACTOR ); -pad->m_Offset.y / SCALE_FACTOR );
fprintf( aFile, "LINE %g %g %g %g\n", fprintf( aFile, "LINE %g %g %g %g\n",
(dr + pad->m_Offset.x) / SCALE_FACTOR, (dr + pad->m_Offset.x) / SCALE_FACTOR,
(-pad->m_Offset.y + radius) / SCALE_FACTOR, (-pad->m_Offset.y + radius) / SCALE_FACTOR,
(-dr + pad->m_Offset.x) / SCALE_FACTOR, (-dr + pad->m_Offset.x) / SCALE_FACTOR,
(-pad->m_Offset.y + radius) / SCALE_FACTOR ); (-pad->m_Offset.y + radius) / SCALE_FACTOR );
fprintf( aFile, "ARC %g %g %g %g %g %g\n", fprintf( aFile, "ARC %g %g %g %g %g %g\n",
(-dr + pad->m_Offset.x) / SCALE_FACTOR, (-dr + pad->m_Offset.x) / SCALE_FACTOR,
(-pad->m_Offset.y + radius) / SCALE_FACTOR, (-pad->m_Offset.y + radius) / SCALE_FACTOR,
(-dr + pad->m_Offset.x) / SCALE_FACTOR, (-dr + pad->m_Offset.x) / SCALE_FACTOR,
(-pad->m_Offset.y - radius) / SCALE_FACTOR, (-pad->m_Offset.y - radius) / SCALE_FACTOR,
(-dr + pad->m_Offset.x) / SCALE_FACTOR, (-dr + pad->m_Offset.x) / SCALE_FACTOR,
-pad->m_Offset.y / SCALE_FACTOR ); -pad->m_Offset.y / SCALE_FACTOR );
} }
else // Vertical oval else // Vertical oval
@ -380,38 +380,38 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
dr = -dr; dr = -dr;
int radius = dx; int radius = dx;
fprintf( aFile, "LINE %g %g %g %g\n", fprintf( aFile, "LINE %g %g %g %g\n",
(-radius + pad->m_Offset.x) / SCALE_FACTOR, (-radius + pad->m_Offset.x) / SCALE_FACTOR,
(-pad->m_Offset.y - dr) / SCALE_FACTOR, (-pad->m_Offset.y - dr) / SCALE_FACTOR,
(-radius + pad->m_Offset.x ) / SCALE_FACTOR, (-radius + pad->m_Offset.x ) / SCALE_FACTOR,
(-pad->m_Offset.y + dr) / SCALE_FACTOR ); (-pad->m_Offset.y + dr) / SCALE_FACTOR );
fprintf( aFile, "ARC %g %g %g %g %g %g\n", fprintf( aFile, "ARC %g %g %g %g %g %g\n",
(-radius + pad->m_Offset.x ) / SCALE_FACTOR, (-radius + pad->m_Offset.x ) / SCALE_FACTOR,
(-pad->m_Offset.y + dr) / SCALE_FACTOR, (-pad->m_Offset.y + dr) / SCALE_FACTOR,
(radius + pad->m_Offset.x ) / SCALE_FACTOR, (radius + pad->m_Offset.x ) / SCALE_FACTOR,
(-pad->m_Offset.y + dr) / SCALE_FACTOR, (-pad->m_Offset.y + dr) / SCALE_FACTOR,
pad->m_Offset.x / SCALE_FACTOR, pad->m_Offset.x / SCALE_FACTOR,
(-pad->m_Offset.y + dr) / SCALE_FACTOR ); (-pad->m_Offset.y + dr) / SCALE_FACTOR );
fprintf( aFile, "LINE %g %g %g %g\n", fprintf( aFile, "LINE %g %g %g %g\n",
(radius + pad->m_Offset.x) / SCALE_FACTOR, (radius + pad->m_Offset.x) / SCALE_FACTOR,
(-pad->m_Offset.y + dr) / SCALE_FACTOR, (-pad->m_Offset.y + dr) / SCALE_FACTOR,
(radius + pad->m_Offset.x) / SCALE_FACTOR, (radius + pad->m_Offset.x) / SCALE_FACTOR,
(-pad->m_Offset.y - dr) / SCALE_FACTOR ); (-pad->m_Offset.y - dr) / SCALE_FACTOR );
fprintf( aFile, "ARC %g %g %g %g %g %g\n", fprintf( aFile, "ARC %g %g %g %g %g %g\n",
(radius + pad->m_Offset.x) / SCALE_FACTOR, (radius + pad->m_Offset.x) / SCALE_FACTOR,
(-pad->m_Offset.y - dr) / SCALE_FACTOR, (-pad->m_Offset.y - dr) / SCALE_FACTOR,
(-radius + pad->m_Offset.x) / SCALE_FACTOR, (-radius + pad->m_Offset.x) / SCALE_FACTOR,
(-pad->m_Offset.y - dr) / SCALE_FACTOR, (-pad->m_Offset.y - dr) / SCALE_FACTOR,
pad->m_Offset.x / SCALE_FACTOR, pad->m_Offset.x / SCALE_FACTOR,
(-pad->m_Offset.y - dr) / SCALE_FACTOR ); (-pad->m_Offset.y - dr) / SCALE_FACTOR );
} }
break; break;
} }
case PAD_TRAPEZOID: case PAD_TRAPEZOID:
fprintf( aFile, " POLYGON %g\n", fprintf( aFile, " POLYGON %g\n",
pad->m_Drill.x / SCALE_FACTOR ); pad->m_Drill.x / SCALE_FACTOR );
// XXX TO BE IMPLEMENTED! and I don't know if it could be actually imported by something // XXX TO BE IMPLEMENTED! and I don't know if it could be actually imported by something
break; break;
} }
} }
@ -423,55 +423,55 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
// Via padstacks // Via padstacks
for( unsigned i = 0; i < viastacks.size(); i++ ) for( unsigned i = 0; i < viastacks.size(); i++ )
{ {
TRACK *via = viastacks[i]; TRACK *via = viastacks[i];
unsigned mask = via->ReturnMaskLayer() & master_layermask; unsigned mask = via->ReturnMaskLayer() & master_layermask;
fprintf( aFile, "PADSTACK VIA%d.%d.%X %g\n", fprintf( aFile, "PADSTACK VIA%d.%d.%X %g\n",
via->m_Width, via->GetDrillValue(), mask, via->m_Width, via->GetDrillValue(), mask,
via->GetDrillValue() / SCALE_FACTOR ); via->GetDrillValue() / SCALE_FACTOR );
for( int layer = 0; layer < 32; layer++) for( int layer = 0; layer < 32; layer++)
{ {
if( mask & (1<<layer) ) if( mask & (1<<layer) )
{ {
fprintf( aFile, "PAD V%d.%d.%X %s 0 0\n", fprintf( aFile, "PAD V%d.%d.%X %s 0 0\n",
via->m_Width, via->GetDrillValue(), via->m_Width, via->GetDrillValue(),
mask, mask,
TO_UTF8( GenCADLayerName[layer]) ); TO_UTF8( GenCADLayerName[layer]) );
} }
} }
} }
/* Component padstacks /* Component padstacks
CAM350 don't apply correctly the FLIP semantics for padstacks, i.e. doesn't CAM350 don't apply correctly the FLIP semantics for padstacks, i.e. doesn't
swap the top and bottom layers... so I need to define the shape as MIRRORX swap the top and bottom layers... so I need to define the shape as MIRRORX
and define a separate 'flipped' padstack... until it appears yet another and define a separate 'flipped' padstack... until it appears yet another
noncompliant importer */ noncompliant importer */
for( unsigned i = 1; i < padstacks.size(); i++ ) for( unsigned i = 1; i < padstacks.size(); i++ )
{ {
D_PAD *pad = padstacks[i]; D_PAD *pad = padstacks[i];
// Straight padstack // Straight padstack
fprintf( aFile, "PADSTACK PAD%d %g\n", i, fprintf( aFile, "PADSTACK PAD%d %g\n", i,
pad->m_Drill.x / SCALE_FACTOR); pad->m_Drill.x / SCALE_FACTOR);
for( int layer = 0; layer < 32; layer++ ) for( int layer = 0; layer < 32; layer++ )
{ {
if( pad->m_layerMask & (1<<layer) & master_layermask ) if( pad->m_layerMask & (1<<layer) & master_layermask )
{ {
fprintf( aFile, "PAD P%d %s 0 0\n", i, fprintf( aFile, "PAD P%d %s 0 0\n", i,
TO_UTF8( GenCADLayerName[layer] ) ); TO_UTF8( GenCADLayerName[layer] ) );
} }
} }
// Flipped padstack // Flipped padstack
fprintf( aFile, "PADSTACK PAD%dF %g\n", i, fprintf( aFile, "PADSTACK PAD%dF %g\n", i,
pad->m_Drill.x / SCALE_FACTOR); pad->m_Drill.x / SCALE_FACTOR);
for( int layer = 0; layer < 32; layer++ ) for( int layer = 0; layer < 32; layer++ )
{ {
if( pad->m_layerMask & (1<<layer) & master_layermask ) if( pad->m_layerMask & (1<<layer) & master_layermask )
{ {
fprintf( aFile, "PAD P%d %s 0 0\n", i, fprintf( aFile, "PAD P%d %s 0 0\n", i,
TO_UTF8( GenCADLayerNameFlipped[layer] ) ); TO_UTF8( GenCADLayerNameFlipped[layer] ) );
} }
} }
} }
fputs( "$ENDPADSTACKS\n\n", aFile ); fputs( "$ENDPADSTACKS\n\n", aFile );
} }
@ -498,20 +498,20 @@ static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
for( pad = module->m_Pads; pad != NULL; pad = pad->Next() ) for( pad = module->m_Pads; pad != NULL; pad = pad->Next() )
{ {
/* Funny thing: GenCAD requires the pad side even if you use /* Funny thing: GenCAD requires the pad side even if you use
padstacks (which are theorically optional but gerbtools padstacks (which are theorically optional but gerbtools
*requires* them). Now the trouble thing is that 'BOTTOM' *requires* them). Now the trouble thing is that 'BOTTOM'
is interpreted by someone as a padstack flip even is interpreted by someone as a padstack flip even
if the spec explicitly says it's not... */ if the spec explicitly says it's not... */
layer = "ALL"; layer = "ALL";
if( ( pad->m_layerMask & ALL_CU_LAYERS ) == LAYER_BACK ) if( ( pad->m_layerMask & ALL_CU_LAYERS ) == LAYER_BACK )
{ {
layer = ( module->flag ) ? "TOP" : "BOTTOM"; layer = ( module->flag ) ? "TOP" : "BOTTOM";
} }
else if( ( pad->m_layerMask & ALL_CU_LAYERS ) == LAYER_FRONT ) else if( ( pad->m_layerMask & ALL_CU_LAYERS ) == LAYER_FRONT )
{ {
layer = ( module->flag ) ? "BOTTOM" : "TOP"; layer = ( module->flag ) ? "BOTTOM" : "TOP";
} }
pad->ReturnStringPadName( pinname ); pad->ReturnStringPadName( pinname );
@ -522,12 +522,12 @@ static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
orient = pad->m_Orient - module->m_Orient; orient = pad->m_Orient - module->m_Orient;
NORMALIZE_ANGLE_POS( orient ); NORMALIZE_ANGLE_POS( orient );
// Bottom side modules use the flipped padstack // Bottom side modules use the flipped padstack
fprintf( aFile, (module->flag) ? fprintf( aFile, (module->flag) ?
"PIN %s PAD%dF %g %g %s %g %s\n" : "PIN %s PAD%dF %g %g %s %g %s\n" :
"PIN %s PAD%d %g %g %s %g %s\n", "PIN %s PAD%d %g %g %s %g %s\n",
TO_UTF8( pinname ), pad->GetSubRatsnest(), TO_UTF8( pinname ), pad->GetSubRatsnest(),
pad->m_Pos0.x / SCALE_FACTOR, pad->m_Pos0.x / SCALE_FACTOR,
-pad->m_Pos0.y / SCALE_FACTOR, -pad->m_Pos0.y / SCALE_FACTOR,
layer, orient / 10.0, mirror ); layer, orient / 10.0, mirror );
} }
@ -548,15 +548,15 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
for(MODULE* module = aPcb->m_Modules ; module != NULL; module = module->Next() ) for(MODULE* module = aPcb->m_Modules ; module != NULL; module = module->Next() )
{ {
TEXTE_MODULE* textmod; TEXTE_MODULE* textmod;
const char* mirror; const char* mirror;
const char* flip; const char* flip;
int orient = module->m_Orient; int orient = module->m_Orient;
if( module->flag ) if( module->flag )
{ {
mirror = "0"; mirror = "0";
flip = "FLIP"; flip = "FLIP";
NEGATE_AND_NORMALIZE_ANGLE_POS( orient ); NEGATE_AND_NORMALIZE_ANGLE_POS( orient );
} }
else else
@ -565,21 +565,21 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
flip = "0"; flip = "0";
} }
fprintf( aFile, "\nCOMPONENT %s\n", fprintf( aFile, "\nCOMPONENT %s\n",
TO_UTF8( module->m_Reference->m_Text ) ); TO_UTF8( module->m_Reference->m_Text ) );
fprintf( aFile, "DEVICE %s_%s\n", fprintf( aFile, "DEVICE %s_%s\n",
TO_UTF8( module->m_Reference->m_Text ), TO_UTF8( module->m_Reference->m_Text ),
TO_UTF8( module->m_Value->m_Text ) ); TO_UTF8( module->m_Value->m_Text ) );
fprintf( aFile, "PLACE %g %g\n", fprintf( aFile, "PLACE %g %g\n",
MapXTo( module->m_Pos.x ), MapXTo( module->m_Pos.x ),
MapYTo( module->m_Pos.y ) ); MapYTo( module->m_Pos.y ) );
fprintf( aFile, "LAYER %s\n", fprintf( aFile, "LAYER %s\n",
(module->flag) ? "BOTTOM" : "TOP" ); (module->flag) ? "BOTTOM" : "TOP" );
fprintf( aFile, "ROTATION %g\n", fprintf( aFile, "ROTATION %g\n",
orient / 10.0 ); orient / 10.0 );
fprintf( aFile, "SHAPE %s %s %s\n", fprintf( aFile, "SHAPE %s %s %s\n",
TO_UTF8( module->m_Reference->m_Text ), TO_UTF8( module->m_Reference->m_Text ),
mirror, flip ); mirror, flip );
// Text on silk layer: RefDes and value (are they actually useful?) // Text on silk layer: RefDes and value (are they actually useful?)
textmod = module->m_Reference; textmod = module->m_Reference;
@ -587,11 +587,11 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
for( int ii = 0; ii < 2; ii++ ) for( int ii = 0; ii < 2; ii++ )
{ {
int orient = textmod->m_Orient; int orient = textmod->m_Orient;
wxString layer = GenCADLayerName[(module->flag) ? wxString layer = GenCADLayerName[(module->flag) ?
SILKSCREEN_N_BACK : SILKSCREEN_N_FRONT]; SILKSCREEN_N_BACK : SILKSCREEN_N_FRONT];
fprintf( aFile, "TEXT %g %g %g %g %s %s \"%s\"", fprintf( aFile, "TEXT %g %g %g %g %s %s \"%s\"",
textmod->m_Pos0.x / SCALE_FACTOR, textmod->m_Pos0.x / SCALE_FACTOR,
-textmod->m_Pos0.y / SCALE_FACTOR, -textmod->m_Pos0.y / SCALE_FACTOR,
textmod->m_Size.x / SCALE_FACTOR, textmod->m_Size.x / SCALE_FACTOR,
orient / 10.0, orient / 10.0,
@ -599,10 +599,10 @@ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb )
TO_UTF8( layer ), TO_UTF8( layer ),
TO_UTF8( textmod->m_Text ) ); TO_UTF8( textmod->m_Text ) );
// Please note, the width is approx // Please note, the width is approx
fprintf( aFile, " 0 0 %g %g\n", fprintf( aFile, " 0 0 %g %g\n",
(textmod->m_Size.x * textmod->m_Text.Len()) (textmod->m_Size.x * textmod->m_Text.Len())
/ SCALE_FACTOR, / SCALE_FACTOR,
textmod->m_Size.y / SCALE_FACTOR ); textmod->m_Size.y / SCALE_FACTOR );
textmod = module->m_Value; // Dirty trick for the second iteration textmod = module->m_Value; // Dirty trick for the second iteration
@ -671,7 +671,7 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
} }
/* Creates the header section; some of the data come from the frame /* Creates the header section; some of the data come from the frame
* (actually the screen), not from the pcb */ * (actually the screen), not from the pcb */
static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame ) static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame )
{ {
@ -683,18 +683,18 @@ static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame )
// Please note: GenCAD syntax requires quoted strings if they can contain spaces // Please note: GenCAD syntax requires quoted strings if they can contain spaces
msg.Printf( wxT( "USER \"%s %s\"\n" ), msg.Printf( wxT( "USER \"%s %s\"\n" ),
GetChars( wxGetApp().GetAppName() ), GetChars( wxGetApp().GetAppName() ),
GetChars( GetBuildVersion() ) ); GetChars( GetBuildVersion() ) );
fputs( TO_UTF8( msg ), aFile ); fputs( TO_UTF8( msg ), aFile );
msg = wxT( "DRAWING \"" ) + screen->GetFileName() + wxT( "\"\n" ); msg = wxT( "DRAWING \"" ) + screen->GetFileName() + wxT( "\"\n" );
fputs( TO_UTF8( msg ), aFile ); fputs( TO_UTF8( msg ), aFile );
msg = wxT( "REVISION \"" ) + screen->m_Revision + wxT( " " ) + msg = wxT( "REVISION \"" ) + screen->m_Revision + wxT( " " ) +
screen->m_Date + wxT( "\"\n" ); screen->m_Date + wxT( "\"\n" );
fputs( TO_UTF8( msg ), aFile ); fputs( TO_UTF8( msg ), aFile );
fputs( "UNITS INCH\n", aFile); fputs( "UNITS INCH\n", aFile);
msg.Printf( wxT( "ORIGIN %g %g\n" ), msg.Printf( wxT( "ORIGIN %g %g\n" ),
MapXTo( aFrame->m_Auxiliary_Axis_Position.x ), MapXTo( aFrame->m_Auxiliary_Axis_Position.x ),
MapYTo( aFrame->m_Auxiliary_Axis_Position.y ) ); MapYTo( aFrame->m_Auxiliary_Axis_Position.y ) );
fputs( TO_UTF8( msg ), aFile ); fputs( TO_UTF8( msg ), aFile );
fputs( "INTERTRACK 0\n", aFile ); fputs( "INTERTRACK 0\n", aFile );
fputs( "$ENDHEADER\n\n", aFile ); fputs( "$ENDHEADER\n\n", aFile );
@ -742,7 +742,7 @@ static void CreateRoutesSection( FILE* aFile, BOARD* aPcb )
int vianum = 1; int vianum = 1;
int old_netcode, old_width, old_layer; int old_netcode, old_width, old_layer;
int nbitems, ii; int nbitems, ii;
unsigned master_layermask = aPcb->GetBoardDesignSettings()->GetEnabledLayers(); unsigned master_layermask = aPcb->GetDesignSettings().GetEnabledLayers();
// Count items // Count items
nbitems = 0; nbitems = 0;
@ -817,7 +817,7 @@ static void CreateRoutesSection( FILE* aFile, BOARD* aPcb )
if( track->Type() == PCB_VIA_T ) if( track->Type() == PCB_VIA_T )
{ {
fprintf( aFile, "VIA VIA%d.%d.%X %g %g ALL %g via%d\n", fprintf( aFile, "VIA VIA%d.%d.%X %g %g ALL %g via%d\n",
track->m_Width,track->GetDrillValue(), track->m_Width,track->GetDrillValue(),
track->ReturnMaskLayer() & master_layermask, track->ReturnMaskLayer() & master_layermask,
MapXTo( track->m_Start.x ), MapYTo( track->m_Start.y ), MapXTo( track->m_Start.x ), MapYTo( track->m_Start.y ),
track->GetDrillValue()/SCALE_FACTOR, vianum++ ); track->GetDrillValue()/SCALE_FACTOR, vianum++ );
@ -844,9 +844,9 @@ static void CreateDevicesSection( FILE* aFile, BOARD* aPcb )
{ {
fprintf( aFile, "DEVICE \"%s\"\n", TO_UTF8( module->m_Reference->m_Text ) ); fprintf( aFile, "DEVICE \"%s\"\n", TO_UTF8( module->m_Reference->m_Text ) );
fprintf( aFile, "PART \"%s\"\n", TO_UTF8( module->m_Value->m_Text ) ); fprintf( aFile, "PART \"%s\"\n", TO_UTF8( module->m_Value->m_Text ) );
fprintf( aFile, "PACKAGE \"%s\"\n", TO_UTF8( module->m_LibRef ) ); fprintf( aFile, "PACKAGE \"%s\"\n", TO_UTF8( module->m_LibRef ) );
// The TYPE attribute is almost freeform // The TYPE attribute is almost freeform
const char *ty = "TH"; const char *ty = "TH";
if( module->m_Attributs & MOD_CMS ) if( module->m_Attributs & MOD_CMS )
ty = "SMD"; ty = "SMD";
if( module->m_Attributs & MOD_VIRTUAL ) if( module->m_Attributs & MOD_VIRTUAL )
@ -864,22 +864,22 @@ static void CreateDevicesSection( FILE* aFile, BOARD* aPcb )
static void CreateBoardSection( FILE* aFile, BOARD* aPcb ) static void CreateBoardSection( FILE* aFile, BOARD* aPcb )
{ {
fputs( "$BOARD\n", aFile ); fputs( "$BOARD\n", aFile );
// Extract the board edges // Extract the board edges
for (EDA_ITEM* drawing = aPcb->m_Drawings; for (EDA_ITEM* drawing = aPcb->m_Drawings;
drawing != 0; drawing != 0;
drawing = drawing->Next() ) drawing = drawing->Next() )
{ {
if ( drawing->Type() == PCB_LINE_T ) if ( drawing->Type() == PCB_LINE_T )
{ {
DRAWSEGMENT *drawseg = dynamic_cast<DRAWSEGMENT*>(drawing); DRAWSEGMENT *drawseg = dynamic_cast<DRAWSEGMENT*>(drawing);
if (drawseg->GetLayer() == EDGE_N) if (drawseg->GetLayer() == EDGE_N)
{ {
// XXX GenCAD supports arc boundaries but I've seen nothing that reads them // XXX GenCAD supports arc boundaries but I've seen nothing that reads them
fprintf( aFile, "LINE %g %g %g %g\n", fprintf( aFile, "LINE %g %g %g %g\n",
MapXTo(drawseg->m_Start.x), MapYTo(drawseg->m_Start.y), MapXTo(drawseg->m_Start.x), MapYTo(drawseg->m_Start.y),
MapXTo(drawseg->m_End.x), MapYTo(drawseg->m_End.y)); MapXTo(drawseg->m_End.x), MapYTo(drawseg->m_End.y));
} }
} }
} }
fputs( "$ENDBOARD\n\n", aFile ); fputs( "$ENDBOARD\n\n", aFile );
} }
@ -946,8 +946,8 @@ static void CreateTracksInfoData( FILE* aFile, BOARD* aPcb )
for( ii = 0; ii < trackinfo.size(); ii++ ) for( ii = 0; ii < trackinfo.size(); ii++ )
{ {
fprintf( aFile, "TRACK TRACK%d %g\n", trackinfo[ii], fprintf( aFile, "TRACK TRACK%d %g\n", trackinfo[ii],
trackinfo[ii] / SCALE_FACTOR ); trackinfo[ii] / SCALE_FACTOR );
} }
fputs( "$ENDTRACKS\n\n", aFile ); fputs( "$ENDTRACKS\n\n", aFile );
@ -964,23 +964,23 @@ static void FootprintWriteShape( FILE* aFile, MODULE* module )
EDGE_MODULE* PtEdge; EDGE_MODULE* PtEdge;
EDA_ITEM* PtStruct; EDA_ITEM* PtStruct;
// Control Y axis change sign for flipped modules // Control Y axis change sign for flipped modules
int Yaxis_sign = -1; int Yaxis_sign = -1;
// Flip for bottom side components // Flip for bottom side components
if( module->flag ) if( module->flag )
Yaxis_sign = 1; Yaxis_sign = 1;
/* creates header: */ /* creates header: */
fprintf( aFile, "\nSHAPE %s\n", TO_UTF8( module->m_Reference->m_Text ) ); fprintf( aFile, "\nSHAPE %s\n", TO_UTF8( module->m_Reference->m_Text ) );
if( module->m_Attributs & MOD_VIRTUAL ) if( module->m_Attributs & MOD_VIRTUAL )
{ {
fprintf( aFile, "INSERT SMD\n"); fprintf( aFile, "INSERT SMD\n");
} }
else else
{ {
if( module->m_Attributs & MOD_CMS ) if( module->m_Attributs & MOD_CMS )
{ {
fprintf( aFile, "INSERT SMD\n"); fprintf( aFile, "INSERT SMD\n");
} }
else else
@ -1015,21 +1015,21 @@ static void FootprintWriteShape( FILE* aFile, MODULE* module )
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
// If we wanted to export text, this is not the correct section // If we wanted to export text, this is not the correct section
break; break;
case PCB_MODULE_EDGE_T: case PCB_MODULE_EDGE_T:
PtEdge = (EDGE_MODULE*) PtStruct; PtEdge = (EDGE_MODULE*) PtStruct;
if( PtEdge->GetLayer() == SILKSCREEN_N_FRONT if( PtEdge->GetLayer() == SILKSCREEN_N_FRONT
|| PtEdge->GetLayer() == SILKSCREEN_N_BACK ) || PtEdge->GetLayer() == SILKSCREEN_N_BACK )
{ {
switch( PtEdge->m_Shape ) switch( PtEdge->m_Shape )
{ {
case S_SEGMENT: case S_SEGMENT:
fprintf( aFile, "LINE %g %g %g %g\n", fprintf( aFile, "LINE %g %g %g %g\n",
(PtEdge->m_Start0.x) / SCALE_FACTOR, (PtEdge->m_Start0.x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->m_Start0.y) / SCALE_FACTOR, (Yaxis_sign * PtEdge->m_Start0.y) / SCALE_FACTOR,
(PtEdge->m_End0.x) / SCALE_FACTOR, (PtEdge->m_End0.x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->m_End0.y ) / SCALE_FACTOR); (Yaxis_sign * PtEdge->m_End0.y ) / SCALE_FACTOR);
break; break;
@ -1039,13 +1039,13 @@ static void FootprintWriteShape( FILE* aFile, MODULE* module )
(double) ( PtEdge->m_End0.x - PtEdge->m_Start0.x ), (double) ( PtEdge->m_End0.x - PtEdge->m_Start0.x ),
(double) ( PtEdge->m_End0.y - PtEdge->m_Start0.y ) ); (double) ( PtEdge->m_End0.y - PtEdge->m_Start0.y ) );
fprintf( aFile, "CIRCLE %g %g %g\n", fprintf( aFile, "CIRCLE %g %g %g\n",
PtEdge->m_Start0.x / SCALE_FACTOR, PtEdge->m_Start0.x / SCALE_FACTOR,
Yaxis_sign * PtEdge->m_Start0.y / SCALE_FACTOR, Yaxis_sign * PtEdge->m_Start0.y / SCALE_FACTOR,
radius / SCALE_FACTOR ); radius / SCALE_FACTOR );
break; break;
} }
case S_ARC: case S_ARC:
{ {
int arcendx, arcendy; int arcendx, arcendy;
arcendx = PtEdge->m_End0.x - PtEdge->m_Start0.x; arcendx = PtEdge->m_End0.x - PtEdge->m_Start0.x;
@ -1053,36 +1053,36 @@ static void FootprintWriteShape( FILE* aFile, MODULE* module )
RotatePoint( &arcendx, &arcendy, -PtEdge->m_Angle ); RotatePoint( &arcendx, &arcendy, -PtEdge->m_Angle );
arcendx += PtEdge->m_Start0.x; arcendx += PtEdge->m_Start0.x;
arcendy += PtEdge->m_Start0.y; arcendy += PtEdge->m_Start0.y;
if (Yaxis_sign == -1) { if (Yaxis_sign == -1) {
// Flipping Y flips the arc direction too // Flipping Y flips the arc direction too
fprintf( aFile, "ARC %g %g %g %g %g %g\n", fprintf( aFile, "ARC %g %g %g %g %g %g\n",
(arcendx) / SCALE_FACTOR, (arcendx) / SCALE_FACTOR,
(Yaxis_sign * arcendy) / SCALE_FACTOR, (Yaxis_sign * arcendy) / SCALE_FACTOR,
(PtEdge->m_End0.x) / SCALE_FACTOR, (PtEdge->m_End0.x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->m_End0.y) / SCALE_FACTOR, (Yaxis_sign * PtEdge->m_End0.y) / SCALE_FACTOR,
(PtEdge->m_Start0.x) / SCALE_FACTOR, (PtEdge->m_Start0.x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->m_Start0.y) / SCALE_FACTOR ); (Yaxis_sign * PtEdge->m_Start0.y) / SCALE_FACTOR );
} else { } else {
fprintf( aFile, "ARC %g %g %g %g %g %g\n", fprintf( aFile, "ARC %g %g %g %g %g %g\n",
(PtEdge->m_End0.x) / SCALE_FACTOR, (PtEdge->m_End0.x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->m_End0.y) / SCALE_FACTOR, (Yaxis_sign * PtEdge->m_End0.y) / SCALE_FACTOR,
(arcendx) / SCALE_FACTOR, (arcendx) / SCALE_FACTOR,
(Yaxis_sign * arcendy) / SCALE_FACTOR, (Yaxis_sign * arcendy) / SCALE_FACTOR,
(PtEdge->m_Start0.x) / SCALE_FACTOR, (PtEdge->m_Start0.x) / SCALE_FACTOR,
(Yaxis_sign * PtEdge->m_Start0.y) / SCALE_FACTOR ); (Yaxis_sign * PtEdge->m_Start0.y) / SCALE_FACTOR );
} }
break; break;
} }
default: default:
DisplayError( NULL, wxT( "Type Edge Module invalid." ) ); DisplayError( NULL, wxT( "Type Edge Module invalid." ) );
break; break;
} }
} }
break; break;
default: default:
break; break;
} }
} }
} }

View File

@ -369,7 +369,7 @@ static void compute_layer_Zs( BOARD* pcb ) /*{{{*/
int copper_layers = pcb->GetCopperLayerCount( ); int copper_layers = pcb->GetCopperLayerCount( );
// We call it 'layer' thickness, but it's the whole board thickness! // We call it 'layer' thickness, but it's the whole board thickness!
double board_thickness = pcb->GetBoardDesignSettings()->m_BoardThickness; double board_thickness = pcb->GetDesignSettings().m_BoardThickness;
double half_thickness = board_thickness / 2; double half_thickness = board_thickness / 2;
/* Compute each layer's Z value, more or less like the 3d view */ /* Compute each layer's Z value, more or less like the 3d view */
@ -1249,9 +1249,11 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName,
/* Define the translation to have the board centre to the 2D axis origin /* Define the translation to have the board centre to the 2D axis origin
* more easy for rotations... * more easy for rotations...
*/ */
pcb->ComputeBoundingBox(); EDA_RECT bbbox = pcb->ComputeBoundingBox();
double dx = board_scaling_factor * pcb->m_BoundaryBox.Centre().x * aScale;
double dy = board_scaling_factor * pcb->m_BoundaryBox.Centre().y * aScale; double dx = board_scaling_factor * bbbox.Centre().x * aScale;
double dy = board_scaling_factor * bbbox.Centre().y * aScale;
fprintf( output_file, " translation %g %g 0.0\n", -dx, dy ); fprintf( output_file, " translation %g %g 0.0\n", -dx, dy );
fprintf( output_file, " children [\n" ); fprintf( output_file, " children [\n" );

View File

@ -47,7 +47,7 @@
#include "io_mgr.h" #include "io_mgr.h"
#include "class_board.h" #include "class_board.h"
#include "build_version.h" // BOARD_FILE_VERSION
static const wxString pcbBackupFileExtension( wxT( "000" ) ); static const wxString pcbBackupFileExtension( wxT( "000" ) );
@ -226,12 +226,12 @@ the changes?" ) ) )
int ver; int ver;
sscanf( reader.Line() , "PCBNEW-BOARD Version %d date", &ver ); sscanf( reader.Line() , "PCBNEW-BOARD Version %d date", &ver );
if ( ver > g_CurrentVersionPCB ) if ( ver > BOARD_FILE_VERSION )
{ {
DisplayInfoMessage( this, _( "This file was created by a more recent \ DisplayInfoMessage( this, _( "This file was created by a more recent \
version of Pcbnew and may not load correctly. Please consider updating!" ) ); version of Pcbnew and may not load correctly. Please consider updating!" ) );
} }
else if ( ver < g_CurrentVersionPCB ) else if ( ver < BOARD_FILE_VERSION )
{ {
DisplayInfoMessage( this, _( "This file was created by an older \ DisplayInfoMessage( this, _( "This file was created by an older \
version of Pcbnew. It will be stored in the new file format when you save \ version of Pcbnew. It will be stored in the new file format when you save \
@ -278,7 +278,16 @@ this file again." ) );
NULL ); NULL );
if( !aAppend ) if( !aAppend )
{
if( board->GetFileFormatVersionAtLoad() < BOARD_FILE_VERSION )
{
DisplayInfoMessage( this, _( "This file was created by an older \
version of Pcbnew. It will be stored in the new file format when you save \
this file again." ) );
}
SetBoard( board ); SetBoard( board );
}
} }
catch( IO_ERROR ioe ) catch( IO_ERROR ioe )
{ {

View File

@ -41,11 +41,11 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
SetLocaleTo_C_standard(); // Use the standard notation for float numbers SetLocaleTo_C_standard(); // Use the standard notation for float numbers
// Calculate dimensions and center of PCB // Calculate dimensions and center of PCB
aPcb->ComputeBoundingBox(); EDA_RECT bbbox = aPcb->ComputeBoundingBox();
dX = aPcb->m_BoundaryBox.GetWidth(); dX = bbbox.GetWidth();
dY = aPcb->m_BoundaryBox.GetHeight(); dY = bbbox.GetHeight();
BoardCentre = aPcb->m_BoundaryBox.Centre(); BoardCentre = bbbox.Centre();
// Calculate the scale for the format type, scale 1 in HPGL, drawing on // Calculate the scale for the format type, scale 1 in HPGL, drawing on
// an A4 sheet in PS, + text description of symbols // an A4 sheet in PS, + text description of symbols
@ -163,8 +163,8 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
intervalle = (int) ( CharSize * CharScale ) + TextWidth; intervalle = (int) ( CharSize * CharScale ) + TextWidth;
/* Trace information. */ /* Trace information. */
plotX = (int) ( (double) aPcb->m_BoundaryBox.GetX() + 200.0 * CharScale ); plotX = (int) ( (double) bbbox.GetX() + 200.0 * CharScale );
plotY = aPcb->m_BoundaryBox.GetBottom() + intervalle; plotY = bbbox.GetBottom() + intervalle;
/* Plot title "Info" */ /* Plot title "Info" */
wxString Text = wxT( "Drill Map:" ); wxString Text = wxT( "Drill Map:" );

View File

@ -33,6 +33,12 @@ public:
}; };
#if 1
static const double conv_unit = 0.0001; // units = INCHES
#else
static const double conv_unit = 0.000254; // units = mm
#endif
static wxPoint File_Place_Offset; /* Offset coordinates for generated file. */ static wxPoint File_Place_Offset; /* Offset coordinates for generated file. */
static void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile ); static void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile );
@ -87,11 +93,6 @@ void PCB_EDIT_FRAME::GenModulesPosition( wxCommandEvent& event )
FILE* fpBack = 0; FILE* fpBack = 0;
bool switchedLocale = false; bool switchedLocale = false;
/* Calculate conversion scales. */
double conv_unit = 0.0001; /* unites = INCHES */
// if(IF_DRILL_METRIC) conv_unit = 0.000254; /* unites = mm */
File_Place_Offset = m_Auxiliary_Axis_Position; File_Place_Offset = m_Auxiliary_Axis_Position;
/* Calculating the number of useful modules (CMS attribute, not VIRTUAL) */ /* Calculating the number of useful modules (CMS attribute, not VIRTUAL) */
@ -319,7 +320,6 @@ exit: // the only safe way out of here, no returns please.
*/ */
void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event ) void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event )
{ {
double conv_unit;
MODULE* Module; MODULE* Module;
D_PAD* pad; D_PAD* pad;
char line[1024]; char line[1024];
@ -328,10 +328,6 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event )
FILE* rptfile; FILE* rptfile;
wxPoint module_pos; wxPoint module_pos;
conv_unit = 0.0001; /* unites = INCHES */
// if(IF_DRILL_METRIC) conv_unit = 0.000254; /* unites = mm */
File_Place_Offset = wxPoint( 0, 0 ); File_Place_Offset = wxPoint( 0, 0 );
wxString boardFilePath = ( (wxFileName) GetScreen()->GetFileName()).GetPath(); wxString boardFilePath = ( (wxFileName) GetScreen()->GetFileName()).GetPath();
@ -369,17 +365,20 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event )
fputs( "##\n", rptfile ); fputs( "##\n", rptfile );
fputs( "\n$BeginDESCRIPTION\n", rptfile ); fputs( "\n$BeginDESCRIPTION\n", rptfile );
GetBoard()->ComputeBoundingBox(); EDA_RECT bbbox = GetBoard()->ComputeBoundingBox();
fputs( "\n$BOARD\n", rptfile ); fputs( "\n$BOARD\n", rptfile );
fputs( "unit INCH\n", rptfile ); fputs( "unit INCH\n", rptfile );
sprintf( line, "upper_left_corner %9.6f %9.6f\n", sprintf( line, "upper_left_corner %9.6f %9.6f\n",
GetBoard()->m_BoundaryBox.GetX() * conv_unit, bbbox.GetX() * conv_unit,
GetBoard()->m_BoundaryBox.GetY() * conv_unit ); bbbox.GetY() * conv_unit );
fputs( line, rptfile ); fputs( line, rptfile );
sprintf( line, "lower_right_corner %9.6f %9.6f\n", sprintf( line, "lower_right_corner %9.6f %9.6f\n",
GetBoard()->m_BoundaryBox.GetRight() * conv_unit, bbbox.GetRight() * conv_unit,
GetBoard()->m_BoundaryBox.GetBottom() * conv_unit ); bbbox.GetBottom() * conv_unit );
fputs( line, rptfile ); fputs( line, rptfile );
fputs( "$EndBOARD\n\n", rptfile ); fputs( "$EndBOARD\n\n", rptfile );
@ -512,12 +511,10 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event )
*/ */
void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile ) void WriteDrawSegmentPcb( DRAWSEGMENT* PtDrawSegment, FILE* rptfile )
{ {
double conv_unit, ux0, uy0, dx, dy; double ux0, uy0, dx, dy;
double radius, width; double radius, width;
char line[1024]; char line[1024];
conv_unit = 0.0001; /* units = INCHES */
ux0 = PtDrawSegment->m_Start.x * conv_unit; ux0 = PtDrawSegment->m_Start.x * conv_unit;
uy0 = PtDrawSegment->m_Start.y * conv_unit; uy0 = PtDrawSegment->m_Start.y * conv_unit;

View File

@ -197,8 +197,8 @@ void TraceFilledCircle( BOARD* Pcb,
break; break;
} }
cx -= Pcb->m_BoundaryBox.m_Pos.x; cx -= Pcb->GetBoundingBox().m_Pos.x;
cy -= Pcb->m_BoundaryBox.m_Pos.y; cy -= Pcb->GetBoundingBox().m_Pos.y;
distmin = radius; distmin = radius;
@ -298,10 +298,10 @@ void TraceSegmentPcb( BOARD* Pcb, TRACK* pt_segm, int color, int marge, int op_l
half_width = ( pt_segm->m_Width / 2 ) + marge; half_width = ( pt_segm->m_Width / 2 ) + marge;
/* Calculate the bounding rectangle of the segment (if H, V or Via) */ /* Calculate the bounding rectangle of the segment (if H, V or Via) */
ux0 = pt_segm->m_Start.x - Pcb->m_BoundaryBox.m_Pos.x; ux0 = pt_segm->m_Start.x - Pcb->GetBoundingBox().m_Pos.x;
uy0 = pt_segm->m_Start.y - Pcb->m_BoundaryBox.m_Pos.y; uy0 = pt_segm->m_Start.y - Pcb->GetBoundingBox().m_Pos.y;
ux1 = pt_segm->m_End.x - Pcb->m_BoundaryBox.m_Pos.x; ux1 = pt_segm->m_End.x - Pcb->GetBoundingBox().m_Pos.x;
uy1 = pt_segm->m_End.y - Pcb->m_BoundaryBox.m_Pos.y; uy1 = pt_segm->m_End.y - Pcb->GetBoundingBox().m_Pos.y;
/* Test if VIA (filled circle was drawn) */ /* Test if VIA (filled circle was drawn) */
if( pt_segm->Type() == PCB_VIA_T ) if( pt_segm->Type() == PCB_VIA_T )
@ -558,10 +558,10 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
break; break;
} }
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; ux0 -= Pcb->GetBoundingBox().m_Pos.x;
uy0 -= Pcb->m_BoundaryBox.m_Pos.y; uy0 -= Pcb->GetBoundingBox().m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; ux1 -= Pcb->GetBoundingBox().m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y; uy1 -= Pcb->GetBoundingBox().m_Pos.y;
/* Calculating limits coord cells belonging to the rectangle. */ /* Calculating limits coord cells belonging to the rectangle. */
row_max = uy1 / Board.m_GridRouting; row_max = uy1 / Board.m_GridRouting;
@ -650,10 +650,10 @@ void TraceFilledRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
break; break;
} }
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; ux0 -= Pcb->GetBoundingBox().m_Pos.x;
uy0 -= Pcb->m_BoundaryBox.m_Pos.y; uy0 -= Pcb->GetBoundingBox().m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; ux1 -= Pcb->GetBoundingBox().m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y; uy1 -= Pcb->GetBoundingBox().m_Pos.y;
cx = (ux0 + ux1) / 2; cx = (ux0 + ux1) / 2;
cy = (uy0 + uy1) / 2; cy = (uy0 + uy1) / 2;

View File

@ -39,7 +39,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
// delete the old BOARD and create a new BOARD so that the default // delete the old BOARD and create a new BOARD so that the default
// layer names are put into the BOARD. // layer names are put into the BOARD.
SetBoard( new BOARD( this ) ); SetBoard( new BOARD() );
SetCurItem( NULL ); SetCurItem( NULL );
/* clear filename, to avoid overwriting an old file */ /* clear filename, to avoid overwriting an old file */

View File

@ -163,41 +163,6 @@ class PLUGIN
{ {
public: public:
virtual ~PLUGIN() {}
/**
* Class RELEASER
* releases a PLUGIN in the context of a potential thrown exception, through
* its destructor.
*/
class RELEASER
{
PLUGIN* plugin;
public:
RELEASER( PLUGIN* aPlugin = NULL ) :
plugin( aPlugin )
{
}
~RELEASER()
{
if( plugin )
IO_MGR::PluginRelease( plugin );
}
operator PLUGIN* ()
{
return plugin;
}
PLUGIN* operator -> ()
{
return plugin;
}
};
//-----<PUBLIC PLUGIN API>------------------------------------------------- //-----<PUBLIC PLUGIN API>-------------------------------------------------
/** /**
@ -259,6 +224,40 @@ public:
PROPERTIES* aProperties = NULL ); PROPERTIES* aProperties = NULL );
//-----</PUBLIC PLUGIN API>------------------------------------------------ //-----</PUBLIC PLUGIN API>------------------------------------------------
virtual ~PLUGIN() {}
/**
* Class RELEASER
* releases a PLUGIN in the context of a potential thrown exception, through
* its destructor.
*/
class RELEASER
{
PLUGIN* plugin;
public:
RELEASER( PLUGIN* aPlugin = NULL ) :
plugin( aPlugin )
{
}
~RELEASER()
{
if( plugin )
IO_MGR::PluginRelease( plugin );
}
operator PLUGIN* ()
{
return plugin;
}
PLUGIN* operator -> ()
{
return plugin;
}
};
}; };

View File

@ -246,7 +246,7 @@ int PCB_BASE_FRAME::ReadGeneralDescrPcb( LINE_READER* aReader )
if( stricmp( data, "BoardThickness" ) == 0 ) if( stricmp( data, "BoardThickness" ) == 0 )
{ {
data = strtok( NULL, delims ); data = strtok( NULL, delims );
GetBoard()->GetBoardDesignSettings()->m_BoardThickness = atoi( data ); GetBoard()->GetDesignSettings().m_BoardThickness = atoi( data );
continue; continue;
} }
@ -265,19 +265,21 @@ int PCB_BASE_FRAME::ReadGeneralDescrPcb( LINE_READER* aReader )
if( strnicmp( data, "Di", 2 ) == 0 ) if( strnicmp( data, "Di", 2 ) == 0 )
{ {
wxSize pcbsize, screensize; data = strtok( NULL, delims );
int x1 = atoi( data );
data = strtok( NULL, delims ); data = strtok( NULL, delims );
GetBoard()->m_BoundaryBox.SetX( atoi( data ) ); int y1 = atoi( data );
data = strtok( NULL, delims ); data = strtok( NULL, delims );
GetBoard()->m_BoundaryBox.SetY( atoi( data ) ); int x2 = atoi( data );
data = strtok( NULL, delims ); data = strtok( NULL, delims );
GetBoard()->m_BoundaryBox.SetWidth( atoi( data ) - GetBoard()->m_BoundaryBox.GetX() ); int y2 = atoi( data );
data = strtok( NULL, delims ); EDA_RECT bbbox( wxPoint( x1, x2 ), wxSize( x2-x1, y2-y1 ) );
GetBoard()->m_BoundaryBox.SetHeight( atoi( data ) - GetBoard()->m_BoundaryBox.GetY() );
GetBoard()->SetBoundingBox( bbbox );
continue; continue;
} }
@ -449,7 +451,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "TrackMinWidth" ) == 0 ) if( stricmp( line, "TrackMinWidth" ) == 0 )
{ {
GetBoard()->GetBoardDesignSettings()->m_TrackMinWidth = atoi( data ); GetBoard()->GetDesignSettings().m_TrackMinWidth = atoi( data );
continue; continue;
} }
@ -461,13 +463,13 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "DrawSegmWidth" ) == 0 ) if( stricmp( line, "DrawSegmWidth" ) == 0 )
{ {
GetBoard()->GetBoardDesignSettings()->m_DrawSegmentWidth = atoi( data ); GetBoard()->GetDesignSettings().m_DrawSegmentWidth = atoi( data );
continue; continue;
} }
if( stricmp( line, "EdgeSegmWidth" ) == 0 ) if( stricmp( line, "EdgeSegmWidth" ) == 0 )
{ {
GetBoard()->GetBoardDesignSettings()->m_EdgeSegmentWidth = atoi( data ); GetBoard()->GetDesignSettings().m_EdgeSegmentWidth = atoi( data );
continue; continue;
} }
@ -478,7 +480,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "ViaMinSize" ) == 0 ) if( stricmp( line, "ViaMinSize" ) == 0 )
{ {
GetBoard()->GetBoardDesignSettings()->m_ViasMinSize = atoi( data ); GetBoard()->GetDesignSettings().m_ViasMinSize = atoi( data );
continue; continue;
} }
@ -489,7 +491,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "MicroViaMinSize" ) == 0 ) if( stricmp( line, "MicroViaMinSize" ) == 0 )
{ {
GetBoard()->GetBoardDesignSettings()->m_MicroViasMinSize = atoi( data ); GetBoard()->GetDesignSettings().m_MicroViasMinSize = atoi( data );
continue; continue;
} }
@ -519,7 +521,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "ViaMinDrill" ) == 0 ) if( stricmp( line, "ViaMinDrill" ) == 0 )
{ {
GetBoard()->GetBoardDesignSettings()->m_ViasMinDrill = atoi( data ); GetBoard()->GetDesignSettings().m_ViasMinDrill = atoi( data );
continue; continue;
} }
@ -533,27 +535,27 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "MicroViaMinDrill" ) == 0 ) if( stricmp( line, "MicroViaMinDrill" ) == 0 )
{ {
int diameter = atoi( data ); int diameter = atoi( data );
GetBoard()->GetBoardDesignSettings()->m_MicroViasMinDrill = diameter; GetBoard()->GetDesignSettings().m_MicroViasMinDrill = diameter;
continue; continue;
} }
if( stricmp( line, "MicroViasAllowed" ) == 0 ) if( stricmp( line, "MicroViasAllowed" ) == 0 )
{ {
GetBoard()->GetBoardDesignSettings()->m_MicroViasAllowed = atoi( data ); GetBoard()->GetDesignSettings().m_MicroViasAllowed = atoi( data );
continue; continue;
} }
if( stricmp( line, "TextPcbWidth" ) == 0 ) if( stricmp( line, "TextPcbWidth" ) == 0 )
{ {
GetBoard()->GetBoardDesignSettings()->m_PcbTextWidth = atoi( data ); GetBoard()->GetDesignSettings().m_PcbTextWidth = atoi( data );
continue; continue;
} }
if( stricmp( line, "TextPcbSize" ) == 0 ) if( stricmp( line, "TextPcbSize" ) == 0 )
{ {
GetBoard()->GetBoardDesignSettings()->m_PcbTextSize.x = atoi( data ); GetBoard()->GetDesignSettings().m_PcbTextSize.x = atoi( data );
data = strtok( NULL, delims ); data = strtok( NULL, delims );
GetBoard()->GetBoardDesignSettings()->m_PcbTextSize.y = atoi( data ); GetBoard()->GetDesignSettings().m_PcbTextSize.y = atoi( data );
continue; continue;
} }
@ -594,19 +596,19 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "Pad2MaskClearance" ) == 0 ) if( stricmp( line, "Pad2MaskClearance" ) == 0 )
{ {
GetBoard()->GetBoardDesignSettings()->m_SolderMaskMargin = atoi( data ); GetBoard()->GetDesignSettings().m_SolderMaskMargin = atoi( data );
continue; continue;
} }
if( stricmp( line, "Pad2PasteClearance" ) == 0 ) if( stricmp( line, "Pad2PasteClearance" ) == 0 )
{ {
GetBoard()->GetBoardDesignSettings()->m_SolderPasteMargin = atoi( data ); GetBoard()->GetDesignSettings().m_SolderPasteMargin = atoi( data );
continue; continue;
} }
if( stricmp( line, "Pad2PasteClearanceRatio" ) == 0 ) if( stricmp( line, "Pad2PasteClearanceRatio" ) == 0 )
{ {
GetBoard()->GetBoardDesignSettings()->m_SolderPasteMarginRatio = atof( data ); GetBoard()->GetDesignSettings().m_SolderPasteMarginRatio = atof( data );
continue; continue;
} }
@ -694,16 +696,16 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard )
fprintf( aFile, "TrackClearence %d\n", netclass_default->GetClearance() ); fprintf( aFile, "TrackClearence %d\n", netclass_default->GetClearance() );
fprintf( aFile, "ZoneClearence %d\n", g_Zone_Default_Setting.m_ZoneClearance ); fprintf( aFile, "ZoneClearence %d\n", g_Zone_Default_Setting.m_ZoneClearance );
fprintf( aFile, "TrackMinWidth %d\n", aBoard->GetBoardDesignSettings()->m_TrackMinWidth ); fprintf( aFile, "TrackMinWidth %d\n", aBoard->GetDesignSettings().m_TrackMinWidth );
fprintf( aFile, "DrawSegmWidth %d\n", aBoard->GetBoardDesignSettings()->m_DrawSegmentWidth ); fprintf( aFile, "DrawSegmWidth %d\n", aBoard->GetDesignSettings().m_DrawSegmentWidth );
fprintf( aFile, "EdgeSegmWidth %d\n", aBoard->GetBoardDesignSettings()->m_EdgeSegmentWidth ); fprintf( aFile, "EdgeSegmWidth %d\n", aBoard->GetDesignSettings().m_EdgeSegmentWidth );
// Save current default via size, for compatibility with older Pcbnew version; // Save current default via size, for compatibility with older Pcbnew version;
fprintf( aFile, "ViaSize %d\n", netclass_default->GetViaDiameter() ); fprintf( aFile, "ViaSize %d\n", netclass_default->GetViaDiameter() );
fprintf( aFile, "ViaDrill %d\n", netclass_default->GetViaDrill() ); fprintf( aFile, "ViaDrill %d\n", netclass_default->GetViaDrill() );
fprintf( aFile, "ViaMinSize %d\n", aBoard->GetBoardDesignSettings()->m_ViasMinSize ); fprintf( aFile, "ViaMinSize %d\n", aBoard->GetDesignSettings().m_ViasMinSize );
fprintf( aFile, "ViaMinDrill %d\n", aBoard->GetBoardDesignSettings()->m_ViasMinDrill ); fprintf( aFile, "ViaMinDrill %d\n", aBoard->GetDesignSettings().m_ViasMinDrill );
// Save custom vias diameters list (the first is not saved here: this is // Save custom vias diameters list (the first is not saved here: this is
// the netclass value // the netclass value
@ -717,19 +719,19 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard )
fprintf( aFile, "MicroViaDrill %d\n", netclass_default->GetuViaDrill() ); fprintf( aFile, "MicroViaDrill %d\n", netclass_default->GetuViaDrill() );
fprintf( aFile, fprintf( aFile,
"MicroViasAllowed %d\n", "MicroViasAllowed %d\n",
aBoard->GetBoardDesignSettings()->m_MicroViasAllowed ); aBoard->GetDesignSettings().m_MicroViasAllowed );
fprintf( aFile, fprintf( aFile,
"MicroViaMinSize %d\n", "MicroViaMinSize %d\n",
aBoard->GetBoardDesignSettings()->m_MicroViasMinSize ); aBoard->GetDesignSettings().m_MicroViasMinSize );
fprintf( aFile, fprintf( aFile,
"MicroViaMinDrill %d\n", "MicroViaMinDrill %d\n",
aBoard->GetBoardDesignSettings()->m_MicroViasMinDrill ); aBoard->GetDesignSettings().m_MicroViasMinDrill );
fprintf( aFile, "TextPcbWidth %d\n", aBoard->GetBoardDesignSettings()->m_PcbTextWidth ); fprintf( aFile, "TextPcbWidth %d\n", aBoard->GetDesignSettings().m_PcbTextWidth );
fprintf( aFile, fprintf( aFile,
"TextPcbSize %d %d\n", "TextPcbSize %d %d\n",
aBoard->GetBoardDesignSettings()->m_PcbTextSize.x, aBoard->GetDesignSettings().m_PcbTextSize.x,
aBoard->GetBoardDesignSettings()->m_PcbTextSize.y ); aBoard->GetDesignSettings().m_PcbTextSize.y );
fprintf( aFile, "EdgeModWidth %d\n", g_ModuleSegmentWidth ); fprintf( aFile, "EdgeModWidth %d\n", g_ModuleSegmentWidth );
fprintf( aFile, "TextModSize %d %d\n", g_ModuleTextSize.x, g_ModuleTextSize.y ); fprintf( aFile, "TextModSize %d %d\n", g_ModuleTextSize.x, g_ModuleTextSize.y );
@ -738,17 +740,17 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard )
fprintf( aFile, "PadDrill %d\n", g_Pad_Master.m_Drill.x ); fprintf( aFile, "PadDrill %d\n", g_Pad_Master.m_Drill.x );
fprintf( aFile, fprintf( aFile,
"Pad2MaskClearance %d\n", "Pad2MaskClearance %d\n",
aBoard->GetBoardDesignSettings()->m_SolderMaskMargin ); aBoard->GetDesignSettings().m_SolderMaskMargin );
if( aBoard->GetBoardDesignSettings()->m_SolderPasteMargin != 0 ) if( aBoard->GetDesignSettings().m_SolderPasteMargin != 0 )
fprintf( aFile, fprintf( aFile,
"Pad2PasteClearance %d\n", "Pad2PasteClearance %d\n",
aBoard->GetBoardDesignSettings()->m_SolderPasteMargin ); aBoard->GetDesignSettings().m_SolderPasteMargin );
if( aBoard->GetBoardDesignSettings()->m_SolderPasteMarginRatio != 0 ) if( aBoard->GetDesignSettings().m_SolderPasteMarginRatio != 0 )
fprintf( aFile, fprintf( aFile,
"Pad2PasteClearanceRatio %g\n", "Pad2PasteClearanceRatio %g\n",
aBoard->GetBoardDesignSettings()->m_SolderPasteMarginRatio ); aBoard->GetDesignSettings().m_SolderPasteMarginRatio );
if ( aFrame->GetScreen()->m_GridOrigin != wxPoint( 0, 0 ) ) if ( aFrame->GetScreen()->m_GridOrigin != wxPoint( 0, 0 ) )
{ {
@ -799,13 +801,13 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File )
fprintf( File, "Links %d\n", GetBoard()->GetRatsnestsCount() ); fprintf( File, "Links %d\n", GetBoard()->GetRatsnestsCount() );
fprintf( File, "NoConn %d\n", GetBoard()->m_NbNoconnect ); fprintf( File, "NoConn %d\n", GetBoard()->m_NbNoconnect );
/* Write Bounding box info */ // Write Bounding box info
GetBoard()->ComputeBoundingBox(); EDA_RECT bbbox = GetBoard()->ComputeBoundingBox();
fprintf( File, "Di %d %d %d %d\n", fprintf( File, "Di %d %d %d %d\n",
GetBoard()->m_BoundaryBox.GetX(), bbbox.GetX(),
GetBoard()->m_BoundaryBox.GetY(), bbbox.GetY(),
GetBoard()->m_BoundaryBox.GetRight(), bbbox.GetRight(),
GetBoard()->m_BoundaryBox.GetBottom() ); bbbox.GetBottom() );
/* Write segment count for footprints, drawings, track and zones */ /* Write segment count for footprints, drawings, track and zones */
/* Calculate the footprint count */ /* Calculate the footprint count */
@ -820,7 +822,7 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File )
fprintf( File, "Ndraw %d\n", NbDrawItem ); fprintf( File, "Ndraw %d\n", NbDrawItem );
fprintf( File, "Ntrack %d\n", GetBoard()->GetNumSegmTrack() ); fprintf( File, "Ntrack %d\n", GetBoard()->GetNumSegmTrack() );
fprintf( File, "Nzone %d\n", GetBoard()->GetNumSegmZone() ); fprintf( File, "Nzone %d\n", GetBoard()->GetNumSegmZone() );
fprintf( File, "BoardThickness %d\n", GetBoard()->GetBoardDesignSettings()->m_BoardThickness ); fprintf( File, "BoardThickness %d\n", GetBoard()->GetDesignSettings().m_BoardThickness );
fprintf( File, "Nmodule %d\n", NbModules ); fprintf( File, "Nmodule %d\n", NbModules );
fprintf( File, "Nnets %d\n", GetBoard()->m_NetInfo->GetCount() ); fprintf( File, "Nnets %d\n", GetBoard()->m_NetInfo->GetCount() );
fprintf( File, "$EndGENERAL\n\n" ); fprintf( File, "$EndGENERAL\n\n" );
@ -1159,7 +1161,7 @@ int PCB_EDIT_FRAME::SavePcbFormatAscii( FILE* aFile )
SetLocaleTo_C_standard(); SetLocaleTo_C_standard();
/* Writing file header. */ /* Writing file header. */
fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB, fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", BOARD_FILE_VERSION,
TO_UTF8( DateAndTime() ) ); TO_UTF8( DateAndTime() ) );
fprintf( aFile, "# Created by Pcbnew%s\n\n", TO_UTF8( GetBuildVersion() ) ); fprintf( aFile, "# Created by Pcbnew%s\n\n", TO_UTF8( GetBuildVersion() ) );

View File

@ -2,7 +2,10 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -57,10 +60,10 @@
#include <auto_ptr.h> #include <auto_ptr.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <macros.h> #include <macros.h>
#include <build_version.h>
//#include <fctsys.h> //#include <fctsys.h>
//#include <confirm.h> //#include <confirm.h>
//#include <build_version.h>
//#include <wxPcbStruct.h"> //#include <wxPcbStruct.h">
//#include <pcbcommon.h> //#include <pcbcommon.h>
@ -85,6 +88,8 @@
#include <trigo.h> #include <trigo.h>
#define VERSION_ERROR_FORMAT _( "File '%s' is format version %d.\nI only support format version <= %d.\nPlease upgrade PCBNew to load this file." )
/* /*
#include <pcbnew.h> #include <pcbnew.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
@ -92,58 +97,6 @@
*/ */
/* ASCII format of structures:
*
* Structure PAD:
*
* $PAD
* Sh "name" form DIMVA dimH dV dH East: general form dV, dH = delta size
* Dr. diam dV dH: drill: diameter drilling offsets
* At Type S / N layers: standard, cms, conn, hole, meca.,
* Stack / Normal, 32-bit hexadecimal: occupation layers
* Nm net_code netname
* Po posrefX posrefy: reFX position, Y (0 = east position / anchor)
* $EndPAD
*
* Module Structure
*
* $MODULE namelib
* Po ax ay east layer masquelayer m_TimeCode
* ax ay ord = anchor (position module)
* east = east to 0.1 degree
* layer = layer number
* masquelayer = silkscreen layer for
* m_TimeCode internal use (groups)
* Li <namelib>
*
* Cd <text> description of the component (Component Doc)
* Kw <text> List of key words
*
* Sc schematic timestamp, reference schematic
*
* Op rot90 rot180 placement Options Auto (court rot 90, 180)
* rot90 is about 2x4-bit:
* lsb = cost rot 90, rot court msb = -90;
*
* Tn px py DIMVA dimh East thickness mirror visible "text"
* n = type (0 = ref, val = 1,> 1 = qcq
* Texts POS x, y / anchor and orient module 0
* DIMVA dimh East
* mirror thickness (Normal / Mirror)
* Visible V / I
* DS ox oy fx fy w
* Edge: coord segment ox, oy has fx, fy, on
* was the anchor and orient 0
* thickness w
* DC ox oy fx fy w descr circle (center, 1 point, thickness)
* $PAD
* $EndPAD section pads if available
* $Endmodule
*/
#define MM_PER_BIU 1e-6
#define UM_PER_BIU 1e-3
/// C string compare test for a specific length of characters. /// C string compare test for a specific length of characters.
/// The -1 is to omit the trailing \0 which is included in sizeof() on a /// The -1 is to omit the trailing \0 which is included in sizeof() on a
@ -155,7 +108,7 @@
#if 1 #if 1
#define READLINE() aReader->ReadLine() #define READLINE() m_reader->ReadLine()
#else #else
/// The function and macro which follow comprise a shim which can be a /// The function and macro which follow comprise a shim which can be a
@ -177,7 +130,7 @@ static inline unsigned ReadLine( LINE_READER* rdr, const char* caller )
return ret; return ret;
} }
#define READLINE() ReadLine( aReader, __FUNCTION__ ) #define READLINE() ReadLine( m_reader, __FUNCTION__ )
#endif #endif
static const char delims[] = " \t\r\n"; static const char delims[] = " \t\r\n";
@ -216,7 +169,7 @@ BOARD* KICAD_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPER
{ {
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
m_board = aAppendToMe ? aAppendToMe : new BOARD( NULL ); m_board = aAppendToMe ? aAppendToMe : new BOARD();
// delete on exception, iff I own m_board, according to aAppendToMe // delete on exception, iff I own m_board, according to aAppendToMe
auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board ); auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board );
@ -231,10 +184,12 @@ BOARD* KICAD_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPER
// reader now owns fp, will close on exception or return // reader now owns fp, will close on exception or return
FILE_LINE_READER reader( fp, aFileName ); FILE_LINE_READER reader( fp, aFileName );
aReader = &reader; // member function accessibility m_reader = &reader; // member function accessibility
init( aProperties ); init( aProperties );
checkVersion();
loadAllSections( bool( aAppendToMe ) ); loadAllSections( bool( aAppendToMe ) );
deleter.release(); deleter.release();
@ -254,7 +209,7 @@ void KICAD_PLUGIN::loadAllSections( bool doAppend )
while( READLINE() ) while( READLINE() )
{ {
char* line = aReader->Line(); char* line = m_reader->Line();
// put the more frequent ones at the top, but realize TRACKs are loaded as a group // put the more frequent ones at the top, but realize TRACKs are loaded as a group
@ -332,7 +287,7 @@ void KICAD_PLUGIN::loadAllSections( bool doAppend )
{ {
while( READLINE() ) while( READLINE() )
{ {
line = aReader->Line(); // gobble until $EndSetup line = m_reader->Line(); // gobble until $EndSetup
if( TESTLINE( "$EndSETUP" ) ) if( TESTLINE( "$EndSETUP" ) )
break; break;
@ -351,7 +306,32 @@ void KICAD_PLUGIN::loadAllSections( bool doAppend )
*/ */
} }
THROW_IO_ERROR( wxT( "Missing '$EndBOARD'" ) ); THROW_IO_ERROR( "Missing '$EndBOARD'" );
}
void KICAD_PLUGIN::checkVersion()
{
// Read first line and TEST if it is a PCB file format header like this:
// "PCBNEW-BOARD Version 1 ...."
m_reader->ReadLine();
char* line = m_reader->Line();
if( !TESTLINE( "PCBNEW-BOARD" ) )
{
THROW_IO_ERROR( "Unknown file type" );
}
int ver = 1; // if sccanf fails
sscanf( line, "PCBNEW-BOARD Version %d", &ver );
if( ver > BOARD_FILE_VERSION )
{
m_error.Printf( VERSION_ERROR_FORMAT, ver );
THROW_IO_ERROR( m_error );
}
} }
@ -359,7 +339,7 @@ void KICAD_PLUGIN::loadGENERAL()
{ {
while( READLINE() ) while( READLINE() )
{ {
char* line = aReader->Line(); char* line = m_reader->Line();
const char* data; const char* data;
if( TESTLINE( "Units" ) ) if( TESTLINE( "Units" ) )
@ -403,7 +383,7 @@ void KICAD_PLUGIN::loadGENERAL()
else if( TESTLINE( "BoardThickness" ) ) else if( TESTLINE( "BoardThickness" ) )
{ {
BIU thickn = biuParse( line + SZ( "BoardThickness" ) ); BIU thickn = biuParse( line + SZ( "BoardThickness" ) );
m_board->GetBoardDesignSettings()->m_BoardThickness = thickn; m_board->GetDesignSettings().m_BoardThickness = thickn;
} }
/* /*
@ -426,11 +406,9 @@ void KICAD_PLUGIN::loadGENERAL()
BIU x2 = biuParse( data, &data ); BIU x2 = biuParse( data, &data );
BIU y2 = biuParse( data ); BIU y2 = biuParse( data );
m_board->m_BoundaryBox.SetX( x1 ); EDA_RECT bbbox( wxPoint( x1, x2 ), wxSize( x2-x1, y2-y1 ) );
m_board->m_BoundaryBox.SetY( y1 );
m_board->m_BoundaryBox.SetWidth( x2 - x1 ); m_board->SetBoundingBox( bbbox );
m_board->m_BoundaryBox.SetHeight( y2 - y1 );
} }
// Read the number of segments of type DRAW, TRACK, ZONE // Read the number of segments of type DRAW, TRACK, ZONE
@ -463,7 +441,7 @@ void KICAD_PLUGIN::loadGENERAL()
return; // preferred exit return; // preferred exit
} }
THROW_IO_ERROR( wxT( "Missing '$EndGENERAL'" ) ); THROW_IO_ERROR( "Missing '$EndGENERAL'" );
} }
@ -474,7 +452,7 @@ void KICAD_PLUGIN::loadSHEET()
while( READLINE() ) while( READLINE() )
{ {
char* line = aReader->Line(); char* line = m_reader->Line();
if( TESTLINE( "Sheet" ) ) if( TESTLINE( "Sheet" ) )
{ {
@ -563,7 +541,7 @@ void KICAD_PLUGIN::loadSHEET()
return; // preferred exit return; // preferred exit
} }
THROW_IO_ERROR( wxT( "Missing '$EndSHEETDESCR'" ) ); THROW_IO_ERROR( "Missing '$EndSHEETDESCR'" );
} }
@ -574,12 +552,11 @@ void KICAD_PLUGIN::loadSETUP()
while( READLINE() ) while( READLINE() )
{ {
const char* data; const char* data;
char* line = m_reader->Line();
char* line = aReader->Line();
if( TESTLINE( "PcbPlotParams" ) ) if( TESTLINE( "PcbPlotParams" ) )
{ {
PCB_PLOT_PARAMS_PARSER parser( line + SZ( "PcbPlotParams" ), aReader->GetSource() ); PCB_PLOT_PARAMS_PARSER parser( line + SZ( "PcbPlotParams" ), m_reader->GetSource() );
g_PcbPlotOptions.Parse( &parser ); g_PcbPlotOptions.Parse( &parser );
} }
@ -650,7 +627,7 @@ void KICAD_PLUGIN::loadSETUP()
else if( TESTLINE( "TrackMinWidth" ) ) else if( TESTLINE( "TrackMinWidth" ) )
{ {
BIU tmp = biuParse( line + SZ( "TrackMinWidth" ) ); BIU tmp = biuParse( line + SZ( "TrackMinWidth" ) );
m_board->GetBoardDesignSettings()->m_TrackMinWidth = tmp; m_board->GetDesignSettings().m_TrackMinWidth = tmp;
} }
else if( TESTLINE( "ZoneClearence" ) ) else if( TESTLINE( "ZoneClearence" ) )
@ -662,25 +639,25 @@ void KICAD_PLUGIN::loadSETUP()
else if( TESTLINE( "DrawSegmWidth" ) ) else if( TESTLINE( "DrawSegmWidth" ) )
{ {
BIU tmp = biuParse( line + SZ( "DrawSegmWidth" ) ); BIU tmp = biuParse( line + SZ( "DrawSegmWidth" ) );
m_board->GetBoardDesignSettings()->m_DrawSegmentWidth = tmp; m_board->GetDesignSettings().m_DrawSegmentWidth = tmp;
} }
else if( TESTLINE( "EdgeSegmWidth" ) ) else if( TESTLINE( "EdgeSegmWidth" ) )
{ {
BIU tmp = biuParse( line + SZ( "EdgeSegmWidth" ) ); BIU tmp = biuParse( line + SZ( "EdgeSegmWidth" ) );
m_board->GetBoardDesignSettings()->m_EdgeSegmentWidth = tmp; m_board->GetDesignSettings().m_EdgeSegmentWidth = tmp;
} }
else if( TESTLINE( "ViaMinSize" ) ) else if( TESTLINE( "ViaMinSize" ) )
{ {
BIU tmp = biuParse( line + SZ( "ViaMinSize" ) ); BIU tmp = biuParse( line + SZ( "ViaMinSize" ) );
m_board->GetBoardDesignSettings()->m_ViasMinSize = tmp; m_board->GetDesignSettings().m_ViasMinSize = tmp;
} }
else if( TESTLINE( "MicroViaMinSize" ) ) else if( TESTLINE( "MicroViaMinSize" ) )
{ {
BIU tmp = biuParse( line + SZ( "MicroViaMinSize" ) ); BIU tmp = biuParse( line + SZ( "MicroViaMinSize" ) );
m_board->GetBoardDesignSettings()->m_MicroViasMinSize = tmp; m_board->GetDesignSettings().m_MicroViasMinSize = tmp;
} }
else if( TESTLINE( "ViaSizeList" ) ) else if( TESTLINE( "ViaSizeList" ) )
@ -706,7 +683,7 @@ void KICAD_PLUGIN::loadSETUP()
else if( TESTLINE( "ViaMinDrill" ) ) else if( TESTLINE( "ViaMinDrill" ) )
{ {
BIU tmp = biuParse( line + SZ( "ViaMinDrill" ) ); BIU tmp = biuParse( line + SZ( "ViaMinDrill" ) );
m_board->GetBoardDesignSettings()->m_ViasMinDrill = tmp; m_board->GetDesignSettings().m_ViasMinDrill = tmp;
} }
else if( TESTLINE( "MicroViaDrill" ) ) else if( TESTLINE( "MicroViaDrill" ) )
@ -718,19 +695,19 @@ void KICAD_PLUGIN::loadSETUP()
else if( TESTLINE( "MicroViaMinDrill" ) ) else if( TESTLINE( "MicroViaMinDrill" ) )
{ {
BIU tmp = biuParse( line + SZ( "MicroViaMinDrill" ) ); BIU tmp = biuParse( line + SZ( "MicroViaMinDrill" ) );
m_board->GetBoardDesignSettings()->m_MicroViasMinDrill = tmp; m_board->GetDesignSettings().m_MicroViasMinDrill = tmp;
} }
else if( TESTLINE( "MicroViasAllowed" ) ) else if( TESTLINE( "MicroViasAllowed" ) )
{ {
int tmp = atoi( line + SZ( "MicroViasAllowed" ) ); int tmp = atoi( line + SZ( "MicroViasAllowed" ) );
m_board->GetBoardDesignSettings()->m_MicroViasAllowed = tmp; m_board->GetDesignSettings().m_MicroViasAllowed = tmp;
} }
else if( TESTLINE( "TextPcbWidth" ) ) else if( TESTLINE( "TextPcbWidth" ) )
{ {
BIU tmp = biuParse( line + SZ( "TextPcbWidth" ) ); BIU tmp = biuParse( line + SZ( "TextPcbWidth" ) );
m_board->GetBoardDesignSettings()->m_PcbTextWidth = tmp; m_board->GetDesignSettings().m_PcbTextWidth = tmp;
} }
else if( TESTLINE( "TextPcbSize" ) ) else if( TESTLINE( "TextPcbSize" ) )
@ -738,7 +715,7 @@ void KICAD_PLUGIN::loadSETUP()
BIU x = biuParse( line + SZ( "TextPcbSize" ), &data ); BIU x = biuParse( line + SZ( "TextPcbSize" ), &data );
BIU y = biuParse( data ); BIU y = biuParse( data );
m_board->GetBoardDesignSettings()->m_PcbTextSize = wxSize( x, y ); m_board->GetDesignSettings().m_PcbTextSize = wxSize( x, y );
} }
else if( TESTLINE( "EdgeModWidth" ) ) else if( TESTLINE( "EdgeModWidth" ) )
@ -787,19 +764,19 @@ void KICAD_PLUGIN::loadSETUP()
else if( TESTLINE( "Pad2MaskClearance" ) ) else if( TESTLINE( "Pad2MaskClearance" ) )
{ {
BIU tmp = biuParse( line + SZ( "Pad2MaskClearance" ) ); BIU tmp = biuParse( line + SZ( "Pad2MaskClearance" ) );
m_board->GetBoardDesignSettings()->m_SolderMaskMargin = tmp; m_board->GetDesignSettings().m_SolderMaskMargin = tmp;
} }
else if( TESTLINE( "Pad2PasteClearance" ) ) else if( TESTLINE( "Pad2PasteClearance" ) )
{ {
BIU tmp = biuParse( line + SZ( "Pad2PasteClearance" ) ); BIU tmp = biuParse( line + SZ( "Pad2PasteClearance" ) );
m_board->GetBoardDesignSettings()->m_SolderPasteMargin = tmp; m_board->GetDesignSettings().m_SolderPasteMargin = tmp;
} }
else if( TESTLINE( "Pad2PasteClearanceRatio" ) ) else if( TESTLINE( "Pad2PasteClearanceRatio" ) )
{ {
double ratio = atof( line + SZ( "Pad2PasteClearanceRatio" ) ); double ratio = atof( line + SZ( "Pad2PasteClearanceRatio" ) );
m_board->GetBoardDesignSettings()->m_SolderPasteMarginRatio = ratio; m_board->GetDesignSettings().m_SolderPasteMarginRatio = ratio;
} }
else if( TESTLINE( "GridOrigin" ) ) else if( TESTLINE( "GridOrigin" ) )
@ -874,7 +851,7 @@ void KICAD_PLUGIN::loadMODULE()
while( READLINE() ) while( READLINE() )
{ {
const char* data; const char* data;
char* line = aReader->Line(); char* line = m_reader->Line();
// most frequently encountered ones at the top // most frequently encountered ones at the top
@ -885,7 +862,7 @@ void KICAD_PLUGIN::loadMODULE()
EDGE_MODULE * edge; EDGE_MODULE * edge;
edge = new EDGE_MODULE( this ); edge = new EDGE_MODULE( this );
m_Drawings.PushBack( edge ); m_Drawings.PushBack( edge );
edge->ReadDescr( aReader ); edge->ReadDescr( m_reader );
edge->SetDrawCoord(); edge->SetDrawCoord();
*/ */
} }
@ -1024,7 +1001,7 @@ void KICAD_PLUGIN::loadMODULE()
} }
} }
THROW_IO_ERROR( wxT( "Missing '$EndMODULE'" ) ); THROW_IO_ERROR( "Missing '$EndMODULE'" );
} }
@ -1035,7 +1012,7 @@ void KICAD_PLUGIN::loadPAD( MODULE* aModule )
while( READLINE() ) while( READLINE() )
{ {
const char* data; const char* data;
char* line = aReader->Line(); char* line = m_reader->Line();
if( TESTLINE( "Sh" ) ) // (Sh)ape and padname if( TESTLINE( "Sh" ) ) // (Sh)ape and padname
{ {
@ -1065,7 +1042,7 @@ void KICAD_PLUGIN::loadPAD( MODULE* aModule )
case 'T': padshape = PAD_TRAPEZOID; break; case 'T': padshape = PAD_TRAPEZOID; break;
default: default:
m_error.Printf( _( "Unknown padshape '%s' on line:%d" ), m_error.Printf( _( "Unknown padshape '%s' on line:%d" ),
FROM_UTF8( line ).GetData(), aReader->LineNumber() ); FROM_UTF8( line ).GetData(), m_reader->LineNumber() );
THROW_IO_ERROR( m_error ); THROW_IO_ERROR( m_error );
} }
@ -1203,14 +1180,14 @@ void KICAD_PLUGIN::loadPAD( MODULE* aModule )
} }
} }
THROW_IO_ERROR( wxT( "Missing '$EndPAD'" ) ); THROW_IO_ERROR( "Missing '$EndPAD'" );
} }
void KICAD_PLUGIN::loadEDGE_MODULE( MODULE* aModule ) void KICAD_PLUGIN::loadEDGE_MODULE( MODULE* aModule )
{ {
STROKE_T shape; STROKE_T shape;
char* line = aReader->Line(); // obtain current (old) line char* line = m_reader->Line(); // obtain current (old) line
switch( line[1] ) switch( line[1] )
{ {
@ -1294,16 +1271,16 @@ void KICAD_PLUGIN::loadEDGE_MODULE( MODULE* aModule )
{ {
if( !READLINE() ) if( !READLINE() )
{ {
THROW_IO_ERROR( wxT( "S_POLGON point count mismatch." ) ); THROW_IO_ERROR( "S_POLGON point count mismatch." );
} }
line = aReader->Line(); line = m_reader->Line();
// e.g. "Dl 23 44\n" // e.g. "Dl 23 44\n"
if( !TESTLINE( "Dl" ) ) if( !TESTLINE( "Dl" ) )
{ {
THROW_IO_ERROR( wxT( "Missing Dl point def" ) ); THROW_IO_ERROR( "Missing Dl point def" );
} }
BIU x = biuParse( line + SZ( "Dl" ), &data ); BIU x = biuParse( line + SZ( "Dl" ), &data );
@ -1352,7 +1329,7 @@ void KICAD_PLUGIN::loadEDGE_MODULE( MODULE* aModule )
void KICAD_PLUGIN::loadTEXTE_MODULE( TEXTE_MODULE* aText ) void KICAD_PLUGIN::loadTEXTE_MODULE( TEXTE_MODULE* aText )
{ {
const char* data; const char* data;
char* line = aReader->Line(); // current (old) line char* line = m_reader->Line(); // current (old) line
// sscanf( line + 1, "%d %d %d %d %d %d %d %s %s %d %s", &type, &m_Pos0.x, &m_Pos0.y, &m_Size.y, &m_Size.x, // sscanf( line + 1, "%d %d %d %d %d %d %d %s %s %d %s", &type, &m_Pos0.x, &m_Pos0.y, &m_Size.y, &m_Size.x,
// &m_Orient, &m_Thickness, BufCar1, BufCar2, &layer, BufCar3 ) >= 10 ) // &m_Orient, &m_Thickness, BufCar1, BufCar2, &layer, BufCar3 ) >= 10 )
@ -1412,7 +1389,7 @@ void KICAD_PLUGIN::loadTEXTE_MODULE( TEXTE_MODULE* aText )
aText->SetMirrored( mirror && *mirror == 'M' ); aText->SetMirrored( mirror && *mirror == 'M' );
aText->SetInvisible( hide && *hide == 'I' ); aText->SetVisible( !(hide && *hide == 'I') );
aText->SetItalic( italic && *italic == 'I' ); aText->SetItalic( italic && *italic == 'I' );
@ -1433,10 +1410,9 @@ void KICAD_PLUGIN::loadTEXTE_MODULE( TEXTE_MODULE* aText )
aText->SetDrawCoord(); aText->SetDrawCoord();
// convert the "quoted, escaped, UTF8, text" to a wxString // convert the "quoted, escaped, UTF8, text" to a wxString
wxString wtext; ReadDelimitedText( &m_field, text ? text : "" );
ReadDelimitedText( &wtext, text ? text : "" );
aText->SetText( wtext ); aText->SetText( m_field );
} }
@ -1455,7 +1431,7 @@ void KICAD_PLUGIN::load3D( MODULE* aModule )
while( READLINE() ) while( READLINE() )
{ {
char* line = aReader->Line(); char* line = m_reader->Line();
if( TESTLINE( "Na" ) ) // Shape File Name if( TESTLINE( "Na" ) ) // Shape File Name
{ {
@ -1492,7 +1468,7 @@ void KICAD_PLUGIN::load3D( MODULE* aModule )
return; // preferred exit return; // preferred exit
} }
THROW_IO_ERROR( wxT( "Missing '$EndSHAPE3D'" ) ); THROW_IO_ERROR( "Missing '$EndSHAPE3D'" );
} }
@ -1510,7 +1486,7 @@ void KICAD_PLUGIN::loadDRAWSEGMENT()
while( READLINE() ) while( READLINE() )
{ {
const char* data; const char* data;
char* line = aReader->Line(); char* line = m_reader->Line();
if( TESTLINE( "Po" ) ) if( TESTLINE( "Po" ) )
{ {
@ -1606,7 +1582,7 @@ void KICAD_PLUGIN::loadDRAWSEGMENT()
} }
} }
THROW_IO_ERROR( wxT( "Missing '$EndDRAWSEGMENT'" ) ); THROW_IO_ERROR( "Missing '$EndDRAWSEGMENT'" );
} }
@ -1620,7 +1596,7 @@ void KICAD_PLUGIN::loadNETINFO_ITEM()
while( READLINE() ) while( READLINE() )
{ {
const char* data; const char* data;
char* line = aReader->Line(); char* line = m_reader->Line();
if( TESTLINE( "Na" ) ) if( TESTLINE( "Na" ) )
{ {
@ -1637,7 +1613,7 @@ void KICAD_PLUGIN::loadNETINFO_ITEM()
return; // preferred exit return; // preferred exit
} }
THROW_IO_ERROR( wxT( "Missing '$EndEQUIPOT'" ) ); THROW_IO_ERROR( "Missing '$EndEQUIPOT'" );
} }
@ -1672,7 +1648,7 @@ void KICAD_PLUGIN::loadPCB_TEXTE()
while( READLINE() ) while( READLINE() )
{ {
const char* data; const char* data;
char* line = aReader->Line(); char* line = m_reader->Line();
if( TESTLINE( "Te" ) ) // Text line (or first line for multi line texts) if( TESTLINE( "Te" ) ) // Text line (or first line for multi line texts)
{ {
@ -1734,7 +1710,7 @@ void KICAD_PLUGIN::loadPCB_TEXTE()
pcbtxt->SetMirrored( !notMirrored ); pcbtxt->SetMirrored( !notMirrored );
pcbtxt->SetTimeStamp( timestamp ); pcbtxt->SetTimeStamp( timestamp );
pcbtxt->SetItalic( strncmp( style, "Italic", SZ( "Italic" ) )==0 ); pcbtxt->SetItalic( !strcmp( style, "Italic" ) );
GRTextHorizJustifyType hj; GRTextHorizJustifyType hj;
@ -1750,9 +1726,9 @@ void KICAD_PLUGIN::loadPCB_TEXTE()
if( layer < FIRST_COPPER_LAYER ) if( layer < FIRST_COPPER_LAYER )
layer = FIRST_COPPER_LAYER; layer = FIRST_COPPER_LAYER;
else if( layer > LAST_NO_COPPER_LAYER ) else if( layer > LAST_NO_COPPER_LAYER )
layer = LAST_NO_COPPER_LAYER; layer = LAST_NO_COPPER_LAYER;
pcbtxt->SetLayer( layer ); pcbtxt->SetLayer( layer );
} }
@ -1763,7 +1739,7 @@ void KICAD_PLUGIN::loadPCB_TEXTE()
} }
} }
THROW_IO_ERROR( wxT( "Missing '$EndTEXTPCB'" ) ); THROW_IO_ERROR( "Missing '$EndTEXTPCB'" );
} }
@ -1775,8 +1751,7 @@ void KICAD_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType )
// example first line: // example first line:
// "Po 0 23994 28800 24400 28800 150 -1\r\n" // "Po 0 23994 28800 24400 28800 150 -1\r\n"
char* line = aReader->Line(); char* line = m_reader->Line();
BIU drill = -1; // SetDefault() if -1
if( line[0] == '$' ) // $EndTRACK if( line[0] == '$' ) // $EndTRACK
return; // preferred exit return; // preferred exit
@ -1796,10 +1771,8 @@ void KICAD_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType )
// optional 7th drill parameter (must be optional in an old format?) // optional 7th drill parameter (must be optional in an old format?)
data = strtok( (char*) data, delims ); data = strtok( (char*) data, delims );
if( data )
{ BIU drill = data ? biuParse( data ) : -1; // SetDefault() if -1
drill = biuParse( data );
}
// Read the 2nd line to determine the exact type, one of: // Read the 2nd line to determine the exact type, one of:
// PCB_TRACE_T, PCB_VIA_T, or PCB_ZONE_T. The type field in 2nd line // PCB_TRACE_T, PCB_VIA_T, or PCB_ZONE_T. The type field in 2nd line
@ -1808,7 +1781,7 @@ void KICAD_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType )
// exactly. // exactly.
READLINE(); READLINE();
line = aReader->Line(); line = m_reader->Line();
// example second line: // example second line:
// "De 0 0 463 0 800000\r\n" // "De 0 0 463 0 800000\r\n"
@ -1816,7 +1789,7 @@ void KICAD_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType )
if( !TESTLINE( "De" ) ) if( !TESTLINE( "De" ) )
{ {
// mandatory 2nd line is missing // mandatory 2nd line is missing
THROW_IO_ERROR( wxT( "Missing 2nd line of a TRACK def" ) ); THROW_IO_ERROR( "Missing 2nd line of a TRACK def" );
} }
int makeType; int makeType;
@ -1877,7 +1850,7 @@ void KICAD_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType )
newTrack->SetState( flags, ON ); newTrack->SetState( flags, ON );
} }
THROW_IO_ERROR( wxT( "Missing '$EndTRACK'" ) ); THROW_IO_ERROR( "Missing '$EndTRACK'" );
} }
@ -1894,7 +1867,7 @@ void KICAD_PLUGIN::loadNETCLASS()
while( READLINE() ) while( READLINE() )
{ {
char* line = aReader->Line(); char* line = m_reader->Line();
if( TESTLINE( "AddNet" ) ) // most frequent type of line if( TESTLINE( "AddNet" ) ) // most frequent type of line
{ {
@ -1973,7 +1946,7 @@ void KICAD_PLUGIN::loadNETCLASS()
} }
} }
THROW_IO_ERROR( wxT( "Missing '$EndNCLASS'" ) ); THROW_IO_ERROR( "Missing '$EndNCLASS'" );
} }
@ -1988,7 +1961,7 @@ void KICAD_PLUGIN::loadZONE_CONTAINER()
while( READLINE() ) while( READLINE() )
{ {
const char* data; const char* data;
char* line = aReader->Line(); char* line = m_reader->Line();
if( TESTLINE( "ZCorner" ) ) // new corner found if( TESTLINE( "ZCorner" ) ) // new corner found
{ {
@ -2016,7 +1989,7 @@ void KICAD_PLUGIN::loadZONE_CONTAINER()
if( ReadDelimitedText( buf, data, sizeof(buf) ) > (int) sizeof(buf) ) if( ReadDelimitedText( buf, data, sizeof(buf) ) > (int) sizeof(buf) )
{ {
THROW_IO_ERROR( wxT( "ZInfo netname too long" ) ); THROW_IO_ERROR( "ZInfo netname too long" );
} }
zc->SetTimeStamp( timestamp ); zc->SetTimeStamp( timestamp );
@ -2129,7 +2102,7 @@ void KICAD_PLUGIN::loadZONE_CONTAINER()
while( READLINE() ) while( READLINE() )
{ {
line = aReader->Line(); line = m_reader->Line();
if( TESTLINE( "$endPOLYSCORNERS" ) ) if( TESTLINE( "$endPOLYSCORNERS" ) )
break; break;
@ -2149,7 +2122,7 @@ void KICAD_PLUGIN::loadZONE_CONTAINER()
{ {
while( READLINE() ) while( READLINE() )
{ {
line = aReader->Line(); line = m_reader->Line();
if( TESTLINE( "$endFILLSEGMENTS" ) ) if( TESTLINE( "$endFILLSEGMENTS" ) )
break; break;
@ -2189,7 +2162,7 @@ void KICAD_PLUGIN::loadZONE_CONTAINER()
} }
} }
THROW_IO_ERROR( wxT( "Missing '$endCZONE_OUTLINE'" ) ); THROW_IO_ERROR( "Missing '$endCZONE_OUTLINE'" );
} }
@ -2200,7 +2173,7 @@ void KICAD_PLUGIN::loadDIMENSION()
while( READLINE() ) while( READLINE() )
{ {
const char* data; const char* data;
char* line = aReader->Line(); char* line = m_reader->Line();
if( TESTLINE( "$EndDIMENSION" ) ) if( TESTLINE( "$EndDIMENSION" ) )
{ {
@ -2390,7 +2363,7 @@ void KICAD_PLUGIN::loadDIMENSION()
} }
} }
THROW_IO_ERROR( wxT( "Missing '$EndDIMENSION'" ) ); THROW_IO_ERROR( "Missing '$EndDIMENSION'" );
} }
@ -2398,7 +2371,7 @@ void KICAD_PLUGIN::loadPCB_TARGET()
{ {
while( READLINE() ) while( READLINE() )
{ {
char* line = aReader->Line(); char* line = m_reader->Line();
if( TESTLINE( "$EndPCB_TARGET" ) ) if( TESTLINE( "$EndPCB_TARGET" ) )
{ {
@ -2432,7 +2405,7 @@ void KICAD_PLUGIN::loadPCB_TARGET()
} }
} }
THROW_IO_ERROR( wxT( "Missing '$EndDIMENSION'" ) ); THROW_IO_ERROR( "Missing '$EndDIMENSION'" );
} }
@ -2470,7 +2443,7 @@ BIU KICAD_PLUGIN::biuParse( const char* aValue, const char** nptrptr )
if( errno ) if( errno )
{ {
m_error.Printf( _( "invalid float number in\nfile: '%s'\nline: %d\noffset: %d" ), m_error.Printf( _( "invalid float number in\nfile: '%s'\nline: %d\noffset: %d" ),
aReader->GetSource().GetData(), aReader->LineNumber(), aValue - aReader->Line() + 1 ); m_reader->GetSource().GetData(), m_reader->LineNumber(), aValue - m_reader->Line() + 1 );
THROW_IO_ERROR( m_error ); THROW_IO_ERROR( m_error );
} }
@ -2478,7 +2451,7 @@ BIU KICAD_PLUGIN::biuParse( const char* aValue, const char** nptrptr )
if( aValue == nptr ) if( aValue == nptr )
{ {
m_error.Printf( _( "missing float number in\nfile: '%s'\nline: %d\noffset: %d" ), m_error.Printf( _( "missing float number in\nfile: '%s'\nline: %d\noffset: %d" ),
aReader->GetSource().GetData(), aReader->LineNumber(), aValue - aReader->Line() + 1 ); m_reader->GetSource().GetData(), m_reader->LineNumber(), aValue - m_reader->Line() + 1 );
THROW_IO_ERROR( m_error ); THROW_IO_ERROR( m_error );
} }
@ -2503,7 +2476,7 @@ double KICAD_PLUGIN::degParse( const char* aValue, const char** nptrptr )
if( errno ) if( errno )
{ {
m_error.Printf( _( "invalid float number in\nfile: '%s'\nline: %d\noffset: %d" ), m_error.Printf( _( "invalid float number in\nfile: '%s'\nline: %d\noffset: %d" ),
aReader->GetSource().GetData(), aReader->LineNumber(), aValue - aReader->Line() + 1 ); m_reader->GetSource().GetData(), m_reader->LineNumber(), aValue - m_reader->Line() + 1 );
THROW_IO_ERROR( m_error ); THROW_IO_ERROR( m_error );
} }
@ -2511,7 +2484,7 @@ double KICAD_PLUGIN::degParse( const char* aValue, const char** nptrptr )
if( aValue == nptr ) if( aValue == nptr )
{ {
m_error.Printf( _( "missing float number in\nfile: '%s'\nline: %d\noffset: %d" ), m_error.Printf( _( "missing float number in\nfile: '%s'\nline: %d\noffset: %d" ),
aReader->GetSource().GetData(), aReader->LineNumber(), aValue - aReader->Line() + 1 ); m_reader->GetSource().GetData(), m_reader->LineNumber(), aValue - m_reader->Line() + 1 );
THROW_IO_ERROR( m_error ); THROW_IO_ERROR( m_error );
} }

View File

@ -54,16 +54,16 @@ public:
//-----<PLUGIN>------------------------------------------------------------- //-----<PLUGIN>-------------------------------------------------------------
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL ); // overload
void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); // overload
const wxString& PluginName() const wxString& PluginName()
{ {
static const wxString name = wxT( "KiCad" ); static const wxString name = wxT( "KiCad" );
return name; return name;
} }
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL ); // overload
void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); // overload
//-----</PLUGIN>------------------------------------------------------------ //-----</PLUGIN>------------------------------------------------------------
protected: protected:
@ -71,7 +71,9 @@ protected:
wxString m_error; ///< for throwing exceptions wxString m_error; ///< for throwing exceptions
BOARD* m_board; ///< which BOARD, no ownership here BOARD* m_board; ///< which BOARD, no ownership here
LINE_READER* aReader; ///< no ownership here. LINE_READER* m_reader; ///< no ownership here.
wxString m_field; ///< reused to stuff MODULE fields.
/// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed. /// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
void init( PROPERTIES* aProperties ); void init( PROPERTIES* aProperties );
@ -117,7 +119,9 @@ protected:
*/ */
double degParse( const char* aValue, const char** nptrptr = NULL ); double degParse( const char* aValue, const char** nptrptr = NULL );
// load / parse functions //-----<load/parse functions>-----------------------------------------------
void checkVersion();
void loadAllSections( bool doAppend ); void loadAllSections( bool doAppend );
@ -152,13 +156,7 @@ protected:
void loadDIMENSION(); // "$COTATION" void loadDIMENSION(); // "$COTATION"
void loadPCB_TARGET(); // "$PCB_TARGET" void loadPCB_TARGET(); // "$PCB_TARGET"
//-----</ load/parse functions>---------------------------------------------
/* @todo
void load( NETINFO* me );
void load( TRACK* me );
*/
// void load( SEGZONE* me );
}; };
#endif // KICAD_PLUGIN_H_ #endif // KICAD_PLUGIN_H_

View File

@ -214,7 +214,7 @@ PCB_TARGET* PCB_EDIT_FRAME::CreateTarget( wxDC* DC )
GetBoard()->Add( target ); GetBoard()->Add( target );
target->SetLayer( EDGE_N ); target->SetLayer( EDGE_N );
target->m_Width = GetBoard()->GetBoardDesignSettings()->m_EdgeSegmentWidth; target->m_Width = GetBoard()->GetDesignSettings().m_EdgeSegmentWidth;
target->m_Size = MireDefaultSize; target->m_Size = MireDefaultSize;
target->m_Pos = DrawPanel->GetScreen()->GetCrossHairPosition(); target->m_Pos = DrawPanel->GetScreen()->GetCrossHairPosition();

View File

@ -155,16 +155,15 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( wxWindow* father,
UpdateTitle(); UpdateTitle();
if( g_ModuleEditor_Pcb == NULL ) if( g_ModuleEditor_Pcb == NULL )
g_ModuleEditor_Pcb = new BOARD( this ); g_ModuleEditor_Pcb = new BOARD();
SetBoard( g_ModuleEditor_Pcb ); SetBoard( g_ModuleEditor_Pcb );
GetBoard()->m_PcbFrame = this;
if( s_screenModule == NULL ) if( s_screenModule == NULL )
s_screenModule = new PCB_SCREEN(); s_screenModule = new PCB_SCREEN();
SetScreen( s_screenModule ); SetScreen( s_screenModule );
GetBoard()->SetBoardDesignSettings( &s_ModuleEditorDesignSetting ); GetBoard()->SetDesignSettings( s_ModuleEditorDesignSetting );
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
LoadSettings(); LoadSettings();

View File

@ -1114,9 +1114,11 @@ bool NETLIST_READER::loadNewModules()
sort( m_newModulesList.begin(), m_newModulesList.end(), SortByLibName ); sort( m_newModulesList.begin(), m_newModulesList.end(), SortByLibName );
// Calculate the footprint "best" position: // Calculate the footprint "best" position:
if( pcb->ComputeBoundingBox( true ) ) EDA_RECT bbbox = pcb->ComputeBoundingBox( true );
if( bbbox.GetWidth() || bbbox.GetHeight() )
{ {
ModuleBestPosition = pcb->m_BoundaryBox.GetEnd(); ModuleBestPosition = bbbox.GetEnd();
ModuleBestPosition.y += 5000; ModuleBestPosition.y += 5000;
} }

View File

@ -835,12 +835,12 @@ static wxMenu* Append_Track_Width_List( BOARD* aBoard )
_( "Use the track width when starting on a track, otherwise the current track width" ), _( "Use the track width when starting on a track, otherwise the current track width" ),
true ); true );
if( aBoard->GetBoardDesignSettings()->m_UseConnectedTrackWidth ) if( aBoard->GetDesignSettings().m_UseConnectedTrackWidth )
trackwidth_menu->Check( ID_POPUP_PCB_SELECT_AUTO_WIDTH, true ); trackwidth_menu->Check( ID_POPUP_PCB_SELECT_AUTO_WIDTH, true );
if( aBoard->m_ViaSizeSelector != 0 if( aBoard->m_ViaSizeSelector != 0
|| aBoard->m_TrackWidthSelector != 0 || aBoard->m_TrackWidthSelector != 0
|| aBoard->GetBoardDesignSettings()->m_UseConnectedTrackWidth ) || aBoard->GetDesignSettings().m_UseConnectedTrackWidth )
trackwidth_menu->Append( ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES, trackwidth_menu->Append( ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES,
_( "Use Netclass Values" ), _( "Use Netclass Values" ),
_( "Use track and via sizes from their Netclass values" ), _( "Use track and via sizes from their Netclass values" ),

View File

@ -283,7 +283,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
for ( int i = 0; i < 10; i++ ) for ( int i = 0; i < 10; i++ )
m_Macros[i].m_Record.clear(); m_Macros[i].m_Record.clear();
SetBoard( new BOARD( this ) ); SetBoard( new BOARD() );
// Create the PCB_LAYER_WIDGET *after* SetBoard(): // Create the PCB_LAYER_WIDGET *after* SetBoard():
@ -617,7 +617,7 @@ bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void )
int copperlayercnt = GetBoard()->GetCopperLayerCount( ); int copperlayercnt = GetBoard()->GetCopperLayerCount( );
int currLayer = getActiveLayer(); int currLayer = getActiveLayer();
if( !GetBoard()->GetBoardDesignSettings()->m_MicroViasAllowed ) if( !GetBoard()->GetDesignSettings().m_MicroViasAllowed )
return false; // Obvious.. return false; // Obvious..
if( copperlayercnt < 4 ) if( copperlayercnt < 4 )

View File

@ -169,12 +169,12 @@ bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName )
wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer ); wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer );
/* Initialize default values. */ // Initialize default values.
g_LibraryNames.Clear(); g_LibraryNames.Clear();
wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false ); wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
/* User library path takes precedent over default library search paths. */ // User library path takes precedent over default library search paths.
wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 ); wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 );
/* Reset the items visibility flag when loading a new configuration because it could /* Reset the items visibility flag when loading a new configuration because it could
@ -207,56 +207,62 @@ void PCB_EDIT_FRAME::SaveProjectSettings()
} }
PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters() PARAM_CFG_ARRAY PCB_EDIT_FRAME::GetProjectFileParameters()
{ {
if( !m_projectFileParams.empty() ) PARAM_CFG_ARRAY pca;
return m_projectFileParams; BOARD_DESIGN_SETTINGS& bds = *GetDesignSettings();
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),&g_UserLibDirBuffer, pca.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),&g_UserLibDirBuffer,
GROUPLIB ) ); GROUPLIB ) );
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), pca.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
&g_LibraryNames, &g_LibraryNames,
GROUPLIB ) ); GROUPLIB ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDrlX" ), &g_Pad_Master.m_Drill.x, pca.push_back( new PARAM_CFG_INT( wxT( "PadDrlX" ), &g_Pad_Master.m_Drill.x,
320, 0, 0x7FFF ) ); 320, 0, 0x7FFF ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDimH" ), &g_Pad_Master.m_Size.x, pca.push_back( new PARAM_CFG_INT( wxT( "PadDimH" ), &g_Pad_Master.m_Size.x,
550, 0, 0x7FFF ) ); 550, 0, 0x7FFF ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDimV" ), &g_Pad_Master.m_Size.y, pca.push_back( new PARAM_CFG_INT( wxT( "PadDimV" ), &g_Pad_Master.m_Size.y,
550, 0, 0x7FFF ) ); 550, 0, 0x7FFF ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "BoardThickness" ),
&boardDesignSettings.m_BoardThickness,
630, 0, 0xFFFF ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtPcbV" ),
&boardDesignSettings.m_PcbTextSize.y,
600, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtPcbH" ),
&boardDesignSettings.m_PcbTextSize.x,
600, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtModV" ), &g_ModuleTextSize.y,
500, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtModH" ), &g_ModuleTextSize.x,
500, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtModW" ), &g_ModuleTextWidth,
100, 1, TEXTS_MAX_WIDTH ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "VEgarde" ),
&boardDesignSettings.m_SolderMaskMargin,
100, 0, 10000 ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "DrawLar" ),
&boardDesignSettings.m_DrawSegmentWidth,
120, 0, 0xFFFF ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "EdgeLar" ),
&boardDesignSettings.m_EdgeSegmentWidth,
120, 0, 0xFFFF ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "TxtLar" ),
&boardDesignSettings.m_PcbTextWidth,
120, 0, 0xFFFF ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "MSegLar" ), &g_ModuleSegmentWidth,
120, 0, 0xFFFF ) );
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastNetListRead" ),
&m_lastNetListRead ) );
return m_projectFileParams;
}
pca.push_back( new PARAM_CFG_INT( wxT( "BoardThickness" ),
&bds.m_BoardThickness,
630, 0, 0xFFFF ) );
pca.push_back( new PARAM_CFG_INT( wxT( "TxtPcbV" ),
&bds.m_PcbTextSize.y,
600, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
pca.push_back( new PARAM_CFG_INT( wxT( "TxtPcbH" ),
&bds.m_PcbTextSize.x,
600, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
pca.push_back( new PARAM_CFG_INT( wxT( "TxtModV" ), &g_ModuleTextSize.y,
500, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
pca.push_back( new PARAM_CFG_INT( wxT( "TxtModH" ), &g_ModuleTextSize.x,
500, TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) );
pca.push_back( new PARAM_CFG_INT( wxT( "TxtModW" ), &g_ModuleTextWidth,
100, 1, TEXTS_MAX_WIDTH ) );
pca.push_back( new PARAM_CFG_INT( wxT( "VEgarde" ),
&bds.m_SolderMaskMargin,
100, 0, 10000 ) );
pca.push_back( new PARAM_CFG_INT( wxT( "DrawLar" ),
&bds.m_DrawSegmentWidth,
120, 0, 0xFFFF ) );
pca.push_back( new PARAM_CFG_INT( wxT( "EdgeLar" ),
&bds.m_EdgeSegmentWidth,
120, 0, 0xFFFF ) );
pca.push_back( new PARAM_CFG_INT( wxT( "TxtLar" ),
&bds.m_PcbTextWidth,
120, 0, 0xFFFF ) );
pca.push_back( new PARAM_CFG_INT( wxT( "MSegLar" ), &g_ModuleSegmentWidth,
120, 0, 0xFFFF ) );
pca.push_back( new PARAM_CFG_FILENAME( wxT( "LastNetListRead" ),
&m_lastNetListRead ) );
return pca;
}
PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()

View File

@ -9,20 +9,13 @@
#include "param_config.h" #include "param_config.h"
#include "colors_selection.h" #include "colors_selection.h"
class BOARD_DESIGN_SETTINGS;
#define GROUP wxT( "/pcbnew" ) #define GROUP wxT( "/pcbnew" )
#define GROUPLIB wxT( "/pcbnew/libraries" ) #define GROUPLIB wxT( "/pcbnew/libraries" )
#define GROUPCOMMON wxT( "/common" ) #define GROUPCOMMON wxT( "/common" )
/* Useful macro : */ /* Useful macro : */
#define LOC_COLOR(layer) &g_ColorsSettings.m_LayersColors[layer] #define LOC_COLOR(layer) &g_ColorsSettings.m_LayersColors[layer]
#define ITEM_COLOR(item_visible) &g_ColorsSettings.m_ItemsColors[item_visible] #define ITEM_COLOR(item_visible) &g_ColorsSettings.m_ItemsColors[item_visible]
/* Configuration parameters. */
extern BOARD_DESIGN_SETTINGS boardDesignSettings;
#endif // _PCBNEW_CONFIG_H_ #endif // _PCBNEW_CONFIG_H_

View File

@ -917,7 +917,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
// If the current layer is a solder mask, use the global mask // If the current layer is a solder mask, use the global mask
// clearance for vias // clearance for vias
if( ( aLayerMask & ( SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT ) ) ) if( ( aLayerMask & ( SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT ) ) )
via_margin = GetBoard()->GetBoardDesignSettings()->m_SolderMaskMargin; via_margin = GetBoard()->GetDesignSettings().m_SolderMaskMargin;
pos = Via->m_Start; pos = Via->m_Start;
size.x = size.y = Via->m_Width + 2 * via_margin; size.x = size.y = Via->m_Width + 2 * via_margin;

View File

@ -62,10 +62,11 @@ bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer
SheetSize.x = currentsheet->m_Size.x * U_PCB; SheetSize.x = currentsheet->m_Size.x * U_PCB;
SheetSize.y = currentsheet->m_Size.y * U_PCB; SheetSize.y = currentsheet->m_Size.y * U_PCB;
/* Calculate the center of the PCB. */ // Calculate the center of the PCB
m_Pcb->ComputeBoundingBox(); EDA_RECT bbbox = GetBoardBoundingBox();
BoardSize = m_Pcb->m_BoundaryBox.GetSize();
BoardCenter = m_Pcb->m_BoundaryBox.Centre(); BoardSize = bbbox.GetSize();
BoardCenter = bbbox.Centre();
if( g_PcbPlotOptions.m_AutoScale ) // Optimum scale if( g_PcbPlotOptions.m_AutoScale ) // Optimum scale
{ {

View File

@ -68,9 +68,10 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int
paperscale = 1; paperscale = 1;
} }
m_Pcb->ComputeBoundingBox(); EDA_RECT bbbox = GetBoardBoundingBox();
BoardSize = m_Pcb->m_BoundaryBox.GetSize();
BoardCenter = m_Pcb->m_BoundaryBox.Centre(); BoardSize = bbbox.GetSize();
BoardCenter = bbbox.Centre();
if( g_PcbPlotOptions.m_AutoScale ) // Optimum scale if( g_PcbPlotOptions.m_AutoScale ) // Optimum scale
{ {
@ -119,10 +120,10 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int
int margin = 500; // Add a 0.5 inch margin around the board int margin = 500; // Add a 0.5 inch margin around the board
plotter->set_negative( true ); plotter->set_negative( true );
plotter->set_color( WHITE ); // Which will be plotted as black plotter->set_color( WHITE ); // Which will be plotted as black
plotter->rect( wxPoint( m_Pcb->m_BoundaryBox.GetX() - margin, plotter->rect( wxPoint( bbbox.GetX() - margin,
m_Pcb->m_BoundaryBox.GetY() - margin ), bbbox.GetY() - margin ),
wxPoint( m_Pcb->m_BoundaryBox.GetRight() + margin, wxPoint( bbbox.GetRight() + margin,
m_Pcb->m_BoundaryBox.GetBottom() + margin ), bbbox.GetBottom() + margin ),
FILLED_SHAPE ); FILLED_SHAPE );
plotter->set_color( BLACK ); plotter->set_color( BLACK );
} }

View File

@ -167,8 +167,8 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in internal units SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in internal units
PCB_BASE_FRAME* pcbframe = (PCB_BASE_FRAME*) m_Parent; PCB_BASE_FRAME* pcbframe = (PCB_BASE_FRAME*) m_Parent;
pcbframe->GetBoard()->ComputeBoundingBox();
EDA_RECT brd_BBox = pcbframe->GetBoard()->m_BoundaryBox; EDA_RECT brd_BBox = pcbframe->GetBoard()->ComputeBoundingBox();
// In module editor, the module is located at 0,0 but for printing // In module editor, the module is located at 0,0 but for printing
// it is moved to SheetSize.x/2, SheetSize.y/2. // it is moved to SheetSize.x/2, SheetSize.y/2.

View File

@ -312,10 +312,10 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
} }
pt_cur_ch = pt_cur_ch; pt_cur_ch = pt_cur_ch;
segm_oX = GetBoard()->m_BoundaryBox.m_Pos.x + (Board.m_GridRouting * col_source); segm_oX = GetBoard()->GetBoundingBox().m_Pos.x + (Board.m_GridRouting * col_source);
segm_oY = GetBoard()->m_BoundaryBox.m_Pos.y + (Board.m_GridRouting * row_source); segm_oY = GetBoard()->GetBoundingBox().m_Pos.y + (Board.m_GridRouting * row_source);
segm_fX = GetBoard()->m_BoundaryBox.m_Pos.x + (Board.m_GridRouting * col_target); segm_fX = GetBoard()->GetBoundingBox().m_Pos.x + (Board.m_GridRouting * col_target);
segm_fY = GetBoard()->m_BoundaryBox.m_Pos.y + (Board.m_GridRouting * row_target); segm_fY = GetBoard()->GetBoundingBox().m_Pos.y + (Board.m_GridRouting * row_target);
/* Draw segment. */ /* Draw segment. */
GRLine( &DrawPanel->m_ClipBox, GRLine( &DrawPanel->m_ClipBox,
@ -461,9 +461,9 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
*/ */
{ {
int cX = ( Board.m_GridRouting * col_source ) int cX = ( Board.m_GridRouting * col_source )
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x; + pcbframe->GetBoard()->GetBoundingBox().m_Pos.x;
int cY = ( Board.m_GridRouting * row_source ) int cY = ( Board.m_GridRouting * row_source )
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y; + pcbframe->GetBoard()->GetBoundingBox().m_Pos.y;
int dx = pt_cur_ch->m_PadStart->m_Size.x / 2; int dx = pt_cur_ch->m_PadStart->m_Size.x / 2;
int dy = pt_cur_ch->m_PadStart->m_Size.y / 2; int dy = pt_cur_ch->m_PadStart->m_Size.y / 2;
int px = pt_cur_ch->m_PadStart->GetPosition().x; int px = pt_cur_ch->m_PadStart->GetPosition().x;
@ -476,9 +476,9 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
goto end_of_route; goto end_of_route;
cX = ( Board.m_GridRouting * col_target ) cX = ( Board.m_GridRouting * col_target )
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x; + pcbframe->GetBoard()->GetBoundingBox().m_Pos.x;
cY = ( Board.m_GridRouting * row_target ) cY = ( Board.m_GridRouting * row_target )
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y; + pcbframe->GetBoard()->GetBoundingBox().m_Pos.y;
dx = pt_cur_ch->m_PadEnd->m_Size.x / 2; dx = pt_cur_ch->m_PadEnd->m_Size.x / 2;
dy = pt_cur_ch->m_PadEnd->m_Size.y / 2; dy = pt_cur_ch->m_PadEnd->m_Size.y / 2;
px = pt_cur_ch->m_PadEnd->GetPosition().x; px = pt_cur_ch->m_PadEnd->GetPosition().x;
@ -1163,15 +1163,15 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
g_CurrentTrackSegment->SetLayer( 0x0F ); g_CurrentTrackSegment->SetLayer( 0x0F );
g_CurrentTrackSegment->m_Start.x = g_CurrentTrackSegment->m_Start.x =
g_CurrentTrackSegment->m_End.x = pcb->m_BoundaryBox.m_Pos.x + g_CurrentTrackSegment->m_End.x = pcb->GetBoundingBox().m_Pos.x +
( Board.m_GridRouting * row ); ( Board.m_GridRouting * row );
g_CurrentTrackSegment->m_Start.y = g_CurrentTrackSegment->m_Start.y =
g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y + g_CurrentTrackSegment->m_End.y = pcb->GetBoundingBox().m_Pos.y +
( Board.m_GridRouting * col ); ( Board.m_GridRouting * col );
g_CurrentTrackSegment->m_Width = pcb->GetCurrentViaSize(); g_CurrentTrackSegment->m_Width = pcb->GetCurrentViaSize();
g_CurrentTrackSegment->m_Shape = pcb->GetBoardDesignSettings()->m_CurrentViaType; g_CurrentTrackSegment->m_Shape = pcb->GetDesignSettings().m_CurrentViaType;
g_CurrentTrackSegment->SetNet( current_net_code ); g_CurrentTrackSegment->SetNet( current_net_code );
} }
@ -1187,9 +1187,9 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
g_CurrentTrackSegment->SetLayer( Route_Layer_TOP ); g_CurrentTrackSegment->SetLayer( Route_Layer_TOP );
g_CurrentTrackSegment->SetState( TRACK_AR, ON ); g_CurrentTrackSegment->SetState( TRACK_AR, ON );
g_CurrentTrackSegment->m_End.x = pcb->m_BoundaryBox.m_Pos.x + g_CurrentTrackSegment->m_End.x = pcb->GetBoundingBox().m_Pos.x +
( Board.m_GridRouting * row ); ( Board.m_GridRouting * row );
g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y + g_CurrentTrackSegment->m_End.y = pcb->GetBoundingBox().m_Pos.y +
( Board.m_GridRouting * col ); ( Board.m_GridRouting * col );
g_CurrentTrackSegment->SetNet( current_net_code ); g_CurrentTrackSegment->SetNet( current_net_code );

View File

@ -890,7 +890,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
} }
else else
{ {
aBoard->ComputeBoundingBox(); EDA_RECT bbbox = aBoard->ComputeBoundingBox();
RECTANGLE* rect = new RECTANGLE( boundary ); RECTANGLE* rect = new RECTANGLE( boundary );
boundary->rectangle = rect; boundary->rectangle = rect;
@ -898,11 +898,9 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
rect->layer_id = "pcb"; rect->layer_id = "pcb";
// opposite corners // opposite corners
wxPoint bottomRight; wxPoint bottomRight( bbbox.GetRight(), bbbox.GetBottom() );
bottomRight.x = aBoard->m_BoundaryBox.GetRight();
bottomRight.y = aBoard->m_BoundaryBox.GetBottom();
rect->SetCorners( mapPt( aBoard->m_BoundaryBox.GetOrigin() ), rect->SetCorners( mapPt( bbbox.GetOrigin() ),
mapPt( bottomRight ) ); mapPt( bottomRight ) );
} }
} }

View File

@ -102,7 +102,7 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator()
change = true; change = true;
} }
int via_type = GetBoard()->GetBoardDesignSettings()->m_CurrentViaType; int via_type = GetBoard()->GetDesignSettings().m_CurrentViaType;
via_color = GetBoard()->GetVisibleElementColor(VIAS_VISIBLE+via_type); via_color = GetBoard()->GetVisibleElementColor(VIAS_VISIBLE+via_type);
if( previous_via_color != via_color ) if( previous_via_color != via_color )

View File

@ -35,7 +35,7 @@ void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
{ {
bool check = ( ( ( ID_POPUP_PCB_SELECT_WIDTH1 + bool check = ( ( ( ID_POPUP_PCB_SELECT_WIDTH1 +
(int) GetBoard()->m_TrackWidthSelector ) == aEvent.GetId() ) && (int) GetBoard()->m_TrackWidthSelector ) == aEvent.GetId() ) &&
!GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth ); !GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth );
aEvent.Check( check ); aEvent.Check( check );
} }
} }
@ -43,7 +43,7 @@ void PCB_EDIT_FRAME::OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent )
void PCB_EDIT_FRAME::OnUpdateSelectAutoTrackWidth( wxUpdateUIEvent& aEvent ) void PCB_EDIT_FRAME::OnUpdateSelectAutoTrackWidth( wxUpdateUIEvent& aEvent )
{ {
aEvent.Check( GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth ); aEvent.Check( GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth );
} }
@ -60,7 +60,7 @@ void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
{ {
bool check = ( ( ( ID_POPUP_PCB_SELECT_VIASIZE1 + bool check = ( ( ( ID_POPUP_PCB_SELECT_VIASIZE1 +
(int) GetBoard()->m_ViaSizeSelector ) == aEvent.GetId() ) && (int) GetBoard()->m_ViaSizeSelector ) == aEvent.GetId() ) &&
!GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth ); !GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth );
aEvent.Check( check ); aEvent.Check( check );
} }