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
......
This diff is collapsed.
...@@ -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.
......
This diff is collapsed.
...@@ -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