Convert separate-compilation of selection.cpp to polymorphism.

This commit is contained in:
Jeff Young 2019-06-08 22:48:22 +01:00
parent e606587ff6
commit 765606012f
55 changed files with 458 additions and 423 deletions

View File

@ -205,18 +205,6 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
return 0; return 0;
} }
const BOX2I SELECTION::ViewBBox() const
{
return BOX2I();
}
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const
{
return std::vector<VIEW_ITEM*>();
}
void CVPCB_SELECTION_TOOL::setTransitions() void CVPCB_SELECTION_TOOL::setTransitions()
{ {
Go( &CVPCB_SELECTION_TOOL::Main, CVPCB_ACTIONS::selectionActivate.MakeEvent() ); Go( &CVPCB_SELECTION_TOOL::Main, CVPCB_ACTIONS::selectionActivate.MakeEvent() );

View File

@ -226,6 +226,7 @@ set( EESCHEMA_SRCS
tools/ee_inspection_tool.cpp tools/ee_inspection_tool.cpp
tools/ee_picker_tool.cpp tools/ee_picker_tool.cpp
tools/ee_point_editor.cpp tools/ee_point_editor.cpp
tools/ee_selection.cpp
tools/ee_selection_tool.cpp tools/ee_selection_tool.cpp
tools/lib_control.cpp tools/lib_control.cpp
tools/lib_drawing_tools.cpp tools/lib_drawing_tools.cpp
@ -237,7 +238,6 @@ set( EESCHEMA_SRCS
tools/sch_editor_control.cpp tools/sch_editor_control.cpp
tools/sch_wire_bus_tool.cpp tools/sch_wire_bus_tool.cpp
tools/sch_move_tool.cpp tools/sch_move_tool.cpp
tools/selection.cpp
) )

View File

@ -21,9 +21,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <tools/ee_actions.h>
#include <tools/ee_inspection_tool.h>
#include <tools/ee_selection_tool.h>
#include <view/view_controls.h> #include <view/view_controls.h>
#include <sch_component.h> #include <sch_component.h>
#include <sch_marker.h> #include <sch_marker.h>
@ -33,8 +30,11 @@
#include <confirm.h> #include <confirm.h>
#include <tool/conditional_menu.h> #include <tool/conditional_menu.h>
#include <tool/selection_conditions.h> #include <tool/selection_conditions.h>
#include <tool/selection.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/ee_actions.h>
#include <tools/ee_inspection_tool.h>
#include <tools/ee_selection_tool.h>
#include <tools/ee_selection.h>
#include <search_stack.h> #include <search_stack.h>
#include <sim/sim_plot_frame.h> #include <sim/sim_plot_frame.h>
#include <sch_view.h> #include <sch_view.h>
@ -300,7 +300,7 @@ int EE_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent )
} }
else if( m_frame->IsType( FRAME_SCH ) ) else if( m_frame->IsType( FRAME_SCH ) )
{ {
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly ); EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
if( selection.Empty() ) if( selection.Empty() )
return 0; return 0;
@ -323,7 +323,7 @@ int EE_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent )
int EE_INSPECTION_TOOL::ShowMarkerInfo( const TOOL_EVENT& aEvent ) int EE_INSPECTION_TOOL::ShowMarkerInfo( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->GetSelection(); EE_SELECTION& selection = m_selectionTool->GetSelection();
if( selection.Empty() ) if( selection.Empty() )
return 0; return 0;
@ -340,7 +340,7 @@ int EE_INSPECTION_TOOL::ShowMarkerInfo( const TOOL_EVENT& aEvent )
int EE_INSPECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) int EE_INSPECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
{ {
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>(); EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
SELECTION& selection = selTool->GetSelection(); EE_SELECTION& selection = selTool->GetSelection();
if( selection.GetSize() == 1 ) if( selection.GetSize() == 1 )
{ {

View File

@ -252,7 +252,7 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
if( !m_selectionTool ) if( !m_selectionTool )
return 0; return 0;
const SELECTION& selection = m_selectionTool->GetSelection(); const EE_SELECTION& selection = m_selectionTool->GetSelection();
if( selection.Size() != 1 || !selection.Front()->IsType( pointTypes ) ) if( selection.Size() != 1 || !selection.Front()->IsType( pointTypes ) )
return 0; return 0;

View File

@ -22,40 +22,12 @@
*/ */
#include <limits> #include <limits>
#include <functional> #include <functional>
#include <tool/selection.h> #include <tools/ee_selection.h>
#include <sch_item.h> #include <sch_item.h>
#include <lib_draw_item.h> #include <lib_draw_item.h>
VECTOR2I SELECTION::GetPosition() const EDA_ITEM* EE_SELECTION::GetTopLeftItem( bool onlyModules ) const
{
return static_cast<VECTOR2I>( GetBoundingBox().GetPosition() );
}
VECTOR2I SELECTION::GetCenter() const
{
return static_cast<VECTOR2I>( GetBoundingBox().Centre() );
}
EDA_RECT SELECTION::GetBoundingBox() const
{
EDA_RECT bbox;
bbox = Front()->GetBoundingBox();
auto i = m_items.begin();
++i;
for( ; i != m_items.end(); ++i )
bbox.Merge( (*i)->GetBoundingBox() );
return bbox;
}
EDA_ITEM* SELECTION::GetTopLeftItem( bool onlyModules ) const
{ {
EDA_ITEM* topLeftItem = nullptr; EDA_ITEM* topLeftItem = nullptr;
wxPoint topLeftPos; wxPoint topLeftPos;
@ -83,22 +55,3 @@ EDA_ITEM* SELECTION::GetTopLeftItem( bool onlyModules ) const
return static_cast<EDA_ITEM*>( topLeftItem ); return static_cast<EDA_ITEM*>( topLeftItem );
} }
const BOX2I SELECTION::ViewBBox() const
{
BOX2I r;
r.SetMaximum();
return r;
}
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const
{
std::vector<VIEW_ITEM*> items;
for( auto item : m_items )
items.push_back( item );
return items;
}

View File

@ -0,0 +1,36 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* 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
*/
#ifndef EE_SELECTION_H
#define EE_SELECTION_H
#include <tool/selection.h>
class EE_SELECTION : public SELECTION
{
public:
EDA_ITEM* GetTopLeftItem( bool onlyModules = false ) const override;
};
#endif // EE_SELECTION_H

View File

@ -460,7 +460,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
} }
SELECTION& EE_SELECTION_TOOL::GetSelection() EE_SELECTION& EE_SELECTION_TOOL::GetSelection()
{ {
return m_selection; return m_selection;
} }
@ -582,7 +582,7 @@ void EE_SELECTION_TOOL::guessSelectionCandidates( EE_COLLECTOR& collector, const
} }
SELECTION& EE_SELECTION_TOOL::RequestSelection( const KICAD_T aFilterList[] ) EE_SELECTION& EE_SELECTION_TOOL::RequestSelection( const KICAD_T aFilterList[] )
{ {
// Filter an existing selection // Filter an existing selection
if( !m_selection.Empty() ) if( !m_selection.Empty() )
@ -1125,7 +1125,7 @@ void EE_SELECTION_TOOL::unselect( EDA_ITEM* aItem )
} }
void EE_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup ) void EE_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* aGroup )
{ {
KICAD_T itemType = aItem->Type(); KICAD_T itemType = aItem->Type();
@ -1182,7 +1182,7 @@ void EE_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup
} }
void EE_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup ) void EE_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* aGroup )
{ {
KICAD_T itemType = aItem->Type(); KICAD_T itemType = aItem->Type();

View File

@ -26,8 +26,8 @@
#include <tool/tool_interactive.h> #include <tool/tool_interactive.h>
#include <tool/action_menu.h> #include <tool/action_menu.h>
#include <tool/selection.h>
#include <tool/tool_menu.h> #include <tool/tool_menu.h>
#include <tools/ee_selection.h>
#include <ee_collectors.h> #include <ee_collectors.h>
#include <sch_component.h> #include <sch_component.h>
@ -79,7 +79,7 @@ public:
* *
* Returns the set of currently selected items. * Returns the set of currently selected items.
*/ */
SELECTION& GetSelection(); EE_SELECTION& GetSelection();
/** /**
* Function RequestSelection() * Function RequestSelection()
@ -87,7 +87,7 @@ public:
* Returns either an existing selection (filtered), or the selection at the current * Returns either an existing selection (filtered), or the selection at the current
* cursor if the existing selection is empty. * cursor if the existing selection is empty.
*/ */
SELECTION& RequestSelection( const KICAD_T* aFilterList = EE_COLLECTOR::AllItems ); EE_SELECTION& RequestSelection( const KICAD_T* aFilterList = EE_COLLECTOR::AllItems );
/** /**
* Function selectPoint() * Function selectPoint()
@ -209,7 +209,7 @@ private:
* @param aHighlightMode should be either SELECTED or BRIGHTENED * @param aHighlightMode should be either SELECTED or BRIGHTENED
* @param aGroup is the group to add the item to in the BRIGHTENED mode. * @param aGroup is the group to add the item to in the BRIGHTENED mode.
*/ */
void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ); void highlight( EDA_ITEM* aItem, int aHighlightMode, EE_SELECTION* aGroup = nullptr );
/** /**
* Function unhighlight() * Function unhighlight()
@ -218,7 +218,7 @@ private:
* @param aHighlightMode should be either SELECTED or BRIGHTENED * @param aHighlightMode should be either SELECTED or BRIGHTENED
* @param aGroup is the group to remove the item from. * @param aGroup is the group to remove the item from.
*/ */
void unhighlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ); void unhighlight( EDA_ITEM* aItem, int aHighlightMode, EE_SELECTION* aGroup = nullptr );
/** /**
* Sets the reference point to the anchor of the top-left item. * Sets the reference point to the anchor of the top-left item.
@ -237,18 +237,18 @@ private:
void setTransitions() override; void setTransitions() override;
private: private:
SCH_BASE_FRAME* m_frame; // Pointer to the parent frame SCH_BASE_FRAME* m_frame; // Pointer to the parent frame
SELECTION m_selection; // Current state of selection EE_SELECTION m_selection; // Current state of selection
bool m_additive; // Items should be added to selection (instead of replacing) bool m_additive; // Items should be added to selection (instead of replacing)
bool m_subtractive; // Items should be removed from selection bool m_subtractive; // Items should be removed from selection
bool m_multiple; // Multiple selection mode is active bool m_multiple; // Multiple selection mode is active
bool m_skip_heuristics; // Heuristics are not allowed when choosing item under cursor bool m_skip_heuristics; // Heuristics are not allowed when choosing item under cursor
bool m_isLibEdit; // True when libedit is the parent frame bool m_isLibEdit; // True when libedit is the parent frame
bool m_isLibView; // True when libview is the parent frame bool m_isLibView; // True when libview is the parent frame
int m_unit; // Fixed unit filter (for symbol editor) int m_unit; // Fixed unit filter (for symbol editor)
int m_convert; // Fixed DeMorgan filter (for symbol editor) int m_convert; // Fixed DeMorgan filter (for symbol editor)
}; };
#endif //KICAD_SCH_SELECTION_TOOL_H #endif //KICAD_SCH_SELECTION_TOOL_H

View File

@ -36,7 +36,7 @@
#include <undo_redo_container.h> #include <undo_redo_container.h>
class SELECTION; class EE_SELECTION;
/** /**
* Class EE_TOOL_BASE * Class EE_TOOL_BASE

View File

@ -124,7 +124,7 @@ bool LIB_EDIT_TOOL::Init()
int LIB_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) int LIB_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection(); EE_SELECTION& selection = m_selectionTool->RequestSelection();
if( selection.GetSize() == 0 ) if( selection.GetSize() == 0 )
return 0; return 0;
@ -164,7 +164,7 @@ int LIB_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
int LIB_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) int LIB_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection(); EE_SELECTION& selection = m_selectionTool->RequestSelection();
if( selection.GetSize() == 0 ) if( selection.GetSize() == 0 )
return 0; return 0;
@ -319,7 +319,7 @@ int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
int LIB_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) int LIB_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection(); EE_SELECTION& selection = m_selectionTool->RequestSelection();
if( selection.Empty() || aEvent.IsAction( &EE_ACTIONS::symbolProperties ) ) if( selection.Empty() || aEvent.IsAction( &EE_ACTIONS::symbolProperties ) )
{ {
@ -550,8 +550,8 @@ int LIB_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
int LIB_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent ) int LIB_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
{ {
LIB_PART* part = m_frame->GetCurPart(); LIB_PART* part = m_frame->GetCurPart();
SELECTION& selection = m_selectionTool->RequestSelection( nonFields ); EE_SELECTION& selection = m_selectionTool->RequestSelection( nonFields );
if( !part || !selection.GetSize() ) if( !part || !selection.GetSize() )
return 0; return 0;
@ -591,7 +591,7 @@ int LIB_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
if( !part ) if( !part )
return 0; return 0;
SELECTION& selection = m_selectionTool->GetSelection(); EE_SELECTION& selection = m_selectionTool->GetSelection();
std::string text = m_toolMgr->GetClipboard(); std::string text = m_toolMgr->GetClipboard();
STRING_LINE_READER reader( text, "Clipboard" ); STRING_LINE_READER reader( text, "Clipboard" );
LIB_PART* newPart; LIB_PART* newPart;
@ -641,8 +641,8 @@ int LIB_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
int LIB_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) int LIB_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
{ {
LIB_PART* part = m_frame->GetCurPart(); LIB_PART* part = m_frame->GetCurPart();
SELECTION& selection = m_selectionTool->RequestSelection( nonFields ); EE_SELECTION& selection = m_selectionTool->RequestSelection( nonFields );
if( selection.GetSize() == 0 ) if( selection.GetSize() == 0 )
return 0; return 0;

View File

@ -83,8 +83,8 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
// Be sure that there is at least one item that we can move. If there's no selection try // Be sure that there is at least one item that we can move. If there's no selection try
// looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection). // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
SELECTION& selection = m_selectionTool->RequestSelection(); EE_SELECTION& selection = m_selectionTool->RequestSelection();
bool unselect = selection.IsHover(); bool unselect = selection.IsHover();
if( selection.Empty() ) if( selection.Empty() )
return 0; return 0;
@ -297,7 +297,7 @@ void LIB_MOVE_TOOL::moveItem( EDA_ITEM* aItem, VECTOR2I aDelta )
} }
bool LIB_MOVE_TOOL::updateModificationPoint( SELECTION& aSelection ) bool LIB_MOVE_TOOL::updateModificationPoint( EE_SELECTION& aSelection )
{ {
if( m_moveInProgress && aSelection.HasReferencePoint() ) if( m_moveInProgress && aSelection.HasReferencePoint() )
return false; return false;

View File

@ -55,7 +55,7 @@ private:
///> Returns the right modification point (e.g. for rotation), depending on the number of ///> Returns the right modification point (e.g. for rotation), depending on the number of
///> selected items. ///> selected items.
bool updateModificationPoint( SELECTION& aSelection ); bool updateModificationPoint( EE_SELECTION& aSelection );
///> Sets up handlers for various events. ///> Sets up handlers for various events.
void setTransitions() override; void setTransitions() override;

View File

@ -294,9 +294,9 @@ void LIB_PIN_TOOL::CreateImagePins( LIB_PIN* aPin )
int LIB_PIN_TOOL::PushPinProperties( const TOOL_EVENT& aEvent ) int LIB_PIN_TOOL::PushPinProperties( const TOOL_EVENT& aEvent )
{ {
LIB_PART* part = m_frame->GetCurPart(); LIB_PART* part = m_frame->GetCurPart();
SELECTION& selection = m_selectionTool->GetSelection(); EE_SELECTION& selection = m_selectionTool->GetSelection();
LIB_PIN* sourcePin = dynamic_cast<LIB_PIN*>( selection.Front() ); LIB_PIN* sourcePin = dynamic_cast<LIB_PIN*>( selection.Front() );
if( !sourcePin ) if( !sourcePin )
return 0; return 0;

View File

@ -173,8 +173,8 @@ bool SCH_DRAWING_TOOLS::Init()
int SCH_DRAWING_TOOLS::AddJunction( const TOOL_EVENT& aEvent ) int SCH_DRAWING_TOOLS::AddJunction( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->GetSelection(); EE_SELECTION& selection = m_selectionTool->GetSelection();
SCH_LINE* wire = dynamic_cast<SCH_LINE*>( selection.Front() ); SCH_LINE* wire = dynamic_cast<SCH_LINE*>( selection.Front() );
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
@ -216,7 +216,7 @@ int SCH_DRAWING_TOOLS::AddLabel( const TOOL_EVENT& aEvent )
int SCH_DRAWING_TOOLS::AddSheetPin( const TOOL_EVENT& aEvent ) int SCH_DRAWING_TOOLS::AddSheetPin( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->GetSelection(); EE_SELECTION& selection = m_selectionTool->GetSelection();
SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( selection.Front() ); SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( selection.Front() );
SCH_HIERLABEL* label = nullptr; SCH_HIERLABEL* label = nullptr;
@ -771,7 +771,7 @@ int SCH_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
else if( item && TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) ) else if( item && TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) )
{ {
// This happens if our text was replaced out from under us by ConvertTextType() // This happens if our text was replaced out from under us by ConvertTextType()
SELECTION& selection = m_selectionTool->GetSelection(); EE_SELECTION& selection = m_selectionTool->GetSelection();
if( selection.GetSize() == 1 ) if( selection.GetSize() == 1 )
{ {

View File

@ -203,7 +203,7 @@ private:
void update() override void update() override
{ {
EE_SELECTION_TOOL* selTool = getToolManager()->GetTool<EE_SELECTION_TOOL>(); EE_SELECTION_TOOL* selTool = getToolManager()->GetTool<EE_SELECTION_TOOL>();
SELECTION& selection = selTool->GetSelection(); EE_SELECTION& selection = selTool->GetSelection();
SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() ); SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
if( !component ) if( !component )
@ -450,7 +450,7 @@ bool SCH_EDIT_TOOL::Init()
int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::RotatableItems ); EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::RotatableItems );
if( selection.GetSize() == 0 ) if( selection.GetSize() == 0 )
return 0; return 0;
@ -620,7 +620,7 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::RotatableItems ); EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::RotatableItems );
if( selection.GetSize() == 0 ) if( selection.GetSize() == 0 )
return 0; return 0;
@ -818,7 +818,7 @@ int SCH_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
EOT EOT
}; };
SELECTION& selection = m_selectionTool->RequestSelection( duplicatableItems ); EE_SELECTION& selection = m_selectionTool->RequestSelection( duplicatableItems );
if( selection.GetSize() == 0 ) if( selection.GetSize() == 0 )
return 0; return 0;
@ -1079,7 +1079,7 @@ int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent )
else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) ) else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
filter = CmpOrFootprint; filter = CmpOrFootprint;
SELECTION& selection = m_selectionTool->RequestSelection( filter ); EE_SELECTION& selection = m_selectionTool->RequestSelection( filter );
if( selection.Empty() ) if( selection.Empty() )
return 0; return 0;
@ -1108,7 +1108,7 @@ int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::AutoplaceFields( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::AutoplaceFields( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly ); EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
if( selection.Empty() ) if( selection.Empty() )
return 0; return 0;
@ -1146,7 +1146,7 @@ int SCH_EDIT_TOOL::UpdateFields( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::ConvertDeMorgan( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::ConvertDeMorgan( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly ); EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
if( selection.Empty() ) if( selection.Empty() )
return 0; return 0;
@ -1175,7 +1175,7 @@ int SCH_EDIT_TOOL::ConvertDeMorgan( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::EditableItems ); EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::EditableItems );
if( selection.Empty() ) if( selection.Empty() )
return 0; return 0;
@ -1267,8 +1267,8 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::ChangeShape( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::ChangeShape( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->GetSelection(); EE_SELECTION& selection = m_selectionTool->GetSelection();
char shape; char shape;
if( aEvent.IsAction( &EE_ACTIONS::toShapeSlash ) ) if( aEvent.IsAction( &EE_ACTIONS::toShapeSlash ) )
shape = '/'; shape = '/';
@ -1302,9 +1302,9 @@ int SCH_EDIT_TOOL::ChangeShape( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
{ {
KICAD_T allTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT }; KICAD_T allTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
SELECTION& selection = m_selectionTool->RequestSelection( allTextTypes ); EE_SELECTION& selection = m_selectionTool->RequestSelection( allTextTypes );
KICAD_T convertTo; KICAD_T convertTo;
if( aEvent.IsAction( &EE_ACTIONS::toLabel ) ) if( aEvent.IsAction( &EE_ACTIONS::toLabel ) )
convertTo = SCH_LABEL_T; convertTo = SCH_LABEL_T;
@ -1347,8 +1347,8 @@ int SCH_EDIT_TOOL::BreakWire( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::CleanupSheetPins( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::CleanupSheetPins( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SheetsOnly ); EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
SCH_SHEET* sheet = (SCH_SHEET*) selection.Front(); SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
if( !sheet ) if( !sheet )
return 0; return 0;

View File

@ -332,11 +332,11 @@ int SCH_EDITOR_CONTROL::FindNext( const TOOL_EVENT& aEvent )
return FindAndReplace( ACTIONS::find.MakeEvent() ); return FindAndReplace( ACTIONS::find.MakeEvent() );
} }
bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY ); bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
SELECTION& selection = m_selectionTool->GetSelection(); EE_SELECTION& selection = m_selectionTool->GetSelection();
SCH_SCREEN* afterScreen = m_frame->GetScreen(); SCH_SCREEN* afterScreen = m_frame->GetScreen();
EDA_ITEM* afterItem = selection.Front(); EDA_ITEM* afterItem = selection.Front();
EDA_ITEM* item = nullptr; EDA_ITEM* item = nullptr;
if( wrapAroundTimer.IsRunning() ) if( wrapAroundTimer.IsRunning() )
{ {
@ -490,14 +490,14 @@ void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aF
if( aForce ) if( aForce )
{ {
SELECTION& selection = selTool->RequestSelection(); EE_SELECTION& selection = selTool->RequestSelection();
if( selection.GetSize() >= 1 ) if( selection.GetSize() >= 1 )
item = (SCH_ITEM*) selection.Front(); item = (SCH_ITEM*) selection.Front();
} }
else else
{ {
SELECTION& selection = selTool->GetSelection(); EE_SELECTION& selection = selTool->GetSelection();
if( selection.GetSize() >= 1 ) if( selection.GetSize() >= 1 )
item = (SCH_ITEM*) selection.Front(); item = (SCH_ITEM*) selection.Front();
@ -861,7 +861,7 @@ int SCH_EDITOR_CONTROL::Redo( const TOOL_EVENT& aEvent )
bool SCH_EDITOR_CONTROL::doCopy() bool SCH_EDITOR_CONTROL::doCopy()
{ {
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>(); EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
SELECTION& selection = selTool->GetSelection(); EE_SELECTION& selection = selTool->GetSelection();
if( !selection.GetSize() ) if( !selection.GetSize() )
return false; return false;
@ -1025,7 +1025,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems ); m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
SELECTION& selection = selTool->GetSelection(); EE_SELECTION& selection = selTool->GetSelection();
if( !selection.Empty() ) if( !selection.Empty() )
{ {
@ -1042,7 +1042,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
int SCH_EDITOR_CONTROL::EditWithLibEdit( const TOOL_EVENT& aEvent ) int SCH_EDITOR_CONTROL::EditWithLibEdit( const TOOL_EVENT& aEvent )
{ {
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>(); EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::ComponentsOnly ); EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
SCH_COMPONENT* sym = nullptr; SCH_COMPONENT* sym = nullptr;
LIB_EDIT_FRAME* libEdit; LIB_EDIT_FRAME* libEdit;
@ -1126,8 +1126,8 @@ int SCH_EDITOR_CONTROL::ShowBusManager( const TOOL_EVENT& aEvent )
int SCH_EDITOR_CONTROL::EnterSheet( const TOOL_EVENT& aEvent ) int SCH_EDITOR_CONTROL::EnterSheet( const TOOL_EVENT& aEvent )
{ {
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>(); EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
const SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly ); const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
if( selection.GetSize() == 1 ) if( selection.GetSize() == 1 )
{ {

View File

@ -165,8 +165,8 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
// Be sure that there is at least one item that we can move. If there's no selection try // Be sure that there is at least one item that we can move. If there's no selection try
// looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection). // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
SELECTION& selection = m_selectionTool->RequestSelection( movableItems ); EE_SELECTION& selection = m_selectionTool->RequestSelection( movableItems );
bool unselect = selection.IsHover(); bool unselect = selection.IsHover();
if( selection.Empty() ) if( selection.Empty() )
return 0; return 0;
@ -548,7 +548,7 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoi
} }
void SCH_MOVE_TOOL::addJunctionsIfNeeded( SELECTION& aSelection ) void SCH_MOVE_TOOL::addJunctionsIfNeeded( EE_SELECTION& aSelection )
{ {
std::vector< wxPoint > pts; std::vector< wxPoint > pts;
std::vector< wxPoint > connections; std::vector< wxPoint > connections;
@ -641,7 +641,7 @@ void SCH_MOVE_TOOL::moveItem( EDA_ITEM* aItem, VECTOR2I aDelta, bool isDrag )
} }
bool SCH_MOVE_TOOL::updateModificationPoint( SELECTION& aSelection ) bool SCH_MOVE_TOOL::updateModificationPoint( EE_SELECTION& aSelection )
{ {
if( m_moveInProgress && aSelection.HasReferencePoint() ) if( m_moveInProgress && aSelection.HasReferencePoint() )
return false; return false;

View File

@ -58,11 +58,11 @@ private:
///> Adds junctions if needed to each item in the list after they have been ///> Adds junctions if needed to each item in the list after they have been
///> moved. ///> moved.
void addJunctionsIfNeeded( SELECTION& aSelection ); void addJunctionsIfNeeded( EE_SELECTION& aSelection );
///> Returns the right modification point (e.g. for rotation), depending on the number of ///> Returns the right modification point (e.g. for rotation), depending on the number of
///> selected items. ///> selected items.
bool updateModificationPoint( SELECTION& aSelection ); bool updateModificationPoint( EE_SELECTION& aSelection );
///> Sets up handlers for various events. ///> Sets up handlers for various events.
void setTransitions() override; void setTransitions() override;

View File

@ -123,7 +123,7 @@ private:
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) getToolManager()->GetEditFrame(); SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) getToolManager()->GetEditFrame();
EE_SELECTION_TOOL* selTool = getToolManager()->GetTool<EE_SELECTION_TOOL>(); EE_SELECTION_TOOL* selTool = getToolManager()->GetTool<EE_SELECTION_TOOL>();
KICAD_T busType[] = { SCH_LINE_LOCATE_BUS_T, EOT }; KICAD_T busType[] = { SCH_LINE_LOCATE_BUS_T, EOT };
SELECTION& selection = selTool->RequestSelection( busType ); EE_SELECTION& selection = selTool->RequestSelection( busType );
SCH_LINE* bus = (SCH_LINE*) selection.Front(); SCH_LINE* bus = (SCH_LINE*) selection.Front();
Clear(); Clear();

View File

@ -63,6 +63,7 @@ set( GERBVIEW_SRCS
gerbview_painter.cpp gerbview_painter.cpp
tools/gerbview_actions.cpp tools/gerbview_actions.cpp
tools/gerbview_selection.cpp
tools/gerbview_selection_tool.cpp tools/gerbview_selection_tool.cpp
tools/gerbview_control.cpp tools/gerbview_control.cpp
gerber_collectors.cpp gerber_collectors.cpp

View File

@ -246,7 +246,7 @@ int GERBVIEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
int GERBVIEW_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) int GERBVIEW_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
{ {
GERBVIEW_SELECTION_TOOL* selTool = m_toolMgr->GetTool<GERBVIEW_SELECTION_TOOL>(); GERBVIEW_SELECTION_TOOL* selTool = m_toolMgr->GetTool<GERBVIEW_SELECTION_TOOL>();
SELECTION& selection = selTool->GetSelection(); GERBVIEW_SELECTION& selection = selTool->GetSelection();
if( selection.GetSize() == 1 ) if( selection.GetSize() == 1 )
{ {

View File

@ -0,0 +1,70 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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 <base_struct.h>
#include <view/view_group.h>
#include <gerber_draw_item.h>
#include <tools/gerbview_selection.h>
VECTOR2I GERBVIEW_SELECTION::GetCenter() const
{
VECTOR2I centre;
if( Size() == 1 )
{
centre = static_cast<GERBER_DRAW_ITEM*>( Front() )->GetPosition();
}
else
{
EDA_RECT bbox = Front()->GetBoundingBox();
auto i = m_items.begin();
++i;
for( ; i != m_items.end(); ++i )
bbox.Merge( (*i)->GetBoundingBox() );
centre = bbox.Centre();
}
return centre;
}
const BOX2I GERBVIEW_SELECTION::ViewBBox() const
{
EDA_RECT eda_bbox;
if( Size() == 1 )
{
eda_bbox = Front()->GetBoundingBox();
}
else if( Size() > 1 )
{
eda_bbox = Front()->GetBoundingBox();
auto i = m_items.begin();
++i;
for( ; i != m_items.end(); ++i )
eda_bbox.Merge( (*i)->GetBoundingBox() );
}
return BOX2I( eda_bbox.GetOrigin(), eda_bbox.GetSize() );
}

View File

@ -0,0 +1,38 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* 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
*/
#ifndef GERBVIEW_SELECTION_H
#define GERBVIEW_SELECTION_H
#include <tool/selection.h>
class GERBVIEW_SELECTION : public SELECTION
{
public:
VECTOR2I GetCenter() const override;
const BOX2I ViewBBox() const override;
};
#endif // GERBVIEW_SELECTION_H

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2017 Jon Evans <jon@craftyjon.com> * Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017-2019 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@ -19,15 +19,12 @@
*/ */
#include <limits> #include <limits>
#include <functional> #include <functional>
using namespace std::placeholders; using namespace std::placeholders;
#include <base_struct.h> #include <base_struct.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <gerber_collectors.h> #include <gerber_collectors.h>
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
#include <view/view.h> #include <view/view.h>
#include <view/view_controls.h> #include <view/view_controls.h>
@ -41,10 +38,8 @@ using namespace std::placeholders;
#include <preview_items/bright_box.h> #include <preview_items/bright_box.h>
#include <preview_items/ruler_item.h> #include <preview_items/ruler_item.h>
#include <preview_items/selection_area.h> #include <preview_items/selection_area.h>
#include <gerbview_id.h> #include <gerbview_id.h>
#include <gerbview_painter.h> #include <gerbview_painter.h>
#include "gerbview_selection_tool.h" #include "gerbview_selection_tool.h"
#include "gerbview_actions.h" #include "gerbview_actions.h"
@ -267,7 +262,7 @@ int GERBVIEW_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
} }
SELECTION& GERBVIEW_SELECTION_TOOL::GetSelection() GERBVIEW_SELECTION& GERBVIEW_SELECTION_TOOL::GetSelection()
{ {
return m_selection; return m_selection;
} }
@ -868,62 +863,3 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
} }
VECTOR2I SELECTION::GetCenter() const
{
VECTOR2I centre;
if( Size() == 1 )
{
centre = static_cast<GERBER_DRAW_ITEM*>( Front() )->GetPosition();
}
else
{
EDA_RECT bbox = Front()->GetBoundingBox();
auto i = m_items.begin();
++i;
for( ; i != m_items.end(); ++i )
{
bbox.Merge( (*i)->GetBoundingBox() );
}
centre = bbox.Centre();
}
return centre;
}
const BOX2I SELECTION::ViewBBox() const
{
EDA_RECT eda_bbox;
if( Size() == 1 )
{
eda_bbox = Front()->GetBoundingBox();
}
else if( Size() > 1 )
{
eda_bbox = Front()->GetBoundingBox();
auto i = m_items.begin();
++i;
for( ; i != m_items.end(); ++i )
{
eda_bbox.Merge( (*i)->GetBoundingBox() );
}
}
return BOX2I( eda_bbox.GetOrigin(), eda_bbox.GetSize() );
}
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const
{
std::vector<VIEW_ITEM*> items;
for( auto item : m_items )
items.push_back( item );
return items;
}

View File

@ -18,18 +18,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __GERBVIEW_SELECTION_TOOL_H #ifndef GERBVIEW_SELECTION_TOOL_H
#define __GERBVIEW_SELECTION_TOOL_H #define GERBVIEW_SELECTION_TOOL_H
#include <memory> #include <memory>
#include <math/vector2d.h> #include <math/vector2d.h>
#include <tool/tool_interactive.h> #include <tool/tool_interactive.h>
#include <tool/action_menu.h> #include <tool/action_menu.h>
#include <tool/selection.h>
#include <tool/selection_conditions.h> #include <tool/selection_conditions.h>
#include <tool/tool_menu.h> #include <tool/tool_menu.h>
#include <tools/gerbview_selection.h>
#include <gerbview_frame.h> #include <gerbview_frame.h>
class SELECTION_AREA; class SELECTION_AREA;
@ -73,7 +71,7 @@ public:
* *
* Returns the set of currently selected items. * Returns the set of currently selected items.
*/ */
SELECTION& GetSelection(); GERBVIEW_SELECTION& GetSelection();
///> Select a single item under cursor event handler. ///> Select a single item under cursor event handler.
int CursorSelection( const TOOL_EVENT& aEvent ); int CursorSelection( const TOOL_EVENT& aEvent );
@ -215,7 +213,7 @@ private:
GERBVIEW_FRAME* m_frame; GERBVIEW_FRAME* m_frame;
/// Current state of selection. /// Current state of selection.
SELECTION m_selection; GERBVIEW_SELECTION m_selection;
/// Flag saying if items should be added to the current selection or rather replace it. /// Flag saying if items should be added to the current selection or rather replace it.
bool m_additive; bool m_additive;

