7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 21:19:20 +00:00
* 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(), and BOARD::m_PcbFrame
  * 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 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 way of
    destroying the derived class 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:15:33 -06:00
parent 2ae221d97f
commit b26580d5df
75 changed files with 1105 additions and 995 deletions

View File

@ -156,12 +156,15 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
m_gllist = glGenLists( 1 );
pcb->ComputeBoundingBox();
g_Parm_3D_Visu.m_BoardSettings = pcb->GetBoardDesignSettings();
g_Parm_3D_Visu.m_BoardSize = pcb->m_BoundaryBox.GetSize();
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_Layers = pcb->GetCopperLayerCount();
EDA_RECT bbbox = pcbframe->GetBoardBoundingBox();
g_Parm_3D_Visu.m_BoardSettings = &pcb->GetDesignSettings();
g_Parm_3D_Visu.m_BoardSize = bbbox.GetSize();
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
// 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:
// 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;
/* calculate z position for each layer */

View File

@ -150,8 +150,10 @@ public:
wxPoint m_BoardPos;
wxSize m_BoardSize;
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:
* when scaled between -1.0 and +1.0 */

View File

@ -4,10 +4,39 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
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(), and BOARD::m_PcbFrame
* 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 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 way of
destroying the derived class 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-Nov-27 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
PCBNew
++PCBNew
* Add PLUGIN and IO_MGR classes.
* Remove one argument from BOARD constructor,
* add BOARD::SetWindowFrame()

View File

@ -53,4 +53,7 @@ E6) Start initial work for changing component library file format to use Dick's
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. */
const wxString ModuleFileWildcard( _( "KiCad footprint library files (*.mod)|*.mod" ) );
int g_CurrentVersionPCB = 1;
int g_RotationAngle;
int g_AnchorColor = BLUE;

View File

@ -169,7 +169,7 @@ void EDA_APP::WriteProjectConfig( const wxString& fileName,
void EDA_APP::WriteProjectConfig( const wxString& fileName,
const wxString& GroupName,
PARAM_CFG_ARRAY& params )
const PARAM_CFG_ARRAY& params )
{
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->SetPath( wxCONFIG_PATH_SEPARATOR );
BOOST_FOREACH( PARAM_CFG_BASE& param, params )
BOOST_FOREACH( const PARAM_CFG_BASE& param, params )
{
if( 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 )
return;
BOOST_FOREACH( PARAM_CFG_BASE& param, List )
BOOST_FOREACH( const PARAM_CFG_BASE& param, List )
{
if( param.m_Setup == false )
continue;
@ -326,7 +326,7 @@ bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName,
PARAM_CFG_ARRAY& params,
const PARAM_CFG_ARRAY& params,
bool Load_Only_if_New )
{
wxString timestamp;
@ -356,7 +356,7 @@ bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
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 )
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 )
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
* @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 )
return;
@ -461,7 +461,7 @@ void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig )
* save the value of parameter this stored in aConfig
* @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 )
return;
@ -497,7 +497,7 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
* read the value of parameter this stored in aConfig
* @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 )
return;
@ -513,7 +513,7 @@ void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig )
* save the the value of parameter this stored in aConfig
* @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 )
return;
@ -555,7 +555,7 @@ PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup,
* read the value of parameter this stored in aConfig
* @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 )
return;
@ -584,7 +584,7 @@ void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig )
* save the the value of parameter this stored in aConfig
* @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 )
return;
@ -619,7 +619,7 @@ PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup,
* read the value of parameter this stored in aConfig
* @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 )
return;
@ -634,7 +634,7 @@ void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig )
* save the the value of parameter this stored in aConfig
* @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 )
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
* @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 )
return;
@ -680,7 +680,7 @@ void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig )
* save the value of parameter this stored in aConfig
* @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 )
return;
@ -703,7 +703,7 @@ PARAM_CFG_FILENAME::PARAM_CFG_FILENAME( const wxChar* ident,
* read the value of parameter this stored in aConfig
* @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 )
return;
@ -722,7 +722,7 @@ void PARAM_CFG_FILENAME::ReadParam( wxConfigBase* aConfig )
* save the value of parameter this stored in aConfig
* @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 )
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
* @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 )
return;
@ -780,7 +780,7 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig )
* save the value of parameter this in aConfig (list of parameters)
* @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 )
return;

