Merge trunk @ 5288

This commit is contained in:
Garth Corral 2014-11-16 00:45:35 -08:00
commit 79a1086089
75 changed files with 1551 additions and 1383 deletions

View File

@ -192,7 +192,7 @@ int VRML1_MODEL_PARSER::readMaterial()
continue;
}
if( ( *text == '}' ) )
if( *text == '}' )
{
return 0;
}
@ -240,7 +240,7 @@ int VRML1_MODEL_PARSER::readCoordinate3()
continue;
}
if( ( *text == '}' ) )
if( *text == '}' )
{
return 0;
}
@ -268,7 +268,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet()
continue;
}
if( ( *text == '}' ) )
if( *text == '}' )
{
return 0;
}

View File

@ -145,7 +145,7 @@ int VRML2_MODEL_PARSER::read_Transform()
continue;
}
if( ( *text == '}' ) )
if( *text == '}' )
{
// DBG( printf( " } Exit Transform\n" ) );
break;
@ -265,7 +265,7 @@ int VRML2_MODEL_PARSER::read_DEF()
continue;
}
if( ( *text == '}' ) )
if( *text == '}' )
{
// DBG( printf( " } Exit DEF\n") );
return 0;
@ -321,7 +321,7 @@ int VRML2_MODEL_PARSER::read_Shape()
continue;
}
if( ( *text == '}' ) )
if( *text == '}' )
{
// DBG( printf( " } Exit Shape\n") );
return 0;
@ -368,7 +368,7 @@ int VRML2_MODEL_PARSER::read_Appearance()
continue;
}
if( ( *text == '}' ) )
if( *text == '}' )
{
return 0;
}
@ -473,7 +473,7 @@ int VRML2_MODEL_PARSER::read_Material()
continue;
}
if( ( *text == '}' ) )
if( *text == '}' )
{
return 0;
}
@ -566,7 +566,7 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet()
continue;
}
if( ( *text == '}' ) )
if( *text == '}' )
{
// DBG( printf( " } Exit IndexedFaceSet\n") );
return 0;
@ -749,7 +749,7 @@ int VRML2_MODEL_PARSER::read_Color()
continue;
}
if( ( *text == '}' ) )
if( *text == '}' )
{
// DBG( printf( " m_DiffuseColor.size: %ld\n", m_model->m_Materials->m_DiffuseColor.size() ) );
return 0;
@ -779,7 +779,7 @@ int VRML2_MODEL_PARSER::read_Normal()
continue;
}
if( ( *text == '}' ) )
if( *text == '}' )
{
// DBG( printf( " m_PerFaceNormalsNormalized.size: %lu\n", m_model->m_PerFaceNormalsNormalized.size() ) );
return 0;
@ -817,7 +817,7 @@ int VRML2_MODEL_PARSER::read_Coordinate()
continue;
}
if( ( *text == '}' ) )
if( *text == '}' )
{
// DBG( printf( " m_Point.size: %lu\n", m_model->m_Point.size() ) );
return 0;

View File

@ -384,7 +384,9 @@ bool X3D_MODEL_PARSER::parseDoubleTriplet( const wxString& aData,
{
wxStringTokenizer tokens( aData );
double x, y, z;
double x = 0;
double y = 0;
double z = 0;
bool ret = tokens.GetNextToken().ToDouble( &x )
&& tokens.GetNextToken().ToDouble( &y )

View File

@ -98,7 +98,8 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe
// Every coordinate description of the Hershey format has an offset,
// it has to be subtracted
point.x = (double) ( coordinate[0] - 'R' ) * HERSHEY_SCALE - glyphStartX;
point.y = (double) ( coordinate[1] - 'R' ) * HERSHEY_SCALE;
// -10 is here to keep GAL rendering consistent with the legacy gfx stuff
point.y = (double) ( coordinate[1] - 'R' - 10) * HERSHEY_SCALE;
pointList.push_back( point );
}
@ -160,28 +161,44 @@ void STROKE_FONT::Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRo
m_gal->Rotate( -aRotationAngle );
// Single line height
int lineHeight = getInterline();
// The overall height of all lines of text
double textBlockHeight = lineHeight * ( linesCount( aText ) - 1 );
int lineHeight = getInterline( );
int lineCount = linesCount( aText );
// align the 1st line of text
switch( m_verticalJustify )
{
case GR_TEXT_VJUSTIFY_TOP:
m_gal->Translate( VECTOR2D( 0, m_glyphSize.y ) );
break;
case GR_TEXT_VJUSTIFY_CENTER:
m_gal->Translate( VECTOR2D( 0, -textBlockHeight / 2.0 ) );
m_gal->Translate( VECTOR2D( 0, m_glyphSize.y / 2.0 ) );
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
m_gal->Translate( VECTOR2D( 0, -textBlockHeight ) );
break;
case GR_TEXT_VJUSTIFY_TOP:
break;
default:
break;
}
if( lineCount > 1 )
{
switch( m_verticalJustify )
{
case GR_TEXT_VJUSTIFY_TOP:
break;
case GR_TEXT_VJUSTIFY_CENTER:
m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight / 2) );
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight ) );
break;
}
}
m_gal->SetIsStroke( true );
m_gal->SetIsFill( false );

View File

@ -175,7 +175,7 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_SEGMENT& aSeg, i
if( col && aNeedMTV )
{
aMTV = pushoutForce( aA, aSeg.GetSeg(), aClearance + aSeg.GetWidth() / 2);
aMTV = -pushoutForce( aA, aSeg.GetSeg(), aClearance + aSeg.GetWidth() / 2);
}
return col;
}
@ -231,16 +231,28 @@ static inline bool Collide( const SHAPE_LINE_CHAIN& aA, const SHAPE_SEGMENT& aB,
}
template<class ShapeAType, class ShapeBType> bool
CollCase( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV )
template<class ShapeAType, class ShapeBType>
inline bool CollCase( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV )
{
return Collide (*static_cast<const ShapeAType*>( aA ),
*static_cast<const ShapeBType*>( aB ),
aClearance, aNeedMTV, aMTV);
}
bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV )
template<class ShapeAType, class ShapeBType>
inline bool CollCaseReversed ( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV )
{
bool rv = Collide (*static_cast<const ShapeBType*>( aB ),
*static_cast<const ShapeAType*>( aA ),
aClearance, aNeedMTV, aMTV);
if(rv && aNeedMTV)
aMTV = -aMTV;
return rv;
}
bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV )
{
switch( aA->Type() )
{
case SH_RECT:
@ -263,8 +275,8 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed
switch( aB->Type() )
{
case SH_RECT:
return CollCase<SHAPE_RECT, SHAPE_CIRCLE>( aB, aA, aClearance, aNeedMTV, aMTV );
return CollCaseReversed<SHAPE_CIRCLE, SHAPE_RECT>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_CIRCLE:
return CollCase<SHAPE_CIRCLE, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
@ -272,8 +284,9 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed
return CollCase<SHAPE_CIRCLE, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_SEGMENT:
return CollCase<SHAPE_CIRCLE, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
default:
return CollCase<SHAPE_CIRCLE, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
default:
break;
}
@ -303,7 +316,7 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed
return CollCase<SHAPE_RECT, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );
case SH_CIRCLE:
return CollCase<SHAPE_CIRCLE, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );
return CollCaseReversed<SHAPE_SEGMENT, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN:
return CollCase<SHAPE_LINE_CHAIN, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );

View File

@ -29,16 +29,15 @@ using boost::optional;
bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance ) const
{
assert( false );
return false;
// fixme: ugly!
SEG s( aP, aP );
return this->Collide( s, aClearance );
}
bool SHAPE_LINE_CHAIN::Collide( const BOX2I& aBox, int aClearance ) const
{
assert( false );
return false;
}
@ -150,10 +149,7 @@ int SHAPE_LINE_CHAIN::Split( const VECTOR2I& aP )
int ii = -1;
int min_dist = 2;
ii = Find( aP );
if( ii >= 0 )
return ii;
int found_index = Find( aP );
for( int s = 0; s < SegmentCount(); s++ )
{
@ -165,10 +161,16 @@ int SHAPE_LINE_CHAIN::Split( const VECTOR2I& aP )
if( dist < min_dist && seg.A != aP && seg.B != aP )
{
min_dist = dist;
ii = s;
if( found_index < 0 )
ii = s;
else if( s < found_index )
ii = s;
}
}
if( ii < 0 )
ii = found_index;
if( ii >= 0 )
{
m_points.insert( m_points.begin() + ii + 1, aP );
@ -519,25 +521,27 @@ const std::string SHAPE_LINE_CHAIN::Format() const
bool SHAPE_LINE_CHAIN::CompareGeometry ( const SHAPE_LINE_CHAIN & aOther ) const
{
SHAPE_LINE_CHAIN a(*this), b(aOther);
SHAPE_LINE_CHAIN a(*this), b( aOther );
a.Simplify();
b.Simplify();
if(a.m_points.size() != b.m_points.size())
if( a.m_points.size() != b.m_points.size() )
return false;
for(int i = 0; i < a.PointCount(); i++)
if(a.CPoint(i) != b.CPoint(i))
for( int i = 0; i < a.PointCount(); i++)
if( a.CPoint( i ) != b.CPoint( i ) )
return false;
return true;
}
bool SHAPE_LINE_CHAIN::Intersects( const SHAPE_LINE_CHAIN& aChain ) const
{
INTERSECTIONS dummy;
return Intersect(aChain, dummy) != 0;
return Intersect( aChain, dummy ) != 0;
}
SHAPE* SHAPE_LINE_CHAIN::Clone() const
{
return new SHAPE_LINE_CHAIN( *this );

View File

@ -557,12 +557,12 @@ void LIB_ARC::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
msg = StringFromValue( g_UserUnit, m_Width, true );
aList.push_back( MSG_PANEL_ITEM( _( "Line width" ), msg, BLUE ) );
aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
aList.push_back( MSG_PANEL_ITEM( _( "Bounding box" ), msg, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) );
}

View File

@ -413,10 +413,10 @@ void LIB_BEZIER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
msg = StringFromValue( g_UserUnit, m_Width, true );
aList.push_back( MSG_PANEL_ITEM( _( "Line width" ), msg, BLUE ) );
aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
aList.push_back( MSG_PANEL_ITEM( _( "Bounding box" ), msg, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) );
}

View File

@ -272,7 +272,7 @@ void LIB_CIRCLE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
msg = StringFromValue( g_UserUnit, m_Width, true );
aList.push_back( MSG_PANEL_ITEM( _( "Line width" ), msg, BLUE ) );
aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
msg = StringFromValue( g_UserUnit, m_Radius, true );
aList.push_back( MSG_PANEL_ITEM( _( "Radius" ), msg, RED ) );
@ -280,7 +280,7 @@ void LIB_CIRCLE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
aList.push_back( MSG_PANEL_ITEM( _( "Bounding box" ), msg, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) );
}

View File

@ -753,10 +753,10 @@ void LIB_FIELD::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
aList.push_back( MSG_PANEL_ITEM( _( "Style" ), msg, MAGENTA ) );
msg = StringFromValue( g_UserUnit, m_Size.x, true );
aList.push_back( MSG_PANEL_ITEM( _( "Size X" ), msg, BLUE ) );
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, BLUE ) );
msg = StringFromValue( g_UserUnit, m_Size.y, true );
aList.push_back( MSG_PANEL_ITEM( _( "Size Y" ), msg, BLUE ) );
aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, BLUE ) );
// Display field name (ref, value ...)
msg = GetName();

View File

@ -402,12 +402,12 @@ void LIB_POLYLINE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
msg = StringFromValue( g_UserUnit, m_Width, true );
aList.push_back( MSG_PANEL_ITEM( _( "Line width" ), msg, BLUE ) );
aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
aList.push_back( MSG_PANEL_ITEM( _( "Bounding box" ), msg, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) );
}

View File

@ -252,7 +252,7 @@ void LIB_RECTANGLE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
msg = StringFromValue( g_UserUnit, m_Width, true );
aList.push_back( MSG_PANEL_ITEM( _( "Line width" ), msg, BLUE ) );
aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
}

View File

@ -420,7 +420,7 @@ void LIB_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
msg = StringFromValue( g_UserUnit, m_Thickness, true );
aList.push_back( MSG_PANEL_ITEM( _( "Line width" ), msg, BLUE ) );
aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
}

View File

@ -1516,7 +1516,7 @@ void SCH_COMPONENT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
// Display description of the component, and keywords found in lib
aList.push_back( MSG_PANEL_ITEM( _( "Description" ), alias->GetDescription(), DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Key words" ), alias->GetKeyWords(), DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Key Words" ), alias->GetKeyWords(), DARKCYAN ) );
}
}

View File

@ -161,7 +161,7 @@ void SCH_MARKER::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
{
wxString msg;
aList.push_back( MSG_PANEL_ITEM( _( "Electronics rule check error" ),
aList.push_back( MSG_PANEL_ITEM( _( "Electronics Rule Check Error" ),
GetReporter().GetErrorText(), DARKRED ) );
}

View File

@ -825,8 +825,8 @@ wxString SCH_SHEET::GetFileName( void ) const
void SCH_SHEET::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
{
aList.push_back( MSG_PANEL_ITEM( _( "Sheet name" ), m_name, CYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "File name" ), m_fileName, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Sheet Name" ), m_name, CYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "File Name" ), m_fileName, BROWN ) );
#if 0 // Set to 1 to display the sheet time stamp (mainly for test)
wxString msg;

View File

@ -708,7 +708,7 @@ void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
switch( Type() )
{
case SCH_TEXT_T:
msg = _( "Graphic text" );
msg = _( "Graphic Text" );
break;
case SCH_LABEL_T:
@ -716,11 +716,11 @@ void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
break;
case SCH_GLOBAL_LABEL_T:
msg = _( "Global label" );
msg = _( "Global Label" );
break;
case SCH_HIERARCHICAL_LABEL_T:
msg = _( "Hierarchical label" );
msg = _( "Hierarchical Label" );
break;
case SCH_SHEET_PIN_T:
@ -767,7 +767,7 @@ void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
if( m_Bold )
style += 2;
aList.push_back( MSG_PANEL_ITEM( _("Style"), textStyle[style], BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) );
// Display electricat type if it is relevant

View File

@ -553,7 +553,7 @@ void GERBER_DRAW_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
// Display graphic layer number
msg.Printf( wxT( "%d" ), GetLayer() + 1 );
aList.push_back( MSG_PANEL_ITEM( _( "Graphic layer" ), msg, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Graphic Layer" ), msg, BROWN ) );
// Display item rotation
// The full rotation is Image rotation + m_lyrRotation

View File

@ -52,7 +52,7 @@ public:
/** Default constructor
* Creates an empty (0, 0) segment, locally-referenced
*/
SEG()
SEG()
{
m_index = -1;
}
@ -61,8 +61,8 @@ public:
* Constructor
* Creates a segment between (aX1, aY1) and (aX2, aY2), locally referenced
*/
SEG( int aX1, int aY1, int aX2, int aY2 ) :
A ( VECTOR2I( aX1, aY1 ) ),
SEG( int aX1, int aY1, int aX2, int aY2 ) :
A ( VECTOR2I( aX1, aY1 ) ),
B ( VECTOR2I( aX2, aY2 ) )
{
m_index = -1;
@ -84,7 +84,7 @@ public:
* @param aB reference to the end point in the parent shape
* @param aIndex index of the segment within the parent shape
*/
SEG ( const VECTOR2I& aA, const VECTOR2I& aB, int aIndex ) : A( aA ), B( aB )
SEG( const VECTOR2I& aA, const VECTOR2I& aB, int aIndex ) : A( aA ), B( aB )
{
m_index = aIndex;
}
@ -92,7 +92,7 @@ public:
/**
* Copy constructor
*/
SEG ( const SEG& aSeg ) : A( aSeg.A ), B( aSeg.B ), m_index ( aSeg.m_index )
SEG( const SEG& aSeg ) : A( aSeg.A ), B( aSeg.B ), m_index( aSeg.m_index )
{
}
@ -101,7 +101,7 @@ public:
A = aSeg.A;
B = aSeg.B;
m_index = aSeg.m_index;
return *this;
}
@ -215,14 +215,35 @@ public:
*/
bool Collinear( const SEG& aSeg ) const
{
ecoord qa1 = A.y - B.y;
ecoord qb1 = B.x - A.x;
ecoord qc1 = -qa1 * A.x - qb1 * A.y;
ecoord qa2 = aSeg.A.y - aSeg.B.y;
ecoord qb2 = aSeg.B.x - aSeg.A.x;
ecoord qc2 = -qa2 * aSeg.A.x - qb2 * aSeg.A.y;
ecoord qa = A.y - B.y;
ecoord qb = B.x - A.x;
ecoord qc = -qa * A.x - qb * A.y;
return ( qa1 == qa2 ) && ( qb1 == qb2 ) && ( qc1 == qc2 );
ecoord d1 = std::abs( aSeg.A.x * qa + aSeg.A.y * qb + qc );
ecoord d2 = std::abs( aSeg.B.x * qa + aSeg.B.y * qb + qc );
return ( d1 <= 1 && d2 <= 1 );
}
bool Overlaps( const SEG& aSeg ) const
{
if( aSeg.A == aSeg.B ) // single point corner case
{
if( A == aSeg.A || B == aSeg.A )
return false;
return Contains( aSeg.A );
}
if( !Collinear( aSeg ) )
return false;
if( Contains( aSeg.A ) || Contains( aSeg.B ) )
return true;
if( aSeg.Contains( A ) || aSeg.Contains( B ) )
return true;
return false;
}
/**

View File

@ -40,7 +40,10 @@ enum SHAPE_TYPE
SH_RECT = 0, ///> axis-aligned rectangle
SH_SEGMENT, ///> line segment
SH_LINE_CHAIN, ///> line chain (polyline)
SH_CIRCLE ///> circle
SH_CIRCLE, ///> circle
SH_CONVEX, ///> convex polygon
SH_POLYGON, ///> any polygon (with holes, etc.)
SH_COMPOUND ///> compound shape, consisting of multiple simple shapes
};
/**
@ -60,7 +63,7 @@ public:
* Creates an empty shape of type aType
*/
SHAPE ( SHAPE_TYPE aType ) : m_type( aType )
SHAPE( SHAPE_TYPE aType ) : m_type( aType )
{}
// Destructor
@ -146,7 +149,11 @@ public:
return BBox( 0 ).Centre(); // if nothing better is available....
}
private:
virtual void Move ( const VECTOR2I& aVector ) = 0;
virtual bool IsSolid() const = 0;
protected:
///> type of our shape
SHAPE_TYPE m_type;
};

View File

@ -38,7 +38,7 @@ public:
SHAPE( SH_CIRCLE ), m_radius( aRadius ), m_center( aCenter )
{}
SHAPE_CIRCLE ( const SHAPE_CIRCLE& aOther ) :
SHAPE_CIRCLE( const SHAPE_CIRCLE& aOther ) :
SHAPE( SH_CIRCLE ),
m_radius( aOther.m_radius ),
m_center( aOther.m_center )
@ -86,6 +86,15 @@ public:
return m_center;
}
void Move( const VECTOR2I& aVector )
{
m_center += aVector;
}
bool IsSolid() const
{
return true;
}
private:
int m_radius;
VECTOR2I m_center;

View File

@ -103,7 +103,18 @@ public:
m_points[2] = aC;
}
SHAPE_LINE_CHAIN(const VECTOR2I* aV, int aCount ) :
SHAPE_LINE_CHAIN( const VECTOR2I& aA, const VECTOR2I& aB, const VECTOR2I& aC, const VECTOR2I& aD ) :
SHAPE( SH_LINE_CHAIN ), m_closed( false )
{
m_points.resize( 4 );
m_points[0] = aA;
m_points[1] = aB;
m_points[2] = aC;
m_points[3] = aD;
}
SHAPE_LINE_CHAIN( const VECTOR2I* aV, int aCount ) :
SHAPE( SH_LINE_CHAIN ),
m_closed( false )
{
@ -553,6 +564,16 @@ public:
bool CompareGeometry( const SHAPE_LINE_CHAIN & aOther ) const;
void Move( const VECTOR2I& aVector )
{
for( std::vector<VECTOR2I>::iterator i = m_points.begin(); i != m_points.end(); ++i )
(*i) += aVector;
}
bool IsSolid() const
{
return false;
}
private:
/// array of vertices
std::vector<VECTOR2I> m_points;

View File

@ -57,7 +57,7 @@ public:
SHAPE( SH_RECT ), m_p0( aP0 ), m_w( aW ), m_h( aH )
{}
SHAPE_RECT ( const SHAPE_RECT& aOther ) :
SHAPE_RECT( const SHAPE_RECT& aOther ) :
SHAPE( SH_RECT ),
m_p0( aOther.m_p0 ),
m_w( aOther.m_w ),
@ -159,6 +159,16 @@ public:
return m_h;
}
void Move( const VECTOR2I& aVector )
{
m_p0 += aVector;
}
bool IsSolid() const
{
return true;
}
private:
///> Top-left corner
VECTOR2I m_p0;

View File

@ -31,60 +31,71 @@
class SHAPE_SEGMENT : public SHAPE {
public:
SHAPE_SEGMENT():
SHAPE( SH_SEGMENT ), m_width( 0 ) {};
SHAPE_SEGMENT( const VECTOR2I& aA, const VECTOR2I& aB, int aWidth = 0 ):
SHAPE( SH_SEGMENT ), m_seg( aA, aB ), m_width( aWidth ) {};
SHAPE_SEGMENT():
SHAPE( SH_SEGMENT ), m_width( 0 ) {};
SHAPE_SEGMENT( const SEG& aSeg, int aWidth = 0 ):
SHAPE( SH_SEGMENT ), m_seg( aSeg ), m_width( aWidth ) {};
SHAPE_SEGMENT( const VECTOR2I& aA, const VECTOR2I& aB, int aWidth = 0 ):
SHAPE( SH_SEGMENT ), m_seg( aA, aB ), m_width( aWidth ) {};
~SHAPE_SEGMENT() {};
SHAPE_SEGMENT( const SEG& aSeg, int aWidth = 0 ):
SHAPE( SH_SEGMENT ), m_seg( aSeg ), m_width( aWidth ) {};
~SHAPE_SEGMENT() {};
SHAPE* Clone() const
{
return new SHAPE_SEGMENT( m_seg, m_width );
}
const BOX2I BBox( int aClearance = 0 ) const
{
return BOX2I( m_seg.A, m_seg.B - m_seg.A ).Inflate( aClearance + m_width / 2 );
}
const BOX2I BBox( int aClearance = 0 ) const
{
return BOX2I( m_seg.A, m_seg.B - m_seg.A ).Inflate( aClearance + m_width / 2 );
}
bool Collide( const SEG& aSeg, int aClearance = 0 ) const
{
return m_seg.Distance( aSeg ) <= m_width / 2 + aClearance;
}
bool Collide( const SEG& aSeg, int aClearance = 0 ) const
{
return m_seg.Distance( aSeg ) <= m_width / 2 + aClearance;
}
bool Collide( const VECTOR2I& aP, int aClearance = 0 ) const
{
return m_seg.Distance( aP ) <= m_width / 2 + aClearance;
}
void SetSeg ( const SEG& aSeg )
{
m_seg = aSeg;
}
const SEG& GetSeg () const
{
return m_seg;
}
bool Collide( const VECTOR2I& aP, int aClearance = 0 ) const
{
return m_seg.Distance( aP ) <= m_width / 2 + aClearance;
}
void SetWidth ( int aWidth )
{
m_width = aWidth;
}
void SetSeg( const SEG& aSeg )
{
m_seg = aSeg;
}
int GetWidth() const
{
return m_width;
}
const SEG& GetSeg() const
{
return m_seg;
}
void SetWidth( int aWidth )
{
m_width = aWidth;
}
int GetWidth() const
{
return m_width;
}
bool IsSolid() const
{
return true;
}
void Move( const VECTOR2I& aVector )
{
m_seg.A += aVector;
m_seg.B += aVector;
}
private:
SEG m_seg;
int m_width;
SEG m_seg;
int m_width;
};
#endif

View File

@ -250,7 +250,7 @@ struct KIFACE
*/
class KIWAY : public wxEvtHandler
{
friend class PGM_SINGLE_TOP; // can use set_kiface()
friend struct PGM_SINGLE_TOP; // can use set_kiface()
public:
/// Known KIFACE implementations

View File

@ -75,7 +75,7 @@ namespace PCB { struct IFACE; } // KIFACE_I is in pcbnew.cpp
*/
class PCB_EDIT_FRAME : public PCB_BASE_EDIT_FRAME
{
friend class PCB::IFACE;
friend struct PCB::IFACE;
friend class PCB_LAYER_WIDGET;
void updateTraceWidthSelectBox();

View File

@ -920,7 +920,7 @@ void BOARD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
aList.push_back( MSG_PANEL_ITEM( _( "Vias" ), txt, DARKGREEN ) );
txt.Printf( wxT( "%d" ), trackSegmentsCount );
aList.push_back( MSG_PANEL_ITEM( _( "trackSegm" ), txt, DARKGREEN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Track Segments" ), txt, DARKGREEN ) );
txt.Printf( wxT( "%d" ), GetNodesCount() );
aList.push_back( MSG_PANEL_ITEM( _( "Nodes" ), txt, DARKCYAN ) );
@ -937,7 +937,7 @@ void BOARD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
aList.push_back( MSG_PANEL_ITEM( _( "Links" ), txt, DARKGREEN ) );
txt.Printf( wxT( "%d" ), GetRatsnestsCount() - GetUnconnectedNetCount() );
aList.push_back( MSG_PANEL_ITEM( _( "Connect" ), txt, DARKGREEN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Connections" ), txt, DARKGREEN ) );
txt.Printf( wxT( "%d" ), GetUnconnectedNetCount() );
aList.push_back( MSG_PANEL_ITEM( _( "Unconnected" ), txt, BLUE ) );

View File

@ -247,8 +247,9 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
}
if( mode == LINE )
{
GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle, radius, color );
}
else if( mode == SKETCH )
{
GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle,
@ -264,14 +265,17 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
break;
case S_CURVE:
m_BezierPoints = Bezier2Poly(m_Start, m_BezierC1, m_BezierC2, m_End);
m_BezierPoints = Bezier2Poly( m_Start, m_BezierC1, m_BezierC2, m_End );
for (unsigned int i=1; i < m_BezierPoints.size(); i++) {
for( unsigned int i=1; i < m_BezierPoints.size(); i++ )
{
if( mode == LINE )
{
GRLine( panel->GetClipBox(), DC,
m_BezierPoints[i].x, m_BezierPoints[i].y,
m_BezierPoints[i-1].x, m_BezierPoints[i-1].y, 0,
color );
}
else if( mode == SKETCH )
{
GRCSegm( panel->GetClipBox(), DC,
@ -317,7 +321,7 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
wxASSERT( m_Parent );
msg = wxT( "DRAWING" );
msg = _( "Drawing" );
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) );
@ -332,7 +336,7 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
case S_ARC:
aList.push_back( MSG_PANEL_ITEM( shape, _( "Arc" ), RED ) );
msg.Printf( wxT( "%.1f" ), m_Angle / 10.0 );
aList.push_back( MSG_PANEL_ITEM( _("Angle"), msg, RED ) );
aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, RED ) );
break;
case S_CURVE:
@ -340,7 +344,18 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
break;
default:
{
aList.push_back( MSG_PANEL_ITEM( shape, _( "Segment" ), RED ) );
msg = ::CoordinateToString( GetLineLength( m_Start, m_End ) );
aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKGREEN ) );
// angle counter-clockwise from 3'o-clock
const double deg = RAD2DEG( atan2( m_Start.y - m_End.y,
m_End.x - m_Start.x ) );
msg.Printf( wxT( "%.1f" ), deg );
aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) );
}
}
wxString start;
@ -373,93 +388,93 @@ const EDA_RECT DRAWSEGMENT::GetBoundingBox() const
break;
case S_ARC:
{
bbox.Merge( m_End );
wxPoint end = m_End;
RotatePoint( &end, m_Start, -m_Angle );
bbox.Merge( end );
// Determine the starting quarter
// 0 right-bottom
// 1 left-bottom
// 2 left-top
// 3 right-top
unsigned int quarter = 0; // assume right-bottom
if( m_End.y < m_Start.y ) // change to left-top
quarter |= 3;
if( m_End.x < m_Start.x ) // for left side, the LSB is 2nd bit negated
quarter ^= 1;
int radius = GetRadius();
int angle = (int) GetArcAngleStart() % 900 + m_Angle;
bool directionCW = ( m_Angle > 0 ); // Is the direction of arc clockwise?
if( !directionCW )
{
bbox.Merge( m_End );
wxPoint end = m_End;
RotatePoint( &end, m_Start, -m_Angle );
bbox.Merge( end );
// Determine the starting quarter
// 0 right-bottom
// 1 left-bottom
// 2 left-top
// 3 right-top
unsigned int quarter = 0; // assume right-bottom
if( m_End.y < m_Start.y ) // change to left-top
quarter |= 3;
if( m_End.x < m_Start.x ) // for left side, the LSB is 2nd bit negated
quarter ^= 1;
int radius = GetRadius();
int angle = (int) GetArcAngleStart() % 900 + m_Angle;
bool directionCW = ( m_Angle > 0 ); // Is the direction of arc clockwise?
if( !directionCW )
{
angle = 900 - angle;
quarter = ( quarter + 3 ) % 4; // -1 modulo arithmetic
}
while( angle > 900 )
{
switch( quarter )
{
case 0:
bbox.Merge( wxPoint( m_Start.x, m_Start.y + radius ) ); // down
break;
case 1:
bbox.Merge( wxPoint( m_Start.x - radius, m_Start.y ) ); // left
break;
case 2:
bbox.Merge( wxPoint( m_Start.x, m_Start.y - radius ) ); // up
break;
case 3:
bbox.Merge( wxPoint( m_Start.x + radius, m_Start.y ) ); // right
break;
}
if( directionCW )
++quarter;
else
quarter += 3; // -1 modulo arithmetic
quarter %= 4;
angle -= 900;
}
angle = 900 - angle;
quarter = ( quarter + 3 ) % 4; // -1 modulo arithmetic
}
while( angle > 900 )
{
switch( quarter )
{
case 0:
bbox.Merge( wxPoint( m_Start.x, m_Start.y + radius ) ); // down
break;
case 1:
bbox.Merge( wxPoint( m_Start.x - radius, m_Start.y ) ); // left
break;
case 2:
bbox.Merge( wxPoint( m_Start.x, m_Start.y - radius ) ); // up
break;
case 3:
bbox.Merge( wxPoint( m_Start.x + radius, m_Start.y ) ); // right
break;
}
if( directionCW )
++quarter;
else
quarter += 3; // -1 modulo arithmetic
quarter %= 4;
angle -= 900;
}
}
break;
case S_POLYGON:
{
wxPoint p_end;
MODULE* module = GetParentModule();
for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
{
wxPoint p_end;
MODULE* module = GetParentModule();
wxPoint pt = m_PolyPoints[ii];
for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
if( module ) // Transform, if we belong to a module
{
wxPoint pt = m_PolyPoints[ii];
if( module ) // Transform, if we belong to a module
{
RotatePoint( &pt, module->GetOrientation() );
pt += module->GetPosition();
}
if( ii == 0 )
p_end = pt;
bbox.SetX( std::min( bbox.GetX(), pt.x ) );
bbox.SetY( std::min( bbox.GetY(), pt.y ) );
p_end.x = std::max( p_end.x, pt.x );
p_end.y = std::max( p_end.y, pt.y );
RotatePoint( &pt, module->GetOrientation() );
pt += module->GetPosition();
}
bbox.SetEnd( p_end );
if( ii == 0 )
p_end = pt;
bbox.SetX( std::min( bbox.GetX(), pt.x ) );
bbox.SetY( std::min( bbox.GetY(), pt.y ) );
p_end.x = std::max( p_end.x, pt.x );
p_end.y = std::max( p_end.y, pt.y );
}
bbox.SetEnd( p_end );
}
break;
default:
@ -479,46 +494,46 @@ bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) const
{
case S_CIRCLE:
case S_ARC:
{
wxPoint relPos = aPosition - GetCenter();
int radius = GetRadius();
int dist = KiROUND( EuclideanNorm( relPos ) );
if( abs( radius - dist ) <= ( m_Width / 2 ) )
{
wxPoint relPos = aPosition - GetCenter();
int radius = GetRadius();
int dist = KiROUND( EuclideanNorm( relPos ) );
if( m_Shape == S_CIRCLE )
return true;
if( abs( radius - dist ) <= ( m_Width / 2 ) )
// For arcs, the test point angle must be >= arc angle start
// and <= arc angle end
// However angle values > 360 deg are not easy to handle
// so we calculate the relative angle between arc start point and teast point
// this relative arc should be < arc angle if arc angle > 0 (CW arc)
// and > arc angle if arc angle < 0 (CCW arc)
double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
double arc_hittest = ArcTangente( relPos.y, relPos.x );
// Calculate relative angle between the starting point of the arc, and the test point
arc_hittest -= arc_angle_start;
// Normalise arc_hittest between 0 ... 360 deg
NORMALIZE_ANGLE_POS( arc_hittest );
// Check angle: inside the arc angle when it is > 0
// and outside the not drawn arc when it is < 0
if( GetAngle() >= 0.0 )
{
if( m_Shape == S_CIRCLE )
if( arc_hittest <= GetAngle() )
return true;
}
else
{
if( arc_hittest >= (3600.0 + GetAngle()) )
return true;
// For arcs, the test point angle must be >= arc angle start
// and <= arc angle end
// However angle values > 360 deg are not easy to handle
// so we calculate the relative angle between arc start point and teast point
// this relative arc should be < arc angle if arc angle > 0 (CW arc)
// and > arc angle if arc angle < 0 (CCW arc)
double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
double arc_hittest = ArcTangente( relPos.y, relPos.x );
// Calculate relative angle between the starting point of the arc, and the test point
arc_hittest -= arc_angle_start;
// Normalise arc_hittest between 0 ... 360 deg
NORMALIZE_ANGLE_POS( arc_hittest );
// Check angle: inside the arc angle when it is > 0
// and outside the not drawn arc when it is < 0
if( GetAngle() >= 0.0 )
{
if( arc_hittest <= GetAngle() )
return true;
}
else
{
if( arc_hittest >= (3600.0 + GetAngle()) )
return true;
}
}
}
}
break;
case S_CURVE:
@ -538,6 +553,7 @@ bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) const
wxASSERT( 0 );
break;
}
return false;
}

View File

@ -280,17 +280,15 @@ void EDGE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
if( !board )
return;
aList.push_back( MSG_PANEL_ITEM( _( "Graphic Item" ), wxEmptyString, DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Module" ), module->GetReference(), DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), module->GetReference(), DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Value" ), module->GetValue(), BLUE ) );
msg.Printf( wxT( "%8.8lX" ), module->GetTimeStamp() );
aList.push_back( MSG_PANEL_ITEM( _( "TimeStamp" ), msg, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Mod Layer" ),
aList.push_back( MSG_PANEL_ITEM( _( "Footprint Layer" ),
module->GetLayerName(), RED ) );
aList.push_back( MSG_PANEL_ITEM( _( "Seg Layer" ),
GetLayerName(), RED ) );
msg = ::CoordinateToString( m_Width );
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, BLUE ) );
// append the features shared with the base class
DRAWSEGMENT::GetMsgPanelInfo( aList );
}
@ -313,8 +311,7 @@ EDA_ITEM* EDGE_MODULE::Clone() const
}
void EDGE_MODULE::Flip(const wxPoint& aCentre )
void EDGE_MODULE::Flip( const wxPoint& aCentre )
{
wxPoint pt;

View File

@ -242,21 +242,21 @@ void MODULE::Copy( MODULE* aModule )
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
{
TEXTE_MODULE* textm = new TEXTE_MODULE( this );
textm->Copy( static_cast<TEXTE_MODULE*>( item ) );
m_Drawings.PushBack( textm );
break;
}
{
TEXTE_MODULE* textm = new TEXTE_MODULE( this );
textm->Copy( static_cast<TEXTE_MODULE*>( item ) );
m_Drawings.PushBack( textm );
break;
}
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE * edge;
edge = new EDGE_MODULE( this );
edge->Copy( (EDGE_MODULE*) item );
m_Drawings.PushBack( edge );
break;
}
{
EDGE_MODULE * edge;
edge = new EDGE_MODULE( this );
edge->Copy( (EDGE_MODULE*) item );
m_Drawings.PushBack( edge );
break;
}
default:
wxLogMessage( wxT( "MODULE::Copy() Internal Err: unknown type" ) );
@ -322,14 +322,14 @@ void MODULE::Add( BOARD_ITEM* aBoardItem, bool doAppend )
break;
default:
{
wxString msg;
msg.Printf( wxT( "MODULE::Add() needs work: BOARD_ITEM type (%d) not handled" ),
aBoardItem->Type() );
wxFAIL_MSG( msg );
{
wxString msg;
msg.Printf( wxT( "MODULE::Add() needs work: BOARD_ITEM type (%d) not handled" ),
aBoardItem->Type() );
wxFAIL_MSG( msg );
return;
}
return;
}
}
aBoardItem->SetParent( this );
@ -353,12 +353,12 @@ BOARD_ITEM* MODULE::Remove( BOARD_ITEM* aBoardItem )
return m_Pads.Remove( static_cast<D_PAD*>( aBoardItem ) );
default:
{
wxString msg;
msg.Printf( wxT( "MODULE::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
aBoardItem->Type() );
wxFAIL_MSG( msg );
}
{
wxString msg;
msg.Printf( wxT( "MODULE::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
aBoardItem->Type() );
wxFAIL_MSG( msg );
}
}
return NULL;
@ -552,7 +552,7 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
aList.push_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) );
// display schematic path
aList.push_back( MSG_PANEL_ITEM( _( "Netlist path" ), m_Path, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Netlist Path" ), m_Path, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), RED ) );
@ -576,32 +576,32 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
if( m_ModuleStatus & MODULE_is_PLACED )
msg[1] = 'P';
aList.push_back( MSG_PANEL_ITEM( _( "Stat" ), msg, MAGENTA ) );
aList.push_back( MSG_PANEL_ITEM( _( "Status" ), msg, MAGENTA ) );
msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 );
aList.push_back( MSG_PANEL_ITEM( _( "Orient" ), msg, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, BROWN ) );
// Controls on right side of the dialog
switch( m_Attributs & 255 )
{
case 0:
msg = _("Normal");
msg = _( "Normal" );
break;
case MOD_CMS:
msg = _("Insert");
msg = _( "Insert" );
break;
case MOD_VIRTUAL:
msg = _("Virtual");
msg = _( "Virtual" );
break;
default:
msg = wxT("???");
msg = wxT( "???" );
break;
}
aList.push_back( MSG_PANEL_ITEM( _( "Attrib" ), msg, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Attributes" ), msg, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), FROM_UTF8( m_fpid.Format().c_str() ), BLUE ) );
msg = _( "No 3D shape" );
@ -619,7 +619,7 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
wxString doc, keyword;
doc.Printf( _( "Doc: %s" ), GetChars( m_Doc ) );
keyword.Printf( _( "KeyW: %s" ), GetChars( m_KeyWord ) );
keyword.Printf( _( "Key Words: %s" ), GetChars( m_KeyWord ) );
aList.push_back( MSG_PANEL_ITEM( doc, keyword, BLACK ) );
}
@ -1047,21 +1047,21 @@ void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector )
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( item );
edge->m_Start0 += moveVector;
edge->m_End0 += moveVector;
edge->SetDrawCoord();
break;
}
{
EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( item );
edge->m_Start0 += moveVector;
edge->m_End0 += moveVector;
edge->SetDrawCoord();
break;
}
case PCB_MODULE_TEXT_T:
{
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
text->SetPos0( text->GetPos0() + moveVector );
text->SetDrawCoord();
break;
}
{
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
text->SetPos0( text->GetPos0() + moveVector );
text->SetDrawCoord();
break;
}
default:
break;
@ -1103,7 +1103,6 @@ void MODULE::SetOrientation( double newangle )
{
static_cast<EDGE_MODULE*>( item )->SetDrawCoord();
}
else if( item->Type() == PCB_MODULE_TEXT_T )
{
static_cast<TEXTE_MODULE*>( item )->SetDrawCoord();

View File

@ -132,7 +132,7 @@ void NETINFO_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
// Displays the full net length (tracks on pcb + internal ICs connections ):
txt = ::LengthDoubleToString( lengthnet + lengthPadToDie );
aList.push_back( MSG_PANEL_ITEM( _( "Net Length:" ), txt, RED ) );
aList.push_back( MSG_PANEL_ITEM( _( "Net Length" ), txt, RED ) );
// Displays the net length of tracks only:
txt = ::LengthDoubleToString( lengthnet );

View File

@ -607,7 +607,7 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList )
if( module )
{
wxString msg = module->GetReference();
aList.push_back( MSG_PANEL_ITEM( _( "Module" ), msg, DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), msg, DARKCYAN ) );
StringPadName( Line );
aList.push_back( MSG_PANEL_ITEM( _( "Pad" ), Line, BROWN ) );
}
@ -629,10 +629,10 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList )
aList.push_back( MSG_PANEL_ITEM( ShowPadShape(), ShowPadAttr(), DARKGREEN ) );
Line = ::CoordinateToString( m_Size.x );
aList.push_back( MSG_PANEL_ITEM( _( "H Size" ), Line, RED ) );
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), Line, RED ) );
Line = ::CoordinateToString( m_Size.y );
aList.push_back( MSG_PANEL_ITEM( _( "V Size" ), Line, RED ) );
aList.push_back( MSG_PANEL_ITEM( _( "Height" ), Line, RED ) );
Line = ::CoordinateToString( (unsigned) m_Drill.x );
@ -658,13 +658,10 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList )
else
Line.Printf( wxT( "%3.1f" ), m_Orient / 10.0 );
aList.push_back( MSG_PANEL_ITEM( _( "Orient" ), Line, LIGHTBLUE ) );
aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), Line, LIGHTBLUE ) );
Line = ::CoordinateToString( m_Pos.x );
aList.push_back( MSG_PANEL_ITEM( _( "X Pos" ), Line, LIGHTBLUE ) );
Line = ::CoordinateToString( m_Pos.y );
aList.push_back( MSG_PANEL_ITEM( _( "Y pos" ), Line, LIGHTBLUE ) );
Line = ::CoordinateToString( m_Pos.x ) + wxT( ", " ) + ::CoordinateToString( m_Pos.y );
aList.push_back( MSG_PANEL_ITEM( _( "Position" ), Line, LIGHTBLUE ) );
if( GetPadToDieLength() )
{

View File

@ -143,16 +143,16 @@ void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "Yes" ), DARKGREEN ) );
msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 );
aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, DARKGREEN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) );
msg = ::CoordinateToString( m_Thickness );
aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, MAGENTA ) );
msg = ::CoordinateToString( m_Size.x );
aList.push_back( MSG_PANEL_ITEM( _( "Size X" ), msg, RED ) );
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) );
msg = ::CoordinateToString( m_Size.y );
aList.push_back( MSG_PANEL_ITEM( _( "Size Y" ), msg, RED ) );
aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) );
}
const EDA_RECT TEXTE_PCB::GetBoundingBox() const

View File

@ -408,16 +408,16 @@ void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), msg, DARKGREEN ) );
msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 );
aList.push_back( MSG_PANEL_ITEM( _( "Orient" ), msg, DARKGREEN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) );
msg = ::CoordinateToString( m_Thickness );
aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, DARKGREEN ) );
msg = ::CoordinateToString( m_Size.x );
aList.push_back( MSG_PANEL_ITEM( _( "H Size" ), msg, RED ) );
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) );
msg = ::CoordinateToString( m_Size.y );
aList.push_back( MSG_PANEL_ITEM( _( "V Size" ), msg, RED ) );
aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) );
}

View File

@ -1023,15 +1023,15 @@ void TRACK::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
double lenPadToDie = 0;
board->MarkTrace( this, NULL, &trackLen, &lenPadToDie, false );
msg = ::LengthDoubleToString( trackLen );
aList.push_back( MSG_PANEL_ITEM( _( "Track Len" ), msg, DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKCYAN ) );
if( lenPadToDie != 0 )
{
msg = ::LengthDoubleToString( trackLen + lenPadToDie );
aList.push_back( MSG_PANEL_ITEM( _( "Full Len" ), msg, DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Full Length" ), msg, DARKCYAN ) );
msg = ::LengthDoubleToString( lenPadToDie );
aList.push_back( MSG_PANEL_ITEM( _( "In Package" ), msg, DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Pad To Die Length" ), msg, DARKCYAN ) );
}
}
@ -1155,7 +1155,7 @@ void SEGZONE::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
if( board )
msg = board->GetLayerName( m_Layer );
else
msg.Printf(wxT("%d"), m_Layer );
msg.Printf( wxT( "%d" ), m_Layer );
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) );
@ -1209,7 +1209,7 @@ void VIA::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
msg = board->GetLayerName( top_layer ) + wxT( "/" )
+ board->GetLayerName( bottom_layer );
else
msg.Printf(wxT("%d/%d"), top_layer, bottom_layer );
msg.Printf( wxT( "%d/%d" ), top_layer, bottom_layer );
aList.push_back( MSG_PANEL_ITEM( _( "Layers" ), msg, BROWN ) );
@ -1217,7 +1217,7 @@ void VIA::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
msg = ::CoordinateToString( (unsigned) m_Width );
// Display diameter value:
aList.push_back( MSG_PANEL_ITEM( _( "Diam" ), msg, DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Diameter" ), msg, DARKCYAN ) );
// Display drill value
int drill_value = GetDrillValue();

View File

@ -608,7 +608,7 @@ void ZONE_CONTAINER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
msg.Empty();
if( GetDoNotAllowVias() )
AccumulateDescription( msg, _("No via") );
AccumulateDescription( msg, _( "No via" ) );
if( GetDoNotAllowTracks() )
AccumulateDescription( msg, _("No track") );
@ -663,16 +663,16 @@ void ZONE_CONTAINER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
else
msg = _( "Polygons" );
aList.push_back( MSG_PANEL_ITEM( _( "Fill mode" ), msg, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Fill Mode" ), msg, BROWN ) );
// Useful for statistics :
msg.Printf( wxT( "%d" ), (int) m_Poly->m_HatchLines.size() );
aList.push_back( MSG_PANEL_ITEM( _( "Hatch lines" ), msg, BLUE ) );
aList.push_back( MSG_PANEL_ITEM( _( "Hatch Lines" ), msg, BLUE ) );
if( m_FilledPolysList.GetCornersCount() )
{
msg.Printf( wxT( "%d" ), (int) m_FilledPolysList.GetCornersCount() );
aList.push_back( MSG_PANEL_ITEM( _( "Corners in DrawList" ), msg, BLUE ) );
aList.push_back( MSG_PANEL_ITEM( _( "Corner Count" ), msg, BLUE ) );
}
}

View File

@ -23,22 +23,22 @@
*/
#include "dialog_track_via_size.h"
#include <router/pns_routing_settings.h>
#include <base_units.h>
#include <confirm.h>
#include <boost/optional.hpp>
DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, PNS_ROUTING_SETTINGS& aSettings ) :
#include "class_board_design_settings.h"
DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, BOARD_DESIGN_SETTINGS& aSettings ) :
DIALOG_TRACK_VIA_SIZE_BASE( aParent ),
m_settings( aSettings )
{
// Load router settings to dialog fields
m_trackWidth->SetValue( To_User_Unit( m_trackWidth->GetUnits(), m_settings.GetTrackWidth() ) );
m_viaDiameter->SetValue( To_User_Unit( m_viaDiameter->GetUnits(), m_settings.GetViaDiameter() ) );
m_viaDrill->SetValue( To_User_Unit( m_viaDrill->GetUnits(), m_settings.GetViaDrill() ) );
m_trackWidth->SetValue( To_User_Unit( m_trackWidth->GetUnits(), m_settings.GetCustomTrackWidth() ) );
m_viaDiameter->SetValue( To_User_Unit( m_viaDiameter->GetUnits(), m_settings.GetCustomViaSize() ) );
m_viaDrill->SetValue( To_User_Unit( m_viaDrill->GetUnits(), m_settings.GetCustomViaDrill() ) );
m_trackWidth->SetFocus();
GetSizer()->SetSizeHints( this );
// Pressing ENTER when any of the text input fields is active applies changes
#if wxCHECK_VERSION( 3, 0, 0 )
@ -46,6 +46,8 @@ DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, PNS_ROUTING_SET
#else
Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE::onOkClick ), NULL, this );
#endif
Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_TRACK_VIA_SIZE::onClose ) );
}
@ -56,7 +58,7 @@ bool DIALOG_TRACK_VIA_SIZE::check()
return false;
// Via drill should be smaller than via diameter
if( *m_viaDrill->GetValue() >= m_viaDiameter->GetValue() )
if( m_viaDrill->GetValue() >= m_viaDiameter->GetValue() )
return false;
return true;
@ -74,9 +76,9 @@ void DIALOG_TRACK_VIA_SIZE::onOkClick( wxCommandEvent& aEvent )
if( check() )
{
// Store dialog values to the router settings
m_settings.SetTrackWidth( From_User_Unit( m_trackWidth->GetUnits(), *m_trackWidth->GetValue() ) );
m_settings.SetViaDiameter( From_User_Unit( m_viaDiameter->GetUnits(), *m_viaDiameter->GetValue() ) );
m_settings.SetViaDrill( From_User_Unit( m_viaDrill->GetUnits(), *m_viaDrill->GetValue() ) );
m_settings.SetCustomTrackWidth( From_User_Unit( m_trackWidth->GetUnits(), *m_trackWidth->GetValue() ) );
m_settings.SetCustomViaSize( From_User_Unit( m_viaDiameter->GetUnits(), *m_viaDiameter->GetValue() ) );
m_settings.SetCustomViaDrill( From_User_Unit( m_viaDrill->GetUnits(), *m_viaDrill->GetValue() ) );
EndModal( 1 );
}
else

View File

@ -19,7 +19,7 @@
*/
/**
* Push and Shove router track width and via size dialog.
* Custom track width and via size dialog.
*/
#ifndef __dialog_track_via_size__
@ -27,18 +27,18 @@
#include "dialog_track_via_size_base.h"
class PNS_ROUTING_SETTINGS;
class BOARD_DESIGN_SETTINGS;
/** Implementing DIALOG_TRACK_VIA_SIZE_BASE */
class DIALOG_TRACK_VIA_SIZE : public DIALOG_TRACK_VIA_SIZE_BASE
{
public:
/** Constructor */
DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, PNS_ROUTING_SETTINGS& aSettings );
DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, BOARD_DESIGN_SETTINGS& aSettings );
protected:
// Routings settings that are modified by the dialog.
PNS_ROUTING_SETTINGS& m_settings;
BOARD_DESIGN_SETTINGS& m_settings;
///> Checks if values given in the dialog are sensible.
bool check();

View File

@ -1,61 +1,57 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// C++ code generated with wxFormBuilder (version Jun 6 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_shim.h"
#include "dialog_track_via_size_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_TRACK_VIA_SIZE_BASE::DIALOG_TRACK_VIA_SIZE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
this->SetSizeHints( wxSize( 280,240 ), wxDefaultSize );
wxBoxSizer* bSizes;
bSizes = new wxBoxSizer( wxVERTICAL );
m_trackWidth = new WX_UNIT_TEXT( this, _("Track width:") );
bSizes->Add( m_trackWidth, 0, wxALL, 5 );
bSizes->Add( m_trackWidth, 0, wxALL|wxEXPAND, 5 );
m_viaDiameter = new WX_UNIT_TEXT( this, _("Via diameter:") );
bSizes->Add( m_viaDiameter, 0, wxALL, 5 );
bSizes->Add( m_viaDiameter, 0, wxALL|wxEXPAND, 5 );
m_viaDrill = new WX_UNIT_TEXT( this, _("Via drill:") );
bSizes->Add( m_viaDrill, 0, wxALL, 5 );
bSizes->Add( m_viaDrill, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bButtons;
bButtons = new wxBoxSizer( wxHORIZONTAL );
m_stdButtons = new wxStdDialogButtonSizer();
m_stdButtonsOK = new wxButton( this, wxID_OK );
m_stdButtons->AddButton( m_stdButtonsOK );
m_stdButtonsCancel = new wxButton( this, wxID_CANCEL );
m_stdButtons->AddButton( m_stdButtonsCancel );
m_stdButtons->Realize();
m_ok = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
bButtons->Add( m_ok, 1, wxALL, 5 );
m_cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
bButtons->Add( m_cancel, 1, wxALL, 5 );
bSizes->Add( bButtons, 0, wxEXPAND, 5 );
bSizes->Add( m_stdButtons, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bSizes );
this->Layout();
bSizes->Fit( this );
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onClose ) );
m_ok->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onOkClick ), NULL, this );
m_cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onCancelClick ), NULL, this );
m_stdButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onCancelClick ), NULL, this );
m_stdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onOkClick ), NULL, this );
}
DIALOG_TRACK_VIA_SIZE_BASE::~DIALOG_TRACK_VIA_SIZE_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onClose ) );
m_ok->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onOkClick ), NULL, this );
m_cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onCancelClick ), NULL, this );
m_stdButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onCancelClick ), NULL, this );
m_stdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onOkClick ), NULL, this );
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="11" />
<FileVersion major="1" minor="13" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
@ -41,11 +41,11 @@
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="minimum_size">280,240</property>
<property name="name">DIALOG_TRACK_VIA_SIZE_BASE</property>
<property name="pos"></property>
<property name="size">388,162</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE</property>
<property name="subclass"></property>
<property name="title">Track width and via size</property>
<property name="tooltip"></property>
@ -147,7 +147,7 @@
<property name="settings"></property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
@ -350,189 +350,28 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">bButtons</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">1</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_OK</property>
<property name="label">OK</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_ok</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">onOkClick</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">1</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_CANCEL</property>
<property name="label">Cancel</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cancel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">onCancelClick</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<property name="name">m_stdButtons</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick">onCancelClick</event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick">onOkClick</event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// C++ code generated with wxFormBuilder (version Jun 6 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -11,16 +11,14 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include <wxunittext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@ -37,18 +35,19 @@ class DIALOG_TRACK_VIA_SIZE_BASE : public wxDialog
WX_UNIT_TEXT* m_trackWidth;
WX_UNIT_TEXT* m_viaDiameter;
WX_UNIT_TEXT* m_viaDrill;
wxButton* m_ok;
wxButton* m_cancel;
wxStdDialogButtonSizer* m_stdButtons;
wxButton* m_stdButtonsOK;
wxButton* m_stdButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void onClose( wxCloseEvent& event ) { event.Skip(); }
virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_TRACK_VIA_SIZE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Track width and via size"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 388,162 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_TRACK_VIA_SIZE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Track width and via size"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE );
~DIALOG_TRACK_VIA_SIZE_BASE();
};

View File

