Code cleanup: remove dead code (some removed methods were broken), and update or add comments.

This commit is contained in:
jean-pierre charras 2016-06-01 11:28:07 +02:00
parent a27ad2beca
commit e2cc78b2b5
12 changed files with 20 additions and 140 deletions

View File

@ -332,14 +332,6 @@ public:
/// @copydoc VIEW_ITEM::ViewGetLayers()
virtual void ViewGetLayers( int aLayers[], int& aCount ) const;
/*!
* Function IncrementItemReference
* Implement if the concept of "incrementing" makes sense for an
* item (e.g. modules and pads)
* @return if item reference was incremented
*/
virtual bool IncrementItemReference() { return false; }
};
#endif /* BOARD_ITEM_STRUCT_H */

View File

@ -87,7 +87,7 @@ void ARRAY_CREATOR::Invoke()
else
{
// PCB items keep the same numbering
new_item = getBoard()->DuplicateAndAddItem( item, false );
new_item = getBoard()->DuplicateAndAddItem( item );
// @TODO: we should merge zones. This is a bit tricky, because
// the undo command needs saving old area, if it is merged.
@ -96,11 +96,8 @@ void ARRAY_CREATOR::Invoke()
if( new_item )
{
array_opts->TransformItem( ptN, new_item, rotPoint );
prePushAction( new_item );
newItemsList.PushItem( new_item ); // For undo list
postPushAction( new_item );
}

View File

@ -866,9 +866,6 @@ void PCB_EDIT_FRAME::Block_Duplicate( bool aIncrement )
newitem = (BOARD_ITEM*)item->Clone();
if( aIncrement )
newitem->IncrementItemReference();
if( item->Type() == PCB_MODULE_T )
m_Pcb->m_Status_Pcb = 0;

View File

@ -299,7 +299,7 @@ void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
break;
case BLOCK_COPY: // Copy
case BLOCK_COPY_AND_INCREMENT: // Copy and increment references
case BLOCK_COPY_AND_INCREMENT: // Copy and increment pad names
GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( currentModule, UR_MODEDIT );
CopyMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector(),
@ -457,7 +457,7 @@ void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement )
module->Pads().PushFront( NewPad );
if( aIncrement )
NewPad->IncrementItemReference();
NewPad->IncrementPadName( true, true );
}
BOARD_ITEM* newItem;
@ -473,9 +473,6 @@ void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement )
newItem->SetParent( module );
newItem->SetFlags( SELECTED );
module->GraphicalItems().PushFront( newItem );
if( aIncrement )
newItem->IncrementItemReference();
}
MoveMarkedItems( module, offset );

View File