View File

@ -61,7 +61,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* father,
icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) );
SetIcon( icon );
SetBoard( new BOARD( this ) );
SetBoard( new BOARD() );
SetScreen( new PCB_SCREEN() );
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() )
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 );
wxBrush bgBrush( bgColor, wxSOLID );
GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent();
int bitmapWidth, bitmapHeight;
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++ )
{
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
continue;
@ -269,7 +271,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
int dcode_highlight = 0;
if( layer == ( (GERBVIEW_FRAME*) m_PcbFrame )->getActiveLayer() )
if( layer == gerbFrame->getActiveLayer() )
dcode_highlight = gerber->m_Selected_Tool;
int layerdrawMode = GR_COPY;

View File

@ -19,6 +19,7 @@
#include "class_board_design_settings.h"
#include "class_gerber_draw_item.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
@ -51,7 +52,7 @@ GBR_TO_PCB_EXPORTER::GBR_TO_PCB_EXPORTER( GERBVIEW_FRAME * aFrame, FILE * aFile
{
m_gerbview_frame = aFrame;
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;
/* Print the copper layer count */
// Print the copper layer count
nbLayers = m_pcb->GetCopperLayerCount();
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, "LayerCount %d\n", nbLayers );
/* Compute and print the board bounding box */
m_pcb->ComputeBoundingBox();
// Compute and print the board bounding box
EDA_RECT bbbox = m_pcb->ComputeBoundingBox();
fprintf( m_file, "Di %d %d %d %d\n",
m_pcb->m_BoundaryBox.GetX(), m_pcb->m_BoundaryBox.GetY(),
m_pcb->m_BoundaryBox.GetRight(),
m_pcb->m_BoundaryBox.GetBottom() );
bbbox.GetX(), bbbox.GetY(),
bbbox.GetRight(),
bbbox.GetBottom() );
fprintf( m_file, "$EndGENERAL\n\n" );
return true;
@ -237,7 +239,7 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( int* LayerLookUpTable )
SetLocaleTo_C_standard();
// 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() ) );
WriteGeneralDescrPcb( );
WriteSetup( );

View File

@ -61,7 +61,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
SetScreen( new PCB_SCREEN() );
GetScreen()->m_CurrentSheetDesc = &g_Sheet_GERBER;
SetBoard( new BOARD( this ) );
SetBoard( new BOARD() );
GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first.
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()->m_BoundaryBox.SetSize( 0, 0 );
GetBoard()->SetBoundingBox( EDA_RECT() );
GetBoard()->m_Status_Pcb = 0;
GetBoard()->m_NbNodes = 0;
GetBoard()->m_NbNoconnect = 0;

View File

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

View File

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

View File

@ -11,34 +11,33 @@
class BOARD_DESIGN_SETTINGS
{
protected:
int m_CopperLayerCount; // Number of copper layers for this design
public:
bool m_MicroViasAllowed; // true to allow micro vias
int m_CurrentViaType; // via type (VIA_BLIND_BURIED, VIA_TROUGHT VIA_MICROVIA)
int m_CopperLayerCount; ///< Number of copper layers for this design
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
// 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;
int m_DrawSegmentWidth; // current graphic line width (not EDGE layer)
int m_EdgeSegmentWidth; // current graphic line width (EDGE layer only)
int m_PcbTextWidth; // current Pcb (not module) Text width
wxSize m_PcbTextSize; // current Pcb (not module) Text size
int m_TrackMinWidth; // track min value for width ((min copper size value
int m_ViasMinSize; // vias (not micro vias) min diameter
int m_ViasMinDrill; // vias (not micro vias) min drill diameter
int m_MicroViasMinSize; // micro vias (not vias) min diameter
int m_MicroViasMinDrill; // micro vias (not vias) min drill diameter
int m_DrawSegmentWidth; ///< current graphic line width (not EDGE layer)
int m_EdgeSegmentWidth; ///< current graphic line width (EDGE layer only)
int m_PcbTextWidth; ///< current Pcb (not module) Text width
wxSize m_PcbTextSize; ///< current Pcb (not module) Text size
int m_TrackMinWidth; ///< track min value for width ((min copper size value
int m_ViasMinSize; ///< vias (not micro vias) min diameter
int m_ViasMinDrill; ///< vias (not micro vias) min drill diameter
int m_MicroViasMinSize; ///< micro vias (not vias) min diameter
int m_MicroViasMinDrill; ///< micro vias (not vias) min drill diameter
// Global mask margins:
int m_SolderMaskMargin; // Solder mask margin
int m_SolderPasteMargin; // Solder paste margin absolute value
double m_SolderPasteMarginRatio; // Solder pask margin ratio value of pad size
// The final margin is the sum of these 2 values
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
int m_SolderMaskMargin; ///< Solder mask margin
int m_SolderPasteMargin; ///< Solder paste margin absolute value
double m_SolderPasteMarginRatio; ///< Solder pask margin ratio value of pad size
///< The final margin is the sum of these 2 values
int m_BoardThickness; ///< Board Thickness for 3D viewer
public:
BOARD_DESIGN_SETTINGS();
@ -79,7 +78,6 @@ public:
return (bool) ( m_VisibleLayers & m_EnabledLayers & (1 << aLayerIndex) );
}
/**
* Function SetLayerVisibility
* changes the visibility of a given layer
@ -98,7 +96,6 @@ public:
return m_VisibleElements;
}
/**
* Function SetVisibleElements
* changes the bit-mask of visible element categories
@ -159,7 +156,6 @@ public:
return bool( m_EnabledLayers & (1 << aLayerIndex) );
}
/**
* Function GetCopperLayerCount
* @return int - the number of neabled copper layers
@ -169,7 +165,6 @@ public:
return m_CopperLayerCount;
}
/**
* Function SetCopperLayerCount
* 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 SetBack( EDA_ITEM* aBack ) { Pback = aBack; }
protected:
int m_Layer;
@ -60,7 +59,6 @@ public:
{
}
BOARD_ITEM( const BOARD_ITEM& src ) :
EDA_ITEM( src.m_Parent, src.Type() )
, m_Layer( src.m_Layer )
@ -68,7 +66,6 @@ public:
m_Flags = src.m_Flags;
}
/**
* 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; }
/**
* Function Draw
* BOARD_ITEMs have their own color information.
@ -115,7 +111,6 @@ public:
virtual void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
int aDrawMode, const wxPoint& offset = ZeroOffset ) = 0;
/**
* Function IsOnLayer
* 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() );
}
/**
* Function GetBoard
* returns the BOARD in which this BOARD_ITEM resides, or NULL if none.

View File

@ -3,8 +3,8 @@
* @file param_config.h
*/
#ifndef __PARAM_CONFIG_H__
#define __PARAM_CONFIG_H__ 1
#ifndef PARAM_CONFIG_H_
#define PARAM_CONFIG_H_
#include "wx/confbase.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)
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
* reads the value of the parameter stored in aConfig
* @param aConfig = the wxConfigBase that holds the parameter
*/
virtual void ReadParam( wxConfigBase* aConfig ) {};
virtual void ReadParam( wxConfigBase* aConfig ) const {};
/**
* Function SaveParam
* saves the value of the parameter stored in aConfig
* @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_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,
const wxChar* group = NULL );
PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
int default_val = 0, int min = INT_MINVAL, int max = INT_MAXVAL,
const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig );
virtual void SaveParam( wxConfigBase* aConfig );
virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ) const;
};
@ -96,13 +99,14 @@ public:
int* m_Pt_param; ///< Pointer to the parameter value
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 );
PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, int* ptparam,
int default_val, const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig );
virtual void SaveParam( wxConfigBase* aConfig );
virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ) const;
};
@ -117,15 +121,16 @@ public:
double m_Default; ///< The default value of the parameter
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,
const wxChar* group = NULL );
PARAM_CFG_DOUBLE( bool Insetup, const wxChar* ident, double* ptparam,
double default_val = 0.0, double min = 0.0, double max = 10000.0,
const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig );
virtual void SaveParam( wxConfigBase* aConfig );
virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ) const;
};
@ -139,13 +144,14 @@ public:
bool* m_Pt_param; ///< Pointer to the parameter value
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 );
PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam,
int default_val = false, const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig );
virtual void SaveParam( wxConfigBase* aConfig );
virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ) const;
};
@ -167,12 +173,11 @@ public:
const wxString& default_val = wxEmptyString,
const wxChar* group = NULL );
virtual ~PARAM_CFG_WXSTRING() {}
virtual void ReadParam( wxConfigBase* aConfig );
virtual void SaveParam( wxConfigBase* aConfig );
virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ) const;
};
/**
* Configuration parameter - PARAM_CFG_FILENAME Class
* Same as PARAM_CFG_WXSTRING, but stores "\" as "/".
@ -184,9 +189,10 @@ class PARAM_CFG_FILENAME : public PARAM_CFG_BASE
public:
wxString* m_Pt_param; ///< Pointer to the parameter value
public: PARAM_CFG_FILENAME( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig );
virtual void SaveParam( wxConfigBase* aConfig );
public:
PARAM_CFG_FILENAME( const wxChar* ident, wxString* ptparam, const wxChar* group = NULL );
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:
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,
const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig );
virtual void SaveParam( wxConfigBase* aConfig );
virtual void ReadParam( wxConfigBase* aConfig ) const;
virtual void SaveParam( wxConfigBase* aConfig ) const;
};
/** A list of parameters type */
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 GENERAL_COLLECTOR;
class GENERAL_COLLECTORS_GUIDE;
class BOARD_DESIGN_SETTINGS;
/**
* class PCB_BASE_FRAME
@ -80,13 +80,17 @@ public:
FOOTPRINT_EDIT_FRAME* m_ModuleEditFrame;
protected:
BOARD* m_Pcb;
GENERAL_COLLECTOR* m_Collector;
// EDA_RECT m_BoundaryBox; // Board size and position
BOARD* m_Pcb;
GENERAL_COLLECTOR* m_Collector;
void updateGridSelectBox();
void updateZoomSelectBox();
virtual void unitsChangeRefresh();
public:
PCB_BASE_FRAME( wxWindow* father, int idtype, const wxString& title,
const wxPoint& pos, const wxSize& size,
@ -94,6 +98,14 @@ public:
~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
* sets the m_Pcb member in such as way as to ensure deleting any previous
@ -108,6 +120,8 @@ public:
return m_Pcb;
}
BOARD_DESIGN_SETTINGS* GetDesignSettings();
// General
virtual void OnCloseWindow( wxCloseEvent& Event ) = 0;
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) { }

View File

@ -88,7 +88,6 @@ protected:
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.
wxString m_lastNetListRead; ///< Last net list read with relative path.
@ -276,16 +275,17 @@ public:
/**
* Function GetProjectFileParameters
* returns the project file parameter list for Pcbnew.
* returns a project file parameter list for Pcbnew.
* <p>
* Populate the project file parameter array specific to Pcbnew if it hasn't
* already been populated and return a reference to the array to the caller.
* Populate a project file parameter array specific to Pcbnew.
* 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
* at compile time requiring global variable definitions by design.
* </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();
@ -302,13 +302,13 @@ public:
* Function GetConfigurationSettings
* 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
* was confusing and caused some settings to get saved and loaded
* incorrectly. Currently, only the settings that are needed at start
* up by the main window are defined here. There are other locally used
* settings are scattered throughout the Pcbnew source code. If you need
* to define a configuration setting that need to be loaded at run time,
* settings that are scattered throughout the Pcbnew source code. If you need
* to define a configuration setting that needs to be loaded at run time,
* this is the place to define it.
*
* @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;
int Ymax_size, Xsize_allowed;
int pas_grille = (int) GetScreen()->GetGridSize().x;
bool edgesExists;
double surface;
if( GetBoard()->m_Modules == NULL )
@ -195,9 +194,12 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( !IsOK( this, _( "Move modules?" ) ) )
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,
_( "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
* 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();
pos.y = GetBoard()->m_BoundaryBox.GetBottom() + 2000;
pos.y = bbbox.GetBottom() + 2000;
GetScreen()->SetCrossHairPosition( pos );
}
}
@ -235,9 +237,9 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
{
Module = moduleList[ii];
if( PlaceModulesHorsPcb && edgesExists )
if( PlaceModulesHorsPcb && edgesExist )
{
if( GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) )
if( bbbox.Contains( Module->m_Pos ) )
continue;
}
@ -256,9 +258,9 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( Module->IsLocked() )
continue;
if( PlaceModulesHorsPcb && edgesExists )
if( PlaceModulesHorsPcb && edgesExist )
{
if( GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) )
if( bbbox.Contains( Module->m_Pos ) )
continue;
}

View File

@ -75,6 +75,9 @@ static const float OrientPenality[11] =
#define OUT_OF_BOARD -2
#define OCCUPED_By_MODULE -1
static EDA_RECT bbbox; // boards bounding box
static wxPoint CurrPosition; // Current position of the current module placement
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 )
break;
if( !GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) )
if( !bbbox.Contains( Module->m_Pos ) )
Module->m_ModuleStatus |= MODULE_to_PLACE;
break;
@ -367,11 +370,11 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC )
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++ )
{
ox = GetBoard()->m_BoundaryBox.m_Pos.x + (jj * Board.m_GridRouting);
ox = bbbox.m_Pos.x + (jj * Board.m_GridRouting);
color = BLACK;
top_state = GetCell( ii, jj, TOP );
@ -408,28 +411,28 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
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!" ) );
return 0;
}
/* The boundary box must have its start point on placing grid: */
GetBoard()->m_BoundaryBox.m_Pos.x -= GetBoard()->m_BoundaryBox.m_Pos.x %
Board.m_GridRouting;
GetBoard()->m_BoundaryBox.m_Pos.y -= GetBoard()->m_BoundaryBox.m_Pos.y %
Board.m_GridRouting;
bbbox.m_Pos.x -= bbbox.m_Pos.x % Board.m_GridRouting;
bbbox.m_Pos.y -= bbbox.m_Pos.y % Board.m_GridRouting;
/* 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 += Board.m_GridRouting;
end.y -= 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;
Ncols = GetBoard()->m_BoundaryBox.GetWidth() / Board.m_GridRouting;
Nrows = bbbox.GetHeight() / Board.m_GridRouting;
Ncols = bbbox.GetWidth() / Board.m_GridRouting;
/* get a small margin for memory allocation: */
Ncols += 2; Nrows += 2;
NbCells = Ncols * Nrows;
@ -533,29 +536,29 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module )
oy = Module->m_BoundaryBox.m_Pos.y - marge;
fy = Module->m_BoundaryBox.GetBottom() + marge;
if( ox < GetBoard()->m_BoundaryBox.m_Pos.x )
ox = GetBoard()->m_BoundaryBox.m_Pos.x;
if( ox < bbbox.m_Pos.x )
ox = bbbox.m_Pos.x;
if( ox > GetBoard()->m_BoundaryBox.GetRight() )
ox = GetBoard()->m_BoundaryBox.GetRight();
if( ox > bbbox.GetRight() )
ox = bbbox.GetRight();
if( fx < GetBoard()->m_BoundaryBox.m_Pos.x )
fx = GetBoard()->m_BoundaryBox.m_Pos.x;
if( fx < bbbox.m_Pos.x )
fx = bbbox.m_Pos.x;
if( fx > GetBoard()->m_BoundaryBox.GetRight() )
fx = GetBoard()->m_BoundaryBox.GetRight();
if( fx > bbbox.GetRight() )
fx = bbbox.GetRight();
if( oy < GetBoard()->m_BoundaryBox.m_Pos.y )
oy = GetBoard()->m_BoundaryBox.m_Pos.y;
if( oy < bbbox.m_Pos.y )
oy = bbbox.m_Pos.y;
if( oy > GetBoard()->m_BoundaryBox.GetBottom() )
oy = GetBoard()->m_BoundaryBox.GetBottom();
if( oy > bbbox.GetBottom() )
oy = bbbox.GetBottom();
if( fy < GetBoard()->m_BoundaryBox.m_Pos.y )
fy = GetBoard()->m_BoundaryBox.m_Pos.y;
if( fy < bbbox.m_Pos.y )
fy = bbbox.m_Pos.y;
if( fy > GetBoard()->m_BoundaryBox.GetBottom() )
fy = GetBoard()->m_BoundaryBox.GetBottom();
if( fy > bbbox.GetBottom() )
fy = bbbox.GetBottom();
layerMask = 0;
@ -598,8 +601,8 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
aModule->DisplayInfo( this );
LastPosOK.x = GetBoard()->m_BoundaryBox.m_Pos.x;
LastPosOK.y = GetBoard()->m_BoundaryBox.m_Pos.y;
LastPosOK.x = bbbox.m_Pos.x;
LastPosOK.y = bbbox.m_Pos.y;
cx = aModule->m_Pos.x; cy = aModule->m_Pos.y;
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;
fy = aModule->m_BoundaryBox.m_Size.y + oy;
CurrPosition.x = GetBoard()->m_BoundaryBox.m_Pos.x - ox;
CurrPosition.y = GetBoard()->m_BoundaryBox.m_Pos.y - oy;
CurrPosition.x = bbbox.m_Pos.x - ox;
CurrPosition.y = bbbox.m_Pos.y - oy;
/* Module placement on grid. */
CurrPosition.x -= CurrPosition.x % Board.m_GridRouting;
@ -647,7 +650,7 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
mincout = -1.0;
SetStatusText( wxT( "Score ??, pos ??" ) );
for( ; CurrPosition.x < GetBoard()->m_BoundaryBox.GetRight() - fx;
for( ; CurrPosition.x < bbbox.GetRight() - fx;
CurrPosition.x += Board.m_GridRouting )
{
wxYield();
@ -667,14 +670,14 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
DrawModuleOutlines( DrawPanel, aDC, aModule );
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. */
CurrPosition.y -= CurrPosition.y % Board.m_GridRouting;
DrawModuleOutlines( DrawPanel, aDC, aModule );
for( ; CurrPosition.y < GetBoard()->m_BoundaryBox.GetBottom() - fy;
for( ; CurrPosition.y < bbbox.GetBottom() - fy;
CurrPosition.y += Board.m_GridRouting )
{
/* 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;
unsigned int data;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x;
uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
ux0 -= Pcb->GetBoundingBox().m_Pos.x;
uy0 -= Pcb->GetBoundingBox().m_Pos.y;
ux1 -= Pcb->GetBoundingBox().m_Pos.x;
uy1 -= Pcb->GetBoundingBox().m_Pos.y;
row_max = uy1 / 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;
unsigned int keepOut;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x;
uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
ux0 -= Pcb->GetBoundingBox().m_Pos.x;
uy0 -= Pcb->GetBoundingBox().m_Pos.y;
ux1 -= Pcb->GetBoundingBox().m_Pos.x;
uy1 -= Pcb->GetBoundingBox().m_Pos.y;
row_max = uy1 / Board.m_GridRouting;
col_max = ux1 / Board.m_GridRouting;
@ -979,10 +982,10 @@ static void CreateKeepOutRectangle( BOARD* Pcb,
if( trace == 0 )
return;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x;
uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
ux0 -= Pcb->GetBoundingBox().m_Pos.x;
uy0 -= Pcb->GetBoundingBox().m_Pos.y;
ux1 -= Pcb->GetBoundingBox().m_Pos.x;
uy1 -= Pcb->GetBoundingBox().m_Pos.y;
ux0 -= marge; ux1 += 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()
{
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 )
{
int dx, dy;
double ii, jj;
wxSize size;
if( m_Pcb == NULL )
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();
if( size.x )
@ -149,7 +187,7 @@ double PCB_BASE_FRAME::BestZoom( void )
double bestzoom = MAX( ii, jj );
GetScreen()->SetScrollCenterPosition( m_Pcb->m_BoundaryBox.Centre() );
GetScreen()->SetScrollCenterPosition( bbbox.Centre() );
return bestzoom ;
}

View File

@ -48,20 +48,25 @@ bool MATRIX_ROUTING_HEAD::ComputeMatrixSize( BOARD* aPcb )
{
aPcb->ComputeBoundingBox();
/* 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;
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 start point on routing grid:
m_BrdBox = aPcb->GetBoundingBox();
/* 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();
end.x -= end.x % m_GridRouting;
end.x += m_GridRouting;
end.y -= end.y % m_GridRouting;
end.y += m_GridRouting;
aPcb->m_BoundaryBox.SetEnd( end );
m_BrdBox.SetEnd(end);
aPcb->SetBoundingBox( m_BrdBox );
m_Nrows = Nrows = m_BrdBox.m_Size.y / 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 )
{
RATSNEST_ITEM* pt_rats;
D_PAD* pt_pad;
int r1, r2, c1, c2, current_net_code;
RATSNEST_ITEM* pt_ch;
int demi_pas = Board.m_GridRouting / 2;
wxString msg;
RATSNEST_ITEM* pt_rats;
D_PAD* pt_pad;
int r1, r2, c1, c2, current_net_code;
RATSNEST_ITEM* pt_ch;
int demi_pas = Board.m_GridRouting / 2;
wxString msg;
EDA_RECT bbbox = Pcb->GetBoundingBox();
InitWork(); /* clear work list */
Ntotal = 0;
@ -361,48 +368,48 @@ int Build_Work( BOARD* Pcb )
current_net_code = pt_pad->GetNet();
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;
if( r1 < 0 || r1 >= Nrows )
{
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 );
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;
if( c1 < 0 || c1 >= Ncols )
{
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 );
return 0;
}
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;
if( r2 < 0 || r2 >= Nrows )
{
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 );
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;
if( c2 < 0 || c2 >= Ncols )
{
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 );
return 0;
}

View File

@ -10,6 +10,7 @@
#include "common.h"
#include "pcbcommon.h"
#include "wxBasePcbFrame.h"
#include "build_version.h" // BOARD_FILE_VERSION
#include "pcbnew.h"
#include "colors_selection.h"
@ -27,18 +28,14 @@
wxPoint BOARD_ITEM::ZeroOffset( 0, 0 );
// Current design settings (used also to read configs):
BOARD_DESIGN_SETTINGS boardDesignSettings;
BOARD::BOARD( PCB_BASE_FRAME* frame ) :
BOARD::BOARD() :
BOARD_ITEM( (BOARD_ITEM*) NULL, PCB_T ),
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.
SetBoardDesignSettings( &boardDesignSettings );
SetColorsSettings( &g_ColorsSettings );
m_NbNodes = 0; // Number of connected pads.
m_NbNoconnect = 0; // Number of unconnected nets.
@ -69,8 +66,12 @@ BOARD::BOARD( PCB_BASE_FRAME* frame ) :
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() )
m_PcbFrame->GetScreen()->ClearUndoRedoList();
*/
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 )
{
TRACK* segment; // The current segment being analyzed.
@ -466,36 +474,36 @@ LAYER_T LAYER::ParseType( const char* aType )
int BOARD::GetCopperLayerCount() const
{
return GetBoardDesignSettings()->GetCopperLayerCount();
return m_designSettings.GetCopperLayerCount();
}
void BOARD::SetCopperLayerCount( int aCount )
{
GetBoardDesignSettings()->SetCopperLayerCount( aCount );
m_designSettings.SetCopperLayerCount( aCount );
}
int BOARD::GetEnabledLayers() const
{
return GetBoardDesignSettings()->GetEnabledLayers();
return m_designSettings.GetEnabledLayers();
}
int BOARD::GetVisibleLayers() const
{
return GetBoardDesignSettings()->GetVisibleLayers();
return m_designSettings.GetVisibleLayers();
}
void BOARD::SetEnabledLayers( int aLayerMask )
{
GetBoardDesignSettings()->SetEnabledLayers( aLayerMask );
m_designSettings.SetEnabledLayers( aLayerMask );
}
void BOARD::SetVisibleLayers( int aLayerMask )
{
GetBoardDesignSettings()->SetVisibleLayers( aLayerMask );
m_designSettings.SetVisibleLayers( aLayerMask );
}
@ -529,13 +537,13 @@ void BOARD::SetVisibleAlls( )
int BOARD::GetVisibleElements() const
{
return GetBoardDesignSettings()->GetVisibleElements();
return m_designSettings.GetVisibleElements();
}
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 )
{
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
// 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
@ -563,7 +571,7 @@ void BOARD::SetElementVisibility( int aPCB_VISIBLE, bool isEnabled )
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;
EDA_RECT area;
@ -898,26 +906,9 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly )
}
}
if( !hasItems && m_PcbFrame )
{
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_BoundingBox = area; // save for BOARD::GetBoundingBox()
m_BoundaryBox = area;
return hasItems;
return area;
}
@ -1782,7 +1773,7 @@ TRACK* BOARD::GetTrace( TRACK* aTrace, const wxPoint& aPosition, int aLayerMask
if( track->GetState( BUSY | IS_DELETED ) )
continue;
if( GetBoardDesignSettings()->IsLayerVisible( layer ) == false )
if( m_designSettings.IsLayerVisible( layer ) == false )
continue;
if( track->Type() == PCB_VIA_T ) /* VIA encountered. */

View File

@ -152,28 +152,24 @@ private:
typedef std::vector<MARKER_PCB*> MARKERS;
/// MARKER_PCBs for clearance problems, owned by pointer.
MARKERS m_markers;
MARKERS m_markers;
// @todo: switch to boost::ptr_vector, and change ~BOARD()
typedef std::vector<ZONE_CONTAINER*> ZONE_CONTAINERS;
/// edge zone descriptors, owned by pointer.
ZONE_CONTAINERS m_ZoneDescriptorList;
ZONE_CONTAINERS m_ZoneDescriptorList;
LAYER m_Layer[NB_COPPER_LAYERS];
// if true m_hightLight_NetCode is used
HIGH_LIGHT_INFO m_hightLight; // current high light data
HIGH_LIGHT_INFO m_hightLightPrevious; // a previously stored high light data
LAYER m_Layer[NB_COPPER_LAYERS];
// if true m_hightLight_NetCode is used
HIGH_LIGHT_INFO m_hightLight; // current 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:
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.
int m_Status_Pcb;
@ -184,29 +180,29 @@ public:
/// Active ratsnest count (ratsnests not already connected by tracks)
int m_NbNoconnect;
DLIST<BOARD_ITEM> m_Drawings; // linked list of lines & texts
DLIST<MODULE> m_Modules; // linked list of MODULEs
DLIST<TRACK> m_Track; // linked list of TRACKs and SEGVIAs
DLIST<SEGZONE> m_Zone; // linked list of SEGZONEs
DLIST<BOARD_ITEM> m_Drawings; // linked list of lines & texts
DLIST<MODULE> m_Modules; // linked list of MODULEs
DLIST<TRACK> m_Track; // linked list of TRACKs and SEGVIAs
DLIST<SEGZONE> m_Zone; // linked list of SEGZONEs
/// nets info list (name, design constraints ..
NETINFO_LIST* m_NetInfo;
NETINFO_LIST* m_NetInfo;
/// 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).
std::vector<RATSNEST_ITEM> m_LocalRatsnest;
std::vector<RATSNEST_ITEM> m_LocalRatsnest;
/// zone contour currently in progress
ZONE_CONTAINER* m_CurrentZoneContour;
ZONE_CONTAINER* m_CurrentZoneContour;
/// 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.
/// This is also the last used netclass after starting a track.
wxString m_CurrentNetClassName;
wxString m_CurrentNetClassName;
// handling of vias and tracks size:
// the first value is always the value of the current NetClass
@ -228,7 +224,7 @@ public:
unsigned m_TrackWidthSelector;
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
/**
@ -243,9 +239,13 @@ private:
void chainMarkedSegments( wxPoint aPosition, int aLayerMask, TRACK_PTRS* aList );
public:
BOARD( PCB_BASE_FRAME* frame );
BOARD();
~BOARD();
void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
int GetFileFormatVersionAtLoad() const { return m_fileFormatVersionAtLoad; }
/**
* Function GetDefaultLayerName
* 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
/**
* Function Delete
* removes the given single item from this BOARD and deletes its memory.
@ -427,7 +426,7 @@ public:
*/
bool IsLayerEnabled( int aLayer ) const
{
return GetBoardDesignSettings()->IsLayerEnabled( aLayer );
return m_designSettings.IsLayerEnabled( aLayer );
}
/**
@ -439,7 +438,7 @@ public:
*/
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 );
/**
* Function GetBoardDesignSettings
* @return the current BOARD_DESIGN_SETTINGS in use
* Function GetDesignSettings
* @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
* @param aDesignSettings = the new BOARD_DESIGN_SETTINGS to use
* Function SetDesignSettings
* @param aDesignSettings the new BOARD_DESIGN_SETTINGS to use
*/
void SetBoardDesignSettings( BOARD_DESIGN_SETTINGS* aDesignSettings)
{
m_boardDesignSettings = aDesignSettings;
}
void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aDesignSettings );
/**
* Function SetBoardSettings
@ -652,9 +647,20 @@ public:
* Function ComputeBoundingBox
* 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 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

Some files were not shown because too many files have changed in this diff Show More