View File

@ -23,11 +23,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#ifndef __SELECTION_H #ifndef SELECTION_H
#define __SELECTION_H #define SELECTION_H
#include <deque> #include <deque>
#include <eda_rect.h>
#include <base_struct.h> #include <base_struct.h>
#include <view/view_group.h> #include <view/view_group.h>
@ -118,7 +118,7 @@ public:
/// Checks if there is anything selected /// Checks if there is anything selected
bool Empty() const bool Empty() const
{ {
return ( m_items.size() == 0 ); return m_items.empty();
} }
/// Returns the number of selected parts /// Returns the number of selected parts
@ -131,17 +131,46 @@ public:
{ {
return m_items; return m_items;
} }
/// Returns the center point of the selection area bounding box. /// Returns the center point of the selection area bounding box.
VECTOR2I GetCenter() const; virtual VECTOR2I GetCenter() const
{
return static_cast<VECTOR2I>( GetBoundingBox().Centre() );
}
const BOX2I ViewBBox() const override; virtual const BOX2I ViewBBox() const override
{
BOX2I r;
r.SetMaximum();
return r;
}
/// Returns the top left point of the selection area bounding box. /// Returns the top left point of the selection area bounding box.
VECTOR2I GetPosition() const; VECTOR2I GetPosition() const
{
return static_cast<VECTOR2I>( GetBoundingBox().GetPosition() );
}
EDA_RECT GetBoundingBox() const; EDA_RECT GetBoundingBox() const
EDA_ITEM* GetTopLeftItem( bool onlyModules = false ) const; {
EDA_RECT bbox;
bbox = Front()->GetBoundingBox();
auto i = m_items.begin();
++i;
for( ; i != m_items.end(); ++i )
{
bbox.Merge( (*i)->GetBoundingBox() );
}
return bbox;
}
virtual EDA_ITEM* GetTopLeftItem( bool onlyModules = false ) const
{
return nullptr;
}
EDA_ITEM* operator[]( const size_t aIdx ) const EDA_ITEM* operator[]( const size_t aIdx ) const
{ {
@ -192,7 +221,15 @@ public:
return false; return false;
} }
virtual const VIEW_GROUP::ITEMS updateDrawList() const override; virtual const VIEW_GROUP::ITEMS updateDrawList() const override
{
std::vector<VIEW_ITEM*> items;
for( auto item : m_items )
items.push_back( item );
return items;
}
bool HasReferencePoint() const bool HasReferencePoint() const
{ {
@ -214,14 +251,10 @@ public:
m_referencePoint = NULLOPT; m_referencePoint = NULLOPT;
} }
private: protected:
OPT<VECTOR2I> m_referencePoint;
OPT<VECTOR2I> m_referencePoint;
/// Set of selected items
std::deque<EDA_ITEM*> m_items; std::deque<EDA_ITEM*> m_items;
bool m_isHover;
bool m_isHover;
// mute hidden overloaded virtual function warnings // mute hidden overloaded virtual function warnings
using VIEW_GROUP::Add; using VIEW_GROUP::Add;

View File

@ -28,13 +28,13 @@ set( PL_EDITOR_SRCS
menubar.cpp menubar.cpp
toolbars_pl_editor.cpp toolbars_pl_editor.cpp
tools/pl_selection.cpp
tools/pl_selection_tool.cpp tools/pl_selection_tool.cpp
tools/pl_drawing_tools.cpp tools/pl_drawing_tools.cpp
tools/pl_edit_tool.cpp tools/pl_edit_tool.cpp
tools/pl_editor_control.cpp tools/pl_editor_control.cpp
tools/pl_picker_tool.cpp tools/pl_picker_tool.cpp
tools/pl_point_editor.cpp tools/pl_point_editor.cpp
tools/selection.cpp
) )
set( PL_EDITOR_EXTRA_SRCS set( PL_EDITOR_EXTRA_SRCS

View File

@ -113,8 +113,8 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
// Be sure that there is at least one item that we can move. If there's no selection try // Be sure that there is at least one item that we can move. If there's no selection try
// looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection). // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
SELECTION& selection = m_selectionTool->RequestSelection(); PL_SELECTION& selection = m_selectionTool->RequestSelection();
bool unselect = selection.IsHover(); bool unselect = selection.IsHover();
if( selection.Empty() ) if( selection.Empty() )
return 0; return 0;
@ -285,7 +285,7 @@ void PL_EDIT_TOOL::moveItem( EDA_ITEM* aItem, VECTOR2I aDelta )
} }
bool PL_EDIT_TOOL::updateModificationPoint( SELECTION& aSelection ) bool PL_EDIT_TOOL::updateModificationPoint( PL_SELECTION& aSelection )
{ {
if( m_moveInProgress && aSelection.HasReferencePoint() ) if( m_moveInProgress && aSelection.HasReferencePoint() )
return false; return false;
@ -320,7 +320,7 @@ int PL_EDIT_TOOL::ImportWorksheetContent( const TOOL_EVENT& aEvent )
int PL_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) int PL_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection(); PL_SELECTION& selection = m_selectionTool->RequestSelection();
if( selection.Size() == 0 ) if( selection.Size() == 0 )
return 0; return 0;
@ -412,7 +412,7 @@ int PL_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
int PL_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent ) int PL_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection(); PL_SELECTION& selection = m_selectionTool->RequestSelection();
std::vector<WS_DATA_ITEM*> items; std::vector<WS_DATA_ITEM*> items;
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance(); WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
wxString sexpr; wxString sexpr;
@ -441,7 +441,7 @@ int PL_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
int PL_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent ) int PL_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->GetSelection(); PL_SELECTION& selection = m_selectionTool->GetSelection();
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance(); WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
std::string sexpr = m_toolMgr->GetClipboard(); std::string sexpr = m_toolMgr->GetClipboard();

View File

@ -71,7 +71,7 @@ private:
///> Returns the right modification point (e.g. for rotation), depending on the number of ///> Returns the right modification point (e.g. for rotation), depending on the number of
///> selected items. ///> selected items.
bool updateModificationPoint( SELECTION& aSelection ); bool updateModificationPoint( PL_SELECTION& aSelection );
///> Sets up handlers for various events. ///> Sets up handlers for various events.
void setTransitions() override; void setTransitions() override;

View File

@ -149,7 +149,7 @@ int PL_EDITOR_CONTROL::ToggleBackgroundColor( const TOOL_EVENT& aEvent )
int PL_EDITOR_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) int PL_EDITOR_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
{ {
PL_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>(); PL_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>();
SELECTION& selection = selTool->GetSelection(); PL_SELECTION& selection = selTool->GetSelection();
// The Properties frame will be updated. Avoid flicker during update: // The Properties frame will be updated. Avoid flicker during update:
m_frame->GetPropertiesFrame()->Freeze(); m_frame->GetPropertiesFrame()->Freeze();

View File

@ -150,7 +150,7 @@ int PL_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
if( !m_selectionTool ) if( !m_selectionTool )
return 0; return 0;
const SELECTION& selection = m_selectionTool->GetSelection(); const PL_SELECTION& selection = m_selectionTool->GetSelection();
if( selection.Size() != 1 || !selection.Front()->IsType( pointTypes ) ) if( selection.Size() != 1 || !selection.Front()->IsType( pointTypes ) )
return 0; return 0;

View File

@ -21,40 +21,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <limits> #include <tools/pl_selection.h>
#include <functional>
#include <tool/selection.h>
#include <ws_draw_item.h> #include <ws_draw_item.h>
VECTOR2I SELECTION::GetPosition() const
{
return static_cast<VECTOR2I>( GetBoundingBox().GetPosition() );
}
EDA_ITEM* PL_SELECTION::GetTopLeftItem( bool onlyModules ) const
VECTOR2I SELECTION::GetCenter() const
{
return static_cast<VECTOR2I>( GetBoundingBox().Centre() );
}
EDA_RECT SELECTION::GetBoundingBox() const
{
EDA_RECT bbox;
bbox = Front()->GetBoundingBox();
auto i = m_items.begin();
++i;
for( ; i != m_items.end(); ++i )
bbox.Merge( (*i)->GetBoundingBox() );
return bbox;
}
EDA_ITEM* SELECTION::GetTopLeftItem( bool onlyModules ) const
{ {
WS_DRAW_ITEM_BASE* topLeftItem = nullptr; WS_DRAW_ITEM_BASE* topLeftItem = nullptr;
EDA_RECT topLeftItemBB; EDA_RECT topLeftItemBB;
@ -86,21 +57,3 @@ EDA_ITEM* SELECTION::GetTopLeftItem( bool onlyModules ) const
return static_cast<EDA_ITEM*>( topLeftItem ); return static_cast<EDA_ITEM*>( topLeftItem );
} }
const BOX2I SELECTION::ViewBBox() const
{
BOX2I r;
r.SetMaximum();
return r;
}
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const
{
std::vector<VIEW_ITEM*> items;
for( auto item : m_items )
items.push_back( item );
return items;
}

View File

@ -0,0 +1,36 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* 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
*/
#ifndef PL_SELECTION_H
#define PL_SELECTION_H
#include <tool/selection.h>
class PL_SELECTION : public SELECTION
{
public:
EDA_ITEM* GetTopLeftItem( bool onlyModules = false ) const override;
};
#endif // PL_SELECTION_H

View File

@ -227,7 +227,7 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
} }
SELECTION& PL_SELECTION_TOOL::GetSelection() PL_SELECTION& PL_SELECTION_TOOL::GetSelection()
{ {
return m_selection; return m_selection;
} }
@ -307,7 +307,7 @@ void PL_SELECTION_TOOL::guessSelectionCandidates( COLLECTOR& collector, const VE
} }
SELECTION& PL_SELECTION_TOOL::RequestSelection() PL_SELECTION& PL_SELECTION_TOOL::RequestSelection()
{ {
// If nothing is selected do a hover selection // If nothing is selected do a hover selection
if( m_selection.Empty() ) if( m_selection.Empty() )
@ -660,7 +660,7 @@ void PL_SELECTION_TOOL::unselect( EDA_ITEM* aItem )
} }
void PL_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup ) void PL_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, PL_SELECTION* aGroup )
{ {
if( aMode == SELECTED ) if( aMode == SELECTED )
aItem->SetSelected(); aItem->SetSelected();
@ -674,7 +674,7 @@ void PL_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup
} }
void PL_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup ) void PL_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, PL_SELECTION* aGroup )
{ {
if( aMode == SELECTED ) if( aMode == SELECTED )
aItem->ClearSelected(); aItem->ClearSelected();

View File

@ -25,9 +25,8 @@
#define PL_SELECTION_TOOL_H #define PL_SELECTION_TOOL_H
#include <tool/tool_interactive.h> #include <tool/tool_interactive.h>
#include <tool/action_menu.h>
#include <tool/tool_menu.h> #include <tool/tool_menu.h>
#include <tool/selection.h> #include <tools/pl_selection.h>
class PL_EDITOR_FRAME; class PL_EDITOR_FRAME;
class SCH_ITEM; class SCH_ITEM;
@ -72,7 +71,7 @@ public:
* *
* Returns the set of currently selected items. * Returns the set of currently selected items.
*/ */
SELECTION& GetSelection(); PL_SELECTION& GetSelection();
/** /**
* Function RequestSelection() * Function RequestSelection()
@ -80,7 +79,7 @@ public:
* Returns either an existing selection (filtered), or the selection at the current * Returns either an existing selection (filtered), or the selection at the current
* cursor if the existing selection is empty. * cursor if the existing selection is empty.
*/ */
SELECTION& RequestSelection(); PL_SELECTION& RequestSelection();
/** /**
* Function selectPoint() * Function selectPoint()
@ -178,7 +177,7 @@ private:
* @param aHighlightMode should be either SELECTED or BRIGHTENED * @param aHighlightMode should be either SELECTED or BRIGHTENED
* @param aGroup is the group to add the item to in the BRIGHTENED mode. * @param aGroup is the group to add the item to in the BRIGHTENED mode.
*/ */
void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ); void highlight( EDA_ITEM* aItem, int aHighlightMode, PL_SELECTION* aGroup = nullptr );
/** /**
* Function unhighlight() * Function unhighlight()
@ -187,7 +186,7 @@ private:
* @param aHighlightMode should be either SELECTED or BRIGHTENED * @param aHighlightMode should be either SELECTED or BRIGHTENED
* @param aGroup is the group to remove the item from. * @param aGroup is the group to remove the item from.
*/ */
void unhighlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ); void unhighlight( EDA_ITEM* aItem, int aHighlightMode, PL_SELECTION* aGroup = nullptr );
/** /**
* Function selectionContains() * Function selectionContains()
@ -202,7 +201,7 @@ private:
private: private:
PL_EDITOR_FRAME* m_frame; // Pointer to the parent frame PL_EDITOR_FRAME* m_frame; // Pointer to the parent frame
SELECTION m_selection; // Current state of selection PL_SELECTION m_selection; // Current state of selection
bool m_additive; // Items should be added to selection (instead of replacing) bool m_additive; // Items should be added to selection (instead of replacing)
bool m_subtractive; // Items should be removed from selection bool m_subtractive; // Items should be removed from selection

View File

@ -305,10 +305,10 @@ set( PCBNEW_CLASS_SRCS
tools/pcb_tool_base.cpp tools/pcb_tool_base.cpp
tools/pcbnew_control.cpp tools/pcbnew_control.cpp
tools/pcbnew_picker_tool.cpp tools/pcbnew_picker_tool.cpp
tools/pcbnew_selection.cpp
tools/placement_tool.cpp tools/placement_tool.cpp
tools/point_editor.cpp tools/point_editor.cpp
tools/position_relative_tool.cpp tools/position_relative_tool.cpp
tools/selection.cpp
tools/selection_tool.cpp tools/selection_tool.cpp
tools/tool_event_utils.cpp tools/tool_event_utils.cpp
tools/zone_create_helper.cpp tools/zone_create_helper.cpp

View File

@ -538,7 +538,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
GRID_HELPER grid( m_frame ); GRID_HELPER grid( m_frame );
// Add a VIEW_GROUP that serves as a preview for the new item // Add a VIEW_GROUP that serves as a preview for the new item
SELECTION preview; PCBNEW_SELECTION preview;
m_view->Add( &preview ); m_view->Add( &preview );
@ -802,7 +802,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
m_frame->SetNoToolSelected(); m_frame->SetNoToolSelected();
// Add a VIEW_GROUP that serves as a preview for the new item // Add a VIEW_GROUP that serves as a preview for the new item
SELECTION preview; PCBNEW_SELECTION preview;
BOARD_COMMIT commit( m_frame ); BOARD_COMMIT commit( m_frame );
// Build the undo list & add items to the current view // Build the undo list & add items to the current view
@ -975,7 +975,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
m_frame->SetActiveLayer( getDrawingLayer() ); m_frame->SetActiveLayer( getDrawingLayer() );
// Add a VIEW_GROUP that serves as a preview for the new item // Add a VIEW_GROUP that serves as a preview for the new item
SELECTION preview; PCBNEW_SELECTION preview;
m_view->Add( &preview ); m_view->Add( &preview );
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
@ -1209,7 +1209,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager, m_frame->GetUserUnits() ); KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager, m_frame->GetUserUnits() );
// Add a VIEW_GROUP that serves as a preview for the new item // Add a VIEW_GROUP that serves as a preview for the new item
SELECTION preview; PCBNEW_SELECTION preview;
m_view->Add( &preview ); m_view->Add( &preview );
m_view->Add( &arcAsst ); m_view->Add( &arcAsst );
GRID_HELPER grid( m_frame ); GRID_HELPER grid( m_frame );
@ -1341,8 +1341,8 @@ bool DRAWING_TOOL::getSourceZoneForAction( ZONE_MODE aMode, ZONE_CONTAINER*& aZo
if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::GRAPHIC_POLYGON ) if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::GRAPHIC_POLYGON )
return true; return true;
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>(); SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection(); const PCBNEW_SELECTION& selection = selTool->GetSelection();
if( selection.Empty() ) if( selection.Empty() )
{ {

View File

@ -579,7 +579,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
return 0; return 0;
} }
bool EDIT_TOOL::changeTrackWidthOnClick( const SELECTION& selection ) bool EDIT_TOOL::changeTrackWidthOnClick( const PCBNEW_SELECTION& selection )
{ {
if ( selection.Size() == 1 && frame()->Settings().g_EditHotkeyChangesTrackWidth ) if ( selection.Size() == 1 && frame()->Settings().g_EditHotkeyChangesTrackWidth )
{ {
@ -875,7 +875,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
std::vector<BOARD_ITEM*> lockedItems; std::vector<BOARD_ITEM*> lockedItems;
// get a copy instead of reference (as we're going to clear the selection before removing items) // get a copy instead of reference (as we're going to clear the selection before removing items)
SELECTION selectionCopy; PCBNEW_SELECTION selectionCopy;
bool isCut = aEvent.Parameter<intptr_t>() == static_cast<intptr_t>( PCB_ACTIONS::REMOVE_FLAGS::CUT ); bool isCut = aEvent.Parameter<intptr_t>() == static_cast<intptr_t>( PCB_ACTIONS::REMOVE_FLAGS::CUT );
bool isAlt = aEvent.Parameter<intptr_t>() == static_cast<intptr_t>( PCB_ACTIONS::REMOVE_FLAGS::ALT ); bool isAlt = aEvent.Parameter<intptr_t>() == static_cast<intptr_t>( PCB_ACTIONS::REMOVE_FLAGS::ALT );
@ -1273,7 +1273,7 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
} }
bool EDIT_TOOL::updateModificationPoint( SELECTION& aSelection ) bool EDIT_TOOL::updateModificationPoint( PCBNEW_SELECTION& aSelection )
{ {
if( m_dragging && aSelection.HasReferencePoint() ) if( m_dragging && aSelection.HasReferencePoint() )
return false; return false;
@ -1375,7 +1375,7 @@ int EDIT_TOOL::doCopyToClipboard( bool withAnchor )
Activate(); Activate();
SELECTION& selection = m_selectionTool->RequestSelection( PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ) []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
{ EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); } ); { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS ); } );

View File

@ -202,14 +202,14 @@ private:
///> Returns the right modification point (e.g. for rotation), depending on the number of ///> Returns the right modification point (e.g. for rotation), depending on the number of
///> selected items. ///> selected items.
bool updateModificationPoint( SELECTION& aSelection ); bool updateModificationPoint( PCBNEW_SELECTION& aSelection );
int EditFpInFpEditor( const TOOL_EVENT& aEvent ); int EditFpInFpEditor( const TOOL_EVENT& aEvent );
bool invokeInlineRouter( int aDragMode ); bool invokeInlineRouter( int aDragMode );
bool isInteractiveDragEnabled() const; bool isInteractiveDragEnabled() const;
bool changeTrackWidthOnClick( const SELECTION& selection ); bool changeTrackWidthOnClick( const PCBNEW_SELECTION& selection );
bool pickCopyReferencePoint( VECTOR2I& aP ); bool pickCopyReferencePoint( VECTOR2I& aP );
std::unique_ptr<BOARD_COMMIT> m_commit; std::unique_ptr<BOARD_COMMIT> m_commit;

View File

@ -615,8 +615,8 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
int MODULE_EDITOR_TOOLS::ExplodePadToShapes( const TOOL_EVENT& aEvent ) int MODULE_EDITOR_TOOLS::ExplodePadToShapes( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection(); PCBNEW_SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
BOARD_COMMIT commit( m_frame ); BOARD_COMMIT commit( m_frame );
if( selection.Size() != 1 ) if( selection.Size() != 1 )
return 0; return 0;
@ -664,7 +664,7 @@ int MODULE_EDITOR_TOOLS::ExplodePadToShapes( const TOOL_EVENT& aEvent )
int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection(); PCBNEW_SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
std::unique_ptr<D_PAD> pad( new D_PAD( board()->GetFirstModule() ) ); std::unique_ptr<D_PAD> pad( new D_PAD( board()->GetFirstModule() ) );
D_PAD *refPad = nullptr; D_PAD *refPad = nullptr;

View File

@ -109,10 +109,10 @@ bool GLOBAL_EDIT_TOOL::Init()
int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent ) int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection( EDIT_TOOL::FootprintFilter ); PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection( EDIT_TOOL::FootprintFilter );
MODULE* mod = (selection.Empty() ? nullptr : selection.FirstOfKind<MODULE> () ); MODULE* mod = (selection.Empty() ? nullptr : selection.FirstOfKind<MODULE> () );
bool updateMode = false; bool updateMode = false;
bool currentMode = false; bool currentMode = false;
if( aEvent.IsAction( &PCB_ACTIONS::updateFootprint ) ) if( aEvent.IsAction( &PCB_ACTIONS::updateFootprint ) )
{ {

View File

@ -30,16 +30,15 @@
#include <view/view.h> #include <view/view.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <class_board_item.h> #include <class_board_item.h>
#include <class_module.h> #include <class_module.h>
#include <board_commit.h> #include <board_commit.h>
#include <dialogs/dialog_push_pad_properties.h> #include <dialogs/dialog_push_pad_properties.h>
#include "pcb_actions.h" #include <tools/pcb_actions.h>
#include "selection_tool.h" #include <tools/pcbnew_selection.h>
#include "pcb_selection_conditions.h" #include <tools/selection_tool.h>
#include "edit_tool.h" #include <tools/pcb_selection_conditions.h>
#include <tools/edit_tool.h>
#include "pcbnew_id.h" #include "pcbnew_id.h"
// Pad tools // Pad tools
@ -128,7 +127,7 @@ private:
void update() override void update() override
{ {
auto selTool = getToolManager()->GetTool<SELECTION_TOOL>(); auto selTool = getToolManager()->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection(); const PCBNEW_SELECTION& selection = selTool->GetSelection();
auto enablements = getEnablements( selection ); auto enablements = getEnablements( selection );

View File

@ -829,8 +829,8 @@ int PCB_EDITOR_CONTROL::UnlockSelected( const TOOL_EVENT& aEvent )
int PCB_EDITOR_CONTROL::modifyLockSelected( MODIFY_MODE aMode ) int PCB_EDITOR_CONTROL::modifyLockSelected( MODIFY_MODE aMode )
{ {
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>(); SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection(); const PCBNEW_SELECTION& selection = selTool->GetSelection();
if( selection.Empty() ) if( selection.Empty() )
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
@ -999,9 +999,9 @@ static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aO
int PCB_EDITOR_CONTROL::ZoneMerge( const TOOL_EVENT& aEvent ) int PCB_EDITOR_CONTROL::ZoneMerge( const TOOL_EVENT& aEvent )
{ {
const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection(); const PCBNEW_SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
BOARD* board = getModel<BOARD>(); BOARD* board = getModel<BOARD>();
BOARD_COMMIT commit( m_frame ); BOARD_COMMIT commit( m_frame );
if( selection.Size() < 2 ) if( selection.Size() < 2 )
return 0; return 0;
@ -1115,8 +1115,8 @@ int PCB_EDITOR_CONTROL::CrossProbePcbToSch( const TOOL_EVENT& aEvent )
return 0; return 0;
} }
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>(); SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection(); const PCBNEW_SELECTION& selection = selTool->GetSelection();
if( selection.Size() == 1 ) if( selection.Size() == 1 )
m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) ); m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
@ -1217,7 +1217,7 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition,
{ {
auto selectionTool = aToolMgr->GetTool<SELECTION_TOOL>(); auto selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selectionTool->GetSelection(); const PCBNEW_SELECTION& selection = selectionTool->GetSelection();
for( auto item : selection ) for( auto item : selection )
{ {
@ -1381,7 +1381,7 @@ static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, BOARD* aBoard, const VECT
aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
aToolMgr->RunAction( PCB_ACTIONS::selectionCursor, true, EDIT_TOOL::PadFilter ); aToolMgr->RunAction( PCB_ACTIONS::selectionCursor, true, EDIT_TOOL::PadFilter );
SELECTION& selection = selectionTool->GetSelection(); PCBNEW_SELECTION& selection = selectionTool->GetSelection();
if( selection.Empty() ) if( selection.Empty() )
{ {

View File

@ -50,7 +50,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer
controls()->SetSnapping( true ); controls()->SetSnapping( true );
// Add a VIEW_GROUP that serves as a preview for the new item // Add a VIEW_GROUP that serves as a preview for the new item
SELECTION preview; PCBNEW_SELECTION preview;
view()->Add( &preview ); view()->Add( &preview );
aPlacer->m_board = board(); aPlacer->m_board = board();
@ -246,7 +246,7 @@ PCB_DRAW_PANEL_GAL* PCB_TOOL_BASE::canvas() const
} }
const SELECTION& PCB_TOOL_BASE::selection() const const PCBNEW_SELECTION& PCB_TOOL_BASE::selection() const
{ {
auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>(); auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const auto& selection = selTool->GetSelection(); const auto& selection = selTool->GetSelection();
@ -254,7 +254,7 @@ const SELECTION& PCB_TOOL_BASE::selection() const
} }
SELECTION& PCB_TOOL_BASE::selection() PCBNEW_SELECTION& PCB_TOOL_BASE::selection()
{ {
auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>(); auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
auto& selection = selTool->GetSelection(); auto& selection = selTool->GetSelection();

View File

@ -47,7 +47,7 @@
class PCB_TOOL_BASE; class PCB_TOOL_BASE;
class PCB_EDIT_FRAME; class PCB_EDIT_FRAME;
class PCB_DISPLAY_OPTIONS; class PCB_DISPLAY_OPTIONS;
class SELECTION; class PCBNEW_SELECTION;
struct INTERACTIVE_PLACER_BASE struct INTERACTIVE_PLACER_BASE
{ {
@ -144,8 +144,8 @@ protected:
} }
PCB_DISPLAY_OPTIONS* displayOptions() const; PCB_DISPLAY_OPTIONS* displayOptions() const;
PCB_DRAW_PANEL_GAL* canvas() const; PCB_DRAW_PANEL_GAL* canvas() const;
const SELECTION& selection() const; const PCBNEW_SELECTION& selection() const;
SELECTION& selection(); PCBNEW_SELECTION& selection();
bool m_editModules; bool m_editModules;
}; };

View File

@ -633,7 +633,7 @@ static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
const SELECTION& selection = selectionTool->RequestSelection( const PCBNEW_SELECTION& selection = selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ) []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
{ EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED ); } ); { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED ); } );
@ -842,7 +842,7 @@ int PCBNEW_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsN
auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>(); auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
auto editTool = m_toolMgr->GetTool<EDIT_TOOL>(); auto editTool = m_toolMgr->GetTool<EDIT_TOOL>();
SELECTION& selection = selectionTool->GetSelection(); PCBNEW_SELECTION& selection = selectionTool->GetSelection();
for( auto item : aItems ) for( auto item : aItems )
{ {
@ -1019,8 +1019,8 @@ void PCBNEW_CONTROL::updateGrid()
int PCBNEW_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
{ {
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>(); SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
SELECTION& selection = selTool->GetSelection(); PCBNEW_SELECTION& selection = selTool->GetSelection();
if( selection.GetSize() == 1 ) if( selection.GetSize() == 1 )
{ {

View File

@ -110,7 +110,7 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
{ {
SELECTION dummy; PCBNEW_SELECTION dummy;
m_menu.ShowContextMenu( dummy ); m_menu.ShowContextMenu( dummy );
} }

View File

@ -36,58 +36,26 @@ using namespace std::placeholders;
#include <class_pcb_text.h> #include <class_pcb_text.h>
#include <class_drawsegment.h> #include <class_drawsegment.h>
#include <class_zone.h> #include <class_zone.h>
#include <pcb_edit_frame.h> #include <pcb_edit_frame.h>
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
#include <view/view_controls.h> #include <view/view_controls.h>
#include <view/view_group.h> #include <view/view_group.h>
#include <preview_items/selection_area.h> #include <preview_items/selection_area.h>
#include <painter.h> #include <painter.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <hotkeys.h>
#include <tool/tool_event.h> #include <tool/tool_event.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/pcbnew_selection.h>
#include <connectivity/connectivity_data.h> #include <connectivity/connectivity_data.h>
#include "selection_tool.h" #include "selection_tool.h"
#include "pcb_bright_box.h" #include "pcb_bright_box.h"
#include "pcb_actions.h" #include "pcb_actions.h"
#include "kicad_plugin.h" #include "kicad_plugin.h"
// TODO(JE) Only works for BOARD_ITEM
VECTOR2I SELECTION::GetPosition() const
{
return static_cast<VECTOR2I>( GetBoundingBox().GetPosition() );
}
VECTOR2I SELECTION::GetCenter() const EDA_ITEM* PCBNEW_SELECTION::GetTopLeftItem( bool onlyModules ) const
{
return static_cast<VECTOR2I>( GetBoundingBox().Centre() );
}
EDA_RECT SELECTION::GetBoundingBox() const
{
EDA_RECT bbox;
bbox = Front()->GetBoundingBox();
auto i = m_items.begin();
++i;
for( ; i != m_items.end(); ++i )
{
bbox.Merge( (*i)->GetBoundingBox() );
}
return bbox;
}
EDA_ITEM* SELECTION::GetTopLeftItem( bool onlyModules ) const
{ {
BOARD_ITEM* topLeftItem = nullptr; BOARD_ITEM* topLeftItem = nullptr;
BOARD_ITEM* currentItem; BOARD_ITEM* currentItem;
@ -123,15 +91,7 @@ EDA_ITEM* SELECTION::GetTopLeftItem( bool onlyModules ) const
} }
const BOX2I SELECTION::ViewBBox() const const KIGFX::VIEW_GROUP::ITEMS PCBNEW_SELECTION::updateDrawList() const
{
BOX2I r;
r.SetMaximum();
return r;
}
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const
{ {
std::vector<VIEW_ITEM*> items; std::vector<VIEW_ITEM*> items;

View File

@ -0,0 +1,38 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* 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
*/
#ifndef PCBNEW_SELECTION_H
#define PCBNEW_SELECTION_H
#include <tool/selection.h>
class PCBNEW_SELECTION : public SELECTION
{
public:
EDA_ITEM* GetTopLeftItem( bool onlyModules = false ) const override;
const KIGFX::VIEW_GROUP::ITEMS updateDrawList() const override;
};
#endif // PCBNEW_SELECTION_H

