Commit 9dce6fba authored by Wayne Stambaugh's avatar Wayne Stambaugh

Encapsulate SCH_JUNCTION, SCH_LINE, and SCH_NO_CONNECT classes.

parent 16131a50
...@@ -88,7 +88,7 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi ...@@ -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: */ if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */
ComputeBreakPoint( CurrentLine, endpos ); ComputeBreakPoint( CurrentLine, endpos );
else else
CurrentLine->m_End = endpos; CurrentLine->SetEndPoint( endpos );
segment = CurrentLine; segment = CurrentLine;
...@@ -201,7 +201,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) ...@@ -201,7 +201,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
if( nextsegment ) if( nextsegment )
{ {
newsegment = new SCH_LINE( *nextsegment ); newsegment = new SCH_LINE( *nextsegment );
nextsegment->m_Start = newsegment->m_End; nextsegment->SetStartPoint( newsegment->GetEndPoint() );
nextsegment->SetNext( NULL ); nextsegment->SetNext( NULL );
nextsegment->SetBack( newsegment ); nextsegment->SetBack( newsegment );
newsegment->SetNext( nextsegment ); newsegment->SetNext( nextsegment );
...@@ -210,10 +210,10 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) ...@@ -210,10 +210,10 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
else else
{ {
newsegment = new SCH_LINE( *oldsegment ); 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->ClearFlags( IS_NEW );
oldsegment->SetFlags( SELECTED ); oldsegment->SetFlags( SELECTED );
newsegment->SetFlags( IS_NEW ); newsegment->SetFlags( IS_NEW );
...@@ -224,7 +224,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) ...@@ -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, * 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 * if the new segment is merged (after a cleanup) with an older one
* (tested when the connection will be finished)*/ * (tested when the connection will be finished)*/
if( oldsegment->m_Start == s_ConnexionStartPoint ) if( oldsegment->GetStartPoint() == s_ConnexionStartPoint )
{ {
if( GetScreen()->IsJunctionNeeded( s_ConnexionStartPoint ) ) if( GetScreen()->IsJunctionNeeded( s_ConnexionStartPoint ) )
AddJunction( DC, s_ConnexionStartPoint ); AddJunction( DC, s_ConnexionStartPoint );
...@@ -288,14 +288,14 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) ...@@ -288,14 +288,14 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
wxPoint end_point, alt_end_point; wxPoint end_point, alt_end_point;
/* A junction can be needed to connect the last segment /* 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, * 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 * a junction can be needed to connect the previous segment m_end
* coordinate with is also the lastsegment->m_Start coordinate */ * coordinate with is also the lastsegment->m_start coordinate */
if( lastsegment ) if( lastsegment )
{ {
end_point = lastsegment->m_End; end_point = lastsegment->GetEndPoint();
alt_end_point = lastsegment->m_Start; alt_end_point = lastsegment->GetStartPoint();
} }
GetScreen()->SchematicCleanUp( DrawPanel ); GetScreen()->SchematicCleanUp( DrawPanel );
...@@ -373,37 +373,36 @@ static void ComputeBreakPoint( SCH_LINE* aSegment, const wxPoint& aPosition ) ...@@ -373,37 +373,36 @@ static void ComputeBreakPoint( SCH_LINE* aSegment, const wxPoint& aPosition )
if( nextsegment == NULL ) if( nextsegment == NULL )
return; return;
#if 0 #if 0
if( ABS( middle_position.x - aSegment->m_Start.x ) < if( ABS( middle_position.x - aSegment->GetStartPoint().x ) <
ABS( middle_position.y - aSegment->m_Start.y ) ) ABS( middle_position.y - aSegment->GetStartPoint().y ) )
middle_position.x = aSegment->m_Start.x; middle_position.x = aSegment->GetStartPoint().x;
else else
middle_position.y = aSegment->m_Start.y; middle_position.y = aSegment->GetStartPoint().y;
#else #else
int iDx = aSegment->m_End.x - aSegment->m_Start.x; int iDx = aSegment->GetEndPoint().x - aSegment->GetStartPoint().x;
int iDy = aSegment->m_End.y - aSegment->m_Start.y; int iDy = aSegment->GetEndPoint().y - aSegment->GetStartPoint().y;
if( iDy != 0 ) // keep the first segment orientation (currently horizontal) 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) 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 else
{ {
if( ABS( middle_position.x - aSegment->m_Start.x ) < if( ABS( middle_position.x - aSegment->GetStartPoint().x ) <
ABS( middle_position.y - aSegment->m_Start.y ) ) ABS( middle_position.y - aSegment->GetStartPoint().y ) )
middle_position.x = aSegment->m_Start.x; middle_position.x = aSegment->GetStartPoint().x;
else else
middle_position.y = aSegment->m_Start.y; middle_position.y = aSegment->GetStartPoint().y;
} }
#endif #endif
aSegment->m_End = middle_position; aSegment->SetEndPoint( middle_position );
nextsegment->SetStartPoint( middle_position );
nextsegment->m_Start = middle_position; nextsegment->SetEndPoint( aPosition );
nextsegment->m_End = aPosition;
} }
......
...@@ -578,7 +578,7 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ) ...@@ -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 ) ); 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. // 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" ), AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label" ),
KiBitmap( add_glabel_xpm ) ); KiBitmap( add_glabel_xpm ) );
} }
...@@ -608,7 +608,7 @@ void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame ) ...@@ -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 ) ); 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. // 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" ), AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label" ),
KiBitmap( add_glabel_xpm ) ); KiBitmap( add_glabel_xpm ) );
} }
......
...@@ -46,9 +46,9 @@ SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : ...@@ -46,9 +46,9 @@ SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) :
SCH_ITEM( NULL, SCH_JUNCTION_T ) SCH_ITEM( NULL, SCH_JUNCTION_T )
{ {
#define DRAWJUNCTION_DIAMETER 32 /* Diameter of junction symbol between wires */ #define DRAWJUNCTION_DIAMETER 32 /* Diameter of junction symbol between wires */
m_Pos = pos; m_pos = pos;
m_Layer = LAYER_JUNCTION; m_Layer = LAYER_JUNCTION;
m_Size.x = m_Size.y = DRAWJUNCTION_DIAMETER; m_size.x = m_size.y = DRAWJUNCTION_DIAMETER;
#undef DRAWJUNCTION_DIAMETER #undef DRAWJUNCTION_DIAMETER
} }
...@@ -56,8 +56,8 @@ SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : ...@@ -56,8 +56,8 @@ SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) :
SCH_JUNCTION::SCH_JUNCTION( const SCH_JUNCTION& aJunction ) : SCH_JUNCTION::SCH_JUNCTION( const SCH_JUNCTION& aJunction ) :
SCH_ITEM( aJunction ) SCH_ITEM( aJunction )
{ {
m_Pos = aJunction.m_Pos; m_pos = aJunction.m_pos;
m_Size = aJunction.m_Size; m_size = aJunction.m_size;
} }
...@@ -65,7 +65,7 @@ bool SCH_JUNCTION::Save( FILE* aFile ) const ...@@ -65,7 +65,7 @@ bool SCH_JUNCTION::Save( FILE* aFile ) const
{ {
bool success = true; 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; success = false;
} }
...@@ -86,8 +86,8 @@ void SCH_JUNCTION::SwapData( SCH_ITEM* aItem ) ...@@ -86,8 +86,8 @@ void SCH_JUNCTION::SwapData( SCH_ITEM* aItem )
wxT( "Cannot swap junction data with invalid item." ) ); wxT( "Cannot swap junction data with invalid item." ) );
SCH_JUNCTION* item = (SCH_JUNCTION*) aItem; SCH_JUNCTION* item = (SCH_JUNCTION*) aItem;
EXCHG( m_Pos, item->m_Pos ); EXCHG( m_pos, item->m_pos );
EXCHG( m_Size, item->m_Size ); EXCHG( m_size, item->m_size );
} }
...@@ -99,7 +99,7 @@ bool SCH_JUNCTION::Load( LINE_READER& aLine, wxString& aErrorMsg ) ...@@ -99,7 +99,7 @@ bool SCH_JUNCTION::Load( LINE_READER& aLine, wxString& aErrorMsg )
while( (*line != ' ' ) && *line ) while( (*line != ' ' ) && *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" ), aErrorMsg.Printf( wxT( "Eeschema file connection load error at line %d, aborted" ),
aLine.LineNumber() ); aLine.LineNumber() );
...@@ -115,8 +115,8 @@ EDA_RECT SCH_JUNCTION::GetBoundingBox() const ...@@ -115,8 +115,8 @@ EDA_RECT SCH_JUNCTION::GetBoundingBox() const
{ {
EDA_RECT rect; EDA_RECT rect;
rect.SetOrigin( m_Pos ); rect.SetOrigin( m_pos );
rect.Inflate( ( GetPenSize() + m_Size.x ) / 2 ); rect.Inflate( ( GetPenSize() + m_size.x ) / 2 );
return rect; return rect;
} }
...@@ -134,36 +134,36 @@ void SCH_JUNCTION::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffs ...@@ -134,36 +134,36 @@ void SCH_JUNCTION::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffs
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
GRFilledCircle( &aPanel->m_ClipBox, aDC, m_Pos.x + aOffset.x, m_Pos.y + aOffset.y, GRFilledCircle( &aPanel->m_ClipBox, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y,
( m_Size.x / 2 ), 0, color, color ); ( m_size.x / 2 ), 0, color, color );
} }
void SCH_JUNCTION::Mirror_X( int aXaxis_position ) void SCH_JUNCTION::Mirror_X( int aXaxis_position )
{ {
m_Pos.y -= aXaxis_position; m_pos.y -= aXaxis_position;
NEGATE( m_Pos.y ); NEGATE( m_pos.y );
m_Pos.y += aXaxis_position; m_pos.y += aXaxis_position;
} }
void SCH_JUNCTION::Mirror_Y( int aYaxis_position ) void SCH_JUNCTION::Mirror_Y( int aYaxis_position )
{ {
m_Pos.x -= aYaxis_position; m_pos.x -= aYaxis_position;
NEGATE( m_Pos.x ); NEGATE( m_pos.x );
m_Pos.x += aYaxis_position; m_pos.x += aYaxis_position;
} }
void SCH_JUNCTION::Rotate( wxPoint rotationPoint ) 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 ) 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 ); aItemList.push_back( item );
} }
...@@ -172,7 +172,7 @@ bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect ) ...@@ -172,7 +172,7 @@ bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect )
{ {
bool previousState = IsSelected(); bool previousState = IsSelected();
if( aRect.Contains( m_Pos ) ) if( aRect.Contains( m_pos ) )
m_Flags |= SELECTED; m_Flags |= SELECTED;
else else
m_Flags &= ~SELECTED; m_Flags &= ~SELECTED;
...@@ -183,7 +183,7 @@ bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect ) ...@@ -183,7 +183,7 @@ bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect )
void SCH_JUNCTION::GetConnectionPoints( vector< wxPoint >& aPoints ) const 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, ...@@ -196,7 +196,7 @@ void SCH_JUNCTION::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
item->m_SheetListInclude = *aSheetPath; item->m_SheetListInclude = *aSheetPath;
item->m_Comp = (SCH_ITEM*) this; item->m_Comp = (SCH_ITEM*) this;
item->m_Type = NET_JUNCTION; 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 ); aNetListItems.push_back( item );
} }
...@@ -208,7 +208,7 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os ) ...@@ -208,7 +208,7 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os )
// XML output: // XML output:
wxString s = GetClass(); wxString s = GetClass();
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << m_Pos << "/>\n"; NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << m_pos << "/>\n";
} }
#endif #endif
...@@ -238,12 +238,12 @@ bool SCH_JUNCTION::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccur ...@@ -238,12 +238,12 @@ bool SCH_JUNCTION::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccur
bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const
{ {
return m_Pos == aPosition; return m_pos == aPosition;
} }
void SCH_JUNCTION::doPlot( PLOTTER* aPlotter ) void SCH_JUNCTION::doPlot( PLOTTER* aPlotter )
{ {
aPlotter->set_color( ReturnLayerColor( GetLayer() ) ); aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
aPlotter->circle( m_Pos, m_Size.x, FILLED_SHAPE ); aPlotter->circle( m_pos, m_size.x, FILLED_SHAPE );
} }
...@@ -36,10 +36,8 @@ ...@@ -36,10 +36,8 @@
class SCH_JUNCTION : public SCH_ITEM class SCH_JUNCTION : public SCH_ITEM
{ {
wxPoint m_Pos; /* XY coordinates of connection. */ wxPoint m_pos; /* XY coordinates of connection. */
wxSize m_size;
public:
wxSize m_Size;
public: public:
SCH_JUNCTION( const wxPoint& pos = wxPoint( 0, 0 ) ); SCH_JUNCTION( const wxPoint& pos = wxPoint( 0, 0 ) );
...@@ -94,7 +92,7 @@ public: ...@@ -94,7 +92,7 @@ public:
*/ */
virtual void Move( const wxPoint& aMoveVector ) virtual void Move( const wxPoint& aMoveVector )
{ {
m_Pos += aMoveVector; m_pos += aMoveVector;
} }
/** /**
...@@ -133,8 +131,8 @@ private: ...@@ -133,8 +131,8 @@ private:
virtual bool doIsConnected( const wxPoint& aPosition ) const; virtual bool doIsConnected( const wxPoint& aPosition ) const;
virtual EDA_ITEM* doClone() const; virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter ); virtual void doPlot( PLOTTER* aPlotter );
virtual wxPoint doGetPosition() const { return m_Pos; } virtual wxPoint doGetPosition() const { return m_pos; }
virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; } virtual void doSetPosition( const wxPoint& aPosition ) { m_pos = aPosition; }
}; };
......
This diff is collapsed.
...@@ -41,13 +41,11 @@ ...@@ -41,13 +41,11 @@
*/ */
class SCH_LINE : public SCH_ITEM class SCH_LINE : public SCH_ITEM
{ {
bool m_StartIsDangling; bool m_startIsDangling; ///< True if start point is not connected.
bool m_EndIsDangling; // true if not connected (wires, tracks...) bool m_endIsDangling; ///< True if end point is not connected.
int m_width; ///< Set to 0 for wires and greater than 0 for busses.
public: wxPoint m_start; ///< Line start point
int m_Width; // 0 = line, > 0 = tracks, bus ... wxPoint m_end; ///< Line end point
wxPoint m_Start; // Line start point
wxPoint m_End; // Line end point
public: public:
SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES ); SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES );
...@@ -64,10 +62,18 @@ public: ...@@ -64,10 +62,18 @@ public:
bool IsEndPoint( const wxPoint& aPoint ) const 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 * Function GetBoundingBox
...@@ -145,7 +151,7 @@ public: ...@@ -145,7 +151,7 @@ public:
virtual bool IsDanglingStateChanged( vector< DANGLING_END_ITEM >& aItemList ); 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 ); virtual bool IsSelectStateChanged( const wxRect& aRect );
...@@ -176,7 +182,7 @@ private: ...@@ -176,7 +182,7 @@ private:
virtual bool doIsConnected( const wxPoint& aPosition ) const; virtual bool doIsConnected( const wxPoint& aPosition ) const;
virtual EDA_ITEM* doClone() const; virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter ); 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 ); virtual void doSetPosition( const wxPoint& aPosition );
}; };
......
...@@ -47,8 +47,8 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : ...@@ -47,8 +47,8 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) :
SCH_ITEM( NULL, SCH_NO_CONNECT_T ) SCH_ITEM( NULL, SCH_NO_CONNECT_T )
{ {
#define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */ #define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */
m_Pos = pos; m_pos = pos;
m_Size.x = m_Size.y = DRAWNOCONNECT_SIZE; m_size.x = m_size.y = DRAWNOCONNECT_SIZE;
#undef DRAWNOCONNECT_SIZE #undef DRAWNOCONNECT_SIZE
SetLayer( LAYER_NOCONNECT ); SetLayer( LAYER_NOCONNECT );
...@@ -58,8 +58,8 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : ...@@ -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_NO_CONNECT::SCH_NO_CONNECT( const SCH_NO_CONNECT& aNoConnect ) :
SCH_ITEM( aNoConnect ) SCH_ITEM( aNoConnect )
{ {
m_Pos = aNoConnect.m_Pos; m_pos = aNoConnect.m_pos;
m_Size = aNoConnect.m_Size; m_size = aNoConnect.m_size;
} }
...@@ -75,17 +75,17 @@ void SCH_NO_CONNECT::SwapData( SCH_ITEM* aItem ) ...@@ -75,17 +75,17 @@ void SCH_NO_CONNECT::SwapData( SCH_ITEM* aItem )
wxT( "Cannot swap no connect data with invalid item." ) ); wxT( "Cannot swap no connect data with invalid item." ) );
SCH_NO_CONNECT* item = (SCH_NO_CONNECT*)aItem; SCH_NO_CONNECT* item = (SCH_NO_CONNECT*)aItem;
EXCHG( m_Pos, item->m_Pos ); EXCHG( m_pos, item->m_pos );
EXCHG( m_Size, item->m_Size ); EXCHG( m_size, item->m_size );
} }
EDA_RECT SCH_NO_CONNECT::GetBoundingBox() const EDA_RECT SCH_NO_CONNECT::GetBoundingBox() const
{ {
int delta = ( GetPenSize() + m_Size.x ) / 2; int delta = ( GetPenSize() + m_size.x ) / 2;
EDA_RECT box; EDA_RECT box;
box.SetOrigin( m_Pos ); box.SetOrigin( m_pos );
box.Inflate( delta ); box.Inflate( delta );
return box; return box;
...@@ -96,7 +96,7 @@ bool SCH_NO_CONNECT::Save( FILE* aFile ) const ...@@ -96,7 +96,7 @@ bool SCH_NO_CONNECT::Save( FILE* aFile ) const
{ {
bool success = true; 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; success = false;
} }
...@@ -113,7 +113,7 @@ bool SCH_NO_CONNECT::Load( LINE_READER& aLine, wxString& aErrorMsg ) ...@@ -113,7 +113,7 @@ bool SCH_NO_CONNECT::Load( LINE_READER& aLine, wxString& aErrorMsg )
while( (*line != ' ' ) && *line ) while( (*line != ' ' ) && *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" ), aErrorMsg.Printf( wxT( "Eeschema file No Connect load error at line %d" ),
aLine.LineNumber() ); aLine.LineNumber() );
...@@ -135,11 +135,11 @@ void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf ...@@ -135,11 +135,11 @@ void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
int aDrawMode, int aColor ) int aDrawMode, int aColor )
{ {
int pX, pY, color; int pX, pY, color;
int delta = m_Size.x / 2; int delta = m_size.x / 2;
int width = g_DrawDefaultLineThickness; int width = g_DrawDefaultLineThickness;
pX = m_Pos.x + aOffset.x; pX = m_pos.x + aOffset.x;
pY = m_Pos.y + aOffset.y; pY = m_pos.y + aOffset.y;
if( aColor >= 0 ) if( aColor >= 0 )
color = aColor; color = aColor;
...@@ -155,23 +155,23 @@ void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf ...@@ -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 ) void SCH_NO_CONNECT::Mirror_X( int aXaxis_position )
{ {
m_Pos.y -= aXaxis_position; m_pos.y -= aXaxis_position;
NEGATE( m_Pos.y ); NEGATE( m_pos.y );
m_Pos.y += aXaxis_position; m_pos.y += aXaxis_position;
} }
void SCH_NO_CONNECT::Mirror_Y( int aYaxis_position ) void SCH_NO_CONNECT::Mirror_Y( int aYaxis_position )
{ {
m_Pos.x -= aYaxis_position; m_pos.x -= aYaxis_position;
NEGATE( m_Pos.x ); NEGATE( m_pos.x );
m_Pos.x += aYaxis_position; m_pos.x += aYaxis_position;
} }
void SCH_NO_CONNECT::Rotate( wxPoint rotationPoint ) 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 ) ...@@ -179,7 +179,7 @@ bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect )
{ {
bool previousState = IsSelected(); bool previousState = IsSelected();
if( aRect.Contains( m_Pos ) ) if( aRect.Contains( m_pos ) )
m_Flags |= SELECTED; m_Flags |= SELECTED;
else else
m_Flags &= ~SELECTED; m_Flags &= ~SELECTED;
...@@ -190,7 +190,7 @@ bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect ) ...@@ -190,7 +190,7 @@ bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect )
void SCH_NO_CONNECT::GetConnectionPoints( vector< wxPoint >& aPoints ) const 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, ...@@ -203,7 +203,7 @@ void SCH_NO_CONNECT::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
item->m_SheetListInclude = *aSheetPath; item->m_SheetListInclude = *aSheetPath;
item->m_Comp = this; item->m_Comp = this;
item->m_Type = NET_NOCONNECT; 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 ); aNetListItems.push_back( item );
} }
...@@ -211,14 +211,14 @@ void SCH_NO_CONNECT::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems, ...@@ -211,14 +211,14 @@ void SCH_NO_CONNECT::GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
bool SCH_NO_CONNECT::doIsConnected( const wxPoint& aPosition ) const 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 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 ) ) if( ( ABS( dist.x ) <= delta ) && ( ABS( dist.y ) <= delta ) )
return true; return true;
...@@ -242,11 +242,11 @@ bool SCH_NO_CONNECT::doHitTest( const EDA_RECT& aRect, bool aContained, int aAcc ...@@ -242,11 +242,11 @@ bool SCH_NO_CONNECT::doHitTest( const EDA_RECT& aRect, bool aContained, int aAcc
void SCH_NO_CONNECT::doPlot( PLOTTER* aPlotter ) void SCH_NO_CONNECT::doPlot( PLOTTER* aPlotter )
{ {
int delta = m_Size.x / 2; int delta = m_size.x / 2;
int pX, pY; int pX, pY;
pX = m_Pos.x; pX = m_pos.x;
pY = m_Pos.y; pY = m_pos.y;
aPlotter->set_current_line_width( GetPenSize() ); aPlotter->set_current_line_width( GetPenSize() );
aPlotter->set_color( ReturnLayerColor( GetLayer() ) ); aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
......
...@@ -36,10 +36,8 @@ ...@@ -36,10 +36,8 @@
class SCH_NO_CONNECT : public SCH_ITEM class SCH_NO_CONNECT : public SCH_ITEM
{ {
wxPoint m_Pos; /* XY coordinates of NoConnect. */ wxPoint m_pos; ///< Position of the no connect object.
wxSize m_size; ///< Size of the no connect object.
public:
wxSize m_Size; // size of this symbol
public: public:
SCH_NO_CONNECT( const wxPoint& pos = wxPoint( 0, 0 ) ); SCH_NO_CONNECT( const wxPoint& pos = wxPoint( 0, 0 ) );
...@@ -101,7 +99,7 @@ public: ...@@ -101,7 +99,7 @@ public:
*/ */
virtual void Move( const wxPoint& aMoveVector ) virtual void Move( const wxPoint& aMoveVector )
{ {
m_Pos += aMoveVector; m_pos += aMoveVector;
} }
/** /**
...@@ -134,8 +132,8 @@ private: ...@@ -134,8 +132,8 @@ private:
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const; virtual EDA_ITEM* doClone() const;
virtual void doPlot( PLOTTER* aPlotter ); virtual void doPlot( PLOTTER* aPlotter );
virtual wxPoint doGetPosition() const { return m_Pos; } virtual wxPoint doGetPosition() const { return m_pos; }
virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; } virtual void doSetPosition( const wxPoint& aPosition ) { m_pos = aPosition; }
}; };
......
...@@ -259,6 +259,7 @@ void SCH_SCREEN::AddToDrawList( SCH_ITEM* aItem ) ...@@ -259,6 +259,7 @@ void SCH_SCREEN::AddToDrawList( SCH_ITEM* aItem )
{ {
if( aItem == NULL ) if( aItem == NULL )
return; return;
aItem->SetNext( GetDrawItems() ); aItem->SetNext( GetDrawItems() );
SetDrawItems( aItem ); SetDrawItems( aItem );
} }
...@@ -393,13 +394,15 @@ void SCH_SCREEN::MarkConnections( SCH_LINE* aSegment ) ...@@ -393,13 +394,15 @@ void SCH_SCREEN::MarkConnections( SCH_LINE* aSegment )
SCH_LINE* segment = (SCH_LINE*) item; 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 ); item->SetFlags( CANDIDATE );
MarkConnections( segment ); 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 ); item->SetFlags( CANDIDATE );
MarkConnections( segment ); MarkConnections( segment );
...@@ -671,17 +674,21 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen ...@@ -671,17 +674,21 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen
{ {
pin = NULL; pin = NULL;
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( component->GetLibName() ); LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( component->GetLibName() );
if( entry == NULL ) if( entry == NULL )
continue; continue;
for( pin = entry->GetNextPin(); pin != NULL; pin = entry->GetNextPin( pin ) ) for( pin = entry->GetNextPin(); pin != NULL; pin = entry->GetNextPin( pin ) )
{ {
// Skip items not used for this part. // Skip items not used for this part.
if( component->GetUnit() && pin->GetUnit() && if( component->GetUnit() && pin->GetUnit() &&
( pin->GetUnit() != component->GetUnit() ) ) ( pin->GetUnit() != component->GetUnit() ) )
continue; continue;
if( component->GetConvert() && pin->GetConvert() && if( component->GetConvert() && pin->GetConvert() &&
( pin->GetConvert() != component->GetConvert() ) ) ( pin->GetConvert() != component->GetConvert() ) )
continue; continue;
if(component->GetPinPhysicalPosition( pin ) == aPosition ) if(component->GetPinPhysicalPosition( pin ) == aPosition )
break; break;
} }
...@@ -691,6 +698,7 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen ...@@ -691,6 +698,7 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen
else else
{ {
pin = (LIB_PIN*) component->GetDrawItem( aPosition, LIB_PIN_T ); pin = (LIB_PIN*) component->GetDrawItem( aPosition, LIB_PIN_T );
if( pin ) if( pin )
break; break;
} }
...@@ -879,9 +887,9 @@ void SCH_SCREEN::addConnectedItemsToBlock( const wxPoint& position ) ...@@ -879,9 +887,9 @@ void SCH_SCREEN::addConnectedItemsToBlock( const wxPoint& position )
SCH_LINE* line = (SCH_LINE*) item; SCH_LINE* line = (SCH_LINE*) item;
if( line->m_Start == position ) if( line->GetStartPoint() == position )
item->ClearFlags( STARTPOINT ); item->ClearFlags( STARTPOINT );
else if( line->m_End == position ) else if( line->GetEndPoint() == position )
item->ClearFlags( ENDPOINT ); item->ClearFlags( ENDPOINT );
} }
else else
...@@ -962,8 +970,8 @@ bool SCH_SCREEN::BreakSegment( const wxPoint& aPoint ) ...@@ -962,8 +970,8 @@ bool SCH_SCREEN::BreakSegment( const wxPoint& aPoint )
// Break the segment at aPoint and create a new segment. // Break the segment at aPoint and create a new segment.
newSegment = new SCH_LINE( *segment ); newSegment = new SCH_LINE( *segment );
newSegment->m_Start = aPoint; newSegment->GetStartPoint() = aPoint;
segment->m_End = newSegment->m_Start; segment->GetEndPoint() = newSegment->GetStartPoint();
newSegment->SetNext( segment->Next() ); newSegment->SetNext( segment->Next() );
segment->SetNext( newSegment ); segment->SetNext( newSegment );
item = newSegment; item = newSegment;
...@@ -991,7 +999,8 @@ bool SCH_SCREEN::BreakSegmentsOnJunctions() ...@@ -991,7 +999,8 @@ bool SCH_SCREEN::BreakSegmentsOnJunctions()
{ {
SCH_BUS_ENTRY* busEntry = ( SCH_BUS_ENTRY* ) item; 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; brokenSegments = true;
} }
} }
...@@ -1117,6 +1126,7 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri ...@@ -1117,6 +1126,7 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri
fpfield->m_Orient = component->GetField( VALUE )->m_Orient; fpfield->m_Orient = component->GetField( VALUE )->m_Orient;
fpfield->m_Pos = component->GetField( VALUE )->m_Pos; fpfield->m_Pos = component->GetField( VALUE )->m_Pos;
fpfield->m_Size = component->GetField( VALUE )->m_Size; fpfield->m_Size = component->GetField( VALUE )->m_Size;
if( fpfield->m_Orient == 0 ) if( fpfield->m_Orient == 0 )
fpfield->m_Pos.y += 100; fpfield->m_Pos.y += 100;
else else
...@@ -1210,14 +1220,14 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis ...@@ -1210,14 +1220,14 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
SCH_LINE* testSegment = (SCH_LINE*) tmp; SCH_LINE* testSegment = (SCH_LINE*) tmp;
// Test for segment connected to the previously deleted segment: // Test for segment connected to the previously deleted segment:
if( testSegment->IsEndPoint( segment->m_Start ) ) if( testSegment->IsEndPoint( segment->GetStartPoint() ) )
break; break;
} }
// when tmp != NULL, segment is a new candidate: // when tmp != NULL, segment is a new candidate:
// put it in deleted list if // put it in deleted list if
// the start point is not connected to an other item (like pin) // 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; noconnect = true;
/* If the wire end point is connected to a wire that has already been found /* 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 ...@@ -1234,14 +1244,14 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
SCH_LINE* testSegment = (SCH_LINE*) tmp; SCH_LINE* testSegment = (SCH_LINE*) tmp;
// Test for segment connected to the previously deleted segment: // Test for segment connected to the previously deleted segment:
if( testSegment->IsEndPoint( segment->m_End ) ) if( testSegment->IsEndPoint( segment->GetEndPoint() ) )
break; break;
} }
// when tmp != NULL, segment is a new candidate: // when tmp != NULL, segment is a new candidate:
// put it in deleted list if // put it in deleted list if
// the end point is not connected to an other item (like pin) // 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; noconnect = true;
item->ClearFlags( SKIP_STRUCT ); item->ClearFlags( SKIP_STRUCT );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment