Commit 9fb2c9fe authored by charras's avatar charras

some code cleaning and comments translations. Added: EDA_Rect::Merge( EDA_Rect...

some code cleaning and comments translations. Added: EDA_Rect::Merge( EDA_Rect & aRect ) (see changelog)
parent ae459044
...@@ -5,6 +5,17 @@ Started 2007-June-11 ...@@ -5,6 +5,17 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2008-Mar-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
some code cleaning and comment translations.
added:
/** EDA_Rect::Merge( EDA_Rect & aRect )
* Modify Position and Size of this in order to contains the given rect
* mainly used to calculate bouding boxes
* @param aRect = given rect to merge with this
*/
2008-Mar-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Mar-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+pcbnew +pcbnew
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "trigo.h" #include "trigo.h"
#include "macros.h"
#include "common.h" #include "common.h"
#include "wxstruct.h" #include "wxstruct.h"
#include "base_struct.h" #include "base_struct.h"
...@@ -98,8 +99,8 @@ void EDA_BaseStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& off ...@@ -98,8 +99,8 @@ void EDA_BaseStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& off
wxString msg, name; wxString msg, name;
msg.Printf( wxT( msg.Printf( wxT(
"EDA_BaseStruct::Draw() error. Method for struct type %d used but not implemented (" ), "EDA_BaseStruct::Draw() error. Method for struct type %d used but not implemented (" ),
Type() ); Type() );
msg += GetClass() + wxT( ")\n" ); msg += GetClass() + wxT( ")\n" );
printf( CONV_TO_UTF8( msg ) ); printf( CONV_TO_UTF8( msg ) );
} }
...@@ -115,14 +116,19 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) ...@@ -115,14 +116,19 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
*/ */
{ {
} }
#endif #endif
// see base_struct.h // see base_struct.h
SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart, SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart,
INSPECTOR* inspector, const void* testData, const KICAD_T scanTypes[] ) INSPECTOR* inspector,
const void* testData,
const KICAD_T scanTypes[] )
{ {
EDA_BaseStruct* p = listStart; EDA_BaseStruct* p = listStart;
for( ; p; p = p->Pnext ) for( ; p; p = p->Pnext )
{ {
if( SEARCH_QUIT == p->Visit( inspector, testData, scanTypes ) ) if( SEARCH_QUIT == p->Visit( inspector, testData, scanTypes ) )
...@@ -136,15 +142,15 @@ SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart, ...@@ -136,15 +142,15 @@ SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart,
// see base_struct.h // see base_struct.h
// many classes inherit this method, be careful: // many classes inherit this method, be careful:
SEARCH_RESULT EDA_BaseStruct::Visit( INSPECTOR* inspector, const void* testData, SEARCH_RESULT EDA_BaseStruct::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ) const KICAD_T scanTypes[] )
{ {
KICAD_T stype; KICAD_T stype;
#if 0 && defined(DEBUG) #if 0 && defined (DEBUG)
std::cout << GetClass().mb_str() << ' '; std::cout << GetClass().mb_str() << ' ';
#endif #endif
for( const KICAD_T* p = scanTypes; (stype=*p) != EOT; ++p ) for( const KICAD_T* p = scanTypes; (stype = *p) != EOT; ++p )
{ {
// If caller wants to inspect my type // If caller wants to inspect my type
if( stype == Type() ) if( stype == Type() )
...@@ -160,7 +166,8 @@ SEARCH_RESULT EDA_BaseStruct::Visit( INSPECTOR* inspector, const void* testData, ...@@ -160,7 +166,8 @@ SEARCH_RESULT EDA_BaseStruct::Visit( INSPECTOR* inspector, const void* testData,
} }
#if defined(DEBUG) #if defined (DEBUG)
// A function that should have been in wxWidgets // A function that should have been in wxWidgets
std::ostream& operator<<( std::ostream& out, const wxSize& size ) std::ostream& operator<<( std::ostream& out, const wxSize& size )
{ {
...@@ -168,6 +175,7 @@ std::ostream& operator<<( std::ostream& out, const wxSize& size ) ...@@ -168,6 +175,7 @@ std::ostream& operator<<( std::ostream& out, const wxSize& size )
return out; return out;
} }
// A function that should have been in wxWidgets // A function that should have been in wxWidgets
std::ostream& operator<<( std::ostream& out, const wxPoint& pt ) std::ostream& operator<<( std::ostream& out, const wxPoint& pt )
{ {
...@@ -187,17 +195,18 @@ void EDA_BaseStruct::Show( int nestLevel, std::ostream& os ) ...@@ -187,17 +195,18 @@ void EDA_BaseStruct::Show( int nestLevel, std::ostream& os )
{ {
// for now, make it look like XML: // for now, make it look like XML:
wxString s = GetClass(); wxString s = GetClass();
s = s + wxT(" ");
s = s + wxT( " " );
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">\n";
/* /*
EDA_BaseStruct* kid = m_Son; * EDA_BaseStruct* kid = m_Son;
for( ; kid; kid = kid->Pnext ) * for( ; kid; kid = kid->Pnext )
{ * {
kid->Show( nestLevel+1, os ); * kid->Show( nestLevel+1, os );
} * }
*/ */
NestedSpace( nestLevel+1, os ) << "Need ::Show() override\n"; NestedSpace( nestLevel + 1, os ) << "Need ::Show() override\n";
NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n";
} }
...@@ -212,13 +221,14 @@ void EDA_BaseStruct::Show( int nestLevel, std::ostream& os ) ...@@ -212,13 +221,14 @@ void EDA_BaseStruct::Show( int nestLevel, std::ostream& os )
**/ **/
std::ostream& EDA_BaseStruct::NestedSpace( int nestLevel, std::ostream& os ) std::ostream& EDA_BaseStruct::NestedSpace( int nestLevel, std::ostream& os )
{ {
for( int i=0; i<nestLevel; ++i ) for( int i = 0; i<nestLevel; ++i )
os << " "; // number of spaces here controls indent per nest level os << " "; // number of spaces here controls indent per nest level
return os; return os;
} }
#endif
#endif
/**************************************************/ /**************************************************/
...@@ -296,6 +306,7 @@ bool EDA_TextStruct::HitTest( const wxPoint& posref ) ...@@ -296,6 +306,7 @@ bool EDA_TextStruct::HitTest( const wxPoint& posref )
return false; return false;
} }
/** /**
* Function HitTest (overlayed) * Function HitTest (overlayed)
* tests if the given EDA_Rect intersect this object. * tests if the given EDA_Rect intersect this object.
...@@ -303,7 +314,7 @@ bool EDA_TextStruct::HitTest( const wxPoint& posref ) ...@@ -303,7 +314,7 @@ bool EDA_TextStruct::HitTest( const wxPoint& posref )
* @return bool - true if a hit, else false * @return bool - true if a hit, else false
*/ */
/*********************************************************/ /*********************************************************/
bool EDA_TextStruct::HitTest( EDA_Rect& refArea ) bool EDA_TextStruct::HitTest( EDA_Rect& refArea )
/*********************************************************/ /*********************************************************/
{ {
if( refArea.Inside( m_Pos ) ) if( refArea.Inside( m_Pos ) )
...@@ -311,6 +322,7 @@ bool EDA_TextStruct::HitTest( EDA_Rect& refArea ) ...@@ -311,6 +322,7 @@ bool EDA_TextStruct::HitTest( EDA_Rect& refArea )
return false; return false;
} }
/*******************************/ /*******************************/
int EDA_TextStruct::Pitch() int EDA_TextStruct::Pitch()
/*******************************/ /*******************************/
...@@ -342,7 +354,7 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -342,7 +354,7 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int ii, jj, kk, ll, nbpoints; int ii, jj, kk, ll, nbpoints;
int width; int width;
if( m_TextDrawings == NULL ) /* pointeur sur la liste des segments de dessin */ if( m_TextDrawings == NULL ) /* pointeur sur la liste des segments de dessin */
CreateDrawData(); CreateDrawData();
if( m_TextDrawings == NULL ) if( m_TextDrawings == NULL )
...@@ -361,11 +373,11 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -361,11 +373,11 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
if( zoom > m_ZoomLevelDrawable ) if( zoom > m_ZoomLevelDrawable )
{ {
GRLine( &panel->m_ClipBox, DC, GRLine( &panel->m_ClipBox, DC,
m_TextDrawings[1] + offset.x + m_Pos.x, m_TextDrawings[1] + offset.x + m_Pos.x,
m_TextDrawings[2] + offset.y + m_Pos.y, m_TextDrawings[2] + offset.y + m_Pos.y,
m_TextDrawings[3] + offset.x + m_Pos.x, m_TextDrawings[3] + offset.x + m_Pos.x,
m_TextDrawings[4] + offset.y + m_Pos.y, m_TextDrawings[4] + offset.y + m_Pos.y,
width, color ); width, color );
} }
else else
{ {
...@@ -381,10 +393,10 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -381,10 +393,10 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
/* trace ancre du texte */ /* trace ancre du texte */
GRLine( &panel->m_ClipBox, DC, cX - anchor_size, cY, GRLine( &panel->m_ClipBox, DC, cX - anchor_size, cY,
cX + anchor_size, cY, 0, anchor_color ); cX + anchor_size, cY, 0, anchor_color );
GRLine( &panel->m_ClipBox, DC, cX, cY - anchor_size, GRLine( &panel->m_ClipBox, DC, cX, cY - anchor_size,
cX, cY + anchor_size, 0, anchor_color ); cX, cY + anchor_size, 0, anchor_color );
} }
jj = 5; ii = jj + 1; jj = 5; ii = jj + 1;
while( ii < m_TextDrawingsSize ) while( ii < m_TextDrawingsSize )
...@@ -407,15 +419,15 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -407,15 +419,15 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
{ {
if( display_mode == SKETCH ) if( display_mode == SKETCH )
GRCSegm( &panel->m_ClipBox, DC, GRCSegm( &panel->m_ClipBox, DC,
coord[ll], coord[ll + 1], coord[ll], coord[ll + 1],
coord[ll + 2], coord[ll + 3], coord[ll + 2], coord[ll + 3],
m_Width, color ); m_Width, color );
else else
GRFillCSegm( &panel->m_ClipBox, DC, GRFillCSegm( &panel->m_ClipBox, DC,
coord[ll], coord[ll + 1], coord[ll], coord[ll + 1],
coord[ll + 2], coord[ll + 3], coord[ll + 2], coord[ll + 3],
m_Width, color ); m_Width, color );
} }
} }
else else
...@@ -548,14 +560,14 @@ void EDA_TextStruct::CreateDrawData() ...@@ -548,14 +560,14 @@ void EDA_TextStruct::CreateDrawData()
/* lorsque les chars sont trop petits pour etre dessines, /* lorsque les chars sont trop petits pour etre dessines,
* le texte est symbolise par une barre */ * le texte est symbolise par une barre */
m_ZoomLevelDrawable = m_Size.x / 3; m_ZoomLevelDrawable = m_Size.x / 3;
dx = (espacement * nbchar) / 2; dx = (espacement * nbchar) / 2;
dy = size_v / 2; /* Decalage du debut du texte / centre */ dy = size_v / 2; /* Decalage du debut du texte / centre */
ux0 = cX - dx; ux0 = cX - dx;
uy0 = cY; uy0 = cY;
dx += cX; dx += cX;
dy = cY; dy = cY;
RotatePoint( &ux0, &uy0, cX, cY, m_Orient ); RotatePoint( &ux0, &uy0, cX, cY, m_Orient );
RotatePoint( &dx, &dy, cX, cY, m_Orient ); RotatePoint( &dx, &dy, cX, cY, m_Orient );
...@@ -595,7 +607,7 @@ void EDA_TextStruct::CreateDrawData() ...@@ -595,7 +607,7 @@ void EDA_TextStruct::CreateDrawData()
coord[jj] = nbpoints; coord[jj] = nbpoints;
jj = ii++; jj = ii++;
} }
plume = f_cod; plume = f_cod;
nbpoints = 0; nbpoints = 0;
break; break;
...@@ -613,8 +625,8 @@ void EDA_TextStruct::CreateDrawData() ...@@ -613,8 +625,8 @@ void EDA_TextStruct::CreateDrawData()
k2 = f_cod; /* trace sur axe H */ k2 = f_cod; /* trace sur axe H */
k2 = (k2 * size_h) / 9; k2 = (k2 * size_h) / 9;
dx = k2 + ox; dx = k2 + ox;
dy = k1 + oy; dy = k1 + oy;
RotatePoint( &dx, &dy, cX, cY, m_Orient ); RotatePoint( &dx, &dy, cX, cY, m_Orient );
if( ii >= coord_count_max ) if( ii >= coord_count_max )
...@@ -680,13 +692,13 @@ bool EDA_Rect::Inside( const wxPoint& point ) ...@@ -680,13 +692,13 @@ bool EDA_Rect::Inside( const wxPoint& point )
if( size.x < 0 ) if( size.x < 0 )
{ {
size.x = -size.x; size.x = -size.x;
rel_posx += size.x; rel_posx += size.x;
} }
if( size.y < 0 ) if( size.y < 0 )
{ {
size.y = -size.y; size.y = -size.y;
rel_posy += size.y; rel_posy += size.y;
} }
...@@ -701,10 +713,10 @@ bool EDA_Rect::Intersects( const EDA_Rect aRect ) const ...@@ -701,10 +713,10 @@ bool EDA_Rect::Intersects( const EDA_Rect aRect ) const
{ {
// this logic taken from wxWidgets' geometry.cpp file: // this logic taken from wxWidgets' geometry.cpp file:
int left = MAX( m_Pos.x , aRect.m_Pos.x ); int left = MAX( m_Pos.x, aRect.m_Pos.x );
int right = MIN( m_Pos.x+m_Size.x, aRect.m_Pos.x+aRect.m_Size.x ); int right = MIN( m_Pos.x + m_Size.x, aRect.m_Pos.x + aRect.m_Size.x );
int top = MAX( m_Pos.y , aRect.m_Pos.y ); int top = MAX( m_Pos.y, aRect.m_Pos.y );
int bottom = MIN( m_Pos.y+m_Size.y, aRect.m_Pos.y + aRect.m_Size.y ); int bottom = MIN( m_Pos.y + m_Size.y, aRect.m_Pos.y + aRect.m_Size.y );
if( left < right && top < bottom ) if( left < right && top < bottom )
{ {
...@@ -750,6 +762,28 @@ EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy ) ...@@ -750,6 +762,28 @@ EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy )
} }
/** Function Merge
* Modify Position and Size of this in order to contain the given rect
* mainly used to calculate bounding boxes
* @param aRect = given rect to merge with this
*/
void EDA_Rect::Merge( EDA_Rect& aRect )
{
Normalize(); // ensure width and height >= 0
EDA_Rect rect = aRect;
rect.Normalize(); // ensure width and height >= 0
wxPoint end = GetEnd();
wxPoint rect_end = rect.GetEnd();
// Change origin and size in order to contain the given rect
m_Pos.x = MIN( m_Pos.x, rect.m_Pos.x );
m_Pos.y = MIN( m_Pos.y, rect.m_Pos.y );
end.x = MAX( end.x, rect_end.x );
end.y = MAX( end.y, rect_end.y );
SetEnd( end );
}
/**************************/ /**************************/
/* class DrawPickedStruct */ /* class DrawPickedStruct */
/**************************/ /**************************/
...@@ -791,4 +825,3 @@ void DrawPickedStruct::DeleteWrapperList() ...@@ -791,4 +825,3 @@ void DrawPickedStruct::DeleteWrapperList()
delete wrapp_struct; delete wrapp_struct;
} }
} }
...@@ -194,12 +194,20 @@ public: ...@@ -194,12 +194,20 @@ public:
operator wxRect() const { return wxRect( m_Pos, m_Size ); } operator wxRect() const { return wxRect( m_Pos, m_Size ); }
EDA_Rect& Inflate( wxCoord dx, wxCoord dy ); EDA_Rect& Inflate( wxCoord dx, wxCoord dy );
/** Function Merge
* Modify Position and Size of this in order to contain the given rect
* mainly used to calculate bounding boxes
* @param aRect = given rect to merge with this
*/
void Merge( EDA_Rect & aRect );
}; };
/********************************************************************/ /******************************************************/
/* Classes de base: servent a deriver les classes reellement utiles */ /* Basic Classes : used classes are derived from them */
/********************************************************************/ /******************************************************/
/** class EDA_BaseStruct /** class EDA_BaseStruct
* Basic class, not directly used. * Basic class, not directly used.
......
...@@ -42,13 +42,13 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset ...@@ -42,13 +42,13 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset
if( (g_AnchorColor & ITEM_NOT_SHOW) == 0 ) if( (g_AnchorColor & ITEM_NOT_SHOW) == 0 )
{ {
GRLine( &panel->m_ClipBox, DC, GRLine( &panel->m_ClipBox, DC,
m_Pos.x - offset.x - anchor_size, m_Pos.y - offset.y, m_Pos.x - offset.x - anchor_size, m_Pos.y - offset.y,
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 ); 0, g_AnchorColor );
GRLine( &panel->m_ClipBox, DC, GRLine( &panel->m_ClipBox, DC,
m_Pos.x - offset.x, m_Pos.y - offset.y - anchor_size, m_Pos.x - offset.x, m_Pos.y - offset.y - anchor_size,
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 ); 0, g_AnchorColor );
} }
} }
...@@ -107,7 +107,7 @@ MODULE::~MODULE() ...@@ -107,7 +107,7 @@ MODULE::~MODULE()
{ {
NextStruct = Struct->Pnext; NextStruct = Struct->Pnext;
switch( (Struct->Type()) ) switch( ( Struct->Type() ) )
{ {
case TYPEEDGEMODULE: case TYPEEDGEMODULE:
delete (EDGE_MODULE*) Struct; delete (EDGE_MODULE*) Struct;
...@@ -142,7 +142,7 @@ void MODULE::Copy( MODULE* Module ) ...@@ -142,7 +142,7 @@ void MODULE::Copy( MODULE* Module )
m_CntRot90 = Module->m_CntRot90; m_CntRot90 = Module->m_CntRot90;
m_CntRot180 = Module->m_CntRot180; m_CntRot180 = Module->m_CntRot180;
m_LastEdit_Time = Module->m_LastEdit_Time; m_LastEdit_Time = Module->m_LastEdit_Time;
m_Path = Module->m_Path; //is this correct behavior? m_Path = Module->m_Path; //is this correct behavior?
m_TimeStamp = GetTimeStamp(); m_TimeStamp = GetTimeStamp();
/* Copy des structures auxiliaires: Reference et value */ /* Copy des structures auxiliaires: Reference et value */
...@@ -170,8 +170,8 @@ void MODULE::Copy( MODULE* Module ) ...@@ -170,8 +170,8 @@ void MODULE::Copy( MODULE* Module )
} }
/* Copy des structures auxiliaires: Drawings */ /* Copy des structures auxiliaires: Drawings */
BOARD_ITEM* OldStruct = Module->m_Drawings; BOARD_ITEM* OldStruct = Module->m_Drawings;
BOARD_ITEM* NewStruct, * LastStruct = NULL; BOARD_ITEM* NewStruct, * LastStruct = NULL;
for( ; OldStruct; OldStruct = OldStruct->Next() ) for( ; OldStruct; OldStruct = OldStruct->Next() )
{ {
NewStruct = NULL; NewStruct = NULL;
...@@ -278,9 +278,9 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -278,9 +278,9 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
D_PAD* pt_pad; D_PAD* pt_pad;
EDA_BaseStruct* PtStruct; EDA_BaseStruct* PtStruct;
TEXTE_MODULE* PtTexte; TEXTE_MODULE* PtTexte;
if ( (m_Flags & DO_NOT_DRAW) ) if( (m_Flags & DO_NOT_DRAW) )
return; return;
/* Draw pads */ /* Draw pads */
pt_pad = m_Pads; pt_pad = m_Pads;
...@@ -328,6 +328,7 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -328,6 +328,7 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC, void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode ) const wxPoint& offset, int draw_mode )
/**************************************************************/ /**************************************************************/
/** Function DrawEdgesOnly /** Function DrawEdgesOnly
* Draws the footprint edges only to the current Device Context * Draws the footprint edges only to the current Device Context
* @param panel = The active Draw Panel (used to know the clip box) * @param panel = The active Draw Panel (used to know the clip box)
...@@ -357,8 +358,8 @@ void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -357,8 +358,8 @@ void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
bool MODULE::Save( FILE* aFile ) const bool MODULE::Save( FILE* aFile ) const
{ {
char statusTxt[8]; char statusTxt[8];
BOARD_ITEM* item; BOARD_ITEM* item;
if( GetState( DELETED ) ) if( GetState( DELETED ) )
return true; return true;
...@@ -380,9 +381,9 @@ bool MODULE::Save( FILE* aFile ) const ...@@ -380,9 +381,9 @@ bool MODULE::Save( FILE* aFile ) const
statusTxt[1] = '~'; statusTxt[1] = '~';
fprintf( aFile, "Po %d %d %d %d %8.8lX %8.8lX %s\n", fprintf( aFile, "Po %d %d %d %d %8.8lX %8.8lX %s\n",
m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y,
m_Orient, m_Layer, m_LastEdit_Time, m_Orient, m_Layer, m_LastEdit_Time,
m_TimeStamp, statusTxt ); m_TimeStamp, statusTxt );
fprintf( aFile, "Li %s\n", CONV_TO_UTF8( m_LibRef ) ); fprintf( aFile, "Li %s\n", CONV_TO_UTF8( m_LibRef ) );
...@@ -397,7 +398,7 @@ bool MODULE::Save( FILE* aFile ) const ...@@ -397,7 +398,7 @@ bool MODULE::Save( FILE* aFile ) const
} }
fprintf( aFile, "Sc %8.8lX\n", m_TimeStamp ); fprintf( aFile, "Sc %8.8lX\n", m_TimeStamp );
fprintf( aFile, "AR %s\n", CONV_TO_UTF8(m_Path) ); fprintf( aFile, "AR %s\n", CONV_TO_UTF8( m_Path ) );
fprintf( aFile, "Op %X %X 0\n", m_CntRot90, m_CntRot180 ); fprintf( aFile, "Op %X %X 0\n", m_CntRot90, m_CntRot180 );
// attributes // attributes
...@@ -420,7 +421,7 @@ bool MODULE::Save( FILE* aFile ) const ...@@ -420,7 +421,7 @@ bool MODULE::Save( FILE* aFile ) const
goto out; goto out;
// save drawing elements // save drawing elements
for( item=m_Drawings; item; item=item->Next() ) for( item = m_Drawings; item; item = item->Next() )
{ {
switch( item->Type() ) switch( item->Type() )
{ {
...@@ -431,7 +432,7 @@ bool MODULE::Save( FILE* aFile ) const ...@@ -431,7 +432,7 @@ bool MODULE::Save( FILE* aFile ) const
break; break;
default: default:
#if defined(DEBUG) #if defined (DEBUG)
printf( "MODULE::Save() ignoring type %d\n", item->Type() ); printf( "MODULE::Save() ignoring type %d\n", item->Type() );
#endif #endif
break; break;
...@@ -439,7 +440,7 @@ bool MODULE::Save( FILE* aFile ) const ...@@ -439,7 +440,7 @@ bool MODULE::Save( FILE* aFile ) const
} }
// save the pads // save the pads
for( item=m_Pads; item; item=item->Next() ) for( item = m_Pads; item; item = item->Next() )
if( !item->Save( aFile ) ) if( !item->Save( aFile ) )
goto out; goto out;
...@@ -473,21 +474,21 @@ int MODULE::Write_3D_Descr( FILE* File ) const ...@@ -473,21 +474,21 @@ int MODULE::Write_3D_Descr( FILE* File ) const
fprintf( File, "Na \"%s\"\n", CONV_TO_UTF8( Struct3D->m_Shape3DName ) ); fprintf( File, "Na \"%s\"\n", CONV_TO_UTF8( Struct3D->m_Shape3DName ) );
sprintf( buf, "Sc %lf %lf %lf\n", sprintf( buf, "Sc %lf %lf %lf\n",
Struct3D->m_MatScale.x, Struct3D->m_MatScale.x,
Struct3D->m_MatScale.y, Struct3D->m_MatScale.y,
Struct3D->m_MatScale.z ); Struct3D->m_MatScale.z );
fprintf( File, to_point( buf ) ); fprintf( File, to_point( buf ) );
sprintf( buf, "Of %lf %lf %lf\n", sprintf( buf, "Of %lf %lf %lf\n",
Struct3D->m_MatPosition.x, Struct3D->m_MatPosition.x,
Struct3D->m_MatPosition.y, Struct3D->m_MatPosition.y,
Struct3D->m_MatPosition.z ); Struct3D->m_MatPosition.z );
fprintf( File, to_point( buf ) ); fprintf( File, to_point( buf ) );
sprintf( buf, "Ro %lf %lf %lf\n", sprintf( buf, "Ro %lf %lf %lf\n",
Struct3D->m_MatRotation.x, Struct3D->m_MatRotation.x,
Struct3D->m_MatRotation.y, Struct3D->m_MatRotation.y,
Struct3D->m_MatRotation.z ); Struct3D->m_MatRotation.z );
fprintf( File, to_point( buf ) ); fprintf( File, to_point( buf ) );
fprintf( File, "$EndSHAPE3D\n" ); fprintf( File, "$EndSHAPE3D\n" );
...@@ -541,23 +542,23 @@ int MODULE::Read_3D_Descr( FILE* File, int* LineNum ) ...@@ -541,23 +542,23 @@ int MODULE::Read_3D_Descr( FILE* File, int* LineNum )
case 'S': // Scale case 'S': // Scale
sscanf( text, "%lf %lf %lf\n", sscanf( text, "%lf %lf %lf\n",
&Struct3D->m_MatScale.x, &Struct3D->m_MatScale.x,
&Struct3D->m_MatScale.y, &Struct3D->m_MatScale.y,
&Struct3D->m_MatScale.z ); &Struct3D->m_MatScale.z );
break; break;
case 'O': // Offset case 'O': // Offset
sscanf( text, "%lf %lf %lf\n", sscanf( text, "%lf %lf %lf\n",
&Struct3D->m_MatPosition.x, &Struct3D->m_MatPosition.x,
&Struct3D->m_MatPosition.y, &Struct3D->m_MatPosition.y,
&Struct3D->m_MatPosition.z ); &Struct3D->m_MatPosition.z );
break; break;
case 'R': // Rotation case 'R': // Rotation
sscanf( text, "%lf %lf %lf\n", sscanf( text, "%lf %lf %lf\n",
&Struct3D->m_MatRotation.x, &Struct3D->m_MatRotation.x,
&Struct3D->m_MatRotation.y, &Struct3D->m_MatRotation.y,
&Struct3D->m_MatRotation.z ); &Struct3D->m_MatRotation.z );
break; break;
default: default:
...@@ -627,13 +628,13 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) ...@@ -627,13 +628,13 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
case 'P': case 'P':
memset( BufCar1, 0, sizeof(BufCar1) ); memset( BufCar1, 0, sizeof(BufCar1) );
sscanf( PtLine, "%d %d %d %d %lX %lX %s", sscanf( PtLine, "%d %d %d %d %lX %lX %s",
&m_Pos.x, &m_Pos.y, &m_Pos.x, &m_Pos.y,
&m_Orient, &m_Layer, &m_Orient, &m_Layer,
&m_LastEdit_Time, &m_TimeStamp, BufCar1 ); &m_LastEdit_Time, &m_TimeStamp, BufCar1 );
m_ModuleStatus = 0; m_ModuleStatus = 0;
if( BufCar1[0] == 'F' ) if( BufCar1[0] == 'F' )
SetLocked(true); SetLocked( true );
if( BufCar1[1] == 'P' ) if( BufCar1[1] == 'P' )
m_ModuleStatus |= MODULE_is_PLACED; m_ModuleStatus |= MODULE_is_PLACED;
break; break;
...@@ -667,17 +668,19 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) ...@@ -667,17 +668,19 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
break; break;
case 'A': case 'A':
if(Line[1] == 't'){ if( Line[1] == 't' )
{
/* At = (At)tributs du module */ /* At = (At)tributs du module */
if( strstr( PtLine, "SMD" ) ) if( strstr( PtLine, "SMD" ) )
m_Attributs |= MOD_CMS; m_Attributs |= MOD_CMS;
if( strstr( PtLine, "VIRTUAL" ) ) if( strstr( PtLine, "VIRTUAL" ) )
m_Attributs |= MOD_VIRTUAL; m_Attributs |= MOD_VIRTUAL;
} }
if(Line[1] == 'R'){ if( Line[1] == 'R' )
{
//alternate reference, e.g. /478C2408/478AD1B6 //alternate reference, e.g. /478C2408/478AD1B6
sscanf( PtLine, " %s", BufLine ); sscanf( PtLine, " %s", BufLine );
m_Path = CONV_FROM_UTF8(BufLine); m_Path = CONV_FROM_UTF8( BufLine );
} }
break; break;
...@@ -705,11 +708,11 @@ int MODULE::ReadDescr( FILE* File, int* LineNum ) ...@@ -705,11 +708,11 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
int layer; int layer;
sscanf( Line + 1, "%d %d %d %d %d %d %d %s %s %d", sscanf( Line + 1, "%d %d %d %d %d %d %d %s %s %d",
&itmp1, &itmp1,
&DrawText->m_Pos0.x, &DrawText->m_Pos0.y, &DrawText->m_Pos0.x, &DrawText->m_Pos0.y,
&DrawText->m_Size.y, &DrawText->m_Size.x, &DrawText->m_Size.y, &DrawText->m_Size.x,
&DrawText->m_Orient, &DrawText->m_Width, &DrawText->m_Orient, &DrawText->m_Width,
BufCar1, BufCar2, &layer ); BufCar1, BufCar2, &layer );
DrawText->m_Type = itmp1; DrawText->m_Type = itmp1;
DrawText->m_Orient -= m_Orient; // m_Orient texte relative au module DrawText->m_Orient -= m_Orient; // m_Orient texte relative au module
...@@ -1054,53 +1057,31 @@ void MODULE::SetRectangleExinscrit() ...@@ -1054,53 +1057,31 @@ void MODULE::SetRectangleExinscrit()
*/ */
EDA_Rect MODULE::GetBoundingBox() EDA_Rect MODULE::GetBoundingBox()
{ {
// Calculate area without text fielsd: // Calculate area without text fields:
SetRectangleExinscrit(); SetRectangleExinscrit();
EDA_Rect area = m_RealBoundaryBox; 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 );
area.Normalize();
// Calculate extended area including text field:
EDGE_MODULE* EdgeMod = (EDGE_MODULE*) m_Drawings; EDGE_MODULE* EdgeMod = (EDGE_MODULE*) m_Drawings;
TEXTE_MODULE* text; for( ; EdgeMod != NULL; EdgeMod = (EDGE_MODULE*) EdgeMod->Pnext )
EDA_Rect text_area;
wxPoint textstart, textend;
wxPoint modstart = area.GetOrigin();
wxPoint modend = area.GetEnd();
for( int ii = 0 ; ; ii++ )
{ {
if ( ii == 0 ) if( EdgeMod->Type() != TYPETEXTEMODULE )
text = m_Reference; continue;
else if ( ii == 1 ) text_area = ((TEXTE_MODULE*)EdgeMod)->GetBoundingBox();
text = m_Value; area.Merge( text_area );
else }
{
if ( EdgeMod == NULL ) break; return area;
text = (TEXTE_MODULE*) EdgeMod;
EdgeMod = (EDGE_MODULE*) EdgeMod->Pnext;
if( text->Type() != TYPETEXTEMODULE )
continue;
}
text_area = text->GetTextRect();
textstart = text_area.GetOrigin();
textend = text_area.GetEnd();
int angle = text->GetDrawRotation();
RotatePoint( &textstart, text->m_Pos, angle);
RotatePoint( &textend, text->m_Pos, angle);
modstart.x = min( modstart.x, textstart.x);
modstart.x = min( modstart.x, textend.x);
modstart.y = min( modstart.y, textstart.y);
modstart.y = min( modstart.y, textend.y);
modend.x = max( modend.x, textstart.x);
modend.x = max( modend.x, textend.x);
modend.y = max( modend.y, textstart.y);
modend.y = max( modend.y, textend.y);
}
area.SetOrigin(modstart);
area.SetEnd(modend);
return area;
} }
/*******************************************************/ /*******************************************************/
void MODULE::Display_Infos( WinEDA_DrawFrame* frame ) void MODULE::Display_Infos( WinEDA_DrawFrame* frame )
/*******************************************************/ /*******************************************************/
...@@ -1135,7 +1116,7 @@ void MODULE::Display_Infos( WinEDA_DrawFrame* frame ) ...@@ -1135,7 +1116,7 @@ void MODULE::Display_Infos( WinEDA_DrawFrame* frame )
else else
{ {
msg.Printf( wxT( "%8.8lX" ), m_TimeStamp ); msg.Printf( wxT( "%8.8lX" ), m_TimeStamp );
Affiche_1_Parametre( frame, pos, _( "Netlist path" ), /*msg*/m_Path, BROWN ); Affiche_1_Parametre( frame, pos, _( "Netlist path" ), /*msg*/ m_Path, BROWN );
} }
pos += 12; pos += 12;
...@@ -1170,7 +1151,7 @@ void MODULE::Display_Infos( WinEDA_DrawFrame* frame ) ...@@ -1170,7 +1151,7 @@ void MODULE::Display_Infos( WinEDA_DrawFrame* frame )
pos += 9; pos += 9;
Affiche_1_Parametre( frame, pos, _( "3D-Shape" ), Affiche_1_Parametre( frame, pos, _( "3D-Shape" ),
m_3D_Drawings->m_Shape3DName, RED ); m_3D_Drawings->m_Shape3DName, RED );
pos += 14; pos += 14;
wxString doc = _( "Doc: " ) + m_Doc; wxString doc = _( "Doc: " ) + m_Doc;
...@@ -1207,7 +1188,7 @@ bool MODULE::HitTest( const wxPoint& refPos ) ...@@ -1207,7 +1188,7 @@ bool MODULE::HitTest( const wxPoint& refPos )
* @param refArea : the given EDA_Rect * @param refArea : the given EDA_Rect
* @return bool - true if a hit, else false * @return bool - true if a hit, else false
*/ */
bool MODULE::HitTest( EDA_Rect& refArea ) bool MODULE::HitTest( EDA_Rect& refArea )
{ {
bool is_out_of_box = false; bool is_out_of_box = false;
...@@ -1230,7 +1211,7 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const ...@@ -1230,7 +1211,7 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
{ {
wxString buf; wxString buf;
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{ {
pad->ReturnStringPadName( buf ); pad->ReturnStringPadName( buf );
#if 1 #if 1
...@@ -1238,6 +1219,7 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const ...@@ -1238,6 +1219,7 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
#else #else
if( buf == aPadName ) if( buf == aPadName )
#endif #endif
return pad; return pad;
} }
...@@ -1247,20 +1229,21 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const ...@@ -1247,20 +1229,21 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
// see class_module.h // see class_module.h
SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] ) const KICAD_T scanTypes[] )
{ {
KICAD_T stype; KICAD_T stype;
SEARCH_RESULT result = SEARCH_CONTINUE; SEARCH_RESULT result = SEARCH_CONTINUE;
const KICAD_T* p = scanTypes; const KICAD_T* p = scanTypes;
bool done = false; bool done = false;
#if 0 && defined(DEBUG) #if 0 && defined (DEBUG)
std::cout << GetClass().mb_str() << ' '; std::cout << GetClass().mb_str() << ' ';
#endif #endif
while( !done ) while( !done )
{ {
stype = *p; stype = *p;
switch( stype ) switch( stype )
{ {
case TYPEMODULE: case TYPEMODULE:
...@@ -1286,18 +1269,23 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, ...@@ -1286,18 +1269,23 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
case TYPEEDGEMODULE: case TYPEEDGEMODULE:
result = IterateForward( m_Drawings, inspector, testData, p ); result = IterateForward( m_Drawings, inspector, testData, p );
// skip over any types handled in the above call. // skip over any types handled in the above call.
for(;;) for( ; ; )
{ {
switch( stype = *++p ) switch( stype = *++p )
{ {
case TYPETEXTEMODULE: case TYPETEXTEMODULE:
case TYPEEDGEMODULE: case TYPEEDGEMODULE:
continue; continue;
default: ;
default:
;
} }
break; break;
} }
break; break;
default: default:
...@@ -1313,7 +1301,8 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, ...@@ -1313,7 +1301,8 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
} }
#if defined(DEBUG) #if defined (DEBUG)
/** /**
* Function Show * Function Show
* is used to output the object tree, currently for debugging only. * is used to output the object tree, currently for debugging only.
...@@ -1323,41 +1312,44 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, ...@@ -1323,41 +1312,44 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
*/ */
void MODULE::Show( int nestLevel, std::ostream& os ) void MODULE::Show( int nestLevel, std::ostream& os )
{ {
BOARD* board = (BOARD*) m_Parent; BOARD* board = (BOARD*) m_Parent;
// for now, make it look like XML, expand on this later. // for now, make it look like XML, expand on this later.
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
" ref=\"" << m_Reference->m_Text.mb_str() << '"' << " ref=\"" << m_Reference->m_Text.mb_str() << '"' <<
" value=\"" << m_Value->m_Text.mb_str() << '"' << " value=\"" << m_Value->m_Text.mb_str() << '"' <<
" layer=\"" << board->GetLayerName(m_Layer).mb_str() << '"' << " layer=\"" << board->GetLayerName( m_Layer ).mb_str() << '"' <<
">\n"; ">\n";
NestedSpace( nestLevel+1, os ) << NestedSpace( nestLevel + 1, os ) <<
"<boundingBox" << m_BoundaryBox.m_Pos << m_BoundaryBox.m_Size << "/>\n"; "<boundingBox" << m_BoundaryBox.m_Pos << m_BoundaryBox.m_Size << "/>\n";
NestedSpace( nestLevel+1, os ) << "<orientation tenths=\"" << m_Orient << "\"/>\n"; NestedSpace( nestLevel + 1, os ) << "<orientation tenths=\"" << m_Orient << "\"/>\n";
EDA_BaseStruct* p; EDA_BaseStruct* p;
NestedSpace( nestLevel+1, os ) << "<mpads>\n"; NestedSpace( nestLevel + 1, os ) << "<mpads>\n";
p = m_Pads; p = m_Pads;
for( ; p; p = p->Pnext ) for( ; p; p = p->Pnext )
p->Show( nestLevel+2, os ); p->Show( nestLevel + 2, os );
NestedSpace( nestLevel+1, os ) << "</mpads>\n";
NestedSpace( nestLevel + 1, os ) << "</mpads>\n";
NestedSpace( nestLevel+1, os ) << "<mdrawings>\n"; NestedSpace( nestLevel + 1, os ) << "<mdrawings>\n";
p = m_Drawings; p = m_Drawings;
for( ; p; p = p->Pnext ) for( ; p; p = p->Pnext )
p->Show( nestLevel+2, os ); p->Show( nestLevel + 2, os );
NestedSpace( nestLevel+1, os ) << "</mdrawings>\n";
NestedSpace( nestLevel + 1, os ) << "</mdrawings>\n";
p = m_Son; p = m_Son;
for( ; p; p = p->Pnext ) for( ; p; p = p->Pnext )
{ {
p->Show( nestLevel+1, os ); p->Show( nestLevel + 1, os );
} }
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
#endif #endif
...@@ -158,6 +158,13 @@ public: ...@@ -158,6 +158,13 @@ public:
int Read_3D_Descr( FILE* File, int* LineNum = NULL ); int Read_3D_Descr( FILE* File, int* LineNum = NULL );
/* drawing functions */ /* drawing functions */
/** Function Draw
* Draw the text accordint to the footprint pos and orient
* @param panel = 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..
*/
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode ); const wxPoint& offset, int draw_mode );
void Draw3D( Pcb3D_GLCanvas* glcanvas ); void Draw3D( Pcb3D_GLCanvas* glcanvas );
......
...@@ -101,11 +101,12 @@ void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) // copy structure ...@@ -101,11 +101,12 @@ void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) // copy structure
m_Pos = source->m_Pos; m_Pos = source->m_Pos;
SetLayer( source->GetLayer() ); SetLayer( source->GetLayer() );
m_Miroir = source->m_Miroir; // vue normale / miroir m_Miroir = source->m_Miroir; // Show normal / mirror
m_NoShow = source->m_NoShow; // 0: visible 1: invisible m_NoShow = source->m_NoShow; // 0: visible 1: invisible
m_Type = source->m_Type; // 0: ref,1: val, autre = 2..255 m_Type = source->m_Type; // 0: ref,1: val, others = 2..255
m_Orient = source->m_Orient; // orientation en 1/10 degre m_Orient = source->m_Orient; // orientation in 1/10 deg
m_Pos0 = source->m_Pos0; // coord du debut du texte /ancre, orient 0 m_Pos0 = source->m_Pos0; // text coordinates relatives to the footprint ancre, orient 0
// Text coordinate ref point is the text centre
m_Size = source->m_Size; m_Size = source->m_Size;
m_Width = source->m_Width; m_Width = source->m_Width;
...@@ -114,8 +115,8 @@ void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) // copy structure ...@@ -114,8 +115,8 @@ void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) // copy structure
} }
/* supprime du chainage la structure Struct /* Remove this from the linked list
* les structures arrieres et avant sont chainees directement * Update Pback and Pnext pointers
*/ */
void TEXTE_MODULE::UnLink() void TEXTE_MODULE::UnLink()
{ {
...@@ -156,7 +157,7 @@ void TEXTE_MODULE:: SetWidth( int new_width ) ...@@ -156,7 +157,7 @@ void TEXTE_MODULE:: SetWidth( int new_width )
} }
// mise a jour des coordonn�s absolues pour affichage // Update draw ccordinates
void TEXTE_MODULE:: SetDrawCoord() void TEXTE_MODULE:: SetDrawCoord()
{ {
MODULE* Module = (MODULE*) m_Parent; MODULE* Module = (MODULE*) m_Parent;
...@@ -175,7 +176,7 @@ void TEXTE_MODULE:: SetDrawCoord() ...@@ -175,7 +176,7 @@ void TEXTE_MODULE:: SetDrawCoord()
} }
// mise a jour des coordonn�s relatives au module // Update "local" cooedinates (coordinates relatives to the footprint anchor point)
void TEXTE_MODULE:: SetLocalCoord() void TEXTE_MODULE:: SetLocalCoord()
{ {
MODULE* Module = (MODULE*) m_Parent; MODULE* Module = (MODULE*) m_Parent;
...@@ -219,45 +220,62 @@ EDA_Rect TEXTE_MODULE::GetTextRect(void) ...@@ -219,45 +220,62 @@ EDA_Rect TEXTE_MODULE::GetTextRect(void)
return area; return area;
} }
bool TEXTE_MODULE::HitTest( const wxPoint& posref ) /**
* 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 TEXTE_MODULE::HitTest( const wxPoint& refPos )
{ {
int mX, mY, dx, dy; wxPoint rel_pos;
MODULE* Module = (MODULE*) m_Parent; EDA_Rect area = GetTextRect();
int angle = m_Orient;
/* Rotate refPos to - angle
if( Module ) * to test if refPos is within area (which is relative to an horizontal text)
angle += Module->m_Orient; */
rel_pos = refPos;
dx = ( m_Size.x * GetLength() ) / 2; RotatePoint( &rel_pos, m_Pos, - GetDrawRotation() );
dx = (dx * 10) / 9; /* Facteur de forme des lettres : 10/9 */
dx += m_Width / 2;
dy = ( m_Size.y + m_Width ) / 2;
/* le point de reference est tourn�de - angle
* pour se ramener a un rectangle de reference horizontal */
mX = posref.x - m_Pos.x;
mY = posref.y - m_Pos.y;
RotatePoint( &mX, &mY, -angle );
/* le point de reference est-il dans ce rectangle */ if( area.Inside(rel_pos) )
if( ( abs( mX ) <= abs( dx ) ) && ( abs( mY ) <= abs( dy ) ) )
{
return true; return true;
}
return false; return false;
} }
/**
* Function GetBoundingBox
* returns the bounding box of this Text (according to text and footprint orientation)
*/
EDA_Rect TEXTE_MODULE::GetBoundingBox()
{
// Calculate area without text fielsd:
EDA_Rect text_area;
int angle = GetDrawRotation();
wxPoint textstart, textend;
text_area = GetTextRect();
textstart = text_area.GetOrigin();
textend = text_area.GetEnd();
RotatePoint( &textstart, m_Pos, angle);
RotatePoint( &textend, m_Pos, angle);
text_area.SetOrigin(textstart);
text_area.SetEnd(textend);
text_area.Normalize();
return text_area;
}
/******************************************************************************************/ /******************************************************************************************/
void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, wxPoint offset, int draw_mode ) void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, wxPoint offset, int draw_mode )
/******************************************************************************************/ /******************************************************************************************/
/* trace 1 texte de module /** Function Draw
* Utilise la police definie dans grfonte.h * Draw the text accordint to the footprint pos and orient
* (Se reporter a ce fichier pour les explications complementaires) * @param panel = draw panel, Used to know the clip box
* offset = offset de trace ( reference au centre du texte) * @param DC = Current Device Context
* draw_mode = GR_OR, GR_XOR.. * @param offset = draw offset (usually wxPoint(0,0)
* @param draw_mode = GR_OR, GR_XOR..
*/ */
{ {
int zoom; int zoom;
......
...@@ -16,15 +16,17 @@ ...@@ -16,15 +16,17 @@
class TEXTE_MODULE : public BOARD_ITEM class TEXTE_MODULE : public BOARD_ITEM
{ {
public: public:
wxPoint m_Pos; // Real coord wxPoint m_Pos; // Real (physical)coord
int m_Width; int m_Width;
wxPoint m_Pos0; // coord du debut du texte /ancre, orient 0 wxPoint m_Pos0; // text coordinates relatives to the footprint ancre, orient 0
// Text coordinate ref point is the text centre
char m_Unused; // unused (reserved for future extensions) char m_Unused; // unused (reserved for future extensions)
char m_Miroir; // vue normale / miroir char m_Miroir; // Show normal / mirror
char m_NoShow; // 0: visible 1: invisible (bool) char m_NoShow; // 0: visible 1: invisible (bool)
char m_Type; // 0: ref,1: val, autre = 2..255 char m_Type; // 0: ref,1: val, others = 2..255
int m_Orient; // orientation en 1/10 degre int m_Orient; // orientation in 1/10 deg relative to the footprint
wxSize m_Size; // dimensions (en X et Y) du texte // Physical orient is m_Orient + m_Parent->m_Orient
wxSize m_Size; // text size
wxString m_Text; wxString m_Text;
public: public:
...@@ -55,10 +57,16 @@ public: ...@@ -55,10 +57,16 @@ public:
int GetDrawRotation(); // Return text rotation for drawings and plotting int GetDrawRotation(); // Return text rotation for drawings and plotting
/** Function GetTextRect /** Function GetTextRect
* @return an EDA_Rect which gives the position and size of the text area (for the O orient text and footprint) * @return an EDA_Rect which gives the position and size of the text area (for the 0 orient text and footprint)
*/ */
EDA_Rect GetTextRect(void); EDA_Rect GetTextRect(void);
/**
* Function GetBoundingBox
* returns the bounding box of this Text (according to text and footprint orientation)
*/
EDA_Rect GetBoundingBox();
void SetDrawCoord(); // mise a jour des coordonn�s absolues de trac� void SetDrawCoord(); // mise a jour des coordonn�s absolues de trac�
// a partir des coord relatives // a partir des coord relatives
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment