KiCad PCB EDA Suite
sch_sheet_path.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2011-2016 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 #ifndef CLASS_DRAWSHEET_PATH_H
32 #define CLASS_DRAWSHEET_PATH_H
33 
34 #include <base_struct.h>
35 
36 #include <map>
37 
38 
81 #include "sch_sheet.h" // SCH_SHEETS
82 
83 class wxFindReplaceData;
84 class SCH_SCREEN;
85 class SCH_MARKER;
86 class SCH_ITEM;
87 class SCH_REFERENCE_LIST;
88 class PART_LIBS;
89 
90 #define SHEET_NOT_FOUND -1
91 
92 
97 typedef std::map<wxString, SCH_REFERENCE_LIST> SCH_MULTI_UNIT_REFERENCE_MAP;
98 
113 {
114 #define MAX_SHEET_DEPTH 32
115 
117 
118 public:
119  SCH_SHEET_PATH();
120 
121  void SetPageNumber( int aPageNumber ) { m_pageNumber = aPageNumber; }
122 
123  int GetPageNumber() const { return m_pageNumber; }
124 
125  const SCH_SHEET* GetSheet( unsigned aIndex ) const
126  {
127  SCH_SHEET* retv = NULL;
128 
129  if( aIndex < size() )
130  retv = at( aIndex );
131 
132  return const_cast< SCH_SHEET* >( retv );
133  }
134 
135  SCH_SHEET* GetSheet( unsigned aIndex )
136  {
137  return const_cast< SCH_SHEET* >( static_cast< const SCH_SHEET_PATH& >( *this ).GetSheet( aIndex ) );
138  }
139 
148  int Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const;
149 
155  SCH_SHEET* Last() const;
156 
161  SCH_SCREEN* LastScreen() const;
162 
168  SCH_ITEM* LastDrawList() const;
169 
176  SCH_ITEM* FirstDrawList() const;
177 
184  wxString Path() const;
185 
193  wxString PathHumanReadable() const;
194 
205 
215  void AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference );
216 
224  void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
225  bool aIncludePowerSymbols = true );
226 
237  bool aIncludePowerSymbols = true );
238 
249  bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
250  bool aSetVisible );
251 
262  SCH_ITEM* FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ) const;
263 
274  SCH_ITEM* FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ) const;
275 
287  bool TestForRecursion( const wxString& aSrcFileName, const wxString& aDestFileName ) const;
288 
289  int FindSheet( const wxString& aFileName ) const;
290 
299  SCH_SHEET* FindSheetByName( const wxString& aSheetName );
300 
309  SCH_SHEET* FindSheetByPageNumber( int aPageNumber );
310 
311  bool operator==( const SCH_SHEET_PATH& d1 ) const;
312 
313  bool operator!=( const SCH_SHEET_PATH& d1 ) const { return !( *this == d1 ) ; }
314 };
315 
316 
317 typedef std::vector< SCH_SHEET_PATH > SCH_SHEET_PATHS;
318 typedef SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER;
319 typedef SCH_SHEET_PATHS::const_iterator SCH_SHEET_PATHS_CITER;
320 typedef SCH_SHEET_PATHS::reverse_iterator SCH_SHEET_PATHS_RITER;
321 typedef SCH_SHEET_PATHS::const_reverse_iterator SCH_SHEET_PATHS_CRITER;
322 
323 
335 {
336 private:
339 
340 public:
341 
348  SCH_SHEET_LIST( SCH_SHEET* aSheet = NULL );
349 
351 
362  SCH_SHEET_PATH* GetSheetByPath( const wxString aPath, bool aHumanReadable = true );
363 
369  bool IsModified();
370 
376  bool IsAutoSaveRequired();
377 
378  void ClearModifyStatus();
379 
385  void AnnotatePowerSymbols( PART_LIBS* aLib );
386 
395  void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
396  bool aIncludePowerSymbols = true );
397 
408  bool aIncludePowerSymbols = true );
409 
421  SCH_ITEM* FindNextItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFound = NULL,
422  SCH_ITEM* aLastItem = NULL, bool aWrap = true );
423 
435  SCH_ITEM* FindPreviousItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFound = NULL,
436  SCH_ITEM* aLastItem = NULL, bool aWrap = true );
437 
448  bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
449  bool aSetVisible );
450 
458  bool IsComplexHierarchy() const;
459 
470  bool TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
471  const wxString& aDestFileName ) const;
472 
481  SCH_SHEET* FindSheetByName( const wxString& aSheetName );
482 
492  void BuildSheetList( SCH_SHEET* aSheet );
493 };
494 
495 #endif // CLASS_DRAWSHEET_PATH_H
SCH_ITEM * LastDrawList() const
Function LastDrawList.
Definition of the SCH_SHEET class for Eeschema.
Class SCH_SHEET_LIST.
void AnnotatePowerSymbols(PART_LIBS *aLib)
Function AnnotatePowerSymbols clear and annotates the entire hierarchy of the sheet path list...
bool IsModified()
Function IsModified checks the entire hierarchy for any modifications.
SCH_SHEET * FindSheetByName(const wxString &aSheetName)
Function FindSheetByName.
int FindSheet(const wxString &aFileName) const
void GetComponents(PART_LIBS *aLibs, SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true)
Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the sheet...
SCH_ITEM * FindPreviousItem(KICAD_T aType, SCH_SHEET_PATH **aSheetFound=NULL, SCH_ITEM *aLastItem=NULL, bool aWrap=true)
Function FindPreviousItem searches the entire schematic for the previous schematic item...
std::vector< SCH_SHEET * > SCH_SHEETS
Definition: sch_sheet.h:611
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER
const SCH_SHEET * GetSheet(unsigned aIndex) const
SCH_ITEM * FindNextItem(KICAD_T aType, SCH_SHEET_PATH **aSheetFound=NULL, SCH_ITEM *aLastItem=NULL, bool aWrap=true)
Function FindNextItem searches the entire schematic for the next schematic object.
void SetPageNumber(int aPageNumber)
void GetMultiUnitComponents(PART_LIBS *aLibs, SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true)
Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference ...
bool operator==(const SCH_SHEET_PATH &d1) const
SCH_SCREEN * LastScreen() const
Function LastScreen.
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:90
SCH_SHEET_LIST(SCH_SHEET *aSheet=NULL)
Constructor build a flattened list of SCH_SHEET_PATH objects from aSheet.
Class SCH_REFERENCE_LIST is used to create a flattened list of components because in a complex hierar...
SCH_SHEET_PATHS::const_reverse_iterator SCH_SHEET_PATHS_CRITER
wxString Path() const
Function Path the path uses the time stamps which do not changes even when editing sheet parameters a...
void AnnotatePowerSymbols(PART_LIBS *aLibs, int *aReference)
Function AnnotatePowerSymbols annotates the power symbols only starting at aReference in the sheet pa...
SCH_SHEET * FindSheetByName(const wxString &aSheetName)
Function FindSheetByName.
SCH_SHEET_PATHS::const_iterator SCH_SHEET_PATHS_CITER
std::vector< SCH_SHEET_PATH > SCH_SHEET_PATHS
SCH_SHEET_PATH m_currentSheetPath
SCH_ITEM * FirstDrawList() const
Get the last schematic item relative to the first sheet in the list.
bool SetComponentFootprint(const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
Function SetFootprintField searches all the sheets for a component with aReference and set the footpr...
bool IsComplexHierarchy() const
Function IsComplexHierarchy searches all of the sheets for duplicate files names which indicates a co...
wxString PathHumanReadable() const
Function PathHumanReadable returns the sheet path in a human readable form, i.e.
bool SetComponentFootprint(const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
Function SetFootprintField searches last sheet in the path for a component with aReference and set th...
SCH_SHEET * GetSheet(unsigned aIndex)
SCH_SHEET * FindSheetByPageNumber(int aPageNumber)
Function FindSheetByPageNumber.
SCH_ITEM * FindPreviousItem(KICAD_T aType, SCH_ITEM *aLastItem=NULL, bool aWrap=false) const
Find the previous schematic item in this sheet path object.
bool operator!=(const SCH_SHEET_PATH &d1) const
SCH_SHEET_PATH()
Page numbers are maintained by the sheet load order.
int GetPageNumber() const
Class SCH_SHEET_PATH.
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
void BuildSheetList(SCH_SHEET *aSheet)
Function BuildSheetList builds the list of sheets and their sheet path from aSheet.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Type SCH_MULTI_UNIT_REFERENCE_MAP is used to create a map of reference designators for multi-unit par...
SCH_ITEM * FindNextItem(KICAD_T aType, SCH_ITEM *aLastItem=NULL, bool aWrap=false) const
Find the next schematic item in this sheet object.
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
Class PART_LIBS is a collection of PART_LIBs.
bool TestForRecursion(const wxString &aSrcFileName, const wxString &aDestFileName) const
Function TestForRecursion.
SCH_SHEET_PATH * GetSheetByPath(const wxString aPath, bool aHumanReadable=true)
Function GetSheetByPath returns a sheet matching the path name in aPath.
SCH_SHEET_PATHS::reverse_iterator SCH_SHEET_PATHS_RITER
void GetComponents(PART_LIBS *aLibs, SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true)
Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the list of...
int Cmp(const SCH_SHEET_PATH &aSheetPathToTest) const
Function Cmp Compare if this is the same sheet path as aSheetPathToTest.
void GetMultiUnitComponents(PART_LIBS *aLibs, SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true)
Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference ...
bool IsAutoSaveRequired()
Function IsAutoSaveRequired checks the entire hierarchy for any modifications that require auto save...
Basic classes for most KiCad items.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName) const
Function TestForRecursion.