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 Wayne Stambaugh <stambaughw@gmail.com>
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 
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 
214  void GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols = true,
215  bool aForceIncludeOrphanComponents = false );
216 
227  bool aIncludePowerSymbols = true );
228 
239  bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
240  bool aSetVisible );
241 
252  SCH_ITEM* FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ) const;
253 
264  SCH_ITEM* FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ) const;
265 
277  bool TestForRecursion( const wxString& aSrcFileName, const wxString& aDestFileName ) const;
278 
279  int FindSheet( const wxString& aFileName ) const;
280 
289  SCH_SHEET* FindSheetByName( const wxString& aSheetName );
290 
299  SCH_SHEET* FindSheetByPageNumber( int aPageNumber );
300 
301  bool operator==( const SCH_SHEET_PATH& d1 ) const;
302 
303  bool operator!=( const SCH_SHEET_PATH& d1 ) const { return !( *this == d1 ) ; }
304 };
305 
306 
307 typedef std::vector< SCH_SHEET_PATH > SCH_SHEET_PATHS;
308 typedef SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER;
309 typedef SCH_SHEET_PATHS::const_iterator SCH_SHEET_PATHS_CITER;
310 typedef SCH_SHEET_PATHS::reverse_iterator SCH_SHEET_PATHS_RITER;
311 typedef SCH_SHEET_PATHS::const_reverse_iterator SCH_SHEET_PATHS_CRITER;
312 
313 
325 {
326 private:
329 
330 public:
331 
338  SCH_SHEET_LIST( SCH_SHEET* aSheet = NULL );
339 
341 
352  SCH_SHEET_PATH* GetSheetByPath( const wxString& aPath, bool aHumanReadable = true );
353 
359  bool IsModified();
360 
361  void ClearModifyStatus();
362 
371  void AnnotatePowerSymbols();
372 
384  void GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols = true,
385  bool aForceIncludeOrphanComponents = false );
386 
397  bool aIncludePowerSymbols = true );
398 
410  SCH_ITEM* FindNextItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFound = NULL,
411  SCH_ITEM* aLastItem = NULL, bool aWrap = true );
412 
424  SCH_ITEM* FindPreviousItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFound = NULL,
425  SCH_ITEM* aLastItem = NULL, bool aWrap = true );
426 
437  bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
438  bool aSetVisible );
439 
447  bool IsComplexHierarchy() const;
448 
459  bool TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
460  const wxString& aDestFileName ) const;
461 
470  SCH_SHEET* FindSheetByName( const wxString& aSheetName );
471 
481  void BuildSheetList( SCH_SHEET* aSheet );
482 };
483 
484 #endif // CLASS_DRAWSHEET_PATH_H
SCH_ITEM * LastDrawList() const
Function LastDrawList.
void GetComponents(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanComponents=false)
Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the sheet...
Definition of the SCH_SHEET class for Eeschema.
Class SCH_SHEET_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
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:576
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)
bool operator==(const SCH_SHEET_PATH &d1) const
SCH_SCREEN * LastScreen() const
Function LastScreen.
SCH_SHEET_PATH * GetSheetByPath(const wxString &aPath, bool aHumanReadable=true)
Function GetSheetByPath returns a sheet matching the path name in aPath.
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:78
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.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
void GetMultiUnitComponents(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true)
Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference ...
bool TestForRecursion(const wxString &aSrcFileName, const wxString &aDestFileName) const
Function TestForRecursion.
SCH_SHEET_PATHS::reverse_iterator SCH_SHEET_PATHS_RITER
int Cmp(const SCH_SHEET_PATH &aSheetPathToTest) const
Function Cmp Compare if this is the same sheet path as aSheetPathToTest.
void AnnotatePowerSymbols()
Function AnnotatePowerSymbols Silently annotates the not yet annotated power symbols of the entire hi...
void GetMultiUnitComponents(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.
void GetComponents(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanComponents=false)
Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the list of...
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.