get rid of some globals, share BOARD_DESIGN_SETTINGS from PCB_EDIT_FRAME with FOOTPRINT_EDIT_FRAME

This commit is contained in:
Dick Hollenbeck 2012-02-02 11:45:37 -06:00
parent cc46daa67f
commit 716d21d88a
21 changed files with 251 additions and 208 deletions

View File

@ -89,7 +89,7 @@ static void CALLBACK tesswxPoint2Vertex( const GLvoid* data );
void EDA_3D_CANVAS::Redraw( bool finish ) void EDA_3D_CANVAS::Redraw( bool finish )
{ {
/* SwapBuffer requires the window to be shown before calling */ // SwapBuffer requires the window to be shown before calling
if( !IsShown() ) if( !IsShown() )
return; return;
@ -112,8 +112,8 @@ void EDA_3D_CANVAS::Redraw( bool finish )
InitGL(); InitGL();
glMatrixMode( GL_MODELVIEW ); /* position viewer */ glMatrixMode( GL_MODELVIEW ); // position viewer
/* transformations */ // transformations
GLfloat mat[4][4]; GLfloat mat[4][4];
// Translate motion first, so rotations don't mess up the orientation... // Translate motion first, so rotations don't mess up the orientation...
@ -180,7 +180,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
g_Parm_3D_Visu.m_Epoxy_Width = pcb->GetDesignSettings().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
for( ii = 0; ii < 32; ii++ ) for( ii = 0; ii < 32; ii++ )
{ {
if( ii < g_Parm_3D_Visu.m_Layers ) if( ii < g_Parm_3D_Visu.m_Layers )
@ -205,7 +205,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
/* draw axis */ // draw axis
if( g_Parm_3D_Visu.m_Draw3DAxis ) if( g_Parm_3D_Visu.m_Draw3DAxis )
{ {
glEnable( GL_COLOR_MATERIAL ); glEnable( GL_COLOR_MATERIAL );
@ -222,7 +222,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
glEnd(); glEnd();
} }
/* Draw epoxy limits (do not use, works and test in progress) */ // Draw epoxy limits (do not use, works and test in progress)
#if 0 #if 0
glEnable( GL_FOG ); glEnable( GL_FOG );
GLfloat param; GLfloat param;
@ -255,14 +255,14 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
glEnd(); glEnd();
#endif #endif
/* move the board in order to draw it with its center at 0,0 3D coordinates */ // move the board in order to draw it with its center at 0,0 3D coordinates
glTranslatef( -g_Parm_3D_Visu.m_BoardPos.x * g_Parm_3D_Visu.m_BoardScale, glTranslatef( -g_Parm_3D_Visu.m_BoardPos.x * g_Parm_3D_Visu.m_BoardScale,
-g_Parm_3D_Visu.m_BoardPos.y * g_Parm_3D_Visu.m_BoardScale, -g_Parm_3D_Visu.m_BoardPos.y * g_Parm_3D_Visu.m_BoardScale,
0.0F ); 0.0F );
glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
/* draw tracks and vias : */ // draw tracks and vias :
for( track = pcb->m_Track; track != NULL; track = track->Next() ) for( track = pcb->m_Track; track != NULL; track = track->Next() )
{ {
if( track->Type() == PCB_VIA_T ) if( track->Type() == PCB_VIA_T )
@ -370,7 +370,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
} }
} }
/* draw graphic items */ // draw graphic items
EDA_ITEM* PtStruct; EDA_ITEM* PtStruct;
for( PtStruct = pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() ) for( PtStruct = pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
@ -390,7 +390,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
} }
} }
/* draw footprints */ // draw footprints
MODULE* Module = pcb->m_Modules; MODULE* Module = pcb->m_Modules;
for( ; Module != NULL; Module = Module->Next() ) for( ; Module != NULL; Module = Module->Next() )
@ -400,7 +400,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
glEndList(); glEndList();
/* Test for errors */ // Test for errors
CheckGLError(); CheckGLError();
return m_gllist; return m_gllist;
@ -694,7 +694,7 @@ void MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
{ {
D_PAD* pad = m_Pads; D_PAD* pad = m_Pads;
/* Draw pads */ // Draw pads
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
@ -703,7 +703,7 @@ void MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
pad->Draw3D( glcanvas ); pad->Draw3D( glcanvas );
} }
/* Draw module shape: 3D shape if exists (or module outlines if not exists) */ // Draw module shape: 3D shape if exists (or module outlines if not exists)
S3D_MASTER* Struct3D = m_3D_Drawings; S3D_MASTER* Struct3D = m_3D_Drawings;
bool As3dShape = false; bool As3dShape = false;
@ -890,7 +890,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
} }
/* Draw 3D pads. */ // Draw 3D pads.
void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
{ {
int ii, ll, layer, nlmax; int ii, ll, layer, nlmax;
@ -912,7 +912,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
holeY = (double) m_Drill.y * scale / 2; holeY = (double) m_Drill.y * scale / 2;
hole = fmin( holeX, holeY ); hole = fmin( holeX, holeY );
/* Calculate the center of the pad. */ // Calculate the center of the pad.
shape_pos = ReturnShapePos(); shape_pos = ReturnShapePos();
ux0 = shape_pos.x; ux0 = shape_pos.x;
uy0 = shape_pos.y; uy0 = shape_pos.y;
@ -926,7 +926,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
drillx = m_Pos.x * scale; drillx = m_Pos.x * scale;
drilly = m_Pos.y * scale; drilly = m_Pos.y * scale;
/* Draw the pad hole (TODO: draw OBLONG hole) */ // Draw the pad hole (TODO: draw OBLONG hole)
if( holeX && holeY ) if( holeX && holeY )
{ {
SetGLColor( DARKGRAY ); SetGLColor( DARKGRAY );
@ -981,13 +981,13 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
break; break;
case PAD_OVAL: case PAD_OVAL:
if( dx > dy ) /* Horizontal ellipse */ if( dx > dy ) // Horizontal ellipse
{ {
delta_cx = dx - dy; delta_cx = dx - dy;
delta_cy = 0; delta_cy = 0;
w = m_Size.y * scale; w = m_Size.y * scale;
} }
else /* Vertical ellipse */ else // Vertical ellipse
{ {
delta_cx = 0; delta_cx = 0;
delta_cy = dy - dx; delta_cy = dy - dx;
@ -1195,7 +1195,7 @@ static void Draw3D_FilledCylinder( double posx, double posy, double rayon,
} }
/* Draw a polygon similar to a segment has rounded tips */ // Draw a polygon similar to a segment has rounded tips
static void Draw3D_FilledSegment( double startx, double starty, double endx, static void Draw3D_FilledSegment( double startx, double starty, double endx,
double endy, double width, double zpos ) double endy, double width, double zpos )
{ {

View File

@ -111,8 +111,6 @@ class BOARD_DESIGN_SETTINGS g_DesignSettings;
*/ */
DLIST<TRACK> g_CurrentTrackList; DLIST<TRACK> g_CurrentTrackList;
BOARD* g_ModuleEditor_Pcb = NULL;
bool g_Zone_45_Only = false; bool g_Zone_45_Only = false;
// Default setting used when creating a new zone // Default setting used when creating a new zone

View File

@ -2,8 +2,8 @@
* @file pcbcommon.h * @file pcbcommon.h
*/ */
#ifndef __PCBCOMMON_H__ #ifndef PCBCOMMON_H_
#define __PCBCOMMON_H__ #define PCBCOMMON_H_
#include <dlist.h> #include <dlist.h>
@ -13,7 +13,7 @@
//#include <wx/arrstr.h> // wxArrayString class. //#include <wx/arrstr.h> // wxArrayString class.
#define MIN_DRAW_WIDTH 1 /* Minimum trace drawing width. */ #define MIN_DRAW_WIDTH 1 ///< Minimum trace drawing width.
//class PCB_SCREEN; //class PCB_SCREEN;
@ -30,7 +30,7 @@ class DISPLAY_OPTIONS;
*/ */
int GetLayerMask( int aLayerNumber ); int GetLayerMask( int aLayerNumber );
/* Look up Table for conversion copper layer count -> general copper layer mask: */ /// Look up Table for conversion copper layer count -> general copper layer mask:
extern int g_TabAllCopperLayerMask[NB_COPPER_LAYERS]; extern int g_TabAllCopperLayerMask[NB_COPPER_LAYERS];
extern DISPLAY_OPTIONS DisplayOpt; extern DISPLAY_OPTIONS DisplayOpt;
@ -52,10 +52,8 @@ extern DLIST<TRACK> g_CurrentTrackList;
#define g_FirstTrackSegment g_CurrentTrackList.GetFirst() ///< first segment created #define g_FirstTrackSegment g_CurrentTrackList.GetFirst() ///< first segment created
extern BOARD* g_ModuleEditor_Pcb; /// Pad editing
/* Pad editing */
extern D_PAD g_Pad_Master; extern D_PAD g_Pad_Master;
#endif /* __PCBCOMMON_H__ */ #endif // PCBCOMMON_H_

View File

@ -122,6 +122,14 @@ public:
const TITLE_BLOCK& GetTitleBlock() const; // overload const TITLE_BLOCK& GetTitleBlock() const; // overload
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload
/**
* Function GetDesignSettings
* returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
* Overloaded in FOOTPRINT_EDIT_FRAME.
*/
virtual BOARD_DESIGN_SETTINGS& GetDesignSettings() const;
virtual void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings );
/** /**
* 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
@ -130,9 +138,9 @@ public:
*/ */
void SetBoard( BOARD* aBoard ); void SetBoard( BOARD* aBoard );
BOARD* GetBoard() BOARD* GetBoard() const
{ {
wxASSERT( m_Pcb ); // phasing out m_Pcb for GerbView wxASSERT( m_Pcb );
return m_Pcb; return m_Pcb;
} }

View File

@ -113,15 +113,13 @@ PCB_BASE_FRAME::~PCB_BASE_FRAME()
{ {
delete m_Collector; delete m_Collector;
// delete m_Pcb; delete m_Pcb; // is already NULL for FOOTPRINT_EDIT_FRAME
} }
void PCB_BASE_FRAME::SetBoard( BOARD* aBoard ) void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
{ {
if( m_Pcb != g_ModuleEditor_Pcb ) delete m_Pcb;
delete m_Pcb;
m_Pcb = aBoard; m_Pcb = aBoard;
} }
@ -182,6 +180,20 @@ void PCB_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
} }
BOARD_DESIGN_SETTINGS& PCB_BASE_FRAME::GetDesignSettings() const
{
wxASSERT( m_Pcb );
return m_Pcb->GetDesignSettings();
}
void PCB_BASE_FRAME::SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings )
{
wxASSERT( m_Pcb );
m_Pcb->SetDesignSettings( aSettings );
}
EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
{ {
wxASSERT( m_Pcb ); wxASSERT( m_Pcb );

View File

@ -93,13 +93,6 @@ 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.

View File

@ -528,17 +528,17 @@ public:
* Function GetDesignSettings * Function GetDesignSettings
* @return the BOARD_DESIGN_SETTINGS for this BOARD * @return the BOARD_DESIGN_SETTINGS for this BOARD
*/ */
// const BOARD_DESIGN_SETTINGS& GetDesignSettings() const want to use this one BOARD_DESIGN_SETTINGS& GetDesignSettings() const
BOARD_DESIGN_SETTINGS& GetDesignSettings()
{ {
return m_designSettings; // remove const-ness with cast.
return (BOARD_DESIGN_SETTINGS&) m_designSettings;
} }
/** /**
* Function SetDesignSettings * Function SetDesignSettings
* @param aDesignSettings the new BOARD_DESIGN_SETTINGS to use * @param aDesignSettings the new BOARD_DESIGN_SETTINGS to use
*/ */
void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aDesignSettings ); void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aDesignSettings ) { m_designSettings = aDesignSettings; }
const PAGE_INFO& GetPageSettings() const { return m_paper; } const PAGE_INFO& GetPageSettings() const { return m_paper; }
void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; } void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }

View File

@ -331,8 +331,8 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
*/ */
int D_PAD::GetSolderMaskMargin() int D_PAD::GetSolderMaskMargin()
{ {
int margin = m_LocalSolderMaskMargin; int margin = m_LocalSolderMaskMargin;
MODULE * module = (MODULE*) GetParent(); MODULE* module = (MODULE*) GetParent();
if( module ) if( module )
{ {
@ -344,7 +344,7 @@ int D_PAD::GetSolderMaskMargin()
if( margin == 0 ) if( margin == 0 )
{ {
BOARD * brd = GetBoard(); BOARD* brd = GetBoard();
margin = brd->GetDesignSettings().m_SolderMaskMargin; margin = brd->GetDesignSettings().m_SolderMaskMargin;
} }
} }

View File

@ -56,17 +56,17 @@ static wxPoint MoveVector; // Move vector for move edge
static wxPoint CursorInitialPosition; // Mouse cursor initial position for move command static wxPoint CursorInitialPosition; // Mouse cursor initial position for move command
void FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC ) void FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod( EDGE_MODULE* aEdge, wxDC* DC )
{ {
if( Edge == NULL ) if( aEdge == NULL )
return; return;
Edge->Draw( m_canvas, DC, GR_XOR ); aEdge->Draw( m_canvas, DC, GR_XOR );
Edge->SetFlags( IS_MOVED ); aEdge->SetFlags( IS_MOVED );
MoveVector.x = MoveVector.y = 0; MoveVector.x = MoveVector.y = 0;
CursorInitialPosition = GetScreen()->GetCrossHairPosition(); CursorInitialPosition = GetScreen()->GetCrossHairPosition();
m_canvas->SetMouseCapture( ShowCurrentOutlineWhileMoving, Abort_Move_ModuleOutline ); m_canvas->SetMouseCapture( ShowCurrentOutlineWhileMoving, Abort_Move_ModuleOutline );
SetCurItem( Edge ); SetCurItem( aEdge );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
} }
@ -101,23 +101,23 @@ static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase ) const wxPoint& aPosition, bool aErase )
{ {
BASE_SCREEN* screen = aPanel->GetScreen(); BASE_SCREEN* screen = aPanel->GetScreen();
EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem(); EDGE_MODULE* edge = (EDGE_MODULE*) screen->GetCurItem();
if( Edge == NULL ) if( edge == NULL )
return; return;
MODULE* Module = (MODULE*) Edge->GetParent(); MODULE* module = (MODULE*) edge->GetParent();
if( aErase ) if( aErase )
{ {
Edge->Draw( aPanel, aDC, GR_XOR, MoveVector ); edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
} }
MoveVector = -(screen->GetCrossHairPosition() - CursorInitialPosition); MoveVector = -(screen->GetCrossHairPosition() - CursorInitialPosition);
Edge->Draw( aPanel, aDC, GR_XOR, MoveVector ); edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
Module->CalculateBoundingBox(); module->CalculateBoundingBox();
} }
@ -128,30 +128,30 @@ static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
bool aErase ) bool aErase )
{ {
BASE_SCREEN* screen = aPanel->GetScreen(); BASE_SCREEN* screen = aPanel->GetScreen();
EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem(); EDGE_MODULE* edge = (EDGE_MODULE*) screen->GetCurItem();
if( Edge == NULL ) if( edge == NULL )
return; return;
MODULE* module = (MODULE*) Edge->GetParent(); MODULE* module = (MODULE*) edge->GetParent();
// if( erase ) // if( erase )
{ {
Edge->Draw( aPanel, aDC, GR_XOR ); edge->Draw( aPanel, aDC, GR_XOR );
} }
Edge->SetEnd( screen->GetCrossHairPosition() ); edge->SetEnd( screen->GetCrossHairPosition() );
// Update relative coordinate. // Update relative coordinate.
Edge->SetEnd0( Edge->GetEnd() - module->GetPosition() ); edge->SetEnd0( edge->GetEnd() - module->GetPosition() );
wxPoint pt( Edge->GetEnd0() ); wxPoint pt( edge->GetEnd0() );
RotatePoint( &pt, -module->GetOrientation() ); RotatePoint( &pt, -module->GetOrientation() );
Edge->SetEnd0( pt ); edge->SetEnd0( pt );
Edge->Draw( aPanel, aDC, GR_XOR ); edge->Draw( aPanel, aDC, GR_XOR );
module->CalculateBoundingBox(); module->CalculateBoundingBox();
} }
@ -172,12 +172,12 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Width( EDGE_MODULE* aEdge )
if( aEdge->Type() != PCB_MODULE_EDGE_T ) if( aEdge->Type() != PCB_MODULE_EDGE_T )
continue; continue;
aEdge->SetWidth( GetBoard()->GetDesignSettings().m_ModuleSegmentWidth ); aEdge->SetWidth( GetDesignSettings().m_ModuleSegmentWidth );
} }
} }
else else
{ {
aEdge->SetWidth( GetBoard()->GetDesignSettings().m_ModuleSegmentWidth ); aEdge->SetWidth( GetDesignSettings().m_ModuleSegmentWidth );
} }
OnModify(); OnModify();
@ -194,7 +194,7 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* aEdge )
if( aEdge ) if( aEdge )
new_layer = aEdge->GetLayer(); new_layer = aEdge->GetLayer();
/* Ask for the new layer */ // Ask for the new layer
new_layer = SelectLayer( new_layer, FIRST_COPPER_LAYER, LAST_NO_COPPER_LAYER ); new_layer = SelectLayer( new_layer, FIRST_COPPER_LAYER, LAST_NO_COPPER_LAYER );
if( new_layer < 0 ) if( new_layer < 0 )
@ -238,7 +238,7 @@ void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge )
{ {
wxString buffer; wxString buffer;
buffer = ReturnStringFromValue( g_UserUnit, GetBoard()->GetDesignSettings().m_ModuleSegmentWidth, buffer = ReturnStringFromValue( g_UserUnit, GetDesignSettings().m_ModuleSegmentWidth,
GetScreen()->GetInternalUnits() ); GetScreen()->GetInternalUnits() );
wxTextEntryDialog dlg( this, _( "New Width:" ), _( "Edge Width" ), buffer ); wxTextEntryDialog dlg( this, _( "New Width:" ), _( "Edge Width" ), buffer );
@ -246,36 +246,36 @@ void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge )
return; // canceled by user return; // canceled by user
buffer = dlg.GetValue( ); buffer = dlg.GetValue( );
GetBoard()->GetDesignSettings().m_ModuleSegmentWidth = GetDesignSettings().m_ModuleSegmentWidth =
ReturnValueFromString( g_UserUnit, buffer, GetScreen()->GetInternalUnits() ); ReturnValueFromString( g_UserUnit, buffer, GetScreen()->GetInternalUnits() );
if( aEdge ) if( aEdge )
{ {
MODULE* module = GetBoard()->m_Modules; MODULE* module = GetBoard()->m_Modules;
aEdge->SetWidth( GetBoard()->GetDesignSettings().m_ModuleSegmentWidth ); aEdge->SetWidth( GetDesignSettings().m_ModuleSegmentWidth );
module->CalculateBoundingBox(); module->CalculateBoundingBox();
OnModify(); OnModify();
} }
} }
void FOOTPRINT_EDIT_FRAME::Delete_Edge_Module( EDGE_MODULE* Edge ) void FOOTPRINT_EDIT_FRAME::Delete_Edge_Module( EDGE_MODULE* aEdge )
{ {
if( Edge == NULL ) if( aEdge == NULL )
return; return;
if( Edge->Type() != PCB_MODULE_EDGE_T ) if( aEdge->Type() != PCB_MODULE_EDGE_T )
{ {
DisplayError( this, wxT( "StructType error: PCB_MODULE_EDGE_T expected" ) ); DisplayError( this, wxT( "StructType error: PCB_MODULE_EDGE_T expected" ) );
return; return;
} }
MODULE* Module = (MODULE*) Edge->GetParent(); MODULE* module = (MODULE*) aEdge->GetParent();
/* Delete segment. */ // Delete segment.
Edge->DeleteStructure(); aEdge->DeleteStructure();
Module->m_LastEdit_Time = time( NULL ); module->m_LastEdit_Time = time( NULL );
Module->CalculateBoundingBox(); module->CalculateBoundingBox();
OnModify(); OnModify();
} }
@ -284,24 +284,24 @@ void FOOTPRINT_EDIT_FRAME::Delete_Edge_Module( EDGE_MODULE* Edge )
*/ */
static void Abort_Move_ModuleOutline( EDA_DRAW_PANEL* Panel, wxDC* DC ) static void Abort_Move_ModuleOutline( EDA_DRAW_PANEL* Panel, wxDC* DC )
{ {
EDGE_MODULE* Edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem(); EDGE_MODULE* edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem();
Panel->SetMouseCapture( NULL, NULL ); Panel->SetMouseCapture( NULL, NULL );
if( Edge && ( Edge->Type() == PCB_MODULE_EDGE_T ) ) if( edge && ( edge->Type() == PCB_MODULE_EDGE_T ) )
{ {
if( Edge->IsNew() ) // On aborting, delete new outline. if( edge->IsNew() ) // On aborting, delete new outline.
{ {
MODULE* Module = (MODULE*) Edge->GetParent(); MODULE* module = (MODULE*) edge->GetParent();
Edge->Draw( Panel, DC, GR_XOR, MoveVector ); edge->Draw( Panel, DC, GR_XOR, MoveVector );
Edge->DeleteStructure(); edge->DeleteStructure();
Module->CalculateBoundingBox(); module->CalculateBoundingBox();
} }
else // On aborting, move existing outline to its initial position. else // On aborting, move existing outline to its initial position.
{ {
Edge->Draw( Panel, DC, GR_XOR, MoveVector ); edge->Draw( Panel, DC, GR_XOR, MoveVector );
Edge->ClearFlags(); edge->ClearFlags();
Edge->Draw( Panel, DC, GR_OR ); edge->Draw( Panel, DC, GR_OR );
} }
} }
@ -309,7 +309,7 @@ static void Abort_Move_ModuleOutline( EDA_DRAW_PANEL* Panel, wxDC* DC )
} }
EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge, EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* aEdge,
wxDC* DC, wxDC* DC,
int type_edge ) int type_edge )
{ {
@ -319,45 +319,45 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge,
if( module == NULL ) if( module == NULL )
return NULL; return NULL;
if( Edge == NULL ) /* Start a new edge item */ if( aEdge == NULL ) // Start a new edge item
{ {
SaveCopyInUndoList( module, UR_MODEDIT ); SaveCopyInUndoList( module, UR_MODEDIT );
Edge = new EDGE_MODULE( module ); aEdge = new EDGE_MODULE( module );
MoveVector.x = MoveVector.y = 0; MoveVector.x = MoveVector.y = 0;
// Add the new item to the Drawings list head // Add the new item to the Drawings list head
module->m_Drawings.PushFront( Edge ); module->m_Drawings.PushFront( aEdge );
// Update characteristics of the segment or arc. // Update characteristics of the segment or arc.
Edge->SetFlags( IS_NEW ); aEdge->SetFlags( IS_NEW );
Edge->SetAngle( angle ); aEdge->SetAngle( angle );
Edge->SetShape( type_edge ); aEdge->SetShape( type_edge );
if( Edge->GetShape() == S_ARC ) if( aEdge->GetShape() == S_ARC )
Edge->SetAngle( ArcValue ); aEdge->SetAngle( ArcValue );
Edge->SetWidth( GetBoard()->GetDesignSettings().m_ModuleSegmentWidth ); aEdge->SetWidth( GetDesignSettings().m_ModuleSegmentWidth );
Edge->SetLayer( module->GetLayer() ); aEdge->SetLayer( module->GetLayer() );
if( module->GetLayer() == LAYER_N_FRONT ) if( module->GetLayer() == LAYER_N_FRONT )
Edge->SetLayer( SILKSCREEN_N_FRONT ); aEdge->SetLayer( SILKSCREEN_N_FRONT );
if( module->GetLayer() == LAYER_N_BACK ) if( module->GetLayer() == LAYER_N_BACK )
Edge->SetLayer( SILKSCREEN_N_BACK ); aEdge->SetLayer( SILKSCREEN_N_BACK );
// Initialize the starting point of the new segment or arc // Initialize the starting point of the new segment or arc
Edge->SetStart( GetScreen()->GetCrossHairPosition() ); aEdge->SetStart( GetScreen()->GetCrossHairPosition() );
// Initialize the ending point of the new segment or arc // Initialize the ending point of the new segment or arc
Edge->SetEnd( Edge->GetStart() ); aEdge->SetEnd( aEdge->GetStart() );
// Initialize the relative coordinates // Initialize the relative coordinates
Edge->SetStart0( Edge->GetStart() - module->GetPosition() ); aEdge->SetStart0( aEdge->GetStart() - module->GetPosition() );
RotatePoint( &Edge->m_Start0, -module->m_Orient ); RotatePoint( &aEdge->m_Start0, -module->m_Orient );
Edge->m_End0 = Edge->m_Start0; aEdge->m_End0 = aEdge->m_Start0;
module->CalculateBoundingBox(); module->CalculateBoundingBox();
m_canvas->SetMouseCapture( ShowNewEdgeModule, Abort_Move_ModuleOutline ); m_canvas->SetMouseCapture( ShowNewEdgeModule, Abort_Move_ModuleOutline );
} }
@ -370,33 +370,33 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge,
{ {
if( type_edge == S_SEGMENT ) if( type_edge == S_SEGMENT )
{ {
if( Edge->m_Start0 != Edge->m_End0 ) if( aEdge->m_Start0 != aEdge->m_End0 )
{ {
Edge->Draw( m_canvas, DC, GR_OR ); aEdge->Draw( m_canvas, DC, GR_OR );
EDGE_MODULE* newedge = new EDGE_MODULE( *Edge ); EDGE_MODULE* newedge = new EDGE_MODULE( *aEdge );
// insert _after_ Edge, which is the same as inserting before Edge->Next() // insert _after_ aEdge, which is the same as inserting before aEdge->Next()
module->m_Drawings.Insert( newedge, Edge->Next() ); module->m_Drawings.Insert( newedge, aEdge->Next() );
Edge->ClearFlags(); aEdge->ClearFlags();
Edge = newedge; // point now new item aEdge = newedge; // point now new item
Edge->SetFlags( IS_NEW ); aEdge->SetFlags( IS_NEW );
Edge->SetWidth( GetBoard()->GetDesignSettings().m_ModuleSegmentWidth ); aEdge->SetWidth( GetDesignSettings().m_ModuleSegmentWidth );
Edge->SetStart( GetScreen()->GetCrossHairPosition() ); aEdge->SetStart( GetScreen()->GetCrossHairPosition() );
Edge->SetEnd( Edge->GetStart() ); aEdge->SetEnd( aEdge->GetStart() );
// Update relative coordinate. // Update relative coordinate.
Edge->SetStart0( Edge->GetStart() - module->GetPosition() ); aEdge->SetStart0( aEdge->GetStart() - module->GetPosition() );
wxPoint pt( Edge->GetStart0() ); wxPoint pt( aEdge->GetStart0() );
RotatePoint( &pt, -module->GetOrientation() ); RotatePoint( &pt, -module->GetOrientation() );
Edge->SetStart0( pt ); aEdge->SetStart0( pt );
Edge->SetEnd0( Edge->GetStart0() ); aEdge->SetEnd0( aEdge->GetStart0() );
module->CalculateBoundingBox(); module->CalculateBoundingBox();
module->m_LastEdit_Time = time( NULL ); module->m_LastEdit_Time = time( NULL );
@ -409,25 +409,25 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge,
} }
} }
return Edge; return aEdge;
} }
void FOOTPRINT_EDIT_FRAME::End_Edge_Module( EDGE_MODULE* Edge ) void FOOTPRINT_EDIT_FRAME::End_Edge_Module( EDGE_MODULE* aEdge )
{ {
MODULE* Module = GetBoard()->m_Modules; MODULE* module = GetBoard()->m_Modules;
if( Edge ) if( aEdge )
{ {
Edge->ClearFlags(); aEdge->ClearFlags();
/* If last segment length is 0: remove it */ // If last segment length is 0: remove it
if( Edge->GetStart() == Edge->GetEnd() ) if( aEdge->GetStart() == aEdge->GetEnd() )
Edge->DeleteStructure(); aEdge->DeleteStructure();
} }
Module->CalculateBoundingBox(); module->CalculateBoundingBox();
Module->m_LastEdit_Time = time( NULL ); module->m_LastEdit_Time = time( NULL );
OnModify(); OnModify();
m_canvas->SetMouseCapture( NULL, NULL ); m_canvas->SetMouseCapture( NULL, NULL );
} }

View File

@ -355,14 +355,14 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
} }
else else
{ {
int v_type = GetBoard()->GetDesignSettings().m_CurrentViaType; int v_type = 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()->GetDesignSettings().m_CurrentViaType = VIA_MICROVIA; GetDesignSettings().m_CurrentViaType = VIA_MICROVIA;
Other_Layer_Route( (TRACK*) GetCurItem(), &dc ); Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
GetBoard()->GetDesignSettings().m_CurrentViaType = v_type; GetDesignSettings().m_CurrentViaType = v_type;
if( DisplayOpt.ContrastModeDisplay ) if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh(); m_canvas->Refresh();

View File

@ -51,7 +51,7 @@ static wxPoint s_InitialPosition; // Initial cursor position.
static wxPoint s_LastPosition; // Current cursor position. static wxPoint s_LastPosition; // Current cursor position.
/* Start move of a graphic element type DRAWSEGMENT */ // Start move of a graphic element type DRAWSEGMENT
void PCB_EDIT_FRAME::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) void PCB_EDIT_FRAME::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
{ {
if( drawitem == NULL ) if( drawitem == NULL )
@ -119,7 +119,7 @@ void PCB_EDIT_FRAME::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
if( Segment->IsNew() ) // Trace in progress. if( Segment->IsNew() ) // Trace in progress.
{ {
/* Delete current segment. */ // Delete current segment.
DisplayOpt.DisplayDrawItems = SKETCH; DisplayOpt.DisplayDrawItems = SKETCH;
Segment->Draw( m_canvas, DC, GR_XOR ); Segment->Draw( m_canvas, DC, GR_XOR );
PtStruct = Segment->Back(); PtStruct = Segment->Back();
@ -236,14 +236,14 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, int shape,
int s_large; int s_large;
DRAWSEGMENT* DrawItem; DRAWSEGMENT* DrawItem;
s_large = GetBoard()->GetDesignSettings().m_DrawSegmentWidth; s_large = GetDesignSettings().m_DrawSegmentWidth;
if( getActiveLayer() == EDGE_N ) if( getActiveLayer() == EDGE_N )
{ {
s_large = GetBoard()->GetDesignSettings().m_EdgeSegmentWidth; s_large = GetDesignSettings().m_EdgeSegmentWidth;
} }
if( Segment == NULL ) /* Create new trace. */ if( Segment == NULL ) // Create new trace.
{ {
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) ); SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );
Segment->SetFlags( IS_NEW ); Segment->SetFlags( IS_NEW );

View File

@ -60,7 +60,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
return true; return true;
} }
/* Avoid more than one via on the current location: */ // Avoid more than one via on the current location:
if( GetBoard()->GetViaByPosition( g_CurrentTrackSegment->m_End, if( GetBoard()->GetViaByPosition( g_CurrentTrackSegment->m_End,
g_CurrentTrackSegment->GetLayer() ) ) g_CurrentTrackSegment->GetLayer() ) )
return false; return false;
@ -71,11 +71,11 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
return false; return false;
} }
/* Is the current segment Ok (no DRC error) ? */ // Is the current segment Ok (no DRC error) ?
if( Drc_On ) if( Drc_On )
{ {
if( BAD_DRC==m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) ) if( BAD_DRC==m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
/* DRC error, the change layer is not made */ // DRC error, the change layer is not made
return false; return false;
// Handle 2 segments. // Handle 2 segments.
@ -94,10 +94,10 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
/* create the via */ // create the via
SEGVIA* via = new SEGVIA( GetBoard() ); SEGVIA* via = new SEGVIA( GetBoard() );
via->SetFlags( IS_NEW ); via->SetFlags( IS_NEW );
via->m_Shape = GetBoard()->GetDesignSettings().m_CurrentViaType; via->m_Shape = 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;
@ -116,7 +116,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
else else
last_layer = GetScreen()->m_Route_Layer_BOTTOM; last_layer = GetScreen()->m_Route_Layer_BOTTOM;
/* Adjust the actual via layer pair */ // Adjust the actual via layer pair
switch ( via->GetShape() ) switch ( via->GetShape() )
{ {
case VIA_BLIND_BURIED: case VIA_BLIND_BURIED:
@ -150,7 +150,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
if( Drc_On && BAD_DRC == m_drc->Drc( via, GetBoard()->m_Track ) ) if( Drc_On && BAD_DRC == m_drc->Drc( via, GetBoard()->m_Track ) )
{ {
/* DRC fault: the Via cannot be placed here ... */ // DRC fault: the Via cannot be placed here ...
delete via; delete via;
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
@ -235,7 +235,7 @@ void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC )
Module = (MODULE*) pt_pad->GetParent(); Module = (MODULE*) pt_pad->GetParent();
} }
if( pt_pad ) /* Displaying the ratsnest of the corresponding net. */ if( pt_pad ) // Displaying the ratsnest of the corresponding net.
{ {
pt_pad->DisplayInfo( this ); pt_pad->DisplayInfo( this );
@ -300,7 +300,7 @@ void PCB_EDIT_FRAME::Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC )
} }
} }
/* Erase if no pad or module has been selected. */ // Erase if no pad or module has been selected.
if( ( pt_pad == NULL ) && ( Module == NULL ) ) if( ( pt_pad == NULL ) && ( Module == NULL ) )
{ {
DrawGeneralRatsnest( DC ); DrawGeneralRatsnest( DC );

View File

@ -76,10 +76,10 @@ TEXTE_MODULE* PCB_BASE_FRAME::CreateTextModule( MODULE* Module, wxDC* DC )
Text->m_Text = wxT( "text" ); Text->m_Text = wxT( "text" );
GetBoard()->GetDesignSettings().m_ModuleTextWidth = Clamp_Text_PenSize( GetBoard()->GetDesignSettings().m_ModuleTextWidth, GetDesignSettings().m_ModuleTextWidth = Clamp_Text_PenSize( GetDesignSettings().m_ModuleTextWidth,
MIN( GetBoard()->GetDesignSettings().m_ModuleTextSize.x, GetBoard()->GetDesignSettings().m_ModuleTextSize.y ), true ); MIN( GetDesignSettings().m_ModuleTextSize.x, GetDesignSettings().m_ModuleTextSize.y ), true );
Text->m_Size = GetBoard()->GetDesignSettings().m_ModuleTextSize; Text->m_Size = GetDesignSettings().m_ModuleTextSize;
Text->m_Thickness = GetBoard()->GetDesignSettings().m_ModuleTextWidth; Text->m_Thickness = GetDesignSettings().m_ModuleTextWidth;
Text->m_Pos = GetScreen()->GetCrossHairPosition(); Text->m_Pos = GetScreen()->GetCrossHairPosition();
Text->SetLocalCoord(); Text->SetLocalCoord();
@ -309,15 +309,15 @@ 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()->GetDesignSettings().m_PcbTextSize; newSize = GetDesignSettings().m_PcbTextSize;
newThickness = GetBoard()->GetDesignSettings().m_PcbTextWidth; newThickness = GetDesignSettings().m_PcbTextWidth;
pcbText = (TEXTE_PCB*) aItem; pcbText = (TEXTE_PCB*) aItem;
text = (EDA_TEXT*) pcbText; text = (EDA_TEXT*) pcbText;
break; break;
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
newSize = GetBoard()->GetDesignSettings().m_ModuleTextSize; newSize = GetDesignSettings().m_ModuleTextSize;
newThickness = GetBoard()->GetDesignSettings().m_ModuleTextWidth; newThickness = GetDesignSettings().m_ModuleTextWidth;
moduleText = (TEXTE_MODULE*) aItem; moduleText = (TEXTE_MODULE*) aItem;
text = (EDA_TEXT*) moduleText; text = (EDA_TEXT*) moduleText;
break; break;
@ -380,7 +380,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC )
case TEXT_is_REFERENCE: case TEXT_is_REFERENCE:
item = module->m_Reference; item = module->m_Reference;
if( item->GetSize() != GetBoard()->GetDesignSettings().m_ModuleTextSize || item->GetThickness() != GetBoard()->GetDesignSettings().m_ModuleTextWidth ) if( item->GetSize() != GetDesignSettings().m_ModuleTextSize || item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
undoItemList.PushItem( itemWrapper ); undoItemList.PushItem( itemWrapper );
break; break;
@ -388,7 +388,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC )
case TEXT_is_VALUE: case TEXT_is_VALUE:
item = module->m_Value; item = module->m_Value;
if( item->GetSize() != GetBoard()->GetDesignSettings().m_ModuleTextSize || item->GetThickness() != GetBoard()->GetDesignSettings().m_ModuleTextWidth ) if( item->GetSize() != GetDesignSettings().m_ModuleTextSize || item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
undoItemList.PushItem( itemWrapper ); undoItemList.PushItem( itemWrapper );
break; break;
@ -401,8 +401,8 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC )
{ {
item = (TEXTE_MODULE*) boardItem; item = (TEXTE_MODULE*) boardItem;
if( item->GetSize() != GetBoard()->GetDesignSettings().m_ModuleTextSize if( item->GetSize() != GetDesignSettings().m_ModuleTextSize
|| item->GetThickness() != GetBoard()->GetDesignSettings().m_ModuleTextWidth ) || item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
{ {
undoItemList.PushItem( itemWrapper ); undoItemList.PushItem( itemWrapper );
break; break;
@ -432,13 +432,13 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC )
switch( aType ) switch( aType )
{ {
case TEXT_is_REFERENCE: case TEXT_is_REFERENCE:
module->m_Reference->SetThickness( GetBoard()->GetDesignSettings().m_ModuleTextWidth ); module->m_Reference->SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->m_Reference->SetSize( GetBoard()->GetDesignSettings().m_ModuleTextSize ); module->m_Reference->SetSize( GetDesignSettings().m_ModuleTextSize );
break; break;
case TEXT_is_VALUE: case TEXT_is_VALUE:
module->m_Value->SetThickness( GetBoard()->GetDesignSettings().m_ModuleTextWidth ); module->m_Value->SetThickness( GetDesignSettings().m_ModuleTextWidth );
module->m_Value->SetSize( GetBoard()->GetDesignSettings().m_ModuleTextSize ); module->m_Value->SetSize( GetDesignSettings().m_ModuleTextSize );
break; break;
case TEXT_is_DIVERS: case TEXT_is_DIVERS:
@ -447,8 +447,8 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC )
if( boardItem->Type() == PCB_MODULE_TEXT_T ) if( boardItem->Type() == PCB_MODULE_TEXT_T )
{ {
item = (TEXTE_MODULE*) boardItem; item = (TEXTE_MODULE*) boardItem;
item->SetThickness( GetBoard()->GetDesignSettings().m_ModuleTextWidth ); item->SetThickness( GetDesignSettings().m_ModuleTextWidth );
item->SetSize( GetBoard()->GetDesignSettings().m_ModuleTextSize ); item->SetSize( GetDesignSettings().m_ModuleTextSize );
} }
} }

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()->GetDesignSettings().m_UseConnectedTrackWidth = GetDesignSettings().m_UseConnectedTrackWidth =
not GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth; not GetDesignSettings().m_UseConnectedTrackWidth;
break; break;
case ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES: case ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES:
GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth = false; 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:
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth = true; 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:
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth = false; 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

@ -703,13 +703,13 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName )
// Update reference: // Update reference:
Module->m_Reference->m_Text = moduleName; Module->m_Reference->m_Text = moduleName;
Module->m_Reference->SetThickness( GetBoard()->GetDesignSettings().m_ModuleTextWidth ); Module->m_Reference->SetThickness( GetDesignSettings().m_ModuleTextWidth );
Module->m_Reference->SetSize( GetBoard()->GetDesignSettings().m_ModuleTextSize ); Module->m_Reference->SetSize( GetDesignSettings().m_ModuleTextSize );
// Set the value field to a default value // Set the value field to a default value
Module->m_Value->m_Text = wxT( "VAL**" ); Module->m_Value->m_Text = wxT( "VAL**" );
Module->m_Value->SetThickness( GetBoard()->GetDesignSettings().m_ModuleTextWidth ); Module->m_Value->SetThickness( GetDesignSettings().m_ModuleTextWidth );
Module->m_Value->SetSize( GetBoard()->GetDesignSettings().m_ModuleTextSize ); Module->m_Value->SetSize( GetDesignSettings().m_ModuleTextSize );
Module->SetPosition( wxPoint( 0, 0 ) ); Module->SetPosition( wxPoint( 0, 0 ) );

View File

@ -215,7 +215,7 @@ PCB_TARGET* PCB_EDIT_FRAME::CreateTarget( wxDC* DC )
GetBoard()->Add( target ); GetBoard()->Add( target );
target->SetLayer( EDGE_N ); target->SetLayer( EDGE_N );
target->SetWidth( GetBoard()->GetDesignSettings().m_EdgeSegmentWidth ); target->SetWidth( GetDesignSettings().m_EdgeSegmentWidth );
target->SetSize( MireDefaultSize ); target->SetSize( MireDefaultSize );
target->SetPosition( m_canvas->GetScreen()->GetCrossHairPosition() ); target->SetPosition( m_canvas->GetScreen()->GetCrossHairPosition() );

View File

@ -3,8 +3,8 @@
* @brief Definition of class FOOTPRINT_EDIT_FRAME. * @brief Definition of class FOOTPRINT_EDIT_FRAME.
*/ */
#ifndef _MODULE_EDITOR_FRAME_H_ #ifndef MODULE_EDITOR_FRAME_H_
#define _MODULE_EDITOR_FRAME_H_ #define MODULE_EDITOR_FRAME_H_
class FOOTPRINT_EDIT_FRAME : public PCB_BASE_FRAME class FOOTPRINT_EDIT_FRAME : public PCB_BASE_FRAME
@ -13,13 +13,16 @@ public:
MODULE* CurrentModule; MODULE* CurrentModule;
public: public:
FOOTPRINT_EDIT_FRAME( wxWindow* father, FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent,
const wxString& title, const wxString& title,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
~FOOTPRINT_EDIT_FRAME(); ~FOOTPRINT_EDIT_FRAME();
BOARD_DESIGN_SETTINGS& GetDesignSettings() const; // overload PCB_BASE_FRAME, get parent's
void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings ); // overload
void InstallOptionsFrame( const wxPoint& pos ); void InstallOptionsFrame( const wxPoint& pos );
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
@ -199,6 +202,8 @@ public:
private: private:
static wxString m_CurrentLib; static wxString m_CurrentLib;
static BOARD* s_Pcb; ///< retain board accross invocations of module editor
/** /**
* Function GetComponentFromUndoList * Function GetComponentFromUndoList
* performs an undo operation on the last edition: * performs an undo operation on the last edition:
@ -328,10 +333,10 @@ public:
*/ */
void Enter_Edge_Width( EDGE_MODULE* aEdge ); void Enter_Edge_Width( EDGE_MODULE* aEdge );
/* Function to initialize the move function params of a graphic item type DRAWSEGMENT */ /// Function to initialize the move function params of a graphic item type DRAWSEGMENT
void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC ); void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC );
/* Function to place a graphic item type EDGE_MODULE currently moved */ /// Function to place a graphic item type EDGE_MODULE currently moved
void Place_EdgeMod( EDGE_MODULE* drawitem ); void Place_EdgeMod( EDGE_MODULE* drawitem );
/** /**
@ -355,4 +360,4 @@ public:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
#endif // #define _MODULE_EDITOR_FRAME_H_ #endif // MODULE_EDITOR_FRAME_H_

View File

@ -49,11 +49,9 @@
static PCB_SCREEN* s_screenModule = NULL; // the PCB_SCREEN used by the footprint editor static PCB_SCREEN* s_screenModule = NULL; // the PCB_SCREEN used by the footprint editor
// Design setting for the module editor:
static BOARD_DESIGN_SETTINGS s_ModuleEditorDesignSetting;
wxString FOOTPRINT_EDIT_FRAME::m_CurrentLib = wxEmptyString; wxString FOOTPRINT_EDIT_FRAME::m_CurrentLib = wxEmptyString;
BOARD* FOOTPRINT_EDIT_FRAME::s_Pcb;
BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END, EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END,
@ -134,12 +132,12 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
END_EVENT_TABLE() END_EVENT_TABLE()
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( wxWindow* father, FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent,
const wxString& title, const wxString& title,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style ) : long style ) :
PCB_BASE_FRAME( father, MODULE_EDITOR_FRAME, wxEmptyString, pos, size, style ) PCB_BASE_FRAME( aParent, MODULE_EDITOR_FRAME, wxEmptyString, pos, size, style )
{ {
m_FrameName = wxT( "ModEditFrame" ); m_FrameName = wxT( "ModEditFrame" );
m_showBorderAndTitleBlock = false; // true to show the frame references m_showBorderAndTitleBlock = false; // true to show the frame references
@ -154,16 +152,21 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( wxWindow* father,
UpdateTitle(); UpdateTitle();
if( g_ModuleEditor_Pcb == NULL ) if( !s_Pcb )
g_ModuleEditor_Pcb = new BOARD(); s_Pcb = new BOARD();
SetBoard( g_ModuleEditor_Pcb ); SetBoard( s_Pcb );
if( s_screenModule == NULL ) if( s_screenModule == NULL )
s_screenModule = new PCB_SCREEN( GetPageSettings().GetSizeIU() ); s_screenModule = new PCB_SCREEN( GetPageSettings().GetSizeIU() );
SetScreen( s_screenModule ); SetScreen( s_screenModule );
GetBoard()->SetDesignSettings( s_ModuleEditorDesignSetting );
/* not sure why this was here, formerly s_ModuleEditorDesignSetting, since
we get default BOARD_DESIGN_SETTINGS in BOARD's constructor.
GetBoard()->SetDesignSettings( BOARD_DESIGN_SETTINGS() );
*/
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
LoadSettings(); LoadSettings();
@ -215,16 +218,42 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( wxWindow* father,
FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME() FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
{ {
/* g_ModuleEditor_Pcb and its corresponding PCB_SCREEN are not deleted // When user reopens the Footprint editor, user would like to find the last edited item.
* here, because if we reopen the Footprint editor, we expect to find // Do not delete PCB_SCREEN (by the destructor of EDA_DRAW_FRAME)
* the last edited item SetScreen( NULL );
*/
SetScreen( NULL ); /* Do not delete (by the destructor of EDA_DRAW_FRAME) the
* PCB_SCREEN handling g_ModuleEditor_Pcb
*/
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent(); PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
frame->m_ModuleEditFrame = NULL; frame->m_ModuleEditFrame = NULL;
// Do not allow PCB_BASE_FRAME::~PCB_BASE_FRAME()
// to delete our precious BOARD, which is also in static FOOTPRINT_EDIT_FRAME::s_Pcb.
// That function, PCB_BASE_FRAME::~PCB_BASE_FRAME(), runs immediately next
// as we return from here.
m_Pcb = 0;
}
BOARD_DESIGN_SETTINGS& FOOTPRINT_EDIT_FRAME::GetDesignSettings() const
{
// get the BOARD_DESIGN_SETTINGS from the parent editor, not our BOARD.
PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) GetParent();
wxASSERT( parentFrame );
return parentFrame->GetDesignSettings();
}
void FOOTPRINT_EDIT_FRAME::SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings )
{
// set the BOARD_DESIGN_SETTINGS int parent editor, not our BOARD.
PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) GetParent();
wxASSERT( parentFrame );
parentFrame->SetDesignSettings( aSettings );
} }

View File

@ -623,7 +623,7 @@ bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void )
int copperlayercnt = GetBoard()->GetCopperLayerCount( ); int copperlayercnt = GetBoard()->GetCopperLayerCount( );
int currLayer = getActiveLayer(); int currLayer = getActiveLayer();
if( !GetBoard()->GetDesignSettings().m_MicroViasAllowed ) if( !GetDesignSettings().m_MicroViasAllowed )
return false; // Obvious.. return false; // Obvious..
if( copperlayercnt < 4 ) if( copperlayercnt < 4 )

View File

@ -127,7 +127,7 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator()
change = true; change = true;
} }
int via_type = GetBoard()->GetDesignSettings().m_CurrentViaType; int via_type = 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

@ -60,7 +60,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()->GetDesignSettings().m_UseConnectedTrackWidth ); !GetDesignSettings().m_UseConnectedTrackWidth );
aEvent.Check( check ); aEvent.Check( check );
} }
} }
@ -68,7 +68,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()->GetDesignSettings().m_UseConnectedTrackWidth ); aEvent.Check( GetDesignSettings().m_UseConnectedTrackWidth );
} }
@ -85,7 +85,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()->GetDesignSettings().m_UseConnectedTrackWidth ); !GetDesignSettings().m_UseConnectedTrackWidth );
aEvent.Check( check ); aEvent.Check( check );
} }