View File

@ -184,7 +184,7 @@ template< typename T >
size_t ALIGN_DISTRIBUTE_TOOL::GetSelections( ALIGNMENT_RECTS& aItems, ALIGNMENT_RECTS& aLocked, T aCompare ) size_t ALIGN_DISTRIBUTE_TOOL::GetSelections( ALIGNMENT_RECTS& aItems, ALIGNMENT_RECTS& aLocked, T aCompare )
{ {
SELECTION& selection = m_selectionTool->RequestSelection( PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ) []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
{ EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } ); { EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } );
@ -435,7 +435,7 @@ int ALIGN_DISTRIBUTE_TOOL::AlignCenterY( const TOOL_EVENT& aEvent )
int ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally( const TOOL_EVENT& aEvent ) int ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection( PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ) []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
{ EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED | EXCLUDE_TRANSIENTS ); } ); { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED | EXCLUDE_TRANSIENTS ); } );
@ -537,7 +537,7 @@ void ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally( ALIGNMENT_RECTS &it
int ALIGN_DISTRIBUTE_TOOL::DistributeVertically( const TOOL_EVENT& aEvent ) int ALIGN_DISTRIBUTE_TOOL::DistributeVertically( const TOOL_EVENT& aEvent )
{ {
SELECTION& selection = m_selectionTool->RequestSelection( PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ) []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
{ EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED | EXCLUDE_TRANSIENTS ); } ); { EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED | EXCLUDE_TRANSIENTS ); } );

