Commit 86bf955d authored by Wayne Stambaugh's avatar Wayne Stambaugh

Add hit testing clarification to schematic library editor.

* Create library collector class.
* Add clarification menu to library editor when multiple items are found
  at the current position.
* Add get clarification menu text to all objects derived from LIB_ITEM.
* Add get menu bitmap for all objects derived from LIB_ITEM.
* Improve LIB_PIN bounding box calculation.
* Rename LIB_ITEM::DoGenCopy to doClone to match behavior defined in base
  class EDA_ITEM.
* Minor class renaming for improved code consistency.
* Added less than operator to EDA_ITEM.
parent 585655e2
...@@ -81,7 +81,6 @@ EDA_ITEM* EDA_ITEM::doClone() const ...@@ -81,7 +81,6 @@ EDA_ITEM* EDA_ITEM::doClone() const
} }
// see base_struct.h
SEARCH_RESULT EDA_ITEM::IterateForward( EDA_ITEM* listStart, SEARCH_RESULT EDA_ITEM::IterateForward( EDA_ITEM* listStart,
INSPECTOR* inspector, INSPECTOR* inspector,
const void* testData, const void* testData,
...@@ -135,6 +134,15 @@ wxString EDA_ITEM::GetSelectMenuText() const ...@@ -135,6 +134,15 @@ wxString EDA_ITEM::GetSelectMenuText() const
} }
bool EDA_ITEM::operator<( const EDA_ITEM& aItem ) const
{
wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
GetChars( GetClass() ) ) );
return false;
}
#if defined(DEBUG) #if defined(DEBUG)
......
...@@ -94,6 +94,7 @@ set(EESCHEMA_SRCS ...@@ -94,6 +94,7 @@ set(EESCHEMA_SRCS
lib_arc.cpp lib_arc.cpp
lib_bezier.cpp lib_bezier.cpp
lib_circle.cpp lib_circle.cpp
lib_collectors.cpp
lib_draw_item.cpp lib_draw_item.cpp
lib_export.cpp lib_export.cpp
lib_field.cpp lib_field.cpp
......
...@@ -189,7 +189,7 @@ LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) : ...@@ -189,7 +189,7 @@ LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) :
LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary ) : LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary ) :
EDA_ITEM( aComponent ) EDA_ITEM( aComponent )
{ {
LIB_DRAW_ITEM* newItem; LIB_ITEM* newItem;
m_library = aLibrary; m_library = aLibrary;
m_name = aComponent.m_name; m_name = aComponent.m_name;
...@@ -202,12 +202,12 @@ LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary ) ...@@ -202,12 +202,12 @@ LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary )
m_dateModified = aComponent.m_dateModified; m_dateModified = aComponent.m_dateModified;
m_options = aComponent.m_options; m_options = aComponent.m_options;
BOOST_FOREACH( LIB_DRAW_ITEM& oldItem, aComponent.GetDrawItemList() ) BOOST_FOREACH( LIB_ITEM& oldItem, aComponent.GetDrawItemList() )
{ {
if( oldItem.IsNew() ) if( oldItem.IsNew() )
continue; continue;
newItem = oldItem.GenCopy(); newItem = (LIB_ITEM*) oldItem.Clone();
newItem->SetParent( this ); newItem->SetParent( this );
drawings.push_back( newItem ); drawings.push_back( newItem );
} }
...@@ -294,7 +294,7 @@ void LIB_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOff ...@@ -294,7 +294,7 @@ void LIB_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOff
*/ */
if( ! (screen->m_IsPrinting && GetGRForceBlackPenState()) && (aColor == -1) ) if( ! (screen->m_IsPrinting && GetGRForceBlackPenState()) && (aColor == -1) )
{ {
BOOST_FOREACH( LIB_DRAW_ITEM& drawItem, drawings ) BOOST_FOREACH( LIB_ITEM& drawItem, drawings )
{ {
if( drawItem.m_Fill != FILLED_WITH_BG_BODYCOLOR ) if( drawItem.m_Fill != FILLED_WITH_BG_BODYCOLOR )
continue; continue;
...@@ -327,7 +327,7 @@ void LIB_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOff ...@@ -327,7 +327,7 @@ void LIB_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOff
} }
} }
BOOST_FOREACH( LIB_DRAW_ITEM& drawItem, drawings ) BOOST_FOREACH( LIB_ITEM& drawItem, drawings )
{ {
if( aOnlySelected && drawItem.m_Selected == 0 ) if( aOnlySelected && drawItem.m_Selected == 0 )
continue; continue;
...@@ -389,7 +389,7 @@ void LIB_COMPONENT::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, ...@@ -389,7 +389,7 @@ void LIB_COMPONENT::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
{ {
wxASSERT( aPlotter != NULL ); wxASSERT( aPlotter != NULL );
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
{ {
if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) ) if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
continue; continue;
...@@ -404,7 +404,7 @@ void LIB_COMPONENT::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, ...@@ -404,7 +404,7 @@ void LIB_COMPONENT::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
} }
void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aDc ) void LIB_COMPONENT::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aDc )
{ {
wxASSERT( aItem != NULL ); wxASSERT( aItem != NULL );
...@@ -424,7 +424,7 @@ from component %s in library %s." ), ...@@ -424,7 +424,7 @@ from component %s in library %s." ),
} }
} }
LIB_DRAW_ITEM_LIST::iterator i; LIB_ITEMS::iterator i;
for( i = drawings.begin(); i < drawings.end(); i++ ) for( i = drawings.begin(); i < drawings.end(); i++ )
{ {
...@@ -441,7 +441,7 @@ from component %s in library %s." ), ...@@ -441,7 +441,7 @@ from component %s in library %s." ),
} }
void LIB_COMPONENT::AddDrawItem( LIB_DRAW_ITEM* aItem ) void LIB_COMPONENT::AddDrawItem( LIB_ITEM* aItem )
{ {
wxASSERT( aItem != NULL ); wxASSERT( aItem != NULL );
...@@ -450,7 +450,7 @@ void LIB_COMPONENT::AddDrawItem( LIB_DRAW_ITEM* aItem ) ...@@ -450,7 +450,7 @@ void LIB_COMPONENT::AddDrawItem( LIB_DRAW_ITEM* aItem )
} }
LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* aItem, KICAD_T aType ) LIB_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_ITEM* aItem, KICAD_T aType )
{ {
/* Return the next draw object pointer. /* Return the next draw object pointer.
* If item is NULL return the first item of type in the list. * If item is NULL return the first item of type in the list.
...@@ -486,7 +486,7 @@ LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* aItem, KICAD_T aTy ...@@ -486,7 +486,7 @@ LIB_DRAW_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_DRAW_ITEM* aItem, KICAD_T aTy
} }
void LIB_COMPONENT::GetPins( LIB_PIN_LIST& aList, int aUnit, int aConvert ) void LIB_COMPONENT::GetPins( LIB_PINS& aList, int aUnit, int aConvert )
{ {
/* Notes: /* Notes:
* when aUnit == 0: no unit filtering * when aUnit == 0: no unit filtering
...@@ -494,7 +494,7 @@ void LIB_COMPONENT::GetPins( LIB_PIN_LIST& aList, int aUnit, int aConvert ) ...@@ -494,7 +494,7 @@ void LIB_COMPONENT::GetPins( LIB_PIN_LIST& aList, int aUnit, int aConvert )
* when .m_Unit == 0, the body item is common to units * when .m_Unit == 0, the body item is common to units
* when .m_Convert == 0, the body item is common to shapes * when .m_Convert == 0, the body item is common to shapes
*/ */
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
{ {
if( item.Type() != LIB_PIN_T ) // we search pins only if( item.Type() != LIB_PIN_T ) // we search pins only
continue; continue;
...@@ -515,7 +515,7 @@ void LIB_COMPONENT::GetPins( LIB_PIN_LIST& aList, int aUnit, int aConvert ) ...@@ -515,7 +515,7 @@ void LIB_COMPONENT::GetPins( LIB_PIN_LIST& aList, int aUnit, int aConvert )
LIB_PIN* LIB_COMPONENT::GetPin( const wxString& aNumber, int aUnit, int aConvert ) LIB_PIN* LIB_COMPONENT::GetPin( const wxString& aNumber, int aUnit, int aConvert )
{ {
wxString pNumber; wxString pNumber;
LIB_PIN_LIST pinList; LIB_PINS pinList;
GetPins( pinList, aUnit, aConvert ); GetPins( pinList, aUnit, aConvert );
...@@ -581,7 +581,7 @@ bool LIB_COMPONENT::Save( FILE* aFile ) ...@@ -581,7 +581,7 @@ bool LIB_COMPONENT::Save( FILE* aFile )
if( !SaveDateAndTime( aFile ) ) if( !SaveDateAndTime( aFile ) )
return false; return false;
LIB_FIELD_LIST fields; LIB_FIELDS fields;
GetFields( fields ); GetFields( fields );
// Fixed fields: // Fixed fields:
...@@ -657,7 +657,7 @@ bool LIB_COMPONENT::Save( FILE* aFile ) ...@@ -657,7 +657,7 @@ bool LIB_COMPONENT::Save( FILE* aFile )
if( fprintf( aFile, "DRAW\n" ) < 0 ) if( fprintf( aFile, "DRAW\n" ) < 0 )
return false; return false;
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
{ {
if( item.Type() == LIB_FIELD_T ) if( item.Type() == LIB_FIELD_T )
continue; continue;
...@@ -811,7 +811,7 @@ bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum, wxString& aEr ...@@ -811,7 +811,7 @@ bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum, wxString& aEr
bool LIB_COMPONENT::LoadDrawEntries( FILE* aFile, char* aLine, bool LIB_COMPONENT::LoadDrawEntries( FILE* aFile, char* aLine,
int* aLineNum, wxString& aErrorMsg ) int* aLineNum, wxString& aErrorMsg )
{ {
LIB_DRAW_ITEM* newEntry = NULL; LIB_ITEM* newEntry = NULL;
while( true ) while( true )
{ {
...@@ -829,31 +829,31 @@ bool LIB_COMPONENT::LoadDrawEntries( FILE* aFile, char* aLine, ...@@ -829,31 +829,31 @@ bool LIB_COMPONENT::LoadDrawEntries( FILE* aFile, char* aLine,
switch( aLine[0] ) switch( aLine[0] )
{ {
case 'A': /* Arc */ case 'A': /* Arc */
newEntry = ( LIB_DRAW_ITEM* ) new LIB_ARC(this); newEntry = ( LIB_ITEM* ) new LIB_ARC( this );
break; break;
case 'C': /* Circle */ case 'C': /* Circle */
newEntry = ( LIB_DRAW_ITEM* ) new LIB_CIRCLE(this); newEntry = ( LIB_ITEM* ) new LIB_CIRCLE( this );
break; break;
case 'T': /* Text */ case 'T': /* Text */
newEntry = ( LIB_DRAW_ITEM* ) new LIB_TEXT(this); newEntry = ( LIB_ITEM* ) new LIB_TEXT( this );
break; break;
case 'S': /* Square */ case 'S': /* Square */
newEntry = ( LIB_DRAW_ITEM* ) new LIB_RECTANGLE(this); newEntry = ( LIB_ITEM* ) new LIB_RECTANGLE( this );
break; break;
case 'X': /* Pin Description */ case 'X': /* Pin Description */
newEntry = ( LIB_DRAW_ITEM* ) new LIB_PIN(this); newEntry = ( LIB_ITEM* ) new LIB_PIN( this );
break; break;
case 'P': /* Polyline */ case 'P': /* Polyline */
newEntry = ( LIB_DRAW_ITEM* ) new LIB_POLYLINE(this); newEntry = ( LIB_ITEM* ) new LIB_POLYLINE( this );
break; break;
case 'B': /* Bezier Curves */ case 'B': /* Bezier Curves */
newEntry = ( LIB_DRAW_ITEM* ) new LIB_BEZIER(this); newEntry = ( LIB_ITEM* ) new LIB_BEZIER( this );
break; break;
default: default:
...@@ -970,7 +970,7 @@ EDA_RECT LIB_COMPONENT::GetBoundingBox( int aUnit, int aConvert ) const ...@@ -970,7 +970,7 @@ EDA_RECT LIB_COMPONENT::GetBoundingBox( int aUnit, int aConvert ) const
{ {
EDA_RECT bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); EDA_RECT bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
BOOST_FOREACH( const LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( const LIB_ITEM& item, drawings )
{ {
if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 ) if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
&& ( aUnit != item.m_Unit ) ) ) && ( aUnit != item.m_Unit ) ) )
...@@ -1000,7 +1000,7 @@ EDA_RECT LIB_COMPONENT::GetBodyBoundingBox( int aUnit, int aConvert ) const ...@@ -1000,7 +1000,7 @@ EDA_RECT LIB_COMPONENT::GetBodyBoundingBox( int aUnit, int aConvert ) const
{ {
EDA_RECT bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); EDA_RECT bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
BOOST_FOREACH( const LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( const LIB_ITEM& item, drawings )
{ {
if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 ) if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
&& ( aUnit != item.m_Unit ) ) ) && ( aUnit != item.m_Unit ) ) )
...@@ -1021,7 +1021,7 @@ EDA_RECT LIB_COMPONENT::GetBodyBoundingBox( int aUnit, int aConvert ) const ...@@ -1021,7 +1021,7 @@ EDA_RECT LIB_COMPONENT::GetBodyBoundingBox( int aUnit, int aConvert ) const
void LIB_COMPONENT::deleteAllFields() void LIB_COMPONENT::deleteAllFields()
{ {
LIB_DRAW_ITEM_LIST::iterator it; LIB_ITEMS::iterator it;
for( it = drawings.begin(); it!=drawings.end(); /* deleting */ ) for( it = drawings.begin(); it!=drawings.end(); /* deleting */ )
{ {
...@@ -1055,7 +1055,7 @@ void LIB_COMPONENT::SetFields( const std::vector <LIB_FIELD>& aFields ) ...@@ -1055,7 +1055,7 @@ void LIB_COMPONENT::SetFields( const std::vector <LIB_FIELD>& aFields )
} }
void LIB_COMPONENT::GetFields( LIB_FIELD_LIST& aList ) void LIB_COMPONENT::GetFields( LIB_FIELDS& aList )
{ {
LIB_FIELD* field; LIB_FIELD* field;
...@@ -1075,7 +1075,7 @@ void LIB_COMPONENT::GetFields( LIB_FIELD_LIST& aList ) ...@@ -1075,7 +1075,7 @@ void LIB_COMPONENT::GetFields( LIB_FIELD_LIST& aList )
} }
// Now grab all the rest of fields. // Now grab all the rest of fields.
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
{ {
if( item.Type() != LIB_FIELD_T ) if( item.Type() != LIB_FIELD_T )
continue; continue;
...@@ -1091,7 +1091,7 @@ void LIB_COMPONENT::GetFields( LIB_FIELD_LIST& aList ) ...@@ -1091,7 +1091,7 @@ void LIB_COMPONENT::GetFields( LIB_FIELD_LIST& aList )
LIB_FIELD* LIB_COMPONENT::GetField( int aId ) LIB_FIELD* LIB_COMPONENT::GetField( int aId )
{ {
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
{ {
if( item.Type() != LIB_FIELD_T ) if( item.Type() != LIB_FIELD_T )
continue; continue;
...@@ -1108,7 +1108,7 @@ LIB_FIELD* LIB_COMPONENT::GetField( int aId ) ...@@ -1108,7 +1108,7 @@ LIB_FIELD* LIB_COMPONENT::GetField( int aId )
LIB_FIELD* LIB_COMPONENT::FindField( const wxString& aFieldName ) LIB_FIELD* LIB_COMPONENT::FindField( const wxString& aFieldName )
{ {
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
{ {
if( item.Type() != LIB_FIELD_T ) if( item.Type() != LIB_FIELD_T )
continue; continue;
...@@ -1188,7 +1188,7 @@ bool LIB_COMPONENT::LoadDateAndTime( char* aLine ) ...@@ -1188,7 +1188,7 @@ bool LIB_COMPONENT::LoadDateAndTime( char* aLine )
void LIB_COMPONENT::SetOffset( const wxPoint& aOffset ) void LIB_COMPONENT::SetOffset( const wxPoint& aOffset )
{ {
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
{ {
item.SetOffset( aOffset ); item.SetOffset( aOffset );
} }
...@@ -1203,7 +1203,7 @@ void LIB_COMPONENT::RemoveDuplicateDrawItems() ...@@ -1203,7 +1203,7 @@ void LIB_COMPONENT::RemoveDuplicateDrawItems()
bool LIB_COMPONENT::HasConversion() const bool LIB_COMPONENT::HasConversion() const
{ {
BOOST_FOREACH( const LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( const LIB_ITEM& item, drawings )
{ {
if( item.m_Convert > 1 ) if( item.m_Convert > 1 )
return true; return true;
...@@ -1215,7 +1215,7 @@ bool LIB_COMPONENT::HasConversion() const ...@@ -1215,7 +1215,7 @@ bool LIB_COMPONENT::HasConversion() const
void LIB_COMPONENT::ClearStatus() void LIB_COMPONENT::ClearStatus()
{ {
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
item.m_Flags = 0; item.m_Flags = 0;
} }
...@@ -1224,7 +1224,7 @@ int LIB_COMPONENT::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool a ...@@ -1224,7 +1224,7 @@ int LIB_COMPONENT::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool a
{ {
int itemCount = 0; int itemCount = 0;
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
{ {
item.m_Selected = 0; item.m_Selected = 0;
...@@ -1253,7 +1253,7 @@ int LIB_COMPONENT::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool a ...@@ -1253,7 +1253,7 @@ int LIB_COMPONENT::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool a
void LIB_COMPONENT::MoveSelectedItems( const wxPoint& aOffset ) void LIB_COMPONENT::MoveSelectedItems( const wxPoint& aOffset )
{ {
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
{ {
if( item.m_Selected == 0 ) if( item.m_Selected == 0 )
continue; continue;
...@@ -1268,14 +1268,14 @@ void LIB_COMPONENT::MoveSelectedItems( const wxPoint& aOffset ) ...@@ -1268,14 +1268,14 @@ void LIB_COMPONENT::MoveSelectedItems( const wxPoint& aOffset )
void LIB_COMPONENT::ClearSelectedItems() void LIB_COMPONENT::ClearSelectedItems()
{ {
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
item.m_Flags = item.m_Selected = 0; item.m_Flags = item.m_Selected = 0;
} }
void LIB_COMPONENT::DeleteSelectedItems() void LIB_COMPONENT::DeleteSelectedItems()
{ {
LIB_DRAW_ITEM_LIST::iterator item = drawings.begin(); LIB_ITEMS::iterator item = drawings.begin();
// We *do not* remove the 2 mandatory fields: reference and value // We *do not* remove the 2 mandatory fields: reference and value
// so skip them (do not remove) if they are flagged selected. // so skip them (do not remove) if they are flagged selected.
...@@ -1312,7 +1312,7 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& aOffset ) ...@@ -1312,7 +1312,7 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& aOffset )
unsigned icnt = drawings.size(); unsigned icnt = drawings.size();
for( unsigned ii = 0; ii < icnt; ii++ ) for( unsigned ii = 0; ii < icnt; ii++ )
{ {
LIB_DRAW_ITEM& item = drawings[ii]; LIB_ITEM& item = drawings[ii];
// We *do not* copy fields because they are unique for the whole component // We *do not* copy fields because they are unique for the whole component
// so skip them (do not duplicate) if they are flagged selected. // so skip them (do not duplicate) if they are flagged selected.
if( item.Type() == LIB_FIELD_T ) if( item.Type() == LIB_FIELD_T )
...@@ -1322,7 +1322,7 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& aOffset ) ...@@ -1322,7 +1322,7 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& aOffset )
continue; continue;
item.m_Selected = 0; item.m_Selected = 0;
LIB_DRAW_ITEM* newItem = item.GenCopy(); LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
newItem->m_Selected = IS_SELECTED; newItem->m_Selected = IS_SELECTED;
drawings.push_back( newItem ); drawings.push_back( newItem );
} }
...@@ -1335,7 +1335,7 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& aOffset ) ...@@ -1335,7 +1335,7 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& aOffset )
void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& aCenter ) void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& aCenter )
{ {
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
{ {
if( item.m_Selected == 0 ) if( item.m_Selected == 0 )
continue; continue;
...@@ -1348,22 +1348,10 @@ void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& aCenter ) ...@@ -1348,22 +1348,10 @@ void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& aCenter )
} }
LIB_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert,
/**
* Locate a draw object.
*
* @param aUnit - Unit number of draw item.
* @param aConvert - Body style of draw item.
* @param aType - Draw object type, set to 0 to search for any type.
* @param aPoint - Coordinate for hit testing.
*
* @return LIB_DRAW_ITEM - Pointer the the draw object if found.
* Otherwise NULL.
*/
LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert,
KICAD_T aType, const wxPoint& aPoint ) KICAD_T aType, const wxPoint& aPoint )
{ {
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
{ {
if( ( aUnit && item.m_Unit && ( aUnit != item.m_Unit) ) if( ( aUnit && item.m_Unit && ( aUnit != item.m_Unit) )
|| ( aConvert && item.m_Convert && ( aConvert != item.m_Convert ) ) || ( aConvert && item.m_Convert && ( aConvert != item.m_Convert ) )
...@@ -1378,7 +1366,7 @@ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, ...@@ -1378,7 +1366,7 @@ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert,
} }
LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, LIB_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
const wxPoint& aPoint, const TRANSFORM& aTransform ) const wxPoint& aPoint, const TRANSFORM& aTransform )
{ {
/* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const /* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const
...@@ -1386,7 +1374,7 @@ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, KICAD_T a ...@@ -1386,7 +1374,7 @@ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, KICAD_T a
* because this function uses DefaultTransformMatrix as orient/mirror matrix * because this function uses DefaultTransformMatrix as orient/mirror matrix
* we temporary copy aTransMat in DefaultTransformMatrix * we temporary copy aTransMat in DefaultTransformMatrix
*/ */
LIB_DRAW_ITEM* item; LIB_ITEM* item;
TRANSFORM transform = DefaultTransform; TRANSFORM transform = DefaultTransform;
DefaultTransform = aTransform; DefaultTransform = aTransform;
...@@ -1406,7 +1394,7 @@ void LIB_COMPONENT::SetPartCount( int aCount ) ...@@ -1406,7 +1394,7 @@ void LIB_COMPONENT::SetPartCount( int aCount )
if( aCount < m_unitCount ) if( aCount < m_unitCount )
{ {
LIB_DRAW_ITEM_LIST::iterator i; LIB_ITEMS::iterator i;
i = drawings.begin(); i = drawings.begin();
while( i != drawings.end() ) while( i != drawings.end() )
...@@ -1432,7 +1420,7 @@ void LIB_COMPONENT::SetPartCount( int aCount ) ...@@ -1432,7 +1420,7 @@ void LIB_COMPONENT::SetPartCount( int aCount )
for( int j = prevCount + 1; j <= aCount; j++ ) for( int j = prevCount + 1; j <= aCount; j++ )
{ {
LIB_DRAW_ITEM* newItem = drawings[ii].GenCopy(); LIB_ITEM* newItem = (LIB_ITEM*) drawings[ii].Clone();
newItem->m_Unit = j; newItem->m_Unit = j;
drawings.push_back( newItem ); drawings.push_back( newItem );
} }
...@@ -1454,14 +1442,14 @@ void LIB_COMPONENT::SetConversion( bool aSetConvert ) ...@@ -1454,14 +1442,14 @@ void LIB_COMPONENT::SetConversion( bool aSetConvert )
if( aSetConvert ) if( aSetConvert )
{ {
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawings ) BOOST_FOREACH( LIB_ITEM& item, drawings )
{ {
/* Only pins are duplicated. */ /* Only pins are duplicated. */
if( item.Type() != LIB_PIN_T ) if( item.Type() != LIB_PIN_T )
continue; continue;
if( item.m_Convert == 1 ) if( item.m_Convert == 1 )
{ {
LIB_DRAW_ITEM* newItem = item.GenCopy(); LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
newItem->m_Convert = 2; newItem->m_Convert = 2;
drawings.push_back( newItem ); drawings.push_back( newItem );
} }
...@@ -1471,7 +1459,7 @@ void LIB_COMPONENT::SetConversion( bool aSetConvert ) ...@@ -1471,7 +1459,7 @@ void LIB_COMPONENT::SetConversion( bool aSetConvert )
{ {
// Delete converted shape items because the converted shape does // Delete converted shape items because the converted shape does
// not exist // not exist
LIB_DRAW_ITEM_LIST::iterator i = drawings.begin(); LIB_ITEMS::iterator i = drawings.begin();
while( i != drawings.end() ) while( i != drawings.end() )
{ {
...@@ -1488,7 +1476,7 @@ wxArrayString LIB_COMPONENT::GetAliasNames( bool aIncludeRoot ) const ...@@ -1488,7 +1476,7 @@ wxArrayString LIB_COMPONENT::GetAliasNames( bool aIncludeRoot ) const
{ {
wxArrayString names; wxArrayString names;
LIB_ALIAS_LIST::const_iterator it; LIB_ALIASES::const_iterator it;
for( it=m_aliases.begin(); it<m_aliases.end(); ++it ) for( it=m_aliases.begin(); it<m_aliases.end(); ++it )
{ {
...@@ -1535,7 +1523,7 @@ void LIB_COMPONENT::SetAliases( const wxArrayString& aAliasList ) ...@@ -1535,7 +1523,7 @@ void LIB_COMPONENT::SetAliases( const wxArrayString& aAliasList )
} }
/* Remove names in the current component that are not in the new alias list. */ /* Remove names in the current component that are not in the new alias list. */
LIB_ALIAS_LIST::iterator it; LIB_ALIASES::iterator it;
for( it = m_aliases.begin(); it < m_aliases.end(); it++ ) for( it = m_aliases.begin(); it < m_aliases.end(); it++ )
{ {
...@@ -1555,7 +1543,7 @@ void LIB_COMPONENT::RemoveAlias( const wxString& aName ) ...@@ -1555,7 +1543,7 @@ void LIB_COMPONENT::RemoveAlias( const wxString& aName )
wxT( "Component aliases cannot be changed when they are owned by a library." ) ); wxT( "Component aliases cannot be changed when they are owned by a library." ) );
wxCHECK_RET( !aName.IsEmpty(), wxT( "Cannot get alias with an empty name." ) ); wxCHECK_RET( !aName.IsEmpty(), wxT( "Cannot get alias with an empty name." ) );
LIB_ALIAS_LIST::iterator it; LIB_ALIASES::iterator it;
for( it = m_aliases.begin(); it < m_aliases.end(); it++ ) for( it = m_aliases.begin(); it < m_aliases.end(); it++ )
{ {
...@@ -1573,7 +1561,7 @@ LIB_ALIAS* LIB_COMPONENT::RemoveAlias( LIB_ALIAS* aAlias ) ...@@ -1573,7 +1561,7 @@ LIB_ALIAS* LIB_COMPONENT::RemoveAlias( LIB_ALIAS* aAlias )
wxCHECK_MSG( aAlias != NULL, NULL, wxT( "Cannot remove alias by NULL pointer." ) ); wxCHECK_MSG( aAlias != NULL, NULL, wxT( "Cannot remove alias by NULL pointer." ) );
LIB_ALIAS* nextAlias = NULL; LIB_ALIAS* nextAlias = NULL;
LIB_ALIAS_LIST::iterator it = find( m_aliases.begin(), m_aliases.end(), aAlias ); LIB_ALIASES::iterator it = find( m_aliases.begin(), m_aliases.end(), aAlias );
if( it != m_aliases.end() ) if( it != m_aliases.end() )
{ {
......
...@@ -32,7 +32,7 @@ struct AliasMapSort ...@@ -32,7 +32,7 @@ struct AliasMapSort
*/ */
typedef std::map< wxString, LIB_ALIAS*, AliasMapSort > LIB_ALIAS_MAP; typedef std::map< wxString, LIB_ALIAS*, AliasMapSort > LIB_ALIAS_MAP;
typedef std::vector< LIB_ALIAS* > LIB_ALIAS_LIST; typedef std::vector< LIB_ALIAS* > LIB_ALIASES;
/* values for member .m_options */ /* values for member .m_options */
enum LibrEntryOptions enum LibrEntryOptions
...@@ -161,10 +161,10 @@ class LIB_COMPONENT : public EDA_ITEM ...@@ -161,10 +161,10 @@ class LIB_COMPONENT : public EDA_ITEM
long m_dateModified; ///< Date the component was last modified. long m_dateModified; ///< Date the component was last modified.
LibrEntryOptions m_options; ///< Special component features such as POWER or NORMAL.) LibrEntryOptions m_options; ///< Special component features such as POWER or NORMAL.)
int m_unitCount; ///< Number of units (parts) per package. int m_unitCount; ///< Number of units (parts) per package.
LIB_DRAW_ITEM_LIST drawings; ///< How to draw this part. LIB_ITEMS drawings; ///< How to draw this part.
wxArrayString m_FootprintList; /**< List of suitable footprint names for the wxArrayString m_FootprintList; /**< List of suitable footprint names for the
component (wild card names accepted). */ component (wild card names accepted). */
LIB_ALIAS_LIST m_aliases; ///< List of alias object pointers associated with the LIB_ALIASES m_aliases; ///< List of alias object pointers associated with the
///< component. ///< component.
CMP_LIBRARY* m_library; ///< Library the component belongs to if any. CMP_LIBRARY* m_library; ///< Library the component belongs to if any.
...@@ -308,7 +308,7 @@ public: ...@@ -308,7 +308,7 @@ public:
* *
* @param aList - List to add fields to * @param aList - List to add fields to
*/ */
void GetFields( LIB_FIELD_LIST& aList ); void GetFields( LIB_FIELDS& aList );
/** /**
* Function FindField * Function FindField
...@@ -373,7 +373,7 @@ public: ...@@ -373,7 +373,7 @@ public:
* *
* @param aItem - New draw object to add to component. * @param aItem - New draw object to add to component.
*/ */
void AddDrawItem( LIB_DRAW_ITEM* aItem ); void AddDrawItem( LIB_ITEM* aItem );
/** /**
* Remove draw \a aItem from list. * Remove draw \a aItem from list.
...@@ -382,7 +382,7 @@ public: ...@@ -382,7 +382,7 @@ public:
* @param aPanel - Panel to remove part from. * @param aPanel - Panel to remove part from.
* @param aDc - Device context to remove part from. * @param aDc - Device context to remove part from.
*/ */
void RemoveDrawItem( LIB_DRAW_ITEM* aItem, EDA_DRAW_PANEL* aPanel = NULL, wxDC* aDc = NULL ); void RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel = NULL, wxDC* aDc = NULL );
/** /**
* Return the next draw object pointer. * Return the next draw object pointer.
...@@ -393,7 +393,7 @@ public: ...@@ -393,7 +393,7 @@ public:
* if TYPE_NOT_INIT search for all items types * if TYPE_NOT_INIT search for all items types
* @return - The next drawing object in the list if found, otherwise NULL. * @return - The next drawing object in the list if found, otherwise NULL.
*/ */
LIB_DRAW_ITEM* GetNextDrawItem( LIB_DRAW_ITEM* aItem = NULL, KICAD_T aType = TYPE_NOT_INIT ); LIB_ITEM* GetNextDrawItem( LIB_ITEM* aItem = NULL, KICAD_T aType = TYPE_NOT_INIT );
/** /**
* Return the next pin object from the draw list. * Return the next pin object from the draw list.
...@@ -406,7 +406,7 @@ public: ...@@ -406,7 +406,7 @@ public:
*/ */
LIB_PIN* GetNextPin( LIB_PIN* aItem = NULL ) LIB_PIN* GetNextPin( LIB_PIN* aItem = NULL )
{ {
return (LIB_PIN*) GetNextDrawItem( (LIB_DRAW_ITEM*) aItem, LIB_PIN_T ); return (LIB_PIN*) GetNextDrawItem( (LIB_ITEM*) aItem, LIB_PIN_T );
} }
...@@ -423,7 +423,7 @@ public: ...@@ -423,7 +423,7 @@ public:
* @param aConvert - Convert number of pin to add to list. Set to 0 to * @param aConvert - Convert number of pin to add to list. Set to 0 to
* get pins from any convert of component. * get pins from any convert of component.
*/ */
void GetPins( LIB_PIN_LIST& aList, int aUnit = 0, int aConvert = 0 ); void GetPins( LIB_PINS& aList, int aUnit = 0, int aConvert = 0 );
/** /**
* Return pin object with the requested pin \a aNumber. * Return pin object with the requested pin \a aNumber.
...@@ -521,7 +521,7 @@ public: ...@@ -521,7 +521,7 @@ public:
* @param aPoint - Coordinate for hit testing. * @param aPoint - Coordinate for hit testing.
* @return The draw object if found. Otherwise NULL. * @return The draw object if found. Otherwise NULL.
*/ */
LIB_DRAW_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, const wxPoint& aPoint ); LIB_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, const wxPoint& aPoint );
/** /**
* Locate a draw object (overlaid) * Locate a draw object (overlaid)
...@@ -533,15 +533,15 @@ public: ...@@ -533,15 +533,15 @@ public:
* @param aTransform = the transform matrix * @param aTransform = the transform matrix
* @return The draw object if found. Otherwise NULL. * @return The draw object if found. Otherwise NULL.
*/ */
LIB_DRAW_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, LIB_ITEM* LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
const wxPoint& aPoint, const TRANSFORM& aTransform ); const wxPoint& aPoint, const TRANSFORM& aTransform );
/** /**
* Return a reference to the draw item list. * Return a reference to the draw item list.
* *
* @return LIB_DRAW_ITEM_LIST& - Reference to the draw item object list. * @return LIB_ITEMS& - Reference to the draw item object list.
*/ */
LIB_DRAW_ITEM_LIST& GetDrawItemList() { return drawings; } LIB_ITEMS& GetDrawItemList() { return drawings; }
/** /**
* Set the part per package count. * Set the part per package count.
......
...@@ -142,7 +142,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aF ...@@ -142,7 +142,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aF
{ {
wxString text = m_collectedItems[i]->GetSelectMenuText(); wxString text = m_collectedItems[i]->GetSelectMenuText();
const char** xpm = m_collectedItems[i]->GetMenuImage(); const char** xpm = m_collectedItems[i]->GetMenuImage();
ADD_MENUITEM( &selectMenu, ID_SCH_SELECT_ITEM_START + i, text, xpm ); ADD_MENUITEM( &selectMenu, ID_SELECT_ITEM_START + i, text, xpm );
} }
// Set to NULL in case user aborts the clarification context menu. // Set to NULL in case user aborts the clarification context menu.
...@@ -220,7 +220,7 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -220,7 +220,7 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
if( DrawPanel->IsMouseCaptured() ) if( DrawPanel->IsMouseCaptured() )
{ {
DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, TRUE ); DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, true );
} }
} }
...@@ -293,15 +293,12 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -293,15 +293,12 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
if( DrawPanel->IsMouseCaptured() ) if( DrawPanel->IsMouseCaptured() )
{ {
DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, TRUE ); DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, true );
} }
} }
if( aHotKey ) if( aHotKey )
{ {
if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
else
OnHotKey( aDC, aHotKey, aPosition, NULL ); OnHotKey( aDC, aHotKey, aPosition, NULL );
} }
...@@ -366,7 +363,7 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -366,7 +363,7 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
if( DrawPanel->IsMouseCaptured() ) if( DrawPanel->IsMouseCaptured() )
{ {
DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, TRUE ); DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, aPosition, true );
} }
} }
......
...@@ -416,7 +416,7 @@ int DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::getSelectedFieldNdx() ...@@ -416,7 +416,7 @@ int DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::getSelectedFieldNdx()
* Function findfield * Function findfield
* searches a LIB_FIELD_LIST for aFieldName. * searches a LIB_FIELD_LIST for aFieldName.
*/ */
static LIB_FIELD* findfield( const LIB_FIELD_LIST& aList, const wxString& aFieldName ) static LIB_FIELD* findfield( const LIB_FIELDS& aList, const wxString& aFieldName )
{ {
const LIB_FIELD* field = NULL; const LIB_FIELD* field = NULL;
...@@ -447,7 +447,7 @@ LIB_FIELD* DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::findField( const wxString& aField ...@@ -447,7 +447,7 @@ LIB_FIELD* DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::findField( const wxString& aField
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::InitBuffers() void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::InitBuffers()
/***********************************************************/ /***********************************************************/
{ {
LIB_FIELD_LIST cmpFields; LIB_FIELDS cmpFields;
m_LibEntry->GetFields( cmpFields ); m_LibEntry->GetFields( cmpFields );
......
...@@ -145,8 +145,8 @@ enum id_eeschema_frm ...@@ -145,8 +145,8 @@ enum id_eeschema_frm
ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE,
ID_POPUP_SCH_ORIENT_NORMAL_CMP, ID_POPUP_SCH_ORIENT_NORMAL_CMP,
ID_SCH_SELECT_ITEM_START, ID_SELECT_ITEM_START,
ID_SCH_SELECT_ITEM_END = ID_SCH_SELECT_ITEM_START + MAX_SELECT_ITEM_IDS, ID_SELECT_ITEM_END = ID_SELECT_ITEM_START + MAX_SELECT_ITEM_IDS,
ID_POPUP_SCH_MOVE_ITEM, ID_POPUP_SCH_MOVE_ITEM,
......
...@@ -844,11 +844,10 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -844,11 +844,10 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
return; return;
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
wxCommandEvent toolCmd( wxEVT_COMMAND_TOOL_CLICKED );
cmd.SetEventObject( this ); cmd.SetEventObject( this );
bool itemInEdit = GetScreen()->GetCurItem() && GetScreen()->GetCurItem()->GetFlags(); bool itemInEdit = m_drawItem && m_drawItem->GetFlags();
/* Convert lower to upper case (the usual toupper function has problem /* Convert lower to upper case (the usual toupper function has problem
* with non ascii codes like function keys */ * with non ascii codes like function keys */
...@@ -905,16 +904,16 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -905,16 +904,16 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_UNDO: case HK_UNDO:
if( !itemInEdit ) if( !itemInEdit )
{ {
toolCmd.SetId( wxID_UNDO ); cmd.SetId( wxID_UNDO );
GetEventHandler()->ProcessEvent( toolCmd ); GetEventHandler()->ProcessEvent( cmd );
} }
break; break;
case HK_REDO: case HK_REDO:
if( !itemInEdit ) if( !itemInEdit )
{ {
toolCmd.SetId( wxID_REDO ); cmd.SetId( wxID_REDO );
GetEventHandler()->ProcessEvent( toolCmd ); GetEventHandler()->ProcessEvent( cmd );
} }
break; break;
...@@ -979,9 +978,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -979,9 +978,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
if( m_drawItem && !m_drawItem->InEditMode() ) if( m_drawItem && !m_drawItem->InEditMode() )
{ {
wxCommandEvent evt; cmd.SetId( ID_POPUP_LIBEDIT_DELETE_ITEM );
evt.SetId( ID_POPUP_LIBEDIT_DELETE_ITEM ); Process_Special_Functions( cmd );
Process_Special_Functions( evt );
} }
break; break;
...@@ -992,9 +990,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -992,9 +990,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
if( m_drawItem ) if( m_drawItem )
{ {
wxCommandEvent evt; cmd.SetId( ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST );
evt.SetId( ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST ); Process_Special_Functions( cmd );
Process_Special_Functions( evt );
} }
} }
break; break;
...@@ -1004,9 +1001,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -1004,9 +1001,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
if( m_drawItem && !m_drawItem->InEditMode() ) if( m_drawItem && !m_drawItem->InEditMode() )
{ {
wxCommandEvent evt; cmd.SetId( ID_POPUP_LIBEDIT_MODIFY_ITEM );
evt.SetId( ID_POPUP_LIBEDIT_MODIFY_ITEM ); Process_Special_Functions( cmd );
Process_Special_Functions( evt );
} }
break; break;
} }
......
...@@ -53,7 +53,7 @@ static wxPoint calcCenter( const wxPoint& A, const wxPoint& B, const wxPoint& C ...@@ -53,7 +53,7 @@ static wxPoint calcCenter( const wxPoint& A, const wxPoint& B, const wxPoint& C
} }
LIB_ARC::LIB_ARC( LIB_COMPONENT* aParent ) : LIB_DRAW_ITEM( LIB_ARC_T, aParent ) LIB_ARC::LIB_ARC( LIB_COMPONENT* aParent ) : LIB_ITEM( LIB_ARC_T, aParent )
{ {
m_Radius = 0; m_Radius = 0;
m_t1 = 0; m_t1 = 0;
...@@ -67,7 +67,7 @@ LIB_ARC::LIB_ARC( LIB_COMPONENT* aParent ) : LIB_DRAW_ITEM( LIB_ARC_T, aParent ) ...@@ -67,7 +67,7 @@ LIB_ARC::LIB_ARC( LIB_COMPONENT* aParent ) : LIB_DRAW_ITEM( LIB_ARC_T, aParent )
} }
LIB_ARC::LIB_ARC( const LIB_ARC& aArc ) : LIB_DRAW_ITEM( aArc ) LIB_ARC::LIB_ARC( const LIB_ARC& aArc ) : LIB_ITEM( aArc )
{ {
m_Radius = aArc.m_Radius; m_Radius = aArc.m_Radius;
m_t1 = aArc.m_t1; m_t1 = aArc.m_t1;
...@@ -211,27 +211,13 @@ bool LIB_ARC::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTran ...@@ -211,27 +211,13 @@ bool LIB_ARC::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTran
} }
LIB_DRAW_ITEM* LIB_ARC::DoGenCopy() EDA_ITEM* LIB_ARC::doClone() const
{ {
LIB_ARC* newitem = new LIB_ARC( GetParent() ); return new LIB_ARC( *this );
newitem->m_Pos = m_Pos;
newitem->m_ArcStart = m_ArcStart;
newitem->m_ArcEnd = m_ArcEnd;
newitem->m_Radius = m_Radius;
newitem->m_t1 = m_t1;
newitem->m_t2 = m_t2;
newitem->m_Width = m_Width;
newitem->m_Unit = m_Unit;
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill;
return (LIB_DRAW_ITEM*) newitem;
} }
int LIB_ARC::DoCompare( const LIB_DRAW_ITEM& aOther ) const int LIB_ARC::DoCompare( const LIB_ITEM& aOther ) const
{ {
wxASSERT( aOther.Type() == LIB_ARC_T ); wxASSERT( aOther.Type() == LIB_ARC_T );
...@@ -479,7 +465,7 @@ void LIB_ARC::DisplayInfo( EDA_DRAW_FRAME* aFrame ) ...@@ -479,7 +465,7 @@ void LIB_ARC::DisplayInfo( EDA_DRAW_FRAME* aFrame )
wxString msg; wxString msg;
EDA_RECT bBox = GetBoundingBox(); EDA_RECT bBox = GetBoundingBox();
LIB_DRAW_ITEM::DisplayInfo( aFrame ); LIB_ITEM::DisplayInfo( aFrame );
msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true ); msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true );
...@@ -492,6 +478,15 @@ void LIB_ARC::DisplayInfo( EDA_DRAW_FRAME* aFrame ) ...@@ -492,6 +478,15 @@ void LIB_ARC::DisplayInfo( EDA_DRAW_FRAME* aFrame )
} }
wxString LIB_ARC::GetSelectMenuText() const
{
return wxString::Format( _( "Arc center (%s, %s), radius %s" ),
GetChars( CoordinateToString( m_Pos.x, EESCHEMA_INTERNAL_UNIT ) ),
GetChars( CoordinateToString( m_Pos.y, EESCHEMA_INTERNAL_UNIT ) ),
GetChars( CoordinateToString( m_Radius, EESCHEMA_INTERNAL_UNIT ) ) );
}
void LIB_ARC::BeginEdit( int aEditMode, const wxPoint aPosition ) void LIB_ARC::BeginEdit( int aEditMode, const wxPoint aPosition )
{ {
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0, wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
class TRANSFORM; class TRANSFORM;
class LIB_ARC : public LIB_DRAW_ITEM class LIB_ARC : public LIB_ITEM
{ {
enum SELECT_T enum SELECT_T
{ {
...@@ -105,22 +105,26 @@ public: ...@@ -105,22 +105,26 @@ public:
virtual int GetPenSize( ) const; virtual int GetPenSize( ) const;
/** /**
* See LIB_DRAW_ITEM::BeginEdit(). * See LIB_ITEM::BeginEdit().
*/ */
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ); void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
/** /**
* See LIB_DRAW_ITEM::ContinueEdit(). * See LIB_ITEM::ContinueEdit().
*/ */
bool ContinueEdit( const wxPoint aNextPoint ); bool ContinueEdit( const wxPoint aNextPoint );
/** /**
* See LIB_DRAW_ITEM::AbortEdit(). * See LIB_ITEM::AbortEdit().
*/ */
void EndEdit( const wxPoint& aPosition, bool aAbort = false ); void EndEdit( const wxPoint& aPosition, bool aAbort = false );
virtual wxString GetSelectMenuText() const;
virtual const char** GetMenuImage() const { return (const char**) add_arc_xpm; }
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual EDA_ITEM* doClone() const;
/** /**
* Provide the arc draw object specific comparison. * Provide the arc draw object specific comparison.
...@@ -131,7 +135,7 @@ protected: ...@@ -131,7 +135,7 @@ protected:
* - Arc start angle. * - Arc start angle.
* - Arc end angle. * - Arc end angle.
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const; virtual bool DoTestInside( EDA_RECT& aRect ) const;
virtual void DoMove( const wxPoint& aPosition ); virtual void DoMove( const wxPoint& aPosition );
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
LIB_BEZIER::LIB_BEZIER( LIB_COMPONENT* aParent ) : LIB_BEZIER::LIB_BEZIER( LIB_COMPONENT* aParent ) :
LIB_DRAW_ITEM( LIB_BEZIER_T, aParent ) LIB_ITEM( LIB_BEZIER_T, aParent )
{ {
m_Fill = NO_FILL; m_Fill = NO_FILL;
m_Width = 0; m_Width = 0;
...@@ -28,7 +28,7 @@ LIB_BEZIER::LIB_BEZIER( LIB_COMPONENT* aParent ) : ...@@ -28,7 +28,7 @@ LIB_BEZIER::LIB_BEZIER( LIB_COMPONENT* aParent ) :
} }
LIB_BEZIER::LIB_BEZIER( const LIB_BEZIER& aBezier ) : LIB_DRAW_ITEM( aBezier ) LIB_BEZIER::LIB_BEZIER( const LIB_BEZIER& aBezier ) : LIB_ITEM( aBezier )
{ {
m_PolyPoints = aBezier.m_PolyPoints; m_PolyPoints = aBezier.m_PolyPoints;
m_BezierPoints = aBezier.m_BezierPoints; // Vector copy m_BezierPoints = aBezier.m_BezierPoints; // Vector copy
...@@ -113,21 +113,13 @@ bool LIB_BEZIER::Load( char* aLine, wxString& aErrorMsg ) ...@@ -113,21 +113,13 @@ bool LIB_BEZIER::Load( char* aLine, wxString& aErrorMsg )
} }
LIB_DRAW_ITEM* LIB_BEZIER::DoGenCopy() EDA_ITEM* LIB_BEZIER::doClone() const
{ {
LIB_BEZIER* newitem = new LIB_BEZIER(GetParent()); return new LIB_BEZIER( *this );
newitem->m_BezierPoints = m_BezierPoints; // Vector copy
newitem->m_Width = m_Width;
newitem->m_Unit = m_Unit;
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill;
return (LIB_DRAW_ITEM*) newitem;
} }
int LIB_BEZIER::DoCompare( const LIB_DRAW_ITEM& aOther ) const int LIB_BEZIER::DoCompare( const LIB_ITEM& aOther ) const
{ {
wxASSERT( aOther.Type() == LIB_BEZIER_T ); wxASSERT( aOther.Type() == LIB_BEZIER_T );
...@@ -366,7 +358,7 @@ void LIB_BEZIER::DisplayInfo( EDA_DRAW_FRAME* aFrame ) ...@@ -366,7 +358,7 @@ void LIB_BEZIER::DisplayInfo( EDA_DRAW_FRAME* aFrame )
wxString msg; wxString msg;
EDA_RECT bBox = GetBoundingBox(); EDA_RECT bBox = GetBoundingBox();
LIB_DRAW_ITEM::DisplayInfo( aFrame ); LIB_ITEM::DisplayInfo( aFrame );
msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true ); msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true );
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
/**************************************************/ /**************************************************/
/* Graphic Body Item: Bezier Curve (set of lines) */ /* Graphic Body Item: Bezier Curve (set of lines) */
/**************************************************/ /**************************************************/
class LIB_BEZIER : public LIB_DRAW_ITEM class LIB_BEZIER : public LIB_ITEM
{ {
int m_Width; // Line width int m_Width; // Line width
std::vector<wxPoint> m_BezierPoints; // list of parameter (3|4) std::vector<wxPoint> m_BezierPoints; // list of parameter (3|4)
...@@ -77,7 +77,7 @@ public: ...@@ -77,7 +77,7 @@ public:
virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame ); virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame );
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual EDA_ITEM* doClone() const;
/** /**
* Provide the bezier curve draw object specific comparison. * Provide the bezier curve draw object specific comparison.
...@@ -86,7 +86,7 @@ protected: ...@@ -86,7 +86,7 @@ protected:
* - Bezier point horizontal (X) point position. * - Bezier point horizontal (X) point position.
* - Bezier point vertical (Y) point position. * - Bezier point vertical (Y) point position.
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const; virtual bool DoTestInside( EDA_RECT& aRect ) const;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "macros.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "plot_common.h" #include "plot_common.h"
#include "trigo.h" #include "trigo.h"
...@@ -17,7 +18,7 @@ ...@@ -17,7 +18,7 @@
LIB_CIRCLE::LIB_CIRCLE( LIB_COMPONENT* aParent ) : LIB_CIRCLE::LIB_CIRCLE( LIB_COMPONENT* aParent ) :
LIB_DRAW_ITEM( LIB_CIRCLE_T, aParent ) LIB_ITEM( LIB_CIRCLE_T, aParent )
{ {
m_Radius = 0; m_Radius = 0;
m_Fill = NO_FILL; m_Fill = NO_FILL;
...@@ -27,7 +28,7 @@ LIB_CIRCLE::LIB_CIRCLE( LIB_COMPONENT* aParent ) : ...@@ -27,7 +28,7 @@ LIB_CIRCLE::LIB_CIRCLE( LIB_COMPONENT* aParent ) :
LIB_CIRCLE::LIB_CIRCLE( const LIB_CIRCLE& aCircle ) : LIB_CIRCLE::LIB_CIRCLE( const LIB_CIRCLE& aCircle ) :
LIB_DRAW_ITEM( aCircle ) LIB_ITEM( aCircle )
{ {
m_Pos = aCircle.m_Pos; m_Pos = aCircle.m_Pos;
m_Radius = aCircle.m_Radius; m_Radius = aCircle.m_Radius;
...@@ -105,23 +106,13 @@ bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTra ...@@ -105,23 +106,13 @@ bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTra
} }
LIB_DRAW_ITEM* LIB_CIRCLE::DoGenCopy() EDA_ITEM* LIB_CIRCLE::doClone() const
{ {
LIB_CIRCLE* newitem = new LIB_CIRCLE( GetParent() ); return new LIB_CIRCLE( *this );
newitem->m_Pos = m_Pos;
newitem->m_Radius = m_Radius;
newitem->m_Width = m_Width;
newitem->m_Unit = m_Unit;
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill;
return (LIB_DRAW_ITEM*) newitem;
} }
int LIB_CIRCLE::DoCompare( const LIB_DRAW_ITEM& aOther ) const int LIB_CIRCLE::DoCompare( const LIB_ITEM& aOther ) const
{ {
wxASSERT( aOther.Type() == LIB_CIRCLE_T ); wxASSERT( aOther.Type() == LIB_CIRCLE_T );
...@@ -255,7 +246,7 @@ void LIB_CIRCLE::DisplayInfo( EDA_DRAW_FRAME* aFrame ) ...@@ -255,7 +246,7 @@ void LIB_CIRCLE::DisplayInfo( EDA_DRAW_FRAME* aFrame )
wxString msg; wxString msg;
EDA_RECT bBox = GetBoundingBox(); EDA_RECT bBox = GetBoundingBox();
LIB_DRAW_ITEM::DisplayInfo( aFrame ); LIB_ITEM::DisplayInfo( aFrame );
msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true ); msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true );
...@@ -271,6 +262,15 @@ void LIB_CIRCLE::DisplayInfo( EDA_DRAW_FRAME* aFrame ) ...@@ -271,6 +262,15 @@ void LIB_CIRCLE::DisplayInfo( EDA_DRAW_FRAME* aFrame )
} }
wxString LIB_CIRCLE::GetSelectMenuText() const
{
return wxString::Format( _( "Circle center (%s, %s), radius %s" ),
GetChars( CoordinateToString( m_Pos.x, EESCHEMA_INTERNAL_UNIT ) ),
GetChars( CoordinateToString( m_Pos.y, EESCHEMA_INTERNAL_UNIT ) ),
GetChars( CoordinateToString( m_Radius, EESCHEMA_INTERNAL_UNIT ) ) );
}
void LIB_CIRCLE::BeginEdit( int aEditMode, const wxPoint aPosition ) void LIB_CIRCLE::BeginEdit( int aEditMode, const wxPoint aPosition )
{ {
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0, wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "lib_draw_item.h" #include "lib_draw_item.h"
class LIB_CIRCLE : public LIB_DRAW_ITEM class LIB_CIRCLE : public LIB_ITEM
{ {
int m_Radius; int m_Radius;
wxPoint m_Pos; // Position or centre (Arc and Circle) or start point (segments). wxPoint m_Pos; // Position or centre (Arc and Circle) or start point (segments).
...@@ -73,22 +73,26 @@ public: ...@@ -73,22 +73,26 @@ public:
virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame ); virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame );
/** /**
* See LIB_DRAW_ITEM::BeginEdit(). * See LIB_ITEM::BeginEdit().
*/ */
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ); void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
/** /**
* See LIB_DRAW_ITEM::ContinueEdit(). * See LIB_ITEM::ContinueEdit().
*/ */
bool ContinueEdit( const wxPoint aNextPoint ); bool ContinueEdit( const wxPoint aNextPoint );
/** /**
* See LIB_DRAW_ITEM::AbortEdit(). * See LIB_ITEM::AbortEdit().
*/ */
void EndEdit( const wxPoint& aPosition, bool aAbort = false ); void EndEdit( const wxPoint& aPosition, bool aAbort = false );
virtual wxString GetSelectMenuText() const;
virtual const char** GetMenuImage() const { return (const char**) add_circle_xpm; }
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual EDA_ITEM* doClone() const;
/** /**
* Provide the circle draw object specific comparison. * Provide the circle draw object specific comparison.
...@@ -98,7 +102,7 @@ protected: ...@@ -98,7 +102,7 @@ protected:
* - Circle vertical (Y) position. * - Circle vertical (Y) position.
* - Circle radius. * - Circle radius.
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const; virtual bool DoTestInside( EDA_RECT& aRect ) const;
......
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "macros.h"
#include "general.h"
#include "transform.h"
#include "lib_collectors.h"
const KICAD_T LIB_COLLECTOR::AllItems[] = {
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_TEXT_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_BEZIER_T,
LIB_PIN_T,
LIB_FIELD_T,
EOT
};
const KICAD_T LIB_COLLECTOR::AllItemsButPins[] = {
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_TEXT_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_BEZIER_T,
LIB_FIELD_T,
EOT
};
const KICAD_T LIB_COLLECTOR::EditableItems[] = {
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_TEXT_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_BEZIER_T,
LIB_PIN_T,
LIB_FIELD_T,
EOT
};
const KICAD_T LIB_COLLECTOR::MovableItems[] = {
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_TEXT_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_BEZIER_T,
LIB_PIN_T,
LIB_FIELD_T,
EOT
};
const KICAD_T LIB_COLLECTOR::RotatableItems[] = {
LIB_ARC_T,
LIB_CIRCLE_T,
LIB_TEXT_T,
LIB_RECTANGLE_T,
LIB_POLYLINE_T,
LIB_BEZIER_T,
LIB_PIN_T,
LIB_FIELD_T,
EOT
};
SEARCH_RESULT LIB_COLLECTOR::Inspect( EDA_ITEM* aItem, const void* aTestData )
{
LIB_ITEM* item = (LIB_ITEM*) aItem;
wxLogDebug( wxT( "Inspecting item %s, unit %d, convert %d" ),
GetChars( item->GetSelectMenuText() ), item->GetUnit(), item->GetConvert() );
if( ( m_data.m_unit && item->GetUnit() && ( m_data.m_unit != item->GetUnit() ) )
|| ( m_data.m_convert && item->GetConvert() && ( m_data.m_convert != item->GetConvert() ) )
|| !item->HitTest( m_RefPos, 2, DefaultTransform ) )
return SEARCH_CONTINUE;
Append( aItem );
return SEARCH_CONTINUE;
}
void LIB_COLLECTOR::Collect( LIB_ITEMS& aItems, const KICAD_T aFilterList[],
const wxPoint& aPosition, int aUnit, int aConvert )
{
Empty(); // empty the collection just in case
SetScanTypes( aFilterList );
// remember where the snapshot was taken from and pass refPos to the Inspect() function.
SetRefPos( aPosition );
m_data.m_unit = aUnit;
m_data.m_convert = aConvert;
for( size_t i = 0; i < aItems.size(); i++ )
{
if( SEARCH_QUIT == aItems[i].Visit( this, NULL, m_ScanTypes ) )
break;
}
}
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-20011 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _LIB_COLLECTORS_H_
#define _LIB_COLLECTORS_H_
#include "class_collector.h"
#include "lib_draw_item.h"
class LIB_COLLECTOR;
class LIB_COLLECTOR_DATA
{
int m_unit;
int m_convert;
friend class LIB_COLLECTOR;
public:
LIB_COLLECTOR_DATA() :
m_unit( 0 ),
m_convert( 0 ) {}
};
/**
* Class LIB_COLLECTOR
*/
class LIB_COLLECTOR : public COLLECTOR
{
LIB_COLLECTOR_DATA m_data;
public:
/**
* A scan list for all schematic items.
*/
static const KICAD_T AllItems[];
/**
* A scan list for all editable schematic items.
*/
static const KICAD_T EditableItems[];
/**
* A scan list for all movable schematic items.
*/
static const KICAD_T MovableItems[];
/**
* A scan list for all rotatable schematic items.
*/
static const KICAD_T RotatableItems[];
/**
* A scan list for all schematic items except pins.
*/
static const KICAD_T AllItemsButPins[];
/**
* Constructor LIB_COLLECTOR
*/
LIB_COLLECTOR( const KICAD_T* aScanTypes = LIB_COLLECTOR::AllItems )
{
SetScanTypes( aScanTypes );
}
/**
* Operator []
* overloads COLLECTOR::operator[](int) to return a LIB_ITEM* instead of
* an EDA_ITEM* type.
* @param aIndex The index into the list.
* @return LIB_ITEM* at \a aIndex or NULL.
*/
LIB_ITEM* operator[]( int aIndex ) const
{
if( (unsigned)aIndex < (unsigned)GetCount() )
return (LIB_ITEM*) m_List[ aIndex ];
return NULL;
}
/**
* Function Inspect
* is the examining function within the INSPECTOR which is passed to the
* Iterate function.
*
* @param aItem An EDA_ITEM to examine.
* @param aTestData is not used in this class.
* @return SEARCH_RESULT #SEARCH_QUIT if the iterator is to stop the scan,
* else #SEARCH_CONTINUE;
*/
SEARCH_RESULT Inspect( EDA_ITEM* aItem, const void* aTestData = NULL );
/**
* Function Collect
* scans a SCH_ITEM using this class's Inspector method, which does the collection.
* @param aItem A SCH_ITEM to scan.
* @param aFilterList A list of #KICAD_T types with a terminating #EOT, that determines
* what is to be collected and the priority order of the resulting
* collection.
* @param aPosition A wxPoint to use in hit-testing.
* @param aUnit The unit of the items to collect or zero if all units.
* @param aConvert The convert of the items to collect or zero if all conversions.
*/
void Collect( LIB_ITEMS& aItem, const KICAD_T aFilterList[], const wxPoint& aPosition,
int aUnit = 0, int aConvert = 0 );
};
#endif // _LIB_COLLECTORS_H_
...@@ -17,7 +17,7 @@ const int fill_tab[3] = { 'N', 'F', 'f' }; ...@@ -17,7 +17,7 @@ const int fill_tab[3] = { 'N', 'F', 'f' };
/* Base class (abstract) for components bodies items */ /* Base class (abstract) for components bodies items */
LIB_DRAW_ITEM::LIB_DRAW_ITEM( KICAD_T aType, LIB_ITEM::LIB_ITEM( KICAD_T aType,
LIB_COMPONENT* aComponent, LIB_COMPONENT* aComponent,
int aUnit, int aUnit,
int aConvert, int aConvert,
...@@ -34,15 +34,15 @@ LIB_DRAW_ITEM::LIB_DRAW_ITEM( KICAD_T aType, ...@@ -34,15 +34,15 @@ LIB_DRAW_ITEM::LIB_DRAW_ITEM( KICAD_T aType,
} }
LIB_DRAW_ITEM::LIB_DRAW_ITEM( const LIB_DRAW_ITEM& aItem ) : LIB_ITEM::LIB_ITEM( const LIB_ITEM& aItem ) :
EDA_ITEM( aItem ) EDA_ITEM( aItem )
{ {
m_Unit = aItem.m_Unit; m_Unit = aItem.m_Unit;
m_Convert = aItem.m_Convert; m_Convert = aItem.m_Convert;
m_Fill = aItem.m_Fill; m_Fill = aItem.m_Fill;
m_Parent = aItem.m_Parent;
m_typeName = aItem.m_typeName; m_typeName = aItem.m_typeName;
m_isFillable = aItem.m_isFillable; m_isFillable = aItem.m_isFillable;
m_eraseLastDrawItem = false;
} }
...@@ -53,7 +53,7 @@ LIB_DRAW_ITEM::LIB_DRAW_ITEM( const LIB_DRAW_ITEM& aItem ) : ...@@ -53,7 +53,7 @@ LIB_DRAW_ITEM::LIB_DRAW_ITEM( const LIB_DRAW_ITEM& aItem ) :
* all library items. Call the base class from the derived class or the * all library items. Call the base class from the derived class or the
* common information will not be updated in the message panel. * common information will not be updated in the message panel.
*/ */
void LIB_DRAW_ITEM::DisplayInfo( EDA_DRAW_FRAME* aFrame ) void LIB_ITEM::DisplayInfo( EDA_DRAW_FRAME* aFrame )
{ {
wxString msg; wxString msg;
...@@ -78,7 +78,7 @@ void LIB_DRAW_ITEM::DisplayInfo( EDA_DRAW_FRAME* aFrame ) ...@@ -78,7 +78,7 @@ void LIB_DRAW_ITEM::DisplayInfo( EDA_DRAW_FRAME* aFrame )
} }
bool LIB_DRAW_ITEM::operator==( const LIB_DRAW_ITEM& aOther ) const bool LIB_ITEM::operator==( const LIB_ITEM& aOther ) const
{ {
return ( ( Type() == aOther.Type() ) return ( ( Type() == aOther.Type() )
&& ( m_Unit == aOther.m_Unit ) && ( m_Unit == aOther.m_Unit )
...@@ -87,7 +87,7 @@ bool LIB_DRAW_ITEM::operator==( const LIB_DRAW_ITEM& aOther ) const ...@@ -87,7 +87,7 @@ bool LIB_DRAW_ITEM::operator==( const LIB_DRAW_ITEM& aOther ) const
} }
bool LIB_DRAW_ITEM::operator<( const LIB_DRAW_ITEM& aOther ) const bool LIB_ITEM::operator<( const LIB_ITEM& aOther ) const
{ {
int result = m_Convert - aOther.m_Convert; int result = m_Convert - aOther.m_Convert;
...@@ -108,7 +108,7 @@ bool LIB_DRAW_ITEM::operator<( const LIB_DRAW_ITEM& aOther ) const ...@@ -108,7 +108,7 @@ bool LIB_DRAW_ITEM::operator<( const LIB_DRAW_ITEM& aOther ) const
} }
void LIB_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor,
int aDrawMode, void* aData, const TRANSFORM& aTransform ) int aDrawMode, void* aData, const TRANSFORM& aTransform )
{ {
if( InEditMode() ) if( InEditMode() )
...@@ -143,7 +143,7 @@ void LIB_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOff ...@@ -143,7 +143,7 @@ void LIB_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOff
} }
int LIB_DRAW_ITEM::GetDefaultColor() int LIB_ITEM::GetDefaultColor()
{ {
return ReturnLayerColor( LAYER_DEVICE ); return ReturnLayerColor( LAYER_DEVICE );
} }
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
/* Definitions of graphic items used to create shapes in component libraries. /* Definitions of graphic items used to create shapes in component libraries.
*/ */
#ifndef _LIB_DRAW_ITEM_H_ #ifndef _LIB_ITEM_H_
#define _LIB_DRAW_ITEM_H_ #define _LIB_ITEM_H_
#include "base_struct.h" #include "base_struct.h"
#include "transform.h" #include "transform.h"
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
class LIB_COMPONENT; class LIB_COMPONENT;
class PLOTTER; class PLOTTER;
class LIB_DRAW_ITEM; class LIB_ITEM;
class LIB_PIN; class LIB_PIN;
...@@ -31,14 +31,14 @@ extern const int fill_tab[]; ...@@ -31,14 +31,14 @@ extern const int fill_tab[];
* in them. If you access a object pointer from the list, do not delete * in them. If you access a object pointer from the list, do not delete
* it directly. * it directly.
*/ */
typedef boost::ptr_vector< LIB_DRAW_ITEM > LIB_DRAW_ITEM_LIST; typedef boost::ptr_vector< LIB_ITEM > LIB_ITEMS;
/** /**
* Helper for defining a list of pin object pointers. The list does not * Helper for defining a list of pin object pointers. The list does not
* use a Boost pointer class so the object pointers do not accidently get * use a Boost pointer class so the object pointers do not accidently get
* deleted when the container is deleted. * deleted when the container is deleted.
*/ */
typedef std::vector< LIB_PIN* > LIB_PIN_LIST; typedef std::vector< LIB_PIN* > LIB_PINS;
/****************************************************************************/ /****************************************************************************/
...@@ -50,7 +50,7 @@ typedef std::vector< LIB_PIN* > LIB_PIN_LIST; ...@@ -50,7 +50,7 @@ typedef std::vector< LIB_PIN* > LIB_PIN_LIST;
* Base class for drawable items used in library components. * Base class for drawable items used in library components.
* (graphic shapes, texts, fields, pins) * (graphic shapes, texts, fields, pins)
*/ */
class LIB_DRAW_ITEM : public EDA_ITEM class LIB_ITEM : public EDA_ITEM
{ {
/** /**
* Draws the item. * Draws the item.
...@@ -111,15 +111,15 @@ protected: ...@@ -111,15 +111,15 @@ protected:
public: public:
LIB_DRAW_ITEM( KICAD_T aType, LIB_ITEM( KICAD_T aType,
LIB_COMPONENT* aComponent = NULL, LIB_COMPONENT* aComponent = NULL,
int aUnit = 0, int aUnit = 0,
int aConvert = 0, int aConvert = 0,
FILL_T aFillType = NO_FILL ); FILL_T aFillType = NO_FILL );
LIB_DRAW_ITEM( const LIB_DRAW_ITEM& aItem ); LIB_ITEM( const LIB_ITEM& aItem );
virtual ~LIB_DRAW_ITEM() { } virtual ~LIB_ITEM() { }
wxString GetTypeName() { return m_typeName; } wxString GetTypeName() { return m_typeName; }
...@@ -236,23 +236,13 @@ public: ...@@ -236,23 +236,13 @@ public:
virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame ); virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame );
/** /**
* Make a copy of this draw item. * Test LIB_ITEM objects for equivalence.
*
* Classes derived from LIB_DRAW_ITEM must implement DoGenCopy().
* This is just a placeholder for the derived class.
*
* @return Copy of this draw item.
*/
LIB_DRAW_ITEM* GenCopy() { return DoGenCopy(); }
/**
* Test LIB_DRAW_ITEM objects for equivalence.
* *
* @param aOther - Object to test against. * @param aOther - Object to test against.
* @return - True if object is identical to this object. * @return - True if object is identical to this object.
*/ */
bool operator==( const LIB_DRAW_ITEM& aOther ) const; bool operator==( const LIB_ITEM& aOther ) const;
bool operator==( const LIB_DRAW_ITEM* aOther ) const bool operator==( const LIB_ITEM* aOther ) const
{ {
return *this == *aOther; return *this == *aOther;
} }
...@@ -263,7 +253,7 @@ public: ...@@ -263,7 +253,7 @@ public:
* @param aOther - Draw item to compare against. * @param aOther - Draw item to compare against.
* @return - True if object is less than this object. * @return - True if object is less than this object.
*/ */
bool operator<( const LIB_DRAW_ITEM& aOther) const; bool operator<( const LIB_ITEM& aOther) const;
/** /**
* Set drawing object offset from the current position. * Set drawing object offset from the current position.
...@@ -369,7 +359,6 @@ public: ...@@ -369,7 +359,6 @@ public:
FILL_T GetFillMode() const { return m_Fill; } FILL_T GetFillMode() const { return m_Fill; }
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy() = 0;
/** /**
* Provide the draw object specific comparison. * Provide the draw object specific comparison.
...@@ -382,7 +371,7 @@ protected: ...@@ -382,7 +371,7 @@ protected:
* - KICAD_T enum value. * - KICAD_T enum value.
* - Result of derived classes comparison. * - Result of derived classes comparison.
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const = 0; virtual int DoCompare( const LIB_ITEM& aOther ) const = 0;
virtual void DoOffset( const wxPoint& aOffset ) = 0; virtual void DoOffset( const wxPoint& aOffset ) = 0;
virtual bool DoTestInside( EDA_RECT& aRect ) const = 0; virtual bool DoTestInside( EDA_RECT& aRect ) const = 0;
virtual void DoMove( const wxPoint& aPosition ) = 0; virtual void DoMove( const wxPoint& aPosition ) = 0;
...@@ -398,4 +387,4 @@ protected: ...@@ -398,4 +387,4 @@ protected:
}; };
#endif // _LIB_DRAW_ITEM_H_ #endif // _LIB_ITEM_H_
...@@ -41,19 +41,19 @@ ...@@ -41,19 +41,19 @@
* others = free fields * others = free fields
*/ */
LIB_FIELD::LIB_FIELD(LIB_COMPONENT * aParent, int idfield ) : LIB_FIELD::LIB_FIELD(LIB_COMPONENT * aParent, int idfield ) :
LIB_DRAW_ITEM( LIB_FIELD_T, aParent ) LIB_ITEM( LIB_FIELD_T, aParent )
{ {
Init( idfield ); Init( idfield );
} }
LIB_FIELD::LIB_FIELD( int idfield ) : LIB_DRAW_ITEM( LIB_FIELD_T, NULL ) LIB_FIELD::LIB_FIELD( int idfield ) : LIB_ITEM( LIB_FIELD_T, NULL )
{ {
Init( idfield ); Init( idfield );
} }
LIB_FIELD::LIB_FIELD( const LIB_FIELD& field ) : LIB_DRAW_ITEM( field ) LIB_FIELD::LIB_FIELD( const LIB_FIELD& field ) : LIB_ITEM( field )
{ {
m_id = field.m_id; m_id = field.m_id;
m_Pos = field.m_Pos; m_Pos = field.m_Pos;
...@@ -390,13 +390,13 @@ bool LIB_FIELD::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTr ...@@ -390,13 +390,13 @@ bool LIB_FIELD::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTr
} }
LIB_DRAW_ITEM* LIB_FIELD::DoGenCopy() EDA_ITEM* LIB_FIELD::doClone() const
{ {
LIB_FIELD* newfield = new LIB_FIELD( m_id ); LIB_FIELD* newfield = new LIB_FIELD( m_id );
Copy( newfield ); Copy( newfield );
return (LIB_DRAW_ITEM*) newfield; return (EDA_ITEM*) newfield;
} }
...@@ -417,7 +417,7 @@ void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const ...@@ -417,7 +417,7 @@ void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
} }
int LIB_FIELD::DoCompare( const LIB_DRAW_ITEM& other ) const int LIB_FIELD::DoCompare( const LIB_ITEM& other ) const
{ {
wxASSERT( other.Type() == LIB_FIELD_T ); wxASSERT( other.Type() == LIB_FIELD_T );
...@@ -654,6 +654,14 @@ void LIB_FIELD::SetText( const wxString& aText ) ...@@ -654,6 +654,14 @@ void LIB_FIELD::SetText( const wxString& aText )
} }
wxString LIB_FIELD::GetSelectMenuText() const
{
return wxString::Format( _( "Field %s %s" ),
GetChars( GetName() ),
GetChars( GetText() ) );
}
void LIB_FIELD::BeginEdit( int aEditMode, const wxPoint aPosition ) void LIB_FIELD::BeginEdit( int aEditMode, const wxPoint aPosition )
{ {
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0, wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
...@@ -723,7 +731,7 @@ void LIB_FIELD::DisplayInfo( EDA_DRAW_FRAME* aFrame ) ...@@ -723,7 +731,7 @@ void LIB_FIELD::DisplayInfo( EDA_DRAW_FRAME* aFrame )
{ {
wxString msg; wxString msg;
LIB_DRAW_ITEM::DisplayInfo( aFrame ); LIB_ITEM::DisplayInfo( aFrame );
// Display style: // Display style:
msg = GetTextStyleName(); msg = GetTextStyleName();
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* the component property editor assumes it. * the component property editor assumes it.
* @see enum NumFieldType * @see enum NumFieldType
*/ */
class LIB_FIELD : public LIB_DRAW_ITEM, public EDA_TEXT class LIB_FIELD : public LIB_ITEM, public EDA_TEXT
{ {
int m_id; ///< @see enum NumFieldType int m_id; ///< @see enum NumFieldType
wxString m_name; ///< Name (not the field text value itself, that is .m_Text) wxString m_name; ///< Name (not the field text value itself, that is .m_Text)
...@@ -190,17 +190,17 @@ public: ...@@ -190,17 +190,17 @@ public:
int GetDefaultColor(); int GetDefaultColor();
/** /**
* See LIB_DRAW_ITEM::BeginEdit(). * See LIB_ITEM::BeginEdit().
*/ */
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ); void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
/** /**
* See LIB_DRAW_ITEM::ContinueEdit(). * See LIB_ITEM::ContinueEdit().
*/ */
bool ContinueEdit( const wxPoint aNextPoint ); bool ContinueEdit( const wxPoint aNextPoint );
/** /**
* See LIB_DRAW_ITEM::AbortEdit(). * See LIB_ITEM::AbortEdit().
*/ */
void EndEdit( const wxPoint& aPosition, bool aAbort = false ); void EndEdit( const wxPoint& aPosition, bool aAbort = false );
...@@ -219,8 +219,12 @@ public: ...@@ -219,8 +219,12 @@ public:
*/ */
void SetText( const wxString& aText ); void SetText( const wxString& aText );
virtual wxString GetSelectMenuText() const;
virtual const char** GetMenuImage() const { return (const char**) move_field_xpm; }
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual EDA_ITEM* doClone() const;
/** /**
* Provide the field draw object specific comparison. * Provide the field draw object specific comparison.
...@@ -234,7 +238,7 @@ protected: ...@@ -234,7 +238,7 @@ protected:
* - Field width. * - Field width.
* - Field height. * - Field height.
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const; virtual int DoCompare( const LIB_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset ); virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_RECT& rect ) const; virtual bool DoTestInside( EDA_RECT& rect ) const;
...@@ -247,6 +251,6 @@ protected: ...@@ -247,6 +251,6 @@ protected:
virtual void DoSetWidth( int width ) { m_Thickness = width; } virtual void DoSetWidth( int width ) { m_Thickness = width; }
}; };
typedef std::vector< LIB_FIELD > LIB_FIELD_LIST; typedef std::vector< LIB_FIELD > LIB_FIELDS;
#endif // CLASS_LIBENTRY_FIELDS_H #endif // CLASS_LIBENTRY_FIELDS_H
...@@ -162,7 +162,7 @@ extern void PlotPinSymbol( PLOTTER* plotter, const wxPoint& pos, ...@@ -162,7 +162,7 @@ extern void PlotPinSymbol( PLOTTER* plotter, const wxPoint& pos,
LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) : LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) :
LIB_DRAW_ITEM( LIB_PIN_T, aParent ) LIB_ITEM( LIB_PIN_T, aParent )
{ {
m_length = 300; /* default Pin len */ m_length = 300; /* default Pin len */
m_orientation = PIN_RIGHT; /* Pin orient: Up, Down, Left, Right */ m_orientation = PIN_RIGHT; /* Pin orient: Up, Down, Left, Right */
...@@ -181,7 +181,7 @@ LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) : ...@@ -181,7 +181,7 @@ LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) :
} }
LIB_PIN::LIB_PIN( const LIB_PIN& pin ) : LIB_DRAW_ITEM( pin ) LIB_PIN::LIB_PIN( const LIB_PIN& pin ) : LIB_ITEM( pin )
{ {
m_position = pin.m_position; m_position = pin.m_position;
m_length = pin.m_length; m_length = pin.m_length;
...@@ -216,7 +216,7 @@ void LIB_PIN::SetName( const wxString& aName ) ...@@ -216,7 +216,7 @@ void LIB_PIN::SetName( const wxString& aName )
if( GetParent() == NULL ) if( GetParent() == NULL )
return; return;
LIB_PIN_LIST pinList; LIB_PINS pinList;
GetParent()->GetPins( pinList ); GetParent()->GetPins( pinList );
for( size_t i = 0; i < pinList.size(); i++ ) for( size_t i = 0; i < pinList.size(); i++ )
...@@ -241,7 +241,7 @@ void LIB_PIN::SetNameTextSize( int size ) ...@@ -241,7 +241,7 @@ void LIB_PIN::SetNameTextSize( int size )
if( GetParent() == NULL ) if( GetParent() == NULL )
return; return;
LIB_PIN_LIST pinList; LIB_PINS pinList;
GetParent()->GetPins( pinList ); GetParent()->GetPins( pinList );
for( size_t i = 0; i < pinList.size(); i++ ) for( size_t i = 0; i < pinList.size(); i++ )
...@@ -285,7 +285,7 @@ void LIB_PIN::SetNumberTextSize( int size ) ...@@ -285,7 +285,7 @@ void LIB_PIN::SetNumberTextSize( int size )
if( GetParent() == NULL ) if( GetParent() == NULL )
return; return;
LIB_PIN_LIST pinList; LIB_PINS pinList;
GetParent()->GetPins( pinList ); GetParent()->GetPins( pinList );
for( size_t i = 0; i < pinList.size(); i++ ) for( size_t i = 0; i < pinList.size(); i++ )
...@@ -310,7 +310,7 @@ void LIB_PIN::SetOrientation( int orientation ) ...@@ -310,7 +310,7 @@ void LIB_PIN::SetOrientation( int orientation )
if( GetParent() == NULL ) if( GetParent() == NULL )
return; return;
LIB_PIN_LIST pinList; LIB_PINS pinList;
GetParent()->GetPins( pinList ); GetParent()->GetPins( pinList );
for( size_t i = 0; i < pinList.size(); i++ ) for( size_t i = 0; i < pinList.size(); i++ )
...@@ -335,7 +335,7 @@ void LIB_PIN::SetShape( int aShape ) ...@@ -335,7 +335,7 @@ void LIB_PIN::SetShape( int aShape )
if( GetParent() == NULL ) if( GetParent() == NULL )
return; return;
LIB_PIN_LIST pinList; LIB_PINS pinList;
GetParent()->GetPins( pinList ); GetParent()->GetPins( pinList );
for( size_t i = 0; i < pinList.size(); i++ ) for( size_t i = 0; i < pinList.size(); i++ )
...@@ -362,7 +362,7 @@ void LIB_PIN::SetType( int aType ) ...@@ -362,7 +362,7 @@ void LIB_PIN::SetType( int aType )
if( GetParent() == NULL ) if( GetParent() == NULL )
return; return;
LIB_PIN_LIST pinList; LIB_PINS pinList;
GetParent()->GetPins( pinList ); GetParent()->GetPins( pinList );
for( size_t i = 0; i < pinList.size(); i++ ) for( size_t i = 0; i < pinList.size(); i++ )
...@@ -387,7 +387,7 @@ void LIB_PIN::SetLength( int length ) ...@@ -387,7 +387,7 @@ void LIB_PIN::SetLength( int length )
if( GetParent() == NULL ) if( GetParent() == NULL )
return; return;
LIB_PIN_LIST pinList; LIB_PINS pinList;
GetParent()->GetPins( pinList ); GetParent()->GetPins( pinList );
for( size_t i = 0; i < pinList.size(); i++ ) for( size_t i = 0; i < pinList.size(); i++ )
...@@ -427,7 +427,7 @@ void LIB_PIN::SetPartNumber( int part ) ...@@ -427,7 +427,7 @@ void LIB_PIN::SetPartNumber( int part )
|| ( pin->m_orientation != m_orientation ) ) || ( pin->m_orientation != m_orientation ) )
continue; continue;
GetParent()->RemoveDrawItem( (LIB_DRAW_ITEM*) pin ); GetParent()->RemoveDrawItem( (LIB_ITEM*) pin );
} }
} }
} }
...@@ -458,7 +458,7 @@ void LIB_PIN::SetConversion( int style ) ...@@ -458,7 +458,7 @@ void LIB_PIN::SetConversion( int style )
|| ( pin->m_orientation != m_orientation ) ) || ( pin->m_orientation != m_orientation ) )
continue; continue;
GetParent()->RemoveDrawItem( (LIB_DRAW_ITEM*) pin ); GetParent()->RemoveDrawItem( (LIB_ITEM*) pin );
} }
} }
} }
...@@ -479,7 +479,7 @@ void LIB_PIN::SetVisible( bool visible ) ...@@ -479,7 +479,7 @@ void LIB_PIN::SetVisible( bool visible )
if( GetParent() == NULL ) if( GetParent() == NULL )
return; return;
LIB_PIN_LIST pinList; LIB_PINS pinList;
GetParent()->GetPins( pinList ); GetParent()->GetPins( pinList );
for( size_t i = 0; i < pinList.size(); i++ ) for( size_t i = 0; i < pinList.size(); i++ )
...@@ -499,7 +499,7 @@ void LIB_PIN::SetVisible( bool visible ) ...@@ -499,7 +499,7 @@ void LIB_PIN::SetVisible( bool visible )
void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin ) void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin )
{ {
LIB_PIN_LIST pinList; LIB_PINS pinList;
if( GetParent() == NULL ) if( GetParent() == NULL )
return; return;
...@@ -525,22 +525,16 @@ void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin ) ...@@ -525,22 +525,16 @@ void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin )
bool LIB_PIN::HitTest( const wxPoint& aPosition ) bool LIB_PIN::HitTest( const wxPoint& aPosition )
{ {
int mindist = m_width ? m_width / 2 : g_DrawDefaultLineThickness / 2; return HitTest( aPosition, 0, DefaultTransform );
// Have a minimal tolerance for hit test
if( mindist < 3 )
mindist = 3; // = 3 mils
return HitTest( aPosition, mindist, DefaultTransform );
} }
bool LIB_PIN::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform ) bool LIB_PIN::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform )
{ {
wxPoint pinPos = aTransform.TransformCoordinate( m_position ); EDA_RECT rect = GetBoundingBox();
wxPoint pinEnd = aTransform.TransformCoordinate( ReturnPinEndPoint() ); rect.Inflate( aThreshold );
return TestSegmentHit( aPosition, pinPos, pinEnd, aThreshold ); return rect.Contains( aPosition );
} }
...@@ -1599,34 +1593,13 @@ void LIB_PIN::SetPinNumFromString( wxString& buffer ) ...@@ -1599,34 +1593,13 @@ void LIB_PIN::SetPinNumFromString( wxString& buffer )
} }
LIB_DRAW_ITEM* LIB_PIN::DoGenCopy() EDA_ITEM* LIB_PIN::doClone() const
{ {
LIB_PIN* newpin = new LIB_PIN( GetParent() ); return new LIB_PIN( *this );
newpin->m_position = m_position;
newpin->m_length = m_length;
newpin->m_orientation = m_orientation;
newpin->m_shape = m_shape;
newpin->m_type = m_type;
newpin->m_attributes = m_attributes;
newpin->m_number = m_number;
newpin->m_PinNumSize = m_PinNumSize;
newpin->m_PinNameSize = m_PinNameSize;
newpin->m_PinNumShapeOpt = m_PinNumShapeOpt;
newpin->m_PinNameShapeOpt = m_PinNameShapeOpt;
newpin->m_PinNumPositionOpt = m_PinNumPositionOpt;
newpin->m_PinNamePositionOpt = m_PinNamePositionOpt;
newpin->m_Unit = m_Unit;
newpin->m_Convert = m_Convert;
newpin->m_Flags = m_Flags;
newpin->m_width = m_width;
newpin->m_name = m_name;
return (LIB_DRAW_ITEM*) newpin;
} }
int LIB_PIN::DoCompare( const LIB_DRAW_ITEM& other ) const int LIB_PIN::DoCompare( const LIB_ITEM& other ) const
{ {
wxASSERT( other.Type() == LIB_PIN_T ); wxASSERT( other.Type() == LIB_PIN_T );
...@@ -1724,7 +1697,7 @@ void LIB_PIN::DisplayInfo( EDA_DRAW_FRAME* frame ) ...@@ -1724,7 +1697,7 @@ void LIB_PIN::DisplayInfo( EDA_DRAW_FRAME* frame )
{ {
wxString Text; wxString Text;
LIB_DRAW_ITEM::DisplayInfo( frame ); LIB_ITEM::DisplayInfo( frame );
frame->AppendMsgPanel( _( "Name" ), m_name, DARKCYAN ); frame->AppendMsgPanel( _( "Name" ), m_name, DARKCYAN );
...@@ -1766,35 +1739,57 @@ EDA_RECT LIB_PIN::GetBoundingBox() const ...@@ -1766,35 +1739,57 @@ EDA_RECT LIB_PIN::GetBoundingBox() const
EDA_RECT bbox; EDA_RECT bbox;
wxPoint begin; wxPoint begin;
wxPoint end; wxPoint end;
int pinname_offset = 0; int nameTextOffset = 0;
bool showName = !m_name.IsEmpty() && (m_name != wxT( "~" ));
int symbolX = TARGET_PIN_DIAM / 2;
int symbolY = TARGET_PIN_DIAM / 2;
if( entry ) if( entry )
pinname_offset = entry->GetPinNameOffset(); {
if( entry->ShowPinNames() )
nameTextOffset = entry->GetPinNameOffset();
else
showName = false;
}
// First, calculate boundary box corners position // First, calculate boundary box corners position
int pinnum_len = m_PinNumSize * GetNumberString().Len(); int numberTextLength = m_PinNumSize * GetNumberString().Len();
// Actual text height are bigger than text size // Actual text height are bigger than text size
int pinname_hight = wxRound( m_PinNameSize * 1.3 ); int nameTextHeight = wxRound( m_PinNameSize * 1.1 );
int pinnum_hight = wxRound( m_PinNumSize * 1.3 ); int numberTextHeight = wxRound( m_PinNumSize * 1.1 );
if( m_shape & INVERT )
symbolX = symbolY = INVERT_PIN_RADIUS;
// calculate top left corner position // calculate top left corner position
// for the default pin orientation (PIN_RIGHT) // for the default pin orientation (PIN_RIGHT)
begin.y = pinnum_hight + TXTMARGE; begin.y = numberTextHeight + TXTMARGE;
begin.x = MIN( -TARGET_PIN_DIAM, m_length - pinnum_len / 2 ); begin.x = MIN( -TARGET_PIN_DIAM / 2, m_length - (numberTextLength / 2) );
// calculate bottom right corner position and adjust top left corner position // calculate bottom right corner position and adjust top left corner position
int pinname_len = m_PinNameSize * m_name.Len(); int nameTextLength = 0;
if( pinname_offset )
if( showName )
{
int length = m_name.Len();
// Don't count the line over text symbol.
if( m_name.Left( 1 ) == wxT( "~" ) )
length -= 1;
nameTextLength = ( m_PinNameSize * length ) + nameTextOffset;
}
if( showName )
{ {
end.y = -pinname_hight / 2; end.y = -nameTextHeight / 2;
end.x = m_length + pinname_offset + pinname_len; end.x = m_length + nameTextLength;
} }
else else
{ {
end.y = -pinname_hight - TXTMARGE; end.y = -symbolY;
end.x = MAX( m_length, pinname_len / 2 ); end.x = m_length;
begin.x = MIN( begin.x, m_length - pinname_len / 2 );
} }
// Now, calculate boundary box corners position for the actual pin orientation // Now, calculate boundary box corners position for the actual pin orientation
......
...@@ -80,7 +80,7 @@ enum DrawPinOrient { ...@@ -80,7 +80,7 @@ enum DrawPinOrient {
}; };
class LIB_PIN : public LIB_DRAW_ITEM class LIB_PIN : public LIB_ITEM
{ {
wxPoint m_position; ///< Position of the pin. wxPoint m_position; ///< Position of the pin.
int m_length; ///< Length of the pin. int m_length; ///< Length of the pin.
...@@ -455,7 +455,7 @@ public: ...@@ -455,7 +455,7 @@ public:
virtual wxString GetSelectMenuText() const; virtual wxString GetSelectMenuText() const;
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual EDA_ITEM* doClone() const;
/** /**
* Provide the pin draw object specific comparison. * Provide the pin draw object specific comparison.
...@@ -466,7 +466,7 @@ protected: ...@@ -466,7 +466,7 @@ protected:
* - Pin horizontal (X) position. * - Pin horizontal (X) position.
* - Pin vertical (Y) position. * - Pin vertical (Y) position.
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const; virtual bool DoTestInside( EDA_RECT& aRect ) const;
virtual void DoMove( const wxPoint& aPosition ); virtual void DoMove( const wxPoint& aPosition );
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
LIB_POLYLINE::LIB_POLYLINE( LIB_COMPONENT* aParent ) : LIB_POLYLINE::LIB_POLYLINE( LIB_COMPONENT* aParent ) :
LIB_DRAW_ITEM( LIB_POLYLINE_T, aParent ) LIB_ITEM( LIB_POLYLINE_T, aParent )
{ {
m_Fill = NO_FILL; m_Fill = NO_FILL;
m_Width = 0; m_Width = 0;
...@@ -30,11 +30,10 @@ LIB_POLYLINE::LIB_POLYLINE( LIB_COMPONENT* aParent ) : ...@@ -30,11 +30,10 @@ LIB_POLYLINE::LIB_POLYLINE( LIB_COMPONENT* aParent ) :
LIB_POLYLINE::LIB_POLYLINE( const LIB_POLYLINE& polyline ) : LIB_POLYLINE::LIB_POLYLINE( const LIB_POLYLINE& polyline ) :
LIB_DRAW_ITEM( polyline ) LIB_ITEM( polyline )
{ {
m_PolyPoints = polyline.m_PolyPoints; // Vector copy m_PolyPoints = polyline.m_PolyPoints; // Vector copy
m_Width = polyline.m_Width; m_Width = polyline.m_Width;
m_Fill = polyline.m_Fill;
} }
...@@ -64,8 +63,7 @@ bool LIB_POLYLINE::Load( char* aLine, wxString& aErrorMsg ) ...@@ -64,8 +63,7 @@ bool LIB_POLYLINE::Load( char* aLine, wxString& aErrorMsg )
int i, ccount = 0; int i, ccount = 0;
wxPoint pt; wxPoint pt;
i = sscanf( &aLine[2], "%d %d %d %d", &ccount, &m_Unit, &m_Convert, i = sscanf( &aLine[2], "%d %d %d %d", &ccount, &m_Unit, &m_Convert, &m_Width );
&m_Width );
m_Fill = NO_FILL; m_Fill = NO_FILL;
...@@ -115,22 +113,13 @@ bool LIB_POLYLINE::Load( char* aLine, wxString& aErrorMsg ) ...@@ -115,22 +113,13 @@ bool LIB_POLYLINE::Load( char* aLine, wxString& aErrorMsg )
} }
LIB_DRAW_ITEM* LIB_POLYLINE::DoGenCopy() EDA_ITEM* LIB_POLYLINE::doClone() const
{ {
LIB_POLYLINE* newitem = new LIB_POLYLINE( GetParent() ); return new LIB_POLYLINE( *this );
newitem->m_PolyPoints = m_PolyPoints; // Vector copy
newitem->m_Width = m_Width;
newitem->m_Unit = m_Unit;
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill;
return (LIB_DRAW_ITEM*) newitem;
} }
int LIB_POLYLINE::DoCompare( const LIB_DRAW_ITEM& aOther ) const int LIB_POLYLINE::DoCompare( const LIB_ITEM& aOther ) const
{ {
wxASSERT( aOther.Type() == LIB_POLYLINE_T ); wxASSERT( aOther.Type() == LIB_POLYLINE_T );
...@@ -383,7 +372,7 @@ void LIB_POLYLINE::DisplayInfo( EDA_DRAW_FRAME* aFrame ) ...@@ -383,7 +372,7 @@ void LIB_POLYLINE::DisplayInfo( EDA_DRAW_FRAME* aFrame )
wxString msg; wxString msg;
EDA_RECT bBox = GetBoundingBox(); EDA_RECT bBox = GetBoundingBox();
LIB_DRAW_ITEM::DisplayInfo( aFrame ); LIB_ITEM::DisplayInfo( aFrame );
msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true ); msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true );
...@@ -396,6 +385,17 @@ void LIB_POLYLINE::DisplayInfo( EDA_DRAW_FRAME* aFrame ) ...@@ -396,6 +385,17 @@ void LIB_POLYLINE::DisplayInfo( EDA_DRAW_FRAME* aFrame )
} }
wxString LIB_POLYLINE::GetSelectMenuText() const
{
return wxString::Format( _( "Polyline at (%s, %s) with %u points" ),
GetChars( CoordinateToString( m_PolyPoints[0].x,
EESCHEMA_INTERNAL_UNIT ) ),
GetChars( CoordinateToString( m_PolyPoints[0].y,
EESCHEMA_INTERNAL_UNIT ) ),
m_PolyPoints.size() );
}
void LIB_POLYLINE::BeginEdit( int aEditMode, const wxPoint aPosition ) void LIB_POLYLINE::BeginEdit( int aEditMode, const wxPoint aPosition )
{ {
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0, wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "lib_draw_item.h" #include "lib_draw_item.h"
class LIB_POLYLINE : public LIB_DRAW_ITEM class LIB_POLYLINE : public LIB_ITEM
{ {
int m_Width; // Line width int m_Width; // Line width
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2) std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
...@@ -91,22 +91,26 @@ public: ...@@ -91,22 +91,26 @@ public:
virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame ); virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame );
/** /**
* See LIB_DRAW_ITEM::BeginEdit(). * See LIB_ITEM::BeginEdit().
*/ */
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ); void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
/** /**
* See LIB_DRAW_ITEM::ContinueEdit(). * See LIB_ITEM::ContinueEdit().
*/ */
bool ContinueEdit( const wxPoint aNextPoint ); bool ContinueEdit( const wxPoint aNextPoint );
/** /**
* See LIB_DRAW_ITEM::AbortEdit(). * See LIB_ITEM::AbortEdit().
*/ */
void EndEdit( const wxPoint& aPosition, bool aAbort = false ); void EndEdit( const wxPoint& aPosition, bool aAbort = false );
virtual wxString GetSelectMenuText() const;
virtual const char** GetMenuImage() const { return (const char**) add_polygon_xpm; }
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual EDA_ITEM* doClone() const;
/** /**
* Provide the polyline segment draw object specific comparison. * Provide the polyline segment draw object specific comparison.
...@@ -115,7 +119,7 @@ protected: ...@@ -115,7 +119,7 @@ protected:
* - Line segment point horizontal (X) position. * - Line segment point horizontal (X) position.
* - Line segment point vertical (Y) position. * - Line segment point vertical (Y) position.
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const; virtual bool DoTestInside( EDA_RECT& aRect ) const;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "macros.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "plot_common.h" #include "plot_common.h"
#include "trigo.h" #include "trigo.h"
...@@ -17,7 +18,7 @@ ...@@ -17,7 +18,7 @@
LIB_RECTANGLE::LIB_RECTANGLE( LIB_COMPONENT* aParent ) : LIB_RECTANGLE::LIB_RECTANGLE( LIB_COMPONENT* aParent ) :
LIB_DRAW_ITEM( LIB_RECTANGLE_T, aParent ) LIB_ITEM( LIB_RECTANGLE_T, aParent )
{ {
m_Width = 0; m_Width = 0;
m_Fill = NO_FILL; m_Fill = NO_FILL;
...@@ -30,7 +31,7 @@ LIB_RECTANGLE::LIB_RECTANGLE( LIB_COMPONENT* aParent ) : ...@@ -30,7 +31,7 @@ LIB_RECTANGLE::LIB_RECTANGLE( LIB_COMPONENT* aParent ) :
LIB_RECTANGLE::LIB_RECTANGLE( const LIB_RECTANGLE& aRect ) : LIB_RECTANGLE::LIB_RECTANGLE( const LIB_RECTANGLE& aRect ) :
LIB_DRAW_ITEM( aRect ) LIB_ITEM( aRect )
{ {
m_Pos = aRect.m_Pos; m_Pos = aRect.m_Pos;
m_End = aRect.m_End; m_End = aRect.m_End;
...@@ -72,23 +73,13 @@ bool LIB_RECTANGLE::Load( char* aLine, wxString& aErrorMsg ) ...@@ -72,23 +73,13 @@ bool LIB_RECTANGLE::Load( char* aLine, wxString& aErrorMsg )
} }
LIB_DRAW_ITEM* LIB_RECTANGLE::DoGenCopy() EDA_ITEM* LIB_RECTANGLE::doClone() const
{ {
LIB_RECTANGLE* newitem = new LIB_RECTANGLE( GetParent() ); return new LIB_RECTANGLE( *this );
newitem->m_Pos = m_Pos;
newitem->m_End = m_End;
newitem->m_Width = m_Width;
newitem->m_Unit = m_Unit;
newitem->m_Convert = m_Convert;
newitem->m_Flags = m_Flags;
newitem->m_Fill = m_Fill;
return (LIB_DRAW_ITEM*) newitem;
} }
int LIB_RECTANGLE::DoCompare( const LIB_DRAW_ITEM& aOther ) const int LIB_RECTANGLE::DoCompare( const LIB_ITEM& aOther ) const
{ {
wxASSERT( aOther.Type() == LIB_RECTANGLE_T ); wxASSERT( aOther.Type() == LIB_RECTANGLE_T );
...@@ -221,7 +212,7 @@ void LIB_RECTANGLE::DisplayInfo( EDA_DRAW_FRAME* aFrame ) ...@@ -221,7 +212,7 @@ void LIB_RECTANGLE::DisplayInfo( EDA_DRAW_FRAME* aFrame )
{ {
wxString msg; wxString msg;
LIB_DRAW_ITEM::DisplayInfo( aFrame ); LIB_ITEM::DisplayInfo( aFrame );
msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true ); msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true );
...@@ -289,6 +280,16 @@ bool LIB_RECTANGLE::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& ...@@ -289,6 +280,16 @@ bool LIB_RECTANGLE::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM&
} }
wxString LIB_RECTANGLE::GetSelectMenuText() const
{
return wxString::Format( _( "Rectangle from (%s, %s) to (%s, %s)" ),
GetChars( CoordinateToString( m_Pos.x, EESCHEMA_INTERNAL_UNIT ) ),
GetChars( CoordinateToString( m_Pos.y, EESCHEMA_INTERNAL_UNIT ) ),
GetChars( CoordinateToString( m_End.x, EESCHEMA_INTERNAL_UNIT ) ),
GetChars( CoordinateToString( m_End.y, EESCHEMA_INTERNAL_UNIT ) ) );
}
void LIB_RECTANGLE::BeginEdit( int aEditMode, const wxPoint aPosition ) void LIB_RECTANGLE::BeginEdit( int aEditMode, const wxPoint aPosition )
{ {
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0, wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "lib_draw_item.h" #include "lib_draw_item.h"
class LIB_RECTANGLE : public LIB_DRAW_ITEM class LIB_RECTANGLE : public LIB_ITEM
{ {
wxPoint m_End; // Rectangle end point. wxPoint m_End; // Rectangle end point.
wxPoint m_Pos; // Rectangle start point. wxPoint m_Pos; // Rectangle start point.
...@@ -79,22 +79,26 @@ public: ...@@ -79,22 +79,26 @@ public:
virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame ); virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame );
/** /**
* See LIB_DRAW_ITEM::BeginEdit(). * See LIB_ITEM::BeginEdit().
*/ */
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ); void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
/** /**
* See LIB_DRAW_ITEM::ContinueEdit(). * See LIB_ITEM::ContinueEdit().
*/ */
bool ContinueEdit( const wxPoint aNextPoint ); bool ContinueEdit( const wxPoint aNextPoint );
/** /**
* See LIB_DRAW_ITEM::AbortEdit(). * See LIB_ITEM::AbortEdit().
*/ */
void EndEdit( const wxPoint& aPosition, bool aAbort = false ); void EndEdit( const wxPoint& aPosition, bool aAbort = false );
virtual wxString GetSelectMenuText() const;
virtual const char** GetMenuImage() const { return (const char**) add_rectangle_xpm; }
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual EDA_ITEM* doClone() const;
/** /**
* Provide the rectangle draw object specific comparison. * Provide the rectangle draw object specific comparison.
...@@ -105,7 +109,7 @@ protected: ...@@ -105,7 +109,7 @@ protected:
* - Rectangle horizontal (X) end position. * - Rectangle horizontal (X) end position.
* - Rectangle vertical (Y) end position. * - Rectangle vertical (Y) end position.
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const; virtual bool DoTestInside( EDA_RECT& aRect ) const;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
LIB_TEXT::LIB_TEXT(LIB_COMPONENT * aParent) : LIB_TEXT::LIB_TEXT(LIB_COMPONENT * aParent) :
LIB_DRAW_ITEM( LIB_TEXT_T, aParent ), LIB_ITEM( LIB_TEXT_T, aParent ),
EDA_TEXT() EDA_TEXT()
{ {
m_Size = wxSize( 50, 50 ); m_Size = wxSize( 50, 50 );
...@@ -187,7 +187,7 @@ bool LIB_TEXT::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTra ...@@ -187,7 +187,7 @@ bool LIB_TEXT::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTra
} }
LIB_DRAW_ITEM* LIB_TEXT::DoGenCopy() EDA_ITEM* LIB_TEXT::doClone() const
{ {
LIB_TEXT* newitem = new LIB_TEXT(NULL); LIB_TEXT* newitem = new LIB_TEXT(NULL);
...@@ -204,11 +204,11 @@ LIB_DRAW_ITEM* LIB_TEXT::DoGenCopy() ...@@ -204,11 +204,11 @@ LIB_DRAW_ITEM* LIB_TEXT::DoGenCopy()
newitem->m_Bold = m_Bold; newitem->m_Bold = m_Bold;
newitem->m_HJustify = m_HJustify; newitem->m_HJustify = m_HJustify;
newitem->m_VJustify = m_VJustify; newitem->m_VJustify = m_VJustify;
return (LIB_DRAW_ITEM*) newitem; return (EDA_ITEM*) newitem;
} }
int LIB_TEXT::DoCompare( const LIB_DRAW_ITEM& other ) const int LIB_TEXT::DoCompare( const LIB_ITEM& other ) const
{ {
wxASSERT( other.Type() == LIB_TEXT_T ); wxASSERT( other.Type() == LIB_TEXT_T );
...@@ -379,7 +379,7 @@ void LIB_TEXT::DisplayInfo( EDA_DRAW_FRAME* frame ) ...@@ -379,7 +379,7 @@ void LIB_TEXT::DisplayInfo( EDA_DRAW_FRAME* frame )
{ {
wxString msg; wxString msg;
LIB_DRAW_ITEM::DisplayInfo( frame ); LIB_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UserUnit, m_Thickness, EESCHEMA_INTERNAL_UNIT, true ); msg = ReturnStringFromValue( g_UserUnit, m_Thickness, EESCHEMA_INTERNAL_UNIT, true );
...@@ -440,6 +440,20 @@ void LIB_TEXT::SetText( const wxString& aText ) ...@@ -440,6 +440,20 @@ void LIB_TEXT::SetText( const wxString& aText )
} }
wxString LIB_TEXT::GetSelectMenuText() const
{
wxString tmp = GetText();
tmp.Replace( wxT( "\n" ), wxT( " " ) );
tmp.Replace( wxT( "\r" ), wxT( " " ) );
tmp.Replace( wxT( "\t" ), wxT( " " ) );
tmp =( tmp.Length() > 15 ) ? tmp.Left( 12 ) + wxT( "..." ) : tmp;
wxString msg;
msg.Printf( _( "Graphic Text %s" ), GetChars( tmp ) );
return msg;
}
void LIB_TEXT::BeginEdit( int aEditMode, const wxPoint aPosition ) void LIB_TEXT::BeginEdit( int aEditMode, const wxPoint aPosition )
{ {
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0, wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
/* Fields like Ref , value... are not Text, */ /* Fields like Ref , value... are not Text, */
/* they are a separate class */ /* they are a separate class */
/*********************************************/ /*********************************************/
class LIB_TEXT : public LIB_DRAW_ITEM, public EDA_TEXT class LIB_TEXT : public LIB_ITEM, public EDA_TEXT
{ {
wxString m_savedText; ///< Temporary storage for the string when edition. wxString m_savedText; ///< Temporary storage for the string when edition.
bool m_rotate; ///< Flag to indicate a rotation occurred while editing. bool m_rotate; ///< Flag to indicate a rotation occurred while editing.
...@@ -103,22 +103,26 @@ public: ...@@ -103,22 +103,26 @@ public:
void Rotate(); void Rotate();
/** /**
* See LIB_DRAW_ITEM::BeginEdit(). * See LIB_ITEM::BeginEdit().
*/ */
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ); void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
/** /**
* See LIB_DRAW_ITEM::ContinueEdit(). * See LIB_ITEM::ContinueEdit().
*/ */
bool ContinueEdit( const wxPoint aNextPoint ); bool ContinueEdit( const wxPoint aNextPoint );
/** /**
* See LIB_DRAW_ITEM::AbortEdit(). * See LIB_ITEM::AbortEdit().
*/ */
void EndEdit( const wxPoint& aPosition, bool aAbort = false ); void EndEdit( const wxPoint& aPosition, bool aAbort = false );
virtual wxString GetSelectMenuText() const;
virtual const char** GetMenuImage() const { return (const char**) add_text_xpm; }
protected: protected:
virtual LIB_DRAW_ITEM* DoGenCopy(); virtual EDA_ITEM* doClone() const;
/** /**
* Provide the text draw object specific comparison. * Provide the text draw object specific comparison.
...@@ -130,7 +134,7 @@ protected: ...@@ -130,7 +134,7 @@ protected:
* - Text width. * - Text width.
* - Text height. * - Text height.
*/ */
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const; virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset ); virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const; virtual bool DoTestInside( EDA_RECT& aRect ) const;
......
...@@ -20,27 +20,32 @@ ...@@ -20,27 +20,32 @@
void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
{ {
LIB_DRAW_ITEM* DrawEntry = m_drawItem; LIB_ITEM* item = m_drawItem;
if( m_component == NULL ) // No component loaded ! if( m_component == NULL ) // No component loaded !
return; return;
if( DrawEntry == NULL || DrawEntry->m_Flags == 0 ) if( item == NULL || item->m_Flags == 0 )
{ {
DrawEntry = LocateItemUsingCursor( aPosition ); item = LocateItemUsingCursor( aPosition );
if( DrawEntry ) if( item )
DrawEntry->DisplayInfo( this ); item->DisplayInfo( this );
else else
{
DisplayCmpDoc(); DisplayCmpDoc();
if( DrawPanel->m_AbortRequest )
DrawPanel->m_AbortRequest = false;
}
} }
switch( GetToolId() ) switch( GetToolId() )
{ {
case ID_NO_TOOL_SELECTED: case ID_NO_TOOL_SELECTED:
if( DrawEntry && DrawEntry->m_Flags ) // moved object if( item && item->m_Flags ) // moved object
{ {
switch( DrawEntry->Type() ) switch( item->Type() )
{ {
case LIB_PIN_T: case LIB_PIN_T:
PlacePin( DC ); PlacePin( DC );
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "bitmaps.h" #include "bitmaps.h"
#include "eeschema_id.h" #include "eeschema_id.h"
#include "hotkeys.h" #include "hotkeys.h"
#include "class_drawpanel.h"
#include "class_sch_screen.h" #include "class_sch_screen.h"
#include "general.h" #include "general.h"
...@@ -30,7 +31,7 @@ static void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame ...@@ -30,7 +31,7 @@ static void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame
bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
{ {
LIB_DRAW_ITEM* DrawEntry = GetDrawItem(); LIB_ITEM* item = GetDrawItem();
bool BlockActive = GetScreen()->IsBlockActive(); bool BlockActive = GetScreen()->IsBlockActive();
if( BlockActive ) if( BlockActive )
...@@ -44,38 +45,47 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -44,38 +45,47 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
return true; return true;
// If Command in progress, put menu "cancel" // If Command in progress, put menu "cancel"
if( DrawEntry && DrawEntry->GetFlags() ) if( item && item->GetFlags() )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _( "Cancel" ), cancel_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _( "Cancel" ), cancel_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
} }
else else
{ {
DrawEntry = LocateItemUsingCursor( aPosition ); item = LocateItemUsingCursor( aPosition );
// If the clarify item selection context menu is aborted, don't show the context menu.
if( item == NULL && DrawPanel->m_AbortRequest )
{
DrawPanel->m_AbortRequest = false;
return false;
}
if( GetToolId() != ID_NO_TOOL_SELECTED ) if( GetToolId() != ID_NO_TOOL_SELECTED )
{ {
// If a tool is active, put menu "end tool" // If a tool is active, put menu "end tool"
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _( "End Tool" ), cancel_tool_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _( "End Tool" ),
cancel_tool_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
} }
} }
if( DrawEntry ) if( item )
DrawEntry->DisplayInfo( this ); item->DisplayInfo( this );
else else
return true; return true;
m_drawItem = DrawEntry; m_drawItem = item;
wxString msg; wxString msg;
switch( DrawEntry->Type() ) switch( item->Type() )
{ {
case LIB_PIN_T: case LIB_PIN_T:
AddMenusForPin( PopMenu, (LIB_PIN*) DrawEntry, this ); AddMenusForPin( PopMenu, (LIB_PIN*) item, this );
break; break;
case LIB_ARC_T: case LIB_ARC_T:
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Move Arc" ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Move Arc" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM ); HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
...@@ -87,7 +97,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -87,7 +97,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
msg = AddHotkeyName( _( "Edit Arc Options" ), s_Libedit_Hokeys_Descr, HK_EDIT ); msg = AddHotkeyName( _( "Edit Arc Options" ), s_Libedit_Hokeys_Descr, HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, options_arc_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, options_arc_xpm );
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Delete Arc" ), s_Libedit_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Arc" ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_arc_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_arc_xpm );
...@@ -95,14 +105,14 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -95,14 +105,14 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
break; break;
case LIB_CIRCLE_T: case LIB_CIRCLE_T:
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Move Circle" ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Move Circle" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM ); HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg, move_circle_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg, move_circle_xpm );
} }
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Drag Circle Outline" ), s_Libedit_Hokeys_Descr, HK_DRAG ); msg = AddHotkeyName( _( "Drag Circle Outline" ), s_Libedit_Hokeys_Descr, HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM, msg, move_rectangle_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM, msg, move_rectangle_xpm );
...@@ -111,7 +121,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -111,7 +121,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
msg = AddHotkeyName( _( "Edit Circle Options" ), s_Libedit_Hokeys_Descr, HK_EDIT ); msg = AddHotkeyName( _( "Edit Circle Options" ), s_Libedit_Hokeys_Descr, HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, options_circle_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, options_circle_xpm );
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Delete Circle" ), s_Libedit_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Circle" ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_circle_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_circle_xpm );
...@@ -119,7 +129,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -119,7 +129,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
break; break;
case LIB_RECTANGLE_T: case LIB_RECTANGLE_T:
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Move Rectangle" ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Move Rectangle" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM ); HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
...@@ -129,13 +139,13 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -129,13 +139,13 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
msg = AddHotkeyName( _( "Edit Rectangle Options" ), s_Libedit_Hokeys_Descr, HK_EDIT ); msg = AddHotkeyName( _( "Edit Rectangle Options" ), s_Libedit_Hokeys_Descr, HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, options_rectangle_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, options_rectangle_xpm );
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Drag Rectangle Edge" ), s_Libedit_Hokeys_Descr, HK_DRAG ); msg = AddHotkeyName( _( "Drag Rectangle Edge" ), s_Libedit_Hokeys_Descr, HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM, msg, move_rectangle_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM, msg, move_rectangle_xpm );
} }
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Delete Rectangle" ), s_Libedit_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Rectangle" ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_rectangle_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_rectangle_xpm );
...@@ -144,7 +154,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -144,7 +154,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
break; break;
case LIB_TEXT_T: case LIB_TEXT_T:
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Move Text" ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Move Text" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM ); HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
...@@ -157,7 +167,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -157,7 +167,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
msg = AddHotkeyName( _( "Rotate Text" ), s_Libedit_Hokeys_Descr, HK_ROTATE ); msg = AddHotkeyName( _( "Rotate Text" ), s_Libedit_Hokeys_Descr, HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_LIBEDIT_ROTATE_ITEM, msg, edit_text_xpm ); ADD_MENUITEM( PopMenu, ID_LIBEDIT_ROTATE_ITEM, msg, edit_text_xpm );
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Delete Text" ), s_Libedit_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Text" ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_text_xpm );
...@@ -165,7 +175,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -165,7 +175,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
break; break;
case LIB_POLYLINE_T: case LIB_POLYLINE_T:
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Move Line" ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Move Line" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM ); HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
...@@ -174,7 +184,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -174,7 +184,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM, msg, move_line_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MODIFY_ITEM, msg, move_line_xpm );
} }
if( DrawEntry->m_Flags & IS_NEW ) if( item->IsNew() )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_END_CREATE_ITEM, _( "Line End" ), apply_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_END_CREATE_ITEM, _( "Line End" ), apply_xpm );
} }
...@@ -182,14 +192,14 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -182,14 +192,14 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
msg = AddHotkeyName( _( "Edit Line Options" ), s_Libedit_Hokeys_Descr, HK_EDIT ); msg = AddHotkeyName( _( "Edit Line Options" ), s_Libedit_Hokeys_Descr, HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, options_segment_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, options_segment_xpm );
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Delete Line " ), s_Libedit_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Line " ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_segment_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_ITEM, msg, delete_segment_xpm );
} }
else if( (DrawEntry->m_Flags & IS_NEW) ) else if( item->IsNew() )
{ {
if( ( (LIB_POLYLINE*) DrawEntry )->GetCornerCount() > 2 ) if( ( (LIB_POLYLINE*) item )->GetCornerCount() > 2 )
{ {
msg = AddHotkeyName( _( "Delete Segment" ), s_Libedit_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Segment" ), s_Libedit_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT, ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
...@@ -200,7 +210,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -200,7 +210,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
break; break;
case LIB_FIELD_T: case LIB_FIELD_T:
if( DrawEntry->m_Flags == 0 ) if( item->GetFlags() == 0 )
{ {
msg = AddHotkeyName( _( "Move Field" ), s_Libedit_Hokeys_Descr, msg = AddHotkeyName( _( "Move Field" ), s_Libedit_Hokeys_Descr,
HK_LIBEDIT_MOVE_GRAPHIC_ITEM ); HK_LIBEDIT_MOVE_GRAPHIC_ITEM );
...@@ -214,10 +224,8 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -214,10 +224,8 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
default: default:
wxString msg; wxFAIL_MSG( wxString::Format( wxT( "Unknown library item type %d" ),
msg.Printf( wxT( "LIB_EDIT_FRAME::OnRightClick Error: unknown StructType %d" ), item->Type() ) );
DrawEntry->Type() );
DisplayError( this, msg );
m_drawItem = NULL; m_drawItem = NULL;
break; break;
} }
...@@ -230,7 +238,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -230,7 +238,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame ) void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame )
{ {
bool selected = (Pin->m_Selected & IS_SELECTED) != 0; bool selected = (Pin->m_Selected & IS_SELECTED) != 0;
bool not_in_move = (Pin->m_Flags == 0); bool not_in_move = (Pin->GetFlags() == 0);
wxString msg; wxString msg;
if( not_in_move ) if( not_in_move )
......
...@@ -61,8 +61,8 @@ CMP_LIBRARY* LIB_EDIT_FRAME:: m_library = NULL; ...@@ -61,8 +61,8 @@ CMP_LIBRARY* LIB_EDIT_FRAME:: m_library = NULL;
wxString LIB_EDIT_FRAME:: m_aliasName; wxString LIB_EDIT_FRAME:: m_aliasName;
int LIB_EDIT_FRAME:: m_unit = 1; int LIB_EDIT_FRAME:: m_unit = 1;
int LIB_EDIT_FRAME:: m_convert = 1; int LIB_EDIT_FRAME:: m_convert = 1;
LIB_DRAW_ITEM* LIB_EDIT_FRAME::m_lastDrawItem = NULL; LIB_ITEM* LIB_EDIT_FRAME::m_lastDrawItem = NULL;
LIB_DRAW_ITEM* LIB_EDIT_FRAME::m_drawItem = NULL; LIB_ITEM* LIB_EDIT_FRAME::m_drawItem = NULL;
bool LIB_EDIT_FRAME:: m_showDeMorgan = false; bool LIB_EDIT_FRAME:: m_showDeMorgan = false;
wxSize LIB_EDIT_FRAME:: m_clientSize = wxSize( -1, -1 ); wxSize LIB_EDIT_FRAME:: m_clientSize = wxSize( -1, -1 );
int LIB_EDIT_FRAME:: m_textSize = DEFAULT_SIZE_TEXT; int LIB_EDIT_FRAME:: m_textSize = DEFAULT_SIZE_TEXT;
...@@ -123,6 +123,9 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) ...@@ -123,6 +123,9 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::Process_Config )
EVT_MENU( ID_LIBEDIT_DIMENSIONS, LIB_EDIT_FRAME::InstallDimensionsDialog ) EVT_MENU( ID_LIBEDIT_DIMENSIONS, LIB_EDIT_FRAME::InstallDimensionsDialog )
// Multple item selection context menu commands.
EVT_MENU_RANGE( ID_SELECT_ITEM_START, ID_SELECT_ITEM_END, LIB_EDIT_FRAME::OnSelectItem )
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END, EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END,
LIB_EDIT_FRAME::Process_Config ) LIB_EDIT_FRAME::Process_Config )
...@@ -282,7 +285,7 @@ void LIB_EDIT_FRAME::LoadSettings() ...@@ -282,7 +285,7 @@ void LIB_EDIT_FRAME::LoadSettings()
} }
void LIB_EDIT_FRAME::SetDrawItem( LIB_DRAW_ITEM* drawItem ) void LIB_EDIT_FRAME::SetDrawItem( LIB_ITEM* drawItem )
{ {
m_drawItem = drawItem; m_drawItem = drawItem;
} }
...@@ -722,7 +725,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -722,7 +725,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST: case ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST:
if( m_drawItem == NULL ) if( m_drawItem == NULL )
break; break;
DrawPanel->MoveCursorToCrossHair();
if( m_drawItem->Type() == LIB_PIN_T ) if( m_drawItem->Type() == LIB_PIN_T )
StartMovePin( &dc ); StartMovePin( &dc );
else else
...@@ -906,7 +909,7 @@ void LIB_EDIT_FRAME::SVG_Print_Component( const wxString& FullFileName ) ...@@ -906,7 +909,7 @@ void LIB_EDIT_FRAME::SVG_Print_Component( const wxString& FullFileName )
} }
void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem )
{ {
if ( ( DrawItem == NULL ) || ( DrawItem->Type() != LIB_TEXT_T ) ) if ( ( DrawItem == NULL ) || ( DrawItem->Type() != LIB_TEXT_T ) )
return; return;
...@@ -1075,18 +1078,77 @@ void LIB_EDIT_FRAME::OnRotateItem( wxCommandEvent& aEvent ) ...@@ -1075,18 +1078,77 @@ void LIB_EDIT_FRAME::OnRotateItem( wxCommandEvent& aEvent )
} }
LIB_DRAW_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition ) LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition,
const KICAD_T aFilterList[] )
{ {
if( m_component == NULL ) if( m_component == NULL )
return NULL; return NULL;
LIB_DRAW_ITEM* item = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, LIB_ITEM* item = locateItem( aPosition, aFilterList );
aPosition );
if( item == NULL )
return NULL;
wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition ); wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition );
if( item == NULL && aPosition != pos ) if( item == NULL && aPosition != pos )
item = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, pos ); item = locateItem( pos, aFilterList );
return item;
}
LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aFilterList[] )
{
if( m_component == NULL )
return NULL;
LIB_ITEM* item = NULL;
m_collectedItems.Collect( m_component->GetDrawItemList(), aFilterList, aPosition,
m_unit, m_convert );
if( m_collectedItems.GetCount() == 0 )
{
ClearMsgPanel();
}
else if( m_collectedItems.GetCount() == 1 )
{
item = m_collectedItems[0];
}
else
{
if( item == NULL )
{
wxASSERT_MSG( m_collectedItems.GetCount() <= MAX_SELECT_ITEM_IDS,
wxT( "Select item clarification context menu size limit exceeded." ) );
wxMenu selectMenu;
wxMenuItem* title = new wxMenuItem( &selectMenu, wxID_NONE, _( "Clarify Selection" ) );
selectMenu.Append( title );
selectMenu.AppendSeparator();
for( int i = 0; i < m_collectedItems.GetCount() && i < MAX_SELECT_ITEM_IDS; i++ )
{
wxString text = m_collectedItems[i]->GetSelectMenuText();
const char** xpm = m_collectedItems[i]->GetMenuImage();
ADD_MENUITEM( &selectMenu, ID_SELECT_ITEM_START + i, text, xpm );
}
// Set to NULL in case user aborts the clarification context menu.
m_drawItem = NULL;
DrawPanel->m_AbortRequest = true; // Changed to false if an item is selected
PopupMenu( &selectMenu );
DrawPanel->MoveCursorToCrossHair();
item = m_drawItem;
}
}
if( item )
item->DisplayInfo( this );
else
ClearMsgPanel();
return item; return item;
} }
...@@ -1104,7 +1166,7 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC ) ...@@ -1104,7 +1166,7 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC )
LIB_PIN* pin = (LIB_PIN*) m_drawItem; LIB_PIN* pin = (LIB_PIN*) m_drawItem;
wxPoint pos = pin->GetPosition(); wxPoint pos = pin->GetPosition();
m_component->RemoveDrawItem( (LIB_DRAW_ITEM*) pin, DrawPanel, aDC ); m_component->RemoveDrawItem( (LIB_ITEM*) pin, DrawPanel, aDC );
if( g_EditPinByPinIsOn == false ) if( g_EditPinByPinIsOn == false )
{ {
...@@ -1118,7 +1180,7 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC ) ...@@ -1118,7 +1180,7 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC )
if( pin->GetPosition() != pos ) if( pin->GetPosition() != pos )
continue; continue;
m_component->RemoveDrawItem( (LIB_DRAW_ITEM*) pin ); m_component->RemoveDrawItem( (LIB_ITEM*) pin );
} }
} }
} }
...@@ -1134,3 +1196,18 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC ) ...@@ -1134,3 +1196,18 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC )
OnModify(); OnModify();
DrawPanel->CrossHairOn( aDC ); DrawPanel->CrossHairOn( aDC );
} }
void LIB_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
{
int id = aEvent.GetId();
int index = id - ID_SELECT_ITEM_START;
if( (id >= ID_SELECT_ITEM_START && id <= ID_SELECT_ITEM_END)
&& (index >= 0 && index < m_collectedItems.GetCount()) )
{
LIB_ITEM* item = m_collectedItems[index];
DrawPanel->m_AbortRequest = false;
m_drawItem = item;
}
}
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "class_sch_screen.h" #include "class_sch_screen.h"
#include "lib_draw_item.h" #include "lib_draw_item.h"
#include "lib_collectors.h"
class SCH_EDIT_FRAME; class SCH_EDIT_FRAME;
...@@ -26,6 +27,9 @@ class DIALOG_LIB_EDIT_TEXT; ...@@ -26,6 +27,9 @@ class DIALOG_LIB_EDIT_TEXT;
class LIB_EDIT_FRAME : public EDA_DRAW_FRAME class LIB_EDIT_FRAME : public EDA_DRAW_FRAME
{ {
LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit. LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit.
LIB_COLLECTOR m_collectedItems; // Used for hit testing.
LIB_ITEM* locateItem( const wxPoint& aPosition, const KICAD_T aFilterList[] );
public: public:
wxComboBox* m_SelpartBox; // a Box to select a part to edit (if any) wxComboBox* m_SelpartBox; // a Box to select a part to edit (if any)
...@@ -74,6 +78,7 @@ public: ...@@ -74,6 +78,7 @@ public:
void OnCheckComponent( wxCommandEvent& event ); void OnCheckComponent( wxCommandEvent& event );
void OnSelectBodyStyle( wxCommandEvent& event ); void OnSelectBodyStyle( wxCommandEvent& event );
void OnEditPin( wxCommandEvent& event ); void OnEditPin( wxCommandEvent& event );
void OnSelectItem( wxCommandEvent& aEvent );
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent ); void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
void OnUpdateEditingPart( wxUpdateUIEvent& event ); void OnUpdateEditingPart( wxUpdateUIEvent& event );
...@@ -159,17 +164,17 @@ public: ...@@ -159,17 +164,17 @@ public:
} }
LIB_DRAW_ITEM* GetLastDrawItem( void ) { return m_lastDrawItem; } LIB_ITEM* GetLastDrawItem( void ) { return m_lastDrawItem; }
void SetLastDrawItem( LIB_DRAW_ITEM* drawItem ) void SetLastDrawItem( LIB_ITEM* drawItem )
{ {
m_lastDrawItem = drawItem; m_lastDrawItem = drawItem;
} }
LIB_DRAW_ITEM* GetDrawItem( void ) { return m_drawItem; } LIB_ITEM* GetDrawItem( void ) { return m_drawItem; }
void SetDrawItem( LIB_DRAW_ITEM* drawItem ); void SetDrawItem( LIB_ITEM* drawItem );
bool GetShowDeMorgan( void ) { return m_showDeMorgan; } bool GetShowDeMorgan( void ) { return m_showDeMorgan; }
...@@ -253,16 +258,17 @@ private: ...@@ -253,16 +258,17 @@ private:
void PlaceAncre(); void PlaceAncre();
// Editing graphic items // Editing graphic items
LIB_DRAW_ITEM* CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC ); LIB_ITEM* CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC );
void GraphicItemBeginDraw( wxDC* DC ); void GraphicItemBeginDraw( wxDC* DC );
void StartMoveDrawSymbol( wxDC* DC ); void StartMoveDrawSymbol( wxDC* DC );
void StartModifyDrawSymbol( wxDC* DC ); //<! Modify the item, adjust size etc. void StartModifyDrawSymbol( wxDC* DC ); //<! Modify the item, adjust size etc.
void EndDrawGraphicItem( wxDC* DC ); void EndDrawGraphicItem( wxDC* DC );
void LoadOneSymbol(); void LoadOneSymbol();
void SaveOneSymbol(); void SaveOneSymbol();
void EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ); void EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem );
void EditSymbolText( wxDC* DC, LIB_DRAW_ITEM* DrawItem ); void EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem );
LIB_DRAW_ITEM* LocateItemUsingCursor( const wxPoint& aPosition ); LIB_ITEM* LocateItemUsingCursor( const wxPoint& aPosition,
const KICAD_T aFilterList[] = LIB_COLLECTOR::AllItems );
void EditField( wxDC* DC, LIB_FIELD* Field ); void EditField( wxDC* DC, LIB_FIELD* Field );
public: public:
...@@ -304,8 +310,8 @@ protected: ...@@ -304,8 +310,8 @@ protected:
/** The current component being edited. NULL if no component is selected. */ /** The current component being edited. NULL if no component is selected. */
static LIB_COMPONENT* m_component; static LIB_COMPONENT* m_component;
static LIB_DRAW_ITEM* m_lastDrawItem; static LIB_ITEM* m_lastDrawItem;
static LIB_DRAW_ITEM* m_drawItem; static LIB_ITEM* m_drawItem;
static wxString m_aliasName; static wxString m_aliasName;
// The unit number to edit and show // The unit number to edit and show
......
...@@ -136,7 +136,7 @@ this component?" ), ...@@ -136,7 +136,7 @@ this component?" ),
if( !aField->InEditMode() ) if( !aField->InEditMode() )
{ {
SaveCopyInUndoList( parent ); SaveCopyInUndoList( parent );
( (LIB_DRAW_ITEM*) aField )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, ( (LIB_ITEM*) aField )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&fieldText, DefaultTransform ); &fieldText, DefaultTransform );
} }
...@@ -144,7 +144,7 @@ this component?" ), ...@@ -144,7 +144,7 @@ this component?" ),
if( !aField->InEditMode() ) if( !aField->InEditMode() )
{ {
fieldText = aField->GetFullText( m_unit ); fieldText = aField->GetFullText( m_unit );
( (LIB_DRAW_ITEM*) aField )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, ( (LIB_ITEM*) aField )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&fieldText, DefaultTransform ); &fieldText, DefaultTransform );
} }
......
...@@ -596,7 +596,7 @@ SCH_COMPONENT* EXPORT_HELP::findNextComponentAndCreatePinList( EDA_ITEM* a ...@@ -596,7 +596,7 @@ SCH_COMPONENT* EXPORT_HELP::findNextComponentAndCreatePinList( EDA_ITEM* a
else // entry->GetPartCount() <= 1 means one part per package else // entry->GetPartCount() <= 1 means one part per package
{ {
LIB_PIN_LIST pins; // constructed once here LIB_PINS pins; // constructed once here
entry->GetPins( pins, comp->GetUnitSelection( aSheetPath ), comp->GetConvert() ); entry->GetPins( pins, comp->GetUnitSelection( aSheetPath ), comp->GetConvert() );
...@@ -727,8 +727,8 @@ XNODE* EXPORT_HELP::makeGenericLibParts() ...@@ -727,8 +727,8 @@ XNODE* EXPORT_HELP::makeGenericLibParts()
wxString sFprints = wxT( "footprints" ); wxString sFprints = wxT( "footprints" );
wxString sFp = wxT( "fp" ); wxString sFp = wxT( "fp" );
LIB_PIN_LIST pinList; LIB_PINS pinList;
LIB_FIELD_LIST fieldList; LIB_FIELDS fieldList;
m_Libraries.clear(); m_Libraries.clear();
......
...@@ -144,13 +144,15 @@ static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC ) ...@@ -144,13 +144,15 @@ static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC )
if( parent == NULL ) if( parent == NULL )
return; return;
LIB_PIN* CurrentPin = (LIB_PIN*) parent->GetDrawItem(); LIB_PIN* pin = (LIB_PIN*) parent->GetDrawItem();
if( CurrentPin == NULL || CurrentPin->Type() != LIB_PIN_T ) if( pin == NULL || pin->Type() != LIB_PIN_T )
return; return;
if( CurrentPin->IsNew() ) pin->ClearFlags();
delete CurrentPin;
if( pin->IsNew() )
delete pin;
else else
parent->RestoreComponent(); parent->RestoreComponent();
...@@ -408,7 +410,7 @@ static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorga ...@@ -408,7 +410,7 @@ static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorga
/* Create "convert" pin at the current position. */ /* Create "convert" pin at the current position. */
if( CreateConv == true ) if( CreateConv == true )
{ {
NewPin = (LIB_PIN*) Pin->GenCopy(); NewPin = (LIB_PIN*) Pin->Clone();
if( Pin->GetConvert() > 1 ) if( Pin->GetConvert() > 1 )
NewPin->SetConvert( 1 ); NewPin->SetConvert( 1 );
...@@ -423,7 +425,7 @@ static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorga ...@@ -423,7 +425,7 @@ static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorga
if( ii == unit || Pin->GetUnit() == 0 ) if( ii == unit || Pin->GetUnit() == 0 )
continue; /* Pin common to all units. */ continue; /* Pin common to all units. */
NewPin = (LIB_PIN*) Pin->GenCopy(); NewPin = (LIB_PIN*) Pin->Clone();
if( convert != 0 ) if( convert != 0 )
NewPin->SetConvert( 1 ); NewPin->SetConvert( 1 );
...@@ -434,7 +436,7 @@ static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorga ...@@ -434,7 +436,7 @@ static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorga
if( CreateConv == false ) if( CreateConv == false )
continue; continue;
NewPin = (LIB_PIN*) Pin->GenCopy(); NewPin = (LIB_PIN*) Pin->Clone();
NewPin->SetConvert( 2 ); NewPin->SetConvert( 2 );
if( Pin->GetUnit() != 0 ) if( Pin->GetUnit() != 0 )
...@@ -510,7 +512,7 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin ) ...@@ -510,7 +512,7 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
if( m_component == NULL || SourcePin == NULL || SourcePin->Type() != LIB_PIN_T ) if( m_component == NULL || SourcePin == NULL || SourcePin->Type() != LIB_PIN_T )
return; return;
Pin = (LIB_PIN*) SourcePin->GenCopy(); Pin = (LIB_PIN*) SourcePin->Clone();
Pin->m_Flags = IS_NEW; Pin->m_Flags = IS_NEW;
Pin->SetPosition( Pin->GetPosition() + wxPoint( g_RepeatStep.x, -g_RepeatStep.y ) ); Pin->SetPosition( Pin->GetPosition() + wxPoint( g_RepeatStep.x, -g_RepeatStep.y ) );
wxString nextName = Pin->GetName(); wxString nextName = Pin->GetName();
...@@ -573,7 +575,7 @@ void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event ) ...@@ -573,7 +575,7 @@ void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event )
int dup_error; int dup_error;
int offgrid_error; int offgrid_error;
LIB_PIN* Pin; LIB_PIN* Pin;
LIB_PIN_LIST PinList; LIB_PINS PinList;
wxString msg; wxString msg;
wxString aux_msg; wxString aux_msg;
......
...@@ -85,11 +85,11 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet ...@@ -85,11 +85,11 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet
m_Flags = IS_NEW | IS_MOVED; m_Flags = IS_NEW | IS_MOVED;
// Import user defined fields from the library component: // Import user defined fields from the library component:
LIB_FIELD_LIST libFields; LIB_FIELDS libFields;
libComponent.GetFields( libFields ); libComponent.GetFields( libFields );
for( LIB_FIELD_LIST::iterator it = libFields.begin(); it!=libFields.end(); ++it ) for( LIB_FIELDS::iterator it = libFields.begin(); it!=libFields.end(); ++it )
{ {
// Can no longer insert an empty name, since names are now keys. The // Can no longer insert an empty name, since names are now keys. The
// field index is not used beyond the first MANDATORY_FIELDS // field index is not used beyond the first MANDATORY_FIELDS
...@@ -1506,7 +1506,7 @@ bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, ...@@ -1506,7 +1506,7 @@ bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void* aAuxData,
if( Entry ) if( Entry )
{ {
LIB_PIN_LIST pinList; LIB_PINS pinList;
Entry->GetPins( pinList, m_unit, m_convert ); Entry->GetPins( pinList, m_unit, m_convert );
// Search for a match in pinList // Search for a match in pinList
...@@ -1611,7 +1611,7 @@ void SCH_COMPONENT::GetConnectionPoints( vector< wxPoint >& aPoints ) const ...@@ -1611,7 +1611,7 @@ void SCH_COMPONENT::GetConnectionPoints( vector< wxPoint >& aPoints ) const
} }
LIB_DRAW_ITEM* SCH_COMPONENT::GetDrawItem( const wxPoint& aPosition, KICAD_T aType ) LIB_ITEM* SCH_COMPONENT::GetDrawItem( const wxPoint& aPosition, KICAD_T aType )
{ {
LIB_COMPONENT* component = CMP_LIBRARY::FindLibraryComponent( m_ChipName ); LIB_COMPONENT* component = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
...@@ -1663,7 +1663,7 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR* aInspector, const void* aTestData ...@@ -1663,7 +1663,7 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR* aInspector, const void* aTestData
if( component != NULL ) if( component != NULL )
{ {
LIB_PIN_LIST pins; LIB_PINS pins;
component->GetPins( pins, m_unit, m_convert ); component->GetPins( pins, m_unit, m_convert );
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
class SCH_SHEET_PATH; class SCH_SHEET_PATH;
class LIB_DRAW_ITEM; class LIB_ITEM;
class LIB_PIN; class LIB_PIN;
class LIB_COMPONENT; class LIB_COMPONENT;
...@@ -357,7 +357,7 @@ public: ...@@ -357,7 +357,7 @@ public:
* @param aType - Type of component library object to find or any if set to TYPE_NOT_INIT. * @param aType - Type of component library object to find or any if set to TYPE_NOT_INIT.
* @return A pointer to the component library object if found, otherwise NULL. * @return A pointer to the component library object if found, otherwise NULL.
*/ */
LIB_DRAW_ITEM* GetDrawItem( const wxPoint& aPosition, KICAD_T aType = TYPE_NOT_INIT ); LIB_ITEM* GetDrawItem( const wxPoint& aPosition, KICAD_T aType = TYPE_NOT_INIT );
virtual wxString GetSelectMenuText() const; virtual wxString GetSelectMenuText() const;
......
...@@ -631,7 +631,7 @@ wxString SCH_TEXT::GetSelectMenuText() const ...@@ -631,7 +631,7 @@ wxString SCH_TEXT::GetSelectMenuText() const
tmp =( tmp.Length() > 15 ) ? tmp.Left( 12 ) + wxT( "..." ) : tmp; tmp =( tmp.Length() > 15 ) ? tmp.Left( 12 ) + wxT( "..." ) : tmp;
wxString msg; wxString msg;
msg.Printf(_( "Graphic Text %s" ), GetChars(tmp)); msg.Printf( _( "Graphic Text %s" ), GetChars( tmp ) );
return msg; return msg;
} }
......
...@@ -129,8 +129,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) ...@@ -129,8 +129,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
SCH_EDIT_FRAME::OnChangeComponentOrientation ) SCH_EDIT_FRAME::OnChangeComponentOrientation )
// Multple item selection context menu commands. // Multple item selection context menu commands.
EVT_MENU_RANGE( ID_SCH_SELECT_ITEM_START, ID_SCH_SELECT_ITEM_END, EVT_MENU_RANGE( ID_SELECT_ITEM_START, ID_SELECT_ITEM_END, SCH_EDIT_FRAME::OnSelectItem )
SCH_EDIT_FRAME::OnSelectItem )
/* Handle user interface update events. */ /* Handle user interface update events. */
EVT_UPDATE_UI( wxID_CUT, SCH_EDIT_FRAME::OnUpdateBlockSelected ) EVT_UPDATE_UI( wxID_CUT, SCH_EDIT_FRAME::OnUpdateBlockSelected )
...@@ -769,19 +768,19 @@ void SCH_EDIT_FRAME::SVG_Print( wxCommandEvent& event ) ...@@ -769,19 +768,19 @@ void SCH_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode) * @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not used here) * @param aData = a pointer on an auxiliary data (not used here)
*/ */
void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData )
bool aPrintMirrorMode, void* aData)
{ {
GetScreen()->Draw( DrawPanel, aDC, GR_DEFAULT_DRAWMODE ); GetScreen()->Draw( DrawPanel, aDC, GR_DEFAULT_DRAWMODE );
TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness ); TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness );
} }
void SCH_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent ) void SCH_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
{ {
int id = aEvent.GetId(); int id = aEvent.GetId();
int index = id - ID_SCH_SELECT_ITEM_START; int index = id - ID_SELECT_ITEM_START;
if( (id >= ID_SCH_SELECT_ITEM_START && id <= ID_SCH_SELECT_ITEM_END) if( (id >= ID_SELECT_ITEM_START && id <= ID_SELECT_ITEM_END)
&& (index >= 0 && index < m_collectedItems.GetCount()) ) && (index >= 0 && index < m_collectedItems.GetCount()) )
{ {
SCH_ITEM* item = m_collectedItems[index]; SCH_ITEM* item = m_collectedItems[index];
......
...@@ -32,7 +32,7 @@ static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx ...@@ -32,7 +32,7 @@ static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
/* /*
* Show the dialog box for editing a graphical item properties * Show the dialog box for editing a graphical item properties
*/ */
void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem )
{ {
if( DrawItem == NULL ) if( DrawItem == NULL )
return; return;
...@@ -102,7 +102,7 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem ) ...@@ -102,7 +102,7 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC ) static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC )
{ {
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) Panel->GetParent(); LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) Panel->GetParent();
LIB_DRAW_ITEM* item = parent->GetDrawItem(); LIB_ITEM* item = parent->GetDrawItem();
if( item == NULL ) if( item == NULL )
return; return;
...@@ -122,7 +122,7 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC ) ...@@ -122,7 +122,7 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC )
} }
LIB_DRAW_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC ) LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC )
{ {
DrawPanel->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn ); DrawPanel->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn );
wxPoint drawPos = GetScreen()->GetCrossHairPosition( true ); wxPoint drawPos = GetScreen()->GetCrossHairPosition( true );
...@@ -229,7 +229,7 @@ void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC ) ...@@ -229,7 +229,7 @@ void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC )
static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase ) bool aErase )
{ {
LIB_DRAW_ITEM* item; LIB_ITEM* item;
item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem(); item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem();
...@@ -286,7 +286,7 @@ static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& ...@@ -286,7 +286,7 @@ static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
bool aErase ) bool aErase )
{ {
BASE_SCREEN* Screen = aPanel->GetScreen(); BASE_SCREEN* Screen = aPanel->GetScreen();
LIB_DRAW_ITEM* item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem(); LIB_ITEM* item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem();
if( item == NULL ) if( item == NULL )
return; return;
......
...@@ -86,9 +86,9 @@ void LIB_EDIT_FRAME::LoadOneSymbol( void ) ...@@ -86,9 +86,9 @@ void LIB_EDIT_FRAME::LoadOneSymbol( void )
} }
Component = Lib->GetFirstEntry()->GetComponent(); Component = Lib->GetFirstEntry()->GetComponent();
LIB_DRAW_ITEM_LIST& drawList = Component->GetDrawItemList(); LIB_ITEMS& drawList = Component->GetDrawItemList();
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawList ) BOOST_FOREACH( LIB_ITEM& item, drawList )
{ {
if( item.Type() == LIB_FIELD_T ) if( item.Type() == LIB_FIELD_T )
continue; continue;
...@@ -99,7 +99,7 @@ void LIB_EDIT_FRAME::LoadOneSymbol( void ) ...@@ -99,7 +99,7 @@ void LIB_EDIT_FRAME::LoadOneSymbol( void )
item.m_Flags = IS_NEW; item.m_Flags = IS_NEW;
item.m_Selected = IS_SELECTED; item.m_Selected = IS_SELECTED;
LIB_DRAW_ITEM* newItem = item.GenCopy(); LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
newItem->SetParent( m_component ); newItem->SetParent( m_component );
m_component->AddDrawItem( newItem ); m_component->AddDrawItem( newItem );
} }
...@@ -196,9 +196,9 @@ void LIB_EDIT_FRAME::SaveOneSymbol() ...@@ -196,9 +196,9 @@ void LIB_EDIT_FRAME::SaveOneSymbol()
|| !file.Write( wxT( "DRAW\n" ) ) ) || !file.Write( wxT( "DRAW\n" ) ) )
return; return;
LIB_DRAW_ITEM_LIST& drawList = m_component->GetDrawItemList(); LIB_ITEMS& drawList = m_component->GetDrawItemList();
BOOST_FOREACH( LIB_DRAW_ITEM& item, drawList ) BOOST_FOREACH( LIB_ITEM& item, drawList )
{ {
if( item.Type() == LIB_FIELD_T ) if( item.Type() == LIB_FIELD_T )
continue; continue;
......
...@@ -576,6 +576,24 @@ public: ...@@ -576,6 +576,24 @@ public:
*/ */
virtual const char** GetMenuImage() const { return (const char**) right_xpm; } virtual const char** GetMenuImage() const { return (const char**) right_xpm; }
/**
* Test if another item is less than this object.
*
* @param aItem - Item to compare against.
* @return - True if \a aItem is less than the item.
*/
bool operator<( const EDA_ITEM& aItem ) const;
/**
* Function Sort
* is a helper function to be used by the C++ STL sort algorithm for sorting a STL
* container of EDA_ITEM pointers.
*
* @param aLeft The left hand item to compare.
* @param aRight The right hand item to compare.
* @return True if \a aLeft is less than \a aRight.
*/
static bool Sort( const EDA_ITEM* aLeft, const EDA_ITEM* aRight ) { return *aLeft < *aRight; }
#if defined(DEBUG) #if defined(DEBUG)
......
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