Commit 9fb2c9fe authored by charras's avatar charras
Browse files

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
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -5,6 +5,17 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
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>
================================================================================
+pcbnew
+81 −48
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include "fctsys.h"
#include "gr_basic.h"
#include "trigo.h"
#include "macros.h"
#include "common.h"
#include "wxstruct.h"
#include "base_struct.h"
@@ -115,14 +116,19 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
 */
{
}


#endif


// see base_struct.h
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;

    for( ; p; p = p->Pnext )
    {
        if( SEARCH_QUIT == p->Visit( inspector, testData, scanTypes ) )
@@ -161,6 +167,7 @@ SEARCH_RESULT EDA_BaseStruct::Visit( INSPECTOR* inspector, const void* testData,


#if defined (DEBUG)

// A function that should have been in wxWidgets
std::ostream& operator<<( std::ostream& out, const wxSize& size )
{
@@ -168,6 +175,7 @@ std::ostream& operator<<( std::ostream& out, const wxSize& size )
    return out;
}


// A function that should have been in wxWidgets
std::ostream& operator<<( std::ostream& out, const wxPoint& pt )
{
@@ -187,15 +195,16 @@ void EDA_BaseStruct::Show( int nestLevel, std::ostream& os )
{
    // for now, make it look like XML:
    wxString s = GetClass();

    s = s + wxT( " " );
    NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">\n";

    /*
    EDA_BaseStruct* kid = m_Son;
    for( ; kid;  kid = kid->Pnext )
    {
        kid->Show( nestLevel+1, os );
    }
      * EDA_BaseStruct* kid = m_Son;
      * for( ; kid;  kid = kid->Pnext )
      * {
      * kid->Show( nestLevel+1, os );
      * }
     */
    NestedSpace( nestLevel + 1, os ) << "Need ::Show() override\n";

@@ -214,11 +223,12 @@ std::ostream& EDA_BaseStruct::NestedSpace( int nestLevel, std::ostream& os )
{
    for( int i = 0; i<nestLevel; ++i )
        os << "  "; // number of spaces here controls indent per nest level

    return os;
}

#endif

#endif


/**************************************************/
@@ -296,6 +306,7 @@ bool EDA_TextStruct::HitTest( const wxPoint& posref )
    return false;
}


/**
 * Function HitTest (overlayed)
 * tests if the given EDA_Rect intersect this object.
@@ -311,6 +322,7 @@ bool EDA_TextStruct::HitTest( EDA_Rect& refArea )
    return false;
}


/*******************************/
int EDA_TextStruct::Pitch()
/*******************************/
@@ -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 */
/**************************/
@@ -791,4 +825,3 @@ void DrawPickedStruct::DeleteWrapperList()
        delete wrapp_struct;
    }
}
+11 −3
Original line number Diff line number Diff line
@@ -194,12 +194,20 @@ public:
    operator wxRect() const { return wxRect( m_Pos, m_Size ); }

    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
 * Basic class, not directly used.
+115 −123
Original line number Diff line number Diff line
@@ -328,6 +328,7 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
                            const wxPoint& offset, int draw_mode )
/**************************************************************/

/** Function DrawEdgesOnly
 *  Draws the footprint edges only to the current Device Context
 *  @param panel = The active Draw Panel (used to know the clip box)
@@ -667,14 +668,16 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
            break;

        case 'A':
            if(Line[1] == 't'){
            if( Line[1] == 't' )
            {
                /* At = (At)tributs du module */
                if( strstr( PtLine, "SMD" ) )
                    m_Attributs |= MOD_CMS;
                if( strstr( PtLine, "VIRTUAL" ) )
                    m_Attributs |= MOD_VIRTUAL;
            }
            if(Line[1] == 'R'){
            if( Line[1] == 'R' )
            {
                //alternate reference, e.g. /478C2408/478AD1B6
                sscanf( PtLine, " %s", BufLine );
                m_Path = CONV_FROM_UTF8( BufLine );
@@ -1054,53 +1057,31 @@ void MODULE::SetRectangleExinscrit()
 */
EDA_Rect MODULE::GetBoundingBox()
{
	// Calculate area without text fielsd:
    // Calculate area without text fields:
    SetRectangleExinscrit();
    EDA_Rect      area = m_RealBoundaryBox;

	area.Normalize();
    // Calculate extended area including text field:
    EDGE_MODULE* EdgeMod = (EDGE_MODULE*) m_Drawings;
	TEXTE_MODULE* text;
    EDA_Rect      text_area;
	wxPoint textstart, textend;
	wxPoint modstart = area.GetOrigin();
	wxPoint modend = area.GetEnd();
    for( int ii = 0 ; ; ii++ )
    {
		if ( ii == 0 )
			text = m_Reference;
		else if ( ii == 1 )
			text = m_Value;
		else
    text_area = m_Reference->GetBoundingBox();
    area.Merge( text_area );

    text_area = m_Value->GetBoundingBox();
    area.Merge( text_area );

    EDGE_MODULE* EdgeMod = (EDGE_MODULE*) m_Drawings;
    for( ; EdgeMod != NULL; EdgeMod = (EDGE_MODULE*) EdgeMod->Pnext )
    {
			if ( EdgeMod == NULL ) break;
			text = (TEXTE_MODULE*) EdgeMod;
			EdgeMod = (EDGE_MODULE*) EdgeMod->Pnext;
			if( text->Type() != TYPETEXTEMODULE )
        if( EdgeMod->Type() != TYPETEXTEMODULE )
            continue;
        text_area = ((TEXTE_MODULE*)EdgeMod)->GetBoundingBox();
        area.Merge( text_area );
    }
		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 )
/*******************************************************/
@@ -1238,6 +1219,7 @@ D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
#else
        if( buf == aPadName )
#endif

            return pad;
    }

@@ -1261,6 +1243,7 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
    while( !done )
    {
        stype = *p;

        switch( stype )
        {
        case TYPEMODULE:
@@ -1286,6 +1269,7 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,

        case TYPEEDGEMODULE:
            result = IterateForward( m_Drawings, inspector, testData, p );

            // skip over any types handled in the above call.
            for( ; ; )
            {
@@ -1294,10 +1278,14 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
                case TYPETEXTEMODULE:
                case TYPEEDGEMODULE:
                    continue;
                default: ;

                default:
                    ;
                }

                break;
            }

            break;

        default:
@@ -1314,6 +1302,7 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,


#if defined (DEBUG)

/**
 * Function Show
 * is used to output the object tree, currently for debugging only.
@@ -1343,12 +1332,14 @@ void MODULE::Show( int nestLevel, std::ostream& os )
    p = m_Pads;
    for( ; p; p = p->Pnext )
        p->Show( nestLevel + 2, os );

    NestedSpace( nestLevel + 1, os ) << "</mpads>\n";

    NestedSpace( nestLevel + 1, os ) << "<mdrawings>\n";
    p = m_Drawings;
    for( ; p; p = p->Pnext )
        p->Show( nestLevel + 2, os );

    NestedSpace( nestLevel + 1, os ) << "</mdrawings>\n";

    p = m_Son;
@@ -1360,4 +1351,5 @@ void MODULE::Show( int nestLevel, std::ostream& os )
    NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
}


#endif
+7 −0
Original line number Diff line number Diff line
@@ -158,6 +158,13 @@ public:
    int     Read_3D_Descr( FILE* File, int* LineNum = NULL );

    /* 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,
                  const wxPoint& offset, int draw_mode );
    void    Draw3D( Pcb3D_GLCanvas* glcanvas );
Loading