Commit 5b0e60e6 authored by Dick Hollenbeck's avatar Dick Hollenbeck

more free software, sweet parser nearing completion

parent 137d1329
...@@ -8,17 +8,58 @@ PARTS="eyes ears feet" ...@@ -8,17 +8,58 @@ PARTS="eyes ears feet"
REVS="rev1 rev5 rev10" REVS="rev1 rev5 rev10"
LINE="(line (pts (xy 12 13)(xy 12 20))(line_width 1.5))"
RECT="(rectangle (start 4 5)(end 6 8)(line_width 2.3)(fill transparent))"
CIRCLE="(circle (center 1 0)(radius 5)(line_width 2.1)(fill none))"
ARC="(arc (pos 22 33)(radius 12)(start 2 4)(end 13 33)(line_width 2.3)(fill filled))"
BEZIER="(bezier (fill none)(line_width 2.0)(pts (xy 0 1)(xy 2 4)))"
TEXT="(text \"This is some text\" (at 23 23 90.0)(justify left bottom)(visible yes)(fill filled))"
PIN="(pin input line (at 7 8 90.0)(length 2)(visible YES))" REFERENCE="
# add to pin (reference U
# (name NAME (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD])(visible YES)) (effects (at 12 13 180)(font (size .7 1))(visible yes))
# (number NUMBER (font [FONT] (size HEIGHT WIDTH) [ITALIC] [BOLD] (visible YES)) )"
LINE="
(line
(pts (xy 12 13)(xy 12 20))(line_width 1.5)
)"
RECT="
(rectangle
(start 4 5)(end 6 8)(line_width 2.3)(fill transparent)
)"
CIRCLE="
(circle
(center 1 0)(radius 5)(line_width 2.1)(fill none)
)"
ARC="
(arc
(pos 22 33)(radius 12)(start 2 4)(end 13 33)(line_width 2.3)(fill filled)
)"
BEZIER="
(bezier
(fill none)(line_width 2.0)(pts (xy 0 1)(xy 2 4))
)"
TEXT="
(text \"This is some text\" (at 23 23 90.0)(justify left bottom)(visible yes)(fill filled)
(font arial (size .8 1.2))
)"
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))
)"
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))
)"
PROP1="
(property mWatts 12
(effects (at 1 34 270)(font (size .5 1) italic bold)(visible no))
)"
for C in ${CATEGORIES}; do for C in ${CATEGORIES}; do
...@@ -28,24 +69,30 @@ for C in ${CATEGORIES}; do ...@@ -28,24 +69,30 @@ for C in ${CATEGORIES}; do
for P in ${PARTS}; do for P in ${PARTS}; do
for R in ${REVS}; do for R in ${REVS}; do
echo "(part $C/$P (value 22)(footprint SM0805)(model Airplane) echo "(part $C/$P (value 22)(footprint SM0805)(model Airplane)
$REFERENCE
$LINE $LINE
$RECT $RECT
$CIRCLE $CIRCLE
$ARC $ARC
$BEZIER $BEZIER
$TEXT $TEXT
$PIN $PIN1
$PIN2
$PROP1
)" > $BASEDIR/$C/$P.part.$R )" > $BASEDIR/$C/$P.part.$R
done done
# also make the part without a rev: # also make the part without a rev:
echo "(part $C/$P (value 22)(footprint SM0805)(model Airplane) echo "(part $C/$P (value 22)(footprint SM0805)(model Airplane)
$REFERENCE
$LINE $LINE
$RECT $RECT
$CIRCLE $CIRCLE
$ARC $ARC
$BEZIER $BEZIER
$TEXT $TEXT
$PIN $PIN1
$PIN2
$PROP1
)" > $BASEDIR/$C/$P.part )" > $BASEDIR/$C/$P.part
done done
done done
......
...@@ -38,7 +38,12 @@ PART::PART( LIB* aOwner, const STRING& aPartNameAndRev ) : ...@@ -38,7 +38,12 @@ PART::PART( LIB* aOwner, const STRING& aPartNameAndRev ) :
contains( 0 ), contains( 0 ),
partNameAndRev( aPartNameAndRev ), partNameAndRev( aPartNameAndRev ),
extends( 0 ), extends( 0 ),
base( 0 ) base( 0 ),
reference( this, wxT( "reference " ) ),
value( this, wxT( "value" ) ),
footprint( this, wxT( "footprint" ) ),
model( this, wxT( "model" ) ),
datasheet( this, wxT( "datasheet" ) )
{ {
// Our goal is to have class LIB only instantiate what is needed, so print here // Our goal is to have class LIB only instantiate what is needed, so print here
// what it is doing. It is the only class where PART can be instantiated. // what it is doing. It is the only class where PART can be instantiated.
...@@ -64,7 +69,11 @@ void PART::clear() ...@@ -64,7 +69,11 @@ void PART::clear()
delete *it; delete *it;
pins.clear(); pins.clear();
// @todo delete all properties // delete non-mandatory properties I own, since their container will not destroy them:
for( PROPERTIES::iterator it = properties.begin(); it != properties.end(); ++it )
delete *it;
properties.clear();
} }
......
...@@ -41,6 +41,7 @@ namespace SCH { ...@@ -41,6 +41,7 @@ namespace SCH {
class PART; class PART;
class SWEET_PARSER; class SWEET_PARSER;
class PROPERTY;
}; };
...@@ -57,10 +58,12 @@ public: ...@@ -57,10 +58,12 @@ public:
{} {}
}; };
typedef float ANGLE;
namespace SCH { namespace SCH {
class GR_FONT class FONT
{ {
friend class PART; friend class PART;
friend class SWEET_PARSER; friend class SWEET_PARSER;
...@@ -72,12 +75,31 @@ protected: ...@@ -72,12 +75,31 @@ protected:
bool bold; bool bold;
public: public:
GR_FONT() : FONT() :
italic( false ), italic( false ),
bold( false ) bold( false )
{} {}
}; };
struct TEXT_EFFECTS
{
POINT pos;
ANGLE angle;
FONT font;
bool isVisible;
PROPERTY* property; ///< only used from a COMPONENT, specifies PROPERTY in PART
wxString propName; ///< only used from a COMPONENT, specifies PROPERTY in PART
TEXT_EFFECTS() :
angle( 0 ),
isVisible( false ),
property( 0 )
{}
};
class BASE_GRAPHIC class BASE_GRAPHIC
{ {
friend class PART; friend class PART;
...@@ -186,13 +208,15 @@ class GR_TEXT : public BASE_GRAPHIC ...@@ -186,13 +208,15 @@ class GR_TEXT : public BASE_GRAPHIC
protected: protected:
POINT pos; POINT pos;
float angle; ANGLE angle;
int fillType; ///< T_none, T_filled, or T_transparent int fillType; ///< T_none, T_filled, or T_transparent
int hjustify; ///< T_center, T_right, or T_left int hjustify; ///< T_center, T_right, or T_left
int vjustify; ///< T_center, T_top, or T_bottom int vjustify; ///< T_center, T_top, or T_bottom
bool isVisible; bool isVisible;
wxString text; wxString text;
// FONT font; FONT font;
public: public:
GR_TEXT( PART* aOwner ) : GR_TEXT( PART* aOwner ) :
...@@ -206,36 +230,71 @@ public: ...@@ -206,36 +230,71 @@ public:
}; };
class PIN : public BASE_GRAPHIC class PROPERTY : public BASE_GRAPHIC
{ {
friend class PART; friend class PART;
friend class SWEET_PARSER; friend class SWEET_PARSER;
protected: protected:
POINT pos; PART* birthplace; ///< at which PART in inheritance chain was this PROPERTY added
float angle;
int connectionType; ///< T_input, T_output, T_bidirectional, 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,
///< T_falling_edge, T_non_logic.
int length; ///< length of pin in internal units
wxString name; wxString name;
wxString number; wxString text;
bool nameIsVisible; ///< name is visible TEXT_EFFECTS effects;
bool numIsVisible; ///< number is visible
bool isVisible; ///< pin is visible public:
PROPERTY( PART* aOwner, const wxChar* aName = wxT( "" ) ) :
BASE_GRAPHIC( aOwner ),
birthplace( aOwner ),
name( aName )
{}
};
struct PINTEXT
{
wxString text;
FONT font;
bool isVisible;
PINTEXT() :
isVisible( true )
{}
};
class PIN : public BASE_GRAPHIC
{
friend class PART;
friend class SWEET_PARSER;
public: public:
PIN( PART* aOwner ) : PIN( PART* aOwner ) :
BASE_GRAPHIC( aOwner ), BASE_GRAPHIC( aOwner ),
birthplace( aOwner ),
angle( 0 ), angle( 0 ),
connectionType( PR::T_input ), connectionType( PR::T_input ),
shape( PR::T_line ), shape( PR::T_line ),
length( 0 ), length( 0 ),
nameIsVisible( true ),
numIsVisible( true ),
isVisible( true ) isVisible( true )
{} {}
protected:
PART* birthplace; ///< at which PART in inheritance chain was this PIN added
POINT pos;
ANGLE angle;
PINTEXT padname;
PINTEXT signal;
int connectionType; ///< T_input, T_output, T_bidirectional, 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,
///< T_falling_edge, T_non_logic.
int length; ///< length of pin in internal units
bool isVisible; ///< pin is visible
}; };
...@@ -249,6 +308,7 @@ namespace SCH { ...@@ -249,6 +308,7 @@ namespace SCH {
typedef std::vector< BASE_GRAPHIC* > GRAPHICS; typedef std::vector< BASE_GRAPHIC* > GRAPHICS;
typedef std::vector< PIN* > PINS; typedef std::vector< PIN* > PINS;
typedef std::vector< PROPERTY* > PROPERTIES;
class LPID; class LPID;
class SWEET_PARSER; class SWEET_PARSER;
...@@ -306,12 +366,20 @@ protected: // not likely to have C++ descendants, but protected none-the-le ...@@ -306,12 +366,20 @@ protected: // not likely to have C++ descendants, but protected none-the-le
/// actually becomes cached in RAM. /// actually becomes cached in RAM.
STRING body; STRING body;
// bool cachedRevisions; ///< allows lazy loading of revision of this same part name // mandatory properties
PROPERTY reference; ///< prefix only, only components have full references
PROPERTY value;
PROPERTY footprint;
PROPERTY model;
PROPERTY datasheet;
// 3 separate lists for speed: // separate lists for speed:
/// A property list. /**
//PROPERTIES properties; * Member properties
* holds the non-mandatory properties.
*/
PROPERTIES properties;
/** /**
* Member graphics * Member graphics
...@@ -325,14 +393,9 @@ protected: // not likely to have C++ descendants, but protected none-the-le ...@@ -325,14 +393,9 @@ protected: // not likely to have C++ descendants, but protected none-the-le
*/ */
PINS pins; PINS pins;
/// Alternate body forms. /// Alternate body forms.
//ALTERNATES alternates; //ALTERNATES alternates;
// mandatory properties
wxString value;
wxString footprint;
wxString model;
wxString keywords; wxString keywords;
...@@ -361,6 +424,7 @@ public: ...@@ -361,6 +424,7 @@ public:
*/ */
void Parse( SWEET_PARSER* aParser, LIB_TABLE* aLibTable ) throw( IO_ERROR, PARSE_ERROR ); void Parse( SWEET_PARSER* aParser, LIB_TABLE* aLibTable ) throw( IO_ERROR, PARSE_ERROR );
/*
void SetValue( const wxString& aValue ) void SetValue( const wxString& aValue )
{ {
value = aValue; value = aValue;
...@@ -387,6 +451,7 @@ public: ...@@ -387,6 +451,7 @@ public:
{ {
return model; return model;
} }
*/
/* /*
void SetBody( const STR_UTF& aSExpression ) void SetBody( const STR_UTF& aSExpression )
......
This diff is collapsed.
...@@ -44,7 +44,11 @@ class ARC; ...@@ -44,7 +44,11 @@ class ARC;
class BEZIER; class BEZIER;
class GR_TEXT; class GR_TEXT;
class PIN; class PIN;
class GR_FONT; class FONT;
class PROPERTY;
struct PINTEXT;
struct TEXT_EFFECTS;
/** /**
...@@ -73,7 +77,10 @@ class SWEET_PARSER : public SWEET_LEXER ...@@ -73,7 +77,10 @@ class SWEET_PARSER : public SWEET_LEXER
void parsePin( PIN* me ); void parsePin( PIN* me );
void parseAt( POINT* pos, float* angle ); void parseAt( POINT* pos, float* angle );
void parseBool( bool* aBool ); void parseBool( bool* aBool );
void parseFont( GR_FONT* me ); void parseFont( FONT* me );
void parsePinText( PINTEXT* me );
void parseTextEffects( TEXT_EFFECTS* me );
public: public:
......
...@@ -32,14 +32,13 @@ length ...@@ -32,14 +32,13 @@ length
line line
line_width line_width
model model
name
no no
non_logic non_logic
none none
number
open_collector open_collector
open_emitter open_emitter
output output
padname
part part
passive passive
pin pin
...@@ -61,6 +60,7 @@ reference ...@@ -61,6 +60,7 @@ reference
right right
route_alt_swap route_alt_swap
route_pin_swap route_pin_swap
signal
size size
start start
start_angle start_angle
......
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