Commit 5748b791 authored by dickelbeck's avatar dickelbeck
Browse files

added some conditional DEBUG code for showing the pcb object tree in simple XML format

parent 02a2268f
Loading
Loading
Loading
Loading
+45 −4
Original line number Original line Diff line number Diff line
@@ -18,8 +18,7 @@




// DrawStructureType names for error messages only:
// DrawStructureType names for error messages only:
static wxString DrawStructureTypeName[MAX_STRUCT_TYPE_ID + 1]
static wxString DrawStructureTypeName[MAX_STRUCT_TYPE_ID + 1] = {
= {
    wxT( "Not init" ),
    wxT( "Not init" ),


    wxT( "Pcb" ),
    wxT( "Pcb" ),
@@ -168,10 +167,9 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
 */
 */
{
{
}
}


#endif
#endif



/*********************************************/
/*********************************************/
wxString EDA_BaseStruct::ReturnClassName( void )
wxString EDA_BaseStruct::ReturnClassName( void )
/*********************************************/
/*********************************************/
@@ -191,6 +189,48 @@ wxString EDA_BaseStruct::ReturnClassName( void )
}
}





#if defined(DEBUG)

/**
 * Function Show
 * is used to output the object tree, currently for debugging only.
 * @param nestLevel An aid to prettier tree indenting, and is the level 
 *          of nesting of this object within the overall tree.
 * @param os The ostream& to output to.
 */
void EDA_BaseStruct::Show( int nestLevel, std::ostream& os )
{
    // for now, make it look like XML:
    NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << ">\n";

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

    
/** 
 * Function NestedSpace
 * outputs nested space for pretty indenting.
 * @param nestLevel The nest count
 * @param os The ostream&, where to output
 * @return std::ostream& - for continuation.
 **/
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


/**********************************************************************************************/
/**********************************************************************************************/
EDA_BaseLineStruct::EDA_BaseLineStruct( EDA_BaseStruct* StructFather, DrawStructureType idtype ) :
EDA_BaseLineStruct::EDA_BaseLineStruct( EDA_BaseStruct* StructFather, DrawStructureType idtype ) :
    EDA_BaseStruct( StructFather, idtype )
    EDA_BaseStruct( StructFather, idtype )
@@ -721,3 +761,4 @@ void DrawPickedStruct::DeleteWrapperList( void )
        delete wrapp_struct;
        delete wrapp_struct;
    }
    }
}
}
+27 −0
Original line number Original line Diff line number Diff line
@@ -6,6 +6,11 @@
#define BASE_STRUCT_H
#define BASE_STRUCT_H




#if defined(DEBUG)
#include <iostream>         // needed for Show()
#endif


/* Id for class identification, at run time */
/* Id for class identification, at run time */
enum DrawStructureType {
enum DrawStructureType {
    TYPE_NOT_INIT = 0,
    TYPE_NOT_INIT = 0,
@@ -123,8 +128,30 @@ public:
                          const wxPoint&    offset,
                          const wxPoint&    offset,
                          int               draw_mode,
                          int               draw_mode,
                          int               Color = -1 );
                          int               Color = -1 );
    
#if defined(DEBUG)
    /**
     * Function Show
     * is used to output the object tree, currently for debugging only.
     * @param nestLevel An aid to prettier tree indenting, and is the level 
     *          of nesting of this object within the overall tree.
     * @param os The ostream& to output to.
     */
    virtual void Show( int nestLevel, std::ostream& os );
    
    /** 
     * Function NestedSpace
     * outputs nested space for pretty indenting.
     * @param nestLevel The nest count
     * @param os The ostream&, where to output
     * @return std::ostream& - for continuation.
     **/
    static std::ostream& NestedSpace( int nestLevel, std::ostream& os );
#endif

};
};



// Text justify:
// Text justify:
// Values -1,0,1 are used in computations, do not change them
// Values -1,0,1 are used in computations, do not change them
typedef enum {
typedef enum {
+16 −3
Original line number Original line Diff line number Diff line
@@ -176,15 +176,16 @@ public:
    EDA_BoardDesignSettings( void );
    EDA_BoardDesignSettings( void );
};
};



// Values for m_DisplayViaMode member:
// Values for m_DisplayViaMode member:
enum DisplayViaMode {
enum DisplayViaMode {
    VIA_HOLE_NOT_SHOW = 0,
    VIA_HOLE_NOT_SHOW = 0,
    VIA_SPECIAL_HOLE_SHOW,
    VIA_SPECIAL_HOLE_SHOW,
    ALL_VIA_HOLE_SHOW,
    ALL_VIA_HOLE_SHOW,
    OPT_VIA_HOLE_END
    OPT_VIA_HOLE_END

};
};



