KiCad PCB EDA Suite
KIGFX::VIEW_OVERLAY Class Reference

#include <view_overlay.h>

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

Classes

struct  COMMAND
 
struct  COMMAND_ARC
 
struct  COMMAND_BITMAP_TEXT
 
struct  COMMAND_CIRCLE
 
struct  COMMAND_GLYPH_SIZE
 
struct  COMMAND_LINE
 
struct  COMMAND_POINT_POLYGON
 
struct  COMMAND_POLY_POLYGON
 
struct  COMMAND_POLYGON
 
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
 Return the bounding box of the item covering all its layers. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const override
 Draw the parts of the object belonging to layer aLayer. More...
 
virtual void ViewGetLayers (int aLayers[], int &aCount) const override
 Return 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, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle)
 
void Rectangle (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 
void Cross (const VECTOR2D &aP, int aSize)
 
void Polygon (const std::deque< VECTOR2D > &aPointList)
 
void Polygon (const SHAPE_POLY_SET &aPolySet)
 
void Polyline (const SHAPE_LINE_CHAIN &aPolyLine)
 
void Polygon (const VECTOR2D aPointList[], int aListSize)
 
void BitmapText (const wxString &aText, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle)
 
void SetIsFill (bool aIsFillEnabled)
 
void SetIsStroke (bool aIsStrokeEnabled)
 
void SetFillColor (const COLOR4D &aColor)
 
void SetStrokeColor (const COLOR4D &aColor)
 
void SetGlyphSize (const VECTOR2I &aSize)
 
void SetLineWidth (double aLineWidth)
 
const COLOR4DGetStrokeColor () const
 
const COLOR4DGetFillColor () const
 
virtual double ViewGetLOD (int aLayer, VIEW *aView) const
 Return 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) const
 
template<typename T >
Get (PROPERTY_BASE *aProperty) const
 
template<typename T >
std::optional< T > Get (const wxString &aProperty) const
 

Private Member Functions

void releaseCommands ()
 

Private Attributes

COLOR4D m_strokeColor
 
COLOR4D m_fillColor
 
std::vector< COMMAND * > m_commands
 
VIEW_ITEM_DATAm_viewPrivData
 

Detailed Description

Definition at line 44 of file view_overlay.h.

Constructor & Destructor Documentation

◆ VIEW_OVERLAY()

KIGFX::VIEW_OVERLAY::VIEW_OVERLAY ( )

Definition at line 265 of file view_overlay.cpp.

266{
267}

◆ ~VIEW_OVERLAY()

KIGFX::VIEW_OVERLAY::~VIEW_OVERLAY ( )
virtual

Definition at line 270 of file view_overlay.cpp.

271{
273}

References releaseCommands().

Member Function Documentation

◆ Arc()

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

Definition at line 373 of file view_overlay.cpp.

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

References m_commands.

Referenced by PNS_LOG_VIEWER_OVERLAY::Arc().

◆ BitmapText()

void KIGFX::VIEW_OVERLAY::BitmapText ( const wxString &  aText,
const VECTOR2I aPosition,
const EDA_ANGLE aAngle 
)

Definition at line 398 of file view_overlay.cpp.

400{
401 m_commands.push_back( new COMMAND_BITMAP_TEXT( aText, aPosition, aAngle ) );
402}

References m_commands.

Referenced by LABEL_MANAGER::Redraw().

◆ Circle()

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

Definition at line 367 of file view_overlay.cpp.

368{
369 m_commands.push_back( new COMMAND_CIRCLE( aCenterPoint, aRadius ) );
370}

References m_commands.

◆ Clear()

void KIGFX::VIEW_OVERLAY::Clear ( )

Definition at line 285 of file view_overlay.cpp.

286{
288}

References releaseCommands().

◆ ClearViewPrivData()

void KIGFX::VIEW_ITEM::ClearViewPrivData ( )
inlineinherited

Definition at line 143 of file view_item.h.

144 {
145 m_viewPrivData = nullptr;
146 }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:151

References KIGFX::VIEW_ITEM::m_viewPrivData.

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

◆ Cross()

void KIGFX::VIEW_OVERLAY::Cross ( const VECTOR2D aP,
int  aSize 
)

Definition at line 429 of file view_overlay.cpp.

