Pcbnew object improvements.

* Remove unnecessary copy constructors from board and module library
  objects.
* Add doClone() method to board and library objects.
* Add comment to class definitions where the default copy constructor
  generated by the compiler was adequate.
* Replace copy method with clone method where applicable.
* Remove DuplicateStruct() function.
* Remove track object copy function.
This commit is contained in:
Wayne Stambaugh 2012-01-14 14:50:32 -05:00
parent 742486dce6
commit 5289c22087
43 changed files with 776 additions and 338 deletions

View File

@ -68,7 +68,9 @@ EDA_ITEM::EDA_ITEM( const EDA_ITEM& base )
m_Parent = base.m_Parent; m_Parent = base.m_Parent;
m_Son = base.m_Son; m_Son = base.m_Son;
m_Flags = base.m_Flags; m_Flags = base.m_Flags;
SetTimeStamp( base.m_TimeStamp );
// A copy of an item cannot have the same time stamp as the original item.
SetTimeStamp( GetNewTimeStamp() );
m_Status = base.m_Status; m_Status = base.m_Status;
} }
@ -214,19 +216,17 @@ bool EDA_ITEM::operator<( const EDA_ITEM& aItem ) const
EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem ) EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem )
{ {
wxCHECK_MSG( Type() == aItem.Type(), *this,
wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
GetClass() );
if( &aItem != this ) if( &aItem != this )
{ {
// Do not assign the linked list pointers. m_StructType = aItem.Type();
Pnext = aItem.Pnext;
Pback = aItem.Pback;
m_StructType = aItem.m_StructType; m_StructType = aItem.m_StructType;
m_Parent = aItem.m_Parent; m_Parent = aItem.m_Parent;
m_Son = aItem.m_Son; m_Son = aItem.m_Son;
m_Flags = aItem.m_Flags; m_Flags = aItem.m_Flags;
SetTimeStamp( aItem.m_TimeStamp ); SetTimeStamp( aItem.m_TimeStamp );
m_Status = aItem.m_Status; m_Status = aItem.m_Status;
} }
return *this; return *this;

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_board_item.h * @file class_board_item.h
* @brief Classes BOARD_ITEM and BOARD_CONNECTED_ITEM. * @brief Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
@ -59,12 +83,7 @@ public:
{ {
} }
BOARD_ITEM( const BOARD_ITEM& src ) : // Do not create a copy constructor. The one generated by the compiler is adequate.
EDA_ITEM( src.m_Parent, src.Type() )
, m_Layer( src.m_Layer )
{
m_Flags = src.m_Flags;
}
/** /**
* A value of wxPoint(0,0) which can be passed to the Draw() functions. * A value of wxPoint(0,0) which can be passed to the Draw() functions.

View File

@ -44,7 +44,6 @@
#include "class_board.h" #include "class_board.h"
#include "class_module.h" #include "class_module.h"
extern BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem );
typedef enum { typedef enum {
FIXE_MODULE, FIXE_MODULE,
@ -265,7 +264,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
} }
// Undo: add copy of old Module to undo // Undo: add copy of old Module to undo
picker.m_Link = DuplicateStruct( Module ); picker.m_Link = Module->Clone();
picker.m_PickedItemType = Module->Type(); picker.m_PickedItemType = Module->Type();
if( current.x > (Xsize_allowed + start.x) ) if( current.x > (Xsize_allowed + start.x) )

View File

@ -834,100 +834,27 @@ void PCB_EDIT_FRAME::Block_Duplicate()
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection; PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
PICKED_ITEMS_LIST newList; PICKED_ITEMS_LIST newList;
newList.m_Status = UR_NEW; newList.m_Status = UR_NEW;
ITEM_PICKER picker( NULL, UR_NEW ); ITEM_PICKER picker( NULL, UR_NEW );
BOARD_ITEM* newitem; BOARD_ITEM* newitem;
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ ) for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
{ {
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii ); BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
newitem = NULL;
switch( item->Type() )
{
case PCB_MODULE_T:
{
MODULE* module = (MODULE*) item;
MODULE* new_module;
m_Pcb->m_Status_Pcb = 0;
module->ClearFlags();
newitem = new_module = new MODULE( m_Pcb );
new_module->Copy( module );
new_module->SetTimeStamp( GetNewTimeStamp() );
m_Pcb->m_Modules.PushFront( new_module );
}
break;
case PCB_TRACE_T: newitem = (BOARD_ITEM*)item->Clone();
case PCB_VIA_T:
{
TRACK* track = (TRACK*) item;
m_Pcb->m_Status_Pcb = 0;
TRACK* new_track = track->Copy();
newitem = new_track;
m_Pcb->m_Track.PushFront( new_track );
}
break;
case PCB_ZONE_T: // SEG_ZONE items are now deprecated if( item->Type() == PCB_MODULE_T )
break; m_Pcb->m_Status_Pcb = 0;
case PCB_ZONE_AREA_T: m_Pcb->Add( newitem );
{
ZONE_CONTAINER* new_zone = new ZONE_CONTAINER( (BOARD*) item->GetParent() );
new_zone->Copy( (ZONE_CONTAINER*) item );
new_zone->SetTimeStamp( GetNewTimeStamp() );
newitem = new_zone;
m_Pcb->Add( new_zone );
}
break;
case PCB_LINE_T:
{
DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( m_Pcb );
new_drawsegment->Copy( (DRAWSEGMENT*) item );
m_Pcb->Add( new_drawsegment );
newitem = new_drawsegment;
}
break;
case PCB_TEXT_T:
{
TEXTE_PCB* new_pcbtext = new TEXTE_PCB( m_Pcb );
new_pcbtext->Copy( (TEXTE_PCB*) item );
m_Pcb->Add( new_pcbtext );
newitem = new_pcbtext;
}
break;
case PCB_TARGET_T:
{
PCB_TARGET* target = new PCB_TARGET( m_Pcb );
target->Copy( (PCB_TARGET*) item );
m_Pcb->Add( target );
newitem = target;
}
break;
case PCB_DIMENSION_T:
{
DIMENSION* new_cotation = new DIMENSION( m_Pcb );
new_cotation->Copy( (DIMENSION*) item );
m_Pcb->Add( new_cotation );
newitem = new_cotation;
}
break;
default:
wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Duplicate( ) error: unexpected type" ) );
break;
}
if( newitem ) if( newitem )
{ {
newitem->Move( MoveVector ); newitem->Move( MoveVector );
picker.m_PickedItem = newitem; picker.m_PickedItem = newitem;
picker.m_PickedItemType = newitem->Type(); picker.m_PickedItemType = newitem->Type();
newList.PushItem( picker ); newList.PushItem( picker );
} }

View File

@ -401,12 +401,14 @@ void CopyMarkedItems( MODULE* module, wxPoint offset )
continue; continue;
pad->ClearFlags( SELECTED ); pad->ClearFlags( SELECTED );
D_PAD* NewPad = new D_PAD( module ); D_PAD* NewPad = new D_PAD( *pad );
NewPad->Copy( pad ); NewPad->SetParent( module );
NewPad->SetFlags( SELECTED ); NewPad->SetFlags( SELECTED );
module->m_Pads.PushFront( NewPad ); module->m_Pads.PushFront( NewPad );
} }
BOARD_ITEM* newItem;
for( BOARD_ITEM* item = module->m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = module->m_Drawings; item; item = item->Next() )
{ {
if( !item->IsSelected() ) if( !item->IsSelected() )
@ -414,28 +416,10 @@ void CopyMarkedItems( MODULE* module, wxPoint offset )
item->ClearFlags( SELECTED ); item->ClearFlags( SELECTED );
switch( item->Type() ) newItem = (BOARD_ITEM*)item->Clone();
{ newItem->SetParent( module );
case PCB_MODULE_TEXT_T: newItem->SetFlags( SELECTED );
TEXTE_MODULE * textm; module->m_Drawings.PushFront( newItem );
textm = new TEXTE_MODULE( module );
textm->Copy( (TEXTE_MODULE*) item );
textm->SetFlags( SELECTED );
module->m_Drawings.PushFront( textm );
break;
case PCB_MODULE_EDGE_T:
EDGE_MODULE * edge;
edge = new EDGE_MODULE( module );
edge->Copy( (EDGE_MODULE*) item );
edge->SetFlags( SELECTED );
module->m_Drawings.PushFront( edge );
break;
default:
DisplayError( NULL, wxT( "CopyMarkedItems: type undefined" ) );
break;
}
} }
MoveMarkedItems( module, offset ); MoveMarkedItems( module, offset );

View File

@ -72,8 +72,6 @@
* *
*/ */
BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem );
/** /**
* Function TestForExistingItem * Function TestForExistingItem
@ -186,7 +184,7 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
{ {
case PCB_MODULE_T: case PCB_MODULE_T:
{ {
MODULE* tmp = (MODULE*) DuplicateStruct( aImage ); MODULE* tmp = (MODULE*) aImage->Clone();
( (MODULE*) aImage )->Copy( (MODULE*) aItem ); ( (MODULE*) aImage )->Copy( (MODULE*) aItem );
( (MODULE*) aItem )->Copy( tmp ); ( (MODULE*) aItem )->Copy( tmp );
delete tmp; delete tmp;
@ -195,7 +193,7 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
case PCB_ZONE_AREA_T: case PCB_ZONE_AREA_T:
{ {
ZONE_CONTAINER* tmp = (ZONE_CONTAINER*) DuplicateStruct( aImage ); ZONE_CONTAINER* tmp = (ZONE_CONTAINER*) aImage->Clone();
( (ZONE_CONTAINER*) aImage )->Copy( (ZONE_CONTAINER*) aItem ); ( (ZONE_CONTAINER*) aImage )->Copy( (ZONE_CONTAINER*) aItem );
( (ZONE_CONTAINER*) aItem )->Copy( tmp ); ( (ZONE_CONTAINER*) aItem )->Copy( tmp );
delete tmp; delete tmp;
@ -290,98 +288,6 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
} }
/* Routine to create a new copy of given struct.
* The new object is not put in list (not linked)
*/
BOARD_ITEM* DuplicateStruct( BOARD_ITEM* aItem )
{
if( aItem == NULL )
{
wxMessageBox( wxT( "DuplicateStruct() error: NULL aItem" ) );
return NULL;
}
switch( aItem->Type() )
{
case PCB_MODULE_T:
{
MODULE* new_module;
new_module = new MODULE( (BOARD*) aItem->GetParent() );
new_module->Copy( (MODULE*) aItem );
return new_module;
}
case PCB_TRACE_T:
{
TRACK* new_track = ( (TRACK*) aItem )->Copy();
return new_track;
}
case PCB_VIA_T:
{
SEGVIA* new_via = (SEGVIA*)( (SEGVIA*) aItem )->Copy();
return new_via;
}
case PCB_ZONE_T:
{
SEGZONE* new_segzone = (SEGZONE*)( (SEGZONE*) aItem )->Copy();
return new_segzone;
}
case PCB_ZONE_AREA_T:
{
ZONE_CONTAINER* new_zone = new ZONE_CONTAINER( (BOARD*) aItem->GetParent() );
new_zone->Copy( (ZONE_CONTAINER*) aItem );
return new_zone;
}
case PCB_LINE_T:
{
DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( aItem->GetParent() );
new_drawsegment->Copy( (DRAWSEGMENT*) aItem );
return new_drawsegment;
}
break;
case PCB_TEXT_T:
{
TEXTE_PCB* new_pcbtext = new TEXTE_PCB( aItem->GetParent() );
new_pcbtext->Copy( (TEXTE_PCB*) aItem );
return new_pcbtext;
}
break;
case PCB_TARGET_T:
{
PCB_TARGET* target = new PCB_TARGET( aItem->GetParent() );
target->Copy( (PCB_TARGET*) aItem );
return target;
}
break;
case PCB_DIMENSION_T:
{
DIMENSION* new_cotation = new DIMENSION( aItem->GetParent() );
new_cotation->Copy( (DIMENSION*) aItem );
return new_cotation;
}
break;
default:
{
wxString msg;
msg << wxT( "DuplicateStruct error: unexpected StructType " ) <<
aItem->Type() << wxT( " " ) << aItem->GetClass();
wxMessageBox( msg );
}
break;
}
return NULL;
}
/* /*
* Function SaveCopyInUndoList * Function SaveCopyInUndoList
* Create a copy of the current board item, and put it in the undo list. * Create a copy of the current board item, and put it in the undo list.
@ -412,9 +318,11 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
{ {
case UR_CHANGED: /* Create a copy of schematic */ case UR_CHANGED: /* Create a copy of schematic */
if( itemWrapper.m_Link == NULL ) // When not null, the copy is already done if( itemWrapper.m_Link == NULL ) // When not null, the copy is already done
itemWrapper.m_Link = DuplicateStruct( aItem );; itemWrapper.m_Link = aItem->Clone();;
if( itemWrapper.m_Link ) if( itemWrapper.m_Link )
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
break; break;
case UR_NEW: case UR_NEW:
@ -444,7 +352,9 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList ); GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
} }
else else
{
delete commandToUndo; delete commandToUndo;
}
} }
@ -478,6 +388,7 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
} }
wxASSERT( item ); wxASSERT( item );
switch( command ) switch( command )
{ {
case UR_CHANGED: case UR_CHANGED:
@ -487,9 +398,11 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
* If this link is not null, the copy is already done * If this link is not null, the copy is already done
*/ */
if( commandToUndo->GetPickedItemLink( ii ) == NULL ) if( commandToUndo->GetPickedItemLink( ii ) == NULL )
commandToUndo->SetPickedItemLink( DuplicateStruct( item ), ii ); commandToUndo->SetPickedItemLink( item->Clone(), ii );
if( commandToUndo->GetPickedItemLink( ii ) == NULL ) if( commandToUndo->GetPickedItemLink( ii ) == NULL )
wxMessageBox( wxT( "SaveCopyInUndoList() in UR_CHANGED mode: NULL link" ) ); wxMessageBox( wxT( "SaveCopyInUndoList() in UR_CHANGED mode: NULL link" ) );
break; break;
case UR_MOVED: case UR_MOVED:
@ -506,7 +419,9 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
msg.Printf( wxT( "SaveCopyInUndoList() error (unknown code %X)" ), command ); msg.Printf( wxT( "SaveCopyInUndoList() error (unknown code %X)" ), command );
wxMessageBox( msg ); wxMessageBox( msg );
} }
break; break;
} }
} }

