get rid of some globals, share BOARD_DESIGN_SETTINGS from PCB_EDIT_FRAME with FOOTPRINT_EDIT_FRAME
This commit is contained in:
parent
cc46daa67f
commit
716d21d88a
|
@ -89,7 +89,7 @@ static void CALLBACK tesswxPoint2Vertex( const GLvoid* data );
|
|||
|
||||
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() )
|
||||
return;
|
||||
|
||||
|
@ -112,8 +112,8 @@ void EDA_3D_CANVAS::Redraw( bool finish )
|
|||
|
||||
InitGL();
|
||||
|
||||
glMatrixMode( GL_MODELVIEW ); /* position viewer */
|
||||
/* transformations */
|
||||
glMatrixMode( GL_MODELVIEW ); // position viewer
|
||||
// transformations
|
||||
GLfloat mat[4][4];
|
||||
|
||||
// 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_BoardScale;
|
||||
|
||||
/* calculate z position for each layer */
|
||||
// calculate z position for each layer
|
||||
for( ii = 0; ii < 32; ii++ )
|
||||
{
|
||||
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 );
|
||||
|
||||
/* draw axis */
|
||||
// draw axis
|
||||
if( g_Parm_3D_Visu.m_Draw3DAxis )
|
||||
{
|
||||
glEnable( GL_COLOR_MATERIAL );
|
||||
|
@ -222,7 +222,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
|
|||
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
|
||||
glEnable( GL_FOG );
|
||||
GLfloat param;
|
||||
|
@ -255,14 +255,14 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
|
|||
glEnd();
|
||||
#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,
|
||||
-g_Parm_3D_Visu.m_BoardPos.y * g_Parm_3D_Visu.m_BoardScale,
|
||||
0.0F );
|
||||
|
||||
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() )
|
||||
{
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
for( ; Module != NULL; Module = Module->Next() )
|
||||
|
@ -400,7 +400,7 @@ GLuint EDA_3D_CANVAS::CreateDrawGL_List()
|
|||
|
||||
glEndList();
|
||||
|
||||
/* Test for errors */
|
||||
// Test for errors
|
||||
CheckGLError();
|
||||
|
||||
return m_gllist;
|
||||
|
@ -694,7 +694,7 @@ void MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
|
|||
{
|
||||
D_PAD* pad = m_Pads;
|
||||
|
||||
/* Draw pads */
|
||||
// Draw pads
|
||||
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
|
||||
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 );
|
||||
}
|
||||
|
||||
/* 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;
|
||||
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 )
|
||||
{
|
||||
int ii, ll, layer, nlmax;
|
||||
|
@ -912,7 +912,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
|
|||
holeY = (double) m_Drill.y * scale / 2;
|
||||
hole = fmin( holeX, holeY );
|
||||
|
||||
/* Calculate the center of the pad. */
|
||||
// Calculate the center of the pad.
|
||||
shape_pos = ReturnShapePos();
|
||||
ux0 = shape_pos.x;
|
||||
uy0 = shape_pos.y;
|
||||
|
@ -926,7 +926,7 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
|
|||
drillx = m_Pos.x * 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 )
|
||||
{
|
||||
SetGLColor( DARKGRAY );
|
||||
|
@ -981,13 +981,13 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
|
|||
break;
|
||||
|
||||
case PAD_OVAL:
|
||||
if( dx > dy ) /* Horizontal ellipse */
|
||||
if( dx > dy ) // Horizontal ellipse
|
||||
{
|
||||
delta_cx = dx - dy;
|
||||
delta_cy = 0;
|
||||
w = m_Size.y * scale;
|
||||
}
|
||||
else /* Vertical ellipse */
|
||||
else // Vertical ellipse
|
||||
{
|
||||
delta_cx = 0;
|
||||
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,
|
||||
double endy, double width, double zpos )
|
||||
{
|
||||
|
|
|
@ -111,8 +111,6 @@ class BOARD_DESIGN_SETTINGS g_DesignSettings;
|
|||
*/
|
||||
DLIST<TRACK> g_CurrentTrackList;
|
||||
|
||||
BOARD* g_ModuleEditor_Pcb = NULL;
|
||||
|
||||
bool g_Zone_45_Only = false;
|
||||
|
||||
// Default setting used when creating a new zone
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* @file pcbcommon.h
|
||||
*/
|
||||
|
||||
#ifndef __PCBCOMMON_H__
|
||||
#define __PCBCOMMON_H__
|
||||
#ifndef PCBCOMMON_H_
|
||||
#define PCBCOMMON_H_
|
||||
|
||||
|
||||
#include <dlist.h>
|
||||
|
@ -13,7 +13,7 @@
|
|||
//#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;
|
||||
|
@ -30,7 +30,7 @@ class DISPLAY_OPTIONS;
|
|||
*/
|
||||
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 DISPLAY_OPTIONS DisplayOpt;
|
||||
|
@ -52,10 +52,8 @@ extern DLIST<TRACK> g_CurrentTrackList;
|
|||
|
||||
#define g_FirstTrackSegment g_CurrentTrackList.GetFirst() ///< first segment created
|
||||
|
||||
extern BOARD* g_ModuleEditor_Pcb;
|
||||
|
||||
/* Pad editing */
|
||||
/// Pad editing
|
||||
extern D_PAD g_Pad_Master;
|
||||
|
||||
|
||||
#endif /* __PCBCOMMON_H__ */
|
||||
#endif // PCBCOMMON_H_
|
||||
|
|
|
@ -122,6 +122,14 @@ public:
|
|||
const TITLE_BLOCK& GetTitleBlock() const; // 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
|
||||
* sets the m_Pcb member in such as way as to ensure deleting any previous
|
||||
|
@ -130,9 +138,9 @@ public:
|
|||
*/
|
||||
void SetBoard( BOARD* aBoard );
|
||||
|
||||
BOARD* GetBoard()
|
||||
BOARD* GetBoard() const
|
||||
{
|
||||
wxASSERT( m_Pcb ); // phasing out m_Pcb for GerbView
|
||||
wxASSERT( m_Pcb );
|
||||
return m_Pcb;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,15 +113,13 @@ PCB_BASE_FRAME::~PCB_BASE_FRAME()
|
|||
{
|
||||
delete m_Collector;
|
||||
|
||||
// delete m_Pcb;
|
||||
delete m_Pcb; // is already NULL for FOOTPRINT_EDIT_FRAME
|
||||
}
|
||||
|
||||
|
||||
void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
|
||||
{
|
||||
if( m_Pcb != g_ModuleEditor_Pcb )
|
||||
delete m_Pcb;
|
||||
|
||||
delete m_Pcb;
|
||||
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
|
||||
{
|
||||
wxASSERT( m_Pcb );
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
TRACK* segment; // The current segment being analyzed.
|
||||
|
|
|
@ -528,17 +528,17 @@ public:
|
|||
* Function GetDesignSettings
|
||||
* @return the BOARD_DESIGN_SETTINGS for this BOARD
|
||||
*/
|
||||
// const BOARD_DESIGN_SETTINGS& GetDesignSettings() const want to use this one
|
||||
BOARD_DESIGN_SETTINGS& GetDesignSettings()
|
||||
BOARD_DESIGN_SETTINGS& GetDesignSettings() const
|
||||
{
|
||||
return m_designSettings;
|
||||
// remove const-ness with cast.
|
||||
return (BOARD_DESIGN_SETTINGS&) m_designSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetDesignSettings
|
||||
* @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; }
|
||||
void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
|
||||
|
|
|
@ -331,8 +331,8 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
|
|||
*/
|
||||
int D_PAD::GetSolderMaskMargin()
|
||||
{
|
||||
int margin = m_LocalSolderMaskMargin;
|
||||
MODULE * module = (MODULE*) GetParent();
|
||||
int margin = m_LocalSolderMaskMargin;
|
||||
MODULE* module = (MODULE*) GetParent();
|
||||
|
||||
if( module )
|
||||
{
|
||||
|
@ -344,7 +344,7 @@ int D_PAD::GetSolderMaskMargin()
|
|||
|
||||
if( margin == 0 )
|
||||
{
|
||||
BOARD * brd = GetBoard();
|
||||
BOARD* brd = GetBoard();
|
||||
margin = brd->GetDesignSettings().m_SolderMaskMargin;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,17 +56,17 @@ static wxPoint MoveVector; // Move vector for move edge
|
|||
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;
|
||||
|
||||
Edge->Draw( m_canvas, DC, GR_XOR );
|
||||
Edge->SetFlags( IS_MOVED );
|
||||
aEdge->Draw( m_canvas, DC, GR_XOR );
|
||||
aEdge->SetFlags( IS_MOVED );
|
||||
MoveVector.x = MoveVector.y = 0;
|
||||
CursorInitialPosition = GetScreen()->GetCrossHairPosition();
|
||||
m_canvas->SetMouseCapture( ShowCurrentOutlineWhileMoving, Abort_Move_ModuleOutline );
|
||||
SetCurItem( Edge );
|
||||
SetCurItem( aEdge );
|
||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
||||
}
|
||||
|
||||
|
@ -101,23 +101,23 @@ static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|||
const wxPoint& aPosition, bool aErase )
|
||||
{
|
||||
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;
|
||||
|
||||
MODULE* Module = (MODULE*) Edge->GetParent();
|
||||
MODULE* module = (MODULE*) edge->GetParent();
|
||||
|
||||
if( aErase )
|
||||
{
|
||||
Edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
|
||||
edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
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;
|
||||
|
||||
MODULE* module = (MODULE*) Edge->GetParent();
|
||||
MODULE* module = (MODULE*) edge->GetParent();
|
||||
|
||||
// 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.
|
||||
Edge->SetEnd0( Edge->GetEnd() - module->GetPosition() );
|
||||
edge->SetEnd0( edge->GetEnd() - module->GetPosition() );
|
||||
|
||||
wxPoint pt( Edge->GetEnd0() );
|
||||
wxPoint pt( edge->GetEnd0() );
|
||||
|
||||
RotatePoint( &pt, -module->GetOrientation() );
|
||||
|
||||
Edge->SetEnd0( pt );
|
||||
edge->SetEnd0( pt );
|
||||
|
||||
Edge->Draw( aPanel, aDC, GR_XOR );
|
||||
edge->Draw( aPanel, aDC, GR_XOR );
|
||||
|
||||
module->CalculateBoundingBox();
|
||||
}
|
||||
|
@ -172,12 +172,12 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Width( EDGE_MODULE* aEdge )
|
|||
if( aEdge->Type() != PCB_MODULE_EDGE_T )
|
||||
|