class BOARD : public EDA_BaseStruct
class BOARD : public EDA_BaseStruct
{
{
public:
public:
@@ -230,6 +231,18 @@ public:


    // Calcul du rectangle d'encadrement:
    // Calcul du rectangle d'encadrement:
    bool    ComputeBoundaryBox( void );
    bool    ComputeBoundaryBox( void );
    
    
#if defined(DEBUG)
    /**
     * Function Show
     * is used to output the object tree, currently for debugging only.
     * @param nestLevel An aid to prettier tree indenting, and is the level 
     *          of nesting of this object within the overall tree.
     * @param os The ostream& to output to.
     */
    virtual void Show( int nestLevel, std::ostream& os );
#endif
};
};




+33 −0
Original line number Original line Diff line number Diff line
@@ -254,3 +254,36 @@ bool BOARD::ComputeBoundaryBox( void )


    return Has_Items;
    return Has_Items;
}
}


#if defined(DEBUG)
/**
 * Function Show
 * is used to output the object tree, currently for debugging only.
 * @param nestLevel An aid to prettier tree indenting, and is the level 
 *          of nesting of this object within the overall tree.
 * @param os The ostream& to output to.
 */
void BOARD::Show( int nestLevel, std::ostream& os )
{
    // for now, make it look like XML:
    NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << ">\n";

    // specialization of the output:
    EDA_BaseStruct* p = m_Modules;
    for( ; p; p = p->Pnext )
        p->Show( nestLevel+1, os );

    p = m_Drawings;
    for( ; p; p = p->Pnext )
        p->Show( nestLevel+1, os );
    
    EDA_BaseStruct* kid = m_Son;
    for( ; kid;  kid = kid->Pnext )
    {
        kid->Show( nestLevel+1, os );
    }
    
    NestedSpace( nestLevel, os ) << "</" << ReturnClassName().mb_str() << ">\n";
}
#endif
+1053 −951
Original line number Original line Diff line number Diff line
@@ -29,9 +29,10 @@
void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
                        int dim_ancre, int draw_mode )
                        int dim_ancre, int draw_mode )
/*********************************************************************************/
/*********************************************************************************/

/* trace de l'ancre (croix verticale)
/* trace de l'ancre (croix verticale)
(doit etre fait apres les pads,
 *  (doit etre fait apres les pads,
car le trace du trou efface tout donc peut etre l'ancre */
 *  car le trace du trou efface tout donc peut etre l'ancre */
{
{
    int zoom = panel->GetZoom();
    int zoom = panel->GetZoom();
    int anchor_size = dim_ancre * zoom;
    int anchor_size = dim_ancre * zoom;
@@ -78,6 +79,7 @@ MODULE::MODULE(BOARD * parent): EDA_BaseStruct( parent, TYPEMODULE)
    m_3D_Drawings  = new Struct3D_Master( this );
    m_3D_Drawings  = new Struct3D_Master( this );
}
}



