KiCad PCB EDA Suite
sch_screen.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) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #ifndef SCREEN_H
31 #define SCREEN_H
32 
33 #include <macros.h>
34 #include <dlist.h>
35 #include <sch_item_struct.h>
36 #include <lib_draw_item.h>
37 #include <base_screen.h>
38 #include <title_block.h>
39 #include <page_info.h>
40 #include <kiway_player.h>
41 #include <sch_marker.h>
42 
43 #include <../eeschema/general.h>
44 
45 
46 class LIB_PIN;
47 class SCH_COMPONENT;
48 class SCH_SHEET_PATH;
49 class SCH_SHEET_PIN;
50 class SCH_LINE;
51 class SCH_TEXT;
52 class PLOTTER;
53 class SCH_SHEET_LIST;
54 
55 
57 {
61 };
62 
63 
65 #define NB_MAX_SHEET 500
66 
67 
68 class SCH_SCREEN : public BASE_SCREEN, public KIWAY_HOLDER
69 {
70 private:
71 
72  wxString m_fileName;
73 
74  int m_refCount;
75 
83  wxArrayString m_clientSheetPathList;
84 
86  PAGE_INFO m_paper; // keep with the MVC 'model' if this class gets split
87 
89 
92 
94 
96 
108  void addConnectedItemsToBlock( const SCH_ITEM* aItem, const wxPoint& aPosition );
109 
110 public:
111 
115  SCH_SCREEN( KIWAY* aKiway );
116 
117  ~SCH_SCREEN();
118 
120 
121  virtual wxString GetClass() const override
122  {
123  return wxT( "SCH_SCREEN" );
124  }
125 
126  const PAGE_INFO& GetPageSettings() const { return m_paper; }
127  void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
128 
129  void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
130 
131  const wxString& GetFileName() const { return m_fileName; }
132 
133  const wxPoint& GetAuxOrigin() const { return m_aux_origin; }
134  void SetAuxOrigin( const wxPoint& aPosition ) { m_aux_origin = aPosition; }
135 
136  const TITLE_BLOCK& GetTitleBlock() const { return m_titles; }
137  //TITLE_BLOCK& GetTitleBlock() const { return (TITLE_BLOCK&) m_titles; }
138  void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
139 
140  void DecRefCount();
141 
142  void IncRefCount();
143 
144  int GetRefCount() const { return m_refCount; }
145 
153  int GetClientSheetPathsCount() { return (int) m_clientSheetPathList.GetCount(); }
154 
155  wxArrayString& GetClientSheetPaths() { return m_clientSheetPathList; }
156 
160  SCH_ITEM* GetDrawItems() const { return m_drawList.begin(); }
161 
162  void Append( SCH_ITEM* aItem )
163  {
164  m_drawList.Append( aItem );
166  }
167 
178  void Append( SCH_SCREEN* aScreen );
179 
185  void Append( DLIST< SCH_ITEM >& aList )
186  {
187  m_drawList.Append( aList );
189  }
190 
198 
204  void SetCurItem( SCH_ITEM* aItem ) { BASE_SCREEN::SetCurItem( (EDA_ITEM*) aItem ); }
205  void SetCurLibItem( LIB_ITEM* aItem ) { BASE_SCREEN::SetCurItem( (EDA_ITEM*) aItem ); }
206 
210  void Clear();
211 
217  void FreeDrawList();
218 
227  SCH_ITEM* GetItem( const wxPoint& aPosition, int aAccuracy = 0,
228  KICAD_T aType = NOT_USED ) const;
229 
230  void Place( SCH_EDIT_FRAME* frame, wxDC* DC ) { };
231 
244  void UpdateSymbolLinks( bool aForce = false );
245 
257  void Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode,
258  COLOR4D aColor = COLOR4D::UNSPECIFIED );
259 
268  void Plot( PLOTTER* aPlotter );
269 
276  void Remove( SCH_ITEM* aItem );
277 
286  void DeleteItem( SCH_ITEM* aItem );
287 
288  bool CheckIfOnDrawList( SCH_ITEM* st );
289 
294  bool TestDanglingEnds();
295 
301  void ReplaceWires( DLIST< SCH_ITEM >& aWireList );
302 
309  void MarkConnections( SCH_LINE* aSegment );
310 
322  int GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aList, bool aFullConnection );
323 
324  /* full undo redo management : */
325  // use BASE_SCREEN::PushCommandToUndoList( PICKED_ITEMS_LIST* aItem )
326  // use BASE_SCREEN::PushCommandToRedoList( PICKED_ITEMS_LIST* aItem )
327 
340  virtual void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 ) override;
341 
345  void ClearDrawingState();
346 
347  int CountConnectedItems( const wxPoint& aPos, bool aTestJunctions ) const;
348 
364  bool IsJunctionNeeded( const wxPoint& aPosition, bool aNew = false );
365 
374  bool IsTerminalPoint( const wxPoint& aPosition, int aLayer );
375 
385  LIB_PIN* GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent = NULL,
386  bool aEndPointOnly = false ) const;
387 
395  SCH_SHEET* GetSheet( const wxString& aName );
396 
403  SCH_SHEET_PIN* GetSheetLabel( const wxPoint& aPosition );
404 
411  void ClearAnnotation( SCH_SHEET_PATH* aSheetPath );
412 
423 
429  void GetHierarchicalItems( EDA_ITEMS& aItems );
430 
438  int GetNode( const wxPoint& aPosition, EDA_ITEMS& aList );
439 
447  SCH_LINE* GetWireOrBus( const wxPoint& aPosition );
448 
459  SCH_LINE* GetLine( const wxPoint& aPosition, int aAccuracy = 0, int aLayer = LAYER_NOTES,
460  SCH_LINE_TEST_T aSearchType = ENTIRE_LENGTH_T );
461 
462  SCH_LINE* GetWire( const wxPoint& aPosition, int aAccuracy = 0,
463  SCH_LINE_TEST_T aSearchType = ENTIRE_LENGTH_T )
464  {
465  return GetLine( aPosition, aAccuracy, LAYER_WIRE, aSearchType );
466  }
467 
468  SCH_LINE* GetBus( const wxPoint& aPosition, int aAccuracy = 0,
469  SCH_LINE_TEST_T aSearchType = ENTIRE_LENGTH_T )
470  {
471  return GetLine( aPosition, aAccuracy, LAYER_BUS, aSearchType );
472  }
473 
482  SCH_TEXT* GetLabel( const wxPoint& aPosition, int aAccuracy = 0 );
483 
494  bool SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxString& aReference,
495  const wxString& aFootPrint, bool aSetVisible );
496 
503  void SelectBlockItems();
504 
510  int UpdatePickList();
511 
512 #if defined(DEBUG)
513  void Show( int nestLevel, std::ostream& os ) const override;
514 #endif
515 };
516 
517 
524 {
525 private:
526  std::vector< SCH_SCREEN* > m_screens;
527  unsigned int m_index;
528 
529 public:
530  SCH_SCREENS( SCH_SHEET* aSheet = NULL );
531  ~SCH_SCREENS();
532  int GetCount() const { return m_screens.size(); }
533  SCH_SCREEN* GetFirst();
534  SCH_SCREEN* GetNext();
535  SCH_SCREEN* GetScreen( unsigned int aIndex ) const;
536 
540  void ClearAnnotation();
541 
550  void ClearAnnotationOfNewSheetPaths( SCH_SHEET_LIST& aInitialSheetPathList );
551 
559  int ReplaceDuplicateTimeStamps();
560 
566  void DeleteAllMarkers( enum MARKER_BASE::TYPEMARKER aMarkerType );
567 
577  int GetMarkerCount( enum MARKER_BASE::TYPEMARKER aMarkerType,
578  enum MARKER_BASE::MARKER_SEVERITY aSeverity );
579 
590  void UpdateSymbolLinks( bool aForce = false );
591 
592  void TestDanglingEnds();
593 
604  bool HasNoFullyDefinedLibIds();
605 
612  size_t GetLibNicknames( wxArrayString& aLibNicknames );
613 
621  int ChangeSymbolLibNickname( const wxString& aFrom, const wxString& aTo );
622 
626  void BuildClientSheetPathList();
627 
628 
629 private:
630  void addScreenToList( SCH_SCREEN* aScreen );
631  void buildScreenList( SCH_SHEET* aSheet);
632 };
633 
634 #endif /* SCREEN_H */
Class SCH_SHEET_LIST.
Class KIWAY_HOLDER is a mix in class which holds the location of a wxWindow&#39;s KIWAY.
Definition: kiway_player.h:48
int CountConnectedItems(const wxPoint &aPos, bool aTestJunctions) const
Definition: sch_screen.cpp:661
const wxPoint & GetAuxOrigin() const
Definition: sch_screen.h:133
void SetCurItem(EDA_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
Definition: base_screen.h:231
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
Base schematic object class definition.
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:325
SCH_SHEET * GetSheet(const wxString &aName)
Returns a sheet object pointer that is named aName.
Definition: sch_screen.cpp:624
int GetClientSheetPathsCount()
Definition: sch_screen.h:153
void Append(T *aNewElement)
Function Append adds aNewElement to the end of the list.
Definition: dlist.h:177
void UpdateSymbolLinks(bool aForce=false)
Initialize or reinitialize the weak reference to the LIB_PART for each SCH_COMPONENT found in m_drawL...
Definition: sch_screen.cpp:476
the 3d code uses this value
Definition: typeinfo.h:80
wxArrayString & GetClientSheetPaths()
Definition: sch_screen.h:155
const wxString & GetFileName() const
Definition: sch_screen.h:131
int m_refCount
Number of sheets referencing this screen.
Definition: sch_screen.h:74
SCH_SCREEN(KIWAY *aKiway)
Constructor.
Definition: sch_screen.cpp:93
T * begin() const
Definition: dlist.h:218
int GetRefCount() const
Definition: sch_screen.h:144
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: sch_screen.h:127
Schematic editor (Eeschema) main window.
void Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:176
void EnsureAlternateReferencesExist()
For screens shared by many sheetpaths (complex hierarchies): to be able to clear or modify any refere...
Definition: sch_screen.cpp:698
wxPoint m_aux_origin
Origin of the auxiliary axis, which is used in exports mostly, but not yet in EESCHEMA.
Definition: sch_screen.h:91
wxString m_fileName
File used to load the screen.
Definition: sch_screen.h:72
void SetAuxOrigin(const wxPoint &aPosition)
Definition: sch_screen.h:134
int m_modification_sync
inequality with PART_LIBS::GetModificationHash() will trigger ResolveAll().
Definition: sch_screen.h:95
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
void addConnectedItemsToBlock(const SCH_ITEM *aItem, const wxPoint &aPosition)
Add items connected at aPosition to the block pick list.
Definition: sch_screen.cpp:808
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
This file contains miscellaneous commonly used macros and functions.
void Place(SCH_EDIT_FRAME *frame, wxDC *DC)
Definition: sch_screen.h:230
SCH_LINE * GetLine(const wxPoint &aPosition, int aAccuracy=0, int aLayer=LAYER_NOTES, SCH_LINE_TEST_T aSearchType=ENTIRE_LENGTH_T)
Return a line item located at aPosition.
Definition: sch_screen.cpp:965
unsigned int m_index
Definition: sch_screen.h:527
Class UNDO_REDO_CONTAINER is a holder to handle alist of undo (or redo) command.
TITLE_BLOCK m_titles
Definition: sch_screen.h:88
int GetConnection(const wxPoint &aPosition, PICKED_ITEMS_LIST &aList, bool aFullConnection)
Adds all of the wires and junctions to aList that make up a connection to the object at aPosition...
PAGE_INFO m_paper
The size of the paper to print or plot on.
Definition: sch_screen.h:86
void GetHierarchicalItems(EDA_ITEMS &aItems)
Add all schematic sheet and component objects in the screen to aItems.
Definition: sch_screen.cpp:715
int UpdatePickList()
Add all the items in the screen within the block selection rectangle to the pick list.
Definition: sch_screen.cpp:873
void Append(DLIST< SCH_ITEM > &aList)
Add aList of SCH_ITEM objects to the list for draw items for the sheet.
Definition: sch_screen.h:185
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: sch_screen.h:196
void DeleteItem(SCH_ITEM *aItem)
Removes aItem from the linked list and deletes the object.
Definition: sch_screen.cpp:182
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:550
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
SCH_LINE_TEST_T
Definition: sch_screen.h:56
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
void MarkConnections(SCH_LINE *aSegment)
Add all wires and junctions connected to aSegment which are not connected any component pin to aItemL...
Definition: sch_screen.cpp:283
void Clear()
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:159
void Draw(EDA_DRAW_PANEL *aCanvas, wxDC *aDC, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED)
Draw all the items in the screen to aCanvas.
Definition: sch_screen.cpp:504
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
int GetNode(const wxPoint &aPosition, EDA_ITEMS &aList)
Return all the items at aPosition that form a node.
Definition: sch_screen.cpp:931
SCH_SHEET_PIN * GetSheetLabel(const wxPoint &aPosition)
Test the screen if aPosition is a sheet label object.
Definition: sch_screen.cpp:641
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
SCH_LINE * GetWire(const wxPoint &aPosition, int aAccuracy=0, SCH_LINE_TEST_T aSearchType=ENTIRE_LENGTH_T)
Definition: sch_screen.h:462
Class SCH_SHEET_PATH.
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: sch_screen.h:138
void SelectBlockItems()
Create a list of items found when a block command is initiated.
Definition: sch_screen.cpp:729
void FreeDrawList()
Free all the items from the schematic associated with the screen.
Definition: sch_screen.cpp:170
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:136
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
void Plot(PLOTTER *aPlotter)
Plot all the schematic objects to aPlotter.
Definition: sch_screen.cpp:533
DLIST< SCH_ITEM > m_drawList
Object list for the screen.
Definition: sch_screen.h:93
void DecRefCount()
Definition: sch_screen.cpp:137
Base plotter engine class.
Definition: plotter.h:97
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:160
bool IsTerminalPoint(const wxPoint &aPosition, int aLayer)
Test if aPosition is a connection point on aLayer.
Definition: sch_screen.cpp:405
SCH_TEXT * GetLabel(const wxPoint &aPosition, int aAccuracy=0)
Return a label item located at aPosition.
Definition: sch_screen.cpp:999
LIB_ITEM * GetCurLibItem() const
Definition: sch_screen.h:197
Segment description base class to describe items which have 2 end points (track, wire, draw line ...)
Definition: sch_line.h:41
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:526
SCH_ITEM * GetItem(const wxPoint &aPosition, int aAccuracy=0, KICAD_T aType=NOT_USED) const
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:221
void Append(SCH_ITEM *aItem)
Definition: sch_screen.h:162
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Definition: sch_screen.cpp:910
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
int GetCount() const
Definition: sch_screen.h:532
LIB_PIN * GetPin(const wxPoint &aPosition, SCH_COMPONENT **aComponent=NULL, bool aEndPointOnly=false) const
Test the screen for a component pin item at aPosition.
Definition: sch_screen.cpp:568
SCH_LINE * GetWireOrBus(const wxPoint &aPosition)
Return a wire or bus item located at aPosition.
Definition: sch_screen.cpp:950
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:126
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:679
void ReplaceWires(DLIST< SCH_ITEM > &aWireList)
Replace all of the wires, buses, and junctions in the screen with aWireList.
Definition: sch_screen.cpp:257
void ClearDrawingState()
Clear the state flags of all the items in the screen.
Definition: sch_screen.cpp:561
virtual void ClearUndoORRedoList(UNDO_REDO_CONTAINER &aList, int aItemCount=-1) override
Free the undo or redo list from aList element.
Definition: sch_screen.cpp:546
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:129
BASE_SCREEN class implementation.
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:205
DLIST< SCH_ITEM > & GetDrawList()
Definition: sch_screen.h:119
void SetCurLibItem(LIB_ITEM *aItem)
Definition: sch_screen.h:205
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
wxArrayString m_clientSheetPathList
the list of scheet paths sharing this screen used in some annotation calculations to update alternate...
Definition: sch_screen.h:83
void IncRefCount()
Definition: sch_screen.cpp:131
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_screen.h:121
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
bool SetComponentFootprint(SCH_SHEET_PATH *aSheetPath, const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
Search this screen for a symbol with aReference and set the footprint field to aFootPrint if found...
SCH_LINE * GetBus(const wxPoint &aPosition, int aAccuracy=0, SCH_LINE_TEST_T aSearchType=ENTIRE_LENGTH_T)
Definition: sch_screen.h:468