@ -2682,8 +2682,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
}
BOARD_ITEM* BOARD::DuplicateAndAddItem( const BOARD_ITEM* aItem,
bool aIncrementReferences )
BOARD_ITEM* BOARD::DuplicateAndAddItem( const BOARD_ITEM* aItem )
{
BOARD_ITEM* new_item = NULL;
@ -2712,52 +2711,12 @@ BOARD_ITEM* BOARD::DuplicateAndAddItem( const BOARD_ITEM* aItem,
}
if( new_item )
{
if( aIncrementReferences )
new_item->IncrementItemReference();
Add( new_item );
}
return new_item;
}
wxString BOARD::GetNextModuleReferenceWithPrefix( const wxString& aPrefix,
bool aFillSequenceGaps )
{
wxString nextRef;
std::set<int> usedNumbers;
for( MODULE* module = m_Modules; module; module = module->Next() )
{
const wxString ref = module->GetReference();
wxString remainder;
// ONly interested in modules with the right prefix
if( !ref.StartsWith( aPrefix, &remainder ) )
continue;
// the suffix must be a number
if( !remainder.IsNumber() )
continue;
long number;
if( remainder.ToCLong( &number ) )
usedNumbers.insert( number );
}
if( usedNumbers.size() )
{
int nextNum = getNextNumberInSequence( usedNumbers, aFillSequenceGaps );
nextRef = wxString::Format( wxT( "%s%i" ), aPrefix, nextNum );
}
return nextRef;
}
/* Extracts the board outlines and build a closed polygon
* from lines, arcs and circle items on edge cut layer
* Any closed outline inside the main outline is a hole

View File

@ -294,15 +294,13 @@ public:
*/
BOARD_ITEM* Remove( BOARD_ITEM* aBoardItem );
BOARD_ITEM* DuplicateAndAddItem( const BOARD_ITEM* aItem,
bool aIncrementReferences );
/**
* Function GetNextModuleReferenceWithPrefix
* Get the next available module reference with this prefix
* Function DuplicateAndAddItem
* duplicates an item, and add it to the board list.
* @param aItem The item to duplicate.
* @return BOARD_ITEM* \a the new item which was added.
*/
wxString GetNextModuleReferenceWithPrefix( const wxString& aPrefix,
bool aFillSequenceGaps );
BOARD_ITEM* DuplicateAndAddItem( const BOARD_ITEM* aItem );
/**
* Function GetRatsnest()

View File

@ -1167,12 +1167,13 @@ BOARD_ITEM* MODULE::DuplicateAndAddItem( const BOARD_ITEM* aItem,
bool aIncrementPadNumbers )
{
BOARD_ITEM* new_item = NULL;
D_PAD* new_pad = NULL;
switch( aItem->Type() )
{
case PCB_PAD_T:
{
D_PAD* new_pad = new D_PAD( *static_cast<const D_PAD*>( aItem ) );
new_pad = new D_PAD( *static_cast<const D_PAD*>( aItem ) );
Pads().PushBack( new_pad );
new_item = new_pad;
@ -1216,9 +1217,9 @@ BOARD_ITEM* MODULE::DuplicateAndAddItem( const BOARD_ITEM* aItem,
break;
}
if( aIncrementPadNumbers && new_item )
if( aIncrementPadNumbers && new_pad )
{
new_item->IncrementItemReference();
new_pad->IncrementPadName( true, true );
}
return new_item;
@ -1264,35 +1265,6 @@ wxString MODULE::GetReferencePrefix() const
}
bool MODULE::IncrementItemReference()
{
// Take the next available module number
return IncrementReference( true );
}
bool MODULE::IncrementReference( bool aFillSequenceGaps )
{
BOARD* board = GetBoard();
if( !board )
return false;
bool success = false;
const wxString prefix = GetReferencePrefix();
const wxString newReference = board->GetNextModuleReferenceWithPrefix(
prefix, aFillSequenceGaps );
if( !newReference.IsEmpty() )
{
SetReference( newReference );
success = true;
}
return success;
}
double MODULE::PadCoverageRatio() const
{
double padArea = 0.0;

View File

@ -450,25 +450,6 @@ public:
TEXTE_MODULE& Value() const { return *m_Value; }
TEXTE_MODULE& Reference() const { return *m_Reference; }
/*!
* Function IncrementItemReference
* Implementation of the generic "reference" incrementing interface
* Increments the numeric suffix, filling any sequence gaps
*/
bool IncrementItemReference(); //override
/**
* Function IncrementReference
* Increments the module's reference, if possible. A reference with
* a numerical suffix and an optional alphabetical prefix can be
* incremented: "A1" and "1" can be, "B" can't.
*
* @param aFillSequenceGaps if true, the next reference in a sequence
* like A1,A3,A4 will be A2. If false, it will be A5.
* @return true if the reference was incremented.
*/
bool IncrementReference( bool aFillSequenceGaps );
/**
* Function FindPadByName
* returns a D_PAD* with a matching name. Note that names may not be

View File

@ -413,13 +413,6 @@ void D_PAD::SetPadName( const wxString& name )
}
bool D_PAD::IncrementItemReference()
{
// Take the next available pad number
return IncrementPadName( true, true );
}
bool D_PAD::IncrementPadName( bool aSkipUnconnectable, bool aFillSequenceGaps )
{
bool skip = aSkipUnconnectable && ( GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED );

View File

@ -132,20 +132,14 @@ public:
*/
const wxUint32 GetPackedPadName() const { return m_NumPadName; }
/*!
* Function IncrementItemReference
* Implementation of the generic "reference" incrementing interface
* Increments the numeric suffix, filling any sequence gaps and skipping
* pads that aren't connectable
*/
bool IncrementItemReference(); // override
/**
* Function IncrementPadName
*
* Increments the pad name to the next available name in the module.
*
* @param aSkipUnconnectable skips any pads that are not connectable (for example NPTH)
* @param aFillSequenceGaps if true, the next reference in a sequence
* like A1,A3,A4 will be A2. If false, it will be A5.
* @return pad name incremented
*/
bool IncrementPadName( bool aSkipUnconnectable, bool aFillSequenceGaps );

View File

@ -127,16 +127,16 @@ protected:
* This function is shared between pcbnew and modedit, as it is virtually
* the same
* @param aItem the item to duplicate
* @aIncrement increment item reference (module ref, pad number, etc,
* if appropriate)
* @param aIncrement (has meaning only for pads in footprint editor):
* increment pad name if appropriate
*/
void duplicateItem( BOARD_ITEM* aItem, bool aIncrement );
/**
* Function duplicateItems
* Find and duplicate the currently selected items
* @param aIncrement increment item reference (module ref, pad number, etc,
* if appropriate)
* @param aIncrement (has meaning only for pads in footprint editor):
* increment pad name if appropriate
*
* @note The implementer should find the selected item (and do processing
* like finding parents when relevant, and then call

View File

@ -756,7 +756,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
// so zones are not duplicated
if( item->Type() != PCB_ZONE_AREA_T )
#endif
new_item = editFrame->GetBoard()->DuplicateAndAddItem( item, increment );
new_item = editFrame->GetBoard()->DuplicateAndAddItem( item );
}
if( new_item )