refactoring: implemented BOARD-specific view Add()/Remove()/Update() methods in PCB_VIEW, moved to libpcbcommon
This commit is contained in:
parent
0245912c34
commit
c9817df9db
|
@ -411,6 +411,9 @@ set( PCB_COMMON_SRCS
|
||||||
../pcbnew/gpcb_plugin.cpp
|
../pcbnew/gpcb_plugin.cpp
|
||||||
../pcbnew/pcb_netlist.cpp
|
../pcbnew/pcb_netlist.cpp
|
||||||
../pcbnew/pcb_display_options.cpp
|
../pcbnew/pcb_display_options.cpp
|
||||||
|
../pcbnew/pcb_draw_panel_gal.cpp
|
||||||
|
../pcbnew/pcb_view.cpp
|
||||||
|
../pcbnew/pcb_painter.cpp
|
||||||
widgets/widget_net_selector.cpp
|
widgets/widget_net_selector.cpp
|
||||||
pcb_plot_params_keywords.cpp
|
pcb_plot_params_keywords.cpp
|
||||||
pcb_keywords.cpp
|
pcb_keywords.cpp
|
||||||
|
|
|
@ -252,7 +252,7 @@ void VIEW::OnDestroy( VIEW_ITEM* aItem )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( data->m_view )
|
if( data->m_view )
|
||||||
data->m_view->Remove( aItem );
|
data->m_view->VIEW::Remove( aItem );
|
||||||
|
|
||||||
delete data;
|
delete data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,8 +260,8 @@ set( PCBNEW_CLASS_SRCS
|
||||||
pad_edition_functions.cpp
|
pad_edition_functions.cpp
|
||||||
pcbnew_config.cpp
|
pcbnew_config.cpp
|
||||||
pcbplot.cpp
|
pcbplot.cpp
|
||||||
pcb_draw_panel_gal.cpp
|
# pcb_draw_panel_gal.cpp
|
||||||
pcb_view.cpp
|
# pcb_view.cpp
|
||||||
plot_board_layers.cpp
|
plot_board_layers.cpp
|
||||||
plot_brditems_plotter.cpp
|
plot_brditems_plotter.cpp
|
||||||
print_board_functions.cpp
|
print_board_functions.cpp
|
||||||
|
|
|
@ -121,13 +121,6 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry )
|
||||||
if( !( changeFlags & CHT_DONE ) )
|
if( !( changeFlags & CHT_DONE ) )
|
||||||
board->Add( boardItem );
|
board->Add( boardItem );
|
||||||
|
|
||||||
//ratsnest->Add( boardItem ); // TODO currently done by BOARD::Add()
|
|
||||||
|
|
||||||
if( boardItem->Type() == PCB_MODULE_T )
|
|
||||||
{
|
|
||||||
MODULE* mod = static_cast<MODULE*>( boardItem );
|
|
||||||
mod->RunOnChildren( std::bind( &KIGFX::VIEW::Add, view, _1, -1 ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -229,7 +222,6 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry )
|
||||||
|
|
||||||
MODULE* module = static_cast<MODULE*>( boardItem );
|
MODULE* module = static_cast<MODULE*>( boardItem );
|
||||||
module->ClearFlags();
|
module->ClearFlags();
|
||||||
module->RunOnChildren( std::bind( &KIGFX::VIEW::Remove, view, _1 ) );
|
|
||||||
|
|
||||||
view->Remove( module );
|
view->Remove( module );
|
||||||
|
|
||||||
|
@ -258,12 +250,6 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry )
|
||||||
undoList.PushItem( itemWrapper );
|
undoList.PushItem( itemWrapper );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( boardItem->Type() == PCB_MODULE_T )
|
|
||||||
{
|
|
||||||
MODULE* module = static_cast<MODULE*>( boardItem );
|
|
||||||
module->RunOnChildren( [&view] ( BOARD_ITEM* aItem ) { view->Update( aItem ); } );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ent.m_copy )
|
if( ent.m_copy )
|
||||||
connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
|
connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
|
||||||
|
|
||||||
|
@ -335,11 +321,6 @@ void BOARD_COMMIT::Revert()
|
||||||
switch( ent.m_type )
|
switch( ent.m_type )
|
||||||
{
|
{
|
||||||
case CHT_ADD:
|
case CHT_ADD:
|
||||||
if( item->Type() == PCB_MODULE_T )
|
|
||||||
{
|
|
||||||
MODULE* oldModule = static_cast<MODULE*>( item );
|
|
||||||
oldModule->RunOnChildren( std::bind( &KIGFX::VIEW::Remove, view, _1 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
view->Remove( item );
|
view->Remove( item );
|
||||||
connectivity->Remove( item );
|
connectivity->Remove( item );
|
||||||
|
@ -350,7 +331,6 @@ void BOARD_COMMIT::Revert()
|
||||||
{
|
{
|
||||||
MODULE* newModule = static_cast<MODULE*>( item );
|
MODULE* newModule = static_cast<MODULE*>( item );
|
||||||
newModule->RunOnChildren( std::bind( &EDA_ITEM::ClearFlags, _1, SELECTED ) );
|
newModule->RunOnChildren( std::bind( &EDA_ITEM::ClearFlags, _1, SELECTED ) );
|
||||||
newModule->RunOnChildren( std::bind( &KIGFX::VIEW::Add, view, _1, -1 ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view->Add( item );
|
view->Add( item );
|
||||||
|
@ -359,12 +339,6 @@ void BOARD_COMMIT::Revert()
|
||||||
|
|
||||||
case CHT_MODIFY:
|
case CHT_MODIFY:
|
||||||
{
|
{
|
||||||
if( item->Type() == PCB_MODULE_T )
|
|
||||||
{
|
|
||||||
MODULE* oldModule = static_cast<MODULE*>( item );
|
|
||||||
oldModule->RunOnChildren( std::bind( &KIGFX::VIEW::Remove, view, _1 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
view->Remove( item );
|
view->Remove( item );
|
||||||
connectivity->Remove( item );
|
connectivity->Remove( item );
|
||||||
|
|
||||||
|
@ -378,7 +352,6 @@ void BOARD_COMMIT::Revert()
|
||||||
{
|
{
|
||||||
MODULE* newModule = static_cast<MODULE*>( item );
|
MODULE* newModule = static_cast<MODULE*>( item );
|
||||||
newModule->RunOnChildren( std::bind( &EDA_ITEM::ClearFlags, _1, SELECTED ) );
|
newModule->RunOnChildren( std::bind( &EDA_ITEM::ClearFlags, _1, SELECTED ) );
|
||||||
newModule->RunOnChildren( std::bind( &KIGFX::VIEW::Add, view, _1, -1 ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view->Add( item );
|
view->Add( item );
|
||||||
|
|
|
@ -300,10 +300,8 @@ void FOOTPRINT_PREVIEW_PANEL::renderFootprint( MODULE *module )
|
||||||
{
|
{
|
||||||
GetView()->Clear();
|
GetView()->Clear();
|
||||||
module->SetParent ( &*m_dummyBoard );
|
module->SetParent ( &*m_dummyBoard );
|
||||||
module->RunOnChildren( boost::bind( &KIGFX::VIEW::Add, GetView(), _1, -1 ) );
|
|
||||||
|
|
||||||
GetView()->Add ( module );
|
GetView()->Add ( module );
|
||||||
|
|
||||||
GetView()->SetVisible( module, true );
|
GetView()->SetVisible( module, true );
|
||||||
GetView()->Update( module, KIGFX::ALL );
|
GetView()->Update( module, KIGFX::ALL );
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,6 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
|
||||||
// Remove old modules
|
// Remove old modules
|
||||||
for( MODULE* module = board->m_Modules; module; module = module->Next() )
|
for( MODULE* module = board->m_Modules; module; module = module->Next() )
|
||||||
{
|
{
|
||||||
module->RunOnChildren( std::bind( &KIGFX::VIEW::Remove, view, _1 ) );
|
|
||||||
view->Remove( module );
|
view->Remove( module );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,7 +157,6 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
|
||||||
// Reload modules
|
// Reload modules
|
||||||
for( MODULE* module = board->m_Modules; module; module = module->Next() )
|
for( MODULE* module = board->m_Modules; module; module = module->Next() )
|
||||||
{
|
{
|
||||||
module->RunOnChildren( std::bind( &KIGFX::VIEW::Add, view, _1, -1 ) );
|
|
||||||
view->Add( module );
|
view->Add( module );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,10 +153,7 @@ void PCB_DRAW_PANEL_GAL::DisplayBoard( const BOARD* aBoard )
|
||||||
|
|
||||||
// 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() )
|
||||||
{
|
|
||||||
module->RunOnChildren( std::bind( &KIGFX::VIEW::Add, m_view, _1, -1 ) );
|
|
||||||
m_view->Add( module );
|
m_view->Add( module );
|
||||||
}
|
|
||||||
|
|
||||||
// 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() )
|
||||||
|
|
|
@ -1,47 +1,110 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013-2017 CERN
|
||||||
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||||
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
using namespace std::placeholders;
|
||||||
|
|
||||||
#include <pcb_view.h>
|
#include <pcb_view.h>
|
||||||
#include <pcb_display_options.h>
|
#include <pcb_display_options.h>
|
||||||
#include <pcb_painter.h>
|
#include <pcb_painter.h>
|
||||||
|
|
||||||
namespace KIGFX
|
#include <class_module.h>
|
||||||
{
|
|
||||||
|
|
||||||
|
namespace KIGFX {
|
||||||
PCB_VIEW::PCB_VIEW( bool aIsDynamic ) :
|
PCB_VIEW::PCB_VIEW( bool aIsDynamic ) :
|
||||||
VIEW ( aIsDynamic )
|
VIEW( aIsDynamic )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PCB_VIEW::~PCB_VIEW()
|
PCB_VIEW::~PCB_VIEW()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCB_VIEW::Add( VIEW_ITEM* aItem, int aDrawPriority )
|
|
||||||
|
void PCB_VIEW::Add( KIGFX::VIEW_ITEM* aItem, int aDrawPriority )
|
||||||
{
|
{
|
||||||
VIEW::Add( aItem, aDrawPriority );
|
auto item = static_cast<BOARD_ITEM*>( aItem );
|
||||||
|
|
||||||
|
if( item->Type() == PCB_MODULE_T )
|
||||||
|
{
|
||||||
|
auto mod = static_cast<MODULE*>( item );
|
||||||
|
mod->RunOnChildren([this] ( BOARD_ITEM* aModItem ) {
|
||||||
|
VIEW::Add( aModItem );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
VIEW::Add( item, aDrawPriority );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCB_VIEW::Remove( VIEW_ITEM* aItem )
|
|
||||||
|
void PCB_VIEW::Remove( KIGFX::VIEW_ITEM* aItem )
|
||||||
{
|
{
|
||||||
VIEW::Remove( aItem );
|
auto item = static_cast<BOARD_ITEM*>( aItem );
|
||||||
|
|
||||||
|
|
||||||
|
if( item->Type() == PCB_MODULE_T )
|
||||||
|
{
|
||||||
|
auto mod = static_cast<MODULE*>( item );
|
||||||
|
mod->RunOnChildren([this] ( BOARD_ITEM* aModItem ) {
|
||||||
|
VIEW::Remove( aModItem );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
VIEW::Remove( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCB_VIEW::Update( VIEW_ITEM* aItem, int aUpdateFlags )
|
|
||||||
|
void PCB_VIEW::Update( KIGFX::VIEW_ITEM* aItem, int aUpdateFlags )
|
||||||
{
|
{
|
||||||
VIEW::Update( aItem, aUpdateFlags );
|
auto item = static_cast<BOARD_ITEM*>( aItem );
|
||||||
|
|
||||||
|
if( item->Type() == PCB_MODULE_T )
|
||||||
|
{
|
||||||
|
auto mod = static_cast<MODULE*>( item );
|
||||||
|
mod->RunOnChildren([this, aUpdateFlags] ( BOARD_ITEM* aModItem ) {
|
||||||
|
VIEW::Update( aModItem, aUpdateFlags );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
VIEW::Update( item, aUpdateFlags );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @copydoc VIEW::Update()
|
|
||||||
void PCB_VIEW::Update( VIEW_ITEM* aItem )
|
void PCB_VIEW::Update( KIGFX::VIEW_ITEM* aItem )
|
||||||
{
|
{
|
||||||
VIEW::Update( aItem );
|
PCB_VIEW::Update( aItem, KIGFX::ALL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_VIEW::UpdateDisplayOptions( PCB_DISPLAY_OPTIONS* aOptions )
|
void PCB_VIEW::UpdateDisplayOptions( PCB_DISPLAY_OPTIONS* aOptions )
|
||||||
{
|
{
|
||||||
auto painter = static_cast<KIGFX::PCB_PAINTER*>( GetPainter() );
|
auto painter = static_cast<KIGFX::PCB_PAINTER*>( GetPainter() );
|
||||||
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||||
|
|
||||||
settings->LoadDisplayOptions( aOptions );
|
settings->LoadDisplayOptions( aOptions );
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <layers_id_colors_and_visibility.h>
|
#include <layers_id_colors_and_visibility.h>
|
||||||
#include <view/view.h>
|
#include <view/view.h>
|
||||||
|
#include <class_board_item.h>
|
||||||
|
|
||||||
class PCB_DISPLAY_OPTIONS;
|
class PCB_DISPLAY_OPTIONS;
|
||||||
|
|
||||||
|
|
|
@ -409,7 +409,7 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
|
||||||
bool reBuild_ratsnest = false;
|
bool reBuild_ratsnest = false;
|
||||||
bool deep_reBuild_ratsnest = false; // true later if pointers must be rebuilt
|
bool deep_reBuild_ratsnest = false; // true later if pointers must be rebuilt
|
||||||
|
|
||||||
KIGFX::VIEW* view = GetGalCanvas()->GetView();
|
auto view = GetGalCanvas()->GetView();
|
||||||
auto connectivity = GetBoard()->GetConnectivity();
|
auto connectivity = GetBoard()->GetConnectivity();
|
||||||
|
|
||||||
// Undo in the reverse order of list creation: (this can allow stacked changes
|
// Undo in the reverse order of list creation: (this can allow stacked changes
|
||||||
|
@ -488,12 +488,6 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
|
||||||
|
|
||||||
// Remove all pads/drawings/texts, as they become invalid
|
// Remove all pads/drawings/texts, as they become invalid
|
||||||
// for the VIEW after SwapData() called for modules
|
// for the VIEW after SwapData() called for modules
|
||||||
if( item->Type() == PCB_MODULE_T )
|
|
||||||
{
|
|
||||||
MODULE* oldModule = static_cast<MODULE*>( item );
|
|
||||||
oldModule->RunOnChildren( std::bind( &KIGFX::VIEW::Remove, view, _1 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
view->Remove( item );
|
view->Remove( item );
|
||||||
connectivity->Remove( item );
|
connectivity->Remove( item );
|
||||||
|
|
||||||
|
@ -504,7 +498,6 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
|
||||||
if( item->Type() == PCB_MODULE_T )
|
if( item->Type() == PCB_MODULE_T )
|
||||||
{
|
{
|
||||||
MODULE* newModule = static_cast<MODULE*>( item );
|
MODULE* newModule = static_cast<MODULE*>( item );
|
||||||
newModule->RunOnChildren( std::bind( &KIGFX::VIEW::Add, view, _1, -1 ) );
|
|
||||||
newModule->RunOnChildren( std::bind( &BOARD_ITEM::ClearFlags, _1, EDA_ITEM_ALL_FLAGS ));
|
newModule->RunOnChildren( std::bind( &BOARD_ITEM::ClearFlags, _1, EDA_ITEM_ALL_FLAGS ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,26 +511,12 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
|
||||||
case UR_NEW: /* new items are deleted */
|
case UR_NEW: /* new items are deleted */
|
||||||
aList->SetPickedItemStatus( UR_DELETED, ii );
|
aList->SetPickedItemStatus( UR_DELETED, ii );
|
||||||
GetModel()->Remove( item );
|
GetModel()->Remove( item );
|
||||||
|
|
||||||
if( item->Type() == PCB_MODULE_T )
|
|
||||||
{
|
|
||||||
MODULE* module = static_cast<MODULE*>( item );
|
|
||||||
module->RunOnChildren( std::bind( &KIGFX::VIEW::Remove, view, _1 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
view->Remove( item );
|
view->Remove( item );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UR_DELETED: /* deleted items are put in List, as new items */
|
case UR_DELETED: /* deleted items are put in List, as new items */
|
||||||
aList->SetPickedItemStatus( UR_NEW, ii );
|
aList->SetPickedItemStatus( UR_NEW, ii );
|
||||||
GetModel()->Add( item );
|
GetModel()->Add( item );
|
||||||
|
|
||||||
if( item->Type() == PCB_MODULE_T )
|
|
||||||
{
|
|
||||||
MODULE* module = static_cast<MODULE*>( item );
|
|
||||||
module->RunOnChildren( std::bind( &KIGFX::VIEW::Add, view, _1, -1 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
view->Add( item );
|
view->Add( item );
|
||||||
build_item_list = true;
|
build_item_list = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue