2011-10-07 14:41:30 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2011-10-21 13:59:15 +00:00
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-07 14:41:30 +00:00
|
|
|
*
|
|
|
|
* 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 sch_sheet_pin.cpp
|
|
|
|
* @brief Implementation of the SCH_SHEET_PIN class.
|
|
|
|
*/
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <drawtxt.h>
|
|
|
|
#include <plot_common.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <richio.h>
|
2015-02-21 09:46:44 +00:00
|
|
|
#include <schframe.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <sch_sheet.h>
|
|
|
|
#include <kicad_string.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) :
|
2011-03-30 19:26:05 +00:00
|
|
|
SCH_HIERLABEL( pos, text, SCH_SHEET_PIN_T )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
SetParent( parent );
|
2008-04-22 16:38:23 +00:00
|
|
|
wxASSERT( parent );
|
2008-12-29 18:02:54 +00:00
|
|
|
m_Layer = LAYER_SHEETLABEL;
|
|
|
|
m_Pos = pos;
|
2011-10-21 13:59:15 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
if( parent->IsVerticalOrientation() )
|
|
|
|
SetEdge( 2 );
|
|
|
|
else
|
|
|
|
SetEdge( 0 );
|
2011-10-21 13:59:15 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_INPUT;
|
|
|
|
m_isDangling = true;
|
|
|
|
m_number = 2;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* SCH_SHEET_PIN::Clone() const
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
|
|
|
return new SCH_SHEET_PIN( *this );
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void SCH_SHEET_PIN::Draw( EDA_DRAW_PANEL* aPanel,
|
|
|
|
wxDC* aDC,
|
|
|
|
const wxPoint& aOffset,
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE aDraw_mode,
|
2012-09-02 12:06:47 +00:00
|
|
|
EDA_COLOR_T aColor )
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
|
|
|
// The icon selection is handle by the virtual method CreateGraphicShape
|
|
|
|
// called by ::Draw
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_HIERLABEL::Draw( aPanel, aDC, aOffset, aDraw_mode, aColor );
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2011-06-07 15:29:01 +00:00
|
|
|
void SCH_SHEET_PIN::SwapData( SCH_ITEM* aItem )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2011-06-07 15:29:01 +00:00
|
|
|
wxCHECK_RET( aItem->Type() == SCH_SHEET_PIN_T,
|
|
|
|
wxString::Format( wxT( "SCH_SHEET_PIN object cannot swap data with %s object." ),
|
|
|
|
GetChars( aItem->GetClass() ) ) );
|
|
|
|
|
|
|
|
SCH_SHEET_PIN* pin = ( SCH_SHEET_PIN* ) aItem;
|
|
|
|
SCH_TEXT::SwapData( (SCH_TEXT*) pin );
|
2010-09-05 17:01:48 +00:00
|
|
|
int tmp;
|
2011-06-07 15:29:01 +00:00
|
|
|
tmp = pin->GetNumber();
|
|
|
|
pin->SetNumber( GetNumber() );
|
2010-09-05 17:01:48 +00:00
|
|
|
SetNumber( tmp );
|
2011-06-07 15:29:01 +00:00
|
|
|
tmp = pin->GetEdge();
|
|
|
|
pin->SetEdge( GetEdge() );
|
2010-09-05 17:01:48 +00:00
|
|
|
SetEdge( tmp );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_SHEET_PIN::operator==( const SCH_SHEET_PIN* aPin ) const
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
|
|
|
return aPin == this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
int SCH_SHEET_PIN::GetPenSize() const
|
2009-06-30 19:21:41 +00:00
|
|
|
{
|
2012-09-28 17:47:41 +00:00
|
|
|
return GetDefaultLineThickness();
|
2009-06-30 19:21:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
void SCH_SHEET_PIN::SetNumber( int aNumber )
|
|
|
|
{
|
|
|
|
wxASSERT( aNumber >= 2 );
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
m_number = aNumber;
|
2010-06-24 18:31:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
void SCH_SHEET_PIN::SetEdge( int aEdge )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
/* use -1 to adjust text orientation without changing edge*/
|
|
|
|
if( aEdge > -1 )
|
2011-12-08 15:45:01 +00:00
|
|
|
m_edge = aEdge;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
switch( m_edge )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
case 0: /* pin on left side*/
|
2011-12-08 15:45:01 +00:00
|
|
|
m_Pos.x = Sheet->m_pos.x;
|
2011-03-03 01:58:12 +00:00
|
|
|
SetOrientation( 2 ); /* Orientation horiz inverse */
|
2010-09-05 17:01:48 +00:00
|
|
|
break;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
case 1: /* pin on right side*/
|
2011-12-08 15:45:01 +00:00
|
|
|
m_Pos.x = Sheet->m_pos.x + Sheet->m_size.x;
|
2011-03-03 01:58:12 +00:00
|
|
|
SetOrientation( 0 ); /* Orientation horiz normal */
|
2010-09-05 17:01:48 +00:00
|
|
|
break;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
case 2: /* pin on top side*/
|
2011-12-08 15:45:01 +00:00
|
|
|
m_Pos.y = Sheet->m_pos.y;
|
2011-03-03 01:58:12 +00:00
|
|
|
SetOrientation( 3 ); /* Orientation vert BOTTOM */
|
2010-09-05 17:01:48 +00:00
|
|
|
break;
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
case 3: /* pin on bottom side*/
|
2011-12-08 15:45:01 +00:00
|
|
|
m_Pos.y = Sheet->m_pos.y + Sheet->m_size.y;
|
2011-03-03 01:58:12 +00:00
|
|
|
SetOrientation( 1 ); /* Orientation vert UP */
|
2010-09-05 17:01:48 +00:00
|
|
|
break;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
2009-05-05 18:25:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-07 15:29:01 +00:00
|
|
|
int SCH_SHEET_PIN::GetEdge() const
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-12-08 15:45:01 +00:00
|
|
|
return m_edge;
|
2010-06-24 18:31:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-21 13:59:15 +00:00
|
|
|
void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos )
|
2009-05-05 18:25:47 +00:00
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
if( Sheet == NULL )
|
|
|
|
return;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
if( m_edge<2 ) /*horizontal sheetpin*/
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2011-12-08 15:45:01 +00:00
|
|
|
if( Pos.x > ( Sheet->m_pos.x + ( Sheet->m_size.x / 2 ) ) )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
SetEdge( 1 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetEdge( 0 );
|
|
|
|
}
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
m_Pos.y = Pos.y;
|
2011-10-21 13:59:15 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
if( m_Pos.y < Sheet->m_pos.y )
|
|
|
|
m_Pos.y = Sheet->m_pos.y;
|
2011-10-21 13:59:15 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
if( m_Pos.y > (Sheet->m_pos.y + Sheet->m_size.y) )
|
|
|
|
m_Pos.y = Sheet->m_pos.y + Sheet->m_size.y;
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
else /* vertical sheetpin*/
|
|
|
|
{
|
2011-12-08 15:45:01 +00:00
|
|
|
if( Pos.y > ( Sheet->m_pos.y + ( Sheet->m_size.y / 2 ) ) )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
SetEdge( 3 ); //bottom
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetEdge( 2 ); //top
|
|
|
|
}
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
m_Pos.x = Pos.x;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
if( m_Pos.x < Sheet->m_pos.x )
|
|
|
|
m_Pos.x = Sheet->m_pos.x;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
if( m_Pos.x > (Sheet->m_pos.x + Sheet->m_size.x) )
|
|
|
|
m_Pos.x = Sheet->m_pos.x + Sheet->m_size.x;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
bool SCH_SHEET_PIN::Save( FILE* aFile ) const
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
|
|
|
int type = 'U', side = 'L';
|
|
|
|
|
|
|
|
if( m_Text.IsEmpty() )
|
|
|
|
return true;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
switch( m_edge )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
case 0: //pin on left side
|
|
|
|
side = 'L';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: //pin on right side
|
2008-04-15 19:38:19 +00:00
|
|
|
side = 'R';
|
2010-09-05 17:01:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: //pin on top side
|
|
|
|
side = 'T';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: //pin on bottom side
|
|
|
|
side = 'B';
|
|
|
|
break;
|
|
|
|
}
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
switch( m_shape )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
|
|
|
case NET_INPUT:
|
|
|
|
type = 'I'; break;
|
|
|
|
|
|
|
|
case NET_OUTPUT:
|
|
|
|
type = 'O'; break;
|
|
|
|
|
|
|
|
case NET_BIDI:
|
|
|
|
type = 'B'; break;
|
|
|
|
|
|
|
|
case NET_TRISTATE:
|
|
|
|
type = 'T'; break;
|
|
|
|
|
|
|
|
case NET_UNSPECIFIED:
|
|
|
|
type = 'U'; break;
|
|
|
|
}
|
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
if( fprintf( aFile, "F%d %s %c %c %-3d %-3d %-3d\n", m_number,
|
2011-03-22 18:29:26 +00:00
|
|
|
EscapedUTF8( m_Text ).c_str(), // supplies wrapping quotes
|
|
|
|
type, side, m_Pos.x, m_Pos.y,
|
2008-12-29 18:02:54 +00:00
|
|
|
m_Size.x ) == EOF )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|
|
|
{
|
2011-03-22 16:49:44 +00:00
|
|
|
int size;
|
|
|
|
char number[256];
|
|
|
|
char name[256];
|
|
|
|
char connectType[256];
|
|
|
|
char sheetSide[256];
|
|
|
|
char* line = aLine.Line();
|
|
|
|
char* cp;
|
|
|
|
|
|
|
|
static const char delims[] = " \t";
|
|
|
|
|
|
|
|
// Read coordinates.
|
2011-06-09 13:30:46 +00:00
|
|
|
// D( printf( "line: \"%s\"\n", line );)
|
2011-03-22 16:49:44 +00:00
|
|
|
|
|
|
|
cp = strtok( line, delims );
|
|
|
|
|
|
|
|
strncpy( number, cp, sizeof(number) );
|
|
|
|
number[sizeof(number)-1] = 0;
|
|
|
|
|
|
|
|
cp += strlen( number ) + 1;
|
|
|
|
|
|
|
|
cp += ReadDelimitedText( name, cp, sizeof(name) );
|
|
|
|
|
|
|
|
cp = strtok( cp, delims );
|
|
|
|
strncpy( connectType, cp, sizeof(connectType) );
|
|
|
|
connectType[sizeof(connectType)-1] = 0;
|
|
|
|
|
|
|
|
cp = strtok( NULL, delims );
|
|
|
|
strncpy( sheetSide, cp, sizeof(sheetSide) );
|
|
|
|
sheetSide[sizeof(sheetSide)-1] = 0;
|
|
|
|
|
|
|
|
cp += strlen( sheetSide ) + 1;
|
|
|
|
|
|
|
|
int r = sscanf( cp, "%d %d %d", &m_Pos.x, &m_Pos.y, &size );
|
|
|
|
if( r != 3 )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file sheet hierarchical label error at line %d.\n" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
2011-03-22 16:49:44 +00:00
|
|
|
|
|
|
|
aErrorMsg << FROM_UTF8( line );
|
2010-11-10 15:30:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
m_Text = FROM_UTF8( name );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
if( size == 0 )
|
2014-05-16 13:57:53 +00:00
|
|
|
size = GetDefaultTextSize();
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
m_Size.x = m_Size.y = size;
|
|
|
|
|
|
|
|
switch( connectType[0] )
|
|
|
|
{
|
|
|
|
case 'I':
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_INPUT;
|
2010-11-10 15:30:12 +00:00
|
|
|
break;
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
case 'O':
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_OUTPUT;
|
2010-11-10 15:30:12 +00:00
|
|
|
break;
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
case 'B':
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_BIDI;
|
2010-11-10 15:30:12 +00:00
|
|
|
break;
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
case 'T':
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_TRISTATE;
|
2010-11-10 15:30:12 +00:00
|
|
|
break;
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
case 'U':
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_UNSPECIFIED;
|
2010-11-10 15:30:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( sheetSide[0] )
|
|
|
|
{
|
|
|
|
case 'R' : /* pin on right side */
|
|
|
|
SetEdge( 1 );
|
|
|
|
break;
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
case 'T' : /* pin on top side */
|
|
|
|
SetEdge( 2 );
|
|
|
|
break;
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
case 'B' : /* pin on bottom side */
|
|
|
|
SetEdge( 3 );
|
|
|
|
break;
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
case 'L' : /* pin on left side */
|
|
|
|
default :
|
|
|
|
SetEdge( 0 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
bool SCH_SHEET_PIN::Matches( wxFindReplaceData& aSearchData,
|
2011-12-01 16:49:28 +00:00
|
|
|
void* aAuxData, wxPoint* aFindLocation )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
2011-12-01 16:49:28 +00:00
|
|
|
wxCHECK_MSG( GetParent() != NULL, false,
|
|
|
|
wxT( "Sheet pin " ) + m_Text + wxT( " does not have a parent sheet!" ) );
|
|
|
|
|
2011-12-13 15:37:33 +00:00
|
|
|
wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText() );
|
2011-12-01 16:49:28 +00:00
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
if( SCH_ITEM::Matches( m_Text, aSearchData ) )
|
|
|
|
{
|
|
|
|
if( aFindLocation )
|
2011-12-01 16:49:28 +00:00
|
|
|
*aFindLocation = GetBoundingBox().Centre();
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2010-03-16 18:22:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_SHEET_PIN::MirrorX( int aXaxis_position )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
int p = m_Pos.y - aXaxis_position;
|
|
|
|
|
|
|
|
m_Pos.y = aXaxis_position - p;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
switch( m_edge )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
SetEdge( 3 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
SetEdge( 2 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_SHEET_PIN::MirrorY( int aYaxis_position )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
int p = m_Pos.x - aYaxis_position;
|
|
|
|
|
|
|
|
m_Pos.x = aYaxis_position - p;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
switch( m_edge )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetEdge( 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
SetEdge( 0 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_SHEET_PIN::Rotate( wxPoint aPosition )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2012-03-15 14:31:16 +00:00
|
|
|
RotatePoint( &m_Pos, aPosition, 900 );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
switch( m_edge )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
case 0: //pin on left side
|
|
|
|
SetEdge( 3 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: //pin on right side
|
|
|
|
SetEdge( 2 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: //pin on top side
|
|
|
|
SetEdge( 0 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: //pin on bottom side
|
|
|
|
SetEdge( 1 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wxPoint& aPos )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
|
|
|
/* This is the same icon shapes as SCH_HIERLABEL
|
|
|
|
* but the graphic icon is slightly different in 2 cases:
|
|
|
|
* for INPUT type the icon is the OUTPUT shape of SCH_HIERLABEL
|
|
|
|
* for OUTPUT type the icon is the INPUT shape of SCH_HIERLABEL
|
|
|
|
*/
|
2011-12-08 15:45:01 +00:00
|
|
|
int tmp = m_shape;
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2011-12-08 15:45:01 +00:00
|
|
|
switch( m_shape )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
|
|
|
case NET_INPUT:
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_OUTPUT;
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_OUTPUT:
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = NET_INPUT;
|
2010-11-03 14:13:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
SCH_HIERLABEL::CreateGraphicShape( aPoints, aPos );
|
2011-12-08 15:45:01 +00:00
|
|
|
m_shape = tmp;
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SHEET_PIN::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
|
|
|
{
|
2011-12-06 21:02:21 +00:00
|
|
|
DANGLING_END_ITEM item( SHEET_LABEL_END, this, m_Pos );
|
2010-11-03 14:13:15 +00:00
|
|
|
aItemList.push_back( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
wxString SCH_SHEET_PIN::GetSelectMenuText() const
|
|
|
|
{
|
2011-03-26 10:08:50 +00:00
|
|
|
wxString tmp;
|
2014-09-13 18:15:45 +00:00
|
|
|
tmp.Printf( _( "Hierarchical Sheet Pin %s" ), GetChars( ShortenedShownText() ) );
|
2011-03-26 10:08:50 +00:00
|
|
|
return tmp;
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool SCH_SHEET_PIN::HitTest( const wxPoint& aPoint, int aAccuracy ) const
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT rect = GetBoundingBox();
|
2011-03-25 19:16:05 +00:00
|
|
|
|
|
|
|
rect.Inflate( aAccuracy );
|
|
|
|
|
|
|
|
return rect.Contains( aPoint );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-22 16:38:23 +00:00
|
|
|
#if defined(DEBUG)
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
void SCH_SHEET_PIN::Show( int nestLevel, std::ostream& os ) const
|
2008-04-22 16:38:23 +00:00
|
|
|
{
|
|
|
|
// XML output:
|
|
|
|
wxString s = GetClass();
|
|
|
|
|
|
|
|
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">"
|
2011-02-28 18:36:19 +00:00
|
|
|
<< " pin_name=\"" << TO_UTF8( m_Text )
|
2009-11-03 13:26:31 +00:00
|
|
|
<< '"' << "/>\n" << std::flush;
|
2008-04-22 16:38:23 +00:00
|
|
|
|
|
|
|
// NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|