component_class.h 4.89 KB
Newer Older
1 2 3
/*****************************************************/
/* Definitions for the Component classes for EESchema */
/*****************************************************/
plyatov's avatar
plyatov committed
4 5 6 7 8 9 10 11 12 13 14 15 16

#ifndef COMPONENT_CLASS_H
#define COMPONENT_CLASS_H

#ifndef eda_global
#define eda_global extern
#endif

#include "macros.h"
#include "base_struct.h"


/* Definition de la representation du composant */
17
#define NUMBER_OF_FIELDS 12 /* Nombre de champs de texte affectes au composant */
18
enum  NumFieldType {
19 20 21 22 23 24 25 26 27 28 29 30
    REFERENCE = 0,          /* Champ Reference of part, i.e. "IC21" */
    VALUE,                  /* Champ Value of part, i.e. "3.3K" */
    FOOTPRINT,              /* Champ Name Module PCB, i.e. "16DIP300" */
    SHEET_FILENAME,         /* Champ Name Schema component, i.e. "cnt16.sch" */
    FIELD1,
    FIELD2,
    FIELD3,
    FIELD4,
    FIELD5,
    FIELD6,
    FIELD7,
    FIELD8
31
};
plyatov's avatar
plyatov committed
32 33 34


/* Class to manage component fields.
35 36 37 38
 *  component fields are texts attached to the component (not the graphic texts)
 *  There are 2 major fields : Reference and Value
 */
class PartTextStruct :  public EDA_BaseStruct, public EDA_TextStruct
plyatov's avatar
plyatov committed
39 40
{
public:
41
    int      m_Layer;
42 43 44
    int      m_FieldId;
    wxString m_Name;    /* Field name (ref, value,pcb, sheet, filed 1..
                         *  and for fields 1 to 8 the name is editable */
plyatov's avatar
plyatov committed
45 46

public:
47 48
    PartTextStruct( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString );
    ~PartTextStruct();
49
    
50 51
    virtual wxString GetClass() const
    {
52
        return wxT( "PartText" );
53
    }
plyatov's avatar
plyatov committed
54

55 56 57 58 59 60 61

    void        PartTextCopy( PartTextStruct* target );
    void        Place( WinEDA_DrawFrame* frame, wxDC* DC );

    EDA_Rect    GetBoundaryBox();
    bool        IsVoid();
    void        SwapData( PartTextStruct* copyitem );
plyatov's avatar
plyatov committed
62 63
};

64

plyatov's avatar
plyatov committed
65
/* the class DrawPartStruct describes a basic virtual component
66 67 68 69 70
 *  Not used directly:
 *  used classes are EDA_SchComponentStruct (the "classic" schematic component
 *  and the Pseudo component DrawSheetStruct
 */
class DrawPartStruct : public EDA_BaseStruct
plyatov's avatar
plyatov committed
71 72
{
public:
73 74 75 76
    int            m_Layer;
    wxString       m_ChipName;  /* Key to look for in the library, i.e. "74LS00". */
    PartTextStruct m_Field[NUMBER_OF_FIELDS];
    wxPoint        m_Pos;       /* Exact position of part. */
plyatov's avatar
plyatov committed
77 78

public:
79 80
    DrawPartStruct( KICAD_T struct_type, const wxPoint &pos );
    ~DrawPartStruct();
81
    
82 83
    virtual wxString GetClass() const
    {
84
        return wxT( "DrawPart" );
85
    }
86 87 88 89 90 91 92

    
    /**
     * Function GetReference
     * returns a reference to the Reference
     */
    const wxString& GetReference() { return m_Field[REFERENCE].m_Text; }
plyatov's avatar
plyatov committed
93 94 95 96
};


/* the class EDA_SchComponentStruct describes a real component */
97
class EDA_SchComponentStruct : public DrawPartStruct
plyatov's avatar
plyatov committed
98 99
{
public:
100 101 102 103 104 105
    int   m_RefIdNumber;        /* reference count: for U1, R2 .. it is the 1 or 2 value */
    int   m_Multi;              /* In multi unit chip - which unit to draw. */
    int   m_FlagControlMulti;
    int   m_Convert;            /* Gestion des mutiples representations (ex: conversion De Morgan) */
    int   m_Transform[2][2];    /* The rotation/mirror transformation matrix. */
    bool* m_PinIsDangling;      // liste des indicateurs de pin non connectee
plyatov's avatar
plyatov committed
106 107

public:
108 109 110
    EDA_SchComponentStruct( const wxPoint& pos = wxPoint( 0, 0 ) );
    ~EDA_SchComponentStruct( void ) { }
    
111 112
    virtual wxString GetClass() const
    {
113
        return wxT( "EDA_SchComponent" );
114
    }
115 116


117
    EDA_SchComponentStruct* GenCopy();
118 119 120 121 122 123 124
    void                    SetRotationMiroir( int type );
    int                     GetRotationMiroir();
    wxPoint                 GetScreenCoord( const wxPoint& coord );
    void                    Display_Infos( WinEDA_DrawFrame* frame );
    void                    ClearAnnotation();
    EDA_Rect                GetBoundaryBox();

125 126 127 128 129 130 131 132 133 134 135 136
    const wxString&         ReturnFieldName( int aFieldNdx ) const;
    

    /**
     * Function GetFieldValue
     * returns a reference to the field value.
     * @param aFieldNdx An index into the array of fields, 0 - FIELD8
     * @return const wxString& - the field value or wxEmptyString
     */
    const wxString&         GetFieldValue( int aFieldNdx ) const;

    
137 138 139 140 141 142 143 144
    virtual void            Draw( WinEDA_DrawPanel* panel,
                                  wxDC* DC,
                                  const wxPoint& offset,
                                  int draw_mode,
                                  int Color = -1 );
    void                    SwapData( EDA_SchComponentStruct* copyitem );

    virtual void            Place( WinEDA_DrawFrame* frame, wxDC* DC );
145 146 147 148 149 150 151 152 153 154 155
    
#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 Show( int nestLevel, std::ostream& os );
#endif    
plyatov's avatar
plyatov committed
156 157 158 159
};


#endif /* COMPONENT_CLASS_H */