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-2019 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 <base_struct.h>
29 #include <math/vector2d.h>
30 #include <view/view.h>
31 
32 #include <memory>
33 #include <vector>
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 100nm as the internal units
42 constexpr double SCH_WORLD_UNIT ( 1e-7 / 0.0254 );
43 
44 static const LAYER_NUM SCH_LAYER_ORDER[] =
45 {
59 };
60 
61 
62 namespace KIGFX
63 {
64  class VIEW_GROUP;
65  class WS_PROXY_VIEW_ITEM;
66 
67  namespace PREVIEW
68  {
69  class SELECTION_AREA;
70  };
71 
72 class SCH_VIEW : public KIGFX::VIEW
73 {
74 public:
75  // Note: aFrame is used to know the sheet path name when drawing the page layout.
76  // It can be null.
77  SCH_VIEW( bool aIsDynamic, SCH_BASE_FRAME* aFrame );
78  ~SCH_VIEW();
79 
80  void DisplaySheet( SCH_SHEET* aSheet );
81  void DisplaySheet( SCH_SCREEN* aScreen );
82  void DisplayComponent( LIB_PART* aPart );
83 
84  // Call it to set new draw area limits (max working and draw area size)
85  void ResizeSheetWorkingArea( SCH_SCREEN *aScreen );
86 
87  void ClearPreview();
88  void AddToPreview( EDA_ITEM* aItem, bool aTakeOwnership = true );
89 
90  void ShowPreview( bool aShow = true );
91 
92  void SetScale( double aScale, VECTOR2D aAnchor = { 0, 0 } ) override;
93 
97  void ClearHiddenFlags();
98 
99  void HideWorksheet();
100 
101  void HighlightItem( EDA_ITEM *aItem, LIB_PIN* aPin = nullptr );
102 
103 private:
104  SCH_BASE_FRAME* m_frame; // The frame using this view. Can be null. Used mainly
105  // to know the sheet path name when drawing the page layout
106 
107  std::unique_ptr<WS_PROXY_VIEW_ITEM> m_worksheet;
108  std::unique_ptr<KIGFX::PREVIEW::SELECTION_AREA> m_selectionArea;
109  std::unique_ptr<KIGFX::VIEW_GROUP> m_preview;
110  std::vector<EDA_ITEM *> m_ownedItems;
111 };
112 
113 }; // namespace
114 
115 #endif
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
Definition: sch_view.cpp:213
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: sch_view.cpp:193
void DisplayComponent(LIB_PART *aPart)
Definition: sch_view.cpp:128
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:131
void ResizeSheetWorkingArea(SCH_SCREEN *aScreen)
Definition: sch_view.cpp:83
void DisplaySheet(SCH_SHEET *aSheet)
Definition: sch_view.cpp:122
std::unique_ptr< KIGFX::PREVIEW::SELECTION_AREA > m_selectionArea
Definition: sch_view.h:108
void HighlightItem(EDA_ITEM *aItem, LIB_PIN *aPin=nullptr)
Definition: sch_view.cpp:226
std::vector< EDA_ITEM * > m_ownedItems
Definition: sch_view.h:110
static const LAYER_NUM SCH_LAYER_ORDER[]
Definition: sch_view.h:44
void HideWorksheet()
Definition: sch_view.cpp:220
void ShowPreview(bool aShow=true)
Definition: sch_view.cpp:207
void ClearPreview()
Definition: sch_view.cpp:181
Define a library symbol object.
std::unique_ptr< WS_PROXY_VIEW_ITEM > m_worksheet
Definition: sch_view.h:107
void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 }) override
Function SetScale() Sets the scaling factor, zooming around a given anchor point.
Definition: sch_view.cpp:73
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:215
Board layer functions and definitions.
constexpr double SCH_WORLD_UNIT(1e-7/0.0254)
currently selected items overlay
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
SCH_BASE_FRAME * m_frame
Definition: sch_view.h:104
SCH_VIEW(bool aIsDynamic, SCH_BASE_FRAME *aFrame)
Definition: sch_view.cpp:49
VIEW.
Definition: view.h:61
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
std::unique_ptr< KIGFX::VIEW_GROUP > m_preview
Definition: sch_view.h:109