View File

@ -2123,7 +2123,7 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS
newPoint.x += aSegment->m_Start.x; newPoint.x += aSegment->m_Start.x;
newPoint.y += aSegment->m_Start.y; newPoint.y += aSegment->m_Start.y;
TRACK* newTrack = aSegment->Copy(); TRACK* newTrack = (TRACK*)aSegment->Clone();
if( aList ) if( aList )
{ {
@ -2139,7 +2139,7 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS
if( aList ) if( aList )
{ {
ITEM_PICKER picker( aSegment, UR_CHANGED ); ITEM_PICKER picker( aSegment, UR_CHANGED );
picker.m_Link = aSegment->Copy(); picker.m_Link = aSegment->Clone();
aList->PushItem( picker ); aList->PushItem( picker );
} }

View File

@ -19,10 +19,12 @@ BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype
} }
BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& src ) : BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& aItem ) :
BOARD_ITEM( src ) BOARD_ITEM( aItem )
{ {
m_Layer = src.m_Layer; m_NetCode = aItem.m_NetCode;
m_Subnet = aItem.m_Subnet;
m_ZoneSubnet = aItem.m_ZoneSubnet;
} }

View File

@ -41,7 +41,8 @@ private:
public: public:
BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ); BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype );
BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& src );
BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& aItem );
/** /**
* Function GetNet * Function GetNet

View File

@ -1,3 +1,28 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_dimension.cpp * @file class_dimension.cpp
*/ */
@ -575,3 +600,9 @@ wxString DIMENSION::GetSelectMenuText() const
return text; return text;
} }
EDA_ITEM* DIMENSION::doClone() const
{
return new DIMENSION( *this );
}

View File

@ -1,3 +1,28 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_dimension.h * @file class_dimension.h
* @brief DIMENSION class definition. * @brief DIMENSION class definition.
@ -35,6 +60,9 @@ public:
public: public:
DIMENSION( BOARD_ITEM* aParent ); DIMENSION( BOARD_ITEM* aParent );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~DIMENSION(); ~DIMENSION();
const wxPoint GetPosition() const { return m_Pos; } const wxPoint GetPosition() const { return m_Pos; }
@ -160,6 +188,8 @@ public:
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif #endif
private:
virtual EDA_ITEM* doClone() const;
}; };
#endif // DIMENSION_H_ #endif // DIMENSION_H_

View File

@ -1,3 +1,28 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_drawsegment.cpp * @file class_drawsegment.cpp
* @brief Class and functions to handle a graphic segments. * @brief Class and functions to handle a graphic segments.
@ -75,10 +100,12 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre )
{ {
m_Start.y = aCentre.y - (m_Start.y - aCentre.y); m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
m_End.y = aCentre.y - (m_End.y - aCentre.y); m_End.y = aCentre.y - (m_End.y - aCentre.y);
if( m_Shape == S_ARC ) if( m_Shape == S_ARC )
{ {
NEGATE( m_Angle ); NEGATE( m_Angle );
} }
SetLayer( ChangeSideNumLayer( GetLayer() ) ); SetLayer( ChangeSideNumLayer( GetLayer() ) );
} }
@ -497,6 +524,12 @@ wxString DRAWSEGMENT::GetSelectMenuText() const
} }
EDA_ITEM* DRAWSEGMENT::doClone() const
{
return new DRAWSEGMENT( *this );
}
#if defined(DEBUG) #if defined(DEBUG)
void DRAWSEGMENT::Show( int nestLevel, std::ostream& os ) const void DRAWSEGMENT::Show( int nestLevel, std::ostream& os ) const
{ {

View File

@ -1,3 +1,28 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_drawsegment.h * @file class_drawsegment.h
* @brief Class to handle a graphic segment. * @brief Class to handle a graphic segment.
@ -34,6 +59,9 @@ protected:
public: public:
DRAWSEGMENT( BOARD_ITEM* aParent = NULL, KICAD_T idtype = PCB_LINE_T ); DRAWSEGMENT( BOARD_ITEM* aParent = NULL, KICAD_T idtype = PCB_LINE_T );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~DRAWSEGMENT(); ~DRAWSEGMENT();
/// skip the linked list stuff, and parent /// skip the linked list stuff, and parent
@ -247,6 +275,9 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
private:
virtual EDA_ITEM* doClone() const;
}; };
#endif // CLASS_DRAWSEGMENT_H_ #endif // CLASS_DRAWSEGMENT_H_

View File

@ -1,3 +1,28 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_edge_mod.cpp * @file class_edge_mod.cpp
* @brief EDGE_MODULE class definition. * @brief EDGE_MODULE class definition.
@ -21,10 +46,6 @@
#include "class_edge_mod.h" #include "class_edge_mod.h"
/*********************/
/* class EDGE_MODULE */
/*********************/
EDGE_MODULE::EDGE_MODULE( MODULE* parent, STROKE_T aShape ) : EDGE_MODULE::EDGE_MODULE( MODULE* parent, STROKE_T aShape ) :
DRAWSEGMENT( parent, PCB_MODULE_EDGE_T ) DRAWSEGMENT( parent, PCB_MODULE_EDGE_T )
{ {
@ -71,14 +92,6 @@ void EDGE_MODULE::SetDrawCoord()
} }
/* Draw EDGE_MODULE:
* Entry: offset = offset trace
* Draw_mode mode = trace (GR_OR, GR_XOR, GR_AND)
* The contours are of different types:
* - Segment
* - Circles
* - Arcs
*/
void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& offset ) void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& offset )
{ {
int ux0, uy0, dx, dy, radius, StAngle, EndAngle; int ux0, uy0, dx, dy, radius, StAngle, EndAngle;
@ -246,6 +259,12 @@ wxString EDGE_MODULE::GetSelectMenuText() const
} }
EDA_ITEM* EDGE_MODULE::doClone() const
{
return new EDGE_MODULE( *this );
}
#if defined(DEBUG) #if defined(DEBUG)
void EDGE_MODULE::Show( int nestLevel, std::ostream& os ) const void EDGE_MODULE::Show( int nestLevel, std::ostream& os ) const

View File

