2008-04-15 19:38:19 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2010-11-11 21:10:27 +00:00
|
|
|
// Name: sch_sheet_pin.cpp
|
2009-11-04 20:46:53 +00:00
|
|
|
// Purpose: member functions SCH_SHEET_PIN
|
2010-11-11 21:10:27 +00:00
|
|
|
// header = sch_sheet.h
|
2008-04-15 19:38:19 +00:00
|
|
|
// Author: jean-pierre Charras
|
|
|
|
// Modified by:
|
|
|
|
// Created: 08/02/2006 18:37:02
|
|
|
|
// RCS-ID:
|
|
|
|
// Copyright: License GNU
|
2009-11-03 13:26:31 +00:00
|
|
|
// License:
|
2008-04-15 19:38:19 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "drawtxt.h"
|
2010-06-24 18:31:43 +00:00
|
|
|
#include "plot_common.h"
|
2010-09-05 17:01:48 +00:00
|
|
|
#include "trigo.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "richio.h"
|
|
|
|
#include "class_sch_screen.h"
|
2011-03-30 19:26:05 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_sheet.h"
|
2011-03-22 16:49:44 +00:00
|
|
|
#include "kicad_string.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
/* m_Edge define on which edge the pin is positionned:
|
|
|
|
*
|
|
|
|
* 0: pin on left side
|
|
|
|
* 1: pin on right side
|
|
|
|
* 2: pin on top side
|
|
|
|
* 3: pin on bottom side
|
|
|
|
* for compatibility reasons, this does not follow same values as text
|
|
|
|
* ortientation.
|
|
|
|
*/
|
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;
|
2010-09-05 17:01:48 +00:00
|
|
|
if( parent->IsVerticalOrientation() )
|
|
|
|
SetEdge( 2 );
|
|
|
|
else
|
|
|
|
SetEdge( 0 );
|
2008-12-29 18:02:54 +00:00
|
|
|
m_Shape = NET_INPUT;
|
2008-04-15 19:38:19 +00:00
|
|
|
m_IsDangling = TRUE;
|
2008-12-29 18:02:54 +00:00
|
|
|
m_Number = 2;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_SHEET_PIN::SCH_SHEET_PIN( const SCH_SHEET_PIN& aSheetLabel ) :
|
|
|
|
SCH_HIERLABEL( aSheetLabel )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2010-12-21 15:13:09 +00:00
|
|
|
m_Number = aSheetLabel.m_Number;
|
|
|
|
m_Edge = aSheetLabel.m_Edge;
|
|
|
|
}
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
EDA_ITEM* SCH_SHEET_PIN::doClone() const
|
|
|
|
{
|
|
|
|
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,
|
|
|
|
int aDraw_mode,
|
|
|
|
int 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
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
void SCH_SHEET_PIN::SwapData( SCH_SHEET_PIN* copyitem )
|
|
|
|
{
|
|
|
|
SCH_TEXT::SwapData( (SCH_TEXT*) copyitem );
|
|
|
|
int tmp;
|
|
|
|
tmp = copyitem->GetNumber();
|
|
|
|
copyitem->SetNumber( GetNumber() );
|
|
|
|
SetNumber( tmp );
|
|
|
|
tmp = copyitem->GetEdge();
|
|
|
|
copyitem->SetEdge( GetEdge() );
|
|
|
|
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
|
|
|
{
|
|
|
|
return g_DrawDefaultLineThickness;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
void SCH_SHEET_PIN::SetNumber( int aNumber )
|
|
|
|
{
|
|
|
|
wxASSERT( aNumber >= 2 );
|
|
|
|
|
|
|
|
m_Number = aNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
void SCH_SHEET_PIN::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC )
|
|
|
|
{
|
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) GetParent();
|
|
|
|
|
|
|
|
wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
|
|
|
|
wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
|
|
|
|
|
|
|
|
int flags = m_Flags;
|
|
|
|
m_Flags = 0;
|
|
|
|
|
|
|
|
if( flags & IS_NEW )
|
|
|
|
{
|
|
|
|
aFrame->SaveCopyInUndoList( sheet, UR_CHANGED );
|
|
|
|
sheet->AddPin( this );
|
|
|
|
}
|
|
|
|
else // pin sheet was existing and only moved
|
|
|
|
{
|
|
|
|
wxPoint tmp = m_Pos;
|
|
|
|
m_Pos = aFrame->GetLastSheetPinPosition();
|
|
|
|
SetEdge( aFrame->GetLastSheetPinEdge() );
|
|
|
|
aFrame->SaveCopyInUndoList( sheet, UR_CHANGED );
|
|
|
|
m_Pos = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstraintOnEdge( aFrame->GetScreen()->GetCrossHairPosition() );
|
|
|
|
|
|
|
|
sheet->Draw( aFrame->DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
|
|
|
aFrame->DrawPanel->SetMouseCapture( NULL, NULL );
|
|
|
|
aFrame->DrawPanel->EndMouseCapture();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
m_Edge = aEdge;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
switch( m_Edge )
|
|
|
|
{
|
|
|
|
case 0: /* pin on left side*/
|
|
|
|
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*/
|
|
|
|
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*/
|
|
|
|
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*/
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
int SCH_SHEET_PIN::GetEdge()
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
return m_Edge;
|
2010-06-24 18:31:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
void SCH_SHEET_PIN::ConstraintOnEdge( 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
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
if( m_Edge<2 ) /*horizontal sheetpin*/
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
if( Pos.x > ( Sheet->m_Pos.x + ( Sheet->m_Size.x / 2 ) ) )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
if( m_Pos.y < Sheet->m_Pos.y )
|
|
|
|
m_Pos.y = Sheet->m_Pos.y;
|
|
|
|
if( m_Pos.y > (Sheet->m_Pos.y + Sheet->m_Size.y) )
|
|
|
|
m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
|
|
|
|
}
|
|
|
|
else /* vertical sheetpin*/
|
|
|
|
{
|
|
|
|
if( Pos.y > ( Sheet->m_Pos.y + ( Sheet->m_Size.y / 2 ) ) )
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2010-09-05 17:01:48 +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
|
|
|
|
2010-09-05 17:01:48 +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
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
switch( m_Edge )
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
switch( m_Shape )
|
|
|
|
{
|
|
|
|
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-03-22 18:29:26 +00:00
|
|
|
if( fprintf( aFile, "F%d %s %c %c %-3d %-3d %-3d\n", m_Number,
|
|
|
|
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.
|
|
|
|
D( printf( "line: \"%s\"\n", line );)
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
aErrorMsg.Printf( wxT( "EESchema file sheet hierarchical label error at line %d.\n" ),
|
|
|
|
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 )
|
|
|
|
size = DEFAULT_SIZE_TEXT;
|
|
|
|
|
|
|
|
m_Size.x = m_Size.y = size;
|
|
|
|
|
|
|
|
switch( connectType[0] )
|
|
|
|
{
|
|
|
|
case 'I':
|
|
|
|
m_Shape = NET_INPUT;
|
|
|
|
break;
|
|
|
|
case 'O':
|
|
|
|
m_Shape = NET_OUTPUT;
|
|
|
|
break;
|
|
|
|
case 'B':
|
|
|
|
m_Shape = NET_BIDI;
|
|
|
|
break;
|
|
|
|
case 'T':
|
|
|
|
m_Shape = NET_TRISTATE;
|
|
|
|
break;
|
|
|
|
case 'U':
|
|
|
|
m_Shape = NET_UNSPECIFIED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( sheetSide[0] )
|
|
|
|
{
|
|
|
|
case 'R' : /* pin on right side */
|
|
|
|
SetEdge( 1 );
|
|
|
|
break;
|
|
|
|
case 'T' : /* pin on top side */
|
|
|
|
SetEdge( 2 );
|
|
|
|
break;
|
|
|
|
case 'B' : /* pin on bottom side */
|
|
|
|
SetEdge( 3 );
|
|
|
|
break;
|
|
|
|
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,
|
|
|
|
void* aAuxData, wxPoint * aFindLocation )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
2010-10-20 19:43:58 +00:00
|
|
|
if( SCH_ITEM::Matches( m_Text, aSearchData ) )
|
|
|
|
{
|
|
|
|
if( aFindLocation )
|
|
|
|
*aFindLocation = m_Pos;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
void SCH_SHEET_PIN::Mirror_X( int aXaxis_position )
|
|
|
|
{
|
|
|
|
int p = m_Pos.y - aXaxis_position;
|
|
|
|
|
|
|
|
m_Pos.y = aXaxis_position - p;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
switch( m_Edge )
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
SetEdge( 3 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
SetEdge( 2 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SHEET_PIN::Mirror_Y( int aYaxis_position )
|
|
|
|
{
|
|
|
|
int p = m_Pos.x - aYaxis_position;
|
|
|
|
|
|
|
|
m_Pos.x = aYaxis_position - p;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
switch( m_Edge )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetEdge( 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
SetEdge( 0 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SHEET_PIN::Rotate( wxPoint rotationPoint )
|
|
|
|
{
|
|
|
|
RotatePoint( &m_Pos, rotationPoint, 900 );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
switch( m_Edge )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
|
|
|
|
const wxPoint& aPos )
|
|
|
|
{
|
|
|
|
/* 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
|
|
|
|
*/
|
|
|
|
int tmp = m_Shape;
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
switch( m_Shape )
|
|
|
|
{
|
|
|
|
case NET_INPUT:
|
|
|
|
m_Shape = NET_OUTPUT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_OUTPUT:
|
|
|
|
m_Shape = NET_INPUT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
SCH_HIERLABEL::CreateGraphicShape( aCorner_list, aPos );
|
|
|
|
m_Shape = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SHEET_PIN::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
|
|
|
{
|
|
|
|
DANGLING_END_ITEM item( SHEET_LABEL_END, this );
|
|
|
|
item.m_Pos = m_Pos;
|
|
|
|
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;
|
2011-03-30 19:26:05 +00:00
|
|
|
tmp.Printf( _( "Hierarchical Sheet Pin %s" ), GetChars( GetText() ) );
|
2011-03-26 10:08:50 +00:00
|
|
|
return tmp;
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_SHEET_PIN::doHitTest( const wxPoint& aPoint, int aAccuracy ) const
|
|
|
|
{
|
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
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void SCH_SHEET_PIN::Show( int nestLevel, std::ostream& os )
|
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
|