View File

@ -301,7 +301,7 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
if( !m_selectionTool ) if( !m_selectionTool )
return 0; return 0;
const SELECTION& selection = m_selectionTool->GetSelection(); const PCBNEW_SELECTION& selection = m_selectionTool->GetSelection();
if( selection.Size() != 1 ) if( selection.Size() != 1 )
return 0; return 0;

View File

@ -150,7 +150,7 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent
picker->SetClickHandler( [&]( const VECTOR2D& aPoint ) -> bool picker->SetClickHandler( [&]( const VECTOR2D& aPoint ) -> bool
{ {
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
const SELECTION& sel = m_selectionTool->RequestSelection( const PCBNEW_SELECTION& sel = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector ) []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector )
{ EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } ); { EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS ); } );

View File

@ -41,7 +41,6 @@ using namespace std::placeholders;
#include <confirm.h> #include <confirm.h>
#include <dialog_find.h> #include <dialog_find.h>
#include <dialog_block_options.h> #include <dialog_block_options.h>
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
#include <view/view_controls.h> #include <view/view_controls.h>
#include <view/view_group.h> #include <view/view_group.h>
@ -56,7 +55,6 @@ using namespace std::placeholders;
#include <connectivity/connectivity_data.h> #include <connectivity/connectivity_data.h>
#include <footprint_viewer_frame.h> #include <footprint_viewer_frame.h>
#include "tool_event_utils.h" #include "tool_event_utils.h"
#include "selection_tool.h" #include "selection_tool.h"
#include "pcb_bright_box.h" #include "pcb_bright_box.h"
#include "pcb_actions.h" #include "pcb_actions.h"
@ -381,13 +379,13 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
} }
SELECTION& SELECTION_TOOL::GetSelection() PCBNEW_SELECTION& SELECTION_TOOL::GetSelection()
{ {
return m_selection; return m_selection;
} }
SELECTION& SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aClientFilter, PCBNEW_SELECTION& SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aClientFilter,
std::vector<BOARD_ITEM*>* aFiltered, bool aConfirmLockedItems ) std::vector<BOARD_ITEM*>* aFiltered, bool aConfirmLockedItems )
{ {
bool selectionEmpty = m_selection.Empty(); bool selectionEmpty = m_selection.Empty();
@ -1392,9 +1390,9 @@ int SELECTION_TOOL::SelectionMenu( const TOOL_EVENT& aEvent )
bool SELECTION_TOOL::doSelectionMenu( GENERAL_COLLECTOR* aCollector, const wxString& aTitle ) bool SELECTION_TOOL::doSelectionMenu( GENERAL_COLLECTOR* aCollector, const wxString& aTitle )
{ {
BOARD_ITEM* current = nullptr; BOARD_ITEM* current = nullptr;
SELECTION highlightGroup; PCBNEW_SELECTION highlightGroup;
ACTION_MENU menu; ACTION_MENU menu;
highlightGroup.SetLayer( LAYER_SELECT_OVERLAY ); highlightGroup.SetLayer( LAYER_SELECT_OVERLAY );
getView()->Add( &highlightGroup ); getView()->Add( &highlightGroup );
@ -1763,7 +1761,7 @@ void SELECTION_TOOL::unselect( BOARD_ITEM* aItem )
} }
void SELECTION_TOOL::highlight( BOARD_ITEM* aItem, int aMode, SELECTION& aGroup ) void SELECTION_TOOL::highlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION& aGroup )
{ {
if( aMode == SELECTED ) if( aMode == SELECTED )
aItem->SetSelected(); aItem->SetSelected();
@ -1799,7 +1797,7 @@ void SELECTION_TOOL::highlight( BOARD_ITEM* aItem, int aMode, SELECTION& aGroup
} }
void SELECTION_TOOL::unhighlight( BOARD_ITEM* aItem, int aMode, SELECTION& aGroup ) void SELECTION_TOOL::unhighlight( BOARD_ITEM* aItem, int aMode, PCBNEW_SELECTION& aGroup )
{ {
if( aMode == SELECTED ) if( aMode == SELECTED )
aItem->ClearSelected(); aItem->ClearSelected();

View File

@ -32,8 +32,7 @@
#include <math/vector2d.h> #include <math/vector2d.h>
#include <tools/pcb_tool_base.h> #include <tools/pcb_tool_base.h>
#include <tool/action_menu.h> #include <tool/action_menu.h>
#include <tool/selection.h> #include <tools/pcbnew_selection.h>
#include <tools/pcb_selection_conditions.h> #include <tools/pcb_selection_conditions.h>
#include <tool/tool_menu.h> #include <tool/tool_menu.h>
@ -85,7 +84,7 @@ public:
* *
* Returns the set of currently selected items. * Returns the set of currently selected items.
*/ */
SELECTION& GetSelection(); PCBNEW_SELECTION& GetSelection();
/** /**
* Function RequestSelection() * Function RequestSelection()
@ -95,7 +94,7 @@ public:
* If the set is empty, performs the legacy-style hover selection. * If the set is empty, performs the legacy-style hover selection.
* @param aFiltered is an optional vector, that is filled with items removed by the filter * @param aFiltered is an optional vector, that is filled with items removed by the filter
*/ */
SELECTION& RequestSelection( CLIENT_SELECTION_FILTER aClientFilter, PCBNEW_SELECTION& RequestSelection( CLIENT_SELECTION_FILTER aClientFilter,
std::vector<BOARD_ITEM*>* aFiltered = nullptr, bool aConfirmLockedItems = false ); std::vector<BOARD_ITEM*>* aFiltered = nullptr, bool aConfirmLockedItems = false );
///> Checks if the user has agreed to modify locked items for the given selection. ///> Checks if the user has agreed to modify locked items for the given selection.
@ -298,7 +297,7 @@ private:
* @param aHighlightMode should be either SELECTED or BRIGHTENED * @param aHighlightMode should be either SELECTED or BRIGHTENED
* @param aGroup is the group to add the item to in the BRIGHTENED mode. * @param aGroup is the group to add the item to in the BRIGHTENED mode.
*/ */
void highlight( BOARD_ITEM* aItem, int aHighlightMode, SELECTION& aGroup ); void highlight( BOARD_ITEM* aItem, int aHighlightMode, PCBNEW_SELECTION& aGroup );
/** /**
* Function unhighlight() * Function unhighlight()
@ -307,7 +306,7 @@ private:
* @param aHighlightMode should be either SELECTED or BRIGHTENED * @param aHighlightMode should be either SELECTED or BRIGHTENED
* @param aGroup is the group to remove the item from. * @param aGroup is the group to remove the item from.
*/ */
void unhighlight( BOARD_ITEM* aItem, int aHighlightMode, SELECTION& aGroup ); void unhighlight( BOARD_ITEM* aItem, int aHighlightMode, PCBNEW_SELECTION& aGroup );
/** /**
* Function selectionContains() * Function selectionContains()
@ -339,14 +338,14 @@ private:
const GENERAL_COLLECTORS_GUIDE getCollectorsGuide() const; const GENERAL_COLLECTORS_GUIDE getCollectorsGuide() const;
private: private:
PCB_BASE_FRAME* m_frame; // Pointer to the parent frame PCB_BASE_FRAME* m_frame; // Pointer to the parent frame
SELECTION m_selection; // Current state of selection PCBNEW_SELECTION m_selection; // Current state of selection
bool m_additive; // Items should be added to selection (instead of replacing) bool m_additive; // Items should be added to selection (instead of replacing)
bool m_subtractive; // Items should be removed from selection bool m_subtractive; // Items should be removed from selection
bool m_multiple; // Multiple selection mode is active bool m_multiple; // Multiple selection mode is active
bool m_skip_heuristics; // Heuristics are not allowed when choosing item under cursor bool m_skip_heuristics; // Heuristics are not allowed when choosing item under cursor
bool m_locked; // Other tools are not allowed to modify locked items bool m_locked; // Other tools are not allowed to modify locked items
/// Private state (opaque pointer/compilation firewall) /// Private state (opaque pointer/compilation firewall)
class PRIV; class PRIV;

View File

@ -39,7 +39,7 @@ add_executable(test_gal_pixel_alignment WIN32
../../qa_utils/mocks.cpp ../../qa_utils/mocks.cpp
../../../common/base_units.cpp ../../../common/base_units.cpp
../../../pcbnew/tools/pcb_tool_base.cpp ../../../pcbnew/tools/pcb_tool_base.cpp
../../../pcbnew/tools/selection.cpp ../../../pcbnew/tools/pcbnew_selection.cpp
../../../pcbnew/tools/selection_tool.cpp ../../../pcbnew/tools/selection_tool.cpp
../../../pcbnew/tools/tool_event_utils.cpp ../../../pcbnew/tools/tool_event_utils.cpp
#../../pcbnew/tools/outline_editor.cpp #../../pcbnew/tools/outline_editor.cpp