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 
211  void GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols = true );
212 
223  bool aIncludePowerSymbols = true );
224 
235  bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
236  bool aSetVisible );
237 
248  SCH_ITEM* FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ) const;
249 
260  SCH_ITEM* FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem = NULL, bool aWrap = false ) const;
261 
273  bool TestForRecursion( const wxString& aSrcFileName, const wxString& aDestFileName ) const;
274 
275  int FindSheet( const wxString& aFileName ) const;
276 
285  SCH_SHEET* FindSheetByName( const wxString& aSheetName );
286 
295  SCH_SHEET* FindSheetByPageNumber( int aPageNumber );
296 
297  bool operator==( const SCH_SHEET_PATH& d1 ) const;
298 
299  bool operator!=( const SCH_SHEET_PATH& d1 ) const { return !( *this == d1 ) ; }
300 };
301 
302 
303 typedef std::vector< SCH_SHEET_PATH > SCH_SHEET_PATHS;
304 typedef SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER;
305 typedef SCH_SHEET_PATHS::const_iterator SCH_SHEET_PATHS_CITER;
306 typedef SCH_SHEET_PATHS::reverse_iterator SCH_SHEET_PATHS_RITER;
307 typedef SCH_SHEET_PATHS::const_reverse_iterator SCH_SHEET_PATHS_CRITER;
308 
309 
321 {
322 private:
325 
326 public:
327 
334  SCH_SHEET_LIST( SCH_SHEET* aSheet = NULL );
335 
337 
348  SCH_SHEET_PATH* GetSheetByPath( const wxString aPath, bool aHumanReadable = true );
349 
355  bool IsModified();
356 
357  void ClearModifyStatus();
358 
367  void AnnotatePowerSymbols();
368 
377  void GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols = true );
378 
389  bool aIncludePowerSymbols = true );
390 
402  SCH_ITEM* FindNextItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFound = NULL,
403  SCH_ITEM* aLastItem = NULL, bool aWrap = true );
404 
416  SCH_ITEM* FindPreviousItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFound = NULL,
417  SCH_ITEM* aLastItem = NULL, bool aWrap = true );
418 
429  bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
430  bool aSetVisible );
431 
439  bool IsComplexHierarchy() const;
440 
451  bool TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
452  const wxString& aDestFileName ) const;
453 
462  SCH_SHEET* FindSheetByName( const wxString& aSheetName );
463 
473  void BuildSheetList( SCH_SHEET* aSheet );
474 };
475 
476 #endif // CLASS_DRAWSHEET_PATH_H
SCH_ITEM * LastDrawList() const
Function LastDrawList.
Definition of the SCH_SHEET class for Eeschema.
Class SCH_SHEET_LIST.
void GetComponents(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true)
Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the list of...
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:569
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.
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...
void GetComponents(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true)
Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the sheet...
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_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
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.
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.