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
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "eeschema_id.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2010-12-21 15:13:09 +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
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusEntry( wxDC* DC, int entry_type )
|
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
|
2011-02-11 20:48:13 +00:00
|
|
|
SCH_BUS_ENTRY* BusEntry = new SCH_BUS_ENTRY( GetScreen()->GetCrossHairPosition(), s_LastShape,
|
|
|
|
entry_type );
|
2007-08-20 01:20:48 +00:00
|
|
|
BusEntry->m_Flags = IS_NEW;
|
2011-03-03 19:08:13 +00:00
|
|
|
BusEntry->Place( this, DC );
|
2010-12-08 20:12:46 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +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
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY* BusEntry, int entry_shape )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( BusEntry == NULL )
|
|
|
|
return;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( BusEntry->Type() != SCH_BUS_ENTRY_T )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, wxT( "SetBusEntryType: Bad StructType" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Put old item in undo list if it is not currently in edit */
|
|
|
|
if( BusEntry->m_Flags == 0 )
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( BusEntry, UR_CHANGED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-01-10 16:50:40 +00:00
|
|
|
BusEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
switch( entry_shape )
|
|
|
|
{
|
|
|
|
case '\\':
|
|
|
|
s_LastShape = '\\';
|
|
|
|
BusEntry->m_Size.y = 100;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '/':
|
|
|
|
s_LastShape = '/';
|
|
|
|
BusEntry->m_Size.y = -100;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
GetScreen()->TestDanglingEnds();
|
2011-01-10 16:50:40 +00:00
|
|
|
BusEntry->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
int SCH_EDIT_FRAME::GetBusEntryShape( SCH_BUS_ENTRY* BusEntry )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int entry_shape = '\\';
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( BusEntry->m_Size.y < 0 )
|
|
|
|
entry_shape = '/';
|
2011-10-19 20:32:21 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return entry_shape;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|