2011-10-19 20:32:21 +00:00
|
|
|
/*
|
|
|
|
* 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) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
/**
|
|
|
|
* @file busentry.cpp
|
|
|
|
* @brief Code to handle manipulation of bus entry objects.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <sch_bus_entry.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
static int s_LastShape = '\\';
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2015-06-28 16:45:05 +00:00
|
|
|
SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry()
|
2009-11-03 13:26:31 +00:00
|
|
|
{
|
2010-11-11 17:54:24 +00:00
|
|
|
// Create and place a new bus entry at cursor position
|
2013-08-03 05:15:23 +00:00
|
|
|
SCH_BUS_BUS_ENTRY* busEntry = new SCH_BUS_BUS_ENTRY( GetCrossHairPosition(), s_LastShape );
|
|
|
|
|
2012-01-04 22:08:46 +00:00
|
|
|
busEntry->SetFlags( IS_NEW );
|
|
|
|
GetScreen()->SetCurItem( busEntry );
|
2018-09-10 10:58:50 +00:00
|
|
|
addCurrentItemToScreen();
|
2012-01-04 22:08:46 +00:00
|
|
|
return busEntry;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2015-06-28 16:45:05 +00:00
|
|
|
SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry()
|
2013-04-01 10:35:20 +00:00
|
|
|
{
|
|
|
|
// Create and place a new bus entry at cursor position
|
2013-08-03 05:15:23 +00:00
|
|
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( GetCrossHairPosition(), s_LastShape );
|
|
|
|
|
2013-04-01 10:35:20 +00:00
|
|
|
busEntry->SetFlags( IS_NEW );
|
|
|
|
GetScreen()->SetCurItem( busEntry );
|
2018-09-10 10:58:50 +00:00
|
|
|
addCurrentItemToScreen();
|
2013-04-01 10:35:20 +00:00
|
|
|
return busEntry;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* set the shape of BusEntry (shape = / or \ )
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2013-04-01 10:35:20 +00:00
|
|
|
void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY_BASE* BusEntry, char entry_shape )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( BusEntry == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Put old item in undo list if it is not currently in edit */
|
2011-12-21 13:42:02 +00:00
|
|
|
if( BusEntry->GetFlags() == 0 )
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( BusEntry, UR_CHANGED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-18 17:57:05 +00:00
|
|
|
s_LastShape = entry_shape == '/' ? '/' : '\\';
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-18 17:57:05 +00:00
|
|
|
BusEntry->SetBusEntryShape( s_LastShape );
|
2018-10-16 13:11:33 +00:00
|
|
|
TestDanglingEnds();
|
2018-10-18 09:50:43 +00:00
|
|
|
|
|
|
|
RefreshItem( BusEntry );
|
2011-12-18 17:57:05 +00:00
|
|
|
OnModify( );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|