2014-10-19 22:17:43 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.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
|
|
|
|
*/
|
|
|
|
|
2010-01-09 08:50:30 +00:00
|
|
|
/*
|
2011-10-07 14:41:30 +00:00
|
|
|
* @file events_called_functions.cpp
|
2010-01-09 08:50:30 +00:00
|
|
|
*/
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <general.h>
|
|
|
|
#include <kicad_device_context.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_text.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2010-01-09 08:50:30 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
|
2010-01-09 08:50:30 +00:00
|
|
|
{
|
|
|
|
SCH_ITEM * curr_item = GetScreen()->GetCurItem();
|
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !curr_item || curr_item->GetFlags() )
|
2010-01-09 08:50:30 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
2010-01-09 08:50:30 +00:00
|
|
|
|
|
|
|
switch( curr_item->Type() )
|
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_COMPONENT_T:
|
2010-01-09 08:50:30 +00:00
|
|
|
{
|
|
|
|
SCH_COMPONENT* newitem;
|
2010-12-21 15:13:09 +00:00
|
|
|
newitem = new SCH_COMPONENT( *( (SCH_COMPONENT*) curr_item ) );
|
2011-12-12 08:37:05 +00:00
|
|
|
newitem->SetTimeStamp( GetNewTimeStamp() );
|
2010-01-09 08:50:30 +00:00
|
|
|
newitem->ClearAnnotation( NULL );
|
2011-12-21 13:42:02 +00:00
|
|
|
newitem->SetFlags( IS_NEW );
|
2013-04-16 10:53:23 +00:00
|
|
|
// Draw the new part, MoveItem() expects it to be already on screen.
|
|
|
|
newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
|
2015-02-28 16:56:09 +00:00
|
|
|
PrepareMoveItem( newitem, &dc );
|
2010-01-09 08:50:30 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_TEXT_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
2010-01-09 08:50:30 +00:00
|
|
|
{
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone();
|
2011-04-05 14:46:51 +00:00
|
|
|
newitem->SetFlags( IS_NEW );
|
2013-04-16 10:53:23 +00:00
|
|
|
// Draw the new item, MoveItem() expects it to be already on screen.
|
|
|
|
newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
|
2015-02-28 16:56:09 +00:00
|
|
|
PrepareMoveItem( newitem, &dc );
|
2010-01-09 08:50:30 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|