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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2011-2016 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 1992-2017 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 {
115 
116 public:
117  SCH_SHEET_PATH();
118 
119  void SetPageNumber( int aPageNumber ) { m_pageNumber = aPageNumber; }
120 
121  int GetPageNumber() const { return m_pageNumber; }
122 
123  const SCH_SHEET* GetSheet( unsigned aIndex ) const
124  {
125  SCH_SHEET* retv = NULL;
126 
127  if( aIndex < size() )
128  retv = at( aIndex );
129 
130  return const_cast< SCH_SHEET* >( retv );
131  }
132 
133  SCH_SHEET* GetSheet( unsigned aIndex )
134  {
135  return const_cast< SCH_SHEET* >( static_cast< const SCH_SHEET_PATH& >( *this ).GetSheet( aIndex ) );
136  }
137 
146  int Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const;
147 
153  SCH_SHEET* Last() const;
154 
159  SCH_SCREEN* LastScreen() const;
160 
166  SCH_ITEM* LastDrawList() const;
167 
174  SCH_ITEM* FirstDrawList() const;
175 
182  wxString Path() const;
183 
191  wxString PathHumanReadable() const;
192 
203 
211  void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
212  bool aIncludePowerSymbols = true );
213 
224  bool aIncludePowerSymbols = true );
225 
236  bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
237  bool aSetVisible );
238 
249  SCH_ITEM* FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ) const;
250 
261  SCH_ITEM* FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ) const;
262 
274  bool TestForRecursion( const wxString& aSrcFileName, const wxString& aDestFileName ) const;
275 
276  int FindSheet( const wxString& aFileName ) const;
277 
286  SCH_SHEET* FindSheetByName( const wxString& aSheetName );
287 
296  SCH_SHEET* FindSheetByPageNumber( int aPageNumber );
297 
298  bool operator==( const SCH_SHEET_PATH& d1 ) const;
299 
300  bool operator!=( const SCH_SHEET_PATH& d1 ) const { return !( *this == d1 ) ; }
301 };
302 
303 
304 typedef std::vector< SCH_SHEET_PATH > SCH_SHEET_PATHS;
305 typedef SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER;
306 typedef SCH_SHEET_PATHS::const_iterator SCH_SHEET_PATHS_CITER;
307 typedef SCH_SHEET_PATHS::reverse_iterator SCH_SHEET_PATHS_RITER;
308 typedef SCH_SHEET_PATHS::const_reverse_iterator SCH_SHEET_PATHS_CRITER;
309 
310 
322 {
323 private:
326 
327 public:
328 
335  SCH_SHEET_LIST( SCH_SHEET* aSheet = NULL );
336 
338 
349  SCH_SHEET_PATH* GetSheetByPath( const wxString aPath, bool aHumanReadable = true );
350 
356  bool IsModified();
357 
358  void ClearModifyStatus();
359 
369  void AnnotatePowerSymbols( PART_LIBS* aLib );
370 
379  void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
380  bool aIncludePowerSymbols = true );
381 
392  bool aIncludePowerSymbols = true );
393 
405  SCH_ITEM* FindNextItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFound = NULL,
406  SCH_ITEM* aLastItem = NULL, bool aWrap = true );
407 
419  SCH_ITEM* FindPreviousItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFound = NULL,
420  SCH_ITEM* aLastItem = NULL, bool aWrap = true );
421 
432  bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
433  bool aSetVisible );
434 
442  bool IsComplexHierarchy() const;
443 
454  bool TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
455  const wxString& aDestFileName ) const;
456 
465  SCH_SHEET* FindSheetByName( const wxString& aSheetName );
466 
476  void BuildSheetList( SCH_SHEET* aSheet );
477 };
478 
479 #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 Silently annotates the not yet annotated power symbols of the entire hi...
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...
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 ...
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.