KiCad PCB EDA Suite
sch_view.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) 2018 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef SCH_VIEW_H_
25 #define SCH_VIEW_H_
26 
27 #include <memory>
28 #include <view/view.h>
29 #include <math/box2.h>
30 
31 #include <view/wx_view_controls.h>
32 #include <worksheet_viewitem.h>
34 
35 class SCH_SHEET;
36 class SCH_SCREEN;
37 class LIB_PART;
38 class LIB_PIN;
39 class SCH_BASE_FRAME;
40 
41 // Eeschema uses mils as the internal units
42 constexpr double SCH_WORLD_UNIT = 0.001;
43 
44 static const LAYER_NUM SCH_LAYER_ORDER[] =
45  {
58  };
59 
60 
61 namespace KIGFX
62 {
63  class VIEW_GROUP;
64  class WORKSHEET_VIEWITEM;
65 
66  namespace PREVIEW
67  {
68  class SELECTION_AREA;
69  };
70 
71 class SCH_VIEW : public KIGFX::VIEW
72 {
73 public:
74  // Note: aFrame is used to know the sheet path name when drawing the page layout.
75  // It can be null.
76  SCH_VIEW( bool aIsDynamic, SCH_BASE_FRAME* aFrame );
77  ~SCH_VIEW();
78 
79  void DisplaySheet( SCH_SHEET* aSheet );
80  void DisplaySheet( SCH_SCREEN* aScreen );
81  void DisplayComponent( LIB_PART* aPart );
82 
83  // Call it to set new draw area limits (max working and draw area size)
84  void ResizeSheetWorkingArea( SCH_SCREEN *aScreen );
85 
86  KIGFX::PREVIEW::SELECTION_AREA* GetSelectionArea() const { return m_selectionArea.get(); }
87 
88  KIGFX::VIEW_GROUP* GetPreview() const { return m_preview.get(); }
89 
90  void ClearPreview();
91  void AddToPreview( EDA_ITEM* aItem, bool aTakeOwnership = true );
92 
93  void ShowSelectionArea( bool aShow = true );
94  void ShowPreview( bool aShow = true );
95 
99  void ClearHiddenFlags();
100 
101  void HideWorksheet();
102 
103  void HighlightItem( EDA_ITEM *aItem, LIB_PIN* aPin = nullptr );
104 
105 private:
106  SCH_BASE_FRAME* m_frame; // The frame using this view. Can be null. Used mainly
107  // to know the sheet path name when drawing the page layout
108  std::unique_ptr<WORKSHEET_VIEWITEM> m_worksheet;
109  std::unique_ptr<KIGFX::PREVIEW::SELECTION_AREA> m_selectionArea;
110  std::unique_ptr<KIGFX::VIEW_GROUP> m_preview;
111  std::vector<EDA_ITEM *> m_ownedItems;
112 };
113 
114 }; // namespace
115 
116 #endif
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:57
KIGFX::PREVIEW::SELECTION_AREA * GetSelectionArea() const
Definition: sch_view.h:86
constexpr double SCH_WORLD_UNIT
Definition: sch_view.h:42
std::unique_ptr< KIGFX::PREVIEW::SELECTION_AREA > m_selectionArea
Definition: sch_view.h:109
WX_VIEW_CONTROLS class definition.
std::vector< EDA_ITEM * > m_ownedItems
Definition: sch_view.h:111
static const LAYER_NUM SCH_LAYER_ORDER[]
Definition: sch_view.h:44
KIGFX::VIEW_GROUP * GetPreview() const
Definition: sch_view.h:88
Class that handles properties and drawing of worksheet layout.
Define a library symbol object.
general purpose overlay
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
std::unique_ptr< WORKSHEET_VIEWITEM > m_worksheet
Definition: sch_view.h:108
Board layer functions and definitions.
currently selected items overlay
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
SCH_BASE_FRAME * m_frame
Definition: sch_view.h:106
Class SELECTION_AREA.
Class VIEW.
Definition: view.h:61
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME, and it brings in a common way of handling the provided virtual functions for the derived classes.
std::unique_ptr< KIGFX::VIEW_GROUP > m_preview
Definition: sch_view.h:110