@ -1,3 +1,28 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_edge_mod.h * @file class_edge_mod.h
* @brief EDGE_MODULE class definition. * @brief EDGE_MODULE class definition.
@ -23,7 +48,9 @@ public:
public: public:
EDGE_MODULE( MODULE* parent, STROKE_T aShape = S_SEGMENT ); EDGE_MODULE( MODULE* parent, STROKE_T aShape = S_SEGMENT );
EDGE_MODULE( EDGE_MODULE* edge );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~EDGE_MODULE(); ~EDGE_MODULE();
EDGE_MODULE* Next() const { return (EDGE_MODULE*) Pnext; } EDGE_MODULE* Next() const { return (EDGE_MODULE*) Pnext; }
@ -83,6 +110,9 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
private:
virtual EDA_ITEM* doClone() const;
}; };
#endif // CLASS_EDGE_MOD_H_ #endif // CLASS_EDGE_MOD_H_

View File

@ -1,3 +1,28 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_mire.cpp * @file class_mire.cpp
* MIRE class definition (targets for photo plots) * MIRE class definition (targets for photo plots)
@ -198,3 +223,9 @@ wxString PCB_TARGET::GetSelectMenuText() const
return text; return text;
} }
EDA_ITEM* PCB_TARGET::doClone() const
{
return new PCB_TARGET( *this );
}

View File

@ -1,3 +1,28 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_mire.h * @file class_mire.h
* @brief PCB_TARGET class definition. (targets for photo plots). * @brief PCB_TARGET class definition. (targets for photo plots).
@ -24,6 +49,9 @@ class PCB_TARGET : public BOARD_ITEM
public: public:
PCB_TARGET( BOARD_ITEM* aParent ); PCB_TARGET( BOARD_ITEM* aParent );
// Do not create a copy constructor. The one generated by the compiler is adequate.
PCB_TARGET( BOARD_ITEM* aParent, int aShape, int aLayer, PCB_TARGET( BOARD_ITEM* aParent, int aShape, int aLayer,
const wxPoint& aPos, int aSize, int aWidth ); const wxPoint& aPos, int aSize, int aWidth );
@ -116,6 +144,9 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif #endif
private:
virtual EDA_ITEM* doClone() const;
}; };

View File

@ -78,6 +78,88 @@ MODULE::MODULE( BOARD* parent ) :
} }
MODULE::MODULE( const MODULE& aModule ) :
BOARD_ITEM( aModule )
{
BOARD_ITEM* newItem;
m_Pos = aModule.m_Pos;
m_LibRef = aModule.m_LibRef;
m_Attributs = aModule.m_Attributs;
m_Orient = aModule.m_Orient;
m_BoundaryBox = aModule.m_BoundaryBox;
m_PadNum = aModule.m_PadNum;
m_CntRot90 = aModule.m_CntRot90;
m_CntRot180 = aModule.m_CntRot180;
m_LastEdit_Time = aModule.m_LastEdit_Time;
m_Link = aModule.m_Link;
m_Path = aModule.m_Path; //is this correct behavior?
m_LocalClearance = aModule.m_LocalClearance;
m_LocalSolderMaskMargin = aModule.m_LocalSolderMaskMargin;
m_LocalSolderPasteMargin = aModule.m_LocalSolderPasteMargin;
m_LocalSolderPasteMarginRatio = aModule.m_LocalSolderPasteMarginRatio;
/* Copy reference and value. */
m_Reference = new TEXTE_MODULE( *aModule.m_Reference );
m_Reference->SetParent( this );
m_Value = new TEXTE_MODULE( *aModule.m_Value );
m_Value->SetParent( this );
/* Copy auxiliary data: Pads */
m_Pads.DeleteAll();
for( D_PAD* pad = aModule.m_Pads; pad; pad = pad->Next() )
{
D_PAD* newpad = new D_PAD( *pad );
newpad->SetParent( this );
m_Pads.PushBack( newpad );
}
/* Copy auxiliary data: Drawings */
m_Drawings.DeleteAll();
for( BOARD_ITEM* item = aModule.m_Drawings; item; item = item->Next() )
{
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
case PCB_MODULE_EDGE_T:
newItem = (BOARD_ITEM*)item->Clone();
newItem->SetParent( this );
m_Drawings.PushBack( newItem );
break;
default:
wxMessageBox( wxT( "MODULE::Copy() Internal Err: unknown type" ) );
break;
}
}
/* Copy auxiliary data: 3D_Drawings info */
m_3D_Drawings.DeleteAll();
for( S3D_MASTER* item = aModule.m_3D_Drawings; item; item = item->Next() )
{
if( item->m_Shape3DName.IsEmpty() ) // do not copy empty shapes.
continue;
S3D_MASTER* t3d = m_3D_Drawings;
t3d = new S3D_MASTER( this );
t3d->Copy( item );
m_3D_Drawings.PushBack( t3d );
}
// Ensure there is at least one item in m_3D_Drawings.
if( m_3D_Drawings.GetCount() == 0 )
m_3D_Drawings.PushBack( new S3D_MASTER( this ) ); // push a void item
m_Doc = aModule.m_Doc;
m_KeyWord = aModule.m_KeyWord;
}
MODULE::~MODULE() MODULE::~MODULE()
{ {
delete m_Reference; delete m_Reference;
@ -563,6 +645,12 @@ wxString MODULE::GetSelectMenuText() const
} }
EDA_ITEM* MODULE::doClone() const
{
return new MODULE( *this );
}
#if defined(DEBUG) #if defined(DEBUG)
void MODULE::Show( int nestLevel, std::ostream& os ) const void MODULE::Show( int nestLevel, std::ostream& os ) const

View File

@ -1,3 +1,28 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_module.h * @file class_module.h
* @brief Module description (excepted pads) * @brief Module description (excepted pads)
@ -104,7 +129,9 @@ public:
public: public:
MODULE( BOARD* parent ); MODULE( BOARD* parent );
MODULE( MODULE* module );
MODULE( const MODULE& aModule );
~MODULE(); ~MODULE();
MODULE* Next() const { return (MODULE*) Pnext; } MODULE* Next() const { return (MODULE*) Pnext; }
@ -377,6 +404,9 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
private:
virtual EDA_ITEM* doClone() const;
}; };

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_pad.cpp * @file class_pad.cpp
* D_PAD class implementation. * D_PAD class implementation.
@ -735,6 +759,12 @@ wxString D_PAD::GetSelectMenuText() const
return text; return text;
} }
EDA_ITEM* D_PAD::doClone() const
{
return new D_PAD( *this );
}
#if defined(DEBUG) #if defined(DEBUG)
void D_PAD::Show( int nestLevel, std::ostream& os ) const void D_PAD::Show( int nestLevel, std::ostream& os ) const

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_pad.h * @file class_pad.h
* @brief Pad object description * @brief Pad object description
@ -139,7 +163,9 @@ public:
public: public:
D_PAD( MODULE* parent ); D_PAD( MODULE* parent );
D_PAD( D_PAD* pad );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~D_PAD(); ~D_PAD();
void Copy( D_PAD* source ); void Copy( D_PAD* source );
@ -452,6 +478,9 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
private:
virtual EDA_ITEM* doClone() const;
}; };

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_pcb_text.cpp * @file class_pcb_text.cpp
* @brief Class TEXTE_PCB texts on copper or technical layers implementation * @brief Class TEXTE_PCB texts on copper or technical layers implementation
@ -160,6 +184,12 @@ wxString TEXTE_PCB::GetSelectMenuText() const
} }
EDA_ITEM* TEXTE_PCB::doClone() const
{
return new TEXTE_PCB( *this );
}
#if defined(DEBUG) #if defined(DEBUG)
void TEXTE_PCB::Show( int nestLevel, std::ostream& os ) const void TEXTE_PCB::Show( int nestLevel, std::ostream& os ) const

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_pcb_text.h * @file class_pcb_text.h
* @brief TEXTE_PCB class definition. * @brief TEXTE_PCB class definition.
@ -18,7 +42,9 @@ class TEXTE_PCB : public BOARD_ITEM, public EDA_TEXT
{ {
public: public:
TEXTE_PCB( BOARD_ITEM* parent ); TEXTE_PCB( BOARD_ITEM* parent );
TEXTE_PCB( TEXTE_PCB* textepcb );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~TEXTE_PCB(); ~TEXTE_PCB();
const wxPoint GetPosition() const // is an overload const wxPoint GetPosition() const // is an overload
@ -140,6 +166,9 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; void Show( int nestLevel, std::ostream& os ) const;
#endif #endif
private:
virtual EDA_ITEM* doClone() const;
}; };
#endif // #define CLASS_PCB_TEXT_H #endif // #define CLASS_PCB_TEXT_H

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_module.cpp * @file class_module.cpp
* @brief TEXT_MODULE class implementation. * @brief TEXT_MODULE class implementation.
@ -23,11 +47,13 @@
TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) : TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) :
BOARD_ITEM( parent, PCB_MODULE_TEXT_T ), EDA_TEXT() BOARD_ITEM( parent, PCB_MODULE_TEXT_T ),
EDA_TEXT()
{ {
MODULE* Module = (MODULE*) m_Parent; MODULE* Module = (MODULE*) m_Parent;
m_Type = text_type; /* Reference */ m_Type = text_type; /* Reference */
if( (m_Type != TEXT_is_REFERENCE) && (m_Type != TEXT_is_VALUE) ) if( (m_Type != TEXT_is_REFERENCE) && (m_Type != TEXT_is_VALUE) )
m_Type = TEXT_is_DIVERS; m_Type = TEXT_is_DIVERS;
@ -36,6 +62,7 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) :
m_Thickness = 120; /* Set default dimension to a reasonable value. */ m_Thickness = 120; /* Set default dimension to a reasonable value. */
SetLayer( SILKSCREEN_N_FRONT ); SetLayer( SILKSCREEN_N_FRONT );
if( Module && ( Module->Type() == PCB_MODULE_T ) ) if( Module && ( Module->Type() == PCB_MODULE_T ) )
{ {
m_Pos = Module->m_Pos; m_Pos = Module->m_Pos;
@ -85,13 +112,13 @@ void TEXTE_MODULE::Copy( TEXTE_MODULE* source )
} }
int TEXTE_MODULE:: GetLength() const int TEXTE_MODULE::GetLength() const
{ {
return m_Text.Len(); return m_Text.Len();
} }
// Update draw coordinates // Update draw coordinates
void TEXTE_MODULE:: SetDrawCoord() void TEXTE_MODULE::SetDrawCoord()
{ {
MODULE* Module = (MODULE*) m_Parent; MODULE* Module = (MODULE*) m_Parent;
@ -110,7 +137,7 @@ void TEXTE_MODULE:: SetDrawCoord()
// Update "local" coordinates (coordinates relatives to the footprint // Update "local" coordinates (coordinates relatives to the footprint
// anchor point) // anchor point)
void TEXTE_MODULE:: SetLocalCoord() void TEXTE_MODULE::SetLocalCoord()
{ {
MODULE* Module = (MODULE*) m_Parent; MODULE* Module = (MODULE*) m_Parent;
@ -453,6 +480,12 @@ wxString TEXTE_MODULE::GetSelectMenuText() const
} }
EDA_ITEM* TEXTE_MODULE::doClone() const
{
return new TEXTE_MODULE( *this );
}
#if defined(DEBUG) #if defined(DEBUG)
void TEXTE_MODULE::Show( int nestLevel, std::ostream& os ) const void TEXTE_MODULE::Show( int nestLevel, std::ostream& os ) const

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_text_mod.h * @file class_text_mod.h
* @brief Footprint text class description. * @brief Footprint text class description.
@ -44,6 +68,8 @@ class TEXTE_MODULE : public BOARD_ITEM, public EDA_TEXT
public: public:
TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS ); TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~TEXTE_MODULE(); ~TEXTE_MODULE();
TEXTE_MODULE* Next() const { return (TEXTE_MODULE*) Pnext; } TEXTE_MODULE* Next() const { return (TEXTE_MODULE*) Pnext; }
@ -190,6 +216,9 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
private:
virtual EDA_ITEM* doClone() const;
}; };
#endif // TEXT_MODULE_H_ #endif // TEXT_MODULE_H_

View File

@ -130,6 +130,12 @@ TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) :
} }
EDA_ITEM* TRACK::doClone() const
{
return new TRACK( *this );
}
wxString TRACK::ShowWidth() const wxString TRACK::ShowWidth() const
{ {
wxString msg; wxString msg;
@ -146,6 +152,12 @@ SEGZONE::SEGZONE( BOARD_ITEM* aParent ) :
} }
EDA_ITEM* SEGZONE::doClone() const
{
return new SEGZONE( *this );
}
wxString SEGZONE::GetSelectMenuText() const wxString SEGZONE::GetSelectMenuText() const
{ {
wxString text; wxString text;
@ -178,6 +190,12 @@ SEGVIA::SEGVIA( BOARD_ITEM* aParent ) :
} }
EDA_ITEM* SEGVIA::doClone() const
{
return new SEGVIA( *this );
}
wxString SEGVIA::GetSelectMenuText() const wxString SEGVIA::GetSelectMenuText() const
{ {
wxString text; wxString text;
@ -222,40 +240,6 @@ wxString SEGVIA::GetSelectMenuText() const
} }
// Copy constructor
TRACK::TRACK( const TRACK& Source ) :
BOARD_CONNECTED_ITEM( Source )
{
m_Shape = Source.m_Shape;
SetNet( Source.GetNet() );
m_Flags = Source.m_Flags;
SetTimeStamp( Source.m_TimeStamp );
SetStatus( Source.GetStatus() );
m_Start = Source.m_Start;
m_End = Source.m_End;
m_Width = Source.m_Width;
m_Drill = Source.m_Drill;
SetSubNet( Source.GetSubNet() );
m_Param = Source.m_Param;
}
TRACK* TRACK::Copy() const
{
if( Type() == PCB_TRACE_T )
return new TRACK( *this );
if( Type() == PCB_VIA_T )
return new SEGVIA( (const SEGVIA &) * this );
if( Type() == PCB_ZONE_T )
return new SEGZONE( (const SEGZONE &) * this );
return NULL; // should never happen
}
int TRACK::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const int TRACK::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
{ {
// Currently tracks have no specific clearance parameter on a per track or per // Currently tracks have no specific clearance parameter on a per track or per

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_track.h * @file class_track.h
* @brief Definitions for tracks, vias and zones. * @brief Definitions for tracks, vias and zones.
@ -67,26 +91,10 @@ public:
double m_Param; // Auxiliary variable ( used in some computations ) double m_Param; // Auxiliary variable ( used in some computations )
protected:
TRACK( const TRACK& track ); // protected so Copy() is used instead.
public: public:
TRACK( BOARD_ITEM* aParent, KICAD_T idtype = PCB_TRACE_T ); TRACK( BOARD_ITEM* aParent, KICAD_T idtype = PCB_TRACE_T );
/** // Do not create a copy constructor. The one generated by the compiler is adequate.
* Function Copy
* will copy this object whether it is a TRACK or a SEGVIA returning
* the corresponding type.
* Because of the way SEGVIA and SEGZONE are derived from TRACK and because there are
* virtual functions being used, we can no longer simply copy a TRACK and
* expect it to be a via or zone. We must construct a true SEGVIA or SEGZONE so its
* constructor can initialize the virtual function table properly. This factory type
* of function called Copy() can duplicate either a TRACK, SEGVIA, or SEGZONE.
*
* @return - TRACK*, SEGVIA*, or SEGZONE*, declared as the least common
* denominator: TRACK
*/
TRACK* Copy() const;
TRACK* Next() const { return (TRACK*) Pnext; } TRACK* Next() const { return (TRACK*) Pnext; }
TRACK* Back() const { return (TRACK*) Pback; } TRACK* Back() const { return (TRACK*) Pback; }
@ -396,6 +404,9 @@ public:
static wxString ShowState( int stateBits ); static wxString ShowState( int stateBits );
#endif #endif
private:
virtual EDA_ITEM* doClone() const;
}; };
@ -404,6 +415,8 @@ class SEGZONE : public TRACK
public: public:
SEGZONE( BOARD_ITEM* aParent ); SEGZONE( BOARD_ITEM* aParent );
// Do not create a copy constructor. The one generated by the compiler is adequate.
/** /**
* Function GetClass * Function GetClass
* returns the class name. * returns the class name.
@ -420,6 +433,9 @@ public:
virtual wxString GetSelectMenuText() const; virtual wxString GetSelectMenuText() const;
virtual BITMAP_DEF GetMenuImage() const { return add_zone_xpm; } virtual BITMAP_DEF GetMenuImage() const { return add_zone_xpm; }
private:
virtual EDA_ITEM* doClone() const;
}; };
@ -428,11 +444,7 @@ class SEGVIA : public TRACK
public: public:
SEGVIA( BOARD_ITEM* aParent ); SEGVIA( BOARD_ITEM* aParent );
SEGVIA( const SEGVIA& source ) : // Do not create a copy constructor. The one generated by the compiler is adequate.
TRACK( source )
{
}
void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode,
const wxPoint& aOffset = ZeroOffset ); const wxPoint& aOffset = ZeroOffset );
@ -491,6 +503,9 @@ public:
#if defined (DEBUG) #if defined (DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload void Show( int nestLevel, std::ostream& os ) const; // overload
#endif #endif
private:
virtual EDA_ITEM* doClone() const;
}; };

View File

@ -65,6 +65,27 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
} }
ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) :
BOARD_CONNECTED_ITEM( aZone )
{
// Should the copy be on the same net?
SetNet( aZone.GetNet() );
m_Poly = new CPolyLine( *aZone.m_Poly );
// For corner moving, corner index to drag, or -1 if no selection
m_CornerSelection = -1;
m_ZoneClearance = aZone.m_ZoneClearance; // clearance value
m_ZoneMinThickness = aZone.m_ZoneMinThickness;
m_FillMode = aZone.m_FillMode; // Filling mode (segments/polygons)
m_ArcToSegmentsCount = aZone.m_ArcToSegmentsCount;
m_PadOption = aZone.m_PadOption;
m_ThermalReliefGap = aZone.m_ThermalReliefGap;
m_ThermalReliefCopperBridge = aZone.m_ThermalReliefCopperBridge;
m_FilledPolysList = aZone.m_FilledPolysList;
m_FillSegmList = aZone.m_FillSegmList;
}
ZONE_CONTAINER::~ZONE_CONTAINER() ZONE_CONTAINER::~ZONE_CONTAINER()
{ {
delete m_Poly; delete m_Poly;
@ -72,6 +93,12 @@ ZONE_CONTAINER::~ZONE_CONTAINER()
} }
EDA_ITEM* ZONE_CONTAINER::doClone() const
{
return new ZONE_CONTAINER( *this );
}
bool ZONE_CONTAINER::UnFill() bool ZONE_CONTAINER::UnFill()
{ {
bool change = ( m_FilledPolysList.size() > 0 ) || ( m_FillSegmList.size() > 0 ); bool change = ( m_FilledPolysList.size() > 0 ) || ( m_FillSegmList.size() > 0 );

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
*/
/** /**
* @file class_zone.h * @file class_zone.h
* @brief Classes to handle copper zones * @brief Classes to handle copper zones
@ -103,6 +127,9 @@ private:
public: public:
ZONE_CONTAINER( BOARD* parent ); ZONE_CONTAINER( BOARD* parent );
ZONE_CONTAINER( const ZONE_CONTAINER& aZone );
~ZONE_CONTAINER(); ~ZONE_CONTAINER();
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
@ -234,7 +261,10 @@ public:
void SetThermalReliefGap( int aThermalReliefGap ) { m_ThermalReliefGap = aThermalReliefGap; } void SetThermalReliefGap( int aThermalReliefGap ) { m_ThermalReliefGap = aThermalReliefGap; }
int GetThermalReliefGap() const { return m_ThermalReliefGap; } int GetThermalReliefGap() const { return m_ThermalReliefGap; }
void SetThermalReliefCopperBridge( int aThermalReliefCopperBridge ) { m_ThermalReliefCopperBridge = aThermalReliefCopperBridge; } void SetThermalReliefCopperBridge( int aThermalReliefCopperBridge )
{
m_ThermalReliefCopperBridge = aThermalReliefCopperBridge;
}
int GetThermalReliefCopperBridge() const { return m_ThermalReliefCopperBridge; } int GetThermalReliefCopperBridge() const { return m_ThermalReliefCopperBridge; }
void SetArcSegCount( int aArcSegCount ) { m_ArcToSegmentsCount = aArcSegCount; } void SetArcSegCount( int aArcSegCount ) { m_ArcToSegmentsCount = aArcSegCount; }
@ -500,6 +530,9 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif #endif
private:
virtual EDA_ITEM* doClone() const;
}; };

View File

@ -797,7 +797,7 @@ static void ConnectDanglingEndToVia( BOARD* pcb )
if( other->m_End != via->GetPosition() && via->HitTest( other->m_Start ) if( other->m_End != via->GetPosition() && via->HitTest( other->m_Start )
&& !other->start ) && !other->start )
{ {
TRACK* newTrack = other->Copy(); TRACK* newTrack = (TRACK*)other->Clone();
pcb->m_Track.Insert( newTrack, other->Next() ); pcb->m_Track.Insert( newTrack, other->Next() );
@ -821,7 +821,7 @@ static void ConnectDanglingEndToVia( BOARD* pcb )
else if( other->m_Start != via->GetPosition() && via->HitTest( other->m_End ) else if( other->m_Start != via->GetPosition() && via->HitTest( other->m_End )
&& !other->end ) && !other->end )
{ {
TRACK* newTrack = other->Copy(); TRACK* newTrack = (TRACK*)other->Clone();
pcb->m_Track.Insert( newTrack, other->Next() ); pcb->m_Track.Insert( newTrack, other->Next() );
@ -874,7 +874,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* aFrame )
{ {
if( segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, START ) == NULL ) if( segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, START ) == NULL )
{ {
TRACK* newTrack = segment->Copy(); TRACK* newTrack = (TRACK*)segment->Clone();
aFrame->GetBoard()->m_Track.Insert( newTrack, segment->Next() ); aFrame->GetBoard()->m_Track.Insert( newTrack, segment->Next() );
@ -896,7 +896,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* aFrame )
{ {
if( segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, END ) == NULL ) if( segment->GetTrace( aFrame->GetBoard()->m_Track, NULL, END ) == NULL )
{ {
TRACK* newTrack = segment->Copy(); TRACK* newTrack = (TRACK*)segment->Clone();
aFrame->GetBoard()->m_Track.Insert( newTrack, segment->Next() ); aFrame->GetBoard()->m_Track.Insert( newTrack, segment->Next() );

View File

@ -374,8 +374,7 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge,
{ {
Edge->Draw( m_canvas, DC, GR_OR ); Edge->Draw( m_canvas, DC, GR_OR );
EDGE_MODULE* newedge = new EDGE_MODULE( module ); EDGE_MODULE* newedge = new EDGE_MODULE( *Edge );
newedge->Copy( Edge );
// insert _after_ Edge, which is the same as inserting before Edge->Next() // insert _after_ Edge, which is the same as inserting before Edge->Next()
module->m_Drawings.Insert( newedge, Edge->Next() ); module->m_Drawings.Insert( newedge, Edge->Next() );

View File

@ -100,7 +100,7 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
{ {
aTrackItem->m_Width = initial_width; aTrackItem->m_Width = initial_width;
ITEM_PICKER picker( aTrackItem, UR_CHANGED ); ITEM_PICKER picker( aTrackItem, UR_CHANGED );
picker.m_Link = aTrackItem->Copy(); picker.m_Link = aTrackItem->Clone();
aItemsListPicker->PushItem( picker ); aItemsListPicker->PushItem( picker );
aTrackItem->m_Width = new_width; aTrackItem->m_Width = new_width;

View File

@ -183,7 +183,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
* it will become the new current segment (from via to the mouse cursor) * it will become the new current segment (from via to the mouse cursor)
*/ */
TRACK* track = lastNonVia->Copy(); TRACK* track = (TRACK*)lastNonVia->Clone();
/* the above creates a new segment from the last entered segment, with the /* the above creates a new segment from the last entered segment, with the
* current width, flags, netcode, etc... values. * current width, flags, netcode, etc... values.
@ -204,7 +204,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
if( g_TwoSegmentTrackBuild ) if( g_TwoSegmentTrackBuild )
{ {
// Create a second segment (we must have 2 track segments to adjust) // Create a second segment (we must have 2 track segments to adjust)
g_CurrentTrackList.PushBack( g_CurrentTrackSegment->Copy() ); g_CurrentTrackList.PushBack( (TRACK*)g_CurrentTrackSegment->Clone() );
} }
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );

View File

@ -186,7 +186,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
if( g_TwoSegmentTrackBuild ) if( g_TwoSegmentTrackBuild )
{ {
// Create 2nd segment // Create 2nd segment
g_CurrentTrackList.PushBack( g_CurrentTrackSegment->Copy() ); g_CurrentTrackList.PushBack( (TRACK*)g_CurrentTrackSegment->Clone() );
D( g_CurrentTrackList.VerifyListIntegrity(); ); D( g_CurrentTrackList.VerifyListIntegrity(); );
@ -254,7 +254,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
TRACK* previousTrack = g_CurrentTrackSegment; TRACK* previousTrack = g_CurrentTrackSegment;
TRACK* newTrack = g_CurrentTrackSegment->Copy(); TRACK* newTrack = (TRACK*)g_CurrentTrackSegment->Clone();
g_CurrentTrackList.PushBack( newTrack ); g_CurrentTrackList.PushBack( newTrack );
newTrack->SetFlags( IS_NEW ); newTrack->SetFlags( IS_NEW );
@ -327,7 +327,7 @@ bool PCB_EDIT_FRAME::Add45DegreeSegment( wxDC* aDC )
return false; return false;
/* Create a new segment and connect it with the previous 2 segments. */ /* Create a new segment and connect it with the previous 2 segments. */
TRACK* newTrack = curTrack->Copy(); TRACK* newTrack = (TRACK*)curTrack->Clone();
newTrack->m_Start = prevTrack->m_End; newTrack->m_Start = prevTrack->m_End;
newTrack->m_End = curTrack->m_Start; newTrack->m_End = curTrack->m_Start;
@ -1079,7 +1079,7 @@ void EnsureEndTrackOnPad( D_PAD* Pad )
if( !g_CurrentTrackSegment->IsNull() ) if( !g_CurrentTrackSegment->IsNull() )
{ {
/* Must create a new segment, from track end to pad center */ /* Must create a new segment, from track end to pad center */
g_CurrentTrackList.PushBack( lasttrack->Copy() ); g_CurrentTrackList.PushBack( (TRACK*)lasttrack->Clone() );
lasttrack->end = g_CurrentTrackSegment; lasttrack->end = g_CurrentTrackSegment;
} }

View File

@ -76,8 +76,8 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
Clear_Pcb( false ); Clear_Pcb( false );
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
newModule = new MODULE( GetBoard() ); newModule = new MODULE( *aModule );
newModule->Copy( aModule ); newModule->SetParent( GetBoard() );
newModule->m_Link = aModule->GetTimeStamp(); newModule->m_Link = aModule->GetTimeStamp();
aModule = newModule; aModule = newModule;

View File

@ -309,8 +309,8 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
} }
// Create the "new" module // Create the "new" module
MODULE* newmodule = new MODULE( mainpcb ); MODULE* newmodule = new MODULE( *module_in_edit );
newmodule->Copy( module_in_edit ); newmodule->SetParent( mainpcb );
newmodule->m_Link = 0; newmodule->m_Link = 0;
// Put the footprint in the main pcb linked list. // Put the footprint in the main pcb linked list.

View File

@ -22,8 +22,7 @@ void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
MODULE* CopyItem; MODULE* CopyItem;
PICKED_ITEMS_LIST* lastcmd; PICKED_ITEMS_LIST* lastcmd;
CopyItem = new MODULE( GetBoard() ); CopyItem = new MODULE( *( (MODULE*) aItem ) );
CopyItem->Copy( (MODULE*) aItem );
CopyItem->SetParent( GetBoard() ); CopyItem->SetParent( GetBoard() );
lastcmd = new PICKED_ITEMS_LIST(); lastcmd = new PICKED_ITEMS_LIST();

