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

more free sweet work

parent 39194ef6
......@@ -40,7 +40,7 @@ BEZIER="
)"
TEXT="
(text \"This is some text\" (at 23 23 90.0)(justify left bottom)(visible yes)(fill filled)
(text (at 23 23 90.0) \"This is some text\" (justify left bottom)(visible yes)(fill filled)
(font arial (size .8 1.2))
)"
......
......@@ -31,6 +31,20 @@
#include <macros.h>
//#include <richio.h>
/**
* Function formatAt
* returns a formatted "(at X Y [ANGLE])" s-expression
*/
static void formatAt( OUTPUTFORMATTER* out, const POINT& aPos, ANGLE aAngle, int indent=0 )
throw( IO_ERROR )
{
out->Print( indent, aAngle==0.0 ? "(at %.6g %.6g %.6g)" : "(at %.6g %.6g)",
InternalToLogical( aPos.x ), InternalToLogical( aPos.y ),
double( aAngle ) );
}
using namespace SCH;
......@@ -40,13 +54,6 @@ PART::PART( LIB* aOwner, const STRING& aPartNameAndRev ) :
partNameAndRev( aPartNameAndRev ),
extends( 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
// what it is doing. It is the only class where PART can be instantiated.
......@@ -307,12 +314,7 @@ void TEXT_EFFECTS::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
else
out->Print( indent, "(effects %s ", out->Quotew( propName ).c_str() );
out->Print( 0, "(at %.6g %.6g", InternalToLogical( pos.x ), InternalToLogical( pos.y ) );
if( angle )
out->Print( 0, " %.6g)", double( angle ) );
else
out->Print( 0, ")" );
formatAt( out, pos, angle );
font.Format( out, 0, ctl | CTL_OMIT_NL );
......@@ -349,13 +351,8 @@ void PIN::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
out->Print( indent, "(pin %s %s ", ShowType(), ShowShape() );
if( angle )
out->Print( 0, "(at %.6g %.6g %.6g)", InternalToLogical( pos.x ), InternalToLogical( pos.y ), double(angle) );
else
out->Print( 0, "(at %.6g %.6g)", InternalToLogical( pos.x ), InternalToLogical( pos.y ) );
formatAt( out, pos, angle );
out->Print( 0, "(length %.6g)", InternalToLogical( length ) );
out->Print( 0, "(visible %s)\n", isVisible ? "yes" : "no" );
signal.Format( out, "signal", indent+1, 0 );
......@@ -386,7 +383,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)", lineWidth ); // @todo use logical units?
out->Print( 0, "(line_width %.6g)", InternalToWidth( lineWidth ) );
if( fillType != PR::T_none )
out->Print( 0, "(fill %s)", ShowFill( fillType ) );
......@@ -437,7 +434,7 @@ void RECTANGLE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
out->Print( indent, "(rectangle (start %.6g %.6g)(end %.6g %.6g)(line_width %.6g)",
InternalToLogical( start.x ), InternalToLogical( start.y ),
InternalToLogical( end.x ), InternalToLogical( end.y ),
lineWidth );
InternalToWidth( lineWidth ) );
if( fillType != PR::T_none )
out->Print( 0, "(fill %s)", ShowFill( fillType ) );
......@@ -456,7 +453,7 @@ void CIRCLE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
out->Print( indent, "(circle (center %.6g %.6g)(radius %.6g)(line_width %.6g)",
InternalToLogical( center.x ), InternalToLogical( center.y ),
InternalToLogical( radius),
lineWidth );
InternalToWidth( lineWidth ) );
if( fillType != PR::T_none )
out->Print( 0, "(fill %s)", ShowFill( fillType ) );
......@@ -477,7 +474,7 @@ void ARC::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
InternalToLogical( radius),
InternalToLogical( start.x ), InternalToLogical( start.y ),
InternalToLogical( end.x ), InternalToLogical( end.y ),
lineWidth );
InternalToWidth( lineWidth ) );
if( fillType != PR::T_none )
out->Print( 0, "(fill %s)", ShowFill( fillType ) );
......@@ -491,23 +488,14 @@ void GR_TEXT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
/*
(text "This is the text that gets drawn."
(at X Y [ANGLE])
# Valid horizontal justification values are center, right, and left. Valid
# vertical justification values are center, top, bottom.
(justify HORIZONTAL_JUSTIFY VERTICAL_JUSTIFY)
(at X Y [ANGLE])(justify HORIZONTAL_JUSTIFY VERTICAL_JUSTIFY)(visible YES)(fill FILL_TYPE)
(font [FONT] (size HEIGHT WIDTH) [italic] [bold])
(visible YES)
(fill FILL_TYPE)
)
*/
out->Print( indent, "(text %s\n", out->Quotew( text ).c_str() );
if( angle )
out->Print( indent+1, "(at %.6g %.6g %.6g)", InternalToLogical( pos.x ), InternalToLogical( pos.y ), double( angle ) );
else
out->Print( indent+1, "(at %.6g %.6g)", InternalToLogical( pos.x ), InternalToLogical( pos.y ) );
formatAt( out, pos, angle, indent+1 );
out->Print( 0, "(justify %s %s)(visible %s)",
ShowJustify( hjustify ), ShowJustify( vjustify ),
......@@ -516,8 +504,7 @@ void GR_TEXT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
if( fillType != PR::T_none )
out->Print( 0, "(fill %s)", ShowFill( fillType ) );
out->Print( 0, "\n" );
font.Format( out, indent+1, CTL_OMIT_NL );
font.Format( out, 0, CTL_OMIT_NL );
out->Print( 0, ")\n" );
}
......@@ -55,6 +55,19 @@ static inline int LogicalToInternal( double aCoord )
return int( aCoord * INTERNAL_PER_LOGICAL );
}
static inline int WidthToInternal( double aWidth )
{
// sweet line widths are a "percent of a logical unit"
return LogicalToInternal( aWidth ) / 100;
}
static inline double InternalToWidth( int aWidth )
{
// sweet line widths are a "percent of a logical unit"
return InternalToLogical( aWidth ) * 100;
}
//-----<temporary home for PART sub objects, move after stable>------------------
#include <wx/gdicmn.h>
......@@ -174,7 +187,7 @@ class POLY_LINE : public BASE_GRAPHIC
friend class SWEET_PARSER;
protected:
double lineWidth;
int lineWidth;
int fillType; // T_none, T_filled, or T_transparent
POINTS pts;
......@@ -216,7 +229,7 @@ class RECTANGLE : public BASE_GRAPHIC
friend class SWEET_PARSER;
protected:
double lineWidth;
int lineWidth;
int fillType; // T_none, T_filled, or T_transparent
POINT start;
POINT end;
......@@ -242,7 +255,7 @@ class CIRCLE : public BASE_GRAPHIC
protected:
POINT center;
int radius;
double lineWidth;
int lineWidth;
int fillType; // T_none, T_filled, or T_transparent
public:
......@@ -266,7 +279,7 @@ class ARC : public BASE_GRAPHIC
protected:
POINT pos;
double lineWidth;
int lineWidth;
int fillType; // T_none, T_filled, or T_transparent
int radius;
POINT start;
......
This diff is collapsed.
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