Commit aeb6dd8c authored by Wayne Stambaugh's avatar Wayne Stambaugh

Minor schematic object improvements and code cleaning.

parent 35843238
...@@ -4,6 +4,20 @@ KiCad ChangeLog 2010 ...@@ -4,6 +4,20 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2010-nov-3 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++common
* Initial ground work for using Boost container for storing draw items
instead of internal linked list.
++EESchema
* Move tests for dangling end code back into schematic objects.
* Add clear draw object state helper to SCH_SCREEN object.
* Add support for schematic objects to keep temporary list of connection
objects for dangling end and other connection related tests.
* Rearrange schematic label object code.
* Remove duplicate error message boxes when loading schematic items.
2010-oct-28, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> 2010-oct-28, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
PolyLine.cpp: PolyLine.cpp:
......
...@@ -542,6 +542,22 @@ PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromRedoList( ) ...@@ -542,6 +542,22 @@ PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromRedoList( )
} }
void BASE_SCREEN::AddItem( EDA_BaseStruct* aItem )
{
wxCHECK_RET( aItem != NULL, wxT( "Attempt to add NULL item pointer to " ) + GetClass() +
wxT( "item list" ) );
m_items.push_back( aItem );
}
void BASE_SCREEN::InsertItem( EDA_ITEMS::iterator aIter, EDA_BaseStruct* aItem )
{
wxCHECK_RET( aItem != NULL, wxT( "Attempt to insert NULL item pointer to " ) + GetClass() +
wxT( "item list" ) );
m_items.insert( aIter, aItem );
}
#if defined(DEBUG) #if defined(DEBUG)
/** /**
* Function Show * Function Show
......
This diff is collapsed.
...@@ -898,6 +898,70 @@ void SCH_SHEET::renumberLabels() ...@@ -898,6 +898,70 @@ void SCH_SHEET::renumberLabels()
} }
void SCH_SHEET::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{
// Using BOOST_FOREACH here creates problems (bad pointer value to pinsheet).
// I do not know why.
for( unsigned ii = 0; ii < GetSheetPins().size(); ii++ )
{
SCH_SHEET_PIN &pinsheet = GetSheetPins()[ii];
wxCHECK2_MSG( pinsheet.Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE, continue,
wxT( "Invalid item in schematic sheet pin list. Bad programmer!" ) );
pinsheet.GetEndPoints( aItemList );
}
}
bool SCH_SHEET::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
{
bool currentState = IsDangling();
BOOST_FOREACH( SCH_SHEET_PIN& pinsheet, GetSheetPins() )
{
pinsheet.IsDanglingStateChanged( aItemList );
}
return currentState != IsDangling();
}
bool SCH_SHEET::IsDangling() const
{
// If any hierarchical label in the sheet is dangling, then the sheet is dangling.
for( size_t i = 0; i < GetSheetPins().size(); i++ )
{
if( GetSheetPins()[i].IsDangling() )
return true;
}
return false;
}
bool SCH_SHEET::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
EDA_Rect boundingBox = GetBoundingBox();
if( aRect.Intersects( boundingBox ) )
m_Flags |= SELECTED;
else
m_Flags &= ~SELECTED;
return previousState != IsSelected();
}
void SCH_SHEET::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
for( size_t i = 0; i < GetSheetPins().size(); i++ )
aPoints.push_back( GetSheetPins()[i].m_Pos );
}
#if defined(DEBUG) #if defined(DEBUG)
void SCH_SHEET::Show( int nestLevel, std::ostream& os ) void SCH_SHEET::Show( int nestLevel, std::ostream& os )
......
...@@ -23,7 +23,6 @@ extern SCH_SHEET* g_RootSheet; ...@@ -23,7 +23,6 @@ extern SCH_SHEET* g_RootSheet;
* the sheet, it corresponds to a hierarchical label. * the sheet, it corresponds to a hierarchical label.
*/ */
//class SCH_SHEET_PIN : public SCH_ITEM, public EDA_TextStruct
class SCH_SHEET_PIN : public SCH_HIERLABEL class SCH_SHEET_PIN : public SCH_HIERLABEL
{ {
private: private:
...@@ -31,15 +30,15 @@ private: ...@@ -31,15 +30,15 @@ private:
///< Sheet label numbering begins at 2. ///< Sheet label numbering begins at 2.
///< 0 is reserved for the sheet name. ///< 0 is reserved for the sheet name.
///< 1 is reserve for the sheet file name. ///< 1 is reserve for the sheet file name.
int m_Edge; /* For pin labels only: sheet edge (0 to 3) of the pin int m_Edge; /* For pin labels only: sheet edge (0 to 3) of the pin
* m_Edge define on which edge the pin is positionned: * m_Edge define on which edge the pin is positionned:
* 0: pin on left side * 0: pin on left side
* 1: pin on right side * 1: pin on right side
* 2: pin on top side * 2: pin on top side
* 3: pin on bottom side * 3: pin on bottom side
* for compatibility reasons, this does not follow same values as text * for compatibility reasons, this does not follow same values as text
* orientation. * orientation.
*/ */
public: public:
SCH_SHEET_PIN( SCH_SHEET* parent, SCH_SHEET_PIN( SCH_SHEET* parent,
...@@ -168,8 +167,9 @@ public: ...@@ -168,8 +167,9 @@ public:
* @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL. * @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL.
* @return True if this item matches the search criteria. * @return True if this item matches the search criteria.
*/ */
virtual bool Matches( wxFindReplaceData& aSearchData, virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation );
void* aAuxData, wxPoint * aFindLocation );
virtual void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList );
}; };
...@@ -251,6 +251,11 @@ public: ...@@ -251,6 +251,11 @@ public:
SCH_SHEET_PIN_LIST& GetSheetPins() { return m_labels; } SCH_SHEET_PIN_LIST& GetSheetPins() { return m_labels; }
SCH_SHEET_PIN_LIST& GetSheetPins() const
{
return const_cast< SCH_SHEET_PIN_LIST& >( m_labels );
}
/** /**
* Remove a sheet label from this sheet. * Remove a sheet label from this sheet.
* *
...@@ -412,7 +417,9 @@ public: ...@@ -412,7 +417,9 @@ public:
virtual void Move( const wxPoint& aMoveVector ) virtual void Move( const wxPoint& aMoveVector )
{ {
m_Pos += aMoveVector; m_Pos += aMoveVector;
BOOST_FOREACH( SCH_SHEET_PIN & label, m_labels ) {
BOOST_FOREACH( SCH_SHEET_PIN & label, m_labels )
{
label.Move( aMoveVector ); label.Move( aMoveVector );
} }
} }
...@@ -437,8 +444,7 @@ public: ...@@ -437,8 +444,7 @@ public:
* *
* @return True if this item matches the search criteria. * @return True if this item matches the search criteria.
*/ */
virtual bool Matches( wxFindReplaceData& aSearchData, virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation );
void* aAuxData, wxPoint * aFindLocation );
/** /**
* Resize this sheet to aSize and adjust all of the labels accordingly. * Resize this sheet to aSize and adjust all of the labels accordingly.
...@@ -457,6 +463,16 @@ public: ...@@ -457,6 +463,16 @@ public:
*/ */
wxPoint GetFileNamePosition (); wxPoint GetFileNamePosition ();
virtual void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList );
virtual bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList );
virtual bool IsDangling() const;
virtual bool IsSelectStateChanged( const wxRect& aRect );
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
#if defined(DEBUG) #if defined(DEBUG)
// comment inherited by Doxygen from Base_Struct // comment inherited by Doxygen from Base_Struct
......
...@@ -340,6 +340,46 @@ void SCH_SHEET_PIN::Rotate( wxPoint rotationPoint ) ...@@ -340,6 +340,46 @@ void SCH_SHEET_PIN::Rotate( wxPoint rotationPoint )
} }
/** Virtual Function SCH_SHEET_PIN::CreateGraphicShape
* calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param aPos = Position of the shape
*/
void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& aPos )
{
/* This is the same icon shapes as SCH_HIERLABEL
* but the graphic icon is slightly different in 2 cases:
* for INPUT type the icon is the OUTPUT shape of SCH_HIERLABEL
* for OUTPUT type the icon is the INPUT shape of SCH_HIERLABEL
*/
int tmp = m_Shape;
switch( m_Shape )
{
case NET_INPUT:
m_Shape = NET_OUTPUT;
break;
case NET_OUTPUT:
m_Shape = NET_INPUT;
break;
default:
break;
}
SCH_HIERLABEL::CreateGraphicShape( aCorner_list, aPos );
m_Shape = tmp;
}
void SCH_SHEET_PIN::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{
DANGLING_END_ITEM item( SHEET_LABEL_END, this );
item.m_Pos = m_Pos;
aItemList.push_back( item );
}
#if defined(DEBUG) #if defined(DEBUG)
void SCH_SHEET_PIN::Show( int nestLevel, std::ostream& os ) void SCH_SHEET_PIN::Show( int nestLevel, std::ostream& os )
{ {
......
...@@ -180,3 +180,16 @@ void SCH_MARKER::Mirror_Y( int aYaxis_position ) ...@@ -180,3 +180,16 @@ void SCH_MARKER::Mirror_Y( int aYaxis_position )
m_Pos.x = -m_Pos.x; m_Pos.x = -m_Pos.x;
m_Pos.x += aYaxis_position; m_Pos.x += aYaxis_position;
} }
bool SCH_MARKER::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
if( aRect.Contains( m_Pos ) )
m_Flags |= SELECTED;
else
m_Flags &= ~SELECTED;
return previousState != IsSelected();
}
...@@ -116,6 +116,8 @@ public: ...@@ -116,6 +116,8 @@ public:
*/ */
void DisplayInfo( WinEDA_DrawFrame* aFrame ); void DisplayInfo( WinEDA_DrawFrame* aFrame );
virtual bool IsSelectStateChanged( const wxRect& aRect );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
......
...@@ -973,9 +973,9 @@ bool SCH_COMPONENT::Save( FILE* f ) const ...@@ -973,9 +973,9 @@ bool SCH_COMPONENT::Save( FILE* f ) const
if( GetField( REFERENCE )->m_Text.IsEmpty() ) if( GetField( REFERENCE )->m_Text.IsEmpty() )
strncpy( Name1, CONV_TO_UTF8( m_PrefixString ), sizeof( Name1 ) ); strncpy( Name1, CONV_TO_UTF8( m_PrefixString ), sizeof( Name1 ) );
else else
strncpy( Name1, CONV_TO_UTF8( GetField( REFERENCE )->m_Text ), strncpy( Name1, CONV_TO_UTF8( GetField( REFERENCE )->m_Text ), sizeof( Name1 ) );
sizeof( Name1 ) );
} }
for( ii = 0; ii < (int) strlen( Name1 ); ii++ ) for( ii = 0; ii < (int) strlen( Name1 ); ii++ )
{ {
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
...@@ -1284,3 +1284,77 @@ bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxP ...@@ -1284,3 +1284,77 @@ bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxP
return false; return false;
} }
void SCH_COMPONENT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
if( Entry == NULL )
return;
for( LIB_PIN* Pin = Entry->GetNextPin(); Pin != NULL; Pin = Entry->GetNextPin( Pin ) )
{
wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE );
if( Pin->GetUnit() && m_Multi && ( m_Multi != Pin->GetUnit() ) )
continue;
if( Pin->GetConvert() && m_Convert && ( m_Convert != Pin->GetConvert() ) )
continue;
DANGLING_END_ITEM item( PIN_END, Pin );
item.m_Pos = GetPinPhysicalPosition( Pin );
aItemList.push_back( item );
}
}
wxPoint SCH_COMPONENT::GetPinPhysicalPosition( LIB_PIN* Pin )
{
wxCHECK_MSG( Pin != NULL && Pin->Type() == COMPONENT_PIN_DRAW_TYPE, wxPoint( 0, 0 ),
wxT( "Cannot get physical position of pin." ) );
return m_Transform.TransformCoordinate( Pin->m_Pos ) + m_Pos;
}
bool SCH_COMPONENT::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
EDA_Rect boundingBox = GetBoundingBox();
if( aRect.Intersects( boundingBox ) )
m_Flags |= SELECTED;
else
m_Flags &= ~SELECTED;
return previousState != IsSelected();
}
void SCH_COMPONENT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
LIB_PIN* pin;
LIB_COMPONENT* component = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
wxCHECK_RET( component != NULL,
wxT( "Cannot add connection points to list. Cannot find component <" ) +
m_ChipName + wxT( "> in any of the loaded libraries." ) );
for( pin = component->GetNextPin( pin ); pin != NULL; pin = component->GetNextPin( pin ) )
{
wxCHECK_RET( pin->Type() == COMPONENT_PIN_DRAW_TYPE,
wxT( "GetNextPin() did not return a pin object. Bad programmer!" ) );
// Skip items not used for this part.
if( m_Multi && pin->GetUnit() && ( pin->GetUnit() != m_Multi ) )
continue;
if( m_Convert && pin->GetConvert() && ( pin->GetConvert() != m_Convert ) )
continue;
// Calculate the pin position relative to the component position and orientation.
aPoints.push_back( m_Transform.TransformCoordinate( pin->m_Pos ) + m_Pos );
}
}
/*****************************************************/ /******************************************************/
/* Definitions for the Component classes for EESchema */ /* Definitions for the Component classes for EESchema */
/*****************************************************/ /******************************************************/
#ifndef COMPONENT_CLASS_H #ifndef COMPONENT_CLASS_H
#define COMPONENT_CLASS_H #define COMPONENT_CLASS_H
...@@ -85,8 +85,7 @@ private: ...@@ -85,8 +85,7 @@ private:
void Init( const wxPoint& pos = wxPoint( 0, 0 ) ); void Init( const wxPoint& pos = wxPoint( 0, 0 ) );
public: public:
SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ), SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ), SCH_ITEM* aParent = NULL );
SCH_ITEM* aParent = NULL );
/** /**
* Create schematic component from library component object. * Create schematic component from library component object.
...@@ -122,6 +121,7 @@ public: ...@@ -122,6 +121,7 @@ public:
return wxT( "SCH_COMPONENT" ); return wxT( "SCH_COMPONENT" );
} }
TRANSFORM& GetTransform() const { return const_cast< TRANSFORM& >( m_Transform ); }
/** /**
* Function Save * Function Save
...@@ -312,8 +312,7 @@ public: ...@@ -312,8 +312,7 @@ public:
int GetUnitSelection( SCH_SHEET_PATH* aSheet ); int GetUnitSelection( SCH_SHEET_PATH* aSheet );
// Set the unit selection, for the given sheet path. // Set the unit selection, for the given sheet path.
void SetUnitSelection( SCH_SHEET_PATH* aSheet, void SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection );
int aUnitSelection );
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
...@@ -355,8 +354,15 @@ public: ...@@ -355,8 +354,15 @@ public:
* @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL. * @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL.
* @return True if this component reference or value field matches the search criteria. * @return True if this component reference or value field matches the search criteria.
*/ */
virtual bool Matches( wxFindReplaceData& aSearchData, virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation );
void* aAuxData, wxPoint * aFindLocation );
virtual void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList );
wxPoint GetPinPhysicalPosition( LIB_PIN* Pin );
virtual bool IsSelectStateChanged( const wxRect& aRect );
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
#if defined(DEBUG) #if defined(DEBUG)
......
...@@ -353,6 +353,13 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ...@@ -353,6 +353,13 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
} }
void SCH_SCREEN::ClearDrawingState()
{
for( SCH_ITEM* item = EEDrawList; item != NULL; item = item->Next() )
item->m_Flags = 0;
}
/******************************************************************/ /******************************************************************/
/* Class SCH_SCREENS to handle the list of screens in a hierarchy */ /* Class SCH_SCREENS to handle the list of screens in a hierarchy */
/******************************************************************/ /******************************************************************/
......
...@@ -167,12 +167,45 @@ void SCH_BUS_ENTRY::Rotate( wxPoint rotationPoint ) ...@@ -167,12 +167,45 @@ void SCH_BUS_ENTRY::Rotate( wxPoint rotationPoint )
} }
void SCH_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
{
DANGLING_END_ITEM item( ENTRY_END, this );
item.m_Pos = m_Pos;
DANGLING_END_ITEM item1( ENTRY_END, this );
item1.m_Pos = m_End();
aItemList.push_back( item );
aItemList.push_back( item1 );
}
bool SCH_BUS_ENTRY::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
// If either end of the bus entry is inside the selection rectangle, the entire
// bus entry is selected. Bus entries have a fixed length and angle.
if( aRect.Contains( m_Pos ) || aRect.Contains( m_End() ) )
m_Flags |= SELECTED;
else
m_Flags &= ~SELECTED;
return previousState != IsSelected();
}
void SCH_BUS_ENTRY::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
aPoints.push_back( m_Pos );
aPoints.push_back( m_End() );
}
/**********************/ /**********************/
/* class SCH_JUNCTION */ /* class SCH_JUNCTION */
/**********************/ /**********************/
SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : SCH_ITEM( NULL, DRAW_JUNCTION_STRUCT_TYPE )
SCH_ITEM( NULL, DRAW_JUNCTION_STRUCT_TYPE )
{ {
#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;
...@@ -289,6 +322,33 @@ void SCH_JUNCTION::Rotate( wxPoint rotationPoint ) ...@@ -289,6 +322,33 @@ void SCH_JUNCTION::Rotate( wxPoint rotationPoint )
} }
void SCH_JUNCTION::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{
DANGLING_END_ITEM item( JUNCTION_END, this );
item.m_Pos = m_Pos;
aItemList.push_back( item );
}
bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
if( aRect.Contains( m_Pos ) )
m_Flags |= SELECTED;
else
m_Flags &= ~SELECTED;
return previousState != IsSelected();
}
void SCH_JUNCTION::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
aPoints.push_back( m_Pos );
}
#if defined(DEBUG) #if defined(DEBUG)
void SCH_JUNCTION::Show( int nestLevel, std::ostream& os ) void SCH_JUNCTION::Show( int nestLevel, std::ostream& os )
{ {
...@@ -306,8 +366,7 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os ) ...@@ -306,8 +366,7 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os )
/* class SCH_NO_CONNECT */ /* class SCH_NO_CONNECT */
/************************/ /************************/
SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : SCH_ITEM( NULL, DRAW_NOCONNECT_STRUCT_TYPE )
SCH_ITEM( NULL, DRAW_NOCONNECT_STRUCT_TYPE )
{ {
#define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */ #define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */
m_Pos = pos; m_Pos = pos;
...@@ -430,6 +489,25 @@ void SCH_NO_CONNECT::Rotate( wxPoint rotationPoint ) ...@@ -430,6 +489,25 @@ void SCH_NO_CONNECT::Rotate( wxPoint rotationPoint )
} }
bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
if( aRect.Contains( m_Pos ) )
m_Flags |= SELECTED;
else
m_Flags &= ~SELECTED;
return previousState != IsSelected();
}
void SCH_NO_CONNECT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
aPoints.push_back( m_Pos );
}
/******************/ /******************/
/* Class SCH_LINE */ /* Class SCH_LINE */
/******************/ /******************/
...@@ -634,9 +712,7 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine ) ...@@ -634,9 +712,7 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine )
wxCHECK_MSG( aLine != NULL && aLine->Type() == DRAW_SEGMENT_STRUCT_TYPE, false, wxCHECK_MSG( aLine != NULL && aLine->Type() == DRAW_SEGMENT_STRUCT_TYPE, false,
wxT( "Cannot test line segment for overlap." ) ); wxT( "Cannot test line segment for overlap." ) );
if( this == aLine ) if( this == aLine || GetLayer() != aLine->GetLayer() )
return false;
if( GetLayer() != aLine->GetLayer() )
return false; return false;
// Search for a common end, and modify coordinates to ensure RefSegm->m_End // Search for a common end, and modify coordinates to ensure RefSegm->m_End
...@@ -658,8 +734,10 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine ) ...@@ -658,8 +734,10 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine )
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. // No common end point, segments cannot be merged.
return false; return false;
}
/* Test alignment: */ /* Test alignment: */
if( m_Start.y == m_End.y ) // Horizontal segment if( m_Start.y == m_End.y ) // Horizontal segment
...@@ -693,12 +771,86 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine ) ...@@ -693,12 +771,86 @@ bool SCH_LINE::MergeOverlap( SCH_LINE* aLine )
} }
/***********************/ void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{
if( GetLayer() == LAYER_NOTES )
return;
if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) )
{
DANGLING_END_ITEM item( (GetLayer() == LAYER_BUS) ? BUS_START_END : WIRE_START_END, this );
item.m_Pos = m_Start;
DANGLING_END_ITEM item1( (GetLayer() == LAYER_BUS) ? BUS_END_END : WIRE_END_END, this );
item1.m_Pos = m_End;
aItemList.push_back( item );
aItemList.push_back( item1 );
}
}
bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
{
bool previousStartState = m_StartIsDangling;
bool previousEndState = m_EndIsDangling;
if( GetLayer() == LAYER_WIRE )
{
BOOST_FOREACH( DANGLING_END_ITEM item, aItemList )
{
if( item.m_Item == this )
continue;
if( m_Start == item.m_Pos )
m_StartIsDangling = false;
if( m_End == item.m_Pos )
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;
}
return ( previousStartState != m_StartIsDangling ) || ( previousEndState != m_EndIsDangling );
}
bool SCH_LINE::IsSelectStateChanged( const wxRect& aRect )
{
bool previousState = IsSelected();
if( aRect.Contains( m_Start ) )
m_Flags |= STARTPOINT | SELECTED;
else
m_Flags &= ~( STARTPOINT | SELECTED );
if( aRect.Contains( m_End ) )
m_Flags |= ENDPOINT | SELECTED;
else
m_Flags &= ~( ENDPOINT | SELECTED );
return previousState != IsSelected();
}
void SCH_LINE::GetConnectionPoints( vector< wxPoint >& aPoints ) const
{
aPoints.push_back( m_Start );
aPoints.push_back( m_End );
}
/**********************/
/* Class SCH_POLYLINE */ /* Class SCH_POLYLINE */
/***********************/ /**********************/
SCH_POLYLINE::SCH_POLYLINE( int layer ) : SCH_POLYLINE::SCH_POLYLINE( int layer ) : SCH_ITEM( NULL, DRAW_POLYLINE_STRUCT_TYPE )
SCH_ITEM( NULL, DRAW_POLYLINE_STRUCT_TYPE )
{ {
m_Width = 0; m_Width = 0;
......
...@@ -108,6 +108,16 @@ public: ...@@ -108,6 +108,16 @@ public:
*/ */
bool MergeOverlap( SCH_LINE* aLine ); bool MergeOverlap( SCH_LINE* aLine );
virtual void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList );
virtual bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList );
virtual bool IsDangling() const { return m_StartIsDangling || m_EndIsDangling; }
virtual bool IsSelectStateChanged( const wxRect& aRect );
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
...@@ -185,6 +195,10 @@ public: ...@@ -185,6 +195,10 @@ public:
virtual void Mirror_Y( int aYaxis_position ); virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position ); virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint ); virtual void Rotate( wxPoint rotationPoint );
virtual bool IsSelectStateChanged( const wxRect& aRect );
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
}; };
...@@ -259,6 +273,12 @@ public: ...@@ -259,6 +273,12 @@ public:
virtual void Mirror_Y( int aYaxis_position ); virtual void Mirror_Y( int aYaxis_position );
virtual void Mirror_X( int aXaxis_position ); virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint ); virtual void Rotate( wxPoint rotationPoint );
virtual void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList );
virtual bool IsSelectStateChanged( const wxRect& aRect );
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
}; };
class SCH_POLYLINE : public SCH_ITEM class SCH_POLYLINE : public SCH_ITEM
...@@ -405,6 +425,12 @@ public: ...@@ -405,6 +425,12 @@ public:
virtual void Mirror_X( int aXaxis_position ); virtual void Mirror_X( int aXaxis_position );
virtual void Rotate( wxPoint rotationPoint ); virtual void Rotate( wxPoint rotationPoint );
virtual void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList );
virtual bool IsSelectStateChanged( const wxRect& aRect );
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
......
This diff is collapsed.
...@@ -167,8 +167,17 @@ public: ...@@ -167,8 +167,17 @@ public:
* @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL. * @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL.
* @return True if this schematic text item matches the search criteria. * @return True if this schematic text item matches the search criteria.
*/ */
virtual bool Matches( wxFindReplaceData& aSearchData, virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation );
void* aAuxData, wxPoint * aFindLocation );
virtual void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList );
virtual bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList );
virtual bool IsDangling() const { return m_IsDangling; }
virtual bool IsSelectStateChanged( const wxRect& aRect );
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const;
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
......
This diff is collapsed.
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
/* in read_from_file_schematic_items_description.cpp */ /* in read_from_file_schematic_items_description.cpp */
SCH_ITEM* ReadTextDescr( LINE_READER* aLine, wxString& aMsgDiag, int aSchematicFileVersion ); SCH_ITEM* ReadTextDescr( LINE_READER* aLine, wxString& aMsgDiag, int aSchematicFileVersion );
int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ); int ReadSheetDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window );
bool ReadSchemaDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ); bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window );
int ReadPartDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ); int ReadPartDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window );
static void LoadLayers( LINE_READER* aLine ); static void LoadLayers( LINE_READER* aLine );
...@@ -29,8 +29,7 @@ static void LoadLayers( LINE_READER* aLine ); ...@@ -29,8 +29,7 @@ static void LoadLayers( LINE_READER* aLine );
* Routine to load an EESchema file. * Routine to load an EESchema file.
* Returns true if file has been loaded (at least partially.) * Returns true if file has been loaded (at least partially.)
*/ */
bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFileName )
const wxString& FullFileName )
{ {
char Name1[256], char Name1[256],
Name2[256]; Name2[256];
...@@ -122,13 +121,13 @@ again." ); ...@@ -122,13 +121,13 @@ again." );
{ {
case '$': // identification block case '$': // identification block
if( line[1] == 'C' ) if( line[1] == 'C' )
Failed = ReadPartDescr( this, &reader, MsgDiag, screen ); Failed = ReadPartDescr( &reader, MsgDiag, screen );
else if( line[1] == 'S' ) else if( line[1] == 'S' )
Failed = ReadSheetDescr( this, &reader, MsgDiag, screen ); Failed = ReadSheetDescr( &reader, MsgDiag, screen );
else if( line[1] == 'D' ) else if( line[1] == 'D' )
Failed = ReadSchemaDescr( this, &reader, MsgDiag, screen ); Failed = ReadSchemaDescr( &reader, MsgDiag, screen );
else if( line[1] == 'T' ) // text part else if( line[1] == 'T' ) // text part
{ {
...@@ -148,7 +147,7 @@ again." ); ...@@ -148,7 +147,7 @@ again." );
break; break;
case 'L': // Its a library item. case 'L': // Its a library item.
Failed = ReadPartDescr( this, &reader, MsgDiag, screen ); Failed = ReadPartDescr( &reader, MsgDiag, screen );
break; break;
case 'W': // Its a Segment (WIRE or BUS) item. case 'W': // Its a Segment (WIRE or BUS) item.
......
...@@ -175,7 +175,7 @@ SCH_ITEM* ReadTextDescr( LINE_READER* aLine, wxString& aMsgDiag, int aSchematicF ...@@ -175,7 +175,7 @@ SCH_ITEM* ReadTextDescr( LINE_READER* aLine, wxString& aMsgDiag, int aSchematicF
/* Function used by LoadEEFile(). /* Function used by LoadEEFile().
* Get the lines for a description of a piece of hierarchy. * Get the lines for a description of a piece of hierarchy.
*/ */
int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) int ReadSheetDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window )
{ {
int ii, fieldNdx, size; int ii, fieldNdx, size;
char Name1[256], Char1[256], Char2[256]; char Name1[256], Char1[256], Char2[256];
...@@ -286,7 +286,6 @@ int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BAS ...@@ -286,7 +286,6 @@ int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BAS
aLine->LineNumber() ); aLine->LineNumber() );
aMsgDiag << CONV_FROM_UTF8( line ); aMsgDiag << CONV_FROM_UTF8( line );
DisplayError( frame, aMsgDiag );
} }
if( size == 0 ) if( size == 0 )
size = DEFAULT_SIZE_TEXT; size = DEFAULT_SIZE_TEXT;
...@@ -316,7 +315,6 @@ int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BAS ...@@ -316,7 +315,6 @@ int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BAS
aMsgDiag.Printf( wxT( "EESchema file sheet label error at line %d, ignoring.\n" ), aMsgDiag.Printf( wxT( "EESchema file sheet label error at line %d, ignoring.\n" ),
aLine->LineNumber() ); aLine->LineNumber() );
aMsgDiag << CONV_FROM_UTF8( line ); aMsgDiag << CONV_FROM_UTF8( line );
DisplayError( frame, aMsgDiag );
continue; continue;
} }
...@@ -391,7 +389,7 @@ int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BAS ...@@ -391,7 +389,7 @@ int ReadSheetDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BAS
/* Read the schematic header. */ /* Read the schematic header. */
bool ReadSchemaDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) bool ReadSchemaDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window )
{ {
char Text[256], buf[1024]; char Text[256], buf[1024];
int ii; int ii;
...@@ -427,7 +425,6 @@ bool ReadSchemaDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, B ...@@ -427,7 +425,6 @@ bool ReadSchemaDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, B
line %d, \aAbort reading file.\n" ), line %d, \aAbort reading file.\n" ),
aLine->LineNumber() ); aLine->LineNumber() );
aMsgDiag << CONV_FROM_UTF8( line ); aMsgDiag << CONV_FROM_UTF8( line );
DisplayError( frame, aMsgDiag );
} }
Window->m_CurrentSheetDesc = wsheet; Window->m_CurrentSheetDesc = wsheet;
...@@ -509,7 +506,7 @@ line %d, \aAbort reading file.\n" ), ...@@ -509,7 +506,7 @@ line %d, \aAbort reading file.\n" ),
* Get the lines for a description of a schematic component. * Get the lines for a description of a schematic component.
*/ */
int ReadPartDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window ) int ReadPartDescr( LINE_READER* aLine, wxString& aMsgDiag, BASE_SCREEN* Window )
{ {
int ii; int ii;
char Name1[256], Name2[256], char Name1[256], Name2[256],
...@@ -754,7 +751,6 @@ int ReadPartDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE ...@@ -754,7 +751,6 @@ int ReadPartDescr( wxWindow* frame, LINE_READER* aLine, wxString& aMsgDiag, BASE
aMsgDiag.Printf( aMsgDiag.Printf(
wxT( "Component Field error line %d, aborted" ), wxT( "Component Field error line %d, aborted" ),
aLine->LineNumber() ); aLine->LineNumber() );
DisplayError( frame, aMsgDiag );
continue; continue;
} }
......
...@@ -348,6 +348,7 @@ public: ...@@ -348,6 +348,7 @@ public:
inline bool IsModified() const { return m_Flags & IS_CHANGED; } inline bool IsModified() const { return m_Flags & IS_CHANGED; }
inline bool IsMoving() const { return m_Flags & IS_MOVED; } inline bool IsMoving() const { return m_Flags & IS_MOVED; }
inline bool IsDragging() const { return m_Flags & IS_DRAGGED; } inline bool IsDragging() const { return m_Flags & IS_DRAGGED; }
inline bool IsSelected() const { return m_Flags & SELECTED; }
int GetState( int type ) const int GetState( int type ) const
{ {
......
...@@ -14,12 +14,23 @@ ...@@ -14,12 +14,23 @@
#include "block_commande.h" #include "block_commande.h"
#include "common.h" #include "common.h"
#include <boost/ptr_container/ptr_vector.hpp>
// Forward declarations: // Forward declarations:
class SCH_ITEM; class SCH_ITEM;
class Ki_PageDescr; class Ki_PageDescr;
/**
* Define list of drawing items for screens.
*
* The Boost containter was choosen over the statand C++ contain because you can detach
* the pointer from a list with the release method.
*/
typedef boost::ptr_vector< EDA_BaseStruct > EDA_ITEMS;
/* Simple class for handling grid arrays. */ /* Simple class for handling grid arrays. */
class GRID_TYPE class GRID_TYPE
{ {
...@@ -56,17 +67,16 @@ WX_DECLARE_OBJARRAY( GRID_TYPE, GridArray ); ...@@ -56,17 +67,16 @@ WX_DECLARE_OBJARRAY( GRID_TYPE, GridArray );
/*******************************************************************/ /*******************************************************************/
class BASE_SCREEN : public EDA_BaseStruct class BASE_SCREEN : public EDA_BaseStruct
{ {
EDA_ITEMS m_items; ///< The drawing items associated with this screen.
public: public:
wxPoint m_DrawOrg; /* offsets for drawing the circuit on the wxPoint m_DrawOrg; /* offsets for drawing the circuit on the screen */
* screen */ wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */
wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */
* units. */
wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user
* units. */
wxPoint m_MousePositionInPixels; wxPoint m_MousePositionInPixels;
wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid)
* in user units. * in user units.
* (coordinates from last reset position)*/ * (coordinates from last reset position)*/
// Scrollbars management: // Scrollbars management:
int m_ScrollPixelsPerUnitX; /* Pixels per scroll unit in the horizontal direction. */ int m_ScrollPixelsPerUnitX; /* Pixels per scroll unit in the horizontal direction. */
int m_ScrollPixelsPerUnitY; /* Pixels per scroll unit in the vertical direction. */ int m_ScrollPixelsPerUnitY; /* Pixels per scroll unit in the vertical direction. */
...@@ -280,8 +290,7 @@ public: ...@@ -280,8 +290,7 @@ public:
/** /**
* Function SetZoomList * Function SetZoomList
* sets the list of zoom factors. * sets the list of zoom factors.
* @param aZoomList An array of zoom factors in ascending order, zero * @param aZoomList An array of zoom factors in ascending order, zero terminated
* terminated
*/ */
void SetZoomList( const wxArrayInt& zoomlist ); void SetZoomList( const wxArrayInt& zoomlist );
...@@ -300,8 +309,7 @@ public: ...@@ -300,8 +309,7 @@ public:
bool SetFirstZoom(); bool SetFirstZoom();
bool SetLastZoom(); bool SetLastZoom();
//----<grid //----<grid stuff>----------------------------------------------------------
// stuff>----------------------------------------------------------
/** /**
* Return the command ID of the currently selected grid. * Return the command ID of the currently selected grid.
...@@ -359,6 +367,13 @@ public: ...@@ -359,6 +367,13 @@ public:
return wxT( "BASE_SCREEN" ); return wxT( "BASE_SCREEN" );
} }
/**
* Helpers for accessing the draw item list.
*/
EDA_ITEMS::iterator Begin() { return m_items.begin(); }
EDA_ITEMS::iterator End() { return m_items.end(); }
virtual void AddItem( EDA_BaseStruct* aItem );
virtual void InsertItem( EDA_ITEMS::iterator aIter, EDA_BaseStruct* aItem );
#if defined(DEBUG) #if defined(DEBUG)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define CLASS_SCREEN_H #define CLASS_SCREEN_H
#include "macros.h" #include "macros.h"
#include "base_struct.h" #include "sch_item_struct.h"
#include "class_base_screen.h" #include "class_base_screen.h"
...@@ -17,8 +17,9 @@ ...@@ -17,8 +17,9 @@
class SCH_SCREEN : public BASE_SCREEN class SCH_SCREEN : public BASE_SCREEN
{ {
public: public:
int m_RefCount; /*how many sheets reference this screen? int m_RefCount; ///< Number of sheets referencing this screen.
* delete when it goes to zero. */ ///< Delete when it goes to zero.
SCH_SCREEN( KICAD_T aType = SCREEN_STRUCT_TYPE ); SCH_SCREEN( KICAD_T aType = SCREEN_STRUCT_TYPE );
~SCH_SCREEN(); ~SCH_SCREEN();
...@@ -80,7 +81,7 @@ public: ...@@ -80,7 +81,7 @@ public:
* items are removed from the beginning of the list. * items are removed from the beginning of the list.
* So this function can be called to remove old commands * So this function can be called to remove old commands
*/ */
virtual void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 ); virtual void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 );
/** /**
* Function Save * Function Save
...@@ -90,6 +91,17 @@ public: ...@@ -90,6 +91,17 @@ public:
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/**
* Clear the state flags of all the items in the screen.
*/
void ClearDrawingState();
virtual void AddItem( SCH_ITEM* aItem ) { BASE_SCREEN::AddItem( (EDA_BaseStruct*) aItem ); }
virtual void InsertItem( EDA_ITEMS::iterator aIter, SCH_ITEM* aItem )
{
BASE_SCREEN::InsertItem( aIter, (EDA_BaseStruct*) aItem );
}
}; };
......
...@@ -5,11 +5,46 @@ ...@@ -5,11 +5,46 @@
#ifndef SCH_ITEM_STRUCT_H #ifndef SCH_ITEM_STRUCT_H
#define SCH_ITEM_STRUCT_H #define SCH_ITEM_STRUCT_H
#include <vector>
#include <class_base_screen.h>
using namespace std;
class SCH_ITEM;
class WinEDA_SchematicFrame; class WinEDA_SchematicFrame;
class wxFindReplaceData; class wxFindReplaceData;
enum DANGLING_END_T {
UNKNOWN = 0,
WIRE_START_END,
WIRE_END_END,
BUS_START_END,
BUS_END_END,
JUNCTION_END,
PIN_END,
LABEL_END,
ENTRY_END,
SHEET_LABEL_END
};
// A helper class to store a list of items that can be connected to something:
class DANGLING_END_ITEM
{
public:
const void* m_Item; // a pointer to the parent
wxPoint m_Pos; // the position of the connecting point
DANGLING_END_T m_Type; // type of parent
DANGLING_END_ITEM( DANGLING_END_T type, const void* aItem )
{
m_Item = aItem;
m_Type = type;
}
};
/** /**
* Class SCH_ITEM * Class SCH_ITEM
* is a base class for any item which can be embedded within the SCHEMATIC * is a base class for any item which can be embedded within the SCHEMATIC
...@@ -21,7 +56,7 @@ class SCH_ITEM : public EDA_BaseStruct ...@@ -21,7 +56,7 @@ class SCH_ITEM : public EDA_BaseStruct
{ {
protected: protected:
int m_Layer; int m_Layer;
EDA_ITEMS m_connections; ///< List of items connected to this item.
public: public:
SCH_ITEM( EDA_BaseStruct* aParent, KICAD_T aType ); SCH_ITEM( EDA_BaseStruct* aParent, KICAD_T aType );
...@@ -72,15 +107,15 @@ public: ...@@ -72,15 +107,15 @@ public:
* move item to a new position. * move item to a new position.
* @param aMoveVector = the deplacement vector * @param aMoveVector = the deplacement vector
*/ */
virtual void Move(const wxPoint& aMoveVector) = 0; virtual void Move( const wxPoint& aMoveVector ) = 0;
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @param aYaxis_position = the y axis position
*/ */
virtual void Mirror_Y(int aYaxis_position) = 0; virtual void Mirror_Y( int aYaxis_position ) = 0;
virtual void Mirror_X(int aXaxis_position) = 0; virtual void Mirror_X( int aXaxis_position ) = 0;
virtual void Rotate(wxPoint rotationPoint) = 0; virtual void Rotate( wxPoint rotationPoint ) = 0;
/** /**
...@@ -109,8 +144,7 @@ public: ...@@ -109,8 +144,7 @@ public:
* @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL. * @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL.
* @return True if this schematic text item matches the search criteria. * @return True if this schematic text item matches the search criteria.
*/ */
virtual bool Matches( wxFindReplaceData& aSearchData, virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation )
void * aAuxData, wxPoint * aFindLocation )
{ return false; } { return false; }
/** /**
...@@ -121,6 +155,62 @@ public: ...@@ -121,6 +155,62 @@ public:
* @return True if this item matches the search criteria. * @return True if this item matches the search criteria.
*/ */
bool Matches( const wxString& aText, wxFindReplaceData& aSearchData ); bool Matches( const wxString& aText, wxFindReplaceData& aSearchData );
/**
* Add schematic item end points to \a aItemList if the item has endpoints.
*
* The default version doesn't do anything since many of the schematic object cannot
* be tested for dangling ends. If you add a new schematic item that can have a
* dangling end ( no connect ), override this method to provide the correct end
* points.
*
* @param aItemList - List of DANGLING_END_ITEMS to add to.
*/
virtual void GetEndPoints( vector< DANGLING_END_ITEM >& aItemList ) {}
/**
* Test the schematic item to \a aItemList to check if it's dangling state has changed.
*
* Note that the return value only true when the state of the test has changed. Use
* the IsDangling() method to get the current dangling state of the item. Some of
* the schematic objects cannot be tested for a dangling state, the default method
* always returns false. Only override the method if the item can be tested for a
* dangling state.
*
* @param aItemList - List of items to test item against.
* @return True if the dangling state has changed from it's current setting.
*/
virtual bool IsDanglingStateChanged( vector< DANGLING_END_ITEM >& aItemList ) { return false; }
virtual bool IsDangling() const { return false; }
/**
* Check if the selection state of an item inside \a aRect has changed.
*
* The is used by the block selection code to verify if an item is selected or not.
* True is be return anytime the select state changes. If you need to know the
* the current selection state, use the IsSelected() method.
*
* @param aRect - Rectange to test against.
*/
virtual bool IsSelectStateChanged( const wxRect& aRect ) { return false; }
/**
* Get a list of connection points for this item.
*
* Not all schematic items have connection points so the default method does nothing.
*
* @param aPoints - List of connection points to add to.
*/
virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const { }
/**
* Clear all of the connection items from the list.
*
* The vector release method is used to prevent the item pointers from being deleted.
* Do not use the vector erase method on the connection list.
*/
void ClearConnections() { m_connections.release(); }
}; };
#endif /* SCH_ITEM_STRUCT_H */ #endif /* SCH_ITEM_STRUCT_H */
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