@ -387,7 +387,6 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
else
{
double width = ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0;
radius -= width / 2.0;
m_gal->SetLineWidth( width );
m_gal->SetIsFill( true );

View File

@ -24,6 +24,7 @@ set( PCBNEW_PNS_SRCS
pns_router.cpp
pns_routing_settings.cpp
pns_shove.cpp
pns_sizes_settings.cpp
pns_solid.cpp
pns_utils.cpp
pns_via.cpp

View File

@ -65,7 +65,7 @@ public:
ANG_UNDEFINED = 0x20
};
DIRECTION_45( Directions aDir = UNDEFINED ) : m_dir( aDir ) {};
DIRECTION_45( Directions aDir = UNDEFINED ) : m_dir( aDir ) {}
/**
* Constructor

View File

@ -25,7 +25,7 @@
#include "pns_router.h"
PNS_DRAGGER::PNS_DRAGGER( PNS_ROUTER* aRouter ) :
PNS_ALGO_BASE ( aRouter )
PNS_ALGO_BASE( aRouter )
{
m_world = NULL;
m_shove = NULL;
@ -39,7 +39,7 @@ PNS_DRAGGER::~PNS_DRAGGER()
}
void PNS_DRAGGER::SetWorld ( PNS_NODE* aWorld )
void PNS_DRAGGER::SetWorld( PNS_NODE* aWorld )
{
m_world = aWorld;
}
@ -49,7 +49,7 @@ bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT* aSeg )
{
int w2 = aSeg->Width() / 2;
m_draggedLine = m_world->AssembleLine ( aSeg, &m_draggedSegmentIndex );
m_draggedLine = m_world->AssembleLine( aSeg, &m_draggedSegmentIndex );
m_shove->SetInitialLine( m_draggedLine );
m_lastValidDraggedLine = *m_draggedLine;
m_lastValidDraggedLine.ClearSegmentLinks();
@ -58,9 +58,9 @@ bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT* aSeg )
m_mode = CORNER;
else if( ( aP - aSeg->Seg().B ).EuclideanNorm() <= w2 )
{
m_draggedSegmentIndex ++;
m_draggedSegmentIndex++;
m_mode = CORNER;
} else
} else
m_mode = SEGMENT;
return true;
@ -74,14 +74,14 @@ bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia )
m_mode = VIA;
VECTOR2I p0( aVia->Pos() );
PNS_JOINT *jt = m_world->FindJoint( p0, aVia->Layers().Start(), aVia->Net() );
PNS_JOINT* jt = m_world->FindJoint( p0, aVia->Layers().Start(), aVia->Net() );
BOOST_FOREACH(PNS_ITEM *item, jt->LinkList() )
BOOST_FOREACH( PNS_ITEM* item, jt->LinkList() )
{
if( item->OfKind( PNS_ITEM::SEGMENT ) )
{
int segIndex;
PNS_SEGMENT* seg = (PNS_SEGMENT*) item;
PNS_SEGMENT* seg = ( PNS_SEGMENT*) item;
std::auto_ptr<PNS_LINE> l( m_world->AssembleLine( seg, &segIndex ) );
if( segIndex != 0 )
@ -97,29 +97,29 @@ bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia )
bool PNS_DRAGGER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
{
m_shove = new PNS_SHOVE( m_world, Router() );
m_shove = new PNS_SHOVE( m_world, Router() );
m_lastNode = NULL;
m_draggedItems.Clear();
m_currentMode = Settings().Mode();
TRACE( 2, "StartDragging: item %p [kind %d]", aStartItem % aStartItem->Kind() );
switch( aStartItem->Kind() )
{
case PNS_ITEM::SEGMENT:
return startDragSegment ( aP, static_cast<PNS_SEGMENT *>( aStartItem ) );
switch( aStartItem->Kind() )
{
case PNS_ITEM::SEGMENT:
return startDragSegment( aP, static_cast<PNS_SEGMENT*>( aStartItem ) );
case PNS_ITEM::VIA:
return startDragVia ( aP, static_cast<PNS_VIA *> (aStartItem) );
case PNS_ITEM::VIA:
return startDragVia( aP, static_cast<PNS_VIA*>( aStartItem ) );
default:
return false;
}
default:
return false;
}
}
bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP )
{
{
if( m_lastNode )
{
delete m_lastNode;
@ -133,20 +133,20 @@ bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP )
{
int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0;
PNS_LINE tmp( *m_draggedLine );
if( m_mode == SEGMENT )
tmp.DragSegment ( aP, m_draggedSegmentIndex, thresh );
tmp.DragSegment( aP, m_draggedSegmentIndex, thresh );
else
tmp.DragCorner ( aP, m_draggedSegmentIndex, thresh );
tmp.DragCorner( aP, m_draggedSegmentIndex, thresh );
m_lastNode = m_shove->CurrentNode()->Branch();
m_lastValidDraggedLine = tmp;
m_lastValidDraggedLine.ClearSegmentLinks();
m_lastValidDraggedLine.Unmark();
m_lastNode->Add ( &m_lastValidDraggedLine );
m_draggedItems = PNS_ITEMSET ( &m_lastValidDraggedLine );
m_lastNode->Add( &m_lastValidDraggedLine );
m_draggedItems = PNS_ITEMSET( &m_lastValidDraggedLine );
break;
}
@ -154,7 +154,7 @@ bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP )
case VIA: // fixme...
{
m_lastNode = m_shove->CurrentNode()->Branch();
dumbDragVia ( m_initialVia, m_lastNode, aP );
dumbDragVia( m_initialVia, m_lastNode, aP );
break;
}
@ -164,7 +164,7 @@ bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP )
m_dragStatus = true;
else
m_dragStatus = !m_world->CheckColliding( m_draggedItems );
return true;
}
@ -176,20 +176,20 @@ void PNS_DRAGGER::dumbDragVia( PNS_VIA* aVia, PNS_NODE* aNode, const VECTOR2I& a
m_draggedVia->SetPos( aP );
m_draggedItems.Clear();
m_draggedItems.Add( m_draggedVia );
m_lastNode->Remove( aVia );
m_lastNode->Add( m_draggedVia );
BOOST_FOREACH( PNS_LINE &l, m_origViaConnections )
{
PNS_LINE origLine (l);
PNS_LINE origLine( l );
PNS_LINE* draggedLine = l.Clone();
draggedLine->DragCorner( aP, 0 );
draggedLine->ClearSegmentLinks();
m_draggedItems.AddOwned( draggedLine );
m_draggedItems.Add( draggedLine ); // FIXME: mem leak
m_lastNode->Remove( &origLine );
m_lastNode->Add( draggedLine );
}
@ -208,43 +208,43 @@ bool PNS_DRAGGER::dragShove( const VECTOR2I& aP )
switch( m_mode )
{
case SEGMENT:
case CORNER:
{
int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0;
PNS_LINE tmp( *m_draggedLine );
case SEGMENT:
case CORNER:
{
int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0;
PNS_LINE tmp( *m_draggedLine );
if( m_mode == SEGMENT )
tmp.DragSegment( aP, m_draggedSegmentIndex, thresh );
else
tmp.DragCorner( aP, m_draggedSegmentIndex, thresh );
if( m_mode == SEGMENT )
tmp.DragSegment( aP, m_draggedSegmentIndex, thresh );
else
tmp.DragCorner( aP, m_draggedSegmentIndex, thresh );
PNS_SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( tmp );
if( st == PNS_SHOVE::SH_OK )
ok = true;
ok = true;
else if( st == PNS_SHOVE::SH_HEAD_MODIFIED )
{
tmp = m_shove->NewHead();
ok = true;
}
}
m_lastNode = m_shove->CurrentNode()->Branch();
if( ok )
m_lastValidDraggedLine = tmp;
m_lastValidDraggedLine.ClearSegmentLinks();
m_lastValidDraggedLine.Unmark();
m_lastNode->Add( &m_lastValidDraggedLine );
m_draggedItems = PNS_ITEMSET( &m_lastValidDraggedLine );
break;
}
}
case VIA:
{
PNS_VIA *newVia;
{
PNS_VIA* newVia;
PNS_SHOVE::SHOVE_STATUS st = m_shove->ShoveDraggingVia( m_draggedVia, aP, &newVia );
if( st == PNS_SHOVE::SH_OK || st == PNS_SHOVE::SH_HEAD_MODIFIED )
@ -261,7 +261,7 @@ bool PNS_DRAGGER::dragShove( const VECTOR2I& aP )
break;
}
}
m_dragStatus = ok;
return ok;
@ -274,7 +274,7 @@ bool PNS_DRAGGER::FixRoute()
{
Router()->CommitRouting( CurrentNode() );
return true;
}
}
return false;
}
@ -282,23 +282,23 @@ bool PNS_DRAGGER::FixRoute()
bool PNS_DRAGGER::Drag( const VECTOR2I& aP )
{
switch( m_currentMode )
{
case RM_MarkObstacles:
return dragMarkObstacles( aP );
switch( m_currentMode )
{
case RM_MarkObstacles:
return dragMarkObstacles( aP );
case RM_Shove:
case RM_Walkaround:
case RM_Smart:
return dragShove( aP );
case RM_Shove:
case RM_Walkaround:
case RM_Smart:
return dragShove( aP );
default:
return false;
}
default:
return false;
}
}
PNS_NODE *PNS_DRAGGER::CurrentNode() const
PNS_NODE* PNS_DRAGGER::CurrentNode() const
{
return m_lastNode;
}

View File

@ -24,32 +24,13 @@
PNS_ITEMSET::PNS_ITEMSET( PNS_ITEM* aInitialItem )
{
if(aInitialItem)
m_items.push_back(aInitialItem);
if( aInitialItem )
m_items.push_back( aInitialItem );
}
PNS_ITEMSET::~PNS_ITEMSET()
PNS_ITEMSET& PNS_ITEMSET::FilterLayers( int aStart, int aEnd, bool aInvert )
{
Clear();
}
void PNS_ITEMSET::Clear()
{
BOOST_FOREACH(PNS_ITEM* item, m_ownedItems)
{
delete item;
}
m_items.clear();
m_ownedItems.clear();
}
PNS_ITEMSET& PNS_ITEMSET::FilterLayers( int aStart, int aEnd )
{
ITEM_VECTOR newItems;
ITEMS newItems;
PNS_LAYERSET l;
if( aEnd < 0 )
@ -59,7 +40,7 @@ PNS_ITEMSET& PNS_ITEMSET::FilterLayers( int aStart, int aEnd )
BOOST_FOREACH( PNS_ITEM* item, m_items )
if( item->Layers().Overlaps( l ) )
if( item->Layers().Overlaps( l ) ^ aInvert )
newItems.push_back( item );
m_items = newItems;
@ -68,13 +49,13 @@ PNS_ITEMSET& PNS_ITEMSET::FilterLayers( int aStart, int aEnd )
}
PNS_ITEMSET& PNS_ITEMSET::FilterKinds( int aKindMask )
PNS_ITEMSET& PNS_ITEMSET::FilterKinds( int aKindMask, bool aInvert )
{
ITEM_VECTOR newItems;
ITEMS newItems;
BOOST_FOREACH( PNS_ITEM* item, m_items )
{
if( item->OfKind ( aKindMask ) )
if( item->OfKind( aKindMask ) ^ aInvert )
newItems.push_back( item );
}
@ -84,13 +65,28 @@ PNS_ITEMSET& PNS_ITEMSET::FilterKinds( int aKindMask )
}
PNS_ITEMSET& PNS_ITEMSET::FilterNet( int aNet )
PNS_ITEMSET& PNS_ITEMSET::FilterNet( int aNet, bool aInvert )
{
ITEM_VECTOR newItems;
ITEMS newItems;
BOOST_FOREACH( PNS_ITEM* item, m_items )
{
if( item->Net() == aNet )
if( ( item->Net() == aNet ) ^ aInvert )
newItems.push_back( item );
}
m_items = newItems;
return *this;
}
PNS_ITEMSET& PNS_ITEMSET::ExcludeItem( const PNS_ITEM* aItem )
{
ITEMS newItems;
BOOST_FOREACH( PNS_ITEM* item, m_items )
{
if( item != aItem )
newItems.push_back( item );
}

View File

@ -22,6 +22,7 @@
#define __PNS_ITEMSET_H
#include <vector>
#include <boost/foreach.hpp>
#include "pns_item.h"
@ -35,53 +36,96 @@
class PNS_ITEMSET
{
public:
typedef std::vector<PNS_ITEM*> ITEM_VECTOR;
typedef std::vector<PNS_ITEM*> ITEMS;
PNS_ITEMSET( PNS_ITEM* aInitialItem = NULL );
PNS_ITEMSET( const PNS_ITEMSET& aOther )
{
m_items = aOther.m_items;
m_ownedItems = ITEM_VECTOR();
}
const PNS_ITEMSET& operator=( const PNS_ITEMSET& aOther )
{
m_items = aOther.m_items;
m_ownedItems = ITEM_VECTOR();
return *this;
}
~PNS_ITEMSET();
int Count( int aKindMask = -1 ) const
{
int n = 0;
BOOST_FOREACH( PNS_ITEM* item, m_items )
{
if( item->Kind() & aKindMask )
n++;
}
return n;
}
ITEM_VECTOR& Items() { return m_items; }
const ITEM_VECTOR& CItems() const { return m_items; }
ITEMS& Items() { return m_items; }
const ITEMS& CItems() const { return m_items; }
PNS_ITEMSET& FilterLayers( int aStart, int aEnd = -1 );
PNS_ITEMSET& FilterKinds( int aKindMask );
PNS_ITEMSET& FilterNet( int aNet );
PNS_ITEMSET& FilterLayers( int aStart, int aEnd = -1, bool aInvert = false );
PNS_ITEMSET& FilterKinds( int aKindMask, bool aInvert = false );
PNS_ITEMSET& FilterNet( int aNet, bool aInvert = false );
int Size() { return m_items.size(); }
PNS_ITEMSET& ExcludeLayers( int aStart, int aEnd = -1 )
{
return FilterLayers( aStart, aEnd, true );
}
PNS_ITEMSET& ExcludeKinds( int aKindMask )
{
return FilterKinds( aKindMask, true );
}
PNS_ITEMSET& ExcludeNet( int aNet )
{
return FilterNet( aNet, true );
}
PNS_ITEMSET& ExcludeItem( const PNS_ITEM* aItem );
int Size() const
{
return m_items.size();
}
void Add( PNS_ITEM* aItem )
{
m_items.push_back( aItem );
}
PNS_ITEM* Get( int index ) const { return m_items[index]; }
void Clear();
void AddOwned( PNS_ITEM *aItem )
PNS_ITEM* Get( int index ) const
{
m_items.push_back( aItem );
m_ownedItems.push_back( aItem );
return m_items[index];
}
PNS_ITEM* operator[] ( int index ) const
{
return m_items[index];
}
void Clear()
{
m_items.clear();
}
bool Contains( const PNS_ITEM* aItem ) const
{
return std::find( m_items.begin(), m_items.end(), aItem ) != m_items.end();
}
void Erase( const PNS_ITEM* aItem )
{
ITEMS::iterator f = std::find( m_items.begin(), m_items.end(), aItem );
if( f != m_items.end() )
m_items.erase( f );
}
private:
ITEM_VECTOR m_items;
ITEM_VECTOR m_ownedItems;
ITEMS m_items;
};
#endif

View File

@ -28,6 +28,7 @@
#include "pns_item.h"
#include "pns_segment.h"
#include "pns_itemset.h"
/**
* Class PNS_JOINT
@ -71,7 +72,7 @@ public:
m_layers = aB.m_layers;
}
PNS_ITEM* Clone ( ) const
PNS_ITEM* Clone( ) const
{
assert( false );
return NULL;
@ -81,7 +82,7 @@ public:
/// segments of the same net, on the same layer.
bool IsLineCorner() const
{
if( m_linkedItems.size() != 2 )
if( m_linkedItems.Size() != 2 )
return false;
if( m_linkedItems[0]->Kind() != SEGMENT || m_linkedItems[1]->Kind() != SEGMENT )
@ -97,24 +98,18 @@ public:
///> Links the joint to a given board item (when it's added to the PNS_NODE)
void Link( PNS_ITEM* aItem )
{
LINKED_ITEMS::iterator f = std::find( m_linkedItems.begin(), m_linkedItems.end(), aItem );
if( f != m_linkedItems.end() )
if( m_linkedItems.Contains( aItem ) )
return;
m_linkedItems.push_back( aItem );
m_linkedItems.Add( aItem );
}
///> Unlinks a given board item from the joint (upon its removal from a PNS_NODE)
///> Returns true if the joint became dangling after unlinking.
bool Unlink( PNS_ITEM* aItem )
{
LINKED_ITEMS::iterator f = std::find( m_linkedItems.begin(), m_linkedItems.end(), aItem );
if( f != m_linkedItems.end() )
f = m_linkedItems.erase( f );
return m_linkedItems.size() == 0;
m_linkedItems.Erase( aItem );
return m_linkedItems.Size() == 0;
}
///> For trivial joints, returns the segment adjacent to (aCurrent). For non-trival ones, returns
@ -127,51 +122,41 @@ public:
return static_cast<PNS_SEGMENT*>( m_linkedItems[m_linkedItems[0] == aCurrent ? 1 : 0] );
}
PNS_VIA* Via()
{
for( LINKED_ITEMS::iterator i = m_linkedItems.begin(); i != m_linkedItems.end(); ++i )
{
if( (*i)->Kind() == PNS_ITEM::VIA )
return (PNS_VIA*)( *i );
}
return NULL;
}
/// trivial accessors
const HASH_TAG& Tag() const
{
return m_tag;
}
const VECTOR2I& Pos() const
{
return m_tag.pos;
}
int Net() const
{
return m_tag.net;
}
LINKED_ITEMS& LinkList()
{
return m_linkedItems;
const HASH_TAG& Tag() const
{
return m_tag;
}
const VECTOR2I& Pos() const
{
return m_tag.pos;
}
int Net() const
{
return m_tag.net;
}
const LINKED_ITEMS& LinkList() const
{
return m_linkedItems.CItems();
}
const PNS_ITEMSET& CLinks() const
{
return m_linkedItems;
}
PNS_ITEMSET Links() const
{
return m_linkedItems;
}
///> Returns the number of linked items of types listed in aMask.
int LinkCount( int aMask = -1 ) const
{
int n = 0;
for( LINKED_ITEMS::const_iterator i = m_linkedItems.begin();
i != m_linkedItems.end(); ++i )
{
if( (*i)->Kind() & aMask )
n++;
}
return n;
return m_linkedItems.Count( aMask );
}
void Dump() const;
@ -188,11 +173,9 @@ public:
m_layers.Merge( aJoint.m_layers );
// fixme: duplicate links (?)
for( LINKED_ITEMS::const_iterator i = aJoint.m_linkedItems.begin();
i != aJoint.m_linkedItems.end(); ++i )
BOOST_FOREACH( PNS_ITEM* item, aJoint.LinkList() )
{
m_linkedItems.push_back( *i );
m_linkedItems.Add( item );
}
}
@ -207,7 +190,7 @@ private:
HASH_TAG m_tag;
///> list of items linked to this joint
LINKED_ITEMS m_linkedItems;
PNS_ITEMSET m_linkedItems;
};

View File

@ -108,7 +108,7 @@ public:
///> Shortcut for comparisons/overlap tests
static PNS_LAYERSET All()
{
return PNS_LAYERSET( 0, 64 );
return PNS_LAYERSET( 0, 256 ); // fixme: use layer IDs header
}
private:

View File

@ -123,7 +123,7 @@ int PNS_LINE::Marker()const
}
void PNS_LINE::copyLinks( const PNS_LINE *aParent )
void PNS_LINE::copyLinks( const PNS_LINE* aParent )
{
if( aParent->m_segmentRefs == NULL )
{
@ -190,6 +190,9 @@ bool PNS_LINE::Walkaround( SHAPE_LINE_CHAIN aObstacle, SHAPE_LINE_CHAIN& aPre,
line.Intersect( aObstacle, ips );
aWalk.Clear();
aPost.Clear();
int nearest_dist = INT_MAX;
int farthest_dist = 0;
@ -410,7 +413,7 @@ void PNS_LINE::DragCorner ( const VECTOR2I& aP, int aIndex, int aSnappingThresho
if( aIndex == 0 )
path = dragCornerInternal( m_line.Reverse(), snapped ).Reverse();
else if ( aIndex == m_line.SegmentCount() )
else if( aIndex == m_line.SegmentCount() )
path = dragCornerInternal( m_line, snapped );
else
{

View File

@ -40,10 +40,10 @@ PNS_LINE_PLACER::PNS_LINE_PLACER( PNS_ROUTER* aRouter ) :
PNS_ALGO_BASE ( aRouter )
{
m_initial_direction = DIRECTION_45::N;
m_iteration = 0;
m_world = NULL;
m_shove = NULL;
m_currentNode = NULL;
m_idle = true;
}
@ -59,52 +59,22 @@ void PNS_LINE_PLACER::setWorld ( PNS_NODE* aWorld )
m_world = aWorld;
}
void PNS_LINE_PLACER::AddVia( bool aEnabled, int aDiameter, int aDrill, VIATYPE_T aType )
const PNS_VIA PNS_LINE_PLACER::makeVia ( const VECTOR2I& aP )
{
const PNS_LAYERSET layers( m_sizes.GetLayerTop(), m_sizes.GetLayerBottom() );
return PNS_VIA ( aP, layers, m_sizes.ViaDiameter(), m_sizes.ViaDrill(), -1, m_sizes.ViaType() );
}
void PNS_LINE_PLACER::ToggleVia( bool aEnabled )
{
m_viaDiameter = aDiameter;
m_viaDrill = aDrill;
m_placingVia = aEnabled;
m_viaType = aType;
if(!m_idle)
Move ( m_currentEnd, NULL );
}
void PNS_LINE_PLACER::startPlacement( const VECTOR2I& aStart, int aNet, int aWidth, int aLayer )
{
assert( m_world != NULL );
m_direction = m_initial_direction;
TRACE( 1, "world %p, initial-direction %s layer %d\n",
m_world % m_direction.Format().c_str() % aLayer );
m_head.SetNet( aNet );
m_tail.SetNet( aNet );
m_head.SetWidth( aWidth );
m_tail.SetWidth( aWidth );
m_head.Line().Clear();
m_tail.Line().Clear();
m_head.SetLayer( aLayer );
m_tail.SetLayer( aLayer );
m_iteration = 0;
m_p_start = aStart;
m_lastNode = NULL;
m_currentNode = m_world;
m_currentMode = Settings().Mode();
if( m_shove )
delete m_shove;
m_shove = NULL;
if( m_currentMode == RM_Shove || m_currentMode == RM_Smart )
{
m_shove = new PNS_SHOVE( m_world->Branch(), Router() );
}
m_placingVia = false;
}
void PNS_LINE_PLACER::setInitialDirection( const DIRECTION_45& aDirection )
{
@ -380,8 +350,9 @@ bool PNS_LINE_PLACER::handleViaPlacement( PNS_LINE& aHead )
if( !m_placingVia )
return true;
PNS_LAYERSET layers( Settings().GetLayerTop(), Settings().GetLayerBottom() );
PNS_VIA v( aHead.CPoint( -1 ), layers, m_viaDiameter, m_viaDrill, aHead.Net(), m_viaType );
PNS_VIA v ( makeVia ( aHead.CPoint( -1 ) ) );
v.SetNet ( aHead.Net() );
VECTOR2I force;
VECTOR2I lead = aHead.CPoint( -1 ) - aHead.CPoint( 0 );
@ -415,12 +386,12 @@ bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead )
walkaround.SetSolidsOnly( false );
walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
PNS_WALKAROUND::WALKAROUND_STATUS wf = walkaround.Route( initTrack, walkFull, false );
switch( Settings().OptimizerEffort() )
{
case OE_LOW:
case OE_LOW:
effort = 0;
break;
@ -440,9 +411,7 @@ bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead )
}
else if( m_placingVia && viaOk )
{
PNS_LAYERSET layers( Settings().GetLayerTop(), Settings().GetLayerBottom() );
PNS_VIA v1( walkFull.CPoint( -1 ), layers, m_viaDiameter, m_viaDrill, -1, m_viaType );
walkFull.AppendVia( v1 );
walkFull.AppendVia( makeVia ( walkFull.CPoint( -1 ) ) );
}
PNS_OPTIMIZER::Optimize( &walkFull, effort, m_currentNode );
@ -454,7 +423,7 @@ bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead )
m_head = walkFull;
aNewHead = walkFull;
return rv;
}
@ -462,16 +431,14 @@ bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead )
bool PNS_LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, PNS_LINE& aNewHead )
{
m_head.SetShape( m_direction.BuildInitialTrace( m_p_start, aP ) );
if( m_placingVia )
{
PNS_LAYERSET layers( Settings().GetLayerTop(), Settings().GetLayerBottom() );
PNS_VIA v1( m_head.CPoint( -1 ), layers, m_viaDiameter, m_viaDrill, -1, m_viaType );
m_head.AppendVia( v1 );
m_head.AppendVia( makeVia ( m_head.CPoint( -1 ) ) );
}
aNewHead = m_head;
return m_currentNode->CheckColliding( &m_head );
}
@ -508,24 +475,23 @@ bool PNS_LINE_PLACER::rhShoveOnly ( const VECTOR2I& aP, PNS_LINE& aNewHead )
if( m_placingVia )
{
PNS_LAYERSET layers( Settings().GetLayerTop(), Settings().GetLayerBottom() );
PNS_VIA v1( l.CPoint( -1 ), layers, m_viaDiameter, m_viaDrill, -1, m_viaType );
PNS_VIA v2( l2.CPoint( -1 ), layers, m_viaDiameter, m_viaDrill, -1, m_viaType );
PNS_VIA v1( makeVia ( l.CPoint( -1 ) ) );
PNS_VIA v2( makeVia ( l2.CPoint( -1 ) ) );
l.AppendVia( v1 );
l2.AppendVia( v2 );
}
l.Line().Simplify();
l.Line().Simplify();
// in certain, uncommon cases there may be loops in the head+tail, In such case, we don't shove to avoid
// screwing up the database.
if( l.HasLoops() )
{
aNewHead = m_head;
return false;
return false;
}
PNS_SHOVE::SHOVE_STATUS status = m_shove->ShoveLines( l );
m_currentNode = m_shove->CurrentNode();
@ -570,7 +536,7 @@ bool PNS_LINE_PLACER::routeHead( const VECTOR2I& aP, PNS_LINE& aNewHead )
default:
break;
}
return false;
}
@ -584,14 +550,14 @@ bool PNS_LINE_PLACER::optimizeTailHeadTransition()
if( tmp.SegmentCount() < 1 )
return false;
m_head = tmp;
m_head = tmp;
m_p_start = tmp.CLine().CPoint( 0 );
m_direction = DIRECTION_45( tmp.CSegment( 0 ) );
m_tail.Line().Clear();
return true;
}
SHAPE_LINE_CHAIN& head = m_head.Line();
SHAPE_LINE_CHAIN& tail = m_tail.Line();
@ -710,9 +676,9 @@ const PNS_LINE PNS_LINE_PLACER::Trace() const
}
const PNS_ITEMSET PNS_LINE_PLACER::Traces()
const PNS_ITEMSET PNS_LINE_PLACER::Traces()
{
m_currentTrace = Trace();
m_currentTrace = Trace();
return PNS_ITEMSET( &m_currentTrace );
}
@ -737,13 +703,13 @@ void PNS_LINE_PLACER::splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, co
{
if( aSeg && aSeg->OfKind( PNS_ITEM::SEGMENT ) )
{
PNS_JOINT *jt = aNode->FindJoint( aP, aSeg );
PNS_JOINT* jt = aNode->FindJoint( aP, aSeg );
if( jt && jt->LinkCount() >= 1 )
return;
PNS_SEGMENT* s_old = static_cast<PNS_SEGMENT*>( aSeg );
PNS_SEGMENT* s_new[2];
s_new[0] = s_old->Clone();
@ -759,15 +725,25 @@ void PNS_LINE_PLACER::splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, co
}
void PNS_LINE_PLACER::SetLayer( int aLayer )
bool PNS_LINE_PLACER::SetLayer( int aLayer )
{
m_currentLayer = aLayer;
if( m_idle )
{
m_currentLayer = aLayer;
return true;
} else if( m_chainedPlacement ) {
return false;
} else if( !m_startItem || ( m_startItem->OfKind( PNS_ITEM::VIA ) && m_startItem->Layers().Overlaps( aLayer ) ) ) {
m_currentLayer = aLayer;
m_splitSeg = false;
initPlacement ( m_splitSeg );
Move ( m_currentEnd, NULL );
return true;
}
m_head.SetLayer( aLayer );
m_tail.SetLayer( aLayer );
return false;
}
void PNS_LINE_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
{
VECTOR2I p( aP );
@ -775,33 +751,71 @@ void PNS_LINE_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
static int unknowNetIdx = 0; // -10000;
int net = -1;
m_lastNode = NULL;
m_placingVia = false;
m_startsOnVia = false;
bool splitSeg = false;
if( Router()->SnappingEnabled() )
p = Router()->SnapToItem( aStartItem, aP, splitSeg );
if( !aStartItem || aStartItem->Net() < 0 )
net = unknowNetIdx--;
else
net = aStartItem->Net();
m_currentStart = p;
m_originalStart = p;
m_currentStart = p;
m_currentEnd = p;
m_currentNet = net;
m_startItem = aStartItem;
m_placingVia = false;
m_chainedPlacement = false;
m_splitSeg = splitSeg;
PNS_NODE* rootNode = Router()->GetWorld()->Branch();
if( splitSeg )
splitAdjacentSegments( rootNode, aStartItem, p );
setWorld( rootNode );
setInitialDirection( Settings().InitialDirection() );
startPlacement( p, m_currentNet, m_currentWidth, m_currentLayer );
initPlacement( m_splitSeg );
}
void PNS_LINE_PLACER::initPlacement( bool aSplitSeg )
{
m_idle = false;
m_head.Line().Clear();
m_tail.Line().Clear();
m_head.SetNet( m_currentNet );
m_tail.SetNet( m_currentNet );
m_head.SetLayer( m_currentLayer );
m_tail.SetLayer( m_currentLayer );
m_head.SetWidth( m_sizes.TrackWidth() );
m_tail.SetWidth( m_sizes.TrackWidth() );
m_p_start = m_currentStart;
m_direction = m_initial_direction;
PNS_NODE* world = Router()->GetWorld();
world->KillChildren();
PNS_NODE* rootNode = world->Branch();
if( aSplitSeg )
splitAdjacentSegments( rootNode, m_startItem, m_currentStart );
setWorld( rootNode );
TRACE( 1, "world %p, intitial-direction %s layer %d\n",
m_world % m_direction.Format().c_str() % aLayer );
m_lastNode = NULL;
m_currentNode = m_world;
m_currentMode = Settings().Mode();
if( m_shove )
delete m_shove;
m_shove = NULL;
if( m_currentMode == RM_Shove || m_currentMode == RM_Smart )
{
m_shove = new PNS_SHOVE( m_world->Branch(), Router() );
}
}
@ -810,20 +824,20 @@ void PNS_LINE_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
PNS_LINE current;
VECTOR2I p = aP;
int eiDepth = -1;
if( aEndItem && aEndItem->Owner() )
eiDepth = aEndItem->Owner()->Depth();
if( m_lastNode )
{
delete m_lastNode;
m_lastNode = NULL;
}
route( p );
current = Trace();
if( !current.PointCount() )
m_currentEnd = m_p_start;
else
@ -831,14 +845,14 @@ void PNS_LINE_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
PNS_NODE* latestNode = m_currentNode;
m_lastNode = latestNode->Branch();
if( eiDepth >= 0 && aEndItem && latestNode->Depth() > eiDepth &&
current.SegmentCount() && current.CPoint( -1 ) == aP )
{
splitAdjacentSegments( m_lastNode, aEndItem, current.CPoint( -1 ) );
if( Settings().RemoveLoops() )
removeLoops( m_lastNode, &current );
removeLoops( m_lastNode, &current );
}
updateLeadingRatLine();
@ -849,7 +863,7 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
bool realEnd = false;
int lastV;
PNS_LINE pl = Trace();
if( m_currentMode == RM_MarkObstacles &&
@ -894,33 +908,22 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
if( realEnd )
simplifyNewLine( m_lastNode, lastSeg );
Router()->CommitRouting( m_lastNode );
m_lastNode = NULL;
if( !realEnd )
{
setInitialDirection( d_last );
VECTOR2I p_start = m_placingVia ? p_last : p_pre_last;
if( m_placingVia )
{
int layerTop = Router()->Settings().GetLayerTop();
int layerBottom = Router()->Settings().GetLayerBottom();
// Change the current layer to the other side of the board
if( m_currentLayer == layerTop )
m_currentLayer = layerBottom;
else
m_currentLayer = layerTop;
}
setWorld( Router()->GetWorld()->Branch() );
startPlacement( p_start, m_head.Net(), m_head.Width(), m_currentLayer );
m_startsOnVia = m_placingVia;
m_currentStart = m_placingVia ? p_last : p_pre_last;
m_startItem = NULL;
m_placingVia = false;
m_chainedPlacement = !pl.EndsWithVia();
m_splitSeg = false;
initPlacement( );
} else {
m_idle = true;
}
return realEnd;
@ -933,10 +936,10 @@ void PNS_LINE_PLACER::removeLoops( PNS_NODE* aNode, PNS_LINE* aLatest )
return;
aNode->Add( aLatest, true );
for( int s = 0; s < aLatest->SegmentCount(); s++ )
{
PNS_SEGMENT *seg = ( *aLatest->LinkedSegments() )[s];
PNS_SEGMENT* seg = ( *aLatest->LinkedSegments() )[s];
PNS_LINE* ourLine = aNode->AssembleLine( seg );
PNS_JOINT a, b;
std::vector<PNS_LINE*> lines;
@ -947,7 +950,7 @@ void PNS_LINE_PLACER::removeLoops( PNS_NODE* aNode, PNS_LINE* aLatest )
{
aNode->FindLineEnds( aLatest, a, b);
}
aNode->FindLinesBetweenJoints( a, b, lines );
int removedCount = 0;
@ -973,7 +976,7 @@ void PNS_LINE_PLACER::removeLoops( PNS_NODE* aNode, PNS_LINE* aLatest )
delete ourLine;
}
aNode->Remove( aLatest );
}
@ -988,44 +991,42 @@ void PNS_LINE_PLACER::simplifyNewLine( PNS_NODE* aNode, PNS_SEGMENT* aLatest )
if( simplified.PointCount() != l->PointCount() )
{
std::auto_ptr<PNS_LINE> lnew ( l->Clone() );
aNode -> Remove(l);
lnew->SetShape(simplified);
aNode -> Remove( l );
lnew->SetShape( simplified );
aNode -> Add( lnew.get() );
}
}
void PNS_LINE_PLACER::UpdateSizes( const PNS_ROUTING_SETTINGS& aSettings )
void PNS_LINE_PLACER::UpdateSizes( const PNS_SIZES_SETTINGS& aSizes )
{
int trackWidth = aSettings.GetTrackWidth();
m_head.SetWidth( trackWidth );
m_tail.SetWidth( trackWidth );
m_currentWidth = trackWidth;
m_viaDiameter = aSettings.GetViaDiameter();
m_viaDrill = aSettings.GetViaDrill();
m_sizes = aSizes;
if( !m_idle )
{
initPlacement ( m_splitSeg );
Move ( m_currentEnd, NULL );
}
}
void PNS_LINE_PLACER::updateLeadingRatLine()
{
PNS_LINE current = Trace();
if( !current.PointCount() )
return;
std::auto_ptr<PNS_NODE> tmpNode ( m_lastNode->Branch() );
tmpNode->Add( &current );
PNS_JOINT *jt = tmpNode->FindJoint( current.CPoint( -1 ),
PNS_JOINT* jt = tmpNode->FindJoint( current.CPoint( -1 ),
current.Layers().Start(), current.Net() );
if( !jt )
return;
int anchor;
PNS_ITEM *it = tmpNode->NearestUnconnectedItem( jt, &anchor );
PNS_ITEM* it = tmpNode->NearestUnconnectedItem( jt, &anchor );
if( it )
{

View File

@ -26,6 +26,7 @@
#include <geometry/shape.h>
#include <geometry/shape_line_chain.h>
#include "pns_sizes_settings.h"
#include "pns_node.h"
#include "pns_via.h"
#include "pns_line.h"
@ -35,11 +36,14 @@ class PNS_ROUTER;
class PNS_SHOVE;
class PNS_OPTIMIZER;
class PNS_ROUTER_BASE;
class PNS_VIA;
class PNS_SIZES_SETTINGS;
/**
* Class PNS_LINE_PLACER
*
* Single track placement algorithm. Interactively routes a track.
* Single track placement algorithm. Interactively routes a track.
* Applies shove and walkaround algorithms when needed.
*/
@ -51,7 +55,7 @@ public:
/**
* Function Start()
*
*
* Starts routing a single track at point aP, taking item aStartItem as anchor
* (unless NULL).
*/
@ -59,8 +63,8 @@ public:
/**
* Function Move()
*
* Moves the end of the currently routed trace to the point aP, taking
*
* Moves the end of the currently routed trace to the point aP, taking
* aEndItem as anchor (if not NULL).
* (unless NULL).
*/
@ -68,7 +72,7 @@ public:
/**
* Function FixRoute()
*
*
* Commits the currently routed track to the parent node, taking
* aP as the final end point and aEndItem as the final anchor (if provided).
* @return true, if route has been commited. May return false if the routing
@ -76,31 +80,21 @@ public:
* if Settings.CanViolateDRC() is on.
*/
bool FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem );
/**
* Function AddVia()
*
* Function ToggleVia()
*
* Enables/disables a via at the end of currently routed trace.
* @param aEnabled if true, a via is attached during placement
* @param aDiameter diameter of the via
* @param aDrill drill of the via
* @param aType Type of the via
*/
void AddVia( bool aEnabled, int aDiameter, int aDrill, VIATYPE_T aType );
void ToggleVia( bool aEnabled );
/**
* Function SetLayer()
*
* Sets the current routing layer.
*/
void SetLayer( int aLayer );
bool SetLayer( int aLayer );
/**
* Function SetWidth()
*
* Sets the current track width.
*/
void SetWidth( int aWidth );
/**
* Function Head()
@ -109,7 +103,7 @@ public:
* that has not "settled" yet.
*/
const PNS_LINE& Head() const { return m_head; }
/**
* Function Tail()
*
@ -137,7 +131,7 @@ public:
*
* Returns the current end of the line being placed. It may not be equal
* to the cursor position due to collisions.
*/
*/
const VECTOR2I& CurrentEnd() const
{
return m_currentEnd;
@ -147,8 +141,8 @@ public:
* Function CurrentNet()
*
* Returns the net code of currently routed track.
*/
int CurrentNet() const
*/
int CurrentNet() const
{
return m_currentNet;
}
@ -157,8 +151,8 @@ public:
* Function CurrentLayer()
*
* Returns the layer of currently routed track.
*/
int CurrentLayer() const
*/
int CurrentLayer() const
{
return m_currentLayer;
}
@ -169,14 +163,14 @@ public:
* Returns the most recent world state.
*/
PNS_NODE* CurrentNode( bool aLoopsRemoved = false ) const;
/**
* Function FlipPosture()
*
* Toggles the current posture (straight/diagonal) of the trace head.
*/
void FlipPosture();
/**
* Function UpdateSizes()
*
@ -184,8 +178,9 @@ public:
* a settings class. Used to dynamically change these parameters as
* the track is routed.
*/
void UpdateSizes( const PNS_ROUTING_SETTINGS& aSettings );
void UpdateSizes( const PNS_SIZES_SETTINGS& aSizes );
bool IsPlacingVia() const { return m_placingVia; }
private:
/**
* Function route()
@ -203,24 +198,24 @@ private:
* Function updateLeadingRatLine()
*
* Draws the "leading" ratsnest line, which connects the end of currently
* routed track and the nearest yet unrouted item. If the routing for
* routed track and the nearest yet unrouted item. If the routing for
* current net is complete, draws nothing.
*/
void updateLeadingRatLine();
/**
* Function setWorld()
*
* Sets the board to route.
*/
void setWorld( PNS_NODE* aWorld );
/**
* Function startPlacement()
*
* Initializes placement of a new line with given parameters.
*/
void startPlacement( const VECTOR2I& aStart, int aNet, int aWidth, int aLayer );
void initPlacement( bool aSplitSeg = false );
/**
* Function setInitialDirection()
@ -250,10 +245,10 @@ private:
* Function simplifyNewLine()
*
* Assembles a line starting from segment aLatest, removes collinear segments
* and redundant vertexes. If a simplification bhas been found, replaces the
* and redundant vertexes. If a simplification bhas been found, replaces the
* old line with the simplified one in aNode.
*/
void simplifyNewLine( PNS_NODE *aNode, PNS_SEGMENT *aLatest );
void simplifyNewLine( PNS_NODE* aNode, PNS_SEGMENT* aLatest );
/**
* Function handleViaPlacement()
@ -346,7 +341,9 @@ private:
///> route step, mark obstacles mode
bool rhMarkObstacles( const VECTOR2I& aP, PNS_LINE& aNewHead );
const PNS_VIA makeVia ( const VECTOR2I& aP );
///> current routing direction
DIRECTION_45 m_direction;
@ -378,6 +375,8 @@ private:
///> Postprocessed world state (including marked collisions & removed loops)
PNS_NODE* m_lastNode;
PNS_SIZES_SETTINGS m_sizes;
///> Are we placing a via?
bool m_placingVia;
@ -386,9 +385,6 @@ private:
///> current via drill
int m_viaDrill;
///> current via type
VIATYPE_T m_viaType;
///> current track width
int m_currentWidth;
@ -397,11 +393,16 @@ private:
int m_currentLayer;
bool m_startsOnVia;
VECTOR2I m_originalStart, m_currentEnd, m_currentStart;
VECTOR2I m_currentEnd, m_currentStart;
PNS_LINE m_currentTrace;
PNS_MODE m_currentMode;
PNS_ITEM* m_startItem;
bool m_idle;
bool m_chainedPlacement;
bool m_splitSeg;
};
#endif // __PNS_LINE_PLACER_H

View File

@ -121,7 +121,6 @@ PNS_ITEM* PNS_ROUTER::syncPad( D_PAD* aPad )
switch( aPad->GetAttribute() )
{
case PAD_STANDARD:
layers = PNS_LAYERSET( 0, MAX_CU_LAYERS - 1 ); // TODO necessary? it is already initialized
break;
case PAD_SMD:
@ -249,31 +248,6 @@ void PNS_ROUTER::SetBoard( BOARD* aBoard )
TRACE( 1, "m_board = %p\n", m_board );
}
int PNS_ROUTER::NextCopperLayer( bool aUp )
{
LSET mask = m_board->GetEnabledLayers() & m_board->GetVisibleLayers();
LAYER_NUM l = m_currentLayer;
do
{
l += ( aUp ? 1 : -1 );
if( l >= MAX_CU_LAYERS )
l = 0;
if( l < 0 )
l = MAX_CU_LAYERS - 1;
if( mask[l] )
return l;
}
while( l != m_currentLayer );
return l;
}
void PNS_ROUTER::SyncWorld()
{
if( !m_board )
@ -324,10 +298,6 @@ PNS_ROUTER::PNS_ROUTER()
m_clearanceFunc = NULL;
m_currentLayer = 1;
m_placingVia = false;
m_startsOnVia = false;
m_currentNet = -1;
m_state = IDLE;
m_world = NULL;
m_placer = NULL;
@ -483,51 +453,21 @@ bool PNS_ROUTER::StartDragging( const VECTOR2I& aP, PNS_ITEM* aStartItem )
return true;
}
bool PNS_ROUTER::StartRouting( const VECTOR2I& aP, PNS_ITEM* aStartItem )
bool PNS_ROUTER::StartRouting( const VECTOR2I& aP, PNS_ITEM* aStartItem, int aLayer )
{
m_state = ROUTE_TRACK;
m_placer = new PNS_LINE_PLACER( this );
m_placer->SetLayer( m_currentLayer );
const BOARD_DESIGN_SETTINGS& dsnSettings = m_board->GetDesignSettings();
if( dsnSettings.UseNetClassTrack() && aStartItem != NULL ) // netclass value
{
m_settings.SetTrackWidth( aStartItem->Parent()->GetNetClass()->GetTrackWidth() );
}
else
{
m_settings.SetTrackWidth( dsnSettings.GetCurrentTrackWidth() );
}
if( dsnSettings.UseNetClassVia() && aStartItem != NULL ) // netclass value
{
m_settings.SetViaDiameter( aStartItem->Parent()->GetNetClass()->GetViaDiameter() );
m_settings.SetViaDrill( aStartItem->Parent()->GetNetClass()->GetViaDrill() );
}
else
{
m_settings.SetViaDiameter( dsnSettings.GetCurrentViaSize() );
m_settings.SetViaDrill( dsnSettings.GetCurrentViaDrill() );
}
m_placer->UpdateSizes( m_settings );
m_placer->UpdateSizes ( m_sizes );
m_placer->SetLayer( aLayer );
m_placer->Start( aP, aStartItem );
m_currentEnd = aP;
m_currentEndItem = NULL;
m_state = ROUTE_TRACK;
return true;
}
const VECTOR2I PNS_ROUTER::CurrentEnd() const
{
return m_currentEnd;
}
void PNS_ROUTER::eraseView()
{
BOOST_FOREACH( BOARD_ITEM* item, m_hiddenItems )
@ -564,7 +504,7 @@ void PNS_ROUTER::DisplayItem( const PNS_ITEM* aItem, int aColor, int aClearance
void PNS_ROUTER::DisplayItems( const PNS_ITEMSET& aItems )
{
BOOST_FOREACH( const PNS_ITEM *item, aItems.CItems() )
BOOST_FOREACH( const PNS_ITEM* item, aItems.CItems() )
DisplayItem( item );
}
@ -664,7 +604,7 @@ void PNS_ROUTER::updateView( PNS_NODE* aNode, PNS_ITEMSET& aCurrent )
return;
if( Settings().Mode() == RM_MarkObstacles )
markViolations(aNode, aCurrent, removed);
markViolations( aNode, aCurrent, removed );
aNode->GetUpdatedItems( removed, added );
@ -689,13 +629,14 @@ void PNS_ROUTER::updateView( PNS_NODE* aNode, PNS_ITEMSET& aCurrent )
}
void PNS_ROUTER::ApplySettings()
void PNS_ROUTER::UpdateSizes ( const PNS_SIZES_SETTINGS& aSizes )
{
m_sizes = aSizes;
// Change track/via size settings
if( m_state == ROUTE_TRACK)
{
m_placer->UpdateSizes( m_settings );
m_placer->Move( m_currentEnd, m_currentEndItem );
m_placer->UpdateSizes( m_sizes );
movePlacing( m_currentEnd, m_currentEndItem );
}
}
@ -791,26 +732,6 @@ void PNS_ROUTER::CommitRouting( PNS_NODE* aNode )
}
PNS_VIA* PNS_ROUTER::checkLoneVia( PNS_JOINT* aJoint ) const
{
PNS_VIA* theVia = NULL;
PNS_LAYERSET l;
BOOST_FOREACH( PNS_ITEM* item, aJoint->LinkList() )
{
if( item->Kind() == PNS_ITEM::VIA )
theVia = static_cast<PNS_VIA*>( item );
l.Merge( item->Layers() );
}
if( l.Start() == l.End() )
return theVia;
return NULL;
}
bool PNS_ROUTER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
bool rv = false;
@ -819,8 +740,6 @@ bool PNS_ROUTER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
case ROUTE_TRACK:
rv = m_placer->FixRoute( aP, aEndItem );
m_startsOnVia = m_placingVia;
m_placingVia = false;
break;
case DRAG_SEGMENT:
@ -841,7 +760,17 @@ bool PNS_ROUTER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
void PNS_ROUTER::StopRouting()
{
// Update the ratsnest with new changes
m_board->GetRatsnest()->Recalculate( m_currentNet );
if( m_placer )
{
int n = m_placer->CurrentNet();
if( n >= 0)
{
// Update the ratsnest with new changes
m_board->GetRatsnest()->Recalculate( n );
}
}
if( !RoutingInProgress() )
return;
@ -868,7 +797,7 @@ void PNS_ROUTER::FlipPosture()
if( m_state == ROUTE_TRACK )
{
m_placer->FlipPosture();
m_placer->Move( m_currentEnd, m_currentEndItem );
movePlacing ( m_currentEnd, m_currentEndItem );
}
}
@ -877,77 +806,38 @@ void PNS_ROUTER::SwitchLayer( int aLayer )
{
switch( m_state )
{
case IDLE:
m_currentLayer = aLayer;
break;
case ROUTE_TRACK:
if( m_startsOnVia )
{
m_currentLayer = aLayer;
case ROUTE_TRACK:
m_placer->SetLayer( aLayer );
}
break;
default:
break;
break;
default:
break;
}
}
void PNS_ROUTER::ToggleViaPlacement(VIATYPE_T type)
void PNS_ROUTER::ToggleViaPlacement()
{
const int layercount = m_board->GetDesignSettings().GetCopperLayerCount();
// Cannot place microvias or blind vias if not allowed (obvious)
if( ( type == VIA_BLIND_BURIED ) && ( !m_board->GetDesignSettings().m_BlindBuriedViaAllowed ) )
return;
if( ( type == VIA_MICROVIA ) && ( !m_board->GetDesignSettings().m_MicroViasAllowed ) )
return;
//Can only place through vias on 2-layer boards
if( ( type != VIA_THROUGH ) && ( layercount <= 2 ) )
return;
//Can only place microvias if we're on an outer layer, or directly adjacent to one
if( ( type == VIA_MICROVIA ) && ( m_currentLayer > In1_Cu ) && ( m_currentLayer < layercount-2 ) )
return;
//Cannot place blind vias with front/back as the layer pair, this doesn't make sense
if( ( type == VIA_BLIND_BURIED ) && ( Settings().GetLayerTop() == F_Cu ) && ( Settings().GetLayerBottom() == B_Cu ) )
return;
if( m_state == ROUTE_TRACK )
if( m_state == ROUTE_TRACK )
{
m_placingVia = !m_placingVia;
m_placer->AddVia( m_placingVia, m_settings.GetViaDiameter(), m_settings.GetViaDrill(), type );
bool toggle = !m_placer->IsPlacingVia();
m_placer->ToggleVia( toggle );
}
}
int PNS_ROUTER::GetCurrentNet() const
{
switch( m_state )
{
case ROUTE_TRACK:
return m_placer->CurrentNet();
default:
return m_currentNet;
}
if( m_placer )
return m_placer->CurrentNet();
return -1;
}
int PNS_ROUTER::GetCurrentLayer() const
{
switch( m_state )
{
case ROUTE_TRACK:
return m_placer->CurrentLayer();
default:
return m_currentLayer;
}
if( m_placer )
return m_placer->CurrentLayer();
return -1;
}
@ -968,3 +858,11 @@ void PNS_ROUTER::DumpLog()
if( logger )
logger->Save( "/tmp/shove.log" );
}
bool PNS_ROUTER::IsPlacingVia() const
{
if(!m_placer)
return NULL;
return m_placer->IsPlacingVia();
}

View File

@ -30,6 +30,7 @@
#include <class_undoredo_container.h>
#include "pns_routing_settings.h"
#include "pns_sizes_settings.h"
#include "pns_item.h"
#include "pns_itemset.h"
#include "pns_node.h"
@ -86,13 +87,12 @@ public:
void SetView( KIGFX::VIEW* aView );
bool RoutingInProgress() const;
bool StartRouting( const VECTOR2I& aP, PNS_ITEM* aItem );
bool StartRouting( const VECTOR2I& aP, PNS_ITEM* aItem, int aLayer );
void Move( const VECTOR2I& aP, PNS_ITEM* aItem );
bool FixRoute( const VECTOR2I& aP, PNS_ITEM* aItem );
void StopRouting();
const VECTOR2I CurrentEnd() const;
int GetClearance( const PNS_ITEM* aA, const PNS_ITEM* aB ) const;
@ -112,7 +112,7 @@ public:
void SwitchLayer( int layer );
void ToggleViaPlacement( VIATYPE_T type = VIA_NOT_DEFINED );
void ToggleViaPlacement();
int GetCurrentLayer() const;
int GetCurrentNet() const;
@ -123,15 +123,7 @@ public:
{
return m_clearanceFunc;
}
bool IsPlacingVia() const
{
return m_placingVia;
}
int NextCopperLayer( bool aUp );
// typedef boost::optional<hoverItem> optHoverItem;
bool IsPlacingVia() const;
const PNS_ITEMSET QueryHoverItems( const VECTOR2I& aP );
const VECTOR2I SnapToItem( PNS_ITEM* aItem, VECTOR2I aP, bool& aSplitsSegment );
@ -175,7 +167,7 @@ public:
* Applies stored settings.
* @see Settings()
*/
void ApplySettings();
void UpdateSizes( const PNS_SIZES_SETTINGS& aSizes );
/**
* Changes routing settings to ones passed in the parameter.
@ -184,8 +176,6 @@ public:
void LoadSettings( const PNS_ROUTING_SETTINGS& aSettings )
{
m_settings = aSettings;
ApplySettings();
}
void EnableSnapping( bool aEnable )
@ -198,6 +188,11 @@ public:
return m_snappingEnabled;
}
PNS_SIZES_SETTINGS& Sizes()
{
return m_sizes;
}
private:
void movePlacing( const VECTOR2I& aP, PNS_ITEM* aItem );
void moveDragging( const VECTOR2I& aP, PNS_ITEM* aItem );
@ -211,7 +206,6 @@ private:
PNS_ITEM* pickSingleItem( PNS_ITEMSET& aItems ) const;
void splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, const VECTOR2I& aP );
PNS_VIA* checkLoneVia( PNS_JOINT* aJoint ) const;
PNS_ITEM* syncPad( D_PAD* aPad );
PNS_ITEM* syncTrack( TRACK* aTrack );
@ -223,11 +217,9 @@ private:
void highlightCurrent( bool enabled );
void markViolations( PNS_NODE* aNode, PNS_ITEMSET& aCurrent, PNS_NODE::ITEM_VECTOR& aRemoved );
int m_currentLayer;
int m_currentNet;
void markViolations( PNS_NODE* aNode, PNS_ITEMSET& aCurrent, PNS_NODE::ITEM_VECTOR& aRemoved );
VECTOR2I m_currentEnd;
RouterState m_state;
BOARD* m_board;
@ -235,9 +227,7 @@ private:
PNS_NODE* m_lastNode;
PNS_LINE_PLACER* m_placer;
PNS_DRAGGER* m_dragger;
PNS_LINE* m_draggedLine;
PNS_SHOVE* m_shove;
int m_draggedSegmentIndex;
int m_iterLimit;
bool m_showInterSteps;
int m_snapshotIter;
@ -247,11 +237,6 @@ private:
PNS_ITEM* m_currentEndItem;
VECTOR2I m_currentEnd;
VECTOR2I m_currentStart;
VECTOR2I m_originalStart;
bool m_placingVia;
bool m_startsOnVia;
bool m_snappingEnabled;
bool m_violation;
@ -264,6 +249,7 @@ private:
///> Stores list of modified items in the current operation
PICKED_ITEMS_LIST m_undoBuffer;
PNS_SIZES_SETTINGS m_sizes;
};
#endif

View File

@ -21,10 +21,12 @@
#ifndef __PNS_ROUTING_SETTINGS
#define __PNS_ROUTING_SETTINGS
#include <cstdio>
#include "time_limit.h"
class DIRECTION_45;
///> Routing modes
enum PNS_MODE
{
@ -35,9 +37,9 @@ enum PNS_MODE
};
///> Optimization effort
enum PNS_OPTIMIZATION_EFFORT
enum PNS_OPTIMIZATION_EFFORT
{
OE_LOW = 0,
OE_LOW = 0,
OE_MEDIUM = 1,
OE_FULL = 2
};
@ -58,44 +60,44 @@ public:
///> Sets the routing mode.
void SetMode( PNS_MODE aMode ) { m_routingMode = aMode; }
///> Returns the optimizer effort. Bigger means cleaner traces, but slower routing.
PNS_OPTIMIZATION_EFFORT OptimizerEffort() const { return m_optimizerEffort; }
///> Sets the optimizer effort. Bigger means cleaner traces, but slower routing.
void SetOptimizerEffort( PNS_OPTIMIZATION_EFFORT aEffort ) { m_optimizerEffort = aEffort; }
///> Returns true if shoving vias is enbled.
bool ShoveVias() const { return m_shoveVias; }
///> Enables/disables shoving vias.
void SetShoveVias( bool aShoveVias ) { m_shoveVias = aShoveVias; }
///> Returns true if loop (redundant track) removal is on.
bool RemoveLoops() const { return m_removeLoops; }
///> Enables/disables loop (redundant track) removal.
void SetRemoveLoops( bool aRemoveLoops ) { m_removeLoops = aRemoveLoops; }
///> Returns true if suggesting the finish of currently placed track is on.
bool SuggestFinish() { return m_suggestFinish; }
///> Enables displaying suggestions for finishing the currently placed track.
void SetSuggestFinish( bool aSuggestFinish ) { m_suggestFinish = aSuggestFinish; }
///> Returns true if Smart Pads (automatic neckdown) is enabled.
bool SmartPads () const { return m_smartPads; }
///> Enables/disables Smart Pads (automatic neckdown).
void SetSmartPads( bool aSmartPads ) { m_smartPads = aSmartPads; }
///> Returns true if follow mouse mode is active (permanently on for the moment).
bool FollowMouse() const
{
bool FollowMouse() const
{
return m_followMouse && !( Mode() == RM_MarkObstacles );
}
///> Returns true if smoothing segments durign dragging is enabled.
///> Returns true if smoothing segments durign dragging is enabled.
bool SmoothDraggedSegments() const { return m_smoothDraggedSegments; }
///> Enables/disabled smoothing segments during dragging.
@ -104,21 +106,14 @@ public:
///> Returns true if jumping over unmovable obstacles is on.
bool JumpOverObstacles() const { return m_jumpOverObstacles; }
///> Enables/disables jumping over unmovable obstacles.
///> Enables/disables jumping over unmovable obstacles.
void SetJumpOverObstacles( bool aJumpOverObstacles ) { m_jumpOverObstacles = aJumpOverObstacles; }
void SetStartDiagonal(bool aStartDiagonal) { m_startDiagonal = aStartDiagonal; }
void SetStartDiagonal( bool aStartDiagonal ) { m_startDiagonal = aStartDiagonal; }
bool CanViolateDRC() const { return m_canViolateDRC; }
void SetCanViolateDRC( bool aViolate ) { m_canViolateDRC = aViolate; }
void SetTrackWidth( int aWidth ) { m_trackWidth = aWidth; }
int GetTrackWidth() const { return m_trackWidth; }
void SetViaDiameter( int aDiameter ) { m_viaDiameter = aDiameter; }
int GetViaDiameter() const { return m_viaDiameter; }
void SetViaDrill( int aDrill ) { m_viaDrill = aDrill; }
int GetViaDrill() const { return m_viaDrill; }
const DIRECTION_45 InitialDirection() const;
int ShoveIterationLimit() const;
@ -127,22 +122,6 @@ public:
int WalkaroundIterationLimit() const { return m_walkaroundIterationLimit; };
TIME_LIMIT WalkaroundTimeLimit() const;
void SetLayerPair( int aLayer1, int aLayer2 )
{
if( aLayer1 < aLayer2 )
{
m_layerTop = aLayer1;
m_layerBottom = aLayer2;
}
else
{
m_layerBottom = aLayer1;
m_layerTop = aLayer2;
}
}
int GetLayerTop() const { return m_layerTop; }
int GetLayerBottom() const { return m_layerBottom; }
private:
bool m_shoveVias;
@ -157,20 +136,12 @@ private:
PNS_MODE m_routingMode;
PNS_OPTIMIZATION_EFFORT m_optimizerEffort;
int m_trackWidth;
int m_viaDiameter;
int m_viaDrill;
int m_preferredLayer;
int m_walkaroundIterationLimit;
int m_shoveIterationLimit;
TIME_LIMIT m_shoveTimeLimit;
TIME_LIMIT m_walkaroundTimeLimit;
// Routing layers pair
int m_layerTop;
int m_layerBottom;
};
#endif

View File

@ -41,7 +41,7 @@
#include <profile.h>
static void sanityCheck( PNS_LINE *aOld, PNS_LINE *aNew )
static void sanityCheck( PNS_LINE* aOld, PNS_LINE* aNew )
{
assert( aOld->CPoint( 0 ) == aNew->CPoint( 0 ) );
assert( aOld->CPoint( -1 ) == aNew->CPoint( -1 ) );
@ -58,26 +58,26 @@ PNS_SHOVE::PNS_SHOVE( PNS_NODE* aWorld, PNS_ROUTER* aRouter ) :
PNS_SHOVE::~PNS_SHOVE()
{
// free all the stuff we've created during routing/dragging operation.
BOOST_FOREACH( PNS_ITEM *item, m_gcItems )
BOOST_FOREACH( PNS_ITEM* item, m_gcItems )
delete item;
}
// garbage-collected line assembling
PNS_LINE* PNS_SHOVE::assembleLine( const PNS_SEGMENT *aSeg, int *aIndex )
PNS_LINE* PNS_SHOVE::assembleLine( const PNS_SEGMENT* aSeg, int* aIndex )
{
PNS_LINE* l = m_currentNode->AssembleLine( const_cast<PNS_SEGMENT*>( aSeg ), aIndex );
m_gcItems.push_back(l);
m_gcItems.push_back( l );
return l;
}
// garbage-collected line cloning
PNS_LINE *PNS_SHOVE::cloneLine ( const PNS_LINE *aLine )
PNS_LINE* PNS_SHOVE::cloneLine ( const PNS_LINE* aLine )
{
PNS_LINE *l = aLine->Clone();
PNS_LINE* l = aLine->Clone();
m_gcItems.push_back( l );
return l;
@ -88,7 +88,7 @@ PNS_LINE *PNS_SHOVE::cloneLine ( const PNS_LINE *aLine )
// visually "outwards" of the line/via applying pressure on it. Unfortunately there's no
// mathematical concept of orientation of an open curve, so we use some primitive heuristics:
// if the shoved line wraps around the start of the "pusher", it's likely shoved in wrong direction.
bool PNS_SHOVE::checkBumpDirection( PNS_LINE *aCurrent, PNS_LINE *aShoved ) const
bool PNS_SHOVE::checkBumpDirection( PNS_LINE* aCurrent, PNS_LINE* aShoved ) const
{
const SEG ss = aCurrent->CSegment( 0 );
@ -98,13 +98,13 @@ bool PNS_SHOVE::checkBumpDirection( PNS_LINE *aCurrent, PNS_LINE *aShoved ) cons
dist += aShoved->Width() / 2;
const VECTOR2I ps = ss.A - ( ss.B - ss.A ).Resize( dist );
return !aShoved->CLine().PointOnEdge( ps );
}
PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::walkaroundLoneVia( PNS_LINE* aCurrent, PNS_LINE* aObstacle,
PNS_LINE* aShoved )
PNS_LINE* aShoved )
{
int clearance = m_currentNode->GetClearance( aCurrent, aObstacle );
const SHAPE_LINE_CHAIN hull = aCurrent->Via().Hull( clearance, aObstacle->Width() );
@ -157,7 +157,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processHullSet( PNS_LINE* aCurrent, PNS_LINE*
path.Simplify();
l.SetShape( path );
}
for( int i = 0; i < std::min ( path.PointCount(), obs.PointCount() ); i++ )
{
if( path.CPoint( i ) != obs.CPoint( i ) )
@ -203,28 +203,28 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processHullSet( PNS_LINE* aCurrent, PNS_LINE*
TRACE( 100, "attempt %d fail self-intersect", attempt );
continue;
}
bool colliding = m_currentNode->CheckColliding( &l, aCurrent );
if( ( aCurrent->Marker() & MK_HEAD ) && !colliding )
{
PNS_JOINT* jtStart = m_currentNode->FindJoint( aCurrent->CPoint( 0 ), aCurrent );
BOOST_FOREACH( PNS_ITEM* item, jtStart->LinkList() )
{
if( m_currentNode->CheckColliding( item, &l ) )
colliding = true;
}
}
if( colliding )
{
TRACE( 100, "attempt %d fail coll-check", attempt );
continue;
}
aShoved->SetShape( l.CLine() );
aShoved->SetShape( l.CLine() );
return SH_OK;
}
@ -254,7 +254,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processSingleLine( PNS_LINE* aCurrent, PNS_LI
bool viaOnEnd = aCurrent->EndsWithVia();
if( viaOnEnd && ( !aCurrent->LayersOverlap( aObstacle ) || aCurrent->SegmentCount() == 0 ) )
if( viaOnEnd && ( !aCurrent->LayersOverlap( aObstacle ) || aCurrent->SegmentCount() == 0 ) )
{
rv = walkaroundLoneVia( aCurrent, aObstacle, aShoved );
}
@ -279,7 +279,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processSingleLine( PNS_LINE* aCurrent, PNS_LI
rv = processHullSet ( aCurrent, aObstacle, aShoved, hulls );
}
if( obstacleIsHead )
aShoved->Mark( aShoved->Marker() | MK_HEAD );
@ -292,16 +292,16 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSegment( PNS_LINE* aCurrent, PNS_S
int segIndex;
PNS_LINE* obstacleLine = assembleLine( aObstacleSeg, &segIndex );
PNS_LINE* shovedLine = cloneLine( obstacleLine );
SHOVE_STATUS rv = processSingleLine( aCurrent, obstacleLine, shovedLine );
assert ( obstacleLine->LayersOverlap( shovedLine ) );
if( rv == SH_OK )
{
if ( shovedLine->Marker() & MK_HEAD )
if( shovedLine->Marker() & MK_HEAD )
m_newHead = *shovedLine;
sanityCheck( obstacleLine, shovedLine );
m_currentNode->Replace( obstacleLine, shovedLine );
sanityCheck( obstacleLine, shovedLine );
@ -313,18 +313,18 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSegment( PNS_LINE* aCurrent, PNS_S
}
#ifdef DEBUG
m_logger.NewGroup ("on-colliding-segment", m_iter);
m_logger.Log ( aObstacleSeg, 0, "obstacle-segment");
m_logger.Log ( aCurrent, 1, "current-line");
m_logger.Log ( obstacleLine, 2, "obstacle-line");
m_logger.Log ( shovedLine, 3, "shoved-line");
m_logger.NewGroup( "on-colliding-segment", m_iter );
m_logger.Log( aObstacleSeg, 0, "obstacle-segment" );
m_logger.Log( aCurrent, 1, "current-line" );
m_logger.Log( obstacleLine, 2, "obstacle-line" );
m_logger.Log( shovedLine, 3, "shoved-line" );
#endif
return rv;
}
PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingLine( PNS_LINE *aCurrent, PNS_LINE *aObstacle )
PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingLine( PNS_LINE* aCurrent, PNS_LINE* aObstacle )
{
PNS_LINE* shovedLine = cloneLine( aObstacle );
@ -332,13 +332,13 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingLine( PNS_LINE *aCurrent, PNS_LINE
if( rv == SH_OK )
{
if ( shovedLine->Marker() & MK_HEAD )
if( shovedLine->Marker() & MK_HEAD )
m_newHead = *shovedLine;
sanityCheck( aObstacle, shovedLine );
m_currentNode->Replace( aObstacle, shovedLine );
sanityCheck( aObstacle, shovedLine );
int rank = aObstacle->Rank();
shovedLine->SetRank ( rank );
@ -360,12 +360,12 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL
{
PNS_WALKAROUND walkaround( m_currentNode, Router() );
PNS_LINE* walkaroundLine = cloneLine( aCurrent );
if( aCurrent->EndsWithVia() )
{
PNS_VIA vh = aCurrent->Via();
PNS_VIA vh = aCurrent->Via();
PNS_VIA* via = NULL;
PNS_JOINT* jtStart = m_currentNode->FindJoint ( vh.Pos(), aCurrent );
PNS_JOINT* jtStart = m_currentNode->FindJoint( vh.Pos(), aCurrent );
if( !jtStart )
return SH_INCOMPLETE;
@ -378,14 +378,14 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL
break;
}
}
if( via && m_currentNode->CheckColliding( via, aObstacleSolid ) )
return onCollidingVia( aObstacleSolid, via );
}
walkaround.SetSolidsOnly( true );
walkaround.SetIterationLimit ( 8 ); // fixme: make configurable
int currentRank = aCurrent->Rank();
int nextRank;
@ -399,7 +399,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL
nextRank = currentRank - 1;
walkaround.SetSingleDirection( true );
}
if( walkaround.Route( *aCurrent, *walkaroundLine, false ) != PNS_WALKAROUND::DONE )
return SH_INCOMPLETE;
@ -415,10 +415,10 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL
walkaroundLine->Mark( MK_HEAD );
m_newHead = *walkaroundLine;
}
m_currentNode->Replace( aCurrent, walkaroundLine );
walkaroundLine->SetRank ( nextRank );
walkaroundLine->SetRank( nextRank );
#ifdef DEBUG
m_logger.NewGroup( "on-colliding-solid", m_iter );
m_logger.Log( aObstacleSolid, 0, "obstacle-solid" );
@ -444,7 +444,7 @@ bool PNS_SHOVE::reduceSpringback( const PNS_ITEMSET& aHeadSet )
if( !spTag.m_node->CheckColliding( aHeadSet ) )
{
rv = true;
delete spTag.m_node;
m_nodeStack.pop_back();
}
@ -498,9 +498,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc
PNS_SEGMENT* seg = (PNS_SEGMENT*) item;
LINE_PAIR lp;
int segIndex;
lp.first = assembleLine( seg, &segIndex );
assert( segIndex == 0 || ( segIndex == ( lp.first->SegmentCount() - 1 ) ) );
if( segIndex == 0 )
@ -523,10 +523,10 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc
pushedVia->SetRank( aCurrentRank - 1 );
#ifdef DEBUG
m_logger.Log ( aVia, 0, "obstacle-via");
m_logger.Log ( pushedVia, 1, "pushed-via");
m_logger.Log( aVia, 0, "obstacle-via" );
m_logger.Log( pushedVia, 1, "pushed-via" );
#endif
BOOST_FOREACH( LINE_PAIR lp, draggedLines )
{
if( lp.first->Marker() & MK_HEAD )
@ -535,13 +535,13 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc
m_newHead = *lp.second;
}
unwindStack(lp.first);
unwindStack( lp.first );
if( lp.second->SegmentCount() )
{
m_currentNode->Replace( lp.first, lp.second );
lp.second->SetRank( aCurrentRank - 1 );
pushLine( lp.second );
pushLine( lp.second );
}
else
m_currentNode->Remove( lp.first );
@ -556,12 +556,12 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc
}
PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia (PNS_ITEM* aCurrent, PNS_VIA* aObstacleVia )
PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia( PNS_ITEM* aCurrent, PNS_VIA* aObstacleVia )
{
int clearance = m_currentNode->GetClearance( aCurrent, aObstacleVia ) ;
LINE_PAIR_VEC draggedLines;
bool colLine = false, colVia = false;
PNS_LINE *currentLine = NULL;
PNS_LINE* currentLine = NULL;
VECTOR2I mtvLine, mtvVia, mtv, mtvSolid;
int rank = -1;
@ -573,12 +573,12 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia (PNS_ITEM* aCurrent, PNS_VIA*
#endif
currentLine = (PNS_LINE*) aCurrent;
colLine = CollideShapes( aObstacleVia->Shape(), currentLine->Shape(),
clearance + currentLine->Width() / 2 + PNS_HULL_MARGIN,
colLine = CollideShapes( aObstacleVia->Shape(), currentLine->Shape(),
clearance + currentLine->Width() / 2 + PNS_HULL_MARGIN,
true, mtvLine );
if( currentLine->EndsWithVia() )
colVia = CollideShapes( currentLine->Via().Shape(), aObstacleVia->Shape(),
colVia = CollideShapes( currentLine->Via().Shape(), aObstacleVia->Shape(),
clearance + PNS_HULL_MARGIN, true, mtvVia );
if( !colLine && !colVia )
@ -590,18 +590,18 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia (PNS_ITEM* aCurrent, PNS_VIA*
mtv = mtvLine;
else
mtv = mtvVia;
rank = currentLine->Rank();
}
else if (aCurrent->OfKind(PNS_ITEM::SOLID))
else if( aCurrent->OfKind( PNS_ITEM::SOLID ) )
{
CollideShapes( aObstacleVia->Shape(), aCurrent->Shape(),
CollideShapes( aObstacleVia->Shape(), aCurrent->Shape(),
clearance + PNS_HULL_MARGIN, true, mtvSolid );
mtv = mtvSolid;
mtv = -mtvSolid;
rank = aCurrent->Rank() + 10000;
}
return pushVia( aObstacleVia, mtv, rank );
return pushVia( aObstacleVia, mtv, rank );
}
@ -617,19 +617,19 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN
shoved->ClearSegmentLinks();
cur->RemoveVia();
unwindStack(aCurrent);
unwindStack( aCurrent );
BOOST_FOREACH( PNS_ITEM* item, jt->LinkList() )
{
if( item->OfKind( PNS_ITEM::SEGMENT ) && item->LayersOverlap( aCurrent ) )
if( item->OfKind( PNS_ITEM::SEGMENT ) && item->LayersOverlap( aCurrent ) )
{
PNS_SEGMENT* seg = (PNS_SEGMENT*) item;
PNS_LINE* head = assembleLine( seg );
head->AppendVia( *aObstacleVia );
SHOVE_STATUS st = processSingleLine ( head, cur, shoved );
SHOVE_STATUS st = processSingleLine( head, cur, shoved );
if( st != SH_OK )
{
#ifdef DEBUG
@ -641,7 +641,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN
return st;
}
cur->SetShape( shoved->CLine() );
n++;
}
@ -654,7 +654,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN
m_logger.Log( aObstacleVia, 0, "the-via" );
m_logger.Log( aCurrent, 1, "current-line" );
#endif
PNS_LINE head( *aCurrent );
head.Line().Clear();
head.AppendVia( *aObstacleVia );
@ -665,7 +665,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN
if( st != SH_OK )
return st;
cur->SetShape ( shoved->CLine() );
cur->SetShape( shoved->CLine() );
}
if( aCurrent->EndsWithVia() )
@ -678,12 +678,12 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN
m_logger.Log( shoved, 3, "shoved-line" );
#endif
int currentRank = aCurrent->Rank();
m_currentNode->Replace ( aCurrent, shoved );
m_currentNode->Replace( aCurrent, shoved );
pushLine( shoved );
shoved->SetRank( currentRank );
return SH_OK;
return SH_OK;
}
@ -691,7 +691,7 @@ void PNS_SHOVE::unwindStack( PNS_SEGMENT *aSeg )
{
for( std::vector<PNS_LINE*>::iterator i = m_lineStack.begin(); i != m_lineStack.end(); )
{
if( (*i)->ContainsSegment ( aSeg ) )
if( (*i)->ContainsSegment( aSeg ) )
i = m_lineStack.erase( i );
else
i++;
@ -703,7 +703,7 @@ void PNS_SHOVE::unwindStack( PNS_SEGMENT *aSeg )
i = m_optimizerQueue.erase( i );
else
i++;
}
}
}
@ -715,20 +715,20 @@ void PNS_SHOVE::unwindStack( PNS_ITEM* aItem )
{
PNS_LINE* l = static_cast<PNS_LINE*>( aItem );
if ( !l->LinkedSegments() )
if( !l->LinkedSegments() )
return;
BOOST_FOREACH( PNS_SEGMENT* seg, *l->LinkedSegments() )
unwindStack( seg );
}
}
void PNS_SHOVE::pushLine( PNS_LINE* aL )
{
if( aL->LinkCount() >= 0 && ( aL->LinkCount() != aL->SegmentCount() ) )
assert( false );
m_lineStack.push_back( aL );
m_optimizerQueue.push_back( aL );
}
@ -756,18 +756,18 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
{
PNS_LINE* currentLine = m_lineStack.back();
PNS_NODE::OPT_OBSTACLE nearest;
SHOVE_STATUS st;
SHOVE_STATUS st = SH_NULL;
PNS_ITEM::PnsKind search_order[] = { PNS_ITEM::SOLID, PNS_ITEM::VIA, PNS_ITEM::SEGMENT };
for( int i = 0; i < 3; i++ )
{
nearest = m_currentNode->NearestObstacle( currentLine, search_order[i] );
if( nearest )
break;
}
}
if( !nearest )
{
m_lineStack.pop_back();
@ -786,7 +786,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
{
PNS_VIA* revVia = (PNS_VIA*) ni;
TRACE( 2, "iter %d: reverse-collide-via", aIter );
if( currentLine->EndsWithVia() && m_currentNode->CheckColliding( &currentLine->Via(), revVia ) )
{
st = SH_INCOMPLETE;
@ -798,7 +798,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
break;
}
case PNS_ITEM::SEGMENT:
{
PNS_SEGMENT* seg = (PNS_SEGMENT*) ni;
@ -819,23 +819,23 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
{ // "forward" collisoins
switch( ni->Kind() )
{
case PNS_ITEM::SEGMENT:
TRACE( 2, "iter %d: collide-segment ", aIter );
st = onCollidingSegment( currentLine, (PNS_SEGMENT*) ni );
break;
case PNS_ITEM::SEGMENT:
TRACE( 2, "iter %d: collide-segment ", aIter );
st = onCollidingSegment( currentLine, (PNS_SEGMENT*) ni );
break;
case PNS_ITEM::VIA:
TRACE( 2, "iter %d: shove-via ", aIter );
st = onCollidingVia( currentLine, (PNS_VIA*) ni );
break;
case PNS_ITEM::VIA:
TRACE( 2, "iter %d: shove-via ", aIter );
st = onCollidingVia( currentLine, (PNS_VIA*) ni );
break;
case PNS_ITEM::SOLID:
TRACE( 2, "iter %d: walk-solid ", aIter );
st = onCollidingSolid( currentLine, (PNS_SOLID*) ni );
break;
default:
break;
case PNS_ITEM::SOLID:
TRACE( 2, "iter %d: walk-solid ", aIter );
st = onCollidingSolid( currentLine, (PNS_SOLID*) ni );
break;
default:
break;
}
}
@ -863,7 +863,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveMainLoop()
m_iter++;
if( st == SH_INCOMPLETE || timeLimit.Expired() || m_iter >= iterLimit )
if( st == SH_INCOMPLETE || timeLimit.Expired() || m_iter >= iterLimit )
{
st = SH_INCOMPLETE;
break;
@ -884,7 +884,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead )
PNS_LINE* head = cloneLine( &aCurrentHead );
head->ClearSegmentLinks();
m_lineStack.clear();
m_optimizerQueue.clear();
m_newHead = OPT_LINE();
@ -899,7 +899,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead )
m_currentNode = parent->Branch();
m_currentNode->ClearRanks();
m_currentNode->Add( head );
head->Mark( MK_HEAD );
head->SetRank( 100000 );
@ -921,11 +921,11 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead )
st = shoveMainLoop();
runOptimizer( m_currentNode, head );
if( m_newHead && st == SH_OK )
if( m_newHead && st == SH_OK )
{
st = SH_HEAD_MODIFIED;
Router()->DisplayDebugLine( m_newHead->CLine(), 3, 20000 );
}
//Router()->DisplayDebugLine( m_newHead->CLine(), 3, 20000 );
}
m_currentNode->RemoveByMarker( MK_HEAD );
@ -939,9 +939,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead )
else
{
delete m_currentNode;
m_currentNode = parent;
m_newHead = OPT_LINE();
m_newHead = OPT_LINE();
}
return st;
@ -952,7 +952,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveDraggingVia( PNS_VIA* aVia, const VECTOR
PNS_VIA** aNewVia )
{
SHOVE_STATUS st = SH_OK;
m_lineStack.clear();
m_optimizerQueue.clear();
m_newHead = OPT_LINE();
@ -996,25 +996,25 @@ void PNS_SHOVE::runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead )
switch( effort )
{
case OE_LOW:
optFlags = PNS_OPTIMIZER::MERGE_OBTUSE;
n_passes = 1;
extend = 0;
break;
case OE_LOW:
optFlags = PNS_OPTIMIZER::MERGE_OBTUSE;
n_passes = 1;
extend = 0;
break;
case OE_MEDIUM:
optFlags = PNS_OPTIMIZER::MERGE_OBTUSE;
n_passes = 2;
extend = 1;
break;
case OE_MEDIUM:
optFlags = PNS_OPTIMIZER::MERGE_OBTUSE;
n_passes = 2;
extend = 1;
break;
case OE_FULL:
optFlags = PNS_OPTIMIZER::MERGE_SEGMENTS;
n_passes = 2;
break;
case OE_FULL:
optFlags = PNS_OPTIMIZER::MERGE_SEGMENTS;
n_passes = 2;
break;
default:
break;
default:
break;
}
if( Settings().SmartPads() )
@ -1028,10 +1028,10 @@ void PNS_SHOVE::runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead )
std::reverse( m_optimizerQueue.begin(), m_optimizerQueue.end() );
for( std::vector<PNS_LINE*>::iterator i = m_optimizerQueue.begin();
i != m_optimizerQueue.end(); ++i)
i != m_optimizerQueue.end(); ++i )
{
PNS_LINE* line = *i;
if( !( line -> Marker() & MK_HEAD ) )
{
if( effort == OE_MEDIUM || effort == OE_LOW )
@ -1057,12 +1057,10 @@ void PNS_SHOVE::runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead )
}
}
}
}
const RANGE<int> PNS_SHOVE::findShovedVertexRange( PNS_LINE *aL )
const RANGE<int> PNS_SHOVE::findShovedVertexRange( PNS_LINE* aL )
{
RANGE<int> r;
@ -1116,8 +1114,9 @@ const PNS_LINE PNS_SHOVE::NewHead() const
return *m_newHead;
}
void PNS_SHOVE::SetInitialLine( PNS_LINE* aInitial )
{
m_root = m_root->Branch();
m_root->Remove ( aInitial );
m_root->Remove( aInitial );
}

View File

@ -37,7 +37,7 @@ class PNS_ROUTER;
/**
* Class PNS_SHOVE
*
* The actual Push and Shove algorithm.
* The actual Push and Shove algorithm.
*/
class PNS_SHOVE : public PNS_ALGO_BASE
@ -88,11 +88,11 @@ private:
SHOVE_STATUS processSingleLine( PNS_LINE* aCurrent, PNS_LINE* aObstacle, PNS_LINE* aShoved );
SHOVE_STATUS processHullSet( PNS_LINE* aCurrent, PNS_LINE* aObstacle,
PNS_LINE* aShoved, const HULL_SET& hulls );
bool reduceSpringback( const PNS_ITEMSET& aHeadItems );
bool pushSpringback( PNS_NODE* aNode, const PNS_ITEMSET &aHeadItems,
const PNS_COST_ESTIMATOR& aCost );
SHOVE_STATUS walkaroundLoneVia( PNS_LINE* aCurrent, PNS_LINE* aObstacle, PNS_LINE* aShoved );
bool checkBumpDirection( PNS_LINE* aCurrent, PNS_LINE* aShoved ) const;
@ -104,20 +104,20 @@ private:
SHOVE_STATUS pushVia( PNS_VIA* aVia, const VECTOR2I& aForce, int aCurrentRank );
void unwindStack( PNS_SEGMENT* aSeg );
void unwindStack( PNS_ITEM *aItem );
void unwindStack( PNS_ITEM* aItem );
void runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead );
void pushLine( PNS_LINE *aL );
void popLine();
void pushLine( PNS_LINE* aL );
void popLine();
const RANGE<int> findShovedVertexRange( PNS_LINE *aL );
const RANGE<int> findShovedVertexRange( PNS_LINE* aL );
PNS_LINE* assembleLine( const PNS_SEGMENT* aSeg, int* aIndex = NULL );
PNS_LINE* cloneLine( const PNS_LINE* aLine );
SHOVE_STATUS shoveIteration( int aIter );
SHOVE_STATUS shoveMainLoop();
SHOVE_STATUS shoveMainLoop();
std::vector<SPRINGBACK_TAG> m_nodeStack;
std::vector<PNS_LINE*> m_lineStack;
@ -126,7 +126,7 @@ private:
PNS_NODE* m_root;
PNS_NODE* m_currentNode;
OPT_LINE m_newHead;
PNS_LOGGER m_logger;

