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

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
......@@ -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="
......
......@@ -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
......
......@@ -29,7 +29,6 @@
#include <sch_lpid.h>
#include <sch_lib_table.h>
#include <macros.h>
//#include <richio.h>
/**
......@@ -39,9 +38,19 @@
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 ) );
}
......@@ -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 )
......@@ -392,14 +399,16 @@ 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 " );
else
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" );
......@@ -408,6 +417,7 @@ void FONT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
out->Print( 0, " bold" );
out->Print( 0, ")%s", (ctl & CTL_OMIT_NL) ? "" : "\n" );
}
}
......@@ -415,19 +425,32 @@ 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" );
}
......@@ -441,11 +464,14 @@ PIN::~PIN()
void PINTEXT::Format( OUTPUTFORMATTER* out, const char* aElement, int indent, int ctl ) const
throw( IO_ERROR )
{
out->Print( indent, "(%s %s ", aElement, out->Quotew( text ).c_str() );
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 );
......
......@@ -71,6 +71,18 @@ static inline double InternalToWidth( int aWidth )
return InternalToLogical( aWidth ) * 100;
}
static inline int FontzToInternal( double aFontSize )
{
// sweet font sizes are deci-pins
return LogicalToInternal( aFontSize ) / 10;
}
static inline double InternalToFontz( int aFontSize )
{
// sweet font sizes are deci-pins
return InternalToLogical( aFontSize ) * 10;
}
//-----<temporary home for PART sub objects, move after stable>------------------
......@@ -113,7 +125,30 @@ public:
{}
};
/**
* Class FONTZ
* is the size of a font, and comes with a constructor which initializes
* height and width to special values which defer font size decision to
* a higher control.
*/
class FONTZ
{
public:
#define FONTZ_DEFAULT -1 ///< when size defers to higher control
FONTZ() :
height( FONTZ_DEFAULT ),
width( FONTZ_DEFAULT )
{}
int height;
int width;
};
typedef float ANGLE;
typedef int STROKE; ///< will be a class someday, currently only line width
namespace SCH {
......@@ -125,7 +160,8 @@ class FONT
protected:
wxString name; ///< name or other id such as number, TBD
wxSize size;
FONTZ size;
bool italic;
bool bold;
......@@ -161,6 +197,11 @@ struct TEXT_EFFECTS
};
#define STROKE_DEFAULT -1 ///< defer line width decision to higher control
#define FILL_TYPE_DEFAULT PR::T_none ///< fillType defaut
class BASE_GRAPHIC
{
friend class PART;
......@@ -200,7 +241,7 @@ class POLY_LINE : public BASE_GRAPHIC
friend class SWEET_PARSER;
protected:
int lineWidth;
STROKE stroke;
int fillType; // T_none, T_filled, or T_transparent
POINTS pts;
......@@ -210,7 +251,7 @@ protected:
public:
POLY_LINE( PART* aOwner ) :
BASE_GRAPHIC( aOwner ),
lineWidth( 1 ),
stroke( STROKE_DEFAULT ),
fillType( PR::T_none )
{
}
......@@ -228,7 +269,7 @@ public:
BEZIER( PART* aOwner ) :
POLY_LINE( aOwner )
{
lineWidth = 1;
stroke = STROKE_DEFAULT;
fillType = PR::T_none;
}
......@@ -242,7 +283,7 @@ class RECTANGLE : public BASE_GRAPHIC
friend class SWEET_PARSER;
protected:
int lineWidth;
STROKE stroke;
int fillType; // T_none, T_filled, or T_transparent
POINT start;
POINT end;
......@@ -250,8 +291,8 @@ protected:
public:
RECTANGLE( PART* aOwner ) :
BASE_GRAPHIC( aOwner ),
lineWidth( 1 ),
fillType( PR::T_none )
stroke( STROKE_DEFAULT ),
fillType( FILL_TYPE_DEFAULT )
{
}
......@@ -268,15 +309,15 @@ class CIRCLE : public BASE_GRAPHIC
protected:
POINT center;
int radius;
int lineWidth;
STROKE stroke;
int fillType; // T_none, T_filled, or T_transparent
public:
CIRCLE( PART* aOwner ) :
BASE_GRAPHIC( aOwner ),
radius( LogicalToInternal( 0.5 ) ),
lineWidth( 1 ),
fillType( PR::T_none )
stroke( STROKE_DEFAULT ),
fillType( FILL_TYPE_DEFAULT )
{
}
......@@ -292,7 +333,7 @@ class ARC : public BASE_GRAPHIC
protected:
POINT pos;
int lineWidth;
STROKE stroke;
int fillType; // T_none, T_filled, or T_transparent
int radius;
POINT start;
......@@ -301,8 +342,8 @@ protected:
public:
ARC( PART* aOwner ) :
BASE_GRAPHIC( aOwner ),
lineWidth( 1 ),
fillType( PR::T_none ),
stroke( STROKE_DEFAULT ),
fillType( FILL_TYPE_DEFAULT ),
radius( LogicalToInternal( 0.5 ) )
{
}
......@@ -322,6 +363,7 @@ protected:
ANGLE angle;
int fillType; ///< T_none, T_filled, or T_transparent
int hjustify; ///< T_center, T_right, or T_left
int vjustify; ///< T_center, T_top, or T_bottom
......@@ -413,6 +455,10 @@ struct PINTEXT
};
#define PIN_LEN_DEFAULT -1 ///< use standard pin length for given type
#define PIN_SHAPE_DEFAULT PR::T_line ///< use standard pin shape
#define PIN_CONN_DEFAULT PR::T_in ///< use standard pin connection type
class PIN : public BASE_GRAPHIC
{
friend class PART;
......@@ -422,9 +468,9 @@ public:
PIN( PART* aOwner ) :
BASE_GRAPHIC( aOwner ),
angle( 0 ),
connectionType( PR::T_input ),
shape( PR::T_line ),
length( 0 ),
connectionType( PIN_CONN_DEFAULT ),
shape( PIN_SHAPE_DEFAULT ),
length( PIN_LEN_DEFAULT ),
isVisible( true )
{}
......@@ -447,10 +493,10 @@ protected:
POINT pos;
ANGLE angle;
PINTEXT padname;
PINTEXT pad;
PINTEXT signal;
int connectionType; ///< T_input, T_output, T_bidirectional, T_tristate, T_passive, T_unspecified,
int connectionType; ///< T_in, T_out, T_inout, T_tristate, T_passive, T_unspecified,
///< T_power_in, T_power_out, T_open_collector, T_open_emitter, or T_unconnected.
int shape; ///< T_none, T_line, T_inverted, T_clock, T_inverted_clk, T_input_low, T_clock_low,
......@@ -459,7 +505,7 @@ protected:
int length; ///< length of pin in internal units
bool isVisible; ///< pin is visible
wxString pin_merge; ///< padname of (pin_merge ...) that I am a member of, else empty if none
wxString pin_merge; ///< pad of (pin_merge ...) that I am a member of, else empty if none
};
......@@ -526,6 +572,7 @@ typedef std::vector< BASE_GRAPHIC* > GRAPHICS;
typedef std::vector< PROPERTY* > PROPERTIES;
typedef std::vector< PIN* > PINS;
typedef std::vector< PIN* > PIN_LIST; ///< no ownership, used for searches
class LPID;
......@@ -624,29 +671,29 @@ public:
PROPERTY* FieldLookup( PROP_ID aPropertyId );
/**
* Function PinFindByPadName
* finds a PIN based on aPadName or returns NULL if not found.
* @param aPadName is the pin to find
* Function PinFindByPad
* finds a PIN based on aPad or returns NULL if not found.
* @param aPad is the pin to find
* @return PIN* - the found PIN or NULL if not found.
*/
PIN* PinFindByPadName( const wxString& aPadName )
PIN* PinFindByPad( const wxString& aPad )
{
PINS::iterator it = pinFindByPadName( aPadName );
PINS::iterator it = pinFindByPad( aPad );
return it != pins.end() ? *it : NULL;
}
PIN* PinFindBySignal( const wxString& aSignal )
{
PINS::iterator it = pinFindBySignal( aSignal );
return it != pins.end() ? *it : NULL;
}
/**
* Function PinsFindBySignal
* fetches all the pins matching aSignal into aResults.
*/
void PinsFindBySignal( PIN_LIST* aResults, const wxString& aSignal );
/**
* Function PinDelete
* deletes the pin with aPadName if found and returns true, else false
* deletes the pin with aPad if found and returns true, else false
* if not found.
*/
bool PinDelete( const wxString& aPadName );
bool PinDelete( const wxString& aPad );
/*
......@@ -714,13 +761,11 @@ protected: // not likely to have C++ descendants, but protected none-the-le
PROPERTIES::iterator propertyFind( const wxString& aPropertyName );
/**
* Function pinFindByPadName
* searches for a PIN with aPadName and returns a PROPERTIES::iterator which
* Function pinFindByPad
* searches for a PIN with aPad and returns a PROPERTIES::iterator which
* is the found item or pins.end() if not found.
*/
PINS::iterator pinFindByPadName( const wxString& aPadName );
PINS::iterator pinFindBySignal( const wxString& aSignal );
PINS::iterator pinFindByPad( const wxString& aPad );
POINT anchor;
......
This diff is collapsed.
......@@ -30,6 +30,7 @@
class POINT;
typedef int STROKE;
namespace SCH {
......@@ -90,6 +91,7 @@ class SWEET_PARSER : public SWEET_LEXER
void parsePinRenum( PART* me );
void parsePinRename( PART* me );
void parsePinMerge( PART* me );
void parseStroke( STROKE* me );
public:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,7 +3,7 @@ anchor
arc
at
bezier
bidirectional
inout
bold
bottom
center
......@@ -21,7 +21,7 @@ filled
font
footprint
hide
input
in
input_low
inverted
inverted_clk
......@@ -31,15 +31,15 @@ keywords
left
length
line
line_width
model
no
non_logic
none
open_collector
open_emitter
output
padname
out
pad
pads
part
passive
pin
......@@ -62,9 +62,11 @@ right
route_alt_swap
route_pin_swap
signal
signals
size
start
start_angle
stroke
text
top
transparent
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment