2017-09-17 22:44:30 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
|
2022-07-12 01:03:45 +00:00
|
|
|
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-09-17 22:44:30 +00:00
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
#include <functional>
|
|
|
|
using namespace std::placeholders;
|
2017-10-23 16:48:03 +00:00
|
|
|
#include <bitmaps.h>
|
2021-03-07 20:31:19 +00:00
|
|
|
#include <eda_item.h>
|
2017-09-17 22:44:30 +00:00
|
|
|
#include <gerber_collectors.h>
|
2021-09-07 20:34:10 +00:00
|
|
|
#include <gerbview_settings.h>
|
2017-09-17 22:44:30 +00:00
|
|
|
#include <class_draw_panel_gal.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2017-09-17 22:44:30 +00:00
|
|
|
#include <view/view.h>
|
|
|
|
#include <view/view_group.h>
|
|
|
|
#include <painter.h>
|
|
|
|
#include <tool/tool_event.h>
|
|
|
|
#include <tool/tool_manager.h>
|
2019-04-28 19:04:28 +00:00
|
|
|
#include "gerbview_selection_tool.h"
|
2017-09-17 22:44:30 +00:00
|
|
|
#include "gerbview_actions.h"
|
|
|
|
|
|
|
|
|
2019-06-15 00:29:42 +00:00
|
|
|
class HIGHLIGHT_MENU : public ACTION_MENU
|
2017-09-17 22:44:30 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-06-15 00:29:42 +00:00
|
|
|
HIGHLIGHT_MENU() :
|
|
|
|
ACTION_MENU( true )
|
2017-09-17 22:44:30 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
SetIcon( BITMAPS::net_highlight_schematic );
|
2018-02-09 16:28:33 +00:00
|
|
|
SetTitle( _( "Highlight" ) );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void update() override
|
|
|
|
{
|
2017-10-23 16:48:03 +00:00
|
|
|
bool addSeparator = false;
|
|
|
|
|
2020-07-07 10:46:46 +00:00
|
|
|
Clear();
|
|
|
|
|
2017-09-17 22:44:30 +00:00
|
|
|
const auto& selection = getToolManager()->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection();
|
|
|
|
|
|
|
|
if( selection.Size() == 1 )
|
|
|
|
{
|
|
|
|
auto item = static_cast<GERBER_DRAW_ITEM*>( selection[0] );
|
|
|
|
const auto& net_attr = item->GetNetAttributes();
|
|
|
|
|
|
|
|
if( ( net_attr.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_PAD ) ||
|
|
|
|
( net_attr.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_CMP ) )
|
|
|
|
{
|
|
|
|
auto menuEntry = Add( GERBVIEW_ACTIONS::highlightComponent );
|
2021-11-04 00:02:14 +00:00
|
|
|
menuEntry->SetItemLabel( wxString::Format( _( "Highlight Items of Component '%s'" ),
|
2020-12-25 23:37:17 +00:00
|
|
|
net_attr.m_Cmpref ) );
|
2017-10-23 16:48:03 +00:00
|
|
|
addSeparator = true;
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( ( net_attr.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_NET ) )
|
|
|
|
{
|
|
|
|
auto menuEntry = Add( GERBVIEW_ACTIONS::highlightNet );
|
2021-11-04 00:02:14 +00:00
|
|
|
menuEntry->SetItemLabel( wxString::Format( _( "Highlight Items of Net '%s'" ),
|
2020-12-25 23:37:17 +00:00
|
|
|
UnescapeString( net_attr.m_Netname ) ) );
|
2017-10-23 16:48:03 +00:00
|
|
|
addSeparator = true;
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
D_CODE* apertDescr = item->GetDcodeDescr();
|
|
|
|
|
|
|
|
if( apertDescr && !apertDescr->m_AperFunction.IsEmpty() )
|
|
|
|
{
|
|
|
|
auto menuEntry = Add( GERBVIEW_ACTIONS::highlightAttribute );
|
2021-11-04 00:02:14 +00:00
|
|
|
menuEntry->SetItemLabel( wxString::Format( _( "Highlight Aperture Type '%s'" ),
|
2020-12-25 23:37:17 +00:00
|
|
|
apertDescr->m_AperFunction ) );
|
2017-10-23 16:48:03 +00:00
|
|
|
addSeparator = true;
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
2021-03-13 17:45:33 +00:00
|
|
|
|
|
|
|
if( apertDescr )
|
|
|
|
{
|
|
|
|
auto menuEntry = Add( GERBVIEW_ACTIONS::highlightDCode );
|
|
|
|
menuEntry->SetItemLabel( wxString::Format( _( "Highlight DCode D%d" ),
|
|
|
|
apertDescr->m_Num_Dcode ) );
|
|
|
|
addSeparator = true;
|
|
|
|
}
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-23 16:48:03 +00:00
|
|
|
if( addSeparator )
|
|
|
|
AppendSeparator();
|
|
|
|
|
2017-09-17 22:44:30 +00:00
|
|
|
Add( GERBVIEW_ACTIONS::highlightClear );
|
|
|
|
}
|
|
|
|
|
2019-05-14 11:14:00 +00:00
|
|
|
ACTION_MENU* create() const override
|
2017-09-17 22:44:30 +00:00
|
|
|
{
|
|
|
|
return new HIGHLIGHT_MENU();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
GERBVIEW_SELECTION_TOOL::GERBVIEW_SELECTION_TOOL() :
|
2022-07-12 01:03:45 +00:00
|
|
|
SELECTION_TOOL( "gerbview.InteractiveSelection" ),
|
2021-09-05 20:37:52 +00:00
|
|
|
m_frame( nullptr )
|
2017-09-17 22:44:30 +00:00
|
|
|
{
|
2019-05-19 10:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-17 22:44:30 +00:00
|
|
|
GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL()
|
|
|
|
{
|
|
|
|
getView()->Remove( &m_selection );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GERBVIEW_SELECTION_TOOL::Init()
|
|
|
|
{
|
2022-09-03 18:29:02 +00:00
|
|
|
std::shared_ptr<HIGHLIGHT_MENU> highlightSubMenu = std::make_shared<HIGHLIGHT_MENU>();
|
|
|
|
highlightSubMenu->SetTool( this );
|
|
|
|
m_menu.RegisterSubMenu( highlightSubMenu );
|
2017-09-17 22:44:30 +00:00
|
|
|
|
2022-09-03 18:29:02 +00:00
|
|
|
m_menu.GetMenu().AddMenu( highlightSubMenu.get() );
|
|
|
|
m_menu.GetMenu().AddSeparator( 1000 );
|
2017-09-17 22:44:30 +00:00
|
|
|
|
2019-06-11 14:38:21 +00:00
|
|
|
getEditFrame<GERBVIEW_FRAME>()->AddStandardSubMenus( m_menu );
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_SELECTION_TOOL::Reset( RESET_REASON aReason )
|
|
|
|
{
|
|
|
|
m_frame = getEditFrame<GERBVIEW_FRAME>();
|
|
|
|
|
|
|
|
if( aReason == TOOL_BASE::MODEL_RELOAD )
|
|
|
|
{
|
|
|
|
// Remove pointers to the selected items from containers
|
|
|
|
// without changing their properties (as they are already deleted
|
|
|
|
// while a new file is loaded)
|
|
|
|
m_selection.Clear();
|
|
|
|
getView()->GetPainter()->GetSettings()->SetHighlight( false );
|
|
|
|
}
|
|
|
|
else
|
2021-07-16 20:13:26 +00:00
|
|
|
{
|
2017-09-17 22:44:30 +00:00
|
|
|
// Restore previous properties of selected items and remove them from containers
|
|
|
|
clearSelection();
|
2021-07-16 20:13:26 +00:00
|
|
|
}
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
// Reinsert the VIEW_GROUP, in case it was removed from the VIEW
|
|
|
|
getView()->Remove( &m_selection );
|
|
|
|
getView()->Add( &m_selection );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
// Main loop: keep receiving events
|
2019-06-17 13:43:22 +00:00
|
|
|
while( TOOL_EVENT* evt = Wait() )
|
2017-09-17 22:44:30 +00:00
|
|
|
{
|
2019-06-27 21:33:48 +00:00
|
|
|
if( m_frame->ToolStackIsEmpty() )
|
2020-10-08 00:50:28 +00:00
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
2019-06-27 21:33:48 +00:00
|
|
|
|
2021-09-05 20:37:52 +00:00
|
|
|
// on left click, a selection is made, depending on modifiers ALT, SHIFT, CTRL:
|
|
|
|
setModifiersState( evt->Modifier( MD_SHIFT ), evt->Modifier( MD_CTRL ),
|
|
|
|
evt->Modifier( MD_ALT ) );
|
2019-07-09 19:50:40 +00:00
|
|
|
|
2017-09-17 22:44:30 +00:00
|
|
|
// single click? Select single object
|
|
|
|
if( evt->IsClick( BUT_LEFT ) )
|
|
|
|
{
|
|
|
|
selectPoint( evt->Position() );
|
|
|
|
}
|
|
|
|
else if( evt->IsClick( BUT_RIGHT ) )
|
|
|
|
{
|
2021-07-16 20:13:26 +00:00
|
|
|
// right click? if there is any object - show the context menu
|
2017-09-17 22:44:30 +00:00
|
|
|
if( m_selection.Empty() )
|
|
|
|
{
|
|
|
|
selectPoint( evt->Position() );
|
|
|
|
m_selection.SetIsHover( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_menu.ShowContextMenu( m_selection );
|
|
|
|
}
|
2020-09-17 00:19:31 +00:00
|
|
|
else if( evt->IsDblClick( BUT_MIDDLE ) )
|
|
|
|
{
|
2021-07-16 20:13:26 +00:00
|
|
|
// Middle double click? Do zoom to fit
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( ACTIONS::zoomFitScreen );
|
2020-09-17 00:19:31 +00:00
|
|
|
}
|
2017-09-17 22:44:30 +00:00
|
|
|
else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE )
|
|
|
|
{
|
|
|
|
clearSelection();
|
|
|
|
}
|
2019-05-28 14:39:14 +00:00
|
|
|
else
|
2020-12-25 23:37:17 +00:00
|
|
|
{
|
2019-06-16 11:06:49 +00:00
|
|
|
evt->SetPassEvent();
|
2020-12-25 23:37:17 +00:00
|
|
|
}
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-08 21:48:22 +00:00
|
|
|
GERBVIEW_SELECTION& GERBVIEW_SELECTION_TOOL::GetSelection()
|
2017-09-17 22:44:30 +00:00
|
|
|
{
|
|
|
|
return m_selection;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-12 01:03:45 +00:00
|
|
|
bool GERBVIEW_SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere )
|
2017-09-17 22:44:30 +00:00
|
|
|
{
|
2022-07-12 01:03:45 +00:00
|
|
|
EDA_ITEM* item = nullptr;
|
2017-09-17 22:44:30 +00:00
|
|
|
GERBER_COLLECTOR collector;
|
2022-07-12 01:03:45 +00:00
|
|
|
EDA_ITEM* model = getModel<EDA_ITEM>();
|
2017-09-17 22:44:30 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
collector.Collect( model, { GERBER_LAYOUT_T, GERBER_IMAGE_T, GERBER_DRAW_ITEM_T }, aWhere );
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
// Remove unselectable items
|
|
|
|
for( int i = collector.GetCount() - 1; i >= 0; --i )
|
|
|
|
{
|
|
|
|
if( !selectable( collector[i] ) )
|
|
|
|
collector.Remove( i );
|
|
|
|
}
|
|
|
|
|
2019-07-09 19:50:40 +00:00
|
|
|
if( collector.GetCount() > 1 )
|
2017-09-17 22:44:30 +00:00
|
|
|
{
|
2022-07-12 01:03:45 +00:00
|
|
|
doSelectionMenu( &collector );
|
2017-09-17 22:44:30 +00:00
|
|
|
|
2022-07-12 01:03:45 +00:00
|
|
|
if( collector.m_MenuCancelled )
|
|
|
|
return false;
|
2019-07-09 19:50:40 +00:00
|
|
|
}
|
2017-09-17 22:44:30 +00:00
|
|
|
|
2019-07-09 19:50:40 +00:00
|
|
|
if( !m_additive && !m_subtractive && !m_exclusive_or )
|
|
|
|
clearSelection();
|
2017-09-17 22:44:30 +00:00
|
|
|
|
2019-07-09 19:50:40 +00:00
|
|
|
if( collector.GetCount() == 1 )
|
|
|
|
{
|
|
|
|
item = collector[ 0 ];
|
2017-09-17 22:44:30 +00:00
|
|
|
|
2019-07-09 19:50:40 +00:00
|
|
|
if( m_subtractive || ( m_exclusive_or && item->IsSelected() ) )
|
|
|
|
{
|
|
|
|
unselect( item );
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::UnselectedEvent );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
select( item );
|
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
|
|
|
return true;
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_SELECTION_TOOL::setTransitions()
|
|
|
|
{
|
2019-07-09 19:50:40 +00:00
|
|
|
Go( &GERBVIEW_SELECTION_TOOL::UpdateMenu, ACTIONS::updateMenu.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_SELECTION_TOOL::Main, GERBVIEW_ACTIONS::selectionActivate.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_SELECTION_TOOL::ClearSelection, GERBVIEW_ACTIONS::selectionClear.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_SELECTION_TOOL::SelectItem, GERBVIEW_ACTIONS::selectItem.MakeEvent() );
|
|
|
|
Go( &GERBVIEW_SELECTION_TOOL::UnselectItem, GERBVIEW_ACTIONS::unselectItem.MakeEvent() );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_SELECTION_TOOL::ClearSelection( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
clearSelection();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_SELECTION_TOOL::SelectItems( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
std::vector<EDA_ITEM*>* items = aEvent.Parameter<std::vector<EDA_ITEM*>*>();
|
|
|
|
|
|
|
|
if( items )
|
|
|
|
{
|
2019-07-09 19:50:40 +00:00
|
|
|
// Perform individual selection of each item before processing the event.
|
2020-12-25 23:37:17 +00:00
|
|
|
for( EDA_ITEM* item : *items )
|
2017-09-17 22:44:30 +00:00
|
|
|
select( item );
|
|
|
|
|
2019-04-21 23:45:34 +00:00
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_SELECTION_TOOL::SelectItem( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
// Check if there is an item to be selected
|
|
|
|
EDA_ITEM* item = aEvent.Parameter<EDA_ITEM*>();
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
select( item );
|
|
|
|
|
|
|
|
// Inform other potentially interested tools
|
2019-04-21 23:45:34 +00:00
|
|
|
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_SELECTION_TOOL::UnselectItems( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
std::vector<EDA_ITEM*>* items = aEvent.Parameter<std::vector<EDA_ITEM*>*>();
|
|
|
|
|
|
|
|
if( items )
|
|
|
|
{
|
2019-07-09 19:50:40 +00:00
|
|
|
// Perform individual unselection of each item before processing the event
|
2020-12-25 23:37:17 +00:00
|
|
|
for( EDA_ITEM* item : *items )
|
2017-09-17 22:44:30 +00:00
|
|
|
unselect( item );
|
|
|
|
|
2019-04-21 23:45:34 +00:00
|
|
|
m_toolMgr->ProcessEvent( EVENTS::UnselectedEvent );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int GERBVIEW_SELECTION_TOOL::UnselectItem( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
// Check if there is an item to be selected
|
|
|
|
EDA_ITEM* item = aEvent.Parameter<EDA_ITEM*>();
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
unselect( item );
|
|
|
|
|
|
|
|
// Inform other potentially interested tools
|
2019-04-21 23:45:34 +00:00
|
|
|
m_toolMgr->ProcessEvent( EVENTS::UnselectedEvent );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_SELECTION_TOOL::clearSelection()
|
|
|
|
{
|
|
|
|
if( m_selection.Empty() )
|
|
|
|
return;
|
|
|
|
|
2020-12-25 23:37:17 +00:00
|
|
|
for( EDA_ITEM* item : m_selection )
|
|
|
|
unselectVisually( item );
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
m_selection.Clear();
|
|
|
|
|
|
|
|
// Inform other potentially interested tools
|
2019-04-21 23:45:34 +00:00
|
|
|
m_toolMgr->ProcessEvent( EVENTS::ClearedEvent );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GERBVIEW_SELECTION_TOOL::selectable( const EDA_ITEM* aItem ) const
|
|
|
|
{
|
2019-06-26 00:13:30 +00:00
|
|
|
GERBVIEW_FRAME* frame = getEditFrame<GERBVIEW_FRAME>();
|
|
|
|
const GERBER_DRAW_ITEM* item = static_cast<const GERBER_DRAW_ITEM*>( aItem );
|
|
|
|
int layer = item->GetLayer();
|
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
if( !frame->gvconfig()->m_Appearance.show_negative_objects && item->GetLayerPolarity() )
|
|
|
|
return false;
|
2017-09-17 22:44:30 +00:00
|
|
|
|
2019-06-26 00:13:30 +00:00
|
|
|
// We do not want to select items that are in the background
|
2021-09-07 20:34:10 +00:00
|
|
|
if( frame->gvconfig()->m_Display.m_HighContrastMode && layer != frame->GetActiveLayer() )
|
2019-06-26 00:13:30 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return frame->IsLayerVisible( layer );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_SELECTION_TOOL::select( EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
if( aItem->IsSelected() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_selection.Add( aItem );
|
2019-08-22 05:50:26 +00:00
|
|
|
getView()->Add( &m_selection, std::numeric_limits<int>::max() );
|
2017-09-25 01:12:58 +00:00
|
|
|
selectVisually( aItem );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_SELECTION_TOOL::unselect( EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
if( !aItem->IsSelected() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
unselectVisually( aItem );
|
|
|
|
m_selection.Remove( aItem );
|
|
|
|
|
|
|
|
if( m_selection.Empty() )
|
|
|
|
getView()->Remove( &m_selection );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-25 01:12:58 +00:00
|
|
|
void GERBVIEW_SELECTION_TOOL::selectVisually( EDA_ITEM* aItem )
|
2017-09-17 22:44:30 +00:00
|
|
|
{
|
|
|
|
// Move the item's layer to the front
|
|
|
|
int layer = static_cast<GERBER_DRAW_ITEM*>( aItem )->GetLayer();
|
2017-09-18 01:54:02 +00:00
|
|
|
m_frame->SetActiveLayer( layer, true );
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
// Hide the original item, so it is shown only on overlay
|
|
|
|
aItem->SetSelected();
|
|
|
|
getView()->Hide( aItem, true );
|
2017-09-25 01:12:58 +00:00
|
|
|
|
|
|
|
getView()->Update( &m_selection );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-25 01:12:58 +00:00
|
|
|
void GERBVIEW_SELECTION_TOOL::unselectVisually( EDA_ITEM* aItem )
|
2017-09-17 22:44:30 +00:00
|
|
|
{
|
|
|
|
// Restore original item visibility
|
|
|
|
aItem->ClearSelected();
|
|
|
|
getView()->Hide( aItem, false );
|
|
|
|
getView()->Update( aItem, KIGFX::ALL );
|
2017-09-25 01:12:58 +00:00
|
|
|
|
|
|
|
getView()->Update( &m_selection );
|
2017-09-17 22:44:30 +00:00
|
|
|
}
|