7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 18:01:41 +00:00

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;
}
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()
{
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_picker_tool.cpp
tools/ee_point_editor.cpp
tools/ee_selection.cpp
tools/ee_selection_tool.cpp
tools/lib_control.cpp
tools/lib_drawing_tools.cpp
@ -237,7 +238,6 @@ set( EESCHEMA_SRCS
tools/sch_editor_control.cpp
tools/sch_wire_bus_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
*/
#include <tools/ee_actions.h>
#include <tools/ee_inspection_tool.h>
#include <tools/ee_selection_tool.h>
#include <view/view_controls.h>
#include <sch_component.h>
#include <sch_marker.h>
@ -33,8 +30,11 @@
#include <confirm.h>
#include <tool/conditional_menu.h>
#include <tool/selection_conditions.h>
#include <tool/selection.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 <sim/sim_plot_frame.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 ) )
{
SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
if( selection.Empty() )
return 0;
@ -323,7 +323,7 @@ int EE_INSPECTION_TOOL::ShowDatasheet( 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() )
return 0;
@ -340,7 +340,7 @@ int EE_INSPECTION_TOOL::ShowMarkerInfo( const TOOL_EVENT& aEvent )
int EE_INSPECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
{
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
SELECTION& selection = selTool->GetSelection();
EE_SELECTION& selection = selTool->GetSelection();
if( selection.GetSize() == 1 )
{

View File

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

View File

@ -22,40 +22,12 @@
*/
#include <limits>
#include <functional>
#include <tool/selection.h>
#include <tools/ee_selection.h>
#include <sch_item.h>
#include <lib_draw_item.h>
VECTOR2I SELECTION::GetPosition() 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* EE_SELECTION::GetTopLeftItem( bool onlyModules ) const
{
EDA_ITEM* topLeftItem = nullptr;
wxPoint topLeftPos;
@ -83,22 +55,3 @@ EDA_ITEM* SELECTION::GetTopLeftItem( bool onlyModules ) const
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;
}
@ -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
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();
@ -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();

View File

@ -26,8 +26,8 @@
#include <tool/tool_interactive.h>
#include <tool/action_menu.h>
#include <tool/selection.h>
#include <tool/tool_menu.h>
#include <tools/ee_selection.h>
#include <ee_collectors.h>
#include <sch_component.h>
@ -79,7 +79,7 @@ public:
*
* Returns the set of currently selected items.
*/
SELECTION& GetSelection();
EE_SELECTION& GetSelection();
/**
* Function RequestSelection()
@ -87,7 +87,7 @@ public:
* Returns either an existing selection (filtered), or the selection at the current
* 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()
@ -209,7 +209,7 @@ private:
* @param aHighlightMode should be either SELECTED or BRIGHTENED
* @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()
@ -218,7 +218,7 @@ private:
* @param aHighlightMode should be either SELECTED or BRIGHTENED
* @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.
@ -237,18 +237,18 @@ private:
void setTransitions() override;
private:
SCH_BASE_FRAME* m_frame; // Pointer to the parent frame
SELECTION m_selection; // Current state of selection
SCH_BASE_FRAME* m_frame; // Pointer to the parent frame
EE_SELECTION m_selection; // Current state of selection
bool m_additive; // Items should be added to selection (instead of replacing)
bool m_subtractive; // Items should be removed from selection
bool m_multiple; // Multiple selection mode is active
bool m_skip_heuristics; // Heuristics are not allowed when choosing item under cursor
bool m_additive; // Items should be added to selection (instead of replacing)
bool m_subtractive; // Items should be removed from selection
bool m_multiple; // Multiple selection mode is active
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_isLibView; // True when libview is the parent frame
int m_unit; // Fixed unit filter (for symbol editor)
int m_convert; // Fixed DeMorgan filter (for symbol editor)
bool m_isLibEdit; // True when libedit 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_convert; // Fixed DeMorgan filter (for symbol editor)
};
#endif //KICAD_SCH_SELECTION_TOOL_H

View File

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

View File

@ -124,7 +124,7 @@ bool LIB_EDIT_TOOL::Init()
int LIB_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
{
SELECTION& selection = m_selectionTool->RequestSelection();
EE_SELECTION& selection = m_selectionTool->RequestSelection();
if( selection.GetSize() == 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 )
{
SELECTION& selection = m_selectionTool->RequestSelection();
EE_SELECTION& selection = m_selectionTool->RequestSelection();
if( selection.GetSize() == 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 )
{
SELECTION& selection = m_selectionTool->RequestSelection();
EE_SELECTION& selection = m_selectionTool->RequestSelection();
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 )
{
LIB_PART* part = m_frame->GetCurPart();
SELECTION& selection = m_selectionTool->RequestSelection( nonFields );
LIB_PART* part = m_frame->GetCurPart();
EE_SELECTION& selection = m_selectionTool->RequestSelection( nonFields );
if( !part || !selection.GetSize() )
return 0;
@ -591,7 +591,7 @@ int LIB_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
if( !part )
return 0;
SELECTION& selection = m_selectionTool->GetSelection();
EE_SELECTION& selection = m_selectionTool->GetSelection();
std::string text = m_toolMgr->GetClipboard();
STRING_LINE_READER reader( text, "Clipboard" );
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 )
{
LIB_PART* part = m_frame->GetCurPart();
SELECTION& selection = m_selectionTool->RequestSelection( nonFields );
LIB_PART* part = m_frame->GetCurPart();
EE_SELECTION& selection = m_selectionTool->RequestSelection( nonFields );
if( selection.GetSize() == 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
// looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
SELECTION& selection = m_selectionTool->RequestSelection();
bool unselect = selection.IsHover();
EE_SELECTION& selection = m_selectionTool->RequestSelection();
bool unselect = selection.IsHover();
if( selection.Empty() )
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() )
return false;

View File

@ -55,7 +55,7 @@ private:
///> Returns the right modification point (e.g. for rotation), depending on the number of
///> selected items.
bool updateModificationPoint( SELECTION& aSelection );
bool updateModificationPoint( EE_SELECTION& aSelection );
///> Sets up handlers for various events.
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 )
{
LIB_PART* part = m_frame->GetCurPart();
SELECTION& selection = m_selectionTool->GetSelection();
LIB_PIN* sourcePin = dynamic_cast<LIB_PIN*>( selection.Front() );
LIB_PART* part = m_frame->GetCurPart();
EE_SELECTION& selection = m_selectionTool->GetSelection();
LIB_PIN* sourcePin = dynamic_cast<LIB_PIN*>( selection.Front() );
if( !sourcePin )
return 0;

View File

@ -173,8 +173,8 @@ bool SCH_DRAWING_TOOLS::Init()
int SCH_DRAWING_TOOLS::AddJunction( const TOOL_EVENT& aEvent )
{
SELECTION& selection = m_selectionTool->GetSelection();
SCH_LINE* wire = dynamic_cast<SCH_LINE*>( selection.Front() );
EE_SELECTION& selection = m_selectionTool->GetSelection();
SCH_LINE* wire = dynamic_cast<SCH_LINE*>( selection.Front() );
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 )
{
SELECTION& selection = m_selectionTool->GetSelection();
EE_SELECTION& selection = m_selectionTool->GetSelection();
SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( selection.Front() );
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() ) )
{
// 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 )
{

View File

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

View File

@ -332,11 +332,11 @@ int SCH_EDITOR_CONTROL::FindNext( const TOOL_EVENT& aEvent )
return FindAndReplace( ACTIONS::find.MakeEvent() );
}
bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
SELECTION& selection = m_selectionTool->GetSelection();
SCH_SCREEN* afterScreen = m_frame->GetScreen();
EDA_ITEM* afterItem = selection.Front();
EDA_ITEM* item = nullptr;
bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
EE_SELECTION& selection = m_selectionTool->GetSelection();
SCH_SCREEN* afterScreen = m_frame->GetScreen();
EDA_ITEM* afterItem = selection.Front();
EDA_ITEM* item = nullptr;
if( wrapAroundTimer.IsRunning() )
{
@ -490,14 +490,14 @@ void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aF
if( aForce )
{
SELECTION& selection = selTool->RequestSelection();
EE_SELECTION& selection = selTool->RequestSelection();
if( selection.GetSize() >= 1 )
item = (SCH_ITEM*) selection.Front();
}
else
{
SELECTION& selection = selTool->GetSelection();
EE_SELECTION& selection = selTool->GetSelection();
if( selection.GetSize() >= 1 )
item = (SCH_ITEM*) selection.Front();
@ -861,7 +861,7 @@ int SCH_EDITOR_CONTROL::Redo( const TOOL_EVENT& aEvent )
bool SCH_EDITOR_CONTROL::doCopy()
{
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
SELECTION& selection = selTool->GetSelection();
EE_SELECTION& selection = selTool->GetSelection();
if( !selection.GetSize() )
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::addItemsToSel, true, &loadedItems );
SELECTION& selection = selTool->GetSelection();
EE_SELECTION& selection = selTool->GetSelection();
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 )
{
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;
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 )
{
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
const SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
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
// looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
SELECTION& selection = m_selectionTool->RequestSelection( movableItems );
bool unselect = selection.IsHover();
EE_SELECTION& selection = m_selectionTool->RequestSelection( movableItems );
bool unselect = selection.IsHover();
if( selection.Empty() )
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 > 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() )
return false;

View File

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

View File

@ -123,7 +123,7 @@ private:
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) getToolManager()->GetEditFrame();
EE_SELECTION_TOOL* selTool = getToolManager()->GetTool<EE_SELECTION_TOOL>();
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();
Clear();

View File

@ -63,6 +63,7 @@ set( GERBVIEW_SRCS
gerbview_painter.cpp
tools/gerbview_actions.cpp
tools/gerbview_selection.cpp
tools/gerbview_selection_tool.cpp
tools/gerbview_control.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 )
{
GERBVIEW_SELECTION_TOOL* selTool = m_toolMgr->GetTool<GERBVIEW_SELECTION_TOOL>();
SELECTION& selection = selTool->GetSelection();
GERBVIEW_SELECTION& selection = selTool->GetSelection();
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.
*
* 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
* under the terms of the GNU General Public License as published by the
@ -19,15 +19,12 @@
*/
#include <limits>
#include <functional>
using namespace std::placeholders;
#include <base_struct.h>
#include <bitmaps.h>
#include <gerber_collectors.h>
#include <class_draw_panel_gal.h>
#include <view/view.h>
#include <view/view_controls.h>
@ -41,10 +38,8 @@ using namespace std::placeholders;
#include <preview_items/bright_box.h>
#include <preview_items/ruler_item.h>
#include <preview_items/selection_area.h>
#include <gerbview_id.h>
#include <gerbview_painter.h>
#include "gerbview_selection_tool.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;
}
@ -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/>.
*/
#ifndef __GERBVIEW_SELECTION_TOOL_H
#define __GERBVIEW_SELECTION_TOOL_H
#ifndef GERBVIEW_SELECTION_TOOL_H
#define GERBVIEW_SELECTION_TOOL_H
#include <memory>
#include <math/vector2d.h>
#include <tool/tool_interactive.h>
#include <tool/action_menu.h>
#include <tool/selection.h>
#include <tool/selection_conditions.h>
#include <tool/tool_menu.h>
#include <tools/gerbview_selection.h>
#include <gerbview_frame.h>
class SELECTION_AREA;
@ -73,7 +71,7 @@ public:
*
* Returns the set of currently selected items.
*/
SELECTION& GetSelection();
GERBVIEW_SELECTION& GetSelection();
///> Select a single item under cursor event handler.
int CursorSelection( const TOOL_EVENT& aEvent );
@ -215,7 +213,7 @@ private:
GERBVIEW_FRAME* m_frame;
/// 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.
bool m_additive;

Some files were not shown because too many files have changed in this diff Show More