KiCad PCB EDA Suite
KIGFX::VIEW_OVERLAY Class Reference

#include <view_overlay.h>

Inheritance diagram for KIGFX::VIEW_OVERLAY:
KIGFX::VIEW_ITEM INSPECTABLE

Classes

struct  COMMAND
 
struct  COMMAND_ARC
 
struct  COMMAND_CIRCLE
 
struct  COMMAND_LINE
 
struct  COMMAND_POINT_POLYGON
 
struct  COMMAND_POINT_POLYLINE
 
struct  COMMAND_POLY_POLYGON
 
struct  COMMAND_POLY_POLYLINE
 
struct  COMMAND_POLYGON
 
struct  COMMAND_POLYLINE
 
struct  COMMAND_RECTANGLE
 
struct  COMMAND_SET_COLOR
 
struct  COMMAND_SET_FILL
 
struct  COMMAND_SET_STROKE
 
struct  COMMAND_SET_WIDTH
 

Public Member Functions

 VIEW_OVERLAY ()
 
virtual ~VIEW_OVERLAY ()
 
void Clear ()
 
virtual const BOX2I ViewBBox () const override
 Function ViewBBox() returns the bounding box of the item covering all its layers. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const override
 Function ViewDraw() Draws the parts of the object belonging to layer aLayer. More...
 
virtual void ViewGetLayers (int aLayers[], int &aCount) const override
 Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on. More...
 
void Line (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 
void Line (const SEG &aSeg)
 
void Segment (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
 
void Circle (const VECTOR2D &aCenterPoint, double aRadius)
 
void Arc (const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
 
void Rectangle (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 
void Polyline (std::deque< VECTOR2D > &aPointList)
 
void Polyline (const VECTOR2D aPointList[], int aListSize)
 
void Polyline (const SHAPE_LINE_CHAIN &aLineChain)
 
void Polygon (const std::deque< VECTOR2D > &aPointList)
 
void Polygon (const SHAPE_POLY_SET &aPolySet)
 
void Polygon (const VECTOR2D aPointList[], int aListSize)
 
void SetIsFill (bool aIsFillEnabled)
 
void SetIsStroke (bool aIsStrokeEnabled)
 
void SetFillColor (const COLOR4D &aColor)
 
void SetStrokeColor (const COLOR4D &aColor)
 
void SetLineWidth (double aLineWidth)
 
virtual unsigned int ViewGetLOD (int aLayer, VIEW *aView) const
 Function ViewGetLOD() Returns the level of detail (LOD) of the item. More...
 
VIEW_ITEM_DATAviewPrivData () const
 
void ClearViewPrivData ()
 
bool Set (PROPERTY_BASE *aProperty, wxAny &aValue)
 
template<typename T >
bool Set (PROPERTY_BASE *aProperty, T aValue)
 
template<typename T >
bool Set (const wxString &aProperty, T aValue)
 
wxAny Get (PROPERTY_BASE *aProperty)
 
template<typename T >
Get (PROPERTY_BASE *aProperty)
 
template<typename T >
boost::optional< T > Get (const wxString &aProperty)
 

Private Member Functions

void releaseCommands ()
 

Private Attributes

std::vector< COMMAND * > m_commands
 

Detailed Description

Definition at line 43 of file view_overlay.h.

Constructor & Destructor Documentation

◆ VIEW_OVERLAY()

KIGFX::VIEW_OVERLAY::VIEW_OVERLAY ( )

Definition at line 268 of file view_overlay.cpp.

269 {
270 }

◆ ~VIEW_OVERLAY()

KIGFX::VIEW_OVERLAY::~VIEW_OVERLAY ( )
virtual

Definition at line 273 of file view_overlay.cpp.

274 {
275  releaseCommands();
276 }

References releaseCommands().

Member Function Documentation

◆ Arc()

void KIGFX::VIEW_OVERLAY::Arc ( const VECTOR2D aCenterPoint,
double  aRadius,
double  aStartAngle,
double  aEndAngle 
)

Definition at line 375 of file view_overlay.cpp.

377 {
378  m_commands.push_back( new COMMAND_ARC( aCenterPoint, aRadius, aStartAngle, aEndAngle ) );
379 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

◆ Circle()

void KIGFX::VIEW_OVERLAY::Circle ( const VECTOR2D aCenterPoint,
double  aRadius 
)

Definition at line 369 of file view_overlay.cpp.

370 {
371  m_commands.push_back( new COMMAND_CIRCLE( aCenterPoint, aRadius ) );
372 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

◆ Clear()

void KIGFX::VIEW_OVERLAY::Clear ( )

Definition at line 288 of file view_overlay.cpp.

289 {
290  releaseCommands();
291 }

References releaseCommands().

◆ ClearViewPrivData()

void KIGFX::VIEW_ITEM::ClearViewPrivData ( )
inlineinherited

Definition at line 154 of file view_item.h.

155  {
157  }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:162
#define NULL

References KIGFX::VIEW_ITEM::m_viewPrivData, and NULL.

Referenced by KIGFX::VIEW::OnDestroy().

◆ Get() [1/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 84 of file inspectable.h.

85  {
87  TYPE_ID thisType = TYPE_HASH( *this );
88  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
89  return object ? aProperty->getter( object ) : wxAny();
90  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
virtual wxAny getter(void *aObject) const =0
Provides class metadata.
Definition: property_mgr.h:58
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_BASE::getter(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

Referenced by CLASS_D_DESC::CLASS_D_DESC(), PCB_EXPR_VAR_REF::GetValue(), and PAD_DESC::PAD_DESC().

◆ Get() [2/3]

template<typename T >
T INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 93 of file inspectable.h.

94  {
96  TYPE_ID thisType = TYPE_HASH( *this );
97  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
98  return object ? aProperty->get<T>( object ) : T();
99  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
T
enum T contains all this lexer's tokens.
Provides class metadata.
Definition: property_mgr.h:58
T get(void *aObject)
Definition: property.h:273
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_BASE::get(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Get() [3/3]

template<typename T >
boost::optional<T> INSPECTABLE::Get ( const wxString &  aProperty)
inlineinherited

Definition at line 102 of file inspectable.h.

103  {
105  TYPE_ID thisType = TYPE_HASH( *this );
106  PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
107  boost::optional<T> ret;
108 
109  if( prop )
110  {
111  void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
112 
113  if( object )
114  ret = prop->get<T>( object );
115  }
116 
117  return ret;
118  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
T
enum T contains all this lexer's tokens.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Returns a property for a specific type.
Provides class metadata.
Definition: property_mgr.h:58
T get(void *aObject)
Definition: property.h:273
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_BASE::get(), PROPERTY_MANAGER::GetProperty(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Line() [1/2]

void KIGFX::VIEW_OVERLAY::Line ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint 
)

Definition at line 317 of file view_overlay.cpp.

318 {
319  m_commands.push_back( new COMMAND_LINE( aStartPoint, aEndPoint ) );
320 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

Referenced by Line(), and Segment().

◆ Line() [2/2]

void KIGFX::VIEW_OVERLAY::Line ( const SEG aSeg)

Definition at line 323 of file view_overlay.cpp.

324 {
325  Line( aSeg.A, aSeg.B );
326 }
void Line(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
VECTOR2I A
Definition: seg.h:47
VECTOR2I B
Definition: seg.h:48

References SEG::A, SEG::B, and Line().

◆ Polygon() [1/3]

void KIGFX::VIEW_OVERLAY::Polygon ( const std::deque< VECTOR2D > &  aPointList)

Definition at line 357 of file view_overlay.cpp.

358 {
359  m_commands.push_back( new COMMAND_POLYGON( aPointList ) );
360 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

◆ Polygon() [2/3]

void KIGFX::VIEW_OVERLAY::Polygon ( const SHAPE_POLY_SET aPolySet)

Definition at line 351 of file view_overlay.cpp.

352 {
353  m_commands.push_back( new COMMAND_POLY_POLYGON( aPolySet ) );
354 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

◆ Polygon() [3/3]

void KIGFX::VIEW_OVERLAY::Polygon ( const VECTOR2D  aPointList[],
int  aListSize 
)

Definition at line 363 of file view_overlay.cpp.

364 {
365  m_commands.push_back( new COMMAND_POINT_POLYGON( aPointList, aListSize ) );
366 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

◆ Polyline() [1/3]

void KIGFX::VIEW_OVERLAY::Polyline ( std::deque< VECTOR2D > &  aPointList)

Definition at line 336 of file view_overlay.cpp.

337 {
338 }

◆ Polyline() [2/3]

void KIGFX::VIEW_OVERLAY::Polyline ( const VECTOR2D  aPointList[],
int  aListSize 
)

Definition at line 341 of file view_overlay.cpp.

342 {
343 }

◆ Polyline() [3/3]

void KIGFX::VIEW_OVERLAY::Polyline ( const SHAPE_LINE_CHAIN aLineChain)

Definition at line 346 of file view_overlay.cpp.

347 {
348 }

◆ Rectangle()

void KIGFX::VIEW_OVERLAY::Rectangle ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint 
)

Definition at line 382 of file view_overlay.cpp.

383 {
384  m_commands.push_back( new COMMAND_RECTANGLE( aStartPoint, aEndPoint ) );
385 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

◆ releaseCommands()

void KIGFX::VIEW_OVERLAY::releaseCommands ( )
private

Definition at line 279 of file view_overlay.cpp.

280 {
281  for( auto cmd : m_commands )
282  delete cmd;
283 
284  m_commands.clear();
285 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

Referenced by Clear(), and ~VIEW_OVERLAY().

◆ Segment()

void KIGFX::VIEW_OVERLAY::Segment ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint,
double  aWidth 
)

Definition at line 329 of file view_overlay.cpp.

330 {
331  SetLineWidth( aWidth );
332  Line( aStartPoint, aEndPoint );
333 }
void Line(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
void SetLineWidth(double aLineWidth)

References Line(), and SetLineWidth().

◆ Set() [1/3]

bool INSPECTABLE::Set ( PROPERTY_BASE aProperty,
wxAny &  aValue 
)
inlineinherited

Definition at line 40 of file inspectable.h.

41  {
43  TYPE_ID thisType = TYPE_HASH( *this );
44  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
45 
46  if( object )
47  aProperty->setter( object, aValue );
48 
49  return object != nullptr;
50  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
virtual void setter(void *aObject, wxAny &aValue)=0
Provides class metadata.
Definition: property_mgr.h:58
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::setter(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Set() [2/3]

template<typename T >
bool INSPECTABLE::Set ( PROPERTY_BASE aProperty,
aValue 
)
inlineinherited

Definition at line 53 of file inspectable.h.

54  {
56  TYPE_ID thisType = TYPE_HASH( *this );
57  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
58 
59  if( object )
60  aProperty->set<T>( object, aValue );
61 
62  return object != nullptr;
63  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
T
enum T contains all this lexer's tokens.
Provides class metadata.
Definition: property_mgr.h:58
void set(void *aObject, T aValue)
Definition: property.h:266
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::set(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Set() [3/3]

template<typename T >
bool INSPECTABLE::Set ( const wxString &  aProperty,
aValue 
)
inlineinherited

Definition at line 66 of file inspectable.h.

67  {
69  TYPE_ID thisType = TYPE_HASH( *this );
70  PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
71  void* object = nullptr;
72 
73  if( prop )
74  {
75  object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
76 
77  if( object )
78  prop->set<T>( object, aValue );
79  }
80 
81  return object != nullptr;
82  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
T
enum T contains all this lexer's tokens.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Returns a property for a specific type.
Provides class metadata.
Definition: property_mgr.h:58
void set(void *aObject, T aValue)
Definition: property.h:266
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

References PROPERTY_MANAGER::GetProperty(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::set(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ SetFillColor()

void KIGFX::VIEW_OVERLAY::SetFillColor ( const COLOR4D aColor)

Definition at line 400 of file view_overlay.cpp.

401 {
402  m_commands.push_back( new COMMAND_SET_COLOR( false, aColor ) );
403 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

◆ SetIsFill()

void KIGFX::VIEW_OVERLAY::SetIsFill ( bool  aIsFillEnabled)

Definition at line 388 of file view_overlay.cpp.

389 {
390  m_commands.push_back( new COMMAND_SET_FILL( aIsFillEnabled ) );
391 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

◆ SetIsStroke()

void KIGFX::VIEW_OVERLAY::SetIsStroke ( bool  aIsStrokeEnabled)

Definition at line 394 of file view_overlay.cpp.

395 {
396  m_commands.push_back( new COMMAND_SET_STROKE( aIsStrokeEnabled ) );
397 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

◆ SetLineWidth()

void KIGFX::VIEW_OVERLAY::SetLineWidth ( double  aLineWidth)

Definition at line 411 of file view_overlay.cpp.

412 {
413  m_commands.push_back( new COMMAND_SET_WIDTH( aLineWidth ) );
414 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

Referenced by Segment().

◆ SetStrokeColor()

void KIGFX::VIEW_OVERLAY::SetStrokeColor ( const COLOR4D aColor)

Definition at line 406 of file view_overlay.cpp.

407 {
408  m_commands.push_back( new COMMAND_SET_COLOR( true, aColor ) );
409 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

◆ ViewBBox()

const BOX2I KIGFX::VIEW_OVERLAY::ViewBBox ( ) const
overridevirtual

Function ViewBBox() returns the bounding box of the item covering all its layers.

Returns
BOX2I - the current bounding box

Implements KIGFX::VIEW_ITEM.

Definition at line 294 of file view_overlay.cpp.

295 {
296  BOX2I maxBox;
297 
298  maxBox.SetMaximum();
299  return maxBox;
300 }
void SetMaximum()
Definition: box2.h:73

References BOX2< Vec >::SetMaximum().

◆ ViewDraw()

void KIGFX::VIEW_OVERLAY::ViewDraw ( int  aLayer,
VIEW aView 
) const
overridevirtual

Function ViewDraw() Draws the parts of the object belonging to layer aLayer.

viewDraw() is an alternative way for drawing objects if if there is no PAINTER assigned for the view or if the PAINTER doesn't know how to paint this particular implementation of VIEW_ITEM. The preferred way of drawing is to design an appropriate PAINTER object, the method below is intended only for quick hacks and debugging purposes.

Parameters
aLayercurrent drawing layer
aViewpointer to the VIEW device we are drawing on

Reimplemented from KIGFX::VIEW_ITEM.

Definition at line 303 of file view_overlay.cpp.

304 {
305  for( const auto& cmd : m_commands )
306  cmd->Execute( aView );
307 }
std::vector< COMMAND * > m_commands
Definition: view_overlay.h:104

References m_commands.

◆ ViewGetLayers()

void KIGFX::VIEW_OVERLAY::ViewGetLayers ( int  aLayers[],
int &  aCount 
) const
overridevirtual

Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.

For instance, a D_PAD spans zero or more copper layers and a few technical layers. ViewDraw() or PAINTER::Draw() is repeatedly called for each of the layers returned by ViewGetLayers(), depending on the rendering order.

Parameters
aLayers[]output layer index array
aCountnumber of layer indices in aLayers[]

Implements KIGFX::VIEW_ITEM.

Definition at line 310 of file view_overlay.cpp.

311 {
312  aLayers[0] = LAYER_GP_OVERLAY;
313  aCount = 1;
314 }

References LAYER_GP_OVERLAY.

◆ ViewGetLOD()

virtual unsigned int KIGFX::VIEW_ITEM::ViewGetLOD ( int  aLayer,
VIEW aView 
) const
inlinevirtualinherited

Function ViewGetLOD() Returns the level of detail (LOD) of the item.

A level of detail is the minimal VIEW scale that is sufficient for an item to be shown on a given layer.

Parameters
aLayercurrent drawing layer
aViewpointer to the VIEW device we are drawing on
Returns
the level of detail. 0 always show the item, because the actual zoom level (or VIEW scale) is always > 0

Reimplemented in MODULE_ZONE_CONTAINER, MODULE, D_PAD, VIA, GERBER_DRAW_ITEM, TEXTE_MODULE, TRACK, and EDGE_MODULE.

Definition at line 141 of file view_item.h.

142  {
143  // By default always show the item
144  return 0;
145  }

Referenced by KIGFX::VIEW::drawItem::operator()(), GRID_HELPER::queryVisible(), and SELECTION_TOOL::Selectable().

◆ viewPrivData()

Member Data Documentation

◆ m_commands

std::vector<COMMAND*> KIGFX::VIEW_OVERLAY::m_commands
private

The documentation for this class was generated from the following files: