Commit 5679e675 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

1) make PART::Format() omit any defaults for conciseness.

2) switch spec format to *.fodt, and edit it, mentioning lots of defaults.

3) Code pin_merge, but did not test it.
parent 6c89776b
Loading
Loading
Loading
Loading
−21.9 KiB

File deleted.

+22 KiB

File added.

No diff preview for this file type.

+18 −18
Original line number Diff line number Diff line
@@ -11,56 +11,56 @@ REVS="rev1 rev5 rev10"

REFERENCE="
    (reference U?
        (effects (at 12 13 180)(font (size .7 1))(visible yes))
        (effects (at 12 13 180)(font (size 7 10))(visible yes))
    )"

LINE="
    (line
        (pts (xy 12 13)(xy 12 20))(line_width 1.5)
        (pts (xy 12 13)(xy 12 20))(stroke 1.5)
    )"

RECT="
    (rectangle
        (start 4 5)(end 6 8)(line_width 2.3)(fill transparent)
        (start 4 5)(end 6 8)(stroke 2.3)(fill transparent)
    )"

CIRCLE="
    (circle
        (center 1 0)(radius 5)(line_width 2.1)(fill none)
        (center 1 0)(radius 5)(stroke 2.1)(fill none)
    )"

ARC="
    (arc
        (pos 22 33)(radius 12)(start 2 4)(end 13 33)(line_width 2.3)(fill filled)
        (pos 22 33)(radius 12)(start 2 4)(end 13 33)(stroke 2.3)(fill filled)
    )"

BEZIER="
    (bezier
        (fill none)(line_width 2.0)(pts (xy 0 1)(xy 2 4))
        (fill none)(stroke 2.0)(pts (xy 0 1)(xy 2 4))
    )"

TEXT="
    (text (at 23 23 90.0) \"This is some text\" (justify left bottom)(visible yes)(fill filled)
        (font arial (size .8 1.2))
        (font arial (size 8 12))
    )"

PIN1="
    (pin output line (at 7 8 90)(length 2)(visible yes)
        (signal #WE  (font  (size 0.9 1.1) bold)(visible yes))
        (padname A23 (font (size 0.9 1.1) italic bold) (visible yes))
    (pin out line (at 7 8 90)
        (signal #WE  (font  (size 8 10) bold)(visible no))
        (pad A23 (font (size 9 11) italic bold))
    )"

PIN2="
    (pin input line (at 8 8)(length 2)(visible yes)
        (signal #WAIT  (font  (size 0.9 1.1) bold)(visible yes))
        (padname A24 (font (size 0.9 1.1) italic bold) (visible yes))
    (pin in line (at 8 8)(visible yes)
        (signal #WAIT  (visible yes))
        (pad A24 (visible yes))
    )"

PIN3="
    (pin (padname A25))"
    (pin (pad A25))"

PINS="
    (pin (padname Z12))(pin (padname Y14))(pin (padname Z13))(pin (padname Y15))"
    (pin (pad Z12))(pin (pad Y14))(pin (pad Z13))(pin (pad Y15))"


PIN_SWAP="
@@ -70,17 +70,17 @@ PIN_RENUM="
    (pin_renum A24 B24)"

PIN_RENAME="
    (pin_rename #WE LED)"
    (pin_rename B24 LED)"

PIN_DELETE="
    (pin_del B24)"

PIN_MERGE="(pin_merge A23 (hide Z12 Y14))(pin_merge A25 (hide Z13 Y15))"
PIN_MERGE="(pin_merge A23 (pads Z12 Y14))(pin_merge A25 (pads Z13 Y15))"


PROP1="
    (property mWatts 12
        (effects (at 1 34 270)(font (size .5 1) italic bold)(visible no))
        (effects (at 1 34 270)(font (size 5 9) italic bold)(visible no))
    )"

KEYWORDS="
+0 −1
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ class LIB_TABLE;
 */
class LIB_SOURCE
{
    friend class LIBS;      ///< the LIB factory is thru LIB_TABLE::LookupPart()
    friend class LIB;       ///< the LIB uses these functions.

protected:                  ///< derived classes must implement
+92 −58
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@
#include <sch_lpid.h>
#include <sch_lib_table.h>
#include <macros.h>
//#include <richio.h>


/**
@@ -38,11 +37,21 @@
 */
static void formatAt( OUTPUTFORMATTER* out, const POINT& aPos, ANGLE aAngle, int indent=0 )
    throw( IO_ERROR )
{
    // if( aPos.x || aPos.y || aAngle )
    {
        out->Print( indent, aAngle!=0.0 ? "(at %.6g %.6g %.6g)" : "(at %.6g %.6g)",
            InternalToLogical( aPos.x ), InternalToLogical( aPos.y ),
            double( aAngle ) );
    }
}

static void formatStroke( OUTPUTFORMATTER* out, STROKE aStroke, int indent=0 )
    throw( IO_ERROR )
{
    if( aStroke == STROKE_DEFAULT )
        out->Print( indent, "(stroke %.6g)", InternalToWidth( aStroke ) );
}


using namespace SCH;
@@ -145,13 +154,13 @@ PROPERTY* PART::FieldLookup( PROP_ID aPropertyId )
    return p;
}

PINS::iterator PART::pinFindByPadName( const wxString& aPadName )
PINS::iterator PART::pinFindByPad( const wxString& aPad )
{
    PINS::iterator it;

    for( it = pins.begin();  it != pins.end();  ++it )
    {
        if( (*it)->padname.text == aPadName )
        if( (*it)->pad.text == aPad )
            break;
    }

@@ -159,23 +168,21 @@ PINS::iterator PART::pinFindByPadName( const wxString& aPadName )
}


PINS::iterator PART::pinFindBySignal( const wxString& aSignal )
void PART::PinsFindBySignal( PIN_LIST* aResults, const wxString& aSignal )
{
    PINS::iterator it;

    for( it = pins.begin();  it != pins.end();  ++it )
    for( PINS::const_iterator it = pins.begin();  it != pins.end();  ++it )
    {
        if( (*it)->signal.text == aSignal )
            break;
        {
            aResults->push_back( *it );
        }
    }

    return it;
}


bool PART::PinDelete( const wxString& aPadName )
bool PART::PinDelete( const wxString& aPad )
{
    PINS::iterator it = pinFindByPadName( aPadName );
    PINS::iterator it = pinFindByPad( aPad );
    if( it != pins.end() )
    {
        delete *it;
@@ -313,7 +320,7 @@ void PART::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const

    for( MERGE_SETS::const_iterator mit = pin_merges.begin();  mit != pin_merges.end();  ++mit )
    {
        out->Print( indent+1, "(pin_merge %s (hide", out->Quotew( mit->first ).c_str() );
        out->Print( indent+1, "(pin_merge %s (pads", out->Quotew( mit->first ).c_str() );

        const MERGE_SET& mset = *mit->second;
        for( MERGE_SET::const_iterator pit = mset.begin();  pit != mset.end();  ++pit )
@@ -391,6 +398,8 @@ void TEXT_EFFECTS::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const

void FONT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
    throw( IO_ERROR )
{
    if( italic || bold || !name.IsEmpty() || size.height != FONTZ_DEFAULT || size.width != FONTZ_DEFAULT )
    {
        if( name.IsEmpty() )
            out->Print( indent, "(font " );
@@ -398,8 +407,8 @@ void FONT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
            out->Print( indent, "(font %s ", out->Quotew( name ).c_str() );

        out->Print( 0, "(size %.6g %.6g)",
            InternalToLogical( size.GetHeight() ),
            InternalToLogical( size.GetWidth() ) );
                InternalToFontz( size.height ),
                InternalToFontz( size.width ) );

        if( italic )
            out->Print( 0, " italic" );
@@ -409,25 +418,39 @@ void FONT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const

        out->Print( 0, ")%s", (ctl & CTL_OMIT_NL) ? "" : "\n" );
    }
}


void PIN::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
    throw( IO_ERROR )
{
    bool    hasSignal = !signal.text.IsEmpty();
    bool    hasPadName = !padname.text.IsEmpty();
    bool    hasPad    = !pad.text.IsEmpty();

    out->Print( indent, "(pin %s %s ", ShowType(), ShowShape() );
    out->Print( indent, "(pin" );

    if( connectionType != PIN_CONN_DEFAULT )
        out->Print( 0, " %s", ShowType() );

    if( shape != PIN_SHAPE_DEFAULT )
        out->Print( 0, " %s", ShowShape() );

    out->Print( 0, " " );

    if( pos.x || pos.y || angle )
        formatAt( out, pos, angle );

    if( length != PIN_LEN_DEFAULT )
        out->Print( 0, "(length %.6g)", InternalToLogical( length ) );
    out->Print( 0, "(visible %s)\n", isVisible ? "yes" : "no" );

    if( !isVisible )
        out->Print( 0, "(visible %s)", isVisible ? "yes" : "no" );

    if( hasSignal )
        signal.Format(  out, "signal",  indent+1, hasPadName ? 0 : CTL_OMIT_NL );
        signal.Format(  out, "signal",  0, CTL_OMIT_NL );

    if( hasPadName )
        padname.Format( out, "padname", indent+1, CTL_OMIT_NL );
    if( hasPad )
        pad.Format( out, "pad", 0, CTL_OMIT_NL );

    out->Print( 0, ")\n" );
}
@@ -442,10 +465,13 @@ void PINTEXT::Format( OUTPUTFORMATTER* out, const char* aElement, int indent, in
    throw( IO_ERROR )
{
    out->Print( indent, "(%s %s", aElement, out->Quotew( text ).c_str() );

    font.Format( out, 0, CTL_OMIT_NL );
    out->Print( 0, "(visible %s))%s",
        isVisible ? "yes" : "no",
        ctl & CTL_OMIT_NL ? "" : "\n" );

    if( !isVisible )
        out->Print( 0, " (visible %s)", isVisible ? "yes" : "no" );

    out->Print( 0, ")%s", ctl & CTL_OMIT_NL ? "" : "\n" );
}


@@ -460,7 +486,7 @@ void POLY_LINE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
void POLY_LINE::formatContents(  OUTPUTFORMATTER* out, int indent, int ctl ) const
    throw( IO_ERROR )
{
    out->Print( 0, "(line_width %.6g)", InternalToWidth( lineWidth ) );
    formatStroke( out, stroke );

    if( fillType != PR::T_none )
        out->Print( 0, "(fill %s)", ShowFill( fillType ) );
@@ -506,12 +532,14 @@ void BEZIER::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
void RECTANGLE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
    throw( IO_ERROR )
{
    // (rectangle (start X Y) (end X Y) (line_width WIDTH) (fill FILL_TYPE))
    // (rectangle (start X Y) (end X Y) [(stroke WIDTH)] (fill FILL_TYPE))

    out->Print( indent, "(rectangle (start %.6g %.6g)(end %.6g %.6g)(line_width %.6g)",
    out->Print( indent, "(rectangle (start %.6g %.6g)(end %.6g %.6g)",
        InternalToLogical( start.x ), InternalToLogical( start.y ),
        InternalToLogical( end.x ), InternalToLogical( end.y ),
        InternalToWidth( lineWidth ) );
        InternalToLogical( end.x ), InternalToLogical( end.y )
        );

    formatStroke( out, stroke );

    if( fillType != PR::T_none )
        out->Print( 0, "(fill %s)", ShowFill( fillType ) );
@@ -524,13 +552,14 @@ void CIRCLE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
    throw( IO_ERROR )
{
    /*
        (circle (center X Y)(radius LENGTH)(line_width WIDTH)(fill FILL_TYPE))
        (circle (center X Y)(radius LENGTH) [(stroke WIDTH)] (fill FILL_TYPE))
    */

    out->Print( indent, "(circle (center %.6g %.6g)(radius %.6g)(line_width %.6g)",
    out->Print( indent, "(circle (center %.6g %.6g)(radius %.6g)",
        InternalToLogical( center.x ), InternalToLogical( center.y ),
        InternalToLogical( radius),
        InternalToWidth( lineWidth ) );
        InternalToLogical( radius) );

    formatStroke( out, stroke );

    if( fillType != PR::T_none )
        out->Print( 0, "(fill %s)", ShowFill( fillType ) );
@@ -543,15 +572,17 @@ void ARC::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
    throw( IO_ERROR )
{
    /*
        (arc (pos X Y)(radius RADIUS)(start X Y)(end X Y)(line_width WIDTH)(fill FILL_TYPE))
        (arc (pos X Y)(radius RADIUS)(start X Y)(end X Y) [(stroke WIDTH)] (fill FILL_TYPE))
    */

    out->Print( indent, "(arc (pos %.6g %.6g)(radius %.6g)(start %.6g %.6g)(end %.6g %.6g)(line_width %.6g)",
    out->Print( indent, "(arc (pos %.6g %.6g)(radius %.6g)(start %.6g %.6g)(end %.6g %.6g)",
        InternalToLogical( pos.x ), InternalToLogical( pos.y ),
        InternalToLogical( radius),
        InternalToLogical( start.x ), InternalToLogical( start.y ),
        InternalToLogical( end.x ),   InternalToLogical( end.y ),
        InternalToWidth( lineWidth ) );
        InternalToLogical( end.x ),   InternalToLogical( end.y )
        );

    formatStroke( out, stroke );

    if( fillType != PR::T_none )
        out->Print( 0, "(fill %s)", ShowFill( fillType ) );
@@ -574,11 +605,14 @@ void GR_TEXT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const

    formatAt( out, pos, angle, indent+1 );

    out->Print( 0, "(justify %s %s)(visible %s)",
            ShowJustify( hjustify ), ShowJustify( vjustify ),
            isVisible ? "yes" : "no" );
    if( hjustify != PR::T_left || vjustify != PR::T_bottom )
        out->Print( 0, "(justify %s %s)",
            ShowJustify( hjustify ), ShowJustify( vjustify ) );

    if( fillType != PR::T_none )
    if( !isVisible )
        out->Print( 0, "(visible %s)", isVisible ? "yes" : "no" );

    if( fillType != PR::T_filled )
        out->Print( 0, "(fill %s)", ShowFill( fillType ) );

    font.Format( out, 0, CTL_OMIT_NL );
Loading