/* Destructeur */
/* Destructeur */
MODULE::~MODULE( void )
MODULE::~MODULE( void )
{
{
@@ -103,6 +105,7 @@ EDA_BaseStruct * Struct, * NextStruct;
    for( Struct = m_Drawings; Struct != NULL; Struct = NextStruct )
    for( Struct = m_Drawings; Struct != NULL; Struct = NextStruct )
    {
    {
        NextStruct = Struct->Pnext;
        NextStruct = Struct->Pnext;

        switch( (Struct->m_StructType) )
        switch( (Struct->m_StructType) )
        {
        {
        case TYPEEDGEMODULE:
        case TYPEEDGEMODULE:
@@ -121,6 +124,7 @@ EDA_BaseStruct * Struct, * NextStruct;
    }
    }
}
}



/*********************************/
/*********************************/
void MODULE::Copy( MODULE* Module )
void MODULE::Copy( MODULE* Module )
/*********************************/
/*********************************/
@@ -169,6 +173,7 @@ D_PAD * pad,* lastpad;
    for( ; OldStruct; OldStruct = OldStruct->Pnext )
    for( ; OldStruct; OldStruct = OldStruct->Pnext )
    {
    {
        NewStruct = NULL;
        NewStruct = NULL;

        switch( OldStruct->m_StructType )
        switch( OldStruct->m_StructType )
        {
        {
        case TYPETEXTEMODULE:
        case TYPETEXTEMODULE:
@@ -180,11 +185,14 @@ D_PAD * pad,* lastpad;
            NewStruct = new EDGE_MODULE( this );
            NewStruct = new EDGE_MODULE( this );
            ( (EDGE_MODULE*) NewStruct )->Copy( (EDGE_MODULE*) OldStruct );
            ( (EDGE_MODULE*) NewStruct )->Copy( (EDGE_MODULE*) OldStruct );
            break;
            break;

        default:
        default:
            DisplayError( NULL, wxT( "Internal Err: CopyModule: type indefini" ) );
            DisplayError( NULL, wxT( "Internal Err: CopyModule: type indefini" ) );
            break;
            break;
        }
        }
		if( NewStruct == NULL) break;

        if( NewStruct == NULL )
            break;
        if( m_Drawings == NULL )
        if( m_Drawings == NULL )
        {
        {
            NewStruct->Pback = this;
            NewStruct->Pback = this;
@@ -215,11 +223,11 @@ Struct3D_Master * Struct3D, *NewStruct3D, *CurrStruct3D;
    /* Copie des elements complementaires */
    /* Copie des elements complementaires */
    m_Doc     = Module->m_Doc;
    m_Doc     = Module->m_Doc;
    m_KeyWord = Module->m_KeyWord;
    m_KeyWord = Module->m_KeyWord;

}
}



/* supprime du chainage la structure Struct
/* supprime du chainage la structure Struct
  les structures arrieres et avant sont chainees directement
 *  les structures arrieres et avant sont chainees directement
 */
 */
void MODULE::UnLink( void )
void MODULE::UnLink( void )
{
{
@@ -230,19 +238,21 @@ void MODULE::UnLink( void )
        {
        {
            Pback->Pnext = Pnext;
            Pback->Pnext = Pnext;
        }
        }

        else                                /* Le chainage arriere pointe sur la structure "Pere" */
        else                                /* Le chainage arriere pointe sur la structure "Pere" */
        {
        {
            if( GetState( DELETED ) )       // A REVOIR car Pback = NULL si place en undelete
            if( GetState( DELETED ) )       // A REVOIR car Pback = NULL si place en undelete
            {
            {
				if( g_UnDeleteStack ) g_UnDeleteStack[g_UnDeleteStackPtr-1] = Pnext;
                if( g_UnDeleteStack )
                    g_UnDeleteStack[g_UnDeleteStackPtr - 1] = Pnext;
            }
            }
			else ((BOARD*)Pback)->m_Modules = (MODULE *) Pnext;
            else
                ( (BOARD*) Pback )->m_Modules = (MODULE*) Pnext;
        }
        }
    }
    }


    /* Modification du chainage avant */
    /* Modification du chainage avant */
	if( Pnext) Pnext->Pback = Pback;
    if( Pnext )
        Pnext->Pback = Pback;


    Pnext = Pback = NULL;
    Pnext = Pback = NULL;
}
}
@@ -252,13 +262,14 @@ void MODULE::UnLink( void )
void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
                   const wxPoint& offset, int draw_mode )
                   const wxPoint& offset, int draw_mode )
/**********************************************************/
/**********************************************************/

/* Dessin d'une empreinte sur l'ecran actif:
/* Dessin d'une empreinte sur l'ecran actif:
	Entree :
 *  Entree :
		Module: pointeur sur le module
 *      Module: pointeur sur le module
		ox, oy = offset de trace
 *      ox, oy = offset de trace
		draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND)
 *      draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND)
	Utilise par ailleur:
 *  Utilise par ailleur:
		Description des parametres de l'empreinte calcules par caract() ;
 *      Description des parametres de l'empreinte calcules par caract() ;
 */
 */
{
{
    D_PAD*          pt_pad;
    D_PAD*          pt_pad;
@@ -269,7 +280,8 @@ TEXTE_MODULE * PtTexte;
    pt_pad = m_Pads;
    pt_pad = m_Pads;
    for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
    for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
    {
    {
		if ( pt_pad->m_Flags & IS_MOVED ) continue;
        if( pt_pad->m_Flags & IS_MOVED )
            continue;
        pt_pad->Draw( panel, DC, offset, draw_mode );
        pt_pad->Draw( panel, DC, offset, draw_mode );
    }
    }


@@ -285,7 +297,8 @@ TEXTE_MODULE * PtTexte;
    PtStruct = m_Drawings;
    PtStruct = m_Drawings;
    for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
    for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
    {
    {
		if ( PtStruct->m_Flags & IS_MOVED ) continue;
        if( PtStruct->m_Flags & IS_MOVED )
            continue;


        switch( PtStruct->m_StructType )
        switch( PtStruct->m_StructType )
        {
        {
@@ -298,7 +311,8 @@ TEXTE_MODULE * PtTexte;
            ( (EDGE_MODULE*) PtStruct )->Draw( panel, DC, offset, draw_mode );
            ( (EDGE_MODULE*) PtStruct )->Draw( panel, DC, offset, draw_mode );
            break;
            break;


			default: break;
        default:
            break;
        }
        }
    }
    }
}
}
@@ -321,7 +335,8 @@ EDA_BaseStruct * PtStruct;
            ( (EDGE_MODULE*) PtStruct )->Draw( panel, DC, offset, draw_mode );
            ( (EDGE_MODULE*) PtStruct )->Draw( panel, DC, offset, draw_mode );
            break;
            break;


			default: break;
        default:
            break;
        }
        }
    }
    }
}
}
@@ -330,6 +345,7 @@ EDA_BaseStruct * PtStruct;
/*************************************/
/*************************************/
int MODULE::WriteDescr( FILE* File )
int MODULE::WriteDescr( FILE* File )
/*************************************/
/*************************************/

