Commit e4efe212 authored by Maciej Suminski's avatar Maciej Suminski

Added MODULE::RunOnChildren().

parent 32065b33
...@@ -200,46 +200,25 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const ...@@ -200,46 +200,25 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
KIGFX::VIEW* view = m_galCanvas->GetView(); KIGFX::VIEW* view = m_galCanvas->GetView();
view->Clear(); view->Clear();
// All of PCB drawing elements should be added to the VIEW // All the PCB drawable items should be added to the VIEW in order to be displayed
// in order to be displayed
// Load zones // Load zones
for( int i = 0; i < aBoard->GetAreaCount(); ++i ) for( int i = 0; i < aBoard->GetAreaCount(); ++i )
{
view->Add( (KIGFX::VIEW_ITEM*) ( aBoard->GetArea( i ) ) ); view->Add( (KIGFX::VIEW_ITEM*) ( aBoard->GetArea( i ) ) );
}
// Load drawings // Load drawings
for( BOARD_ITEM* drawing = aBoard->m_Drawings; drawing; drawing = drawing->Next() ) for( BOARD_ITEM* drawing = aBoard->m_Drawings; drawing; drawing = drawing->Next() )
{
view->Add( drawing ); view->Add( drawing );
}
// Load tracks // Load tracks
for( TRACK* track = aBoard->m_Track; track; track = track->Next() ) for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
{
view->Add( track ); view->Add( track );
}
// Load modules and its additional elements // Load modules and its additional elements
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{ {
// Load module's pads // Load items that belong to a module
for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() ) module->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Add ), view ) );
{
view->Add( pad );
}
// Load module's drawing (mostly silkscreen)
for( BOARD_ITEM* drawing = module->GraphicalItems().GetFirst(); drawing;
drawing = drawing->Next() )
{
view->Add( drawing );
}
// Load module's texts (name and value)
view->Add( &module->Reference() );
view->Add( &module->Value() );
// Add the module itself // Add the module itself
view->Add( module ); view->Add( module );
...@@ -247,9 +226,7 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const ...@@ -247,9 +226,7 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
// Segzones (equivalent of ZONE_CONTAINER for legacy boards) // Segzones (equivalent of ZONE_CONTAINER for legacy boards)
for( SEGZONE* zone = aBoard->m_Zone; zone; zone = zone->Next() ) for( SEGZONE* zone = aBoard->m_Zone; zone; zone = zone->Next() )
{
view->Add( zone ); view->Add( zone );
}
// Add an entry for the worksheet layout // Add an entry for the worksheet layout
KIGFX::WORKSHEET_VIEWITEM* worksheet = new KIGFX::WORKSHEET_VIEWITEM( KIGFX::WORKSHEET_VIEWITEM* worksheet = new KIGFX::WORKSHEET_VIEWITEM(
......
...@@ -728,6 +728,19 @@ EDA_ITEM* MODULE::Clone() const ...@@ -728,6 +728,19 @@ EDA_ITEM* MODULE::Clone() const
} }
void MODULE::RunOnChildren( boost::function<void (BOARD_ITEM*)> aFunction )
{
for( D_PAD* pad = m_Pads.GetFirst(); pad; pad = pad->Next() )
aFunction( static_cast<BOARD_ITEM*>( pad ) );
for( BOARD_ITEM* drawing = m_Drawings.GetFirst(); drawing; drawing = drawing->Next() )
aFunction( drawing );
aFunction( static_cast<BOARD_ITEM*>( m_Reference ) );
aFunction( static_cast<BOARD_ITEM*>( m_Value ) );
}
void MODULE::ViewUpdate( int aUpdateFlags ) void MODULE::ViewUpdate( int aUpdateFlags )
{ {
if( !m_view ) if( !m_view )
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <PolyLine.h> #include <PolyLine.h>
#include "zones.h" #include "zones.h"
#include <boost/function.hpp>
class LINE_READER; class LINE_READER;
class EDA_3D_CANVAS; class EDA_3D_CANVAS;
...@@ -447,6 +448,14 @@ public: ...@@ -447,6 +448,14 @@ public:
EDA_ITEM* Clone() const; EDA_ITEM* Clone() const;
/**
* Function RunOnChildren
*
* Invokes a function on all BOARD_ITEMs that belong to the module (pads, drawings, texts).
* @param aFunction is the function to be invoked.
*/
void RunOnChildren( boost::function<void (BOARD_ITEM*)> aFunction );
/// @copydoc VIEW_ITEM::ViewUpdate() /// @copydoc VIEW_ITEM::ViewUpdate()
void ViewUpdate( int aUpdateFlags ); void ViewUpdate( int aUpdateFlags );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment