2008-02-12 21:12:46 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2010-11-11 21:10:27 +00:00
|
|
|
// Name: sch_sheet.cpp
|
2009-11-04 20:46:53 +00:00
|
|
|
// Purpose: member functions for SCH_SHEET
|
2010-11-11 21:10:27 +00:00
|
|
|
// header = sch_sheet.h
|
2008-02-12 21:12:46 +00:00
|
|
|
// Author: jean-pierre Charras
|
2011-01-20 16:34:57 +00:00
|
|
|
// Modified by: Wayne Stambaugh
|
2008-02-12 21:12:46 +00:00
|
|
|
// Created: 08/02/2006 18:37:02
|
|
|
|
// RCS-ID:
|
2008-04-15 19:38:19 +00:00
|
|
|
// Copyright:
|
2009-11-03 13:26:31 +00:00
|
|
|
// License: License GNU
|
2008-02-12 21:12:46 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-01-29 14:26:20 +00:00
|
|
|
#include "gr_basic.h"
|
2008-02-12 21:12:46 +00:00
|
|
|
#include "common.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "macros.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "drawtxt.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"
|
|
|
|
#include "wxEeschemaStruct.h"
|
2011-06-17 13:24:22 +00:00
|
|
|
#include "plot_common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_sheet.h"
|
|
|
|
#include "sch_sheet_path.h"
|
|
|
|
#include "sch_component.h"
|
2011-03-25 20:07:27 +00:00
|
|
|
#include "kicad_string.h"
|
2008-02-12 21:12:46 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
|
|
|
|
SCH_ITEM( NULL, SCH_SHEET_T )
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
m_Layer = LAYER_SHEET;
|
|
|
|
m_Pos = pos;
|
2011-06-07 15:29:01 +00:00
|
|
|
m_Size = wxSize( MIN_SHEET_WIDTH, MIN_SHEET_HEIGHT );
|
2009-11-03 13:26:31 +00:00
|
|
|
m_TimeStamp = GetTimeStamp();
|
2008-02-29 12:33:07 +00:00
|
|
|
m_SheetNameSize = m_FileNameSize = 60;
|
2008-02-26 19:19:54 +00:00
|
|
|
m_AssociatedScreen = NULL;
|
2008-02-29 12:33:07 +00:00
|
|
|
m_SheetName.Printf( wxT( "Sheet%8.8lX" ), m_TimeStamp );
|
|
|
|
m_FileName.Printf( wxT( "file%8.8lX.sch" ), m_TimeStamp );
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) :
|
|
|
|
SCH_ITEM( aSheet )
|
|
|
|
{
|
|
|
|
m_Pos = aSheet.m_Pos;
|
2010-12-23 13:16:06 +00:00
|
|
|
m_Size = aSheet.m_Size;
|
|
|
|
m_Layer = aSheet.m_Layer;
|
2010-12-21 15:13:09 +00:00
|
|
|
m_TimeStamp = aSheet.m_TimeStamp;
|
|
|
|
m_SheetNameSize = aSheet.m_SheetNameSize;
|
|
|
|
m_FileNameSize = aSheet.m_FileNameSize;
|
|
|
|
m_AssociatedScreen = aSheet.m_AssociatedScreen;
|
|
|
|
m_SheetName = aSheet.m_SheetName;
|
|
|
|
m_FileName = aSheet.m_FileName;
|
2011-03-30 19:26:05 +00:00
|
|
|
m_pins = aSheet.m_pins;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
for( size_t i = 0; i < m_pins.size(); i++ )
|
|
|
|
m_pins[i].SetParent( this );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
|
|
|
if( m_AssociatedScreen )
|
2011-01-12 21:47:54 +00:00
|
|
|
m_AssociatedScreen->IncRefCount();
|
2010-12-21 15:13:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET::~SCH_SHEET()
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2011-01-23 21:22:42 +00:00
|
|
|
wxLogDebug( wxT( "Destroying sheet " ) + m_SheetName );
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
// also, look at the associated sheet & its reference count
|
|
|
|
// perhaps it should be deleted also.
|
2008-02-26 19:19:54 +00:00
|
|
|
if( m_AssociatedScreen )
|
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
m_AssociatedScreen->DecRefCount();
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2011-01-12 21:47:54 +00:00
|
|
|
if( m_AssociatedScreen->GetRefCount() == 0 )
|
2008-02-26 19:19:54 +00:00
|
|
|
delete m_AssociatedScreen;
|
|
|
|
}
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
EDA_ITEM* SCH_SHEET::doClone() const
|
|
|
|
{
|
|
|
|
return new SCH_SHEET( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
void SCH_SHEET::SetScreen( SCH_SCREEN* aScreen )
|
|
|
|
{
|
|
|
|
if( aScreen == m_AssociatedScreen )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( m_AssociatedScreen != NULL )
|
|
|
|
{
|
|
|
|
m_AssociatedScreen->DecRefCount();
|
|
|
|
|
|
|
|
if( m_AssociatedScreen->GetRefCount() == 0 )
|
|
|
|
{
|
|
|
|
delete m_AssociatedScreen;
|
|
|
|
m_AssociatedScreen = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_AssociatedScreen = aScreen;
|
|
|
|
|
|
|
|
if( m_AssociatedScreen )
|
|
|
|
m_AssociatedScreen->IncRefCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_SHEET::GetScreenCount() const
|
|
|
|
{
|
|
|
|
if( m_AssociatedScreen == NULL )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return m_AssociatedScreen->GetRefCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
bool SCH_SHEET::Save( FILE* aFile ) const
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
if( fprintf( aFile, "$Sheet\n" ) == EOF
|
|
|
|
|| fprintf( aFile, "S %-4d %-4d %-4d %-4d\n",
|
|
|
|
m_Pos.x, m_Pos.y, m_Size.x, m_Size.y ) == EOF )
|
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
//save the unique timestamp, like other schematic parts.
|
2009-12-02 21:44:03 +00:00
|
|
|
if( fprintf( aFile, "U %8.8lX\n", m_TimeStamp ) == EOF )
|
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Save schematic sheetname and filename. */
|
2008-04-15 19:38:19 +00:00
|
|
|
if( !m_SheetName.IsEmpty() )
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2011-03-25 20:07:27 +00:00
|
|
|
if( fprintf( aFile, "F0 %s %d\n", EscapedUTF8( m_SheetName ).c_str(),
|
2008-12-05 16:03:05 +00:00
|
|
|
m_SheetNameSize ) == EOF )
|
2009-12-02 21:44:03 +00:00
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
if( !m_FileName.IsEmpty() )
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2011-03-25 20:07:27 +00:00
|
|
|
if( fprintf( aFile, "F1 %s %d\n", EscapedUTF8( m_FileName ).c_str(),
|
2008-12-05 16:03:05 +00:00
|
|
|
m_FileNameSize ) == EOF )
|
2009-12-02 21:44:03 +00:00
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
/* Save the list of labels in the sheet. */
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( const SCH_SHEET_PIN& label, m_pins )
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2010-06-24 18:31:43 +00:00
|
|
|
if( !label.Save( aFile ) )
|
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
if( fprintf( aFile, "$EndSheet\n" ) == EOF )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|
|
|
{
|
2011-03-25 20:07:27 +00:00
|
|
|
int fieldNdx, size;
|
2011-03-30 19:26:05 +00:00
|
|
|
SCH_SHEET_PIN* sheetPin;
|
2010-11-10 15:30:12 +00:00
|
|
|
char* ptcar;
|
|
|
|
|
|
|
|
m_TimeStamp = GetTimeStamp();
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
// sheets are added to the GetDrawItems() like other schematic components.
|
2010-11-10 15:30:12 +00:00
|
|
|
// however, in order to preserve the hierarchy (through m_Parent pointers),
|
|
|
|
// a duplicate of the sheet is added to m_SubSheet array.
|
|
|
|
// must be a duplicate, references just work for a two-layer structure.
|
|
|
|
// this is accomplished through the Sync() function.
|
|
|
|
|
|
|
|
if( ((char*)aLine)[0] == '$' ) // line should be "$Sheet"
|
|
|
|
{
|
|
|
|
if( !aLine.ReadLine() )
|
|
|
|
{
|
2011-06-07 15:29:01 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Read File Error" ) );
|
2010-11-10 15:30:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Next line: must be "S xx yy nn mm" with xx, yy = sheet position
|
|
|
|
* ( upper left corner ) et nn,mm = sheet size */
|
|
|
|
if( ( sscanf( &((char*)aLine)[1], "%d %d %d %d",
|
|
|
|
&m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y ) != 4 )
|
|
|
|
|| ( ((char*)aLine)[0] != 'S' ) )
|
|
|
|
{
|
|
|
|
aErrorMsg.Printf( wxT( " ** EESchema file sheet struct error at line %d, aborted\n" ),
|
|
|
|
aLine.LineNumber() );
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
aErrorMsg << FROM_UTF8( ((char*)aLine) );
|
2010-11-10 15:30:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read fields */
|
|
|
|
for( ; ; ) /* Analysis of lines "Fn" text. */
|
|
|
|
{
|
|
|
|
if( !aLine.ReadLine() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( ((char*)aLine)[0] == 'U' )
|
|
|
|
{
|
|
|
|
sscanf( ((char*)aLine) + 1, "%lX", &m_TimeStamp );
|
|
|
|
if( m_TimeStamp == 0 ) // zero is not unique!
|
|
|
|
m_TimeStamp = GetTimeStamp();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ((char*)aLine)[0] != 'F' )
|
|
|
|
break;
|
|
|
|
|
|
|
|
sscanf( ((char*)aLine) + 1, "%d", &fieldNdx );
|
|
|
|
|
|
|
|
/* Read the field:
|
|
|
|
* If fieldNdx> = 2: Fn "text" t s posx posy
|
|
|
|
* If F0 "text" for SheetName
|
|
|
|
* F1 and "text" for filename
|
|
|
|
*/
|
|
|
|
ptcar = ((char*)aLine);
|
|
|
|
while( *ptcar && ( *ptcar != '"' ) )
|
|
|
|
ptcar++;
|
|
|
|
|
|
|
|
if( *ptcar != '"' )
|
|
|
|
{
|
|
|
|
aErrorMsg.Printf( wxT( "EESchema file sheet label F%d at line %d, aborted\n" ),
|
|
|
|
fieldNdx, aLine.LineNumber() );
|
2011-02-28 18:36:19 +00:00
|
|
|
aErrorMsg << FROM_UTF8( (char*) aLine );
|
2010-11-10 15:30:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-03-25 20:07:27 +00:00
|
|
|
wxString sheetName;
|
|
|
|
ptcar += ReadDelimitedText( &sheetName, ptcar );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2011-03-25 20:07:27 +00:00
|
|
|
if( *ptcar == 0 )
|
|
|
|
{
|
|
|
|
aErrorMsg.Printf( wxT( "EESchema file sheet field F at line %d, aborted\n" ),
|
|
|
|
aLine.LineNumber() );
|
|
|
|
aErrorMsg << FROM_UTF8( (char*) aLine );
|
|
|
|
return false;
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( ( fieldNdx == 0 ) || ( fieldNdx == 1 ) )
|
|
|
|
{
|
|
|
|
if( sscanf( ptcar, "%d", &size ) != 1 )
|
|
|
|
{
|
|
|
|
aErrorMsg.Printf( wxT( "EESchema file sheet Label error line %d, aborted\n" ),
|
|
|
|
aLine.LineNumber() );
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
aErrorMsg << FROM_UTF8( (char*) aLine );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
if( size == 0 )
|
|
|
|
size = DEFAULT_SIZE_TEXT;
|
|
|
|
|
|
|
|
if( fieldNdx == 0 )
|
|
|
|
{
|
2011-03-25 20:07:27 +00:00
|
|
|
m_SheetName = sheetName;
|
2010-11-10 15:30:12 +00:00
|
|
|
m_SheetNameSize = size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-25 20:07:27 +00:00
|
|
|
SetFileName( sheetName );
|
2010-11-10 15:30:12 +00:00
|
|
|
m_FileNameSize = size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( fieldNdx > 1 )
|
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
sheetPin = new SCH_SHEET_PIN( this );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
if( !sheetPin->Load( aLine, aErrorMsg ) )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
delete sheetPin;
|
|
|
|
sheetPin = NULL;
|
2010-11-10 15:30:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
AddPin( sheetPin );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strnicmp( "$End", ((char*)aLine), 4 ) != 0 )
|
|
|
|
{
|
|
|
|
aErrorMsg.Printf( wxT( "**EESchema file end_sheet struct error at line %d, aborted\n" ),
|
|
|
|
aLine.LineNumber() );
|
2011-02-28 18:36:19 +00:00
|
|
|
aErrorMsg << FROM_UTF8( ((char*)aLine) );
|
2010-11-10 15:30:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-07 15:29:01 +00:00
|
|
|
void SCH_SHEET::SwapData( SCH_ITEM* aItem )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2011-06-07 15:29:01 +00:00
|
|
|
wxCHECK_RET( aItem->Type() == SCH_SHEET_T,
|
|
|
|
wxString::Format( wxT( "SCH_SHEET object cannot swap data with %s object." ),
|
|
|
|
GetChars( aItem->GetClass() ) ) );
|
|
|
|
|
|
|
|
SCH_SHEET* sheet = ( SCH_SHEET* ) aItem;
|
|
|
|
|
|
|
|
EXCHG( m_Pos, sheet->m_Pos );
|
|
|
|
EXCHG( m_Size, sheet->m_Size );
|
|
|
|
EXCHG( m_SheetName, sheet->m_SheetName );
|
|
|
|
EXCHG( m_SheetNameSize, sheet->m_SheetNameSize );
|
|
|
|
EXCHG( m_FileNameSize, sheet->m_FileNameSize );
|
|
|
|
m_pins.swap( sheet->m_pins );
|
2008-03-30 16:15:53 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
// Ensure sheet labels have their .m_Parent member pointing really on their
|
2009-11-03 13:26:31 +00:00
|
|
|
// parent, after swapping.
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
|
|
|
sheetPin.SetParent( this );
|
|
|
|
}
|
|
|
|
|
2011-06-07 15:29:01 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, sheet->m_pins )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-06-07 15:29:01 +00:00
|
|
|
sheetPin.SetParent( sheet );
|
2010-06-24 18:31:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
void SCH_SHEET::AddPin( SCH_SHEET_PIN* aSheetPin )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
wxASSERT( aSheetPin != NULL );
|
|
|
|
wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
m_pins.push_back( aSheetPin );
|
|
|
|
renumberPins();
|
2010-06-24 18:31:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
void SCH_SHEET::RemovePin( SCH_SHEET_PIN* aSheetPin )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
wxASSERT( aSheetPin != NULL );
|
|
|
|
wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
SCH_SHEET_PINS::iterator i;
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
for( i = m_pins.begin(); i < m_pins.end(); ++i )
|
2008-03-30 16:15:53 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
if( *i == aSheetPin )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
m_pins.erase( i );
|
|
|
|
renumberPins();
|
2010-06-24 18:31:43 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-03-30 16:15:53 +00:00
|
|
|
}
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
wxLogDebug( wxT( "Fix me: attempt to remove label %s which is not in sheet %s." ),
|
2011-03-30 19:26:05 +00:00
|
|
|
GetChars( aSheetPin->m_Text ), GetChars( m_SheetName ) );
|
2010-06-24 18:31:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
bool SCH_SHEET::HasPin( const wxString& aName )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN pin, m_pins )
|
2008-03-30 16:15:53 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
if( pin.m_Text.CmpNoCase( aName ) == 0 )
|
2010-06-24 18:31:43 +00:00
|
|
|
return true;
|
2008-03-30 16:15:53 +00:00
|
|
|
}
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
bool SCH_SHEET::IsVerticalOrientation() const
|
2010-09-09 17:37:25 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN pin, m_pins )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
if( pin.GetEdge() > 1 )
|
2010-09-09 17:37:25 +00:00
|
|
|
return true;
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
2010-09-09 17:37:25 +00:00
|
|
|
return false;
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
bool SCH_SHEET::HasUndefinedPins()
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN pin, m_pins )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
|
|
|
/* Search the schematic for a hierarchical label corresponding to this sheet label. */
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* DrawStruct = m_AssociatedScreen->GetDrawItems();
|
|
|
|
SCH_HIERLABEL* HLabel = NULL;
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
|
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T )
|
2010-06-24 18:31:43 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
HLabel = (SCH_HIERLABEL*) DrawStruct;
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
if( pin.m_Text.CmpNoCase( HLabel->m_Text ) == 0 )
|
2010-06-24 18:31:43 +00:00
|
|
|
break; // Found!
|
|
|
|
|
|
|
|
HLabel = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( HLabel == NULL ) // Corresponding hierarchical label not found.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2011-06-07 15:29:01 +00:00
|
|
|
int SCH_SHEET::GetMinWidth() const
|
|
|
|
{
|
|
|
|
int width = MIN_SHEET_WIDTH;
|
|
|
|
|
|
|
|
for( size_t i = 0; i < m_pins.size(); i++ )
|
|
|
|
{
|
|
|
|
int edge = m_pins[i].GetEdge();
|
|
|
|
|
|
|
|
// Make sure pin is on right or left side of sheet.
|
|
|
|
if( edge >= 2 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
EDA_RECT rect = m_pins[i].GetBoundingBox();
|
|
|
|
|
|
|
|
if( width < rect.GetWidth() )
|
|
|
|
width = rect.GetWidth();
|
|
|
|
|
|
|
|
for( size_t j = 0; j < m_pins.size(); j++ )
|
|
|
|
{
|
|
|
|
if( (i == j) || (m_pins[i].m_Pos.y != m_pins[j].m_Pos.y) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( width < rect.GetWidth() + m_pins[j].GetBoundingBox().GetWidth() )
|
|
|
|
{
|
|
|
|
width = rect.GetWidth() + m_pins[j].GetBoundingBox().GetWidth();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_SHEET::GetMinHeight() const
|
|
|
|
{
|
|
|
|
int height = MIN_SHEET_HEIGHT;
|
|
|
|
|
|
|
|
for( size_t i = 0; i < m_pins.size(); i++ )
|
|
|
|
{
|
|
|
|
int pinY = m_pins[i].m_Pos.y - m_Pos.y;
|
|
|
|
|
|
|
|
if( pinY > height )
|
|
|
|
height = pinY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_SHEET::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Place list structures for new sheet. */
|
2011-01-20 16:34:57 +00:00
|
|
|
if( IsNew() )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2011-01-26 08:09:52 +00:00
|
|
|
// fix size and position of the new sheet
|
2011-02-11 20:48:13 +00:00
|
|
|
// using the last values set by the m_mouseCaptureCallback function
|
|
|
|
frame->DrawPanel->SetMouseCapture( NULL, NULL );
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
if( !frame->EditSheet( this, DC ) )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
|
|
|
frame->GetScreen()->SetCurItem( NULL );
|
2011-01-07 19:24:24 +00:00
|
|
|
Draw( frame->DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
2008-02-26 19:19:54 +00:00
|
|
|
delete this;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2010-03-24 18:26:04 +00:00
|
|
|
else /* save old text in undo list */
|
|
|
|
{
|
2011-04-05 14:46:51 +00:00
|
|
|
frame->SaveUndoItemInUndoList( this );
|
2010-03-24 18:26:04 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_ITEM::Place( frame, DC ); //puts it on the GetDrawItems().
|
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
if( IsNew() )
|
2009-01-06 20:09:32 +00:00
|
|
|
{
|
|
|
|
frame->SetSheetNumberAndCount();
|
|
|
|
}
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
/**
|
|
|
|
* Delete sheet labels which do not have corresponding hierarchical label.
|
2008-02-12 21:12:46 +00:00
|
|
|
*/
|
2010-06-24 18:31:43 +00:00
|
|
|
void SCH_SHEET::CleanupSheet()
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
SCH_SHEET_PINS::iterator i = m_pins.begin();
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
while( i != m_pins.end() )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2010-06-24 18:31:43 +00:00
|
|
|
/* Search the schematic for a hierarchical label corresponding to this sheet label. */
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* DrawStruct = m_AssociatedScreen->GetDrawItems();
|
|
|
|
SCH_HIERLABEL* HLabel = NULL;
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T )
|
2008-02-26 19:19:54 +00:00
|
|
|
continue;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
HLabel = (SCH_HIERLABEL*) DrawStruct;
|
2010-06-24 18:31:43 +00:00
|
|
|
|
|
|
|
if( i->m_Text.CmpNoCase( HLabel->m_Text ) == 0 )
|
2009-11-03 13:26:31 +00:00
|
|
|
break; // Found!
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
HLabel = NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
if( HLabel == NULL ) // Hlabel not found: delete sheet label.
|
2011-03-30 19:26:05 +00:00
|
|
|
m_pins.erase( i );
|
2010-06-24 18:31:43 +00:00
|
|
|
else
|
|
|
|
++i;
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
2010-06-24 18:31:43 +00:00
|
|
|
}
|
|
|
|
|
2008-04-30 17:04:22 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
SCH_SHEET_PIN* SCH_SHEET::GetPin( const wxPoint& aPosition )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN& pin, m_pins )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
if( pin.HitTest( aPosition ) )
|
|
|
|
return &pin;
|
2010-06-24 18:31:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
int SCH_SHEET::GetPenSize() const
|
2009-06-30 19:21:41 +00:00
|
|
|
{
|
|
|
|
return g_DrawDefaultLineThickness;
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
wxPoint SCH_SHEET::GetSheetNamePosition()
|
|
|
|
{
|
|
|
|
wxPoint pos = m_Pos;
|
|
|
|
if( IsVerticalOrientation() )
|
|
|
|
{
|
|
|
|
pos.x -= 8;
|
|
|
|
pos.y += m_Size.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pos.y -= 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
wxPoint SCH_SHEET::GetFileNamePosition()
|
|
|
|
{
|
|
|
|
wxPoint pos = m_Pos;
|
2011-05-25 10:42:56 +00:00
|
|
|
int margin = GetPenSize() + 4;
|
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
if( IsVerticalOrientation() )
|
|
|
|
{
|
2011-05-25 10:42:56 +00:00
|
|
|
pos.x += m_Size.x + margin;
|
2010-10-20 19:43:58 +00:00
|
|
|
pos.y += m_Size.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-25 10:42:56 +00:00
|
|
|
pos.y += m_Size.y + margin;
|
2010-10-20 19:43:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
2009-12-02 21:44:03 +00:00
|
|
|
const wxPoint& aOffset, int aDrawMode, int aColor )
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
int txtcolor;
|
|
|
|
wxString Text;
|
|
|
|
int color;
|
2010-09-05 17:01:48 +00:00
|
|
|
int name_orientation;
|
|
|
|
wxPoint pos_sheetname,pos_filename;
|
2009-01-04 18:52:57 +00:00
|
|
|
wxPoint pos = m_Pos + aOffset;
|
2011-04-29 12:42:04 +00:00
|
|
|
int lineWidth = GetPenSize();
|
2008-02-12 21:12:46 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
if( aColor >= 0 )
|
|
|
|
color = aColor;
|
2008-02-12 21:12:46 +00:00
|
|
|
else
|
|
|
|
color = ReturnLayerColor( m_Layer );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
GRSetDrawMode( aDC, aDrawMode );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
GRRect( &aPanel->m_ClipBox, aDC, pos.x, pos.y,
|
2011-04-29 12:42:04 +00:00
|
|
|
pos.x + m_Size.x, pos.y + m_Size.y, lineWidth, color );
|
2010-10-20 19:43:58 +00:00
|
|
|
|
|
|
|
pos_sheetname = GetSheetNamePosition() + aOffset;
|
|
|
|
pos_filename = GetFileNamePosition() + aOffset;
|
|
|
|
|
2010-09-09 17:37:25 +00:00
|
|
|
if( IsVerticalOrientation() )
|
|
|
|
name_orientation = TEXT_ORIENT_VERT;
|
2010-09-05 17:01:48 +00:00
|
|
|
else
|
2010-09-09 17:37:25 +00:00
|
|
|
name_orientation = TEXT_ORIENT_HORIZ;
|
2010-10-20 19:43:58 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/* Draw text : SheetName */
|
2009-01-04 18:52:57 +00:00
|
|
|
if( aColor > 0 )
|
|
|
|
txtcolor = aColor;
|
2008-02-12 21:12:46 +00:00
|
|
|
else
|
|
|
|
txtcolor = ReturnLayerColor( LAYER_SHEETNAME );
|
|
|
|
|
|
|
|
Text = wxT( "Sheet: " ) + m_SheetName;
|
2010-09-05 17:01:48 +00:00
|
|
|
DrawGraphicText( aPanel, aDC, pos_sheetname,
|
|
|
|
(EDA_Colors) txtcolor, Text, name_orientation,
|
2009-11-03 13:26:31 +00:00
|
|
|
wxSize( m_SheetNameSize, m_SheetNameSize ),
|
2011-04-29 12:42:04 +00:00
|
|
|
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, lineWidth,
|
2010-11-20 19:53:00 +00:00
|
|
|
false, false );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
|
|
|
/* Draw text : FileName */
|
2009-01-04 18:52:57 +00:00
|
|
|
if( aColor >= 0 )
|
|
|
|
txtcolor = aColor;
|
2008-02-12 21:12:46 +00:00
|
|
|
else
|
|
|
|
txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
Text = wxT( "File: " ) + m_FileName;
|
2010-09-05 17:01:48 +00:00
|
|
|
DrawGraphicText( aPanel, aDC, pos_filename,
|
|
|
|
(EDA_Colors) txtcolor, Text, name_orientation,
|
2009-11-03 13:26:31 +00:00
|
|
|
wxSize( m_FileNameSize, m_FileNameSize ),
|
2011-04-29 12:42:04 +00:00
|
|
|
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, lineWidth,
|
2010-11-20 19:53:00 +00:00
|
|
|
false, false );
|
2008-02-12 21:12:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Draw text : SheetLabel */
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins )
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2010-06-24 18:31:43 +00:00
|
|
|
if( !( sheetPin.m_Flags & IS_MOVED ) )
|
|
|
|
sheetPin.Draw( aPanel, aDC, aOffset, aDrawMode, aColor );
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT SCH_SHEET::GetBoundingBox() const
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2011-04-29 12:42:04 +00:00
|
|
|
wxPoint end;
|
|
|
|
EDA_RECT box( m_Pos, m_Size );
|
|
|
|
int lineWidth = GetPenSize();
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2008-03-30 10:14:37 +00:00
|
|
|
// Determine length of texts
|
2011-04-29 12:42:04 +00:00
|
|
|
wxString text = wxT( "Sheet: " ) + m_SheetName;
|
|
|
|
int textlen = ReturnGraphicTextWidth( text, m_SheetNameSize, false, lineWidth );
|
|
|
|
text = wxT( "File: " ) + m_FileName;
|
|
|
|
int textlen2 = ReturnGraphicTextWidth( text, m_FileNameSize, false, lineWidth );
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2011-04-29 12:42:04 +00:00
|
|
|
// Calculate bounding box X size:
|
|
|
|
textlen = MAX( textlen, textlen2 );
|
|
|
|
end.x = MAX( m_Size.x, textlen );
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2011-04-29 12:42:04 +00:00
|
|
|
// Calculate bounding box pos:
|
|
|
|
end.y = m_Size.y;
|
|
|
|
end += m_Pos;
|
|
|
|
|
|
|
|
// Move upper and lower limits to include texts:
|
|
|
|
box.m_Pos.y -= wxRound( m_SheetNameSize * 1.3 ) + 8;
|
|
|
|
end.y += wxRound( m_FileNameSize * 1.3 ) + 8;
|
|
|
|
|
|
|
|
box.SetEnd( end );
|
|
|
|
box.Inflate( lineWidth / 2 );
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2008-03-30 10:14:37 +00:00
|
|
|
return box;
|
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
int SCH_SHEET::ComponentCount()
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
if( m_AssociatedScreen )
|
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* bs;
|
|
|
|
|
|
|
|
for( bs = m_AssociatedScreen->GetDrawItems(); bs != NULL; bs = bs->Next() )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( bs->Type() == SCH_COMPONENT_T )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_COMPONENT* Cmp = (SCH_COMPONENT*) bs;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
if( Cmp->GetField( VALUE )->m_Text.GetChar( 0 ) != '#' )
|
2008-02-26 19:19:54 +00:00
|
|
|
n++;
|
|
|
|
}
|
2010-12-10 19:47:44 +00:00
|
|
|
|
|
|
|
if( bs->Type() == SCH_SHEET_T )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) bs;
|
2008-02-26 19:19:54 +00:00
|
|
|
n += sheet->ComponentCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-02 21:44:03 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
return n;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
if( m_AssociatedScreen )
|
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
EDA_ITEM* item = m_AssociatedScreen->GetDrawItems();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
while( item )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
if( item->Type() == SCH_SHEET_T )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
|
|
|
|
|
|
|
if( sheet->m_AssociatedScreen
|
|
|
|
&& sheet->m_AssociatedScreen->GetFileName().CmpNoCase( aFilename ) == 0 )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
*aScreen = sheet->m_AssociatedScreen;
|
2008-02-26 19:19:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-12-02 21:44:03 +00:00
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
if( sheet->SearchHierarchy( aFilename, aScreen ) )
|
2008-02-26 19:19:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-20 16:34:57 +00:00
|
|
|
|
|
|
|
item = item->Next();
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-02 21:44:03 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
return false;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
bool SCH_SHEET::LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList )
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
if( m_AssociatedScreen )
|
|
|
|
{
|
2009-01-04 18:52:57 +00:00
|
|
|
aList->Push( this );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
if( m_AssociatedScreen == aScreen )
|
2008-02-26 19:19:54 +00:00
|
|
|
return true;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
|
|
|
EDA_ITEM* strct = m_AssociatedScreen->GetDrawItems();
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
while( strct )
|
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( strct->Type() == SCH_SHEET_T )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET* ss = (SCH_SHEET*) strct;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
if( ss->LocatePathOfScreen( aScreen, aList ) )
|
2008-02-26 19:19:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
strct = strct->Next();
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
aList->Pop();
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
return false;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2008-02-29 12:33:07 +00:00
|
|
|
bool success = true;
|
2008-02-28 19:27:25 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
if( !m_AssociatedScreen )
|
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = NULL;
|
|
|
|
g_RootSheet->SearchHierarchy( m_FileName, &screen );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
if( screen )
|
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
SetScreen( screen );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
//do not need to load the sub-sheets - this has already been done.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
SetScreen( new SCH_SCREEN() );
|
2009-01-04 18:52:57 +00:00
|
|
|
success = aFrame->LoadOneEEFile( m_AssociatedScreen, m_FileName );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2008-02-29 12:33:07 +00:00
|
|
|
if( success )
|
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* bs = m_AssociatedScreen->GetDrawItems();
|
|
|
|
|
2008-02-29 12:33:07 +00:00
|
|
|
while( bs )
|
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( bs->Type() == SCH_SHEET_T )
|
2008-02-29 12:33:07 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET* sheetstruct = (SCH_SHEET*) bs;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
if( !sheetstruct->Load( aFrame ) )
|
2008-02-29 12:33:07 +00:00
|
|
|
success = false;
|
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
bs = bs->Next();
|
2008-02-29 12:33:07 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-02 21:44:03 +00:00
|
|
|
|
2008-02-28 19:27:25 +00:00
|
|
|
return success;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
int SCH_SHEET::CountSheets()
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
int count = 1; //1 = this!!
|
|
|
|
|
|
|
|
if( m_AssociatedScreen )
|
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* strct = m_AssociatedScreen->GetDrawItems();
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; strct; strct = strct->Next() )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( strct->Type() == SCH_SHEET_T )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET* subsheet = (SCH_SHEET*) strct;
|
2009-01-06 20:09:32 +00:00
|
|
|
count += subsheet->CountSheets();
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return count;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
wxString SCH_SHEET::GetFileName( void ) const
|
2008-02-28 19:27:25 +00:00
|
|
|
{
|
2008-02-29 12:33:07 +00:00
|
|
|
return m_FileName;
|
2008-02-28 19:27:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void SCH_SHEET::DisplayInfo( EDA_DRAW_FRAME* frame )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2009-10-14 19:43:31 +00:00
|
|
|
frame->ClearMsgPanel();
|
|
|
|
frame->AppendMsgPanel( _( "Sheet name" ), m_SheetName, CYAN );
|
|
|
|
frame->AppendMsgPanel( _( "File name" ), m_FileName, BROWN );
|
2011-01-01 17:28:21 +00:00
|
|
|
#if 0 // Set to 1 to display the sheet time stamp (mainly for test)
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf(wxT("%.8X"), m_TimeStamp );
|
|
|
|
frame->AppendMsgPanel( _( "Time Stamp" ), msg, BLUE );
|
|
|
|
#endif
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
void SCH_SHEET::Rotate(wxPoint rotationPoint)
|
|
|
|
{
|
2010-09-09 17:37:25 +00:00
|
|
|
RotatePoint( &m_Pos, rotationPoint, 900 );
|
|
|
|
RotatePoint( &m_Size.x, &m_Size.y, 900 );
|
|
|
|
|
|
|
|
if( m_Size.x < 0 )
|
|
|
|
{
|
|
|
|
m_Pos.x += m_Size.x;
|
|
|
|
NEGATE( m_Size.x );
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
2010-09-09 17:37:25 +00:00
|
|
|
|
|
|
|
if( m_Size.y < 0 )
|
|
|
|
{
|
|
|
|
m_Pos.y += m_Size.y;
|
|
|
|
NEGATE( m_Size.y );
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
2010-09-09 17:37:25 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
sheetPin.Rotate( rotationPoint );
|
|
|
|
}
|
|
|
|
}
|
2010-09-09 17:37:25 +00:00
|
|
|
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
void SCH_SHEET::Mirror_X( int aXaxis_position )
|
|
|
|
{
|
|
|
|
m_Pos.y -= aXaxis_position;
|
|
|
|
NEGATE( m_Pos.y );
|
|
|
|
m_Pos.y += aXaxis_position;
|
|
|
|
m_Pos.y -= m_Size.y;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
sheetPin.Mirror_X( aXaxis_position );
|
|
|
|
}
|
|
|
|
}
|
2010-09-09 17:37:25 +00:00
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void SCH_SHEET::Mirror_Y( int aYaxis_position )
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
|
|
|
m_Pos.x -= aYaxis_position;
|
|
|
|
NEGATE( m_Pos.x );
|
|
|
|
m_Pos.x += aYaxis_position;
|
|
|
|
m_Pos.x -= m_Size.x;
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN& label, m_pins )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
|
|
|
label.Mirror_Y( aYaxis_position );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SHEET::Resize( const wxSize& aSize )
|
|
|
|
{
|
|
|
|
if( aSize == m_Size )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_Size = aSize;
|
|
|
|
|
|
|
|
/* Move the sheet labels according to the new sheet size. */
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN& label, m_pins )
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
2010-09-09 17:37:25 +00:00
|
|
|
label.ConstraintOnEdge( label.m_Pos );
|
2009-07-27 14:32:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
bool SCH_SHEET::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_FileName, aSearchData ) )
|
|
|
|
{
|
|
|
|
if( aFindLocation )
|
|
|
|
*aFindLocation = GetFileNamePosition();
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
if( SCH_ITEM::Matches( m_SheetName, aSearchData ) )
|
|
|
|
{
|
|
|
|
if( aFindLocation )
|
|
|
|
*aFindLocation = GetSheetNamePosition();
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2010-03-16 18:22:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
void SCH_SHEET::renumberPins()
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
int id = 2;
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN& pin, m_pins )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
pin.SetNumber( id );
|
|
|
|
id++;
|
2010-06-24 18:31:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
void SCH_SHEET::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
|
|
|
{
|
|
|
|
// Using BOOST_FOREACH here creates problems (bad pointer value to pinsheet).
|
|
|
|
// I do not know why.
|
2011-03-30 19:26:05 +00:00
|
|
|
for( unsigned ii = 0; ii < GetPins().size(); ii++ )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
SCH_SHEET_PIN &pinsheet = GetPins()[ii];
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
wxCHECK2_MSG( pinsheet.Type() == SCH_SHEET_PIN_T, continue,
|
2010-11-03 14:13:15 +00:00
|
|
|
wxT( "Invalid item in schematic sheet pin list. Bad programmer!" ) );
|
|
|
|
|
|
|
|
pinsheet.GetEndPoints( aItemList );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_SHEET::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList )
|
|
|
|
{
|
|
|
|
bool currentState = IsDangling();
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN& pinsheet, GetPins() )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
|
|
|
pinsheet.IsDanglingStateChanged( aItemList );
|
|
|
|
}
|
|
|
|
|
|
|
|
return currentState != IsDangling();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_SHEET::IsDangling() const
|
|
|
|
{
|
|
|
|
// If any hierarchical label in the sheet is dangling, then the sheet is dangling.
|
2011-03-30 19:26:05 +00:00
|
|
|
for( size_t i = 0; i < GetPins().size(); i++ )
|
2010-11-03 14:13:15 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
if( GetPins()[i].IsDangling() )
|
2010-11-03 14:13:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_SHEET::IsSelectStateChanged( const wxRect& aRect )
|
|
|
|
{
|
|
|
|
bool previousState = IsSelected();
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT boundingBox = GetBoundingBox();
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
if( aRect.Intersects( boundingBox ) )
|
|
|
|
m_Flags |= SELECTED;
|
|
|
|
else
|
|
|
|
m_Flags &= ~SELECTED;
|
|
|
|
|
|
|
|
return previousState != IsSelected();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_SHEET::GetConnectionPoints( vector< wxPoint >& aPoints ) const
|
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
for( size_t i = 0; i < GetPins().size(); i++ )
|
|
|
|
aPoints.push_back( GetPins()[i].m_Pos );
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR* aInspector, const void* aTestData,
|
|
|
|
const KICAD_T aFilterTypes[] )
|
2010-12-10 19:47:44 +00:00
|
|
|
{
|
2011-03-25 19:16:05 +00:00
|
|
|
KICAD_T stype;
|
|
|
|
|
|
|
|
for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p )
|
|
|
|
{
|
|
|
|
// If caller wants to inspect my type
|
|
|
|
if( stype == Type() )
|
|
|
|
{
|
|
|
|
if( SEARCH_QUIT == aInspector->Inspect( this, aTestData ) )
|
|
|
|
return SEARCH_QUIT;
|
|
|
|
}
|
2011-03-30 19:26:05 +00:00
|
|
|
else if( stype == SCH_SHEET_PIN_T )
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
|
|
|
// Test the bounding boxes of sheet labels.
|
2011-03-30 19:26:05 +00:00
|
|
|
for( size_t i = 0; i < m_pins.size(); i++ )
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
2011-03-30 19:26:05 +00:00
|
|
|
if( SEARCH_QUIT == aInspector->Inspect( &m_pins[ i ], aTestData ) )
|
2011-03-25 19:16:05 +00:00
|
|
|
return SEARCH_QUIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SEARCH_CONTINUE;
|
|
|
|
}
|
2010-12-13 15:59:00 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
|
|
|
|
wxString SCH_SHEET::GetSelectMenuText() const
|
|
|
|
{
|
2011-03-26 10:08:50 +00:00
|
|
|
wxString tmp;
|
|
|
|
tmp.Printf( _( "Hierarchical Sheet " ), GetChars( m_SheetName ) );
|
|
|
|
return tmp;
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_SHEET::doHitTest( const wxPoint& aPoint, int aAccuracy ) const
|
|
|
|
{
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT rect = GetBoundingBox();
|
2010-12-10 19:47:44 +00:00
|
|
|
|
|
|
|
rect.Inflate( aAccuracy );
|
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
return rect.Contains( aPoint );
|
2010-12-10 19:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
bool SCH_SHEET::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
2010-12-10 19:47:44 +00:00
|
|
|
{
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT rect = aRect;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
|
|
|
rect.Inflate( aAccuracy );
|
|
|
|
|
|
|
|
if( aContained )
|
2010-12-20 17:44:25 +00:00
|
|
|
return rect.Contains( GetBoundingBox() );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
|
|
|
return rect.Intersects( GetBoundingBox() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-07 15:29:01 +00:00
|
|
|
wxPoint SCH_SHEET::GetResizePosition() const
|
|
|
|
{
|
|
|
|
return wxPoint( m_Pos.x + m_Size.GetWidth(), m_Pos.y + m_Size.GetHeight() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 13:24:22 +00:00
|
|
|
void SCH_SHEET::doPlot( PLOTTER* aPlotter )
|
|
|
|
{
|
|
|
|
EDA_Colors txtcolor = UNSPECIFIED_COLOR;
|
|
|
|
wxSize size;
|
|
|
|
wxString Text;
|
|
|
|
int name_orientation;
|
|
|
|
wxPoint pos_sheetname, pos_filename;
|
|
|
|
wxPoint pos;
|
|
|
|
|
|
|
|
aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
|
|
|
|
|
|
|
|
int thickness = GetPenSize();
|
|
|
|
aPlotter->set_current_line_width( thickness );
|
|
|
|
|
|
|
|
aPlotter->move_to( m_Pos );
|
|
|
|
pos = m_Pos;
|
|
|
|
pos.x += m_Size.x;
|
|
|
|
|
|
|
|
aPlotter->line_to( pos );
|
|
|
|
pos.y += m_Size.y;
|
|
|
|
|
|
|
|
aPlotter->line_to( pos );
|
|
|
|
pos = m_Pos;
|
|
|
|
pos.y += m_Size.y;
|
|
|
|
|
|
|
|
aPlotter->line_to( pos );
|
|
|
|
aPlotter->finish_to( m_Pos );
|
|
|
|
|
|
|
|
if( IsVerticalOrientation() )
|
|
|
|
{
|
|
|
|
pos_sheetname = wxPoint( m_Pos.x - 8, m_Pos.y + m_Size.y );
|
|
|
|
pos_filename = wxPoint( m_Pos.x + m_Size.x + 4, m_Pos.y + m_Size.y );
|
|
|
|
name_orientation = TEXT_ORIENT_VERT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pos_sheetname = wxPoint( m_Pos.x, m_Pos.y - 4 );
|
|
|
|
pos_filename = wxPoint( m_Pos.x, m_Pos.y + m_Size.y + 4 );
|
|
|
|
name_orientation = TEXT_ORIENT_HORIZ;
|
|
|
|
}
|
|
|
|
/* Draw texts: SheetName */
|
|
|
|
Text = m_SheetName;
|
|
|
|
size = wxSize( m_SheetNameSize, m_SheetNameSize );
|
|
|
|
|
|
|
|
//pos = m_Pos; pos.y -= 4;
|
|
|
|
thickness = g_DrawDefaultLineThickness;
|
|
|
|
thickness = Clamp_Text_PenSize( thickness, size, false );
|
|
|
|
|
|
|
|
aPlotter->set_color( ReturnLayerColor( LAYER_SHEETNAME ) );
|
|
|
|
|
|
|
|
bool italic = false;
|
|
|
|
aPlotter->text( pos_sheetname, txtcolor, Text, name_orientation, size,
|
|
|
|
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM,
|
|
|
|
thickness, italic, false );
|
|
|
|
|
|
|
|
/*Draw texts : FileName */
|
|
|
|
Text = GetFileName();
|
|
|
|
size = wxSize( m_FileNameSize, m_FileNameSize );
|
|
|
|
thickness = g_DrawDefaultLineThickness;
|
|
|
|
thickness = Clamp_Text_PenSize( thickness, size, false );
|
|
|
|
|
|
|
|
aPlotter->set_color( ReturnLayerColor( LAYER_SHEETFILENAME ) );
|
|
|
|
|
|
|
|
aPlotter->text( pos_filename, txtcolor, Text, name_orientation, size,
|
|
|
|
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP,
|
|
|
|
thickness, italic, false );
|
|
|
|
|
|
|
|
aPlotter->set_color( ReturnLayerColor( GetLayer() ) );
|
|
|
|
|
|
|
|
/* Draw texts : SheetLabel */
|
|
|
|
for( size_t i = 0; i < m_pins.size(); i++ )
|
|
|
|
{
|
|
|
|
m_pins[i].Plot( aPlotter );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-22 16:38:23 +00:00
|
|
|
#if defined(DEBUG)
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void SCH_SHEET::Show( int nestLevel, std::ostream& os )
|
2008-04-22 16:38:23 +00:00
|
|
|
{
|
|
|
|
// XML output:
|
|
|
|
wxString s = GetClass();
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" << " sheet_name=\""
|
2011-02-28 18:36:19 +00:00
|
|
|
<< TO_UTF8( m_SheetName ) << '"' << ">\n";
|
2008-04-22 16:38:23 +00:00
|
|
|
|
|
|
|
// show all the pins, and check the linked list integrity
|
2011-03-30 19:26:05 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN& label, m_pins )
|
2008-04-22 16:38:23 +00:00
|
|
|
{
|
2010-06-24 18:31:43 +00:00
|
|
|
label.Show( nestLevel + 1, os );
|
2008-04-22 16:38:23 +00:00
|
|
|
}
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n" << std::flush;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
#endif
|