/* Sauvegarde de la description d'un MODULE
/* Sauvegarde de la description d'un MODULE
 */
 */
{
{
@@ -341,7 +357,8 @@ EDA_BaseStruct * PtStruct;
    int             ii, NbLigne = 0;
    int             ii, NbLigne = 0;
    wxString        msg;
    wxString        msg;


	if( GetState(DELETED) ) return(NbLigne);
    if( GetState( DELETED ) )
        return NbLigne;


    /* Generation du fichier module: */
    /* Generation du fichier module: */
    fprintf( File, "$MODULE %s\n", CONV_TO_UTF8( m_LibRef ) );
    fprintf( File, "$MODULE %s\n", CONV_TO_UTF8( m_LibRef ) );
@@ -351,10 +368,12 @@ wxString msg;
    memset( StringStat, 0, sizeof(StringStat) );
    memset( StringStat, 0, sizeof(StringStat) );
    if( m_ModuleStatus & MODULE_is_LOCKED )
    if( m_ModuleStatus & MODULE_is_LOCKED )
        StringStat[0] = 'F';
        StringStat[0] = 'F';
	else  StringStat[0] = '~';
    else
        StringStat[0] = '~';
    if( m_ModuleStatus & MODULE_is_PLACED )
    if( m_ModuleStatus & MODULE_is_PLACED )
        StringStat[1] = 'P';
        StringStat[1] = 'P';
	else  StringStat[1] = '~';
    else
        StringStat[1] = '~';


    fprintf( File, "Po %d %d %d %d %8.8lX %8.8lX %s\n",
    fprintf( File, "Po %d %d %d %d %8.8lX %8.8lX %s\n",
             m_Pos.x, m_Pos.y,
             m_Pos.x, m_Pos.y,
@@ -387,8 +406,10 @@ wxString msg;
    if( m_Attributs != MOD_DEFAULT )
    if( m_Attributs != MOD_DEFAULT )
    {
    {
        fprintf( File, "At " );
        fprintf( File, "At " );
		if( m_Attributs & MOD_CMS ) fprintf(File,"SMD ");
        if( m_Attributs & MOD_CMS )
		if( m_Attributs & MOD_VIRTUAL ) fprintf(File,"VIRTUAL ");
            fprintf( File, "SMD " );
        if( m_Attributs & MOD_VIRTUAL )
            fprintf( File, "VIRTUAL " );
        fprintf( File, "\n" );
        fprintf( File, "\n" );
    }
    }


@@ -443,7 +464,9 @@ wxString msg;
                        PtStruct->m_StructType );
                        PtStruct->m_StructType );
            DisplayError( NULL, msg );
            DisplayError( NULL, msg );
            break;
            break;
			}	/* Fin switch gestion des Items draw */
        }

        /* Fin switch gestion des Items draw */
    }
    }


    /* Generation de la liste des pads */
    /* Generation de la liste des pads */
@@ -454,18 +477,20 @@ wxString msg;
        NbLigne += ii;
        NbLigne += ii;
    }
    }


	/* Generation des informations de trac 3D */
    /* Generation des informations de trac3D */
    Write_3D_Descr( File );
    Write_3D_Descr( File );


    /* Fin de description: */
    /* Fin de description: */
    fprintf( File, "$EndMODULE  %s\n", CONV_TO_UTF8( m_LibRef ) );
    fprintf( File, "$EndMODULE  %s\n", CONV_TO_UTF8( m_LibRef ) );
    NbLigne++;
    NbLigne++;
	return(NbLigne);
    return NbLigne;
}
}



/***************************************/
/***************************************/
int MODULE::Write_3D_Descr( FILE* File )
int MODULE::Write_3D_Descr( FILE* File )
/***************************************/
/***************************************/

/* Sauvegarde de la description 3D du MODULE
/* Sauvegarde de la description 3D du MODULE
 */
 */
{
{
@@ -505,12 +530,14 @@ Struct3D_Master * Struct3D = m_3D_Drawings;
    return 0;
    return 0;
}
}



/****************************************************/
/****************************************************/
int MODULE::Read_3D_Descr( FILE* File, int* LineNum )
int MODULE::Read_3D_Descr( FILE* File, int* LineNum )
/****************************************************/
/****************************************************/

/* Lecture de la description d'un MODULE (format Ascii)
/* Lecture de la description d'un MODULE (format Ascii)
	la 1ere ligne de descr ($MODULE) est supposee etre deja lue
 *  la 1ere ligne de descr ($MODULE) est supposee etre deja lue
	retourne 0 si OK
 *  retourne 0 si OK
 */
 */
{
{
    char             Line[1024];
    char             Line[1024];
@@ -522,6 +549,7 @@ Struct3D_Master * Struct3D = m_3D_Drawings;
        Struct3D_Master* NewStruct3D;
        Struct3D_Master* NewStruct3D;
        while( Struct3D->Pnext )
        while( Struct3D->Pnext )
            Struct3D = (Struct3D_Master*) Struct3D->Pnext;
            Struct3D = (Struct3D_Master*) Struct3D->Pnext;

        Struct3D->Pnext    = NewStruct3D = new Struct3D_Master( this );
        Struct3D->Pnext    = NewStruct3D = new Struct3D_Master( this );
        NewStruct3D->Pback = Struct3D;
        NewStruct3D->Pback = Struct3D;
        Struct3D = NewStruct3D;
        Struct3D = NewStruct3D;
@@ -532,7 +560,8 @@ Struct3D_Master * Struct3D = m_3D_Drawings;
        switch( Line[0] )
        switch( Line[0] )
        {
        {
        case '$':       // Fin de description
        case '$':       // Fin de description
				if( Line[1] == 'E' ) return 0;
            if( Line[1] == 'E' )
                return 0;
            return 1;
            return 1;


        case 'N':       // Shape File Name
        case 'N':       // Shape File Name
@@ -568,15 +597,18 @@ Struct3D_Master * Struct3D = m_3D_Drawings;
            break;
            break;
        }
        }
    }
    }

    return 1;
    return 1;
}
}



/**************************************************/
/**************************************************/
int MODULE::ReadDescr( FILE* File, int* LineNum )
int MODULE::ReadDescr( FILE* File, int* LineNum )
/**************************************************/
/**************************************************/

