KiCad PCB EDA Suite
KIGFX::VIEW::DRAW_ITEM_VISITOR Struct Reference

Public Member Functions

 DRAW_ITEM_VISITOR (VIEW *aView, int aLayer, bool aUseDrawPriority, bool aReverseDrawOrder)
 
bool operator() (VIEW_ITEM *aItem)
 
void deferredDraw ()
 

Public Attributes

VIEWview
 
int layer
 
int layers [VIEW_MAX_LAYERS]
 
bool useDrawPriority
 
bool reverseDrawOrder
 
std::vector< VIEW_ITEM * > drawItems
 

Detailed Description

Definition at line 938 of file view.cpp.

Constructor & Destructor Documentation

◆ DRAW_ITEM_VISITOR()

KIGFX::VIEW::DRAW_ITEM_VISITOR::DRAW_ITEM_VISITOR ( VIEW aView,
int  aLayer,
bool  aUseDrawPriority,
bool  aReverseDrawOrder 
)
inline

Definition at line 940 of file view.cpp.

940  :
941  view( aView ),
942  layer( aLayer ),
943  useDrawPriority( aUseDrawPriority ),
944  reverseDrawOrder( aReverseDrawOrder )
945  {
946  }

Member Function Documentation

◆ deferredDraw()

void KIGFX::VIEW::DRAW_ITEM_VISITOR::deferredDraw ( )
inline

Definition at line 966 of file view.cpp.

967  {
968  if( reverseDrawOrder )
969  std::sort( drawItems.begin(), drawItems.end(),
970  []( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool {
971  return b->viewPrivData()->m_drawPriority < a->viewPrivData()->m_drawPriority;
972  });
973  else
974  std::sort( drawItems.begin(), drawItems.end(),
975  []( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool {
976  return a->viewPrivData()->m_drawPriority < b->viewPrivData()->m_drawPriority;
977  });
978 
979  for( VIEW_ITEM* item : drawItems )
980  view->draw( item, layer );
981  }
friend class VIEW_ITEM
Definition: view.h:71
void draw(VIEW_ITEM *aItem, int aLayer, bool aImmediate=false)
Draw an item, but on a specified layers.
Definition: view.cpp:1023
std::vector< VIEW_ITEM * > drawItems
Definition: view.cpp:986

References KIGFX::VIEW::draw(), drawItems, layer, KIGFX::VIEW_ITEM_DATA::m_drawPriority, reverseDrawOrder, view, and KIGFX::VIEW_ITEM::viewPrivData().

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

◆ operator()()

bool KIGFX::VIEW::DRAW_ITEM_VISITOR::operator() ( VIEW_ITEM aItem)
inline

Definition at line 948 of file view.cpp.

949  {
950  wxCHECK( aItem->viewPrivData(), false );
951 
952  // Conditions that have to be fulfilled for an item to be drawn
953  bool drawCondition = aItem->viewPrivData()->isRenderable() &&
954  aItem->ViewGetLOD( layer, view ) < view->m_scale;
955  if( !drawCondition )
956  return true;
957 
958  if( useDrawPriority )
959  drawItems.push_back( aItem );
960  else
961  view->draw( aItem, layer );
962 
963  return true;
964  }
void draw(VIEW_ITEM *aItem, int aLayer, bool aImmediate=false)
Draw an item, but on a specified layers.
Definition: view.cpp:1023
double m_scale
View boundaries.
Definition: view.h:852
std::vector< VIEW_ITEM * > drawItems
Definition: view.cpp:986

References KIGFX::VIEW::draw(), drawItems, KIGFX::VIEW_ITEM_DATA::isRenderable(), layer, KIGFX::VIEW::m_scale, useDrawPriority, view, KIGFX::VIEW_ITEM::ViewGetLOD(), and KIGFX::VIEW_ITEM::viewPrivData().

Member Data Documentation

◆ drawItems

std::vector<VIEW_ITEM*> KIGFX::VIEW::DRAW_ITEM_VISITOR::drawItems

Definition at line 986 of file view.cpp.

Referenced by deferredDraw(), and operator()().

◆ layer

int KIGFX::VIEW::DRAW_ITEM_VISITOR::layer

Definition at line 984 of file view.cpp.

Referenced by deferredDraw(), and operator()().

◆ layers

int KIGFX::VIEW::DRAW_ITEM_VISITOR::layers[VIEW_MAX_LAYERS]

Definition at line 984 of file view.cpp.

◆ reverseDrawOrder

bool KIGFX::VIEW::DRAW_ITEM_VISITOR::reverseDrawOrder

Definition at line 985 of file view.cpp.

Referenced by deferredDraw().

◆ useDrawPriority

bool KIGFX::VIEW::DRAW_ITEM_VISITOR::useDrawPriority

Definition at line 985 of file view.cpp.

Referenced by operator()().

◆ view

VIEW* KIGFX::VIEW::DRAW_ITEM_VISITOR::view

Definition at line 983 of file view.cpp.

Referenced by deferredDraw(), and operator()().


The documentation for this struct was generated from the following file: