Пример #1
0
bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
{
    bool isReplaced;
    wxString text = GetText();

    if( m_id == REFERENCE && aAuxData != NULL )
    {
        wxCHECK_MSG( aSearchData.GetFlags() & FR_REPLACE_REFERENCES, false,
                     wxT( "Invalid replace component reference field call." ) ) ;

        SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;

        wxCHECK_MSG( component != NULL, false,
                     wxT( "No component associated with field" ) + text );

        text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );

        if( component->GetPartCount() > 1 )
            text << LIB_COMPONENT::ReturnSubReference( component->GetUnit() );

        isReplaced = EDA_ITEM::Replace( aSearchData, text );

        if( isReplaced )
            component->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
    }
    else
    {
        isReplaced = EDA_ITEM::Replace( aSearchData, m_Text );
    }

    return isReplaced;
}
Пример #2
0
void SCH_FIELD::Plot( PLOTTER* aPlotter )
{
    SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent();

    wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T,
                 wxT( "Cannot plot field with invalid parent." ) );

    EDA_COLOR_T color = ReturnLayerColor( GetLayer() );

    if( m_Attributs & TEXT_NO_VISIBLE )
        return;

    if( IsVoid() )
        return;

    /* Calculate the text orientation, according to the component
     * orientation/mirror */
    int orient = m_Orient;

    if( parent->GetTransform().y1 )  // Rotate component 90 deg.
    {
        if( orient == TEXT_ORIENT_HORIZ )
            orient = TEXT_ORIENT_VERT;
        else
            orient = TEXT_ORIENT_HORIZ;
    }

    /* Calculate the text justification, according to the component
     * orientation/mirror
     * this is a bit complicated due to cumulative calculations:
     * - numerous cases (mirrored or not, rotation)
     * - the DrawGraphicText function recalculate also H and H justifications
     *      according to the text orientation.
     * - When a component is mirrored, the text is not mirrored and
     *   justifications are complicated to calculate
     * so the more easily way is to use no justifications ( Centered text )
     * and use GetBoundaryBox to know the text coordinate considered as centered
     */
    EDA_RECT BoundaryBox = GetBoundingBox();
    EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER;
    EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER;
    wxPoint  textpos = BoundaryBox.Centre();

    int      thickness = GetPenSize();

    if( (parent->GetPartCount() <= 1) || (m_id != REFERENCE) )
    {
        aPlotter->Text( textpos, color, m_Text, orient, m_Size, hjustify, vjustify,
                        thickness, m_Italic, m_Bold );
    }
    else    /* We plot the reference, for a multiple parts per package */
    {
        /* Adding A, B ... to the reference */
        wxString Text = m_Text + LIB_COMPONENT::ReturnSubReference( parent->GetUnit() );

        aPlotter->Text( textpos, color, Text, orient, m_Size, hjustify, vjustify,
                        thickness, m_Italic, m_Bold );
    }
}
Пример #3
0
const wxString SCH_FIELD::GetText() const
{
    wxString text = m_Text;

    /* For more than one part per package, we must add the part selection
     * A, B, ... or 1, 2, .. to the reference. */
    if( m_id == REFERENCE )
    {
        SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;

        wxCHECK_MSG( component != NULL, text,
                     wxT( "No component associated with field" ) + text );

        if( component->GetPartCount() > 1 )
            text << LIB_COMPONENT::ReturnSubReference( component->GetUnit() );
    }

    return text;
}
Пример #4
0
bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation )
{
    bool match;
    wxString text = GetFullyQualifiedText();

    // User defined fields have an ID of -1.
    if( ((m_id > VALUE || m_id < REFERENCE) && !(aSearchData.GetFlags() & FR_SEARCH_ALL_FIELDS))
        || ((m_id == REFERENCE) && !(aSearchData.GetFlags() & FR_REPLACE_REFERENCES)) )
        return false;

    wxLogTrace( traceFindItem, wxT( "    child item " ) + GetSelectMenuText() );

    // Take sheet path into account which effects the reference field and the unit for
    // components with multiple parts.
    if( m_id == REFERENCE && aAuxData != NULL )
    {
        SCH_COMPONENT* component = (SCH_COMPONENT*) m_Parent;

        wxCHECK_MSG( component != NULL, false,
                     wxT( "No component associated with field" ) + text );

        text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );

        if( component->GetPartCount() > 1 )
            text << LIB_COMPONENT::ReturnSubReference( component->GetUnit() );
    }

    match = SCH_ITEM::Matches( text, aSearchData );

    if( match )
    {
        if( aFindLocation )
            *aFindLocation = GetBoundingBox().Centre();

        return true;
    }

    return false;
}