KiCad PCB EDA Suite
pcb_marker.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-2018 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 1992-2018 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 
25 #ifndef PCB_MARKER_H
26 #define PCB_MARKER_H
27 
28 
29 #include <board_item.h>
30 #include <drc/drc_item.h>
31 #include <marker_base.h>
32 
33 class DRC_ITEM;
34 
35 // Coordinates count for the basic shape marker
36 #define MARKER_SHAPE_POINT_COUNT 9
37 
38 class MSG_PANEL_ITEM;
39 
40 
41 class PCB_MARKER : public BOARD_ITEM, public MARKER_BASE
42 {
43 public:
44  PCB_MARKER( std::shared_ptr<RC_ITEM> aItem, const wxPoint& aPosition );
45  ~PCB_MARKER();
46 
47  static inline bool ClassOf( const EDA_ITEM* aItem )
48  {
49  return aItem && PCB_MARKER_T == aItem->Type();
50  }
51 
52  const KIID GetUUID() const override { return m_Uuid; }
53 
54  wxString Serialize() const;
55 
56  static PCB_MARKER* Deserialize( const wxString& data );
57 
58  void Move(const wxPoint& aMoveVector) override
59  {
60  m_Pos += aMoveVector;
61  }
62 
63  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
64 
65  void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
66 
67  wxPoint GetPosition() const override { return m_Pos; }
68  void SetPosition( const wxPoint& aPos ) override { m_Pos = aPos; }
69 
70  wxPoint GetCenter() const override
71  {
72  return GetPosition();
73  }
74 
75  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override
76  {
77  return HitTestMarker( aPosition, aAccuracy );
78  }
79 
81 
82  std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer ) const override;
83 
84  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
85 
86  bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
87  {
88  return BOARD_ITEM::Matches( m_rcItem->GetErrorMessage(), aSearchData );
89  }
90 
91  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
92 
93  BITMAP_DEF GetMenuImage() const override;
94 
95  const BOX2I ViewBBox() const override;
96 
97  const EDA_RECT GetBoundingBox() const override;
98 
99  void ViewGetLayers( int aLayers[], int& aCount ) const override;
100 
101 #if defined(DEBUG)
102  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
103 #endif
104 
108  virtual wxString GetClass() const override
109  {
110  return wxT( "PCB_MARKER" );
111  }
112 
113 protected:
114  KIGFX::COLOR4D getColor() const override;
115 };
116 
117 #endif // PCB_MARKER_H
KIGFX::COLOR4D getColor() const override
Definition: pcb_marker.cpp:200
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:414
PNG memory record (file in memory).
Definition: bitmap_def.h:29
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pcb_marker.cpp:220
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: pcb_marker.h:58
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: pcb_marker.cpp:117
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_marker.h:70
wxPoint m_Pos
position of the marker
Definition: marker_base.h:123
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
wxString Serialize() const
Definition: pcb_marker.cpp:63
The base class for create windows for drawing purpose.
virtual wxString GetClass() const override
Get class name.
Definition: pcb_marker.h:108
bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: pcb_marker.h:86
Definition: kiid.h:44
bool HitTestMarker(const wxPoint &aHitPosition, int aAccuracy) const
Test if the given wxPoint is within the bounds of this object.
Definition: marker_base.cpp:90
PCB_LAYER_ID
A quick note on layer IDs:
const KIID GetUUID() const override
Definition: pcb_marker.h:52
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: pcb_marker.cpp:151
std::shared_ptr< RC_ITEM > m_rcItem
Definition: marker_base.h:128
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcb_marker.cpp:129
static PCB_MARKER * Deserialize(const wxString &data)
Definition: pcb_marker.cpp:74
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pcb_marker.h:47
GAL_LAYER_ID GetColorLayer() const
Definition: pcb_marker.cpp:179
const KIID m_Uuid
Definition: eda_item.h:524
BITMAP_DEF GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_marker.cpp:145
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: pcb_marker.cpp:137
EDA_UNITS
Definition: eda_units.h:38
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_marker.cpp:123
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:98
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: pcb_marker.h:75
PCB_MARKER(std::shared_ptr< RC_ITEM > aItem, const wxPoint &aPosition)
Definition: pcb_marker.cpp:46
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_marker.cpp:207
Handle the component boundary box.
Definition: eda_rect.h:42
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:54
void SetPosition(const wxPoint &aPos) override
Definition: pcb_marker.h:68
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.
Definition: pcb_marker.cpp:91
wxPoint GetPosition() const override
Definition: pcb_marker.h:67
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98