Commit e1b5d49f authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

EESchema component library and hierarchical sheet label object improvements.

* Continue component library class clean up and encapsulation work.
* Change hierarchical sheet label container to boost::vector_ptr.
* Encapsulate hierarchical label handling in hierarchical sheet class.
* Convert some missed occurrences of wxString::GetData() to GetChars( wxString ).
* Fix some minor code formatting issues.
parent bf9e49dd
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -675,13 +675,12 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )

        if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE )
        {
            SCH_SHEET* sheet = (SCH_SHEET*) Struct;

            // Add all pins sheets of a selected hierarchical sheet to the list
            SCH_SHEET_PIN* SLabel = ( (SCH_SHEET*) Struct )->m_Label;
            while( SLabel )
            BOOST_FOREACH( SCH_SHEET_PIN label, sheet->GetSheetPins() )
            {
                if( SLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
                    AddPickedItem( screen, SLabel->m_Pos );
                SLabel = (SCH_SHEET_PIN*) SLabel->Next();
                AddPickedItem( screen, label.m_Pos );
            }
        }

+19 −25
Original line number Diff line number Diff line
@@ -340,30 +340,27 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
{
    EDA_BaseStruct* SchItem;
    SCH_COMPONENT*  DrawLibItem;
    SCH_SHEET_PATH* sheet;
    SCH_SHEET_PATH* sheetPath;

    /* Build the sheet (not screen) list */
    SCH_SHEET_LIST  SheetList;

    for( sheet = SheetList.GetFirst();
        sheet != NULL;
        sheet = SheetList.GetNext() )
    for( sheetPath = SheetList.GetFirst();  sheetPath != NULL;  sheetPath = SheetList.GetNext() )
    {
        for( SchItem = sheet->LastDrawList(); SchItem;
            SchItem = SchItem->Next() )
        for( SchItem = sheetPath->LastDrawList();  SchItem;  SchItem = SchItem->Next() )
        {
            if( SchItem->Type() != TYPE_SCH_COMPONENT )
                continue;

            DrawLibItem = (SCH_COMPONENT*) SchItem;
            DrawLibItem->SetParent( sheet->LastScreen() );
            DrawLibItem->SetParent( sheetPath->LastScreen() );
            OBJ_CMP_TO_LIST item;
            item.m_RootCmp   = DrawLibItem;
            item.m_SheetPath = *sheet;
            item.m_Unit = DrawLibItem->GetUnitSelection( sheet );
            item.m_SheetPath = *sheetPath;
            item.m_Unit = DrawLibItem->GetUnitSelection( sheetPath );

            strncpy( item.m_Reference,
                    CONV_TO_UTF8( DrawLibItem->GetRef( sheet ) ),
                     CONV_TO_UTF8( DrawLibItem->GetRef( sheetPath ) ),
                     sizeof( item.m_Reference ) );

            // Ensure always null terminate m_Ref.
@@ -384,19 +381,17 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
{
    SCH_ITEM*       DrawList;
    SCH_SHEET_PIN*  PinLabel;
    SCH_SHEET_PATH* sheet;
    SCH_SHEET_PATH* sheetPath;

    /* Build the sheet list */
    SCH_SHEET_LIST  SheetList;

    LABEL_OBJECT    labet_object;

    for( sheet = SheetList.GetFirst();
        sheet != NULL;
        sheet = SheetList.GetNext() )
    for( sheetPath = SheetList.GetFirst();  sheetPath != NULL;  sheetPath = SheetList.GetNext() )
    {
        DrawList = (SCH_ITEM*) sheet->LastDrawList();
        DrawList = (SCH_ITEM*) sheetPath->LastDrawList();

        while( DrawList )
        {
            switch( DrawList->Type() )
@@ -404,22 +399,21 @@ static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
            case TYPE_SCH_HIERLABEL:
            case TYPE_SCH_GLOBALLABEL:
                labet_object.m_LabelType = DrawList->Type();
                labet_object.m_SheetPath = *sheet;
                labet_object.m_SheetPath = *sheetPath;
                labet_object.m_Label     = DrawList;
                aList.push_back( labet_object );
                break;

            case DRAW_SHEET_STRUCT_TYPE:
            {
                PinLabel = ( (SCH_SHEET*) DrawList )->m_Label;
                while( PinLabel != NULL )
                SCH_SHEET* sheet = (SCH_SHEET*) DrawList;

                BOOST_FOREACH( SCH_SHEET_PIN sheetLabel, sheet->GetSheetPins() )
                {
                    labet_object.m_LabelType =
                        DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE;
                    labet_object.m_SheetPath = *sheet;
                    labet_object.m_Label     = PinLabel;
                    labet_object.m_LabelType = DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE;
                    labet_object.m_SheetPath = *sheetPath;
                    labet_object.m_Label     = &sheetLabel;
                    aList.push_back( labet_object );
                    PinLabel = PinLabel->Next();
                }
            }
            break;
+168 −101
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@
SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
    SCH_ITEM( NULL, DRAW_SHEET_STRUCT_TYPE )
{
    m_Label = NULL;
    m_NbLabel = 0;
    m_Layer = LAYER_SHEET;
    m_Pos = pos;
    m_TimeStamp = GetTimeStamp();
@@ -39,20 +37,12 @@ SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :

SCH_SHEET::~SCH_SHEET()
{
    SCH_SHEET_PIN* label = m_Label, * next_label;

    while( label )
    {
        next_label = label->Next();
        delete label;
        label = next_label;
    }

    // also, look at the associated sheet & its reference count
    // perhaps it should be deleted also.
    if( m_AssociatedScreen )
    {
        m_AssociatedScreen->m_RefCount--;

        if( m_AssociatedScreen->m_RefCount == 0 )
            delete m_AssociatedScreen;
    }
@@ -66,8 +56,6 @@ SCH_SHEET::~SCH_SHEET()
 */
bool SCH_SHEET::Save( FILE* aFile ) const
{
    SCH_SHEET_PIN* SheetLabel;

    if( fprintf( aFile, "$Sheet\n" ) == EOF
        || fprintf( aFile, "S %-4d %-4d %-4d %-4d\n",
                    m_Pos.x, m_Pos.y, m_Size.x, m_Size.y ) == EOF )
@@ -92,15 +80,12 @@ bool SCH_SHEET::Save( FILE* aFile ) const
            return false;
    }

    /* Create the list of labels in the sheet. */
    SheetLabel = m_Label;
    int l_id = 2;
    while( SheetLabel != NULL )
    /* Save the list of labels in the sheet. */

    BOOST_FOREACH( const SCH_SHEET_PIN& label, m_labels )
    {
        SheetLabel->m_Number = l_id;
        SheetLabel->Save( aFile );
        l_id++;
        SheetLabel = SheetLabel->Next();
        if( !label.Save( aFile ) )
            return false;
    }

    if( fprintf( aFile, "$EndSheet\n" ) == EOF )
@@ -132,24 +117,14 @@ SCH_SHEET* SCH_SHEET::GenCopy()
 */
    newitem->m_SheetNameSize = m_SheetNameSize;

    newitem->m_Label = NULL;

    SCH_SHEET_PIN* Slabel = NULL, * label = m_Label;

    if( label )
    BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels )
    {
        Slabel = newitem->m_Label = label->GenCopy();
        Slabel->SetParent( newitem );
        label = label->Next();
        SCH_SHEET_PIN* newSheetPin = sheetPin.GenCopy();
        newSheetPin->SetParent( newitem );
        newitem->GetSheetPins().push_back( newSheetPin );
    }

    while( label )
    {
        Slabel->SetNext( label->GenCopy() );
        Slabel = Slabel->Next();
        Slabel->SetParent( newitem );
        label = label->Next();
    }
    newitem->renumberLabels();

    /* don't copy screen data - just reference it. */
    newitem->m_AssociatedScreen = m_AssociatedScreen;
@@ -170,24 +145,92 @@ void SCH_SHEET::SwapData( SCH_SHEET* copyitem )
    EXCHG( m_SheetName, copyitem->m_SheetName );
    EXCHG( m_SheetNameSize, copyitem->m_SheetNameSize );
    EXCHG( m_FileNameSize, copyitem->m_FileNameSize );
    EXCHG( m_Label, copyitem->m_Label );
    EXCHG( m_NbLabel, copyitem->m_NbLabel );
    m_labels.swap( copyitem->m_labels );

    // Ensure sheet labels have their .m_Parent member pointing really on their
    // parent, after swapping.
    SCH_SHEET_PIN* label = m_Label;
    while( label )
    BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels )
    {
        sheetPin.SetParent( this );
    }

    BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, copyitem->m_labels )
    {
        sheetPin.SetParent( copyitem );
    }
}


void SCH_SHEET::AddLabel( SCH_SHEET_PIN* aLabel )
{
    wxASSERT( aLabel != NULL );
    wxASSERT( aLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE );

    m_labels.push_back( aLabel );
    renumberLabels();
}


void SCH_SHEET::RemoveLabel( SCH_SHEET_PIN* aLabel )
{
    wxASSERT( aLabel != NULL );
    wxASSERT( aLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE );

    SCH_SHEET_PIN_LIST::iterator i;

    for( i = m_labels.begin();  i < m_labels.end();  ++i )
    {
        if( *i == aLabel )
        {
            m_labels.erase( i );
            renumberLabels();
            return;
        }
    }

    wxLogDebug( wxT( "Fix me: attempt to remove label %s which is not in sheet %s." ),
                GetChars( aLabel->m_Text ), GetChars( m_SheetName ) );
}


bool SCH_SHEET::HasLabel( const wxString& aName )
{
    BOOST_FOREACH( SCH_SHEET_PIN label, m_labels )
    {
        label->SetParent( this );
        label = label->Next();
        if( label.m_Text.CmpNoCase( aName ) == 0 )
            return true;
    }

    return false;
}

    label = copyitem->m_Label;
    while( label )

bool SCH_SHEET::HasUndefinedLabels()
{
    BOOST_FOREACH( SCH_SHEET_PIN label, m_labels )
    {
        /* Search the schematic for a hierarchical label corresponding to this sheet label. */
        EDA_BaseStruct* DrawStruct = m_AssociatedScreen->EEDrawList;
        SCH_HIERLABEL*  HLabel     = NULL;

        for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
        {
        label->SetParent( copyitem );
        label = label->Next();
            if( DrawStruct->Type() != TYPE_SCH_HIERLABEL )
                continue;

            HLabel = (SCH_HIERLABEL*) DrawStruct;

            if( label.m_Text.CmpNoCase( HLabel->m_Text ) == 0 )
                break;  // Found!

            HLabel = NULL;
        }

        if( HLabel == NULL )   // Corresponding hierarchical label not found.
            return true;
    }

    return false;
}


@@ -233,56 +276,61 @@ void SCH_SHEET::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
}


/** Function CleanupSheet
 * Delete pinsheets which are not corresponding to a hierarchical label
 * @param aRedraw = true to redraw Sheet
 * @param aFrame = the schematic frame
/**
 * Delete sheet labels which do not have corresponding hierarchical label.
 */
void SCH_SHEET::CleanupSheet( WinEDA_SchematicFrame* aFrame,
                              bool                   aRedraw,
                              bool                   aSaveForUndoRedo)
void SCH_SHEET::CleanupSheet()
{
    SCH_SHEET_PIN* Pinsheet, * NextPinsheet;
    bool isSaved = false;
    SCH_SHEET_PIN_LIST::iterator i = m_labels.begin();

    if( !IsOK( aFrame, _( "Ok to cleanup this sheet" ) ) )
        return;

    Pinsheet = m_Label;
    while( Pinsheet )
    while( i != m_labels.end() )
    {
        /* Search Hlabel corresponding to this Pinsheet */

        /* Search the schematic for a hierarchical label corresponding to this sheet label. */
        EDA_BaseStruct* DrawStruct = m_AssociatedScreen->EEDrawList;
        SCH_HIERLABEL*  HLabel     = NULL;

        for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
        {
            if( DrawStruct->Type() != TYPE_SCH_HIERLABEL )
                continue;

            HLabel = (SCH_HIERLABEL*) DrawStruct;
            if( Pinsheet->m_Text.CmpNoCase( HLabel->m_Text ) == 0 )

            if( i->m_Text.CmpNoCase( HLabel->m_Text ) == 0 )
                break;  // Found!

            HLabel = NULL;
        }

        NextPinsheet = Pinsheet->Next();
        if( HLabel == NULL )   // Hlabel not found: delete pinsheet
        {
            if( aSaveForUndoRedo && !isSaved )
            {
                isSaved = true;
                aFrame->SaveCopyInUndoList( this, UR_CHANGED);
        if( HLabel == NULL )   // Hlabel not found: delete sheet label.
            m_labels.erase( i );
        else
            ++i;
    }
            aFrame->OnModify( );
            aFrame->DeleteSheetLabel( false, Pinsheet );
}
        Pinsheet = NextPinsheet;


SCH_SHEET_PIN* SCH_SHEET::GetLabel( const wxPoint& aPosition )
{
    int size, dy, minx, maxx;

    BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
    {
        size = ( label.GetLength() + 1 ) * label.m_Size.x;
        if( label.m_Edge )
            size = -size;
        minx = label.m_Pos.x;
        maxx = label.m_Pos.x + size;
        if( maxx < minx )
            EXCHG( maxx, minx );
        dy = label.m_Size.x / 2;

        if( ( ABS( aPosition.y - label.m_Pos.y ) <= dy )
            && ( aPosition.x <= maxx ) && ( aPosition.x >= minx ) )
            return &label;
    }

    if( aRedraw )
        aFrame->DrawPanel->PostDirtyRect( GetBoundingBox() );
    return NULL;
}


@@ -307,7 +355,6 @@ int SCH_SHEET::GetPenSize()
void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
                      const wxPoint& aOffset, int aDrawMode, int aColor )
{
    SCH_SHEET_PIN* SheetLabelStruct;
    int      txtcolor;
    wxString Text;
    int      color;
@@ -350,12 +397,10 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,


    /* Draw text : SheetLabel */
    SheetLabelStruct = m_Label;
    while( SheetLabelStruct != NULL )
    BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels )
    {
        if( !( SheetLabelStruct->m_Flags & IS_MOVED ) )
            SheetLabelStruct->Draw( aPanel, aDC, aOffset, aDrawMode, aColor );
        SheetLabelStruct = SheetLabelStruct->Next();
        if( !( sheetPin.m_Flags & IS_MOVED ) )
            sheetPin.Draw( aPanel, aDC, aOffset, aDrawMode, aColor );
    }
}

@@ -377,8 +422,8 @@ EDA_Rect SCH_SHEET::GetBoundingBox()
    dx = MAX( m_Size.x, textlen1 );
    dy = m_Size.y + m_SheetNameSize + m_FileNameSize + 16;

    EDA_Rect box( wxPoint( m_Pos.x, m_Pos.y - m_SheetNameSize - 8 ),
                  wxSize( dx, dy ) );
    EDA_Rect box( wxPoint( m_Pos.x, m_Pos.y - m_SheetNameSize - 8 ), wxSize( dx, dy ) );

    return box;
}

@@ -603,7 +648,7 @@ bool SCH_SHEET::ChangeFileName( WinEDA_SchematicFrame* aFrame,
        {
            msg.Printf( _( "A Sub Hierarchy named %s exists, Use it (The \
data in this sheet will be replaced)?" ),
                        aFileName.GetData() );
                        GetChars( aFileName ) );
            if( !IsOK( NULL, msg ) )
            {
                DisplayInfoMessage( (wxWindow*) NULL,
@@ -617,7 +662,7 @@ data in this sheet will be replaced)?" ),
    {
        msg.Printf( _( "A file named %s exists, load it (otherwise keep \
current sheet data if possible)?" ),
                   aFileName.GetData() );
                    GetChars( aFileName ) );
        if( IsOK( NULL, msg ) )
        {
            LoadFromFile = true;
@@ -708,11 +753,25 @@ void SCH_SHEET::Mirror_Y( int aYaxis_position )

    m_Pos.x -= m_Size.x;

    SCH_SHEET_PIN* label = m_Label;
    while( label != NULL )
    BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
    {
        label.Mirror_Y( aYaxis_position );
    }
}


void SCH_SHEET::Resize( const wxSize& aSize )
{
    if( aSize == m_Size )
        return;

    m_Size = aSize;

    /* Move the sheet labels according to the new sheet size. */
    BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
    {
        label->Mirror_Y( aYaxis_position );
        label = label->Next();
        if( label.m_Edge )
            label.m_Pos.x = m_Pos.x + m_Size.x;
    }
}

@@ -726,27 +785,35 @@ bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData )
}


void SCH_SHEET::renumberLabels()
{
    int labelId = 2;

    BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
    {
        label.SetNumber( labelId );
        labelId++;
    }
}


#if defined(DEBUG)

void SCH_SHEET::Show( int nestLevel, std::ostream& os )
{
    // XML output:
    wxString s = GetClass();

    NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">"
                                 << " sheet_name=\""
                                 << CONV_TO_UTF8( m_SheetName )
                                 << '"' << ">\n";
    NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" << " sheet_name=\""
                                 << CONV_TO_UTF8( m_SheetName ) << '"' << ">\n";

    // show all the pins, and check the linked list integrity
    SCH_SHEET_PIN* label;
    for( label = m_Label; label; label = label->Next() )
    BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
    {
        label->Show( nestLevel + 1, os );
        label.Show( nestLevel + 1, os );
    }

    NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n"
                                 << std::flush;
    NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n" << std::flush;
}


#endif
+124 −24
Original line number Diff line number Diff line
@@ -6,6 +6,9 @@
#define CLASS_DRAWSHEET_H

#include "base_struct.h"
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/foreach.hpp>


extern SCH_SHEET* g_RootSheet;

@@ -21,12 +24,15 @@ extern SCH_SHEET* g_RootSheet;
 */
class SCH_SHEET_PIN : public SCH_ITEM, public EDA_TextStruct
{
private:
    int  m_Number;      ///< Label number use for saving sheet label to file.
                        ///< Sheet label numbering begins at 2.
                        ///< 0 is reserved for the sheet name.
                        ///< 1 is reserve for the sheet file name.

public:
    int  m_Edge, m_Shape;
    bool m_IsDangling;  // TRUE non connected
    int  m_Number;      // used to numbered labels when writing data on file .
                        // m_Number >= 2
                        // value 0 is for sheet name and 1 for sheet filename

public:
    SCH_SHEET_PIN( SCH_SHEET* parent,
@@ -40,6 +46,7 @@ public:
        return wxT( "SCH_SHEET_PIN" );
    }

    bool operator==( const SCH_SHEET_PIN* aPin ) const;

    SCH_SHEET_PIN* GenCopy();

@@ -48,14 +55,43 @@ public:
        return ( SCH_SHEET_PIN*) Pnext;
    }

    void Place( WinEDA_SchematicFrame* frame,
                wxDC*                  DC );
    /**
     * Get the sheet label number.
     *
     * @return Number of the sheet label.
     */
    int GetNumber() { return m_Number; }

    /**
     * Set the sheet label number.
     *
     * @param aNumber - New sheet number label.
     */
    void SetNumber( int aNumber );

    /**
     * Get the parent sheet object of this sheet pin.
     *
     * @return The sheet that is the parent of this sheet pin or NULL if it does
     *         not have a parent.
     */
    SCH_SHEET* GetParent() const { return (SCH_SHEET*) m_Parent; }

    void Place( WinEDA_SchematicFrame* frame, wxDC* DC );

    void Draw( WinEDA_DrawPanel* panel,
               wxDC*             DC,
               const wxPoint&    offset,
               int               draw_mode,
               int               Color = -1 );

    /**
     * Plot this sheet pin object to aPlotter.
     *
     * @param aPlotter - The plotter object to plot to.
     */
    void Plot( PLOTTER* aPlotter );

    /**
     * Function Save
     * writes the data structures for this object out to a FILE in "*.sch"
@@ -119,6 +155,9 @@ public:
};


typedef boost::ptr_vector< SCH_SHEET_PIN > SCH_SHEET_PIN_LIST;


/* class SCH_SHEET
 * This class is the sheet symbol placed in a schematic, and is the entry point
 * for a sub schematic
@@ -135,6 +174,10 @@ private:
                                         * but need it here for loading after
                                         * reading the sheet description from
                                         * file. */

protected:
    SCH_SHEET_PIN_LIST m_labels;        /* List of points to be connected.*/

public:
    int         m_SheetNameSize;        /* Size (height) of the text, used to
                                         * draw the sheet name */
@@ -143,10 +186,6 @@ public:
    wxPoint     m_Pos;
    wxSize      m_Size;                 /* Position and Size of *sheet symbol */
    int         m_Layer;
    SCH_SHEET_PIN* m_Label;             /* Points Be connection, linked
                                         * list.*/
    int         m_NbLabel;              /* Pins sheet (corresponding to
                                         * hierarchical labels) count */
    SCH_SCREEN* m_AssociatedScreen;     /* Associated Screen which
                                         * handle the physical data
                                         * In complex hierarchies we
@@ -176,14 +215,60 @@ public:
    SCH_SHEET*   GenCopy();
    void         DisplayInfo( WinEDA_DrawFrame* frame );

    /** Function CleanupSheet
     * Delete pinsheets which are not corresponding to a hierarchical label
     * @param aFrame = the schematic frame
     * @param aRedraw = true to redraw Sheet
     * @param aSaveForUndoRedo = true to put this sheet in UndoRedo list,
     *          if it is modified.
    /**
     * Add aLabel to this sheet.
     *
     * Note: Once a label is added to the sheet, it is owned by the sheet.
     *       Do not delete the label object or you will likely get a segfault
     *       when this sheet is destroyed.
     *
     * @param aLabel - The label to add to the sheet.
     */
    void         CleanupSheet( WinEDA_SchematicFrame* frame, bool aRedraw, bool aSaveForUndoRedo );
    void AddLabel( SCH_SHEET_PIN* aLabel );

    SCH_SHEET_PIN_LIST& GetSheetPins() { return m_labels; }

    /**
     * Remove a sheet label from this sheet.
     *
     * @param aSheetLabel - The sheet label to remove from the list.
     */
    void RemoveLabel( SCH_SHEET_PIN* aSheetLabel );

    /**
     * Delete sheet label which do not have a corresponding hierarchical label.
     *
     * Note: Make sure you save a copy of the sheet in the undo list before calling
     *       CleanupSheet() otherwise any unrefernced sheet labels will be lost.
     */
    void CleanupSheet();

    /**
     * Return the label found at aPosition in this sheet.
     *
     * @param aPosition - The position to check for a label.
     *
     * @return The label found at aPosition or NULL if no label is found.
     */
    SCH_SHEET_PIN* GetLabel( const wxPoint& aPosition );

    /**
     * Checks if a label already exists with aName.
     *
     * @param aName - Name of label to search for.
     *
     * @return - True if label found, otherwise false.
     */
    bool HasLabel( const wxString& aName );

    bool HasLabels() { return !m_labels.empty(); }

    /**
     * Check all sheet labels against schematic for undefined hierarchical labels.
     *
     * @return True if there are any undefined labels.
     */
    bool HasUndefinedLabels();

    /** Function GetPenSize
     * @return the size of the "pen" that be used to draw or plot this item
@@ -304,11 +389,9 @@ public:
    virtual void Move( const wxPoint& aMoveVector )
    {
        m_Pos += aMoveVector;
        SCH_SHEET_PIN* label = m_Label;
        while( label != NULL )
        BOOST_FOREACH( SCH_SHEET_PIN& label, m_labels )
        {
            label->Move( aMoveVector );
            label = label->Next();
            label.Move( aMoveVector );
        }
    }

@@ -323,18 +406,35 @@ public:
     * Compare schematic sheet file and sheet name against search string.
     *
     * @param aSearchData - Criteria to search against.
     * @param aCaseSensitive - True for case sensitive search.
     * @param aWholeWord - True to match whole word.
     *
     * @return True if this item matches the search criteria.
     */
    virtual bool Matches( wxFindReplaceData& aSearchData );

    /**
     * Resize this sheet to aSize and adjust all of the labels accordingly.
     *
     * @param aSize - The new size for this sheet.
     */
    void Resize( const wxSize& aSize );

#if defined(DEBUG)

    // comment inherited by Doxygen from Base_Struct
    void         Show( int nestLevel, std::ostream& os );

#endif

protected:

    /**
     * Renumber labels in list.
     *
     * This method is used internally by SCH_SHEET to update the label numbering
     * when the label list changes.  Make sure you call this method any time a
     * label is added or removed.
     */
    void renumberLabels();
};

#endif /* CLASS_DRAWSHEET_H */
+61 −13

File changed.

Preview size limit exceeded, changes collapsed.

Loading