2007-08-06 02:02:39 +00:00
|
|
|
|
/****************************************************/
|
|
|
|
|
/* class_module.cpp : fonctions de la classe MODULE */
|
|
|
|
|
/****************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
|
|
#include "wxstruct.h"
|
|
|
|
|
#include "common.h"
|
|
|
|
|
#include "plot_common.h"
|
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
#include "trigo.h"
|
|
|
|
|
|
|
|
|
|
#ifdef PCBNEW
|
|
|
|
|
#include "autorout.h"
|
|
|
|
|
#include "drag.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef CVPCB
|
|
|
|
|
#include "cvpcb.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "3d_struct.h"
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
|
|
|
|
|
int dim_ancre, int draw_mode )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*********************************************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* trace de l'ancre (croix verticale)
|
2007-08-06 02:02:39 +00:00
|
|
|
|
* (doit etre fait apres les pads,
|
|
|
|
|
* car le trace du trou efface tout donc peut etre l'ancre */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
int zoom = panel->GetZoom();
|
|
|
|
|
int anchor_size = dim_ancre * zoom;
|
|
|
|
|
|
|
|
|
|
GRSetDrawMode( DC, draw_mode );
|
|
|
|
|
|
|
|
|
|
if( (g_AnchorColor & ITEM_NOT_SHOW) == 0 )
|
|
|
|
|
{
|
|
|
|
|
GRLine( &panel->m_ClipBox, DC,
|
2008-03-15 10:24:32 +00:00
|
|
|
|
m_Pos.x - offset.x - anchor_size, m_Pos.y - offset.y,
|
|
|
|
|
m_Pos.x - offset.x + anchor_size, m_Pos.y - offset.y,
|
|
|
|
|
0, g_AnchorColor );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
GRLine( &panel->m_ClipBox, DC,
|
2008-03-15 10:24:32 +00:00
|
|
|
|
m_Pos.x - offset.x, m_Pos.y - offset.y - anchor_size,
|
|
|
|
|
m_Pos.x - offset.x, m_Pos.y - offset.y + anchor_size,
|
|
|
|
|
0, g_AnchorColor );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
/*************************************************/
|
|
|
|
|
/* Class MODULE : description d'un composant pcb */
|
|
|
|
|
/*************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
/* Constructeur de la classe MODULE */
|
2008-02-19 00:30:10 +00:00
|
|
|
|
MODULE::MODULE( BOARD* parent ) :
|
2007-08-23 04:28:46 +00:00
|
|
|
|
BOARD_ITEM( parent, TYPEMODULE )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
m_Pads = NULL;
|
|
|
|
|
m_Drawings = NULL;
|
|
|
|
|
m_3D_Drawings = NULL;
|
|
|
|
|
m_Attributs = MOD_DEFAULT;
|
|
|
|
|
m_Layer = CMP_N;
|
|
|
|
|
m_Orient = 0;
|
|
|
|
|
m_ModuleStatus = 0;
|
|
|
|
|
flag = 0;
|
|
|
|
|
m_CntRot90 = m_CntRot180 = 0;
|
|
|
|
|
m_Surface = 0;
|
|
|
|
|
m_Link = 0;
|
|
|
|
|
m_LastEdit_Time = time( NULL );
|
|
|
|
|
m_Reference = new TEXTE_MODULE( this, TEXT_is_REFERENCE );
|
|
|
|
|
m_Reference->Pback = this;
|
|
|
|
|
m_Value = new TEXTE_MODULE( this, TEXT_is_VALUE );
|
|
|
|
|
m_Value->Pback = this;
|
|
|
|
|
m_3D_Drawings = new Struct3D_Master( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
|
|
/* Destructeur */
|
2007-09-01 12:00:30 +00:00
|
|
|
|
MODULE::~MODULE()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
D_PAD* Pad;
|
|
|
|
|
EDA_BaseStruct* Struct, * NextStruct;
|
|
|
|
|
|
|
|
|
|
delete m_Reference;
|
|
|
|
|
delete m_Value;
|
|
|
|
|
for( Struct = m_3D_Drawings; Struct != NULL; Struct = NextStruct )
|
|
|
|
|
{
|
|
|
|
|
NextStruct = Struct->Pnext;
|
|
|
|
|
delete Struct;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* effacement des pads */
|
|
|
|
|
for( Pad = m_Pads; Pad != NULL; Pad = (D_PAD*) NextStruct )
|
|
|
|
|
{
|
|
|
|
|
NextStruct = Pad->Pnext;
|
|
|
|
|
delete Pad;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* effacement des elements de trace */
|
|
|
|
|
for( Struct = m_Drawings; Struct != NULL; Struct = NextStruct )
|
|
|
|
|
{
|
|
|
|
|
NextStruct = Struct->Pnext;
|
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
|
switch( ( Struct->Type() ) )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
{
|
|
|
|
|
case TYPEEDGEMODULE:
|
|
|
|
|
delete (EDGE_MODULE*) Struct;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPETEXTEMODULE:
|
|
|
|
|
delete (TEXTE_MODULE*) Struct;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
DisplayError( NULL, wxT( "Warn: ItemType not handled in delete MODULE" ) );
|
|
|
|
|
NextStruct = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*********************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
void MODULE::Copy( MODULE* Module )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*********************************/
|
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
D_PAD* pad, * lastpad;
|
|
|
|
|
|
|
|
|
|
m_Pos = Module->m_Pos;
|
|
|
|
|
m_Layer = Module->m_Layer;
|
|
|
|
|
m_LibRef = Module->m_LibRef;
|
|
|
|
|
m_Attributs = Module->m_Attributs;
|
|
|
|
|
m_Orient = Module->m_Orient;
|
|
|
|
|
m_BoundaryBox = Module->m_BoundaryBox;
|
|
|
|
|
m_PadNum = Module->m_PadNum;
|
|
|
|
|
m_CntRot90 = Module->m_CntRot90;
|
|
|
|
|
m_CntRot180 = Module->m_CntRot180;
|
|
|
|
|
m_LastEdit_Time = Module->m_LastEdit_Time;
|
2008-03-15 10:24:32 +00:00
|
|
|
|
m_Path = Module->m_Path; //is this correct behavior?
|
2007-08-06 02:02:39 +00:00
|
|
|
|
m_TimeStamp = GetTimeStamp();
|
|
|
|
|
|
|
|
|
|
/* Copy des structures auxiliaires: Reference et value */
|
|
|
|
|
m_Reference->Copy( Module->m_Reference );
|
|
|
|
|
m_Value->Copy( Module->m_Value );
|
|
|
|
|
|
|
|
|
|
/* Copie des structures auxiliaires: Pads */
|
|
|
|
|
lastpad = NULL; pad = Module->m_Pads;
|
|
|
|
|
for( ; pad != NULL; pad = (D_PAD*) pad->Pnext )
|
|
|
|
|
{
|
|
|
|
|
D_PAD* newpad = new D_PAD( this );
|
|
|
|
|
newpad->Copy( pad );
|
|
|
|
|
|
|
|
|
|
if( m_Pads == NULL )
|
|
|
|
|
{
|
|
|
|
|
newpad->Pback = this;
|
|
|
|
|
m_Pads = (D_PAD*) newpad;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
newpad->Pback = lastpad;
|
|
|
|
|
lastpad->Pnext = newpad;
|
|
|
|
|
}
|
|
|
|
|
lastpad = newpad;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Copy des structures auxiliaires: Drawings */
|
2008-03-15 10:24:32 +00:00
|
|
|
|
BOARD_ITEM* OldStruct = Module->m_Drawings;
|
|
|
|
|
BOARD_ITEM* NewStruct, * LastStruct = NULL;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
for( ; OldStruct; OldStruct = OldStruct->Next() )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
{
|
|
|
|
|
NewStruct = NULL;
|
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
|
switch( OldStruct->Type() )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
{
|
|
|
|
|
case TYPETEXTEMODULE:
|
|
|
|
|
NewStruct = new TEXTE_MODULE( this );
|
|
|
|
|
( (TEXTE_MODULE*) NewStruct )->Copy( (TEXTE_MODULE*) OldStruct );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPEEDGEMODULE:
|
|
|
|
|
NewStruct = new EDGE_MODULE( this );
|
|
|
|
|
( (EDGE_MODULE*) NewStruct )->Copy( (EDGE_MODULE*) OldStruct );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
DisplayError( NULL, wxT( "Internal Err: CopyModule: type indefini" ) );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( NewStruct == NULL )
|
|
|
|
|
break;
|
|
|
|
|
if( m_Drawings == NULL )
|
|
|
|
|
{
|
|
|
|
|
NewStruct->Pback = this;
|
|
|
|
|
m_Drawings = NewStruct;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NewStruct->Pback = LastStruct;
|
|
|
|
|
LastStruct->Pnext = NewStruct;
|
|
|
|
|
}
|
|
|
|
|
LastStruct = NewStruct;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Copy des elements complementaires Drawings 3D */
|
|
|
|
|
m_3D_Drawings->Copy( Module->m_3D_Drawings );
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
Struct3D_Master* Struct3D, * NewStruct3D, * CurrStruct3D;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
Struct3D = (Struct3D_Master*) Module->m_3D_Drawings->Pnext;
|
|
|
|
|
CurrStruct3D = m_3D_Drawings;
|
|
|
|
|
for( ; Struct3D != NULL; Struct3D = (Struct3D_Master*) Struct3D->Pnext )
|
|
|
|
|
{
|
|
|
|
|
NewStruct3D = new Struct3D_Master( this );
|
|
|
|
|
NewStruct3D->Copy( Struct3D );
|
|
|
|
|
CurrStruct3D->Pnext = NewStruct3D;
|
|
|
|
|
NewStruct3D->Pback = CurrStruct3D;
|
|
|
|
|
CurrStruct3D = NewStruct3D;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Copie des elements complementaires */
|
|
|
|
|
m_Doc = Module->m_Doc;
|
|
|
|
|
m_KeyWord = Module->m_KeyWord;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* supprime du chainage la structure Struct
|
2007-08-06 02:02:39 +00:00
|
|
|
|
* les structures arrieres et avant sont chainees directement
|
2007-06-05 12:10:51 +00:00
|
|
|
|
*/
|
2007-09-01 12:00:30 +00:00
|
|
|
|
void MODULE::UnLink()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
/* Modification du chainage arriere */
|
|
|
|
|
if( Pback )
|
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
|
if( Pback->Type() != TYPEPCB )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
{
|
|
|
|
|
Pback->Pnext = Pnext;
|
|
|
|
|
}
|
|
|
|
|
else /* Le chainage arriere pointe sur la structure "Pere" */
|
|
|
|
|
{
|
|
|
|
|
if( GetState( DELETED ) ) // A REVOIR car Pback = NULL si place en undelete
|
|
|
|
|
{
|
2007-11-05 07:07:00 +00:00
|
|
|
|
if( g_UnDeleteStackPtr )
|
2007-09-01 12:00:30 +00:00
|
|
|
|
g_UnDeleteStack[g_UnDeleteStackPtr - 1] = Next();
|
2007-08-06 02:02:39 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
( (BOARD*) Pback )->m_Modules = (MODULE*) Pnext;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Modification du chainage avant */
|
|
|
|
|
if( Pnext )
|
|
|
|
|
Pnext->Pback = Pback;
|
|
|
|
|
|
|
|
|
|
Pnext = Pback = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
2008-04-01 05:21:50 +00:00
|
|
|
|
int draw_mode, const wxPoint& offset )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**********************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2008-03-13 21:18:05 +00:00
|
|
|
|
/** Function Draw
|
|
|
|
|
* Draws the footprint to the current Device Context
|
|
|
|
|
* @param panel = The active Draw Panel (used to know the clip box)
|
|
|
|
|
* @param DC = current Device Context
|
|
|
|
|
* @param offset = draw offset (usually wxPoint(0,0)
|
|
|
|
|
* @param draw_mode = GR_OR, GR_XOR, GR_AND
|
2007-08-06 02:02:39 +00:00
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-03-15 10:24:32 +00:00
|
|
|
|
if( (m_Flags & DO_NOT_DRAW) )
|
|
|
|
|
return;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2008-03-13 21:18:05 +00:00
|
|
|
|
/* Draw pads */
|
2008-04-01 05:21:50 +00:00
|
|
|
|
D_PAD* pt_pad = m_Pads;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
|
|
|
|
|
{
|
|
|
|
|
if( pt_pad->m_Flags & IS_MOVED )
|
|
|
|
|
continue;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
pt_pad->Draw( panel, DC, draw_mode, offset );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
|
// Draws foootprint anchor
|
2007-08-06 02:02:39 +00:00
|
|
|
|
DrawAncre( panel, DC, offset, DIM_ANCRE_MODULE, draw_mode );
|
|
|
|
|
|
2008-03-13 21:18:05 +00:00
|
|
|
|
/* Draw graphic items */
|
2007-08-06 02:02:39 +00:00
|
|
|
|
if( !(m_Reference->m_Flags & IS_MOVED) )
|
2008-04-01 05:21:50 +00:00
|
|
|
|
m_Reference->Draw( panel, DC, draw_mode, offset );
|
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
if( !(m_Value->m_Flags & IS_MOVED) )
|
2008-04-01 05:21:50 +00:00
|
|
|
|
m_Value->Draw( panel, DC, draw_mode, offset );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
|
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
|
if( item->m_Flags & IS_MOVED )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
|
switch( item->Type() )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
{
|
|
|
|
|
case TYPETEXTEMODULE:
|
|
|
|
|
case TYPEEDGEMODULE:
|
2008-04-01 05:21:50 +00:00
|
|
|
|
item->Draw( panel, DC, draw_mode, offset );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
|
|
|
|
|
const wxPoint& offset, int draw_mode )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************************/
|
2008-03-15 10:24:32 +00:00
|
|
|
|
|
2008-03-13 21:18:05 +00:00
|
|
|
|
/** Function DrawEdgesOnly
|
|
|
|
|
* Draws the footprint edges only to the current Device Context
|
|
|
|
|
* @param panel = The active Draw Panel (used to know the clip box)
|
|
|
|
|
* @param DC = current Device Context
|
|
|
|
|
* @param offset = draw offset (usually wxPoint(0,0)
|
|
|
|
|
* @param draw_mode = GR_OR, GR_XOR, GR_AND
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
|
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
|
switch( item->Type() )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
{
|
|
|
|
|
case TYPEEDGEMODULE:
|
2008-04-01 05:21:50 +00:00
|
|
|
|
item->Draw( panel, DC, draw_mode, offset );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-07-13 10:04:00 +00:00
|
|
|
|
/**************************************/
|
2007-10-30 21:30:58 +00:00
|
|
|
|
bool MODULE::Save( FILE* aFile ) const
|
2008-07-13 10:04:00 +00:00
|
|
|
|
/**************************************/
|
2007-10-30 21:30:58 +00:00
|
|
|
|
{
|
2008-03-15 10:24:32 +00:00
|
|
|
|
char statusTxt[8];
|
|
|
|
|
BOARD_ITEM* item;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
|
if( GetState( DELETED ) )
|
|
|
|
|
return true;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
|
bool rc = false;
|
|
|
|
|
|
|
|
|
|
fprintf( aFile, "$MODULE %s\n", CONV_TO_UTF8( m_LibRef ) );
|
|
|
|
|
|
|
|
|
|
// Generation des coord et caracteristiques
|
|
|
|
|
memset( statusTxt, 0, sizeof(statusTxt) );
|
|
|
|
|
if( IsLocked() )
|
|
|
|
|
statusTxt[0] = 'F';
|
|
|
|
|
else
|
|
|
|
|
statusTxt[0] = '~';
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
|
if( m_ModuleStatus & MODULE_is_PLACED )
|
|
|
|
|
statusTxt[1] = 'P';
|
|
|
|
|
else
|
|
|
|
|
statusTxt[1] = '~';
|
|
|
|
|
|
|
|
|
|
fprintf( aFile, "Po %d %d %d %d %8.8lX %8.8lX %s\n",
|
2008-03-15 10:24:32 +00:00
|
|
|
|
m_Pos.x, m_Pos.y,
|
|
|
|
|
m_Orient, m_Layer, m_LastEdit_Time,
|
|
|
|
|
m_TimeStamp, statusTxt );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
|
|
|
|
|
fprintf( aFile, "Li %s\n", CONV_TO_UTF8( m_LibRef ) );
|
|
|
|
|
|
|
|
|
|
if( !m_Doc.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
fprintf( aFile, "Cd %s\n", CONV_TO_UTF8( m_Doc ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !m_KeyWord.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
fprintf( aFile, "Kw %s\n", CONV_TO_UTF8( m_KeyWord ) );
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
|
fprintf( aFile, "Sc %8.8lX\n", m_TimeStamp );
|
2008-03-15 10:24:32 +00:00
|
|
|
|
fprintf( aFile, "AR %s\n", CONV_TO_UTF8( m_Path ) );
|
2007-10-30 21:30:58 +00:00
|
|
|
|
fprintf( aFile, "Op %X %X 0\n", m_CntRot90, m_CntRot180 );
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
if( m_Attributs != MOD_DEFAULT )
|
|
|
|
|
{
|
|
|
|
|
fprintf( aFile, "At " );
|
|
|
|
|
if( m_Attributs & MOD_CMS )
|
|
|
|
|
fprintf( aFile, "SMD " );
|
|
|
|
|
if( m_Attributs & MOD_VIRTUAL )
|
|
|
|
|
fprintf( aFile, "VIRTUAL " );
|
|
|
|
|
fprintf( aFile, "\n" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// save reference
|
|
|
|
|
if( !m_Reference->Save( aFile ) )
|
|
|
|
|
goto out;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
|
// save value
|
|
|
|
|
if( !m_Value->Save( aFile ) )
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
// save drawing elements
|
2008-03-15 10:24:32 +00:00
|
|
|
|
for( item = m_Drawings; item; item = item->Next() )
|
2007-10-30 21:30:58 +00:00
|
|
|
|
{
|
|
|
|
|
switch( item->Type() )
|
|
|
|
|
{
|
|
|
|
|
case TYPETEXTEMODULE:
|
|
|
|
|
case TYPEEDGEMODULE:
|
|
|
|
|
if( !item->Save( aFile ) )
|
|
|
|
|
goto out;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2008-03-15 10:24:32 +00:00
|
|
|
|
#if defined (DEBUG)
|
2007-10-30 21:30:58 +00:00
|
|
|
|
printf( "MODULE::Save() ignoring type %d\n", item->Type() );
|
2008-02-19 00:30:10 +00:00
|
|
|
|
#endif
|
2007-10-30 21:30:58 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// save the pads
|
2008-03-15 10:24:32 +00:00
|
|
|
|
for( item = m_Pads; item; item = item->Next() )
|
2007-10-30 21:30:58 +00:00
|
|
|
|
if( !item->Save( aFile ) )
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
// Generation des informations de trac<61>3D
|
|
|
|
|
Write_3D_Descr( aFile );
|
|
|
|
|
|
|
|
|
|
fprintf( aFile, "$EndMODULE %s\n", CONV_TO_UTF8( m_LibRef ) );
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-10-30 21:30:58 +00:00
|
|
|
|
rc = true;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
out:
|
2007-10-30 21:30:58 +00:00
|
|
|
|
return rc;
|
|
|
|
|
}
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/***************************************/
|
2007-10-30 21:30:58 +00:00
|
|
|
|
int MODULE::Write_3D_Descr( FILE* File ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/***************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Sauvegarde de la description 3D du MODULE
|
2007-08-06 02:02:39 +00:00
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
char buf[512];
|
|
|
|
|
Struct3D_Master* Struct3D = m_3D_Drawings;
|
|
|
|
|
|
|
|
|
|
for( ; Struct3D != NULL; Struct3D = (Struct3D_Master*) Struct3D->Pnext )
|
|
|
|
|
{
|
|
|
|
|
if( !Struct3D->m_Shape3DName.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
fprintf( File, "$SHAPE3D\n" );
|
|
|
|
|
|
|
|
|
|
fprintf( File, "Na \"%s\"\n", CONV_TO_UTF8( Struct3D->m_Shape3DName ) );
|
|
|
|
|
|
|
|
|
|
sprintf( buf, "Sc %lf %lf %lf\n",
|
2008-03-15 10:24:32 +00:00
|
|
|
|
Struct3D->m_MatScale.x,
|
|
|
|
|
Struct3D->m_MatScale.y,
|
|
|
|
|
Struct3D->m_MatScale.z );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
fprintf( File, to_point( buf ) );
|
|
|
|
|
|
|
|
|
|
sprintf( buf, "Of %lf %lf %lf\n",
|
2008-03-15 10:24:32 +00:00
|
|
|
|
Struct3D->m_MatPosition.x,
|
|
|
|
|
Struct3D->m_MatPosition.y,
|
|
|
|
|
Struct3D->m_MatPosition.z );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
fprintf( File, to_point( buf ) );
|
|
|
|
|
|
|
|
|
|
sprintf( buf, "Ro %lf %lf %lf\n",
|
2008-03-15 10:24:32 +00:00
|
|
|
|
Struct3D->m_MatRotation.x,
|
|
|
|
|
Struct3D->m_MatRotation.y,
|
|
|
|
|
Struct3D->m_MatRotation.z );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
fprintf( File, to_point( buf ) );
|
|
|
|
|
|
|
|
|
|
fprintf( File, "$EndSHAPE3D\n" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/****************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
int MODULE::Read_3D_Descr( FILE* File, int* LineNum )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/****************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Lecture de la description d'un MODULE (format Ascii)
|
2007-08-06 02:02:39 +00:00
|
|
|
|
* la 1ere ligne de descr ($MODULE) est supposee etre deja lue
|
|
|
|
|
* retourne 0 si OK
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
char Line[1024];
|
|
|
|
|
char* text = Line + 3;
|
|
|
|
|
Struct3D_Master* Struct3D = m_3D_Drawings;
|
|
|
|
|
|
|
|
|
|
if( !Struct3D->m_Shape3DName.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
Struct3D_Master* NewStruct3D;
|
|
|
|
|
while( Struct3D->Pnext )
|
|
|
|
|
Struct3D = (Struct3D_Master*) Struct3D->Pnext;
|
|
|
|
|
|
|
|
|
|
Struct3D->Pnext = NewStruct3D = new Struct3D_Master( this );
|
|
|
|
|
NewStruct3D->Pback = Struct3D;
|
|
|
|
|
Struct3D = NewStruct3D;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while( GetLine( File, Line, LineNum, sizeof(Line) - 1 ) != NULL )
|
|
|
|
|
{
|
|
|
|
|
switch( Line[0] )
|
|
|
|
|
{
|
|
|
|
|
case '$': // Fin de description
|
|
|
|
|
if( Line[1] == 'E' )
|
|
|
|
|
return 0;
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
case 'N': // Shape File Name
|
|
|
|
|
{
|
|
|
|
|
char buf[512];
|
|
|
|
|
ReadDelimitedText( buf, text, 512 );
|
|
|
|
|
Struct3D->m_Shape3DName = CONV_FROM_UTF8( buf );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 'S': // Scale
|
|
|
|
|
sscanf( text, "%lf %lf %lf\n",
|
2008-03-15 10:24:32 +00:00
|
|
|
|
&Struct3D->m_MatScale.x,
|
|
|
|
|
&Struct3D->m_MatScale.y,
|
|
|
|
|
&Struct3D->m_MatScale.z );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'O': // Offset
|
|
|
|
|
sscanf( text, "%lf %lf %lf\n",
|
2008-03-15 10:24:32 +00:00
|
|
|
|
&Struct3D->m_MatPosition.x,
|
|
|
|
|
&Struct3D->m_MatPosition.y,
|
|
|
|
|
&Struct3D->m_MatPosition.z );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'R': // Rotation
|
|
|
|
|
sscanf( text, "%lf %lf %lf\n",
|
2008-03-15 10:24:32 +00:00
|
|
|
|
&Struct3D->m_MatRotation.x,
|
|
|
|
|
&Struct3D->m_MatRotation.y,
|
|
|
|
|
&Struct3D->m_MatRotation.z );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
int MODULE::ReadDescr( FILE* File, int* LineNum )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Lecture de la description d'un MODULE (format Ascii)
|
2007-08-06 02:02:39 +00:00
|
|
|
|
* la 1ere ligne de descr ($MODULE) est supposee etre deja lue
|
|
|
|
|
* retourne 0 si OK
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
D_PAD* LastPad = NULL, * ptpad;
|
|
|
|
|
EDA_BaseStruct* LastModStruct = NULL;
|
|
|
|
|
EDGE_MODULE* DrawSegm;
|
|
|
|
|
TEXTE_MODULE* DrawText;
|
2008-08-09 08:05:42 +00:00
|
|
|
|
char Line[256], BufLine[256], BufCar1[128], * PtLine;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
int itmp1, itmp2;
|
|
|
|
|
|
|
|
|
|
while( GetLine( File, Line, LineNum, sizeof(Line) - 1 ) != NULL )
|
|
|
|
|
{
|
|
|
|
|
if( Line[0] == '$' )
|
|
|
|
|
{
|
|
|
|
|
if( Line[1] == 'E' )
|
|
|
|
|
break;
|
|
|
|
|
if( Line[1] == 'P' )
|
|
|
|
|
{
|
|
|
|
|
ptpad = new D_PAD( this );
|
|
|
|
|
ptpad->ReadDescr( File, LineNum );
|
|
|
|
|
RotatePoint( &ptpad->m_Pos.x, &ptpad->m_Pos.y, m_Orient );
|
|
|
|
|
ptpad->m_Pos.x += m_Pos.x;
|
|
|
|
|
ptpad->m_Pos.y += m_Pos.y;
|
|
|
|
|
|
|
|
|
|
if( LastPad == NULL )
|
|
|
|
|
{
|
|
|
|
|
ptpad->Pback = (EDA_BaseStruct*) this;
|
|
|
|
|
m_Pads = ptpad;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ptpad->Pback = (EDA_BaseStruct*) LastPad;
|
|
|
|
|
LastPad->Pnext = (EDA_BaseStruct*) ptpad;
|
|
|
|
|
}
|
|
|
|
|
LastPad = ptpad;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if( Line[1] == 'S' )
|
|
|
|
|
Read_3D_Descr( File, LineNum );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( strlen( Line ) < 4 )
|
|
|
|
|
continue;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
PtLine = Line + 3;
|
|
|
|
|
|
|
|
|
|
/* Pointe 1er code utile de la ligne */
|
|
|
|
|
switch( Line[0] )
|
|
|
|
|
{
|
|
|
|
|
case 'P':
|
|
|
|
|
memset( BufCar1, 0, sizeof(BufCar1) );
|
|
|
|
|
sscanf( PtLine, "%d %d %d %d %lX %lX %s",
|
2008-03-15 10:24:32 +00:00
|
|
|
|
&m_Pos.x, &m_Pos.y,
|
|
|
|
|
&m_Orient, &m_Layer,
|
|
|
|
|
&m_LastEdit_Time, &m_TimeStamp, BufCar1 );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
|
|
m_ModuleStatus = 0;
|
|
|
|
|
if( BufCar1[0] == 'F' )
|
2008-03-15 10:24:32 +00:00
|
|
|
|
SetLocked( true );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
if( BufCar1[1] == 'P' )
|
|
|
|
|
m_ModuleStatus |= MODULE_is_PLACED;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'L': /* Li = Lecture du nom librairie du module */
|
|
|
|
|
*BufLine = 0;
|
|
|
|
|
sscanf( PtLine, " %s", BufLine );
|
|
|
|
|
m_LibRef = CONV_FROM_UTF8( BufLine );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'S':
|
|
|
|
|
sscanf( PtLine, " %lX", &m_TimeStamp );
|
|
|
|
|
break;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
|
|
case 'O': /* (Op)tions de placement auto */
|
|
|
|
|
itmp1 = itmp2 = 0;
|
|
|
|
|
sscanf( PtLine, " %X %X", &itmp1, &itmp2 );
|
|
|
|
|
|
|
|
|
|
m_CntRot180 = itmp2 & 0x0F;
|
|
|
|
|
if( m_CntRot180 > 10 )
|
|
|
|
|
m_CntRot180 = 10;
|
|
|
|
|
|
|
|
|
|
m_CntRot90 = itmp1 & 0x0F;
|
|
|
|
|
if( m_CntRot90 > 10 )
|
|
|
|
|
m_CntRot90 = 0;
|
|
|
|
|
itmp1 = (itmp1 >> 4) & 0x0F;
|
|
|
|
|
if( itmp1 > 10 )
|
|
|
|
|
itmp1 = 0;
|
|
|
|
|
m_CntRot90 |= itmp1 << 4;
|
|
|
|
|
break;
|
|
|
|
|
|
2008-02-19 00:30:10 +00:00
|
|
|
|
case 'A':
|
2008-03-15 10:24:32 +00:00
|
|
|
|
if( Line[1] == 't' )
|
|
|
|
|
{
|
2008-02-19 00:30:10 +00:00
|
|
|
|
/* At = (At)tributs du module */
|
|
|
|
|
if( strstr( PtLine, "SMD" ) )
|
|
|
|
|
m_Attributs |= MOD_CMS;
|
|
|
|
|
if( strstr( PtLine, "VIRTUAL" ) )
|
|
|
|
|
m_Attributs |= MOD_VIRTUAL;
|
|
|
|
|
}
|
2008-03-15 10:24:32 +00:00
|
|
|
|
if( Line[1] == 'R' )
|
|
|
|
|
{
|
2008-02-19 00:30:10 +00:00
|
|
|
|
//alternate reference, e.g. /478C2408/478AD1B6
|
|
|
|
|
sscanf( PtLine, " %s", BufLine );
|
2008-03-15 10:24:32 +00:00
|
|
|
|
m_Path = CONV_FROM_UTF8( BufLine );
|
2008-02-19 00:30:10 +00:00
|
|
|
|
}
|
2007-08-06 02:02:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2008-08-09 08:05:42 +00:00
|
|
|
|
case 'T': /* Read a footprint text description (ref, value, or drawing */
|
2007-08-06 02:02:39 +00:00
|
|
|
|
sscanf( Line + 1, "%d", &itmp1 );
|
|
|
|
|
if( itmp1 == TEXT_is_REFERENCE )
|
|
|
|
|
DrawText = m_Reference;
|
|
|
|
|
else if( itmp1 == TEXT_is_VALUE )
|
|
|
|
|
DrawText = m_Value;
|
|
|
|
|
else /* text is a drawing */
|
|
|
|
|
{
|
|
|
|
|
DrawText = new TEXTE_MODULE( this );
|
|
|
|
|
if( LastModStruct == NULL )
|
|
|
|
|
{
|
|
|
|
|
DrawText->Pback = this;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
m_Drawings = DrawText;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DrawText->Pback = LastModStruct;
|
|
|
|
|
LastModStruct->Pnext = DrawText;
|
|
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
|
LastModStruct = DrawText;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-08-09 08:05:42 +00:00
|
|
|
|
DrawText->ReadDescr( Line, File, LineNum );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'D': /* lecture du contour */
|
|
|
|
|
DrawSegm = new EDGE_MODULE( this );
|
|
|
|
|
|
|
|
|
|
if( LastModStruct == NULL )
|
|
|
|
|
{
|
|
|
|
|
DrawSegm->Pback = this;
|
|
|
|
|
m_Drawings = DrawSegm;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DrawSegm->Pback = LastModStruct;
|
|
|
|
|
LastModStruct->Pnext = DrawSegm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LastModStruct = DrawSegm;
|
|
|
|
|
DrawSegm->ReadDescr( Line, File, LineNum );
|
|
|
|
|
DrawSegm->SetDrawCoord();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'C': /* Lecture de la doc */
|
|
|
|
|
m_Doc = CONV_FROM_UTF8( StrPurge( PtLine ) );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'K': /* Lecture de la liste des mots cle */
|
|
|
|
|
m_KeyWord = CONV_FROM_UTF8( StrPurge( PtLine ) );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-10 08:14:20 +00:00
|
|
|
|
/* Recalculate the bounding box */
|
2007-08-06 02:02:39 +00:00
|
|
|
|
Set_Rectangle_Encadrement();
|
|
|
|
|
return 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2008-03-10 08:14:20 +00:00
|
|
|
|
/*************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
void MODULE::SetPosition( const wxPoint& newpos )
|
2008-03-10 08:14:20 +00:00
|
|
|
|
/*************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
// replace le module en position newpos
|
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
int deltaX = newpos.x - m_Pos.x;
|
|
|
|
|
int deltaY = newpos.y - m_Pos.y;
|
|
|
|
|
|
|
|
|
|
/* deplacement de l'ancre */
|
2008-02-19 00:30:10 +00:00
|
|
|
|
m_Pos.x += deltaX;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
m_Pos.y += deltaY;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
|
|
/* deplacement de la reference */
|
2008-02-19 00:30:10 +00:00
|
|
|
|
m_Reference->m_Pos.x += deltaX;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
m_Reference->m_Pos.y += deltaY;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
|
|
/* deplacement de la Valeur */
|
2008-02-19 00:30:10 +00:00
|
|
|
|
m_Value->m_Pos.x += deltaX;
|
2007-08-06 20:26:59 +00:00
|
|
|
|
m_Value->m_Pos.y += deltaY;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
|
|
/* deplacement des pastilles */
|
|
|
|
|
D_PAD* pad = m_Pads;
|
|
|
|
|
for( ; pad != NULL; pad = (D_PAD*) pad->Pnext )
|
|
|
|
|
{
|
2008-02-19 00:30:10 +00:00
|
|
|
|
pad->m_Pos.x += deltaX;
|
2007-08-09 21:15:08 +00:00
|
|
|
|
pad->m_Pos.y += deltaY;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* deplacement des dessins de l'empreinte : */
|
|
|
|
|
EDA_BaseStruct* PtStruct = m_Drawings;
|
|
|
|
|
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
|
switch( PtStruct->Type() )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
{
|
|
|
|
|
case TYPEEDGEMODULE:
|
|
|
|
|
{
|
|
|
|
|
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct;
|
|
|
|
|
pt_edgmod->SetDrawCoord();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case TYPETEXTEMODULE:
|
|
|
|
|
{
|
|
|
|
|
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
pt_texte->m_Pos.x += deltaX;
|
2007-08-09 21:15:08 +00:00
|
|
|
|
pt_texte->m_Pos.y += deltaY;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
DisplayError( NULL, wxT( "Type Draw Indefini" ) ); break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Set_Rectangle_Encadrement();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
void MODULE::SetOrientation( int newangle )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*********************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Tourne de newangle (en 0.1 degres) le module
|
2007-08-06 02:02:39 +00:00
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
int px, py;
|
|
|
|
|
|
|
|
|
|
newangle -= m_Orient; // = delta de rotation
|
|
|
|
|
|
|
|
|
|
m_Orient += newangle;
|
|
|
|
|
NORMALIZE_ANGLE_POS( m_Orient );
|
|
|
|
|
|
|
|
|
|
/* deplacement et rotation des pastilles */
|
|
|
|
|
D_PAD* pad = m_Pads;
|
|
|
|
|
for( ; pad != NULL; pad = (D_PAD*) pad->Pnext )
|
|
|
|
|
{
|
|
|
|
|
px = pad->m_Pos0.x;
|
|
|
|
|
py = pad->m_Pos0.y;
|
|
|
|
|
|
|
|
|
|
pad->m_Orient += newangle; /* change m_Orientation */
|
|
|
|
|
NORMALIZE_ANGLE_POS( pad->m_Orient );
|
|
|
|
|
|
|
|
|
|
RotatePoint( &px, &py, (int) m_Orient );
|
|
|
|
|
pad->m_Pos.x = m_Pos.x + px;
|
|
|
|
|
pad->m_Pos.y = m_Pos.y + py;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* mise a jour de la reference et de la valeur*/
|
|
|
|
|
m_Reference->SetDrawCoord();
|
|
|
|
|
m_Value->SetDrawCoord();
|
|
|
|
|
|
|
|
|
|
/* deplacement des contours et textes de l'empreinte : */
|
|
|
|
|
EDA_BaseStruct* PtStruct = m_Drawings;
|
|
|
|
|
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
|
if( PtStruct->Type() == TYPEEDGEMODULE )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
{
|
|
|
|
|
EDGE_MODULE* pt_edgmod = (EDGE_MODULE*) PtStruct;
|
|
|
|
|
pt_edgmod->SetDrawCoord();
|
|
|
|
|
}
|
2007-09-01 12:00:30 +00:00
|
|
|
|
if( PtStruct->Type() == TYPETEXTEMODULE )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
{
|
|
|
|
|
/* deplacement des inscriptions : */
|
|
|
|
|
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) PtStruct;
|
|
|
|
|
pt_texte->SetDrawCoord();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Recalcul du rectangle d'encadrement */
|
|
|
|
|
Set_Rectangle_Encadrement();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/************************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
|
void MODULE::Set_Rectangle_Encadrement()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/************************************************/
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Mise a jour du rectangle d'encadrement du module
|
2007-08-06 02:02:39 +00:00
|
|
|
|
* Entree : pointeur sur module
|
|
|
|
|
* Le rectangle d'encadrement est le rectangle comprenant les contours et les
|
|
|
|
|
* pads.
|
|
|
|
|
* Le rectangle est calcule:
|
|
|
|
|
* pour orient 0
|
|
|
|
|
* en coord relatives / position ancre
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
EDGE_MODULE* pt_edge_mod;
|
|
|
|
|
D_PAD* pad;
|
|
|
|
|
int width;
|
|
|
|
|
int cx, cy, uxf, uyf, rayon;
|
|
|
|
|
int xmax, ymax;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Init des pointeurs */
|
|
|
|
|
pt_edge_mod = (EDGE_MODULE*) m_Drawings;
|
|
|
|
|
|
|
|
|
|
/* Init des coord du cadre a une valeur limite non nulle */
|
|
|
|
|
m_BoundaryBox.m_Pos.x = -500; xmax = 500;
|
|
|
|
|
m_BoundaryBox.m_Pos.y = -500; ymax = 500;
|
|
|
|
|
|
|
|
|
|
/* Contours: Recherche des coord min et max et mise a jour du cadre */
|
|
|
|
|
for( ; pt_edge_mod != NULL; pt_edge_mod = (EDGE_MODULE*) pt_edge_mod->Pnext )
|
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
|
if( pt_edge_mod->Type() != TYPEEDGEMODULE )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
continue;
|
|
|
|
|
width = pt_edge_mod->m_Width / 2;
|
|
|
|
|
|
|
|
|
|
switch( pt_edge_mod->m_Shape )
|
|
|
|
|
{
|
|
|
|
|
case S_ARC:
|
|
|
|
|
case S_CIRCLE:
|
|
|
|
|
{
|
|
|
|
|
cx = pt_edge_mod->m_Start0.x; cy = pt_edge_mod->m_Start0.y; // centre
|
|
|
|
|
uxf = pt_edge_mod->m_End0.x; uyf = pt_edge_mod->m_End0.y;
|
|
|
|
|
rayon = (int) hypot( (double) (cx - uxf), (double) (cy - uyf) );
|
|
|
|
|
rayon += width;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x, cx - rayon );
|
|
|
|
|
m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y, cy - rayon );
|
|
|
|
|
xmax = MAX( xmax, cx + rayon );
|
|
|
|
|
ymax = MAX( ymax, cy + rayon );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
2007-08-23 04:28:46 +00:00
|
|
|
|
m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x, pt_edge_mod->m_Start0.x - width );
|
|
|
|
|
m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x, pt_edge_mod->m_End0.x - width );
|
|
|
|
|
m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y, pt_edge_mod->m_Start0.y - width );
|
|
|
|
|
m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y, pt_edge_mod->m_End0.y - width );
|
|
|
|
|
xmax = MAX( xmax, pt_edge_mod->m_Start0.x + width );
|
|
|
|
|
xmax = MAX( xmax, pt_edge_mod->m_End0.x + width );
|
|
|
|
|
ymax = MAX( ymax, pt_edge_mod->m_Start0.y + width );
|
|
|
|
|
ymax = MAX( ymax, pt_edge_mod->m_End0.y + width );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pads: Recherche des coord min et max et mise a jour du cadre */
|
|
|
|
|
for( pad = m_Pads; pad != NULL; pad = (D_PAD*) pad->Pnext )
|
|
|
|
|
{
|
|
|
|
|
rayon = pad->m_Rayon;
|
|
|
|
|
cx = pad->m_Pos0.x; cy = pad->m_Pos0.y;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x, cx - rayon );
|
|
|
|
|
m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y, cy - rayon );
|
|
|
|
|
xmax = MAX( xmax, cx + rayon );
|
|
|
|
|
ymax = MAX( ymax, cy + rayon );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_BoundaryBox.SetWidth( xmax - m_BoundaryBox.m_Pos.x );
|
|
|
|
|
m_BoundaryBox.SetHeight( ymax - m_BoundaryBox.m_Pos.y );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
|
void MODULE::SetRectangleExinscrit()
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/****************************************/
|
|
|
|
|
|
|
|
|
|
/* Analogue a MODULE::Set_Rectangle_Encadrement() mais en coord reelles:
|
2007-08-06 02:02:39 +00:00
|
|
|
|
* Mise a jour du rectangle d'encadrement reel du module c.a.d en coord PCB
|
|
|
|
|
* Entree : pointeur sur module
|
|
|
|
|
* Le rectangle d'encadrement est le rectangle comprenant les contours et les
|
|
|
|
|
* pads.
|
|
|
|
|
* Met egalement a jour la surface (.m_Surface) du module.
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
EDGE_MODULE* EdgeMod;
|
|
|
|
|
D_PAD* Pad;
|
|
|
|
|
int width;
|
|
|
|
|
int cx, cy, uxf, uyf, rayon;
|
|
|
|
|
int xmax, ymax;
|
|
|
|
|
|
|
|
|
|
m_RealBoundaryBox.m_Pos.x = xmax = m_Pos.x;
|
|
|
|
|
m_RealBoundaryBox.m_Pos.y = ymax = m_Pos.y;
|
|
|
|
|
|
|
|
|
|
/* Contours: Recherche des coord min et max et mise a jour du cadre */
|
|
|
|
|
EdgeMod = (EDGE_MODULE*) m_Drawings;
|
|
|
|
|
for( ; EdgeMod != NULL; EdgeMod = (EDGE_MODULE*) EdgeMod->Pnext )
|
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
|
if( EdgeMod->Type() != TYPEEDGEMODULE )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
continue;
|
|
|
|
|
width = EdgeMod->m_Width / 2;
|
|
|
|
|
|
|
|
|
|
switch( EdgeMod->m_Shape )
|
|
|
|
|
{
|
|
|
|
|
case S_ARC:
|
|
|
|
|
case S_CIRCLE:
|
|
|
|
|
{
|
|
|
|
|
cx = EdgeMod->m_Start.x; cy = EdgeMod->m_Start.y; // centre
|
|
|
|
|
uxf = EdgeMod->m_End.x; uyf = EdgeMod->m_End.y;
|
|
|
|
|
rayon = (int) hypot( (double) (cx - uxf), (double) (cy - uyf) );
|
|
|
|
|
rayon += width;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, cx - rayon );
|
|
|
|
|
m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y, cy - rayon );
|
|
|
|
|
xmax = MAX( xmax, cx + rayon );
|
|
|
|
|
ymax = MAX( ymax, cy + rayon );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
2007-08-23 04:28:46 +00:00
|
|
|
|
m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, EdgeMod->m_Start.x - width );
|
|
|
|
|
m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, EdgeMod->m_End.x - width );
|
|
|
|
|
m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y, EdgeMod->m_Start.y - width );
|
|
|
|
|
m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y, EdgeMod->m_End.y - width );
|
|
|
|
|
xmax = MAX( xmax, EdgeMod->m_Start.x + width );
|
|
|
|
|
xmax = MAX( xmax, EdgeMod->m_End.x + width );
|
|
|
|
|
ymax = MAX( ymax, EdgeMod->m_Start.y + width );
|
|
|
|
|
ymax = MAX( ymax, EdgeMod->m_End.y + width );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pads: Recherche des coord min et max et mise a jour du cadre */
|
|
|
|
|
for( Pad = m_Pads; Pad != NULL; Pad = (D_PAD*) Pad->Pnext )
|
|
|
|
|
{
|
|
|
|
|
rayon = Pad->m_Rayon;
|
|
|
|
|
cx = Pad->m_Pos.x; cy = Pad->m_Pos.y;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, cx - rayon );
|
|
|
|
|
m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y, cy - rayon );
|
|
|
|
|
xmax = MAX( xmax, cx + rayon );
|
|
|
|
|
ymax = MAX( ymax, cy + rayon );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_RealBoundaryBox.SetWidth( xmax - m_RealBoundaryBox.m_Pos.x );
|
|
|
|
|
m_RealBoundaryBox.SetHeight( ymax - m_RealBoundaryBox.m_Pos.y );
|
|
|
|
|
m_Surface = ABS( (float) m_RealBoundaryBox.GetWidth() * m_RealBoundaryBox.GetHeight() );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-13 10:08:42 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function GetBoundingBox
|
2008-03-13 21:18:05 +00:00
|
|
|
|
* returns the full bounding box of this Footprint, including texts
|
2008-03-18 11:53:52 +00:00
|
|
|
|
* Mainly used to redraw the screen area occuped by the footprint
|
2008-03-13 10:08:42 +00:00
|
|
|
|
*/
|
|
|
|
|
EDA_Rect MODULE::GetBoundingBox()
|
|
|
|
|
{
|
2008-03-15 10:24:32 +00:00
|
|
|
|
// Calculate area without text fields:
|
|
|
|
|
SetRectangleExinscrit();
|
|
|
|
|
EDA_Rect area = m_RealBoundaryBox;
|
|
|
|
|
|
|
|
|
|
// Calculate extended area including text field:
|
|
|
|
|
EDA_Rect text_area;
|
|
|
|
|
text_area = m_Reference->GetBoundingBox();
|
|
|
|
|
area.Merge( text_area );
|
|
|
|
|
|
|
|
|
|
text_area = m_Value->GetBoundingBox();
|
|
|
|
|
area.Merge( text_area );
|
2008-03-13 21:18:05 +00:00
|
|
|
|
|
|
|
|
|
EDGE_MODULE* EdgeMod = (EDGE_MODULE*) m_Drawings;
|
2008-03-15 10:24:32 +00:00
|
|
|
|
for( ; EdgeMod != NULL; EdgeMod = (EDGE_MODULE*) EdgeMod->Pnext )
|
2008-03-13 21:18:05 +00:00
|
|
|
|
{
|
2008-03-15 10:24:32 +00:00
|
|
|
|
if( EdgeMod->Type() != TYPETEXTEMODULE )
|
|
|
|
|
continue;
|
|
|
|
|
text_area = ((TEXTE_MODULE*)EdgeMod)->GetBoundingBox();
|
|
|
|
|
area.Merge( text_area );
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
|
// Add the Clearence shape size: (shape around the pads when the clearence is shown
|
|
|
|
|
// Not optimized, but the draw cost is small (perhaps smaller than optimization)
|
|
|
|
|
area.Inflate(g_DesignSettings.m_TrackClearence, g_DesignSettings.m_TrackClearence);
|
2008-03-18 11:53:52 +00:00
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
|
return area;
|
2008-03-13 10:08:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*******************************************************/
|
2007-08-30 22:20:52 +00:00
|
|
|
|
void MODULE::Display_Infos( WinEDA_DrawFrame* frame )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*******************************************************/
|
|
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
|
int nbpad;
|
|
|
|
|
char bufcar[512], Line[512];
|
|
|
|
|
int pos;
|
|
|
|
|
bool flag = FALSE;
|
|
|
|
|
wxString msg;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
BOARD* board = (BOARD*) m_Parent;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
|
|
frame->MsgPanel->EraseMsgBox(); /* Effacement de la zone message */
|
|
|
|
|
if( frame->m_Ident != PCB_FRAME )
|
|
|
|
|
flag = TRUE;
|
|
|
|
|
pos = 1;
|
|
|
|
|
Affiche_1_Parametre( frame, pos, m_Reference->m_Text, m_Value->m_Text, DARKCYAN );
|
|
|
|
|
|
|
|
|
|
/* Affiche signature temporelle ou date de modif (en edition de modules) */
|
2008-02-12 21:12:46 +00:00
|
|
|
|
pos += 6;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
if( flag ) // Affichage date de modification (utile en Module Editor)
|
|
|
|
|
{
|
2008-10-29 15:26:53 +00:00
|
|
|
|
time_t edit_time = m_LastEdit_Time;
|
|
|
|
|
strcpy( Line, ctime( &edit_time ) );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
strtok( Line, " \n\r" );
|
|
|
|
|
strcpy( bufcar, strtok( NULL, " \n\r" ) ); strcat( bufcar, " " );
|
|
|
|
|
strcat( bufcar, strtok( NULL, " \n\r" ) ); strcat( bufcar, ", " );
|
|
|
|
|
strtok( NULL, " \n\r" );
|
|
|
|
|
strcat( bufcar, strtok( NULL, " \n\r" ) );
|
|
|
|
|
msg = CONV_FROM_UTF8( bufcar );
|
|
|
|
|
Affiche_1_Parametre( frame, pos, _( "Last Change" ), msg, BROWN );
|
|
|
|
|
pos += 4;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
msg.Printf( wxT( "%8.8lX" ), m_TimeStamp );
|
2008-03-15 10:24:32 +00:00
|
|
|
|
Affiche_1_Parametre( frame, pos, _( "Netlist path" ), /*msg*/ m_Path, BROWN );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
pos += 12;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
Affiche_1_Parametre( frame, pos, _( "Layer" ), board->GetLayerName( m_Layer ), RED );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
|
|
pos += 6;
|
|
|
|
|
EDA_BaseStruct* PtStruct = m_Pads;
|
|
|
|
|
nbpad = 0;
|
|
|
|
|
while( PtStruct )
|
|
|
|
|
{
|
2008-02-19 00:30:10 +00:00
|
|
|
|
nbpad++;
|
|
|
|
|
PtStruct = PtStruct->Pnext;
|
2007-08-06 02:02:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
msg.Printf( wxT( "%d" ), nbpad );
|
|
|
|
|
Affiche_1_Parametre( frame, pos, _( "Pads" ), msg, BLUE );
|
|
|
|
|
|
|
|
|
|
pos += 4;
|
|
|
|
|
msg = wxT( ".." );
|
2007-09-09 02:27:56 +00:00
|
|
|
|
if( IsLocked() )
|
2007-09-21 10:38:50 +00:00
|
|
|
|
msg[0] = 'L';
|
2007-08-06 02:02:39 +00:00
|
|
|
|
if( m_ModuleStatus & MODULE_is_PLACED )
|
|
|
|
|
msg[1] = 'P';
|
|
|
|
|
Affiche_1_Parametre( frame, pos, _( "Stat" ), msg, MAGENTA );
|
|
|
|
|
|
|
|
|
|
pos += 4;
|
|
|
|
|
msg.Printf( wxT( "%.1f" ), (float) m_Orient / 10 );
|
|
|
|
|
Affiche_1_Parametre( frame, pos, _( "Orient" ), msg, BROWN );
|
|
|
|
|
|
|
|
|
|
pos += 5;
|
|
|
|
|
Affiche_1_Parametre( frame, pos, _( "Module" ), m_LibRef, BLUE );
|
|
|
|
|
|
|
|
|
|
pos += 9;
|
|
|
|
|
Affiche_1_Parametre( frame, pos, _( "3D-Shape" ),
|
2008-03-15 10:24:32 +00:00
|
|
|
|
m_3D_Drawings->m_Shape3DName, RED );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
|
|
pos += 14;
|
|
|
|
|
wxString doc = _( "Doc: " ) + m_Doc;
|
|
|
|
|
wxString keyword = _( "KeyW: " ) + m_KeyWord;
|
|
|
|
|
Affiche_1_Parametre( frame, pos, doc, keyword, BLACK );
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function HitTest
|
|
|
|
|
* tests if the given wxPoint is within the bounds of this object.
|
|
|
|
|
* @param refPos A wxPoint to test
|
|
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
|
*/
|
|
|
|
|
bool MODULE::HitTest( const wxPoint& refPos )
|
|
|
|
|
{
|
|
|
|
|
/* Calcul des coord souris dans le repere module */
|
|
|
|
|
int spot_cX = refPos.x - m_Pos.x;
|
|
|
|
|
int spot_cY = refPos.y - m_Pos.y;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
RotatePoint( &spot_cX, &spot_cY, -m_Orient );
|
|
|
|
|
|
|
|
|
|
/* la souris est-elle dans ce rectangle : */
|
|
|
|
|
if( m_BoundaryBox.Inside( spot_cX, spot_cY ) )
|
|
|
|
|
return true;
|
2007-09-09 02:27:56 +00:00
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-01-06 12:43:57 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function HitTest (overlayed)
|
|
|
|
|
* tests if the given EDA_Rect intersect the bounds of this object.
|
|
|
|
|
* @param refArea : the given EDA_Rect
|
|
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
|
*/
|
2008-03-15 10:24:32 +00:00
|
|
|
|
bool MODULE::HitTest( EDA_Rect& refArea )
|
2008-01-06 12:43:57 +00:00
|
|
|
|
{
|
|
|
|
|
bool is_out_of_box = false;
|
|
|
|
|
|
|
|
|
|
SetRectangleExinscrit();
|
|
|
|
|
|
|
|
|
|
if( m_RealBoundaryBox.m_Pos.x < refArea.GetX() )
|
|
|
|
|
is_out_of_box = true;
|
|
|
|
|
if( m_RealBoundaryBox.m_Pos.y < refArea.GetY() )
|
|
|
|
|
is_out_of_box = true;
|
|
|
|
|
if( m_RealBoundaryBox.GetRight() > refArea.GetRight() )
|
|
|
|
|
is_out_of_box = true;
|
|
|
|
|
if( m_RealBoundaryBox.GetBottom() > refArea.GetBottom() )
|
|
|
|
|
is_out_of_box = true;
|
|
|
|
|
|
|
|
|
|
return is_out_of_box ? false : true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
|
D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
|
|
|
|
|
{
|
|
|
|
|
wxString buf;
|
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
|
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
|
2008-03-04 04:22:27 +00:00
|
|
|
|
{
|
|
|
|
|
pad->ReturnStringPadName( buf );
|
|
|
|
|
#if 1
|
|
|
|
|
if( buf.CmpNoCase( aPadName ) == 0 ) // why case insensitive?
|
|
|
|
|
#else
|
|
|
|
|
if( buf == aPadName )
|
|
|
|
|
#endif
|
2008-03-15 10:24:32 +00:00
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
|
return pad;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-19 00:30:10 +00:00
|
|
|
|
// see class_module.h
|
|
|
|
|
SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
|
2008-03-15 10:24:32 +00:00
|
|
|
|
const KICAD_T scanTypes[] )
|
2007-08-09 21:15:08 +00:00
|
|
|
|
{
|
2008-03-15 10:24:32 +00:00
|
|
|
|
KICAD_T stype;
|
|
|
|
|
SEARCH_RESULT result = SEARCH_CONTINUE;
|
|
|
|
|
const KICAD_T* p = scanTypes;
|
|
|
|
|
bool done = false;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
|
#if 0 && defined (DEBUG)
|
|
|
|
|
std::cout << GetClass().mb_str() << ' ';
|
2008-02-19 00:30:10 +00:00
|
|
|
|
#endif
|
2007-08-09 21:15:08 +00:00
|
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
|
while( !done )
|
2007-08-09 21:15:08 +00:00
|
|
|
|
{
|
2007-08-24 03:40:04 +00:00
|
|
|
|
stype = *p;
|
2008-03-15 10:24:32 +00:00
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
switch( stype )
|
|
|
|
|
{
|
|
|
|
|
case TYPEMODULE:
|
|
|
|
|
result = inspector->Inspect( this, testData ); // inspect me
|
2007-08-24 03:40:04 +00:00
|
|
|
|
++p;
|
2007-08-09 21:15:08 +00:00
|
|
|
|
break;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
case TYPEPAD:
|
2007-08-24 03:40:04 +00:00
|
|
|
|
result = IterateForward( m_Pads, inspector, testData, p );
|
|
|
|
|
++p;
|
2007-08-09 21:15:08 +00:00
|
|
|
|
break;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
case TYPETEXTEMODULE:
|
|
|
|
|
result = inspector->Inspect( m_Reference, testData );
|
|
|
|
|
if( result == SEARCH_QUIT )
|
|
|
|
|
break;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
result = inspector->Inspect( m_Value, testData );
|
|
|
|
|
if( result == SEARCH_QUIT )
|
|
|
|
|
break;
|
|
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
|
// m_Drawings can hold TYPETEXTMODULE also, so fall thru
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
case TYPEEDGEMODULE:
|
2007-08-24 03:40:04 +00:00
|
|
|
|
result = IterateForward( m_Drawings, inspector, testData, p );
|
2008-03-15 10:24:32 +00:00
|
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
|
// skip over any types handled in the above call.
|
2008-03-15 10:24:32 +00:00
|
|
|
|
for( ; ; )
|
2007-08-24 03:40:04 +00:00
|
|
|
|
{
|
|
|
|
|
switch( stype = *++p )
|
|
|
|
|
{
|
|
|
|
|
case TYPETEXTEMODULE:
|
|
|
|
|
case TYPEEDGEMODULE:
|
|
|
|
|
continue;
|
2008-03-15 10:24:32 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
;
|
2007-08-24 03:40:04 +00:00
|
|
|
|
}
|
2008-03-15 10:24:32 +00:00
|
|
|
|
|
2007-08-24 03:40:04 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2008-03-15 10:24:32 +00:00
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
break;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
default:
|
2007-08-24 03:40:04 +00:00
|
|
|
|
done = true;
|
2007-08-09 21:15:08 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-09 21:15:08 +00:00
|
|
|
|
if( result == SEARCH_QUIT )
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-19 00:30:10 +00:00
|
|
|
|
return result;
|
2007-08-09 21:15:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
|
#if defined (DEBUG)
|
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function Show
|
|
|
|
|
* is used to output the object tree, currently for debugging only.
|
2008-02-19 00:30:10 +00:00
|
|
|
|
* @param nestLevel An aid to prettier tree indenting, and is the level
|
2007-08-06 02:02:39 +00:00
|
|
|
|
* of nesting of this object within the overall tree.
|
|
|
|
|
* @param os The ostream& to output to.
|
|
|
|
|
*/
|
|
|
|
|
void MODULE::Show( int nestLevel, std::ostream& os )
|
|
|
|
|
{
|
2008-03-15 10:24:32 +00:00
|
|
|
|
BOARD* board = (BOARD*) m_Parent;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
// for now, make it look like XML, expand on this later.
|
2007-08-07 06:21:19 +00:00
|
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
|
2008-03-15 10:24:32 +00:00
|
|
|
|
" ref=\"" << m_Reference->m_Text.mb_str() << '"' <<
|
|
|
|
|
" value=\"" << m_Value->m_Text.mb_str() << '"' <<
|
|
|
|
|
" layer=\"" << board->GetLayerName( m_Layer ).mb_str() << '"' <<
|
|
|
|
|
">\n";
|
2007-08-30 22:20:52 +00:00
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
|
NestedSpace( nestLevel + 1, os ) <<
|
|
|
|
|
"<boundingBox" << m_BoundaryBox.m_Pos << m_BoundaryBox.m_Size << "/>\n";
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
|
NestedSpace( nestLevel + 1, os ) << "<orientation tenths=\"" << m_Orient << "\"/>\n";
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-08 03:50:44 +00:00
|
|
|
|
EDA_BaseStruct* p;
|
2007-08-07 06:21:19 +00:00
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
|
NestedSpace( nestLevel + 1, os ) << "<mpads>\n";
|
2007-08-07 06:21:19 +00:00
|
|
|
|
p = m_Pads;
|
|
|
|
|
for( ; p; p = p->Pnext )
|
2008-03-15 10:24:32 +00:00
|
|
|
|
p->Show( nestLevel + 2, os );
|
|
|
|
|
|
|
|
|
|
NestedSpace( nestLevel + 1, os ) << "</mpads>\n";
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
|
NestedSpace( nestLevel + 1, os ) << "<mdrawings>\n";
|
2007-08-06 20:26:59 +00:00
|
|
|
|
p = m_Drawings;
|
|
|
|
|
for( ; p; p = p->Pnext )
|
2008-03-15 10:24:32 +00:00
|
|
|
|
p->Show( nestLevel + 2, os );
|
|
|
|
|
|
|
|
|
|
NestedSpace( nestLevel + 1, os ) << "</mdrawings>\n";
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-06 20:26:59 +00:00
|
|
|
|
p = m_Son;
|
|
|
|
|
for( ; p; p = p->Pnext )
|
2007-08-06 02:02:39 +00:00
|
|
|
|
{
|
2008-03-15 10:24:32 +00:00
|
|
|
|
p->Show( nestLevel + 1, os );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
}
|
2008-02-19 00:30:10 +00:00
|
|
|
|
|
2007-08-07 06:21:19 +00:00
|
|
|
|
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-03-15 10:24:32 +00:00
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
#endif
|