/* Lecture de la description d'un MODULE (format Ascii)
/* Lecture de la description d'un MODULE (format Ascii)
	la 1ere ligne de descr ($MODULE) est supposee etre deja lue
 *  la 1ere ligne de descr ($MODULE) est supposee etre deja lue
	retourne 0 si OK
 *  retourne 0 si OK
 */
 */
{
{
    D_PAD*          LastPad = NULL, * ptpad;
    D_PAD*          LastPad = NULL, * ptpad;
@@ -590,7 +622,8 @@ int itmp1, itmp2;
    {
    {
        if( Line[0] == '$' )
        if( Line[0] == '$' )
        {
        {
			if( Line[1] == 'E' ) break;
            if( Line[1] == 'E' )
                break;
            if( Line[1] == 'P' )
            if( Line[1] == 'P' )
            {
            {
                ptpad = new D_PAD( this );
                ptpad = new D_PAD( this );
@@ -612,12 +645,16 @@ int itmp1, itmp2;
                LastPad = ptpad;
                LastPad = ptpad;
                continue;
                continue;
            }
            }
			if( Line[1] == 'S' ) Read_3D_Descr(File, LineNum );
            if( Line[1] == 'S' )
                Read_3D_Descr( File, LineNum );
        }
        }




		if ( strlen(Line) < 4 ) continue;
        if( strlen( Line ) < 4 )
		PtLine = Line + 3;  /* Pointe 1er code utile de la ligne */
            continue;
        PtLine = Line + 3;

        /* Pointe 1er code utile de la ligne */
        switch( Line[0] )
        switch( Line[0] )
        {
        {
        case 'P':
        case 'P':
@@ -628,8 +665,10 @@ int itmp1, itmp2;
                    &m_LastEdit_Time, &m_TimeStamp, BufCar1 );
                    &m_LastEdit_Time, &m_TimeStamp, BufCar1 );


            m_ModuleStatus = 0;
            m_ModuleStatus = 0;
				if(BufCar1[0] == 'F') m_ModuleStatus |= MODULE_is_LOCKED;
            if( BufCar1[0] == 'F' )
				if(BufCar1[1] == 'P') m_ModuleStatus |= MODULE_is_PLACED;
                m_ModuleStatus |= MODULE_is_LOCKED;
            if( BufCar1[1] == 'P' )
                m_ModuleStatus |= MODULE_is_PLACED;
            break;
            break;


        case 'L':       /* Li = Lecture du nom librairie du module */
        case 'L':       /* Li = Lecture du nom librairie du module */
@@ -647,18 +686,23 @@ int itmp1, itmp2;
            sscanf( PtLine, " %X %X", &itmp1, &itmp2 );
            sscanf( PtLine, " %X %X", &itmp1, &itmp2 );


            m_CntRot180 = itmp2 & 0x0F;
            m_CntRot180 = itmp2 & 0x0F;
				if( m_CntRot180 > 10 ) m_CntRot180 = 10;
            if( m_CntRot180 > 10 )
                m_CntRot180 = 10;


            m_CntRot90 = itmp1 & 0x0F;
            m_CntRot90 = itmp1 & 0x0F;
				if( m_CntRot90 > 10 ) m_CntRot90 = 0;
            if( m_CntRot90 > 10 )
                m_CntRot90 = 0;
            itmp1 = (itmp1 >> 4) & 0x0F;
            itmp1 = (itmp1 >> 4) & 0x0F;
				if( itmp1 > 10 ) itmp1 = 0;
            if( itmp1 > 10 )
                itmp1 = 0;
            m_CntRot90 |= itmp1 << 4;
            m_CntRot90 |= itmp1 << 4;
            break;
            break;


        case 'A':       /* At = (At)tributs du module */
        case 'A':       /* At = (At)tributs du module */
				if ( strstr(PtLine, "SMD") ) m_Attributs |= MOD_CMS;
            if( strstr( PtLine, "SMD" ) )
				if ( strstr(PtLine, "VIRTUAL") ) m_Attributs |= MOD_VIRTUAL;
                m_Attributs |= MOD_CMS;
            if( strstr( PtLine, "VIRTUAL" ) )
                m_Attributs |= MOD_VIRTUAL;
            break;
            break;


        case 'T':    /* lecture des textes modules */
        case 'T':    /* lecture des textes modules */
@@ -668,7 +712,8 @@ int itmp1, itmp2;
            else if( itmp1 == TEXT_is_VALUE )
            else if( itmp1 == TEXT_is_VALUE )
                DrawText = m_Value;
                DrawText = m_Value;
            else        /* text is a drawing */
            else        /* text is a drawing */
					{DrawText = new TEXTE_MODULE(this);
            {
                DrawText = new TEXTE_MODULE( this );
                if( LastModStruct == NULL )
                if( LastModStruct == NULL )
                {
                {
                    DrawText->Pback = this;
                    DrawText->Pback = this;
@@ -691,22 +736,31 @@ int itmp1, itmp2;


            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
				if( BufCar1[0] == 'M') DrawText->m_Miroir = 0;
            if( BufCar1[0] == 'M' )
				else DrawText->m_Miroir = 1;
                DrawText->m_Miroir = 0;
				if( BufCar2[0]  == 'I') DrawText->m_NoShow = 1;
            else
				else  DrawText->m_NoShow = 0;
                DrawText->m_Miroir = 1;
            if( BufCar2[0]  == 'I' )
                DrawText->m_NoShow = 1;
            else
                DrawText->m_NoShow = 0;


				if(m_Layer == CUIVRE_N) DrawText->m_Layer = SILKSCREEN_N_CU;
            if( m_Layer == CUIVRE_N )
				if(m_Layer == CMP_N) DrawText->m_Layer = SILKSCREEN_N_CMP;
                DrawText->m_Layer = SILKSCREEN_N_CU;
            if( m_Layer == CMP_N )
                DrawText->m_Layer = SILKSCREEN_N_CMP;


            /* calcul de la position vraie */
            /* calcul de la position vraie */
            DrawText->SetDrawCoord();
            DrawText->SetDrawCoord();
            /* Lecture de la chaine "text" */
            /* Lecture de la chaine "text" */
            ReadDelimitedText( BufLine, Line, sizeof(BufLine) );
            ReadDelimitedText( BufLine, Line, sizeof(BufLine) );
            DrawText->m_Text = CONV_FROM_UTF8( BufLine );
            DrawText->m_Text = CONV_FROM_UTF8( BufLine );

            // Controle d'epaisseur raisonnable:
            // Controle d'epaisseur raisonnable:
				if( DrawText->m_Width <= 1 ) DrawText->m_Width = 1;
            if( DrawText->m_Width <= 1 )
				if( DrawText->m_Width > MAX_WIDTH ) DrawText->m_Width = MAX_WIDTH;
                DrawText->m_Width = 1;
            if( DrawText->m_Width > MAX_WIDTH )
                DrawText->m_Width = MAX_WIDTH;
            break;
            break;


        case 'D':    /* lecture du contour */
        case 'D':    /* lecture du contour */
@@ -740,14 +794,17 @@ int itmp1, itmp2;
            break;
            break;
        }
        }
    }
    }

    /* Recalcul de l'encadrement */
    /* Recalcul de l'encadrement */
    Set_Rectangle_Encadrement();
    Set_Rectangle_Encadrement();
	return(0);
    return 0;
}
}



/****************************************************/
/****************************************************/
void MODULE::SetPosition( const wxPoint& newpos )
void MODULE::SetPosition( const wxPoint& newpos )
/****************************************************/
/****************************************************/

// replace le module en position newpos
// replace le module en position newpos
{
{
    int deltaX = newpos.x - m_Pos.x;
    int deltaX = newpos.x - m_Pos.x;
@@ -789,7 +846,8 @@ int deltaY = newpos.y - m_Pos.y;
            break;
            break;
        }
        }


			default: DisplayError(NULL, wxT("Type Draw Indefini")); break;
        default:
            DisplayError( NULL, wxT( "Type Draw Indefini" ) ); break;
        }
        }
    }
    }


@@ -797,10 +855,10 @@ int deltaY = newpos.y - m_Pos.y;
}
}





/*********************************************/
/*********************************************/
void MODULE::SetOrientation( int newangle )
void MODULE::SetOrientation( int newangle )
/*********************************************/
/*********************************************/

/* Tourne de newangle (en 0.1 degres) le module
/* Tourne de newangle (en 0.1 degres) le module
 */
 */
{
{
@@ -851,16 +909,18 @@ int px ,py;
    Set_Rectangle_Encadrement();
    Set_Rectangle_Encadrement();
}
}



/************************************************/
/************************************************/
void MODULE::Set_Rectangle_Encadrement( void )
void MODULE::Set_Rectangle_Encadrement( void )
/************************************************/
/************************************************/

/* Mise a jour du rectangle d'encadrement du module
/* Mise a jour du rectangle d'encadrement du module
	Entree : pointeur sur module
 *  Entree : pointeur sur module
	Le rectangle d'encadrement est le rectangle comprenant les contours et les
 *  Le rectangle d'encadrement est le rectangle comprenant les contours et les
	pads.
 *  pads.
	Le rectangle est calcule:
 *  Le rectangle est calcule:
		pour orient 0
 *      pour orient 0
		en coord relatives / position ancre
 *      en coord relatives / position ancre
 */
 */
{
{
    EDGE_MODULE* pt_edge_mod;
    EDGE_MODULE* pt_edge_mod;
@@ -880,8 +940,10 @@ int xmax, ymax;
    /* Contours: Recherche des coord min et max et mise a jour du cadre */
    /* 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 )
    for( ; pt_edge_mod != NULL; pt_edge_mod = (EDGE_MODULE*) pt_edge_mod->Pnext )
    {
    {
		if( pt_edge_mod->m_StructType != TYPEEDGEMODULE) continue;
        if( pt_edge_mod->m_StructType != TYPEEDGEMODULE )
            continue;
        width = pt_edge_mod->m_Width / 2;
        width = pt_edge_mod->m_Width / 2;

        switch( pt_edge_mod->m_Shape )
        switch( pt_edge_mod->m_Shape )
        {
        {
        case S_ARC:
        case S_ARC:
@@ -927,18 +989,16 @@ int xmax, ymax;
}
}






/****************************************/
/****************************************/
void MODULE::SetRectangleExinscrit( void )
void MODULE::SetRectangleExinscrit( void )
/****************************************/
/****************************************/


/*	Analogue a MODULE::Set_Rectangle_Encadrement() mais en coord reelles:
/*	Analogue a MODULE::Set_Rectangle_Encadrement() mais en coord reelles:
	Mise a jour du rectangle d'encadrement reel du module c.a.d en coord PCB
 *  Mise a jour du rectangle d'encadrement reel du module c.a.d en coord PCB
	Entree : pointeur sur module
 *  Entree : pointeur sur module
	Le rectangle d'encadrement est le rectangle comprenant les contours et les
 *  Le rectangle d'encadrement est le rectangle comprenant les contours et les
	pads.
 *  pads.
	Met egalement a jour la surface (.m_Surface) du module.
 *  Met egalement a jour la surface (.m_Surface) du module.
 */
 */
{
{
    EDGE_MODULE* EdgeMod;
    EDGE_MODULE* EdgeMod;
@@ -954,8 +1014,10 @@ int xmax, ymax;
    EdgeMod = (EDGE_MODULE*) m_Drawings;
    EdgeMod = (EDGE_MODULE*) m_Drawings;
    for( ; EdgeMod != NULL; EdgeMod = (EDGE_MODULE*) EdgeMod->Pnext )
    for( ; EdgeMod != NULL; EdgeMod = (EDGE_MODULE*) EdgeMod->Pnext )
    {
    {
		if( EdgeMod->m_StructType != TYPEEDGEMODULE) continue;
        if( EdgeMod->m_StructType != TYPEEDGEMODULE )
            continue;
        width = EdgeMod->m_Width / 2;
        width = EdgeMod->m_Width / 2;

        switch( EdgeMod->m_Shape )
        switch( EdgeMod->m_Shape )
        {
        {
        case S_ARC:
        case S_ARC:
@@ -995,6 +1057,7 @@ int xmax, ymax;
        xmax = max( xmax, cx + rayon );
        xmax = max( xmax, cx + rayon );
        ymax = max( ymax, cy + rayon );
        ymax = max( ymax, cy + rayon );
    }
    }

    m_RealBoundaryBox.SetWidth( xmax - m_RealBoundaryBox.m_Pos.x );
    m_RealBoundaryBox.SetWidth( xmax - m_RealBoundaryBox.m_Pos.x );
    m_RealBoundaryBox.SetHeight( ymax - m_RealBoundaryBox.m_Pos.y );
    m_RealBoundaryBox.SetHeight( ymax - m_RealBoundaryBox.m_Pos.y );
    m_Surface = ABS( (float) m_RealBoundaryBox.GetWidth() * m_RealBoundaryBox.GetHeight() );
    m_Surface = ABS( (float) m_RealBoundaryBox.GetWidth() * m_RealBoundaryBox.GetHeight() );
@@ -1012,7 +1075,8 @@ bool flag = FALSE;
    wxString msg;
    wxString msg;


    frame->MsgPanel->EraseMsgBox();    /* Effacement de la zone message */
    frame->MsgPanel->EraseMsgBox();    /* Effacement de la zone message */
	if ( frame->m_Ident != PCB_FRAME ) flag = TRUE;
    if( frame->m_Ident != PCB_FRAME )
        flag = TRUE;
    pos = 1;
    pos = 1;
    Affiche_1_Parametre( frame, pos, m_Reference->m_Text, m_Value->m_Text, DARKCYAN );
    Affiche_1_Parametre( frame, pos, m_Reference->m_Text, m_Value->m_Text, DARKCYAN );


@@ -1042,14 +1106,20 @@ wxString msg;
    pos += 6;
    pos += 6;
    EDA_BaseStruct* PtStruct = m_Pads;
    EDA_BaseStruct* PtStruct = m_Pads;
    nbpad = 0;
    nbpad = 0;
	while( PtStruct ) { nbpad ++; PtStruct = PtStruct->Pnext; }
    while( PtStruct )
    {
        nbpad++; PtStruct = PtStruct->Pnext;
    }

    msg.Printf( wxT( "%d" ), nbpad );
    msg.Printf( wxT( "%d" ), nbpad );
    Affiche_1_Parametre( frame, pos, _( "Pads" ), msg, BLUE );
    Affiche_1_Parametre( frame, pos, _( "Pads" ), msg, BLUE );


    pos += 4;
    pos += 4;
    msg  = wxT( ".." );
    msg  = wxT( ".." );
	if( m_ModuleStatus & MODULE_is_LOCKED ) msg[0] = 'F';
    if( m_ModuleStatus & MODULE_is_LOCKED )
	if( m_ModuleStatus & MODULE_is_PLACED ) msg[1] = 'P';
        msg[0] = 'F';
    if( m_ModuleStatus & MODULE_is_PLACED )
        msg[1] = 'P';
    Affiche_1_Parametre( frame, pos, _( "Stat" ), msg, MAGENTA );
    Affiche_1_Parametre( frame, pos, _( "Stat" ), msg, MAGENTA );


    pos += 4;
    pos += 4;
@@ -1067,6 +1137,38 @@ wxString msg;
    wxString doc     = _( "Doc:  " ) + m_Doc;
    wxString doc     = _( "Doc:  " ) + m_Doc;
    wxString keyword = _( "KeyW: " ) + m_KeyWord;
    wxString keyword = _( "KeyW: " ) + m_KeyWord;
    Affiche_1_Parametre( frame, pos, doc, keyword, BLACK );
    Affiche_1_Parametre( frame, pos, doc, keyword, BLACK );
}


#if defined(DEBUG)
/**
 * Function Show
 * is used to output the object tree, currently for debugging only.
 * @param nestLevel An aid to prettier tree indenting, and is the level 
 *          of nesting of this object within the overall tree.
 * @param os The ostream& to output to.
 */
void MODULE::Show( int nestLevel, std::ostream& os )
{
    // for now, make it look like XML, expand on this later.
    
    NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() <<
        " ref=\""      <<  m_Reference->m_Text.mb_str() << 

        "\" value=\"" <<  m_Value->m_Text.mb_str() << 
        "\">\n";

    EDA_BaseStruct* p = m_Drawings;
    for( ; p; p = p->Pnext )
        p->Show( nestLevel+1, os );
    
    
    EDA_BaseStruct* kid = m_Son;
    for( ; kid;  kid = kid->Pnext )
    {
        kid->Show( nestLevel+1, os );
    }
    
    NestedSpace( nestLevel, os ) << "</" << ReturnClassName().mb_str() << ">\n";
}
}


#endif
Loading