View File

@ -99,8 +99,8 @@ void PCB_EDIT_FRAME::StartMove_Module( MODULE* module, wxDC* DC )
s_PickedList.ClearItemsList(); // Should be empty, but... s_PickedList.ClearItemsList(); // Should be empty, but...
// Creates a copy of the current module, for abort and undo commands // Creates a copy of the current module, for abort and undo commands
s_ModuleInitialCopy = new MODULE( GetBoard() ); s_ModuleInitialCopy = (MODULE*)module->Clone();
s_ModuleInitialCopy->Copy( module ); s_ModuleInitialCopy->SetParent( GetBoard() );
s_ModuleInitialCopy->ClearFlags(); s_ModuleInitialCopy->ClearFlags();
SetCurItem( module ); SetCurItem( module );
@ -122,7 +122,7 @@ void PCB_EDIT_FRAME::StartMove_Module( MODULE* module, wxDC* DC )
{ {
TRACK* segm = g_DragSegmentList[ii].m_Segm; TRACK* segm = g_DragSegmentList[ii].m_Segm;
itemWrapper.m_PickedItem = segm; itemWrapper.m_PickedItem = segm;
itemWrapper.m_Link = segm->Copy(); itemWrapper.m_Link = segm->Clone();
itemWrapper.m_Link->SetState( IN_EDIT, OFF ); itemWrapper.m_Link->SetState( IN_EDIT, OFF );
s_PickedList.PushItem( itemWrapper ); s_PickedList.PushItem( itemWrapper );
} }

View File

@ -758,14 +758,14 @@ void PCB_EDIT_FRAME::StartMoveOneNodeOrSegment( TRACK* aTrack, wxDC* aDC, int aC
// Prepare the Undo command // Prepare the Undo command
ITEM_PICKER picker( aTrack, UR_CHANGED ); ITEM_PICKER picker( aTrack, UR_CHANGED );
picker.m_Link = aTrack->Copy(); picker.m_Link = aTrack->Clone();
s_ItemsListPicker.PushItem( picker ); s_ItemsListPicker.PushItem( picker );
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{ {
TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm; TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm;
picker.m_PickedItem = draggedtrack; picker.m_PickedItem = draggedtrack;
picker.m_Link = draggedtrack->Copy(); picker.m_Link = draggedtrack->Clone();
s_ItemsListPicker.PushItem( picker ); s_ItemsListPicker.PushItem( picker );
draggedtrack = (TRACK*) picker.m_Link; draggedtrack = (TRACK*) picker.m_Link;
draggedtrack->SetStatus( 0 ); draggedtrack->SetStatus( 0 );
@ -980,7 +980,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
{ {
TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm; TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm;
picker.m_PickedItem = draggedtrack; picker.m_PickedItem = draggedtrack;
picker.m_Link = draggedtrack->Copy(); picker.m_Link = draggedtrack->Clone();
s_ItemsListPicker.PushItem( picker ); s_ItemsListPicker.PushItem( picker );
draggedtrack = (TRACK*) picker.m_Link; draggedtrack = (TRACK*) picker.m_Link;
draggedtrack->SetStatus( 0 ); draggedtrack->SetStatus( 0 );

View File

@ -267,8 +267,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
PtPad->m_PadShape = PAD_CIRCLE; PtPad->m_PadShape = PAD_CIRCLE;
PtPad->ComputeShapeMaxRadius(); PtPad->ComputeShapeMaxRadius();
D_PAD* newpad = new D_PAD( module ); D_PAD* newpad = new D_PAD( *PtPad );
newpad->Copy( PtPad );
module->m_Pads.Insert( newpad, PtPad->Next() ); module->m_Pads.Insert( newpad, PtPad->Next() );

View File

@ -1165,8 +1165,8 @@ bool NETLIST_READER::loadNewModules()
if( Module == NULL ) if( Module == NULL )
continue; // Module does not exist in library. continue; // Module does not exist in library.
MODULE* newmodule = new MODULE( pcb ); MODULE* newmodule = new MODULE( *Module );
newmodule->Copy( Module ); newmodule->SetParent( pcb );
pcb->Add( newmodule, ADD_APPEND ); pcb->Add( newmodule, ADD_APPEND );

View File

@ -1219,7 +1219,7 @@ static void OrCell_Trace( BOARD* pcb, int col, int row,
{ {
g_CurrentTrackSegment->m_Start = pt_cur_ch->m_PadEnd->GetPosition(); g_CurrentTrackSegment->m_Start = pt_cur_ch->m_PadEnd->GetPosition();
newTrack = g_CurrentTrackSegment->Copy(); newTrack = (TRACK*)g_CurrentTrackSegment->Clone();
newTrack->m_Start = g_CurrentTrackSegment->m_End; newTrack->m_Start = g_CurrentTrackSegment->m_End;
g_CurrentTrackList.PushBack( newTrack ); g_CurrentTrackList.PushBack( newTrack );
@ -1292,7 +1292,7 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
} }
else else
{ {
TRACK* newTrack = g_CurrentTrackSegment->Copy(); TRACK* newTrack = (TRACK*)g_CurrentTrackSegment->Clone();
newTrack->m_End = pt_cur_ch->m_PadStart->GetPosition(); newTrack->m_End = pt_cur_ch->m_PadStart->GetPosition();
newTrack->m_Start = g_CurrentTrackSegment->m_End; newTrack->m_Start = g_CurrentTrackSegment->m_End;

View File

@ -132,8 +132,8 @@ int SaveCopyOfZones( PICKED_ITEMS_LIST& aPickList, BOARD* aPcb, int aNetCode, in
if( aLayer >= 0 && aLayer != zone->GetLayer() ) if( aLayer >= 0 && aLayer != zone->GetLayer() )
continue; continue;
ZONE_CONTAINER* zoneDup = new ZONE_CONTAINER( aPcb ); ZONE_CONTAINER* zoneDup = new ZONE_CONTAINER( *zone );
zoneDup->Copy( zone ); zoneDup->SetParent( aPcb );
ITEM_PICKER picker( zone, UR_CHANGED ); ITEM_PICKER picker( zone, UR_CHANGED );
picker.m_Link = zoneDup; picker.m_Link = zoneDup;
picker.m_PickedItemType = zone->Type(); picker.m_PickedItemType = zone->Type();
@ -211,7 +211,8 @@ void UpdateCopyOfZonesList( PICKED_ITEMS_LIST& aPickList,
else else
wxMessageBox( wxT( "UpdateCopyOfZonesList() error: link = NULL" ) ); wxMessageBox( wxT( "UpdateCopyOfZonesList() error: link = NULL" ) );
aPickList.SetPickedItemLink( NULL, kk ); // the copy was deleted; the link does not exists now // the copy was deleted; the link does not exists now.
aPickList.SetPickedItemLink( NULL, kk );
delete zcopy; delete zcopy;
} }