Commit 726a8ab4 authored by dickelbeck's avatar dickelbeck
Browse files

collector work

parent 4272380e
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -530,7 +530,7 @@ int color;
			break;
			break;


		case RECT :
		case RECT :
		case SPECIAL_PAD:
//		case SPECIAL_PAD:
		case TRAPEZE:
		case TRAPEZE:
			{
			{
			int ddx, ddy ;
			int ddx, ddy ;
+28 −8
Original line number Original line Diff line number Diff line
@@ -4,6 +4,26 @@ 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.


2007-Aug-30 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+ pcbnew
  * Removed SEGVIA::IsViaOnLayer, and instead implemented an override to 
    virtual BOARD_ITEM::IsOnLayer() called SEGVIA::IsOnLayer().
  * Tweaked TRACK::Visit() to not traverse the KICAD_T scan list and a 
    corresponding change to BOARD::Vist() so we can now get VIA priority 
    if desired.  (Have to traverse m_Tracks twice, wonder if we could use
    two lists: m_Tracks and a new m_Vias?)
  * Changed signature of MODULE::Display_Infos( WinEDA_DrawFrame* frame ) so
    it gets called virtually with any BOARD_ITEM* which is actually a MODULE*.
    This was a bug.
  * With virtual functions, it is now critical that the correct object type
    be instantiated.  This was not happening in ioascii.cpp when reading 
    the vias.  Bug fixed.
  * GENERAL_COLLECTOR getting closer to useable.
    @todo search further for new TRACK( TRACK* ) and make sure no vias are
    being made this way.


2007-aug-30 UPDATE   Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
2007-aug-30 UPDATE   Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
================================================================================
+ eeschema & pcbnew
+ eeschema & pcbnew
+1 −1
Original line number Original line Diff line number Diff line
@@ -211,7 +211,7 @@ SEARCH_RESULT EDA_BaseStruct::Visit( INSPECTOR* inspector, const void* testData,
{
{
    KICAD_T     stype;
    KICAD_T     stype;


#if defined(DEBUG)
#if 0 && defined(DEBUG)
    std::cout <<  GetClass().mb_str() << ' ';
    std::cout <<  GetClass().mb_str() << ' ';
#endif
#endif
    
    
+26 −25
Original line number Original line Diff line number Diff line
@@ -160,7 +160,7 @@ private:
    int             m_Status;
    int             m_Status;


private:
private:
    void InitVars( void );
    void InitVars();


public:
public:


@@ -174,7 +174,7 @@ public:
    int     GetState( int type );
    int     GetState( int type );
    void    SetState( int type, int state );
    void    SetState( int type, int state );


    int ReturnStatus( void ) const
    int ReturnStatus() const
    {
    {
        return m_Status;
        return m_Status;
    }
    }
@@ -347,11 +347,11 @@ public:


public:
public:
    EDA_TextStruct( const wxString& text = wxEmptyString );
    EDA_TextStruct( const wxString& text = wxEmptyString );
    virtual ~EDA_TextStruct( void );
    virtual ~EDA_TextStruct();
    void    CreateDrawData( void );
    void    CreateDrawData();


    int     GetLength( void ) { return m_Text.Length(); };
    int     GetLength() { return m_Text.Length(); };
    int     Pitch( void );/* retourne le pas entre 2 caracteres */
    int     Pitch();/* retourne le pas entre 2 caracteres */
    void    Draw( WinEDA_DrawPanel* panel, wxDC* DC,
    void    Draw( WinEDA_DrawPanel* panel, wxDC* DC,
                  const wxPoint& offset, int color,
                  const wxPoint& offset, int color,
                  int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 );
                  int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 );
@@ -364,13 +364,13 @@ public:
     */
     */
    bool    HitTest( const wxPoint& ref_pos );
    bool    HitTest( const wxPoint& ref_pos );
    
    
    int     Len_Size( void ); // Return the text lenght in internal units
    int     Len_Size(); // Return the text lenght in internal units
};
};




/**
/**
 * Class BOARD_ITEM
 * Class BOARD_ITEM
 * is an abstract base class for any item which can be embedded within the BOARD
 * is a base class for any item which can be embedded within the BOARD
 * container class, and therefore instances of derived classes should only be 
 * container class, and therefore instances of derived classes should only be 
 * found in PCBNEW or other programs that use class BOARD and its contents. 
 * found in PCBNEW or other programs that use class BOARD and its contents. 
 * The corresponding class in EESCHEMA seems to be DrawPartStruct.
 * The corresponding class in EESCHEMA seems to be DrawPartStruct.
@@ -441,7 +441,7 @@ public:
    
    
    /**
    /**
     * Function IsLocked
     * Function IsLocked
     * @returns bool - true if the object is locked, else false
     * @return bool - true if the object is locked, else false
     */
     */
    virtual bool IsLocked() const
    virtual bool IsLocked() const
    {
    {
@@ -469,11 +469,11 @@ public:


public:
public:
    DrawPickedStruct( EDA_BaseStruct* pickedstruct = NULL );
    DrawPickedStruct( EDA_BaseStruct* pickedstruct = NULL );
    ~DrawPickedStruct( void );
    ~DrawPickedStruct();
    void Place( WinEDA_DrawFrame* frame, wxDC* DC ) { };
    void Place( WinEDA_DrawFrame* frame, wxDC* DC ) { };
    void DeleteWrapperList( void );
    void DeleteWrapperList();


    DrawPickedStruct* Next( void ) { return (DrawPickedStruct*) Pnext; }
    DrawPickedStruct* Next() { return (DrawPickedStruct*) Pnext; }
};
};




@@ -490,27 +490,28 @@ public:
    wxSize  m_Size;     // Rectangle Size
    wxSize  m_Size;     // Rectangle Size


public:
public:
    EDA_Rect( void ) { };
    EDA_Rect() { };
    wxPoint Centre( void )
    
    wxPoint Centre()
    {
    {
        return wxPoint( m_Pos.x + (m_Size.x >> 1), m_Pos.y + (m_Size.y >> 1) );
        return wxPoint( m_Pos.x + (m_Size.x >> 1), m_Pos.y + (m_Size.y >> 1) );
    }
    }




    void    Normalize( void );              // Ensure the height ant width are >= 0
    void    Normalize();              // Ensure the height and width are >= 0
    bool    Inside( const wxPoint& point ); // Return TRUE if point is in Rect
    bool    Inside( const wxPoint& point ); // Return TRUE if point is in Rect


    bool Inside( int x, int y ) { return Inside( wxPoint( x, y ) ); }
    bool Inside( int x, int y ) { return Inside( wxPoint( x, y ) ); }
    wxSize GetSize( void ) { return m_Size; }
    wxSize GetSize() { return m_Size; }
    int GetX( void ) { return m_Pos.x; }
    int GetX() { return m_Pos.x; }
    int GetY( void ) { return m_Pos.y; }
    int GetY() { return m_Pos.y; }
    wxPoint GetOrigin( void ) { return m_Pos; }
    wxPoint GetOrigin() { return m_Pos; }
    wxPoint GetPosition( void ) { return m_Pos; }
    wxPoint GetPosition() { return m_Pos; }
    wxPoint GetEnd( void ) { return wxPoint( GetRight(), GetBottom() ); }
    wxPoint GetEnd() { return wxPoint( GetRight(), GetBottom() ); }
    int GetWidth( void ) { return m_Size.x; }
    int GetWidth() { return m_Size.x; }
    int GetHeight( void ) { return m_Size.y; }
    int GetHeight() { return m_Size.y; }
    int GetRight( void ) { return m_Pos.x + m_Size.x; }
    int GetRight() { return m_Pos.x + m_Size.x; }
    int GetBottom( void ) { return m_Pos.y + m_Size.y; }
    int GetBottom() { return m_Pos.y + m_Size.y; }
    void SetOrigin( const wxPoint& pos ) { m_Pos = pos; }
    void SetOrigin( const wxPoint& pos ) { m_Pos = pos; }
    void SetOrigin( int x, int y ) { m_Pos.x = x; m_Pos.y = y; }
    void SetOrigin( int x, int y ) { m_Pos.x = x; m_Pos.y = y; }
    void SetSize( const wxSize& size ) { m_Size = size; }
    void SetSize( const wxSize& size ) { m_Size = size; }
+61 −33
Original line number Original line Diff line number Diff line
@@ -54,15 +54,15 @@ protected:
    /// Which object types to scan
    /// Which object types to scan
    const KICAD_T*  m_ScanTypes;
    const KICAD_T*  m_ScanTypes;


    /// The layer that is desired as a primary search criterion
    int             m_PreferredLayer;
    
    /// A place to hold collected objects without taking ownership of their memory.
    /// A place to hold collected objects without taking ownership of their memory.
    std::vector<EDA_BaseStruct*>    list;
    std::vector<EDA_BaseStruct*>    m_List;


    /// The point at which the snapshot was taken.
    /// A point to test against, andt that was used to make the collection.
    wxPoint         m_RefPos;
    wxPoint         m_RefPos;


    /// A bounding box to test against, and that was used to make the collection.
    EDA_Rect        m_RefBox;
    
    /// The time at which the collection was made.
    /// The time at which the collection was made.
    int             m_TimeAtCollection;
    int             m_TimeAtCollection;
    
    
@@ -71,7 +71,6 @@ public:


    COLLECTOR()
    COLLECTOR()
    {
    {
        m_PreferredLayer = 0;
        m_ScanTypes      = 0;
        m_ScanTypes      = 0;
    }
    }


@@ -80,19 +79,13 @@ public:
    }
    }


    
    
    void SetPreferredLayer( int aPreferredLayer )
    {
        m_PreferredLayer = aPreferredLayer;
    }
    
    
    /**
    /**
     * Function GetCount
     * Function GetCount
     * returns the number of objects in the list
     * returns the number of objects in the list
     */
     */
    unsigned GetCount() const
    unsigned GetCount() const
    {
    {
        return list.size();
        return m_List.size();
    }
    }


    
    
@@ -102,7 +95,7 @@ public:
     */
     */
    void Empty()
    void Empty()
    {
    {
        list.clear();
        m_List.clear();
    }
    }


    
    
@@ -113,7 +106,7 @@ public:
     */
     */
    void Append( EDA_BaseStruct* item )
    void Append( EDA_BaseStruct* item )
    {
    {
        list.push_back( item );
        m_List.push_back( item );
    }
    }




@@ -126,22 +119,23 @@ public:
    EDA_BaseStruct* operator[]( int ndx ) const
    EDA_BaseStruct* operator[]( int ndx ) const
    {
    {
        if( (unsigned)ndx < GetCount() )
        if( (unsigned)ndx < GetCount() )
            return list[ ndx ];
            return m_List[ ndx ];
        return NULL;
        return NULL;
    }
    }


    
    /**
     * Function SetScanTypes
     * records the list of KICAD_T types to consider for collection by
     * the Inspect() function.
     * @param scanTypes An array of KICAD_T, terminated by EOT.  No copy is
     *  is made of this array (so cannot come from caller's stack).
     */
    void SetScanTypes( const KICAD_T* scanTypes )
    void SetScanTypes( const KICAD_T* scanTypes )
    {
    {
        m_ScanTypes = scanTypes;
        m_ScanTypes = scanTypes;
    }
    }
    
    
    wxPoint GetRefPos() const  {  return m_RefPos; }
    
    void SetRefPos( const wxPoint& arefPos )
    {
        m_RefPos = arefPos;
    }

    void SetTimeNow()
    void SetTimeNow()
    {
    {
        m_TimeAtCollection = GetTimeStamp();
        m_TimeAtCollection = GetTimeStamp();
@@ -151,6 +145,12 @@ public:
        return m_TimeAtCollection;
        return m_TimeAtCollection;
    }
    }


    void SetRefPos( const wxPoint& aRefPos )  {  m_RefPos = aRefPos; }
    const wxPoint& GetRefPos() const  {  return m_RefPos; }

    void SetBoundingBox( const EDA_Rect& aRefBox ) { m_RefBox = aRefBox;  }
    const EDA_Rect& GetBoundingBox() const {  return m_RefBox; }
    
    
    
    /**
    /**
     * Function IsSimilarPointAndTime
     * Function IsSimilarPointAndTime
@@ -196,28 +196,56 @@ public:
    
    


    /**
    /**
     * Function Scan
     * Function Collect
     * scans a BOARD using this class's Inspector method, which does the collection.
     * scans an EDA_BaseStruct using this class's Inspector method, which does 
     * @param board A BOARD to scan.
     * the collection.
     * @param refPos A wxPoint to use in hit-testing.
     * @param container An EDA_BaseStruct to scan, including those items it contains.
     * @param aRefPos A wxPoint to use in hit-testing.
     *
     * example implementation, in derived class:
     *
    virtual void Collect( EDA_BaseStruct* container, const wxPoint& aRefPos )
    {
        example implementation:
        
        SetRefPos( aRefPos );    // remember where the snapshot was taken from
        
        Empty();        // empty the collection
        
        // visit the board with the INSPECTOR (me).
        container->Visit(   this,       // INSPECTOR* inspector
                            NULL,       // const void* testData, 
                            m_ScanTypes);
        SetTimeNow();                   // when it was taken
    }
    */
    
    
    /**
     * Function Collect
     * scans an EDA_BaseStruct using this class's Inspector method, which does 
     * the collection.
     * @param container An EDA_BaseStruct to scan, including those items it contains.
     * @param aRefBox An EDA_Rect to use in bounds-testing.
     *
     *
     * example implementation, in derived class:
     * example implementation, in derived class:
     *
     *
    virtual void Scan( BOARD* board, const wxPoint& refPos )
    virtual void Collect( EDA_BaseStruct* container, const EDA_Rect& aRefBox )
    {
    {
        example implementation:
        example implementation:
        
        
        SetRefPos( refPos );        // remember where the snapshot was taken from
        SetBoundingBox( aRefBox );  // pass box to Inspect()
        
        
        Empty();        // empty the collection
        Empty();        // empty the collection
        
        
        // visit the board with the INSPECTOR (me).
        // visit the board with the INSPECTOR (me).
        board->Visit(   this,       // INSPECTOR* inspector
        container->Visit(   this,       // INSPECTOR* inspector
                            NULL,       // const void* testData, 
                            NULL,       // const void* testData, 
                            m_ScanTypes);
                            m_ScanTypes);
        SetTimeNow();                   // when it was taken
        SetTimeNow();                   // when it was taken
    }
    }
    */
    */
    
};
};


#endif  // COLLECTOR_H
#endif  // COLLECTOR_H
Loading