KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_drill_map.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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef PCB_DRILL_MAP_H
21#define PCB_DRILL_MAP_H
22
23#include <board_item.h>
24#include <drill/drill_span.h>
26
27#include <memory>
28#include <mutex>
29
30class BOARD;
31
32namespace KIGFX
33{
34class VIEW;
35}
36
37
48{
49public:
50 PCB_DRILL_MAP( BOARD_ITEM* aParent );
51
56 PCB_DRILL_MAP( const PCB_DRILL_MAP& aOther );
57
58 static inline bool ClassOf( const EDA_ITEM* aItem )
59 {
60 return aItem && PCB_DRILL_MAP_T == aItem->Type();
61 }
62
63 wxString GetClass() const override { return wxT( "PCB_DRILL_MAP" ); }
64
65 EDA_ITEM* Clone() const override { return new PCB_DRILL_MAP( *this ); }
66
75 VECTOR2I GetPosition() const override { return m_offset; }
76 void SetPosition( const VECTOR2I& aPos ) override { m_offset = aPos; }
77
78 void Move( const VECTOR2I& aMoveVector ) override { m_offset += aMoveVector; }
79
80 const VECTOR2I& GetOffset() const { return m_offset; }
81 void SetOffset( const VECTOR2I& aOffset ) { m_offset = aOffset; }
82
83 int GetOffsetX() const { return m_offset.x; }
84 void SetOffsetX( int aX ) { m_offset.x = aX; }
85 int GetOffsetY() const { return m_offset.y; }
86 void SetOffsetY( int aY ) { m_offset.y = aY; }
87
88 int GetSymbolSize() const { return m_symbolSize; }
89 void SetSymbolSize( int aSize );
90 int GetSymbolExtent() const;
91
95 void Rotate( const VECTOR2I& aCentre, const EDA_ANGLE& aAngle ) override;
96 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
97
98 bool GetOutlineSlots() const { return m_outlineSlots; }
99 void SetOutlineSlots( bool aOn ) { m_outlineSlots = aOn; }
100
101 bool GetGuideCross() const { return m_guideCross; }
102 void SetGuideCross( bool aOn ) { m_guideCross = aOn; }
103
104 const DRILL_SPAN& GetSpan() const { return m_span; }
105 void SetSpan( const DRILL_SPAN& aSpan ) { m_span = aSpan; }
106
107 bool GetAllSpans() const { return m_allSpans; }
108 void SetAllSpans( bool aAll ) { m_allSpans = aAll; }
109
117 int GetSpanChoice() const;
118 void SetSpanChoice( int aIndex );
119
120 const BOX2I GetBoundingBox() const override;
121
131 std::shared_ptr<const SHAPE_POLY_SET> GetBoardOutlines() const;
132
133 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
134 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
135
136 std::vector<int> ViewGetLayers() const override;
137
138 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
139
140 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
141
142 double Similarity( const BOARD_ITEM& aOther ) const override;
143
144 bool operator==( const BOARD_ITEM& aOther ) const override;
145
146 void Serialize( google::protobuf::Any& aContainer ) const override;
147 bool Deserialize( const google::protobuf::Any& aContainer ) override;
148
149#if defined( DEBUG )
150 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
151#endif
152
153protected:
154 void swapData( BOARD_ITEM* aImage ) override;
155
156private:
163
164 mutable std::shared_ptr<const SHAPE_POLY_SET> m_outlineCache;
166 mutable uint64_t m_outlineCacheGeneration;
167 mutable std::mutex m_outlineCacheMutex;
168};
169
170
177void RefreshDrillMapOutlines( const BOARD& aBoard, KIGFX::VIEW* aView );
178
179#endif // PCB_DRILL_MAP_H
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
The base class for create windows for drawing purpose.
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool GetAllSpans() const
int GetOffsetX() const
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
std::shared_ptr< const SHAPE_POLY_SET > m_outlineCache
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void SetSpanChoice(int aIndex)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
VECTOR2I m_outlineCacheOffset
std::mutex m_outlineCacheMutex
int GetSymbolSize() const
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetOffsetY(int aY)
bool GetGuideCross() const
void SetGuideCross(bool aOn)
void SetSymbolSize(int aSize)
VECTOR2I GetPosition() const override
The map has no place of its own.
void swapData(BOARD_ITEM *aImage) override
uint64_t m_outlineCacheGeneration
bool GetOutlineSlots() const
void SetOutlineSlots(bool aOn)
void SetOffsetX(int aX)
bool operator==(const BOARD_ITEM &aOther) const override
VECTOR2I m_offset
int GetSymbolExtent() const
const DRILL_SPAN & GetSpan() const
void SetAllSpans(bool aAll)
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Configuration operations, deliberately not geometry transforms.
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
DRILL_SPAN m_span
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
wxString GetClass() const override
Return the class name.
std::shared_ptr< const SHAPE_POLY_SET > GetBoardOutlines() const
The board outline displaced by this map's offset.
const VECTOR2I & GetOffset() const
void SetOffset(const VECTOR2I &aOffset)
static bool ClassOf(const EDA_ITEM *aItem)
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
int GetOffsetY() const
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
PCB_DRILL_MAP(BOARD_ITEM *aParent)
void SetSpan(const DRILL_SPAN &aSpan)
void SetPosition(const VECTOR2I &aPos) override
int GetSpanChoice() const
The span as an index into the board's spans, with -1 for every span.
Hole classification and drill span, shared by the drill model and the drill writers.
FLIP_DIRECTION
Definition mirror.h:23
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
void RefreshDrillMapOutlines(const BOARD &aBoard, KIGFX::VIEW *aView)
Repaint every drill map after an Edge.Cuts edit.
@ PCB_DRILL_MAP_T
class PCB_DRILL_MAP, drill symbols drawn at the holes
Definition typeinfo.h:240
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683