Undo commit -r 6353.
This commit is contained in:
parent
03bf559465
commit
97949ffde9
|
@ -260,7 +260,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
|
|
||||||
GetScreen()->SetFileName( fullFileName );
|
GetScreen()->SetFileName( fullFileName );
|
||||||
g_RootSheet->SetFileName( fullFileName );
|
g_RootSheet->SetFileName( fullFileName );
|
||||||
g_RootSheet->SetName( "root" );
|
|
||||||
SetStatusText( wxEmptyString );
|
SetStatusText( wxEmptyString );
|
||||||
ClearMsgPanel();
|
ClearMsgPanel();
|
||||||
|
|
||||||
|
|
|
@ -98,11 +98,6 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item = LocateAndShowItem( aPosition );
|
item = LocateAndShowItem( aPosition );
|
||||||
|
|
||||||
// Show the sheet information when the user clicks anywhere there are no items
|
|
||||||
// in the schematic.
|
|
||||||
if( item == NULL )
|
|
||||||
SetMsgPanel( GetCurrentSheet().Last() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2011 Kicad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -204,7 +204,7 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
||||||
&m_pos.x, &m_pos.y, &m_size.x, &m_size.y ) != 4 )
|
&m_pos.x, &m_pos.y, &m_size.x, &m_size.y ) != 4 )
|
||||||
|| ( ((char*)aLine)[0] != 'S' ) )
|
|| ( ((char*)aLine)[0] != 'S' ) )
|
||||||
{
|
{
|
||||||
aErrorMsg.Printf( wxT( " ** Eeschema file sheet error at line %d, aborted\n" ),
|
aErrorMsg.Printf( wxT( " ** Eeschema file sheet struct error at line %d, aborted\n" ),
|
||||||
aLine.LineNumber() );
|
aLine.LineNumber() );
|
||||||
|
|
||||||
aErrorMsg << FROM_UTF8( ((char*)aLine) );
|
aErrorMsg << FROM_UTF8( ((char*)aLine) );
|
||||||
|
@ -301,7 +301,7 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
||||||
|
|
||||||
if( strnicmp( "$End", ((char*)aLine), 4 ) != 0 )
|
if( strnicmp( "$End", ((char*)aLine), 4 ) != 0 )
|
||||||
{
|
{
|
||||||
aErrorMsg.Printf( wxT( "**Eeschema file end_sheet error at line %d, aborted\n" ),
|
aErrorMsg.Printf( wxT( "**Eeschema file end_sheet struct error at line %d, aborted\n" ),
|
||||||
aLine.LineNumber() );
|
aLine.LineNumber() );
|
||||||
aErrorMsg << FROM_UTF8( ((char*)aLine) );
|
aErrorMsg << FROM_UTF8( ((char*)aLine) );
|
||||||
return false;
|
return false;
|
||||||
|
@ -474,6 +474,9 @@ int SCH_SHEET::GetMinHeight() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete sheet labels which do not have corresponding hierarchical label.
|
||||||
|
*/
|
||||||
void SCH_SHEET::CleanupSheet()
|
void SCH_SHEET::CleanupSheet()
|
||||||
{
|
{
|
||||||
SCH_SHEET_PINS::iterator i = m_pins.begin();
|
SCH_SHEET_PINS::iterator i = m_pins.begin();
|
||||||
|
@ -718,15 +721,44 @@ bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SCH_SHEET::LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList )
|
||||||
|
{
|
||||||
|
if( m_screen )
|
||||||
|
{
|
||||||
|
aList->Push( this );
|
||||||
|
|
||||||
|
if( m_screen == aScreen )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
EDA_ITEM* strct = m_screen->GetDrawItems();
|
||||||
|
|
||||||
|
while( strct )
|
||||||
|
{
|
||||||
|
if( strct->Type() == SCH_SHEET_T )
|
||||||
|
{
|
||||||
|
SCH_SHEET* ss = (SCH_SHEET*) strct;
|
||||||
|
|
||||||
|
if( ss->LocatePathOfScreen( aScreen, aList ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
strct = strct->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
aList->Pop();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
|
bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
SCH_SCREEN* screen = NULL;
|
SCH_SCREEN* screen = NULL;
|
||||||
|
|
||||||
if( !m_screen )
|
if( !m_screen )
|
||||||
{
|
{
|
||||||
GetRootSheet()->SearchHierarchy( m_fileName, &screen );
|
g_RootSheet->SearchHierarchy( m_fileName, &screen );
|
||||||
|
|
||||||
if( screen )
|
if( screen )
|
||||||
{
|
{
|
||||||
|
@ -750,11 +782,6 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
|
||||||
{
|
{
|
||||||
SCH_SHEET* sheetstruct = (SCH_SHEET*) bs;
|
SCH_SHEET* sheetstruct = (SCH_SHEET*) bs;
|
||||||
|
|
||||||
// Set the parent to this sheet. This effectively creates the
|
|
||||||
// schematic sheet hierarchy eliminating the need to keep a
|
|
||||||
// copy of the root sheet in order to generate the hierarchy.
|
|
||||||
sheetstruct->SetParent( this );
|
|
||||||
|
|
||||||
if( !sheetstruct->Load( aFrame ) )
|
if( !sheetstruct->Load( aFrame ) )
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
@ -786,7 +813,6 @@ int SCH_SHEET::CountSheets()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,10 +827,11 @@ void SCH_SHEET::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
|
||||||
{
|
{
|
||||||
aList.push_back( MSG_PANEL_ITEM( _( "Sheet Name" ), m_name, CYAN ) );
|
aList.push_back( MSG_PANEL_ITEM( _( "Sheet Name" ), m_name, CYAN ) );
|
||||||
aList.push_back( MSG_PANEL_ITEM( _( "File Name" ), m_fileName, BROWN ) );
|
aList.push_back( MSG_PANEL_ITEM( _( "File Name" ), m_fileName, BROWN ) );
|
||||||
aList.push_back( MSG_PANEL_ITEM( _( "Path" ), GetHumanReadablePath(), DARKMAGENTA ) );
|
|
||||||
|
|
||||||
#if 1 // Set to 1 to display the sheet time stamp (mainly for test)
|
#if 0 // Set to 1 to display the sheet time stamp (mainly for test)
|
||||||
aList.push_back( MSG_PANEL_ITEM( _( "Time Stamp" ), GetPath(), BLUE ) );
|
wxString msg;
|
||||||
|
msg.Printf( wxT( "%.8X" ), m_TimeStamp );
|
||||||
|
aList.push_back( MSG_PANEL_ITEM( _( "Time Stamp" ), msg, BLUE ) );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1121,6 +1148,7 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter )
|
||||||
Text = m_name;
|
Text = m_name;
|
||||||
size = wxSize( m_sheetNameSize, m_sheetNameSize );
|
size = wxSize( m_sheetNameSize, m_sheetNameSize );
|
||||||
|
|
||||||
|
//pos = m_pos; pos.y -= 4;
|
||||||
thickness = GetDefaultLineThickness();
|
thickness = GetDefaultLineThickness();
|
||||||
thickness = Clamp_Text_PenSize( thickness, size, false );
|
thickness = Clamp_Text_PenSize( thickness, size, false );
|
||||||
|
|
||||||
|
@ -1153,67 +1181,6 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SCH_SHEET* SCH_SHEET::GetRootSheet()
|
|
||||||
{
|
|
||||||
EDA_ITEM* parent = GetParent();
|
|
||||||
SCH_SHEET* rootSheet = this;
|
|
||||||
|
|
||||||
while( parent )
|
|
||||||
{
|
|
||||||
// The parent of a SCH_SHEET object can only be another SCH_SHEET object or NULL.
|
|
||||||
wxASSERT_MSG( parent->Type() == SCH_SHEET_T, "SCH_SHEET parent is not a SCH_SHEET" );
|
|
||||||
rootSheet = static_cast<SCH_SHEET*>( parent );
|
|
||||||
parent = parent->GetParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
return rootSheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SCH_SHEET::GetPath( SCH_CONST_SHEETS& aSheetPath ) const
|
|
||||||
{
|
|
||||||
aSheetPath.insert( aSheetPath.begin(), const_cast<SCH_SHEET*>( this ) );
|
|
||||||
|
|
||||||
if( GetParent() )
|
|
||||||
static_cast<SCH_SHEET*>( GetParent() )->GetPath( aSheetPath );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxString SCH_SHEET::GetPath() const
|
|
||||||
{
|
|
||||||
wxString tmp;
|
|
||||||
wxString path = "/";
|
|
||||||
const SCH_SHEET* sheet = this;
|
|
||||||
|
|
||||||
while( sheet->GetParent() )
|
|
||||||
{
|
|
||||||
tmp.Printf( "/%8.8lX", (long unsigned) sheet->GetTimeStamp() );
|
|
||||||
|
|
||||||
// We are walking up the parent stack so prepend each time stamp.
|
|
||||||
path = tmp + path;
|
|
||||||
sheet = static_cast<SCH_SHEET*>( sheet->GetParent() );
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxString SCH_SHEET::GetHumanReadablePath() const
|
|
||||||
{
|
|
||||||
wxString path = "/";
|
|
||||||
const SCH_SHEET* sheet = this;
|
|
||||||
|
|
||||||
while( sheet->GetParent() )
|
|
||||||
{
|
|
||||||
// We are walking up the parent stack so prepend each sheet name.
|
|
||||||
path = "/" + sheet->GetName() + path;
|
|
||||||
sheet = static_cast<SCH_SHEET*>( sheet->GetParent() );
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
|
SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "Sheet assignment operator." ) );
|
wxLogDebug( wxT( "Sheet assignment operator." ) );
|
||||||
|
@ -1247,35 +1214,6 @@ SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_SHEET::operator<( const SCH_SHEET& aRhs ) const
|
|
||||||
{
|
|
||||||
// Don't waste time against comparing the same objects..
|
|
||||||
if( this == &aRhs )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
SCH_CONST_SHEETS lhsPath, rhsPath;
|
|
||||||
|
|
||||||
GetPath( lhsPath );
|
|
||||||
aRhs.GetPath( rhsPath );
|
|
||||||
|
|
||||||
// Shorter paths are less than longer paths.
|
|
||||||
if( lhsPath.size() < rhsPath.size() )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if( lhsPath.size() > rhsPath.size() )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Compare time stamps when path lengths are the same.
|
|
||||||
for( unsigned i = 0; i < lhsPath.size(); i++ )
|
|
||||||
{
|
|
||||||
if( lhsPath[i]->GetTimeStamp() < rhsPath[i]->GetTimeStamp() )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
|
|
||||||
void SCH_SHEET::Show( int nestLevel, std::ostream& os ) const
|
void SCH_SHEET::Show( int nestLevel, std::ostream& os ) const
|
||||||
|
|
|
@ -265,7 +265,7 @@ public:
|
||||||
* Return true for items which are moved with the anchor point at mouse cursor
|
* Return true for items which are moved with the anchor point at mouse cursor
|
||||||
* and false for items moved with no reference to anchor
|
* and false for items moved with no reference to anchor
|
||||||
* Usually return true for small items (labels, junctions) and false for
|
* Usually return true for small items (labels, junctions) and false for
|
||||||
* items which can be large (hierarchical sheets, components)
|
* items which can be large (hierarchical sheets, compoments)
|
||||||
* @return false for a hierarchical sheet
|
* @return false for a hierarchical sheet
|
||||||
*/
|
*/
|
||||||
bool IsMovableFromAnchorPoint() { return false; }
|
bool IsMovableFromAnchorPoint() { return false; }
|
||||||
|
@ -457,6 +457,19 @@ public:
|
||||||
*/
|
*/
|
||||||
bool SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen );
|
bool SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function LocatePathOfScreen
|
||||||
|
* search the existing hierarchy for an instance of screen "FileName".
|
||||||
|
* don't bother looking at the root sheet - it must be unique,
|
||||||
|
* no other references to its m_screen otherwise there would be
|
||||||
|
* loops in the hierarchy.
|
||||||
|
*
|
||||||
|
* @param aScreen = the SCH_SCREEN* screen that we search for
|
||||||
|
* @param aList = the SCH_SHEET_PATH* that must be used
|
||||||
|
* @return true if found
|
||||||
|
*/
|
||||||
|
bool LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function CountSheets
|
* Function CountSheets
|
||||||
* calculates the number of sheets found in "this"
|
* calculates the number of sheets found in "this"
|
||||||
|
@ -477,7 +490,7 @@ public:
|
||||||
{
|
{
|
||||||
m_fileName = aFilename;
|
m_fileName = aFilename;
|
||||||
// Filenames are stored using unix notation
|
// Filenames are stored using unix notation
|
||||||
m_fileName.Replace( wxT( "\\" ), wxT( "/" ) );
|
m_fileName.Replace( wxT("\\"), wxT("/") );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChangeFileName( SCH_EDIT_FRAME* aFrame, const wxString& aFileName );
|
bool ChangeFileName( SCH_EDIT_FRAME* aFrame, const wxString& aFileName );
|
||||||
|
@ -553,21 +566,6 @@ public:
|
||||||
|
|
||||||
SCH_ITEM& operator=( const SCH_ITEM& aSheet );
|
SCH_ITEM& operator=( const SCH_ITEM& aSheet );
|
||||||
|
|
||||||
/**
|
|
||||||
* Operator <
|
|
||||||
*
|
|
||||||
* test if a \a aRhs is less than this sheet.
|
|
||||||
*
|
|
||||||
* Sheet comparison order is:
|
|
||||||
* The number of parent sheets of this sheet is less than \a aRhs.
|
|
||||||
* When the number of parent sheets for this sheet are the same as \a aRhs, the time
|
|
||||||
* stamps of each parent sheet are compared from the root sheet to the last sheet.
|
|
||||||
*
|
|
||||||
* @param aRhs is an SCH_SHEET reference to the right hand side of the comparison.
|
|
||||||
* @return true if this #SCH_SHEET is less than \a aRhs.
|
|
||||||
*/
|
|
||||||
bool operator<( const SCH_SHEET& aRhs ) const;
|
|
||||||
|
|
||||||
wxPoint GetPosition() const { return m_pos; }
|
wxPoint GetPosition() const { return m_pos; }
|
||||||
|
|
||||||
void SetPosition( const wxPoint& aPosition );
|
void SetPosition( const wxPoint& aPosition );
|
||||||
|
@ -580,59 +578,6 @@ public:
|
||||||
|
|
||||||
EDA_ITEM* Clone() const;
|
EDA_ITEM* Clone() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetRootSheet
|
|
||||||
*
|
|
||||||
* returns the root sheet of this SCH_SHEET object.
|
|
||||||
*
|
|
||||||
* The root (top level) sheet can be found by walking up the parent links until the only
|
|
||||||
* sheet that has no parent is found. The root sheet can be found from any sheet in the
|
|
||||||
* hierarchy.
|
|
||||||
*
|
|
||||||
* @return a SCH_SHEET pointer to the root sheet.
|
|
||||||
*/
|
|
||||||
SCH_SHEET* GetRootSheet();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function IsRootSheet
|
|
||||||
*
|
|
||||||
* returns true if `this` sheet has no parent which indicates it is the root (top level)
|
|
||||||
* sheet.
|
|
||||||
*
|
|
||||||
* @return true if this is the root sheet, otherwise false.
|
|
||||||
*/
|
|
||||||
bool IsRootSheet() const { return GetParent() == NULL; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetPath
|
|
||||||
*
|
|
||||||
* recurses up the parent branch up to the root sheet adding a pointer for each
|
|
||||||
* parent sheet to \a aSheetPath.
|
|
||||||
*
|
|
||||||
* @param aSheetPath is a refernce to an #SCH_SHEETS object to populate.
|
|
||||||
*/
|
|
||||||
void GetPath( std::vector<const SCH_SHEET*>& aSheetPath ) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetPath
|
|
||||||
*
|
|
||||||
* returns a wxString containing the sheet path of this SCH_SHEET.
|
|
||||||
*
|
|
||||||
* The SCH_SHEET path is a Posix like path containing the hexadecimal time stamps in
|
|
||||||
* the parent order of this SCH_SHEET. It looks something like /4567FEDC/AA2233DD/.
|
|
||||||
*/
|
|
||||||
wxString GetPath() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetHumanReadablePath
|
|
||||||
*
|
|
||||||
* returns a wxString containing the human readable path of this sheet.
|
|
||||||
*
|
|
||||||
* Human readable SCH_SHEET paths are Posix like paths made up of the sheet names
|
|
||||||
* in the parent order of this SCH_SHEET. It looks something like /sheet1/sheet2.
|
|
||||||
*/
|
|
||||||
wxString GetHumanReadablePath() const;
|
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
void Show( int nestLevel, std::ostream& os ) const; // override
|
void Show( int nestLevel, std::ostream& os ) const; // override
|
||||||
#endif
|
#endif
|
||||||
|
@ -651,8 +596,5 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
typedef std::vector< SCH_SHEET* > SCH_SHEETS;
|
typedef std::vector< SCH_SHEET* > SCH_SHEETS;
|
||||||
typedef std::vector< const SCH_SHEET* > SCH_CONST_SHEETS;
|
|
||||||
typedef SCH_SHEETS::iterator SCH_SHEETS_ITER;
|
|
||||||
typedef SCH_SHEETS::const_iterator SCH_SHEETS_CITER;
|
|
||||||
|
|
||||||
#endif /* SCH_SHEEET_H */
|
#endif /* SCH_SHEEET_H */
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -523,8 +523,6 @@ void SCH_EDIT_FRAME::CreateScreens()
|
||||||
if( g_RootSheet == NULL )
|
if( g_RootSheet == NULL )
|
||||||
{
|
{
|
||||||
g_RootSheet = new SCH_SHEET();
|
g_RootSheet = new SCH_SHEET();
|
||||||
g_RootSheet->SetName( "root" );
|
|
||||||
g_RootSheet->SetFileName( "noname.sch" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( g_RootSheet->GetScreen() == NULL )
|
if( g_RootSheet->GetScreen() == NULL )
|
||||||
|
|
Loading…
Reference in New Issue