430{
431 Line( aP + VECTOR2D( -aSize, -aSize ), aP + VECTOR2D( aSize, aSize ) );
432 Line( aP + VECTOR2D( aSize, -aSize ), aP + VECTOR2D( -aSize, aSize ) );
433}
void Line(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589

References Line().

◆ Get() [1/3]

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

Definition at line 104 of file inspectable.h.

105 {
107 TYPE_ID thisType = TYPE_HASH( *this );
108 PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
109 std::optional<T> ret;
110
111 if( prop )
112 {
113 const void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
114
115 if( object )
116 ret = prop->get<T>( object );
117 }
118
119 return ret;
120 }
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.
T get(const void *aObject) const
Definition: property.h:352
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:74
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:76
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
#define TYPE_HASH(x)
Definition: property.h:63
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:46

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

◆ Get() [2/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty) const
inlineinherited

Definition at line 84 of file inspectable.h.

85 {
87 const void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
88 return object ? aProperty->getter( object ) : wxAny();
89 }
virtual wxAny getter(const void *aObject) const =0

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

Referenced by BOOST_AUTO_TEST_CASE(), CLASS_D_DESC::CLASS_D_DESC(), EDA_SHAPE_DESC::EDA_SHAPE_DESC(), PROPERTIES_PANEL::getItemValue(), PCB_EXPR_VAR_REF::GetValue(), and PAD_DESC::PAD_DESC().

◆ Get() [3/3]

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

Definition at line 92 of file inspectable.h.

93 {
95 const void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
96
97 if( !object )
98 throw std::runtime_error( "Could not cast INSPECTABLE to the requested type" );
99
100 return aProperty->get<T>( object );
101 }

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

◆ GetFillColor()

const COLOR4D & KIGFX::VIEW_OVERLAY::GetFillColor ( ) const
inline

Definition at line 105 of file view_overlay.h.

105{ return m_fillColor; }

References m_fillColor.

◆ GetStrokeColor()

const COLOR4D & KIGFX::VIEW_OVERLAY::GetStrokeColor ( ) const
inline

◆ Line() [1/2]

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

Definition at line 326 of file view_overlay.cpp.

327{
328 Line( aSeg.A, aSeg.B );
329}
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50

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

◆ Line() [2/2]

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

Definition at line 320 of file view_overlay.cpp.

321{
322 m_commands.push_back( new COMMAND_LINE( aStartPoint, aEndPoint ) );
323}

References m_commands.

Referenced by PNS_LOG_VIEWER_OVERLAY::AnnotatedPoint(), Cross(), Line(), Polyline(), LABEL_MANAGER::Redraw(), and Segment().

◆ Polygon() [1/3]

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

Definition at line 349 of file view_overlay.cpp.

350{
351 m_commands.push_back( new COMMAND_POLY_POLYGON( aPolySet ) );
352}

References m_commands.

◆ Polygon() [2/3]

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

Definition at line 355 of file view_overlay.cpp.

356{
357 m_commands.push_back( new COMMAND_POLYGON( aPointList ) );
358}

References m_commands.

◆ Polygon() [3/3]

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

Definition at line 361 of file view_overlay.cpp.

362{
363 m_commands.push_back( new COMMAND_POINT_POLYGON( aPointList, aListSize ) );
364}

References m_commands.

◆ Polyline()

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

Definition at line 339 of file view_overlay.cpp.

340{
341 SetIsStroke( true );
342 SetIsFill( false );
343
344 for( int i = 0; i < aPolyLine.SegmentCount(); i++ )
345 Line( aPolyLine.CSegment( i ) );
346}
void SetIsFill(bool aIsFillEnabled)
void SetIsStroke(bool aIsStrokeEnabled)
int SegmentCount() const
Return the number of segments in this line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.

References SHAPE_LINE_CHAIN::CSegment(), Line(), SHAPE_LINE_CHAIN::SegmentCount(), SetIsFill(), and SetIsStroke().

Referenced by PNS_LOG_VIEWER_OVERLAY::AnnotatedPolyline().

◆ Rectangle()

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

Definition at line 380 of file view_overlay.cpp.

381{
382 m_commands.push_back( new COMMAND_RECTANGLE( aStartPoint, aEndPoint ) );
383}

References m_commands.

Referenced by LABEL_MANAGER::Redraw().

◆ releaseCommands()

void KIGFX::VIEW_OVERLAY::releaseCommands ( )
private

Definition at line 276 of file view_overlay.cpp.

277{
278 for( VIEW_OVERLAY::COMMAND* cmd : m_commands )
279 delete cmd;
280
281 m_commands.clear();
282}

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 332 of file view_overlay.cpp.

333{
334 SetLineWidth( aWidth );
335 Line( aStartPoint, aEndPoint );
336}
void SetLineWidth(double aLineWidth)

References Line(), and SetLineWidth().

◆ Set() [1/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 }
void set(void *aObject, T aValue)
Definition: property.h:325

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

◆ Set() [2/3]

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

Definition at line 54 of file inspectable.h.

55 {
57 void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
58
59 if( object )
60 aProperty->set<T>( object, aValue );
61
62 return object != nullptr;
63 }

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

◆ Set() [3/3]

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

Definition at line 42 of file inspectable.h.

43 {
45 void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
46
47 if( object )
48 aProperty->setter( object, aValue );
49
50 return object != nullptr;
51 }
virtual void setter(void *aObject, wxAny &aValue)=0

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

Referenced by PCB_PROPERTIES_PANEL::valueChanged().

◆ SetFillColor()

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

Definition at line 411 of file view_overlay.cpp.

412{
413 m_fillColor = aColor;
414 m_commands.push_back( new COMMAND_SET_COLOR( false, aColor ) );
415}

References m_commands, and m_fillColor.

◆ SetGlyphSize()

void KIGFX::VIEW_OVERLAY::SetGlyphSize ( const VECTOR2I aSize)

Definition at line 392 of file view_overlay.cpp.

393{
394 m_commands.push_back( new COMMAND_GLYPH_SIZE( aSize ) );
395}

References m_commands.

◆ SetIsFill()

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

Definition at line 386 of file view_overlay.cpp.

387{
388 m_commands.push_back( new COMMAND_SET_FILL( aIsFillEnabled ) );
389}

References m_commands.

Referenced by Polyline(), and LABEL_MANAGER::Redraw().

◆ SetIsStroke()

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

Definition at line 405 of file view_overlay.cpp.

406{
407 m_commands.push_back( new COMMAND_SET_STROKE( aIsStrokeEnabled ) );
408}

References m_commands.

Referenced by Polyline(), and LABEL_MANAGER::Redraw().

◆ SetLineWidth()

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

Definition at line 424 of file view_overlay.cpp.

425{
426 m_commands.push_back( new COMMAND_SET_WIDTH( aLineWidth ) );
427}

References m_commands.

Referenced by PNS_LOG_VIEWER_OVERLAY::Arc(), LABEL_MANAGER::Redraw(), and Segment().

◆ SetStrokeColor()

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

Definition at line 418 of file view_overlay.cpp.

419{
420 m_strokeColor = aColor;
421 m_commands.push_back( new COMMAND_SET_COLOR( true, aColor ) );
422}

References m_commands, and m_strokeColor.

Referenced by PNS_LOG_VIEWER_OVERLAY::Arc(), and LABEL_MANAGER::Redraw().

◆ ViewBBox()

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

Return the bounding box of the item covering all its layers.

Returns
the current bounding box.

Implements KIGFX::VIEW_ITEM.

Definition at line 291 of file view_overlay.cpp.

292{
293 BOX2I maxBox;
294
295 maxBox.SetMaximum();
296 return maxBox;
297}
void SetMaximum()
Definition: box2.h:63

References BOX2< Vec >::SetMaximum().

◆ ViewDraw()

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

Draw the parts of the object belonging to layer aLayer.

An alternative way for drawing objects 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
aLayeris the current drawing layer.
aViewis a pointer to the VIEW device we are drawing on.

Reimplemented from KIGFX::VIEW_ITEM.

Definition at line 300 of file view_overlay.cpp.

301{
302 auto gal = aView->GetGAL();
303 gal->PushDepth();
304 gal->SetLayerDepth( gal->GetMinDepth() );
305
306 for( const VIEW_OVERLAY::COMMAND* cmd : m_commands )
307 cmd->Execute( aView );
308
309 gal->PopDepth();
310}

References KIGFX::VIEW::GetGAL(), m_commands, and KIGFX::GAL::PushDepth().

◆ ViewGetLayers()

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

Return the all the layers within the VIEW the object is painted on.

For instance, a 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[]is the output layer index array.
aCountis the number of layer indices in aLayers[].

Implements KIGFX::VIEW_ITEM.

Definition at line 313 of file view_overlay.cpp.

314{
315 aLayers[0] = LAYER_GP_OVERLAY;
316 aCount = 1;
317}
@ LAYER_GP_OVERLAY
general purpose overlay
Definition: layer_ids.h:218

References LAYER_GP_OVERLAY.

◆ ViewGetLOD()

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

Return 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
aLayeris the current drawing layer.
aViewis a pointer 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 SCH_LINE, GERBER_DRAW_ITEM, PCB_GROUP, FOOTPRINT, FP_SHAPE, FP_TEXT, FP_TEXTBOX, PAD, PCB_BITMAP, PCB_SHAPE, PCB_TEXT, PCB_TEXTBOX, PCB_TRACK, PCB_VIA, ZONE, and FP_ZONE.

Definition at line 132 of file view_item.h.

133 {
134 // By default always show the item
135 return 0.0;
136 }

Referenced by PNS_KICAD_IFACE::IsItemVisible(), KIGFX::VIEW::DRAW_ITEM_VISITOR::operator()(), EE_GRID_HELPER::queryVisible(), and PCB_GRID_HELPER::queryVisible().

◆ viewPrivData()

Member Data Documentation

◆ m_commands

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

◆ m_fillColor

COLOR4D KIGFX::VIEW_OVERLAY::m_fillColor
private

Definition at line 111 of file view_overlay.h.

Referenced by GetFillColor(), and SetFillColor().

◆ m_strokeColor

COLOR4D KIGFX::VIEW_OVERLAY::m_strokeColor
private

Definition at line 110 of file view_overlay.h.

Referenced by GetStrokeColor(), and SetStrokeColor().

◆ m_viewPrivData

VIEW_ITEM_DATA* KIGFX::VIEW_ITEM::m_viewPrivData
privateinherited

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