KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ds_proxy_view_item.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) 2013 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Maciej Suminski <[email protected]>
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, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef DS_PROXY_VIEW_ITEM_H
23#define DS_PROXY_VIEW_ITEM_H
24
25#include <eda_item.h>
26#include <eda_units.h>
27#include <functional>
28#include <memory>
29#include <vector>
30
31class BOARD;
32class PAGE_INFO;
33class PROJECT;
34class TITLE_BLOCK;
41struct TEXT_VAR_REF_KEY;
42
43namespace KIGFX
44{
45class VIEW;
46class GAL;
47class DS_PAINTER;
48}
49
51{
52public:
53 DS_PROXY_VIEW_ITEM( const EDA_IU_SCALE& aIuScale, const PAGE_INFO* aPageInfo,
54 const PROJECT* aProject, const TITLE_BLOCK* aTitleBlock,
55 const std::map<wxString, wxString>* aProperties );
56
60 void SetFileName( const std::string& aFileName ) { m_fileName = aFileName; }
61
65 void SetSheetName( const std::string& aSheetName ) { m_sheetName = aSheetName; }
66
70 void SetSheetPath( const std::string& aSheetPath ) { m_sheetPath = aSheetPath; }
71
75 void SetPageNumber( const std::string& aPageNumber ) { m_pageNumber = aPageNumber; }
76
80 void SetSheetCount( int aSheetCount ) { m_sheetCount = aSheetCount; }
81
88 void SetIsFirstPage( bool aIsFirstPage ) { m_isFirstPage = aIsFirstPage; }
89
93 void SetVariantName( const std::string& aVariant ) { m_variantName = aVariant; }
94 void SetVariantDesc( const std::string& aVariantDesc ) { m_variantDesc = aVariantDesc; }
95
100 void SetColorLayer( int aLayerId ) { m_colorLayer = aLayerId; }
101
107 void SetPageBorderColorLayer( int aLayerId ) { m_pageBorderColorLayer = aLayerId; }
108
109 const PAGE_INFO& GetPageInfo() { return *m_pageInfo; }
111
112 const BOX2I ViewBBox() const override;
113
114 void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override;
115
116 std::vector<int> ViewGetLayers() const override;
117
118#if defined(DEBUG)
119 void Show( int x, std::ostream& st ) const override { }
120#endif
121
127 virtual wxString GetClass() const override
128 {
129 return wxT( "DS_PROXY_VIEW_ITEM" );
130 }
131
132 bool HitTestDrawingSheetItems( KIGFX::VIEW* aView, const VECTOR2I& aPosition );
133
141 std::vector<TEXT_VAR_REF_KEY> CollectTextVarKeys() const;
142
157 void AttachToTracker( TEXT_VAR_TRACKER* aTracker );
158
159 ~DS_PROXY_VIEW_ITEM() override;
160
161protected:
162 void buildDrawList( KIGFX::VIEW* aView, const std::map<wxString, wxString>* aProperties,
163 DS_DRAW_ITEM_LIST* aDrawList ) const;
164
165protected:
167
168 std::string m_fileName;
169 std::string m_sheetName;
170 std::string m_sheetPath;
173 std::string m_pageNumber;
176 std::string m_variantName;
177 std::string m_variantDesc;
179
180 const std::map<wxString, wxString>* m_properties;
181
187
190
192 mutable std::unique_ptr<KIGFX::DS_PAINTER> m_painter;
193 mutable KIGFX::GAL* m_painterGal = nullptr;
194
198};
199
200#endif /* DS_PROXY_VIEW_ITEM_H */
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:410
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
Non filled rectangle with thick segment.
A graphic text.
void SetSheetPath(const std::string &aSheetPath)
Set the sheet path displayed in the title block.
void SetSheetCount(int aSheetCount)
Change the sheet-count number displayed in the title block.
void SetVariantName(const std::string &aVariant)
Set the current variant name and description to be shown on the drawing sheet.
const PROJECT * m_project
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
void SetVariantDesc(const std::string &aVariantDesc)
void SetPageNumber(const std::string &aPageNumber)
Change the page number displayed in the title block.
int m_colorLayer
Layer that is used for drawing sheet color (LAYER_DRAWINGSHEET is always used for visibility).
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
const TITLE_BLOCK * m_titleBlock
void SetSheetName(const std::string &aSheetName)
Set the sheet name displayed in the title block.
std::unique_ptr< KIGFX::DS_PAINTER > m_painter
Painter kept between draws because building its settings is costly, rebuilt if the GAL changes.
void SetPageBorderColorLayer(int aLayerId)
Override the layer used to pick the color of the page border (normally LAYER_GRID)
const PAGE_INFO & GetPageInfo()
const EDA_IU_SCALE & m_iuScale
void SetIsFirstPage(bool aIsFirstPage)
Change if this is first page.
const std::map< wxString, wxString > * m_properties
void AttachToTracker(TEXT_VAR_TRACKER *aTracker)
Register this proxy with aTracker as a dependent on every title-block source variable its current tem...
const TITLE_BLOCK & GetTitleBlock()
bool HitTestDrawingSheetItems(KIGFX::VIEW *aView, const VECTOR2I &aPosition)
TEXT_VAR_TRACKER * m_attachedTracker
Tracker this proxy is currently registered with (null if detached).
void SetFileName(const std::string &aFileName)
Set the file name displayed in the title block.
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Draw the parts of the object belonging to layer aLayer.
DS_PROXY_VIEW_ITEM(const EDA_IU_SCALE &aIuScale, const PAGE_INFO *aPageInfo, const PROJECT *aProject, const TITLE_BLOCK *aTitleBlock, const std::map< wxString, wxString > *aProperties)
void SetColorLayer(int aLayerId)
Can be used to override which layer ID is used for drawing sheet item colors.
void buildDrawList(KIGFX::VIEW *aView, const std::map< wxString, wxString > *aProperties, DS_DRAW_ITEM_LIST *aDrawList) const
virtual wxString GetClass() const override
Get class name.
const PAGE_INFO * m_pageInfo
int m_pageBorderColorLayer
Layer that is used for page border color.
std::vector< TEXT_VAR_REF_KEY > CollectTextVarKeys() const
Walk the current drawing-sheet definition and collect every ${...} reference encountered in its text ...
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
Methods for painting drawing sheet items.
Definition ds_painter.h:94
Abstract interface for drawing on a 2D-surface.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
Container for project specific data.
Definition project.h:63
Coordinates the dependency index with change notifications.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition title_block.h:38
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
Identifies a single resolvable source that a text item's ${...} reference depends on.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708