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>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <eeschema_id.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <wxEeschemaStruct.h>
|
|
|
|
|
|
|
|
#include <general.h>
|
|
|
|
#include <protos.h>
|
|
|
|
#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
|
|
|
|
2013-04-01 10:35:20 +00:00
|
|
|
SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry( wxDC* aDC )
|
2009-11-03 13:26:31 +00:00
|
|
|
{
|
2012-01-04 22:08:46 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
|
2010-11-11 17:54:24 +00:00
|
|
|
// Create and place a new bus entry at cursor position
|
2013-04-01 10:35:20 +00:00
|
|
|
SCH_BUS_BUS_ENTRY* busEntry = new SCH_BUS_BUS_ENTRY( screen->GetCrossHairPosition(), s_LastShape );
|
2012-01-04 22:08:46 +00:00
|
|
|
busEntry->SetFlags( IS_NEW );
|
|
|
|
GetScreen()->SetCurItem( busEntry );
|
|
|
|
addCurrentItemToList( aDC );
|
|
|
|
return busEntry;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-01 10:35:20 +00:00
|
|
|
SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry( wxDC* aDC )
|
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
|
|
|
|
// Create and place a new bus entry at cursor position
|
|
|
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( screen->GetCrossHairPosition(), s_LastShape );
|
|
|
|
busEntry->SetFlags( IS_NEW );
|
|
|
|
GetScreen()->SetCurItem( busEntry );
|
|
|
|
addCurrentItemToList( aDC );
|
|
|
|
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-22 13:28:11 +00:00
|
|
|
BusEntry->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
|
2011-12-18 17:57:05 +00:00
|
|
|
BusEntry->SetBusEntryShape( s_LastShape );
|
2011-01-21 19:30:59 +00:00
|
|
|
GetScreen()->TestDanglingEnds();
|
2011-12-22 13:28:11 +00:00
|
|
|
BusEntry->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-12-18 17:57:05 +00:00
|
|
|
OnModify( );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|