From bcbde5d813121020d54a57949d0834b06ffc8048 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 7 Dec 2011 16:49:32 +0100 Subject: [PATCH] All: fix a collision name between accessor function GetTimeStamp and GetTimeStamp in common.cpp. In common.cpp GetTimeStamp is renamed GetNewTimeStamp (a better name). Pcbnew: prepare work to calculate connections between pads that inteserct and therefore can be connected without any track (composite pads). --- common/common.cpp | 15 +- eeschema/block.cpp | 2 +- eeschema/bus-wire-junction.cpp | 2 +- eeschema/class_library.cpp | 2 +- eeschema/erc.cpp | 4 +- eeschema/events_called_functions_for_edit.cpp | 2 +- eeschema/operations_on_items_lists.cpp | 4 +- eeschema/sch_component.cpp | 2 +- eeschema/sch_screen.cpp | 4 +- eeschema/sch_sheet.cpp | 6 +- eeschema/sheet.cpp | 4 +- include/class_board_item.h | 187 ---------------- include/class_collector.h | 7 +- include/common.h | 5 +- include/wxBasePcbFrame.h | 1 + pcbnew/block.cpp | 4 +- pcbnew/class_board_connected_item.h | 206 ++++++++++++++++++ pcbnew/class_dimension.cpp | 2 +- pcbnew/class_mire.cpp | 2 +- pcbnew/class_module.cpp | 2 +- pcbnew/class_pad.cpp | 2 +- pcbnew/class_pad.h | 2 +- pcbnew/class_track.h | 1 + pcbnew/class_zone.cpp | 4 +- pcbnew/class_zone.h | 1 + .../dialog_edit_module_for_BoardEditor.cpp | 2 +- pcbnew/item_io.cpp | 4 +- pcbnew/loadcmp.cpp | 2 +- pcbnew/modedit.cpp | 2 +- pcbnew/muonde.cpp | 2 +- pcbnew/netlist.cpp | 4 +- pcbnew/zones_by_polygon.cpp | 2 +- pcbnew/zones_test_and_combine_areas.cpp | 2 +- 33 files changed, 260 insertions(+), 233 deletions(-) create mode 100644 pcbnew/class_board_connected_item.h diff --git a/common/common.cpp b/common/common.cpp index 804e0ee5cb..14d5fc8a96 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -525,18 +525,19 @@ bool ProcessExecute( const wxString& aCommandLine, int aFlags ) } -int GetTimeStamp() +unsigned long GetNewTimeStamp() { - static int OldTimeStamp, NewTimeStamp; + static unsigned long oldTimeStamp; + unsigned long newTimeStamp; - NewTimeStamp = time( NULL ); + newTimeStamp = time( NULL ); - if( NewTimeStamp <= OldTimeStamp ) - NewTimeStamp = OldTimeStamp + 1; + if( newTimeStamp <= oldTimeStamp ) + newTimeStamp = oldTimeStamp + 1; - OldTimeStamp = NewTimeStamp; + oldTimeStamp = newTimeStamp; - return NewTimeStamp; + return newTimeStamp; } diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 069a909f71..4c7d0b3145 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -554,7 +554,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC ) // Clear annotation and init new time stamp for the new components: if( Struct->Type() == SCH_COMPONENT_T ) { - ( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp(); + ( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetNewTimeStamp(); ( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL ); } diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 4dd996abcb..e6093423cd 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -527,7 +527,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) wxPoint pos = GetScreen()->GetCrossHairPosition() - ( (SCH_COMPONENT*) m_itemToRepeat )->GetPosition(); m_itemToRepeat->SetFlags( IS_NEW ); - ( (SCH_COMPONENT*) m_itemToRepeat )->m_TimeStamp = GetTimeStamp(); + ( (SCH_COMPONENT*) m_itemToRepeat )->m_TimeStamp = GetNewTimeStamp(); m_itemToRepeat->Move( pos ); m_itemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); MoveItem( m_itemToRepeat, DC ); diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index d95615c2ee..0d7b0ee03f 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -673,7 +673,7 @@ bool CMP_LIBRARY::Save( OUTPUTFORMATTER& aFormatter ) { if( isModified ) { - timeStamp = GetTimeStamp(); + timeStamp = GetNewTimeStamp(); isModified = false; } diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index dbeaef2f87..7d50ae8e85 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -204,7 +204,7 @@ int TestDuplicateSheetNames( bool aCreateMarker ) { /* Create a new marker type ERC error*/ SCH_MARKER* marker = new SCH_MARKER(); - marker->m_TimeStamp = GetTimeStamp(); + marker->m_TimeStamp = GetNewTimeStamp(); marker->SetData( ERCE_DUPLICATE_SHEET_NAME, ( (SCH_SHEET*) test_item )->m_Pos, _( "Duplicate sheet name" ), @@ -237,7 +237,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, /* Create new marker for ERC error. */ marker = new SCH_MARKER(); - marker->m_TimeStamp = GetTimeStamp(); + marker->m_TimeStamp = GetNewTimeStamp(); marker->SetMarkerType( MARK_ERC ); marker->SetErrorLevel( WAR ); diff --git a/eeschema/events_called_functions_for_edit.cpp b/eeschema/events_called_functions_for_edit.cpp index 9edaa4872b..29bd68eb01 100644 --- a/eeschema/events_called_functions_for_edit.cpp +++ b/eeschema/events_called_functions_for_edit.cpp @@ -29,7 +29,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) { SCH_COMPONENT* newitem; newitem = new SCH_COMPONENT( *( (SCH_COMPONENT*) curr_item ) ); - newitem->m_TimeStamp = GetTimeStamp(); + newitem->m_TimeStamp = GetNewTimeStamp(); newitem->ClearAnnotation( NULL ); newitem->m_Flags = IS_NEW; MoveItem( (SCH_ITEM*) newitem, &dc ); diff --git a/eeschema/operations_on_items_lists.cpp b/eeschema/operations_on_items_lists.cpp index da1c6f6927..ef7ea0fd22 100644 --- a/eeschema/operations_on_items_lists.cpp +++ b/eeschema/operations_on_items_lists.cpp @@ -207,13 +207,13 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, case SCH_SHEET_T: { SCH_SHEET* sheet = (SCH_SHEET*) newitem; - sheet->m_TimeStamp = GetTimeStamp(); + sheet->m_TimeStamp = GetNewTimeStamp(); sheet->SetSon( NULL ); break; } case SCH_COMPONENT_T: - ( (SCH_COMPONENT*) newitem )->m_TimeStamp = GetTimeStamp(); + ( (SCH_COMPONENT*) newitem )->m_TimeStamp = GetNewTimeStamp(); ( (SCH_COMPONENT*) newitem )->ClearAnnotation( NULL ); break; } diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 60d6208282..3b3f8f7262 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -130,7 +130,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet m_unit = unit; m_convert = convert; m_ChipName = libComponent.GetName(); - m_TimeStamp = GetTimeStamp(); + m_TimeStamp = GetNewTimeStamp(); if( setNewItemFlag ) m_Flags = IS_NEW | IS_MOVED; diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 9752dbbb1d..783197ded5 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1460,14 +1460,14 @@ int SCH_SCREENS::ReplaceDuplicateTimeStamps() // for a component, update its Time stamp and its paths // (m_PathsAndReferences field) if( item->Type() == SCH_COMPONENT_T ) - ( (SCH_COMPONENT*) item )->SetTimeStamp( GetTimeStamp() ); + ( (SCH_COMPONENT*) item )->SetTimeStamp( GetNewTimeStamp() ); // for a sheet, update only its time stamp (annotation of its // components will be lost) // @todo: see how to change sheet paths for its cmp list (can // be possible in most cases) else - item->m_TimeStamp = GetTimeStamp(); + item->m_TimeStamp = GetNewTimeStamp(); } } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 2169fa4458..19704fa7c1 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -53,7 +53,7 @@ SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : m_Layer = LAYER_SHEET; m_Pos = pos; m_Size = wxSize( MIN_SHEET_WIDTH, MIN_SHEET_HEIGHT ); - m_TimeStamp = GetTimeStamp(); + m_TimeStamp = GetNewTimeStamp(); m_SheetNameSize = m_FileNameSize = 60; m_AssociatedScreen = NULL; m_SheetName.Printf( wxT( "Sheet%8.8lX" ), m_TimeStamp ); @@ -184,7 +184,7 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg ) SCH_SHEET_PIN* sheetPin; char* ptcar; - m_TimeStamp = GetTimeStamp(); + m_TimeStamp = GetNewTimeStamp(); // sheets are added to the GetDrawItems() like other schematic components. // however, in order to preserve the hierarchy (through m_Parent pointers), @@ -224,7 +224,7 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg ) { sscanf( ((char*)aLine) + 1, "%lX", &m_TimeStamp ); if( m_TimeStamp == 0 ) // zero is not unique! - m_TimeStamp = GetTimeStamp(); + m_TimeStamp = GetNewTimeStamp(); continue; } diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 604805e7a6..1f7d52ee7b 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -201,7 +201,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) m_InternalUnits ); if( aSheet->m_SheetName.IsEmpty() ) - aSheet->m_SheetName.Printf( wxT( "Sheet%8.8lX" ), GetTimeStamp() ); + aSheet->m_SheetName.Printf( wxT( "Sheet%8.8lX" ), aSheet->GetTimeStamp() ); DrawPanel->MoveCursorToCrossHair(); DrawPanel->m_IgnoreMouseEvents = false; @@ -311,7 +311,7 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC ) SCH_SHEET* sheet = new SCH_SHEET( GetScreen()->GetCrossHairPosition() ); sheet->SetFlags( IS_NEW | IS_RESIZED ); - sheet->m_TimeStamp = GetTimeStamp(); + sheet->m_TimeStamp = GetNewTimeStamp(); sheet->SetParent( GetScreen() ); sheet->SetScreen( NULL ); diff --git a/include/class_board_item.h b/include/class_board_item.h index dedb352fed..030378007c 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -224,191 +224,4 @@ public: wxString GetLayerName() const; }; - -class NETCLASS; - -/** - * Class BOARD_CONNECTED_ITEM - * This is a base class derived from BOARD_ITEM for items that can be connected - * and have a net, a netname, a clearance ... - * mainly: tracks, pads and zones - * Handle connection info - */ -class BOARD_CONNECTED_ITEM : public BOARD_ITEM -{ -protected: - int m_NetCode; // Net number - - int m_Subnet; /* In rastnest routines : for the current net, block number - * (number common to the current connected items found) - */ - - int m_ZoneSubnet; // variable used in rastnest computations : for the current net, - // handle block number in zone connection - -public: - BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ); - BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& src ); - - /** - * Function GetNet - * @return int - the net code. - */ - int GetNet() const; - virtual void SetNet( int aNetCode ); - - /** - * Function GetSubNet - * @return int - the sub net code. - */ - int GetSubNet() const; - void SetSubNet( int aSubNetCode ); - - /** - * Function GetZoneSubNet - * @return int - the sub net code in zone connections. - */ - int GetZoneSubNet() const; - void SetZoneSubNet( int aSubNetCode ); - - /** - * Function GetClearance - * returns the clearance in 1/10000 inches. If \a aItem is not NULL then the - * returned clearance is the greater of this object's NETCLASS clearance and - * aItem's NETCLASS clearance. If \a aItem is NULL, then this objects clearance - * is returned. - * @param aItem is another BOARD_CONNECTED_ITEM or NULL - * @return int - the clearance in 1/10000 inches. - */ - virtual int GetClearance( BOARD_CONNECTED_ITEM* aItem = NULL ) const; - - /** - * Function GetNetClass - * returns the NETCLASS for this item. - */ - NETCLASS* GetNetClass() const; - - /** - * Function GetNetClassName - * @return the Net Class name of this item - */ - wxString GetNetClassName() const; -}; - - -/* - * class BOARD_ITEM_LIST - * Handles a collection of BOARD_ITEM elements - */ -class BOARD_ITEM_LIST : public BOARD_ITEM -{ - typedef boost::ptr_vector ITEM_ARRAY; - - ITEM_ARRAY myItems; - - BOARD_ITEM_LIST( const BOARD_ITEM_LIST& other ) : - BOARD_ITEM( NULL, PCB_ITEM_LIST_T ) - { - // copy constructor is not supported, is private to cause compiler error - } - -public: - - BOARD_ITEM_LIST( BOARD_ITEM* aParent = NULL ) : - BOARD_ITEM( aParent, PCB_ITEM_LIST_T ) - {} - - //-----< satisfy some virtual functions >------------------------------ - const wxPoint GetPosition() - { - return wxPoint(0, 0); // dummy - } - - void Draw( EDA_DRAW_PANEL* DrawPanel, wxDC* DC, - int aDrawMode, const wxPoint& offset = ZeroOffset ) - { - } - - void UnLink() - { - /* if it were needed: - DHEAD* list = GetList(); - - wxASSERT( list ); - - list->remove( this ); - */ - } - - bool Save( FILE* aFile ) const - { - return true; - } - - //---------------------------------- - - - /** - * Function GetCount - * returns the number of BOARD_ITEMs. - */ - int GetCount() const - { - return myItems.size(); - } - - void Append( BOARD_ITEM* aItem ) - { - myItems.push_back( aItem ); - } - - BOARD_ITEM* Replace( int aIndex, BOARD_ITEM* aItem ) - { - ITEM_ARRAY::auto_type ret = myItems.replace( aIndex, aItem ); - return ret.release(); - } - - BOARD_ITEM* Remove( int aIndex ) - { - ITEM_ARRAY::auto_type ret = myItems.release( myItems.begin()+aIndex ); - return ret.release(); - } - - void Insert( int aIndex, BOARD_ITEM* aItem ) - { - myItems.insert( myItems.begin()+aIndex, aItem ); - } - - BOARD_ITEM* At( int aIndex ) const - { - // we have varying sized objects and are using polymorphism, so we - // must return a pointer not a reference. - return (BOARD_ITEM*) &myItems[aIndex]; - } - - BOARD_ITEM* operator[]( int aIndex ) const - { - return At( aIndex ); - } - - void Delete( int aIndex ) - { - myItems.erase( myItems.begin()+aIndex ); - } - - void PushBack( BOARD_ITEM* aItem ) - { - Append( aItem ); - } - - BOARD_ITEM* PopBack() - { - if( GetCount() ) - return Remove( GetCount()-1 ); - - return NULL; - } -}; - - #endif /* BOARD_ITEM_STRUCT_H */ diff --git a/include/class_collector.h b/include/class_collector.h index 436745c4a6..e8f2174191 100644 --- a/include/class_collector.h +++ b/include/class_collector.h @@ -34,7 +34,7 @@ #include "fctsys.h" #include "base_struct.h" // SEARCH_RESULT -#include "common.h" // GetTimeStamp() +#include "common.h" // GetNewTimeStamp() class EDA_ITEM; @@ -201,7 +201,7 @@ public: void SetTimeNow() { - m_TimeAtCollection = GetTimeStamp(); + m_TimeAtCollection = GetNewTimeStamp(); } @@ -234,7 +234,8 @@ public: int dx = abs( aRefPos.x - m_RefPos.x ); int dy = abs( aRefPos.y - m_RefPos.y ); - if( dx <= distMax && dy <= distMax && GetTimeStamp()-m_TimeAtCollection <= timeMax ) + if( dx <= distMax && dy <= distMax && + (int)GetNewTimeStamp() - m_TimeAtCollection <= timeMax ) return true; else return false; diff --git a/include/common.h b/include/common.h index 75a170e24e..b6a0651ce6 100644 --- a/include/common.h +++ b/include/common.h @@ -294,7 +294,10 @@ void InitKiCadAbout( wxAboutDialogInfo& info ); /* common.cpp */ /**************/ -int GetTimeStamp(); +/** + * @return an unique time stamp that changes after each call + */ +unsigned long GetNewTimeStamp(); int DisplayColorFrame( wxWindow* parent, int OldColor ); int GetCommandOptions( const int argc, const char** argv, diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index d2059e4122..eaad68fda6 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -47,6 +47,7 @@ /* Forward declarations of classes. */ class FOOTPRINT_EDIT_FRAME; class BOARD; +class BOARD_CONNECTED_ITEM; class MODULE; class TRACK; class D_PAD; diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index 041cc51082..5e6946f0e0 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -854,7 +854,7 @@ void PCB_EDIT_FRAME::Block_Duplicate() module->m_Flags = 0; newitem = new_module = new MODULE( m_Pcb ); new_module->Copy( module ); - new_module->m_TimeStamp = GetTimeStamp(); + new_module->m_TimeStamp = GetNewTimeStamp(); m_Pcb->m_Modules.PushFront( new_module ); } break; @@ -877,7 +877,7 @@ void PCB_EDIT_FRAME::Block_Duplicate() { ZONE_CONTAINER* new_zone = new ZONE_CONTAINER( (BOARD*) item->GetParent() ); new_zone->Copy( (ZONE_CONTAINER*) item ); - new_zone->m_TimeStamp = GetTimeStamp(); + new_zone->m_TimeStamp = GetNewTimeStamp(); newitem = new_zone; m_Pcb->Add( new_zone ); } diff --git a/pcbnew/class_board_connected_item.h b/pcbnew/class_board_connected_item.h new file mode 100644 index 0000000000..e711b09e3b --- /dev/null +++ b/pcbnew/class_board_connected_item.h @@ -0,0 +1,206 @@ +/** + * @file class_board_connected_item.h + * @brief Class BOARD_CONNECTED_ITEM. + */ + +#ifndef BOARD_CONNECTED_ITEM_H +#define BOARD_CONNECTED_ITEM_H + + +#include "class_board_item.h" + +class NETCLASS; +class TRACK; +class D_PAD; + +/** + * Class BOARD_CONNECTED_ITEM + * This is a base class derived from BOARD_ITEM for items that can be connected + * and have a net, a netname, a clearance ... + * mainly: tracks, pads and zones + * Handle connection info + */ +class BOARD_CONNECTED_ITEM : public BOARD_ITEM +{ + friend class CONNECTIONS; + +private: + // These 2 members are used for temporary storage during connections calculations: + std::vector m_TracksConnected; // list of other tracks connected to me + std::vector m_PadsConnected; // list of other pads connected to me + + int m_NetCode; // Net number + + int m_Subnet; /* In rastnest routines : for the current net, block number + * (number common to the current connected items found) + */ + + int m_ZoneSubnet; // used in rastnest computations : for the current net, + // handle cluster number in zone connection + +public: + BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ); + BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& src ); + + /** + * Function GetNet + * @return int - the net code. + */ + int GetNet() const; + virtual void SetNet( int aNetCode ); + + /** + * Function GetSubNet + * @return int - the sub net code. + */ + int GetSubNet() const; + void SetSubNet( int aSubNetCode ); + + /** + * Function GetZoneSubNet + * @return int - the sub net code in zone connections. + */ + int GetZoneSubNet() const; + void SetZoneSubNet( int aSubNetCode ); + + /** + * Function GetClearance + * returns the clearance in 1/10000 inches. If \a aItem is not NULL then the + * returned clearance is the greater of this object's NETCLASS clearance and + * aItem's NETCLASS clearance. If \a aItem is NULL, then this objects clearance + * is returned. + * @param aItem is another BOARD_CONNECTED_ITEM or NULL + * @return int - the clearance in 1/10000 inches. + */ + virtual int GetClearance( BOARD_CONNECTED_ITEM* aItem = NULL ) const; + + /** + * Function GetNetClass + * returns the NETCLASS for this item. + */ + NETCLASS* GetNetClass() const; + + /** + * Function GetNetClassName + * @return the Net Class name of this item + */ + wxString GetNetClassName() const; +}; + + +/* + * class BOARD_ITEM_LIST + * Handles a collection of BOARD_ITEM elements + */ +class BOARD_ITEM_LIST : public BOARD_ITEM +{ + typedef boost::ptr_vector ITEM_ARRAY; + + ITEM_ARRAY myItems; + + BOARD_ITEM_LIST( const BOARD_ITEM_LIST& other ) : + BOARD_ITEM( NULL, PCB_ITEM_LIST_T ) + { + // copy constructor is not supported, is private to cause compiler error + } + +public: + + BOARD_ITEM_LIST( BOARD_ITEM* aParent = NULL ) : + BOARD_ITEM( aParent, PCB_ITEM_LIST_T ) + {} + + //-----< satisfy some virtual functions >------------------------------ + const wxPoint GetPosition() + { + return wxPoint(0, 0); // dummy + } + + void Draw( EDA_DRAW_PANEL* DrawPanel, wxDC* DC, + int aDrawMode, const wxPoint& offset = ZeroOffset ) + { + } + + void UnLink() + { + /* if it were needed: + DHEAD* list = GetList(); + + wxASSERT( list ); + + list->remove( this ); + */ + } + + bool Save( FILE* aFile ) const + { + return true; + } + + //---------------------------------- + + + /** + * Function GetCount + * returns the number of BOARD_ITEMs. + */ + int GetCount() const + { + return myItems.size(); + } + + void Append( BOARD_ITEM* aItem ) + { + myItems.push_back( aItem ); + } + + BOARD_ITEM* Replace( int aIndex, BOARD_ITEM* aItem ) + { + ITEM_ARRAY::auto_type ret = myItems.replace( aIndex, aItem ); + return ret.release(); + } + + BOARD_ITEM* Remove( int aIndex ) + { + ITEM_ARRAY::auto_type ret = myItems.release( myItems.begin()+aIndex ); + return ret.release(); + } + + void Insert( int aIndex, BOARD_ITEM* aItem ) + { + myItems.insert( myItems.begin()+aIndex, aItem ); + } + + BOARD_ITEM* At( int aIndex ) const + { + // we have varying sized objects and are using polymorphism, so we + // must return a pointer not a reference. + return (BOARD_ITEM*) &myItems[aIndex]; + } + + BOARD_ITEM* operator[]( int aIndex ) const + { + return At( aIndex ); + } + + void Delete( int aIndex ) + { + myItems.erase( myItems.begin()+aIndex ); + } + + void PushBack( BOARD_ITEM* aItem ) + { + Append( aItem ); + } + + BOARD_ITEM* PopBack() + { + if( GetCount() ) + return Remove( GetCount()-1 ); + + return NULL; + } +}; + + +#endif /* BOARD_CONNECTED_ITEM_H */ diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index d10ab67d92..6e80cebd8c 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -71,7 +71,7 @@ void DIMENSION::Copy( DIMENSION* source ) m_Pos = source->m_Pos; m_Shape = source->m_Shape; m_Unit = source->m_Unit; - m_TimeStamp = GetTimeStamp(); + m_TimeStamp = GetNewTimeStamp(); m_Text->Copy( source->m_Text ); m_crossBarOx = source->m_crossBarOx; diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index 161c2d7605..33d0d168f3 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -50,7 +50,7 @@ void PCB_TARGET::Copy( PCB_TARGET* source ) m_Pos = source->m_Pos; m_Shape = source->m_Shape; m_Size = source->m_Size; - m_TimeStamp = GetTimeStamp(); + m_TimeStamp = GetNewTimeStamp(); } diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index a8c8d750a1..34aeaf17c8 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -125,7 +125,7 @@ void MODULE::Copy( MODULE* aModule ) m_LastEdit_Time = aModule->m_LastEdit_Time; m_Link = aModule->m_Link; m_Path = aModule->m_Path; //is this correct behavior? - m_TimeStamp = GetTimeStamp(); + m_TimeStamp = GetNewTimeStamp(); m_LocalClearance = aModule->m_LocalClearance; m_LocalSolderMaskMargin = aModule->m_LocalSolderMaskMargin; diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index c726e4029f..35ff4e6902 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -393,7 +393,7 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) /* For test and debug only: display m_physical_connexion and * m_logical_connexion */ #if 1 // Used only to debug connectivity calculations - Line.Printf( wxT( "%d-%d-%d " ), GetSubRatsnest(), GetSubNet(), m_ZoneSubnet ); + Line.Printf( wxT( "%d-%d-%d " ), GetSubRatsnest(), GetSubNet(), GetZoneSubNet() ); frame->AppendMsgPanel( wxT( "L-P-Z" ), Line, DARKGREEN ); #endif diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 09fd998774..2306d9fe26 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -8,6 +8,7 @@ #include "class_board_item.h" +#include "class_board_connected_item.h" #include "pad_shapes.h" #include "PolyLine.h" @@ -131,7 +132,6 @@ public: int m_LocalSolderPasteMargin; // Local solder paste margin absolute value double m_LocalSolderPasteMarginRatio; // Local solder mask margin ratio value of pad size // The final margin is the sum of these 2 values - std::vector m_TracksConnected; // list of other tracks connected to me private: int m_SubRatsnest; // variable used in rats nest computations diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 5fdc738080..3d807af709 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -8,6 +8,7 @@ #include "class_board_item.h" +#include "class_board_connected_item.h" #include "PolyLine.h" diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 8bbdcd0eb0..bbedb78cc1 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -51,7 +51,7 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) : BOARD_CONNECTED_ITEM( parent, PCB_ZONE_AREA_T ) { - m_NetCode = -1; // Net number for fast comparisons + SetNet( -1 ); // Net number for fast comparisons m_CornerSelection = -1; m_IsFilled = false; // fill status : true when the zone is filled m_FillMode = 0; // How to fill areas: 0 = use filled polygons, != 0 fill with segments @@ -95,7 +95,7 @@ void ZONE_CONTAINER::SetPosition( const wxPoint& aPos ) {} void ZONE_CONTAINER::SetNet( int aNetCode ) { - m_NetCode = aNetCode; + BOARD_CONNECTED_ITEM::SetNet( aNetCode ); if( aNetCode < 0 ) return; diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 89b82dd48b..3b5b90ce56 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -10,6 +10,7 @@ #include #include "gr_basic.h" #include "class_board_item.h" +#include "class_board_connected_item.h" #include "layers_id_colors_and_visibility.h" #include "PolyLine.h" #include "class_zone_setting.h" diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 7c9aa7d2e5..f3ab292a78 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -146,7 +146,7 @@ void DIALOG_MODULE_BOARD_EDITOR::GotoModuleEditor( wxCommandEvent& event ) if( m_CurrentModule->m_TimeStamp == 0 ) // Module Editor needs a non // null timestamp { - m_CurrentModule->m_TimeStamp = GetTimeStamp(); + m_CurrentModule->m_TimeStamp = GetNewTimeStamp(); m_Parent->OnModify(); } diff --git a/pcbnew/item_io.cpp b/pcbnew/item_io.cpp index c662987a15..0c35812af6 100644 --- a/pcbnew/item_io.cpp +++ b/pcbnew/item_io.cpp @@ -225,7 +225,7 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const // Save the outline main info ret = fprintf( aFile, "ZInfo %8.8lX %d %s\n", - m_TimeStamp, m_NetCode, + m_TimeStamp, GetNet(), EscapedUTF8( m_Netname ).c_str() ); if( ret < 3 ) @@ -1739,7 +1739,7 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) else { m_TimeStamp = ts; - m_NetCode = netcode; + SetNet( netcode ); ReadDelimitedText( netname_buffer, netname_buffer, 1024 ); m_Netname = FROM_UTF8( netname_buffer ); } diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index a65b75033a..9ba14b7f1d 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -185,7 +185,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC* module->m_Flags = IS_NEW; module->m_Link = 0; - module->m_TimeStamp = GetTimeStamp(); + module->m_TimeStamp = GetNewTimeStamp(); GetBoard()->m_Status_Pcb = 0; module->SetPosition( curspos ); diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index d5176ca4bb..49a4eede85 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -336,7 +336,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) pcbframe->GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); pcbframe->PlaceModule( newmodule, NULL ); pcbframe->GetScreen()->SetCrossHairPosition( cursor_pos ); - newmodule->m_TimeStamp = GetTimeStamp(); + newmodule->m_TimeStamp = GetNewTimeStamp(); pcbframe->SaveCopyInUndoList( newmodule, UR_NEW ); } diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index bc56d8120f..251f931c48 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -532,7 +532,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c return NULL; #define DEFAULT_SIZE 30 - Module->m_TimeStamp = GetTimeStamp(); + Module->m_TimeStamp = GetNewTimeStamp(); Module->m_Value->m_Size = wxSize( DEFAULT_SIZE, DEFAULT_SIZE ); Module->m_Value->m_Pos0.y = -DEFAULT_SIZE; Module->m_Value->m_Pos.y += Module->m_Value->m_Pos0.y; diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index 1db3f98e85..c00418f62d 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -1160,7 +1160,7 @@ bool NETLIST_READER::loadNewModules() /* Update schematic links : reference "Time Stamp" and schematic * hierarchical path */ Module->m_Reference->m_Text = cmp->m_CmpName; - Module->m_TimeStamp = GetTimeStamp(); + Module->m_TimeStamp = GetNewTimeStamp(); Module->m_Path = cmp->m_TimeStampPath; } else @@ -1176,7 +1176,7 @@ bool NETLIST_READER::loadNewModules() Module = newmodule; Module->m_Reference->m_Text = cmp->m_CmpName; - Module->m_TimeStamp = GetTimeStamp(); + Module->m_TimeStamp = GetNewTimeStamp(); Module->m_Path = cmp->m_TimeStampPath; } } diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 6bf1b47102..d7424ebec8 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -534,7 +534,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) if( zone->GetNumCorners() == 0 ) { zone->m_Flags = IS_NEW; - zone->m_TimeStamp = GetTimeStamp(); + zone->m_TimeStamp = GetNewTimeStamp(); g_Zone_Default_Setting.ExportSetting( *zone ); zone->m_Poly->Start( g_Zone_Default_Setting.m_CurrentZone_Layer, GetScreen()->GetCrossHairPosition().x, diff --git a/pcbnew/zones_test_and_combine_areas.cpp b/pcbnew/zones_test_and_combine_areas.cpp index 6c53f74b38..9078c44ea5 100644 --- a/pcbnew/zones_test_and_combine_areas.cpp +++ b/pcbnew/zones_test_and_combine_areas.cpp @@ -88,7 +88,7 @@ ZONE_CONTAINER* BOARD::InsertArea( int netcode, int iarea, int layer, int x, int new_area->SetNet( netcode ); new_area->SetLayer( layer ); - new_area->m_TimeStamp = GetTimeStamp(); + new_area->m_TimeStamp = GetNewTimeStamp(); if( iarea < (int) ( m_ZoneDescriptorList.size() - 1 ) ) m_ZoneDescriptorList.insert( m_ZoneDescriptorList.begin() + iarea + 1, new_area );