Encapsulate SCH_JUNCTION, SCH_LINE, and SCH_NO_CONNECT classes.

This commit is contained in:
Wayne Stambaugh 2011-12-07 15:19:29 -05:00
parent 16131a500d
commit 9dce6fba09
9 changed files with 228 additions and 217 deletions

View File

@ -88,7 +88,7 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */
ComputeBreakPoint( CurrentLine, endpos );
else
CurrentLine->m_End = endpos;
CurrentLine->SetEndPoint( endpos );
segment = CurrentLine;
@ -201,7 +201,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
if( nextsegment )
{
newsegment = new SCH_LINE( *nextsegment );
nextsegment->m_Start = newsegment->m_End;
nextsegment->SetStartPoint( newsegment->GetEndPoint() );
nextsegment->SetNext( NULL );
nextsegment->SetBack( newsegment );
newsegment->SetNext( nextsegment );
@ -210,10 +210,10 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
else
{
newsegment = new SCH_LINE( *oldsegment );
newsegment->m_Start = oldsegment->m_End;
newsegment->SetStartPoint( oldsegment->GetEndPoint() );
}
newsegment->m_End = cursorpos;
newsegment->SetEndPoint( cursorpos );
oldsegment->ClearFlags( IS_NEW );
oldsegment->SetFlags( SELECTED );
newsegment->SetFlags( IS_NEW );
@ -224,7 +224,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
* Create a junction if needed. Note: a junction can be needed later,
* if the new segment is merged (after a cleanup) with an older one
* (tested when the connection will be finished)*/
if( oldsegment->m_Start == s_ConnexionStartPoint )
if( oldsegment->GetStartPoint() == s_ConnexionStartPoint )
{
if( GetScreen()->IsJunctionNeeded( s_ConnexionStartPoint ) )
AddJunction( DC, s_ConnexionStartPoint );
@ -288,14 +288,14 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
wxPoint end_point, alt_end_point;
/* A junction can be needed to connect the last segment
* usually to m_End coordinate.
* usually to m_end coordinate.
* But if the last segment is removed by a cleanup, because of redundancy,
* a junction can be needed to connect the previous segment m_End
* coordinate with is also the lastsegment->m_Start coordinate */
* a junction can be needed to connect the previous segment m_end
* coordinate with is also the lastsegment->m_start coordinate */
if( lastsegment )
{
end_point = lastsegment->m_End;
alt_end_point = lastsegment->m_Start;
end_point = lastsegment->GetEndPoint();
alt_end_point = lastsegment->GetStartPoint();
}
GetScreen()->SchematicCleanUp( DrawPanel );
@ -373,37 +373,36 @@ static void ComputeBreakPoint( SCH_LINE* aSegment, const wxPoint& aPosition )
if( nextsegment == NULL )
return;
#if 0
if( ABS( middle_position.x - aSegment->m_Start.x ) <
ABS( middle_position.y - aSegment->m_Start.y ) )
middle_position.x = aSegment->m_Start.x;
if( ABS( middle_position.x - aSegment->GetStartPoint().x ) <
ABS( middle_position.y - aSegment->GetStartPoint().y ) )
middle_position.x = aSegment->GetStartPoint().x;
else
middle_position.y = aSegment->m_Start.y;
middle_position.y = aSegment->GetStartPoint().y;
#else
int iDx = aSegment->m_End.x - aSegment->m_Start.x;
int iDy = aSegment->m_End.y - aSegment->m_Start.y;
int iDx = aSegment->GetEndPoint().x - aSegment->GetStartPoint().x;
int iDy = aSegment->GetEndPoint().y - aSegment->GetStartPoint().y;
if( iDy != 0 ) // keep the first segment orientation (currently horizontal)
{
middle_position.x = aSegment->m_Start.x;
middle_position.x = aSegment->GetStartPoint().x;
}
else if( iDx != 0 ) // keep the first segment orientation (currently vertical)
{
middle_position.y = aSegment->m_Start.y;
middle_position.y = aSegment->GetStartPoint().y;
}
else
{
if( ABS( middle_position.x - aSegment->m_Start.x ) <
ABS( middle_position.y - aSegment->m_Start.y ) )
middle_position.x = aSegment->m_Start.x;
if( ABS( middle_position.x - aSegment->GetStartPoint().x ) <
ABS( middle_position.y - aSegment->GetStartPoint().y ) )
middle_position.x = aSegment->GetStartPoint().x;
else
middle_position.y = aSegment->m_Start.y;
middle_position.y = aSegment->GetStartPoint().y;
}
#endif
aSegment->m_End = middle_position;
nextsegment->m_Start = middle_position;
nextsegment->m_End = aPosition;
aSegment->SetEndPoint( middle_position );
nextsegment->SetStartPoint( middle_position );
nextsegment->SetEndPoint( aPosition );
}

View File

@ -578,7 +578,7 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_LABEL, msg, KiBitmap( add_line_label_xpm ) );
// Add global label command only if the cursor is over one end of the wire.
if( ( pos == Wire->m_Start ) || ( pos == Wire->m_End ) )
if( Wire->IsEndPoint( pos ) )
AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label" ),
KiBitmap( add_glabel_xpm ) );
}
@ -608,7 +608,7 @@ void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame )
AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_LABEL, msg, KiBitmap( add_line_label_xpm ) );
// Add global label command only if the cursor is over one end of the bus.
if( ( pos == Bus->m_Start ) || ( pos == Bus->m_End ) )
if( Bus->IsEndPoint( pos ) )
AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label" ),
KiBitmap( add_glabel_xpm ) );
}

View File

@ -46,9 +46,9 @@ SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) :
SCH_ITEM( NULL, SCH_JUNCTION_T )
{
#define DRAWJUNCTION_DIAMETER 32 /* Diameter of junction symbol between wires */
m_Pos = pos;
m_pos = pos;
m_Layer = LAYER_JUNCTION;
m_Size.x = m_Size.y = DRAWJUNCTION_DIAMETER;
m_size.x = m_size.y = DRAWJUNCTION_DIAMETER;
#undef DRAWJUNCTION_DIAMETER
}
@ -56,8 +56,8 @@ SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) :
SCH_JUNCTION::SCH_JUNCTION( const SCH_JUNCTION& aJunction ) :
SCH_ITEM( aJunction )
{
m_Pos = aJunction.m_Pos;
m_Size = aJunction.m_Size;
m_pos = aJunction.m_pos;
m_size = aJunction.m_size;
}
@ -65,7 +65,7 @@ bool SCH_JUNCTION::Save( FILE* aFile ) const
{
bool success = true;
if( fprintf( aFile, "Connection ~ %-4d %-4d\n", m_Pos.x, m_Pos.y ) == EOF )
if( fprintf( aFile, "Connection ~ %-4d %-4d\n", m_pos.x, m_pos.y ) == EOF )
{
success = false;
}
@ -86,8 +86,8 @@ void SCH_JUNCTION::SwapData( SCH_ITEM* aItem )
wxT( "Cannot swap junction data with invalid item." ) );
SCH_JUNCTION* item = (SCH_JUNCTION*) aItem;
EXCHG( m_Pos, item->m_Pos );
EXCHG( m_Size, item->m_Size );
EXCHG( m_pos, item->m_pos );
EXCHG( m_size, item->m_size );
}
@ -99,7 +99,7 @@ bool SCH_JUNCTION::Load( LINE_READER& aLine, wxString& aErrorMsg )
while( (*line != ' ' ) && *line )
line++;
if( sscanf( line, "%s %d %d", name, &m_Pos.x, &m_Pos.y ) != 3 )
if( sscanf( line, "%s %d %d", name, &m_pos.x, &m_pos.y ) != 3 )
{
aErrorMsg.Printf( wxT( "Eeschema file connection load error at line %d, aborted" ),
aLine.LineNumber() );
@ -115,8 +115,8 @@ EDA_RECT SCH_JUNCTION::GetBoundingBox() const
{
EDA_RECT rect;
rect.SetOrigin( m_Pos );
rect.Inflate( ( GetPenSize() + m_Size.x ) / 2 );
rect.SetOrigin( m_pos );
rect.Inflate( ( GetPenSize() + m_size.x ) / 2 );
return rect;
}
@ -134,36 +134,36 @@ void SCH_JUNCTION::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffs
GRSetDrawMode( aDC, aDrawMode );
GRFilledCircle( &aPanel->m_ClipBox, aDC, m_Pos.x + aOffset.x, m_Pos.y + aOffset.y,
( m_Size.x / 2 ), 0, color, color );
GRFilledCircle( &aPanel->m_ClipBox, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y,
( m_size.x / 2 ), 0, color, color );
}
void SCH_JUNCTION::Mirror_X( int aXaxis_position )
{
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
m_pos.y -= aXaxis_position;
NEGATE( m_pos.y );
m_pos.y += aXaxis_position;
}
void SCH_JUNCTION::Mirror_Y( int aYaxis_position )
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
m_pos.x -= aYaxis_position;
NEGATE( m_pos.x );
m_pos.x += aYaxis_position;
}
void SCH_JUNCTION::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
RotatePoint( &m_pos, rotationPoint, 900 );
}
void SCH_JUNCTION::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{
DANGLING_END_ITEM item( JUNCTION_END, this, m_Pos );
DANGLING_END_ITEM item( JUNCTION_END, this, m_pos );
aItemList.push_back( item );
}
@ -172,7 +172,7 @@ bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
if( aRect.Contains( m_Pos ) )
if( aRect.Contains( m_pos ) )
m_Flags |= SELECTED;
else
m_Flags &= ~SELECTED;
@ -183,7 +183,7 @@ bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect )
void SCH_JUNCTION::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
aPoints.push_back( m_Pos );
aPoints.push_back( m_pos );
}
@ -196,7 +196,7 @@ void SCH_JUNCTION::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
item->m_SheetListInclude = *aSheetPath;
item->m_Comp = (SCH_ITEM*) this;
item->m_Type = NET_JUNCTION;
item->m_Start = item->m_End = m_Pos;
item->m_Start = item->m_End = m_pos;
aNetListItems.push_back( item );
}
@ -208,7 +208,7 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os )
// XML output:
wxString s = GetClass();
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << m_Pos << "/>\n";
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << m_pos << "/>\n";
}
#endif
@ -238,12 +238,12 @@ bool SCH_JUNCTION::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccur
bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const
{
return m_Pos == aPosition;
return m_pos == aPosition;
}
void SCH_JUNCTION::doPlot( PLOTTER* aPlotter )
{
aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
aPlotter->circle( m_Pos, m_Size.x, FILLED_SHAPE );
aPlotter->circle( m_pos, m_size.x, FILLED_SHAPE );
}

View File

@ -36,10 +36,8 @@
class SCH_JUNCTION : public SCH_ITEM
{
wxPoint m_Pos; /* XY coordinates of connection. */
public:
wxSize m_Size;
wxPoint m_pos; /* XY coordinates of connection. */
wxSize m_size;
public:
SCH_JUNCTION( const wxPoint& pos = wxPoint( 0, 0 ) );
@ -94,7 +92,7 @@ public:
*/
virtual void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
m_pos += aMoveVector;
}
/**
@ -133,8 +131,8 @@ private:
virtual bool doIsConnected( const wxPoint& aPosition ) const;
virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
virtual wxPoint doGetPosition() const { return m_Pos; }
virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; }
virtual wxPoint doGetPosition() const { return m_pos; }
virtual void doSetPosition( const wxPoint& aPosition ) { m_pos = aPosition; }
};

View File

@ -47,10 +47,10 @@
SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) :
SCH_ITEM( NULL, SCH_LINE_T )
{
m_Start = pos;
m_End = pos;
m_Width = 0; // Default thickness used
m_StartIsDangling = m_EndIsDangling = false;
m_start = pos;
m_end = pos;
m_width = 0; // Default thickness used
m_startIsDangling = m_endIsDangling = false;
switch( layer )
{
@ -72,10 +72,10 @@ SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) :
SCH_LINE::SCH_LINE( const SCH_LINE& aLine ) :
SCH_ITEM( aLine )
{
m_Start = aLine.m_Start;
m_End = aLine.m_End;
m_Width = aLine.m_Width;
m_StartIsDangling = m_EndIsDangling = false;
m_start = aLine.m_start;
m_end = aLine.m_end;
m_width = aLine.m_width;
m_startIsDangling = m_endIsDangling = false;
}
@ -89,13 +89,13 @@ void SCH_LINE::Move( const wxPoint& aOffset )
{
if( (m_Flags & STARTPOINT) == 0 && aOffset != wxPoint( 0, 0 ) )
{
m_Start += aOffset;
m_start += aOffset;
SetModified();
}
if( (m_Flags & ENDPOINT) == 0 && aOffset != wxPoint( 0, 0 ) )
{
m_End += aOffset;
m_end += aOffset;
SetModified();
}
}
@ -107,12 +107,12 @@ void SCH_LINE::Show( int nestLevel, std::ostream& os ) const
{
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
<< " layer=\"" << m_Layer << '"'
<< " width=\"" << m_Width << '"'
<< " startIsDangling=\"" << m_StartIsDangling
<< " width=\"" << m_width << '"'
<< " startIsDangling=\"" << m_startIsDangling
<< '"' << " endIsDangling=\""
<< m_EndIsDangling << '"' << ">"
<< " <start" << m_Start << "/>"
<< " <end" << m_End << "/>" << "</"
<< m_endIsDangling << '"' << ">"
<< " <start" << m_start << "/>"
<< " <end" << m_end << "/>" << "</"
<< GetClass().Lower().mb_str() << ">\n";
}
@ -123,11 +123,11 @@ EDA_RECT SCH_LINE::GetBoundingBox() const
{
int width = 25;
int xmin = MIN( m_Start.x, m_End.x ) - width;
int ymin = MIN( m_Start.y, m_End.y ) - width;
int xmin = MIN( m_start.x, m_end.x ) - width;
int ymin = MIN( m_start.y, m_end.y ) - width;
int xmax = MAX( m_Start.x, m_End.x ) + width;
int ymax = MAX( m_Start.y, m_End.y ) + width;
int xmax = MAX( m_start.x, m_end.x ) + width;
int ymax = MAX( m_start.y, m_end.y ) + width;
// return a rectangle which is [pos,dim) in nature. therefore the +1
EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
@ -138,7 +138,7 @@ EDA_RECT SCH_LINE::GetBoundingBox() const
double SCH_LINE::GetLength() const
{
return GetLineLength( m_Start, m_End );
return GetLineLength( m_start, m_end );
}
@ -160,8 +160,8 @@ bool SCH_LINE::Save( FILE* aFile ) const
success = false;
}
if( fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n", m_Start.x, m_Start.y,
m_End.x, m_End.y ) == EOF )
if( fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n", m_start.x, m_start.y,
m_end.x, m_end.y ) == EOF )
{
success = false;
}
@ -196,7 +196,7 @@ bool SCH_LINE::Load( LINE_READER& aLine, wxString& aErrorMsg )
m_Layer = LAYER_BUS;
if( !aLine.ReadLine() || sscanf( (char*) aLine, "%d %d %d %d ",
&m_Start.x, &m_Start.y, &m_End.x, &m_End.y ) != 4 )
&m_start.x, &m_start.y, &m_end.x, &m_end.y ) != 4 )
{
aErrorMsg.Printf( wxT( "Eeschema file Segment struct error at line %d, aborted" ),
aLine.LineNumber() );
@ -210,9 +210,9 @@ bool SCH_LINE::Load( LINE_READER& aLine, wxString& aErrorMsg )
int SCH_LINE::GetPenSize() const
{
int pensize = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
int pensize = ( m_width == 0 ) ? g_DrawDefaultLineThickness : m_width;
if( m_Layer == LAYER_BUS && m_Width == 0 )
if( m_Layer == LAYER_BUS && m_width == 0 )
{
pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND );
pensize = MAX( pensize, 3 );
@ -235,8 +235,8 @@ void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
GRSetDrawMode( DC, DrawMode );
wxPoint start = m_Start;
wxPoint end = m_End;
wxPoint start = m_start;
wxPoint end = m_end;
if( ( m_Flags & STARTPOINT ) == 0 )
start += offset;
@ -248,40 +248,40 @@ void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
else
GRLine( &panel->m_ClipBox, DC, start, end, width, color );
if( m_StartIsDangling )
if( m_startIsDangling )
DrawDanglingSymbol( panel, DC, start, color );
if( m_EndIsDangling )
if( m_endIsDangling )
DrawDanglingSymbol( panel, DC, end, color );
}
void SCH_LINE::Mirror_X( int aXaxis_position )
{
m_Start.y -= aXaxis_position;
NEGATE( m_Start.y );
m_Start.y += aXaxis_position;
m_End.y -= aXaxis_position;
NEGATE( m_End.y );
m_End.y += aXaxis_position;
m_start.y -= aXaxis_position;
NEGATE( m_start.y );
m_start.y += aXaxis_position;
m_end.y -= aXaxis_position;
NEGATE( m_end.y );
m_end.y += aXaxis_position;
}
void SCH_LINE::Mirror_Y( int aYaxis_position )
{
m_Start.x -= aYaxis_position;
NEGATE( m_Start.x );
m_Start.x += aYaxis_position;
m_End.x -= aYaxis_position;
NEGATE( m_End.x );
m_End.x += aYaxis_position;
m_start.x -= aYaxis_position;
NEGATE( m_start.x );
m_start.x += aYaxis_position;
m_end.x -= aYaxis_position;
NEGATE( m_end.x );
m_end.x += aYaxis_position;
}
void SCH_LINE::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Start, rotationPoint, 900 );
RotatePoint( &m_End, rotationPoint, 900 );
RotatePoint( &m_start, rotationPoint, 900 );
RotatePoint( &m_end, rotationPoint, 900 );
}
@ -293,54 +293,54 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine )
if( this == aLine || GetLayer() != aLine->GetLayer() )
return false;
// Search for a common end, and modify coordinates to ensure RefSegm->m_End
// == TstSegm->m_Start
if( m_Start == aLine->m_Start )
// Search for a common end, and modify coordinates to ensure RefSegm->m_end
// == TstSegm->m_start
if( m_start == aLine->m_start )
{
if( m_End == aLine->m_End )
if( m_end == aLine->m_end )
return true;
EXCHG( m_Start, m_End );
EXCHG( m_start, m_end );
}
else if( m_Start == aLine->m_End )
else if( m_start == aLine->m_end )
{
EXCHG( m_Start, m_End );
EXCHG( aLine->m_Start, aLine->m_End );
EXCHG( m_start, m_end );
EXCHG( aLine->m_start, aLine->m_end );
}
else if( m_End == aLine->m_End )
else if( m_end == aLine->m_end )
{
EXCHG( aLine->m_Start, aLine->m_End );
EXCHG( aLine->m_start, aLine->m_end );
}
else if( m_End != aLine->m_Start )
else if( m_end != aLine->m_start )
{
// No common end point, segments cannot be merged.
return false;
}
/* Test alignment: */
if( m_Start.y == m_End.y ) // Horizontal segment
if( m_start.y == m_end.y ) // Horizontal segment
{
if( aLine->m_Start.y == aLine->m_End.y )
if( aLine->m_start.y == aLine->m_end.y )
{
m_End = aLine->m_End;
m_end = aLine->m_end;
return true;
}
}
else if( m_Start.x == m_End.x ) // Vertical segment
else if( m_start.x == m_end.x ) // Vertical segment
{
if( aLine->m_Start.x == aLine->m_End.x )
if( aLine->m_start.x == aLine->m_end.x )
{
m_End = aLine->m_End;
m_end = aLine->m_end;
return true;
}
}
else
{
if( atan2( (double) ( m_Start.x - m_End.x ), (double) ( m_Start.y - m_End.y ) )
== atan2( (double) ( aLine->m_Start.x - aLine->m_End.x ),
(double) ( aLine->m_Start.y - aLine->m_End.y ) ) )
if( atan2( (double) ( m_start.x - m_end.x ), (double) ( m_start.y - m_end.y ) )
== atan2( (double) ( aLine->m_start.x - aLine->m_end.x ),
(double) ( aLine->m_start.y - aLine->m_end.y ) ) )
{
m_End = aLine->m_End;
m_end = aLine->m_end;
return true;
}
}
@ -357,11 +357,11 @@ void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) )
{
DANGLING_END_ITEM item( (GetLayer() == LAYER_BUS) ? BUS_START_END : WIRE_START_END, this,
m_Start );
m_start );
aItemList.push_back( item );
DANGLING_END_ITEM item1( (GetLayer() == LAYER_BUS) ? BUS_END_END : WIRE_END_END, this,
m_End );
m_end );
aItemList.push_back( item1 );
}
}
@ -369,10 +369,10 @@ void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
{
bool previousStartState = m_StartIsDangling;
bool previousEndState = m_EndIsDangling;
bool previousStartState = m_startIsDangling;
bool previousEndState = m_endIsDangling;
m_StartIsDangling = m_EndIsDangling = true;
m_startIsDangling = m_endIsDangling = true;
if( GetLayer() == LAYER_WIRE )
{
@ -381,23 +381,23 @@ bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi
if( item.GetItem() == this )
continue;
if( m_Start == item.GetPosition() )
m_StartIsDangling = false;
if( m_start == item.GetPosition() )
m_startIsDangling = false;
if( m_End == item.GetPosition() )
m_EndIsDangling = false;
if( m_end == item.GetPosition() )
m_endIsDangling = false;
if( (m_StartIsDangling == false) && (m_EndIsDangling == false) )
if( (m_startIsDangling == false) && (m_endIsDangling == false) )
break;
}
}
else if( GetLayer() == LAYER_BUS || GetLayer() == LAYER_NOTES )
{
// Lines on the notes layer and the bus layer cannot be tested for dangling ends.
previousStartState = previousEndState = m_StartIsDangling = m_EndIsDangling = false;
previousStartState = previousEndState = m_startIsDangling = m_endIsDangling = false;
}
return ( previousStartState != m_StartIsDangling ) || ( previousEndState != m_EndIsDangling );
return ( previousStartState != m_startIsDangling ) || ( previousEndState != m_endIsDangling );
}
@ -405,17 +405,17 @@ bool SCH_LINE::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
if( aRect.Contains( m_Start ) && aRect.Contains( m_End ) )
if( aRect.Contains( m_start ) && aRect.Contains( m_end ) )
{
m_Flags |= SELECTED;
m_Flags &= ~(STARTPOINT | ENDPOINT);
}
else if( aRect.Contains( m_Start ) )
else if( aRect.Contains( m_start ) )
{
m_Flags &= ~STARTPOINT;
m_Flags |= ( SELECTED | ENDPOINT );
}
else if( aRect.Contains( m_End ) )
else if( aRect.Contains( m_end ) )
{
m_Flags &= ~ENDPOINT;
m_Flags |= ( SELECTED | STARTPOINT );
@ -440,8 +440,8 @@ bool SCH_LINE::IsConnectable() const
void SCH_LINE::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
aPoints.push_back( m_Start );
aPoints.push_back( m_End );
aPoints.push_back( m_start );
aPoints.push_back( m_end );
}
@ -449,9 +449,9 @@ wxString SCH_LINE::GetSelectMenuText() const
{
wxString menuText, txtfmt, orient;
if( m_Start.x == m_End.x )
if( m_start.x == m_end.x )
orient = _("Vert.");
else if( m_Start.y == m_End.y )
else if( m_start.y == m_end.y )
orient = _("Horiz.");
switch( m_Layer )
@ -473,10 +473,10 @@ wxString SCH_LINE::GetSelectMenuText() const
}
menuText.Printf( txtfmt, GetChars( orient ),
GetChars(CoordinateToString( m_Start.x, EESCHEMA_INTERNAL_UNIT )),
GetChars(CoordinateToString( m_Start.y, EESCHEMA_INTERNAL_UNIT )),
GetChars(CoordinateToString( m_End.x, EESCHEMA_INTERNAL_UNIT )),
GetChars(CoordinateToString( m_End.y, EESCHEMA_INTERNAL_UNIT )) );
GetChars(CoordinateToString( m_start.x, EESCHEMA_INTERNAL_UNIT )),
GetChars(CoordinateToString( m_start.y, EESCHEMA_INTERNAL_UNIT )),
GetChars(CoordinateToString( m_end.x, EESCHEMA_INTERNAL_UNIT )),
GetChars(CoordinateToString( m_end.y, EESCHEMA_INTERNAL_UNIT )) );
return menuText;
}
@ -504,8 +504,8 @@ void SCH_LINE::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
item->m_SheetList = *aSheetPath;
item->m_SheetListInclude = *aSheetPath;
item->m_Comp = (SCH_ITEM*) this;
item->m_Start = m_Start;
item->m_End = m_End;
item->m_Start = m_start;
item->m_End = m_end;
if( GetLayer() == LAYER_BUS )
{
@ -530,11 +530,11 @@ bool SCH_LINE::operator <( const SCH_ITEM& aItem ) const
if( GetLength() != line->GetLength() )
return GetLength() < line->GetLength();
if( m_Start.x != line->m_Start.x )
return m_Start.x < line->m_Start.x;
if( m_start.x != line->m_start.x )
return m_start.x < line->m_start.x;
if( m_Start.y != line->m_Start.y )
return m_Start.y < line->m_Start.y;
if( m_start.y != line->m_start.y )
return m_start.y < line->m_start.y;
return false;
}
@ -542,7 +542,7 @@ bool SCH_LINE::operator <( const SCH_ITEM& aItem ) const
bool SCH_LINE::doHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
return TestSegmentHit( aPoint, m_Start, m_End, aAccuracy );
return TestSegmentHit( aPoint, m_start, m_end, aAccuracy );
}
@ -576,8 +576,8 @@ void SCH_LINE::doPlot( PLOTTER* aPlotter )
if( m_Layer == LAYER_NOTES )
aPlotter->set_dash( true );
aPlotter->move_to( m_Start );
aPlotter->finish_to( m_End );
aPlotter->move_to( m_start );
aPlotter->finish_to( m_end );
if( m_Layer == LAYER_NOTES )
aPlotter->set_dash( false );
@ -586,6 +586,6 @@ void SCH_LINE::doPlot( PLOTTER* aPlotter )
void SCH_LINE::doSetPosition( const wxPoint& aPosition )
{
m_End = m_End - ( m_Start - aPosition );
m_Start = aPosition;
m_end = m_end - ( m_start - aPosition );
m_start = aPosition;
}

View File

@ -41,13 +41,11 @@
*/
class SCH_LINE : public SCH_ITEM
{
bool m_StartIsDangling;
bool m_EndIsDangling; // true if not connected (wires, tracks...)
public:
int m_Width; // 0 = line, > 0 = tracks, bus ...
wxPoint m_Start; // Line start point
wxPoint m_End; // Line end point
bool m_startIsDangling; ///< True if start point is not connected.
bool m_endIsDangling; ///< True if end point is not connected.
int m_width; ///< Set to 0 for wires and greater than 0 for busses.
wxPoint m_start; ///< Line start point
wxPoint m_end; ///< Line end point
public:
SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES );
@ -64,10 +62,18 @@ public:
bool IsEndPoint( const wxPoint& aPoint ) const
{
return aPoint == m_Start || aPoint == m_End;
return aPoint == m_start || aPoint == m_end;
}
bool IsNull() const { return m_Start == m_End; }
bool IsNull() const { return m_start == m_end; }
wxPoint GetStartPoint() const { return m_start; }
void SetStartPoint( const wxPoint& aPosition ) { m_start = aPosition; }
wxPoint GetEndPoint() const { return m_end; }
void SetEndPoint( const wxPoint& aPosition ) { m_end = aPosition; }
/**
* Function GetBoundingBox
@ -145,7 +151,7 @@ public:
virtual bool IsDanglingStateChanged( vector< DANGLING_END_ITEM >& aItemList );
virtual bool IsDangling() const { return m_StartIsDangling || m_EndIsDangling; }
virtual bool IsDangling() const { return m_startIsDangling || m_endIsDangling; }
virtual bool IsSelectStateChanged( const wxRect& aRect );
@ -176,7 +182,7 @@ private:
virtual bool doIsConnected( const wxPoint& aPosition ) const;
virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
virtual wxPoint doGetPosition() const { return m_Start; }
virtual wxPoint doGetPosition() const { return m_start; }
virtual void doSetPosition( const wxPoint& aPosition );
};

View File

@ -47,8 +47,8 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) :
SCH_ITEM( NULL, SCH_NO_CONNECT_T )
{
#define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */
m_Pos = pos;
m_Size.x = m_Size.y = DRAWNOCONNECT_SIZE;
m_pos = pos;
m_size.x = m_size.y = DRAWNOCONNECT_SIZE;
#undef DRAWNOCONNECT_SIZE
SetLayer( LAYER_NOCONNECT );
@ -58,8 +58,8 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) :
SCH_NO_CONNECT::SCH_NO_CONNECT( const SCH_NO_CONNECT& aNoConnect ) :
SCH_ITEM( aNoConnect )
{
m_Pos = aNoConnect.m_Pos;
m_Size = aNoConnect.m_Size;
m_pos = aNoConnect.m_pos;
m_size = aNoConnect.m_size;
}
@ -75,17 +75,17 @@ void SCH_NO_CONNECT::SwapData( SCH_ITEM* aItem )
wxT( "Cannot swap no connect data with invalid item." ) );
SCH_NO_CONNECT* item = (SCH_NO_CONNECT*)aItem;
EXCHG( m_Pos, item->m_Pos );
EXCHG( m_Size, item->m_Size );
EXCHG( m_pos, item->m_pos );
EXCHG( m_size, item->m_size );
}
EDA_RECT SCH_NO_CONNECT::GetBoundingBox() const
{
int delta = ( GetPenSize() + m_Size.x ) / 2;
int delta = ( GetPenSize() + m_size.x ) / 2;
EDA_RECT box;
box.SetOrigin( m_Pos );
box.SetOrigin( m_pos );
box.Inflate( delta );
return box;
@ -96,7 +96,7 @@ bool SCH_NO_CONNECT::Save( FILE* aFile ) const
{
bool success = true;
if( fprintf( aFile, "NoConn ~ %-4d %-4d\n", m_Pos.x, m_Pos.y ) == EOF )
if( fprintf( aFile, "NoConn ~ %-4d %-4d\n", m_pos.x, m_pos.y ) == EOF )
{
success = false;
}
@ -113,7 +113,7 @@ bool SCH_NO_CONNECT::Load( LINE_READER& aLine, wxString& aErrorMsg )
while( (*line != ' ' ) && *line )
line++;
if( sscanf( line, "%s %d %d", name, &m_Pos.x, &m_Pos.y ) != 3 )
if( sscanf( line, "%s %d %d", name, &m_pos.x, &m_pos.y ) != 3 )
{
aErrorMsg.Printf( wxT( "Eeschema file No Connect load error at line %d" ),
aLine.LineNumber() );
@ -135,11 +135,11 @@ void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
int aDrawMode, int aColor )
{
int pX, pY, color;
int delta = m_Size.x / 2;
int delta = m_size.x / 2;
int width = g_DrawDefaultLineThickness;
pX = m_Pos.x + aOffset.x;
pY = m_Pos.y + aOffset.y;
pX = m_pos.x + aOffset.x;
pY = m_pos.y + aOffset.y;
if( aColor >= 0 )
color = aColor;
@ -155,23 +155,23 @@ void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
void SCH_NO_CONNECT::Mirror_X( int aXaxis_position )
{
m_Pos.y -= aXaxis_position;
NEGATE( m_Pos.y );
m_Pos.y += aXaxis_position;
m_pos.y -= aXaxis_position;
NEGATE( m_pos.y );
m_pos.y += aXaxis_position;
}
void SCH_NO_CONNECT::Mirror_Y( int aYaxis_position )
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
m_pos.x -= aYaxis_position;
NEGATE( m_pos.x );
m_pos.x += aYaxis_position;
}
void SCH_NO_CONNECT::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
RotatePoint( &m_pos, rotationPoint, 900 );
}
@ -179,7 +179,7 @@ bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
if( aRect.Contains( m_Pos ) )
if( aRect.Contains( m_pos ) )
m_Flags |= SELECTED;
else
m_Flags &= ~SELECTED;
@ -190,7 +190,7 @@ bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect )
void SCH_NO_CONNECT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
aPoints.push_back( m_Pos );
aPoints.push_back( m_pos );
}
@ -203,7 +203,7 @@ void SCH_NO_CONNECT::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
item->m_SheetListInclude = *aSheetPath;
item->m_Comp = this;
item->m_Type = NET_NOCONNECT;
item->m_Start = item->m_End = m_Pos;
item->m_Start = item->m_End = m_pos;
aNetListItems.push_back( item );
}
@ -211,14 +211,14 @@ void SCH_NO_CONNECT::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
bool SCH_NO_CONNECT::doIsConnected( const wxPoint& aPosition ) const
{
return m_Pos == aPosition;
return m_pos == aPosition;
}
bool SCH_NO_CONNECT::doHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
int delta = ( ( m_Size.x + g_DrawDefaultLineThickness ) / 2 ) + aAccuracy;
int delta = ( ( m_size.x + g_DrawDefaultLineThickness ) / 2 ) + aAccuracy;
wxPoint dist = aPoint - m_Pos;
wxPoint dist = aPoint - m_pos;
if( ( ABS( dist.x ) <= delta ) && ( ABS( dist.y ) <= delta ) )
return true;
@ -242,11 +242,11 @@ bool SCH_NO_CONNECT::doHitTest( const EDA_RECT& aRect, bool aContained, int aAcc
void SCH_NO_CONNECT::doPlot( PLOTTER* aPlotter )
{
int delta = m_Size.x / 2;
int delta = m_size.x / 2;
int pX, pY;
pX = m_Pos.x;
pY = m_Pos.y;
pX = m_pos.x;
pY = m_pos.y;
aPlotter->set_current_line_width( GetPenSize() );
aPlotter->set_color( ReturnLayerColor( GetLayer() ) );

View File

@ -36,10 +36,8 @@
class SCH_NO_CONNECT : public SCH_ITEM
{
wxPoint m_Pos; /* XY coordinates of NoConnect. */
public:
wxSize m_Size; // size of this symbol
wxPoint m_pos; ///< Position of the no connect object.
wxSize m_size; ///< Size of the no connect object.
public:
SCH_NO_CONNECT( const wxPoint& pos = wxPoint( 0, 0 ) );
@ -101,7 +99,7 @@ public:
*/
virtual void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
m_pos += aMoveVector;
}
/**
@ -134,8 +132,8 @@ private:
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter );
virtual wxPoint doGetPosition() const { return m_Pos; }
virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; }
virtual wxPoint doGetPosition() const { return m_pos; }
virtual void doSetPosition( const wxPoint& aPosition ) { m_pos = aPosition; }
};

View File

@ -259,6 +259,7 @@ void SCH_SCREEN::AddToDrawList( SCH_ITEM* aItem )
{
if( aItem == NULL )
return;
aItem->SetNext( GetDrawItems() );
SetDrawItems( aItem );
}
@ -393,13 +394,15 @@ void SCH_SCREEN::MarkConnections( SCH_LINE* aSegment )
SCH_LINE* segment = (SCH_LINE*) item;
if( aSegment->IsEndPoint( segment->m_Start ) && !GetPin( segment->m_Start, NULL, true ) )
if( aSegment->IsEndPoint( segment->GetStartPoint() )
&& !GetPin( segment->GetStartPoint(), NULL, true ) )
{
item->SetFlags( CANDIDATE );
MarkConnections( segment );
}
if( aSegment->IsEndPoint( segment->m_End ) && !GetPin( segment->m_End, NULL, true ) )
if( aSegment->IsEndPoint( segment->GetEndPoint() )
&& !GetPin( segment->GetEndPoint(), NULL, true ) )
{
item->SetFlags( CANDIDATE );
MarkConnections( segment );
@ -671,17 +674,21 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen
{
pin = NULL;
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( component->GetLibName() );
if( entry == NULL )
continue;
for( pin = entry->GetNextPin(); pin != NULL; pin = entry->GetNextPin( pin ) )
{
// Skip items not used for this part.
if( component->GetUnit() && pin->GetUnit() &&
( pin->GetUnit() != component->GetUnit() ) )
continue;
if( component->GetConvert() && pin->GetConvert() &&
( pin->GetConvert() != component->GetConvert() ) )
continue;
if(component->GetPinPhysicalPosition( pin ) == aPosition )
break;
}
@ -691,6 +698,7 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen
else
{
pin = (LIB_PIN*) component->GetDrawItem( aPosition, LIB_PIN_T );
if( pin )
break;
}
@ -879,9 +887,9 @@ void SCH_SCREEN::addConnectedItemsToBlock( const wxPoint& position )
SCH_LINE* line = (SCH_LINE*) item;
if( line->m_Start == position )
if( line->GetStartPoint() == position )
item->ClearFlags( STARTPOINT );
else if( line->m_End == position )
else if( line->GetEndPoint() == position )
item->ClearFlags( ENDPOINT );
}
else
@ -962,8 +970,8 @@ bool SCH_SCREEN::BreakSegment( const wxPoint& aPoint )
// Break the segment at aPoint and create a new segment.
newSegment = new SCH_LINE( *segment );
newSegment->m_Start = aPoint;
segment->m_End = newSegment->m_Start;
newSegment->GetStartPoint() = aPoint;
segment->GetEndPoint() = newSegment->GetStartPoint();
newSegment->SetNext( segment->Next() );
segment->SetNext( newSegment );
item = newSegment;
@ -991,7 +999,8 @@ bool SCH_SCREEN::BreakSegmentsOnJunctions()
{
SCH_BUS_ENTRY* busEntry = ( SCH_BUS_ENTRY* ) item;
if( BreakSegment( busEntry->GetPosition() ) || BreakSegment( busEntry->m_End() ) )
if( BreakSegment( busEntry->GetPosition() )
|| BreakSegment( busEntry->m_End() ) )
brokenSegments = true;
}
}
@ -1117,6 +1126,7 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri
fpfield->m_Orient = component->GetField( VALUE )->m_Orient;
fpfield->m_Pos = component->GetField( VALUE )->m_Pos;
fpfield->m_Size = component->GetField( VALUE )->m_Size;
if( fpfield->m_Orient == 0 )
fpfield->m_Pos.y += 100;
else
@ -1210,14 +1220,14 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
SCH_LINE* testSegment = (SCH_LINE*) tmp;
// Test for segment connected to the previously deleted segment:
if( testSegment->IsEndPoint( segment->m_Start ) )
if( testSegment->IsEndPoint( segment->GetStartPoint() ) )
break;
}
// when tmp != NULL, segment is a new candidate:
// put it in deleted list if
// the start point is not connected to an other item (like pin)
if( tmp && !CountConnectedItems( segment->m_Start, true ) )
if( tmp && !CountConnectedItems( segment->GetStartPoint(), true ) )
noconnect = true;
/* If the wire end point is connected to a wire that has already been found
@ -1234,14 +1244,14 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
SCH_LINE* testSegment = (SCH_LINE*) tmp;
// Test for segment connected to the previously deleted segment:
if( testSegment->IsEndPoint( segment->m_End ) )
if( testSegment->IsEndPoint( segment->GetEndPoint() ) )
break;
}
// when tmp != NULL, segment is a new candidate:
// put it in deleted list if
// the end point is not connected to an other item (like pin)
if( tmp && !CountConnectedItems( segment->m_End, true ) )
if( tmp && !CountConnectedItems( segment->GetEndPoint(), true ) )
noconnect = true;
item->ClearFlags( SKIP_STRUCT );