View File

@ -0,0 +1,159 @@
/*
* KiRouter - a push-and-(sometimes-)shove PCB router
*
* Copyright (C) 2014 CERN
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <class_board.h>
#include "pns_item.h"
#include "pns_via.h"
#include "pns_solid.h"
#include "pns_node.h"
#include "pns_sizes_settings.h"
int PNS_SIZES_SETTINGS::inheritTrackWidth( PNS_ITEM* aItem )
{
VECTOR2I p;
assert( aItem->Owner() != NULL );
switch( aItem->Kind() )
{
case PNS_ITEM::VIA:
p = static_cast<PNS_VIA*>( aItem )->Pos();
break;
case PNS_ITEM::SOLID:
p = static_cast<PNS_SOLID*>( aItem )->Pos();
break;
case PNS_ITEM::SEGMENT:
return static_cast<PNS_SEGMENT*>( aItem )->Width();
default:
return 0;
}
PNS_JOINT* jt = aItem->Owner()->FindJoint( p, aItem );
assert( jt != NULL );
int mval = INT_MAX;
PNS_ITEMSET linkedSegs = jt->Links().ExcludeItem( aItem ).FilterKinds( PNS_ITEM::SEGMENT );
BOOST_FOREACH( PNS_ITEM* item, linkedSegs.Items() )
{
int w = static_cast<PNS_SEGMENT*>( item )->Width();
mval = std::min( w, mval );
}
return ( mval == INT_MAX ? 0 : mval );
}
void PNS_SIZES_SETTINGS::Init( BOARD* aBoard, PNS_ITEM* aStartItem, int aNet )
{
BOARD_DESIGN_SETTINGS &bds = aBoard->GetDesignSettings();
NETCLASSPTR netClass;
int net = aNet;
if( aStartItem )
net = aStartItem->Net();
if( net >= 0 )
{
NETINFO_ITEM* ni = aBoard->FindNet( net );
if( ni )
{
wxString netClassName = ni->GetClassName();
netClass = bds.m_NetClasses.Find( netClassName );
}
}
if( !netClass )
netClass = bds.GetDefault();
m_trackWidth = 0;
if( bds.m_UseConnectedTrackWidth && aStartItem != NULL )
{
m_trackWidth = inheritTrackWidth( aStartItem );
}
if( !m_trackWidth && ( bds.UseNetClassTrack() && netClass != NULL ) ) // netclass value
{
m_trackWidth = netClass->GetTrackWidth();
}
if( !m_trackWidth )
{
m_trackWidth = bds.GetCurrentTrackWidth();
}
if( bds.UseNetClassVia() && netClass != NULL ) // netclass value
{
m_viaDiameter = netClass->GetViaDiameter();
m_viaDrill = netClass->GetViaDrill();
}
else
{
m_viaDiameter = bds.GetCurrentViaSize();
m_viaDrill = bds.GetCurrentViaDrill();
}
m_layerPairs.clear();
}
void PNS_SIZES_SETTINGS::ClearLayerPairs()
{
m_layerPairs.clear();
}
void PNS_SIZES_SETTINGS::AddLayerPair( int aL1, int aL2 )
{
int top = std::min( aL1, aL2 );
int bottom = std::max( aL1, aL2 );
m_layerPairs[bottom] = top;
m_layerPairs[top] = bottom;
}
void PNS_SIZES_SETTINGS::ImportCurrent( BOARD_DESIGN_SETTINGS& aSettings )
{
m_trackWidth = aSettings.GetCurrentTrackWidth();
m_viaDiameter = aSettings.GetCurrentViaSize();
m_viaDrill = aSettings.GetCurrentViaDrill();
}
int PNS_SIZES_SETTINGS::GetLayerTop() const
{
if( m_layerPairs.empty() )
return F_Cu;
else
return m_layerPairs.begin()->first;
}
int PNS_SIZES_SETTINGS::GetLayerBottom() const
{
if( m_layerPairs.empty() )
return B_Cu;
else
return m_layerPairs.begin()->second;
}

View File

@ -0,0 +1,95 @@
/*
* KiRouter - a push-and-(sometimes-)shove PCB router
*
* Copyright (C) 2014 CERN
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __PNS_SIZES_SETTINGS_H
#define __PNS_SIZES_SETTINGS_H
#include <map>
#include <boost/optional.hpp>
#include "../class_track.h" // for VIATYPE_T
class BOARD;
class BOARD_DESIGN_SETTINGS;
class PNS_ITEM;
class PNS_SIZES_SETTINGS {
public:
PNS_SIZES_SETTINGS() :
m_trackWidth( 100000 ),
m_diffPairWidth( 100000 ),
m_diffPairGap( 125000 ),
m_viaDiameter( 500000 ),
m_viaDrill( 200000 ),
m_viaType( VIA_THROUGH )
{};
~PNS_SIZES_SETTINGS() {};
void Init( BOARD* aBoard, PNS_ITEM* aStartItem = NULL, int aNet = -1 );
void ImportCurrent ( BOARD_DESIGN_SETTINGS& aSettings );
void ClearLayerPairs();
void AddLayerPair( int aL1, int aL2 );
int TrackWidth() const { return m_trackWidth; }
void SetTrackWidth( int aWidth ) { m_trackWidth = aWidth; }
int DiffPairWidth() const { return m_diffPairWidth; }
int DiffPairGap() const { return m_diffPairGap; }
int ViaDiameter() const { return m_viaDiameter; }
void SetViaDiameter( int aDiameter) { m_viaDiameter = aDiameter; }
int ViaDrill() const { return m_viaDrill; }
void SetViaDrill( int aDrill ) { m_viaDrill = aDrill; }
boost::optional<int> PairedLayer ( int aLayerId )
{
if( m_layerPairs.find(aLayerId) == m_layerPairs.end() )
return boost::optional<int>();
return m_layerPairs [ aLayerId ];
}
int GetLayerTop() const;
int GetLayerBottom() const;
void SetViaType( VIATYPE_T aViaType ) { m_viaType = aViaType; }
VIATYPE_T ViaType() const { return m_viaType; }
private:
int inheritTrackWidth( PNS_ITEM* aItem );
int m_trackWidth;
int m_diffPairWidth;
int m_diffPairGap;
int m_viaDiameter;
int m_viaDrill;
VIATYPE_T m_viaType;
std::map<int, int> m_layerPairs;
};
#endif // __PNS_SIZES_SETTINGS_H

View File

@ -48,12 +48,12 @@ public:
m_drill = aDrill;
m_shape = SHAPE_CIRCLE( aPos, aDiameter / 2 );
m_viaType = aViaType;
//If we're a through-board via, use all layers regardless of the set passed
if( aViaType == VIA_THROUGH )
{
PNS_LAYERSET allLayers( 0, MAX_CU_LAYERS - 1 );
SetLayers( allLayers);
SetLayers( allLayers );
}
}

View File

@ -57,7 +57,7 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::singleStep( PNS_LINE& aPath,
VECTOR2I last = aPath.CPoint( -1 );
if( ( current_obs->m_hull ).PointInside( last ) )
if( ( current_obs->m_hull ).PointInside( last ) || ( current_obs->m_hull ).PointOnEdge( last ) )
{
m_recursiveBlockageCount++;
@ -83,10 +83,10 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::singleStep( PNS_LINE& aPath,
m_logger.Log( &current_obs->m_hull, 2, "hull" );
m_logger.Log( current_obs->m_item, 3, "item" );
#endif
int len_pre = path_walk[0].Length();
int len_alt = path_walk[1].Length();
PNS_LINE walk_path( aPath, path_walk[1] );
bool alt_collides = m_world->CheckColliding( &walk_path, m_itemMask );
@ -99,7 +99,10 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::singleStep( PNS_LINE& aPath,
pnew.Append( path_walk[1] );
pnew.Append( path_post[1] );
current_obs = nearestObstacle( PNS_LINE( aPath, path_post[1] ) );
if(!path_post[1].PointCount() || !path_walk[1].PointCount())
current_obs = nearestObstacle( PNS_LINE( aPath, path_pre[1] ) );
else
current_obs = nearestObstacle( PNS_LINE( aPath, path_post[1] ) );
prev_recursive = false;
}
else
@ -108,7 +111,10 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::singleStep( PNS_LINE& aPath,
pnew.Append( path_walk[0] );
pnew.Append( path_post[0] );
current_obs = nearestObstacle( PNS_LINE( aPath, path_walk[0] ) );
if(!path_post[0].PointCount() || !path_walk[0].PointCount())
current_obs = nearestObstacle( PNS_LINE( aPath, path_pre[0] ) );
else
current_obs = nearestObstacle( PNS_LINE( aPath, path_walk[0] ) );
if( !current_obs )
{
@ -152,7 +158,7 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::Route( const PNS_LINE& aInitia
{
int len_cw = path_cw.CLine().Length();
int len_ccw = path_ccw.CLine().Length();
if( m_forceLongerPath )
aWalkPath = (len_cw > len_ccw ? path_cw : path_ccw);
else
@ -173,7 +179,7 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::Route( const PNS_LINE& aInitia
m_iteration++;
}
if( m_iteration == m_iterationLimit )
{
int len_cw = path_cw.CLine().Length();
@ -229,7 +235,7 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::Route( const PNS_LINE& aInitia
if( aWalkPath.CPoint( 0 ) != aInitialPath.CPoint( 0 ) )
return STUCK;
WALKAROUND_STATUS st = s_ccw == DONE || s_cw == DONE ? DONE : STUCK;
if( aOptimize && st == DONE )

View File

@ -34,7 +34,7 @@ class PNS_WALKAROUND : public PNS_ALGO_BASE
public:
PNS_WALKAROUND( PNS_NODE* aWorld, PNS_ROUTER* aRouter ) :
PNS_ALGO_BASE ( aRouter ),
m_world( aWorld ),
m_world( aWorld ),
m_iterationLimit( DefaultIterationLimit )
{
m_forceSingleDirection = false;

View File

@ -38,7 +38,7 @@ ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS_ITEM* aItem, VIEW_GROUP* aPa
EDA_ITEM( NOT_USED )
{
m_parent = aParent;
m_shape = NULL;
m_clearance = -1;
m_originLayer = m_layer = ITEM_GAL_LAYER( GP_OVERLAY );
@ -64,7 +64,7 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS_ITEM* aItem )
m_color.a = 0.8;
m_depth = BaseOverlayDepth - aItem->Layers().Start();
m_shape = aItem->Shape()->Clone();
switch( aItem->Kind() )
{
case PNS_ITEM::LINE:
@ -81,6 +81,7 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS_ITEM* aItem )
}
case PNS_ITEM::VIA:
m_originLayer = m_layer = ITEM_GAL_LAYER( VIAS_VISIBLE );
m_type = PR_SHAPE;
m_width = 0;
m_color = COLOR4D( 0.7, 0.7, 0.7, 0.8 );
@ -98,7 +99,7 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS_ITEM* aItem )
if( aItem->Marker() & MK_VIOLATION )
m_color = COLOR4D( 0, 1, 0, 1 );
if( aItem->Marker() & MK_HEAD )
m_color.Brighten( 0.7 );
@ -177,7 +178,7 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
aGal->SetLineWidth( m_width + 2 * m_clearance );
aGal->DrawLine( s->GetSeg().A, s->GetSeg().B );
}
break;
}
@ -193,7 +194,7 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
aGal->SetIsStroke( false );
aGal->DrawCircle( c->GetCenter(), c->GetRadius() + m_clearance );
}
break;
}
@ -224,7 +225,7 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
void ROUTER_PREVIEW_ITEM::Line( const SHAPE_LINE_CHAIN& aLine, int aWidth, int aStyle )
{
m_originLayer = m_layer = 0;
m_originLayer = m_layer = 0;
m_width = aWidth;
m_color = assignColor( aStyle );
m_type = PR_SHAPE;

View File

@ -32,6 +32,7 @@
#include <macros.h>
#include <pcbnew_id.h>
#include <view/view_controls.h>
#include <pcbcommon.h>
#include <pcb_painter.h>
#include <dialogs/dialog_pns_settings.h>
#include <dialogs/dialog_track_via_size.h>
@ -303,7 +304,7 @@ PNS_ITEM* ROUTER_TOOL::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLa
PNS_ITEM* prioritized[4];
for(int i = 0; i < 4; i++)
for( int i = 0; i < 4; i++ )
prioritized[i] = 0;
PNS_ITEMSET candidates = m_router->QueryHoverItems( aWhere );
@ -377,6 +378,9 @@ void ROUTER_TOOL::highlightNet( bool aEnabled, int aNetcode )
void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent )
{
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME> ();
BOARD* board = getModel<BOARD> ();
#ifdef DEBUG
if( aEvent.IsKeyPressed() )
{
@ -392,36 +396,32 @@ void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent )
#endif
if( aEvent.IsAction( &ACT_RouterOptions ) )
{
DIALOG_PNS_SETTINGS settingsDlg( getEditFrame<PCB_EDIT_FRAME>(), m_router->Settings() );
DIALOG_PNS_SETTINGS settingsDlg( frame, m_router->Settings() );
if( settingsDlg.ShowModal() )
m_router->ApplySettings();
{
// FIXME: do we need an explicit update?
}
}
else if( aEvent.IsAction( &ACT_CustomTrackWidth ) )
{
DIALOG_TRACK_VIA_SIZE sizeDlg( getEditFrame<PCB_EDIT_FRAME>(), m_router->Settings() );
BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
DIALOG_TRACK_VIA_SIZE sizeDlg( frame, bds );
sizeDlg.ShowModal();
// TODO it should be changed, router settings won't keep track & via sizes in the future
bds.SetCustomTrackWidth( m_router->Settings().GetTrackWidth() );
bds.SetCustomViaSize( m_router->Settings().GetViaDiameter() );
bds.SetCustomViaDrill( m_router->Settings().GetViaDrill() );
bds.UseCustomTrackViaSize( true );
m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged );
if( sizeDlg.ShowModal() )
{
bds.UseCustomTrackViaSize( true );
m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged );
}
}
else if( aEvent.IsAction( &COMMON_ACTIONS::trackViaSizeChanged ) )
{
BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings();
m_router->Settings().SetTrackWidth( bds.GetCurrentTrackWidth() );
m_router->Settings().SetViaDiameter( bds.GetCurrentViaSize() );
m_router->Settings().SetViaDrill( bds.GetCurrentViaDrill() );
m_router->ApplySettings();
PNS_SIZES_SETTINGS sizes;
sizes.ImportCurrent ( board->GetDesignSettings() );
m_router->UpdateSizes ( sizes );
}
}
@ -437,7 +437,7 @@ void ROUTER_TOOL::updateStartItem( TOOL_EVENT& aEvent )
{
VECTOR2I p = aEvent.Position();
startItem = pickSingleItem( p );
bool snapEnabled = !aEvent.Modifier(MD_SHIFT);
bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
m_router->EnableSnapping ( snapEnabled );
if( !snapEnabled && startItem && !startItem->Layers().Overlaps( tl ) )
@ -459,10 +459,10 @@ void ROUTER_TOOL::updateStartItem( TOOL_EVENT& aEvent )
ctls->ForceCursorPosition( false );
}
if( startItem->Layers().IsMultilayer() )
m_startLayer = tl;
else
m_startLayer = startItem->Layers().Start();
// if( startItem->Layers().IsMultilayer() )
// m_startLayer = tl;
// else
// m_startLayer = startItem->Layers().Start();
m_startItem = startItem;
}
@ -470,7 +470,6 @@ void ROUTER_TOOL::updateStartItem( TOOL_EVENT& aEvent )
{
m_startItem = NULL;
m_startSnapPoint = cp;
m_startLayer = tl;
ctls->ForceCursorPosition( false );
}
}
@ -521,25 +520,99 @@ void ROUTER_TOOL::updateEndItem( TOOL_EVENT& aEvent )
TRACE( 0, "%s, layer : %d", m_endItem->KindStr().c_str() % m_endItem->Layers().Start() );
}
int ROUTER_TOOL::getStartLayer( const PNS_ITEM* aItem )
{
int tl = getView()->GetTopLayer();
if( m_startItem )
{
const PNS_LAYERSET& ls = m_startItem->Layers();
if( ls.Overlaps( tl ) )
return tl;
else
return ls.Start();
}
return tl;
}
void ROUTER_TOOL::switchLayerOnViaPlacement()
{
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
int al = frame->GetActiveLayer();
int cl = m_router->GetCurrentLayer();
if( cl != al )
{
m_router->SwitchLayer( al );
}
optional<int> newLayer = m_router->Sizes().PairedLayer( cl );
if( newLayer )
{
m_router->SwitchLayer ( *newLayer );
frame->SetActiveLayer ( ToLAYER_ID( *newLayer ) );
}
}
bool ROUTER_TOOL::onViaCommand( VIATYPE_T aType )
{
BOARD* board = getModel<BOARD> ();
BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
const int layerCount = bds.GetCopperLayerCount();
int currentLayer = m_router->GetCurrentLayer();
PNS_SIZES_SETTINGS sizes = m_router->Sizes();
sizes.ClearLayerPairs();
sizes.AddLayerPair( frame->GetScreen()->m_Route_Layer_TOP,
frame->GetScreen()->m_Route_Layer_BOTTOM );
if( !m_router->IsPlacingVia() )
{
// Cannot place microvias or blind vias if not allowed (obvious)
if( ( aType == VIA_BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
return false;
if( ( aType == VIA_MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
return false;
//Can only place through vias on 2-layer boards
if( ( aType != VIA_THROUGH ) && ( layerCount <= 2 ) )
return false;
//Can only place microvias if we're on an outer layer, or directly adjacent to one
if( ( aType == VIA_MICROVIA ) && ( currentLayer > In1_Cu ) && ( currentLayer < layerCount-2 ) )
return false;
//Cannot place blind vias with front/back as the layer pair, this doesn't make sense
if( ( aType == VIA_BLIND_BURIED ) && ( sizes.GetLayerTop() == F_Cu ) && ( sizes.GetLayerBottom() == B_Cu ) )
return false;
}
sizes.SetViaType ( aType );
m_router->ToggleViaPlacement( );
m_router->UpdateSizes( sizes );
m_router->Move( m_endSnapPoint, m_endItem ); // refresh
return false;
}
void ROUTER_TOOL::performRouting()
{
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
bool saveUndoBuffer = true;
VIEW_CONTROLS* ctls = getViewControls();
BOARD* board = getModel<BOARD>();
if( getModel<BOARD>()->GetDesignSettings().m_UseConnectedTrackWidth )
{
int width = getDefaultWidth( m_startItem ? m_startItem->Net() : -1 );
if( m_startItem && m_startItem->OfKind( PNS_ITEM::SEGMENT ) )
width = static_cast<PNS_SEGMENT*>( m_startItem )->Width();
m_router->Settings().SetTrackWidth( width );
}
m_router->SwitchLayer( m_startLayer );
frame->SetActiveLayer( ToLAYER_ID( m_startLayer ) );
int routingLayer = getStartLayer ( m_startItem );
frame->SetActiveLayer( ToLAYER_ID ( routingLayer ) );
// fixme: switch on invisible layer
if( m_startItem && m_startItem->Net() >= 0 )
{
@ -553,7 +626,13 @@ void ROUTER_TOOL::performRouting()
ctls->ForceCursorPosition( false );
ctls->SetAutoPan( true );
m_router->StartRouting( m_startSnapPoint, m_startItem );
PNS_SIZES_SETTINGS sizes;
sizes.Init ( board, m_startItem );
sizes.AddLayerPair ( frame->GetScreen()->m_Route_Layer_TOP,
frame->GetScreen()->m_Route_Layer_BOTTOM );
m_router->UpdateSizes( sizes );
m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer );
m_endItem = NULL;
m_endSnapPoint = m_startSnapPoint;
@ -575,10 +654,16 @@ void ROUTER_TOOL::performRouting()
else if( evt->IsClick( BUT_LEFT ) )
{
updateEndItem( *evt );
bool needLayerSwitch = m_router->IsPlacingVia();
if( m_router->FixRoute( m_endSnapPoint, m_endItem ) )
break;
if( needLayerSwitch )
{
switchLayerOnViaPlacement();
}
// Synchronize the indicated layer
frame->SetActiveLayer( ToLAYER_ID( m_router->GetCurrentLayer() ) );
@ -586,24 +671,15 @@ void ROUTER_TOOL::performRouting()
}
else if( evt->IsAction( &ACT_PlaceThroughVia ) )
{
m_router->Settings().SetLayerPair( frame->GetScreen()->m_Route_Layer_TOP,
frame->GetScreen()->m_Route_Layer_BOTTOM );
m_router->ToggleViaPlacement( VIA_THROUGH );
m_router->Move( m_endSnapPoint, m_endItem ); // refresh
onViaCommand ( VIA_THROUGH );
}
else if( evt->IsAction( &ACT_PlaceBlindVia ) )
{
m_router->Settings().SetLayerPair( frame->GetScreen()->m_Route_Layer_TOP,
frame->GetScreen()->m_Route_Layer_BOTTOM );
m_router->ToggleViaPlacement( VIA_BLIND_BURIED );
m_router->Move( m_endSnapPoint, m_endItem ); // refresh
onViaCommand ( VIA_BLIND_BURIED );
}
else if( evt->IsAction( &ACT_PlaceMicroVia ) )
{
m_router->Settings().SetLayerPair( frame->GetScreen()->m_Route_Layer_TOP,
frame->GetScreen()->m_Route_Layer_BOTTOM );
m_router->ToggleViaPlacement( VIA_MICROVIA );
m_router->Move( m_endSnapPoint, m_endItem ); // refresh
onViaCommand ( VIA_MICROVIA );
}
else if( evt->IsAction( &ACT_SwitchPosture ) )
{
@ -649,26 +725,19 @@ void ROUTER_TOOL::performRouting()
int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
{
VIEW_CONTROLS* ctls = getViewControls();
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
BOARD* board = getModel<BOARD>();
BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
// Deselect all items
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
getEditFrame<PCB_EDIT_FRAME>()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL,
_( "Interactive Router" ) );
frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Interactive Router" ) );
ctls->SetSnapping( true );
ctls->ShowCursor( true );
// Set current track widths & via size
m_router->Settings().SetTrackWidth( bds.GetCurrentTrackWidth() );
m_router->Settings().SetViaDiameter( bds.GetCurrentViaSize() );
m_router->Settings().SetViaDrill( bds.GetCurrentViaDrill() );
ROUTER_TOOL_MENU* ctxMenu = new ROUTER_TOOL_MENU( board );
SetContextMenu ( ctxMenu );
std::auto_ptr<ROUTER_TOOL_MENU> ctxMenu ( new ROUTER_TOOL_MENU( board ) );
SetContextMenu ( ctxMenu.get() );
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
@ -695,7 +764,7 @@ int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
else
performRouting();
}
else if ( evt->IsAction( &ACT_Drag ) )
else if( evt->IsAction( &ACT_Drag ) )
performDragging();
handleCommonEvents( *evt );
@ -704,11 +773,10 @@ int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
// Restore the default settings
ctls->SetAutoPan( false );
ctls->ShowCursor( false );
getEditFrame<PCB_EDIT_FRAME>()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
// Store routing settings till the next invocation
m_settings = m_router->Settings();
delete ctxMenu;
return 0;
}

View File

@ -47,19 +47,22 @@ private:
PNS_ITEM* pickSingleItem( const VECTOR2I& aWhere, int aNet = -1, int aLayer = -1 );
int getDefaultWidth( int aNetCode );
void performRouting();
void performDragging();
void highlightNet( bool aEnabled, int aNetcode = -1 );
void updateStartItem( TOOL_EVENT& aEvent );
void updateEndItem( TOOL_EVENT& aEvent );
void getNetclassDimensions( int aNetCode, int& aWidth, int& aViaDiameter, int& aViaDrill );
void handleCommonEvents( TOOL_EVENT& evt );
int getStartLayer( const PNS_ITEM* aItem );
void switchLayerOnViaPlacement();
bool onViaCommand( VIATYPE_T aType );
MSG_PANEL_ITEMS m_panelItems;
PNS_ROUTER* m_router;

View File

@ -28,7 +28,7 @@
#include <boost/function.hpp>
#include <core/typeinfo.h>
class SELECTION;
struct SELECTION;
///> Functor type that checks a specific condition for selected items.
typedef boost::function<bool (const SELECTION&)> SELECTION_CONDITION;

View File

@ -1,11 +1,10 @@
[Desktop Entry]
Categories=Development;Electronics
Comment=Design a printed circuit board
Categories=Development;Electronics;
Comment=Create a component from a bitmap for use with KiCad
Exec=bitmap2component
GenericName=EDA Suite
Icon=bitmap2component
MimeType=application/x-bitmap2component-project;
Name=bitmap2component
Name=Bitmap to Component Converter
Type=Application
Name[en_US]=bitmap2component
Name[en_US]=Bitmap to Component Converter

View File

@ -1,11 +1,10 @@
[Desktop Entry]
Categories=Development;Electronics
Comment=Design a printed circuit board
Categories=Development;Electronics;
Comment=Assign footprints to symbols (part of KiCad)
Exec=cvpcb
GenericName=EDA Suite
Icon=cvpcb
MimeType=application/x-cvpcb-project;
Name=cvpcb
Name=CvPcb
Type=Application
Name[en_US]=cvpcb
Name[en_US]=CvPcb

View File

@ -1,5 +1,5 @@
[Desktop Entry]
Categories=Development;Electronics
Categories=Development;Electronics;
Comment=Design an electronic schematic
Comment[fr]=Dessiner des schémas électroniques
Exec=eeschema %f

View File

@ -1,11 +1,10 @@
[Desktop Entry]
Categories=Development;Electronics
Comment=Design a printed circuit board
Categories=Development;Electronics;
Comment=View gerber files
Exec=gerbview
GenericName=EDA Suite
Icon=gerbview
MimeType=application/x-gerbview-project;
Name=gerbview
Name=GerbView
Type=Application
Name[en_US]=gerbview
Name[en_US]=GerbView

View File

@ -1,5 +1,5 @@
[Desktop Entry]
Categories=Development;Electronics
Categories=Development;Electronics;
Comment=Design a printed circuit board
Comment[fr]=Concevoir un circuit imprimé
Exec=kicad %f

View File

@ -1,11 +1,10 @@
[Desktop Entry]
Categories=Development;Electronics
Comment=Design a printed circuit board
Categories=Development;Electronics;
Comment=Calculator for various electronics related computations
Exec=pcb_calculator
GenericName=EDA Suite
Icon=pcbcalculator
MimeType=application/x-pcbcalculator-project;
Name=pcbcalculator
Name=Pcb Calculator
Type=Application
Name[en_US]=pcbcalculator
Name[en_US]=Pcb Calculator

View File

@ -1,11 +1,10 @@
[Desktop Entry]
Categories=Development;Electronics
Comment=Design a printed circuit board
Categories=Development;Electronics;
Comment=Layout a printed circuit board
Exec=pcbnew %f
GenericName=EDA Suite
Icon=pcbnew
MimeType=application/x-pcbnew-pcb;
Name=pcbnew
Name=Pcbnew
Type=Application
Name[en_US]=pcbnew
Name[en_US]=Pcbnew

View File

@ -848,7 +848,7 @@ bool VRML_LAYER::Tesselate( VRML_LAYER* holes, bool aHolesOnly )
std::ostringstream ostr;
ostr << "Tesselate():FAILED: " << holes->GetError();
error = ostr.str();
return NULL;
return false;
}
if( Fault )

View File

@ -62,7 +62,6 @@
#define M_PI4 ( M_PI / 4.0 )
#endif
struct GLUtesselator;
struct VERTEX_3D
{